From 072ee519423a8acc64639ca2f92688341a184a0e Mon Sep 17 00:00:00 2001 From: Robert Stone Date: Mon, 26 May 2008 20:09:56 +0000 Subject: [PATCH 0001/1680] run test cases in the Perl set by the --with-perl5 configure option. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10498 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/perl5/run-perl-test.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/test-suite/perl5/run-perl-test.pl b/Examples/test-suite/perl5/run-perl-test.pl index f0e1b0288..106bf002b 100755 --- a/Examples/test-suite/perl5/run-perl-test.pl +++ b/Examples/test-suite/perl5/run-perl-test.pl @@ -7,7 +7,7 @@ use strict; my $command = shift @ARGV; -my $output = `perl $command 2>&1`; +my $output = `$^X $command 2>&1`; die "SWIG Perl test failed: \n\n$output\n" if $?; From e64d75f2807bd6a94712c8f02426d65c92406381 Mon Sep 17 00:00:00 2001 From: Robert Stone Date: Mon, 26 May 2008 21:04:06 +0000 Subject: [PATCH 0002/1680] The perl5 minherit runtime test will work better if the classes are actually built under SWIGPERL. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10499 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/minherit.i | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/test-suite/minherit.i b/Examples/test-suite/minherit.i index aba299387..24092b6c6 100644 --- a/Examples/test-suite/minherit.i +++ b/Examples/test-suite/minherit.i @@ -6,7 +6,7 @@ %module(ruby_minherit="1") minherit -#if defined(SWIGPYTHON) || defined(SWIGRUBY) || defined(SWIGOCAML) || defined(SWIGOCTAVE) +#if defined(SWIGPYTHON) || defined(SWIGRUBY) || defined(SWIGOCAML) || defined(SWIGOCTAVE) || defined(SWIGPERL) %inline %{ From dac30b0de29a0642803c3212f1142fcd0b5a5fa6 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 28 May 2008 09:44:37 +0000 Subject: [PATCH 0003/1680] Fix variable wrappers when using -proxy. Patch from Jan Jezabek git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10503 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/csharp.cxx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index df4677e26..778c47898 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -1073,7 +1073,9 @@ public: global_variable_flag = false; generate_property_declaration_flag = false; - Printf(module_class_code, "\n }\n\n"); + if (proxy_flag) { + Printf(module_class_code, "\n }\n\n"); + } return ret; } From 1dfb0d7fad9a58625517a66d0b502e890f2e1f17 Mon Sep 17 00:00:00 2001 From: Haoyu Bai Date: Wed, 28 May 2008 17:27:48 +0000 Subject: [PATCH 0004/1680] Fixed SF #1971977: typo in pycontainer.swg (related to -extranative option) git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10504 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 3 +++ Lib/python/pycontainer.swg | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 27e9925d2..1407dd3c2 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,5 +1,8 @@ Version 1.3.36 (in progress) ============================= +05/29/2008: bhy + [Python] Fixed a typo of %#ifdef in Lib/python/pycontainer.swg, which is related + to -extranative SWIG option - SF #1971977. 05/20/2008: wsfulton New partialcheck makefile targets for partial testing of the test-suite. These diff --git a/Lib/python/pycontainer.swg b/Lib/python/pycontainer.swg index 8f1db7ce1..ed0eb7f0b 100644 --- a/Lib/python/pycontainer.swg +++ b/Lib/python/pycontainer.swg @@ -738,12 +738,12 @@ namespace swig { typedef typename sequence::const_iterator const_iterator; static PyObject *from(const sequence& seq) { -#ifdef SWIG_PYTHON_EXTRA_NATIVE_CONTAINERS +%#ifdef SWIG_PYTHON_EXTRA_NATIVE_CONTAINERS swig_type_info *desc = swig::type_info(); if (desc && desc->clientdata) { return SWIG_NewPointerObj(new sequence(seq), desc, SWIG_POINTER_OWN); } -#endif +%#endif size_type size = seq.size(); if (size <= (size_type)INT_MAX) { PyObject *obj = PyTuple_New((int)size); From 9ecf676f7099af22d767e2cf1728c039e8cf02db Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 29 May 2008 00:45:28 +0000 Subject: [PATCH 0005/1680] Fix variable wrappers when using -noproxy git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10506 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++++ Source/Modules/csharp.cxx | 35 +++++++++++++++++++---------------- Source/Modules/java.cxx | 33 ++++++++++++++++++--------------- 3 files changed, 41 insertions(+), 31 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 1407dd3c2..13efa71c6 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,5 +1,9 @@ Version 1.3.36 (in progress) ============================= + +05/29/2008: wsfulton + [Java, C#] Fix variable wrappers when using -noproxy. + 05/29/2008: bhy [Python] Fixed a typo of %#ifdef in Lib/python/pycontainer.swg, which is related to -extranative SWIG option - SF #1971977. diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index 778c47898..45564c6e7 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -1926,7 +1926,7 @@ public: Swig_warning(WARN_CSHARP_TYPEMAP_CSWTYPE_UNDEF, input_file, line_number, "No cstype typemap defined for %s\n", SwigType_str(t, 0)); } - if (proxy_flag && wrapping_member_flag && !enum_constant_flag) { + if (wrapping_member_flag && !enum_constant_flag) { // Properties setter_flag = (Cmp(Getattr(n, "sym:name"), Swig_name_set(Swig_name_member(proxy_class_name, variable_name))) == 0); if (setter_flag) @@ -2109,7 +2109,7 @@ public: Swig_warning(WARN_CSHARP_TYPEMAP_CSOUT_UNDEF, input_file, line_number, "No csout typemap defined for %s\n", SwigType_str(t, 0)); } - if (proxy_flag && wrapping_member_flag && !enum_constant_flag) { + if (wrapping_member_flag && !enum_constant_flag) { // Properties if (generate_property_declaration_flag) { // Ensure the declaration is generated just once should the property contain both a set and get // Get the C# variable type - obtained differently depending on whether a setter is required. @@ -2543,6 +2543,7 @@ public: num_arguments = emit_num_arguments(l); num_required = emit_num_required(l); + bool global_or_member_variable = global_variable_flag || (wrapping_member_flag && !enum_constant_flag); int gencomma = 0; /* Output each parameter */ @@ -2569,7 +2570,7 @@ public: if (gencomma) Printf(imcall, ", "); - String *arg = makeParameterName(n, p, i, setter_flag); + String *arg = makeParameterName(n, p, i, global_or_member_variable); // Use typemaps to transform type used in C# wrapper function (in proxy class) to type used in PInvoke function (in intermediary class) if ((tm = Getattr(p, "tmap:csin"))) { @@ -2879,7 +2880,7 @@ public: * n - Node * p - parameter node * arg_num - parameter argument number - * setter - set this flag when wrapping member variables + * setter - set this flag when wrapping variables * Return: * arg - a unique parameter name * ----------------------------------------------------------------------------- */ @@ -2888,20 +2889,22 @@ public: String *arg = 0; String *pn = Getattr(p, "name"); - if (setter) { + + // Use C parameter name unless it is a duplicate or an empty parameter name + int count = 0; + ParmList *plist = Getattr(n, "parms"); + while (plist) { + if ((Cmp(pn, Getattr(plist, "name")) == 0)) + count++; + plist = nextSibling(plist); + } + String *wrn = pn ? Swig_name_warning(p, 0, pn, 0) : 0; + arg = (!pn || (count > 1) || wrn) ? NewStringf("arg%d", arg_num) : Copy(pn); + + if (setter && Cmp(arg, "self") != 0) { // Note that in C# properties, the input variable name is always called 'value' + Delete(arg); arg = NewString("value"); - } else { - // Use C parameter name unless it is a duplicate or an empty parameter name - int count = 0; - ParmList *plist = Getattr(n, "parms"); - while (plist) { - if ((Cmp(pn, Getattr(plist, "name")) == 0)) - count++; - plist = nextSibling(plist); - } - String *wrn = pn ? Swig_name_warning(p, 0, pn, 0) : 0; - arg = (!pn || (count > 1) || wrn) ? NewStringf("arg%d", arg_num) : Copy(pn); } return arg; diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index 5660b4885..1fb9b1c13 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -1932,7 +1932,7 @@ public: Swig_warning(WARN_JAVA_TYPEMAP_JSTYPE_UNDEF, input_file, line_number, "No jstype typemap defined for %s\n", SwigType_str(t, 0)); } - if (proxy_flag && wrapping_member_flag && !enum_constant_flag) { + if (wrapping_member_flag && !enum_constant_flag) { // For wrapping member variables (Javabean setter) setter_flag = (Cmp(Getattr(n, "sym:name"), Swig_name_set(Swig_name_member(proxy_class_name, variable_name))) == 0); } @@ -2463,6 +2463,7 @@ public: num_arguments = emit_num_arguments(l); num_required = emit_num_required(l); + bool global_or_member_variable = global_variable_flag || (wrapping_member_flag && !enum_constant_flag); int gencomma = 0; /* Output each parameter */ @@ -2487,7 +2488,7 @@ public: if (gencomma) Printf(imcall, ", "); - String *arg = makeParameterName(n, p, i, setter_flag); + String *arg = makeParameterName(n, p, i, global_or_member_variable); // Use typemaps to transform type used in Java wrapper function (in proxy class) to type used in JNI function (in intermediary class) if ((tm = Getattr(p, "tmap:javain"))) { @@ -2759,7 +2760,7 @@ public: * n - Node * p - parameter node * arg_num - parameter argument number - * setter - set this flag when wrapping member variables + * setter - set this flag when wrapping variables * Return: * arg - a unique parameter name * ----------------------------------------------------------------------------- */ @@ -2768,21 +2769,23 @@ public: String *arg = 0; String *pn = Getattr(p, "name"); - if (setter) { + + // Use C parameter name unless it is a duplicate or an empty parameter name + int count = 0; + ParmList *plist = Getattr(n, "parms"); + while (plist) { + if ((Cmp(pn, Getattr(plist, "name")) == 0)) + count++; + plist = nextSibling(plist); + } + String *wrn = pn ? Swig_name_warning(p, 0, pn, 0) : 0; + arg = (!pn || (count > 1) || wrn) ? NewStringf("arg%d", arg_num) : Copy(pn); + + if (setter && Cmp(arg, "self") != 0) { // Note that for setters the parameter name is always set but sometimes includes C++ // scope resolution, so we need to strip off the scope resolution to make a valid name. + Delete(arg); arg = NewString("value"); //Swig_scopename_last(pn); - } else { - // Use C parameter name unless it is a duplicate or an empty parameter name - int count = 0; - ParmList *plist = Getattr(n, "parms"); - while (plist) { - if ((Cmp(pn, Getattr(plist, "name")) == 0)) - count++; - plist = nextSibling(plist); - } - String *wrn = pn ? Swig_name_warning(p, 0, pn, 0) : 0; - arg = (!pn || (count > 1) || wrn) ? NewStringf("arg%d", arg_num) : Copy(pn); } return arg; From 2dcb84a4c3348d2ca1c357e7bb74a6992185925f Mon Sep 17 00:00:00 2001 From: Haoyu Bai Date: Fri, 30 May 2008 13:53:33 +0000 Subject: [PATCH 0006/1680] Fixed SF #1976978, apply the macros for primitive types to std::wstring git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10508 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++++ Lib/typemaps/primtypes.swg | 1 + 2 files changed, 5 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 13efa71c6..f971524b1 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,10 @@ Version 1.3.36 (in progress) ============================= +05/30/2008: bhy + Added std::wstring into Lib/typemaps/primtypes.swg, since it is also a primitive + type in SWIG - fixed SF #1976978. + 05/29/2008: wsfulton [Java, C#] Fix variable wrappers when using -noproxy. diff --git a/Lib/typemaps/primtypes.swg b/Lib/typemaps/primtypes.swg index c59aa1d1e..42728e5fe 100644 --- a/Lib/typemaps/primtypes.swg +++ b/Lib/typemaps/primtypes.swg @@ -283,6 +283,7 @@ _apply_macro(Macro, ptrdiff_t , Arg2); _apply_macro(Macro, std::size_t, Arg2); _apply_macro(Macro, std::ptrdiff_t, Arg2); _apply_macro(Macro, std::string, Arg2); +_apply_macro(Macro, std::wstring, Arg2); _apply_macro(Macro, std::complex, Arg2); _apply_macro(Macro, std::complex, Arg2); %enddef From eb50e9c4b9e460727527bf0aa7040454c4c3edcb Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Fri, 30 May 2008 16:11:27 +0000 Subject: [PATCH 0007/1680] Fix typo in handling of /*@SWIG[...]*/ comments in the scanner. This just meant we were only actually looking for /*@SWI at the start of the comment, so was pretty harmless in practice. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10511 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/CParse/cscanner.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CParse/cscanner.c b/Source/CParse/cscanner.c index 2a0d341b5..032c71f7e 100644 --- a/Source/CParse/cscanner.c +++ b/Source/CParse/cscanner.c @@ -423,7 +423,7 @@ int yylook(void) { { String *cmt = Scanner_text(scan); char *loc = Char(cmt); - if ((strncmp(loc,"/*@SWIG@",6) == 0) && (loc[Len(cmt)-3] == '@')) { + if ((strncmp(loc,"/*@SWIG",7) == 0) && (loc[Len(cmt)-3] == '@')) { scanner_locator(cmt); } } From e6d50f5d65aca77e552160d28f580ab7e3a85517 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 2 Jun 2008 20:10:40 +0000 Subject: [PATCH 0008/1680] Fix samename testcase for c# and java git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10515 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/samename.i | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Examples/test-suite/samename.i b/Examples/test-suite/samename.i index 1e9645e70..819cb4abd 100644 --- a/Examples/test-suite/samename.i +++ b/Examples/test-suite/samename.i @@ -1,6 +1,15 @@ %module samename -%inline { +#if !(defined(SWIGCSHARP) || defined(SWIGJAVA)) +class samename { + public: + void do_something() { + // ... + } +}; +#endif + +%{ class samename { public: @@ -9,5 +18,5 @@ class samename { } }; -} +%} From dfcd771463011634364c720e2fc56044c61ce5c1 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 2 Jun 2008 20:15:39 +0000 Subject: [PATCH 0009/1680] Fix enums when using -noproxy git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10516 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 3 +++ Source/Modules/csharp.cxx | 2 +- Source/Modules/java.cxx | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index f971524b1..4b8c831c9 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,9 @@ Version 1.3.36 (in progress) ============================= +06/02/2008: wsfulton + [Java, C#] Fix enum wrappers when using -noproxy. + 05/30/2008: bhy Added std::wstring into Lib/typemaps/primtypes.swg, since it is also a primitive type in SWIG - fixed SF #1976978. diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index 45564c6e7..7ea10170a 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -2758,7 +2758,7 @@ public: value = Getattr(n, "enumvalue") ? Copy(Getattr(n, "enumvalue")) : Copy(Getattr(n, "enumvalueex")); } else { // Get the enumvalue from a PINVOKE call - if (!getCurrentClass() || !cparse_cplusplus) { + if (!getCurrentClass() || !cparse_cplusplus || !proxy_flag) { // Strange hack to change the name Setattr(n, "name", Getattr(n, "value")); /* for wrapping of enums in a namespace when emit_action is used */ constantWrapper(n); diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index 1fb9b1c13..b92fccdfb 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -2633,7 +2633,7 @@ public: value = Getattr(n, "enumvalue") ? Copy(Getattr(n, "enumvalue")) : Copy(Getattr(n, "enumvalueex")); } else { // Get the enumvalue from a JNI call - if (!getCurrentClass() || !cparse_cplusplus) { + if (!getCurrentClass() || !cparse_cplusplus || !proxy_flag) { // Strange hack to change the name Setattr(n, "name", Getattr(n, "value")); /* for wrapping of enums in a namespace when emit_action is used */ constantWrapper(n); From aec1473a6e167b46de150bd9e3dc1d0721d7b98a Mon Sep 17 00:00:00 2001 From: Haoyu Bai Date: Sat, 7 Jun 2008 11:20:07 +0000 Subject: [PATCH 0010/1680] Added a test case for keyword renaming. Now it works for Python in SWIG's -c++ mode, but in C mode it doesn't work! (you can try with make keyword_rename.ctest) git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10518 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/common.mk | 2 ++ Examples/test-suite/keyword_rename.i | 26 +++++++++++++++++++ .../test-suite/python/keyword_rename_runme.py | 4 +++ 3 files changed, 32 insertions(+) create mode 100644 Examples/test-suite/keyword_rename.i create mode 100644 Examples/test-suite/python/keyword_rename_runme.py diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 3607a4253..0a3a0858a 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -202,6 +202,7 @@ CPP_TEST_CASES += \ inherit_target_language \ inherit_void_arg \ inline_initializer \ + keyword_rename \ kind \ langobj \ li_attribute \ @@ -422,6 +423,7 @@ C_TEST_CASES += \ immutable \ inctest \ integers \ + keyword_rename \ lextype \ li_carrays \ li_cdata \ diff --git a/Examples/test-suite/keyword_rename.i b/Examples/test-suite/keyword_rename.i new file mode 100644 index 000000000..afa301a29 --- /dev/null +++ b/Examples/test-suite/keyword_rename.i @@ -0,0 +1,26 @@ +/* + * Test reserved keyword renaming + */ + +%module keyword_rename + +%inline %{ + +#define KW(x, y) int x (int y) { return y;} + +/* Python keywords */ +KW(in, except) +KW(except, in) +KW(raise, in) + +/* Perl keywords */ +KW(tie, die) +KW(use, next) + +/* Java keywords */ +KW(implements, native) +KW(byte, final) + +%} + + diff --git a/Examples/test-suite/python/keyword_rename_runme.py b/Examples/test-suite/python/keyword_rename_runme.py new file mode 100644 index 000000000..5646ce7d6 --- /dev/null +++ b/Examples/test-suite/python/keyword_rename_runme.py @@ -0,0 +1,4 @@ +#!/usr/bin/env python +import keyword_rename +keyword_rename._in(1) +keyword_rename._except(1) From 32617f7804673dd922f0d80a067c931cd5c2924a Mon Sep 17 00:00:00 2001 From: Haoyu Bai Date: Sat, 7 Jun 2008 13:40:51 +0000 Subject: [PATCH 0011/1680] fixed keyword_rename.ctest tese case, caused by a mistake in Swig/naming.c git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10519 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++++ Examples/test-suite/keyword_rename.i | 2 +- Source/Swig/naming.c | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 4b8c831c9..c7ac814af 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,10 @@ Version 1.3.36 (in progress) ============================= +06/07/2008: bhy + Added test case keyword_rename, then made the keyword renaming works properly + by fixing Swig_name_make() for a incomplete condition checking. + 06/02/2008: wsfulton [Java, C#] Fix enum wrappers when using -noproxy. diff --git a/Examples/test-suite/keyword_rename.i b/Examples/test-suite/keyword_rename.i index afa301a29..4323304cf 100644 --- a/Examples/test-suite/keyword_rename.i +++ b/Examples/test-suite/keyword_rename.i @@ -3,7 +3,7 @@ */ %module keyword_rename - +%warnfilter(SWIGWARN_PARSE_KEYWORD); %inline %{ #define KW(x, y) int x (int y) { return y;} diff --git a/Source/Swig/naming.c b/Source/Swig/naming.c index 519e5b59e..6f58c7dc7 100644 --- a/Source/Swig/naming.c +++ b/Source/Swig/naming.c @@ -1477,7 +1477,7 @@ String *Swig_name_make(Node *n, String *prefix, String_or_char *cname, SwigType } - if (rename_hash || rename_list) { + if (rename_hash || rename_list || namewarn_hash || namewarn_list) { Hash *rn = Swig_name_object_get(Swig_name_rename_hash(), prefix, name, decl); if (!rn || !Swig_name_match_nameobj(rn, n)) { rn = Swig_name_nameobj_lget(Swig_name_rename_list(), n, prefix, name, decl); From de6d6ccaa862d0ad427498ef98909f6b9f42c0b7 Mon Sep 17 00:00:00 2001 From: Mark Gossage Date: Tue, 17 Jun 2008 02:57:15 +0000 Subject: [PATCH 0012/1680] [lua] bugfix 1938142 (bool& and bool* support) git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10527 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++ Examples/test-suite/lua/li_typemaps_runme.lua | 40 +++++++++++++++++++ Lib/lua/luatypemaps.swg | 4 +- Lib/lua/typemaps.i | 21 ++++++++++ 4 files changed, 67 insertions(+), 2 deletions(-) create mode 100644 Examples/test-suite/lua/li_typemaps_runme.lua diff --git a/CHANGES.current b/CHANGES.current index c7ac814af..ed1b7d2d0 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,10 @@ Version 1.3.36 (in progress) ============================= +06/17/2008: mgossage + [Lua] Added missing support for bool& and bool*. Added runtest for li_typemaps testcase. + (Bug #1938142) + 06/07/2008: bhy Added test case keyword_rename, then made the keyword renaming works properly by fixing Swig_name_make() for a incomplete condition checking. diff --git a/Examples/test-suite/lua/li_typemaps_runme.lua b/Examples/test-suite/lua/li_typemaps_runme.lua new file mode 100644 index 000000000..77aeb54e4 --- /dev/null +++ b/Examples/test-suite/lua/li_typemaps_runme.lua @@ -0,0 +1,40 @@ +require("import") -- the import fn +import("li_typemaps") -- import code + +-- catch "undefined" global variables +setmetatable(getfenv(),{__index=function (t,i) error("undefined global variable `"..i.."'",2) end}) + +-- Check double INPUT typemaps +assert(li_typemaps.in_double(22.22) == 22.22) +assert(li_typemaps.inr_double(22.22) == 22.22) + +-- Check double OUTPUT typemaps +assert(li_typemaps.out_double(22.22) == 22.22) +assert(li_typemaps.outr_double(22.22) == 22.22) + +-- Check double INOUT typemaps +assert(li_typemaps.inout_double(22.22) == 22.22) +assert(li_typemaps.inoutr_double(22.22) == 22.22) + +-- check long long +assert(li_typemaps.in_ulonglong(20)==20) +assert(li_typemaps.inr_ulonglong(20)==20) +assert(li_typemaps.out_ulonglong(20)==20) +assert(li_typemaps.outr_ulonglong(20)==20) +assert(li_typemaps.inout_ulonglong(20)==20) +assert(li_typemaps.inoutr_ulonglong(20)==20) + +-- check bools +assert(li_typemaps.in_bool(true)==true) +assert(li_typemaps.inr_bool(false)==false) +assert(li_typemaps.out_bool(true)==true) +assert(li_typemaps.outr_bool(false)==false) +assert(li_typemaps.inout_bool(true)==true) +assert(li_typemaps.inoutr_bool(false)==false) + +-- the others +a,b=li_typemaps.inoutr_int2(1,2) +assert(a==1 and b==2) + +f,i=li_typemaps.out_foo(10) +assert(f.a==10 and i==20) diff --git a/Lib/lua/luatypemaps.swg b/Lib/lua/luatypemaps.swg index 462d6a055..0941c9da1 100644 --- a/Lib/lua/luatypemaps.swg +++ b/Lib/lua/luatypemaps.swg @@ -73,7 +73,7 @@ %{$1 = (lua_toboolean(L, $input)!=0);%} %typemap(out) bool -%{ lua_pushboolean(L,(int)($1==true)); SWIG_arg++;%} +%{ lua_pushboolean(L,(int)($1!=0)); SWIG_arg++;%} // for const bool&, SWIG treats this as a const bool* so we must dereference it %typemap(in,checkfn="lua_isboolean") const bool& (bool temp) @@ -81,7 +81,7 @@ $1=&temp;%} %typemap(out) const bool& -%{ lua_pushboolean(L,(int)(*$1==true)); SWIG_arg++;%} +%{ lua_pushboolean(L,(int)((*$1)!=0)); SWIG_arg++;%} // strings (char* and char[]) %typemap(in,checkfn="lua_isstring") const char*, char* diff --git a/Lib/lua/typemaps.i b/Lib/lua/typemaps.i index e0adcf192..fa0c0d0e5 100644 --- a/Lib/lua/typemaps.i +++ b/Lib/lua/typemaps.i @@ -80,6 +80,22 @@ SWIG_NUMBER_TYPEMAP(long long); SWIG_NUMBER_TYPEMAP(unsigned long long); SWIG_NU // note we dont do char, as a char* is probably a string not a ptr to a single char +// similar for booleans +%typemap(in,checkfn="lua_isboolean") bool *INPUT(bool temp), bool &INPUT(bool temp) +%{ temp = (lua_toboolean(L,$input)!=0); + $1 = &temp; %} + +%typemap(in, numinputs=0) bool *OUTPUT (bool temp),bool &OUTPUT (bool temp) +%{ $1 = &temp; %} + +%typemap(argout) bool *OUTPUT,bool &OUTPUT +%{ lua_pushboolean(L, (int)((*$1)!=0)); SWIG_arg++;%} + +%typemap(in) bool *INOUT = bool *INPUT; +%typemap(argout) bool *INOUT = bool *OUTPUT; +%typemap(in) bool &INOUT = bool &INPUT; +%typemap(argout) bool &INOUT = bool &OUTPUT; + /* ----------------------------------------------------------------------------- * Basic Array typemaps * ----------------------------------------------------------------------------- */ @@ -320,6 +336,11 @@ for array handling %typemap(freearg) (TYPE *INOUT,int)=(TYPE *INPUT,int); // TODO out variable arrays (is there a standard form for such things?) + +// referencing so that (int *INPUT,int) and (int INPUT[],int) are the same +%typemap(in) (TYPE INPUT[],int)=(TYPE *INPUT,int); +%typemap(freearg) (TYPE INPUT[],int)=(TYPE *INPUT,int); + %enddef // the following line of code From 9c323f4a70d687ceda3700e8e193263be04f04f3 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 19 Jun 2008 20:02:13 +0000 Subject: [PATCH 0013/1680] Add R keyword support. Rename keywords for successful compilation of Java and C# code. More consistent keyword warnings across the different languages. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10530 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 9 +++++++++ Examples/test-suite/keyword_rename.i | 8 +++++++- Lib/chicken/chickenkw.swg | 2 +- Lib/csharp/csharpkw.swg | 2 +- Lib/java/javakw.swg | 2 +- Lib/ocaml/ocamlkw.swg | 2 +- Lib/perl5/perlkw.swg | 4 ++-- Lib/php4/php4kw.swg | 10 +++++----- Lib/pike/pikekw.swg | 2 +- Lib/python/pythonkw.swg | 4 ++-- Lib/r/r.swg | 2 ++ Lib/r/rkw.swg | 17 +++++++++++++++++ Lib/ruby/rubykw.swg | 2 +- Source/Modules/r.cxx | 3 +++ 14 files changed, 53 insertions(+), 16 deletions(-) create mode 100644 Lib/r/rkw.swg diff --git a/CHANGES.current b/CHANGES.current index ed1b7d2d0..5df243eca 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,15 @@ Version 1.3.36 (in progress) ============================= +06/19/2008: wsfulton + [Java, C#] C# and Java keywords will be renamed instead of just issuing a warning + and then generating uncompileable code. Warning 314 gives the new name when a + keyword is found. + +06/19/2008: wsfulton + [R] Keyword handling added. R Keywords will be renamed as necessary. + Warning 314 gives the new name when a keyword is found. + 06/17/2008: mgossage [Lua] Added missing support for bool& and bool*. Added runtest for li_typemaps testcase. (Bug #1938142) diff --git a/Examples/test-suite/keyword_rename.i b/Examples/test-suite/keyword_rename.i index 4323304cf..28d813499 100644 --- a/Examples/test-suite/keyword_rename.i +++ b/Examples/test-suite/keyword_rename.i @@ -3,7 +3,9 @@ */ %module keyword_rename -%warnfilter(SWIGWARN_PARSE_KEYWORD); + +#pragma SWIG nowarn=SWIGWARN_PARSE_KEYWORD + %inline %{ #define KW(x, y) int x (int y) { return y;} @@ -21,6 +23,10 @@ KW(use, next) KW(implements, native) KW(byte, final) +/* C# Keywords */ +KW(string, out) +struct sealed {}; + %} diff --git a/Lib/chicken/chickenkw.swg b/Lib/chicken/chickenkw.swg index f01faf14f..d2c26c74c 100644 --- a/Lib/chicken/chickenkw.swg +++ b/Lib/chicken/chickenkw.swg @@ -3,7 +3,7 @@ /* Warnings for certain CHICKEN keywords. From Section 7.1.1 of Revised^5 Report on the Algorithmic Language Scheme */ -#define CHICKENKW(x) %namewarn("314:" #x " is a R^5RS syntatic keyword") #x +#define CHICKENKW(x) %namewarn("314: '" #x "' is a R^5RS syntatic keyword") #x CHICKENKW(else); CHICKENKW(=>); diff --git a/Lib/csharp/csharpkw.swg b/Lib/csharp/csharpkw.swg index c96042d2d..9a6d979f1 100644 --- a/Lib/csharp/csharpkw.swg +++ b/Lib/csharp/csharpkw.swg @@ -2,7 +2,7 @@ #define CSHARP_CSHARPKW_SWG_ /* Warnings for C# keywords */ -#define CSHARPKW(x) %namewarn("314:" #x " is a csharp keyword") #x +#define CSHARPKW(x) %keywordwarn("'" `x` "' is a C# keyword, renaming to '_" `x` "'",rename="_%s") `x` /* from diff --git a/Lib/java/javakw.swg b/Lib/java/javakw.swg index 9dcd97062..99cd54770 100644 --- a/Lib/java/javakw.swg +++ b/Lib/java/javakw.swg @@ -2,7 +2,7 @@ #define JAVA_JAVAKW_SWG_ /* Warnings for Java keywords */ -#define JAVAKW(x) %namewarn("314:" #x " is a java keyword") #x +#define JAVAKW(x) %keywordwarn("'" `x` "' is a java keyword, renaming to '_"`x`"'",rename="_%s") `x` /* from diff --git a/Lib/ocaml/ocamlkw.swg b/Lib/ocaml/ocamlkw.swg index ba06f238e..9b9096e2b 100644 --- a/Lib/ocaml/ocamlkw.swg +++ b/Lib/ocaml/ocamlkw.swg @@ -2,7 +2,7 @@ #define OCAML_OCAMLKW_SWG_ /* Warnings for Ocaml keywords */ -#define OCAMLKW(x) %namewarn("314:" #x " is a ocaml keyword and it will properly renamed") #x +#define OCAMLKW(x) %namewarn("314: '" #x "' is a ocaml keyword and it will properly renamed") #x /* from diff --git a/Lib/perl5/perlkw.swg b/Lib/perl5/perlkw.swg index 71a229c66..00648e0bf 100644 --- a/Lib/perl5/perlkw.swg +++ b/Lib/perl5/perlkw.swg @@ -1,6 +1,6 @@ /* Warnings for Perl keywords */ -#define PERLKW(x) %keywordwarn(`x` " is a perl keyword") `x` -#define PERLBN(x) %builtinwarn(`x` " conflicts with a built-in name in perl") "::" `x` +#define PERLKW(x) %keywordwarn("'" `x` "' is a perl keyword") `x` +#define PERLBN(x) %builtinwarn("'" `x` "' conflicts with a built-in name in perl") "::" `x` /* diff --git a/Lib/php4/php4kw.swg b/Lib/php4/php4kw.swg index 0d28994c5..a6b519445 100644 --- a/Lib/php4/php4kw.swg +++ b/Lib/php4/php4kw.swg @@ -8,15 +8,15 @@ * 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` /* diff --git a/Lib/pike/pikekw.swg b/Lib/pike/pikekw.swg index 85fd091a8..844b1f189 100644 --- a/Lib/pike/pikekw.swg +++ b/Lib/pike/pikekw.swg @@ -2,7 +2,7 @@ #define PIKE_PIKEKW_SWG_ /* Warnings for Pike keywords */ -#define PIKEKW(x) %namewarn("314:" #x " is a pike keyword") #x +#define PIKEKW(x) %namewarn("314: '" #x "' is a pike keyword") #x /* from diff --git a/Lib/python/pythonkw.swg b/Lib/python/pythonkw.swg index f57d34ce4..2ee233516 100644 --- a/Lib/python/pythonkw.swg +++ b/Lib/python/pythonkw.swg @@ -2,8 +2,8 @@ Warnings for Python keywords, built-in names and bad names. */ -#define PYTHONKW(x) %keywordwarn(`x` " is a python keyword, symbol will be renamed as '_" `x`"'", rename="_%s") `x` -#define PYTHONBN(x) %builtinwarn(`x` " conflicts with a built-in name in python") "::"`x` +#define PYTHONKW(x) %keywordwarn("'" `x` "' is a python keyword, renaming to '_" `x` "'", rename="_%s") `x` +#define PYTHONBN(x) %builtinwarn("'" `x` "' conflicts with a built-in name in python") "::"`x` /* diff --git a/Lib/r/r.swg b/Lib/r/r.swg index 3095529a0..0ab7e11a0 100644 --- a/Lib/r/r.swg +++ b/Lib/r/r.swg @@ -12,6 +12,8 @@ SWIGEXPORT void SWIG_init(void) { %} +%include + #define %Rruntime %insert("s") #define SWIG_Object SEXP diff --git a/Lib/r/rkw.swg b/Lib/r/rkw.swg new file mode 100644 index 000000000..24bb5d83c --- /dev/null +++ b/Lib/r/rkw.swg @@ -0,0 +1,17 @@ +/* + Warnings for R keywords, built-in names and bad names. +*/ + +#define RKW(x) %keywordwarn("'" `x` "' is a R keyword, renaming to '_" `x`"'", rename="_%s") `x` + + +/* + Warnings for R keywords + REFERENCE ???? +*/ + +RKW(except); +RKW(in); +RKW(next); + +#undef RKW diff --git a/Lib/ruby/rubykw.swg b/Lib/ruby/rubykw.swg index fec47baff..194687b95 100644 --- a/Lib/ruby/rubykw.swg +++ b/Lib/ruby/rubykw.swg @@ -2,7 +2,7 @@ #define RUBY_RUBYKW_SWG_ /* Warnings for Ruby keywords */ -#define RUBYKW(x) %keywordwarn("'" `x` "' is a ruby keyword, and it will renamed as 'C_"`x`"'",rename="C_%s",fullname=1) `x` +#define RUBYKW(x) %keywordwarn("'" `x` "' is a ruby keyword, renaming to 'C_" `x` "'",rename="C_%s",fullname=1) `x` /* diff --git a/Source/Modules/r.cxx b/Source/Modules/r.cxx index 989136a9d..32c7a3925 100644 --- a/Source/Modules/r.cxx +++ b/Source/Modules/r.cxx @@ -1841,6 +1841,9 @@ int R::functionWrapper(Node *n) { String *name = Getattr(p,"name"); String *lname = Getattr(p,"lname"); + // R keyword renaming + if (name && Swig_name_warning(p, 0, name, 0)) + name = 0; /* If we have a :: in the parameter name because we are accessing a static member of a class, say, then we need to remove that prefix. */ From 1d85e466972955db2c83532784c23d64a2637000 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 19 Jun 2008 21:15:48 +0000 Subject: [PATCH 0014/1680] add complete list of R reserved words git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10531 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/r/rkw.swg | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/Lib/r/rkw.swg b/Lib/r/rkw.swg index 24bb5d83c..2c181faa0 100644 --- a/Lib/r/rkw.swg +++ b/Lib/r/rkw.swg @@ -4,14 +4,29 @@ #define RKW(x) %keywordwarn("'" `x` "' is a R keyword, renaming to '_" `x`"'", rename="_%s") `x` - /* - Warnings for R keywords - REFERENCE ???? + Warnings for R reserved words taken from + http://cran.r-project.org/doc/manuals/R-lang.html#Reserved-words */ -RKW(except); +RKW(if); +RKW(else); +RKW(repeat); +RKW(while); +RKW(function); +RKW(for); RKW(in); RKW(next); +RKW(break); +RKW(TRUE); +RKW(FALSE); +RKW(NULL); +RKW(Inf); +RKW(NaN); +RKW(NA); +RKW(NA_integer_); +RKW(NA_real_); +RKW(NA_complex_); +RKW(NA_character_); #undef RKW From 595ce07838fccb86a723f6bd20e6f8b302280d4c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 21 Jun 2008 11:35:33 +0000 Subject: [PATCH 0015/1680] better terminology for static types git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10536 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/SWIGPlus.html | 5 +++-- Doc/Manual/Typemaps.html | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Doc/Manual/SWIGPlus.html b/Doc/Manual/SWIGPlus.html index faf0b254c..ef7487ff8 100644 --- a/Doc/Manual/SWIGPlus.html +++ b/Doc/Manual/SWIGPlus.html @@ -1153,8 +1153,9 @@ public:

-This is great for reducing the size of the wrappers, but the caveat is it does not work for the strongly typed languages -which don't have optional arguments in the language, such as C# and Java. +This is great for reducing the size of the wrappers, but the caveat is it does not work for the statically typed languages, +such as C# and Java, +which don't have optional arguments in the language, Another restriction of this feature is that it cannot handle default arguments that are not public. The following example illustrates this:

diff --git a/Doc/Manual/Typemaps.html b/Doc/Manual/Typemaps.html index e07f9f87e..e8856c95c 100644 --- a/Doc/Manual/Typemaps.html +++ b/Doc/Manual/Typemaps.html @@ -702,7 +702,7 @@ variables (parms). The purpose of these variables will be explained shortly.

code specifies the code used in the typemap. -Usually this is C/C++ code, but in the strongly typed target languages, such as Java and C#, this can contain target language code for certain typemaps. +Usually this is C/C++ code, but in the statically typed target languages, such as Java and C#, this can contain target language code for certain typemaps. It can take any one of the following forms:

From a1e23610d60f3bf1085e5ca114557ebabb8bbfb4 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 21 Jun 2008 11:42:48 +0000 Subject: [PATCH 0016/1680] remove raise as keyword test- it conflicts with _raise in LIBCMT on windows git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10537 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/keyword_rename.i | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Examples/test-suite/keyword_rename.i b/Examples/test-suite/keyword_rename.i index 28d813499..f2eff8af5 100644 --- a/Examples/test-suite/keyword_rename.i +++ b/Examples/test-suite/keyword_rename.i @@ -8,12 +8,12 @@ %inline %{ -#define KW(x, y) int x (int y) { return y;} +#define KW(x, y) int x (int y) { return y; } /* Python keywords */ KW(in, except) KW(except, in) -KW(raise, in) +KW(pass, in) /* Perl keywords */ KW(tie, die) @@ -25,7 +25,7 @@ KW(byte, final) /* C# Keywords */ KW(string, out) -struct sealed {}; +struct sealed {int i;}; %} From 7a68c5c003d08c7e276e12a883be0c17a2824a3f Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 21 Jun 2008 15:21:29 +0000 Subject: [PATCH 0017/1680] Lua example warning removal fixes for vc++ git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10539 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/lua/arrays/example.c | 2 +- Examples/lua/embed2/embed2.c | 13 ++++++++++++- Examples/lua/embed3/embed3.cpp | 14 +++++++++++--- Examples/lua/owner/example.cxx | 4 ++-- 4 files changed, 26 insertions(+), 7 deletions(-) diff --git a/Examples/lua/arrays/example.c b/Examples/lua/arrays/example.c index 40ed12c79..56c7b19d9 100644 --- a/Examples/lua/arrays/example.c +++ b/Examples/lua/arrays/example.c @@ -16,7 +16,7 @@ void sort_int(int* arr, int len) // ditto doubles int compare_double(const void * a, const void * b) { - return ( *(double*)a - *(double*)b ); + return (int)( *(double*)a - *(double*)b ); } void sort_double(double* arr, int len) diff --git a/Examples/lua/embed2/embed2.c b/Examples/lua/embed2/embed2.c index 07b7a44d2..dac527eb4 100644 --- a/Examples/lua/embed2/embed2.c +++ b/Examples/lua/embed2/embed2.c @@ -11,6 +11,17 @@ We will be using the luaL_dostring()/lua_dostring() function to call into lua */ +/* Deal with Microsoft's attempt at deprecating C standard runtime functions */ +#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) +# define _CRT_SECURE_NO_DEPRECATE +#endif + +/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */ +#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE) +# define _SCL_SECURE_NO_DEPRECATE +#endif + + #include #include @@ -108,7 +119,7 @@ int call_va (lua_State *L,const char *func, const char *sig, ...) { endwhile: /* do the call */ - nres = strlen(sig); /* number of expected results */ + nres = (int)strlen(sig); /* number of expected results */ if (lua_pcall(L, narg, nres, 0) != 0) /* do the call */ { printf("error running function `%s': %s\n",func, lua_tostring(L, -1)); diff --git a/Examples/lua/embed3/embed3.cpp b/Examples/lua/embed3/embed3.cpp index e42401cda..c2424f9af 100644 --- a/Examples/lua/embed3/embed3.cpp +++ b/Examples/lua/embed3/embed3.cpp @@ -5,6 +5,17 @@ passing C++ objects to this function. */ +/* Deal with Microsoft's attempt at deprecating C standard runtime functions */ +#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) +# define _CRT_SECURE_NO_DEPRECATE +#endif + +/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */ +#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE) +# define _SCL_SECURE_NO_DEPRECATE +#endif + + #include #include #include @@ -70,9 +81,6 @@ int call_onEvent(lua_State *L, Event e) { int main(int argc, char* argv[]) { - int ok; - int res; - char str[80]; printf("[C++] Welcome to the simple embedded Lua example v3\n"); printf("[C++] We are in C++\n"); printf("[C++] opening a Lua state & loading the libraries\n"); diff --git a/Examples/lua/owner/example.cxx b/Examples/lua/owner/example.cxx index 6e4091327..d6caeef15 100644 --- a/Examples/lua/owner/example.cxx +++ b/Examples/lua/owner/example.cxx @@ -54,14 +54,14 @@ void ShapeOwner::add(Shape* ptr) // this method takes ownership of the object Shape* ShapeOwner::get(int idx) // this pointer is still owned by the class (assessor) { - if (idx<0 || idx>=shapes.size()) + if (idx < 0 || idx >= static_cast(shapes.size())) return NULL; return shapes[idx]; } Shape* ShapeOwner::remove(int idx) // this method returns memory which must be deleted { - if (idx<0 || idx>=shapes.size()) + if (idx < 0 || idx >= static_cast(shapes.size())) return NULL; Shape* ptr=shapes[idx]; shapes.erase(shapes.begin()+idx); From 49675199f472956c6a05ce1e88793d28807478e6 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 21 Jun 2008 15:23:02 +0000 Subject: [PATCH 0018/1680] Remove some vc++ /W4 warnings git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10540 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/CParse/parser.y | 29 +++++++--------- Source/CParse/templ.c | 4 +-- Source/DOH/hash.c | 31 ++++++++--------- Source/Modules/allegrocl.cxx | 6 ++-- Source/Modules/chicken.cxx | 11 ++---- Source/Modules/lang.cxx | 61 +++++++++++++++----------------- Source/Modules/lua.cxx | 4 --- Source/Modules/modula3.cxx | 4 +-- Source/Modules/php4.cxx | 67 ++++++++++++++++++------------------ Source/Modules/python.cxx | 1 - Source/Modules/r.cxx | 14 ++++++-- Source/Modules/ruby.cxx | 10 +++--- Source/Preprocessor/cpp.c | 5 ++- Source/Swig/cwrap.c | 3 +- Source/Swig/include.c | 3 +- Source/Swig/misc.c | 23 +++++++++---- Source/Swig/naming.c | 4 ++- Source/Swig/scanner.c | 4 +-- Source/Swig/typeobj.c | 3 +- Source/Swig/typesys.c | 11 +++--- 20 files changed, 146 insertions(+), 152 deletions(-) diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index 4fe8b47ed..58e0c0c41 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -331,7 +331,9 @@ static void add_symbols(Node *n) { Delete(prefix); } - if (0 && !Getattr(n,"parentNode") && class_level) set_parentNode(n,class_decl[class_level - 1]); + /* + if (!Getattr(n,"parentNode") && class_level) set_parentNode(n,class_decl[class_level - 1]); + */ Setattr(n,"ismember","1"); } } @@ -4109,10 +4111,11 @@ cpp_destructor_decl : NOT idtemplate LPAREN parms RPAREN cpp_end { /* Check for template names. If the class is a template and the constructor is missing the template part, we add it */ - if (Classprefix && (c = strchr(Char(Classprefix),'<'))) { - if (!Strchr($3,'<')) { - $3 = NewStringf("%s%s",$3,c); - } + if (Classprefix) { + c = strchr(Char(Classprefix),'<'); + if (c && !Strchr($3,'<')) { + $3 = NewStringf("%s%s",$3,c); + } } Setattr($$,"storage","virtual"); name = NewStringf("%s",$3); @@ -4428,12 +4431,8 @@ parms : rawparms { ; rawparms : parm ptail { - if (1) { - set_nextSibling($1,$2); - $$ = $1; - } else { - $$ = $2; - } + set_nextSibling($1,$2); + $$ = $1; } | empty { $$ = 0; } ; @@ -4486,12 +4485,8 @@ valparms : rawvalparms { ; rawvalparms : valparm valptail { - if (1) { - set_nextSibling($1,$2); - $$ = $1; - } else { - $$ = $2; - } + set_nextSibling($1,$2); + $$ = $1; } | empty { $$ = 0; } ; diff --git a/Source/CParse/templ.c b/Source/CParse/templ.c index a1f0c8e08..8142125a7 100644 --- a/Source/CParse/templ.c +++ b/Source/CParse/templ.c @@ -281,13 +281,13 @@ int Swig_cparse_template_expand(Node *n, String *rname, ParmList *tparms, Symtab Delete(ptargs); } - if (0) { + /* Parm *p = tparms; while (p) { Printf(stdout, "tparm: '%s' '%s' '%s'\n", Getattr(p, "name"), Getattr(p, "type"), Getattr(p, "value")); p = nextSibling(p); } - } + */ /* Printf(stdout,"targs = '%s'\n", templateargs); Printf(stdout,"rname = '%s'\n", rname); diff --git a/Source/DOH/hash.c b/Source/DOH/hash.c index ccb94314a..62aef10f2 100644 --- a/Source/DOH/hash.c +++ b/Source/DOH/hash.c @@ -112,12 +112,11 @@ static void DelHash(DOH *ho) { int i; for (i = 0; i < h->hashsize; i++) { - if ((n = h->hashtable[i])) { - while (n) { - next = n->next; - DelNode(n); - n = next; - } + n = h->hashtable[i]; + while (n) { + next = n->next; + DelNode(n); + n = next; } } DohFree(h->hashtable); @@ -138,12 +137,11 @@ static void Hash_clear(DOH *ho) { int i; for (i = 0; i < h->hashsize; i++) { - if ((n = h->hashtable[i])) { - while (n) { - next = n->next; - DelNode(n); - n = next; - } + n = h->hashtable[i]; + while (n) { + next = n->next; + DelNode(n); + n = next; } h->hashtable[i] = 0; } @@ -454,11 +452,10 @@ static DOH *CopyHash(DOH *ho) { nho = DohObjMalloc(&DohHashType, nh); for (i = 0; i < h->hashsize; i++) { - if ((n = h->hashtable[i])) { - while (n) { - Hash_setattr(nho, n->key, n->object); - n = n->next; - } + n = h->hashtable[i]; + while (n) { + Hash_setattr(nho, n->key, n->object); + n = n->next; } } return nho; diff --git a/Source/Modules/allegrocl.cxx b/Source/Modules/allegrocl.cxx index 561997276..8eed2e861 100644 --- a/Source/Modules/allegrocl.cxx +++ b/Source/Modules/allegrocl.cxx @@ -2935,11 +2935,9 @@ int ALLEGROCL::classHandler(Node *n) { #endif if (Generate_Wrapper) - return cppClassHandler(n); + return cppClassHandler(n); else - return cClassHandler(n); - - return SWIG_OK; + return cClassHandler(n); } int ALLEGROCL::cClassHandler(Node *n) { diff --git a/Source/Modules/chicken.cxx b/Source/Modules/chicken.cxx index a76e09945..33ec9294f 100644 --- a/Source/Modules/chicken.cxx +++ b/Source/Modules/chicken.cxx @@ -329,7 +329,6 @@ int CHICKEN::functionWrapper(Node *n) { Parm *p; int i; String *wname; - String *source; Wrapper *f; String *mangle = NewString(""); String *get_pointers; @@ -398,8 +397,6 @@ int CHICKEN::functionWrapper(Node *n) { SwigType *pt = Getattr(p, "type"); String *ln = Getattr(p, "lname"); - source = NewStringf("scm%d", i + 1); - Printf(f->def, ", C_word scm%d", i + 1); Printf(declfunc, ",C_word"); @@ -407,6 +404,7 @@ int CHICKEN::functionWrapper(Node *n) { if ((tm = Getattr(p, "tmap:in"))) { String *parse = Getattr(p, "tmap:in:parse"); if (!parse) { + String *source = NewStringf("scm%d", i + 1); Replaceall(tm, "$source", source); Replaceall(tm, "$target", ln); Replaceall(tm, "$input", source); @@ -445,20 +443,15 @@ int CHICKEN::functionWrapper(Node *n) { } } } - - } else { + Delete(source); } - p = Getattr(p, "tmap:in:next"); continue; } else { Swig_warning(WARN_TYPEMAP_IN_UNDEF, input_file, line_number, "Unable to use type %s as a function argument.\n", SwigType_str(pt, 0)); break; } - - Delete(source); - p = nextSibling(p); } /* finish argument marshalling */ diff --git a/Source/Modules/lang.cxx b/Source/Modules/lang.cxx index 4a7bf8813..6718903d0 100644 --- a/Source/Modules/lang.cxx +++ b/Source/Modules/lang.cxx @@ -1097,38 +1097,33 @@ int Language::globalfunctionHandler(Node *n) { String *name = Getattr(n, "name"); String *symname = Getattr(n, "sym:name"); SwigType *type = Getattr(n, "type"); - String *storage = Getattr(n, "storage"); ParmList *parms = Getattr(n, "parms"); - if (0 && (Cmp(storage, "static") == 0)) { - Swig_restore(n); - return SWIG_NOWRAP; /* Can't wrap static functions */ - } else { - /* Check for callback mode */ - String *cb = GetFlagAttr(n, "feature:callback"); - if (cb) { - String *cbname = Getattr(n, "feature:callback:name"); - if (!cbname) { - cbname = NewStringf(cb, symname); - Setattr(n, "feature:callback:name", cbname); - } - - callbackfunctionHandler(n); - if (Cmp(cbname, symname) == 0) { - Delete(cbname); - Swig_restore(n); - return SWIG_NOWRAP; - } - Delete(cbname); + /* Check for callback mode */ + String *cb = GetFlagAttr(n, "feature:callback"); + if (cb) { + String *cbname = Getattr(n, "feature:callback:name"); + if (!cbname) { + cbname = NewStringf(cb, symname); + Setattr(n, "feature:callback:name", cbname); } - Setattr(n, "parms", nonvoid_parms(parms)); - String *call = Swig_cfunction_call(name, parms); - String *cres = Swig_cresult(type, "result", call); - Setattr(n, "wrap:action", cres); - Delete(cres); - Delete(call); - functionWrapper(n); + + callbackfunctionHandler(n); + if (Cmp(cbname, symname) == 0) { + Delete(cbname); + Swig_restore(n); + return SWIG_NOWRAP; + } + Delete(cbname); } + Setattr(n, "parms", nonvoid_parms(parms)); + String *call = Swig_cfunction_call(name, parms); + String *cres = Swig_cresult(type, "result", call); + Setattr(n, "wrap:action", cres); + Delete(cres); + Delete(call); + functionWrapper(n); + Swig_restore(n); return SWIG_OK; } @@ -1376,9 +1371,6 @@ int Language::variableHandler(Node *n) { * ---------------------------------------------------------------------- */ int Language::globalvariableHandler(Node *n) { - String *storage = Getattr(n, "storage"); - if (0 && (Cmp(storage, "static") == 0)) - return SWIG_NOWRAP; variableWrapper(n); return SWIG_OK; } @@ -2108,8 +2100,8 @@ int Language::classDirector(Node *n) { String *using_protected_members_code = NewString(""); for (ni = Getattr(n, "firstChild"); ni; ni = nextSibling(ni)) { Node *nodeType = Getattr(ni, "nodeType"); - bool cdecl = (Cmp(nodeType, "cdecl") == 0); - if (cdecl && !GetFlag(ni, "feature:ignore")) { + bool cdeclaration = (Cmp(nodeType, "cdecl") == 0); + if (cdeclaration && !GetFlag(ni, "feature:ignore")) { if (is_non_virtual_protected_access(ni)) { Node *overloaded = Getattr(ni, "sym:overloaded"); // emit the using base::member statement (but only once if the method is overloaded) @@ -3391,7 +3383,8 @@ int Language::is_assignable(Node *n) { SwigType *ftd = SwigType_typedef_resolve_all(type); SwigType *td = SwigType_strip_qualifiers(ftd); if (SwigType_type(td) == T_USER) { - if ((cn = Swig_symbol_clookup(td, 0))) { + cn = Swig_symbol_clookup(td, 0); + if (cn) { if ((Strcmp(nodeType(cn), "class") == 0)) { if (Getattr(cn, "allocate:noassign")) { SetFlag(n, "feature:immutable"); diff --git a/Source/Modules/lua.cxx b/Source/Modules/lua.cxx index f46c9e809..6113da960 100644 --- a/Source/Modules/lua.cxx +++ b/Source/Modules/lua.cxx @@ -490,8 +490,6 @@ public: Swig_warning(WARN_TYPEMAP_IN_UNDEF, input_file, line_number, "Unable to use type %s as a function argument.\n", SwigType_str(pt, 0)); break; } - - p = nextSibling(p); } // add all argcheck code @@ -1101,7 +1099,6 @@ public: virtual int staticmemberfunctionHandler(Node *n) { current = STATIC_FUNC; return Language::staticmemberfunctionHandler(n); - current = NO_CPP; } /* ------------------------------------------------------------ @@ -1123,7 +1120,6 @@ public: // REPORT("staticmembervariableHandler",n); current = STATIC_VAR; return Language::staticmembervariableHandler(n); - current = NO_CPP; } /* --------------------------------------------------------------------- diff --git a/Source/Modules/modula3.cxx b/Source/Modules/modula3.cxx index 99d28e167..6cb24d39a 100644 --- a/Source/Modules/modula3.cxx +++ b/Source/Modules/modula3.cxx @@ -472,9 +472,9 @@ MODULA3(): cap = true; } else { if (cap) { - m3sym[i] = toupper(c); + m3sym[i] = (char)toupper(c); } else { - m3sym[i] = tolower(c); + m3sym[i] = (char)tolower(c); } cap = false; } diff --git a/Source/Modules/php4.cxx b/Source/Modules/php4.cxx index cfe948e3f..60a6dd09d 100644 --- a/Source/Modules/php4.cxx +++ b/Source/Modules/php4.cxx @@ -150,45 +150,44 @@ void SwigPHP_emit_resource_registrations() { ki = First(zend_types); if (ki.key) Printf(s_oinit, "\n/* Register resource destructors for pointer types */\n"); - while (ki.key) - if (1 /* is pointer type */ ) { - DOH *key = ki.key; - Node *class_node = ki.item; - String *human_name = key; + while (ki.key) { + DOH *key = ki.key; + Node *class_node = ki.item; + 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); + // Write out destructor function header + Printf(s_wrappers, "/* NEW Destructor style */\nstatic ZEND_RSRC_DTOR_FUNC(_wrap_destroy%s) {\n", key); - // write out body - if ((class_node != NOTCLASS)) { - String *destructor = Getattr(class_node, "destructor"); - human_name = Getattr(class_node, "sym:name"); - if (!human_name) - human_name = Getattr(class_node, "name"); - // Do we have a known destructor for this type? - if (destructor) { - Printf(s_wrappers, " %s(rsrc, SWIGTYPE%s->name TSRMLS_CC);\n", destructor, key); - } else { - Printf(s_wrappers, " /* No destructor for class %s */\n", human_name); - } + // write out body + if ((class_node != NOTCLASS)) { + String *destructor = Getattr(class_node, "destructor"); + human_name = Getattr(class_node, "sym:name"); + if (!human_name) + human_name = Getattr(class_node, "name"); + // Do we have a known destructor for this type? + if (destructor) { + Printf(s_wrappers, " %s(rsrc, SWIGTYPE%s->name TSRMLS_CC);\n", destructor, key); } else { - Printf(s_wrappers, " /* No destructor for simple type %s */\n", key); + Printf(s_wrappers, " /* No destructor for class %s */\n", human_name); } - - // close function - Printf(s_wrappers, "}\n"); - - // declare le_swig_ to store php registration - Printf(s_vdecl, "static int le_swig_%s=0; /* handle for %s */\n", key, human_name); - - // register with php - Printf(s_oinit, "le_swig_%s=zend_register_list_destructors_ex" "(_wrap_destroy%s,NULL,(char *)(SWIGTYPE%s->name),module_number);\n", key, key, key); - - // store php type in class struct - Printf(s_oinit, "SWIG_TypeClientData(SWIGTYPE%s,&le_swig_%s);\n", key, key); - - ki = Next(ki); + } else { + Printf(s_wrappers, " /* No destructor for simple type %s */\n", key); } + + // close function + Printf(s_wrappers, "}\n"); + + // declare le_swig_ to store php registration + Printf(s_vdecl, "static int le_swig_%s=0; /* handle for %s */\n", key, human_name); + + // register with php + Printf(s_oinit, "le_swig_%s=zend_register_list_destructors_ex" "(_wrap_destroy%s,NULL,(char *)(SWIGTYPE%s->name),module_number);\n", key, key, key); + + // store php type in class struct + Printf(s_oinit, "SWIG_TypeClientData(SWIGTYPE%s,&le_swig_%s);\n", key, key); + + ki = Next(ki); + } } class PHP:public Language { diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index bfdec0d76..f0e335c37 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -1773,7 +1773,6 @@ public: Swig_warning(WARN_TYPEMAP_IN_UNDEF, input_file, line_number, "Unable to use type %s as a function argument.\n", SwigType_str(pt, 0)); break; } - p = nextSibling(p); } /* finish argument marshalling */ diff --git a/Source/Modules/r.cxx b/Source/Modules/r.cxx index 32c7a3925..49d3ecc89 100644 --- a/Source/Modules/r.cxx +++ b/Source/Modules/r.cxx @@ -57,11 +57,13 @@ static String * getRTypeName(SwigType *t, int *outCount = NULL) { Insert(tmp, 0, retName); return tmp; + /* if(count) return(b); Delete(b); return(NewString("")); + */ } #if 0 @@ -104,7 +106,7 @@ static String * getRType(Node *n) { Now handles arrays, i.e. struct A[2] ****************/ -static String *getRClassName(String *retType, int addRef = 1, int upRef=0) { +static String *getRClassName(String *retType, int /*addRef*/ = 1, int upRef=0) { String *tmp = NewString(""); SwigType *resolved = SwigType_typedef_resolve_all(retType); char *retName = Char(SwigType_manglestr(resolved)); @@ -115,6 +117,7 @@ static String *getRClassName(String *retType, int addRef = 1, int upRef=0) { } return tmp; +/* #if 1 List *l = SwigType_split(retType); int n = Len(l); @@ -160,6 +163,7 @@ static String *getRClassName(String *retType, int addRef = 1, int upRef=0) { #endif return tmp; +*/ } /********************* @@ -2030,14 +2034,18 @@ int R::functionWrapper(Node *n) { Replaceall(tm,"$owner", "R_SWIG_EXTERNAL"); } - if(0 && addCopyParam) { +#if 0 + if(addCopyParam) { Printf(f->code, "if(LOGICAL(s_swig_copy)[0]) {\n"); Printf(f->code, "/* Deal with returning a reference. */\nr_ans = R_NilValue;\n"); Printf(f->code, "}\n else {\n"); } +#endif Printf(f->code, "%s\n", tm); - if(0 && addCopyParam) +#if 0 + if(addCopyParam) Printf(f->code, "}\n"); /* end of if(s_swig_copy) ... else { ... } */ +#endif } else { Swig_warning(WARN_TYPEMAP_OUT_UNDEF, input_file, line_number, diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx index a57571bb8..ad448d34e 100644 --- a/Source/Modules/ruby.cxx +++ b/Source/Modules/ruby.cxx @@ -448,7 +448,7 @@ private: parent_name = Copy( Getattr(mod, "name") ); if ( parent_name ) { - (Char(parent_name))[0] = toupper((Char(parent_name))[0]); + (Char(parent_name))[0] = (char)toupper((Char(parent_name))[0]); } } if ( parent_name ) @@ -1194,7 +1194,7 @@ public: while (m.item) { if (Len(m.item) > 0) { String *cap = NewString(m.item); - (Char(cap))[0] = toupper((Char(cap))[0]); + (Char(cap))[0] = (char)toupper((Char(cap))[0]); if (last != 0) { Append(module, "::"); } @@ -1206,7 +1206,7 @@ public: if (feature == 0) { feature = Copy(last); } - (Char(last))[0] = toupper((Char(last))[0]); + (Char(last))[0] = (char)toupper((Char(last))[0]); modvar = NewStringf("m%s", last); Delete(modules); } @@ -2219,7 +2219,7 @@ public: return name; if (islower(name[0])) { - name[0] = toupper(name[0]); + name[0] = (char)toupper(name[0]); Swig_warning(WARN_RUBY_WRONG_NAME, input_file, line_number, "Wrong %s name (corrected to `%s')\n", reason, name); return name; } @@ -2545,7 +2545,7 @@ public: String *name = Copy(symname); char *cname = Char(name); if (cname) - cname[0] = toupper(cname[0]); + cname[0] = (char)toupper(cname[0]); Printv(director_prot_ctor_code, "if ( $comparison ) { /* subclassed */\n", " $director_new \n", diff --git a/Source/Preprocessor/cpp.c b/Source/Preprocessor/cpp.c index 560d12998..c04f95f00 100644 --- a/Source/Preprocessor/cpp.c +++ b/Source/Preprocessor/cpp.c @@ -36,6 +36,7 @@ static int error_as_warning = 0; /* Understand the cpp #error directive as a spe /* Test a character to see if it valid in an identifier (after the first letter) */ #define isidchar(c) ((isalnum(c)) || (c == '_') || (c == '$')) +DOH *Preprocessor_replace(DOH *); /* Skip whitespace */ static void skip_whitespace(String *s, String *out) { @@ -698,7 +699,6 @@ static String *get_options(String *str) { static String *expand_macro(String *name, List *args) { String *ns; DOH *symbols, *macro, *margs, *mvalue, *temp, *tempa, *e; - DOH *Preprocessor_replace(DOH *); int i, l; int isvarargs = 0; @@ -935,7 +935,6 @@ static String *expand_macro(String *name, List *args) { List *evaluate_args(List *x) { Iterator i; - String *Preprocessor_replace(String *); List *nl = NewList(); for (i = First(x); i.item; i = Next(i)) { @@ -1795,7 +1794,7 @@ String *Preprocessor_parse(String *s) { for (i = 0; i < 6;) { c = Getc(s); Putc(c, value); - statement[i++] = c; + statement[i++] = (char)c; if (strncmp(statement, ed, i) && strncmp(statement, df, i)) break; } diff --git a/Source/Swig/cwrap.c b/Source/Swig/cwrap.c index 2fc444290..18920ecc2 100644 --- a/Source/Swig/cwrap.c +++ b/Source/Swig/cwrap.c @@ -513,7 +513,8 @@ String *Swig_cppconstructor_base_call(String_or_char *name, ParmList *parms, int pname = Swig_cparm_name(p, i); i++; } else { - if ((pname = Getattr(p, "value"))) + pname = Getattr(p, "value"); + if (pname) pname = Copy(pname); else pname = Copy(Getattr(p, "name")); diff --git a/Source/Swig/include.c b/Source/Swig/include.c index 25ea0683f..3f47be15b 100644 --- a/Source/Swig/include.c +++ b/Source/Swig/include.c @@ -352,7 +352,8 @@ char *Swig_file_filename(const String_or_char *filename) { char *c; strcpy(tmp, Char(filename)); - if ((c = strrchr(tmp, *delim))) + c = strrchr(tmp, *delim); + if (c) return c + 1; else return tmp; diff --git a/Source/Swig/misc.c b/Source/Swig/misc.c index 04691b595..d29250517 100644 --- a/Source/Swig/misc.c +++ b/Source/Swig/misc.c @@ -614,7 +614,8 @@ void Swig_scopename_split(String *s, String **rprefix, String **rlast) { *rlast = Copy(s); } - if ((co = strstr(cc, "operator "))) { + co = strstr(cc, "operator "); + if (co) { if (co == cc) { *rprefix = 0; *rlast = Copy(s); @@ -664,7 +665,9 @@ String *Swig_scopename_prefix(String *s) { char *co = 0; if (!strstr(c, "::")) return 0; - if ((co = strstr(cc, "operator "))) { + co = strstr(cc, "operator "); + + if (co) { if (co == cc) { return 0; } else { @@ -715,7 +718,8 @@ String *Swig_scopename_last(String *s) { if (!strstr(c, "::")) return NewString(s); - if ((co = strstr(cc, "operator "))) { + co = strstr(cc, "operator "); + if (co) { return NewString(co); } @@ -756,7 +760,9 @@ String *Swig_scopename_first(String *s) { char *co = 0; if (!strstr(c, "::")) return 0; - if ((co = strstr(c, "operator "))) { + + co = strstr(c, "operator "); + if (co) { if (co == c) { return 0; } @@ -804,7 +810,9 @@ String *Swig_scopename_suffix(String *s) { char *co = 0; if (!strstr(c, "::")) return 0; - if ((co = strstr(c, "operator "))) { + + co = strstr(c, "operator "); + if (co) { if (co == c) return 0; } @@ -842,8 +850,9 @@ String *Swig_scopename_suffix(String *s) { int Swig_scopename_check(String *s) { char *c = Char(s); - char *co = 0; - if ((co = strstr(c, "operator "))) { + char *co = strstr(c, "operator "); + + if (co) { if (co == c) return 0; } diff --git a/Source/Swig/naming.c b/Source/Swig/naming.c index 6f58c7dc7..f34a24612 100644 --- a/Source/Swig/naming.c +++ b/Source/Swig/naming.c @@ -482,7 +482,8 @@ DOH *Swig_name_object_get(Hash *namehash, String *prefix, String *name, SwigType Delete(t_name); } /* A template-based class lookup */ - if (0 && !rn && SwigType_istemplate(prefix)) { + /* + if (!rn && SwigType_istemplate(prefix)) { String *t_prefix = SwigType_templateprefix(prefix); if (Strcmp(t_prefix, prefix) != 0) { String *t_name = SwigType_templateprefix(name); @@ -491,6 +492,7 @@ DOH *Swig_name_object_get(Hash *namehash, String *prefix, String *name, SwigType } Delete(t_prefix); } + */ } /* A wildcard-based class lookup */ if (!rn) { diff --git a/Source/Swig/scanner.c b/Source/Swig/scanner.c index e8b1b5f46..06e78db37 100644 --- a/Source/Swig/scanner.c +++ b/Source/Swig/scanner.c @@ -200,7 +200,7 @@ static char nextchar(Scanner * s) { if ((nc == '\n') && (!s->freeze_line)) s->line++; Putc(nc,s->text); - return nc; + return (char)nc; } /* ----------------------------------------------------------------------------- @@ -349,7 +349,7 @@ static void get_escape(Scanner *s) { } else { char tmp[3]; tmp[0] = '\\'; - tmp[1] = c; + tmp[1] = (char)c; tmp[2] = 0; Delitem(s->text, DOH_END); Append(s->text, tmp); diff --git a/Source/Swig/typeobj.c b/Source/Swig/typeobj.c index f234839fe..18d1b2304 100644 --- a/Source/Swig/typeobj.c +++ b/Source/Swig/typeobj.c @@ -937,7 +937,8 @@ String *SwigType_templateargs(const SwigType *t) { int SwigType_istemplate(const SwigType *t) { char *ct = Char(t); - if ((ct = strstr(ct, "<(")) && (strstr(ct + 2, ")>"))) + ct = strstr(ct, "<("); + if (ct && (strstr(ct + 2, ")>"))) return 1; return 0; } diff --git a/Source/Swig/typesys.c b/Source/Swig/typesys.c index fdf37ece1..704e1ec53 100644 --- a/Source/Swig/typesys.c +++ b/Source/Swig/typesys.c @@ -108,6 +108,8 @@ static Hash *typedef_resolve_cache = 0; static Hash *typedef_all_cache = 0; static Hash *typedef_qualified_cache = 0; +static Typetab *SwigType_find_scope(Typetab *s, String *nameprefix); + /* common attribute keys, to avoid calling find_key all the times */ /* @@ -162,7 +164,6 @@ void SwigType_typesystem_init() { * ----------------------------------------------------------------------------- */ int SwigType_typedef(SwigType *type, String_or_char *name) { - Typetab *SwigType_find_scope(Typetab *, String *s); if (Getattr(current_typetab, name)) return -1; /* Already defined */ if (Strcmp(type, name) == 0) { /* Can't typedef a name to itself */ @@ -409,7 +410,7 @@ void SwigType_print_scope(Typetab *t) { } } -Typetab *SwigType_find_scope(Typetab *s, String *nameprefix) { +static Typetab *SwigType_find_scope(Typetab *s, String *nameprefix) { Typetab *ss; String *nnameprefix = 0; static int check_parent = 1; @@ -1311,7 +1312,8 @@ SwigType *SwigType_alttype(SwigType *t, int local_tmap) { SwigType *ftd = SwigType_typedef_resolve_all(t); td = SwigType_strip_qualifiers(ftd); Delete(ftd); - if ((n = Swig_symbol_clookup(td, 0))) { + n = Swig_symbol_clookup(td, 0); + if (n) { if (GetFlag(n, "feature:valuewrapper")) { use_wrapper = 1; } else { @@ -1334,7 +1336,8 @@ SwigType *SwigType_alttype(SwigType *t, int local_tmap) { Delete(ftd); if (SwigType_type(td) == T_USER) { use_wrapper = 1; - if ((n = Swig_symbol_clookup(td, 0))) { + n = Swig_symbol_clookup(td, 0); + if (n) { if ((Checkattr(n, "nodeType", "class") && !Getattr(n, "allocate:noassign") && (Getattr(n, "allocate:default_constructor"))) From 979ad76153a4848384e8ea83cbf68b2bda5904fa Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 21 Jun 2008 16:04:55 +0000 Subject: [PATCH 0019/1680] minor vc++ /W4 warning fixes git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10541 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/apply_signed_char.i | 2 ++ Examples/test-suite/bools.i | 2 ++ Examples/test-suite/constant_pointers.i | 6 ++++++ Examples/test-suite/cpp_basic.i | 2 ++ Examples/test-suite/enum_thorough.i | 2 ++ Examples/test-suite/java_typemaps_proxy.i | 2 ++ 6 files changed, 16 insertions(+) diff --git a/Examples/test-suite/apply_signed_char.i b/Examples/test-suite/apply_signed_char.i index ff1f1d83f..c0fa00cfe 100644 --- a/Examples/test-suite/apply_signed_char.i +++ b/Examples/test-suite/apply_signed_char.i @@ -31,5 +31,7 @@ const char memberconstchar; virtual ~DirectorTest() {} + private: + DirectorTest& operator=(const DirectorTest &); }; %} diff --git a/Examples/test-suite/bools.i b/Examples/test-suite/bools.i index 40e8989bd..7b94fcf88 100644 --- a/Examples/test-suite/bools.i +++ b/Examples/test-suite/bools.i @@ -57,6 +57,8 @@ struct BoolStructure { m_rbool(m_bool2), m_const_pbool(m_pbool), m_const_rbool(m_rbool) {} +private: + BoolStructure& operator=(const BoolStructure &); }; %} diff --git a/Examples/test-suite/constant_pointers.i b/Examples/test-suite/constant_pointers.i index 367baf49c..5bd2fd533 100644 --- a/Examples/test-suite/constant_pointers.i +++ b/Examples/test-suite/constant_pointers.i @@ -46,6 +46,8 @@ public: int* array_member1[ARRAY_SIZE]; ParametersTest* array_member2[ARRAY_SIZE]; MemberVariablesTest() : member3(NULL), member4(NULL) {} +private: + MemberVariablesTest& operator=(const MemberVariablesTest&); }; void foo(const int *const i) {} @@ -69,6 +71,8 @@ public: void ret6(int*& a) {} int*& ret7() {return GlobalIntPtr;} ReturnValuesTest() : int3(NULL) {} +private: + ReturnValuesTest& operator=(const ReturnValuesTest&); }; const int* globalRet1() {return &GlobalInt;} @@ -100,6 +104,8 @@ int* const globalRet2() {return &GlobalInt;} A* ap; const A* cap; Acptr acptr; + private: + B& operator=(const B&); }; const B* bar(const B* b) { diff --git a/Examples/test-suite/cpp_basic.i b/Examples/test-suite/cpp_basic.i index becf84708..a247dd268 100644 --- a/Examples/test-suite/cpp_basic.i +++ b/Examples/test-suite/cpp_basic.i @@ -55,6 +55,8 @@ class Bar { Foo *testFoo(int a, Foo *f) { return new Foo(2 * a + (f ? f->num : 0) + fval.num); } +private: + Bar& operator=(const Bar&); }; %} diff --git a/Examples/test-suite/enum_thorough.i b/Examples/test-suite/enum_thorough.i index 4aa0613f2..31e3e2105 100644 --- a/Examples/test-suite/enum_thorough.i +++ b/Examples/test-suite/enum_thorough.i @@ -81,6 +81,8 @@ struct SpeedClass { const colour myColour2; speedtd1 mySpeedtd1; SpeedClass() : myColour2(red), mySpeedtd1(slow) { } +private: + SpeedClass& operator=(const SpeedClass&); }; int speedTest0(int s) { return s; } diff --git a/Examples/test-suite/java_typemaps_proxy.i b/Examples/test-suite/java_typemaps_proxy.i index 5a1e61bb2..e315a36b5 100644 --- a/Examples/test-suite/java_typemaps_proxy.i +++ b/Examples/test-suite/java_typemaps_proxy.i @@ -119,6 +119,8 @@ public: void const_member_method(const ConstWithout *p) const {} const ConstWithout * const_var; const ConstWithout * const var_const; +private: + ConstWithout& operator=(const ConstWithout &); }; const ConstWithout * global_constwithout = 0; void global_method_constwithout(const ConstWithout *p) {} From d798adbbb74fabffdcb51617da6bc8d913f98011 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 21 Jun 2008 19:07:51 +0000 Subject: [PATCH 0020/1680] 'byte' is already used in Ruby on windows, so use another keyword git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10542 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/keyword_rename.i | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/test-suite/keyword_rename.i b/Examples/test-suite/keyword_rename.i index f2eff8af5..da9328868 100644 --- a/Examples/test-suite/keyword_rename.i +++ b/Examples/test-suite/keyword_rename.i @@ -21,7 +21,7 @@ KW(use, next) /* Java keywords */ KW(implements, native) -KW(byte, final) +KW(synchronized, final) /* C# Keywords */ KW(string, out) From 67f59319522e031a5d72112ab4dbd532efd55f0f Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 21 Jun 2008 20:45:32 +0000 Subject: [PATCH 0021/1680] Fix crashing in the Ruby reject method in the STL wrappers git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10543 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/ruby/rubycontainer.swg | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Lib/ruby/rubycontainer.swg b/Lib/ruby/rubycontainer.swg index e3cae5778..919695ec2 100644 --- a/Lib/ruby/rubycontainer.swg +++ b/Lib/ruby/rubycontainer.swg @@ -691,10 +691,12 @@ namespace swig for ( ; i != e; ) { VALUE r = swig::from< Sequence::value_type >(*i); - if ( RTEST( rb_yield(r) ) ) + if ( RTEST( rb_yield(r) ) ) { $self->erase(i++); - else + e = self->end(); + } else { ++i; + } } return self; From c69e7d7472ca5ae7ad50782f115e2cc4a76c5fa4 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 21 Jun 2008 20:48:28 +0000 Subject: [PATCH 0022/1680] Fix crashing in the Ruby reject method in the STL wrappers git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10544 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 5df243eca..8e290b0fa 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,9 @@ Version 1.3.36 (in progress) ============================= +06/21/2008: wsfulton + [Ruby] Fix crashing in the STL wrappers (reject! and delete_if methods) + 06/19/2008: wsfulton [Java, C#] C# and Java keywords will be renamed instead of just issuing a warning and then generating uncompileable code. Warning 314 gives the new name when a From 7743ae39733cafbb18524312e51247ccca8c5a0a Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 21 Jun 2008 20:49:10 +0000 Subject: [PATCH 0023/1680] remove unnecessary variable int the char **STRING_ARRAY out typemap git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10545 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/java/various.i | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/java/various.i b/Lib/java/various.i index c53f08aa2..733b8fa79 100644 --- a/Lib/java/various.i +++ b/Lib/java/various.i @@ -60,7 +60,7 @@ #endif } -%typemap(out) char **STRING_ARRAY (char *s) { +%typemap(out) char **STRING_ARRAY { int i; int len=0; jstring temp_string; From 600deef43dbc0ecd3730880798a6961907c0438e Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 21 Jun 2008 21:07:49 +0000 Subject: [PATCH 0024/1680] Fix Ruby C++ example dependencies in dsp files git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10546 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/ruby/class/example.dsp | 4 ++-- Examples/ruby/free_function/example.dsp | 4 ++-- Examples/ruby/import/bar.dsp | 4 ++-- Examples/ruby/import/base.dsp | 4 ++-- Examples/ruby/import/foo.dsp | 4 ++-- Examples/ruby/import/spam.dsp | 4 ++-- Examples/ruby/mark_function/example.dsp | 4 ++-- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Examples/ruby/class/example.dsp b/Examples/ruby/class/example.dsp index 49c480575..9a26322ec 100644 --- a/Examples/ruby/class/example.dsp +++ b/Examples/ruby/class/example.dsp @@ -123,7 +123,7 @@ SOURCE=.\example.i InputPath=.\example.i InputName=example -"$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" +"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo RUBY_INCLUDE: %RUBY_INCLUDE% echo RUBY_LIB: %RUBY_LIB% @@ -138,7 +138,7 @@ InputName=example InputPath=.\example.i InputName=example -"$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" +"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo RUBY_INCLUDE: %RUBY_INCLUDE% echo RUBY_LIB: %RUBY_LIB% diff --git a/Examples/ruby/free_function/example.dsp b/Examples/ruby/free_function/example.dsp index 49c480575..9a26322ec 100644 --- a/Examples/ruby/free_function/example.dsp +++ b/Examples/ruby/free_function/example.dsp @@ -123,7 +123,7 @@ SOURCE=.\example.i InputPath=.\example.i InputName=example -"$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" +"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo RUBY_INCLUDE: %RUBY_INCLUDE% echo RUBY_LIB: %RUBY_LIB% @@ -138,7 +138,7 @@ InputName=example InputPath=.\example.i InputName=example -"$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" +"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo RUBY_INCLUDE: %RUBY_INCLUDE% echo RUBY_LIB: %RUBY_LIB% diff --git a/Examples/ruby/import/bar.dsp b/Examples/ruby/import/bar.dsp index e897f8d5c..dd09ca021 100644 --- a/Examples/ruby/import/bar.dsp +++ b/Examples/ruby/import/bar.dsp @@ -115,7 +115,7 @@ SOURCE=.\bar.i InputPath=.\bar.i InputName=bar -"$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" +"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo RUBY_INCLUDE: %RUBY_INCLUDE% echo RUBY_LIB: %RUBY_LIB% @@ -130,7 +130,7 @@ InputName=bar InputPath=.\bar.i InputName=bar -"$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" +"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo RUBY_INCLUDE: %RUBY_INCLUDE% echo RUBY_LIB: %RUBY_LIB% diff --git a/Examples/ruby/import/base.dsp b/Examples/ruby/import/base.dsp index 45d2fe2ea..2bd4fa243 100644 --- a/Examples/ruby/import/base.dsp +++ b/Examples/ruby/import/base.dsp @@ -115,7 +115,7 @@ SOURCE=.\base.i InputPath=.\base.i InputName=base -"$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" +"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo RUBY_INCLUDE: %RUBY_INCLUDE% echo RUBY_LIB: %RUBY_LIB% @@ -130,7 +130,7 @@ InputName=base InputPath=.\base.i InputName=base -"$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" +"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo RUBY_INCLUDE: %RUBY_INCLUDE% echo RUBY_LIB: %RUBY_LIB% diff --git a/Examples/ruby/import/foo.dsp b/Examples/ruby/import/foo.dsp index 2dfba9d60..2a764bbd7 100644 --- a/Examples/ruby/import/foo.dsp +++ b/Examples/ruby/import/foo.dsp @@ -115,7 +115,7 @@ SOURCE=.\foo.i InputPath=.\foo.i InputName=foo -"$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" +"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo RUBY_INCLUDE: %RUBY_INCLUDE% echo RUBY_LIB: %RUBY_LIB% @@ -130,7 +130,7 @@ InputName=foo InputPath=.\foo.i InputName=foo -"$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" +"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo RUBY_INCLUDE: %RUBY_INCLUDE% echo RUBY_LIB: %RUBY_LIB% diff --git a/Examples/ruby/import/spam.dsp b/Examples/ruby/import/spam.dsp index 0530b7303..d2d7158bb 100644 --- a/Examples/ruby/import/spam.dsp +++ b/Examples/ruby/import/spam.dsp @@ -115,7 +115,7 @@ SOURCE=.\spam.i InputPath=.\spam.i InputName=spam -"$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" +"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo RUBY_INCLUDE: %RUBY_INCLUDE% echo RUBY_LIB: %RUBY_LIB% @@ -130,7 +130,7 @@ InputName=spam InputPath=.\spam.i InputName=spam -"$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" +"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo RUBY_INCLUDE: %RUBY_INCLUDE% echo RUBY_LIB: %RUBY_LIB% diff --git a/Examples/ruby/mark_function/example.dsp b/Examples/ruby/mark_function/example.dsp index 49c480575..9a26322ec 100644 --- a/Examples/ruby/mark_function/example.dsp +++ b/Examples/ruby/mark_function/example.dsp @@ -123,7 +123,7 @@ SOURCE=.\example.i InputPath=.\example.i InputName=example -"$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" +"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo RUBY_INCLUDE: %RUBY_INCLUDE% echo RUBY_LIB: %RUBY_LIB% @@ -138,7 +138,7 @@ InputName=example InputPath=.\example.i InputName=example -"$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" +"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo RUBY_INCLUDE: %RUBY_INCLUDE% echo RUBY_LIB: %RUBY_LIB% From 1213c5640ab4053f3a78b52b450b90d7aab56495 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 21 Jun 2008 22:25:36 +0000 Subject: [PATCH 0025/1680] Fix unused parameter warnings in python when using gcc's -W -Wall options git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10547 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/python/pyiterators.swg | 6 +++--- Source/Swig/typesys.c | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Lib/python/pyiterators.swg b/Lib/python/pyiterators.swg index e2dfbc3f5..38f1791a9 100644 --- a/Lib/python/pyiterators.swg +++ b/Lib/python/pyiterators.swg @@ -38,18 +38,18 @@ namespace swig { virtual PySwigIterator *incr(size_t n = 1) = 0; // Backward iterator method, very common in C++, but not required in Python - virtual PySwigIterator *decr(size_t n = 1) + virtual PySwigIterator *decr(size_t /*n*/ = 1) { throw stop_iteration(); } // Random access iterator methods, but not required in Python - virtual ptrdiff_t distance(const PySwigIterator &x) const + virtual ptrdiff_t distance(const PySwigIterator &/*x*/) const { throw std::invalid_argument("operation not supported"); } - virtual bool equal (const PySwigIterator &x) const + virtual bool equal (const PySwigIterator &/*x*/) const { throw std::invalid_argument("operation not supported"); } diff --git a/Source/Swig/typesys.c b/Source/Swig/typesys.c index 704e1ec53..d0c27dcfd 100644 --- a/Source/Swig/typesys.c +++ b/Source/Swig/typesys.c @@ -1798,13 +1798,15 @@ void SwigType_inherit_equiv(File *out) { String *lprefix = SwigType_lstr(prefix, 0); Hash *subhash = Getattr(sub, bk.key); String *convcode = Getattr(subhash, "convcode"); - Printf(out, "static void *%s(void *x, int *newmemory) {", convname); if (convcode) { + char *newmemoryused = Strstr(convcode, "newmemory"); /* see if newmemory parameter is used in order to avoid unused paramater warnings */ String *fn = Copy(convcode); Replaceall(fn, "$from", "x"); + Printf(out, "static void *%s(void *x, int *%s) {", convname, newmemoryused ? "newmemory" : ""); Printf(out, "%s", fn); } else { String *cast = Getattr(subhash, "cast"); + Printf(out, "static void *%s(void *x, int *) {", convname); Printf(out, "\n return (void *)((%s) ", lkey); if (cast) Printf(out, "%s", cast); From 4bb0e642131f0a907c99f6b4f9f0e3ecc75eff3d Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 21 Jun 2008 22:26:35 +0000 Subject: [PATCH 0026/1680] Fix virtual destructor git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10548 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/perl5/import/base.h | 2 +- Examples/tcl/import/base.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Examples/perl5/import/base.h b/Examples/perl5/import/base.h index be3cdef7d..5a266f68c 100644 --- a/Examples/perl5/import/base.h +++ b/Examples/perl5/import/base.h @@ -3,7 +3,7 @@ class Base { public: Base() { }; - ~Base() { }; + virtual ~Base() { }; virtual void A() { printf("I'm Base::A\n"); } diff --git a/Examples/tcl/import/base.h b/Examples/tcl/import/base.h index be3cdef7d..5a266f68c 100644 --- a/Examples/tcl/import/base.h +++ b/Examples/tcl/import/base.h @@ -3,7 +3,7 @@ class Base { public: Base() { }; - ~Base() { }; + virtual ~Base() { }; virtual void A() { printf("I'm Base::A\n"); } From 3463ced9179731ce5a63c35ba7614b3ede079a77 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 21 Jun 2008 23:25:20 +0000 Subject: [PATCH 0027/1680] various warning fixes git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10549 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/guile/multimap/example.i | 4 ++-- Examples/guile/multivalue/example.i | 6 +++++ Examples/perl5/multiple_inheritance/example.h | 23 +++++++++---------- Examples/ruby/free_function/example.cxx | 2 +- Lib/csharp/csharphead.swg | 4 ++-- 5 files changed, 22 insertions(+), 17 deletions(-) diff --git a/Examples/guile/multimap/example.i b/Examples/guile/multimap/example.i index a1cc0bb67..7337d1e9e 100644 --- a/Examples/guile/multimap/example.i +++ b/Examples/guile/multimap/example.i @@ -20,7 +20,7 @@ extern int gcd(int x, int y); SCM *v; if (!(SCM_NIMP($input) && SCM_VECTORP($input))) { SWIG_exception(SWIG_ValueError, "Expecting a vector"); - return; + return 0; } $1 = SCM_LENGTH($input); if ($1 == 0) { @@ -32,7 +32,7 @@ extern int gcd(int x, int y); if (!(SCM_NIMP(v[i]) && SCM_STRINGP(v[i]))) { free($2); SWIG_exception(SWIG_ValueError, "Vector items must be strings"); - return; + return 0; } $2[i] = SCM_CHARS(v[i]); } diff --git a/Examples/guile/multivalue/example.i b/Examples/guile/multivalue/example.i index abc2a6fbc..135389487 100644 --- a/Examples/guile/multivalue/example.i +++ b/Examples/guile/multivalue/example.i @@ -2,6 +2,12 @@ %module example; +%{ +void divide_l(int a, int b, int *quotient_p, int *remainder_p); +void divide_v(int a, int b, int *quotient_p, int *remainder_p); +void divide_mv(int a, int b, int *quotient_p, int *remainder_p); +%} + /* Multiple values as lists. By default, if more than one value is to be returned, a list of the values is created and returned; to switch back to this behavior, use: */ diff --git a/Examples/perl5/multiple_inheritance/example.h b/Examples/perl5/multiple_inheritance/example.h index ce7dfe6a7..a8f544898 100644 --- a/Examples/perl5/multiple_inheritance/example.h +++ b/Examples/perl5/multiple_inheritance/example.h @@ -7,26 +7,25 @@ using namespace std; class Bar { public: - virtual void bar () - { - cout << "bar" << endl; - } + virtual void bar () { + cout << "bar" << endl; + } + virtual ~Bar() {} }; class Foo { public: - virtual void foo () - { - cout << "foo" << endl; - } + virtual void foo () { + cout << "foo" << endl; + } + virtual ~Foo() {} }; class Foo_Bar : public Foo, public Bar { public: - virtual void fooBar () - { - cout << "foobar" << endl; - } + virtual void fooBar () { + cout << "foobar" << endl; + } }; diff --git a/Examples/ruby/free_function/example.cxx b/Examples/ruby/free_function/example.cxx index 9e0d24b1a..402a947e9 100644 --- a/Examples/ruby/free_function/example.cxx +++ b/Examples/ruby/free_function/example.cxx @@ -23,7 +23,7 @@ Zoo::~Zoo() IterType iter = this->animals.begin(); IterType end = this->animals.end(); - for(iter; iter != end; ++iter) + for(; iter != end; ++iter) { Animal* animal = *iter; delete animal; diff --git a/Lib/csharp/csharphead.swg b/Lib/csharp/csharphead.swg index 7938dee04..ffff70372 100644 --- a/Lib/csharp/csharphead.swg +++ b/Lib/csharp/csharphead.swg @@ -73,7 +73,7 @@ static SWIG_CSharpExceptionArgument_t SWIG_csharp_exceptions_argument[] = { static void SWIGUNUSED SWIG_CSharpSetPendingException(SWIG_CSharpExceptionCodes code, const char *msg) { SWIG_CSharpExceptionCallback_t callback = SWIG_csharp_exceptions[SWIG_CSharpApplicationException].callback; - if (code >=0 && (size_t)code < sizeof(SWIG_csharp_exceptions)/sizeof(SWIG_CSharpException_t)) { + if ((size_t)code < sizeof(SWIG_csharp_exceptions)/sizeof(SWIG_CSharpException_t)) { callback = SWIG_csharp_exceptions[code].callback; } callback(msg); @@ -81,7 +81,7 @@ static void SWIGUNUSED SWIG_CSharpSetPendingException(SWIG_CSharpExceptionCodes static void SWIGUNUSED SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpExceptionArgumentCodes code, const char *msg, const char *param_name) { SWIG_CSharpExceptionArgumentCallback_t callback = SWIG_csharp_exceptions_argument[SWIG_CSharpArgumentException].callback; - if (code >=0 && (size_t)code < sizeof(SWIG_csharp_exceptions_argument)/sizeof(SWIG_CSharpExceptionArgument_t)) { + if ((size_t)code < sizeof(SWIG_csharp_exceptions_argument)/sizeof(SWIG_CSharpExceptionArgument_t)) { callback = SWIG_csharp_exceptions_argument[code].callback; } callback(msg, param_name); From a1590359c97bab5481c9a34494abcfb08acb13ff Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 22 Jun 2008 00:09:11 +0000 Subject: [PATCH 0028/1680] Another fix for the JVM hanging on exit problem when using directors git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10550 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 5 +++++ Doc/Manual/Java.html | 8 ++++++++ Lib/java/director.swg | 10 ++++++++-- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 8e290b0fa..4aaedd8d3 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,11 @@ Version 1.3.36 (in progress) ============================= +06/22/2008: wsfulton + [Java] Add a way to use AttachCurrentThreadAsDaemon instead of AttachCurrentThread + in director code. Define the SWIG_JAVA_ATTACH_CURRENT_THREAD_AS_DAEMON macro, see + Lib/java/director.swg. + 06/21/2008: wsfulton [Ruby] Fix crashing in the STL wrappers (reject! and delete_if methods) diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html index 88963caf5..6b34e51b6 100644 --- a/Doc/Manual/Java.html +++ b/Doc/Manual/Java.html @@ -3450,6 +3450,14 @@ DirectorDerived::upcall_method() invoked. +

Director threading issues

+ +

+Depending on your operating system and version of Java and how you are using threads, you might find the JVM hangs on exit. +There are a couple of solutions to try out. The preferred solution requires jdk-1.4 and later and uses AttachCurrentThreadAsDaemon instead of AttachCurrentThread whenever a call into the JVM is required. This can be enabled by defining the SWIG_JAVA_ATTACH_CURRENT_THREAD_AS_DAEMON macro when compiling the C++ wrapper code. For older JVMs define SWIG_JAVA_NO_DETACH_CURRENT_THREAD instead, to avoid the DetachCurrentThread call but this will result in a memory leak instead. For further details inspect the source code in the java/director.swg library file. +

+ +

20.6 Accessing protected members

diff --git a/Lib/java/director.swg b/Lib/java/director.swg index bade80c9d..fa588671d 100644 --- a/Lib/java/director.swg +++ b/Lib/java/director.swg @@ -117,12 +117,18 @@ namespace Swig { JNIEnv *jenv_; public: JNIEnvWrapper(const Director *director) : director_(director), jenv_(0) { +#if defined(SWIG_JAVA_ATTACH_CURRENT_THREAD_AS_DAEMON) + // Attach a daemon thread to the JVM. Useful when the JVM should not wait for + // the thread to exit upon shutdown. Only for jdk-1.4 and later. + director_->swig_jvm_->AttachCurrentThreadAsDaemon((void **) &jenv_, NULL); +#else director_->swig_jvm_->AttachCurrentThread((void **) &jenv_, NULL); +#endif } ~JNIEnvWrapper() { -// Some JVMs, eg JDK 1.4.2 and lower on Solaris have a bug and crash with the DetachCurrentThread call. -// However, without this call, the JVM hangs on exit when the thread was not created by the JVM and creates a memory leak. #if !defined(SWIG_JAVA_NO_DETACH_CURRENT_THREAD) + // Some JVMs, eg jdk-1.4.2 and lower on Solaris have a bug and crash with the DetachCurrentThread call. + // However, without this call, the JVM hangs on exit when the thread was not created by the JVM and creates a memory leak. director_->swig_jvm_->DetachCurrentThread(); #endif } From d2ea4834964d67912eddd1b662381615355f86ec Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 22 Jun 2008 00:09:51 +0000 Subject: [PATCH 0029/1680] documentation sections update git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10551 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Contents.html | 1 + Doc/Manual/Java.html | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index 5c7a18eaf..961b4c8b0 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -768,6 +768,7 @@
  • Director classes
  • Overhead and code bloat
  • Simple directors example +
  • Director threading issues
  • Accessing protected members
  • Common customization features diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html index 6b34e51b6..c27eedb34 100644 --- a/Doc/Manual/Java.html +++ b/Doc/Manual/Java.html @@ -85,6 +85,7 @@
  • Director classes
  • Overhead and code bloat
  • Simple directors example +
  • Director threading issues
  • Accessing protected members
  • Common customization features @@ -3450,7 +3451,8 @@ DirectorDerived::upcall_method() invoked. -

    Director threading issues

    +

    20.5.5 Director threading issues

    +

    Depending on your operating system and version of Java and how you are using threads, you might find the JVM hangs on exit. From f062f15d36db5ba706b790e4e62a9bdd89c0fd8d Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 22 Jun 2008 00:18:10 +0000 Subject: [PATCH 0030/1680] more docs on defining macros for the thread hanging problem git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10552 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Java.html | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html index c27eedb34..164fc21e7 100644 --- a/Doc/Manual/Java.html +++ b/Doc/Manual/Java.html @@ -3459,6 +3459,17 @@ Depending on your operating system and version of Java and how you are using thr There are a couple of solutions to try out. The preferred solution requires jdk-1.4 and later and uses AttachCurrentThreadAsDaemon instead of AttachCurrentThread whenever a call into the JVM is required. This can be enabled by defining the SWIG_JAVA_ATTACH_CURRENT_THREAD_AS_DAEMON macro when compiling the C++ wrapper code. For older JVMs define SWIG_JAVA_NO_DETACH_CURRENT_THREAD instead, to avoid the DetachCurrentThread call but this will result in a memory leak instead. For further details inspect the source code in the java/director.swg library file.

    +

    +Macros can be defined on the commandline when compiling your C++ code, or alternatively added to the C++ wrapper file as shown below: +

    + +
    +
    +%insert("runtime") %{
    +#define SWIG_JAVA_NO_DETACH_CURRENT_THREAD
    +%}
    +
    +

    20.6 Accessing protected members

    From f85ef02890a383a711f355b137023cfd294a0bf7 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 22 Jun 2008 21:30:20 +0000 Subject: [PATCH 0031/1680] fix unused parms in last commit for C code git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10558 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Swig/typesys.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Swig/typesys.c b/Source/Swig/typesys.c index d0c27dcfd..48657141e 100644 --- a/Source/Swig/typesys.c +++ b/Source/Swig/typesys.c @@ -1802,11 +1802,11 @@ void SwigType_inherit_equiv(File *out) { char *newmemoryused = Strstr(convcode, "newmemory"); /* see if newmemory parameter is used in order to avoid unused paramater warnings */ String *fn = Copy(convcode); Replaceall(fn, "$from", "x"); - Printf(out, "static void *%s(void *x, int *%s) {", convname, newmemoryused ? "newmemory" : ""); + Printf(out, "static void *%s(void *x, int *%s) {", convname, newmemoryused ? "newmemory" : "SWIGUNUSEDPARM(newmemory)"); Printf(out, "%s", fn); } else { String *cast = Getattr(subhash, "cast"); - Printf(out, "static void *%s(void *x, int *) {", convname); + Printf(out, "static void *%s(void *x, int *SWIGUNUSEDPARM(newmemory)) {", convname); Printf(out, "\n return (void *)((%s) ", lkey); if (cast) Printf(out, "%s", cast); From db820edd2337edfb80d71c05ea04d5ba4906a274 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 22 Jun 2008 22:12:43 +0000 Subject: [PATCH 0032/1680] Suppress unused methods warning for VC++ git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10559 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/swiglabels.swg | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Lib/swiglabels.swg b/Lib/swiglabels.swg index 09de6c969..b943afb47 100644 --- a/Lib/swiglabels.swg +++ b/Lib/swiglabels.swg @@ -40,6 +40,12 @@ # endif #endif +#ifndef SWIG_MSC_UNSUPPRESS_4505 +# if defined(_MSC_VER) +# pragma warning(disable : 4505) /* unreferenced local function has been removed */ +# endif +#endif + #ifndef SWIGUNUSEDPARM # ifdef __cplusplus # define SWIGUNUSEDPARM(p) From 1d2856d82056fed36f6453d4fb57ec87fba3a191 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 23 Jun 2008 20:26:07 +0000 Subject: [PATCH 0033/1680] fix partialcheck-test-suite and parallel make for r, chicken, tcl and php git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10560 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/Makefile.in | 17 ++++++++--------- Examples/test-suite/chicken/Makefile.in | 6 +++--- Examples/test-suite/php4/Makefile.in | 6 +++--- Examples/test-suite/r/Makefile.in | 4 ++-- configure.in | 13 +------------ 5 files changed, 17 insertions(+), 29 deletions(-) diff --git a/Examples/Makefile.in b/Examples/Makefile.in index 0bf9f6767..dd334c225 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -40,8 +40,9 @@ LIBCRYPT = @LIBCRYPT@ SYSLIBS = $(LIBM) $(LIBC) $(LIBCRYPT) LIBPREFIX = -# RUNTOOL is for use as with runtime tools, eg set it to valgrind +# RUNTOOL is for use with runtime tools, eg set it to valgrind RUNTOOL = +# COMPILETOOL is a way to run the compiler under another tool, or more commonly just to stop the compiler executing COMPILETOOL= # X11 options @@ -94,8 +95,6 @@ TK_OPTS = -ltk -ltcl @LIBS@ # Extra Tcl specific dynamic linking options TCL_DLNK = @TCLDYNAMICLINKING@ -TCL_LDSHARED = @TCL_LDSHARED@ -TCL_CXXSHARED = @TCL_CXXSHARED@ TCL_SO = @TCL_SO@ # ----------------------------------------------------------- @@ -135,7 +134,7 @@ wish_cpp: $(SRCS) tcl: $(SRCS) $(SWIG) -tcl8 $(SWIGOPT) $(TCL_SWIGOPTS) $(INTERFACE) $(CC) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) $(TCL_INCLUDE) - $(TCL_LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(TCL_DLNK) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(TCL_SO) + $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(TCL_DLNK) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(TCL_SO) # ----------------------------------------------------------- # Build a Tcl7.5 dynamic loadable module for C++ @@ -144,7 +143,7 @@ tcl: $(SRCS) tcl_cpp: $(SRCS) $(SWIG) -tcl8 -c++ $(SWIGOPT) $(TCL_SWIGOPTS) $(INTERFACE) $(CXX) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(TCL_INCLUDE) - $(TCL_CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(TCL_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(TCL_SO) + $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(TCL_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(TCL_SO) # ----------------------------------------------------------------- # Cleaning the Tcl examples @@ -880,11 +879,11 @@ chicken_static_cpp: $(CXXSRCS) $(CHICKSRCS) chicken: $(SWIG) -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACE) - $(CHICKEN_CSC) -s `echo $(INCLUDES) | sed 's/-I/-C -I/g'` $(CHICKEN_GENERATED_SCHEME) $(SRCS) $(ISRCS) -o $(TARGET)$(SO) + $(COMPILETOOL) $(CHICKEN_CSC) -s `echo $(INCLUDES) | sed 's/-I/-C -I/g'` $(CHICKEN_GENERATED_SCHEME) $(SRCS) $(ISRCS) -o $(TARGET)$(SO) chicken_cpp: $(SWIG) -c++ -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACE) - $(CHICKEN_CSC) -s `echo $(INCLUDES) | sed 's/-I/-C -I/g'` $(CHICKEN_GENERATED_SCHEME) $(SRCS) $(ICXXSRCS) $(CXXSRCS) -o $(TARGET)$(SO) + $(COMPILETOOL) $(CHICKEN_CSC) -s `echo $(INCLUDES) | sed 's/-I/-C -I/g'` $(CHICKEN_GENERATED_SCHEME) $(SRCS) $(ICXXSRCS) $(CXXSRCS) -o $(TARGET)$(SO) chicken_externalhdr: $(SWIG) -chicken -external-runtime $(TARGET) @@ -1078,11 +1077,11 @@ RRSRC = $(INTERFACE:.i=.R) r: $(SRCS) $(SWIG) -r $(SWIGOPT) $(INTERFACE) - +( PKG_LIBS="$(SRCS)" PKG_CPPFLAGS="$(INCLUDES)" $(R) CMD SHLIB -o $(LIBPREFIX)$(TARGET)$(SO) $(ISRCS) ) + +( PKG_LIBS="$(SRCS)" PKG_CPPFLAGS="$(INCLUDES)" $(COMPILETOOL) $(R) CMD SHLIB -o $(LIBPREFIX)$(TARGET)$(SO) $(ISRCS) ) r_cpp: $(CXXSRCS) $(SWIG) -c++ -r $(SWIGOPT) -o $(RCXXSRCS) $(INTERFACE) - +( PKG_LIBS="$(CXXSRCS)" PKG_CPPFLAGS="$(INCLUDES)" $(R) CMD SHLIB -o $(LIBPREFIX)$(TARGET)$(SO) $(RCXXSRCS) ) + +( PKG_LIBS="$(CXXSRCS)" PKG_CPPFLAGS="$(INCLUDES)" $(COMPILETOOL) $(R) CMD SHLIB -o $(LIBPREFIX)$(TARGET)$(SO) $(RCXXSRCS) ) r_clean: rm -f *_wrap* *~ .~* diff --git a/Examples/test-suite/chicken/Makefile.in b/Examples/test-suite/chicken/Makefile.in index 0ac37d16a..0d80ccfc2 100644 --- a/Examples/test-suite/chicken/Makefile.in +++ b/Examples/test-suite/chicken/Makefile.in @@ -40,7 +40,7 @@ SWIGOPT += -nounit $(setup) +$(swig_and_compile_c) $(run_testcase) - +if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(PROXYSUFFIX) ]; then ( \ + if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(PROXYSUFFIX) ]; then ( \ $(MAKE) $*.cproxy; ) \ fi; @@ -54,7 +54,7 @@ SWIGOPT += -nounit %.externaltest: $(setup) - $(swig_and_compile_external) + +$(swig_and_compile_external) $(run_testcase) # Runs the testcase. A testcase is only run if @@ -70,7 +70,7 @@ run_testcase = \ %.cppproxy: SCRIPTSUFFIX = $(PROXYSUFFIX) %.cppproxy: echo "Checking testcase $* (with run test) under chicken with -proxy" - $(swig_and_compile_cpp) + +$(swig_and_compile_cpp) $(run_testcase) %.cproxy: SWIGOPT += -proxy diff --git a/Examples/test-suite/php4/Makefile.in b/Examples/test-suite/php4/Makefile.in index dbd239964..2e14ef9a2 100644 --- a/Examples/test-suite/php4/Makefile.in +++ b/Examples/test-suite/php4/Makefile.in @@ -42,17 +42,17 @@ missingtests: missingcpptests missingctests %.cpptest: $(setup) +$(swig_and_compile_cpp) - $(run_testcase) + +$(run_testcase) %.ctest: $(setup) +$(swig_and_compile_c) - $(run_testcase) + +$(run_testcase) %.multicpptest: $(setup) +$(swig_and_compile_multi_cpp) - $(run_testcase) + +$(run_testcase) # Runs the testcase. A testcase is only run if # a file is found which has _runme.php4 appended after the testcase name. diff --git a/Examples/test-suite/r/Makefile.in b/Examples/test-suite/r/Makefile.in index 0a1b3567e..70dd62ec5 100644 --- a/Examples/test-suite/r/Makefile.in +++ b/Examples/test-suite/r/Makefile.in @@ -42,7 +42,7 @@ run_testcase = \ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PATH=.:"$$PATH" \ $(RUNTOOL) $(RUNR) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ;) \ else \ - ($(RUNR) $(srcdir)/$(SCRIPTPREFIX)$*$(WRAPSUFFIX);) \ + ($(RUNTOOL) $(RUNR) $(srcdir)/$(SCRIPTPREFIX)$*$(WRAPSUFFIX);) \ fi; run_multitestcase = \ @@ -51,7 +51,7 @@ run_multitestcase = \ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PATH=.:"$$PATH" \ $(RUNTOOL) $(RUNR) $(srcdir)/$(SCRIPTPREFIX)$${f}$(SCRIPTSUFFIX) ;) \ else \ - ($(RUNR) $(srcdir)/$(SCRIPTPREFIX)$${f}$(WRAPSUFFIX);) \ + ($(RUNTOOL) $(RUNR) $(srcdir)/$(SCRIPTPREFIX)$${f}$(WRAPSUFFIX);) \ fi; \ done # Clean diff --git a/configure.in b/configure.in index 82d83a4f0..a6aa77535 100644 --- a/configure.in +++ b/configure.in @@ -254,18 +254,6 @@ case $host in *) MZSCHEME_SO=.so;; esac -AC_SUBST(TCL_LDSHARED) -case $host in - *-*-darwin*) TCL_LDSHARED="gcc -dynamiclib -flat_namespace -undefined suppress";; - *) TCL_LDSHARED=$LDSHARED;; -esac - -AC_SUBST(TCL_CXXSHARED) -case $host in - *-*-darwin*) TCL_CXXSHARED="g++ -dynamiclib -flat_namespace -undefined suppress";; - *) TCL_CXXSHARED=$TRYLINKINGWITHCXX;; -esac - AC_SUBST(LUA_SO) case $host in *-*-darwin*) LUA_SO=.so;; @@ -545,6 +533,7 @@ fi # Cygwin (Windows) needs the library for dynamic linking case $host in *-*-cygwin* | *-*-mingw*) TCLDYNAMICLINKING="$TCLLIB";; +*-*-darwin*) TCLDYNAMICLINKING="-dynamiclib -flat_namespace -undefined suppress";; *)TCLDYNAMICLINKING="";; esac fi From 67f0d42dfc7e502d9e8002a8db423581676301bb Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 23 Jun 2008 20:39:41 +0000 Subject: [PATCH 0034/1680] correct message display when running the partialcheck-test-suite make target git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10561 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/chicken/Makefile.in | 6 +++--- Examples/test-suite/csharp/Makefile.in | 4 ++-- Examples/test-suite/guilescm/Makefile.in | 8 ++++---- Examples/test-suite/java/Makefile.in | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Examples/test-suite/chicken/Makefile.in b/Examples/test-suite/chicken/Makefile.in index 0d80ccfc2..ef6d7056c 100644 --- a/Examples/test-suite/chicken/Makefile.in +++ b/Examples/test-suite/chicken/Makefile.in @@ -69,21 +69,21 @@ run_testcase = \ %.cppproxy: SWIGOPT += -proxy %.cppproxy: SCRIPTSUFFIX = $(PROXYSUFFIX) %.cppproxy: - echo "Checking testcase $* (with run test) under chicken with -proxy" + 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 "Checking testcase $* (with run test) under chicken with -proxy" + 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 "Checking testcase $* (with run test) under chicken with -proxy" + echo "$(ACTION)ing testcase $* (with run test) under chicken with -proxy" +$(swig_and_compile_multi_cpp) $(run_testcase) diff --git a/Examples/test-suite/csharp/Makefile.in b/Examples/test-suite/csharp/Makefile.in index 44a1b3675..5fd576ed8 100644 --- a/Examples/test-suite/csharp/Makefile.in +++ b/Examples/test-suite/csharp/Makefile.in @@ -51,9 +51,9 @@ intermediary_classname.customtest: # Makes a directory for the testcase if it does not exist setup = \ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ - echo "Checking testcase $* (with run test) under $(LANGUAGE)" ; \ + echo "$(ACTION)ing testcase $* (with run test) under $(LANGUAGE)" ; \ else \ - echo "Checking testcase $* under $(LANGUAGE)" ; \ + echo "$(ACTION)ing testcase $* under $(LANGUAGE)" ; \ fi; \ if [ ! -d $* ]; then \ mkdir $*; \ diff --git a/Examples/test-suite/guilescm/Makefile.in b/Examples/test-suite/guilescm/Makefile.in index 285426ee8..04de236db 100644 --- a/Examples/test-suite/guilescm/Makefile.in +++ b/Examples/test-suite/guilescm/Makefile.in @@ -21,9 +21,9 @@ run_testcase = \ setup = \ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ - echo "Checking testcase $* (with run test) under $(LANGUAGE) (with SCM API)" ; \ + echo "$(ACTION)ing testcase $* (with run test) under $(LANGUAGE) (with SCM API)" ; \ else \ - echo "Checking testcase $* under $(LANGUAGE) (with SCM API)" ; \ + echo "$(ACTION)ing testcase $* under $(LANGUAGE) (with SCM API)" ; \ fi; swig_and_compile_multi_cpp = \ @@ -43,9 +43,9 @@ swig_and_compile_multi_cpp = \ # Same as setup and run_testcase, but without the SCRIPTPREFIX (so the runme comes from the guilescm directory) local_setup = \ if [ -f $(srcdir)/$*$(SCRIPTSUFFIX) ]; then \ - echo "Checking testcase $* (with run test) under $(LANGUAGE) (with SCM API)" ; \ + echo "$(ACTION)ing testcase $* (with run test) under $(LANGUAGE) (with SCM API)" ; \ else \ - echo "Checking testcase $* under $(LANGUAGE) (with SCM API)" ; \ + echo "$(ACTION)ing testcase $* under $(LANGUAGE) (with SCM API)" ; \ fi; local_run_testcase = \ diff --git a/Examples/test-suite/java/Makefile.in b/Examples/test-suite/java/Makefile.in index 53816f6d0..ace8dee86 100644 --- a/Examples/test-suite/java/Makefile.in +++ b/Examples/test-suite/java/Makefile.in @@ -57,9 +57,9 @@ SWIGOPT += -package $* # Makes a directory for the testcase if it does not exist setup = \ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ - echo "Checking testcase $* (with run test) under $(LANGUAGE)" ; \ + echo "$(ACTION)ing testcase $* (with run test) under $(LANGUAGE)" ; \ else \ - echo "Checking testcase $* under $(LANGUAGE)" ; \ + echo "$(ACTION)ing testcase $* under $(LANGUAGE)" ; \ fi; \ if [ ! -d $* ]; then \ mkdir $*; \ From d4e283eb8c21f79da83fd5f85772c2a860b1c5e0 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 23 Jun 2008 21:14:53 +0000 Subject: [PATCH 0035/1680] fix typo git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10562 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/chicken.cxx | 2 +- Source/Modules/guile.cxx | 2 +- Source/Swig/typesys.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/Modules/chicken.cxx b/Source/Modules/chicken.cxx index 33ec9294f..2298d2939 100644 --- a/Source/Modules/chicken.cxx +++ b/Source/Modules/chicken.cxx @@ -1503,7 +1503,7 @@ int CHICKEN::validIdentifier(String *s) { /* ------------------------------------------------------------ * closNameMapping() * Maps the identifier from C++ to the CLOS based on command - * line paramaters and such. + * line parameters and such. * If class_name = "" that means the mapping is for a function or * variable not attached to any class. * ------------------------------------------------------------ */ diff --git a/Source/Modules/guile.cxx b/Source/Modules/guile.cxx index 2390e8ad6..f5f080034 100644 --- a/Source/Modules/guile.cxx +++ b/Source/Modules/guile.cxx @@ -1649,7 +1649,7 @@ public: /* ------------------------------------------------------------ * goopsNameMapping() * Maps the identifier from C++ to the GOOPS based * on command - * line paramaters and such. + * line parameters and such. * If class_name = "" that means the mapping is for a function or * variable not attached to any class. * ------------------------------------------------------------ */ diff --git a/Source/Swig/typesys.c b/Source/Swig/typesys.c index 48657141e..ae6ab3dc8 100644 --- a/Source/Swig/typesys.c +++ b/Source/Swig/typesys.c @@ -1799,7 +1799,7 @@ void SwigType_inherit_equiv(File *out) { Hash *subhash = Getattr(sub, bk.key); String *convcode = Getattr(subhash, "convcode"); if (convcode) { - char *newmemoryused = Strstr(convcode, "newmemory"); /* see if newmemory parameter is used in order to avoid unused paramater warnings */ + char *newmemoryused = Strstr(convcode, "newmemory"); /* see if newmemory parameter is used in order to avoid unused parameter warnings */ String *fn = Copy(convcode); Replaceall(fn, "$from", "x"); Printf(out, "static void *%s(void *x, int *%s) {", convname, newmemoryused ? "newmemory" : "SWIGUNUSEDPARM(newmemory)"); From ef2a963c89b9795ebe599d353fdb9ec2634f49fd Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Mon, 23 Jun 2008 21:23:54 +0000 Subject: [PATCH 0036/1680] Fix bad use of Python API (untested, since I can't even compile this code on x86-64!) git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10563 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Tools/WAD/Python/type.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tools/WAD/Python/type.c b/Tools/WAD/Python/type.c index 5236c1c64..7d8248e0b 100644 --- a/Tools/WAD/Python/type.c +++ b/Tools/WAD/Python/type.c @@ -62,7 +62,7 @@ new_wadobject(WadFrame *f, int count) { /* release a wad object */ static void wadobject_dealloc(wadobject *self) { - PyMem_DEL(self); + PyObject_Del(self); } static char message[65536]; From 376adf0e64be072dcbd615a29db00338b887f9e8 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Mon, 23 Jun 2008 22:58:03 +0000 Subject: [PATCH 0037/1680] [PHP] Fix segfault when wrapping a non-class function marked with %newobject (testcase char_strings). git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10564 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++++ Source/Modules/php4.cxx | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index 4aaedd8d3..0dfb5ad2f 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,10 @@ Version 1.3.36 (in progress) ============================= +06/24/2008: olly + [PHP] Fix segfault when wrapping a non-class function marked with + %newobject (testcase char_strings). + 06/22/2008: wsfulton [Java] Add a way to use AttachCurrentThreadAsDaemon instead of AttachCurrentThread in director code. Define the SWIG_JAVA_ATTACH_CURRENT_THREAD_AS_DAEMON macro, see diff --git a/Source/Modules/php4.cxx b/Source/Modules/php4.cxx index 60a6dd09d..04209f894 100644 --- a/Source/Modules/php4.cxx +++ b/Source/Modules/php4.cxx @@ -1749,7 +1749,8 @@ public: } Printf(output, "\n"); - if (wrapperType == memberfn || newobject) { + // If it's a member function or a class constructor... + if (wrapperType == memberfn || (newobject && current_class)) { Printf(output, "\tfunction %s(%s) {\n", methodname, args); // 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. From caf2c6904b583171c92f13ee527bdf33081c0faa Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Tue, 24 Jun 2008 00:27:34 +0000 Subject: [PATCH 0038/1680] [PHP] Fix assertion failure when handling %typemap(in,numinputs=0) (testcase ignore_parameter). git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10565 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++++ Source/Modules/php4.cxx | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 0dfb5ad2f..d1d08a525 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,10 @@ Version 1.3.36 (in progress) ============================= +06/24/2008: olly + [PHP] Fix assertion failure when handling %typemap(in,numinputs=0) + (testcase ignore_parameter). + 06/24/2008: olly [PHP] Fix segfault when wrapping a non-class function marked with %newobject (testcase char_strings). diff --git a/Source/Modules/php4.cxx b/Source/Modules/php4.cxx index 04209f894..ded77e3c4 100644 --- a/Source/Modules/php4.cxx +++ b/Source/Modules/php4.cxx @@ -1439,6 +1439,10 @@ public: if (wrapperType == memberfn) p = nextSibling(p); while (p) { + if (GetInt(p, "tmap:in:numinputs") == 0) { + p = nextSibling(p); + continue; + } assert(0 <= argno && argno < max_num_of_arguments); String *&pname = arg_names[argno]; const char *pname_cstr = GetChar(p, "name"); From 5ea3e69bef4a0d439e75b920e4db7934e965f1e1 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Tue, 24 Jun 2008 00:33:08 +0000 Subject: [PATCH 0039/1680] [PHP] Fix typemap_namespace.i to not try to copy a non-existent typemap. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10566 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++++ Examples/test-suite/typemap_namespace.i | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index d1d08a525..6a8eaac2a 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,10 @@ Version 1.3.36 (in progress) ============================= +06/24/2008: olly + [PHP] Fix typemap_namespace.i to not try to copy a non-existent + typemap. + 06/24/2008: olly [PHP] Fix assertion failure when handling %typemap(in,numinputs=0) (testcase ignore_parameter). diff --git a/Examples/test-suite/typemap_namespace.i b/Examples/test-suite/typemap_namespace.i index d30a4ddb1..5375c43b6 100644 --- a/Examples/test-suite/typemap_namespace.i +++ b/Examples/test-suite/typemap_namespace.i @@ -27,7 +27,7 @@ namespace Foo { %typemap(javaout) Str1 * = char *; #endif %typemap(in) Str1 * = char *; -#if !(defined(SWIGCSHARP) || defined(SWIGLUA)) +#if !(defined(SWIGCSHARP) || defined(SWIGLUA) || defined(SWIGPHP)) %typemap(freearg) Str1 * = char *; #endif %typemap(typecheck) Str1 * = char *; From d062b4381aefe8bc71484c92ea3312d25aa6006e Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Tue, 24 Jun 2008 00:41:07 +0000 Subject: [PATCH 0040/1680] Clean up dead and unused code in SwigToPhpType(), and rename to GetShadowReturnType(). git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10567 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/php4.cxx | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/Source/Modules/php4.cxx b/Source/Modules/php4.cxx index ded77e3c4..42d71e79a 100644 --- a/Source/Modules/php4.cxx +++ b/Source/Modules/php4.cxx @@ -1194,7 +1194,7 @@ public: if (native_constructor == NATIVE_CONSTRUCTOR) { Printf(f->code, "add_property_zval(this_ptr,\"" SWIG_PTR "\",_cPtr);\n"); } else { - String *shadowrettype = SwigToPhpType(n, true); + String *shadowrettype = GetShadowReturnType(n); Printf(f->code, "object_init_ex(return_value,ptr_ce_swig_%s);\n", shadowrettype); Delete(shadowrettype); Printf(f->code, "add_property_zval(return_value,\"" SWIG_PTR "\",_cPtr);\n"); @@ -2559,20 +2559,9 @@ public: return SWIG_OK; } - - String * SwigToPhpType(Node *n, int shadow_flag) { - String *ptype = 0; + String * GetShadowReturnType(Node *n) { SwigType *t = Getattr(n, "type"); - if (shadow_flag) { - ptype = PhpTypeFromTypemap((char *) "pstype", n, (char *) ""); - } - if (!ptype) { - ptype = PhpTypeFromTypemap((char *) "ptype", n, (char *) ""); - } - - if (ptype) return ptype; - /* Map type here */ switch (SwigType_type(t)) { case T_CHAR: @@ -2593,7 +2582,7 @@ public: case T_POINTER: case T_REFERENCE: case T_USER: - if (shadow_flag && is_shadow(t)) { + if (is_shadow(t)) { return NewString(Char(is_shadow(t))); } break; @@ -2601,7 +2590,7 @@ public: /* TODO */ break; default: - Printf(stderr, "SwigToPhpType: unhandled data type: %s\n", SwigType_str(t, 0)); + Printf(stderr, "GetShadowReturnType: unhandled data type: %s\n", SwigType_str(t, 0)); break; } From 8c287a1678de62b9c63ef9eb19e9195f1d8f1bba Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Tue, 24 Jun 2008 00:42:29 +0000 Subject: [PATCH 0041/1680] Fix cosmetic typo in string constant. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10568 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/char_strings.i | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/test-suite/char_strings.i b/Examples/test-suite/char_strings.i index a91afaded..b06eba773 100644 --- a/Examples/test-suite/char_strings.i +++ b/Examples/test-suite/char_strings.i @@ -10,7 +10,7 @@ below. %warnfilter(SWIGWARN_TYPEMAP_CHARLEAK_MSG) global_const_char; // Setting a const char * variable may leak memory. %{ -#define OTHERLAND_MSG "Little message from the the safe world." +#define OTHERLAND_MSG "Little message from the safe world." #define CPLUSPLUS_MSG "A message from the deep dark world of C++, where anything is possible." static char *global_str = NULL; const int UINT_DIGITS = 10; // max unsigned int is 4294967295 From 09638387ddaec818a655cb572aef49e7142f3d41 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 24 Jun 2008 20:10:28 +0000 Subject: [PATCH 0042/1680] zap last entry git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10574 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 6a8eaac2a..88f36b9ed 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,10 +1,6 @@ -Version 1.3.36 (in progress) +Version 1.3.36 (24 June 2008) ============================= -06/24/2008: olly - [PHP] Fix typemap_namespace.i to not try to copy a non-existent - typemap. - 06/24/2008: olly [PHP] Fix assertion failure when handling %typemap(in,numinputs=0) (testcase ignore_parameter). From f8ae12fe4d9a6e57339d8bec013d376602804b40 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 24 Jun 2008 20:11:46 +0000 Subject: [PATCH 0043/1680] variable name changes to remove php keywords git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10575 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/csharp/char_strings_runme.cs | 2 +- Examples/test-suite/fvirtual.i | 4 ++-- Examples/test-suite/java/char_strings_runme.java | 2 +- Examples/test-suite/li_std_string.i | 2 +- Examples/test-suite/octave/fvirtual_runme.m | 2 +- Examples/test-suite/octave/li_std_string_runme.m | 2 +- Examples/test-suite/perl5/li_std_string_runme.pl | 4 ++-- Examples/test-suite/python/fvirtual_runme.py | 2 +- Examples/test-suite/python/li_std_string_runme.py | 2 +- Examples/test-suite/ruby/li_std_string_runme.rb | 2 +- Examples/test-suite/template_int_const.i | 8 ++++---- Examples/test-suite/template_typedef_rec.i | 6 +++--- 12 files changed, 19 insertions(+), 19 deletions(-) diff --git a/Examples/test-suite/csharp/char_strings_runme.cs b/Examples/test-suite/csharp/char_strings_runme.cs index a1e878016..a8907fb16 100644 --- a/Examples/test-suite/csharp/char_strings_runme.cs +++ b/Examples/test-suite/csharp/char_strings_runme.cs @@ -5,7 +5,7 @@ using char_stringsNamespace; public class char_strings_runme { private static string CPLUSPLUS_MSG = "A message from the deep dark world of C++, where anything is possible."; - private static string OTHERLAND_MSG = "Little message from the the safe world."; + private static string OTHERLAND_MSG = "Little message from the safe world."; public static void Main() { diff --git a/Examples/test-suite/fvirtual.i b/Examples/test-suite/fvirtual.i index 074202bee..af189ed1f 100644 --- a/Examples/test-suite/fvirtual.i +++ b/Examples/test-suite/fvirtual.i @@ -10,11 +10,11 @@ virtual ~Node() {} }; - class Switch : public Node { + class NodeSwitch : public Node { public : virtual int addChild( Node *child ) { return 2; } // This was hidden with -fvirtual virtual int addChild( Node *child, bool value ) { return 3; } - virtual ~Switch() {} + virtual ~NodeSwitch() {} }; %} diff --git a/Examples/test-suite/java/char_strings_runme.java b/Examples/test-suite/java/char_strings_runme.java index 2e62080f5..2c71d3ea7 100644 --- a/Examples/test-suite/java/char_strings_runme.java +++ b/Examples/test-suite/java/char_strings_runme.java @@ -12,7 +12,7 @@ public class char_strings_runme { } private static String CPLUSPLUS_MSG = "A message from the deep dark world of C++, where anything is possible."; - private static String OTHERLAND_MSG = "Little message from the the safe world."; + private static String OTHERLAND_MSG = "Little message from the safe world."; public static void main(String argv[]) { diff --git a/Examples/test-suite/li_std_string.i b/Examples/test-suite/li_std_string.i index 8c2f1b857..2d0b7503d 100644 --- a/Examples/test-suite/li_std_string.i +++ b/Examples/test-suite/li_std_string.i @@ -129,7 +129,7 @@ public: %} %inline %{ - std::string empty() { + std::string stdstring_empty() { return std::string(); } diff --git a/Examples/test-suite/octave/fvirtual_runme.m b/Examples/test-suite/octave/fvirtual_runme.m index 06c6e7ccb..e755a559a 100644 --- a/Examples/test-suite/octave/fvirtual_runme.m +++ b/Examples/test-suite/octave/fvirtual_runme.m @@ -1,6 +1,6 @@ fvirtual -sw = Switch(); +sw = NodeSwitch(); n = Node(); i = sw.addChild(n); diff --git a/Examples/test-suite/octave/li_std_string_runme.m b/Examples/test-suite/octave/li_std_string_runme.m index 1c24ac344..fa0e260e0 100644 --- a/Examples/test-suite/octave/li_std_string_runme.m +++ b/Examples/test-suite/octave/li_std_string_runme.m @@ -148,7 +148,7 @@ if (s != "hellohello") endif -if (li_std_string.empty() != "") +if (li_std_string.stdstring_empty() != "") error endif diff --git a/Examples/test-suite/perl5/li_std_string_runme.pl b/Examples/test-suite/perl5/li_std_string_runme.pl index 0ee11bdc7..9ec7dd08c 100644 --- a/Examples/test-suite/perl5/li_std_string_runme.pl +++ b/Examples/test-suite/perl5/li_std_string_runme.pl @@ -98,7 +98,7 @@ SKIP: { is($gen1->testl("9234567890121111113"), "9234567890121111114", "ulonglong big number"); -is(li_std_string::empty(), "", "empty"); +is(li_std_string::stdstring_empty(), "", "stdstring_empty"); is(li_std_string::c_empty(), "", "c_empty"); @@ -110,4 +110,4 @@ is(li_std_string::get_null(li_std_string::c_null()), undef, "c_empty"); is(li_std_string::get_null(li_std_string::c_empty()), "non-null", "c_empty"); -is(li_std_string::get_null(li_std_string::empty()), "non-null", "c_empty"); +is(li_std_string::get_null(li_std_string::stdstring_empty()), "non-null", "stdstring_empty"); diff --git a/Examples/test-suite/python/fvirtual_runme.py b/Examples/test-suite/python/fvirtual_runme.py index e06ab5b4f..ada3313de 100644 --- a/Examples/test-suite/python/fvirtual_runme.py +++ b/Examples/test-suite/python/fvirtual_runme.py @@ -1,6 +1,6 @@ from fvirtual import * -sw = Switch() +sw = NodeSwitch() n = Node() i = sw.addChild(n); diff --git a/Examples/test-suite/python/li_std_string_runme.py b/Examples/test-suite/python/li_std_string_runme.py index ed79718d2..c0dae1e25 100644 --- a/Examples/test-suite/python/li_std_string_runme.py +++ b/Examples/test-suite/python/li_std_string_runme.py @@ -121,7 +121,7 @@ if s != "hellohello": raise RuntimeError -if li_std_string.empty() != "": +if li_std_string.stdstring_empty() != "": raise RuntimeError diff --git a/Examples/test-suite/ruby/li_std_string_runme.rb b/Examples/test-suite/ruby/li_std_string_runme.rb index f572573bc..dc85b5dab 100644 --- a/Examples/test-suite/ruby/li_std_string_runme.rb +++ b/Examples/test-suite/ruby/li_std_string_runme.rb @@ -124,7 +124,7 @@ if (s != "hellohello") end -if (empty() != "") +if (stdstring_empty() != "") raise RuntimeError end diff --git a/Examples/test-suite/template_int_const.i b/Examples/test-suite/template_int_const.i index 37b1cf998..e69a53c4f 100644 --- a/Examples/test-suite/template_int_const.i +++ b/Examples/test-suite/template_int_const.i @@ -10,7 +10,7 @@ static const Polarization polarization = UnaryPolarization; }; template - struct Interface + struct Interface_ { }; @@ -26,16 +26,16 @@ }; %} -%template(Interface_UP) Interface; +%template(Interface_UP) Interface_; %template(Module_1) Module<1>; %inline %{ struct ExtInterface1 : - Interface // works + Interface_ // works { }; struct ExtInterface2 : - Interface // doesn't work + Interface_ // doesn't work { }; struct ExtModule1 : diff --git a/Examples/test-suite/template_typedef_rec.i b/Examples/test-suite/template_typedef_rec.i index 83fe2104a..abdf11382 100644 --- a/Examples/test-suite/template_typedef_rec.i +++ b/Examples/test-suite/template_typedef_rec.i @@ -16,7 +16,7 @@ public: template -class ArrayIterator +class ArrayIterator_ { public: typedef test_Array::intT intT; @@ -38,8 +38,8 @@ class ArrayPrimitiveT public: typedef T ValueT; typedef T valueT; - typedef ArrayIterator Iterator; - typedef ArrayIterator ConstIterator; + typedef ArrayIterator_ Iterator; + typedef ArrayIterator_ ConstIterator; typedef ArrayReverseIterator ReverseIterator; typedef ArrayReverseIterator ConstReverseIterator; }; From 2a7586cf27c31179a68e89e649262f16222031ee Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 24 Jun 2008 20:12:08 +0000 Subject: [PATCH 0044/1680] variable name hiding fix git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10576 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/allegrocl.cxx | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/Source/Modules/allegrocl.cxx b/Source/Modules/allegrocl.cxx index 8eed2e861..a968e506c 100644 --- a/Source/Modules/allegrocl.cxx +++ b/Source/Modules/allegrocl.cxx @@ -2271,7 +2271,7 @@ int ALLEGROCL::emit_dispatch_defun(Node *n) { return SWIG_OK; } -int ALLEGROCL::emit_defun(Node *n, File *f_cl) { +int ALLEGROCL::emit_defun(Node *n, File *fcl) { #ifdef ALLEGROCL_WRAP_DEBUG Printf(stderr, "emit_defun: ENTER... "); #endif @@ -2307,27 +2307,27 @@ int ALLEGROCL::emit_defun(Node *n, File *f_cl) { if (Generate_Wrapper) { String *extra_parms = id_converter_arguments(n)->noname_str(); if (Getattr(n, "sym:overloaded")) - Printf(f_cl, "(swig-defmethod (\"%s\" \"%s\"%s)\n", funcname, mangled_name, extra_parms); + Printf(fcl, "(swig-defmethod (\"%s\" \"%s\"%s)\n", funcname, mangled_name, extra_parms); else - Printf(f_cl, "(swig-defun (\"%s\" \"%s\"%s)\n", funcname, mangled_name, extra_parms); + Printf(fcl, "(swig-defun (\"%s\" \"%s\"%s)\n", funcname, mangled_name, extra_parms); Delete(extra_parms); } // Just C else { - Printf(f_cl, "(swig-defun (\"%s\" \"%s\")\n", funcname, Generate_Wrapper ? mangled_name : funcname); + Printf(fcl, "(swig-defun (\"%s\" \"%s\")\n", funcname, Generate_Wrapper ? mangled_name : funcname); } ////////////////////////////////////// // Lisp foreign call parameter list // ////////////////////////////////////// - Printf(f_cl, " ("); + Printf(fcl, " ("); /* Special cases */ if (ParmList_len(pl) == 0) { - Printf(f_cl, ":void"); + Printf(fcl, ":void"); /* } else if (any_varargs(pl)) { - Printf(f_cl, "#| varargs |#"); + Printf(fcl, "#| varargs |#"); varargs=1; */ } else { String *largs = NewString(""); @@ -2337,7 +2337,7 @@ int ALLEGROCL::emit_defun(Node *n, File *f_cl) { SwigType *argtype = Swig_cparse_type(Getattr(p, "tmap:ctype")); if (!first) { - Printf(f_cl, "\n "); + Printf(fcl, "\n "); } if (SwigType_isvarargs(argtype)) { @@ -2393,7 +2393,7 @@ int ALLEGROCL::emit_defun(Node *n, File *f_cl) { // if this parameter has been removed from the C/++ wrapper // it shouldn't be in the lisp wrapper either. if (!checkAttribute(p, "tmap:in:numinputs", "0")) { - Printf(f_cl, "(%s %s %s %s %s)", + Printf(fcl, "(%s %s %s %s %s)", // parms in the ff wrapper, but not in the lisp wrapper. (checkAttribute(p, "tmap:lin:numinputs", "0") ? ":p-" : ":p+"), argname, dispatchtype, ffitype, lisptype); @@ -2479,12 +2479,12 @@ int ALLEGROCL::emit_defun(Node *n, File *f_cl) { Replaceall(wrap->code, "$ldestructor", ldestructor); Delete(ldestructor); - Printf(f_cl, ")\n"); /* finish arg list */ + Printf(fcl, ")\n"); /* finish arg list */ ///////////////////////////////////////////////////// // Lisp foreign call return type and optimizations // ///////////////////////////////////////////////////// - Printf(f_cl, " (:returning (%s %s)", compose_foreign_type(result_type), get_lisp_type(Getattr(n, "type"), "result")); + Printf(fcl, " (:returning (%s %s)", compose_foreign_type(result_type), get_lisp_type(Getattr(n, "type"), "result")); for (Iterator option = First(n); option.item; option = Next(option)) { if (Strncmp("feature:ffargs:", option.key, 15)) @@ -2494,12 +2494,12 @@ int ALLEGROCL::emit_defun(Node *n, File *f_cl) { Replaceall(option_name, "_", "-"); // TODO: varargs vs call-direct ? - Printf(f_cl, "\n %s %s", option_name, option_val); + Printf(fcl, "\n %s %s", option_name, option_val); Delete(option_name); } - Printf(f_cl, ")\n %s)\n\n", wrap->code); + Printf(fcl, ")\n %s)\n\n", wrap->code); // Wrapper_print(wrap, stderr); Delete(result_type); From a5c10ecde3132e9e5bb13797385f8c81b3990720 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 24 Jun 2008 20:12:43 +0000 Subject: [PATCH 0045/1680] More info about numobjects added git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10577 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Typemaps.html | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Doc/Manual/Typemaps.html b/Doc/Manual/Typemaps.html index e8856c95c..d0011e07d 100644 --- a/Doc/Manual/Typemaps.html +++ b/Doc/Manual/Typemaps.html @@ -1933,7 +1933,7 @@ to implement customized conversions.

    In addition, the "in" typemap allows the number of converted arguments to be -specified. For example: +specified. The numinputs attributes facilitates this. For example:

    @@ -1946,7 +1946,12 @@ specified. For example:

    -At this time, only zero or one arguments may be converted. +At this time, only zero or one arguments may be converted. +When numinputs is set to 0, the argument is effectively ignored and cannot be supplied from the target language. +The argument is still required when making the C/C++ call and the above typemap +shows the value used is instead obtained from a locally declared variable called temp. +Usually numinputs is not specified, whereupon the default value is 1, that is, there is a one to one mapping of the number of arguments when used from the target language to the C/C++ call. +Multi-argument typemaps provide a similar concept where the number of arguments mapped from the target language to C/C++ can be changed for more tha multiple adjacent C/C++ arguments.

    @@ -2811,7 +2816,7 @@ optimal attribute usage in the out typemap at example.i:7. However, it doesn't always get it right, for example when $1 is within some commented out code.

    -

    10.9 Multi-argument typemaps

    +

    10.9 Multi-argument typemaps

    From fc0becfc786a88de13510d4b89ddc3b1199aeef3 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 24 Jun 2008 20:13:41 +0000 Subject: [PATCH 0046/1680] update for 1.3.36 release git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10578 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- ANNOUNCE | 10 +++++----- Doc/Manual/Sections.html | 2 +- README | 9 ++++++++- TODO | 2 +- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/ANNOUNCE b/ANNOUNCE index 0fb688344..7c0e95e3f 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -1,10 +1,10 @@ -*** ANNOUNCE: SWIG 1.3.35 (7 April 2008) *** +*** ANNOUNCE: SWIG 1.3.36 (24 June 2008) *** http://www.swig.org -We're pleased to announce SWIG-1.3.35, the latest installment in the -SWIG development effort. SWIG-1.3.35 includes a number of bug fixes +We're pleased to announce SWIG-1.3.36, the latest installment in the +SWIG development effort. SWIG-1.3.36 includes a number of bug fixes and large number of enhancements throughout. 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.35.tar.gz + http://prdownloads.sourceforge.net/swig/swig-1.3.36.tar.gz A Windows version is also available at - http://prdownloads.sourceforge.net/swig/swigwin-1.3.35.zip + http://prdownloads.sourceforge.net/swig/swigwin-1.3.36.zip Release numbers --------------- diff --git a/Doc/Manual/Sections.html b/Doc/Manual/Sections.html index b7b4798e7..9f235b633 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.36 (in progress) +Last update : SWIG-1.3.36 (24 June 2008)

    Sections

    diff --git a/README b/README index 61550e558..12e9c3331 100644 --- a/README +++ b/README @@ -1,6 +1,6 @@ SWIG (Simplified Wrapper and Interface Generator) -Version: 1.3.35 (7 April 2008) +Version: 1.3.35 (24 June 2008) Tagline: SWIG is a compiler that integrates C and C++ with languages including Perl, Python, Tcl, Ruby, PHP, Java, Ocaml, Lua, @@ -91,6 +91,13 @@ A SWIG FAQ and other hints can be found on the SWIG Wiki: What's New? =========== +SWIG-1.3.36 summary: +- Enhancement to directors to wrap all protected members +- Optimisation feature for objects returned by value +- A few bugs fixes in the PHP, Java, Ruby, R, C#, Python, Lua and + Perl modules +- Other minor generic bug fixes + SWIG-1.3.35 summary: - Octave language module added - Bug fixes in Python, Lua, Java, C#, Perl modules diff --git a/TODO b/TODO index d764d1d20..103185d23 100644 --- a/TODO +++ b/TODO @@ -1,6 +1,6 @@ SWIG TO-DO -Release: SWIG-1.3.35 +Release: SWIG-1.3.36 ----------------------------------------------------------------------------- From afe519f8a1286f7ce879ebb243a780090a3fde4b Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 24 Jun 2008 21:48:46 +0000 Subject: [PATCH 0047/1680] remove deprecated -c commandline option (runtime library generation) git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10579 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 3 +++ Doc/Manual/Warnings.html | 2 +- Source/Modules/main.cxx | 8 ++++---- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 88f36b9ed..1bb800493 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,9 @@ Version 1.3.36 (24 June 2008) ============================= +06/24/2008: wsfulton + Remove deprecated -c commandline option (runtime library generation). + 06/24/2008: olly [PHP] Fix assertion failure when handling %typemap(in,numinputs=0) (testcase ignore_parameter). diff --git a/Doc/Manual/Warnings.html b/Doc/Manual/Warnings.html index 39d5d3f01..0b3cb37e9 100644 --- a/Doc/Manual/Warnings.html +++ b/Doc/Manual/Warnings.html @@ -373,7 +373,7 @@ example.i(4): Syntax error in input.
  • 117. Deprecated %new directive.
  • 118. Deprecated %typemap(except).
  • 119. Deprecated %typemap(ignore). -
  • 120. Deprecated command line option (-c). +
  • 120. Deprecated command line option (-runtime, -noruntime).
  • 121. Deprecated %name directive. diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx index 3453f5de2..c99a2e540 100644 --- a/Source/Modules/main.cxx +++ b/Source/Modules/main.cxx @@ -33,7 +33,7 @@ int GenerateDefault = 1; // Generate default constructors int Verbose = 0; int AddExtern = 0; int NoExcept = 0; -int SwigRuntime = 0; // 0 = no option, 1 = -c or -runtime, 2 = -noruntime +int SwigRuntime = 0; // 0 = no option, 1 = -runtime, 2 = -noruntime /* Suppress warning messages for private inheritance, preprocessor evaluation etc... WARN_PP_EVALUATION 202 @@ -493,11 +493,11 @@ void SWIG_getoptions(int argc, char *argv[]) { Swig_mark_arg(i); } else if (strcmp(argv[i], "-runtime") == 0) { Swig_mark_arg(i); - Swig_warning(WARN_DEPRECATED_OPTC, "SWIG", 1, "-c, -runtime, -noruntime command line options are deprecated.\n"); + Swig_warning(WARN_DEPRECATED_OPTC, "SWIG", 1, "-runtime, -noruntime command line options are deprecated.\n"); SwigRuntime = 1; - } else if ((strcmp(argv[i], "-c") == 0) || (strcmp(argv[i], "-noruntime") == 0)) { + } else if (strcmp(argv[i], "-noruntime") == 0) { // Used to also accept -c. removed in swig-1.3.36 Swig_mark_arg(i); - Swig_warning(WARN_DEPRECATED_OPTC, "SWIG", 1, "-c, -runtime, -noruntime command line options are deprecated.\n"); + Swig_warning(WARN_DEPRECATED_OPTC, "SWIG", 1, "-runtime, -noruntime command line options are deprecated.\n"); SwigRuntime = 2; } else if (strcmp(argv[i], "-external-runtime") == 0) { external_runtime = 1; From 16a88b3dc82f36395550cf233358a4955bd94006 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 24 Jun 2008 21:53:12 +0000 Subject: [PATCH 0048/1680] correct comment about deprecated option git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10580 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/main.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx index c99a2e540..901ee812e 100644 --- a/Source/Modules/main.cxx +++ b/Source/Modules/main.cxx @@ -491,11 +491,11 @@ void SWIG_getoptions(int argc, char *argv[]) { Wrapper_compact_print_mode_set(1); Wrapper_virtual_elimination_mode_set(1); Swig_mark_arg(i); - } else if (strcmp(argv[i], "-runtime") == 0) { + } else if (strcmp(argv[i], "-runtime") == 0) { // Used to also accept -c. removed in swig-1.3.36 Swig_mark_arg(i); Swig_warning(WARN_DEPRECATED_OPTC, "SWIG", 1, "-runtime, -noruntime command line options are deprecated.\n"); SwigRuntime = 1; - } else if (strcmp(argv[i], "-noruntime") == 0) { // Used to also accept -c. removed in swig-1.3.36 + } else if (strcmp(argv[i], "-noruntime") == 0) { Swig_mark_arg(i); Swig_warning(WARN_DEPRECATED_OPTC, "SWIG", 1, "-runtime, -noruntime command line options are deprecated.\n"); SwigRuntime = 2; From 505582bad5b32f0a70381c970f3f5ea2dd1439e9 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 24 Jun 2008 23:00:27 +0000 Subject: [PATCH 0049/1680] use rsync and ssh to upload releases to SourceForge as ftp no longer works git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10582 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Tools/mkrelease.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Tools/mkrelease.py b/Tools/mkrelease.py index 574720dab..d7927f8e6 100755 --- a/Tools/mkrelease.py +++ b/Tools/mkrelease.py @@ -21,8 +21,8 @@ except: print "where version should be 1.3.x and username is your SF username" sys.exit(1) -print "Looking for wput" -os.system("which wput") and failed("wput not installed/found. Please install.") +print "Looking for rsync" +os.system("which rsync") and failed("rsync not installed/found. Please install.") print "Making source tarball" os.system("python ./mkdist.py " + version) and failed("") @@ -31,8 +31,8 @@ print "Build Windows package" os.system("./mkwindows.sh " + version) and failed("") print "Uploading to Sourceforge" -os.system("wput --verbose --binary swig-" + version + ".tar.gz ftp://anonymous:" + username + "@users.sourceforge.net@upload.sourceforge.net/incoming/") and failed("") -os.system("wput --verbose --binary swigwin-" + version + ".zip ftp://anonymous:" + username + "@users.sourceforge.net@upload.sourceforge.net/incoming/") and failed("") +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("") 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 + "/") From 5bb73165fa107241297034cf271ea2506b05779d Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 24 Jun 2008 23:24:48 +0000 Subject: [PATCH 0050/1680] correction for 1.3.36 git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10584 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README b/README index 12e9c3331..2898130b0 100644 --- a/README +++ b/README @@ -1,6 +1,6 @@ SWIG (Simplified Wrapper and Interface Generator) -Version: 1.3.35 (24 June 2008) +Version: 1.3.36 (24 June 2008) Tagline: SWIG is a compiler that integrates C and C++ with languages including Perl, Python, Tcl, Ruby, PHP, Java, Ocaml, Lua, From ac5b951a574ae0dea900a4501ea09567f9c2f315 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 25 Jun 2008 00:16:04 +0000 Subject: [PATCH 0051/1680] section update git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10588 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Contents.html | 2 +- Doc/Manual/Typemaps.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index 961b4c8b0..c3197b9dc 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -380,7 +380,7 @@
  • Typemaps for multiple languages
  • Optimal code generation when returning by value -
  • Multi-argument typemaps +
  • Multi-argument typemaps
  • The run-time type checker
    • Implementation diff --git a/Doc/Manual/Typemaps.html b/Doc/Manual/Typemaps.html index d0011e07d..8f3035dc8 100644 --- a/Doc/Manual/Typemaps.html +++ b/Doc/Manual/Typemaps.html @@ -65,7 +65,7 @@
  • Typemaps for multiple languages
  • Optimal code generation when returning by value -
  • Multi-argument typemaps +
  • Multi-argument typemaps
  • The run-time type checker
    • Implementation From a49edfb2b5f82bcb6d1581d8fabbdf34395535f2 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 25 Jun 2008 00:16:40 +0000 Subject: [PATCH 0052/1680] bump version to 1.3.37 git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10589 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES | 156 +++++++++++++++++++++++++++++++++++++++ CHANGES.current | 155 +------------------------------------- Doc/Manual/Sections.html | 2 +- configure.in | 2 +- 4 files changed, 159 insertions(+), 156 deletions(-) diff --git a/CHANGES b/CHANGES index fc3018a1d..56b3b6b82 100644 --- a/CHANGES +++ b/CHANGES @@ -2,6 +2,162 @@ SWIG (Simplified Wrapper and Interface Generator) See CHANGES.current for current version. +Version 1.3.36 (24 June 2008) +============================= + +06/24/2008: wsfulton + Remove deprecated -c commandline option (runtime library generation). + +06/24/2008: olly + [PHP] Fix assertion failure when handling %typemap(in,numinputs=0) + (testcase ignore_parameter). + +06/24/2008: olly + [PHP] Fix segfault when wrapping a non-class function marked with + %newobject (testcase char_strings). + +06/22/2008: wsfulton + [Java] Add a way to use AttachCurrentThreadAsDaemon instead of AttachCurrentThread + in director code. Define the SWIG_JAVA_ATTACH_CURRENT_THREAD_AS_DAEMON macro, see + Lib/java/director.swg. + +06/21/2008: wsfulton + [Ruby] Fix crashing in the STL wrappers (reject! and delete_if methods) + +06/19/2008: wsfulton + [Java, C#] C# and Java keywords will be renamed instead of just issuing a warning + and then generating uncompileable code. Warning 314 gives the new name when a + keyword is found. + +06/19/2008: wsfulton + [R] Keyword handling added. R Keywords will be renamed as necessary. + Warning 314 gives the new name when a keyword is found. + +06/17/2008: mgossage + [Lua] Added missing support for bool& and bool*. Added runtest for li_typemaps testcase. + (Bug #1938142) + +06/07/2008: bhy + Added test case keyword_rename, then made the keyword renaming works properly + by fixing Swig_name_make() for a incomplete condition checking. + +06/02/2008: wsfulton + [Java, C#] Fix enum wrappers when using -noproxy. + +05/30/2008: bhy + Added std::wstring into Lib/typemaps/primtypes.swg, since it is also a primitive + type in SWIG - fixed SF #1976978. + +05/29/2008: wsfulton + [Java, C#] Fix variable wrappers when using -noproxy. + +05/29/2008: bhy + [Python] Fixed a typo of %#ifdef in Lib/python/pycontainer.swg, which is related + to -extranative SWIG option - SF #1971977. + +05/20/2008: wsfulton + New partialcheck makefile targets for partial testing of the test-suite. These + just invoke SWIG, ie no compilation and no runtime testing. It can be faster + when developing by just doing a directory diff of the files SWIG generates + against those from a previous run. Example usage from the top level directory: + + make partialcheck-test-suite + make partialcheck-java-test-suite + + This change also encompasses more flexibility in running the test-suite, eg + it is possible to prefix the command line which runs any target language test + with a tool. See the RUNTOOL, COMPILETOOL and SWIGTOOL targets in the common.mk + file and makefiles in the test-suite directory. For example it is possible to + run the runtime tests through valgrind using: + + make check RUNTOOL="valgrind --leak-check=full" + + or invoke SWIG under valgrind using: + + make check SWIGTOOL="valgrind --tool=memcheck" + +05/19/2008: drjoe + [R] Fixed define that was breaking pre-2.7. Checked in + patch from Soren Sonnenburg that creates strings in + version independent way + +05/15/2008: wsfulton + [Java] Fix variable name clash in directors - SF #1963316 reported by Tristan. + +05/14/2008: wsfulton + Add an optimisation for functions that return objects by value, reducing + the number of copies of the object that are made. Implemented using an + optional attribute in the "out" typemap called "optimal". Details in + Typemaps.html. + +05/11/2008: olly + [PHP] Check for %feature("notabstract") when generating PHP5 class + wrapper. + +05/11/2008: wsfulton + Fix SF #1943608 - $self substitution in %contract, patch submitted by + Toon Verstraelen. + +05/09/2008: olly + [PHP] Fix char * typemaps to work when applied to signed char * and + unsigned char * (uncovered by testcase apply_strings). + +05/09/2008: wsfulton + Fix wrapping of char * member variables when using allprotected mode. + Bug reported by Warren Wang. + +05/09/2008: olly + [PHP] Fix bad PHP code generated when wrapping an enum in a + namespace (uncovered by testcase arrays_scope). + +05/09/2008: olly + [PHP] SWIG now runs the PHP testsuite using PHP5, not PHP4. PHP4 + is essentially obsolete now, so we care much more about solid PHP5 + support. + +05/07/2008: wsfulton + STL fixes when using %import rather than %include and the Solaris Workshop + compiler and the Roguewave STL. + +05/07/2008: wsfulton + Fix wrapping of overloaded protected methods when using allprotected mode. + Bug reported by Warren Wang. + +05/03/2008: wsfulton + Commit patch #1956607 to add -MT support from Richard Boulton. + This patch mirrors the gcc -MT option which allows one to change the default + Makefile target being generated when generating makefiles with the -M family + of options. For example: + + $ swig -java -MM -MT overiddenname -c++ example.i + overiddenname: \ + example.i \ + example.h + +04/30/2008: mgossage + [Lua] Removed generation of _wrap_delete_XXXXX (wrappered destructor) + which was unused and causing warning with g++ -Wall. + Removed other unused warning in typemaps.i and other places. + Added Examples/lua/embed3, and run tests a few test cases. + +04/24/2008: olly + [Python] Fix generated code for IBM's C++ compiler on AIX (patch + from Goeran Uddeborg in SF#1928048). + +04/24/2008: olly + Rename BSIZE in Examples/test-suite/arrays_scope.i to BBSIZE to + avoid a clash with BSIZE defined by headers on AIX with Perl + (reported in SF#1928048). + +04/20/2008: wsfulton + Add the ability to wrap all protected members when using directors. + Previously only the virtual methods were available to the target language. + Now all protected members, (static and non-static variables, non-virtual methods + and static methods) are wrapped when using the allprotected mode. The allprotected + mode is turned on in the module declaration: + + %module(directors="1", allprotected="1") modulename + Version 1.3.35 (7 April 2008) ============================= diff --git a/CHANGES.current b/CHANGES.current index 1bb800493..ef3fcca54 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,156 +1,3 @@ -Version 1.3.36 (24 June 2008) +Version 1.3.36 (in progress) ============================= -06/24/2008: wsfulton - Remove deprecated -c commandline option (runtime library generation). - -06/24/2008: olly - [PHP] Fix assertion failure when handling %typemap(in,numinputs=0) - (testcase ignore_parameter). - -06/24/2008: olly - [PHP] Fix segfault when wrapping a non-class function marked with - %newobject (testcase char_strings). - -06/22/2008: wsfulton - [Java] Add a way to use AttachCurrentThreadAsDaemon instead of AttachCurrentThread - in director code. Define the SWIG_JAVA_ATTACH_CURRENT_THREAD_AS_DAEMON macro, see - Lib/java/director.swg. - -06/21/2008: wsfulton - [Ruby] Fix crashing in the STL wrappers (reject! and delete_if methods) - -06/19/2008: wsfulton - [Java, C#] C# and Java keywords will be renamed instead of just issuing a warning - and then generating uncompileable code. Warning 314 gives the new name when a - keyword is found. - -06/19/2008: wsfulton - [R] Keyword handling added. R Keywords will be renamed as necessary. - Warning 314 gives the new name when a keyword is found. - -06/17/2008: mgossage - [Lua] Added missing support for bool& and bool*. Added runtest for li_typemaps testcase. - (Bug #1938142) - -06/07/2008: bhy - Added test case keyword_rename, then made the keyword renaming works properly - by fixing Swig_name_make() for a incomplete condition checking. - -06/02/2008: wsfulton - [Java, C#] Fix enum wrappers when using -noproxy. - -05/30/2008: bhy - Added std::wstring into Lib/typemaps/primtypes.swg, since it is also a primitive - type in SWIG - fixed SF #1976978. - -05/29/2008: wsfulton - [Java, C#] Fix variable wrappers when using -noproxy. - -05/29/2008: bhy - [Python] Fixed a typo of %#ifdef in Lib/python/pycontainer.swg, which is related - to -extranative SWIG option - SF #1971977. - -05/20/2008: wsfulton - New partialcheck makefile targets for partial testing of the test-suite. These - just invoke SWIG, ie no compilation and no runtime testing. It can be faster - when developing by just doing a directory diff of the files SWIG generates - against those from a previous run. Example usage from the top level directory: - - make partialcheck-test-suite - make partialcheck-java-test-suite - - This change also encompasses more flexibility in running the test-suite, eg - it is possible to prefix the command line which runs any target language test - with a tool. See the RUNTOOL, COMPILETOOL and SWIGTOOL targets in the common.mk - file and makefiles in the test-suite directory. For example it is possible to - run the runtime tests through valgrind using: - - make check RUNTOOL="valgrind --leak-check=full" - - or invoke SWIG under valgrind using: - - make check SWIGTOOL="valgrind --tool=memcheck" - -05/19/2008: drjoe - [R] Fixed define that was breaking pre-2.7. Checked in - patch from Soren Sonnenburg that creates strings in - version independent way - -05/15/2008: wsfulton - [Java] Fix variable name clash in directors - SF #1963316 reported by Tristan. - -05/14/2008: wsfulton - Add an optimisation for functions that return objects by value, reducing - the number of copies of the object that are made. Implemented using an - optional attribute in the "out" typemap called "optimal". Details in - Typemaps.html. - -05/11/2008: olly - [PHP] Check for %feature("notabstract") when generating PHP5 class - wrapper. - -05/11/2008: wsfulton - Fix SF #1943608 - $self substitution in %contract, patch submitted by - Toon Verstraelen. - -05/09/2008: olly - [PHP] Fix char * typemaps to work when applied to signed char * and - unsigned char * (uncovered by testcase apply_strings). - -05/09/2008: wsfulton - Fix wrapping of char * member variables when using allprotected mode. - Bug reported by Warren Wang. - -05/09/2008: olly - [PHP] Fix bad PHP code generated when wrapping an enum in a - namespace (uncovered by testcase arrays_scope). - -05/09/2008: olly - [PHP] SWIG now runs the PHP testsuite using PHP5, not PHP4. PHP4 - is essentially obsolete now, so we care much more about solid PHP5 - support. - -05/07/2008: wsfulton - STL fixes when using %import rather than %include and the Solaris Workshop - compiler and the Roguewave STL. - -05/07/2008: wsfulton - Fix wrapping of overloaded protected methods when using allprotected mode. - Bug reported by Warren Wang. - -05/03/2008: wsfulton - Commit patch #1956607 to add -MT support from Richard Boulton. - This patch mirrors the gcc -MT option which allows one to change the default - Makefile target being generated when generating makefiles with the -M family - of options. For example: - - $ swig -java -MM -MT overiddenname -c++ example.i - overiddenname: \ - example.i \ - example.h - -04/30/2008: mgossage - [Lua] Removed generation of _wrap_delete_XXXXX (wrappered destructor) - which was unused and causing warning with g++ -Wall. - Removed other unused warning in typemaps.i and other places. - Added Examples/lua/embed3, and run tests a few test cases. - -04/24/2008: olly - [Python] Fix generated code for IBM's C++ compiler on AIX (patch - from Goeran Uddeborg in SF#1928048). - -04/24/2008: olly - Rename BSIZE in Examples/test-suite/arrays_scope.i to BBSIZE to - avoid a clash with BSIZE defined by headers on AIX with Perl - (reported in SF#1928048). - -04/20/2008: wsfulton - Add the ability to wrap all protected members when using directors. - Previously only the virtual methods were available to the target language. - Now all protected members, (static and non-static variables, non-virtual methods - and static methods) are wrapped when using the allprotected mode. The allprotected - mode is turned on in the module declaration: - - %module(directors="1", allprotected="1") modulename - diff --git a/Doc/Manual/Sections.html b/Doc/Manual/Sections.html index 9f235b633..5406f44ea 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.36 (24 June 2008) +Last update : SWIG-1.3.37 (in progress)

      Sections

      diff --git a/configure.in b/configure.in index a6aa77535..13c3c6bc9 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.36],[http://www.swig.org]) +AC_INIT([swig],[1.3.37],[http://www.swig.org]) AC_PREREQ(2.58) AC_CONFIG_SRCDIR([Source/Swig/swig.h]) AC_CONFIG_AUX_DIR([Tools/config]) From acc27451771bdaf62bb4c609813ae37c0e0eae0c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 26 Jun 2008 18:33:06 +0000 Subject: [PATCH 0053/1680] correct typo in first entry about %fragment git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10594 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 56b3b6b82..782849c6f 100644 --- a/CHANGES +++ b/CHANGES @@ -12279,7 +12279,8 @@ Version 1.3.14 (August 12, 2002) with helper functions even if they aren't used. To fix this, a new fragment directive is available. For example: - %fragment("type_helper","header") %{ + (corrected typo in line below - 06/26/2008) + %fragment("type_header","header") %{ void some_helper_function() { ... } From e5acd3b48a483fbedf2e0586516574afe9a4bc07 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 29 Jun 2008 00:19:05 +0000 Subject: [PATCH 0054/1680] fix some potential null pointer usage as reported by CoveriCoverity Prevent git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10607 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/allegrocl.cxx | 22 ++++++---- Source/Modules/ocaml.cxx | 82 +++++++++++++++++------------------- 2 files changed, 52 insertions(+), 52 deletions(-) diff --git a/Source/Modules/allegrocl.cxx b/Source/Modules/allegrocl.cxx index a968e506c..c1d271c57 100644 --- a/Source/Modules/allegrocl.cxx +++ b/Source/Modules/allegrocl.cxx @@ -2518,6 +2518,8 @@ int ALLEGROCL::functionWrapper(Node *n) { ParmList *parms = CopyParmList(Getattr(n, "parms")); Wrapper *f = NewWrapper(); + SwigType *t = Getattr(n, "type"); + String *name = Getattr(n, "name"); String *raw_return_type = Swig_typemap_lookup("ctype", n, "", 0); SwigType *return_type = Swig_cparse_type(raw_return_type); @@ -2556,7 +2558,7 @@ int ALLEGROCL::functionWrapper(Node *n) { if (Getattr(n, "overload:ignore")) { // if we're the last overload, make sure to force the emit // of the rest of the overloads before we leave. - Printf(stderr, "ignored overload %s(%x)\n", Getattr(n, "name"), Getattr(n, "sym:nextSibling")); + Printf(stderr, "ignored overload %s(%x)\n", name, Getattr(n, "sym:nextSibling")); if (!Getattr(n, "sym:nextSibling")) { update_package_if_needed(n); emit_buffered_defuns(n); @@ -2571,7 +2573,7 @@ int ALLEGROCL::functionWrapper(Node *n) { int gencomma = 0; #ifdef ALLEGROCL_DEBUG - Printf(stderr, "Walking parameters for %s '%s'\n", Getattr(n, "allegrocl:kind"), Getattr(n, "name")); + Printf(stderr, "Walking parameters for %s '%s'\n", Getattr(n, "allegrocl:kind"), name); #endif // Now walk the function parameter list and generate code to get arguments String *name_and_parms = NewStringf("%s (", mangled); @@ -2625,12 +2627,16 @@ int ALLEGROCL::functionWrapper(Node *n) { String *actioncode = emit_action(n); - String *result_convert = Swig_typemap_lookup_out("out", n, "result", f, actioncode); - Replaceall(result_convert, "$result", "lresult"); - Printf(f->code, "%s\n", result_convert); - Printf(f->code, " return lresult;\n"); - Delete(result_convert); - emit_return_variable(n, Getattr(n, "type"), f); + String *tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode); + if (tm) { + Replaceall(tm, "$result", "lresult"); + Printf(f->code, "%s\n", tm); + Printf(f->code, " return lresult;\n"); + Delete(tm); + } else { + Swig_warning(WARN_TYPEMAP_OUT_UNDEF, input_file, line_number, "Unable to use return type %s in function %s.\n", SwigType_str(t, 0), name); + } + emit_return_variable(n, t, f); if (CPlusPlus) { Printf(f->code, " } catch (...) {\n"); diff --git a/Source/Modules/ocaml.cxx b/Source/Modules/ocaml.cxx index 9f5677ba5..0d0f4c7f2 100755 --- a/Source/Modules/ocaml.cxx +++ b/Source/Modules/ocaml.cxx @@ -1292,56 +1292,50 @@ public: * which means looking up and registering by typedef and enum name. */ int enumDeclaration(Node *n) { String *name = Getattr(n, "name"); - String *oname = name ? NewString(name) : NULL; - /* name is now fully qualified */ - String *fully_qualified_name = NewString(name); - bool seen_enum = false; - if (name_qualifier) - Delete(name_qualifier); - char *strip_position; - name_qualifier = fully_qualify_enum_name(n, NewString("")); + if (name) { + String *oname = NewString(name); + /* name is now fully qualified */ + String *fully_qualified_name = NewString(name); + bool seen_enum = false; + if (name_qualifier) + Delete(name_qualifier); + char *strip_position; + name_qualifier = fully_qualify_enum_name(n, NewString("")); - /* Recent changes have distrubed enum and template naming again. - * Will try to keep it consistent by can't guarantee much given - * that these things move around a lot. - * - * I need to figure out a way to isolate this module better. - */ - if (oname) { strip_position = strstr(Char(oname), "::"); while (strip_position) { - strip_position += 2; - oname = NewString(strip_position); - strip_position = strstr(Char(oname), "::"); - } - } - - seen_enum = oname ? (Getattr(seen_enums, fully_qualified_name) ? true : false) : false; - - if (oname && !seen_enum) { - const_enum = true; - Printf(f_enum_to_int, "| `%s -> (match y with\n", oname); - Printf(f_int_to_enum, "| `%s -> C_enum (\n", oname); - /* * * * A note about enum name resolution * * * * - * This code should now work, but I think we can do a bit better. - * The problem I'm having is that swig isn't very precise about - * typedef name resolution. My opinion is that SwigType_typedef - * resolve_all should *always* return the enum tag if one exists, - * rather than the admittedly friendlier enclosing typedef. - * - * This would make one of the cases below unnecessary. - * * * */ - Printf(f_mlbody, "let _ = Callback.register \"%s_marker\" (`%s)\n", fully_qualified_name, oname); - if (!strncmp(Char(fully_qualified_name), "enum ", 5)) { - String *fq_noenum = NewString(Char(fully_qualified_name) + 5); - Printf(f_mlbody, - "let _ = Callback.register \"%s_marker\" (`%s)\n" "let _ = Callback.register \"%s_marker\" (`%s)\n", fq_noenum, oname, fq_noenum, name); + strip_position += 2; + oname = NewString(strip_position); + strip_position = strstr(Char(oname), "::"); } - Printf(f_enumtypes_type, "| `%s\n", oname); - Insert(fully_qualified_name, 0, "enum "); - Setattr(seen_enums, fully_qualified_name, n); + seen_enum = (Getattr(seen_enums, fully_qualified_name) ? true : false); + + if (!seen_enum) { + const_enum = true; + Printf(f_enum_to_int, "| `%s -> (match y with\n", oname); + Printf(f_int_to_enum, "| `%s -> C_enum (\n", oname); + /* * * * A note about enum name resolution * * * * + * This code should now work, but I think we can do a bit better. + * The problem I'm having is that swig isn't very precise about + * typedef name resolution. My opinion is that SwigType_typedef + * resolve_all should *always* return the enum tag if one exists, + * rather than the admittedly friendlier enclosing typedef. + * + * This would make one of the cases below unnecessary. + * * * */ + Printf(f_mlbody, "let _ = Callback.register \"%s_marker\" (`%s)\n", fully_qualified_name, oname); + if (!strncmp(Char(fully_qualified_name), "enum ", 5)) { + String *fq_noenum = NewString(Char(fully_qualified_name) + 5); + Printf(f_mlbody, + "let _ = Callback.register \"%s_marker\" (`%s)\n" "let _ = Callback.register \"%s_marker\" (`%s)\n", fq_noenum, oname, fq_noenum, name); + } + + Printf(f_enumtypes_type, "| `%s\n", oname); + Insert(fully_qualified_name, 0, "enum "); + Setattr(seen_enums, fully_qualified_name, n); + } } int ret = Language::enumDeclaration(n); From b02017c658568435b1665a3abecb9a85ebb0ce74 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 29 Jun 2008 00:50:27 +0000 Subject: [PATCH 0055/1680] fix potential null pointer usage as reported by Coverity Prevent git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10608 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/CParse/templ.c | 23 +++++++++++++---------- Source/Modules/csharp.cxx | 3 ++- Source/Swig/typesys.c | 2 +- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/Source/CParse/templ.c b/Source/CParse/templ.c index 8142125a7..a3e992f83 100644 --- a/Source/CParse/templ.c +++ b/Source/CParse/templ.c @@ -167,18 +167,21 @@ static int cparse_template_expand(Node *n, String *tname, String *rname, String add_parms(Getattr(n, "throws"), cpatchlist, typelist); } else if (Equal(nodeType, "destructor")) { String *name = Getattr(n, "name"); - if (name && strchr(Char(name), '<')) { - Append(patchlist, Getattr(n, "name")); - } else { - Append(name, templateargs); + if (name) { + if (strchr(Char(name), '<')) + Append(patchlist, Getattr(n, "name")); + else + Append(name, templateargs); } name = Getattr(n, "sym:name"); - if (name && strchr(Char(name), '<')) { - String *sn = Copy(tname); - Setattr(n, "sym:name", sn); - Delete(sn); - } else { - Replace(name, tname, rname, DOH_REPLACE_ANY); + if (name) { + if (strchr(Char(name), '<')) { + String *sn = Copy(tname); + Setattr(n, "sym:name", sn); + Delete(sn); + } else { + Replace(name, tname, rname, DOH_REPLACE_ANY); + } } /* Setattr(n,"sym:name",name); */ Append(cpatchlist, Getattr(n, "code")); diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index 7ea10170a..c802ad3a2 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -1998,7 +1998,8 @@ public: if (!(variable_wrapper_flag && i == 0)) { SwigType *pt = Getattr(p, "type"); String *param_type = NewString(""); - last_parm = p; + if (setter_flag) + last_parm = p; /* Get the C# parameter type */ if ((tm = Getattr(p, "tmap:cstype"))) { diff --git a/Source/Swig/typesys.c b/Source/Swig/typesys.c index ae6ab3dc8..a9e2898bd 100644 --- a/Source/Swig/typesys.c +++ b/Source/Swig/typesys.c @@ -847,7 +847,7 @@ SwigType *SwigType_typedef_qualified(SwigType *t) { String *result; int i, len; - if (t && strncmp(Char(t), "::", 2) == 0) { + if (strncmp(Char(t), "::", 2) == 0) { return Copy(t); } From 253e932816ef6b81f64ee635af3c47d72ad85651 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 29 Jun 2008 10:08:14 +0000 Subject: [PATCH 0056/1680] make life easier for svn status updates as everyone has different autotool versions installed - use svn:ignore on config.sub and config.guess git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10610 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Tools/config/config.guess | 1500 ---------------------------------- Tools/config/config.sub | 1616 ------------------------------------- 2 files changed, 3116 deletions(-) delete mode 100755 Tools/config/config.guess delete mode 100755 Tools/config/config.sub diff --git a/Tools/config/config.guess b/Tools/config/config.guess deleted file mode 100755 index 396482d6c..000000000 --- a/Tools/config/config.guess +++ /dev/null @@ -1,1500 +0,0 @@ -#! /bin/sh -# Attempt to guess a canonical system name. -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -# 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, -# Inc. - -timestamp='2006-07-02' - -# This file is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA -# 02110-1301, USA. -# -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - - -# Originally written by Per Bothner . -# Please send patches to . Submit a context -# diff and a properly formatted ChangeLog entry. -# -# This script attempts to guess a canonical system name similar to -# config.sub. If it succeeds, it prints the system name on stdout, and -# exits with 0. Otherwise, it exits with 1. -# -# The plan is that this can be called by configure scripts if you -# don't specify an explicit build system type. - -me=`echo "$0" | sed -e 's,.*/,,'` - -usage="\ -Usage: $0 [OPTION] - -Output the configuration name of the system \`$me' is run on. - -Operation modes: - -h, --help print this help, then exit - -t, --time-stamp print date of last modification, then exit - -v, --version print version number, then exit - -Report bugs and patches to ." - -version="\ -GNU config.guess ($timestamp) - -Originally written by Per Bothner. -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 -Free Software Foundation, Inc. - -This is free software; see the source for copying conditions. There is NO -warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." - -help=" -Try \`$me --help' for more information." - -# Parse command line -while test $# -gt 0 ; do - case $1 in - --time-stamp | --time* | -t ) - echo "$timestamp" ; exit ;; - --version | -v ) - echo "$version" ; exit ;; - --help | --h* | -h ) - echo "$usage"; exit ;; - -- ) # Stop option processing - shift; break ;; - - ) # Use stdin as input. - break ;; - -* ) - echo "$me: invalid option $1$help" >&2 - exit 1 ;; - * ) - break ;; - esac -done - -if test $# != 0; then - echo "$me: too many arguments$help" >&2 - exit 1 -fi - -trap 'exit 1' 1 2 15 - -# CC_FOR_BUILD -- compiler used by this script. Note that the use of a -# compiler to aid in system detection is discouraged as it requires -# temporary files to be created and, as you can see below, it is a -# headache to deal with in a portable fashion. - -# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still -# use `HOST_CC' if defined, but it is deprecated. - -# Portable tmp directory creation inspired by the Autoconf team. - -set_cc_for_build=' -trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; -trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; -: ${TMPDIR=/tmp} ; - { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || - { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || - { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || - { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; -dummy=$tmp/dummy ; -tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; -case $CC_FOR_BUILD,$HOST_CC,$CC in - ,,) echo "int x;" > $dummy.c ; - for c in cc gcc c89 c99 ; do - if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then - CC_FOR_BUILD="$c"; break ; - fi ; - done ; - if test x"$CC_FOR_BUILD" = x ; then - CC_FOR_BUILD=no_compiler_found ; - fi - ;; - ,,*) CC_FOR_BUILD=$CC ;; - ,*,*) CC_FOR_BUILD=$HOST_CC ;; -esac ; set_cc_for_build= ;' - -# This is needed to find uname on a Pyramid OSx when run in the BSD universe. -# (ghazi@noc.rutgers.edu 1994-08-24) -if (test -f /.attbin/uname) >/dev/null 2>&1 ; then - PATH=$PATH:/.attbin ; export PATH -fi - -UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown -UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown -UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown -UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown - -# Note: order is significant - the case branches are not exclusive. - -case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in - *:NetBSD:*:*) - # NetBSD (nbsd) targets should (where applicable) match one or - # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, - # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently - # switched to ELF, *-*-netbsd* would select the old - # object file format. This provides both forward - # compatibility and a consistent mechanism for selecting the - # object file format. - # - # Note: NetBSD doesn't particularly care about the vendor - # portion of the name. We always set it to "unknown". - sysctl="sysctl -n hw.machine_arch" - UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ - /usr/sbin/$sysctl 2>/dev/null || echo unknown)` - case "${UNAME_MACHINE_ARCH}" in - armeb) machine=armeb-unknown ;; - arm*) machine=arm-unknown ;; - sh3el) machine=shl-unknown ;; - sh3eb) machine=sh-unknown ;; - *) machine=${UNAME_MACHINE_ARCH}-unknown ;; - esac - # The Operating System including object format, if it has switched - # to ELF recently, or will in the future. - case "${UNAME_MACHINE_ARCH}" in - arm*|i386|m68k|ns32k|sh3*|sparc|vax) - eval $set_cc_for_build - if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ - | grep __ELF__ >/dev/null - then - # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). - # Return netbsd for either. FIX? - os=netbsd - else - os=netbsdelf - fi - ;; - *) - os=netbsd - ;; - esac - # The OS release - # Debian GNU/NetBSD machines have a different userland, and - # thus, need a distinct triplet. However, they do not need - # kernel version information, so it can be replaced with a - # suitable tag, in the style of linux-gnu. - case "${UNAME_VERSION}" in - Debian*) - release='-gnu' - ;; - *) - release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` - ;; - esac - # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: - # contains redundant information, the shorter form: - # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. - echo "${machine}-${os}${release}" - exit ;; - *:OpenBSD:*:*) - UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` - echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} - exit ;; - *:ekkoBSD:*:*) - echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} - exit ;; - *:SolidBSD:*:*) - echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} - exit ;; - macppc:MirBSD:*:*) - echo powerpc-unknown-mirbsd${UNAME_RELEASE} - exit ;; - *:MirBSD:*:*) - echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} - exit ;; - alpha:OSF1:*:*) - case $UNAME_RELEASE in - *4.0) - UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` - ;; - *5.*) - UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` - ;; - esac - # According to Compaq, /usr/sbin/psrinfo has been available on - # OSF/1 and Tru64 systems produced since 1995. I hope that - # covers most systems running today. This code pipes the CPU - # types through head -n 1, so we only detect the type of CPU 0. - ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` - case "$ALPHA_CPU_TYPE" in - "EV4 (21064)") - UNAME_MACHINE="alpha" ;; - "EV4.5 (21064)") - UNAME_MACHINE="alpha" ;; - "LCA4 (21066/21068)") - UNAME_MACHINE="alpha" ;; - "EV5 (21164)") - UNAME_MACHINE="alphaev5" ;; - "EV5.6 (21164A)") - UNAME_MACHINE="alphaev56" ;; - "EV5.6 (21164PC)") - UNAME_MACHINE="alphapca56" ;; - "EV5.7 (21164PC)") - UNAME_MACHINE="alphapca57" ;; - "EV6 (21264)") - UNAME_MACHINE="alphaev6" ;; - "EV6.7 (21264A)") - UNAME_MACHINE="alphaev67" ;; - "EV6.8CB (21264C)") - UNAME_MACHINE="alphaev68" ;; - "EV6.8AL (21264B)") - UNAME_MACHINE="alphaev68" ;; - "EV6.8CX (21264D)") - UNAME_MACHINE="alphaev68" ;; - "EV6.9A (21264/EV69A)") - UNAME_MACHINE="alphaev69" ;; - "EV7 (21364)") - UNAME_MACHINE="alphaev7" ;; - "EV7.9 (21364A)") - UNAME_MACHINE="alphaev79" ;; - esac - # A Pn.n version is a patched version. - # A Vn.n version is a released version. - # A Tn.n version is a released field test version. - # A Xn.n version is an unreleased experimental baselevel. - # 1.2 uses "1.2" for uname -r. - echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - exit ;; - Alpha\ *:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # Should we change UNAME_MACHINE based on the output of uname instead - # of the specific Alpha model? - echo alpha-pc-interix - exit ;; - 21064:Windows_NT:50:3) - echo alpha-dec-winnt3.5 - exit ;; - Amiga*:UNIX_System_V:4.0:*) - echo m68k-unknown-sysv4 - exit ;; - *:[Aa]miga[Oo][Ss]:*:*) - echo ${UNAME_MACHINE}-unknown-amigaos - exit ;; - *:[Mm]orph[Oo][Ss]:*:*) - echo ${UNAME_MACHINE}-unknown-morphos - exit ;; - *:OS/390:*:*) - echo i370-ibm-openedition - exit ;; - *:z/VM:*:*) - echo s390-ibm-zvmoe - exit ;; - *:OS400:*:*) - echo powerpc-ibm-os400 - exit ;; - arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) - echo arm-acorn-riscix${UNAME_RELEASE} - exit ;; - arm:riscos:*:*|arm:RISCOS:*:*) - echo arm-unknown-riscos - exit ;; - SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) - echo hppa1.1-hitachi-hiuxmpp - exit ;; - Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) - # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. - if test "`(/bin/universe) 2>/dev/null`" = att ; then - echo pyramid-pyramid-sysv3 - else - echo pyramid-pyramid-bsd - fi - exit ;; - NILE*:*:*:dcosx) - echo pyramid-pyramid-svr4 - exit ;; - DRS?6000:unix:4.0:6*) - echo sparc-icl-nx6 - exit ;; - DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) - case `/usr/bin/uname -p` in - sparc) echo sparc-icl-nx7; exit ;; - esac ;; - sun4H:SunOS:5.*:*) - echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) - echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - i86pc:SunOS:5.*:*) - echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - sun4*:SunOS:6*:*) - # According to config.sub, this is the proper way to canonicalize - # SunOS6. Hard to guess exactly what SunOS6 will be like, but - # it's likely to be more like Solaris than SunOS4. - echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - sun4*:SunOS:*:*) - case "`/usr/bin/arch -k`" in - Series*|S4*) - UNAME_RELEASE=`uname -v` - ;; - esac - # Japanese Language versions have a version number like `4.1.3-JL'. - echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` - exit ;; - sun3*:SunOS:*:*) - echo m68k-sun-sunos${UNAME_RELEASE} - exit ;; - sun*:*:4.2BSD:*) - UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` - test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 - case "`/bin/arch`" in - sun3) - echo m68k-sun-sunos${UNAME_RELEASE} - ;; - sun4) - echo sparc-sun-sunos${UNAME_RELEASE} - ;; - esac - exit ;; - aushp:SunOS:*:*) - echo sparc-auspex-sunos${UNAME_RELEASE} - exit ;; - # The situation for MiNT is a little confusing. The machine name - # can be virtually everything (everything which is not - # "atarist" or "atariste" at least should have a processor - # > m68000). The system name ranges from "MiNT" over "FreeMiNT" - # to the lowercase version "mint" (or "freemint"). Finally - # the system name "TOS" denotes a system which is actually not - # MiNT. But MiNT is downward compatible to TOS, so this should - # be no problem. - atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit ;; - atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit ;; - *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit ;; - milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) - echo m68k-milan-mint${UNAME_RELEASE} - exit ;; - hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) - echo m68k-hades-mint${UNAME_RELEASE} - exit ;; - *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) - echo m68k-unknown-mint${UNAME_RELEASE} - exit ;; - m68k:machten:*:*) - echo m68k-apple-machten${UNAME_RELEASE} - exit ;; - powerpc:machten:*:*) - echo powerpc-apple-machten${UNAME_RELEASE} - exit ;; - RISC*:Mach:*:*) - echo mips-dec-mach_bsd4.3 - exit ;; - RISC*:ULTRIX:*:*) - echo mips-dec-ultrix${UNAME_RELEASE} - exit ;; - VAX*:ULTRIX*:*:*) - echo vax-dec-ultrix${UNAME_RELEASE} - exit ;; - 2020:CLIX:*:* | 2430:CLIX:*:*) - echo clipper-intergraph-clix${UNAME_RELEASE} - exit ;; - mips:*:*:UMIPS | mips:*:*:RISCos) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c -#ifdef __cplusplus -#include /* for printf() prototype */ - int main (int argc, char *argv[]) { -#else - int main (argc, argv) int argc; char *argv[]; { -#endif - #if defined (host_mips) && defined (MIPSEB) - #if defined (SYSTYPE_SYSV) - printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); - #endif - #if defined (SYSTYPE_SVR4) - printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); - #endif - #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) - printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); - #endif - #endif - exit (-1); - } -EOF - $CC_FOR_BUILD -o $dummy $dummy.c && - dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && - SYSTEM_NAME=`$dummy $dummyarg` && - { echo "$SYSTEM_NAME"; exit; } - echo mips-mips-riscos${UNAME_RELEASE} - exit ;; - Motorola:PowerMAX_OS:*:*) - echo powerpc-motorola-powermax - exit ;; - Motorola:*:4.3:PL8-*) - echo powerpc-harris-powermax - exit ;; - Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) - echo powerpc-harris-powermax - exit ;; - Night_Hawk:Power_UNIX:*:*) - echo powerpc-harris-powerunix - exit ;; - m88k:CX/UX:7*:*) - echo m88k-harris-cxux7 - exit ;; - m88k:*:4*:R4*) - echo m88k-motorola-sysv4 - exit ;; - m88k:*:3*:R3*) - echo m88k-motorola-sysv3 - exit ;; - AViiON:dgux:*:*) - # DG/UX returns AViiON for all architectures - UNAME_PROCESSOR=`/usr/bin/uname -p` - if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] - then - if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ - [ ${TARGET_BINARY_INTERFACE}x = x ] - then - echo m88k-dg-dgux${UNAME_RELEASE} - else - echo m88k-dg-dguxbcs${UNAME_RELEASE} - fi - else - echo i586-dg-dgux${UNAME_RELEASE} - fi - exit ;; - M88*:DolphinOS:*:*) # DolphinOS (SVR3) - echo m88k-dolphin-sysv3 - exit ;; - M88*:*:R3*:*) - # Delta 88k system running SVR3 - echo m88k-motorola-sysv3 - exit ;; - XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) - echo m88k-tektronix-sysv3 - exit ;; - Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) - echo m68k-tektronix-bsd - exit ;; - *:IRIX*:*:*) - echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` - exit ;; - ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. - echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id - exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' - i*86:AIX:*:*) - echo i386-ibm-aix - exit ;; - ia64:AIX:*:*) - if [ -x /usr/bin/oslevel ] ; then - IBM_REV=`/usr/bin/oslevel` - else - IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} - fi - echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} - exit ;; - *:AIX:2:3) - if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #include - - main() - { - if (!__power_pc()) - exit(1); - puts("powerpc-ibm-aix3.2.5"); - exit(0); - } -EOF - if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` - then - echo "$SYSTEM_NAME" - else - echo rs6000-ibm-aix3.2.5 - fi - elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then - echo rs6000-ibm-aix3.2.4 - else - echo rs6000-ibm-aix3.2 - fi - exit ;; - *:AIX:*:[45]) - IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` - if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then - IBM_ARCH=rs6000 - else - IBM_ARCH=powerpc - fi - if [ -x /usr/bin/oslevel ] ; then - IBM_REV=`/usr/bin/oslevel` - else - IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} - fi - echo ${IBM_ARCH}-ibm-aix${IBM_REV} - exit ;; - *:AIX:*:*) - echo rs6000-ibm-aix - exit ;; - ibmrt:4.4BSD:*|romp-ibm:BSD:*) - echo romp-ibm-bsd4.4 - exit ;; - ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and - echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to - exit ;; # report: romp-ibm BSD 4.3 - *:BOSX:*:*) - echo rs6000-bull-bosx - exit ;; - DPX/2?00:B.O.S.:*:*) - echo m68k-bull-sysv3 - exit ;; - 9000/[34]??:4.3bsd:1.*:*) - echo m68k-hp-bsd - exit ;; - hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) - echo m68k-hp-bsd4.4 - exit ;; - 9000/[34678]??:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - case "${UNAME_MACHINE}" in - 9000/31? ) HP_ARCH=m68000 ;; - 9000/[34]?? ) HP_ARCH=m68k ;; - 9000/[678][0-9][0-9]) - if [ -x /usr/bin/getconf ]; then - sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` - sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` - case "${sc_cpu_version}" in - 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 - 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 - 532) # CPU_PA_RISC2_0 - case "${sc_kernel_bits}" in - 32) HP_ARCH="hppa2.0n" ;; - 64) HP_ARCH="hppa2.0w" ;; - '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 - esac ;; - esac - fi - if [ "${HP_ARCH}" = "" ]; then - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - - #define _HPUX_SOURCE - #include - #include - - int main () - { - #if defined(_SC_KERNEL_BITS) - long bits = sysconf(_SC_KERNEL_BITS); - #endif - long cpu = sysconf (_SC_CPU_VERSION); - - switch (cpu) - { - case CPU_PA_RISC1_0: puts ("hppa1.0"); break; - case CPU_PA_RISC1_1: puts ("hppa1.1"); break; - case CPU_PA_RISC2_0: - #if defined(_SC_KERNEL_BITS) - switch (bits) - { - case 64: puts ("hppa2.0w"); break; - case 32: puts ("hppa2.0n"); break; - default: puts ("hppa2.0"); break; - } break; - #else /* !defined(_SC_KERNEL_BITS) */ - puts ("hppa2.0"); break; - #endif - default: puts ("hppa1.0"); break; - } - exit (0); - } -EOF - (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` - test -z "$HP_ARCH" && HP_ARCH=hppa - fi ;; - esac - if [ ${HP_ARCH} = "hppa2.0w" ] - then - eval $set_cc_for_build - - # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating - # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler - # generating 64-bit code. GNU and HP use different nomenclature: - # - # $ CC_FOR_BUILD=cc ./config.guess - # => hppa2.0w-hp-hpux11.23 - # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess - # => hppa64-hp-hpux11.23 - - if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | - grep __LP64__ >/dev/null - then - HP_ARCH="hppa2.0w" - else - HP_ARCH="hppa64" - fi - fi - echo ${HP_ARCH}-hp-hpux${HPUX_REV} - exit ;; - ia64:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - echo ia64-hp-hpux${HPUX_REV} - exit ;; - 3050*:HI-UX:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #include - int - main () - { - long cpu = sysconf (_SC_CPU_VERSION); - /* The order matters, because CPU_IS_HP_MC68K erroneously returns - true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct - results, however. */ - if (CPU_IS_PA_RISC (cpu)) - { - switch (cpu) - { - case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; - case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; - case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; - default: puts ("hppa-hitachi-hiuxwe2"); break; - } - } - else if (CPU_IS_HP_MC68K (cpu)) - puts ("m68k-hitachi-hiuxwe2"); - else puts ("unknown-hitachi-hiuxwe2"); - exit (0); - } -EOF - $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && - { echo "$SYSTEM_NAME"; exit; } - echo unknown-hitachi-hiuxwe2 - exit ;; - 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) - echo hppa1.1-hp-bsd - exit ;; - 9000/8??:4.3bsd:*:*) - echo hppa1.0-hp-bsd - exit ;; - *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) - echo hppa1.0-hp-mpeix - exit ;; - hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) - echo hppa1.1-hp-osf - exit ;; - hp8??:OSF1:*:*) - echo hppa1.0-hp-osf - exit ;; - i*86:OSF1:*:*) - if [ -x /usr/sbin/sysversion ] ; then - echo ${UNAME_MACHINE}-unknown-osf1mk - else - echo ${UNAME_MACHINE}-unknown-osf1 - fi - exit ;; - parisc*:Lites*:*:*) - echo hppa1.1-hp-lites - exit ;; - C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) - echo c1-convex-bsd - exit ;; - C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) - if getsysinfo -f scalar_acc - then echo c32-convex-bsd - else echo c2-convex-bsd - fi - exit ;; - C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) - echo c34-convex-bsd - exit ;; - C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) - echo c38-convex-bsd - exit ;; - C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) - echo c4-convex-bsd - exit ;; - CRAY*Y-MP:*:*:*) - echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; - CRAY*[A-Z]90:*:*:*) - echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ - | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ - -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ - -e 's/\.[^.]*$/.X/' - exit ;; - CRAY*TS:*:*:*) - echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; - CRAY*T3E:*:*:*) - echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; - CRAY*SV1:*:*:*) - echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; - *:UNICOS/mp:*:*) - echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; - F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) - FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` - echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" - exit ;; - 5000:UNIX_System_V:4.*:*) - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` - echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" - exit ;; - i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) - echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} - exit ;; - sparc*:BSD/OS:*:*) - echo sparc-unknown-bsdi${UNAME_RELEASE} - exit ;; - *:BSD/OS:*:*) - echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} - exit ;; - *:FreeBSD:*:*) - case ${UNAME_MACHINE} in - pc98) - echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; - amd64) - echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; - *) - echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; - esac - exit ;; - i*:CYGWIN*:*) - echo ${UNAME_MACHINE}-pc-cygwin - exit ;; - i*:MINGW*:*) - echo ${UNAME_MACHINE}-pc-mingw32 - exit ;; - i*:windows32*:*) - # uname -m includes "-pc" on this system. - echo ${UNAME_MACHINE}-mingw32 - exit ;; - i*:PW*:*) - echo ${UNAME_MACHINE}-pc-pw32 - exit ;; - x86:Interix*:[3456]*) - echo i586-pc-interix${UNAME_RELEASE} - exit ;; - EM64T:Interix*:[3456]*) - echo x86_64-unknown-interix${UNAME_RELEASE} - exit ;; - [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) - echo i${UNAME_MACHINE}-pc-mks - exit ;; - i*:Windows_NT*:* | Pentium*:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we - # UNAME_MACHINE based on the output of uname instead of i386? - echo i586-pc-interix - exit ;; - i*:UWIN*:*) - echo ${UNAME_MACHINE}-pc-uwin - exit ;; - amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) - echo x86_64-unknown-cygwin - exit ;; - p*:CYGWIN*:*) - echo powerpcle-unknown-cygwin - exit ;; - prep*:SunOS:5.*:*) - echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - *:GNU:*:*) - # the GNU system - echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` - exit ;; - *:GNU/*:*:*) - # other systems with GNU libc and userland - echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu - exit ;; - i*86:Minix:*:*) - echo ${UNAME_MACHINE}-pc-minix - exit ;; - arm*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; - avr32*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; - cris:Linux:*:*) - echo cris-axis-linux-gnu - exit ;; - crisv32:Linux:*:*) - echo crisv32-axis-linux-gnu - exit ;; - frv:Linux:*:*) - echo frv-unknown-linux-gnu - exit ;; - ia64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; - m32r*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; - m68*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; - mips:Linux:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #undef CPU - #undef mips - #undef mipsel - #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) - CPU=mipsel - #else - #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) - CPU=mips - #else - CPU= - #endif - #endif -EOF - eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' - /^CPU/{ - s: ::g - p - }'`" - test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } - ;; - mips64:Linux:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #undef CPU - #undef mips64 - #undef mips64el - #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) - CPU=mips64el - #else - #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) - CPU=mips64 - #else - CPU= - #endif - #endif -EOF - eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' - /^CPU/{ - s: ::g - p - }'`" - test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } - ;; - or32:Linux:*:*) - echo or32-unknown-linux-gnu - exit ;; - ppc:Linux:*:*) - echo powerpc-unknown-linux-gnu - exit ;; - ppc64:Linux:*:*) - echo powerpc64-unknown-linux-gnu - exit ;; - alpha:Linux:*:*) - case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in - EV5) UNAME_MACHINE=alphaev5 ;; - EV56) UNAME_MACHINE=alphaev56 ;; - PCA56) UNAME_MACHINE=alphapca56 ;; - PCA57) UNAME_MACHINE=alphapca56 ;; - EV6) UNAME_MACHINE=alphaev6 ;; - EV67) UNAME_MACHINE=alphaev67 ;; - EV68*) UNAME_MACHINE=alphaev68 ;; - esac - objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null - if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi - echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} - exit ;; - parisc:Linux:*:* | hppa:Linux:*:*) - # Look for CPU level - case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in - PA7*) echo hppa1.1-unknown-linux-gnu ;; - PA8*) echo hppa2.0-unknown-linux-gnu ;; - *) echo hppa-unknown-linux-gnu ;; - esac - exit ;; - parisc64:Linux:*:* | hppa64:Linux:*:*) - echo hppa64-unknown-linux-gnu - exit ;; - s390:Linux:*:* | s390x:Linux:*:*) - echo ${UNAME_MACHINE}-ibm-linux - exit ;; - sh64*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; - sh*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; - sparc:Linux:*:* | sparc64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; - vax:Linux:*:*) - echo ${UNAME_MACHINE}-dec-linux-gnu - exit ;; - x86_64:Linux:*:*) - echo x86_64-unknown-linux-gnu - exit ;; - i*86:Linux:*:*) - # The BFD linker knows what the default object file format is, so - # first see if it will tell us. cd to the root directory to prevent - # problems with other programs or directories called `ld' in the path. - # Set LC_ALL=C to ensure ld outputs messages in English. - ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \ - | sed -ne '/supported targets:/!d - s/[ ][ ]*/ /g - s/.*supported targets: *// - s/ .*// - p'` - case "$ld_supported_targets" in - elf32-i386) - TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu" - ;; - a.out-i386-linux) - echo "${UNAME_MACHINE}-pc-linux-gnuaout" - exit ;; - coff-i386) - echo "${UNAME_MACHINE}-pc-linux-gnucoff" - exit ;; - "") - # Either a pre-BFD a.out linker (linux-gnuoldld) or - # one that does not give us useful --help. - echo "${UNAME_MACHINE}-pc-linux-gnuoldld" - exit ;; - esac - # Determine whether the default compiler is a.out or elf - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #include - #ifdef __ELF__ - # ifdef __GLIBC__ - # if __GLIBC__ >= 2 - LIBC=gnu - # else - LIBC=gnulibc1 - # endif - # else - LIBC=gnulibc1 - # endif - #else - #if defined(__INTEL_COMPILER) || defined(__PGI) || defined(__SUNPRO_C) || defined(__SUNPRO_CC) - LIBC=gnu - #else - LIBC=gnuaout - #endif - #endif - #ifdef __dietlibc__ - LIBC=dietlibc - #endif -EOF - eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' - /^LIBC/{ - s: ::g - p - }'`" - test x"${LIBC}" != x && { - echo "${UNAME_MACHINE}-pc-linux-${LIBC}" - exit - } - test x"${TENTATIVE}" != x && { echo "${TENTATIVE}"; exit; } - ;; - i*86:DYNIX/ptx:4*:*) - # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. - # earlier versions are messed up and put the nodename in both - # sysname and nodename. - echo i386-sequent-sysv4 - exit ;; - i*86:UNIX_SV:4.2MP:2.*) - # Unixware is an offshoot of SVR4, but it has its own version - # number series starting with 2... - # I am not positive that other SVR4 systems won't match this, - # I just have to hope. -- rms. - # Use sysv4.2uw... so that sysv4* matches it. - echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} - exit ;; - i*86:OS/2:*:*) - # If we were able to find `uname', then EMX Unix compatibility - # is probably installed. - echo ${UNAME_MACHINE}-pc-os2-emx - exit ;; - i*86:XTS-300:*:STOP) - echo ${UNAME_MACHINE}-unknown-stop - exit ;; - i*86:atheos:*:*) - echo ${UNAME_MACHINE}-unknown-atheos - exit ;; - i*86:syllable:*:*) - echo ${UNAME_MACHINE}-pc-syllable - exit ;; - i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) - echo i386-unknown-lynxos${UNAME_RELEASE} - exit ;; - i*86:*DOS:*:*) - echo ${UNAME_MACHINE}-pc-msdosdjgpp - exit ;; - i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) - UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` - if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then - echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} - else - echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} - fi - exit ;; - i*86:*:5:[678]*) - # UnixWare 7.x, OpenUNIX and OpenServer 6. - case `/bin/uname -X | grep "^Machine"` in - *486*) UNAME_MACHINE=i486 ;; - *Pentium) UNAME_MACHINE=i586 ;; - *Pent*|*Celeron) UNAME_MACHINE=i686 ;; - esac - echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} - exit ;; - i*86:*:3.2:*) - if test -f /usr/options/cb.name; then - UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then - UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` - (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 - (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ - && UNAME_MACHINE=i586 - (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ - && UNAME_MACHINE=i686 - (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ - && UNAME_MACHINE=i686 - echo ${UNAME_MACHINE}-pc-sco$UNAME_REL - else - echo ${UNAME_MACHINE}-pc-sysv32 - fi - exit ;; - pc:*:*:*) - # Left here for compatibility: - # uname -m prints for DJGPP always 'pc', but it prints nothing about - # the processor, so we play safe by assuming i386. - echo i386-pc-msdosdjgpp - exit ;; - Intel:Mach:3*:*) - echo i386-pc-mach3 - exit ;; - paragon:*:*:*) - echo i860-intel-osf1 - exit ;; - i860:*:4.*:*) # i860-SVR4 - if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then - echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 - else # Add other i860-SVR4 vendors below as they are discovered. - echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 - fi - exit ;; - mini*:CTIX:SYS*5:*) - # "miniframe" - echo m68010-convergent-sysv - exit ;; - mc68k:UNIX:SYSTEM5:3.51m) - echo m68k-convergent-sysv - exit ;; - M680?0:D-NIX:5.3:*) - echo m68k-diab-dnix - exit ;; - M68*:*:R3V[5678]*:*) - test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; - 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) - OS_REL='' - test -r /etc/.relid \ - && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4.3${OS_REL}; exit; } - /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; - 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4; exit; } ;; - m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) - echo m68k-unknown-lynxos${UNAME_RELEASE} - exit ;; - mc68030:UNIX_System_V:4.*:*) - echo m68k-atari-sysv4 - exit ;; - TSUNAMI:LynxOS:2.*:*) - echo sparc-unknown-lynxos${UNAME_RELEASE} - exit ;; - rs6000:LynxOS:2.*:*) - echo rs6000-unknown-lynxos${UNAME_RELEASE} - exit ;; - PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*) - echo powerpc-unknown-lynxos${UNAME_RELEASE} - exit ;; - SM[BE]S:UNIX_SV:*:*) - echo mips-dde-sysv${UNAME_RELEASE} - exit ;; - RM*:ReliantUNIX-*:*:*) - echo mips-sni-sysv4 - exit ;; - RM*:SINIX-*:*:*) - echo mips-sni-sysv4 - exit ;; - *:SINIX-*:*:*) - if uname -p 2>/dev/null >/dev/null ; then - UNAME_MACHINE=`(uname -p) 2>/dev/null` - echo ${UNAME_MACHINE}-sni-sysv4 - else - echo ns32k-sni-sysv - fi - exit ;; - PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort - # says - echo i586-unisys-sysv4 - exit ;; - *:UNIX_System_V:4*:FTX*) - # From Gerald Hewes . - # How about differentiating between stratus architectures? -djm - echo hppa1.1-stratus-sysv4 - exit ;; - *:*:*:FTX*) - # From seanf@swdc.stratus.com. - echo i860-stratus-sysv4 - exit ;; - i*86:VOS:*:*) - # From Paul.Green@stratus.com. - echo ${UNAME_MACHINE}-stratus-vos - exit ;; - *:VOS:*:*) - # From Paul.Green@stratus.com. - echo hppa1.1-stratus-vos - exit ;; - mc68*:A/UX:*:*) - echo m68k-apple-aux${UNAME_RELEASE} - exit ;; - news*:NEWS-OS:6*:*) - echo mips-sony-newsos6 - exit ;; - R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) - if [ -d /usr/nec ]; then - echo mips-nec-sysv${UNAME_RELEASE} - else - echo mips-unknown-sysv${UNAME_RELEASE} - fi - exit ;; - BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. - echo powerpc-be-beos - exit ;; - BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. - echo powerpc-apple-beos - exit ;; - BePC:BeOS:*:*) # BeOS running on Intel PC compatible. - echo i586-pc-beos - exit ;; - SX-4:SUPER-UX:*:*) - echo sx4-nec-superux${UNAME_RELEASE} - exit ;; - SX-5:SUPER-UX:*:*) - echo sx5-nec-superux${UNAME_RELEASE} - exit ;; - SX-6:SUPER-UX:*:*) - echo sx6-nec-superux${UNAME_RELEASE} - exit ;; - Power*:Rhapsody:*:*) - echo powerpc-apple-rhapsody${UNAME_RELEASE} - exit ;; - *:Rhapsody:*:*) - echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} - exit ;; - *:Darwin:*:*) - UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown - case $UNAME_PROCESSOR in - unknown) UNAME_PROCESSOR=powerpc ;; - esac - echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} - exit ;; - *:procnto*:*:* | *:QNX:[0123456789]*:*) - UNAME_PROCESSOR=`uname -p` - if test "$UNAME_PROCESSOR" = "x86"; then - UNAME_PROCESSOR=i386 - UNAME_MACHINE=pc - fi - echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} - exit ;; - *:QNX:*:4*) - echo i386-pc-qnx - exit ;; - NSE-?:NONSTOP_KERNEL:*:*) - echo nse-tandem-nsk${UNAME_RELEASE} - exit ;; - NSR-?:NONSTOP_KERNEL:*:*) - echo nsr-tandem-nsk${UNAME_RELEASE} - exit ;; - *:NonStop-UX:*:*) - echo mips-compaq-nonstopux - exit ;; - BS2000:POSIX*:*:*) - echo bs2000-siemens-sysv - exit ;; - DS/*:UNIX_System_V:*:*) - echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} - exit ;; - *:Plan9:*:*) - # "uname -m" is not consistent, so use $cputype instead. 386 - # is converted to i386 for consistency with other x86 - # operating systems. - if test "$cputype" = "386"; then - UNAME_MACHINE=i386 - else - UNAME_MACHINE="$cputype" - fi - echo ${UNAME_MACHINE}-unknown-plan9 - exit ;; - *:TOPS-10:*:*) - echo pdp10-unknown-tops10 - exit ;; - *:TENEX:*:*) - echo pdp10-unknown-tenex - exit ;; - KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) - echo pdp10-dec-tops20 - exit ;; - XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) - echo pdp10-xkl-tops20 - exit ;; - *:TOPS-20:*:*) - echo pdp10-unknown-tops20 - exit ;; - *:ITS:*:*) - echo pdp10-unknown-its - exit ;; - SEI:*:*:SEIUX) - echo mips-sei-seiux${UNAME_RELEASE} - exit ;; - *:DragonFly:*:*) - echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` - exit ;; - *:*VMS:*:*) - UNAME_MACHINE=`(uname -p) 2>/dev/null` - case "${UNAME_MACHINE}" in - A*) echo alpha-dec-vms ; exit ;; - I*) echo ia64-dec-vms ; exit ;; - V*) echo vax-dec-vms ; exit ;; - esac ;; - *:XENIX:*:SysV) - echo i386-pc-xenix - exit ;; - i*86:skyos:*:*) - echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' - exit ;; - i*86:rdos:*:*) - echo ${UNAME_MACHINE}-pc-rdos - exit ;; -esac - -#echo '(No uname command or uname output not recognized.)' 1>&2 -#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 - -eval $set_cc_for_build -cat >$dummy.c < -# include -#endif -main () -{ -#if defined (sony) -#if defined (MIPSEB) - /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, - I don't know.... */ - printf ("mips-sony-bsd\n"); exit (0); -#else -#include - printf ("m68k-sony-newsos%s\n", -#ifdef NEWSOS4 - "4" -#else - "" -#endif - ); exit (0); -#endif -#endif - -#if defined (__arm) && defined (__acorn) && defined (__unix) - printf ("arm-acorn-riscix\n"); exit (0); -#endif - -#if defined (hp300) && !defined (hpux) - printf ("m68k-hp-bsd\n"); exit (0); -#endif - -#if defined (NeXT) -#if !defined (__ARCHITECTURE__) -#define __ARCHITECTURE__ "m68k" -#endif - int version; - version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; - if (version < 4) - printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); - else - printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); - exit (0); -#endif - -#if defined (MULTIMAX) || defined (n16) -#if defined (UMAXV) - printf ("ns32k-encore-sysv\n"); exit (0); -#else -#if defined (CMU) - printf ("ns32k-encore-mach\n"); exit (0); -#else - printf ("ns32k-encore-bsd\n"); exit (0); -#endif -#endif -#endif - -#if defined (__386BSD__) - printf ("i386-pc-bsd\n"); exit (0); -#endif - -#if defined (sequent) -#if defined (i386) - printf ("i386-sequent-dynix\n"); exit (0); -#endif -#if defined (ns32000) - printf ("ns32k-sequent-dynix\n"); exit (0); -#endif -#endif - -#if defined (_SEQUENT_) - struct utsname un; - - uname(&un); - - if (strncmp(un.version, "V2", 2) == 0) { - printf ("i386-sequent-ptx2\n"); exit (0); - } - if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ - printf ("i386-sequent-ptx1\n"); exit (0); - } - printf ("i386-sequent-ptx\n"); exit (0); - -#endif - -#if defined (vax) -# if !defined (ultrix) -# include -# if defined (BSD) -# if BSD == 43 - printf ("vax-dec-bsd4.3\n"); exit (0); -# else -# if BSD == 199006 - printf ("vax-dec-bsd4.3reno\n"); exit (0); -# else - printf ("vax-dec-bsd\n"); exit (0); -# endif -# endif -# else - printf ("vax-dec-bsd\n"); exit (0); -# endif -# else - printf ("vax-dec-ultrix\n"); exit (0); -# endif -#endif - -#if defined (alliant) && defined (i860) - printf ("i860-alliant-bsd\n"); exit (0); -#endif - - exit (1); -} -EOF - -$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` && - { echo "$SYSTEM_NAME"; exit; } - -# Apollos put the system type in the environment. - -test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; } - -# Convex versions that predate uname can use getsysinfo(1) - -if [ -x /usr/convex/getsysinfo ] -then - case `getsysinfo -f cpu_type` in - c1*) - echo c1-convex-bsd - exit ;; - c2*) - if getsysinfo -f scalar_acc - then echo c32-convex-bsd - else echo c2-convex-bsd - fi - exit ;; - c34*) - echo c34-convex-bsd - exit ;; - c38*) - echo c38-convex-bsd - exit ;; - c4*) - echo c4-convex-bsd - exit ;; - esac -fi - -cat >&2 < in order to provide the needed -information to handle your system. - -config.guess timestamp = $timestamp - -uname -m = `(uname -m) 2>/dev/null || echo unknown` -uname -r = `(uname -r) 2>/dev/null || echo unknown` -uname -s = `(uname -s) 2>/dev/null || echo unknown` -uname -v = `(uname -v) 2>/dev/null || echo unknown` - -/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` -/bin/uname -X = `(/bin/uname -X) 2>/dev/null` - -hostinfo = `(hostinfo) 2>/dev/null` -/bin/universe = `(/bin/universe) 2>/dev/null` -/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` -/bin/arch = `(/bin/arch) 2>/dev/null` -/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` -/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` - -UNAME_MACHINE = ${UNAME_MACHINE} -UNAME_RELEASE = ${UNAME_RELEASE} -UNAME_SYSTEM = ${UNAME_SYSTEM} -UNAME_VERSION = ${UNAME_VERSION} -EOF - -exit 1 - -# Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "timestamp='" -# time-stamp-format: "%:y-%02m-%02d" -# time-stamp-end: "'" -# End: diff --git a/Tools/config/config.sub b/Tools/config/config.sub deleted file mode 100755 index fab0aa355..000000000 --- a/Tools/config/config.sub +++ /dev/null @@ -1,1616 +0,0 @@ -#! /bin/sh -# Configuration validation subroutine script. -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -# 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, -# Inc. - -timestamp='2006-09-20' - -# This file is (in principle) common to ALL GNU software. -# The presence of a machine in this file suggests that SOME GNU software -# can handle that machine. It does not imply ALL GNU software can. -# -# This file is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA -# 02110-1301, USA. -# -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - - -# Please send patches to . Submit a context -# diff and a properly formatted ChangeLog entry. -# -# Configuration subroutine to validate and canonicalize a configuration type. -# Supply the specified configuration type as an argument. -# If it is invalid, we print an error message on stderr and exit with code 1. -# Otherwise, we print the canonical config type on stdout and succeed. - -# This file is supposed to be the same for all GNU packages -# and recognize all the CPU types, system types and aliases -# that are meaningful with *any* GNU software. -# Each package is responsible for reporting which valid configurations -# it does not support. The user should be able to distinguish -# a failure to support a valid configuration from a meaningless -# configuration. - -# The goal of this file is to map all the various variations of a given -# machine specification into a single specification in the form: -# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM -# or in some cases, the newer four-part form: -# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM -# It is wrong to echo any other type of specification. - -me=`echo "$0" | sed -e 's,.*/,,'` - -usage="\ -Usage: $0 [OPTION] CPU-MFR-OPSYS - $0 [OPTION] ALIAS - -Canonicalize a configuration name. - -Operation modes: - -h, --help print this help, then exit - -t, --time-stamp print date of last modification, then exit - -v, --version print version number, then exit - -Report bugs and patches to ." - -version="\ -GNU config.sub ($timestamp) - -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 -Free Software Foundation, Inc. - -This is free software; see the source for copying conditions. There is NO -warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." - -help=" -Try \`$me --help' for more information." - -# Parse command line -while test $# -gt 0 ; do - case $1 in - --time-stamp | --time* | -t ) - echo "$timestamp" ; exit ;; - --version | -v ) - echo "$version" ; exit ;; - --help | --h* | -h ) - echo "$usage"; exit ;; - -- ) # Stop option processing - shift; break ;; - - ) # Use stdin as input. - break ;; - -* ) - echo "$me: invalid option $1$help" - exit 1 ;; - - *local*) - # First pass through any local machine types. - echo $1 - exit ;; - - * ) - break ;; - esac -done - -case $# in - 0) echo "$me: missing argument$help" >&2 - exit 1;; - 1) ;; - *) echo "$me: too many arguments$help" >&2 - exit 1;; -esac - -# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). -# Here we must recognize all the valid KERNEL-OS combinations. -maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` -case $maybe_os in - nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \ - uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \ - storm-chaos* | os2-emx* | rtmk-nova*) - os=-$maybe_os - basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` - ;; - *) - basic_machine=`echo $1 | sed 's/-[^-]*$//'` - if [ $basic_machine != $1 ] - then os=`echo $1 | sed 's/.*-/-/'` - else os=; fi - ;; -esac - -### Let's recognize common machines as not being operating systems so -### that things like config.sub decstation-3100 work. We also -### recognize some manufacturers as not being operating systems, so we -### can provide default operating systems below. -case $os in - -sun*os*) - # Prevent following clause from handling this invalid input. - ;; - -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ - -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ - -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ - -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ - -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ - -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ - -apple | -axis | -knuth | -cray) - os= - basic_machine=$1 - ;; - -sim | -cisco | -oki | -wec | -winbond) - os= - basic_machine=$1 - ;; - -scout) - ;; - -wrs) - os=-vxworks - basic_machine=$1 - ;; - -chorusos*) - os=-chorusos - basic_machine=$1 - ;; - -chorusrdb) - os=-chorusrdb - basic_machine=$1 - ;; - -hiux*) - os=-hiuxwe2 - ;; - -sco6) - os=-sco5v6 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco5) - os=-sco3.2v5 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco4) - os=-sco3.2v4 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco3.2.[4-9]*) - os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco3.2v[4-9]*) - # Don't forget version if it is 3.2v4 or newer. - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco5v6*) - # Don't forget version if it is 3.2v4 or newer. - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco*) - os=-sco3.2v2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -udk*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -isc) - os=-isc2.2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -clix*) - basic_machine=clipper-intergraph - ;; - -isc*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -lynx*) - os=-lynxos - ;; - -ptx*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` - ;; - -windowsnt*) - os=`echo $os | sed -e 's/windowsnt/winnt/'` - ;; - -psos*) - os=-psos - ;; - -mint | -mint[0-9]*) - basic_machine=m68k-atari - os=-mint - ;; -esac - -# Decode aliases for certain CPU-COMPANY combinations. -case $basic_machine in - # Recognize the basic CPU types without company name. - # Some are omitted here because they have special meanings below. - 1750a | 580 \ - | a29k \ - | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ - | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ - | am33_2.0 \ - | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \ - | bfin \ - | c4x | clipper \ - | d10v | d30v | dlx | dsp16xx \ - | fr30 | frv \ - | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ - | i370 | i860 | i960 | ia64 \ - | ip2k | iq2000 \ - | m32c | m32r | m32rle | m68000 | m68k | m88k \ - | maxq | mb | microblaze | mcore \ - | mips | mipsbe | mipseb | mipsel | mipsle \ - | mips16 \ - | mips64 | mips64el \ - | mips64vr | mips64vrel \ - | mips64orion | mips64orionel \ - | mips64vr4100 | mips64vr4100el \ - | mips64vr4300 | mips64vr4300el \ - | mips64vr5000 | mips64vr5000el \ - | mips64vr5900 | mips64vr5900el \ - | mipsisa32 | mipsisa32el \ - | mipsisa32r2 | mipsisa32r2el \ - | mipsisa64 | mipsisa64el \ - | mipsisa64r2 | mipsisa64r2el \ - | mipsisa64sb1 | mipsisa64sb1el \ - | mipsisa64sr71k | mipsisa64sr71kel \ - | mipstx39 | mipstx39el \ - | mn10200 | mn10300 \ - | mt \ - | msp430 \ - | nios | nios2 \ - | ns16k | ns32k \ - | or32 \ - | pdp10 | pdp11 | pj | pjl \ - | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ - | pyramid \ - | score \ - | sh | sh[1234] | sh[24]a | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ - | sh64 | sh64le \ - | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ - | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ - | spu | strongarm \ - | tahoe | thumb | tic4x | tic80 | tron \ - | v850 | v850e \ - | we32k \ - | x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \ - | z8k) - basic_machine=$basic_machine-unknown - ;; - m6811 | m68hc11 | m6812 | m68hc12) - # Motorola 68HC11/12. - basic_machine=$basic_machine-unknown - os=-none - ;; - m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) - ;; - ms1) - basic_machine=mt-unknown - ;; - - # We use `pc' rather than `unknown' - # because (1) that's what they normally are, and - # (2) the word "unknown" tends to confuse beginning users. - i*86 | x86_64) - basic_machine=$basic_machine-pc - ;; - # Object if more than one company name word. - *-*-*) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 - exit 1 - ;; - # Recognize the basic CPU types with company name. - 580-* \ - | a29k-* \ - | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ - | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ - | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ - | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ - | avr-* | avr32-* \ - | bfin-* | bs2000-* \ - | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \ - | clipper-* | craynv-* | cydra-* \ - | d10v-* | d30v-* | dlx-* \ - | elxsi-* \ - | f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \ - | h8300-* | h8500-* \ - | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ - | i*86-* | i860-* | i960-* | ia64-* \ - | ip2k-* | iq2000-* \ - | m32c-* | m32r-* | m32rle-* \ - | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ - | m88110-* | m88k-* | maxq-* | mcore-* \ - | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ - | mips16-* \ - | mips64-* | mips64el-* \ - | mips64vr-* | mips64vrel-* \ - | mips64orion-* | mips64orionel-* \ - | mips64vr4100-* | mips64vr4100el-* \ - | mips64vr4300-* | mips64vr4300el-* \ - | mips64vr5000-* | mips64vr5000el-* \ - | mips64vr5900-* | mips64vr5900el-* \ - | mipsisa32-* | mipsisa32el-* \ - | mipsisa32r2-* | mipsisa32r2el-* \ - | mipsisa64-* | mipsisa64el-* \ - | mipsisa64r2-* | mipsisa64r2el-* \ - | mipsisa64sb1-* | mipsisa64sb1el-* \ - | mipsisa64sr71k-* | mipsisa64sr71kel-* \ - | mipstx39-* | mipstx39el-* \ - | mmix-* \ - | mt-* \ - | msp430-* \ - | nios-* | nios2-* \ - | none-* | np1-* | ns16k-* | ns32k-* \ - | orion-* \ - | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ - | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ - | pyramid-* \ - | romp-* | rs6000-* \ - | sh-* | sh[1234]-* | sh[24]a-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ - | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ - | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ - | sparclite-* \ - | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \ - | tahoe-* | thumb-* \ - | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ - | tron-* \ - | v850-* | v850e-* | vax-* \ - | we32k-* \ - | x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \ - | xstormy16-* | xtensa-* \ - | ymp-* \ - | z8k-*) - ;; - # Recognize the various machine names and aliases which stand - # for a CPU type and a company and sometimes even an OS. - 386bsd) - basic_machine=i386-unknown - os=-bsd - ;; - 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) - basic_machine=m68000-att - ;; - 3b*) - basic_machine=we32k-att - ;; - a29khif) - basic_machine=a29k-amd - os=-udi - ;; - abacus) - basic_machine=abacus-unknown - ;; - adobe68k) - basic_machine=m68010-adobe - os=-scout - ;; - alliant | fx80) - basic_machine=fx80-alliant - ;; - altos | altos3068) - basic_machine=m68k-altos - ;; - am29k) - basic_machine=a29k-none - os=-bsd - ;; - amd64) - basic_machine=x86_64-pc - ;; - amd64-*) - basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - amdahl) - basic_machine=580-amdahl - os=-sysv - ;; - amiga | amiga-*) - basic_machine=m68k-unknown - ;; - amigaos | amigados) - basic_machine=m68k-unknown - os=-amigaos - ;; - amigaunix | amix) - basic_machine=m68k-unknown - os=-sysv4 - ;; - apollo68) - basic_machine=m68k-apollo - os=-sysv - ;; - apollo68bsd) - basic_machine=m68k-apollo - os=-bsd - ;; - aux) - basic_machine=m68k-apple - os=-aux - ;; - balance) - basic_machine=ns32k-sequent - os=-dynix - ;; - c90) - basic_machine=c90-cray - os=-unicos - ;; - convex-c1) - basic_machine=c1-convex - os=-bsd - ;; - convex-c2) - basic_machine=c2-convex - os=-bsd - ;; - convex-c32) - basic_machine=c32-convex - os=-bsd - ;; - convex-c34) - basic_machine=c34-convex - os=-bsd - ;; - convex-c38) - basic_machine=c38-convex - os=-bsd - ;; - cray | j90) - basic_machine=j90-cray - os=-unicos - ;; - craynv) - basic_machine=craynv-cray - os=-unicosmp - ;; - cr16c) - basic_machine=cr16c-unknown - os=-elf - ;; - crds | unos) - basic_machine=m68k-crds - ;; - crisv32 | crisv32-* | etraxfs*) - basic_machine=crisv32-axis - ;; - cris | cris-* | etrax*) - basic_machine=cris-axis - ;; - crx) - basic_machine=crx-unknown - os=-elf - ;; - da30 | da30-*) - basic_machine=m68k-da30 - ;; - decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) - basic_machine=mips-dec - ;; - decsystem10* | dec10*) - basic_machine=pdp10-dec - os=-tops10 - ;; - decsystem20* | dec20*) - basic_machine=pdp10-dec - os=-tops20 - ;; - delta | 3300 | motorola-3300 | motorola-delta \ - | 3300-motorola | delta-motorola) - basic_machine=m68k-motorola - ;; - delta88) - basic_machine=m88k-motorola - os=-sysv3 - ;; - djgpp) - basic_machine=i586-pc - os=-msdosdjgpp - ;; - dpx20 | dpx20-*) - basic_machine=rs6000-bull - os=-bosx - ;; - dpx2* | dpx2*-bull) - basic_machine=m68k-bull - os=-sysv3 - ;; - ebmon29k) - basic_machine=a29k-amd - os=-ebmon - ;; - elxsi) - basic_machine=elxsi-elxsi - os=-bsd - ;; - encore | umax | mmax) - basic_machine=ns32k-encore - ;; - es1800 | OSE68k | ose68k | ose | OSE) - basic_machine=m68k-ericsson - os=-ose - ;; - fx2800) - basic_machine=i860-alliant - ;; - genix) - basic_machine=ns32k-ns - ;; - gmicro) - basic_machine=tron-gmicro - os=-sysv - ;; - go32) - basic_machine=i386-pc - os=-go32 - ;; - h3050r* | hiux*) - basic_machine=hppa1.1-hitachi - os=-hiuxwe2 - ;; - h8300hms) - basic_machine=h8300-hitachi - os=-hms - ;; - h8300xray) - basic_machine=h8300-hitachi - os=-xray - ;; - h8500hms) - basic_machine=h8500-hitachi - os=-hms - ;; - harris) - basic_machine=m88k-harris - os=-sysv3 - ;; - hp300-*) - basic_machine=m68k-hp - ;; - hp300bsd) - basic_machine=m68k-hp - os=-bsd - ;; - hp300hpux) - basic_machine=m68k-hp - os=-hpux - ;; - hp3k9[0-9][0-9] | hp9[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hp9k2[0-9][0-9] | hp9k31[0-9]) - basic_machine=m68000-hp - ;; - hp9k3[2-9][0-9]) - basic_machine=m68k-hp - ;; - hp9k6[0-9][0-9] | hp6[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hp9k7[0-79][0-9] | hp7[0-79][0-9]) - basic_machine=hppa1.1-hp - ;; - hp9k78[0-9] | hp78[0-9]) - # FIXME: really hppa2.0-hp - basic_machine=hppa1.1-hp - ;; - hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) - # FIXME: really hppa2.0-hp - basic_machine=hppa1.1-hp - ;; - hp9k8[0-9][13679] | hp8[0-9][13679]) - basic_machine=hppa1.1-hp - ;; - hp9k8[0-9][0-9] | hp8[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hppa-next) - os=-nextstep3 - ;; - hppaosf) - basic_machine=hppa1.1-hp - os=-osf - ;; - hppro) - basic_machine=hppa1.1-hp - os=-proelf - ;; - i370-ibm* | ibm*) - basic_machine=i370-ibm - ;; -# I'm not sure what "Sysv32" means. Should this be sysv3.2? - i*86v32) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv32 - ;; - i*86v4*) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv4 - ;; - i*86v) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv - ;; - i*86sol2) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-solaris2 - ;; - i386mach) - basic_machine=i386-mach - os=-mach - ;; - i386-vsta | vsta) - basic_machine=i386-unknown - os=-vsta - ;; - iris | iris4d) - basic_machine=mips-sgi - case $os in - -irix*) - ;; - *) - os=-irix4 - ;; - esac - ;; - isi68 | isi) - basic_machine=m68k-isi - os=-sysv - ;; - m88k-omron*) - basic_machine=m88k-omron - ;; - magnum | m3230) - basic_machine=mips-mips - os=-sysv - ;; - merlin) - basic_machine=ns32k-utek - os=-sysv - ;; - mingw32) - basic_machine=i386-pc - os=-mingw32 - ;; - miniframe) - basic_machine=m68000-convergent - ;; - *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) - basic_machine=m68k-atari - os=-mint - ;; - mips3*-*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` - ;; - mips3*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown - ;; - monitor) - basic_machine=m68k-rom68k - os=-coff - ;; - morphos) - basic_machine=powerpc-unknown - os=-morphos - ;; - msdos) - basic_machine=i386-pc - os=-msdos - ;; - ms1-*) - basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` - ;; - mvs) - basic_machine=i370-ibm - os=-mvs - ;; - ncr3000) - basic_machine=i486-ncr - os=-sysv4 - ;; - netbsd386) - basic_machine=i386-unknown - os=-netbsd - ;; - netwinder) - basic_machine=armv4l-rebel - os=-linux - ;; - news | news700 | news800 | news900) - basic_machine=m68k-sony - os=-newsos - ;; - news1000) - basic_machine=m68030-sony - os=-newsos - ;; - news-3600 | risc-news) - basic_machine=mips-sony - os=-newsos - ;; - necv70) - basic_machine=v70-nec - os=-sysv - ;; - next | m*-next ) - basic_machine=m68k-next - case $os in - -nextstep* ) - ;; - -ns2*) - os=-nextstep2 - ;; - *) - os=-nextstep3 - ;; - esac - ;; - nh3000) - basic_machine=m68k-harris - os=-cxux - ;; - nh[45]000) - basic_machine=m88k-harris - os=-cxux - ;; - nindy960) - basic_machine=i960-intel - os=-nindy - ;; - mon960) - basic_machine=i960-intel - os=-mon960 - ;; - nonstopux) - basic_machine=mips-compaq - os=-nonstopux - ;; - np1) - basic_machine=np1-gould - ;; - nsr-tandem) - basic_machine=nsr-tandem - ;; - op50n-* | op60c-*) - basic_machine=hppa1.1-oki - os=-proelf - ;; - openrisc | openrisc-*) - basic_machine=or32-unknown - ;; - os400) - basic_machine=powerpc-ibm - os=-os400 - ;; - OSE68000 | ose68000) - basic_machine=m68000-ericsson - os=-ose - ;; - os68k) - basic_machine=m68k-none - os=-os68k - ;; - pa-hitachi) - basic_machine=hppa1.1-hitachi - os=-hiuxwe2 - ;; - paragon) - basic_machine=i860-intel - os=-osf - ;; - pbd) - basic_machine=sparc-tti - ;; - pbb) - basic_machine=m68k-tti - ;; - pc532 | pc532-*) - basic_machine=ns32k-pc532 - ;; - pc98) - basic_machine=i386-pc - ;; - pc98-*) - basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentium | p5 | k5 | k6 | nexgen | viac3) - basic_machine=i586-pc - ;; - pentiumpro | p6 | 6x86 | athlon | athlon_*) - basic_machine=i686-pc - ;; - pentiumii | pentium2 | pentiumiii | pentium3) - basic_machine=i686-pc - ;; - pentium4) - basic_machine=i786-pc - ;; - pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) - basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentiumpro-* | p6-* | 6x86-* | athlon-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentium4-*) - basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pn) - basic_machine=pn-gould - ;; - power) basic_machine=power-ibm - ;; - ppc) basic_machine=powerpc-unknown - ;; - ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppcle | powerpclittle | ppc-le | powerpc-little) - basic_machine=powerpcle-unknown - ;; - ppcle-* | powerpclittle-*) - basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppc64) basic_machine=powerpc64-unknown - ;; - ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppc64le | powerpc64little | ppc64-le | powerpc64-little) - basic_machine=powerpc64le-unknown - ;; - ppc64le-* | powerpc64little-*) - basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ps2) - basic_machine=i386-ibm - ;; - pw32) - basic_machine=i586-unknown - os=-pw32 - ;; - rdos) - basic_machine=i386-pc - os=-rdos - ;; - rom68k) - basic_machine=m68k-rom68k - os=-coff - ;; - rm[46]00) - basic_machine=mips-siemens - ;; - rtpc | rtpc-*) - basic_machine=romp-ibm - ;; - s390 | s390-*) - basic_machine=s390-ibm - ;; - s390x | s390x-*) - basic_machine=s390x-ibm - ;; - sa29200) - basic_machine=a29k-amd - os=-udi - ;; - sb1) - basic_machine=mipsisa64sb1-unknown - ;; - sb1el) - basic_machine=mipsisa64sb1el-unknown - ;; - sde) - basic_machine=mipsisa32-sde - os=-elf - ;; - sei) - basic_machine=mips-sei - os=-seiux - ;; - sequent) - basic_machine=i386-sequent - ;; - sh) - basic_machine=sh-hitachi - os=-hms - ;; - sh64) - basic_machine=sh64-unknown - ;; - sparclite-wrs | simso-wrs) - basic_machine=sparclite-wrs - os=-vxworks - ;; - sps7) - basic_machine=m68k-bull - os=-sysv2 - ;; - spur) - basic_machine=spur-unknown - ;; - st2000) - basic_machine=m68k-tandem - ;; - stratus) - basic_machine=i860-stratus - os=-sysv4 - ;; - sun2) - basic_machine=m68000-sun - ;; - sun2os3) - basic_machine=m68000-sun - os=-sunos3 - ;; - sun2os4) - basic_machine=m68000-sun - os=-sunos4 - ;; - sun3os3) - basic_machine=m68k-sun - os=-sunos3 - ;; - sun3os4) - basic_machine=m68k-sun - os=-sunos4 - ;; - sun4os3) - basic_machine=sparc-sun - os=-sunos3 - ;; - sun4os4) - basic_machine=sparc-sun - os=-sunos4 - ;; - sun4sol2) - basic_machine=sparc-sun - os=-solaris2 - ;; - sun3 | sun3-*) - basic_machine=m68k-sun - ;; - sun4) - basic_machine=sparc-sun - ;; - sun386 | sun386i | roadrunner) - basic_machine=i386-sun - ;; - sv1) - basic_machine=sv1-cray - os=-unicos - ;; - symmetry) - basic_machine=i386-sequent - os=-dynix - ;; - t3e) - basic_machine=alphaev5-cray - os=-unicos - ;; - t90) - basic_machine=t90-cray - os=-unicos - ;; - tic54x | c54x*) - basic_machine=tic54x-unknown - os=-coff - ;; - tic55x | c55x*) - basic_machine=tic55x-unknown - os=-coff - ;; - tic6x | c6x*) - basic_machine=tic6x-unknown - os=-coff - ;; - tx39) - basic_machine=mipstx39-unknown - ;; - tx39el) - basic_machine=mipstx39el-unknown - ;; - toad1) - basic_machine=pdp10-xkl - os=-tops20 - ;; - tower | tower-32) - basic_machine=m68k-ncr - ;; - tpf) - basic_machine=s390x-ibm - os=-tpf - ;; - udi29k) - basic_machine=a29k-amd - os=-udi - ;; - ultra3) - basic_machine=a29k-nyu - os=-sym1 - ;; - v810 | necv810) - basic_machine=v810-nec - os=-none - ;; - vaxv) - basic_machine=vax-dec - os=-sysv - ;; - vms) - basic_machine=vax-dec - os=-vms - ;; - vpp*|vx|vx-*) - basic_machine=f301-fujitsu - ;; - vxworks960) - basic_machine=i960-wrs - os=-vxworks - ;; - vxworks68) - basic_machine=m68k-wrs - os=-vxworks - ;; - vxworks29k) - basic_machine=a29k-wrs - os=-vxworks - ;; - w65*) - basic_machine=w65-wdc - os=-none - ;; - w89k-*) - basic_machine=hppa1.1-winbond - os=-proelf - ;; - xbox) - basic_machine=i686-pc - os=-mingw32 - ;; - xps | xps100) - basic_machine=xps100-honeywell - ;; - ymp) - basic_machine=ymp-cray - os=-unicos - ;; - z8k-*-coff) - basic_machine=z8k-unknown - os=-sim - ;; - none) - basic_machine=none-none - os=-none - ;; - -# Here we handle the default manufacturer of certain CPU types. It is in -# some cases the only manufacturer, in others, it is the most popular. - w89k) - basic_machine=hppa1.1-winbond - ;; - op50n) - basic_machine=hppa1.1-oki - ;; - op60c) - basic_machine=hppa1.1-oki - ;; - romp) - basic_machine=romp-ibm - ;; - mmix) - basic_machine=mmix-knuth - ;; - rs6000) - basic_machine=rs6000-ibm - ;; - vax) - basic_machine=vax-dec - ;; - pdp10) - # there are many clones, so DEC is not a safe bet - basic_machine=pdp10-unknown - ;; - pdp11) - basic_machine=pdp11-dec - ;; - we32k) - basic_machine=we32k-att - ;; - sh[1234] | sh[24]a | sh[34]eb | sh[1234]le | sh[23]ele) - basic_machine=sh-unknown - ;; - sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) - basic_machine=sparc-sun - ;; - cydra) - basic_machine=cydra-cydrome - ;; - orion) - basic_machine=orion-highlevel - ;; - orion105) - basic_machine=clipper-highlevel - ;; - mac | mpw | mac-mpw) - basic_machine=m68k-apple - ;; - pmac | pmac-mpw) - basic_machine=powerpc-apple - ;; - *-unknown) - # Make sure to match an already-canonicalized machine name. - ;; - *) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 - exit 1 - ;; -esac - -# Here we canonicalize certain aliases for manufacturers. -case $basic_machine in - *-digital*) - basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` - ;; - *-commodore*) - basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` - ;; - *) - ;; -esac - -# Decode manufacturer-specific aliases for certain operating systems. - -if [ x"$os" != x"" ] -then -case $os in - # First match some system type aliases - # that might get confused with valid system types. - # -solaris* is a basic system type, with this one exception. - -solaris1 | -solaris1.*) - os=`echo $os | sed -e 's|solaris1|sunos4|'` - ;; - -solaris) - os=-solaris2 - ;; - -svr4*) - os=-sysv4 - ;; - -unixware*) - os=-sysv4.2uw - ;; - -gnu/linux*) - os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` - ;; - # First accept the basic system types. - # The portable systems comes first. - # Each alternative MUST END IN A *, to match a version number. - # -sysv* is not here because it comes later, after sysvr4. - -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ - | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ - | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ - | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ - | -aos* \ - | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ - | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ - | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ - | -openbsd* | -solidbsd* \ - | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ - | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ - | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ - | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ - | -chorusos* | -chorusrdb* \ - | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ - | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \ - | -uxpv* | -beos* | -mpeix* | -udk* \ - | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ - | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ - | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ - | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ - | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ - | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ - | -skyos* | -haiku* | -rdos* | -toppers*) - # Remember, each alternative MUST END IN *, to match a version number. - ;; - -qnx*) - case $basic_machine in - x86-* | i*86-*) - ;; - *) - os=-nto$os - ;; - esac - ;; - -nto-qnx*) - ;; - -nto*) - os=`echo $os | sed -e 's|nto|nto-qnx|'` - ;; - -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ - | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ - | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) - ;; - -mac*) - os=`echo $os | sed -e 's|mac|macos|'` - ;; - -linux-dietlibc) - os=-linux-dietlibc - ;; - -linux*) - os=`echo $os | sed -e 's|linux|linux-gnu|'` - ;; - -sunos5*) - os=`echo $os | sed -e 's|sunos5|solaris2|'` - ;; - -sunos6*) - os=`echo $os | sed -e 's|sunos6|solaris3|'` - ;; - -opened*) - os=-openedition - ;; - -os400*) - os=-os400 - ;; - -wince*) - os=-wince - ;; - -osfrose*) - os=-osfrose - ;; - -osf*) - os=-osf - ;; - -utek*) - os=-bsd - ;; - -dynix*) - os=-bsd - ;; - -acis*) - os=-aos - ;; - -atheos*) - os=-atheos - ;; - -syllable*) - os=-syllable - ;; - -386bsd) - os=-bsd - ;; - -ctix* | -uts*) - os=-sysv - ;; - -nova*) - os=-rtmk-nova - ;; - -ns2 ) - os=-nextstep2 - ;; - -nsk*) - os=-nsk - ;; - # Preserve the version number of sinix5. - -sinix5.*) - os=`echo $os | sed -e 's|sinix|sysv|'` - ;; - -sinix*) - os=-sysv4 - ;; - -tpf*) - os=-tpf - ;; - -triton*) - os=-sysv3 - ;; - -oss*) - os=-sysv3 - ;; - -svr4) - os=-sysv4 - ;; - -svr3) - os=-sysv3 - ;; - -sysvr4) - os=-sysv4 - ;; - # This must come after -sysvr4. - -sysv*) - ;; - -ose*) - os=-ose - ;; - -es1800*) - os=-ose - ;; - -xenix) - os=-xenix - ;; - -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) - os=-mint - ;; - -aros*) - os=-aros - ;; - -kaos*) - os=-kaos - ;; - -zvmoe) - os=-zvmoe - ;; - -none) - ;; - *) - # Get rid of the `-' at the beginning of $os. - os=`echo $os | sed 's/[^-]*-//'` - echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 - exit 1 - ;; -esac -else - -# Here we handle the default operating systems that come with various machines. -# The value should be what the vendor currently ships out the door with their -# machine or put another way, the most popular os provided with the machine. - -# Note that if you're going to try to match "-MANUFACTURER" here (say, -# "-sun"), then you have to tell the case statement up towards the top -# that MANUFACTURER isn't an operating system. Otherwise, code above -# will signal an error saying that MANUFACTURER isn't an operating -# system, and we'll never get to this point. - -case $basic_machine in - score-*) - os=-elf - ;; - spu-*) - os=-elf - ;; - *-acorn) - os=-riscix1.2 - ;; - arm*-rebel) - os=-linux - ;; - arm*-semi) - os=-aout - ;; - c4x-* | tic4x-*) - os=-coff - ;; - # This must come before the *-dec entry. - pdp10-*) - os=-tops20 - ;; - pdp11-*) - os=-none - ;; - *-dec | vax-*) - os=-ultrix4.2 - ;; - m68*-apollo) - os=-domain - ;; - i386-sun) - os=-sunos4.0.2 - ;; - m68000-sun) - os=-sunos3 - # This also exists in the configure program, but was not the - # default. - # os=-sunos4 - ;; - m68*-cisco) - os=-aout - ;; - mips*-cisco) - os=-elf - ;; - mips*-*) - os=-elf - ;; - or32-*) - os=-coff - ;; - *-tti) # must be before sparc entry or we get the wrong os. - os=-sysv3 - ;; - sparc-* | *-sun) - os=-sunos4.1.1 - ;; - *-be) - os=-beos - ;; - *-haiku) - os=-haiku - ;; - *-ibm) - os=-aix - ;; - *-knuth) - os=-mmixware - ;; - *-wec) - os=-proelf - ;; - *-winbond) - os=-proelf - ;; - *-oki) - os=-proelf - ;; - *-hp) - os=-hpux - ;; - *-hitachi) - os=-hiux - ;; - i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) - os=-sysv - ;; - *-cbm) - os=-amigaos - ;; - *-dg) - os=-dgux - ;; - *-dolphin) - os=-sysv3 - ;; - m68k-ccur) - os=-rtu - ;; - m88k-omron*) - os=-luna - ;; - *-next ) - os=-nextstep - ;; - *-sequent) - os=-ptx - ;; - *-crds) - os=-unos - ;; - *-ns) - os=-genix - ;; - i370-*) - os=-mvs - ;; - *-next) - os=-nextstep3 - ;; - *-gould) - os=-sysv - ;; - *-highlevel) - os=-bsd - ;; - *-encore) - os=-bsd - ;; - *-sgi) - os=-irix - ;; - *-siemens) - os=-sysv4 - ;; - *-masscomp) - os=-rtu - ;; - f30[01]-fujitsu | f700-fujitsu) - os=-uxpv - ;; - *-rom68k) - os=-coff - ;; - *-*bug) - os=-coff - ;; - *-apple) - os=-macos - ;; - *-atari*) - os=-mint - ;; - *) - os=-none - ;; -esac -fi - -# Here we handle the case where we know the os, and the CPU type, but not the -# manufacturer. We pick the logical manufacturer. -vendor=unknown -case $basic_machine in - *-unknown) - case $os in - -riscix*) - vendor=acorn - ;; - -sunos*) - vendor=sun - ;; - -aix*) - vendor=ibm - ;; - -beos*) - vendor=be - ;; - -hpux*) - vendor=hp - ;; - -mpeix*) - vendor=hp - ;; - -hiux*) - vendor=hitachi - ;; - -unos*) - vendor=crds - ;; - -dgux*) - vendor=dg - ;; - -luna*) - vendor=omron - ;; - -genix*) - vendor=ns - ;; - -mvs* | -opened*) - vendor=ibm - ;; - -os400*) - vendor=ibm - ;; - -ptx*) - vendor=sequent - ;; - -tpf*) - vendor=ibm - ;; - -vxsim* | -vxworks* | -windiss*) - vendor=wrs - ;; - -aux*) - vendor=apple - ;; - -hms*) - vendor=hitachi - ;; - -mpw* | -macos*) - vendor=apple - ;; - -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) - vendor=atari - ;; - -vos*) - vendor=stratus - ;; - esac - basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` - ;; -esac - -echo $basic_machine$os -exit - -# Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "timestamp='" -# time-stamp-format: "%:y-%02m-%02d" -# time-stamp-end: "'" -# End: From d5f16a867c4e0d7d06a59e7c29a187e9e849b755 Mon Sep 17 00:00:00 2001 From: Robert Stone Date: Mon, 30 Jun 2008 23:41:27 +0000 Subject: [PATCH 0057/1680] Hopefully this provides more portable values for Infinity and NaN in Perl. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10616 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- .../test-suite/perl5/li_typemaps_runme.pl | 39 +++++++++++-------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/Examples/test-suite/perl5/li_typemaps_runme.pl b/Examples/test-suite/perl5/li_typemaps_runme.pl index c149284ae..c182cdbb1 100644 --- a/Examples/test-suite/perl5/li_typemaps_runme.pl +++ b/Examples/test-suite/perl5/li_typemaps_runme.pl @@ -37,24 +37,29 @@ batch('ulong', 0, 1, 12, 0xffffffff); batch('uchar', 0, 1, 12, 0xff); batch('schar', -0x80, 0, 1, 12, 0x7f); -# IEEE 754 machine, please! -batch('float', - -(2 - 2 ** -23) * 2 ** 127, - -1, -2 ** -149, 0, 2 ** -149, 1, - (2 - 2 ** -23) * 2 ** 127, - 'nan'); -{ local $TODO = "shouldn't some Inf <=> float work?"; - # I'm going to guess that it could work reasonably as - # NV Inf => float Inf - # float Inf => NV NaN - # but this needs some thought. - batch('float', 'inf'); +{ + use Math::BigInt qw(); + # the pack dance is to get plain old NVs out of the + # Math::BigInt objects. + my $inf = unpack 'd', pack 'd', Math::BigInt->binf(); + my $nan = unpack 'd', pack 'd', Math::BigInt->bnan(); + batch('float', + -(2 - 2 ** -23) * 2 ** 127, + -1, -2 ** -149, 0, 2 ** -149, 1, + (2 - 2 ** -23) * 2 ** 127, + $nan); + { local $TODO = "float typemaps don't pass infinity"; + # it seems as though SWIG is unwilling to pass infinity around + # because that value always fails bounds checking. I think that + # is a bug. + batch('float', $inf); + } + batch('double', + -(2 - 2 ** -53) ** 1023, + -1, -2 ** -1074, 0, 2 ** 1074, + (2 - 2 ** -53) ** 1023, + $nan, $inf); } -batch('double', - -(2 - 2 ** -53) ** 1023, - -1, -2 ** -1074, 0, 2 ** 1074, - (2 - 2 ** -53) ** 1023, - 'nan', 'inf'); batch('longlong', -1, 0, 1, 12); batch('ulonglong', 0, 1, 12); SKIP: { From 64c05405c6928a298e2cdde4c0deb3b4bf57740a Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 1 Jul 2008 22:02:14 +0000 Subject: [PATCH 0058/1680] update old commandline option git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10621 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Extending.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Doc/Manual/Extending.html b/Doc/Manual/Extending.html index 588912b68..5639663a1 100644 --- a/Doc/Manual/Extending.html +++ b/Doc/Manual/Extending.html @@ -448,7 +448,8 @@ of the output.

      The contents of each parse tree node consist of a collection of attribute/value pairs. Internally, the nodes are simply represented by hash tables. A display of -the entire parse-tree structure can be obtained using swig -dump_tree. +the entire parse-tree structure can be obtained using swig -debug-top <n>, where n is +the stage being processed. There are a number of other parse tree display options, for example, swig -debug-module <n> will avoid displaying system parse information and only display the parse tree pertaining to the user's module at stage n of processing. From 31926ad905013ecd2dcb2fb97fbdcb2ec5a070d9 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Wed, 2 Jul 2008 03:17:46 +0000 Subject: [PATCH 0059/1680] [Python] Import the C extension differently for Python 2.6 and later so that an implicit relative import doesn't produce a deprecation warning for 2.6 and a failure for 2.7 and later. Patch from Richard Boulton in SF#2008229. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10624 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 6 ++++++ Source/Modules/python.cxx | 20 +++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index ef3fcca54..89f48ce93 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,3 +1,9 @@ Version 1.3.36 (in progress) ============================= +2008-07-02: olly + [Python] Import the C extension differently for Python 2.6 and + later so that an implicit relative import doesn't produce a + deprecation warning for 2.6 and a failure for 2.7 and later. + Patch from Richard Boulton in SF#2008229. + diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index f0e335c37..d497b57b3 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -689,7 +689,25 @@ public: mod_docstring = NULL; } - Printf(f_shadow, "\nimport %s\n", module); + Printv(f_shadow, "\nfrom sys import version_info\n", NULL); + + /* Import the C-extension module. This should be a relative import, + * since the shadow module may also have been imported by a relative + * import, and there is thus no guarantee that the C-extension is on + * sys.path. Relative imports must be explicitly specified from 2.6.0 + * onwards (implicit relative imports will raise a DeprecationWarning + * in 2.6, and fail in 2.7 onwards), but the relative import syntax + * isn't available in python 2.4 or earlier, so we have to write some + * code conditional on the python version. + */ + Printv(f_shadow, "if version_info >= (2,6,0):\n", NULL); + Printf(f_shadow, tab4 "from . import %s\n", module); + Printv(f_shadow, "else:\n", NULL); + Printf(f_shadow, tab4 "import %s\n", module); + + /* Delete the version_info symbol since we don't use it elsewhere in the + * module. */ + Printv(f_shadow, "del version_info\n", NULL); Printv(f_shadow, "import new\n", NULL); Printv(f_shadow, "new_instancemethod = new.instancemethod\n", NULL); From 1f2c29342faac4dca906a3f66893eb215c262559 Mon Sep 17 00:00:00 2001 From: Haoyu Bai Date: Wed, 2 Jul 2008 04:56:11 +0000 Subject: [PATCH 0060/1680] fix the relative import patch by try both relative and absolute import git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10625 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/python.cxx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index d497b57b3..5e6f45637 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -701,7 +701,10 @@ public: * code conditional on the python version. */ Printv(f_shadow, "if version_info >= (2,6,0):\n", NULL); - Printf(f_shadow, tab4 "from . import %s\n", module); + Printv(f_shadow, tab4, "try:\n", NULL); + Printf(f_shadow, tab8 "from . import %s\n", module); + Printv(f_shadow, tab4, "except ValueError:\n"); + Printf(f_shadow, tab8 "import %s\n", module); Printv(f_shadow, "else:\n", NULL); Printf(f_shadow, tab4 "import %s\n", module); From 9ff8981708dbe0a74a754d84bf85bd492eb10f09 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Wed, 2 Jul 2008 05:55:18 +0000 Subject: [PATCH 0061/1680] [PHP4] Support for PHP4 has been removed. The PHP developers are no longer making new PHP4 releases, and won't even be patching critical security issues after 2008-08-08. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10626 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 5 + Source/Modules/php4.cxx | 478 +++--------------------------------- Source/Modules/swigmain.cxx | 4 +- 3 files changed, 41 insertions(+), 446 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 89f48ce93..615800a33 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,11 @@ Version 1.3.36 (in progress) ============================= +2008-07-02: olly + [PHP4] Support for PHP4 has been removed. The PHP developers are + no longer making new PHP4 releases, and won't even be patching + critical security issues after 2008-08-08. + 2008-07-02: olly [Python] Import the C extension differently for Python 2.6 and later so that an implicit relative import doesn't produce a diff --git a/Source/Modules/php4.cxx b/Source/Modules/php4.cxx index 42d71e79a..1bd214423 100644 --- a/Source/Modules/php4.cxx +++ b/Source/Modules/php4.cxx @@ -13,11 +13,9 @@ * Short term: * * Sort out auto-renaming of method and class names which are reserved - * words (e.g. empty, clone, exception, etc.) vs -php4/-php5 in some - * sane way. + * words (e.g. empty, clone, exception, etc.) * - * Sort out wrapping of static member variables in OO PHP5 (which first may - * mean we need to sort them out for PHP4!) + * Sort out wrapping of static member variables in OO PHP5. * * Medium term: * @@ -50,7 +48,7 @@ char cvsroot_php4_cxx[] = "$Id$"; #include static const char *usage = (char *) "\ -PHP Options (available with -php4 or -php5)\n\ +PHP Options (available with -php5)\n\ -cppext - cpp file extension (default to .cpp)\n\ -noproxy - Don't generate proxy classes.\n\ -prefix - Prepend to all class names in PHP5 wrappers\n\ @@ -116,9 +114,6 @@ static Node *current_class = 0; static Hash *shadow_get_vars; static Hash *shadow_set_vars; -#define NATIVE_CONSTRUCTOR 1 -#define ALTERNATIVE_CONSTRUCTOR 2 -static int native_constructor = 0; static Hash *zend_types = 0; static int shadow = 1; @@ -295,11 +290,7 @@ public: } Preprocessor_define((void *) "SWIGPHP 1", 0); - if (php_version == 4) { - Preprocessor_define((void *) "SWIGPHP4 1", 0); - } else if (php_version == 5) { - Preprocessor_define((void *) "SWIGPHP5 1", 0); - } + Preprocessor_define((void *) "SWIGPHP5 1", 0); SWIG_typemap_lang("php4"); /* DB: Suggest using a language configuration file */ SWIG_config_file("php4.swg"); @@ -609,9 +600,8 @@ public: 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"); - Printf(f_phpcode, " // PHP_SHLIB_SUFFIX is available as of PHP 4.3.0, for older PHP assume 'so'.\n"); - Printf(f_phpcode, " // It gives 'dylib' on MacOS X which is for libraries, modules are 'so'.\n"); - Printf(f_phpcode, " if (PHP_SHLIB_SUFFIX === 'PHP_SHLIB_SUFFIX' || PHP_SHLIB_SUFFIX === 'dylib') {\n"); + Printf(f_phpcode, " // PHP_SHLIB_SUFFIX gives 'dylib' on MacOS X but modules are 'so'.\n"); + Printf(f_phpcode, " if (PHP_SHLIB_SUFFIX === 'dylib') {\n"); Printf(f_phpcode, " if (!dl('%s.so')) return;\n", module); Printf(f_phpcode, " } else {\n"); Printf(f_phpcode, " if (!dl('%s.'.PHP_SHLIB_SUFFIX)) return;\n", module); @@ -852,10 +842,6 @@ public: /* Just need to append function names to function table to register with PHP. */ void create_command(String *cname, String *iname) { // This is for the single main zend_function_entry record - if (shadow && php_version == 4) { - if (wrapperType != standard) - return; - } Printf(f_h, "ZEND_NAMED_FUNCTION(%s);\n", iname); String * s = cs_entry; if (!s) s = s_entry; @@ -872,8 +858,6 @@ public: String *tmp = NewStringEmpty(); String *dispatch = Swig_overload_dispatch(n, "return %s(INTERNAL_FUNCTION_PARAM_PASSTHRU);", &maxargs); - int has_this_ptr = (wrapperType == memberfn && shadow && php_version == 4); - /* Generate a dispatch wrapper for all overloaded functions */ Wrapper *f = NewWrapper(); @@ -890,13 +874,7 @@ public: Printf(f->code, "argc = ZEND_NUM_ARGS();\n"); - if (has_this_ptr) { - Printf(f->code, "argv[0] = &this_ptr;\n"); - Printf(f->code, "zend_get_parameters_array_ex(argc,argv+1);\n"); - Printf(f->code, "argc++;\n"); - } else { - Printf(f->code, "zend_get_parameters_array_ex(argc,argv);\n"); - } + Printf(f->code, "zend_get_parameters_array_ex(argc,argv);\n"); Replaceall(dispatch, "$args", "self,args"); @@ -945,8 +923,6 @@ public: int numopt; String *tm; Wrapper *f; - bool mvr = (shadow && php_version == 4 && wrapperType == membervar); - bool mvrset = (mvr && (Strcmp(iname, Swig_name_set(Swig_name_member(shadow_classname, name))) == 0)); String *wname; int overloaded = 0; @@ -971,19 +947,6 @@ public: if (overname) { Printf(wname, "%s", overname); } - // if PHP4, shadow and variable wrapper we want to snag the main contents - // of this function to stick in to the property handler... - if (mvr) { - String *php_function_name = NewString(iname); - if (Strcmp(iname, Swig_name_set(Swig_name_member(shadow_classname, name))) == 0) { - Setattr(shadow_set_vars, php_function_name, name); - } - if (Strcmp(iname, Swig_name_get(Swig_name_member(shadow_classname, name))) == 0) { - Setattr(shadow_get_vars, php_function_name, name); - } - - Delete(php_function_name); - } f = NewWrapper(); numopt = 0; @@ -991,20 +954,11 @@ public: String *outarg = NewStringEmpty(); String *cleanup = NewStringEmpty(); - if (mvr) { // do prop[gs]et header - if (mvrset) { - Printf(f->def, "static int _wrap_%s(zend_property_reference *property_reference, pval *value) {\n", iname); - } else { - Printf(f->def, "static pval _wrap_%s(zend_property_reference *property_reference) {\n", iname); - } - } else { - // regular header - // Not issued for overloaded functions or static member variables. - if (!overloaded && wrapperType != staticmembervar) { - create_command(iname, wname); - } - Printv(f->def, "ZEND_NAMED_FUNCTION(", wname, ") {\n", NIL); + // Not issued for overloaded functions or static member variables. + if (!overloaded && wrapperType != staticmembervar) { + create_command(iname, wname); } + Printv(f->def, "ZEND_NAMED_FUNCTION(", wname, ") {\n", NIL); emit_parameter_variables(l, f); /* Attach standard typemaps */ @@ -1018,10 +972,8 @@ public: int num_required = emit_num_required(l); numopt = num_arguments - num_required; - int has_this_ptr = (wrapperType == memberfn && shadow && php_version == 4); - - if (num_arguments - has_this_ptr > 0) { - String *args = NewStringf("zval **args[%d]", num_arguments - has_this_ptr); + if (num_arguments > 0) { + String *args = NewStringf("zval **args[%d]", num_arguments); Wrapper_add_local(f, "args", args); Delete(args); args = NULL; @@ -1036,34 +988,17 @@ public: Printf(f->code, "SWIG_ResetError();\n"); - if (has_this_ptr) - Printf(f->code, "/* This function uses a this_ptr*/\n"); - - if (native_constructor) { - if (native_constructor == NATIVE_CONSTRUCTOR) { - Printf(f->code, "/* NATIVE Constructor */\n"); - } else { - Printf(f->code, "/* ALTERNATIVE Constructor */\n"); - } - } - - if (mvr && !mvrset) { - Wrapper_add_local(f, "_return_value", "zval _return_value"); - Wrapper_add_local(f, "return_value", "zval *return_value=&_return_value"); - } - if (numopt > 0) { // membervariable wrappers do not have optional args Wrapper_add_local(f, "arg_count", "int arg_count"); Printf(f->code, "arg_count = ZEND_NUM_ARGS();\n"); Printf(f->code, "if(arg_count<%d || arg_count>%d ||\n", num_required, num_arguments); Printf(f->code, " zend_get_parameters_array_ex(arg_count,args)!=SUCCESS)\n"); Printf(f->code, "\tWRONG_PARAM_COUNT;\n\n"); - } else if (!mvr) { - int num = num_arguments - has_this_ptr; - if (num == 0) { + } else { + if (num_arguments == 0) { Printf(f->code, "if(ZEND_NUM_ARGS() != 0) {\n"); } else { - Printf(f->code, "if(ZEND_NUM_ARGS() != %d || zend_get_parameters_array_ex(%d, args) != SUCCESS) {\n", num, num); + Printf(f->code, "if(ZEND_NUM_ARGS() != %d || zend_get_parameters_array_ex(%d, args) != SUCCESS) {\n", num_arguments, num_arguments); } Printf(f->code, "WRONG_PARAM_COUNT;\n}\n\n"); } @@ -1089,19 +1024,7 @@ public: SwigType *pt = Getattr(p, "type"); - if (mvr) { // do we assert that numargs=2, that i<2 - if (i == 0) { - source = NewString("&(property_reference->object)"); - } else { - source = NewString("&value"); - } - } else { - if (i == 0 && has_this_ptr) { - source = NewString("&this_ptr"); - } else { - source = NewStringf("args[%d]", i - has_this_ptr); - } - } + source = NewStringf("args[%d]", i); String *ln = Getattr(p, "lname"); @@ -1183,24 +1106,6 @@ public: Replaceall(tm, "$result", "return_value"); Replaceall(tm, "$owner", newobject ? "1" : "0"); Printf(f->code, "%s\n", tm); - // Are we returning a wrapable object? - if (shadow && php_version == 4 && is_shadow(d) && (SwigType_type(d) != T_ARRAY)) { - // Make object. - Printf(f->code, "{\n/* Wrap this return value */\n"); - Printf(f->code, "zval *_cPtr;\n"); - Printf(f->code, "ALLOC_ZVAL(_cPtr);\n"); - Printf(f->code, "*_cPtr = *return_value;\n"); - Printf(f->code, "INIT_ZVAL(*return_value);\n"); - if (native_constructor == NATIVE_CONSTRUCTOR) { - Printf(f->code, "add_property_zval(this_ptr,\"" SWIG_PTR "\",_cPtr);\n"); - } else { - String *shadowrettype = GetShadowReturnType(n); - Printf(f->code, "object_init_ex(return_value,ptr_ce_swig_%s);\n", shadowrettype); - Delete(shadowrettype); - Printf(f->code, "add_property_zval(return_value,\"" SWIG_PTR "\",_cPtr);\n"); - } - Printf(f->code, "}\n"); - } } else { Swig_warning(WARN_TYPEMAP_OUT_UNDEF, input_file, line_number, "Unable to use return type %s in function %s.\n", SwigType_str(d, 0), name); } @@ -1228,16 +1133,7 @@ public: Delete(tm); } - - if (mvr) { - if (!mvrset) { - Printf(f->code, "return _return_value;\n"); - } else { - Printf(f->code, "return SUCCESS;\n"); - } - } else { - Printf(f->code, "return;\n"); - } + Printf(f->code, "return;\n"); /* Error handling code */ Printf(f->code, "fail:\n"); @@ -1638,8 +1534,8 @@ public: Setattr(seen, "this", seen); /* We use $r to store the return value, so disallow that as a parameter * name in case the user uses the "call-time pass-by-reference" feature - * (it's deprecated and off by default in PHP5 and even later PHP4 - * versions apparently, but we want to be maximally portable). + * (it's deprecated and off by default in PHP5, but we want to be + * maximally portable). */ Setattr(seen, "r", seen); @@ -2018,52 +1914,7 @@ public: current_class = n; // String *use_class_name=SwigType_manglestr(SwigType_ltype(t)); - if (shadow && php_version == 4) { - char *rename = GetChar(n, "sym:name"); - - if (!addSymbol(rename, n)) - return SWIG_ERROR; - shadow_classname = NewString(rename); - cs_entry = NewStringEmpty(); - Printf(cs_entry, "/* Function entries for %s */\n", shadow_classname); - Printf(cs_entry, "static zend_function_entry %s_functions[] = {\n", shadow_classname); - - if (Strcmp(shadow_classname, module) == 0) { - Printf(stderr, "class name cannot be equal to module name: %s\n", module); - SWIG_exit(1); - } - - shadow_get_vars = NewHash(); - shadow_set_vars = NewHash(); - - /* Deal with inheritance */ - List *baselist = Getattr(n, "bases"); - if (baselist) { - Iterator base = First(baselist); - while (base.item && GetFlag(base.item, "feature:ignore")) { - base = Next(base); - } - base = Next(base); - if (base.item) { - /* Warn about multiple inheritance for additional base class(es) */ - while (base.item) { - if (GetFlag(base.item, "feature:ignore")) { - base = Next(base); - continue; - } - String *proxyclassname = SwigType_str(Getattr(n, "classtypeobj"), 0); - String *baseclassname = SwigType_str(Getattr(base.item, "name"), 0); - Swig_warning(WARN_PHP4_MULTIPLE_INHERITANCE, input_file, line_number, - "Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Php4.\n", proxyclassname, baseclassname); - base = Next(base); - } - } - } - - /* Write out class init code */ - Printf(s_vdecl, "static zend_class_entry ce_swig_%s;\n", shadow_classname); - Printf(s_vdecl, "static zend_class_entry* ptr_ce_swig_%s=NULL;\n", shadow_classname); - } else if (shadow && php_version == 5) { + if (shadow) { char *rename = GetChar(n, "sym:name"); if (!addSymbol(rename, n)) @@ -2102,217 +1953,7 @@ public: Language::classHandler(n); classnode = 0; - if (shadow && php_version == 4) { - DOH *key; - String *s_propget = NewStringEmpty(); - String *s_propset = NewStringEmpty(); - List *baselist = Getattr(n, "bases"); - Iterator ki, base; - - // If no constructor was generated (abstract class) we had better - // generate a constructor that raises an error about instantiating - // abstract classes - if (Getattr(n, "abstract") && constructors == 0) { - // have to write out fake constructor which raises an error when called - abstractConstructorHandler(n); - } - - Printf(s_oinit, "/* Define class %s */\n", shadow_classname); - Printf(s_oinit, "INIT_OVERLOADED_CLASS_ENTRY(ce_swig_%s,\"%(lower)s\",%s_functions,", shadow_classname, shadow_classname, shadow_classname); - Printf(s_oinit, "NULL,_wrap_propget_%s,_wrap_propset_%s);\n", shadow_classname, shadow_classname); - - // ******** Write property SET handlers - Printf(s_header, "static int _wrap_propset_%s(zend_property_reference *property_reference, pval *value);\n", shadow_classname); - Printf(s_header, "static int _propset_%s(zend_property_reference *property_reference, pval *value);\n", shadow_classname); - - Printf(s_propset, "static int _wrap_propset_%s(zend_property_reference *property_reference, pval *value) { \n", shadow_classname); - Printf(s_propset, " zval * _value;\n"); - Printf(s_propset, " zend_llist_element *element = property_reference->elements_list->head;\n"); - Printf(s_propset, " zend_overloaded_element *property=(zend_overloaded_element *)element->data;\n"); - Printf(s_propset, " if (_propset_%s(property_reference, value)==SUCCESS) return SUCCESS;\n", shadow_classname); - Printf(s_propset, " /* set it ourselves as it is %s */\n", shadow_classname); - Printf(s_propset, " MAKE_STD_ZVAL(_value);\n"); - Printf(s_propset, " *_value=*value;\n"); - Printf(s_propset, " INIT_PZVAL(_value);\n"); - Printf(s_propset, " zval_copy_ctor(_value);\n"); - Printf(s_propset, - " return add_property_zval_ex(property_reference->object,Z_STRVAL_P(&(property->element)),1+Z_STRLEN_P(&(property->element)),_value);\n"); - Printf(s_propset, "}\n"); - Printf(s_propset, "static int _propset_%s(zend_property_reference *property_reference, pval *value) {\n", shadow_classname); - - - if (baselist) { - base = First(baselist); - } else { - base.item = NULL; - } - - while (base.item && GetFlag(base.item, "feature:ignore")) { - base = Next(base); - } - - ki = First(shadow_set_vars); - key = ki.key; - - // Print function header; we only need to find property name if there - // are properties for this class to look up... - if (key || !base.item) { // or if we are base class and set it ourselves - Printf(s_propset, " /* get the property name */\n"); - Printf(s_propset, " zend_llist_element *element = property_reference->elements_list->head;\n"); - Printf(s_propset, " zend_overloaded_element *property=(zend_overloaded_element *)element->data;\n"); - Printf(s_propset, " char *propname=Z_STRVAL_P(&(property->element));\n"); - } else { - if (base.item) { - Printf(s_propset, " /* No extra properties for subclass %s */\n", shadow_classname); - } else { - Printf(s_propset, " /* No properties for base class %s */\n", shadow_classname); - } - } - - while (ki.key) { - key = ki.key; - Printf(s_propset, " if (strcmp(propname,\"%s\")==0) return _wrap_%s(property_reference, value);\n", ki.item, key); - - ki = Next(ki); - } - - // If the property wasn't in this class, try the handlers of each base - // class (if any) in turn until we succeed in setting the property or - // have tried all base classes. - if (base.item) { - Printf(s_propset, " /* Try base class(es) */\n"); - while (base.item) { - Printf(s_propset, " if (_propset_%s(property_reference, value)==SUCCESS) return SUCCESS;\n", GetChar(base.item, "sym:name")); - - base = Next(base); - while (base.item && GetFlag(base.item, "feature:ignore")) { - base = Next(base); - } - } - } - Printf(s_propset, " return FAILURE;\n}\n\n"); - - // ******** Write property GET handlers - Printf(s_header, "static pval _wrap_propget_%s(zend_property_reference *property_reference);\n", shadow_classname); - Printf(s_header, "static int _propget_%s(zend_property_reference *property_reference, pval *value);\n", shadow_classname); - - Printf(s_propget, "static pval _wrap_propget_%s(zend_property_reference *property_reference) {\n", shadow_classname); - Printf(s_propget, " pval result;\n"); - Printf(s_propget, " pval **_result;\n"); - Printf(s_propget, " zend_llist_element *element = property_reference->elements_list->head;\n"); - Printf(s_propget, " zend_overloaded_element *property=(zend_overloaded_element *)element->data;\n"); - Printf(s_propget, " result.type = IS_NULL;\n"); - Printf(s_propget, " if (_propget_%s(property_reference, &result)==SUCCESS) return result;\n", shadow_classname); - Printf(s_propget, " /* return it ourselves */\n"); - Printf(s_propget, - " if (zend_hash_find(Z_OBJPROP_P(property_reference->object),Z_STRVAL_P(&(property->element)),1+Z_STRLEN_P(&(property->element)),(void**)&_result)==SUCCESS) {\n"); - Printf(s_propget, " zval *_value;\n"); - Printf(s_propget, " MAKE_STD_ZVAL(_value);"); - Printf(s_propget, " *_value=**_result;\n"); - Printf(s_propget, " INIT_PZVAL(_value);\n"); - Printf(s_propget, " zval_copy_ctor(_value);\n"); - Printf(s_propget, " return *_value;\n"); - Printf(s_propget, " }\n"); - Printf(s_propget, " result.type = IS_NULL;\n"); - Printf(s_propget, " return result;\n"); - Printf(s_propget, "}\n"); - Printf(s_propget, "static int _propget_%s(zend_property_reference *property_reference, pval *value) {\n", shadow_classname); - - if (baselist) { - base = First(baselist); - } else { - base.item = NULL; - } - while (base.item && GetFlag(base.item, "feature:ignore")) { - base = Next(base); - } - ki = First(shadow_get_vars); - - key = ki.key; - - // Print function header; we only need to find property name if there - // are properties for this class to look up... - if (key || !base.item) { // or if we are base class... - Printf(s_propget, " /* get the property name */\n"); - Printf(s_propget, " zend_llist_element *element = property_reference->elements_list->head;\n"); - Printf(s_propget, " zend_overloaded_element *property=(zend_overloaded_element *)element->data;\n"); - Printf(s_propget, " char *propname=Z_STRVAL_P(&(property->element));\n"); - } else { - if (base.item) { - Printf(s_propget, " /* No extra properties for subclass %s */\n", shadow_classname); - } else { - Printf(s_propget, " /* No properties for base class %s */\n", shadow_classname); - } - } - - while (ki.key) { - key = ki.key; - Printf(s_propget, " if (strcmp(propname,\"%s\")==0) {\n", ki.item); - Printf(s_propget, " *value=_wrap_%s(property_reference);\n", key); - Printf(s_propget, " return SUCCESS;\n"); - Printf(s_propget, " }\n"); - - ki = Next(ki); - } - - // If the property wasn't in this class, try the handlers of each base - // class (if any) in turn until we succeed in setting the property or - // have tried all base classes. - if (base.item) { - Printf(s_propget, " /* Try base class(es). */\n"); - while (base.item) { - Printf(s_propget, " if (_propget_%s(property_reference, value)==SUCCESS) return SUCCESS;\n", GetChar(base.item, "sym:name")); - - base = Next(base); - while (base.item && GetFlag(base.item, "feature:ignore")) { - base = Next(base); - } - } - } - Printf(s_propget, " return FAILURE;\n}\n\n"); - - // wrappers generated now... - - // add wrappers to output code - Printf(s_wrappers, "/* property handler for class %s */\n", shadow_classname); - Printv(s_wrappers, s_propget, s_propset, NIL); - - // Save class in class table - if (baselist) { - base = First(baselist); - } else { - base.item = NULL; - } - while (base.item && GetFlag(base.item, "feature:ignore")) { - base = Next(base); - } - - if (base.item) { - Printf(s_oinit, - "if (! (ptr_ce_swig_%s=zend_register_internal_class_ex(&ce_swig_%s,&ce_swig_%s,NULL TSRMLS_CC))) zend_error(E_ERROR,\"Error registering wrapper for class %s\");\n", - shadow_classname, shadow_classname, GetChar(base.item, "sym:name"), shadow_classname); - } else { - Printf(s_oinit, - "if (! (ptr_ce_swig_%s=zend_register_internal_class_ex(&ce_swig_%s,NULL,NULL TSRMLS_CC))) zend_error(E_ERROR,\"Error registering wrapper for class %s\");\n", - shadow_classname, shadow_classname, shadow_classname); - } - Printf(s_oinit, "\n"); - - // Write the enum initialisation code in a static block - // These are all the enums defined within the C++ class. - - Delete(shadow_classname); - shadow_classname = NULL; - - Delete(shadow_set_vars); - shadow_set_vars = NULL; - Delete(shadow_get_vars); - shadow_get_vars = NULL; - - Printv(all_cs_entry, cs_entry, " { NULL, NULL, NULL}\n};\n", NIL); - Delete(cs_entry); - cs_entry = NULL; - } else if (shadow && php_version == 5) { + if (shadow) { DOH *key; List *baselist = Getattr(n, "bases"); Iterator ki, base; @@ -2434,21 +2075,10 @@ public: * ------------------------------------------------------------ */ virtual int memberfunctionHandler(Node *n) { - char *name = GetChar(n, "name"); - char *iname = GetChar(n, "sym:name"); - wrapperType = memberfn; this->Language::memberfunctionHandler(n); wrapperType = standard; - // Only declare the member function if - // we are doing shadow classes, and the function - // is not overloaded, or if it is overloaded, it is the dispatch function. - if (shadow && php_version == 4 && (!Getattr(n, "sym:overloaded") || !Getattr(n, "sym:nextSibling"))) { - char *realname = iname ? iname : name; - String *php_function_name = Swig_name_member(shadow_classname, realname); - create_command(realname, Swig_name_wrapper(php_function_name)); - } return SWIG_OK; } @@ -2457,7 +2087,6 @@ public: * ------------------------------------------------------------ */ virtual int membervariableHandler(Node *n) { - wrapperType = membervar; Language::membervariableHandler(n); wrapperType = standard; @@ -2470,7 +2099,6 @@ public: * ------------------------------------------------------------ */ virtual int staticmembervariableHandler(Node *n) { - wrapperType = staticmembervar; Language::staticmembervariableHandler(n); wrapperType = standard; @@ -2492,12 +2120,13 @@ public: * 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 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. + // 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); @@ -2542,20 +2171,10 @@ public: * ------------------------------------------------------------ */ virtual int staticmemberfunctionHandler(Node *n) { - char *name = GetChar(n, "name"); - char *iname = GetChar(n, "sym:name"); - wrapperType = staticmemberfn; Language::staticmemberfunctionHandler(n); wrapperType = standard; - if (shadow && php_version == 4) { - String *symname = Getattr(n, "sym:name"); - char *realname = iname ? iname : name; - String *php_function_name = Swig_name_member(shadow_classname, realname); - create_command(symname, Swig_name_wrapper(php_function_name)); - } - return SWIG_OK; } @@ -2605,54 +2224,20 @@ public: return NewStringf("%s", tms); } - int abstractConstructorHandler(Node *n) { - String *iname = GetChar(n, "sym:name"); - if (shadow && php_version == 4) { - Wrapper *f = NewWrapper(); - - String *wname = NewStringf("_wrap_new_%s", iname); - create_command(iname, wname); - - Printf(f->def, "ZEND_NAMED_FUNCTION(_wrap_new_%s) {\n", iname); - Printf(f->def, " zend_error(E_ERROR,\"Cannot create swig object type: %s as the underlying class is abstract\");\n", iname); - Printf(f->def, "}\n\n"); - Wrapper_print(f, s_wrappers); - DelWrapper(f); - Delete(wname); - } + int abstractConstructorHandler(Node *) { return SWIG_OK; } + /* ------------------------------------------------------------ * constructorHandler() * ------------------------------------------------------------ */ virtual int constructorHandler(Node *n) { - char *name = GetChar(n, "name"); - char *iname = GetChar(n, "sym:name"); - - if (shadow && php_version == 4) { - if (iname && strcmp(iname, Char(shadow_classname)) == 0) { - native_constructor = NATIVE_CONSTRUCTOR; - } else { - native_constructor = ALTERNATIVE_CONSTRUCTOR; - } - } else { - native_constructor = 0; - } constructors++; wrapperType = constructor; Language::constructorHandler(n); wrapperType = standard; - if (shadow && php_version == 4) { - if (!Getattr(n, "sym:overloaded") || !Getattr(n, "sym:nextSibling")) { - char *realname = iname ? iname : name; - String *php_function_name = Swig_name_construct(realname); - create_command(realname, Swig_name_wrapper(php_function_name)); - } - } - - native_constructor = 0; return SWIG_OK; } @@ -2763,9 +2348,14 @@ static Language *new_swig_php(int php_version) { } return maininstance; } + extern "C" Language *swig_php4(void) { - return new_swig_php(4); + Printf(stderr, "*** -php4 is no longer supported.\n" + "*** Either upgrade to PHP5 or use SWIG 1.3.36 or earlier.\n"); + SWIG_exit(EXIT_FAILURE); + return NULL; // To avoid compiler warnings. } + extern "C" Language *swig_php5(void) { return new_swig_php(5); } diff --git a/Source/Modules/swigmain.cxx b/Source/Modules/swigmain.cxx index 3b60f2259..5b103e71e 100644 --- a/Source/Modules/swigmain.cxx +++ b/Source/Modules/swigmain.cxx @@ -74,8 +74,8 @@ static swig_module modules[] = { {"-octave", swig_octave, "Octave"}, {"-perl", swig_perl5, "Perl"}, {"-perl5", swig_perl5, 0}, - {"-php", swig_php4, 0}, - {"-php4", swig_php4, "PHP4"}, + {"-php", swig_php5, 0}, + {"-php4", swig_php4, 0}, {"-php5", swig_php5, "PHP5"}, {"-pike", swig_pike, "Pike"}, {"-python", swig_python, "Python"}, From 9fbab46bd4bff86e2db11089873d74a60d9e0c5a Mon Sep 17 00:00:00 2001 From: Haoyu Bai Date: Wed, 2 Jul 2008 06:06:56 +0000 Subject: [PATCH 0062/1680] fix the previous commit -- new approach using imp module git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10627 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/python.cxx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 5e6f45637..cf92514d3 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -701,10 +701,11 @@ public: * code conditional on the python version. */ Printv(f_shadow, "if version_info >= (2,6,0):\n", NULL); - Printv(f_shadow, tab4, "try:\n", NULL); - Printf(f_shadow, tab8 "from . import %s\n", module); - Printv(f_shadow, tab4, "except ValueError:\n"); - Printf(f_shadow, tab8 "import %s\n", module); + Printv(f_shadow, tab4, "from os.path import dirname\n", NULL); + Printv(f_shadow, tab4, "import imp\n", NULL); + Printf(f_shadow, tab4 "fp, pathname, description = imp.find_module('%s', [dirname(__file__)])\n", module); + Printf(f_shadow, tab4 "%s = imp.load_module('%s', fp, pathname, description)\n", module, module); + Printv(f_shadow, tab4, "del fp, pathname, description, imp, dirname\n", NULL); Printv(f_shadow, "else:\n", NULL); Printf(f_shadow, tab4 "import %s\n", module); From 4d3e448b386aa56a20f85776e5a553deb3d7762f Mon Sep 17 00:00:00 2001 From: Haoyu Bai Date: Wed, 2 Jul 2008 06:29:15 +0000 Subject: [PATCH 0063/1680] minor fix on relative import: close fp if exception occured during imp.find_module git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10628 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/python.cxx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index cf92514d3..d22fa256e 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -703,8 +703,11 @@ public: Printv(f_shadow, "if version_info >= (2,6,0):\n", NULL); Printv(f_shadow, tab4, "from os.path import dirname\n", NULL); Printv(f_shadow, tab4, "import imp\n", NULL); - Printf(f_shadow, tab4 "fp, pathname, description = imp.find_module('%s', [dirname(__file__)])\n", module); - Printf(f_shadow, tab4 "%s = imp.load_module('%s', fp, pathname, description)\n", module, module); + Printv(f_shadow, tab4, "try:\n", NULL); + Printf(f_shadow, tab8 "fp, pathname, description = imp.find_module('%s', [dirname(__file__)])\n", module); + Printf(f_shadow, tab8 "%s = imp.load_module('%s', fp, pathname, description)\n", module, module); + Printv(f_shadow, tab4, "except:\n", NULL); + Printf(f_shadow, tab8, "if fp is not None: fp.close()\n", NULL); Printv(f_shadow, tab4, "del fp, pathname, description, imp, dirname\n", NULL); Printv(f_shadow, "else:\n", NULL); Printf(f_shadow, tab4 "import %s\n", module); From 9fc127d68b140f4631b436413f1a6d80b75c06af Mon Sep 17 00:00:00 2001 From: Haoyu Bai Date: Wed, 2 Jul 2008 07:08:00 +0000 Subject: [PATCH 0064/1680] reconstruct the relative import, now the generated code looks better git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10629 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/python.cxx | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index d22fa256e..ddd23d1f3 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -701,14 +701,17 @@ public: * code conditional on the python version. */ Printv(f_shadow, "if version_info >= (2,6,0):\n", NULL); - Printv(f_shadow, tab4, "from os.path import dirname\n", NULL); - Printv(f_shadow, tab4, "import imp\n", NULL); - Printv(f_shadow, tab4, "try:\n", NULL); - Printf(f_shadow, tab8 "fp, pathname, description = imp.find_module('%s', [dirname(__file__)])\n", module); - Printf(f_shadow, tab8 "%s = imp.load_module('%s', fp, pathname, description)\n", module, module); - Printv(f_shadow, tab4, "except:\n", NULL); - Printf(f_shadow, tab8, "if fp is not None: fp.close()\n", NULL); - Printv(f_shadow, tab4, "del fp, pathname, description, imp, dirname\n", NULL); + Printv(f_shadow, tab4, "def swig_import_helper():\n", NULL); + Printv(f_shadow, tab8, "from os.path import dirname\n", NULL); + Printv(f_shadow, tab8, "import imp\n", NULL); + Printv(f_shadow, tab8, "try:\n", NULL); + Printf(f_shadow, tab4 tab8 "fp, pathname, description = imp.find_module('%s', [dirname(__file__)])\n", module); + Printf(f_shadow, tab4 tab8 "_mod = imp.load_module('%s', fp, pathname, description)\n", module); + Printv(f_shadow, tab8, "finally:\n", NULL); + Printv(f_shadow, tab4 tab8, "if fp is not None: fp.close()\n", NULL); + Printv(f_shadow, tab8, "return _mod\n", NULL); + Printf(f_shadow, tab4 "%s = swig_import_helper()\n", module); + Printv(f_shadow, tab4, "del swig_import_helper\n", NULL); Printv(f_shadow, "else:\n", NULL); Printf(f_shadow, tab4 "import %s\n", module); From 7dfd9aae311c04a99453bcabc4204646bb458b87 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Thu, 3 Jul 2008 00:09:56 +0000 Subject: [PATCH 0065/1680] WARN_* constants are user visible, so keep existing WARN_PHP4_* for backward compatibility, but add preferred forms WARN_PHP_* and use these ourselves. Rename Lib/php4 to Lib/php, Source/Modules/php4.cxx to Source/Modules/php.cxx. Add typemaps for const reference so Examples/test-suite/apply_signed_char.i works. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10633 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/abstract_virtual.i | 4 +- Examples/test-suite/contract.i | 2 +- Examples/test-suite/default_constructor.i | 4 +- Examples/test-suite/evil_diamond.i | 2 +- Examples/test-suite/evil_diamond_ns.i | 2 +- Examples/test-suite/evil_diamond_prop.i | 2 +- Examples/test-suite/multiple_inheritance.i | 4 +- Examples/test-suite/pure_virtual.i | 2 +- .../test-suite/template_inherit_abstract.i | 2 +- Examples/test-suite/using_composition.i | 6 +- Examples/test-suite/using_extend.i | 2 +- Examples/test-suite/using_namespace.i | 2 +- Lib/{php4 => php}/const.i | 0 Lib/{php4 => php}/globalvar.i | 0 Lib/{php4 => php}/php4.swg | 0 Lib/{php4 => php}/php4init.swg | 0 Lib/{php4 => php}/php4kw.swg | 0 Lib/{php4 => php}/php4run.swg | 0 Lib/{php4 => php}/phppointers.i | 0 Lib/{php4 => php}/std_common.i | 0 Lib/{php4 => php}/std_deque.i | 0 Lib/{php4 => php}/std_map.i | 0 Lib/{php4 => php}/std_pair.i | 0 Lib/{php4 => php}/std_string.i | 0 Lib/{php4 => php}/std_vector.i | 0 Lib/{php4 => php}/stl.i | 0 Lib/{php4 => php}/typemaps.i | 0 Lib/{php4 => php}/utils.i | 2 +- Source/Include/swigwarn.h | 13 +- Source/Makefile.am | 2 +- Source/Modules/php.cxx | 2359 +++++++++++++++++ Source/Modules/{php4.cxx => php5.cxx} | 0 32 files changed, 2388 insertions(+), 22 deletions(-) rename Lib/{php4 => php}/const.i (100%) rename Lib/{php4 => php}/globalvar.i (100%) rename Lib/{php4 => php}/php4.swg (100%) rename Lib/{php4 => php}/php4init.swg (100%) rename Lib/{php4 => php}/php4kw.swg (100%) rename Lib/{php4 => php}/php4run.swg (100%) rename Lib/{php4 => php}/phppointers.i (100%) rename Lib/{php4 => php}/std_common.i (100%) rename Lib/{php4 => php}/std_deque.i (100%) rename Lib/{php4 => php}/std_map.i (100%) rename Lib/{php4 => php}/std_pair.i (100%) rename Lib/{php4 => php}/std_string.i (100%) rename Lib/{php4 => php}/std_vector.i (100%) rename Lib/{php4 => php}/stl.i (100%) rename Lib/{php4 => php}/typemaps.i (100%) rename Lib/{php4 => php}/utils.i (97%) create mode 100644 Source/Modules/php.cxx rename Source/Modules/{php4.cxx => php5.cxx} (100%) diff --git a/Examples/test-suite/abstract_virtual.i b/Examples/test-suite/abstract_virtual.i index e2d8054bb..2e4d105b1 100644 --- a/Examples/test-suite/abstract_virtual.i +++ b/Examples/test-suite/abstract_virtual.i @@ -2,10 +2,10 @@ %warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE, SWIGWARN_CSHARP_MULTIPLE_INHERITANCE, - SWIGWARN_PHP4_MULTIPLE_INHERITANCE) D; /* C#, Java, Php4 multiple inheritance */ + SWIGWARN_PHP_MULTIPLE_INHERITANCE) D; /* C#, Java, PHP multiple inheritance */ %warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE, SWIGWARN_CSHARP_MULTIPLE_INHERITANCE, - SWIGWARN_PHP4_MULTIPLE_INHERITANCE) E; /* C#, Java, Php4 multiple inheritance */ + SWIGWARN_PHP_MULTIPLE_INHERITANCE) E; /* C#, Java, PHP multiple inheritance */ %inline %{ #if defined(_MSC_VER) diff --git a/Examples/test-suite/contract.i b/Examples/test-suite/contract.i index 6ee0a353c..a5732105b 100644 --- a/Examples/test-suite/contract.i +++ b/Examples/test-suite/contract.i @@ -3,7 +3,7 @@ %warnfilter(SWIGWARN_RUBY_MULTIPLE_INHERITANCE, SWIGWARN_JAVA_MULTIPLE_INHERITANCE, SWIGWARN_CSHARP_MULTIPLE_INHERITANCE, - SWIGWARN_PHP4_MULTIPLE_INHERITANCE) C; /* Ruby, C#, Java, Php4 multiple inheritance */ + SWIGWARN_PHP_MULTIPLE_INHERITANCE) C; /* Ruby, C#, Java, PHP multiple inheritance */ #ifdef SWIGCSHARP %ignore B::bar; // otherwise get a warning: `C.bar' no suitable methods found to override diff --git a/Examples/test-suite/default_constructor.i b/Examples/test-suite/default_constructor.i index 71600e55a..ff22c7834 100644 --- a/Examples/test-suite/default_constructor.i +++ b/Examples/test-suite/default_constructor.i @@ -5,11 +5,11 @@ %warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE, SWIGWARN_CSHARP_MULTIPLE_INHERITANCE, - SWIGWARN_PHP4_MULTIPLE_INHERITANCE) EB; /* C#, Java, Php4 multiple inheritance */ + SWIGWARN_PHP_MULTIPLE_INHERITANCE) EB; /* C#, Java, PHP multiple inheritance */ %warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE, SWIGWARN_CSHARP_MULTIPLE_INHERITANCE, - SWIGWARN_PHP4_MULTIPLE_INHERITANCE) AD; /* C#, Java, Php4 multiple inheritance */ + SWIGWARN_PHP_MULTIPLE_INHERITANCE) AD; /* C#, Java, PHP multiple inheritance */ %warnfilter(SWIGWARN_LANG_FRIEND_IGNORE) F; /* friend function */ diff --git a/Examples/test-suite/evil_diamond.i b/Examples/test-suite/evil_diamond.i index 33353e32e..7b2e9152f 100644 --- a/Examples/test-suite/evil_diamond.i +++ b/Examples/test-suite/evil_diamond.i @@ -6,7 +6,7 @@ %warnfilter(SWIGWARN_RUBY_WRONG_NAME, SWIGWARN_JAVA_MULTIPLE_INHERITANCE, SWIGWARN_CSHARP_MULTIPLE_INHERITANCE, - SWIGWARN_PHP4_MULTIPLE_INHERITANCE) spam; // Ruby, wrong class name - C# & Java, Php4 multiple inheritance + SWIGWARN_PHP_MULTIPLE_INHERITANCE) spam; // Ruby, wrong class name - C# & Java, PHP multiple inheritance %inline %{ diff --git a/Examples/test-suite/evil_diamond_ns.i b/Examples/test-suite/evil_diamond_ns.i index 78a764ccc..515044007 100644 --- a/Examples/test-suite/evil_diamond_ns.i +++ b/Examples/test-suite/evil_diamond_ns.i @@ -6,7 +6,7 @@ %warnfilter(SWIGWARN_RUBY_WRONG_NAME, SWIGWARN_JAVA_MULTIPLE_INHERITANCE, SWIGWARN_CSHARP_MULTIPLE_INHERITANCE, - SWIGWARN_PHP4_MULTIPLE_INHERITANCE) Blah::spam; // Ruby, wrong class name - C# & Java, Php4 multiple inheritance + SWIGWARN_PHP_MULTIPLE_INHERITANCE) Blah::spam; // Ruby, wrong class name - C# & Java, PHP multiple inheritance %inline %{ namespace Blah { diff --git a/Examples/test-suite/evil_diamond_prop.i b/Examples/test-suite/evil_diamond_prop.i index e9fc24f4d..804ea66b4 100644 --- a/Examples/test-suite/evil_diamond_prop.i +++ b/Examples/test-suite/evil_diamond_prop.i @@ -6,7 +6,7 @@ %warnfilter(SWIGWARN_RUBY_WRONG_NAME, SWIGWARN_JAVA_MULTIPLE_INHERITANCE, SWIGWARN_CSHARP_MULTIPLE_INHERITANCE, - SWIGWARN_PHP4_MULTIPLE_INHERITANCE) spam; // Ruby, wrong class name - C# & Java, Php4 multiple inheritance + SWIGWARN_PHP_MULTIPLE_INHERITANCE) spam; // Ruby, wrong class name - C# & Java, PHP multiple inheritance %inline %{ diff --git a/Examples/test-suite/multiple_inheritance.i b/Examples/test-suite/multiple_inheritance.i index 1c4458114..1fc68eef9 100644 --- a/Examples/test-suite/multiple_inheritance.i +++ b/Examples/test-suite/multiple_inheritance.i @@ -5,11 +5,11 @@ It tests basic multiple inheritance */ %warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE, SWIGWARN_CSHARP_MULTIPLE_INHERITANCE, - SWIGWARN_PHP4_MULTIPLE_INHERITANCE) FooBar; /* C#, Java, Php4 multiple inheritance */ + SWIGWARN_PHP_MULTIPLE_INHERITANCE) FooBar; /* C#, Java, PHP multiple inheritance */ %warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE, SWIGWARN_CSHARP_MULTIPLE_INHERITANCE, - SWIGWARN_PHP4_MULTIPLE_INHERITANCE) FooBarSpam; /* C#, Java, Php4 multiple inheritance */ + SWIGWARN_PHP_MULTIPLE_INHERITANCE) FooBarSpam; /* C#, Java, PHP multiple inheritance */ %inline %{ diff --git a/Examples/test-suite/pure_virtual.i b/Examples/test-suite/pure_virtual.i index b41e48a89..aab9741a9 100644 --- a/Examples/test-suite/pure_virtual.i +++ b/Examples/test-suite/pure_virtual.i @@ -9,7 +9,7 @@ %warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE, SWIGWARN_CSHARP_MULTIPLE_INHERITANCE, - SWIGWARN_PHP4_MULTIPLE_INHERITANCE) E; /* C#, Java, Php4 multiple inheritance */ + SWIGWARN_PHP_MULTIPLE_INHERITANCE) E; /* C#, Java, PHP multiple inheritance */ %nodefaultctor C; %nodefaultdtor C; diff --git a/Examples/test-suite/template_inherit_abstract.i b/Examples/test-suite/template_inherit_abstract.i index f676b3b3e..89d983de0 100644 --- a/Examples/test-suite/template_inherit_abstract.i +++ b/Examples/test-suite/template_inherit_abstract.i @@ -4,7 +4,7 @@ %warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE, SWIGWARN_CSHARP_MULTIPLE_INHERITANCE, - SWIGWARN_PHP4_MULTIPLE_INHERITANCE) oss::Module; /* C#, Java, Php4 multiple inheritance */ + SWIGWARN_PHP_MULTIPLE_INHERITANCE) oss::Module; /* C#, Java, PHP multiple inheritance */ %inline %{ diff --git a/Examples/test-suite/using_composition.i b/Examples/test-suite/using_composition.i index 7bb6add2a..bd0f712b5 100644 --- a/Examples/test-suite/using_composition.i +++ b/Examples/test-suite/using_composition.i @@ -2,13 +2,13 @@ %warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE, SWIGWARN_CSHARP_MULTIPLE_INHERITANCE, - SWIGWARN_PHP4_MULTIPLE_INHERITANCE) FooBar; // C#, Java, Php4 multiple inheritance + SWIGWARN_PHP_MULTIPLE_INHERITANCE) FooBar; // C#, Java, PHP multiple inheritance %warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE, SWIGWARN_CSHARP_MULTIPLE_INHERITANCE, - SWIGWARN_PHP4_MULTIPLE_INHERITANCE) FooBar2; // C#, Java, Php4 multiple inheritance + SWIGWARN_PHP_MULTIPLE_INHERITANCE) FooBar2; // C#, Java, PHP multiple inheritance %warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE, SWIGWARN_CSHARP_MULTIPLE_INHERITANCE, - SWIGWARN_PHP4_MULTIPLE_INHERITANCE) FooBar3; // C#, Java, Php4 multiple inheritance + SWIGWARN_PHP_MULTIPLE_INHERITANCE) FooBar3; // C#, Java, PHP multiple inheritance #ifdef SWIGLUA // lua only has one numeric type, so some overloads shadow each other creating warnings %warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) blah; #endif diff --git a/Examples/test-suite/using_extend.i b/Examples/test-suite/using_extend.i index 414ceedb4..e14cc28e8 100644 --- a/Examples/test-suite/using_extend.i +++ b/Examples/test-suite/using_extend.i @@ -2,7 +2,7 @@ %warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE, SWIGWARN_CSHARP_MULTIPLE_INHERITANCE, - SWIGWARN_PHP4_MULTIPLE_INHERITANCE) FooBar; // C#, Java, Php4 multiple inheritance + SWIGWARN_PHP_MULTIPLE_INHERITANCE) FooBar; // C#, Java, PHP multiple inheritance #ifdef SWIGLUA // lua only has one numeric type, so some overloads shadow each other creating warnings %warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) blah; #endif diff --git a/Examples/test-suite/using_namespace.i b/Examples/test-suite/using_namespace.i index 1989b6a0d..799c7cfb5 100644 --- a/Examples/test-suite/using_namespace.i +++ b/Examples/test-suite/using_namespace.i @@ -5,7 +5,7 @@ %warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE, SWIGWARN_CSHARP_MULTIPLE_INHERITANCE, - SWIGWARN_PHP4_MULTIPLE_INHERITANCE) Hi; // C#, Java, Php4 multiple inheritance + SWIGWARN_PHP_MULTIPLE_INHERITANCE) Hi; // C#, Java, PHP multiple inheritance %inline %{ namespace hello diff --git a/Lib/php4/const.i b/Lib/php/const.i similarity index 100% rename from Lib/php4/const.i rename to Lib/php/const.i diff --git a/Lib/php4/globalvar.i b/Lib/php/globalvar.i similarity index 100% rename from Lib/php4/globalvar.i rename to Lib/php/globalvar.i diff --git a/Lib/php4/php4.swg b/Lib/php/php4.swg similarity index 100% rename from Lib/php4/php4.swg rename to Lib/php/php4.swg diff --git a/Lib/php4/php4init.swg b/Lib/php/php4init.swg similarity index 100% rename from Lib/php4/php4init.swg rename to Lib/php/php4init.swg diff --git a/Lib/php4/php4kw.swg b/Lib/php/php4kw.swg similarity index 100% rename from Lib/php4/php4kw.swg rename to Lib/php/php4kw.swg diff --git a/Lib/php4/php4run.swg b/Lib/php/php4run.swg similarity index 100% rename from Lib/php4/php4run.swg rename to Lib/php/php4run.swg diff --git a/Lib/php4/phppointers.i b/Lib/php/phppointers.i similarity index 100% rename from Lib/php4/phppointers.i rename to Lib/php/phppointers.i diff --git a/Lib/php4/std_common.i b/Lib/php/std_common.i similarity index 100% rename from Lib/php4/std_common.i rename to Lib/php/std_common.i diff --git a/Lib/php4/std_deque.i b/Lib/php/std_deque.i similarity index 100% rename from Lib/php4/std_deque.i rename to Lib/php/std_deque.i diff --git a/Lib/php4/std_map.i b/Lib/php/std_map.i similarity index 100% rename from Lib/php4/std_map.i rename to Lib/php/std_map.i diff --git a/Lib/php4/std_pair.i b/Lib/php/std_pair.i similarity index 100% rename from Lib/php4/std_pair.i rename to Lib/php/std_pair.i diff --git a/Lib/php4/std_string.i b/Lib/php/std_string.i similarity index 100% rename from Lib/php4/std_string.i rename to Lib/php/std_string.i diff --git a/Lib/php4/std_vector.i b/Lib/php/std_vector.i similarity index 100% rename from Lib/php4/std_vector.i rename to Lib/php/std_vector.i diff --git a/Lib/php4/stl.i b/Lib/php/stl.i similarity index 100% rename from Lib/php4/stl.i rename to Lib/php/stl.i diff --git a/Lib/php4/typemaps.i b/Lib/php/typemaps.i similarity index 100% rename from Lib/php4/typemaps.i rename to Lib/php/typemaps.i diff --git a/Lib/php4/utils.i b/Lib/php/utils.i similarity index 97% rename from Lib/php4/utils.i rename to Lib/php/utils.i index f7241187c..77c9e923e 100644 --- a/Lib/php4/utils.i +++ b/Lib/php/utils.i @@ -29,7 +29,7 @@ %enddef %define %pass_by_val( TYPE, CONVERT_IN ) -%typemap(in) TYPE +%typemap(in) TYPE, const TYPE & %{ CONVERT_IN($1,$1_ltype,$input); %} diff --git a/Source/Include/swigwarn.h b/Source/Include/swigwarn.h index 174e8b001..8c4678847 100644 --- a/Source/Include/swigwarn.h +++ b/Source/Include/swigwarn.h @@ -247,10 +247,17 @@ /* please leave 850-869 free for Modula 3 */ -#define WARN_PHP4_MULTIPLE_INHERITANCE 870 -#define WARN_PHP4_UNKNOWN_PRAGMA 871 +/* 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_PHP4_MULTIPLE_INHERITANCE 870 +#define WARN_PHP4_UNKNOWN_PRAGMA 871 -/* please leave 870-889 free for Php */ +#define WARN_PHP_MULTIPLE_INHERITANCE 870 +#define WARN_PHP_UNKNOWN_PRAGMA 871 + +/* please leave 870-889 free for PHP */ /* Feel free to claim any number in this space that's not currently being used. Just make sure you diff --git a/Source/Makefile.am b/Source/Makefile.am index a72671305..84c595bc0 100644 --- a/Source/Makefile.am +++ b/Source/Makefile.am @@ -57,7 +57,7 @@ eswig_SOURCES = CParse/cscanner.c \ Modules/octave.cxx \ Modules/overload.cxx \ Modules/perl5.cxx \ - Modules/php4.cxx \ + Modules/php.cxx \ Modules/pike.cxx \ Modules/python.cxx \ Modules/r.cxx \ diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx new file mode 100644 index 000000000..77f3e0d73 --- /dev/null +++ b/Source/Modules/php.cxx @@ -0,0 +1,2359 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * php4.cxx + * + * Php language module for SWIG. + * ----------------------------------------------------------------------------- + */ + +/* FIXME: PHP5 OO wrapping TODO list: + * + * 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: + * + * Handle default parameters on overloaded methods in PHP where possible. + * (Mostly done - just need to handle cases of overloaded methods with + * default parameters...) + * This is an optimisation - we could handle this case using a PHP + * default value, but currently we treat it as we would for a default + * value which is a compound C++ expression (i.e. as if we had a + * method with two overloaded forms instead of a single method with + * a default parameter value). + * + * Long term: + * + * Sort out locale-dependent behaviour of strtod() - it's harmless unless + * SWIG ever sets the locale and DOH/base.c calls atof, so we're probably + * OK currently at least. + */ + +/* + * TODO: Replace remaining stderr messages with Swig_error or Swig_warning + * (may need to add more WARN_PHP_xxx codes...) + */ + +char cvsroot_php4_cxx[] = "$Id$"; + +#include "swigmod.h" + +#include +#include + +static const char *usage = (char *) "\ +PHP Options (available with -php5)\n\ + -cppext - cpp file extension (default to .cpp)\n\ + -noproxy - Don't generate proxy classes.\n\ + -prefix - Prepend to all class names in PHP5 wrappers\n\ + -make - Create simple makefile\n\ + -phpfull - Create full make files\n\ + -withincs - With -phpfull writes needed incs in config.m4\n\ + -withlibs - With -phpfull writes needed libs in config.m4\n\ + -withc - With -phpfull makes extra C files in Makefile.in\n\ + -withcxx - With -phpfull makes extra C++ files in Makefile.in\n\ +\n"; + +/* The original class wrappers for PHP4 store the pointer to the C++ class in + * the object property _cPtr. If we use the same name for the member variable + * which we put the pointer to the C++ class in, then the flat function + * wrappers will automatically pull it out without any changes being required. + * FIXME: Isn't using a leading underscore a bit suspect here? + */ +#define SWIG_PTR "_cPtr" + +static int constructors = 0; +static String *NOTCLASS = NewString("Not a class"); +static Node *classnode = 0; +static String *module = 0; +static String *cap_module = 0; +static String *prefix = 0; +static String *withlibs = 0; +static String *withincs = 0; +static String *withc = 0; +static String *withcxx = 0; + +static String *shadow_classname = 0; + +static int gen_extra = 0; +static int gen_make = 0; + +static File *f_runtime = 0; +static File *f_h = 0; +static File *f_phpcode = 0; +static String *phpfilename = 0; + +static String *s_header; +static String *s_wrappers; +static String *s_init; +static String *r_init; // RINIT user code +static String *s_shutdown; // MSHUTDOWN user code +static String *r_shutdown; // RSHUTDOWN user code +static String *s_vinit; // varinit initialization code. +static String *s_vdecl; +static String *s_cinit; // consttab initialization code. +static String *s_oinit; +static String *s_entry; +static String *cs_entry; +static String *all_cs_entry; +static String *pragma_incl; +static String *pragma_code; +static String *pragma_phpinfo; +static String *s_oowrappers; +static String *s_fakeoowrappers; +static String *s_phpclasses; + +/* Variables for using PHP classes */ +static Node *current_class = 0; + +static Hash *shadow_get_vars; +static Hash *shadow_set_vars; +static Hash *zend_types = 0; + +static int shadow = 1; + +static bool class_has_ctor = false; +static String *wrapping_member_constant = NULL; + +// These static variables are used to pass some state from Handlers into functionWrapper +static enum { + standard = 0, + memberfn, + staticmemberfn, + membervar, + staticmembervar, + constructor, + destructor +} wrapperType = standard; + +extern "C" { + static void (*r_prevtracefunc) (SwigType *t, String *mangled, String *clientdata) = 0; +} + +void SwigPHP_emit_resource_registrations() { + Iterator ki; + + if (!zend_types) + return; + + ki = First(zend_types); + if (ki.key) + Printf(s_oinit, "\n/* Register resource destructors for pointer types */\n"); + while (ki.key) { + DOH *key = ki.key; + Node *class_node = ki.item; + String *human_name = key; + + // Write out destructor function header + Printf(s_wrappers, "/* NEW Destructor style */\nstatic ZEND_RSRC_DTOR_FUNC(_wrap_destroy%s) {\n", key); + + // write out body + if ((class_node != NOTCLASS)) { + String *destructor = Getattr(class_node, "destructor"); + human_name = Getattr(class_node, "sym:name"); + if (!human_name) + human_name = Getattr(class_node, "name"); + // Do we have a known destructor for this type? + if (destructor) { + Printf(s_wrappers, " %s(rsrc, SWIGTYPE%s->name TSRMLS_CC);\n", destructor, key); + } else { + Printf(s_wrappers, " /* No destructor for class %s */\n", human_name); + } + } else { + Printf(s_wrappers, " /* No destructor for simple type %s */\n", key); + } + + // close function + Printf(s_wrappers, "}\n"); + + // declare le_swig_ to store php registration + Printf(s_vdecl, "static int le_swig_%s=0; /* handle for %s */\n", key, human_name); + + // register with php + Printf(s_oinit, "le_swig_%s=zend_register_list_destructors_ex" "(_wrap_destroy%s,NULL,(char *)(SWIGTYPE%s->name),module_number);\n", key, key, key); + + // store php type in class struct + Printf(s_oinit, "SWIG_TypeClientData(SWIGTYPE%s,&le_swig_%s);\n", key, key); + + ki = Next(ki); + } +} + +class PHP:public Language { + int php_version; + +public: + PHP(int php_version_):php_version(php_version_) { + } + + /* 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() + * ------------------------------------------------------------ */ + + virtual void main(int argc, char *argv[]) { + SWIG_library_directory("php"); + SWIG_config_cppext("cpp"); + + for (int i = 1; i < argc; i++) { + if (argv[i]) { + if (strcmp(argv[i], "-phpfull") == 0) { + gen_extra = 1; + Swig_mark_arg(i); + } else if (strcmp(argv[i], "-dlname") == 0) { + Printf(stderr, "*** -dlname is no longer supported\n*** if you want to change the module name, use -module instead.\n"); + SWIG_exit(EXIT_FAILURE); + } else if (strcmp(argv[i], "-prefix") == 0) { + if (argv[i + 1]) { + prefix = NewString(argv[i + 1]); + Swig_mark_arg(i); + Swig_mark_arg(i + 1); + i++; + } else { + Swig_arg_error(); + } + } else if (strcmp(argv[i], "-withlibs") == 0) { + if (argv[i + 1]) { + withlibs = NewString(argv[i + 1]); + Swig_mark_arg(i); + Swig_mark_arg(i + 1); + i++; + } else { + Swig_arg_error(); + } + } else if (strcmp(argv[i], "-withincs") == 0) { + if (argv[i + 1]) { + withincs = NewString(argv[i + 1]); + Swig_mark_arg(i); + Swig_mark_arg(i + 1); + i++; + } else { + Swig_arg_error(); + } + } else if (strcmp(argv[i], "-withc") == 0) { + if (argv[i + 1]) { + withc = NewString(argv[i + 1]); + Swig_mark_arg(i); + Swig_mark_arg(i + 1); + i++; + } else { + Swig_arg_error(); + } + } else if (strcmp(argv[i], "-withcxx") == 0) { + if (argv[i + 1]) { + withcxx = NewString(argv[i + 1]); + Swig_mark_arg(i); + Swig_mark_arg(i + 1); + i++; + } else { + Swig_arg_error(); + } + } else if (strcmp(argv[i], "-cppext") == 0) { + if (argv[i + 1]) { + SWIG_config_cppext(argv[i + 1]); + Swig_mark_arg(i); + Swig_mark_arg(i + 1); + i++; + } else { + Swig_arg_error(); + } + } else if ((strcmp(argv[i], "-noshadow") == 0) || (strcmp(argv[i], "-noproxy") == 0)) { + shadow = 0; + Swig_mark_arg(i); + } else if (strcmp(argv[i], "-make") == 0) { + gen_make = 1; + Swig_mark_arg(i); + } else if (strcmp(argv[i], "-help") == 0) { + fputs(usage, stdout); + } + } + } + + Preprocessor_define("SWIGPHP 1", 0); + Preprocessor_define("SWIGPHP5 1", 0); + SWIG_typemap_lang("php4"); + SWIG_config_file("php4.swg"); + allow_overloading(); + } + + void create_simple_make(void) { + File *f_make; + + f_make = NewFile((void *) "makefile", "w"); + Printf(f_make, "CC=gcc\n"); + Printf(f_make, "CXX=g++\n"); + Printf(f_make, "CXX_SOURCES=%s\n", withcxx); + Printf(f_make, "C_SOURCES=%s\n", withc); + Printf(f_make, "OBJS=%s_wrap.o $(C_SOURCES:.c=.o) $(CXX_SOURCES:.cxx=.o)\n", module); + Printf(f_make, "MODULE=%s.so\n", module); + Printf(f_make, "CFLAGS=-fpic\n"); + Printf(f_make, "LDFLAGS=-shared\n"); + Printf(f_make, "PHP_INC=`php-config --includes`\n"); + Printf(f_make, "EXTRA_INC=\n"); + Printf(f_make, "EXTRA_LIB=\n\n"); + Printf(f_make, "$(MODULE): $(OBJS)\n"); + if (CPlusPlus || (withcxx != NULL)) { + Printf(f_make, "\t$(CXX) $(LDFLAGS) $(OBJS) -o $@ $(EXTRA_LIB)\n\n"); + } else { + Printf(f_make, "\t$(CC) $(LDFLAGS) $(OBJS) -o $@ $(EXTRA_LIB)\n\n"); + } + Printf(f_make, "%%.o: %%.cpp\n"); + Printf(f_make, "\t$(CXX) $(EXTRA_INC) $(PHP_INC) $(CFLAGS) -c $<\n"); + Printf(f_make, "%%.o: %%.cxx\n"); + Printf(f_make, "\t$(CXX) $(EXTRA_INC) $(PHP_INC) $(CFLAGS) -c $<\n"); + Printf(f_make, "%%.o: %%.c\n"); + Printf(f_make, "\t$(CC) $(EXTRA_INC) $(PHP_INC) $(CFLAGS) -c $<\n"); + + Close(f_make); + } + + void create_extra_files(String *outfile) { + File *f_extra; + + static String *configm4 = 0; + static String *makefilein = 0; + static String *credits = 0; + + configm4 = NewStringEmpty(); + Printv(configm4, SWIG_output_directory(), "config.m4", NIL); + + makefilein = NewStringEmpty(); + Printv(makefilein, SWIG_output_directory(), "Makefile.in", NIL); + + credits = NewStringEmpty(); + Printv(credits, SWIG_output_directory(), "CREDITS", NIL); + + // are we a --with- or --enable- + int with = (withincs || withlibs) ? 1 : 0; + + // Note Makefile.in only copes with one source file + // also withincs and withlibs only take one name each now + // the code they generate should be adapted to take multiple lines + + /* Write out Makefile.in */ + f_extra = NewFile(makefilein, "w"); + if (!f_extra) { + FileErrorDisplay(makefilein); + SWIG_exit(EXIT_FAILURE); + } + + Printf(f_extra, "# $Id$\n\n" "LTLIBRARY_NAME = %s.la\n", module); + + // C++ has more and different entries to C in Makefile.in + if (!CPlusPlus) { + Printf(f_extra, "LTLIBRARY_SOURCES = %s %s\n", Swig_file_filename(outfile), withc); + Printf(f_extra, "LTLIBRARY_SOURCES_CPP = %s\n", withcxx); + } else { + Printf(f_extra, "LTLIBRARY_SOURCES = %s\n", withc); + Printf(f_extra, "LTLIBRARY_SOURCES_CPP = %s %s\n", Swig_file_filename(outfile), withcxx); + Printf(f_extra, "LTLIBRARY_OBJECTS_X = $(LTLIBRARY_SOURCES_CPP:.cpp=.lo) $(LTLIBRARY_SOURCES_CPP:.cxx=.lo)\n"); + } + Printf(f_extra, "LTLIBRARY_SHARED_NAME = %s.la\n", module); + Printf(f_extra, "LTLIBRARY_SHARED_LIBADD = $(%s_SHARED_LIBADD)\n\n", cap_module); + Printf(f_extra, "include $(top_srcdir)/build/dynlib.mk\n"); + + Printf(f_extra, "\n# patch in .cxx support to php build system to work like .cpp\n"); + Printf(f_extra, ".SUFFIXES: .cxx\n\n"); + + Printf(f_extra, ".cxx.o:\n"); + Printf(f_extra, "\t$(CXX_COMPILE) -c $<\n\n"); + + Printf(f_extra, ".cxx.lo:\n"); + Printf(f_extra, "\t$(CXX_PHP_COMPILE)\n\n"); + Printf(f_extra, ".cxx.slo:\n"); + + Printf(f_extra, "\t$(CXX_SHARED_COMPILE)\n\n"); + + Printf(f_extra, "\n# make it easy to test module\n"); + Printf(f_extra, "testmodule:\n"); + Printf(f_extra, "\tphp -q -d extension_dir=modules %s\n\n", Swig_file_filename(phpfilename)); + + Close(f_extra); + + /* Now config.m4 */ + // Note: # comments are OK in config.m4 if you don't mind them + // appearing in the final ./configure file + // (which can help with ./configure debugging) + + // NOTE2: phpize really ought to be able to write out a sample + // config.m4 based on some simple data, I'll take this up with + // the php folk! + f_extra = NewFile(configm4, "w"); + if (!f_extra) { + FileErrorDisplay(configm4); + SWIG_exit(EXIT_FAILURE); + } + + Printf(f_extra, "dnl $Id$\n"); + Printf(f_extra, "dnl ***********************************************************************\n"); + Printf(f_extra, "dnl ** THIS config.m4 is provided for PHPIZE and PHP's consumption NOT\n"); + Printf(f_extra, "dnl ** for any part of the rest of the %s build system\n", module); + Printf(f_extra, "dnl ***********************************************************************\n\n"); + + + if (!with) { // must be enable then + Printf(f_extra, "PHP_ARG_ENABLE(%s, whether to enable %s support,\n", module, module); + Printf(f_extra, "[ --enable-%s Enable %s support])\n\n", module, module); + } else { + Printf(f_extra, "PHP_ARG_WITH(%s, for %s support,\n", module, module); + Printf(f_extra, "[ --with-%s[=DIR] Include %s support.])\n\n", module, module); + // These tests try and file the library we need + Printf(f_extra, "dnl THESE TESTS try and find the library and header files\n"); + Printf(f_extra, "dnl your new php module needs. YOU MAY NEED TO EDIT THEM\n"); + Printf(f_extra, "dnl as written they assume your header files are all in the same place\n\n"); + + Printf(f_extra, "dnl ** are we looking for %s_lib.h or something else?\n", module); + if (withincs) + Printf(f_extra, "HNAMES=\"%s\"\n\n", withincs); + else + Printf(f_extra, "HNAMES=\"\"; # %s_lib.h ?\n\n", module); + + Printf(f_extra, "dnl ** Are we looking for lib%s.a or lib%s.so or something else?\n", module, module); + + if (withlibs) + Printf(f_extra, "LIBNAMES=\"%s\"\n\n", withlibs); + else + Printf(f_extra, "LIBNAMES=\"\"; # lib%s.so ?\n\n", module); + + Printf(f_extra, "dnl IF YOU KNOW one of the symbols in the library and you\n"); + Printf(f_extra, "dnl specify it below then we can have a link test to see if it works\n"); + Printf(f_extra, "LIBSYMBOL=\"\"\n\n"); + } + + // Now write out tests to find thing.. they may need to extend tests + Printf(f_extra, "if test \"$PHP_%s\" != \"no\"; then\n\n", cap_module); + + // Ready for when we add libraries as we find them + Printf(f_extra, " PHP_SUBST(%s_SHARED_LIBADD)\n\n", cap_module); + + if (withlibs) { // find more than one library + Printf(f_extra, " for LIBNAME in $LIBNAMES ; do\n"); + Printf(f_extra, " LIBDIR=\"\"\n"); + // For each path element to try... + Printf(f_extra, " for i in $PHP_%s $PHP_%s/lib /usr/lib /usr/local/lib ; do\n", cap_module, cap_module); + Printf(f_extra, " if test -r $i/lib$LIBNAME.a -o -r $i/lib$LIBNAME.so ; then\n"); + Printf(f_extra, " LIBDIR=\"$i\"\n"); + Printf(f_extra, " break\n"); + Printf(f_extra, " fi\n"); + Printf(f_extra, " done\n\n"); + Printf(f_extra, " dnl ** and $LIBDIR should be the library path\n"); + Printf(f_extra, " if test \"$LIBNAME\" != \"\" -a -z \"$LIBDIR\" ; then\n"); + Printf(f_extra, " AC_MSG_RESULT(Library files $LIBNAME not found)\n"); + Printf(f_extra, " AC_MSG_ERROR(Is the %s distribution installed properly?)\n", module); + Printf(f_extra, " else\n"); + Printf(f_extra, " AC_MSG_RESULT(Library files $LIBNAME found in $LIBDIR)\n"); + Printf(f_extra, " PHP_ADD_LIBRARY_WITH_PATH($LIBNAME, $LIBDIR, %s_SHARED_LIBADD)\n", cap_module); + Printf(f_extra, " fi\n"); + Printf(f_extra, " done\n\n"); + } + + if (withincs) { // Find more than once include + Printf(f_extra, " for HNAME in $HNAMES ; do\n"); + Printf(f_extra, " INCDIR=\"\"\n"); + // For each path element to try... + Printf(f_extra, " for i in $PHP_%s $PHP_%s/include $PHP_%s/includes $PHP_%s/inc $PHP_%s/incs /usr/local/include /usr/include; do\n", cap_module, + cap_module, cap_module, cap_module, cap_module); + // Try and find header files + Printf(f_extra, " if test \"$HNAME\" != \"\" -a -r $i/$HNAME ; then\n"); + Printf(f_extra, " INCDIR=\"$i\"\n"); + Printf(f_extra, " break\n"); + Printf(f_extra, " fi\n"); + Printf(f_extra, " done\n\n"); + + Printf(f_extra, " dnl ** Now $INCDIR should be the include file path\n"); + Printf(f_extra, " if test \"$HNAME\" != \"\" -a -z \"$INCDIR\" ; then\n"); + Printf(f_extra, " AC_MSG_RESULT(Include files $HNAME not found)\n"); + Printf(f_extra, " AC_MSG_ERROR(Is the %s distribution installed properly?)\n", module); + Printf(f_extra, " else\n"); + Printf(f_extra, " AC_MSG_RESULT(Include files $HNAME found in $INCDIR)\n"); + Printf(f_extra, " PHP_ADD_INCLUDE($INCDIR)\n"); + Printf(f_extra, " fi\n\n"); + Printf(f_extra, " done\n\n"); + } + + if (CPlusPlus) { + Printf(f_extra, " # As this is a C++ module..\n"); + } + + Printf(f_extra, " PHP_REQUIRE_CXX\n"); + Printf(f_extra, " AC_CHECK_LIB(stdc++, cin)\n"); + + if (with) { + Printf(f_extra, " if test \"$LIBSYMBOL\" != \"\" ; then\n"); + Printf(f_extra, " old_LIBS=\"$LIBS\"\n"); + Printf(f_extra, " LIBS=\"$LIBS -L$TEST_DIR/lib -lm -ldl\"\n"); + Printf(f_extra, " AC_CHECK_LIB($LIBNAME, $LIBSYMBOL, [AC_DEFINE(HAVE_TESTLIB,1, [ ])],\n"); + Printf(f_extra, " [AC_MSG_ERROR(wrong test lib version or lib not found)])\n"); + Printf(f_extra, " LIBS=\"$old_LIBS\"\n"); + Printf(f_extra, " fi\n\n"); + } + + Printf(f_extra, " AC_DEFINE(HAVE_%s, 1, [ ])\n", cap_module); + Printf(f_extra, "dnl AC_DEFINE_UNQUOTED(PHP_%s_DIR, \"$%s_DIR\", [ ])\n", cap_module, cap_module); + Printf(f_extra, " PHP_EXTENSION(%s, $ext_shared)\n", module); + + // and thats all! + Printf(f_extra, "fi\n"); + + Close(f_extra); + + /* CREDITS */ + f_extra = NewFile(credits, "w"); + if (!f_extra) { + FileErrorDisplay(credits); + SWIG_exit(EXIT_FAILURE); + } + Printf(f_extra, "%s\n", module); + Close(f_extra); + } + + /* ------------------------------------------------------------ + * top() + * ------------------------------------------------------------ */ + + virtual int top(Node *n) { + + String *filen; + String *s_type; + + /* Initialize all of the output files */ + String *outfile = Getattr(n, "outfile"); + + /* main output file */ + f_runtime = NewFile(outfile, "w"); + if (!f_runtime) { + FileErrorDisplay(outfile); + SWIG_exit(EXIT_FAILURE); + } + + Swig_banner(f_runtime); + + /* sections of the output file */ + s_init = NewString("/* init section */\n"); + r_init = NewString("/* rinit section */\n"); + s_shutdown = NewString("/* shutdown section */\n"); + r_shutdown = NewString("/* rshutdown section */\n"); + s_header = NewString("/* header section */\n"); + s_wrappers = NewString("/* wrapper section */\n"); + s_type = NewStringEmpty(); + /* subsections of the init section */ + s_vinit = NewString("/* vinit subsection */\n"); + s_vdecl = NewString("/* vdecl subsection */\n"); + s_cinit = NewString("/* cinit subsection */\n"); + s_oinit = NewString("/* oinit subsection */\n"); + pragma_phpinfo = NewStringEmpty(); + s_phpclasses = NewString("/* PHP Proxy Classes */\n"); + + /* Register file targets with the SWIG file handler */ + Swig_register_filebyname("runtime", f_runtime); + Swig_register_filebyname("init", s_init); + Swig_register_filebyname("rinit", r_init); + Swig_register_filebyname("shutdown", s_shutdown); + Swig_register_filebyname("rshutdown", r_shutdown); + Swig_register_filebyname("header", s_header); + Swig_register_filebyname("wrapper", s_wrappers); + + /* Set the module name */ + module = Copy(Getattr(n, "name")); + cap_module = NewStringf("%(upper)s", module); + if (!prefix) + prefix = NewStringEmpty(); + + /* PHP module file */ + filen = NewStringEmpty(); + Printv(filen, SWIG_output_directory(), module, ".php", NIL); + phpfilename = NewString(filen); + + f_phpcode = NewFile(filen, "w"); + if (!f_phpcode) { + FileErrorDisplay(filen); + SWIG_exit(EXIT_FAILURE); + } + + Printf(f_phpcode, "error_msg = default_error_msg;\n"); + Printf(s_header, " globals->error_code = default_error_code;\n"); + Printf(s_header, "}\n"); + + Printf(s_header, "static void %s_destroy_globals(zend_%s_globals * globals) { (void)globals; }\n", module, module); + + Printf(s_header, "\n"); + Printf(s_header, "static void SWIG_ResetError() {\n"); + Printf(s_header, " TSRMLS_FETCH();\n"); + Printf(s_header, " SWIG_ErrorMsg() = default_error_msg;\n"); + Printf(s_header, " SWIG_ErrorCode() = default_error_code;\n"); + Printf(s_header, "}\n"); + + Printf(s_header, "#define SWIG_name \"%s\"\n", module); + /* Printf(s_header,"#ifdef HAVE_CONFIG_H\n"); + Printf(s_header,"#include \"config.h\"\n"); + Printf(s_header,"#endif\n\n"); + */ + Printf(s_header, "#ifdef __cplusplus\n"); + Printf(s_header, "extern \"C\" {\n"); + Printf(s_header, "#endif\n"); + Printf(s_header, "#include \"php.h\"\n"); + Printf(s_header, "#include \"php_ini.h\"\n"); + Printf(s_header, "#include \"ext/standard/info.h\"\n"); + Printf(s_header, "#include \"php_%s.h\"\n", module); + Printf(s_header, "#ifdef __cplusplus\n"); + Printf(s_header, "}\n"); + Printf(s_header, "#endif\n\n"); + + /* Create the .h file too */ + filen = NewStringEmpty(); + Printv(filen, SWIG_output_directory(), "php_", module, ".h", NIL); + f_h = NewFile(filen, "w"); + if (!f_h) { + FileErrorDisplay(filen); + SWIG_exit(EXIT_FAILURE); + } + + Swig_banner(f_h); + + Printf(f_h, "\n\n"); + Printf(f_h, "#ifndef PHP_%s_H\n", cap_module); + Printf(f_h, "#define PHP_%s_H\n\n", cap_module); + Printf(f_h, "extern zend_module_entry %s_module_entry;\n", module); + Printf(f_h, "#define phpext_%s_ptr &%s_module_entry\n\n", module, module); + Printf(f_h, "#ifdef PHP_WIN32\n"); + Printf(f_h, "# define PHP_%s_API __declspec(dllexport)\n", cap_module); + Printf(f_h, "#else\n"); + Printf(f_h, "# define PHP_%s_API\n", cap_module); + Printf(f_h, "#endif\n\n"); + Printf(f_h, "#ifdef ZTS\n"); + Printf(f_h, "#include \"TSRM.h\"\n"); + Printf(f_h, "#endif\n\n"); + Printf(f_h, "PHP_MINIT_FUNCTION(%s);\n", module); + Printf(f_h, "PHP_MSHUTDOWN_FUNCTION(%s);\n", module); + Printf(f_h, "PHP_RINIT_FUNCTION(%s);\n", module); + Printf(f_h, "PHP_RSHUTDOWN_FUNCTION(%s);\n", module); + Printf(f_h, "PHP_MINFO_FUNCTION(%s);\n\n", module); + + /* start the function entry section */ + s_entry = NewString("/* entry subsection */\n"); + + /* holds all the per-class function entry sections */ + all_cs_entry = NewString("/* class entry subsection */\n"); + cs_entry = NULL; + + Printf(s_entry, "/* Every non-class user visible function must have an entry here */\n"); + Printf(s_entry, "static zend_function_entry %s_functions[] = {\n", module); + + /* start the init section */ + 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); + Printf(s_init, " PHP_MINIT(%s),\n", module); + Printf(s_init, " PHP_MSHUTDOWN(%s),\n", module); + Printf(s_init, " PHP_RINIT(%s),\n", module); + Printf(s_init, " PHP_RSHUTDOWN(%s),\n", module); + Printf(s_init, " PHP_MINFO(%s),\n", module); + Printf(s_init, "#if ZEND_MODULE_API_NO > 20010900\n"); + Printf(s_init, " NO_VERSION_YET,\n"); + Printf(s_init, "#endif\n"); + Printf(s_init, " STANDARD_MODULE_PROPERTIES\n"); + Printf(s_init, "};\n"); + Printf(s_init, "zend_module_entry* SWIG_module_entry = &%s_module_entry;\n\n", module); + + if (gen_extra) { + Printf(s_init, "#ifdef COMPILE_DL_%s\n", cap_module); + } + Printf(s_init, "#ifdef __cplusplus\n"); + Printf(s_init, "extern \"C\" {\n"); + Printf(s_init, "#endif\n"); + // We want to write "SWIGEXPORT ZEND_GET_MODULE(%s)" but ZEND_GET_MODULE + // in PHP5 has "extern "C" { ... }" around it so we can't do that. + Printf(s_init, "SWIGEXPORT zend_module_entry *get_module(void) { return &%s_module_entry; }\n", module); + Printf(s_init, "#ifdef __cplusplus\n"); + Printf(s_init, "}\n"); + Printf(s_init, "#endif\n\n"); + + if (gen_extra) { + Printf(s_init, "#endif\n\n"); + } + + /* We have to register the constants before they are (possibly) used + * by the pointer typemaps. This all needs re-arranging really as + * things are being called in the wrong order + */ + Printf(s_init, "#define SWIG_php_minit PHP_MINIT_FUNCTION(%s)\n", module); + + /* Emit all of the code */ + Language::top(n); + + SwigPHP_emit_resource_registrations(); + // Printv(s_init,s_resourcetypes,NIL); + /* We need this after all classes written out by ::top */ + Printf(s_oinit, "CG(active_class_entry) = NULL;\n"); + Printf(s_oinit, "/* end oinit subsection */\n"); + Printf(s_init, "%s\n", s_oinit); + + /* Constants generated during top call */ + Printf(s_cinit, "/* end cinit subsection */\n"); + Printf(s_init, "%s\n", s_cinit); + Clear(s_cinit); + Delete(s_cinit); + + Printf(s_init, " return SUCCESS;\n"); + Printf(s_init, "}\n\n"); + + // Now do REQUEST init which holds any user specified %rinit, and also vinit + Printf(s_init, "PHP_RINIT_FUNCTION(%s)\n{\n", module); + Printf(s_init, "%s\n", r_init); + + /* finish our init section which will have been used by class wrappers */ + Printf(s_vinit, "/* end vinit subsection */\n"); + Printf(s_init, "%s\n", s_vinit); + Clear(s_vinit); + Delete(s_vinit); + + Printf(s_init, " return SUCCESS;\n"); + Printf(s_init, "}\n\n"); + + Printv(s_init, "PHP_MSHUTDOWN_FUNCTION(", module, ")\n" + "{\n", + s_shutdown, + "#ifdef ZTS\n" + " ts_free_id(", module, "_globals_id);\n" + "#endif\n" + " return SUCCESS;\n" + "}\n\n", NIL); + + Printf(s_init, "PHP_RSHUTDOWN_FUNCTION(%s)\n{\n", module); + Printf(s_init, "%s\n", r_shutdown); + Printf(s_init, " return SUCCESS;\n"); + Printf(s_init, "}\n\n"); + + Printf(s_init, "PHP_MINFO_FUNCTION(%s)\n{\n", module); + Printf(s_init, "%s", pragma_phpinfo); + Printf(s_init, "}\n"); + Printf(s_init, "/* end init section */\n"); + + Printf(f_h, "#endif /* PHP_%s_H */\n", cap_module); + + Close(f_h); + + String *type_table = NewStringEmpty(); + SwigType_emit_type_table(f_runtime, type_table); + Printf(s_header, "%s", type_table); + Delete(type_table); + + /* Oh dear, more things being called in the wrong order. This whole + * function really needs totally redoing. + */ + + Printf(s_header, "/* end header section */\n"); + Printf(s_wrappers, "/* end wrapper section */\n"); + Printf(s_vdecl, "/* end vdecl subsection */\n"); + + Printv(f_runtime, s_header, s_vdecl, s_wrappers, NIL); + Printv(f_runtime, all_cs_entry, "\n\n", s_entry, "{NULL, NULL, NULL}\n};\n\n", NIL); + Printv(f_runtime, s_init, NIL); + Delete(s_header); + Delete(s_wrappers); + Delete(s_init); + Delete(s_vdecl); + Delete(all_cs_entry); + Delete(s_entry); + Close(f_runtime); + + Printf(f_phpcode, "%s\n%s\n", pragma_incl, pragma_code); + if (s_fakeoowrappers) { + Printf(f_phpcode, "abstract class %s {", Len(prefix) ? prefix : module); + Printf(f_phpcode, "%s", s_fakeoowrappers); + Printf(f_phpcode, "}\n\n"); + Delete(s_fakeoowrappers); + s_fakeoowrappers = NULL; + } + Printf(f_phpcode, "%s\n?>\n", s_phpclasses); + Close(f_phpcode); + + if (gen_extra) { + create_extra_files(outfile); + } else if (gen_make) { + create_simple_make(); + } + + return SWIG_OK; + } + + /* Just need to append function names to function table to register with PHP. */ + void create_command(String *cname, String *iname) { + // This is for the single main zend_function_entry record + Printf(f_h, "ZEND_NAMED_FUNCTION(%s);\n", iname); + String * s = cs_entry; + if (!s) s = s_entry; + Printf(s, " SWIG_ZEND_NAMED_FE(%(lower)s,%s,NULL)\n", cname, iname); + } + + /* ------------------------------------------------------------ + * dispatchFunction() + * ------------------------------------------------------------ */ + void dispatchFunction(Node *n) { + /* Last node in overloaded chain */ + + int maxargs; + String *tmp = NewStringEmpty(); + String *dispatch = Swig_overload_dispatch(n, "return %s(INTERNAL_FUNCTION_PARAM_PASSTHRU);", &maxargs); + + /* Generate a dispatch wrapper for all overloaded functions */ + + Wrapper *f = NewWrapper(); + String *symname = Getattr(n, "sym:name"); + String *wname = Swig_name_wrapper(symname); + + create_command(symname, wname); + Printv(f->def, "ZEND_NAMED_FUNCTION(", wname, ") {\n", NIL); + + Wrapper_add_local(f, "argc", "int argc"); + + Printf(tmp, "zval **argv[%d]", maxargs); + Wrapper_add_local(f, "argv", tmp); + + Printf(f->code, "argc = ZEND_NUM_ARGS();\n"); + + Printf(f->code, "zend_get_parameters_array_ex(argc,argv);\n"); + + Replaceall(dispatch, "$args", "self,args"); + + Printv(f->code, dispatch, "\n", NIL); + + Printf(f->code, "SWIG_ErrorCode() = E_ERROR;\n"); + Printf(f->code, "SWIG_ErrorMsg() = \"No matching function for overloaded '%s'\";\n", symname); + Printv(f->code, "zend_error(SWIG_ErrorCode(),SWIG_ErrorMsg());\n", NIL); + + Printv(f->code, "}\n", NIL); + Wrapper_print(f, s_wrappers); + + DelWrapper(f); + Delete(dispatch); + Delete(tmp); + Delete(wname); + } + + /* ------------------------------------------------------------ + * functionWrapper() + * ------------------------------------------------------------ */ + + /* Helper method for PHP::functionWrapper */ + bool is_class(SwigType *t) { + Node *n = classLookup(t); + if (n) { + String *r = Getattr(n, "php:proxy"); // Set by classDeclaration() + if (!r) + r = Getattr(n, "sym:name"); // Not seen by classDeclaration yet, but this is the name + if (r) + return true; + } + return false; + } + + virtual int functionWrapper(Node *n) { + String *name = GetChar(n, "name"); + String *iname = GetChar(n, "sym:name"); + SwigType *d = Getattr(n, "type"); + ParmList *l = Getattr(n, "parms"); + String *nodeType = Getattr(n, "nodeType"); + int newobject = GetFlag(n, "feature:new"); + + Parm *p; + int i; + int numopt; + String *tm; + Wrapper *f; + + String *wname; + int overloaded = 0; + String *overname = 0; + + if (Cmp(nodeType, "destructor") == 0) { + // We just generate the Zend List Destructor and let Zend manage the + // reference counting. There's no explicit destructor, but the user can + // just do `$obj = null;' to remove a reference to an object. + return CreateZendListDestructor(n); + } + // Test for overloading; + if (Getattr(n, "sym:overloaded")) { + overloaded = 1; + overname = Getattr(n, "sym:overname"); + } else { + if (!addSymbol(iname, n)) + return SWIG_ERROR; + } + + wname = Swig_name_wrapper(iname); + if (overname) { + Printf(wname, "%s", overname); + } + + f = NewWrapper(); + numopt = 0; + + String *outarg = NewStringEmpty(); + String *cleanup = NewStringEmpty(); + + // Not issued for overloaded functions or static member variables. + if (!overloaded && wrapperType != staticmembervar) { + create_command(iname, wname); + } + Printv(f->def, "ZEND_NAMED_FUNCTION(", wname, ") {\n", NIL); + + emit_parameter_variables(l, f); + /* Attach standard typemaps */ + + emit_attach_parmmaps(l, f); + + // wrap:parms is used by overload resolution. + Setattr(n, "wrap:parms", l); + + int num_arguments = emit_num_arguments(l); + int num_required = emit_num_required(l); + numopt = num_arguments - num_required; + + if (num_arguments > 0) { + String *args = NewStringf("zval **args[%d]", num_arguments); + Wrapper_add_local(f, "args", args); + Delete(args); + args = NULL; + } + // This generated code may be called: + // 1) as an object method, or + // 2) as a class-method/function (without a "this_ptr") + // Option (1) has "this_ptr" for "this", option (2) needs it as + // first parameter + + // NOTE: possible we ignore this_ptr as a param for native constructor + + Printf(f->code, "SWIG_ResetError();\n"); + + if (numopt > 0) { // membervariable wrappers do not have optional args + Wrapper_add_local(f, "arg_count", "int arg_count"); + Printf(f->code, "arg_count = ZEND_NUM_ARGS();\n"); + Printf(f->code, "if(arg_count<%d || arg_count>%d ||\n", num_required, num_arguments); + Printf(f->code, " zend_get_parameters_array_ex(arg_count,args)!=SUCCESS)\n"); + Printf(f->code, "\tWRONG_PARAM_COUNT;\n\n"); + } else { + if (num_arguments == 0) { + Printf(f->code, "if(ZEND_NUM_ARGS() != 0) {\n"); + } else { + Printf(f->code, "if(ZEND_NUM_ARGS() != %d || zend_get_parameters_array_ex(%d, args) != SUCCESS) {\n", num_arguments, num_arguments); + } + Printf(f->code, "WRONG_PARAM_COUNT;\n}\n\n"); + } + + /* Now convert from php to C variables */ + // At this point, argcount if used is the number of deliberately passed args + // not including this_ptr even if it is used. + // It means error messages may be out by argbase with error + // reports. We can either take argbase into account when raising + // errors, or find a better way of dealing with _thisptr. + // I would like, if objects are wrapped, to assume _thisptr is always + // _this and not the first argument. + // This may mean looking at Language::memberfunctionHandler + + for (i = 0, p = l; i < num_arguments; i++) { + String *source; + + /* Skip ignored arguments */ + //while (Getattr(p,"tmap:ignore")) { p = Getattr(p,"tmap:ignore:next");} + while (checkAttribute(p, "tmap:in:numinputs", "0")) { + p = Getattr(p, "tmap:in:next"); + } + + SwigType *pt = Getattr(p, "type"); + + source = NewStringf("args[%d]", i); + + String *ln = Getattr(p, "lname"); + + /* Check if optional */ + if (i >= num_required) { + Printf(f->code, "\tif(arg_count > %d) {\n", i); + } + + if ((tm = Getattr(p, "tmap:in"))) { + Replaceall(tm, "$source", source); + Replaceall(tm, "$target", ln); + Replaceall(tm, "$input", source); + Setattr(p, "emit:input", source); + Printf(f->code, "%s\n", tm); + if (i == 0 && Getattr(p, "self")) { + Printf(f->code, "\tif(!arg1) SWIG_PHP_Error(E_ERROR, \"this pointer is NULL\");\n"); + } + p = Getattr(p, "tmap:in:next"); + if (i >= num_required) { + Printf(f->code, "}\n"); + } + continue; + } else { + Swig_warning(WARN_TYPEMAP_IN_UNDEF, input_file, line_number, "Unable to use type %s as a function argument.\n", SwigType_str(pt, 0)); + } + if (i >= num_required) { + Printf(f->code, "\t}\n"); + } + Delete(source); + } + + /* Insert constraint checking code */ + for (p = l; p;) { + if ((tm = Getattr(p, "tmap:check"))) { + Replaceall(tm, "$target", Getattr(p, "lname")); + Printv(f->code, tm, "\n", NIL); + p = Getattr(p, "tmap:check:next"); + } else { + p = nextSibling(p); + } + } + + /* Insert cleanup code */ + for (i = 0, p = l; p; i++) { + if ((tm = Getattr(p, "tmap:freearg"))) { + Replaceall(tm, "$source", Getattr(p, "lname")); + Printv(cleanup, tm, "\n", NIL); + p = Getattr(p, "tmap:freearg:next"); + } else { + p = nextSibling(p); + } + } + + /* Insert argument output code */ + for (i = 0, p = l; p; i++) { + if ((tm = Getattr(p, "tmap:argout"))) { + Replaceall(tm, "$source", Getattr(p, "lname")); + // Replaceall(tm,"$input",Getattr(p,"lname")); + Replaceall(tm, "$target", "return_value"); + Replaceall(tm, "$result", "return_value"); + Replaceall(tm, "$arg", Getattr(p, "emit:input")); + Replaceall(tm, "$input", Getattr(p, "emit:input")); + Printv(outarg, tm, "\n", NIL); + p = Getattr(p, "tmap:argout:next"); + } else { + p = nextSibling(p); + } + } + + Setattr(n, "wrap:name", wname); + + /* emit function call */ + String *actioncode = emit_action(n); + + if ((tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode))) { + Replaceall(tm, "$input", "result"); + Replaceall(tm, "$source", "result"); + Replaceall(tm, "$target", "return_value"); + Replaceall(tm, "$result", "return_value"); + Replaceall(tm, "$owner", newobject ? "1" : "0"); + Printf(f->code, "%s\n", tm); + } else { + Swig_warning(WARN_TYPEMAP_OUT_UNDEF, input_file, line_number, "Unable to use return type %s in function %s.\n", SwigType_str(d, 0), name); + } + emit_return_variable(n, d, f); + + if (outarg) { + Printv(f->code, outarg, NIL); + } + + if (cleanup) { + Printv(f->code, cleanup, NIL); + } + + /* Look to see if there is any newfree cleanup code */ + if (GetFlag(n, "feature:new")) { + if ((tm = Swig_typemap_lookup("newfree", n, "result", 0))) { + Printf(f->code, "%s\n", tm); + Delete(tm); + } + } + + /* See if there is any return cleanup code */ + if ((tm = Swig_typemap_lookup("ret", n, "result", 0))) { + Printf(f->code, "%s\n", tm); + Delete(tm); + } + + Printf(f->code, "return;\n"); + + /* Error handling code */ + Printf(f->code, "fail:\n"); + Printv(f->code, cleanup, NIL); + Printv(f->code, "zend_error(SWIG_ErrorCode(),SWIG_ErrorMsg());", NIL); + + Printf(f->code, "}\n"); + + Replaceall(f->code, "$cleanup", cleanup); + Replaceall(f->code, "$symname", iname); + + Wrapper_print(f, s_wrappers); + + if (overloaded && !Getattr(n, "sym:nextSibling")) { + dispatchFunction(n); + } + + Delete(wname); + wname = NULL; + + if (!(shadow && php_version == 5)) { + DelWrapper(f); + return SWIG_OK; + } + + // Handle getters and setters. + if (wrapperType == membervar) { + const char *p = Char(iname); + if (strlen(p) > 4) { + p += strlen(p) - 4; + String *varname = Getattr(n, "membervariableHandler:sym:name"); + if (strcmp(p, "_get") == 0) { + Setattr(shadow_get_vars, varname, iname); + } else if (strcmp(p, "_set") == 0) { + Setattr(shadow_set_vars, varname, iname); + } + } + } + // Only look at non-overloaded methods and the last entry in each overload + // chain (we check the last so that wrap:parms and wrap:name have been set + // for them all). + if (overloaded && Getattr(n, "sym:nextSibling") != 0) + return SWIG_OK; + + if (!s_oowrappers) + s_oowrappers = NewStringEmpty(); + if (newobject || wrapperType == memberfn || wrapperType == staticmemberfn || wrapperType == standard) { + bool handle_as_overload = false; + String **arg_names; + String **arg_values; + // Method or static method or plain function. + const char *methodname = 0; + String *output = s_oowrappers; + if (newobject) { + class_has_ctor = true; + methodname = "__construct"; + } else if (wrapperType == memberfn) { + methodname = Char(Getattr(n, "memberfunctionHandler:sym:name")); + } else if (wrapperType == staticmemberfn) { + methodname = Char(Getattr(n, "staticmemberfunctionHandler:sym:name")); + } else { // wrapperType == standard + methodname = Char(iname); + if (!s_fakeoowrappers) + s_fakeoowrappers = NewStringEmpty(); + output = s_fakeoowrappers; + } + + bool really_overloaded = overloaded ? true : false; + int min_num_of_arguments = emit_num_required(l); + int max_num_of_arguments = emit_num_arguments(l); + // For a function with default arguments, we end up with the fullest + // parmlist in full_parmlist. + ParmList *full_parmlist = l; + Hash *ret_types = NewHash(); + Setattr(ret_types, d, d); + + if (overloaded) { + // Look at all the overloaded versions of this method in turn to + // decide if it's really an overloaded method, or just one where some + // parameters have default values. + Node *o = Getattr(n, "sym:overloaded"); + while (o) { + if (o == n) { + o = Getattr(o, "sym:nextSibling"); + continue; + } + + SwigType *d2 = Getattr(o, "type"); + if (!d2) { + assert(constructor); + } else if (!Getattr(ret_types, d2)) { + Setattr(ret_types, d2, d2); + } + + ParmList *l2 = Getattr(o, "wrap:parms"); + int num_arguments = emit_num_arguments(l2); + int num_required = emit_num_required(l2); + if (num_required < min_num_of_arguments) + min_num_of_arguments = num_required; + + if (num_arguments > max_num_of_arguments) { + max_num_of_arguments = num_arguments; + full_parmlist = l2; + } + o = Getattr(o, "sym:nextSibling"); + } + + o = Getattr(n, "sym:overloaded"); + while (o) { + if (o == n) { + o = Getattr(o, "sym:nextSibling"); + continue; + } + + ParmList *l2 = Getattr(o, "wrap:parms"); + Parm *p = l, *p2 = l2; + if (wrapperType == memberfn) { + p = nextSibling(p); + p2 = nextSibling(p2); + } + while (p && p2) { + if (Cmp(Getattr(p, "type"), Getattr(p2, "type")) != 0) + break; + if (Cmp(Getattr(p, "name"), Getattr(p2, "name")) != 0) + break; + String *value = Getattr(p, "value"); + String *value2 = Getattr(p2, "value"); + if (value && !value2) + break; + if (!value && value2) + break; + if (value) { + if (Cmp(value, value2) != 0) + break; + } + p = nextSibling(p); + p2 = nextSibling(p2); + } + if (p && p2) + break; + // One parameter list is a prefix of the other, so check that all + // remaining parameters of the longer list are optional. + if (p2) + p = p2; + while (p && Getattr(p, "value")) + p = nextSibling(p); + if (p) + break; + o = Getattr(o, "sym:nextSibling"); + } + if (!o) { + // This "overloaded method" is really just one with default args. + really_overloaded = false; + if (l != full_parmlist) { + l = full_parmlist; + if (wrapperType == memberfn) + l = nextSibling(l); + } + } + } + + if (wrapperType == memberfn) { + // Allow for the "this" pointer. + --min_num_of_arguments; + --max_num_of_arguments; + } + + arg_names = (String **) malloc(max_num_of_arguments * sizeof(String *)); + if (!arg_names) { + /* FIXME: How should this be handled? The rest of SWIG just seems + * to not bother checking for malloc failing! */ + fprintf(stderr, "Malloc failed!\n"); + exit(1); + } + for (i = 0; i < max_num_of_arguments; ++i) { + arg_names[i] = NULL; + } + + arg_values = (String **) malloc(max_num_of_arguments * sizeof(String *)); + if (!arg_values) { + /* FIXME: How should this be handled? The rest of SWIG just seems + * to not bother checking for malloc failing! */ + fprintf(stderr, "Malloc failed!\n"); + exit(1); + } + for (i = 0; i < max_num_of_arguments; ++i) { + arg_values[i] = NULL; + } + + Node *o; + if (overloaded) { + o = Getattr(n, "sym:overloaded"); + } else { + o = n; + } + while (o) { + int argno = 0; + Parm *p = Getattr(o, "wrap:parms"); + if (wrapperType == memberfn) + p = nextSibling(p); + while (p) { + if (GetInt(p, "tmap:in:numinputs") == 0) { + p = nextSibling(p); + continue; + } + assert(0 <= argno && argno < max_num_of_arguments); + String *&pname = arg_names[argno]; + const char *pname_cstr = GetChar(p, "name"); + if (!pname_cstr) { + // Unnamed parameter, e.g. int foo(int); + } else if (pname == NULL) { + pname = NewString(pname_cstr); + } else { + size_t len = strlen(pname_cstr); + size_t spc = 0; + size_t len_pname = strlen(Char(pname)); + while (spc + len <= len_pname) { + if (strncmp(pname_cstr, Char(pname) + spc, len) == 0) { + char ch = ((char *) Char(pname))[spc + len]; + if (ch == '\0' || ch == ' ') { + // Already have this pname_cstr. + pname_cstr = NULL; + break; + } + } + char *p = strchr(Char(pname) + spc, ' '); + if (!p) + break; + spc = (p + 4) - Char(pname); + } + if (pname_cstr) { + Printf(pname, " or_%s", pname_cstr); + } + } + String *value = NewString(Getattr(p, "value")); + if (Len(value)) { + /* Check that value is a valid constant in PHP (and adjust it if + * necessary, or replace it with "?" if it's just not valid). */ + SwigType *type = Getattr(p, "type"); + switch (SwigType_type(type)) { + case T_BOOL: { + if (Strcmp(value, "true") == 0 || Strcmp(value, "false") == 0) + break; + char *p; + errno = 0; + int n = strtol(Char(value), &p, 0); + Clear(value); + if (errno || *p) { + Append(value, "?"); + } else if (n) { + Append(value, "true"); + } else { + Append(value, "false"); + } + break; + } + case T_CHAR: + case T_SCHAR: + case T_SHORT: + case T_INT: + case T_LONG: { + char *p; + errno = 0; + (void) strtol(Char(value), &p, 0); + if (errno || *p) { + Clear(value); + Append(value, "?"); + } + break; + } + case T_UCHAR: + case T_USHORT: + case T_UINT: + case T_ULONG: { + char *p; + errno = 0; + (void) strtoul(Char(value), &p, 0); + if (errno || *p) { + Clear(value); + Append(value, "?"); + } + break; + } + case T_FLOAT: + case T_DOUBLE:{ + char *p; + errno = 0; + /* FIXME: strtod is locale dependent... */ + double val = strtod(Char(value), &p); + if (errno || *p) { + Clear(value); + Append(value, "?"); + } else if (strchr(Char(value), '.') == NULL) { + // Ensure value is a double constant, not an integer one. + Append(value, ".0"); + double val2 = strtod(Char(value), &p); + if (errno || *p || val != val2) { + Clear(value); + Append(value, "?"); + } + } + break; + } + case T_REFERENCE: + case T_USER: + case T_ARRAY: + Clear(value); + Append(value, "?"); + break; + case T_STRING: + if (Len(value) < 2) { + // How can a string (including "" be less than 2 characters?) + Clear(value); + Append(value, "?"); + } else { + const char *v = Char(value); + if (v[0] != '"' || v[Len(value) - 1] != '"') { + Clear(value); + Append(value, "?"); + } + // Strings containing "$" require special handling, but we do + // that later. + } + break; + case T_VOID: + assert(false); + break; + case T_POINTER: { + const char *v = Char(value); + if (v[0] == '(') { + // Handle "(void*)0", "(TYPE*)0", "(char*)NULL", etc. + v += strcspn(v + 1, "*()") + 1; + if (*v == '*') { + do { + v++; + v += strspn(v, " \t"); + } while (*v == '*'); + if (*v++ == ')') { + v += strspn(v, " \t"); + String * old = value; + value = NewString(v); + Delete(old); + } + } + } + if (Strcmp(value, "NULL") == 0 || + Strcmp(value, "0") == 0 || + Strcmp(value, "0L") == 0) { + Clear(value); + Append(value, "null"); + } else { + Clear(value); + Append(value, "?"); + } + break; + } + } + + if (!arg_values[argno]) { + arg_values[argno] = value; + value = NULL; + } else if (Cmp(arg_values[argno], value) != 0) { + // If a parameter has two different default values in + // different overloaded forms of the function, we can't + // set its default in PHP. Flag this by setting its + // default to `?'. + Delete(arg_values[argno]); + arg_values[argno] = NewString("?"); + } + } else if (arg_values[argno]) { + // This argument already has a default value in another overloaded + // form, but doesn't in this form. So don't try to do anything + // clever, just let the C wrappers resolve the overload and set the + // default values. + // + // This handling is safe, but I'm wondering if it may be overly + // conservative (FIXME) in some cases. It seems it's only bad when + // there's an overloaded form with the appropriate number of + // parameters which doesn't want the default value, but I need to + // think about this more. + Delete(arg_values[argno]); + arg_values[argno] = NewString("?"); + } + Delete(value); + p = nextSibling(p); + ++argno; + } + if (!really_overloaded) + break; + o = Getattr(o, "sym:nextSibling"); + } + + /* Clean up any parameters which haven't yet got names, or whose + * names clash. */ + Hash *seen = NewHash(); + /* We need $this to refer to the current class, so can't allow it + * to be used as a parameter. */ + Setattr(seen, "this", seen); + /* We use $r to store the return value, so disallow that as a parameter + * name in case the user uses the "call-time pass-by-reference" feature + * (it's deprecated and off by default in PHP5, but we want to be + * maximally portable). + */ + Setattr(seen, "r", seen); + + for (int argno = 0; argno < max_num_of_arguments; ++argno) { + String *&pname = arg_names[argno]; + if (pname) { + Replaceall(pname, " ", "_"); + } else { + /* We get here if the SWIG .i file has "int foo(int);" */ + pname = NewStringEmpty(); + Printf(pname, "arg%d", argno + 1); + } + // Check if we've already used this parameter name. + while (Getattr(seen, pname)) { + // Append "_" to clashing names until they stop clashing... + Printf(pname, "_"); + } + Setattr(seen, Char(pname), seen); + + if (arg_values[argno] && Cmp(arg_values[argno], "?") == 0) { + handle_as_overload = true; + } + } + Delete(seen); + seen = NULL; + + String *invoke = NewStringEmpty(); + String *prepare = NewStringEmpty(); + String *args = NewStringEmpty(); + + if (!handle_as_overload && !(really_overloaded && max_num_of_arguments > min_num_of_arguments)) { + Printf(invoke, "%s(", iname); + if (wrapperType == memberfn) { + Printf(invoke, "$this->%s", SWIG_PTR); + } + for (int i = 0; i < max_num_of_arguments; ++i) { + if (i) + Printf(args, ","); + if (i || wrapperType == memberfn) + Printf(invoke, ","); + String *value = arg_values[i]; + if (value) { + const char *v = Char(value); + if (v[0] == '"') { + /* In a PHP double quoted string, $ needs to be escaped as \$. */ + Replaceall(value, "$", "\\$"); + } + Printf(args, "$%s=%s", arg_names[i], value); + } else { + Printf(args, "$%s", arg_names[i]); + } + Printf(invoke, "$%s", arg_names[i]); + } + Printf(invoke, ")"); + } else { + int i; + for (i = 0; i < min_num_of_arguments; ++i) { + if (i) + Printf(args, ","); + Printf(args, "$%s", arg_names[i]); + } + String *invoke_args = NewStringEmpty(); + if (wrapperType == memberfn) { + Printf(invoke_args, "$this->%s", SWIG_PTR); + if (min_num_of_arguments > 0) + Printf(invoke_args, ","); + } + Printf(invoke_args, "%s", args); + bool had_a_case = false; + int last_handled_i = i - 1; + for (; i < max_num_of_arguments; ++i) { + if (i) + Printf(args, ","); + const char *value = Char(arg_values[i]); + // FIXME: (really_overloaded && handle_as_overload) is perhaps a + // little conservative, but it doesn't hit any cases that it + // shouldn't for Xapian at least (and we need it to handle + // "Enquire::get_mset()" correctly). + bool non_php_default = ((really_overloaded && handle_as_overload) || + !value || strcmp(value, "?") == 0); + if (non_php_default) + value = "null"; + Printf(args, "$%s=%s", arg_names[i], value); + if (non_php_default) { + if (!had_a_case) { + Printf(prepare, "\t\tswitch (func_num_args()) {\n"); + had_a_case = true; + } + Printf(prepare, "\t\t"); + while (last_handled_i < i) { + Printf(prepare, "case %d: ", ++last_handled_i); + } + if (Cmp(d, "void") != 0) + Printf(prepare, "$r="); + Printf(prepare, "%s(%s); break;\n", iname, invoke_args); + } + if (i || wrapperType == memberfn) + Printf(invoke_args, ","); + Printf(invoke_args, "$%s", arg_names[i]); + } + Printf(prepare, "\t\t"); + if (had_a_case) + Printf(prepare, "default: "); + if (Cmp(d, "void") != 0) + Printf(prepare, "$r="); + Printf(prepare, "%s(%s);\n", iname, invoke_args); + if (had_a_case) + Printf(prepare, "\t\t}\n"); + Delete(invoke_args); + Printf(invoke, "$r"); + } + + Printf(output, "\n"); + // If it's a member function or a class constructor... + if (wrapperType == memberfn || (newobject && current_class)) { + Printf(output, "\tfunction %s(%s) {\n", methodname, args); + // 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")) { + SwigType *t = Getattr(current_class, "classtype"); + String *mangled_type = SwigType_manglestr(SwigType_ltype(t)); + Printf(s_oowrappers, "\t\tif (is_resource($%s) && get_resource_type($%s) == \"_p%s\") {\n", arg_names[0], arg_names[0], mangled_type); + Printf(s_oowrappers, "\t\t\t$this->%s=$%s;\n", SWIG_PTR, arg_names[0]); + Printf(s_oowrappers, "\t\t\treturn;\n"); + Printf(s_oowrappers, "\t\t}\n"); + } + } 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); + } else if (Cmp(d, "void") == 0) { + if (Cmp(invoke, "$r") != 0) + Printf(output, "\t\t%s;\n", invoke); + } else if (is_class(d)) { + if (Cmp(invoke, "$r") != 0) + Printf(output, "\t\t$r=%s;\n", invoke); + if (Len(ret_types) == 1) { + Printf(output, "\t\treturn is_resource($r) ? new %s%s($r) : $r;\n", prefix, Getattr(classLookup(d), "sym:name")); + } else { + Printf(output, "\t\tif (!is_resource($r)) return $r;\n"); + Printf(output, "\t\tswitch (get_resource_type($r)) {\n"); + Iterator i = First(ret_types); + while (i.item) { + SwigType *ret_type = i.item; + i = Next(i); + Printf(output, "\t\t"); + String *mangled = NewString("_p"); + Printf(mangled, "%s", SwigType_manglestr(ret_type)); + Node *class_node = Getattr(zend_types, mangled); + if (!class_node) { + /* This is needed when we're returning a pointer to a type + * rather than returning the type by value or reference. */ + class_node = current_class; + Delete(mangled); + mangled = NewString(SwigType_manglestr(ret_type)); + class_node = Getattr(zend_types, mangled); + } + if (i.item) { + Printf(output, "case \"%s\": ", mangled); + } else { + Printf(output, "default: "); + } + const char *classname = GetChar(class_node, "sym:name"); + if (!classname) + classname = GetChar(class_node, "name"); + if (classname) + Printf(output, "return new %s%s($r);\n", prefix, classname); + else + Printf(output, "return $r;\n"); + Delete(mangled); + } + Printf(output, "\t\t}\n"); + } + } else { + Printf(output, "\t\treturn %s;\n", invoke); + } + Printf(output, "\t}\n"); + Delete(prepare); + Delete(invoke); + free(arg_values); + } + + DelWrapper(f); + + return SWIG_OK; + } + + /* ------------------------------------------------------------ + * globalvariableHandler() + * ------------------------------------------------------------ */ + + virtual int globalvariableHandler(Node *n) { + char *name = GetChar(n, "name"); + char *iname = GetChar(n, "sym:name"); + SwigType *t = Getattr(n, "type"); + String *tm; + + /* First do the wrappers such as name_set(), name_get() + * as provided by the baseclass's implementation of variableWrapper + */ + if (Language::globalvariableHandler(n) == SWIG_NOWRAP) { + return SWIG_NOWRAP; + } + + if (!addSymbol(iname, n)) + return SWIG_ERROR; + + SwigType_remember(t); + + /* First link C variables to PHP */ + + tm = Swig_typemap_lookup("varinit", n, name, 0); + if (tm) { + Replaceall(tm, "$target", name); + Printf(s_vinit, "%s\n", tm); + } else { + Printf(stderr, "%s: Line %d, Unable to link with type %s\n", input_file, line_number, SwigType_str(t, 0)); + } + + /* Now generate PHP -> C sync blocks */ + /* + tm = Swig_typemap_lookup("varin", n, name, 0); + if(tm) { + Replaceall(tm, "$symname", iname); + Printf(f_c->code, "%s\n", tm); + } else { + Printf(stderr,"%s: Line %d, Unable to link with type %s\n", + input_file, line_number, SwigType_str(t, 0)); + } + */ + /* Now generate C -> PHP sync blocks */ + /* + if(!GetFlag(n,"feature:immutable")) { + + tm = Swig_typemap_lookup("varout", n, name, 0); + if(tm) { + Replaceall(tm, "$symname", iname); + Printf(f_php->code, "%s\n", tm); + } else { + Printf(stderr,"%s: Line %d, Unable to link with type %s\n", + input_file, line_number, SwigType_str(t, 0)); + } + } + */ + return SWIG_OK; + } + + /* ------------------------------------------------------------ + * constantWrapper() + * ------------------------------------------------------------ */ + + virtual int constantWrapper(Node *n) { + String *name = GetChar(n, "name"); + String *iname = GetChar(n, "sym:name"); + SwigType *type = Getattr(n, "type"); + String *rawval = Getattr(n, "rawval"); + String *value = rawval ? rawval : Getattr(n, "value"); + String *tm; + + if (!addSymbol(iname, n)) + return SWIG_ERROR; + + SwigType_remember(type); + + if ((tm = Swig_typemap_lookup("consttab", n, name, 0))) { + Replaceall(tm, "$source", value); + Replaceall(tm, "$target", name); + Replaceall(tm, "$value", value); + Printf(s_cinit, "%s\n", tm); + } + + if (shadow && php_version == 5) { + String *enumvalue = GetChar(n, "enumvalue"); + String *set_to = iname; + + if (!enumvalue) { + enumvalue = GetChar(n, "enumvalueex"); + } + + if (enumvalue) { + // Check for a simple constant expression which is valid in PHP. + // If we find one, initialise the const member with it; otherwise + // we initialise it using the C/C++ wrapped constant. + const char *p; + for (p = Char(enumvalue); *p; ++p) { + if (!isdigit((unsigned char)*p) && !strchr(" +-", *p)) { + // FIXME: enhance to handle ` + 1' which is what + // we get for enums that don't have an explicit value set. + break; + } + } + if (!*p) set_to = enumvalue; + } + + if (wrapping_member_constant) { + if (!s_oowrappers) + s_oowrappers = NewStringEmpty(); + Printf(s_oowrappers, "\n\tconst %s = %s;\n", wrapping_member_constant, set_to); + } else { + if (!s_fakeoowrappers) + s_fakeoowrappers = NewStringEmpty(); + Printf(s_fakeoowrappers, "\n\tconst %s = %s;\n", iname, set_to); + } + } + + return SWIG_OK; + } + + /* + * PHP::pragma() + * + * Pragma directive. + * + * %pragma(php4) code="String" # Includes a string in the .php file + * %pragma(php4) include="file.pl" # Includes a file in the .php file + */ + + virtual int pragmaDirective(Node *n) { + if (!ImportMode) { + String *lang = Getattr(n, "lang"); + String *type = Getattr(n, "name"); + String *value = Getattr(n, "value"); + + if (Strcmp(lang, "php4") == 0) { + if (Strcmp(type, "code") == 0) { + if (value) { + Printf(pragma_code, "%s\n", value); + } + } else if (Strcmp(type, "include") == 0) { + if (value) { + Printf(pragma_incl, "include \"%s\";\n", value); + } + } else if (Strcmp(type, "phpinfo") == 0) { + if (value) { + Printf(pragma_phpinfo, "%s\n", value); + } + } else { + Swig_warning(WARN_PHP_UNKNOWN_PRAGMA, input_file, line_number, "Unrecognized pragma <%s>.\n", type); + } + } + } + return Language::pragmaDirective(n); + } + + /* ------------------------------------------------------------ + * classDeclaration() + * ------------------------------------------------------------ */ + + virtual int classDeclaration(Node *n) { + if (!Getattr(n, "feature:onlychildren")) { + String *symname = Getattr(n, "sym:name"); + Setattr(n, "php:proxy", symname); + } + + return Language::classDeclaration(n); + } + + /* ------------------------------------------------------------ + * classHandler() + * ------------------------------------------------------------ */ + + virtual int classHandler(Node *n) { + constructors = 0; + //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"); + + if (!addSymbol(rename, n)) + return SWIG_ERROR; + shadow_classname = NewString(rename); + + shadow_get_vars = NewHash(); + shadow_set_vars = NewHash(); + + /* Deal with inheritance */ + List *baselist = Getattr(n, "bases"); + if (baselist) { + Iterator base = First(baselist); + while (base.item && GetFlag(base.item, "feature:ignore")) { + base = Next(base); + } + base = Next(base); + if (base.item) { + /* Warn about multiple inheritance for additional base class(es) */ + while (base.item) { + if (GetFlag(base.item, "feature:ignore")) { + base = Next(base); + continue; + } + String *proxyclassname = SwigType_str(Getattr(n, "classtypeobj"), 0); + String *baseclassname = SwigType_str(Getattr(base.item, "name"), 0); + Swig_warning(WARN_PHP_MULTIPLE_INHERITANCE, input_file, line_number, + "Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in PHP.\n", proxyclassname, baseclassname); + base = Next(base); + } + } + } + } + + classnode = n; + Language::classHandler(n); + classnode = 0; + + if (shadow) { + DOH *key; + List *baselist = Getattr(n, "bases"); + Iterator ki, base; + + if (baselist) { + base = First(baselist); + while (base.item && GetFlag(base.item, "feature:ignore")) { + base = Next(base); + } + } else { + base.item = NULL; + } + + if (Getattr(n, "abstract") && !GetFlag(n, "feature:notabstract")) { + Printf(s_phpclasses, "abstract "); + } + + Printf(s_phpclasses, "class %s%s ", prefix, shadow_classname); + if (base.item) { + String *baseclass = Getattr(base.item, "sym:name"); + if (!baseclass) + baseclass = Getattr(base.item, "name"); + Printf(s_phpclasses, "extends %s%s ", prefix, baseclass); + } + Printf(s_phpclasses, "{\n\tpublic $%s=null;\n", SWIG_PTR); + + // 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); + 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}\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}\n"); + } + // Write property GET handlers + ki = First(shadow_get_vars); + + if (ki.key) { + // This class has getters. + Printf(s_phpclasses, "\n\tfunction __get($var) {\n"); + // 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); + } + } 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); + } + // Reading an unknown property name gives null in PHP. + Printf(s_phpclasses, "\t\treturn null;\n"); + Printf(s_phpclasses, "\t}\n"); + } + + if (!class_has_ctor) { + Printf(s_phpclasses, "\tfunction __construct($h) {\n"); + Printf(s_phpclasses, "\t\t$this->%s=$h;\n", SWIG_PTR); + Printf(s_phpclasses, "\t}\n"); + } + + if (s_oowrappers) { + Printf(s_phpclasses, "%s", s_oowrappers); + Delete(s_oowrappers); + s_oowrappers = NULL; + } + class_has_ctor = false; + + Printf(s_phpclasses, "}\n\n"); + + Delete(shadow_classname); + shadow_classname = NULL; + + Delete(shadow_set_vars); + shadow_set_vars = NULL; + Delete(shadow_get_vars); + shadow_get_vars = NULL; + } + return SWIG_OK; + } + + /* ------------------------------------------------------------ + * memberfunctionHandler() + * ------------------------------------------------------------ */ + + virtual int memberfunctionHandler(Node *n) { + wrapperType = memberfn; + this->Language::memberfunctionHandler(n); + wrapperType = standard; + + return SWIG_OK; + } + + /* ------------------------------------------------------------ + * membervariableHandler() + * ------------------------------------------------------------ */ + + virtual int membervariableHandler(Node *n) { + wrapperType = membervar; + Language::membervariableHandler(n); + wrapperType = standard; + + return SWIG_OK; + } + + /* ------------------------------------------------------------ + * staticmembervariableHandler() + * ------------------------------------------------------------ */ + + virtual int staticmembervariableHandler(Node *n) { + wrapperType = staticmembervar; + Language::staticmembervariableHandler(n); + wrapperType = standard; + + 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); + create_command(iname, Swig_name_wrapper(class_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; + } + + /* ------------------------------------------------------------ + * staticmemberfunctionHandler() + * ------------------------------------------------------------ */ + + virtual int staticmemberfunctionHandler(Node *n) { + wrapperType = staticmemberfn; + Language::staticmemberfunctionHandler(n); + wrapperType = standard; + + 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(); + } + + String *PhpTypeFromTypemap(char *op, Node *n, String_or_char *lname) { + String *tms = Swig_typemap_lookup(op, n, lname, 0); + if (!tms) + return 0; + else + return NewStringf("%s", tms); + } + + int abstractConstructorHandler(Node *) { + return SWIG_OK; + } + + /* ------------------------------------------------------------ + * constructorHandler() + * ------------------------------------------------------------ */ + + virtual int constructorHandler(Node *n) { + constructors++; + wrapperType = constructor; + Language::constructorHandler(n); + wrapperType = standard; + + return SWIG_OK; + } + + /* ------------------------------------------------------------ + * CreateZendListDestructor() + * ------------------------------------------------------------ */ + //virtual int destructorHandler(Node *n) { + //} + int CreateZendListDestructor(Node *n) { + String *name = GetChar(Swig_methodclass(n), "name"); + String *iname = GetChar(n, "sym:name"); + ParmList *l = Getattr(n, "parms"); + + String *destructorname = NewStringEmpty(); + Printf(destructorname, "_%s", Swig_name_wrapper(iname)); + Setattr(classnode, "destructor", destructorname); + + Wrapper *f = NewWrapper(); + Printf(f->def, "/* This function is designed to be called by the zend list destructors */\n"); + Printf(f->def, "/* to typecast and do the actual destruction */\n"); + Printf(f->def, "static void %s(zend_rsrc_list_entry *rsrc, const char *type_name TSRMLS_DC) {\n", destructorname); + + Wrapper_add_localv(f, "value", "swig_object_wrapper *value=(swig_object_wrapper *) rsrc->ptr", NIL); + Wrapper_add_localv(f, "ptr", "void *ptr=value->ptr", NIL); + Wrapper_add_localv(f, "newobject", "int newobject=value->newobject", NIL); + + emit_parameter_variables(l, f); + emit_attach_parmmaps(l, f); + + // Get type of first arg, thing to be destructed + // Skip ignored arguments + Parm *p = l; + //while (Getattr(p,"tmap:ignore")) {p = Getattr(p,"tmap:ignore:next");} + while (checkAttribute(p, "tmap:in:numinputs", "0")) { + p = Getattr(p, "tmap:in:next"); + } + SwigType *pt = Getattr(p, "type"); + + Printf(f->code, " efree(value);\n"); + Printf(f->code, " if (! newobject) return; /* can't delete it! */\n"); + Printf(f->code, " arg1 = (%s)SWIG_ZTS_ConvertResourceData(ptr,type_name,SWIGTYPE%s TSRMLS_CC);\n", SwigType_lstr(pt, 0), SwigType_manglestr(pt)); + Printf(f->code, " if (! arg1) zend_error(E_ERROR, \"%s resource already free'd\");\n", Char(name)); + + Setattr(n, "wrap:name", destructorname); + + String *actioncode = emit_action(n); + Append(f->code, actioncode); + Delete(actioncode); + + Printf(f->code, "}\n"); + + Wrapper_print(f, s_wrappers); + + return SWIG_OK; + + } + + /* ------------------------------------------------------------ + * memberconstantHandler() + * ------------------------------------------------------------ */ + + virtual int memberconstantHandler(Node *n) { + wrapping_member_constant = Getattr(n, "name"); + Language::memberconstantHandler(n); + wrapping_member_constant = NULL; + return SWIG_OK; + } + +}; /* class PHP */ + +/* ----------------------------------------------------------------------------- + * swig_php() - Instantiate module + * ----------------------------------------------------------------------------- */ + +static PHP *maininstance = 0; + +// We use this function to be able to write out zend_register_list_destructor_ex +// lines for most things in the type table +// NOTE: it's a function NOT A PHP::METHOD +extern "C" void typetrace(SwigType *ty, String *mangled, String *clientdata) { + Node *class_node; + if (!zend_types) { + zend_types = NewHash(); + } + // we want to know if the type which reduced to this has a constructor + if ((class_node = maininstance->classLookup(ty))) { + if (!Getattr(zend_types, mangled)) { + // OK it may have been set before by a different SwigType but it would + // have had the same underlying class node I think + // - it is certainly required not to have different originating class + // nodes for the same SwigType + Setattr(zend_types, mangled, class_node); + } + } else { // a non-class pointer + Setattr(zend_types, mangled, NOTCLASS); + } + if (r_prevtracefunc) + (*r_prevtracefunc) (ty, mangled, (String *) clientdata); +} + +static Language *new_swig_php(int php_version) { + maininstance = new PHP(php_version); + if (!r_prevtracefunc) { + r_prevtracefunc = SwigType_remember_trace(typetrace); + } else { + Printf(stderr, "php Typetrace vector already saved!\n"); + assert(0); + } + return maininstance; +} + +extern "C" Language *swig_php4(void) { + Printf(stderr, "*** -php4 is no longer supported.\n" + "*** Either upgrade to PHP5 or use SWIG 1.3.36 or earlier.\n"); + SWIG_exit(EXIT_FAILURE); + return NULL; // To avoid compiler warnings. +} + +extern "C" Language *swig_php5(void) { + return new_swig_php(5); +} diff --git a/Source/Modules/php4.cxx b/Source/Modules/php5.cxx similarity index 100% rename from Source/Modules/php4.cxx rename to Source/Modules/php5.cxx From 12a2463f24551de8db0b1add703e65e33b4e316b Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Thu, 3 Jul 2008 00:12:58 +0000 Subject: [PATCH 0066/1680] Remove file added in error. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10634 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/php5.cxx | 2361 --------------------------------------- 1 file changed, 2361 deletions(-) delete mode 100644 Source/Modules/php5.cxx diff --git a/Source/Modules/php5.cxx b/Source/Modules/php5.cxx deleted file mode 100644 index 1bd214423..000000000 --- a/Source/Modules/php5.cxx +++ /dev/null @@ -1,2361 +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. - * - * php4.cxx - * - * Php language module for SWIG. - * ----------------------------------------------------------------------------- - */ - -/* FIXME: PHP5 OO wrapping TODO list: - * - * 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: - * - * Handle default parameters on overloaded methods in PHP where possible. - * (Mostly done - just need to handle cases of overloaded methods with - * default parameters...) - * This is an optimisation - we could handle this case using a PHP - * default value, but currently we treat it as we would for a default - * value which is a compound C++ expression (i.e. as if we had a - * method with two overloaded forms instead of a single method with - * a default parameter value). - * - * Long term: - * - * Sort out locale-dependent behaviour of strtod() - it's harmless unless - * SWIG ever sets the locale and DOH/base.c calls atof, so we're probably - * OK currently at least. - */ - -/* - * TODO: Replace remaining stderr messages with Swig_error or Swig_warning - * (may need to add more WARN_PHP4_xxx codes...) - */ - -char cvsroot_php4_cxx[] = "$Id$"; - -#include "swigmod.h" - -#include -#include - -static const char *usage = (char *) "\ -PHP Options (available with -php5)\n\ - -cppext - cpp file extension (default to .cpp)\n\ - -noproxy - Don't generate proxy classes.\n\ - -prefix - Prepend to all class names in PHP5 wrappers\n\ - -make - Create simple makefile\n\ - -phpfull - Create full make files\n\ - -withincs - With -phpfull writes needed incs in config.m4\n\ - -withlibs - With -phpfull writes needed libs in config.m4\n\ - -withc - With -phpfull makes extra C files in Makefile.in\n\ - -withcxx - With -phpfull makes extra C++ files in Makefile.in\n\ -\n"; - -/* The original class wrappers for PHP4 store the pointer to the C++ class in - * the object property _cPtr. If we use the same name for the member variable - * which we put the pointer to the C++ class in, then the flat function - * wrappers will automatically pull it out without any changes being required. - * FIXME: Isn't using a leading underscore a bit suspect here? - */ -#define SWIG_PTR "_cPtr" - -static int constructors = 0; -static String *NOTCLASS = NewString("Not a class"); -static Node *classnode = 0; -static String *module = 0; -static String *cap_module = 0; -static String *prefix = 0; -static String *withlibs = 0; -static String *withincs = 0; -static String *withc = 0; -static String *withcxx = 0; - -static String *shadow_classname = 0; - -static int gen_extra = 0; -static int gen_make = 0; - -static File *f_runtime = 0; -static File *f_h = 0; -static File *f_phpcode = 0; -static String *phpfilename = 0; - -static String *s_header; -static String *s_wrappers; -static String *s_init; -static String *r_init; // RINIT user code -static String *s_shutdown; // MSHUTDOWN user code -static String *r_shutdown; // RSHUTDOWN user code -static String *s_vinit; // varinit initialization code. -static String *s_vdecl; -static String *s_cinit; // consttab initialization code. -static String *s_oinit; -static String *s_entry; -static String *cs_entry; -static String *all_cs_entry; -static String *pragma_incl; -static String *pragma_code; -static String *pragma_phpinfo; -static String *s_oowrappers; -static String *s_fakeoowrappers; -static String *s_phpclasses; - -/* Variables for using PHP classes */ -static Node *current_class = 0; - -static Hash *shadow_get_vars; -static Hash *shadow_set_vars; -static Hash *zend_types = 0; - -static int shadow = 1; - -static bool class_has_ctor = false; -static String *wrapping_member_constant = NULL; - -// These static variables are used to pass some state from Handlers into functionWrapper -static enum { - standard = 0, - memberfn, - staticmemberfn, - membervar, - staticmembervar, - constructor, - destructor -} wrapperType = standard; - -extern "C" { - static void (*r_prevtracefunc) (SwigType *t, String *mangled, String *clientdata) = 0; -} - -void SwigPHP_emit_resource_registrations() { - Iterator ki; - - if (!zend_types) - return; - - ki = First(zend_types); - if (ki.key) - Printf(s_oinit, "\n/* Register resource destructors for pointer types */\n"); - while (ki.key) { - DOH *key = ki.key; - Node *class_node = ki.item; - String *human_name = key; - - // Write out destructor function header - Printf(s_wrappers, "/* NEW Destructor style */\nstatic ZEND_RSRC_DTOR_FUNC(_wrap_destroy%s) {\n", key); - - // write out body - if ((class_node != NOTCLASS)) { - String *destructor = Getattr(class_node, "destructor"); - human_name = Getattr(class_node, "sym:name"); - if (!human_name) - human_name = Getattr(class_node, "name"); - // Do we have a known destructor for this type? - if (destructor) { - Printf(s_wrappers, " %s(rsrc, SWIGTYPE%s->name TSRMLS_CC);\n", destructor, key); - } else { - Printf(s_wrappers, " /* No destructor for class %s */\n", human_name); - } - } else { - Printf(s_wrappers, " /* No destructor for simple type %s */\n", key); - } - - // close function - Printf(s_wrappers, "}\n"); - - // declare le_swig_ to store php registration - Printf(s_vdecl, "static int le_swig_%s=0; /* handle for %s */\n", key, human_name); - - // register with php - Printf(s_oinit, "le_swig_%s=zend_register_list_destructors_ex" "(_wrap_destroy%s,NULL,(char *)(SWIGTYPE%s->name),module_number);\n", key, key, key); - - // store php type in class struct - Printf(s_oinit, "SWIG_TypeClientData(SWIGTYPE%s,&le_swig_%s);\n", key, key); - - ki = Next(ki); - } -} - -class PHP:public Language { - int php_version; - -public: - PHP(int php_version_):php_version(php_version_) { - } - - /* 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() - * ------------------------------------------------------------ */ - - virtual void main(int argc, char *argv[]) { - int i; - SWIG_library_directory("php4"); - SWIG_config_cppext("cpp"); - - for (i = 1; i < argc; i++) { - if (argv[i]) { - if (strcmp(argv[i], "-phpfull") == 0) { - gen_extra = 1; - Swig_mark_arg(i); - } else if (strcmp(argv[i], "-dlname") == 0) { - Printf(stderr, "*** -dlname is no longer supported\n*** if you want to change the module name, use -module instead.\n"); - SWIG_exit(EXIT_FAILURE); - } else if (strcmp(argv[i], "-prefix") == 0) { - if (argv[i + 1]) { - prefix = NewString(argv[i + 1]); - Swig_mark_arg(i); - Swig_mark_arg(i + 1); - i++; - } else { - Swig_arg_error(); - } - } else if (strcmp(argv[i], "-withlibs") == 0) { - if (argv[i + 1]) { - withlibs = NewString(argv[i + 1]); - Swig_mark_arg(i); - Swig_mark_arg(i + 1); - i++; - } else { - Swig_arg_error(); - } - } else if (strcmp(argv[i], "-withincs") == 0) { - if (argv[i + 1]) { - withincs = NewString(argv[i + 1]); - Swig_mark_arg(i); - Swig_mark_arg(i + 1); - i++; - } else { - Swig_arg_error(); - } - } else if (strcmp(argv[i], "-withc") == 0) { - if (argv[i + 1]) { - withc = NewString(argv[i + 1]); - Swig_mark_arg(i); - Swig_mark_arg(i + 1); - i++; - } else { - Swig_arg_error(); - } - } else if (strcmp(argv[i], "-withcxx") == 0) { - if (argv[i + 1]) { - withcxx = NewString(argv[i + 1]); - Swig_mark_arg(i); - Swig_mark_arg(i + 1); - i++; - } else { - Swig_arg_error(); - } - } else if (strcmp(argv[i], "-cppext") == 0) { - if (argv[i + 1]) { - SWIG_config_cppext(argv[i + 1]); - Swig_mark_arg(i); - Swig_mark_arg(i + 1); - i++; - } else { - Swig_arg_error(); - } - } else if ((strcmp(argv[i], "-noshadow") == 0) || (strcmp(argv[i], "-noproxy") == 0)) { - shadow = 0; - Swig_mark_arg(i); - } else if (strcmp(argv[i], "-make") == 0) { - gen_make = 1; - Swig_mark_arg(i); - } else if (strcmp(argv[i], "-help") == 0) { - fputs(usage, stdout); - } - } - } - - Preprocessor_define((void *) "SWIGPHP 1", 0); - Preprocessor_define((void *) "SWIGPHP5 1", 0); - SWIG_typemap_lang("php4"); - /* DB: Suggest using a language configuration file */ - SWIG_config_file("php4.swg"); - allow_overloading(); - } - - void create_simple_make(void) { - File *f_make; - - f_make = NewFile((void *) "makefile", "w"); - Printf(f_make, "CC=gcc\n"); - Printf(f_make, "CXX=g++\n"); - Printf(f_make, "CXX_SOURCES=%s\n", withcxx); - Printf(f_make, "C_SOURCES=%s\n", withc); - Printf(f_make, "OBJS=%s_wrap.o $(C_SOURCES:.c=.o) $(CXX_SOURCES:.cxx=.o)\n", module); - Printf(f_make, "MODULE=%s.so\n", module); - Printf(f_make, "CFLAGS=-fpic\n"); - Printf(f_make, "LDFLAGS=-shared\n"); - Printf(f_make, "PHP_INC=`php-config --includes`\n"); - Printf(f_make, "EXTRA_INC=\n"); - Printf(f_make, "EXTRA_LIB=\n\n"); - Printf(f_make, "$(MODULE): $(OBJS)\n"); - if (CPlusPlus || (withcxx != NULL)) { - Printf(f_make, "\t$(CXX) $(LDFLAGS) $(OBJS) -o $@ $(EXTRA_LIB)\n\n"); - } else { - Printf(f_make, "\t$(CC) $(LDFLAGS) $(OBJS) -o $@ $(EXTRA_LIB)\n\n"); - } - Printf(f_make, "%%.o: %%.cpp\n"); - Printf(f_make, "\t$(CXX) $(EXTRA_INC) $(PHP_INC) $(CFLAGS) -c $<\n"); - Printf(f_make, "%%.o: %%.cxx\n"); - Printf(f_make, "\t$(CXX) $(EXTRA_INC) $(PHP_INC) $(CFLAGS) -c $<\n"); - Printf(f_make, "%%.o: %%.c\n"); - Printf(f_make, "\t$(CC) $(EXTRA_INC) $(PHP_INC) $(CFLAGS) -c $<\n"); - - Close(f_make); - } - - void create_extra_files(String *outfile) { - File *f_extra; - - static String *configm4 = 0; - static String *makefilein = 0; - static String *credits = 0; - - configm4 = NewStringEmpty(); - Printv(configm4, SWIG_output_directory(), "config.m4", NIL); - - makefilein = NewStringEmpty(); - Printv(makefilein, SWIG_output_directory(), "Makefile.in", NIL); - - credits = NewStringEmpty(); - Printv(credits, SWIG_output_directory(), "CREDITS", NIL); - - // are we a --with- or --enable- - int with = (withincs || withlibs) ? 1 : 0; - - // Note Makefile.in only copes with one source file - // also withincs and withlibs only take one name each now - // the code they generate should be adapted to take multiple lines - - /* Write out Makefile.in */ - f_extra = NewFile(makefilein, "w"); - if (!f_extra) { - FileErrorDisplay(makefilein); - SWIG_exit(EXIT_FAILURE); - } - - Printf(f_extra, "# $Id$\n\n" "LTLIBRARY_NAME = %s.la\n", module); - - // C++ has more and different entries to C in Makefile.in - if (!CPlusPlus) { - Printf(f_extra, "LTLIBRARY_SOURCES = %s %s\n", Swig_file_filename(outfile), withc); - Printf(f_extra, "LTLIBRARY_SOURCES_CPP = %s\n", withcxx); - } else { - Printf(f_extra, "LTLIBRARY_SOURCES = %s\n", withc); - Printf(f_extra, "LTLIBRARY_SOURCES_CPP = %s %s\n", Swig_file_filename(outfile), withcxx); - Printf(f_extra, "LTLIBRARY_OBJECTS_X = $(LTLIBRARY_SOURCES_CPP:.cpp=.lo) $(LTLIBRARY_SOURCES_CPP:.cxx=.lo)\n"); - } - Printf(f_extra, "LTLIBRARY_SHARED_NAME = %s.la\n", module); - Printf(f_extra, "LTLIBRARY_SHARED_LIBADD = $(%s_SHARED_LIBADD)\n\n", cap_module); - Printf(f_extra, "include $(top_srcdir)/build/dynlib.mk\n"); - - Printf(f_extra, "\n# patch in .cxx support to php build system to work like .cpp\n"); - Printf(f_extra, ".SUFFIXES: .cxx\n\n"); - - Printf(f_extra, ".cxx.o:\n"); - Printf(f_extra, "\t$(CXX_COMPILE) -c $<\n\n"); - - Printf(f_extra, ".cxx.lo:\n"); - Printf(f_extra, "\t$(CXX_PHP_COMPILE)\n\n"); - Printf(f_extra, ".cxx.slo:\n"); - - Printf(f_extra, "\t$(CXX_SHARED_COMPILE)\n\n"); - - Printf(f_extra, "\n# make it easy to test module\n"); - Printf(f_extra, "testmodule:\n"); - Printf(f_extra, "\tphp -q -d extension_dir=modules %s\n\n", Swig_file_filename(phpfilename)); - - Close(f_extra); - - /* Now config.m4 */ - // Note: # comments are OK in config.m4 if you don't mind them - // appearing in the final ./configure file - // (which can help with ./configure debugging) - - // NOTE2: phpize really ought to be able to write out a sample - // config.m4 based on some simple data, I'll take this up with - // the php folk! - f_extra = NewFile(configm4, "w"); - if (!f_extra) { - FileErrorDisplay(configm4); - SWIG_exit(EXIT_FAILURE); - } - - Printf(f_extra, "dnl $Id$\n"); - Printf(f_extra, "dnl ***********************************************************************\n"); - Printf(f_extra, "dnl ** THIS config.m4 is provided for PHPIZE and PHP's consumption NOT\n"); - Printf(f_extra, "dnl ** for any part of the rest of the %s build system\n", module); - Printf(f_extra, "dnl ***********************************************************************\n\n"); - - - if (!with) { // must be enable then - Printf(f_extra, "PHP_ARG_ENABLE(%s, whether to enable %s support,\n", module, module); - Printf(f_extra, "[ --enable-%s Enable %s support])\n\n", module, module); - } else { - Printf(f_extra, "PHP_ARG_WITH(%s, for %s support,\n", module, module); - Printf(f_extra, "[ --with-%s[=DIR] Include %s support.])\n\n", module, module); - // These tests try and file the library we need - Printf(f_extra, "dnl THESE TESTS try and find the library and header files\n"); - Printf(f_extra, "dnl your new php module needs. YOU MAY NEED TO EDIT THEM\n"); - Printf(f_extra, "dnl as written they assume your header files are all in the same place\n\n"); - - Printf(f_extra, "dnl ** are we looking for %s_lib.h or something else?\n", module); - if (withincs) - Printf(f_extra, "HNAMES=\"%s\"\n\n", withincs); - else - Printf(f_extra, "HNAMES=\"\"; # %s_lib.h ?\n\n", module); - - Printf(f_extra, "dnl ** Are we looking for lib%s.a or lib%s.so or something else?\n", module, module); - - if (withlibs) - Printf(f_extra, "LIBNAMES=\"%s\"\n\n", withlibs); - else - Printf(f_extra, "LIBNAMES=\"\"; # lib%s.so ?\n\n", module); - - Printf(f_extra, "dnl IF YOU KNOW one of the symbols in the library and you\n"); - Printf(f_extra, "dnl specify it below then we can have a link test to see if it works\n"); - Printf(f_extra, "LIBSYMBOL=\"\"\n\n"); - } - - // Now write out tests to find thing.. they may need to extend tests - Printf(f_extra, "if test \"$PHP_%s\" != \"no\"; then\n\n", cap_module); - - // Ready for when we add libraries as we find them - Printf(f_extra, " PHP_SUBST(%s_SHARED_LIBADD)\n\n", cap_module); - - if (withlibs) { // find more than one library - Printf(f_extra, " for LIBNAME in $LIBNAMES ; do\n"); - Printf(f_extra, " LIBDIR=\"\"\n"); - // For each path element to try... - Printf(f_extra, " for i in $PHP_%s $PHP_%s/lib /usr/lib /usr/local/lib ; do\n", cap_module, cap_module); - Printf(f_extra, " if test -r $i/lib$LIBNAME.a -o -r $i/lib$LIBNAME.so ; then\n"); - Printf(f_extra, " LIBDIR=\"$i\"\n"); - Printf(f_extra, " break\n"); - Printf(f_extra, " fi\n"); - Printf(f_extra, " done\n\n"); - Printf(f_extra, " dnl ** and $LIBDIR should be the library path\n"); - Printf(f_extra, " if test \"$LIBNAME\" != \"\" -a -z \"$LIBDIR\" ; then\n"); - Printf(f_extra, " AC_MSG_RESULT(Library files $LIBNAME not found)\n"); - Printf(f_extra, " AC_MSG_ERROR(Is the %s distribution installed properly?)\n", module); - Printf(f_extra, " else\n"); - Printf(f_extra, " AC_MSG_RESULT(Library files $LIBNAME found in $LIBDIR)\n"); - Printf(f_extra, " PHP_ADD_LIBRARY_WITH_PATH($LIBNAME, $LIBDIR, %s_SHARED_LIBADD)\n", cap_module); - Printf(f_extra, " fi\n"); - Printf(f_extra, " done\n\n"); - } - - if (withincs) { // Find more than once include - Printf(f_extra, " for HNAME in $HNAMES ; do\n"); - Printf(f_extra, " INCDIR=\"\"\n"); - // For each path element to try... - Printf(f_extra, " for i in $PHP_%s $PHP_%s/include $PHP_%s/includes $PHP_%s/inc $PHP_%s/incs /usr/local/include /usr/include; do\n", cap_module, - cap_module, cap_module, cap_module, cap_module); - // Try and find header files - Printf(f_extra, " if test \"$HNAME\" != \"\" -a -r $i/$HNAME ; then\n"); - Printf(f_extra, " INCDIR=\"$i\"\n"); - Printf(f_extra, " break\n"); - Printf(f_extra, " fi\n"); - Printf(f_extra, " done\n\n"); - - Printf(f_extra, " dnl ** Now $INCDIR should be the include file path\n"); - Printf(f_extra, " if test \"$HNAME\" != \"\" -a -z \"$INCDIR\" ; then\n"); - Printf(f_extra, " AC_MSG_RESULT(Include files $HNAME not found)\n"); - Printf(f_extra, " AC_MSG_ERROR(Is the %s distribution installed properly?)\n", module); - Printf(f_extra, " else\n"); - Printf(f_extra, " AC_MSG_RESULT(Include files $HNAME found in $INCDIR)\n"); - Printf(f_extra, " PHP_ADD_INCLUDE($INCDIR)\n"); - Printf(f_extra, " fi\n\n"); - Printf(f_extra, " done\n\n"); - } - - if (CPlusPlus) { - Printf(f_extra, " # As this is a C++ module..\n"); - } - - Printf(f_extra, " PHP_REQUIRE_CXX\n"); - Printf(f_extra, " AC_CHECK_LIB(stdc++, cin)\n"); - - if (with) { - Printf(f_extra, " if test \"$LIBSYMBOL\" != \"\" ; then\n"); - Printf(f_extra, " old_LIBS=\"$LIBS\"\n"); - Printf(f_extra, " LIBS=\"$LIBS -L$TEST_DIR/lib -lm -ldl\"\n"); - Printf(f_extra, " AC_CHECK_LIB($LIBNAME, $LIBSYMBOL, [AC_DEFINE(HAVE_TESTLIB,1, [ ])],\n"); - Printf(f_extra, " [AC_MSG_ERROR(wrong test lib version or lib not found)])\n"); - Printf(f_extra, " LIBS=\"$old_LIBS\"\n"); - Printf(f_extra, " fi\n\n"); - } - - Printf(f_extra, " AC_DEFINE(HAVE_%s, 1, [ ])\n", cap_module); - Printf(f_extra, "dnl AC_DEFINE_UNQUOTED(PHP_%s_DIR, \"$%s_DIR\", [ ])\n", cap_module, cap_module); - Printf(f_extra, " PHP_EXTENSION(%s, $ext_shared)\n", module); - - // and thats all! - Printf(f_extra, "fi\n"); - - Close(f_extra); - - /* CREDITS */ - f_extra = NewFile(credits, "w"); - if (!f_extra) { - FileErrorDisplay(credits); - SWIG_exit(EXIT_FAILURE); - } - Printf(f_extra, "%s\n", module); - Close(f_extra); - } - - /* ------------------------------------------------------------ - * top() - * ------------------------------------------------------------ */ - - virtual int top(Node *n) { - - String *filen; - String *s_type; - - /* Initialize all of the output files */ - String *outfile = Getattr(n, "outfile"); - - /* main output file */ - f_runtime = NewFile(outfile, "w"); - if (!f_runtime) { - FileErrorDisplay(outfile); - SWIG_exit(EXIT_FAILURE); - } - - Swig_banner(f_runtime); - - /* sections of the output file */ - s_init = NewString("/* init section */\n"); - r_init = NewString("/* rinit section */\n"); - s_shutdown = NewString("/* shutdown section */\n"); - r_shutdown = NewString("/* rshutdown section */\n"); - s_header = NewString("/* header section */\n"); - s_wrappers = NewString("/* wrapper section */\n"); - s_type = NewStringEmpty(); - /* subsections of the init section */ - s_vinit = NewString("/* vinit subsection */\n"); - s_vdecl = NewString("/* vdecl subsection */\n"); - s_cinit = NewString("/* cinit subsection */\n"); - s_oinit = NewString("/* oinit subsection */\n"); - pragma_phpinfo = NewStringEmpty(); - s_phpclasses = NewString("/* PHP Proxy Classes */\n"); - - /* Register file targets with the SWIG file handler */ - Swig_register_filebyname("runtime", f_runtime); - Swig_register_filebyname("init", s_init); - Swig_register_filebyname("rinit", r_init); - Swig_register_filebyname("shutdown", s_shutdown); - Swig_register_filebyname("rshutdown", r_shutdown); - Swig_register_filebyname("header", s_header); - Swig_register_filebyname("wrapper", s_wrappers); - - /* Set the module name */ - module = Copy(Getattr(n, "name")); - cap_module = NewStringf("%(upper)s", module); - if (!prefix) - prefix = NewStringEmpty(); - - /* PHP module file */ - filen = NewStringEmpty(); - Printv(filen, SWIG_output_directory(), module, ".php", NIL); - phpfilename = NewString(filen); - - f_phpcode = NewFile(filen, "w"); - if (!f_phpcode) { - FileErrorDisplay(filen); - SWIG_exit(EXIT_FAILURE); - } - - Printf(f_phpcode, "error_msg = default_error_msg;\n"); - Printf(s_header, " globals->error_code = default_error_code;\n"); - Printf(s_header, "}\n"); - - Printf(s_header, "static void %s_destroy_globals(zend_%s_globals * globals) { (void)globals; }\n", module, module); - - Printf(s_header, "\n"); - Printf(s_header, "static void SWIG_ResetError() {\n"); - Printf(s_header, " TSRMLS_FETCH();\n"); - Printf(s_header, " SWIG_ErrorMsg() = default_error_msg;\n"); - Printf(s_header, " SWIG_ErrorCode() = default_error_code;\n"); - Printf(s_header, "}\n"); - - Printf(s_header, "#define SWIG_name \"%s\"\n", module); - /* Printf(s_header,"#ifdef HAVE_CONFIG_H\n"); - Printf(s_header,"#include \"config.h\"\n"); - Printf(s_header,"#endif\n\n"); - */ - Printf(s_header, "#ifdef __cplusplus\n"); - Printf(s_header, "extern \"C\" {\n"); - Printf(s_header, "#endif\n"); - Printf(s_header, "#include \"php.h\"\n"); - Printf(s_header, "#include \"php_ini.h\"\n"); - Printf(s_header, "#include \"ext/standard/info.h\"\n"); - Printf(s_header, "#include \"php_%s.h\"\n", module); - Printf(s_header, "#ifdef __cplusplus\n"); - Printf(s_header, "}\n"); - Printf(s_header, "#endif\n\n"); - - /* Create the .h file too */ - filen = NewStringEmpty(); - Printv(filen, SWIG_output_directory(), "php_", module, ".h", NIL); - f_h = NewFile(filen, "w"); - if (!f_h) { - FileErrorDisplay(filen); - SWIG_exit(EXIT_FAILURE); - } - - Swig_banner(f_h); - - Printf(f_h, "\n\n"); - Printf(f_h, "#ifndef PHP_%s_H\n", cap_module); - Printf(f_h, "#define PHP_%s_H\n\n", cap_module); - Printf(f_h, "extern zend_module_entry %s_module_entry;\n", module); - Printf(f_h, "#define phpext_%s_ptr &%s_module_entry\n\n", module, module); - Printf(f_h, "#ifdef PHP_WIN32\n"); - Printf(f_h, "# define PHP_%s_API __declspec(dllexport)\n", cap_module); - Printf(f_h, "#else\n"); - Printf(f_h, "# define PHP_%s_API\n", cap_module); - Printf(f_h, "#endif\n\n"); - Printf(f_h, "#ifdef ZTS\n"); - Printf(f_h, "#include \"TSRM.h\"\n"); - Printf(f_h, "#endif\n\n"); - Printf(f_h, "PHP_MINIT_FUNCTION(%s);\n", module); - Printf(f_h, "PHP_MSHUTDOWN_FUNCTION(%s);\n", module); - Printf(f_h, "PHP_RINIT_FUNCTION(%s);\n", module); - Printf(f_h, "PHP_RSHUTDOWN_FUNCTION(%s);\n", module); - Printf(f_h, "PHP_MINFO_FUNCTION(%s);\n\n", module); - - /* start the function entry section */ - s_entry = NewString("/* entry subsection */\n"); - - /* holds all the per-class function entry sections */ - all_cs_entry = NewString("/* class entry subsection */\n"); - cs_entry = NULL; - - Printf(s_entry, "/* Every non-class user visible function must have an entry here */\n"); - Printf(s_entry, "static zend_function_entry %s_functions[] = {\n", module); - - /* start the init section */ - 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); - Printf(s_init, " PHP_MINIT(%s),\n", module); - Printf(s_init, " PHP_MSHUTDOWN(%s),\n", module); - Printf(s_init, " PHP_RINIT(%s),\n", module); - Printf(s_init, " PHP_RSHUTDOWN(%s),\n", module); - Printf(s_init, " PHP_MINFO(%s),\n", module); - Printf(s_init, "#if ZEND_MODULE_API_NO > 20010900\n"); - Printf(s_init, " NO_VERSION_YET,\n"); - Printf(s_init, "#endif\n"); - Printf(s_init, " STANDARD_MODULE_PROPERTIES\n"); - Printf(s_init, "};\n"); - Printf(s_init, "zend_module_entry* SWIG_module_entry = &%s_module_entry;\n\n", module); - - if (gen_extra) { - Printf(s_init, "#ifdef COMPILE_DL_%s\n", cap_module); - } - Printf(s_init, "#ifdef __cplusplus\n"); - Printf(s_init, "extern \"C\" {\n"); - Printf(s_init, "#endif\n"); - // We want to write "SWIGEXPORT ZEND_GET_MODULE(%s)" but ZEND_GET_MODULE - // in PHP5 has "extern "C" { ... }" around it so we can't do that. - Printf(s_init, "SWIGEXPORT zend_module_entry *get_module(void) { return &%s_module_entry; }\n", module); - Printf(s_init, "#ifdef __cplusplus\n"); - Printf(s_init, "}\n"); - Printf(s_init, "#endif\n\n"); - - if (gen_extra) { - Printf(s_init, "#endif\n\n"); - } - - /* We have to register the constants before they are (possibly) used - * by the pointer typemaps. This all needs re-arranging really as - * things are being called in the wrong order - */ - Printf(s_init, "#define SWIG_php_minit PHP_MINIT_FUNCTION(%s)\n", module); - - /* Emit all of the code */ - Language::top(n); - - SwigPHP_emit_resource_registrations(); - // Printv(s_init,s_resourcetypes,NIL); - /* We need this after all classes written out by ::top */ - Printf(s_oinit, "CG(active_class_entry) = NULL;\n"); - Printf(s_oinit, "/* end oinit subsection */\n"); - Printf(s_init, "%s\n", s_oinit); - - /* Constants generated during top call */ - Printf(s_cinit, "/* end cinit subsection */\n"); - Printf(s_init, "%s\n", s_cinit); - Clear(s_cinit); - Delete(s_cinit); - - Printf(s_init, " return SUCCESS;\n"); - Printf(s_init, "}\n\n"); - - // Now do REQUEST init which holds any user specified %rinit, and also vinit - Printf(s_init, "PHP_RINIT_FUNCTION(%s)\n{\n", module); - Printf(s_init, "%s\n", r_init); - - /* finish our init section which will have been used by class wrappers */ - Printf(s_vinit, "/* end vinit subsection */\n"); - Printf(s_init, "%s\n", s_vinit); - Clear(s_vinit); - Delete(s_vinit); - - Printf(s_init, " return SUCCESS;\n"); - Printf(s_init, "}\n\n"); - - Printv(s_init, "PHP_MSHUTDOWN_FUNCTION(", module, ")\n" - "{\n", - s_shutdown, - "#ifdef ZTS\n" - " ts_free_id(", module, "_globals_id);\n" - "#endif\n" - " return SUCCESS;\n" - "}\n\n", NIL); - - Printf(s_init, "PHP_RSHUTDOWN_FUNCTION(%s)\n{\n", module); - Printf(s_init, "%s\n", r_shutdown); - Printf(s_init, " return SUCCESS;\n"); - Printf(s_init, "}\n\n"); - - Printf(s_init, "PHP_MINFO_FUNCTION(%s)\n{\n", module); - Printf(s_init, "%s", pragma_phpinfo); - Printf(s_init, "}\n"); - Printf(s_init, "/* end init section */\n"); - - Printf(f_h, "#endif /* PHP_%s_H */\n", cap_module); - - Close(f_h); - - String *type_table = NewStringEmpty(); - SwigType_emit_type_table(f_runtime, type_table); - Printf(s_header, "%s", type_table); - Delete(type_table); - - /* Oh dear, more things being called in the wrong order. This whole - * function really needs totally redoing. - */ - - Printf(s_header, "/* end header section */\n"); - Printf(s_wrappers, "/* end wrapper section */\n"); - Printf(s_vdecl, "/* end vdecl subsection */\n"); - - Printv(f_runtime, s_header, s_vdecl, s_wrappers, NIL); - Printv(f_runtime, all_cs_entry, "\n\n", s_entry, "{NULL, NULL, NULL}\n};\n\n", NIL); - Printv(f_runtime, s_init, NIL); - Delete(s_header); - Delete(s_wrappers); - Delete(s_init); - Delete(s_vdecl); - Delete(all_cs_entry); - Delete(s_entry); - Close(f_runtime); - - Printf(f_phpcode, "%s\n%s\n", pragma_incl, pragma_code); - if (s_fakeoowrappers) { - Printf(f_phpcode, "abstract class %s {", Len(prefix) ? prefix : module); - Printf(f_phpcode, "%s", s_fakeoowrappers); - Printf(f_phpcode, "}\n\n"); - Delete(s_fakeoowrappers); - s_fakeoowrappers = NULL; - } - Printf(f_phpcode, "%s\n?>\n", s_phpclasses); - Close(f_phpcode); - - if (gen_extra) { - create_extra_files(outfile); - } else if (gen_make) { - create_simple_make(); - } - - return SWIG_OK; - } - - /* Just need to append function names to function table to register with PHP. */ - void create_command(String *cname, String *iname) { - // This is for the single main zend_function_entry record - Printf(f_h, "ZEND_NAMED_FUNCTION(%s);\n", iname); - String * s = cs_entry; - if (!s) s = s_entry; - Printf(s, " SWIG_ZEND_NAMED_FE(%(lower)s,%s,NULL)\n", cname, iname); - } - - /* ------------------------------------------------------------ - * dispatchFunction() - * ------------------------------------------------------------ */ - void dispatchFunction(Node *n) { - /* Last node in overloaded chain */ - - int maxargs; - String *tmp = NewStringEmpty(); - String *dispatch = Swig_overload_dispatch(n, "return %s(INTERNAL_FUNCTION_PARAM_PASSTHRU);", &maxargs); - - /* Generate a dispatch wrapper for all overloaded functions */ - - Wrapper *f = NewWrapper(); - String *symname = Getattr(n, "sym:name"); - String *wname = Swig_name_wrapper(symname); - - create_command(symname, wname); - Printv(f->def, "ZEND_NAMED_FUNCTION(", wname, ") {\n", NIL); - - Wrapper_add_local(f, "argc", "int argc"); - - Printf(tmp, "zval **argv[%d]", maxargs); - Wrapper_add_local(f, "argv", tmp); - - Printf(f->code, "argc = ZEND_NUM_ARGS();\n"); - - Printf(f->code, "zend_get_parameters_array_ex(argc,argv);\n"); - - Replaceall(dispatch, "$args", "self,args"); - - Printv(f->code, dispatch, "\n", NIL); - - Printf(f->code, "SWIG_ErrorCode() = E_ERROR;\n"); - Printf(f->code, "SWIG_ErrorMsg() = \"No matching function for overloaded '%s'\";\n", symname); - Printv(f->code, "zend_error(SWIG_ErrorCode(),SWIG_ErrorMsg());\n", NIL); - - Printv(f->code, "}\n", NIL); - Wrapper_print(f, s_wrappers); - - DelWrapper(f); - Delete(dispatch); - Delete(tmp); - Delete(wname); - } - - /* ------------------------------------------------------------ - * functionWrapper() - * ------------------------------------------------------------ */ - - /* Helper method for PHP::functionWrapper */ - bool is_class(SwigType *t) { - Node *n = classLookup(t); - if (n) { - String *r = Getattr(n, "php:proxy"); // Set by classDeclaration() - if (!r) - r = Getattr(n, "sym:name"); // Not seen by classDeclaration yet, but this is the name - if (r) - return true; - } - return false; - } - - virtual int functionWrapper(Node *n) { - String *name = GetChar(n, "name"); - String *iname = GetChar(n, "sym:name"); - SwigType *d = Getattr(n, "type"); - ParmList *l = Getattr(n, "parms"); - String *nodeType = Getattr(n, "nodeType"); - int newobject = GetFlag(n, "feature:new"); - - Parm *p; - int i; - int numopt; - String *tm; - Wrapper *f; - - String *wname; - int overloaded = 0; - String *overname = 0; - - if (Cmp(nodeType, "destructor") == 0) { - // We just generate the Zend List Destructor and let Zend manage the - // reference counting. There's no explicit destructor, but the user can - // just do `$obj = null;' to remove a reference to an object. - return CreateZendListDestructor(n); - } - // Test for overloading; - if (Getattr(n, "sym:overloaded")) { - overloaded = 1; - overname = Getattr(n, "sym:overname"); - } else { - if (!addSymbol(iname, n)) - return SWIG_ERROR; - } - - wname = Swig_name_wrapper(iname); - if (overname) { - Printf(wname, "%s", overname); - } - - f = NewWrapper(); - numopt = 0; - - String *outarg = NewStringEmpty(); - String *cleanup = NewStringEmpty(); - - // Not issued for overloaded functions or static member variables. - if (!overloaded && wrapperType != staticmembervar) { - create_command(iname, wname); - } - Printv(f->def, "ZEND_NAMED_FUNCTION(", wname, ") {\n", NIL); - - emit_parameter_variables(l, f); - /* Attach standard typemaps */ - - emit_attach_parmmaps(l, f); - - // wrap:parms is used by overload resolution. - Setattr(n, "wrap:parms", l); - - int num_arguments = emit_num_arguments(l); - int num_required = emit_num_required(l); - numopt = num_arguments - num_required; - - if (num_arguments > 0) { - String *args = NewStringf("zval **args[%d]", num_arguments); - Wrapper_add_local(f, "args", args); - Delete(args); - args = NULL; - } - // This generated code may be called: - // 1) as an object method, or - // 2) as a class-method/function (without a "this_ptr") - // Option (1) has "this_ptr" for "this", option (2) needs it as - // first parameter - - // NOTE: possible we ignore this_ptr as a param for native constructor - - Printf(f->code, "SWIG_ResetError();\n"); - - if (numopt > 0) { // membervariable wrappers do not have optional args - Wrapper_add_local(f, "arg_count", "int arg_count"); - Printf(f->code, "arg_count = ZEND_NUM_ARGS();\n"); - Printf(f->code, "if(arg_count<%d || arg_count>%d ||\n", num_required, num_arguments); - Printf(f->code, " zend_get_parameters_array_ex(arg_count,args)!=SUCCESS)\n"); - Printf(f->code, "\tWRONG_PARAM_COUNT;\n\n"); - } else { - if (num_arguments == 0) { - Printf(f->code, "if(ZEND_NUM_ARGS() != 0) {\n"); - } else { - Printf(f->code, "if(ZEND_NUM_ARGS() != %d || zend_get_parameters_array_ex(%d, args) != SUCCESS) {\n", num_arguments, num_arguments); - } - Printf(f->code, "WRONG_PARAM_COUNT;\n}\n\n"); - } - - /* Now convert from php to C variables */ - // At this point, argcount if used is the number of deliberately passed args - // not including this_ptr even if it is used. - // It means error messages may be out by argbase with error - // reports. We can either take argbase into account when raising - // errors, or find a better way of dealing with _thisptr. - // I would like, if objects are wrapped, to assume _thisptr is always - // _this and not the first argument. - // This may mean looking at Language::memberfunctionHandler - - for (i = 0, p = l; i < num_arguments; i++) { - String *source; - - /* Skip ignored arguments */ - //while (Getattr(p,"tmap:ignore")) { p = Getattr(p,"tmap:ignore:next");} - while (checkAttribute(p, "tmap:in:numinputs", "0")) { - p = Getattr(p, "tmap:in:next"); - } - - SwigType *pt = Getattr(p, "type"); - - source = NewStringf("args[%d]", i); - - String *ln = Getattr(p, "lname"); - - /* Check if optional */ - if (i >= num_required) { - Printf(f->code, "\tif(arg_count > %d) {\n", i); - } - - if ((tm = Getattr(p, "tmap:in"))) { - Replaceall(tm, "$source", source); - Replaceall(tm, "$target", ln); - Replaceall(tm, "$input", source); - Setattr(p, "emit:input", source); - Printf(f->code, "%s\n", tm); - if (i == 0 && Getattr(p, "self")) { - Printf(f->code, "\tif(!arg1) SWIG_PHP_Error(E_ERROR, \"this pointer is NULL\");\n"); - } - p = Getattr(p, "tmap:in:next"); - if (i >= num_required) { - Printf(f->code, "}\n"); - } - continue; - } else { - Swig_warning(WARN_TYPEMAP_IN_UNDEF, input_file, line_number, "Unable to use type %s as a function argument.\n", SwigType_str(pt, 0)); - } - if (i >= num_required) { - Printf(f->code, "\t}\n"); - } - Delete(source); - } - - /* Insert constraint checking code */ - for (p = l; p;) { - if ((tm = Getattr(p, "tmap:check"))) { - Replaceall(tm, "$target", Getattr(p, "lname")); - Printv(f->code, tm, "\n", NIL); - p = Getattr(p, "tmap:check:next"); - } else { - p = nextSibling(p); - } - } - - /* Insert cleanup code */ - for (i = 0, p = l; p; i++) { - if ((tm = Getattr(p, "tmap:freearg"))) { - Replaceall(tm, "$source", Getattr(p, "lname")); - Printv(cleanup, tm, "\n", NIL); - p = Getattr(p, "tmap:freearg:next"); - } else { - p = nextSibling(p); - } - } - - /* Insert argument output code */ - for (i = 0, p = l; p; i++) { - if ((tm = Getattr(p, "tmap:argout"))) { - Replaceall(tm, "$source", Getattr(p, "lname")); - // Replaceall(tm,"$input",Getattr(p,"lname")); - Replaceall(tm, "$target", "return_value"); - Replaceall(tm, "$result", "return_value"); - Replaceall(tm, "$arg", Getattr(p, "emit:input")); - Replaceall(tm, "$input", Getattr(p, "emit:input")); - Printv(outarg, tm, "\n", NIL); - p = Getattr(p, "tmap:argout:next"); - } else { - p = nextSibling(p); - } - } - - Setattr(n, "wrap:name", wname); - - /* emit function call */ - String *actioncode = emit_action(n); - - if ((tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode))) { - Replaceall(tm, "$input", "result"); - Replaceall(tm, "$source", "result"); - Replaceall(tm, "$target", "return_value"); - Replaceall(tm, "$result", "return_value"); - Replaceall(tm, "$owner", newobject ? "1" : "0"); - Printf(f->code, "%s\n", tm); - } else { - Swig_warning(WARN_TYPEMAP_OUT_UNDEF, input_file, line_number, "Unable to use return type %s in function %s.\n", SwigType_str(d, 0), name); - } - emit_return_variable(n, d, f); - - if (outarg) { - Printv(f->code, outarg, NIL); - } - - if (cleanup) { - Printv(f->code, cleanup, NIL); - } - - /* Look to see if there is any newfree cleanup code */ - if (GetFlag(n, "feature:new")) { - if ((tm = Swig_typemap_lookup("newfree", n, "result", 0))) { - Printf(f->code, "%s\n", tm); - Delete(tm); - } - } - - /* See if there is any return cleanup code */ - if ((tm = Swig_typemap_lookup("ret", n, "result", 0))) { - Printf(f->code, "%s\n", tm); - Delete(tm); - } - - Printf(f->code, "return;\n"); - - /* Error handling code */ - Printf(f->code, "fail:\n"); - Printv(f->code, cleanup, NIL); - Printv(f->code, "zend_error(SWIG_ErrorCode(),SWIG_ErrorMsg());", NIL); - - Printf(f->code, "}\n"); - - Replaceall(f->code, "$cleanup", cleanup); - Replaceall(f->code, "$symname", iname); - - Wrapper_print(f, s_wrappers); - - if (overloaded && !Getattr(n, "sym:nextSibling")) { - dispatchFunction(n); - } - - Delete(wname); - wname = NULL; - - if (!(shadow && php_version == 5)) { - DelWrapper(f); - return SWIG_OK; - } - - // Handle getters and setters. - if (wrapperType == membervar) { - const char *p = Char(iname); - if (strlen(p) > 4) { - p += strlen(p) - 4; - String *varname = Getattr(n, "membervariableHandler:sym:name"); - if (strcmp(p, "_get") == 0) { - Setattr(shadow_get_vars, varname, iname); - } else if (strcmp(p, "_set") == 0) { - Setattr(shadow_set_vars, varname, iname); - } - } - } - // Only look at non-overloaded methods and the last entry in each overload - // chain (we check the last so that wrap:parms and wrap:name have been set - // for them all). - if (overloaded && Getattr(n, "sym:nextSibling") != 0) - return SWIG_OK; - - if (!s_oowrappers) - s_oowrappers = NewStringEmpty(); - if (newobject || wrapperType == memberfn || wrapperType == staticmemberfn || wrapperType == standard) { - bool handle_as_overload = false; - String **arg_names; - String **arg_values; - // Method or static method or plain function. - const char *methodname = 0; - String *output = s_oowrappers; - if (newobject) { - class_has_ctor = true; - methodname = "__construct"; - } else if (wrapperType == memberfn) { - methodname = Char(Getattr(n, "memberfunctionHandler:sym:name")); - } else if (wrapperType == staticmemberfn) { - methodname = Char(Getattr(n, "staticmemberfunctionHandler:sym:name")); - } else { // wrapperType == standard - methodname = Char(iname); - if (!s_fakeoowrappers) - s_fakeoowrappers = NewStringEmpty(); - output = s_fakeoowrappers; - } - - bool really_overloaded = overloaded ? true : false; - int min_num_of_arguments = emit_num_required(l); - int max_num_of_arguments = emit_num_arguments(l); - // For a function with default arguments, we end up with the fullest - // parmlist in full_parmlist. - ParmList *full_parmlist = l; - Hash *ret_types = NewHash(); - Setattr(ret_types, d, d); - - if (overloaded) { - // Look at all the overloaded versions of this method in turn to - // decide if it's really an overloaded method, or just one where some - // parameters have default values. - Node *o = Getattr(n, "sym:overloaded"); - while (o) { - if (o == n) { - o = Getattr(o, "sym:nextSibling"); - continue; - } - - SwigType *d2 = Getattr(o, "type"); - if (!d2) { - assert(constructor); - } else if (!Getattr(ret_types, d2)) { - Setattr(ret_types, d2, d2); - } - - ParmList *l2 = Getattr(o, "wrap:parms"); - int num_arguments = emit_num_arguments(l2); - int num_required = emit_num_required(l2); - if (num_required < min_num_of_arguments) - min_num_of_arguments = num_required; - - if (num_arguments > max_num_of_arguments) { - max_num_of_arguments = num_arguments; - full_parmlist = l2; - } - o = Getattr(o, "sym:nextSibling"); - } - - o = Getattr(n, "sym:overloaded"); - while (o) { - if (o == n) { - o = Getattr(o, "sym:nextSibling"); - continue; - } - - ParmList *l2 = Getattr(o, "wrap:parms"); - Parm *p = l, *p2 = l2; - if (wrapperType == memberfn) { - p = nextSibling(p); - p2 = nextSibling(p2); - } - while (p && p2) { - if (Cmp(Getattr(p, "type"), Getattr(p2, "type")) != 0) - break; - if (Cmp(Getattr(p, "name"), Getattr(p2, "name")) != 0) - break; - String *value = Getattr(p, "value"); - String *value2 = Getattr(p2, "value"); - if (value && !value2) - break; - if (!value && value2) - break; - if (value) { - if (Cmp(value, value2) != 0) - break; - } - p = nextSibling(p); - p2 = nextSibling(p2); - } - if (p && p2) - break; - // One parameter list is a prefix of the other, so check that all - // remaining parameters of the longer list are optional. - if (p2) - p = p2; - while (p && Getattr(p, "value")) - p = nextSibling(p); - if (p) - break; - o = Getattr(o, "sym:nextSibling"); - } - if (!o) { - // This "overloaded method" is really just one with default args. - really_overloaded = false; - if (l != full_parmlist) { - l = full_parmlist; - if (wrapperType == memberfn) - l = nextSibling(l); - } - } - } - - if (wrapperType == memberfn) { - // Allow for the "this" pointer. - --min_num_of_arguments; - --max_num_of_arguments; - } - - arg_names = (String **) malloc(max_num_of_arguments * sizeof(String *)); - if (!arg_names) { - /* FIXME: How should this be handled? The rest of SWIG just seems - * to not bother checking for malloc failing! */ - fprintf(stderr, "Malloc failed!\n"); - exit(1); - } - for (i = 0; i < max_num_of_arguments; ++i) { - arg_names[i] = NULL; - } - - arg_values = (String **) malloc(max_num_of_arguments * sizeof(String *)); - if (!arg_values) { - /* FIXME: How should this be handled? The rest of SWIG just seems - * to not bother checking for malloc failing! */ - fprintf(stderr, "Malloc failed!\n"); - exit(1); - } - for (i = 0; i < max_num_of_arguments; ++i) { - arg_values[i] = NULL; - } - - Node *o; - if (overloaded) { - o = Getattr(n, "sym:overloaded"); - } else { - o = n; - } - while (o) { - int argno = 0; - Parm *p = Getattr(o, "wrap:parms"); - if (wrapperType == memberfn) - p = nextSibling(p); - while (p) { - if (GetInt(p, "tmap:in:numinputs") == 0) { - p = nextSibling(p); - continue; - } - assert(0 <= argno && argno < max_num_of_arguments); - String *&pname = arg_names[argno]; - const char *pname_cstr = GetChar(p, "name"); - if (!pname_cstr) { - // Unnamed parameter, e.g. int foo(int); - } else if (pname == NULL) { - pname = NewString(pname_cstr); - } else { - size_t len = strlen(pname_cstr); - size_t spc = 0; - size_t len_pname = strlen(Char(pname)); - while (spc + len <= len_pname) { - if (strncmp(pname_cstr, Char(pname) + spc, len) == 0) { - char ch = ((char *) Char(pname))[spc + len]; - if (ch == '\0' || ch == ' ') { - // Already have this pname_cstr. - pname_cstr = NULL; - break; - } - } - char *p = strchr(Char(pname) + spc, ' '); - if (!p) - break; - spc = (p + 4) - Char(pname); - } - if (pname_cstr) { - Printf(pname, " or_%s", pname_cstr); - } - } - String *value = NewString(Getattr(p, "value")); - if (Len(value)) { - /* Check that value is a valid constant in PHP (and adjust it if - * necessary, or replace it with "?" if it's just not valid). */ - SwigType *type = Getattr(p, "type"); - switch (SwigType_type(type)) { - case T_BOOL: { - if (Strcmp(value, "true") == 0 || Strcmp(value, "false") == 0) - break; - char *p; - errno = 0; - int n = strtol(Char(value), &p, 0); - Clear(value); - if (errno || *p) { - Append(value, "?"); - } else if (n) { - Append(value, "true"); - } else { - Append(value, "false"); - } - break; - } - case T_CHAR: - case T_SCHAR: - case T_SHORT: - case T_INT: - case T_LONG: { - char *p; - errno = 0; - (void) strtol(Char(value), &p, 0); - if (errno || *p) { - Clear(value); - Append(value, "?"); - } - break; - } - case T_UCHAR: - case T_USHORT: - case T_UINT: - case T_ULONG: { - char *p; - errno = 0; - (void) strtoul(Char(value), &p, 0); - if (errno || *p) { - Clear(value); - Append(value, "?"); - } - break; - } - case T_FLOAT: - case T_DOUBLE:{ - char *p; - errno = 0; - /* FIXME: strtod is locale dependent... */ - double val = strtod(Char(value), &p); - if (errno || *p) { - Clear(value); - Append(value, "?"); - } else if (strchr(Char(value), '.') == NULL) { - // Ensure value is a double constant, not an integer one. - Append(value, ".0"); - double val2 = strtod(Char(value), &p); - if (errno || *p || val != val2) { - Clear(value); - Append(value, "?"); - } - } - break; - } - case T_REFERENCE: - case T_USER: - case T_ARRAY: - Clear(value); - Append(value, "?"); - break; - case T_STRING: - if (Len(value) < 2) { - // How can a string (including "" be less than 2 characters?) - Clear(value); - Append(value, "?"); - } else { - const char *v = Char(value); - if (v[0] != '"' || v[Len(value) - 1] != '"') { - Clear(value); - Append(value, "?"); - } - // Strings containing "$" require special handling, but we do - // that later. - } - break; - case T_VOID: - assert(false); - break; - case T_POINTER: { - const char *v = Char(value); - if (v[0] == '(') { - // Handle "(void*)0", "(TYPE*)0", "(char*)NULL", etc. - v += strcspn(v + 1, "*()") + 1; - if (*v == '*') { - do { - v++; - v += strspn(v, " \t"); - } while (*v == '*'); - if (*v++ == ')') { - v += strspn(v, " \t"); - String * old = value; - value = NewString(v); - Delete(old); - } - } - } - if (Strcmp(value, "NULL") == 0 || - Strcmp(value, "0") == 0 || - Strcmp(value, "0L") == 0) { - Clear(value); - Append(value, "null"); - } else { - Clear(value); - Append(value, "?"); - } - break; - } - } - - if (!arg_values[argno]) { - arg_values[argno] = value; - value = NULL; - } else if (Cmp(arg_values[argno], value) != 0) { - // If a parameter has two different default values in - // different overloaded forms of the function, we can't - // set its default in PHP. Flag this by setting its - // default to `?'. - Delete(arg_values[argno]); - arg_values[argno] = NewString("?"); - } - } else if (arg_values[argno]) { - // This argument already has a default value in another overloaded - // form, but doesn't in this form. So don't try to do anything - // clever, just let the C wrappers resolve the overload and set the - // default values. - // - // This handling is safe, but I'm wondering if it may be overly - // conservative (FIXME) in some cases. It seems it's only bad when - // there's an overloaded form with the appropriate number of - // parameters which doesn't want the default value, but I need to - // think about this more. - Delete(arg_values[argno]); - arg_values[argno] = NewString("?"); - } - Delete(value); - p = nextSibling(p); - ++argno; - } - if (!really_overloaded) - break; - o = Getattr(o, "sym:nextSibling"); - } - - /* Clean up any parameters which haven't yet got names, or whose - * names clash. */ - Hash *seen = NewHash(); - /* We need $this to refer to the current class, so can't allow it - * to be used as a parameter. */ - Setattr(seen, "this", seen); - /* We use $r to store the return value, so disallow that as a parameter - * name in case the user uses the "call-time pass-by-reference" feature - * (it's deprecated and off by default in PHP5, but we want to be - * maximally portable). - */ - Setattr(seen, "r", seen); - - for (int argno = 0; argno < max_num_of_arguments; ++argno) { - String *&pname = arg_names[argno]; - if (pname) { - Replaceall(pname, " ", "_"); - } else { - /* We get here if the SWIG .i file has "int foo(int);" */ - pname = NewStringEmpty(); - Printf(pname, "arg%d", argno + 1); - } - // Check if we've already used this parameter name. - while (Getattr(seen, pname)) { - // Append "_" to clashing names until they stop clashing... - Printf(pname, "_"); - } - Setattr(seen, Char(pname), seen); - - if (arg_values[argno] && Cmp(arg_values[argno], "?") == 0) { - handle_as_overload = true; - } - } - Delete(seen); - seen = NULL; - - String *invoke = NewStringEmpty(); - String *prepare = NewStringEmpty(); - String *args = NewStringEmpty(); - - if (!handle_as_overload && !(really_overloaded && max_num_of_arguments > min_num_of_arguments)) { - Printf(invoke, "%s(", iname); - if (wrapperType == memberfn) { - Printf(invoke, "$this->%s", SWIG_PTR); - } - for (int i = 0; i < max_num_of_arguments; ++i) { - if (i) - Printf(args, ","); - if (i || wrapperType == memberfn) - Printf(invoke, ","); - String *value = arg_values[i]; - if (value) { - const char *v = Char(value); - if (v[0] == '"') { - /* In a PHP double quoted string, $ needs to be escaped as \$. */ - Replaceall(value, "$", "\\$"); - } - Printf(args, "$%s=%s", arg_names[i], value); - } else { - Printf(args, "$%s", arg_names[i]); - } - Printf(invoke, "$%s", arg_names[i]); - } - Printf(invoke, ")"); - } else { - int i; - for (i = 0; i < min_num_of_arguments; ++i) { - if (i) - Printf(args, ","); - Printf(args, "$%s", arg_names[i]); - } - String *invoke_args = NewStringEmpty(); - if (wrapperType == memberfn) { - Printf(invoke_args, "$this->%s", SWIG_PTR); - if (min_num_of_arguments > 0) - Printf(invoke_args, ","); - } - Printf(invoke_args, "%s", args); - bool had_a_case = false; - int last_handled_i = i - 1; - for (; i < max_num_of_arguments; ++i) { - if (i) - Printf(args, ","); - const char *value = Char(arg_values[i]); - // FIXME: (really_overloaded && handle_as_overload) is perhaps a - // little conservative, but it doesn't hit any cases that it - // shouldn't for Xapian at least (and we need it to handle - // "Enquire::get_mset()" correctly). - bool non_php_default = ((really_overloaded && handle_as_overload) || - !value || strcmp(value, "?") == 0); - if (non_php_default) - value = "null"; - Printf(args, "$%s=%s", arg_names[i], value); - if (non_php_default) { - if (!had_a_case) { - Printf(prepare, "\t\tswitch (func_num_args()) {\n"); - had_a_case = true; - } - Printf(prepare, "\t\t"); - while (last_handled_i < i) { - Printf(prepare, "case %d: ", ++last_handled_i); - } - if (Cmp(d, "void") != 0) - Printf(prepare, "$r="); - Printf(prepare, "%s(%s); break;\n", iname, invoke_args); - } - if (i || wrapperType == memberfn) - Printf(invoke_args, ","); - Printf(invoke_args, "$%s", arg_names[i]); - } - Printf(prepare, "\t\t"); - if (had_a_case) - Printf(prepare, "default: "); - if (Cmp(d, "void") != 0) - Printf(prepare, "$r="); - Printf(prepare, "%s(%s);\n", iname, invoke_args); - if (had_a_case) - Printf(prepare, "\t\t}\n"); - Delete(invoke_args); - Printf(invoke, "$r"); - } - - Printf(output, "\n"); - // If it's a member function or a class constructor... - if (wrapperType == memberfn || (newobject && current_class)) { - Printf(output, "\tfunction %s(%s) {\n", methodname, args); - // 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")) { - SwigType *t = Getattr(current_class, "classtype"); - String *mangled_type = SwigType_manglestr(SwigType_ltype(t)); - Printf(s_oowrappers, "\t\tif (is_resource($%s) && get_resource_type($%s) == \"_p%s\") {\n", arg_names[0], arg_names[0], mangled_type); - Printf(s_oowrappers, "\t\t\t$this->%s=$%s;\n", SWIG_PTR, arg_names[0]); - Printf(s_oowrappers, "\t\t\treturn;\n"); - Printf(s_oowrappers, "\t\t}\n"); - } - } 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); - } else if (Cmp(d, "void") == 0) { - if (Cmp(invoke, "$r") != 0) - Printf(output, "\t\t%s;\n", invoke); - } else if (is_class(d)) { - if (Cmp(invoke, "$r") != 0) - Printf(output, "\t\t$r=%s;\n", invoke); - if (Len(ret_types) == 1) { - Printf(output, "\t\treturn is_resource($r) ? new %s%s($r) : $r;\n", prefix, Getattr(classLookup(d), "sym:name")); - } else { - Printf(output, "\t\tif (!is_resource($r)) return $r;\n"); - Printf(output, "\t\tswitch (get_resource_type($r)) {\n"); - Iterator i = First(ret_types); - while (i.item) { - SwigType *ret_type = i.item; - i = Next(i); - Printf(output, "\t\t"); - String *mangled = NewString("_p"); - Printf(mangled, "%s", SwigType_manglestr(ret_type)); - Node *class_node = Getattr(zend_types, mangled); - if (!class_node) { - /* This is needed when we're returning a pointer to a type - * rather than returning the type by value or reference. */ - class_node = current_class; - Delete(mangled); - mangled = NewString(SwigType_manglestr(ret_type)); - class_node = Getattr(zend_types, mangled); - } - if (i.item) { - Printf(output, "case \"%s\": ", mangled); - } else { - Printf(output, "default: "); - } - const char *classname = GetChar(class_node, "sym:name"); - if (!classname) - classname = GetChar(class_node, "name"); - if (classname) - Printf(output, "return new %s%s($r);\n", prefix, classname); - else - Printf(output, "return $r;\n"); - Delete(mangled); - } - Printf(output, "\t\t}\n"); - } - } else { - Printf(output, "\t\treturn %s;\n", invoke); - } - Printf(output, "\t}\n"); - Delete(prepare); - Delete(invoke); - free(arg_values); - } - - DelWrapper(f); - - return SWIG_OK; - } - - /* ------------------------------------------------------------ - * globalvariableHandler() - * ------------------------------------------------------------ */ - - virtual int globalvariableHandler(Node *n) { - char *name = GetChar(n, "name"); - char *iname = GetChar(n, "sym:name"); - SwigType *t = Getattr(n, "type"); - String *tm; - - /* First do the wrappers such as name_set(), name_get() - * as provided by the baseclass's implementation of variableWrapper - */ - if (Language::globalvariableHandler(n) == SWIG_NOWRAP) { - return SWIG_NOWRAP; - } - - if (!addSymbol(iname, n)) - return SWIG_ERROR; - - SwigType_remember(t); - - /* First link C variables to PHP */ - - tm = Swig_typemap_lookup("varinit", n, name, 0); - if (tm) { - Replaceall(tm, "$target", name); - Printf(s_vinit, "%s\n", tm); - } else { - Printf(stderr, "%s: Line %d, Unable to link with type %s\n", input_file, line_number, SwigType_str(t, 0)); - } - - /* Now generate PHP -> C sync blocks */ - /* - tm = Swig_typemap_lookup("varin", n, name, 0); - if(tm) { - Replaceall(tm, "$symname", iname); - Printf(f_c->code, "%s\n", tm); - } else { - Printf(stderr,"%s: Line %d, Unable to link with type %s\n", - input_file, line_number, SwigType_str(t, 0)); - } - */ - /* Now generate C -> PHP sync blocks */ - /* - if(!GetFlag(n,"feature:immutable")) { - - tm = Swig_typemap_lookup("varout", n, name, 0); - if(tm) { - Replaceall(tm, "$symname", iname); - Printf(f_php->code, "%s\n", tm); - } else { - Printf(stderr,"%s: Line %d, Unable to link with type %s\n", - input_file, line_number, SwigType_str(t, 0)); - } - } - */ - return SWIG_OK; - } - - /* ------------------------------------------------------------ - * constantWrapper() - * ------------------------------------------------------------ */ - - virtual int constantWrapper(Node *n) { - String *name = GetChar(n, "name"); - String *iname = GetChar(n, "sym:name"); - SwigType *type = Getattr(n, "type"); - String *rawval = Getattr(n, "rawval"); - String *value = rawval ? rawval : Getattr(n, "value"); - String *tm; - - if (!addSymbol(iname, n)) - return SWIG_ERROR; - - SwigType_remember(type); - - if ((tm = Swig_typemap_lookup("consttab", n, name, 0))) { - Replaceall(tm, "$source", value); - Replaceall(tm, "$target", name); - Replaceall(tm, "$value", value); - Printf(s_cinit, "%s\n", tm); - } - - if (shadow && php_version == 5) { - String *enumvalue = GetChar(n, "enumvalue"); - String *set_to = iname; - - if (!enumvalue) { - enumvalue = GetChar(n, "enumvalueex"); - } - - if (enumvalue) { - // Check for a simple constant expression which is valid in PHP. - // If we find one, initialise the const member with it; otherwise - // we initialise it using the C/C++ wrapped constant. - const char *p; - for (p = Char(enumvalue); *p; ++p) { - if (!isdigit((unsigned char)*p) && !strchr(" +-", *p)) { - // FIXME: enhance to handle ` + 1' which is what - // we get for enums that don't have an explicit value set. - break; - } - } - if (!*p) set_to = enumvalue; - } - - if (wrapping_member_constant) { - if (!s_oowrappers) - s_oowrappers = NewStringEmpty(); - Printf(s_oowrappers, "\n\tconst %s = %s;\n", wrapping_member_constant, set_to); - } else { - if (!s_fakeoowrappers) - s_fakeoowrappers = NewStringEmpty(); - Printf(s_fakeoowrappers, "\n\tconst %s = %s;\n", iname, set_to); - } - } - - return SWIG_OK; - } - - /* - * PHP::pragma() - * - * Pragma directive. - * - * %pragma(php4) code="String" # Includes a string in the .php file - * %pragma(php4) include="file.pl" # Includes a file in the .php file - */ - - virtual int pragmaDirective(Node *n) { - if (!ImportMode) { - String *lang = Getattr(n, "lang"); - String *type = Getattr(n, "name"); - String *value = Getattr(n, "value"); - - if (Strcmp(lang, "php4") == 0) { - if (Strcmp(type, "code") == 0) { - if (value) { - Printf(pragma_code, "%s\n", value); - } - } else if (Strcmp(type, "include") == 0) { - if (value) { - Printf(pragma_incl, "include \"%s\";\n", value); - } - } else if (Strcmp(type, "phpinfo") == 0) { - if (value) { - Printf(pragma_phpinfo, "%s\n", value); - } - } else { - Swig_warning(WARN_PHP4_UNKNOWN_PRAGMA, input_file, line_number, "Unrecognized pragma <%s>.\n", type); - } - } - } - return Language::pragmaDirective(n); - } - - /* ------------------------------------------------------------ - * classDeclaration() - * ------------------------------------------------------------ */ - - virtual int classDeclaration(Node *n) { - if (!Getattr(n, "feature:onlychildren")) { - String *symname = Getattr(n, "sym:name"); - Setattr(n, "php:proxy", symname); - } - - return Language::classDeclaration(n); - } - - /* ------------------------------------------------------------ - * classHandler() - * ------------------------------------------------------------ */ - - virtual int classHandler(Node *n) { - constructors = 0; - //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"); - - if (!addSymbol(rename, n)) - return SWIG_ERROR; - shadow_classname = NewString(rename); - - shadow_get_vars = NewHash(); - shadow_set_vars = NewHash(); - - /* Deal with inheritance */ - List *baselist = Getattr(n, "bases"); - if (baselist) { - Iterator base = First(baselist); - while (base.item && GetFlag(base.item, "feature:ignore")) { - base = Next(base); - } - base = Next(base); - if (base.item) { - /* Warn about multiple inheritance for additional base class(es) */ - while (base.item) { - if (GetFlag(base.item, "feature:ignore")) { - base = Next(base); - continue; - } - String *proxyclassname = SwigType_str(Getattr(n, "classtypeobj"), 0); - String *baseclassname = SwigType_str(Getattr(base.item, "name"), 0); - Swig_warning(WARN_PHP4_MULTIPLE_INHERITANCE, input_file, line_number, - "Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in PHP.\n", proxyclassname, baseclassname); - base = Next(base); - } - } - } - } - - classnode = n; - Language::classHandler(n); - classnode = 0; - - if (shadow) { - DOH *key; - List *baselist = Getattr(n, "bases"); - Iterator ki, base; - - if (baselist) { - base = First(baselist); - while (base.item && GetFlag(base.item, "feature:ignore")) { - base = Next(base); - } - } else { - base.item = NULL; - } - - if (Getattr(n, "abstract") && !GetFlag(n, "feature:notabstract")) { - Printf(s_phpclasses, "abstract "); - } - - Printf(s_phpclasses, "class %s%s ", prefix, shadow_classname); - if (base.item) { - String *baseclass = Getattr(base.item, "sym:name"); - if (!baseclass) - baseclass = Getattr(base.item, "name"); - Printf(s_phpclasses, "extends %s%s ", prefix, baseclass); - } - Printf(s_phpclasses, "{\n\tpublic $%s=null;\n", SWIG_PTR); - - // 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); - 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}\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}\n"); - } - // Write property GET handlers - ki = First(shadow_get_vars); - - if (ki.key) { - // This class has getters. - Printf(s_phpclasses, "\n\tfunction __get($var) {\n"); - // 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); - } - } 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); - } - // Reading an unknown property name gives null in PHP. - Printf(s_phpclasses, "\t\treturn null;\n"); - Printf(s_phpclasses, "\t}\n"); - } - - if (!class_has_ctor) { - Printf(s_phpclasses, "\tfunction __construct($h) {\n"); - Printf(s_phpclasses, "\t\t$this->%s=$h;\n", SWIG_PTR); - Printf(s_phpclasses, "\t}\n"); - } - - if (s_oowrappers) { - Printf(s_phpclasses, "%s", s_oowrappers); - Delete(s_oowrappers); - s_oowrappers = NULL; - } - class_has_ctor = false; - - Printf(s_phpclasses, "}\n\n"); - - Delete(shadow_classname); - shadow_classname = NULL; - - Delete(shadow_set_vars); - shadow_set_vars = NULL; - Delete(shadow_get_vars); - shadow_get_vars = NULL; - } - return SWIG_OK; - } - - /* ------------------------------------------------------------ - * memberfunctionHandler() - * ------------------------------------------------------------ */ - - virtual int memberfunctionHandler(Node *n) { - wrapperType = memberfn; - this->Language::memberfunctionHandler(n); - wrapperType = standard; - - return SWIG_OK; - } - - /* ------------------------------------------------------------ - * membervariableHandler() - * ------------------------------------------------------------ */ - - virtual int membervariableHandler(Node *n) { - wrapperType = membervar; - Language::membervariableHandler(n); - wrapperType = standard; - - return SWIG_OK; - } - - /* ------------------------------------------------------------ - * staticmembervariableHandler() - * ------------------------------------------------------------ */ - - virtual int staticmembervariableHandler(Node *n) { - wrapperType = staticmembervar; - Language::staticmembervariableHandler(n); - wrapperType = standard; - - 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); - create_command(iname, Swig_name_wrapper(class_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; - } - - /* ------------------------------------------------------------ - * staticmemberfunctionHandler() - * ------------------------------------------------------------ */ - - virtual int staticmemberfunctionHandler(Node *n) { - wrapperType = staticmemberfn; - Language::staticmemberfunctionHandler(n); - wrapperType = standard; - - 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(); - } - - String *PhpTypeFromTypemap(char *op, Node *n, String_or_char *lname) { - String *tms = Swig_typemap_lookup(op, n, lname, 0); - if (!tms) - return 0; - else - return NewStringf("%s", tms); - } - - int abstractConstructorHandler(Node *) { - return SWIG_OK; - } - - /* ------------------------------------------------------------ - * constructorHandler() - * ------------------------------------------------------------ */ - - virtual int constructorHandler(Node *n) { - constructors++; - wrapperType = constructor; - Language::constructorHandler(n); - wrapperType = standard; - - return SWIG_OK; - } - - /* ------------------------------------------------------------ - * CreateZendListDestructor() - * ------------------------------------------------------------ */ - //virtual int destructorHandler(Node *n) { - //} - int CreateZendListDestructor(Node *n) { - String *name = GetChar(Swig_methodclass(n), "name"); - String *iname = GetChar(n, "sym:name"); - ParmList *l = Getattr(n, "parms"); - - String *destructorname = NewStringEmpty(); - Printf(destructorname, "_%s", Swig_name_wrapper(iname)); - Setattr(classnode, "destructor", destructorname); - - Wrapper *f = NewWrapper(); - Printf(f->def, "/* This function is designed to be called by the zend list destructors */\n"); - Printf(f->def, "/* to typecast and do the actual destruction */\n"); - Printf(f->def, "static void %s(zend_rsrc_list_entry *rsrc, const char *type_name TSRMLS_DC) {\n", destructorname); - - Wrapper_add_localv(f, "value", "swig_object_wrapper *value=(swig_object_wrapper *) rsrc->ptr", NIL); - Wrapper_add_localv(f, "ptr", "void *ptr=value->ptr", NIL); - Wrapper_add_localv(f, "newobject", "int newobject=value->newobject", NIL); - - emit_parameter_variables(l, f); - emit_attach_parmmaps(l, f); - - // Get type of first arg, thing to be destructed - // Skip ignored arguments - Parm *p = l; - //while (Getattr(p,"tmap:ignore")) {p = Getattr(p,"tmap:ignore:next");} - while (checkAttribute(p, "tmap:in:numinputs", "0")) { - p = Getattr(p, "tmap:in:next"); - } - SwigType *pt = Getattr(p, "type"); - - Printf(f->code, " efree(value);\n"); - Printf(f->code, " if (! newobject) return; /* can't delete it! */\n"); - Printf(f->code, " arg1 = (%s)SWIG_ZTS_ConvertResourceData(ptr,type_name,SWIGTYPE%s TSRMLS_CC);\n", SwigType_lstr(pt, 0), SwigType_manglestr(pt)); - Printf(f->code, " if (! arg1) zend_error(E_ERROR, \"%s resource already free'd\");\n", Char(name)); - - Setattr(n, "wrap:name", destructorname); - - String *actioncode = emit_action(n); - Append(f->code, actioncode); - Delete(actioncode); - - Printf(f->code, "}\n"); - - Wrapper_print(f, s_wrappers); - - return SWIG_OK; - - } - - /* ------------------------------------------------------------ - * memberconstantHandler() - * ------------------------------------------------------------ */ - - virtual int memberconstantHandler(Node *n) { - wrapping_member_constant = Getattr(n, "name"); - Language::memberconstantHandler(n); - wrapping_member_constant = NULL; - return SWIG_OK; - } - -}; /* class PHP */ - -/* ----------------------------------------------------------------------------- - * swig_php() - Instantiate module - * ----------------------------------------------------------------------------- */ - -static PHP *maininstance = 0; - -// We use this function to be able to write out zend_register_list_destructor_ex -// lines for most things in the type table -// NOTE: it's a function NOT A PHP::METHOD -extern "C" void typetrace(SwigType *ty, String *mangled, String *clientdata) { - Node *class_node; - if (!zend_types) { - zend_types = NewHash(); - } - // we want to know if the type which reduced to this has a constructor - if ((class_node = maininstance->classLookup(ty))) { - if (!Getattr(zend_types, mangled)) { - // OK it may have been set before by a different SwigType but it would - // have had the same underlying class node I think - // - it is certainly required not to have different originating class - // nodes for the same SwigType - Setattr(zend_types, mangled, class_node); - } - } else { // a non-class pointer - Setattr(zend_types, mangled, NOTCLASS); - } - if (r_prevtracefunc) - (*r_prevtracefunc) (ty, mangled, (String *) clientdata); -} - -static Language *new_swig_php(int php_version) { - maininstance = new PHP(php_version); - if (!r_prevtracefunc) { - r_prevtracefunc = SwigType_remember_trace(typetrace); - } else { - Printf(stderr, "php Typetrace vector already saved!\n"); - assert(0); - } - return maininstance; -} - -extern "C" Language *swig_php4(void) { - Printf(stderr, "*** -php4 is no longer supported.\n" - "*** Either upgrade to PHP5 or use SWIG 1.3.36 or earlier.\n"); - SWIG_exit(EXIT_FAILURE); - return NULL; // To avoid compiler warnings. -} - -extern "C" Language *swig_php5(void) { - return new_swig_php(5); -} From 3d3bc01a2fbe560428b1f662e200d34010677984 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Thu, 3 Jul 2008 00:37:38 +0000 Subject: [PATCH 0067/1680] Rename php4*.swg to php*.swg. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10635 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/minherit2.i | 2 +- Lib/php/{php4.swg => php.swg} | 10 +++++----- Lib/php/{php4init.swg => phpinit.swg} | 0 Lib/php/{php4kw.swg => phpkw.swg} | 4 ++-- Lib/php/{php4run.swg => phprun.swg} | 4 ++-- Source/Modules/php.cxx | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) rename Lib/php/{php4.swg => php.swg} (97%) rename Lib/php/{php4init.swg => phpinit.swg} (100%) rename Lib/php/{php4kw.swg => phpkw.swg} (99%) rename Lib/php/{php4run.swg => phprun.swg} (99%) diff --git a/Examples/test-suite/minherit2.i b/Examples/test-suite/minherit2.i index f55131ff5..1bca4fc48 100644 --- a/Examples/test-suite/minherit2.i +++ b/Examples/test-suite/minherit2.i @@ -7,7 +7,7 @@ %warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE, SWIGWARN_CSHARP_MULTIPLE_INHERITANCE, SWIGWARN_RUBY_MULTIPLE_INHERITANCE, - SWIGWARN_PHP4_MULTIPLE_INHERITANCE) RemoteMpe; + SWIGWARN_PHP_MULTIPLE_INHERITANCE) RemoteMpe; #if defined(SWIGJAVA) || defined(SWIGCSHARP) diff --git a/Lib/php/php4.swg b/Lib/php/php.swg similarity index 97% rename from Lib/php/php4.swg rename to Lib/php/php.swg index feaee68f6..50630bc03 100644 --- a/Lib/php/php4.swg +++ b/Lib/php/php.swg @@ -2,15 +2,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. * - * php4.swg + * php.swg * - * PHP4 configuration file + * PHP configuration file * ----------------------------------------------------------------------------- */ %runtime "swigrun.swg" // Common C API type-checking code -%runtime "php4run.swg" // Php4 runtime functions +%runtime "phprun.swg" // PHP runtime functions -%include // Php4 initialization routine. +%include // PHP initialization routine. %include // Global variables. %include @@ -295,4 +295,4 @@ /* php keywords */ -%include +%include diff --git a/Lib/php/php4init.swg b/Lib/php/phpinit.swg similarity index 100% rename from Lib/php/php4init.swg rename to Lib/php/phpinit.swg diff --git a/Lib/php/php4kw.swg b/Lib/php/phpkw.swg similarity index 99% rename from Lib/php/php4kw.swg rename to Lib/php/phpkw.swg index a6b519445..3d1a62511 100644 --- a/Lib/php/php4kw.swg +++ b/Lib/php/phpkw.swg @@ -2,7 +2,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. * - * php4kw.swg + * phpkw.swg * * The 'keywords' in PHP are global, ie, the following names are fine * when used as class methods. @@ -67,7 +67,7 @@ PHPKW(include_once); PHPKW(isset); PHPKW(list); PHPKW(new); -PHPKW(old_function); /* No longer reserved in PHP5 */ +// PHPKW(old_function); /* No longer reserved in PHP5 */ PHPKW(or); PHPKW(print); PHPKW(require); diff --git a/Lib/php/php4run.swg b/Lib/php/phprun.swg similarity index 99% rename from Lib/php/php4run.swg rename to Lib/php/phprun.swg index d38452764..b4e4276f5 100644 --- a/Lib/php/php4run.swg +++ b/Lib/php/phprun.swg @@ -2,9 +2,9 @@ * See the LICENSE file for information on copyright, usage and redistribution * of SWIG, and the README file for authors - http://www.swig.org/release.html. * - * php4run.swg + * phprun.swg * - * PHP4 runtime library + * PHP runtime library * ----------------------------------------------------------------------------- */ #ifdef __cplusplus diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index 77f3e0d73..d67e3deff 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -291,7 +291,7 @@ public: Preprocessor_define("SWIGPHP 1", 0); Preprocessor_define("SWIGPHP5 1", 0); SWIG_typemap_lang("php4"); - SWIG_config_file("php4.swg"); + SWIG_config_file("php.swg"); allow_overloading(); } From fa5b3a0b6699ce008d03275e05731aa563987845 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Thu, 3 Jul 2008 01:13:51 +0000 Subject: [PATCH 0068/1680] Update wrt PHP4. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10636 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Php.html | 44 ++++++++++++++++++-------------------------- 1 file changed, 18 insertions(+), 26 deletions(-) diff --git a/Doc/Manual/Php.html b/Doc/Manual/Php.html index 6b654fde5..6dbc09dd3 100644 --- a/Doc/Manual/Php.html +++ b/Doc/Manual/Php.html @@ -43,21 +43,24 @@ 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, +and won't even be patching critical security issues after 2008-08-08, so it +doesn't make much sense for SWIG to continue to support PHP4 at this point. +If you need to continue to use PHP4, stick with SWIG 1.3.36. +

      +

      In this chapter, we discuss SWIG's support of PHP. The PHP module -was extensively rewritten in release 1.3.26, and although it is -significantly more functional, it still does not implement all the +was extensively rewritten in release 1.3.26, and support for generating +OO wrappers for PHP5 was added in 1.3.30. The PHP module works fairly +well, but currently does not implement all the features available in some of the other languages.

      -The examples and test cases have been developed with PHP4. Release -1.3.30 added support for generating PHP5 class wrappers for C++ -libraries. -

      - -

      -In order to use this module, you will need to have a copy of the PHP4 or PHP5 +In order to use this module, you will need to have a copy of the PHP5 include files to compile the SWIG generated files. If you installed PHP from a binary package, you may need to install a "php-dev" or "php-devel" package for these to be installed. You can find out where these files are @@ -717,20 +720,9 @@ variable, or assigning NULL to a variable.

      -SWIG defaults to wrapping C++ structs and classes with PHP classes. This -requires SWIG to generate different code for PHP4 and PHP5, so you must -specify which you want using -php4 or -php5 (currently --php generates PHP4 class wrappers for compatibility with -SWIG 1.3.29 and earlier, but this may change in the future). -

      - -

      -PHP4 classes are implemented entirely using the Zend C API so -no additional php code is generated. For PHP5, a PHP wrapper +SWIG defaults to wrapping C++ structs and classes with PHP classes +unless "-noproxy" is specified. For PHP5, a PHP wrapper class is generated which calls a set of flat functions wrapping the C++ class. -In many cases the PHP4 and PHP5 wrappers will behave the same way, -but the PHP5 ones make use of better PHP5's better OO functionality -where appropriate.

      @@ -754,7 +746,7 @@ struct Complex {

      -Would be used in the following way from either PHP4 or PHP5: +Would be used in the following way from PHP5:

      @@ -854,9 +846,9 @@ the programmer can either reassign the variable or call
       
       
       

      -Static member variables are not supported in PHP4, and it does not -appear to be possible to intercept accesses to static member variables -in PHP5. Therefore, static member variables are +Static member variables in C++ are not wrapped as such in PHP +as it does not appear to be possible to intercept accesses to such variables. +Therefore, static member variables are wrapped using a class function with the same name, which returns the current value of the class variable. For example

      From 7893f114a4b048f7980896ad4ddb5fa7cd897b91 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Thu, 3 Jul 2008 02:32:11 +0000 Subject: [PATCH 0069/1680] [PHP] The deprecated command line option "-phpfull" has been removed. We recommend building your extension as a dynamically loadable module. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10637 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 8 +- Doc/Manual/Php.html | 130 +--------------- Source/Modules/php.cxx | 337 +++++++---------------------------------- 3 files changed, 63 insertions(+), 412 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 615800a33..646aaff3f 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,11 @@ Version 1.3.36 (in progress) ============================= +2008-07-03: olly + [PHP] The deprecated command line option "-phpfull" has been + removed. We recommend building your extension as a dynamically + loadable module. + 2008-07-02: olly [PHP4] Support for PHP4 has been removed. The PHP developers are no longer making new PHP4 releases, and won't even be patching @@ -10,5 +15,6 @@ Version 1.3.36 (in progress) [Python] Import the C extension differently for Python 2.6 and later so that an implicit relative import doesn't produce a deprecation warning for 2.6 and a failure for 2.7 and later. - Patch from Richard Boulton in SF#2008229. + Patch from Richard Boulton in SF#2008229, plus follow-up patches + from Richard and Haoyu Bai. diff --git a/Doc/Manual/Php.html b/Doc/Manual/Php.html index 6dbc09dd3..9beedc1ef 100644 --- a/Doc/Manual/Php.html +++ b/Doc/Manual/Php.html @@ -91,7 +91,7 @@ you wish to statically link the extension into the php interpreter. The third file, example.php can be included by PHP scripts. It attempts to dynamically load the extension and contains extra php code specified -in the interface file. If wrapping C++ code for PHP5, it will +in the interface file. If wrapping C++ code with PHP classes, it will also contain PHP5 class wrappers.

      @@ -103,7 +103,8 @@ more detail in section 27.2.6.

      The usual (and recommended) way is to build the extension as a separate -dynamically loaded module. You can then specify that this be loaded +dynamically loaded module (which is supported by all modern operating +systems). You can then specify that this be loaded automatically in php.ini or load it explicitly for any script which needs it.

      @@ -113,17 +114,15 @@ It is also possible to rebuild PHP from source so that your module is statically linked into the php executable/library. This is a lot more work, and also requires a full rebuild of PHP to update your module, and it doesn't play nicely with package system. We don't recommend -this approach, but if you really want to do this, the -phpfull -command line argument to swig may be of use - see below for details. +this approach, or provide explicit support for it.

      28.1.1 Building a loadable extension

      -

      To build your module as a dynamically loadable extension, use compilation commands like these (if you aren't using GCC, the commands will be different, -and there may be so variation between platforms - these commands should at +and there may be some variation between platforms - these commands should at least work for Linux though):

      @@ -141,128 +140,9 @@ add them to your Makefile or other build system directly. We recommend that you don't use -make and it's likely to be removed at some point.

      -

      28.1.2 Building extensions into PHP

      - - -

      -Note that we don't recommend this approach - it's cleaner and simpler to -use dynamically loadable modules, which are supported by all modern OSes. -Support for this may be discontinued entirely in the future. -

      - -

      -It is possible to rebuild PHP itself with your module statically linked -in. To do this, you can use the -phpfull command line option to -swig. Using this option will generate three additional files. The first -extra file, config.m4 contains the m4 and shell code needed to -enable the extension as part of the PHP build process. The second -extra file, Makefile.in contains the information needed to -build the final Makefile after substitutions. The third and final -extra file, CREDITS should contain the credits for the -extension. -

      - -

      -To build with phpize, after you have run swig you will need to run the -'phpize' command (installed as part of php) in the same -directory. This re-creates the php build environment in that -directory. It also creates a configure file which includes the shell -code from the config.m4 that was generated by SWIG, this configure -script will accept a command line argument to enable the extension to -be run (by default the command line argument is --enable-modulename, -however you can edit the config.m4 file before running phpize to -accept --with-modulename. You can also add extra tests in config.m4 to -check that a correct library version is installed or correct header -files are included, etc, but you must edit this file before running -phpize.) You can also get SWIG to generate simple extra tests for -libraries and header files for you. -

      - -
      -	swig -php -phpfull
      -
      - -

      -If you depend on source files not generated by SWIG, before generating -the configure file, you may need to edit the Makefile.in -file. This contains the names of the source files to compile (just the -wrapper file by default) and any additional libraries needed to be -linked in. If there are extra C files to compile, you will need to add -them to the Makefile.in, or add the names of libraries if they are -needed. In simple cases SWIG is pretty good at generating a complete -Makefile.in and config.m4 which need no further editing. -

      - -

      -You then run the configure script with the command line argument needed -to enable the extension. Then run make, which builds the extension. -The extension object file will be left in the modules sub directory, you can -move it to wherever it is convenient to call from your php script. -

      - -

      -When using -phpfull, swig also accepts the following -additional optional arguments: -

      -
        -
      • -withincs "<incs>" Adds include files to the config.m4 file. -
      • -withlibs "<libs>" Links with the specified libraries. -
      • -withc "<files>" Compiles and links the additional specified C files. -
      • -withcxx "<files>" Compiles and links the additional specified C++ files. -
      - -

      -After running swig with the -phpfull switch, you will be left with a shockingly -similar set of files to the previous build process. However you will then need -to move these files to a subdirectory within the php source tree, this subdirectory you will need to create under the ext directory, with the name of the extension (e.g. mkdir php-4.0.6/ext/modulename). -

      - -

      -After moving the files into this directory, you will need to run the 'buildall' -script in the php source directory. This rebuilds the configure script -and includes the extra command line arguments from the module you have added. -

      - -

      -Before running the generated configure file, you may need to edit the -Makefile.in. This contains the names of the source files to compile ( -just the wrapper file by default) and any additional libraries needed to -link in. If there are extra C files to compile you will need to add them -to the Makefile, or add the names of libraries if they are needed. -In most cases Makefile.in will be complete, especially if you -make use of -withlibs and -withincs -

      - -
      -	swig -php -phpfull -withlibs "xapian omquery" --withincs "om.h"
      -
      - -

      -Will include in the config.m4 and Makefile.in search for -libxapian.a or libxapian.so and search for -libomquery.a or libomquery.so as well as a -search for om.h. -

      - -

      -You then need to run the configure command and pass the necessary command -line arguments to enable your module (by default this is --enable-modulename, -but this can be changed by editing the config.m4 file in the modules directory -before running the buildall script. In addition, extra tests can be added to -the config.m4 file to ensure the correct libraries and header files are -installed.) -

      - -

      -Once configure has completed, you can run make to build php. If this all -compiles correctly, you should end up with a php executable/library -which contains your new module. You can test it with a php script which -does not have the 'dl' command as used above. -

      28.1.3 Using PHP Extensions

      -

      To test the extension from a PHP script, you need to load it first. You can load it for every script by adding this line the [PHP] section of diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index d67e3deff..87a6235c1 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -53,11 +53,6 @@ PHP Options (available with -php5)\n\ -noproxy - Don't generate proxy classes.\n\ -prefix - Prepend to all class names in PHP5 wrappers\n\ -make - Create simple makefile\n\ - -phpfull - Create full make files\n\ - -withincs - With -phpfull writes needed incs in config.m4\n\ - -withlibs - With -phpfull writes needed libs in config.m4\n\ - -withc - With -phpfull makes extra C files in Makefile.in\n\ - -withcxx - With -phpfull makes extra C++ files in Makefile.in\n\ \n"; /* The original class wrappers for PHP4 store the pointer to the C++ class in @@ -74,14 +69,11 @@ static Node *classnode = 0; static String *module = 0; static String *cap_module = 0; static String *prefix = 0; -static String *withlibs = 0; -static String *withincs = 0; static String *withc = 0; static String *withcxx = 0; static String *shadow_classname = 0; -static int gen_extra = 0; static int gen_make = 0; static File *f_runtime = 0; @@ -215,76 +207,58 @@ public: SWIG_config_cppext("cpp"); for (int i = 1; i < argc; i++) { - if (argv[i]) { - if (strcmp(argv[i], "-phpfull") == 0) { - gen_extra = 1; + if (strcmp(argv[i], "-prefix") == 0) { + if (argv[i + 1]) { + prefix = NewString(argv[i + 1]); Swig_mark_arg(i); - } else if (strcmp(argv[i], "-dlname") == 0) { - Printf(stderr, "*** -dlname is no longer supported\n*** if you want to change the module name, use -module instead.\n"); - SWIG_exit(EXIT_FAILURE); - } else if (strcmp(argv[i], "-prefix") == 0) { - if (argv[i + 1]) { - prefix = NewString(argv[i + 1]); - Swig_mark_arg(i); - Swig_mark_arg(i + 1); - i++; - } else { - Swig_arg_error(); - } - } else if (strcmp(argv[i], "-withlibs") == 0) { - if (argv[i + 1]) { - withlibs = NewString(argv[i + 1]); - Swig_mark_arg(i); - Swig_mark_arg(i + 1); - i++; - } else { - Swig_arg_error(); - } - } else if (strcmp(argv[i], "-withincs") == 0) { - if (argv[i + 1]) { - withincs = NewString(argv[i + 1]); - Swig_mark_arg(i); - Swig_mark_arg(i + 1); - i++; - } else { - Swig_arg_error(); - } - } else if (strcmp(argv[i], "-withc") == 0) { - if (argv[i + 1]) { - withc = NewString(argv[i + 1]); - Swig_mark_arg(i); - Swig_mark_arg(i + 1); - i++; - } else { - Swig_arg_error(); - } - } else if (strcmp(argv[i], "-withcxx") == 0) { - if (argv[i + 1]) { - withcxx = NewString(argv[i + 1]); - Swig_mark_arg(i); - Swig_mark_arg(i + 1); - i++; - } else { - Swig_arg_error(); - } - } else if (strcmp(argv[i], "-cppext") == 0) { - if (argv[i + 1]) { - SWIG_config_cppext(argv[i + 1]); - Swig_mark_arg(i); - Swig_mark_arg(i + 1); - i++; - } else { - Swig_arg_error(); - } - } else if ((strcmp(argv[i], "-noshadow") == 0) || (strcmp(argv[i], "-noproxy") == 0)) { - shadow = 0; - Swig_mark_arg(i); - } else if (strcmp(argv[i], "-make") == 0) { - gen_make = 1; - Swig_mark_arg(i); - } else if (strcmp(argv[i], "-help") == 0) { - fputs(usage, stdout); + Swig_mark_arg(i + 1); + i++; + } else { + Swig_arg_error(); } + } else if (strcmp(argv[i], "-withc") == 0) { + if (argv[i + 1]) { + withc = NewString(argv[i + 1]); + Swig_mark_arg(i); + Swig_mark_arg(i + 1); + i++; + } else { + Swig_arg_error(); + } + } else if (strcmp(argv[i], "-withcxx") == 0) { + if (argv[i + 1]) { + withcxx = NewString(argv[i + 1]); + Swig_mark_arg(i); + Swig_mark_arg(i + 1); + i++; + } else { + Swig_arg_error(); + } + } else if (strcmp(argv[i], "-cppext") == 0) { + if (argv[i + 1]) { + SWIG_config_cppext(argv[i + 1]); + Swig_mark_arg(i); + Swig_mark_arg(i + 1); + i++; + } else { + Swig_arg_error(); + } + } else if ((strcmp(argv[i], "-noshadow") == 0) || (strcmp(argv[i], "-noproxy") == 0)) { + shadow = 0; + Swig_mark_arg(i); + } else if (strcmp(argv[i], "-make") == 0) { + gen_make = 1; + Swig_mark_arg(i); + } else if (strcmp(argv[i], "-help") == 0) { + fputs(usage, stdout); + } else if (strcmp(argv[i], "-phpfull") == 0 || + strcmp(argv[i], "-withlibs") == 0 || + strcmp(argv[i], "-withincs") == 0) { + Printf(stderr, "*** %s is no longer supported.\n*** We recommend building as a dynamically loadable module.\n", argv[i]); + SWIG_exit(EXIT_FAILURE); + } else if (strcmp(argv[i], "-dlname") == 0) { + Printf(stderr, "*** -dlname is no longer supported.\n*** If you want to change the module name, use -module instead.\n"); + SWIG_exit(EXIT_FAILURE); } } @@ -326,206 +300,6 @@ public: Close(f_make); } - void create_extra_files(String *outfile) { - File *f_extra; - - static String *configm4 = 0; - static String *makefilein = 0; - static String *credits = 0; - - configm4 = NewStringEmpty(); - Printv(configm4, SWIG_output_directory(), "config.m4", NIL); - - makefilein = NewStringEmpty(); - Printv(makefilein, SWIG_output_directory(), "Makefile.in", NIL); - - credits = NewStringEmpty(); - Printv(credits, SWIG_output_directory(), "CREDITS", NIL); - - // are we a --with- or --enable- - int with = (withincs || withlibs) ? 1 : 0; - - // Note Makefile.in only copes with one source file - // also withincs and withlibs only take one name each now - // the code they generate should be adapted to take multiple lines - - /* Write out Makefile.in */ - f_extra = NewFile(makefilein, "w"); - if (!f_extra) { - FileErrorDisplay(makefilein); - SWIG_exit(EXIT_FAILURE); - } - - Printf(f_extra, "# $Id$\n\n" "LTLIBRARY_NAME = %s.la\n", module); - - // C++ has more and different entries to C in Makefile.in - if (!CPlusPlus) { - Printf(f_extra, "LTLIBRARY_SOURCES = %s %s\n", Swig_file_filename(outfile), withc); - Printf(f_extra, "LTLIBRARY_SOURCES_CPP = %s\n", withcxx); - } else { - Printf(f_extra, "LTLIBRARY_SOURCES = %s\n", withc); - Printf(f_extra, "LTLIBRARY_SOURCES_CPP = %s %s\n", Swig_file_filename(outfile), withcxx); - Printf(f_extra, "LTLIBRARY_OBJECTS_X = $(LTLIBRARY_SOURCES_CPP:.cpp=.lo) $(LTLIBRARY_SOURCES_CPP:.cxx=.lo)\n"); - } - Printf(f_extra, "LTLIBRARY_SHARED_NAME = %s.la\n", module); - Printf(f_extra, "LTLIBRARY_SHARED_LIBADD = $(%s_SHARED_LIBADD)\n\n", cap_module); - Printf(f_extra, "include $(top_srcdir)/build/dynlib.mk\n"); - - Printf(f_extra, "\n# patch in .cxx support to php build system to work like .cpp\n"); - Printf(f_extra, ".SUFFIXES: .cxx\n\n"); - - Printf(f_extra, ".cxx.o:\n"); - Printf(f_extra, "\t$(CXX_COMPILE) -c $<\n\n"); - - Printf(f_extra, ".cxx.lo:\n"); - Printf(f_extra, "\t$(CXX_PHP_COMPILE)\n\n"); - Printf(f_extra, ".cxx.slo:\n"); - - Printf(f_extra, "\t$(CXX_SHARED_COMPILE)\n\n"); - - Printf(f_extra, "\n# make it easy to test module\n"); - Printf(f_extra, "testmodule:\n"); - Printf(f_extra, "\tphp -q -d extension_dir=modules %s\n\n", Swig_file_filename(phpfilename)); - - Close(f_extra); - - /* Now config.m4 */ - // Note: # comments are OK in config.m4 if you don't mind them - // appearing in the final ./configure file - // (which can help with ./configure debugging) - - // NOTE2: phpize really ought to be able to write out a sample - // config.m4 based on some simple data, I'll take this up with - // the php folk! - f_extra = NewFile(configm4, "w"); - if (!f_extra) { - FileErrorDisplay(configm4); - SWIG_exit(EXIT_FAILURE); - } - - Printf(f_extra, "dnl $Id$\n"); - Printf(f_extra, "dnl ***********************************************************************\n"); - Printf(f_extra, "dnl ** THIS config.m4 is provided for PHPIZE and PHP's consumption NOT\n"); - Printf(f_extra, "dnl ** for any part of the rest of the %s build system\n", module); - Printf(f_extra, "dnl ***********************************************************************\n\n"); - - - if (!with) { // must be enable then - Printf(f_extra, "PHP_ARG_ENABLE(%s, whether to enable %s support,\n", module, module); - Printf(f_extra, "[ --enable-%s Enable %s support])\n\n", module, module); - } else { - Printf(f_extra, "PHP_ARG_WITH(%s, for %s support,\n", module, module); - Printf(f_extra, "[ --with-%s[=DIR] Include %s support.])\n\n", module, module); - // These tests try and file the library we need - Printf(f_extra, "dnl THESE TESTS try and find the library and header files\n"); - Printf(f_extra, "dnl your new php module needs. YOU MAY NEED TO EDIT THEM\n"); - Printf(f_extra, "dnl as written they assume your header files are all in the same place\n\n"); - - Printf(f_extra, "dnl ** are we looking for %s_lib.h or something else?\n", module); - if (withincs) - Printf(f_extra, "HNAMES=\"%s\"\n\n", withincs); - else - Printf(f_extra, "HNAMES=\"\"; # %s_lib.h ?\n\n", module); - - Printf(f_extra, "dnl ** Are we looking for lib%s.a or lib%s.so or something else?\n", module, module); - - if (withlibs) - Printf(f_extra, "LIBNAMES=\"%s\"\n\n", withlibs); - else - Printf(f_extra, "LIBNAMES=\"\"; # lib%s.so ?\n\n", module); - - Printf(f_extra, "dnl IF YOU KNOW one of the symbols in the library and you\n"); - Printf(f_extra, "dnl specify it below then we can have a link test to see if it works\n"); - Printf(f_extra, "LIBSYMBOL=\"\"\n\n"); - } - - // Now write out tests to find thing.. they may need to extend tests - Printf(f_extra, "if test \"$PHP_%s\" != \"no\"; then\n\n", cap_module); - - // Ready for when we add libraries as we find them - Printf(f_extra, " PHP_SUBST(%s_SHARED_LIBADD)\n\n", cap_module); - - if (withlibs) { // find more than one library - Printf(f_extra, " for LIBNAME in $LIBNAMES ; do\n"); - Printf(f_extra, " LIBDIR=\"\"\n"); - // For each path element to try... - Printf(f_extra, " for i in $PHP_%s $PHP_%s/lib /usr/lib /usr/local/lib ; do\n", cap_module, cap_module); - Printf(f_extra, " if test -r $i/lib$LIBNAME.a -o -r $i/lib$LIBNAME.so ; then\n"); - Printf(f_extra, " LIBDIR=\"$i\"\n"); - Printf(f_extra, " break\n"); - Printf(f_extra, " fi\n"); - Printf(f_extra, " done\n\n"); - Printf(f_extra, " dnl ** and $LIBDIR should be the library path\n"); - Printf(f_extra, " if test \"$LIBNAME\" != \"\" -a -z \"$LIBDIR\" ; then\n"); - Printf(f_extra, " AC_MSG_RESULT(Library files $LIBNAME not found)\n"); - Printf(f_extra, " AC_MSG_ERROR(Is the %s distribution installed properly?)\n", module); - Printf(f_extra, " else\n"); - Printf(f_extra, " AC_MSG_RESULT(Library files $LIBNAME found in $LIBDIR)\n"); - Printf(f_extra, " PHP_ADD_LIBRARY_WITH_PATH($LIBNAME, $LIBDIR, %s_SHARED_LIBADD)\n", cap_module); - Printf(f_extra, " fi\n"); - Printf(f_extra, " done\n\n"); - } - - if (withincs) { // Find more than once include - Printf(f_extra, " for HNAME in $HNAMES ; do\n"); - Printf(f_extra, " INCDIR=\"\"\n"); - // For each path element to try... - Printf(f_extra, " for i in $PHP_%s $PHP_%s/include $PHP_%s/includes $PHP_%s/inc $PHP_%s/incs /usr/local/include /usr/include; do\n", cap_module, - cap_module, cap_module, cap_module, cap_module); - // Try and find header files - Printf(f_extra, " if test \"$HNAME\" != \"\" -a -r $i/$HNAME ; then\n"); - Printf(f_extra, " INCDIR=\"$i\"\n"); - Printf(f_extra, " break\n"); - Printf(f_extra, " fi\n"); - Printf(f_extra, " done\n\n"); - - Printf(f_extra, " dnl ** Now $INCDIR should be the include file path\n"); - Printf(f_extra, " if test \"$HNAME\" != \"\" -a -z \"$INCDIR\" ; then\n"); - Printf(f_extra, " AC_MSG_RESULT(Include files $HNAME not found)\n"); - Printf(f_extra, " AC_MSG_ERROR(Is the %s distribution installed properly?)\n", module); - Printf(f_extra, " else\n"); - Printf(f_extra, " AC_MSG_RESULT(Include files $HNAME found in $INCDIR)\n"); - Printf(f_extra, " PHP_ADD_INCLUDE($INCDIR)\n"); - Printf(f_extra, " fi\n\n"); - Printf(f_extra, " done\n\n"); - } - - if (CPlusPlus) { - Printf(f_extra, " # As this is a C++ module..\n"); - } - - Printf(f_extra, " PHP_REQUIRE_CXX\n"); - Printf(f_extra, " AC_CHECK_LIB(stdc++, cin)\n"); - - if (with) { - Printf(f_extra, " if test \"$LIBSYMBOL\" != \"\" ; then\n"); - Printf(f_extra, " old_LIBS=\"$LIBS\"\n"); - Printf(f_extra, " LIBS=\"$LIBS -L$TEST_DIR/lib -lm -ldl\"\n"); - Printf(f_extra, " AC_CHECK_LIB($LIBNAME, $LIBSYMBOL, [AC_DEFINE(HAVE_TESTLIB,1, [ ])],\n"); - Printf(f_extra, " [AC_MSG_ERROR(wrong test lib version or lib not found)])\n"); - Printf(f_extra, " LIBS=\"$old_LIBS\"\n"); - Printf(f_extra, " fi\n\n"); - } - - Printf(f_extra, " AC_DEFINE(HAVE_%s, 1, [ ])\n", cap_module); - Printf(f_extra, "dnl AC_DEFINE_UNQUOTED(PHP_%s_DIR, \"$%s_DIR\", [ ])\n", cap_module, cap_module); - Printf(f_extra, " PHP_EXTENSION(%s, $ext_shared)\n", module); - - // and thats all! - Printf(f_extra, "fi\n"); - - Close(f_extra); - - /* CREDITS */ - f_extra = NewFile(credits, "w"); - if (!f_extra) { - FileErrorDisplay(credits); - SWIG_exit(EXIT_FAILURE); - } - Printf(f_extra, "%s\n", module); - Close(f_extra); - } - /* ------------------------------------------------------------ * top() * ------------------------------------------------------------ */ @@ -715,9 +489,6 @@ public: Printf(s_init, "};\n"); Printf(s_init, "zend_module_entry* SWIG_module_entry = &%s_module_entry;\n\n", module); - if (gen_extra) { - Printf(s_init, "#ifdef COMPILE_DL_%s\n", cap_module); - } Printf(s_init, "#ifdef __cplusplus\n"); Printf(s_init, "extern \"C\" {\n"); Printf(s_init, "#endif\n"); @@ -728,10 +499,6 @@ public: Printf(s_init, "}\n"); Printf(s_init, "#endif\n\n"); - if (gen_extra) { - Printf(s_init, "#endif\n\n"); - } - /* We have to register the constants before they are (possibly) used * by the pointer typemaps. This all needs re-arranging really as * things are being called in the wrong order @@ -828,9 +595,7 @@ public: Printf(f_phpcode, "%s\n?>\n", s_phpclasses); Close(f_phpcode); - if (gen_extra) { - create_extra_files(outfile); - } else if (gen_make) { + if (gen_make) { create_simple_make(); } From dccd552d73ae8f1e6738ee79d8ac0ec84f4be351 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Thu, 3 Jul 2008 02:32:41 +0000 Subject: [PATCH 0070/1680] Fix version number git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10638 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index 646aaff3f..bdb8288fb 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,4 +1,4 @@ -Version 1.3.36 (in progress) +Version 1.3.37 (in progress) ============================= 2008-07-03: olly From 30cdd1f71e95a38864b8ca32c5bfd752991f4f82 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Thu, 3 Jul 2008 06:04:24 +0000 Subject: [PATCH 0071/1680] Make t_output_helper() static. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10639 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/php/utils.i | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/php/utils.i b/Lib/php/utils.i index 77c9e923e..661a48777 100644 --- a/Lib/php/utils.i +++ b/Lib/php/utils.i @@ -36,7 +36,7 @@ %enddef %fragment("t_output_helper","header") %{ -void +static void t_output_helper( zval **target, zval *o) { if ( (*target)->type == IS_ARRAY ) { /* it's already an array, just append */ From fbfda8f7d26b32b5a967d5bef04f73c5c4047f04 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Thu, 3 Jul 2008 06:05:34 +0000 Subject: [PATCH 0072/1680] Make testcase li_typemaps work for PHP. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10640 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/php/typemaps.i | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Lib/php/typemaps.i b/Lib/php/typemaps.i index c388fdf96..c5b749578 100644 --- a/Lib/php/typemaps.i +++ b/Lib/php/typemaps.i @@ -107,6 +107,17 @@ int_typemap(unsigned char); %typemap(in) unsigned long *INOUT = unsigned long *INPUT; %typemap(in) unsigned char *INOUT = unsigned char *INPUT; +%typemap(in) float &INOUT = float *INPUT; +%typemap(in) double &INOUT = double *INPUT; + +%typemap(in) int &INOUT = int *INPUT; +%typemap(in) short &INOUT = short *INPUT; +%typemap(in) long &INOUT = long *INPUT; +%typemap(in) 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(argout) float *INOUT = float *OUTPUT; %typemap(argout) double *INOUT= double *OUTPUT; @@ -117,6 +128,16 @@ int_typemap(unsigned char); %typemap(argout) unsigned long *INOUT = unsigned long *OUTPUT; %typemap(argout) unsigned char *INOUT = unsigned char *OUTPUT; +%typemap(argout) float &INOUT = float *OUTPUT; +%typemap(argout) double &INOUT= double *OUTPUT; + +%typemap(argout) int &INOUT = int *OUTPUT; +%typemap(argout) short &INOUT = short *OUTPUT; +%typemap(argout) long &INOUT= long *OUTPUT; +%typemap(argout) unsigned short &INOUT= unsigned short *OUTPUT; +%typemap(argout) unsigned long &INOUT = unsigned long *OUTPUT; +%typemap(argout) unsigned char &INOUT = unsigned char *OUTPUT; + %typemap(in) char INPUT[ANY] ( char temp[$1_dim0] ) %{ convert_to_string_ex($input); From a172b1d4b034c12712e9207b64b069fc011afb9c Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Thu, 3 Jul 2008 09:12:16 +0000 Subject: [PATCH 0073/1680] Fix check::classname() to compare case-insensitively and not try to interpolate objects into strings. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10641 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/php4/tests.php4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/test-suite/php4/tests.php4 b/Examples/test-suite/php4/tests.php4 index ae43398df..36e9f4163 100644 --- a/Examples/test-suite/php4/tests.php4 +++ b/Examples/test-suite/php4/tests.php4 @@ -67,7 +67,7 @@ class check { } function classname($string,$object) { - if ($string!=($classname=get_class($object))) return check::fail("Object: $object is of class %s not class %s",$classname,$string); + 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 3d6dcc3ce61afbe43a9dce61c26eed144c3c239f Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Thu, 3 Jul 2008 22:00:01 +0000 Subject: [PATCH 0074/1680] The operator& trick in allowexcept.i doesn't work for SWIG/PHP because the generated code takes the address of the variable in the code in the "vinit" section. So comment out the private operator& for PHP. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10643 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/allowexcept.i | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Examples/test-suite/allowexcept.i b/Examples/test-suite/allowexcept.i index 14b19b33d..37b01cd75 100644 --- a/Examples/test-suite/allowexcept.i +++ b/Examples/test-suite/allowexcept.i @@ -26,14 +26,26 @@ UVW Bar::static_member_variable; struct XYZ { }; +// The operator& trick doesn't work for SWIG/PHP because the generated code +// takes the address of the variable in the code in the "vinit" section. +#ifdef SWIGPHP %{ struct XYZ { void foo() {} private: XYZ& operator=(const XYZ& other); // prevent assignment used in normally generated set method - XYZ* operator&(); // prevent dereferencing used in normally generated get method }; %} +#else +%{ +struct XYZ { + void foo() {} +private: + XYZ& operator=(const XYZ& other); // prevent assignment used in normally generated set method + XYZ* operator&(); // prevent dereferencing used in normally generated get method +}; +%} +#endif #if defined(SWIGUTL) %exception { /* From 1e6d6b2708fc50c644f23df6fe9d76c882ec1a43 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Thu, 3 Jul 2008 23:55:33 +0000 Subject: [PATCH 0075/1680] [PHP] The SWIG cdata.i library module is now supported. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10647 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 3 +++ Lib/cdata.i | 9 +++++---- Lib/php/php.swg | 7 +++++++ 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index bdb8288fb..a3a4b6751 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,9 @@ Version 1.3.37 (in progress) ============================= +2008-07-04: olly + [PHP] The SWIG cdata.i library module is now supported. + 2008-07-03: olly [PHP] The deprecated command line option "-phpfull" has been removed. We recommend building your extension as a dynamically diff --git a/Lib/cdata.i b/Lib/cdata.i index a9e74ed8a..67601f737 100644 --- a/Lib/cdata.i +++ b/Lib/cdata.i @@ -29,6 +29,11 @@ typedef struct SWIGCDATA { $result = C_string(&string_space, $1.len, $1.data); } %typemap(in) (const void *indata, int inlen) = (char *STRING, int LENGTH); +#elif SWIGPHP +%typemap(out) SWIGCDATA { + ZVAL_STRINGL($result, $1.data, $1.len, 1); +} +%typemap(in) (const void *indata, int inlen) = (char *STRING, int LENGTH); #else %echo "cdata.i module not supported." #endif @@ -76,7 +81,3 @@ SWIGCDATA cdata_##NAME(TYPE *ptr, int nelements); /* Memory move function */ void memmove(void *data, const void *indata, int inlen); - - - - diff --git a/Lib/php/php.swg b/Lib/php/php.swg index 50630bc03..d30e0b2a9 100644 --- a/Lib/php/php.swg +++ b/Lib/php/php.swg @@ -73,6 +73,13 @@ $1 = ($1_ltype) Z_STRVAL_PP($input); } +%typemap(in) (char *STRING, int LENGTH) +{ + convert_to_string_ex($input); + $1 = ($1_ltype) Z_STRVAL_PP($input); + $2 = ($2_ltype) Z_STRLEN_PP($input); +} + /* Object passed by value. Convert to a pointer */ %typemap(in) SWIGTYPE ($&1_ltype tmp) { From 70ff1c3005203f4487ee06dfa41a400683076072 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Fri, 4 Jul 2008 01:02:22 +0000 Subject: [PATCH 0076/1680] [PHP] The deprecated command line option "-make" has been removed. Searches on Google codesearch suggest that nobody is using it now anyway. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10649 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 5 ++ Doc/Manual/Php.html | 10 ---- Examples/php4/reference/BUILD-proxy.sh | 5 -- Source/Modules/php.cxx | 66 ++------------------------ 4 files changed, 10 insertions(+), 76 deletions(-) delete mode 100755 Examples/php4/reference/BUILD-proxy.sh diff --git a/CHANGES.current b/CHANGES.current index a3a4b6751..eba314fb2 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,11 @@ Version 1.3.37 (in progress) ============================= +2008-07-03: olly + [PHP] The deprecated command line option "-make" has been removed. + Searches on Google codesearch suggest that nobody is using it now + anyway. + 2008-07-04: olly [PHP] The SWIG cdata.i library module is now supported. diff --git a/Doc/Manual/Php.html b/Doc/Manual/Php.html index 9beedc1ef..8adbc36b1 100644 --- a/Doc/Manual/Php.html +++ b/Doc/Manual/Php.html @@ -131,16 +131,6 @@ least work for Linux though): gcc -shared example_wrap.o -o example.so

      -

      -There is a deprecated -make command line argument to swig which will -generate an additional file makefile which can usually build the -extension (at least on some UNIX platforms), but the Makefile generated isn't -very flexible, and the commands required are trivial so it is simpler to just -add them to your Makefile or other build system directly. We recommend that -you don't use -make and it's likely to be removed at some point. -

      - -

      28.1.3 Using PHP Extensions

      diff --git a/Examples/php4/reference/BUILD-proxy.sh b/Examples/php4/reference/BUILD-proxy.sh deleted file mode 100755 index b1c8c71a4..000000000 --- a/Examples/php4/reference/BUILD-proxy.sh +++ /dev/null @@ -1,5 +0,0 @@ -#! /bin/sh -e - -${SWIG:=swig} -php4 -make -c++ -withcxx example.cxx example.i -make -php -d extension_dir=. runme-proxy.php4 diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index 87a6235c1..9369c2489 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -52,7 +52,6 @@ PHP Options (available with -php5)\n\ -cppext - cpp file extension (default to .cpp)\n\ -noproxy - Don't generate proxy classes.\n\ -prefix - Prepend to all class names in PHP5 wrappers\n\ - -make - Create simple makefile\n\ \n"; /* The original class wrappers for PHP4 store the pointer to the C++ class in @@ -69,13 +68,9 @@ static Node *classnode = 0; static String *module = 0; static String *cap_module = 0; static String *prefix = 0; -static String *withc = 0; -static String *withcxx = 0; static String *shadow_classname = 0; -static int gen_make = 0; - static File *f_runtime = 0; static File *f_h = 0; static File *f_phpcode = 0; @@ -216,24 +211,6 @@ public: } else { Swig_arg_error(); } - } else if (strcmp(argv[i], "-withc") == 0) { - if (argv[i + 1]) { - withc = NewString(argv[i + 1]); - Swig_mark_arg(i); - Swig_mark_arg(i + 1); - i++; - } else { - Swig_arg_error(); - } - } else if (strcmp(argv[i], "-withcxx") == 0) { - if (argv[i + 1]) { - withcxx = NewString(argv[i + 1]); - Swig_mark_arg(i); - Swig_mark_arg(i + 1); - i++; - } else { - Swig_arg_error(); - } } else if (strcmp(argv[i], "-cppext") == 0) { if (argv[i + 1]) { SWIG_config_cppext(argv[i + 1]); @@ -246,11 +223,13 @@ public: } else if ((strcmp(argv[i], "-noshadow") == 0) || (strcmp(argv[i], "-noproxy") == 0)) { shadow = 0; Swig_mark_arg(i); - } else if (strcmp(argv[i], "-make") == 0) { - gen_make = 1; - Swig_mark_arg(i); } else if (strcmp(argv[i], "-help") == 0) { fputs(usage, stdout); + } else if (strcmp(argv[i], "-make") == 0 || + strcmp(argv[i], "-withc") == 0 || + strcmp(argv[i], "-withcxx") == 0) { + Printf(stderr, "*** %s is no longer supported.\n", argv[i]); + SWIG_exit(EXIT_FAILURE); } else if (strcmp(argv[i], "-phpfull") == 0 || strcmp(argv[i], "-withlibs") == 0 || strcmp(argv[i], "-withincs") == 0) { @@ -269,37 +248,6 @@ public: allow_overloading(); } - void create_simple_make(void) { - File *f_make; - - f_make = NewFile((void *) "makefile", "w"); - Printf(f_make, "CC=gcc\n"); - Printf(f_make, "CXX=g++\n"); - Printf(f_make, "CXX_SOURCES=%s\n", withcxx); - Printf(f_make, "C_SOURCES=%s\n", withc); - Printf(f_make, "OBJS=%s_wrap.o $(C_SOURCES:.c=.o) $(CXX_SOURCES:.cxx=.o)\n", module); - Printf(f_make, "MODULE=%s.so\n", module); - Printf(f_make, "CFLAGS=-fpic\n"); - Printf(f_make, "LDFLAGS=-shared\n"); - Printf(f_make, "PHP_INC=`php-config --includes`\n"); - Printf(f_make, "EXTRA_INC=\n"); - Printf(f_make, "EXTRA_LIB=\n\n"); - Printf(f_make, "$(MODULE): $(OBJS)\n"); - if (CPlusPlus || (withcxx != NULL)) { - Printf(f_make, "\t$(CXX) $(LDFLAGS) $(OBJS) -o $@ $(EXTRA_LIB)\n\n"); - } else { - Printf(f_make, "\t$(CC) $(LDFLAGS) $(OBJS) -o $@ $(EXTRA_LIB)\n\n"); - } - Printf(f_make, "%%.o: %%.cpp\n"); - Printf(f_make, "\t$(CXX) $(EXTRA_INC) $(PHP_INC) $(CFLAGS) -c $<\n"); - Printf(f_make, "%%.o: %%.cxx\n"); - Printf(f_make, "\t$(CXX) $(EXTRA_INC) $(PHP_INC) $(CFLAGS) -c $<\n"); - Printf(f_make, "%%.o: %%.c\n"); - Printf(f_make, "\t$(CC) $(EXTRA_INC) $(PHP_INC) $(CFLAGS) -c $<\n"); - - Close(f_make); - } - /* ------------------------------------------------------------ * top() * ------------------------------------------------------------ */ @@ -595,10 +543,6 @@ public: Printf(f_phpcode, "%s\n?>\n", s_phpclasses); Close(f_phpcode); - if (gen_make) { - create_simple_make(); - } - return SWIG_OK; } From b2cea3c42a717b19faf0772bd0bf264b1d77319b Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Fri, 4 Jul 2008 01:22:11 +0000 Subject: [PATCH 0077/1680] [PHP] For std_vector.i and std_map.i, rename empty() to is_empty() since "empty" is a PHP reserved word. Based of patch from Mark Klein in SF#1943417. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10650 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 7 ++++++- Lib/php/std_map.i | 4 ++++ Lib/php/std_vector.i | 2 ++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index eba314fb2..19caae55d 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,7 +1,12 @@ Version 1.3.37 (in progress) ============================= -2008-07-03: olly +2008-07-04: olly + [PHP] For std_vector.i and std_map.i, rename empty() to is_empty() + since "empty" is a PHP reserved word. Based of patch from Mark Klein + in SF#1943417. + +2008-07-04: olly [PHP] The deprecated command line option "-make" has been removed. Searches on Google codesearch suggest that nobody is using it now anyway. diff --git a/Lib/php/std_map.i b/Lib/php/std_map.i index c35f21dc7..c6721806b 100644 --- a/Lib/php/std_map.i +++ b/Lib/php/std_map.i @@ -30,6 +30,7 @@ namespace std { map(const map &); unsigned int size() const; + %rename(is_empty) empty; bool empty() const; void clear(); %extend { @@ -69,6 +70,7 @@ namespace std { map(const map &); unsigned int size() const; + %rename(is_empty) empty; bool empty() const; void clear(); %extend { @@ -105,6 +107,7 @@ namespace std { map(const map &); unsigned int size() const; + %rename(is_empty) empty; bool empty() const; void clear(); %extend { @@ -142,6 +145,7 @@ namespace std { map(const map &); unsigned int size() const; + %rename(is_empty) empty; bool empty() const; void clear(); %extend { diff --git a/Lib/php/std_vector.i b/Lib/php/std_vector.i index fe084aca4..b54181618 100644 --- a/Lib/php/std_vector.i +++ b/Lib/php/std_vector.i @@ -48,6 +48,7 @@ namespace std { public: vector(unsigned int size = 0); unsigned int size() const; + %rename(is_empty) empty; bool empty() const; void clear(); %rename(push) push_back; @@ -86,6 +87,7 @@ namespace std { public: vector(unsigned int size = 0); unsigned int size() const; + %rename(is_empty) empty; bool empty() const; void clear(); %rename(push) push_back; From 4887e7be7cc15888a2b52c73b52aa1ab5e51e194 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 14 Jul 2008 21:09:23 +0000 Subject: [PATCH 0078/1680] Fix director typemaps for pointers so that NULL pointers are correctly marshalled to C#/Java null in director methods git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10662 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 + .../test-suite/csharp/director_basic_runme.cs | 74 +++++++++++++++++++ Examples/test-suite/director_basic.i | 6 +- .../test-suite/java/director_basic_runme.java | 57 ++++++++++---- Lib/csharp/csharp.swg | 3 +- Lib/java/java.swg | 3 +- 6 files changed, 127 insertions(+), 20 deletions(-) create mode 100644 Examples/test-suite/csharp/director_basic_runme.cs diff --git a/CHANGES.current b/CHANGES.current index 19caae55d..2a3e14d8b 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,10 @@ Version 1.3.37 (in progress) ============================= +2008-07-14: wsfultonn + [Java, C#] Fix director typemaps for pointers so that NULL pointers are correctly + marshalled to C#/Java null in director methods. + 2008-07-04: olly [PHP] For std_vector.i and std_map.i, rename empty() to is_empty() since "empty" is a PHP reserved word. Based of patch from Mark Klein diff --git a/Examples/test-suite/csharp/director_basic_runme.cs b/Examples/test-suite/csharp/director_basic_runme.cs new file mode 100644 index 000000000..b9916108c --- /dev/null +++ b/Examples/test-suite/csharp/director_basic_runme.cs @@ -0,0 +1,74 @@ +using System; + +namespace director_basicNamespace { + +public class runme +{ + static void Main() + { + runme r = new runme(); + r.run(); + } + + void run() + { + director_basic_MyFoo a = new director_basic_MyFoo(); + + if (a.ping() != "director_basic_MyFoo::ping()") { + throw new Exception ( "a.ping()" ); + } + + if (a.pong() != "Foo::pong();director_basic_MyFoo::ping()") { + throw new Exception ( "a.pong()" ); + } + + Foo b = new Foo(); + + if (b.ping() != "Foo::ping()") { + throw new Exception ( "b.ping()" ); + } + + if (b.pong() != "Foo::pong();Foo::ping()") { + throw new Exception ( "b.pong()" ); + } + + A1 a1 = new A1(1, false); + a1.Dispose(); + + { + MyOverriddenClass my = new MyOverriddenClass(); + + my.expectNull = true; + if (MyClass.call_pmethod(my, null) != null) + throw new Exception("null pointer marshalling problem"); + + Bar myBar = new Bar(); + my.expectNull = false; + Bar myNewBar = MyClass.call_pmethod(my, myBar); + if (myNewBar == null) + throw new Exception("non-null pointer marshalling problem"); + myNewBar.x = 10; + } + } +} + +class director_basic_MyFoo : Foo { + public director_basic_MyFoo() : base() { + } + + public override string ping() { + return "director_basic_MyFoo::ping()"; + } +} + +class MyOverriddenClass : MyClass { + public bool expectNull = false; + public bool nonNullReceived = false; + public override Bar pmethod(Bar b) { + if ( expectNull && (b != null) ) + throw new Exception("null not received as expected"); + return b; + } +} + +} diff --git a/Examples/test-suite/director_basic.i b/Examples/test-suite/director_basic.i index 986a1706f..12cb0db65 100644 --- a/Examples/test-suite/director_basic.i +++ b/Examples/test-suite/director_basic.i @@ -112,12 +112,14 @@ public: return vmethod(b); } - static MyClass *get_self(MyClass *c) { return c; } - + + static Bar * call_pmethod(MyClass *myclass, Bar *b) { + return myclass->pmethod(b); + } }; template diff --git a/Examples/test-suite/java/director_basic_runme.java b/Examples/test-suite/java/director_basic_runme.java index eafe20bec..16a46aa35 100644 --- a/Examples/test-suite/java/director_basic_runme.java +++ b/Examples/test-suite/java/director_basic_runme.java @@ -14,28 +14,43 @@ public class director_basic_runme { public static void main(String argv[]) { - director_basic_MyFoo a = new director_basic_MyFoo(); + director_basic_MyFoo a = new director_basic_MyFoo(); - if (!a.ping().equals("director_basic_MyFoo::ping()")) { - throw new RuntimeException ( "a.ping()" ); - } + if (!a.ping().equals("director_basic_MyFoo::ping()")) { + throw new RuntimeException ( "a.ping()" ); + } - if (!a.pong().equals("Foo::pong();director_basic_MyFoo::ping()")) { - throw new RuntimeException ( "a.pong()" ); - } + if (!a.pong().equals("Foo::pong();director_basic_MyFoo::ping()")) { + throw new RuntimeException ( "a.pong()" ); + } - Foo b = new Foo(); + Foo b = new Foo(); - if (!b.ping().equals("Foo::ping()")) { - throw new RuntimeException ( "b.ping()" ); - } + if (!b.ping().equals("Foo::ping()")) { + throw new RuntimeException ( "b.ping()" ); + } - if (!b.pong().equals("Foo::pong();Foo::ping()")) { - throw new RuntimeException ( "b.pong()" ); - } + if (!b.pong().equals("Foo::pong();Foo::ping()")) { + throw new RuntimeException ( "b.pong()" ); + } - A1 a1 = new A1(1, false); - a1.delete(); + A1 a1 = new A1(1, false); + a1.delete(); + + { + MyOverriddenClass my = new MyOverriddenClass(); + + my.expectNull = true; + if (MyClass.call_pmethod(my, null) != null) + throw new RuntimeException("null pointer marshalling problem"); + + Bar myBar = new Bar(); + my.expectNull = false; + Bar myNewBar = MyClass.call_pmethod(my, myBar); + if (myNewBar == null) + throw new RuntimeException("non-null pointer marshalling problem"); + myNewBar.setX(10); + } } } @@ -45,3 +60,13 @@ class director_basic_MyFoo extends Foo { } } +class MyOverriddenClass extends MyClass { + public boolean expectNull = false; + public boolean nonNullReceived = false; + public Bar pmethod(Bar b) { + if ( expectNull && (b != null) ) + throw new RuntimeException("null not received as expected"); + return b; + } +} + diff --git a/Lib/csharp/csharp.swg b/Lib/csharp/csharp.swg index 35e5c26d7..e381ff9ae 100644 --- a/Lib/csharp/csharp.swg +++ b/Lib/csharp/csharp.swg @@ -428,7 +428,8 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) { %typemap(directorin) SWIGTYPE & %{ $input = ($1_ltype) &$1; %} -%typemap(csdirectorin) SWIGTYPE *, SWIGTYPE (CLASS::*), SWIGTYPE & "new $csclassname($iminput, false)" +%typemap(csdirectorin) SWIGTYPE *, SWIGTYPE (CLASS::*) "($iminput == IntPtr.Zero) ? null : new $csclassname($iminput, false)" +%typemap(csdirectorin) SWIGTYPE & "new $csclassname($iminput, false)" %typemap(csdirectorout) SWIGTYPE *, SWIGTYPE (CLASS::*), SWIGTYPE & "$csclassname.getCPtr($cscall).Handle" /* Default array handling */ diff --git a/Lib/java/java.swg b/Lib/java/java.swg index b7c5607c3..7d1808632 100644 --- a/Lib/java/java.swg +++ b/Lib/java/java.swg @@ -620,7 +620,8 @@ %typemap(directorin,descriptor="L$packagepath/$javaclassname;") SWIGTYPE & %{ *($&1_ltype)&$input = ($1_ltype) &$1; %} -%typemap(javadirectorin) SWIGTYPE *, SWIGTYPE (CLASS::*), SWIGTYPE & "new $javaclassname($jniinput, false)" +%typemap(javadirectorin) SWIGTYPE *, SWIGTYPE (CLASS::*) "($jniinput == 0) ? null : new $javaclassname($jniinput, false)" +%typemap(javadirectorin) SWIGTYPE & "new $javaclassname($jniinput, false)" %typemap(javadirectorout) SWIGTYPE *, SWIGTYPE (CLASS::*), SWIGTYPE & "$javaclassname.getCPtr($javacall)" /* Default array handling */ From 18fb8497ff4c9bfdf9a6b6a5a62a88468d084bd2 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Thu, 17 Jul 2008 01:17:08 +0000 Subject: [PATCH 0079/1680] Fix a typo; improve wording. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10672 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 2a3e14d8b..1570a1ad1 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,7 +7,7 @@ Version 1.3.37 (in progress) 2008-07-04: olly [PHP] For std_vector.i and std_map.i, rename empty() to is_empty() - since "empty" is a PHP reserved word. Based of patch from Mark Klein + since "empty" is a PHP reserved word. Based on patch from Mark Klein in SF#1943417. 2008-07-04: olly @@ -25,8 +25,8 @@ Version 1.3.37 (in progress) 2008-07-02: olly [PHP4] Support for PHP4 has been removed. The PHP developers are - no longer making new PHP4 releases, and won't even be patching - critical security issues after 2008-08-08. + no longer making new PHP4 releases, and won't even be providing + patches for critical security issues after 2008-08-08. 2008-07-02: olly [Python] Import the C extension differently for Python 2.6 and From 5c52b699e3ac033e67212656c3853920c3626be4 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 17 Jul 2008 21:05:49 +0000 Subject: [PATCH 0080/1680] SF #2019156 Configuring with --without-octave or --without-alllang did not disable octave. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10676 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++++ configure.in | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 1570a1ad1..bd94eca51 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,10 @@ Version 1.3.37 (in progress) ============================= +2008-07-17: wsfulton + Fix SF #2019156 Configuring with --without-octave or --without-alllang + did not disable octave. + 2008-07-14: wsfultonn [Java, C#] Fix director typemaps for pointers so that NULL pointers are correctly marshalled to C#/Java null in director methods. diff --git a/configure.in b/configure.in index 13c3c6bc9..b9a5dc04a 100644 --- a/configure.in +++ b/configure.in @@ -732,13 +732,13 @@ OCTAVEDYNAMICLINKING= OCTAVE_SO=.oct AC_ARG_WITH(octave, AS_HELP_STRING([--without-octave], [Disable Octave]) -AS_HELP_STRING([--with-octave=path], [Set location of Octave executable]),[ OCTAVEBIN="$withval"], [OCTAVEBIN=yes]) +AS_HELP_STRING([--with-octave=path], [Set location of Octave executable]),[OCTAVEBIN="$withval"], [OCTAVEBIN=yes]) # First, check for "--without-octave" or "--with-octave=no". if test x"${OCTAVEBIN}" = xno -o x"${with_alllang}" = xno ; then AC_MSG_NOTICE([Disabling Octave]) OCTAVE= -fi +else # First figure out what the name of Octave is @@ -779,6 +779,8 @@ else AC_MSG_RESULT(could not figure out how to run octave) fi +fi + AC_SUBST(OCTAVE) AC_SUBST(OCTAVEEXT) AC_SUBST(OCTAVE_SO) From ea0a1a7f0624959f167beb9e18fc424389800e47 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 17 Jul 2008 21:08:22 +0000 Subject: [PATCH 0081/1680] tidy output after detecting X11 headers git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10677 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- configure.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.in b/configure.in index b9a5dc04a..4f9d37b26 100644 --- a/configure.in +++ b/configure.in @@ -376,12 +376,12 @@ if test "$no_x" = "yes" -o "$not_really_there" = "yes"; then dirs="/usr/unsupported/include /usr/local/include /usr/X386/include /usr/include/X11R4 /usr/X11R5/include /usr/include/X11R5 /usr/openwin/include /usr/X11/include /usr/sww/include /usr/X11R6/include /usr/include/X11R6" for i in $dirs ; do if test -r $i/X11/Intrinsic.h; then - AC_MSG_RESULT($i) XINCLUDES=" -I$i" break fi done fi + AC_MSG_RESULT($XINCLUDES) else if test "$x_includes" != ""; then XINCLUDES=-I$x_includes From b5b11ce6f4df3a0c2ad5ace47a566d986c3de091 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 19 Jul 2008 18:08:06 +0000 Subject: [PATCH 0082/1680] a bit more on pgcpp git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10682 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Java.html | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html index 164fc21e7..518426f5a 100644 --- a/Doc/Manual/Java.html +++ b/Doc/Manual/Java.html @@ -2857,7 +2857,11 @@ and therefore there is no possibility of premature garbage collection. In practi

      The premature garbage collection prevention parameter for proxy classes is generated by default whenever proxy classes are passed by value, reference or with a pointer. -The additional parameters do impose a slight performance overhead and the parameter generation can be suppressed globally with the -nopgcpp commandline option. +The implementation for this extra parameter generation requires the "jtype" typemap to contain long and the "jstype" typemap to contain the name of a proxy class. +

      + +

      +The additional parameter does impose a slight performance overhead and the parameter generation can be suppressed globally with the -nopgcpp commandline option. More selective suppression is possible with the 'nopgcpp' attribute in the "jtype" Java typemap. The attribute is a flag and so should be set to "1" to enable the suppression, or it can be omitted or set to "0" to disable. For example: From bbadd7033083d8d56d1b49654bf2b7b730877266 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 19 Jul 2008 22:45:54 +0000 Subject: [PATCH 0083/1680] Fix building of Tcl examples/test-suite on Mac OSX git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10683 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 3 +++ Examples/Makefile.in | 6 ++++-- configure.in | 15 ++++++++++++++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index bd94eca51..eb8d81e29 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,9 @@ Version 1.3.37 (in progress) ============================= +2008-07-19: wsfulton + Fix building of Tcl examples/test-suite on Mac OSX reported by Gideon Simpson. + 2008-07-17: wsfulton Fix SF #2019156 Configuring with --without-octave or --without-alllang did not disable octave. diff --git a/Examples/Makefile.in b/Examples/Makefile.in index dd334c225..555aa3e92 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -96,6 +96,8 @@ TK_OPTS = -ltk -ltcl @LIBS@ # Extra Tcl specific dynamic linking options TCL_DLNK = @TCLDYNAMICLINKING@ TCL_SO = @TCL_SO@ +TCLLDSHARED = @TCLLDSHARED@ +TCLCXXSHARED = @TCLCXXSHARED@ # ----------------------------------------------------------- # Build a new version of the tclsh shell @@ -134,7 +136,7 @@ wish_cpp: $(SRCS) tcl: $(SRCS) $(SWIG) -tcl8 $(SWIGOPT) $(TCL_SWIGOPTS) $(INTERFACE) $(CC) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) $(TCL_INCLUDE) - $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(TCL_DLNK) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(TCL_SO) + $(TCLLDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(TCL_DLNK) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(TCL_SO) # ----------------------------------------------------------- # Build a Tcl7.5 dynamic loadable module for C++ @@ -143,7 +145,7 @@ tcl: $(SRCS) tcl_cpp: $(SRCS) $(SWIG) -tcl8 -c++ $(SWIGOPT) $(TCL_SWIGOPTS) $(INTERFACE) $(CXX) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(TCL_INCLUDE) - $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(TCL_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(TCL_SO) + $(TCLCXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(TCL_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(TCL_SO) # ----------------------------------------------------------------- # Cleaning the Tcl examples diff --git a/configure.in b/configure.in index 4f9d37b26..85208368a 100644 --- a/configure.in +++ b/configure.in @@ -533,14 +533,27 @@ fi # Cygwin (Windows) needs the library for dynamic linking case $host in *-*-cygwin* | *-*-mingw*) TCLDYNAMICLINKING="$TCLLIB";; -*-*-darwin*) TCLDYNAMICLINKING="-dynamiclib -flat_namespace -undefined suppress";; *)TCLDYNAMICLINKING="";; esac + +case $host in +*-*-darwin*) + TCLLDSHARED='$(CC) -dynamiclib -undefined suppress -flat_namespace' + TCLCXXSHARED='$(CXX) -dynamiclib -undefined suppress -flat_namespace' + ;; +*) + TCLLDSHARED='$(LDSHARED)' + TCLCXXSHARED='$(CXXSHARED)' + ;; +esac + fi AC_SUBST(TCLINCLUDE) AC_SUBST(TCLLIB) AC_SUBST(TCLDYNAMICLINKING) +AC_SUBST(TCLLDSHARED) +AC_SUBST(TCLCXXSHARED) #---------------------------------------------------------------- # Look for Python From 2ceff37eb250f64201eb2503223ce6ee70620150 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Sun, 27 Jul 2008 12:51:16 +0000 Subject: [PATCH 0084/1680] Fix "can can" typo in docs (SF#2026756) git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10714 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/SWIG.html | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html index c22d81c07..c1ffcff60 100644 --- a/Doc/Manual/SWIG.html +++ b/Doc/Manual/SWIG.html @@ -53,7 +53,7 @@

    • Character strings and structures
    • Array members
    • Structure data members -
    • C constructors and destructors +
    • C constructors and destructors
    • Adding member functions to C structures
    • Nested structures
    • Other things to note about structure wrapping @@ -224,7 +224,7 @@ The C/C++ output file created by SWIG often contains everything that is needed to construct a extension module for the target scripting language. SWIG is not a stub compiler nor is it usually necessary to edit the output file (and if you look at the output, -you probably won't want to). To build the final extension module, the +you probably won't want to). To build the final extension module, the SWIG output file is compiled and linked with the rest of your C/C++ program to create a shared library.

      @@ -232,7 +232,7 @@ program to create a shared library.

      Many target languages will also generate proxy class files in the target language. The default output directory for these language -specific files is the same directory as the generated C/C++ file. This can +specific files is the same directory as the generated C/C++ file. This can be modified using the -outdir option. For example:

      @@ -2219,13 +2219,13 @@ void Foo_w_set(FOO *f, WORD value) {

      -Compatibility Note: SWIG-1.3.11 and earlier releases transformed all non-primitive member datatypes -to pointers. Starting in SWIG-1.3.12, this transformation only occurs if a datatype is known to be a structure, -class, or union. This is unlikely to break existing code. However, if you need to tell SWIG that an undeclared +Compatibility Note: SWIG-1.3.11 and earlier releases transformed all non-primitive member datatypes +to pointers. Starting in SWIG-1.3.12, this transformation only occurs if a datatype is known to be a structure, +class, or union. This is unlikely to break existing code. However, if you need to tell SWIG that an undeclared datatype is really a struct, simply use a forward struct declaration such as "struct Foo;".

      -

      5.5.5 C constructors and destructors

      +

      5.5.5 C constructors and destructors

      @@ -2282,7 +2282,7 @@ struct Bar { // Default constructor generated. Since ignoring the implicit or default destructors most of the times produce memory leaks, SWIG will always try to generate them. If needed, however, you can selectively disable the generation of the -default/implicit destructor by using %nodefaultdtor +default/implicit destructor by using %nodefaultdtor

      From 6870f7a6233481f26ddca8fbeb0af6aab0dc6123 Mon Sep 17 00:00:00 2001 From: John Lenz Date: Sat, 2 Aug 2008 08:28:02 +0000 Subject: [PATCH 0085/1680] Commit patch 2019314 git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10726 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 5 +++ Lib/allegrocl/allegrocl.swg | 80 +++++++++++++++++++++--------------- Lib/chicken/chicken.swg | 1 + Source/Modules/allegrocl.cxx | 9 ++-- 4 files changed, 58 insertions(+), 37 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index eb8d81e29..56a385d57 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,11 @@ Version 1.3.37 (in progress) ============================= +2008-08-02: wuzzeb + [Chicken,Allegro] Commit Patch 2019314 + Fixes a build error in chicken, and several build errors and other errors + in Allegro CL + 2008-07-19: wsfulton Fix building of Tcl examples/test-suite on Mac OSX reported by Gideon Simpson. diff --git a/Lib/allegrocl/allegrocl.swg b/Lib/allegrocl/allegrocl.swg index 0ae8ed76c..8132e4628 100644 --- a/Lib/allegrocl/allegrocl.swg +++ b/Lib/allegrocl/allegrocl.swg @@ -296,15 +296,30 @@ $body)" sym)))) (cl::defun full-name (id type arity class) - (cl::case type - (:getter (cl::format nil "~@[~A_~]~A" class id)) - (:constructor (cl::format nil "new_~A~@[~A~]" id arity)) - (:destructor (cl::format nil "delete_~A" id)) - (:type (cl::format nil "ff_~A" id)) - (:slot id) - (:ff-operator (cl::format nil "ffi_~A" id)) - (otherwise (cl::format nil "~@[~A_~]~A~@[~A~]" - class id arity)))) + ; We need some kind of a hack here to handle template classes + ; and other synonym types right. We need the original name. + (let*( (sym (read-symbol-from-string + (if (eq *swig-identifier-converter* 'identifier-convert-lispify) + (string-lispify id) + id))) + (sym-class (find-class sym nil)) + (id (cond ( (not sym-class) + id ) + ( (and sym-class + (not (eq (class-name sym-class) + sym))) + (class-name sym-class) ) + ( t + id ))) ) + (cl::case type + (:getter (cl::format nil "~@[~A_~]~A" class id)) + (:constructor (cl::format nil "new_~A~@[~A~]" id arity)) + (:destructor (cl::format nil "delete_~A" id)) + (:type (cl::format nil "ff_~A" id)) + (:slot id) + (:ff-operator (cl::format nil "ffi_~A" id)) + (otherwise (cl::format nil "~@[~A_~]~A~@[~A~]" + class id arity))))) (cl::defun identifier-convert-null (id &key type class arity) (cl::if (cl::eq type :setter) @@ -312,6 +327,27 @@ $body)" id :type :getter :class class :arity arity)) (read-symbol-from-string (full-name id type arity class)))) +(cl::defun string-lispify (str) + (cl::let ( (cname (excl::replace-regexp str "_" "-")) + (lastcase :other) + newcase char res ) + (cl::dotimes (n (cl::length cname)) + (cl::setf char (cl::schar cname n)) + (excl::if* (cl::alpha-char-p char) + then + (cl::setf newcase (cl::if (cl::upper-case-p char) :upper :lower)) + (cl::when (cl::and (cl::eq lastcase :lower) + (cl::eq newcase :upper)) + ;; case change... add a dash + (cl::push #\- res) + (cl::setf newcase :other)) + (cl::push (cl::char-downcase char) res) + (cl::setf lastcase newcase) + else + (cl::push char res) + (cl::setf lastcase :other))) + (cl::coerce (cl::nreverse res) 'string))) + (cl::defun identifier-convert-lispify (cname &key type class arity) (cl::assert (cl::stringp cname)) (cl::when (cl::eq type :setter) @@ -321,31 +357,7 @@ $body)" (cl::setq cname (full-name cname type arity class)) (cl::if (cl::eq type :constant) (cl::setf cname (cl::format nil "*~A*" cname))) - (cl::setf cname (excl::replace-regexp cname "_" "-")) - (cl::let ((lastcase :other) - newcase char res) - (cl::dotimes (n (cl::length cname)) - (cl::setf char (cl::schar cname n)) - (excl::if* (cl::alpha-char-p char) - then - (cl::setf newcase (cl::if (cl::upper-case-p char) :upper :lower)) - - (cl::when (cl::or (cl::and (cl::eq lastcase :upper) - (cl::eq newcase :lower)) - (cl::and (cl::eq lastcase :lower) - (cl::eq newcase :upper))) - ;; case change... add a dash - (cl::push #\- res) - (cl::setf newcase :other)) - - (cl::push (cl::char-downcase char) res) - - (cl::setf lastcase newcase) - - else - (cl::push char res) - (cl::setf lastcase :other))) - (read-symbol-from-string (cl::coerce (cl::nreverse res) 'string)))) + (read-symbol-from-string (string-lispify cname))) (cl::defun id-convert-and-export (name &rest kwargs) (cl::multiple-value-bind (symbol package) diff --git a/Lib/chicken/chicken.swg b/Lib/chicken/chicken.swg index d8b71874e..a8d1b5a57 100644 --- a/Lib/chicken/chicken.swg +++ b/Lib/chicken/chicken.swg @@ -10,6 +10,7 @@ /* chicken.h has to appear first. */ %insert(runtime) %{ +#include #include %} diff --git a/Source/Modules/allegrocl.cxx b/Source/Modules/allegrocl.cxx index c1d271c57..217c89b1f 100644 --- a/Source/Modules/allegrocl.cxx +++ b/Source/Modules/allegrocl.cxx @@ -1084,7 +1084,8 @@ void emit_synonym(Node *synonym) { of_ltype = lookup_defined_foreign_ltype(of_name); // Printf(f_clhead,";; from emit-synonym\n"); - Printf(f_clhead, "(swig-def-synonym-type %s\n %s\n %s)\n", syn_ltype, of_ltype, syn_type); + if( of_ltype ) + Printf(f_clhead, "(swig-def-synonym-type %s\n %s\n %s)\n", syn_ltype, of_ltype, syn_type); Delete(synonym_ns); Delete(of_ns_list); @@ -1521,6 +1522,8 @@ void ALLEGROCL::main(int argc, char *argv[]) { } + Preprocessor_define("SWIGALLEGROCL 1", 0); + allow_overloading(); } @@ -1531,7 +1534,7 @@ int ALLEGROCL::top(Node *n) { swig_package = unique_swig_package ? NewStringf("swig.%s", module_name) : NewString("swig"); - Printf(cl_filename, "%s%s.cl", SWIG_output_directory(), Swig_file_basename(Getattr(n,"infile"))); + Printf(cl_filename, "%s%s.cl", SWIG_output_directory(), module_name); f_cl = NewFile(cl_filename, "w"); if (!f_cl) { @@ -2628,7 +2631,7 @@ int ALLEGROCL::functionWrapper(Node *n) { String *actioncode = emit_action(n); String *tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode); - if (tm) { + if (!is_void_return && tm) { Replaceall(tm, "$result", "lresult"); Printf(f->code, "%s\n", tm); Printf(f->code, " return lresult;\n"); From adf1e5373d4dc1c1ef8d0505836901107905f935 Mon Sep 17 00:00:00 2001 From: John Lenz Date: Sat, 2 Aug 2008 08:49:43 +0000 Subject: [PATCH 0086/1680] add assert.h to fix chicken build of external runtime (ext_test testsuite) git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10727 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/chicken/chickenrun.swg | 1 + 1 file changed, 1 insertion(+) diff --git a/Lib/chicken/chickenrun.swg b/Lib/chicken/chickenrun.swg index bd7242407..8703ea65a 100644 --- a/Lib/chicken/chickenrun.swg +++ b/Lib/chicken/chickenrun.swg @@ -7,6 +7,7 @@ * ----------------------------------------------------------------------------- */ #include +#include #include #include #include From b9a88dec5a94dca53ca5bd7f765c0b180cf45300 Mon Sep 17 00:00:00 2001 From: Robert Stone Date: Thu, 7 Aug 2008 06:28:13 +0000 Subject: [PATCH 0087/1680] hoist globals to local scope where trival. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10738 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/perl5.cxx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/Modules/perl5.cxx b/Source/Modules/perl5.cxx index 6e706fc8d..0153545ed 100644 --- a/Source/Modules/perl5.cxx +++ b/Source/Modules/perl5.cxx @@ -100,8 +100,6 @@ static int have_constructor = 0; static int have_destructor = 0; static int have_data_members = 0; static String *class_name = 0; /* Name of the class (what Perl thinks it is) */ -static String *real_classname = 0; /* Real name of C/C++ class */ -static String *fullclassname = 0; static String *pcode = 0; /* Perl code associated with each class */ /* static String *blessedmembers = 0; *//* Member data associated with each class */ @@ -1186,6 +1184,8 @@ public: * ------------------------------------------------------------ */ virtual int classHandler(Node *n) { + String *name = 0; /* Real name of C/C++ class */ + String *fullclassname = 0; if (blessed) { have_constructor = 0; @@ -1205,7 +1205,7 @@ public: } else { fullclassname = NewString(class_name); } - real_classname = Getattr(n, "name"); + name = Getattr(n, "name"); pcode = NewString(""); // blessedmembers = NewString(""); } @@ -1217,7 +1217,7 @@ public: /* Finish the rest of the class */ if (blessed) { /* Generate a client-data entry */ - SwigType *ct = NewStringf("p.%s", real_classname); + SwigType *ct = NewStringf("p.%s", name); Printv(f_init, "SWIG_TypeClientData(SWIGTYPE", SwigType_manglestr(ct), ", (void*) \"", fullclassname, "\");\n", NIL); SwigType_remember(ct); Delete(ct); From 2728e5a606d0f01ea819ac878813602b79634ec6 Mon Sep 17 00:00:00 2001 From: Robert Stone Date: Fri, 8 Aug 2008 03:10:55 +0000 Subject: [PATCH 0088/1680] initial steps to clean up perl5 class methods (primarily constructors). git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10743 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/perl5/imports_runme.pl | 2 +- Source/Modules/perl5.cxx | 67 ++++++++++++++++------ 2 files changed, 52 insertions(+), 17 deletions(-) diff --git a/Examples/test-suite/perl5/imports_runme.pl b/Examples/test-suite/perl5/imports_runme.pl index fd730fedf..13ca08a1c 100644 --- a/Examples/test-suite/perl5/imports_runme.pl +++ b/Examples/test-suite/perl5/imports_runme.pl @@ -1,5 +1,5 @@ use imports_b; use imports_a; -$x = imports_bc::new_B(); +$x = imports_b::B->new(); imports_ac::A_hello($x); diff --git a/Source/Modules/perl5.cxx b/Source/Modules/perl5.cxx index 0153545ed..1484a62f9 100644 --- a/Source/Modules/perl5.cxx +++ b/Source/Modules/perl5.cxx @@ -556,6 +556,7 @@ public: String *iname = Getattr(n, "sym:name"); SwigType *d = Getattr(n, "type"); ParmList *l = Getattr(n, "parms"); + ParmList *outer = Getattr(n, "perl5:implicits"); String *overname = 0; Parm *p; @@ -565,7 +566,7 @@ public: String *tm; String *cleanup, *outarg; int num_saved = 0; - int num_arguments, num_required; + int num_arguments, num_required, num_implicits; int varargs = 0; if (Getattr(n, "sym:overloaded")) { @@ -587,6 +588,19 @@ public: Printv(f->def, "XS(", wname, ") {\n", "{\n", /* scope to destroy C++ objects before croaking */ NIL); + num_implicits = 0; + if(outer) { + Parm *tmp = outer; + Parm *tail; + while(tmp) { + tail = tmp; + num_implicits++; + tmp = nextSibling(tmp); + } + /* link the outer with inner parms */ + set_nextSibling(tail, l); + } + emit_parameter_variables(l, f); emit_attach_parmmaps(l, f); Setattr(n, "wrap:parms", l); @@ -599,13 +613,28 @@ public: /* Check the number of arguments */ if (!varargs) { - Printf(f->code, " if ((items < %d) || (items > %d)) {\n", num_required, num_arguments); + Printf(f->code, " if ((items < %d) || (items > %d)) {\n", + num_required + num_implicits, num_arguments + num_implicits); } else { - Printf(f->code, " if (items < %d) {\n", num_required); + Printf(f->code, " if (items < %d) {\n", + num_required + num_implicits); } - Printf(f->code, " SWIG_croak(\"Usage: %s\");\n", usage_func(Char(iname), d, l)); + Printf(f->code, " SWIG_croak(\"Usage: %s\");\n", usage_func(Char(iname), d, outer)); Printf(f->code, "}\n"); + if (num_implicits) { + /* TODO: support implicits of types other than SVs */ + Parm *p = outer; + for(i = 0; i < num_implicits; i++) { + String *pname = Getattr(p, "name"); + String *pinit = SwigType_str(Getattr(p, "type"), pname); + Wrapper_add_local(f, pname, pinit); + Delete(pinit); + Printf(f->code, "%s = ST(%d);\n", pname, i++); + p = nextSibling(p); + } + Printf(f->code, "ax += %d;\n", num_implicits); + } /* Write code to extract parameters. */ i = 0; for (i = 0, p = l; i < num_arguments; i++) { @@ -795,6 +824,10 @@ public: Printv(df->def, "XS(", dname, ") {\n", NIL); Wrapper_add_local(df, "dXSARGS", "dXSARGS"); + if(num_implicits) { + Printf(df->code, "ax += %d;\n", num_implicits); + Printf(df->code, "items -= %d;\n", num_implicits); + } Printv(df->code, dispatch, "\n", NIL); Printf(df->code, "croak(\"No matching function for overloaded '%s'\");\n", iname); Printf(df->code, "XSRETURN(0);\n"); @@ -1041,13 +1074,14 @@ public: Clear(temp); Printf(temp, "%s(", iname); - /* Now go through and print parameters */ - p = l; i = 0; + /* Now go through and print normal parameters */ + p = l; while (p != 0) { SwigType *pt = Getattr(p, "type"); String *pn = Getattr(p, "name"); if (!checkAttribute(p,"tmap:in:numinputs","0")) { + if(i > 0) Append(temp, ","); /* If parameter has been named, use that. Otherwise, just print a type */ if (SwigType_type(pt) != T_VOID) { if (Len(pn) > 0) { @@ -1057,16 +1091,8 @@ public: } } i++; - p = nextSibling(p); - if (p) - if (!checkAttribute(p,"tmap:in:numinputs","0")) - Putc(',', temp); - } else { - p = nextSibling(p); - if (p) - if ((i > 0) && (!checkAttribute(p,"tmap:in:numinputs","0"))) - Putc(',', temp); } + p = nextSibling(p); } Printf(temp, ");"); return Char(temp); @@ -1490,6 +1516,15 @@ public: String *symname = Getattr(n, "sym:name"); + { + String *type = NewString("SV"); + SwigType_add_pointer(type); + Parm *p = NewParm(type, "proto"); + Delete(type); + Setattr(n, "perl5:implicits", p); + Delete(p); + } + member_func = 1; Language::constructorHandler(n); @@ -1510,7 +1545,7 @@ public: } Printv(pcode, - tab4, "my $pkg = shift;\n", + tab4, "my $pkg = $_[0];\n", tab4, "my $self = ", cmodule, "::", Swig_name_construct(symname), "(@_);\n", tab4, "bless $self, $pkg if defined($self);\n", "}\n\n", NIL); have_constructor = 1; From 93652cdc70164e147f421aaee8692bc559413cb2 Mon Sep 17 00:00:00 2001 From: Robert Stone Date: Sat, 9 Aug 2008 04:08:26 +0000 Subject: [PATCH 0089/1680] moves perl space constructor fixups into wrapper code. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10747 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/perl5.cxx | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/Source/Modules/perl5.cxx b/Source/Modules/perl5.cxx index 1484a62f9..e68b2fe5e 100644 --- a/Source/Modules/perl5.cxx +++ b/Source/Modules/perl5.cxx @@ -589,7 +589,7 @@ public: NIL); num_implicits = 0; - if(outer) { + if (outer) { Parm *tmp = outer; Parm *tail; while(tmp) { @@ -633,7 +633,8 @@ public: Printf(f->code, "%s = ST(%d);\n", pname, i++); p = nextSibling(p); } - Printf(f->code, "ax += %d;\n", num_implicits); + if (l) + Printf(f->code, "ax += %d;\n", num_implicits); } /* Write code to extract parameters. */ i = 0; @@ -747,6 +748,9 @@ public: Wrapper_add_localv(f, "_saved", "SV *", temp, NIL); } + if (num_implicits && l) + Printf(f->code, "ax -= %d;\n", num_implicits); + /* Now write code to make the function call */ Swig_director_emit_dynamic_cast(n, f); @@ -793,6 +797,11 @@ public: Printf(f->code, "%s\n", tm); } + if (blessed && Equal(nodeType(n), "constructor")) { + Append(f->code, + "if (SvOK(ST(0))) sv_bless(ST(0), gv_stashsv(proto, 0));\n"); + } + Printv(f->code, "XSRETURN(argvi);\n", "fail:\n", cleanup, "SWIG_croak_null();\n" "}\n" "}\n", NIL); /* Add the dXSARGS last */ @@ -824,7 +833,7 @@ public: Printv(df->def, "XS(", dname, ") {\n", NIL); Wrapper_add_local(df, "dXSARGS", "dXSARGS"); - if(num_implicits) { + if (num_implicits) { Printf(df->code, "ax += %d;\n", num_implicits); Printf(df->code, "items -= %d;\n", num_implicits); } @@ -1081,7 +1090,7 @@ public: SwigType *pt = Getattr(p, "type"); String *pn = Getattr(p, "name"); if (!checkAttribute(p,"tmap:in:numinputs","0")) { - if(i > 0) Append(temp, ","); + if (i > 0) Append(temp, ","); /* If parameter has been named, use that. Otherwise, just print a type */ if (SwigType_type(pt) != T_VOID) { if (Len(pn) > 0) { @@ -1536,17 +1545,16 @@ public: Delete(plaction); Printv(pcode, plcode, NIL); } else { - if ((Cmp(symname, class_name) == 0)) { - /* Emit a blessed constructor */ - Printf(pcode, "sub new {\n"); - } else { - /* Constructor doesn't match classname so we'll just use the normal name */ - Printv(pcode, "sub ", Swig_name_construct(symname), " () {\n", NIL); - } - - Printv(pcode, - tab4, "my $pkg = $_[0];\n", - tab4, "my $self = ", cmodule, "::", Swig_name_construct(symname), "(@_);\n", tab4, "bless $self, $pkg if defined($self);\n", "}\n\n", NIL); + /* Emit a blessed constructor */ + String *cname = Swig_name_construct(symname); + char *pname; + /* override Class->Class to be Class->new */ + if (Cmp(symname, class_name) == 0) + pname = "new"; + else + pname = Char(cname); + Printf(pcode, "*%s = *%s::%s;\n", pname, cmodule, cname); + Delete(cname); have_constructor = 1; } From 3ecb83fc0b55874fd420888e79e6f203cf966114 Mon Sep 17 00:00:00 2001 From: Robert Stone Date: Sat, 9 Aug 2008 23:57:55 +0000 Subject: [PATCH 0090/1680] usage_func() fix + CHANGES.current entry to explain my past few commits. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10749 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 3 +++ Source/Modules/perl5.cxx | 7 +++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 56a385d57..7d1b70ca7 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,9 @@ Version 1.3.37 (in progress) ============================= +2008-08-09: talby + [Perl5] Unify Perl and C portions of constructor wrappers. + 2008-08-02: wuzzeb [Chicken,Allegro] Commit Patch 2019314 Fixes a build error in chicken, and several build errors and other errors diff --git a/Source/Modules/perl5.cxx b/Source/Modules/perl5.cxx index e68b2fe5e..2e714efe5 100644 --- a/Source/Modules/perl5.cxx +++ b/Source/Modules/perl5.cxx @@ -619,7 +619,7 @@ public: Printf(f->code, " if (items < %d) {\n", num_required + num_implicits); } - Printf(f->code, " SWIG_croak(\"Usage: %s\");\n", usage_func(Char(iname), d, outer)); + Printf(f->code, " SWIG_croak(\"Usage: %s\");\n", usage_func(Char(iname), d, outer, l)); Printf(f->code, "}\n"); if (num_implicits) { @@ -1073,7 +1073,7 @@ public: /* ------------------------------------------------------------ * usage_func() * ------------------------------------------------------------ */ - char *usage_func(char *iname, SwigType *, ParmList *l) { + char *usage_func(char *iname, SwigType *, ParmList *il, ParmList *l) { static String *temp = 0; Parm *p; int i; @@ -1084,6 +1084,9 @@ public: Printf(temp, "%s(", iname); i = 0; + /* Print implicit parameters */ + for(p = il; p; p = nextSibling(p)) + Printv(temp, (i > 0 ? "," : ""), Getattr(p, "name"), NIL); /* Now go through and print normal parameters */ p = l; while (p != 0) { From 2ee3d98d79e19ac513eaf8f52cb486ea6cad8a73 Mon Sep 17 00:00:00 2001 From: Robert Stone Date: Tue, 19 Aug 2008 07:09:29 +0000 Subject: [PATCH 0091/1680] rollback 10737:10749, this work is better left on a branch until it is in support a significant feature enhancement. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10794 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 3 - Examples/test-suite/perl5/imports_runme.pl | 2 +- Source/Modules/perl5.cxx | 108 ++++++--------------- 3 files changed, 32 insertions(+), 81 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 7d1b70ca7..56a385d57 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,9 +1,6 @@ Version 1.3.37 (in progress) ============================= -2008-08-09: talby - [Perl5] Unify Perl and C portions of constructor wrappers. - 2008-08-02: wuzzeb [Chicken,Allegro] Commit Patch 2019314 Fixes a build error in chicken, and several build errors and other errors diff --git a/Examples/test-suite/perl5/imports_runme.pl b/Examples/test-suite/perl5/imports_runme.pl index 13ca08a1c..fd730fedf 100644 --- a/Examples/test-suite/perl5/imports_runme.pl +++ b/Examples/test-suite/perl5/imports_runme.pl @@ -1,5 +1,5 @@ use imports_b; use imports_a; -$x = imports_b::B->new(); +$x = imports_bc::new_B(); imports_ac::A_hello($x); diff --git a/Source/Modules/perl5.cxx b/Source/Modules/perl5.cxx index 2e714efe5..6e706fc8d 100644 --- a/Source/Modules/perl5.cxx +++ b/Source/Modules/perl5.cxx @@ -100,6 +100,8 @@ static int have_constructor = 0; static int have_destructor = 0; static int have_data_members = 0; static String *class_name = 0; /* Name of the class (what Perl thinks it is) */ +static String *real_classname = 0; /* Real name of C/C++ class */ +static String *fullclassname = 0; static String *pcode = 0; /* Perl code associated with each class */ /* static String *blessedmembers = 0; *//* Member data associated with each class */ @@ -556,7 +558,6 @@ public: String *iname = Getattr(n, "sym:name"); SwigType *d = Getattr(n, "type"); ParmList *l = Getattr(n, "parms"); - ParmList *outer = Getattr(n, "perl5:implicits"); String *overname = 0; Parm *p; @@ -566,7 +567,7 @@ public: String *tm; String *cleanup, *outarg; int num_saved = 0; - int num_arguments, num_required, num_implicits; + int num_arguments, num_required; int varargs = 0; if (Getattr(n, "sym:overloaded")) { @@ -588,19 +589,6 @@ public: Printv(f->def, "XS(", wname, ") {\n", "{\n", /* scope to destroy C++ objects before croaking */ NIL); - num_implicits = 0; - if (outer) { - Parm *tmp = outer; - Parm *tail; - while(tmp) { - tail = tmp; - num_implicits++; - tmp = nextSibling(tmp); - } - /* link the outer with inner parms */ - set_nextSibling(tail, l); - } - emit_parameter_variables(l, f); emit_attach_parmmaps(l, f); Setattr(n, "wrap:parms", l); @@ -613,29 +601,13 @@ public: /* Check the number of arguments */ if (!varargs) { - Printf(f->code, " if ((items < %d) || (items > %d)) {\n", - num_required + num_implicits, num_arguments + num_implicits); + Printf(f->code, " if ((items < %d) || (items > %d)) {\n", num_required, num_arguments); } else { - Printf(f->code, " if (items < %d) {\n", - num_required + num_implicits); + Printf(f->code, " if (items < %d) {\n", num_required); } - Printf(f->code, " SWIG_croak(\"Usage: %s\");\n", usage_func(Char(iname), d, outer, l)); + Printf(f->code, " SWIG_croak(\"Usage: %s\");\n", usage_func(Char(iname), d, l)); Printf(f->code, "}\n"); - if (num_implicits) { - /* TODO: support implicits of types other than SVs */ - Parm *p = outer; - for(i = 0; i < num_implicits; i++) { - String *pname = Getattr(p, "name"); - String *pinit = SwigType_str(Getattr(p, "type"), pname); - Wrapper_add_local(f, pname, pinit); - Delete(pinit); - Printf(f->code, "%s = ST(%d);\n", pname, i++); - p = nextSibling(p); - } - if (l) - Printf(f->code, "ax += %d;\n", num_implicits); - } /* Write code to extract parameters. */ i = 0; for (i = 0, p = l; i < num_arguments; i++) { @@ -748,9 +720,6 @@ public: Wrapper_add_localv(f, "_saved", "SV *", temp, NIL); } - if (num_implicits && l) - Printf(f->code, "ax -= %d;\n", num_implicits); - /* Now write code to make the function call */ Swig_director_emit_dynamic_cast(n, f); @@ -797,11 +766,6 @@ public: Printf(f->code, "%s\n", tm); } - if (blessed && Equal(nodeType(n), "constructor")) { - Append(f->code, - "if (SvOK(ST(0))) sv_bless(ST(0), gv_stashsv(proto, 0));\n"); - } - Printv(f->code, "XSRETURN(argvi);\n", "fail:\n", cleanup, "SWIG_croak_null();\n" "}\n" "}\n", NIL); /* Add the dXSARGS last */ @@ -833,10 +797,6 @@ public: Printv(df->def, "XS(", dname, ") {\n", NIL); Wrapper_add_local(df, "dXSARGS", "dXSARGS"); - if (num_implicits) { - Printf(df->code, "ax += %d;\n", num_implicits); - Printf(df->code, "items -= %d;\n", num_implicits); - } Printv(df->code, dispatch, "\n", NIL); Printf(df->code, "croak(\"No matching function for overloaded '%s'\");\n", iname); Printf(df->code, "XSRETURN(0);\n"); @@ -1073,7 +1033,7 @@ public: /* ------------------------------------------------------------ * usage_func() * ------------------------------------------------------------ */ - char *usage_func(char *iname, SwigType *, ParmList *il, ParmList *l) { + char *usage_func(char *iname, SwigType *, ParmList *l) { static String *temp = 0; Parm *p; int i; @@ -1083,17 +1043,13 @@ public: Clear(temp); Printf(temp, "%s(", iname); - i = 0; - /* Print implicit parameters */ - for(p = il; p; p = nextSibling(p)) - Printv(temp, (i > 0 ? "," : ""), Getattr(p, "name"), NIL); - /* Now go through and print normal parameters */ + /* Now go through and print parameters */ p = l; + i = 0; while (p != 0) { SwigType *pt = Getattr(p, "type"); String *pn = Getattr(p, "name"); if (!checkAttribute(p,"tmap:in:numinputs","0")) { - if (i > 0) Append(temp, ","); /* If parameter has been named, use that. Otherwise, just print a type */ if (SwigType_type(pt) != T_VOID) { if (Len(pn) > 0) { @@ -1103,8 +1059,16 @@ public: } } i++; + p = nextSibling(p); + if (p) + if (!checkAttribute(p,"tmap:in:numinputs","0")) + Putc(',', temp); + } else { + p = nextSibling(p); + if (p) + if ((i > 0) && (!checkAttribute(p,"tmap:in:numinputs","0"))) + Putc(',', temp); } - p = nextSibling(p); } Printf(temp, ");"); return Char(temp); @@ -1222,8 +1186,6 @@ public: * ------------------------------------------------------------ */ virtual int classHandler(Node *n) { - String *name = 0; /* Real name of C/C++ class */ - String *fullclassname = 0; if (blessed) { have_constructor = 0; @@ -1243,7 +1205,7 @@ public: } else { fullclassname = NewString(class_name); } - name = Getattr(n, "name"); + real_classname = Getattr(n, "name"); pcode = NewString(""); // blessedmembers = NewString(""); } @@ -1255,7 +1217,7 @@ public: /* Finish the rest of the class */ if (blessed) { /* Generate a client-data entry */ - SwigType *ct = NewStringf("p.%s", name); + SwigType *ct = NewStringf("p.%s", real_classname); Printv(f_init, "SWIG_TypeClientData(SWIGTYPE", SwigType_manglestr(ct), ", (void*) \"", fullclassname, "\");\n", NIL); SwigType_remember(ct); Delete(ct); @@ -1528,15 +1490,6 @@ public: String *symname = Getattr(n, "sym:name"); - { - String *type = NewString("SV"); - SwigType_add_pointer(type); - Parm *p = NewParm(type, "proto"); - Delete(type); - Setattr(n, "perl5:implicits", p); - Delete(p); - } - member_func = 1; Language::constructorHandler(n); @@ -1548,16 +1501,17 @@ public: Delete(plaction); Printv(pcode, plcode, NIL); } else { - /* Emit a blessed constructor */ - String *cname = Swig_name_construct(symname); - char *pname; - /* override Class->Class to be Class->new */ - if (Cmp(symname, class_name) == 0) - pname = "new"; - else - pname = Char(cname); - Printf(pcode, "*%s = *%s::%s;\n", pname, cmodule, cname); - Delete(cname); + if ((Cmp(symname, class_name) == 0)) { + /* Emit a blessed constructor */ + Printf(pcode, "sub new {\n"); + } else { + /* Constructor doesn't match classname so we'll just use the normal name */ + Printv(pcode, "sub ", Swig_name_construct(symname), " () {\n", NIL); + } + + Printv(pcode, + tab4, "my $pkg = shift;\n", + tab4, "my $self = ", cmodule, "::", Swig_name_construct(symname), "(@_);\n", tab4, "bless $self, $pkg if defined($self);\n", "}\n\n", NIL); have_constructor = 1; } From 553135885c408d8d5a5bb01f8276e553e3b0f0e6 Mon Sep 17 00:00:00 2001 From: Joseph Wang Date: Sun, 31 Aug 2008 16:07:43 +0000 Subject: [PATCH 0092/1680] change Rf_warning to warning. Looks like a typo git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10801 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/r/r.swg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/r/r.swg b/Lib/r/r.swg index 0ab7e11a0..0a4d0c36e 100644 --- a/Lib/r/r.swg +++ b/Lib/r/r.swg @@ -79,7 +79,7 @@ SWIG_InitializeModule(0); %typemap(scheck) int %{ if(length($input) > 1) { - Rf_warning("using only the first element of $input") + warning("using only the first element of $input") } %} From ad2374ab8dfd0b7714788854c7d0dba0d49c5e12 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 1 Sep 2008 19:59:23 +0000 Subject: [PATCH 0093/1680] Fix ruby detection problem breaking configure git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10802 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- configure.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.in b/configure.in index 85208368a..77ff25aee 100644 --- a/configure.in +++ b/configure.in @@ -1129,7 +1129,7 @@ fi AC_MSG_CHECKING(for Ruby header files) if test -n "$RUBY"; then RUBYDIR=`($RUBY -rmkmf -e 'print Config::CONFIG[["archdir"]] || $archdir') 2>/dev/null` - if test "$RUBYDIR" != ""; then + if test x"$RUBYDIR" != x""; then dirs="$RUBYDIR" RUBYINCLUDE=none for i in $dirs; do From 86913e26e3844e1e26dac8bb5412e65eafeba53d Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 1 Sep 2008 20:00:28 +0000 Subject: [PATCH 0094/1680] Fix another perl global namespace pollution git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10803 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/perl5/noembed.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Lib/perl5/noembed.h b/Lib/perl5/noembed.h index a29de61f5..8d3dc7338 100644 --- a/Lib/perl5/noembed.h +++ b/Lib/perl5/noembed.h @@ -91,3 +91,7 @@ #ifdef open #undef open #endif +#ifdef readdir + #undef readdir +#endif + From a83eebb3698999e80197e96072a5ad8820cd5c5e Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 1 Sep 2008 20:32:53 +0000 Subject: [PATCH 0095/1680] Fix array bounds checking in C# std::vector wrappers git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10804 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++++ Lib/csharp/std_vector.i | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 56a385d57..bd601bee7 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,10 @@ Version 1.3.37 (in progress) ============================= +2008-09-01: wsfulton + [C#] Correct array bounds checking in std::vector typemaps - Insert and InsertRange + methods. + 2008-08-02: wuzzeb [Chicken,Allegro] Commit Patch 2019314 Fixes a build error in chicken, and several build errors and other errors diff --git a/Lib/csharp/std_vector.i b/Lib/csharp/std_vector.i index a04831f75..2e4d47c00 100755 --- a/Lib/csharp/std_vector.i +++ b/Lib/csharp/std_vector.i @@ -231,14 +231,14 @@ return new std::vector(self->begin()+index, self->begin()+index+count); } void Insert(int index, const value_type& x) throw (std::out_of_range) { - if (index>=0 && index<(int)self->size()+1) + if (index>=0 && index<(int)self->size()) self->insert(self->begin()+index, x); else throw std::out_of_range("index"); } // Takes a deep copy of the elements unlike ArrayList.InsertRange void InsertRange(int index, const std::vector& values) throw (std::out_of_range) { - if (index>=0 && index<(int)self->size()+1) + if (index>=0 && index<(int)self->size()) self->insert(self->begin()+index, values.begin(), values.end()); else throw std::out_of_range("index"); From f396ecc619c9f28dc4f53da3f5d08a9e7868db6f Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 1 Sep 2008 20:34:49 +0000 Subject: [PATCH 0096/1680] fix runtime problem in Ruby std_vector example git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10805 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/ruby/std_vector/runme.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Examples/ruby/std_vector/runme.rb b/Examples/ruby/std_vector/runme.rb index 1529d38c6..851190536 100644 --- a/Examples/ruby/std_vector/runme.rb +++ b/Examples/ruby/std_vector/runme.rb @@ -9,7 +9,7 @@ puts Example::average([1,2,3,4]) # ... or a wrapped std::vector v = Example::IntVector.new(4) -0.upto(v.length-1) { |i| v[i] = i+1 } +0.upto(v.size-1) { |i| v[i] = i+1 } puts Example::average(v) @@ -17,7 +17,7 @@ puts Example::average(v) # Call it with a Ruby array... w = Example::half([1.0, 1.5, 2.0, 2.5, 3.0]) -0.upto(w.length-1) { |i| print w[i],"; " } +0.upto(w.size-1) { |i| print w[i],"; " } puts # ... or a wrapped std::vector @@ -25,12 +25,12 @@ puts v = Example::DoubleVector.new [1,2,3,4].each { |i| v.push(i) } w = Example::half(v) -0.upto(w.length-1) { |i| print w[i],"; " } +0.upto(w.size-1) { |i| print w[i],"; " } puts # now halve a wrapped std::vector in place Example::halve_in_place(v) -0.upto(v.length-1) { |i| print v[i],"; " } +0.upto(v.size-1) { |i| print v[i],"; " } puts From ee2b86e8e175d1f705134757fac076ac0aaffca0 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 1 Sep 2008 20:42:40 +0000 Subject: [PATCH 0097/1680] Fix portability problem using /dev/null git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10806 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/uffi.cxx | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/Source/Modules/uffi.cxx b/Source/Modules/uffi.cxx index 7a94b77bb..5d4affb8c 100644 --- a/Source/Modules/uffi.cxx +++ b/Source/Modules/uffi.cxx @@ -26,7 +26,6 @@ public: }; static File *f_cl = 0; -static File *f_null = 0; static struct { int count; @@ -225,15 +224,7 @@ void UFFI::main(int argc, char *argv[]) { int UFFI::top(Node *n) { String *module = Getattr(n, "name"); String *output_filename = NewString(""); - String *devnull = NewString("/dev/null"); - - f_null = NewFile(devnull, "w+"); - if (!f_null) { - FileErrorDisplay(devnull); - SWIG_exit(EXIT_FAILURE); - } - Delete(devnull); - + File *f_null = NewString(""); Printf(output_filename, "%s%s.cl", SWIG_output_directory(), module); From 907171735fafcf1a4d39b5d8dacb0307411069ee Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 1 Sep 2008 21:46:41 +0000 Subject: [PATCH 0098/1680] patch #2079381 submitted by Boris Smilga - constant exprs put into no-eval context in DEFCENUM git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10807 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++++ Source/Modules/cffi.cxx | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index bd601bee7..4d9310062 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,10 @@ Version 1.3.37 (in progress) ============================= +2008-09-01: wsfulton + [CFFI] Commit patch #2079381 submitted by Boris Smilga - constant exprs put into + no-eval context in DEFCENUM + 2008-09-01: wsfulton [C#] Correct array bounds checking in std::vector typemaps - Insert and InsertRange methods. diff --git a/Source/Modules/cffi.cxx b/Source/Modules/cffi.cxx index 736564d1a..4b3ddac70 100644 --- a/Source/Modules/cffi.cxx +++ b/Source/Modules/cffi.cxx @@ -630,7 +630,7 @@ int CFFI::enumDeclaration(Node *n) { else { String *type = Getattr(c, "type"); String *converted_value = convert_literal(value, type); - Printf(f_cl, "\n\t(%s %s)", slot_name, converted_value); + Printf(f_cl, "\n\t(%s #.%s)", slot_name, converted_value); Delete(converted_value); } Delete(value); From 044895ef6e2c351c57bb8c6b9ccbe4f43b9f47fe Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 2 Sep 2008 20:56:52 +0000 Subject: [PATCH 0099/1680] Add new terminator attribute for the csin typemap for C# git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10808 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 12 ++++ Doc/Manual/CSharp.html | 58 +++++++++++++-- Examples/test-suite/csharp_prepost.i | 101 ++++++++++++++++++++++++++- Source/Modules/csharp.cxx | 48 ++++++++++++- 4 files changed, 210 insertions(+), 9 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 4d9310062..79b0aaec6 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,18 @@ Version 1.3.37 (in progress) ============================= +2008-09-02: wsfulton + [C#] Support for 'using' and 'fixed' blocks in the 'csin' typemap is now + possible through the use of the pre attribute and the new terminator attribute, eg + + %typemap(csin, + pre=" using (CDate temp$csinput = new CDate($csinput)) {", + terminator=" } // terminate temp$csinput using block", + ) const CDate & + "$csclassname.getCPtr(temp$csinput)" + + See CSharp.html for more info. + 2008-09-01: wsfulton [CFFI] Commit patch #2079381 submitted by Boris Smilga - constant exprs put into no-eval context in DEFCENUM diff --git a/Doc/Manual/CSharp.html b/Doc/Manual/CSharp.html index 97cb75409..a712f82f2 100644 --- a/Doc/Manual/CSharp.html +++ b/Doc/Manual/CSharp.html @@ -1567,6 +1567,7 @@ Let's assume the code being wrapped is as follows:
       class CDate {
       public:
      +  CDate();
         CDate(int year, int month, int day);
         int getYear();
         int getMonth();
      @@ -1649,8 +1650,8 @@ The typemaps to achieve this are shown below.
       
       %typemap(cstype) const CDate& "System.DateTime"
       %typemap(csin, 
      -         pre="    CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day);")
      -         const CDate &
      +         pre="    CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day);"
      +        ) const CDate &
                "$csclassname.getCPtr(temp$csinput)"
       
       %typemap(cstype) CDate& "out System.DateTime"
      @@ -1658,7 +1659,8 @@ The typemaps to achieve this are shown below.
                pre="    CDate temp$csinput = new CDate();", 
                post="      $csinput = new System.DateTime(temp$csinput.getYear(),"
                     " temp$csinput.getMonth(), temp$csinput.getDay(), 0, 0, 0);", 
      -         cshin="out $csinput") CDate &
      +         cshin="out $csinput"
      +        ) CDate &
                "$csclassname.getCPtr(temp$csinput)"
       
       
      @@ -1763,7 +1765,8 @@ will be possible with the following CDate * typemaps pre=" CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day);", post=" $csinput = new System.DateTime(temp$csinput.getYear()," " temp$csinput.getMonth(), temp$csinput.getDay(), 0, 0, 0);", - cshin="ref $csinput") CDate * + cshin="ref $csinput" + ) CDate * "$csclassname.getCPtr(temp$csinput)"
      @@ -1788,6 +1791,50 @@ public class example { +

      +The following typemap is the same as the previous but demonstrates how a using block can be used for the temporary variable. +The only change to the previous typemap is the introduction of the 'terminator' attribute to terminate the using block. +The subtractYears method is nearly identical to the above addYears method. +

      + +
      +
      +%typemap(csin,
      +         pre="    using (CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day)) {",
      +         post="      $csinput = new System.DateTime(temp$csinput.getYear(),"
      +              " temp$csinput.getMonth(), temp$csinput.getDay(), 0, 0, 0);", 
      +         terminator="    } // terminate temp$csinput using block",
      +         cshin="ref $csinput"
      +        ) CDate *
      +         "$csclassname.getCPtr(temp$csinput)"
      +
      +void subtractYears(CDate *pDate, int years) {
      +  *pDate = CDate(pDate->getYear() - years, pDate->getMonth(), pDate->getDay());
      +}
      +
      +
      + +

      +The resulting generated code shows the termination of the using block: +

      + +
      +
      +public class example {
      +  public static void subtractYears(ref System.DateTime pDate, int years) {
      +    using (CDate temppDate = new CDate(pDate.Year, pDate.Month, pDate.Day)) {
      +    try {
      +      examplePINVOKE.subtractYears(CDate.getCPtr(temppDate), years);
      +    } finally {
      +      pDate = new System.DateTime(temppDate.getYear(), temppDate.getMonth(), temppDate.getDay(), 0, 0, 0);
      +    }
      +    } // terminate temppDate using block
      +  }
      +  ...
      +}
      +
      +
      +

      17.5.4 A date example demonstrating marshalling of C# properties

      @@ -1827,7 +1874,8 @@ The typemap type required is thus CDate *. Given that the previous sect pre=" CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day);", post=" $csinput = new System.DateTime(temp$csinput.getYear()," " temp$csinput.getMonth(), temp$csinput.getDay(), 0, 0, 0);", - cshin="ref $csinput") CDate * + cshin="ref $csinput" + ) CDate * "$csclassname.getCPtr(temp$csinput)" %typemap(csvarin, excode=SWIGEXCODE2) CDate * %{ diff --git a/Examples/test-suite/csharp_prepost.i b/Examples/test-suite/csharp_prepost.i index 9c2cedc83..0c35c1833 100644 --- a/Examples/test-suite/csharp_prepost.i +++ b/Examples/test-suite/csharp_prepost.i @@ -1,6 +1,6 @@ %module csharp_prepost -// Test the pre, post and cshin attributes for csin typemaps +// Test the pre, post, terminate and cshin attributes for csin typemaps %include "std_vector.i" @@ -88,3 +88,102 @@ public: }; %} + + +// test Date marshalling with pre post and terminate typemap attributes (Documented in CSharp.html) +%typemap(cstype) const CDate& "System.DateTime" +%typemap(csin, + pre=" CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day);" + ) const CDate & + "$csclassname.getCPtr(temp$csinput)" + +%typemap(cstype) CDate& "out System.DateTime" +%typemap(csin, + pre=" CDate temp$csinput = new CDate();", + post=" $csinput = new System.DateTime(temp$csinput.getYear()," + " temp$csinput.getMonth(), temp$csinput.getDay(), 0, 0, 0);", + cshin="out $csinput" + ) CDate & + "$csclassname.getCPtr(temp$csinput)" + + +%inline %{ +class CDate { +public: + CDate(); + CDate(int year, int month, int day); + int getYear(); + int getMonth(); + int getDay(); +private: + int m_year; + int m_month; + int m_day; +}; +struct Action { + int doSomething(const CDate &dateIn, CDate &dateOut); + Action(const CDate &dateIn, CDate& dateOut); +}; +%} + +%{ +Action::Action(const CDate &dateIn, CDate& dateOut) {dateOut = dateIn;} +int Action::doSomething(const CDate &dateIn, CDate &dateOut) { dateOut = dateIn; return 0; } +CDate::CDate() : m_year(0), m_month(0), m_day(0) {} +CDate::CDate(int year, int month, int day) : m_year(year), m_month(month), m_day(day) {} +int CDate::getYear() { return m_year; } +int CDate::getMonth() { return m_month; } +int CDate::getDay() { return m_day; } +%} + +%typemap(cstype, out="System.DateTime") CDate * "ref System.DateTime" + +%typemap(csin, + pre=" CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day);", + post=" $csinput = new System.DateTime(temp$csinput.getYear()," + " temp$csinput.getMonth(), temp$csinput.getDay(), 0, 0, 0);", + cshin="ref $csinput" + ) CDate * + "$csclassname.getCPtr(temp$csinput)" + +%inline %{ +void addYears(CDate *pDate, int years) { + *pDate = CDate(pDate->getYear() + years, pDate->getMonth(), pDate->getDay()); +} +%} + +%typemap(csin, + pre=" using (CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day)) {", + post=" $csinput = new System.DateTime(temp$csinput.getYear()," + " temp$csinput.getMonth(), temp$csinput.getDay(), 0, 0, 0);", + terminator=" } // terminate temp$csinput using block", + cshin="ref $csinput" + ) CDate * + "$csclassname.getCPtr(temp$csinput)" + +%inline %{ +void subtractYears(CDate *pDate, int years) { + *pDate = CDate(pDate->getYear() - years, pDate->getMonth(), pDate->getDay()); +} +%} + +%typemap(csvarin, excode=SWIGEXCODE2) CDate * %{ + /* csvarin typemap code */ + set { + CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day); + $imcall;$excode + } %} + +%typemap(csvarout, excode=SWIGEXCODE2) CDate * %{ + /* csvarout typemap code */ + get { + IntPtr cPtr = $imcall; + CDate tempDate = (cPtr == IntPtr.Zero) ? null : new CDate(cPtr, $owner);$excode + return new System.DateTime(tempDate.getYear(), tempDate.getMonth(), tempDate.getDay(), + 0, 0, 0); + } %} + +%inline %{ +CDate ImportantDate = CDate(1999, 12, 31); +%} + diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index c802ad3a2..431181355 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -1887,6 +1887,7 @@ public: bool setter_flag = false; String *pre_code = NewString(""); String *post_code = NewString(""); + String *terminator_code = NewString(""); if (!proxy_flag) return; @@ -2035,6 +2036,14 @@ public: Printf(post_code, "\n"); Printv(post_code, post, NIL); } + String *terminator = Getattr(p, "tmap:csin:terminator"); + if (terminator) { + substituteClassname(pt, terminator); + Replaceall(terminator, "$csinput", arg); + if (Len(terminator_code) > 0) + Insert(terminator_code, 0, "\n"); + Insert(terminator_code, 0, terminator); + } Printv(imcall, tm, NIL); } else { Swig_warning(WARN_CSHARP_TYPEMAP_CSIN_UNDEF, input_file, line_number, "No csin typemap defined for %s\n", SwigType_str(pt, 0)); @@ -2060,7 +2069,8 @@ public: excodeSubstitute(n, tm, "csout", n); bool is_pre_code = Len(pre_code) > 0; bool is_post_code = Len(post_code) > 0; - if (is_pre_code || is_post_code) { + bool is_terminator_code = Len(terminator_code) > 0; + if (is_pre_code || is_post_code || is_terminator_code) { Replaceall(tm, "\n ", "\n "); // add extra indentation to code in typemap if (is_post_code) { Insert(tm, 0, "\n try "); @@ -2072,6 +2082,9 @@ public: Insert(tm, 0, pre_code); Insert(tm, 0, "\n"); } + if (is_terminator_code) { + Printv(tm, "\n", terminator_code, NIL); + } Insert(tm, 0, "{"); Printf(tm, "\n }"); } @@ -2171,6 +2184,7 @@ public: Delete(pre_code); Delete(post_code); + Delete(terminator_code); Delete(function_code); Delete(return_type); Delete(imcall); @@ -2191,6 +2205,7 @@ public: String *helper_args = NewString(""); String *pre_code = NewString(""); String *post_code = NewString(""); + String *terminator_code = NewString(""); String *im_return_type = NewString(""); bool feature_director = (parentNode(n) && Swig_directorclass(n)); @@ -2286,6 +2301,14 @@ public: Printf(post_code, "\n"); Printv(post_code, post, NIL); } + String *terminator = Getattr(p, "tmap:csin:terminator"); + if (terminator) { + substituteClassname(pt, terminator); + Replaceall(terminator, "$csinput", arg); + if (Len(terminator_code) > 0) + Insert(terminator_code, 0, "\n"); + Insert(terminator_code, 0, terminator); + } cshin = Getattr(p, "tmap:csin:cshin"); if (cshin) Replaceall(cshin, "$csinput", arg); @@ -2342,7 +2365,8 @@ public: bool is_pre_code = Len(pre_code) > 0; bool is_post_code = Len(post_code) > 0; - if (is_pre_code || is_post_code) { + bool is_terminator_code = Len(terminator_code) > 0; + if (is_pre_code || is_post_code || is_terminator_code) { Printf(helper_code, " {\n"); if (is_pre_code) { Printv(helper_code, pre_code, "\n", NIL); @@ -2354,6 +2378,9 @@ public: } else { Printv(helper_code, " return ", imcall, ";", NIL); } + if (is_terminator_code) { + Printv(helper_code, "\n", terminator_code, NIL); + } Printf(helper_code, "\n }\n"); String *helper_name = NewStringf("%s.SwigConstruct%s(%s)", proxy_class_name, proxy_class_name, helper_args); String *im_outattributes = Getattr(n, "tmap:imtype:outattributes"); @@ -2372,6 +2399,7 @@ public: Delete(im_return_type); Delete(pre_code); Delete(post_code); + Delete(terminator_code); Delete(construct_tm); Delete(attributes); Delete(overloaded_name); @@ -2489,6 +2517,7 @@ public: bool setter_flag = false; String *pre_code = NewString(""); String *post_code = NewString(""); + String *terminator_code = NewString(""); if (l) { if (SwigType_type(Getattr(l, "type")) == T_VOID) { @@ -2593,6 +2622,14 @@ public: Printf(post_code, "\n"); Printv(post_code, post, NIL); } + String *terminator = Getattr(p, "tmap:csin:terminator"); + if (terminator) { + substituteClassname(pt, terminator); + Replaceall(terminator, "$csinput", arg); + if (Len(terminator_code) > 0) + Insert(terminator_code, 0, "\n"); + Insert(terminator_code, 0, terminator); + } Printv(imcall, tm, NIL); } else { Swig_warning(WARN_CSHARP_TYPEMAP_CSIN_UNDEF, input_file, line_number, "No csin typemap defined for %s\n", SwigType_str(pt, 0)); @@ -2617,7 +2654,8 @@ public: excodeSubstitute(n, tm, "csout", n); bool is_pre_code = Len(pre_code) > 0; bool is_post_code = Len(post_code) > 0; - if (is_pre_code || is_post_code) { + bool is_terminator_code = Len(terminator_code) > 0; + if (is_pre_code || is_post_code || is_terminator_code) { Replaceall(tm, "\n ", "\n "); // add extra indentation to code in typemap if (is_post_code) { Insert(tm, 0, "\n try "); @@ -2629,6 +2667,9 @@ public: Insert(tm, 0, pre_code); Insert(tm, 0, "\n"); } + if (is_terminator_code) { + Printv(tm, "\n", terminator_code, NIL); + } Insert(tm, 0, "{"); Printf(tm, "\n }"); } @@ -2704,6 +2745,7 @@ public: Delete(pre_code); Delete(post_code); + Delete(terminator_code); Delete(function_code); Delete(return_type); Delete(imcall); From 2cafaf9d439d43c81b81dc6c7bdb296afe9e8623 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 2 Sep 2008 23:01:37 +0000 Subject: [PATCH 0100/1680] Fix #1988296 - Multiple module director linking issue git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10809 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++++ Lib/python/director.swg | 6 +----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 79b0aaec6..18f565cec 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,10 @@ Version 1.3.37 (in progress) ============================= +2008-09-02: wsfulton + [Python] Commit patch #1988296 GCItem multiple module linking issue when using + directors. + 2008-09-02: wsfulton [C#] Support for 'using' and 'fixed' blocks in the 'csin' typemap is now possible through the use of the pre attribute and the new terminator attribute, eg diff --git a/Lib/python/director.swg b/Lib/python/director.swg index 176ee3336..7438cfbff 100644 --- a/Lib/python/director.swg +++ b/Lib/python/director.swg @@ -107,7 +107,7 @@ namespace Swig { /* memory handler */ struct GCItem { - virtual ~GCItem() = 0; + virtual ~GCItem() {} virtual int get_own() const { @@ -115,10 +115,6 @@ namespace Swig { } }; - GCItem::~GCItem() - { - } - struct GCItem_var { GCItem_var(GCItem *item = 0) : _item(item) From 761ef2b98fac9926fadafcac483fe71af092d0a9 Mon Sep 17 00:00:00 2001 From: Richard Boulton Date: Wed, 10 Sep 2008 10:08:21 +0000 Subject: [PATCH 0101/1680] [Python] Commit patch #2089149: Director exception handling mangles returned exception. Exceptions raised by Python code in directors are now passed through to the caller without change. Also, remove the ": " prefix which used to be added to other director exceptions (eg, those due to incorrect return types). git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10827 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 7 +++ .../python/director_exception_runme.py | 49 ++++++++++++++----- Lib/python/director.swg | 3 -- 3 files changed, 45 insertions(+), 14 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 18f565cec..6b552c994 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,13 @@ Version 1.3.37 (in progress) ============================= +2008-09-02: wsfulton + [Python] Commit patch #2089149: Director exception handling mangles + returned exception. Exceptions raised by Python code in directors + are now passed through to the caller without change. Also, remove + the ": " prefix which used to be added to other director exceptions + (eg, those due to incorrect return types). + 2008-09-02: wsfulton [Python] Commit patch #1988296 GCItem multiple module linking issue when using directors. diff --git a/Examples/test-suite/python/director_exception_runme.py b/Examples/test-suite/python/director_exception_runme.py index 7c9e69250..28521ffa5 100644 --- a/Examples/test-suite/python/director_exception_runme.py +++ b/Examples/test-suite/python/director_exception_runme.py @@ -1,45 +1,72 @@ from director_exception import * from exceptions import * +class MyException(Exception): + def __init__(self, a, b): + self.msg = a + b + class MyFoo(Foo): def ping(self): raise NotImplementedError, "MyFoo::ping() EXCEPTION" class MyFoo2(Foo): def ping(self): - return true + return True pass # error: should return a string -ok = 0 +class MyFoo3(Foo): + def ping(self): + raise MyException("foo", "bar") +# Check that the NotImplementedError raised by MyFoo.ping() is returned by +# MyFoo.pong(). +ok = 0 a = MyFoo() b = launder(a) - try: b.pong() except NotImplementedError, e: - ok = 1 + if str(e) == "MyFoo::ping() EXCEPTION": + ok = 1 + else: + print "Unexpected error message: %s" % str(e) except: pass - if not ok: raise RuntimeError -ok = 0 +# Check that the director returns the appropriate TypeError if the return type +# is wrong. +ok = 0 a = MyFoo2() b = launder(a) - try: b.pong() -except: - ok = 1 - - +except TypeError, e: + if str(e) == "Swig director type mismatch in output value of type 'std::string'": + ok = 1 + else: + print "Unexpected error message: %s" % str(e) if not ok: raise RuntimeError +# Check that the director can return an exception which requires two arguments +# to the constructor, without mangling it. +ok = 0 +a = MyFoo3() +b = launder(a) +try: + b.pong() +except MyException, e: + if e.msg == 'foobar': + ok = 1 + else: + print "Unexpected error message: %s" % str(e) +if not ok: + raise RuntimeError + try: raise Exception2() except Exception2: diff --git a/Lib/python/director.swg b/Lib/python/director.swg index 7438cfbff..836d107ce 100644 --- a/Lib/python/director.swg +++ b/Lib/python/director.swg @@ -208,10 +208,7 @@ namespace Swig { swig_msg += msg; } if (!PyErr_Occurred()) { - swig_msg.insert(0, ": "); PyErr_SetString(error, getMessage()); - } else { - SWIG_Python_AddErrorMsg(getMessage()); } SWIG_PYTHON_THREAD_END_BLOCK; } From 3d8ddfc442f1f73bc2c567aaa972680d14fea0df Mon Sep 17 00:00:00 2001 From: Haoyu Bai Date: Thu, 11 Sep 2008 17:18:07 +0000 Subject: [PATCH 0102/1680] Merged the Python 3.0 support branch. The merging progress is not so smooth, so hope this commit won't make anything broken. This is the (incomplemete) log produced by svnmerge.py: Merged revisions 10405-10409,10420-10422,10426,10438,10445,10451,10454-10465,10467,10473-10475,10485,10488-10489,10493-10495,10497,10509-10510,10513-10514,10517,10520,10525,10528-10529,10533-10535,10554-10557,10570,10573,10593,10614,10666-10669,10673,10678,10687,10690,10704-10706,10731,10744,10750-10752,10755,10759,10770,10775-10776,10813,10819 via svnmerge from https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-bhy git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10834 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Python.html | 253 ++++++++- Examples/GIFPlot/Python/full/Makefile | 3 +- Examples/GIFPlot/Python/shadow/Makefile | 3 +- Examples/GIFPlot/Python/simple/Makefile | 3 +- Examples/Makefile.in | 58 +- Examples/python/callback/Makefile | 1 + Examples/python/class/Makefile | 1 + Examples/python/constants/Makefile | 1 + Examples/python/contract/Makefile | 1 + Examples/python/docstrings/Makefile | 1 + Examples/python/enum/Makefile | 1 + Examples/python/exception/Makefile | 1 + Examples/python/exceptproxy/Makefile | 1 + Examples/python/extend/Makefile | 1 + Examples/python/funcptr/Makefile | 1 + Examples/python/funcptr2/Makefile | 1 + Examples/python/functor/Makefile | 1 + Examples/python/import/Makefile | 1 + Examples/python/import_template/Makefile | 1 + Examples/python/libffi/Makefile | 1 + Examples/python/multimap/Makefile | 1 + Examples/python/multimap/example.i | 32 +- Examples/python/operator/Makefile | 1 + Examples/python/pointer/Makefile | 1 + Examples/python/reference/Makefile | 1 + Examples/python/simple/Makefile | 1 + Examples/python/smartptr/Makefile | 1 + Examples/python/std_map/Makefile | 1 + Examples/python/std_vector/Makefile | 1 + Examples/python/swigrun/Makefile | 1 + Examples/python/template/Makefile | 1 + Examples/python/varargs/Makefile | 1 + Examples/python/variables/Makefile | 1 + Examples/python/weave/Makefile | 1 + Examples/test-suite/common.mk | 1 + Examples/test-suite/li_cstring.i | 8 +- Examples/test-suite/li_cwstring.i | 8 +- Examples/test-suite/name_warnings.i | 3 +- Examples/test-suite/namespace_typemap.i | 2 +- Examples/test-suite/operbool.i | 10 + Examples/test-suite/python/Makefile.in | 67 ++- Examples/test-suite/python/README | 6 +- Examples/test-suite/python/abstractbase.i | 18 + .../test-suite/python/abstractbase_runme3.py | 8 + .../test-suite/python/cpp_namespace_runme.py | 20 +- .../python/director_classic_runme.py | 68 +-- .../python/director_exception_runme.py | 1 - Examples/test-suite/python/file_test_runme.py | 3 +- Examples/test-suite/python/hugemod.pl | 8 +- Examples/test-suite/python/operbool_runme.py | 4 + Examples/test-suite/python/pybuf.i | 34 ++ Examples/test-suite/python/pybuf_benchmark.i | 31 ++ .../python/pybuf_benchmark_runme.py | 16 + .../python/pybuf_benchmark_runme3.py | 16 + Examples/test-suite/python/pybuf_runme3.py | 15 + .../python/template_typedef_cplx2_runme.py | 13 +- .../python/template_typedef_cplx_runme.py | 13 +- Lib/python/file.i | 4 +- Lib/python/pyabc.i | 10 + Lib/python/pyapi.swg | 14 + Lib/python/pybuffer.i | 107 ++++ Lib/python/pycontainer.swg | 61 +++ Lib/python/pyerrors.swg | 6 +- Lib/python/pyhead.swg | 44 ++ Lib/python/pyinit.swg | 68 ++- Lib/python/pyiterators.swg | 8 + Lib/python/pyopers.swg | 6 + Lib/python/pyrun.swg | 113 +++- Lib/python/pystrings.swg | 20 +- Lib/python/pywstrings.swg | 2 + Lib/python/std_map.i | 4 + Source/CParse/cscanner.c | 18 +- Source/CParse/parser.y | 8 + Source/Modules/python.cxx | 496 ++++++++++++++---- configure.in | 107 +++- 75 files changed, 1603 insertions(+), 246 deletions(-) create mode 100644 Examples/test-suite/operbool.i create mode 100644 Examples/test-suite/python/abstractbase.i create mode 100644 Examples/test-suite/python/abstractbase_runme3.py create mode 100644 Examples/test-suite/python/operbool_runme.py create mode 100644 Examples/test-suite/python/pybuf.i create mode 100644 Examples/test-suite/python/pybuf_benchmark.i create mode 100644 Examples/test-suite/python/pybuf_benchmark_runme.py create mode 100644 Examples/test-suite/python/pybuf_benchmark_runme3.py create mode 100644 Examples/test-suite/python/pybuf_runme3.py create mode 100644 Lib/python/pyabc.i create mode 100644 Lib/python/pybuffer.i diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html index 62b72fabf..c0b71b52d 100644 --- a/Doc/Manual/Python.html +++ b/Doc/Manual/Python.html @@ -46,7 +46,7 @@
    • Memory management
    • Python 2.2 and classic classes
    -
  • Cross language polymorphism +
  • Cross language polymorphism
  • Python Packages +
  • Python 3 Support + @@ -113,9 +119,9 @@

    This chapter describes SWIG's support of Python. SWIG is compatible -with most recent Python versions including Python 2.2 as well as older -versions dating back to Python 1.5.2. For the best results, consider using Python -2.0 or newer. +with most recent Python versions including Python 3.0 and Python 2.6, +as well as older versions dating back to Python 2.0. For the best results, +consider using Python 2.3 or newer.

    @@ -2544,7 +2550,7 @@ class itself. In Python-2.1 and earlier, they have to be accessed as a global function or through an instance (see the earlier section).

    -

    30.5 Cross language polymorphism

    +

    30.5 Cross language polymorphism

    @@ -4929,7 +4935,7 @@ with more than one line.

    Using the package option of the %module directive allows you to specify what Python package that the module will be -living in when installed. +living in when installed.

    @@ -4950,6 +4956,241 @@ and also in base class declarations, etc. if the package name is different than its own.

    +

    30.12 Python 3 Support

    + + +

    +SWIG is able to support Python 3.0. The wrapper code generated by +SWIG can be compiled with both Python 2.x or 3.0. Further more, by +passing the -py3 command line option to SWIG, wrapper code +with some Python 3 specific features can be generated (see below +subsections for details of these features). The -py3 option also +disables some incompatible features for Python 3, such as +-classic. + +

    +There is a list of known-to-be-broken features in Python 3: +

    +
      +
    • No more support for FILE* typemaps, because PyFile_AsFile has been dropped + in Python 3.
    • +
    • The -apply command line option is removed and generating + code using apply() is no longer supported.
    • +
    + +

    +The following are Python 3.0 new features that are currently supported by +SWIG. +

    + +

    30.12.1 Function annotation

    + + +

    +The -py3 option will enable function annotation support. When used +SWIG is able to generate proxy method definitions like +this: +

    + +
    +  def foo(self, bar : "int" = 0) -> "void" : ...
    +
    + +

    +For details of usage of function annotation, see PEP 3107. +

    + +

    30.12.2 Buffer interface

    + + +

    +Buffer protocols were revised in Python 3. SWIG also gains a series of +new typemaps to support buffer interfaces. These typemap macros are +defined in pybuffer.i, which must be included in order to use them. +By using these typemaps, your wrapped function will be able to +accept any Python object that exposes a suitable buffer interface. +

    + +

    +For example, the get_path() function puts the path string +into the memory pointed to by its argument: +

    + +
    +void get_path(char *s);
    +
    + +

    +Then you can write a typemap like this: (the following example is +applied to both Python 3.0 and 2.6, since the bytearray type +is backported to 2.6. +

    + + +
    +%include <pybuffer.i>
    +%pybuffer_mutable_string(char *str);
    +void get_path(char *s);
    +
    + +

    +And then on the Python side the wrapped get_path could be used in this +way: +

    + +
    +>>> p = bytearray(10)
    +>>> get_path(p)
    +>>> print(p)
    +bytearray(b'/Foo/Bar/\x00')
    +
    + +

    +The macros defined in pybuffer.i are similar to those in +cstring.i: +

    + +

    +%pybuffer_mutable_binary(parm, size_parm) +

    + +
    + +

    +The macro can be used to generate a typemap which maps a buffer of an +object to a pointer provided by parm and a size argument +provided by size_parm. For example: +

    + +
    +%pybuffer_mutable_binary(char *str, size_t size);
    +...
    +int snprintf(char *str, size_t size, const char *format, ...);
    +
    + +

    +In Python: +

    + +
    +>>> buf = bytearray(6)
    +>>> snprintf(buf, "Hello world!")
    +>>> print(buf)
    +bytearray(b'Hello\x00')
    +>>> 
    +
    + +
    + +

    +%pybuffer_mutable_string(parm) +

    + +
    + +

    +This typemap macro requires the buffer to be a zero terminated string, +and maps the pointer of the buffer to parm. For example: +

    + +
    +%pybuffer_mutable_string(char *str);
    +...
    +size_t make_upper(char *str);
    +
    + +

    +In Python: +

    + +
    +>>> buf = bytearray(b'foo\x00')
    +>>> make_upper(buf)
    +>>> print(buf)
    +bytearray(b'FOO\x00')
    +>>>
    +
    + +

    +Both %pybuffer_mutable_binary and %pybuffer_mutable_string +require the provided buffer to be mutable, eg. they can accept a +bytearray type but can't accept an immutable byte +type. +

    + +
    + +

    +%pybuffer_binary(parm, size_parm) +

    + +
    + +

    +This macro maps an object's buffer to a pointer parm and a +size size_parm. It is similar to +%pybuffer_mutable_binary, except the +%pybuffer_binary an accept both mutable and immutable +buffers. As a result, the wrapped function should not modify the buffer. +

    + +
    + +

    +%pybuffer_string(parm) +

    + +
    + +

    +This macro maps an object's buffer as a string pointer parm. +It is similar to %pybuffer_mutable_string but the buffer +could be both mutable and immutable. And your function should not +modify the buffer. +

    + +
    + + +

    30.12.3 Abstract base classes

    + + +

    +By including pyabc.i and using the -py3 command +line option when calling SWIG, the proxy classes of the STL containers +will automatically gain an appropriate abstract base class. For +example, the following SWIG interface: +

    + +
    +%include <pyabc.i>
    +%include <std_map.i>
    +%include <std_list.i>
    +
    +namespace std {
    +  %template(Mapii) map<int, int>;
    +  %template(IntList) list<int>;
    +}
    +
    + +

    +will generate a Python proxy class Mapii inheriting from +collections.MutableMap and a proxy class IntList +inheriting from collections.MutableSequence. +

    + +

    +pyabc.i also provides a macro %pythonabc that could be +used to define an abstract base class for your own C++ class: +

    + +
    +%pythonabc(MySet, collections.MutableSet);
    +
    + +

    +For details of abstract base class, please see PEP 3119. +

    diff --git a/Examples/GIFPlot/Python/full/Makefile b/Examples/GIFPlot/Python/full/Makefile index ae927b72b..83a7c864b 100644 --- a/Examples/GIFPlot/Python/full/Makefile +++ b/Examples/GIFPlot/Python/full/Makefile @@ -1,5 +1,5 @@ TOP = ../../.. -SWIG = $(TOP)/../swig +SWIG = $(TOP)/../preinst-swig SWIGOPT = -I../../Include SRCS = TARGET = gifplot @@ -23,3 +23,4 @@ clean:: rm -f *.gif check: all + $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/GIFPlot/Python/shadow/Makefile b/Examples/GIFPlot/Python/shadow/Makefile index 1f5014895..73fca9673 100644 --- a/Examples/GIFPlot/Python/shadow/Makefile +++ b/Examples/GIFPlot/Python/shadow/Makefile @@ -1,5 +1,5 @@ TOP = ../../.. -SWIG = $(TOP)/../swig +SWIG = $(TOP)/../preinst-swig SWIGOPT = -I../../Interface SRCS = TARGET = gifplot @@ -23,3 +23,4 @@ clean:: rm -f *.gif check: all + $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/GIFPlot/Python/simple/Makefile b/Examples/GIFPlot/Python/simple/Makefile index 5eb0344e8..9fc9a6c72 100644 --- a/Examples/GIFPlot/Python/simple/Makefile +++ b/Examples/GIFPlot/Python/simple/Makefile @@ -1,5 +1,5 @@ TOP = ../../.. -SWIG = $(TOP)/../swig +SWIG = $(TOP)/../preinst-swig SWIGOPT = SRCS = TARGET = simple @@ -23,3 +23,4 @@ clean:: rm -f *.gif check: all + $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/Makefile.in b/Examples/Makefile.in index 555aa3e92..f85075906 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -223,19 +223,39 @@ perl5_clean: ################################################################## # Make sure these locate your Python installation -PYTHON_INCLUDE= $(DEFS) @PYINCLUDE@ -PYTHON_LIB = @PYLIB@ +ifeq (,$(PY3)) + PYTHON_INCLUDE= $(DEFS) @PYINCLUDE@ + PYTHON_LIB = @PYLIB@ + PYTHON = @PYTHON@ +else + PYTHON_INCLUDE= $(DEFS) @PY3INCLUDE@ + PYTHON_LIB = @PY3LIB@ + PYTHON = @PYTHON3@ +endif -# Extra Python specific dynamic linking options -PYTHON_DLNK = @PYTHONDYNAMICLINKING@ +# Extra Python specific linking options +ifeq (,$(PY3)) + PYTHON_DLNK = @PYTHONDYNAMICLINKING@ + PYTHON_LINK = @PYLINK@ +else + PYTHON_DLNK = @PYTHON3DYNAMICLINKING@ + PYTHON_LINK = @PY3LINK@ +endif PYTHON_SO = @PYTHON_SO@ +# SWIG option for Python +ifeq (,$(PY3)) + SWIGPYTHON = $(SWIG) -python +else + SWIGPYTHON = $(SWIG) -python -py3 +endif + # ---------------------------------------------------------------- # Build a C dynamically loadable module # ---------------------------------------------------------------- python: $(SRCS) - $(SWIG) -python $(SWIGOPT) $(INTERFACE) + $(SWIGPYTHON) $(SWIGOPT) $(INTERFACE) $(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(SRCS) $(INCLUDES) $(PYTHON_INCLUDE) $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(PYTHON_DLNK) $(LIBS) -o $(LIBPREFIX)_$(TARGET)$(PYTHON_SO) @@ -244,7 +264,7 @@ python: $(SRCS) # ----------------------------------------------------------------- python_cpp: $(SRCS) - $(SWIG) -c++ -python $(SWIGOPT) $(INTERFACE) + $(SWIGPYTHON) -c++ $(SWIGOPT) $(INTERFACE) $(CXX) -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) $(PYTHON_INCLUDE) $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(PYTHON_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)_$(TARGET)$(PYTHON_SO) @@ -257,18 +277,37 @@ python_cpp: $(SRCS) #TKINTER = -L/usr/X11R6.3/lib -L/usr/local/compat/lib -ltk4.0 -ltcl7.4 -lX11 TKINTER = -PYTHON_LIBOPTS = @PYLINK@ @LIBS@ $(TKINTER) $(SYSLIBS) +PYTHON_LIBOPTS = $(PYTHON_LINK) @LIBS@ $(TKINTER) $(SYSLIBS) python_static: $(SRCS) - $(SWIG) -python -lembed.i $(SWIGOPT) $(INTERFACE) + $(SWIGPYTHON) -lembed.i $(SWIGOPT) $(INTERFACE) $(CC) $(CFLAGS) @LINKFORSHARED@ $(ISRCS) $(SRCS) $(INCLUDES) \ $(PYTHON_INCLUDE) $(LIBS) -L$(PYTHON_LIB) $(PYTHON_LIBOPTS) -o $(TARGET) python_static_cpp: $(SRCS) - $(SWIG) -c++ -python -lembed.i $(SWIGOPT) $(INTERFACE) + $(SWIGPYTHON) -c++ -lembed.i $(SWIGOPT) $(INTERFACE) $(CXX) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) \ $(PYTHON_INCLUDE) $(LIBS) -L$(PYTHON_LIB) $(PYTHON_LIBOPTS) -o $(TARGET) +# ----------------------------------------------------------------- +# Running a Python example +# ----------------------------------------------------------------- + +ifeq (,$(PY3)) + SCRIPT = runme.py +else + SCRIPT = runme3.py +endif + +PY2TO3 = 2to3 `2to3 -l | grep -v -E "Available|import$$" | awk '{print "-f "$$0}'` + +python_run: $(SCRIPT) + env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PYTHONPATH=$(srcdir):$$PYTHONPATH $(PYTHON) $(SCRIPT) >/dev/null + +runme3.py: runme.py + cp $< $@ + $(PY2TO3) -w $@ >/dev/null 2>&1 + # ----------------------------------------------------------------- # Cleaning the python examples # ----------------------------------------------------------------- @@ -278,6 +317,7 @@ python_clean: rm -f core @EXTRA_CLEAN@ rm -f *.@OBJEXT@ *@SO@ *@PYTHON_SO@ + ################################################################## ##### OCTAVE ###### ################################################################## diff --git a/Examples/python/callback/Makefile b/Examples/python/callback/Makefile index ad36d7d7e..a29276e58 100644 --- a/Examples/python/callback/Makefile +++ b/Examples/python/callback/Makefile @@ -19,3 +19,4 @@ clean:: rm -f $(TARGET).py check: all + $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/class/Makefile b/Examples/python/class/Makefile index f331b8203..74625b992 100644 --- a/Examples/python/class/Makefile +++ b/Examples/python/class/Makefile @@ -18,3 +18,4 @@ clean:: rm -f $(TARGET).py check: all + $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/constants/Makefile b/Examples/python/constants/Makefile index 01d0f943a..1420b4e0b 100644 --- a/Examples/python/constants/Makefile +++ b/Examples/python/constants/Makefile @@ -17,3 +17,4 @@ clean:: rm -f $(TARGET).py check: all + $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/contract/Makefile b/Examples/python/contract/Makefile index c7b476995..77fe94b1a 100644 --- a/Examples/python/contract/Makefile +++ b/Examples/python/contract/Makefile @@ -17,3 +17,4 @@ clean:: rm -f $(TARGET).py check: all + $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/docstrings/Makefile b/Examples/python/docstrings/Makefile index 74ab112a1..f25450cac 100644 --- a/Examples/python/docstrings/Makefile +++ b/Examples/python/docstrings/Makefile @@ -21,3 +21,4 @@ clean:: rm -f $(TARGET).py check: all + $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/enum/Makefile b/Examples/python/enum/Makefile index f331b8203..74625b992 100644 --- a/Examples/python/enum/Makefile +++ b/Examples/python/enum/Makefile @@ -18,3 +18,4 @@ clean:: rm -f $(TARGET).py check: all + $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/exception/Makefile b/Examples/python/exception/Makefile index 17c4f30b7..7dbdde944 100644 --- a/Examples/python/exception/Makefile +++ b/Examples/python/exception/Makefile @@ -18,3 +18,4 @@ clean:: rm -f $(TARGET).py check: all + $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/exceptproxy/Makefile b/Examples/python/exceptproxy/Makefile index a4f334311..ba5c79827 100644 --- a/Examples/python/exceptproxy/Makefile +++ b/Examples/python/exceptproxy/Makefile @@ -19,3 +19,4 @@ clean:: rm -f $(TARGET).py check: all + $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/extend/Makefile b/Examples/python/extend/Makefile index ad36d7d7e..a29276e58 100644 --- a/Examples/python/extend/Makefile +++ b/Examples/python/extend/Makefile @@ -19,3 +19,4 @@ clean:: rm -f $(TARGET).py check: all + $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/funcptr/Makefile b/Examples/python/funcptr/Makefile index 4a1e1bb71..0f4a1e077 100644 --- a/Examples/python/funcptr/Makefile +++ b/Examples/python/funcptr/Makefile @@ -17,3 +17,4 @@ clean:: rm -f $(TARGET).py check: all + $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/funcptr2/Makefile b/Examples/python/funcptr2/Makefile index 4a1e1bb71..0f4a1e077 100644 --- a/Examples/python/funcptr2/Makefile +++ b/Examples/python/funcptr2/Makefile @@ -17,3 +17,4 @@ clean:: rm -f $(TARGET).py check: all + $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/functor/Makefile b/Examples/python/functor/Makefile index c45536529..fe389757a 100644 --- a/Examples/python/functor/Makefile +++ b/Examples/python/functor/Makefile @@ -19,3 +19,4 @@ clean:: rm -f $(TARGET).py check: all + $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/import/Makefile b/Examples/python/import/Makefile index e00e81864..74d4f88cf 100644 --- a/Examples/python/import/Makefile +++ b/Examples/python/import/Makefile @@ -19,3 +19,4 @@ clean:: @rm -f foo.py bar.py spam.py base.py check: all + $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/import_template/Makefile b/Examples/python/import_template/Makefile index fa49f3145..ee47e994d 100644 --- a/Examples/python/import_template/Makefile +++ b/Examples/python/import_template/Makefile @@ -19,3 +19,4 @@ clean:: @rm -f foo.py bar.py spam.py base.py check: all + $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/libffi/Makefile b/Examples/python/libffi/Makefile index 8c7edfa65..fafb7de09 100644 --- a/Examples/python/libffi/Makefile +++ b/Examples/python/libffi/Makefile @@ -17,3 +17,4 @@ clean:: rm -f $(TARGET).py check: all + $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/multimap/Makefile b/Examples/python/multimap/Makefile index 4a1e1bb71..0f4a1e077 100644 --- a/Examples/python/multimap/Makefile +++ b/Examples/python/multimap/Makefile @@ -17,3 +17,4 @@ clean:: rm -f $(TARGET).py check: all + $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/multimap/example.i b/Examples/python/multimap/example.i index 163d7cc8e..3d5a09771 100644 --- a/Examples/python/multimap/example.i +++ b/Examples/python/multimap/example.i @@ -17,6 +17,7 @@ extern int gcd(int x, int y); %typemap(in,fragment="t_output_helper") (int argc, char *argv[]) { int i; + int l; if (!PyList_Check($input)) { SWIG_exception(SWIG_ValueError, "Expecting a list"); } @@ -27,11 +28,21 @@ extern int gcd(int x, int y); $2 = (char **) malloc(($1+1)*sizeof(char *)); for (i = 0; i < $1; i++) { PyObject *s = PyList_GetItem($input,i); - if (!PyString_Check(s)) { +%#if PY_VERSION_HEX >= 0x03000000 + if (!PyUnicode_Check(s)) +%#else + if (!PyString_Check(s)) +%#endif + { free($2); SWIG_exception(SWIG_ValueError, "List items must be strings"); } +%#if PY_VERSION_HEX >= 0x03000000 + $2[i] = PyUnicode_AsStringAndSize(s, &l); +%#else $2[i] = PyString_AsString(s); +%#endif + } $2[i] = 0; } @@ -39,12 +50,21 @@ extern int gcd(int x, int y); extern int gcdmain(int argc, char *argv[]); %typemap(in) (char *bytes, int len) { + +%#if PY_VERSION_HEX >= 0x03000000 + if (!PyUnicode_Check($input)) { + PyErr_SetString(PyExc_ValueError,"Expected a string"); + return NULL; + } + $1 = PyUnicode_AsStringAndSize($input, &$2); +%#else if (!PyString_Check($input)) { PyErr_SetString(PyExc_ValueError,"Expected a string"); return NULL; } $1 = PyString_AsString($input); $2 = PyString_Size($input); +%#endif } extern int count(char *bytes, int len, char c); @@ -56,9 +76,15 @@ extern int count(char *bytes, int len, char c); so that we don't violate it's mutability */ %typemap(in) (char *str, int len) { +%#if PY_VERSION_HEX >= 0x03000000 + $2 = PyUnicode_GetSize($input); + $1 = (char *) malloc($2+1); + memmove($1,PyUnicode_AsString($input),$2); +%#else $2 = PyString_Size($input); $1 = (char *) malloc($2+1); memmove($1,PyString_AsString($input),$2); +%#endif } /* Return the mutated string as a new object. The t_output_helper @@ -67,7 +93,11 @@ extern int count(char *bytes, int len, char c); %typemap(argout) (char *str, int len) { PyObject *o; +%#if PY_VERSION_HEX >= 0x03000000 + o = PyUnicode_FromStringAndSize($1,$2); +%#else o = PyString_FromStringAndSize($1,$2); +%#endif $result = t_output_helper($result,o); free($1); } diff --git a/Examples/python/operator/Makefile b/Examples/python/operator/Makefile index c45536529..fe389757a 100644 --- a/Examples/python/operator/Makefile +++ b/Examples/python/operator/Makefile @@ -19,3 +19,4 @@ clean:: rm -f $(TARGET).py check: all + $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/pointer/Makefile b/Examples/python/pointer/Makefile index 4a1e1bb71..0f4a1e077 100644 --- a/Examples/python/pointer/Makefile +++ b/Examples/python/pointer/Makefile @@ -17,3 +17,4 @@ clean:: rm -f $(TARGET).py check: all + $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/reference/Makefile b/Examples/python/reference/Makefile index f331b8203..74625b992 100644 --- a/Examples/python/reference/Makefile +++ b/Examples/python/reference/Makefile @@ -18,3 +18,4 @@ clean:: rm -f $(TARGET).py check: all + $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/simple/Makefile b/Examples/python/simple/Makefile index 4a1e1bb71..0f4a1e077 100644 --- a/Examples/python/simple/Makefile +++ b/Examples/python/simple/Makefile @@ -17,3 +17,4 @@ clean:: rm -f $(TARGET).py check: all + $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/smartptr/Makefile b/Examples/python/smartptr/Makefile index 58d139643..f73802a6b 100644 --- a/Examples/python/smartptr/Makefile +++ b/Examples/python/smartptr/Makefile @@ -19,3 +19,4 @@ clean:: rm -f $(TARGET).py check: all + $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/std_map/Makefile b/Examples/python/std_map/Makefile index 2d4c1b4a3..5d13da764 100644 --- a/Examples/python/std_map/Makefile +++ b/Examples/python/std_map/Makefile @@ -22,3 +22,4 @@ run: python runme.py check: all + $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/std_vector/Makefile b/Examples/python/std_vector/Makefile index a4f334311..ba5c79827 100644 --- a/Examples/python/std_vector/Makefile +++ b/Examples/python/std_vector/Makefile @@ -19,3 +19,4 @@ clean:: rm -f $(TARGET).py check: all + $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/swigrun/Makefile b/Examples/python/swigrun/Makefile index 53bf701c9..2142be5bb 100644 --- a/Examples/python/swigrun/Makefile +++ b/Examples/python/swigrun/Makefile @@ -22,3 +22,4 @@ clean:: check: all + $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/template/Makefile b/Examples/python/template/Makefile index a4f334311..ba5c79827 100644 --- a/Examples/python/template/Makefile +++ b/Examples/python/template/Makefile @@ -19,3 +19,4 @@ clean:: rm -f $(TARGET).py check: all + $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/varargs/Makefile b/Examples/python/varargs/Makefile index 01d0f943a..1420b4e0b 100644 --- a/Examples/python/varargs/Makefile +++ b/Examples/python/varargs/Makefile @@ -17,3 +17,4 @@ clean:: rm -f $(TARGET).py check: all + $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/variables/Makefile b/Examples/python/variables/Makefile index 4a1e1bb71..0f4a1e077 100644 --- a/Examples/python/variables/Makefile +++ b/Examples/python/variables/Makefile @@ -17,3 +17,4 @@ clean:: rm -f $(TARGET).py check: all + $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/weave/Makefile b/Examples/python/weave/Makefile index 822779bd1..88f95c095 100644 --- a/Examples/python/weave/Makefile +++ b/Examples/python/weave/Makefile @@ -19,3 +19,4 @@ clean:: rm -f $(TARGET).py check: all + $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 0a3a0858a..57b57c271 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -237,6 +237,7 @@ CPP_TEST_CASES += \ null_pointer \ operator_overload \ operator_overload_break \ + operbool \ ordering \ overload_copy \ overload_extend \ diff --git a/Examples/test-suite/li_cstring.i b/Examples/test-suite/li_cstring.i index fd92ac7d3..28e8049e8 100644 --- a/Examples/test-suite/li_cstring.i +++ b/Examples/test-suite/li_cstring.i @@ -4,7 +4,7 @@ #ifndef SWIG_CSTRING_UNIMPL -%cstring_input_binary(char *in, int n); +%cstring_input_binary(char *str_in, int n); %cstring_bounded_output(char *out1, 512); %cstring_chunk_output(char *out2, 64); %cstring_bounded_mutable(char *out3, 512); @@ -22,13 +22,13 @@ %inline %{ -int count(char *in, int n, char c) { +int count(char *str_in, int n, char c) { int r = 0; while (n > 0) { - if (*in == c) { + if (*str_in == c) { r++; } - in++; + str_in++; --n; } return r; diff --git a/Examples/test-suite/li_cwstring.i b/Examples/test-suite/li_cwstring.i index dc9a1c4b9..769dcce12 100644 --- a/Examples/test-suite/li_cwstring.i +++ b/Examples/test-suite/li_cwstring.i @@ -4,7 +4,7 @@ #ifndef SWIG_CWSTRING_UNIMPL -%cwstring_input_binary(wchar_t *in, int n); +%cwstring_input_binary(wchar_t *str_in, int n); %cwstring_bounded_output(wchar_t *out1, 512); %cwstring_chunk_output(wchar_t *out2, 64); %cwstring_bounded_mutable(wchar_t *out3, 512); @@ -22,13 +22,13 @@ %inline %{ -int count(wchar_t *in, int n, wchar_t c) { +int count(wchar_t *str_in, int n, wchar_t c) { int r = 0; while (n > 0) { - if (*in == c) { + if (*str_in == c) { r++; } - in++; + str_in++; --n; } return r; diff --git a/Examples/test-suite/name_warnings.i b/Examples/test-suite/name_warnings.i index a9cb35686..527dbcfaa 100644 --- a/Examples/test-suite/name_warnings.i +++ b/Examples/test-suite/name_warnings.i @@ -58,13 +58,12 @@ namespace std %template(max_i) max; - %inline { /* silently rename the parameter names in csharp/java */ #ifdef SWIGR double foo(double inparam, double out) { return 1.0; } #else - double foo(double in, double out) { return 1.0; } + double foo(double abstract, double out) { return 1.0; } #endif double bar(double native, bool boolean) { return 1.0; } } diff --git a/Examples/test-suite/namespace_typemap.i b/Examples/test-suite/namespace_typemap.i index e4e0af905..984b93a6f 100644 --- a/Examples/test-suite/namespace_typemap.i +++ b/Examples/test-suite/namespace_typemap.i @@ -75,7 +75,7 @@ namespace test { class string_class; #ifdef SWIGPYTHON %typemap(in) string_class * { - $1 = new string_class(PyString_AsString($input)); + $1 = new string_class(SWIG_Python_str_AsChar($input)); } %typemap(freearg) string_class * { delete $1; diff --git a/Examples/test-suite/operbool.i b/Examples/test-suite/operbool.i new file mode 100644 index 000000000..d6d7fc706 --- /dev/null +++ b/Examples/test-suite/operbool.i @@ -0,0 +1,10 @@ +%module operbool + +%inline %{ + class Test { + public: + operator bool() { + return false; + } + }; +%} diff --git a/Examples/test-suite/python/Makefile.in b/Examples/test-suite/python/Makefile.in index 7f11cd495..a3a027453 100644 --- a/Examples/test-suite/python/Makefile.in +++ b/Examples/test-suite/python/Makefile.in @@ -2,14 +2,41 @@ # Makefile for python test-suite ####################################################################### +ifeq (,$(PY3)) + PYBIN = @PYTHON@ +else + PYBIN = @PYTHON3@ +endif + LANGUAGE = python -PYTHON = @PYTHON@ -SCRIPTSUFFIX = _runme.py +ifneq (,$(USE_VALGRIND)) + PYTHON = valgrind --leak-check=full --suppressions=pyswig.supp $(PYBIN) +else + PYTHON = $(PYBIN) +endif + +#*_runme.py for Python 2.x, *_runme3.py for Python 3.x +PY2SCRIPTSUFFIX = _runme.py +PY3SCRIPTSUFFIX = _runme3.py + +ifeq (,$(PY3)) + SCRIPTSUFFIX = $(PY2SCRIPTSUFFIX) +else + SCRIPTSUFFIX = $(PY3SCRIPTSUFFIX) +endif + srcdir = @srcdir@ top_srcdir = @top_srcdir@ top_builddir = @top_builddir@ + +#Use the tricky command because we want to disable the "import" fixer, +#but currently 2to3 has no option to let us do it +PY2TO3 = 2to3 `2to3 -l | grep -v -E "Available|import$$" | awk '{print "-f "$$0}'` + + CPP_TEST_CASES += \ + abstractbase \ argcargvtest \ autodoc \ callback \ @@ -77,12 +104,35 @@ VALGRIND_OPT += --suppressions=pythonswig.supp +$(swig_and_compile_multi_cpp) $(run_testcase) + +# Call 2to3 to generate Python 3.x test from the Python 2.x's *_runme.py file +%$(PY3SCRIPTSUFFIX): %$(PY2SCRIPTSUFFIX) + cp $< $@ + $(PY2TO3) -w $@ >/dev/null 2>&1 + + # Runs the testcase. A testcase is only run if -# a file is found which has _runme.py appended after the testcase name. +# a file is found which has _runme.py (or _runme3.py for Python 3) appended after the testcase name. + +run_python = env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PYTHONPATH=$(srcdir):$$PYTHONPATH $(RUNTOOL) $(PYTHON) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) + +ifeq (,$(PY3)) run_testcase = \ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then ( \ - env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PYTHONPATH=$(srcdir):$$PYTHONPATH $(RUNTOOL) $(PYTHON) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX);) \ + $(run_python);)\ fi; +else +py2_runme = $(srcdir)/$(SCRIPTPREFIX)$*$(PY2SCRIPTSUFFIX) +py3_runme = $(srcdir)/$(SCRIPTPREFIX)$*$(PY3SCRIPTSUFFIX) + +run_testcase = \ + if [ -f $(py2_runme) ]; then ( \ + $(MAKE) -f $(srcdir)/Makefile $(py3_runme) && \ + $(run_python);) \ + elif [ -f $(py3_runme)]; then ( \ + $(run_python);) \ + fi; +endif # Clean: remove the generated .py file %.clean: @@ -101,14 +151,15 @@ cvsignore: @echo clientdata_prop_b.py @echo imports_a.py @echo imports_b.py - @echo mod_a.py mod_b.py + @echo mod_a.py mod_b.py @echo hugemod.h hugemod_a.i hugemod_b.i hugemod_a.py hugemod_b.py hugemod_runme.py @echo template_typedef_import.py +hugemod_runme = hugemod$(SCRIPTPREFIX) hugemod: - perl hugemod.pl + perl hugemod.pl $(hugemod_runme) $(MAKE) hugemod_a.cpptest $(MAKE) hugemod_b.cpptest - time $(PYTHON) hugemod_runme.py - time $(PYTHON) hugemod_runme.py + sh -c "time $(PYTHON) $(hugemod_runme)" + sh -c "time $(PYTHON) $(hugemod_runme)" diff --git a/Examples/test-suite/python/README b/Examples/test-suite/python/README index b86ec5289..71db759b5 100644 --- a/Examples/test-suite/python/README +++ b/Examples/test-suite/python/README @@ -1,4 +1,8 @@ See ../README for common README file. -Any testcases which have _runme.py appended after the testcase name will be detected and run. +Any testcases which have _runme.py (or _runme3.py for Python 3) appended after the testcase name will be detected and run. +If you intend to write a testcase for both Python 2.x and 3.x, do *not* directly put the _runme3.py in this directory. Just write Python 2.x's _runme.py testcase and it will be automatically converted to Python 3 code during test. + +You can run make with PY3=y to run test case with Python 3.x, eg. + $ make voidtest.cpptest PY3=y diff --git a/Examples/test-suite/python/abstractbase.i b/Examples/test-suite/python/abstractbase.i new file mode 100644 index 000000000..530f21921 --- /dev/null +++ b/Examples/test-suite/python/abstractbase.i @@ -0,0 +1,18 @@ +%module abstractbase +%include +%include +%include +%include +%include +%include +%include + +namespace std +{ + %template(Mapii) map; + %template(Multimapii) multimap; + %template(IntSet) set; + %template(IntMultiset) multiset; + %template(IntVector) vector; + %template(IntList) list; +} diff --git a/Examples/test-suite/python/abstractbase_runme3.py b/Examples/test-suite/python/abstractbase_runme3.py new file mode 100644 index 000000000..13a87ee5e --- /dev/null +++ b/Examples/test-suite/python/abstractbase_runme3.py @@ -0,0 +1,8 @@ +from abstractbase import * +from collections import * +assert issubclass(Mapii, MutableMapping) +assert issubclass(Multimapii, MutableMapping) +assert issubclass(IntSet, MutableSet) +assert issubclass(IntMultiset, MutableSet) +assert issubclass(IntVector, MutableSequence) +assert issubclass(IntList, MutableSequence) diff --git a/Examples/test-suite/python/cpp_namespace_runme.py b/Examples/test-suite/python/cpp_namespace_runme.py index 3108b4f47..a454774f5 100644 --- a/Examples/test-suite/python/cpp_namespace_runme.py +++ b/Examples/test-suite/python/cpp_namespace_runme.py @@ -3,20 +3,20 @@ import cpp_namespace n = cpp_namespace.fact(4) if n != 24: - raise "Bad return value!" + raise RuntimeError("Bad return value!") if cpp_namespace.cvar.Foo != 42: - raise "Bad variable value!" + raise RuntimeError("Bad variable value!") t = cpp_namespace.Test() if t.method() != "Test::method": - raise "Bad method return value!" + raise RuntimeError("Bad method return value!") if cpp_namespace.do_method(t) != "Test::method": - raise "Bad return value!" + raise RuntimeError("Bad return value!") if cpp_namespace.do_method2(t) != "Test::method": - raise "Bad return value!" + raise RuntimeError("Bad return value!") cpp_namespace.weird("hello", 4) @@ -28,18 +28,18 @@ t4 = cpp_namespace.Test4() t5 = cpp_namespace.Test5() if cpp_namespace.foo3(42) != 42: - raise "Bad return value!" + raise RuntimeError("Bad return value!") if cpp_namespace.do_method3(t2,40) != "Test2::method": - raise "Bad return value!" + raise RuntimeError("Bad return value!") if cpp_namespace.do_method3(t3,40) != "Test3::method": - raise "Bad return value!" + raise RuntimeError("Bad return value!") if cpp_namespace.do_method3(t4,40) != "Test4::method": - raise "Bad return value!" + raise RuntimeError("Bad return value!") if cpp_namespace.do_method3(t5,40) != "Test5::method": - raise "Bad return value!" + raise RuntimeError("Bad return value!") diff --git a/Examples/test-suite/python/director_classic_runme.py b/Examples/test-suite/python/director_classic_runme.py index 878905679..7e18a9a61 100644 --- a/Examples/test-suite/python/director_classic_runme.py +++ b/Examples/test-suite/python/director_classic_runme.py @@ -1,56 +1,56 @@ from director_classic import * class TargetLangPerson(Person): - def __init__(self): - Person.__init__(self) - def id(self): - identifier = "TargetLangPerson" - return identifier + def __init__(self): + Person.__init__(self) + def id(self): + identifier = "TargetLangPerson" + return identifier class TargetLangChild(Child): - def __init__(self): - Child.__init__(self) - def id(self): - identifier = "TargetLangChild" - return identifier + def __init__(self): + Child.__init__(self) + def id(self): + identifier = "TargetLangChild" + return identifier class TargetLangGrandChild(GrandChild): - def __init__(self): - GrandChild.__init__(self) - def id(self): - identifier = "TargetLangGrandChild" - return identifier + def __init__(self): + GrandChild.__init__(self) + def id(self): + identifier = "TargetLangGrandChild" + return identifier # Semis - don't override id() in target language class TargetLangSemiPerson(Person): - def __init__(self): - Person.__init__(self) + def __init__(self): + Person.__init__(self) # No id() override class TargetLangSemiChild(Child): - def __init__(self): - Child.__init__(self) + def __init__(self): + Child.__init__(self) # No id() override class TargetLangSemiGrandChild(GrandChild): - def __init__(self): - GrandChild.__init__(self) + def __init__(self): + GrandChild.__init__(self) # No id() override # Orphans - don't override id() in C++ class TargetLangOrphanPerson(OrphanPerson): - def __init__(self): - OrphanPerson.__init__(self) - def id(self): - identifier = "TargetLangOrphanPerson" - return identifier + def __init__(self): + OrphanPerson.__init__(self) + def id(self): + identifier = "TargetLangOrphanPerson" + return identifier class TargetLangOrphanChild(OrphanChild): - def __init__(self): - Child.__init__(self) - def id(self): - identifier = "TargetLangOrphanChild" - return identifier + def __init__(self): + Child.__init__(self) + def id(self): + identifier = "TargetLangOrphanChild" + return identifier def check(person, expected): @@ -61,7 +61,7 @@ def check(person, expected): if (debug): print(ret) if (ret != expected): - raise ("Failed. Received: " + ret + " Expected: " + expected) + raise RuntimeError("Failed. Received: " + str(ret) + " Expected: " + expected) # Polymorphic call from C++ caller = Caller() @@ -70,7 +70,7 @@ def check(person, expected): if (debug): print(ret) if (ret != expected): - raise ("Failed. Received: " + ret + " Expected: " + expected) + raise RuntimeError("Failed. Received: " + str(ret) + " Expected: " + expected) # Polymorphic call of object created in target language and passed to C++ and back again baseclass = caller.baseClass() @@ -78,7 +78,7 @@ def check(person, expected): if (debug): print(ret) if (ret != expected): - raise ("Failed. Received: " + ret + " Expected: " + expected) + raise RuntimeError("Failed. Received: " + str(ret)+ " Expected: " + expected) caller.resetCallback() if (debug): diff --git a/Examples/test-suite/python/director_exception_runme.py b/Examples/test-suite/python/director_exception_runme.py index 28521ffa5..ef7a044f1 100644 --- a/Examples/test-suite/python/director_exception_runme.py +++ b/Examples/test-suite/python/director_exception_runme.py @@ -1,5 +1,4 @@ from director_exception import * -from exceptions import * class MyException(Exception): def __init__(self, a, b): diff --git a/Examples/test-suite/python/file_test_runme.py b/Examples/test-suite/python/file_test_runme.py index 64154c619..de4e2669e 100644 --- a/Examples/test-suite/python/file_test_runme.py +++ b/Examples/test-suite/python/file_test_runme.py @@ -1,7 +1,8 @@ import sys import file_test -file_test.nfile(sys.stdout) +if sys.version_info < (3,0): + file_test.nfile(sys.stdout) cstdout = file_test.GetStdOut() diff --git a/Examples/test-suite/python/hugemod.pl b/Examples/test-suite/python/hugemod.pl index 15c4ce41b..5420926e4 100644 --- a/Examples/test-suite/python/hugemod.pl +++ b/Examples/test-suite/python/hugemod.pl @@ -2,8 +2,12 @@ use strict; +my $modsize = 399; #adjust it so you can have a smaller or bigger hugemod + +my $runme = shift @ARGV; + open HEADER, ">hugemod.h" or die "error"; -open TEST, ">hugemod_runme.py" or die "error"; +open TEST, ">$runme" or die "error"; open I1, ">hugemod_a.i" or die "error"; open I2, ">hugemod_b.i" or die "error"; @@ -21,7 +25,7 @@ print I2 "\%inline \%{\n"; my $i; -for ($i = 0; $i < 6000; $i++) { +for ($i = 0; $i < $modsize; $i++) { my $t = $i * 4; print HEADER "class type$i { public: int a; };\n"; print I2 "class dtype$i : public type$i { public: int b; };\n"; diff --git a/Examples/test-suite/python/operbool_runme.py b/Examples/test-suite/python/operbool_runme.py new file mode 100644 index 000000000..4218b5dd4 --- /dev/null +++ b/Examples/test-suite/python/operbool_runme.py @@ -0,0 +1,4 @@ +#!/usr/bin/env python +import operbool +assert not operbool.Test() + diff --git a/Examples/test-suite/python/pybuf.i b/Examples/test-suite/python/pybuf.i new file mode 100644 index 000000000..207b5b7e9 --- /dev/null +++ b/Examples/test-suite/python/pybuf.i @@ -0,0 +1,34 @@ +%module pybuf +%include + +%pybuffer_mutable_binary(char *buf1, int len); +%pybuffer_mutable_string(char *buf2); +%pybuffer_binary(const char *buf3, int len); +%pybuffer_string(const char *buf4); + +%inline %{ + void func1(char *buf1, int len) + { + int i; + for (i=0; i +%include +%pybuffer_mutable_string(char *str1); +%cstring_mutable(char *str2); + +%inline %{ +void title(char *str) { + int outword = 0; + while(*str) { + if (isalnum(*str)) { + if (outword) { + outword = 1; + *str = toupper(*str); + } + } + else { + outword = 0; + } + str++; + } +} + +void title1(char *str1) { + title(str1); +} +void title2(char *str2) { + title(str2); +} +%} diff --git a/Examples/test-suite/python/pybuf_benchmark_runme.py b/Examples/test-suite/python/pybuf_benchmark_runme.py new file mode 100644 index 000000000..6676a910b --- /dev/null +++ b/Examples/test-suite/python/pybuf_benchmark_runme.py @@ -0,0 +1,16 @@ +import pybuf +import time +k=1000000 +n=7 + +t=time.time() +a = bytearray(b'hello world') +for i in range(k): + pybuf.title1(a) +print "Time used by bytearray:",time.time()-t + +t=time.time() +b = 'hello world' +for i in range(k): + pybuf.title2(b) +print "Time used by string:",time.time()-t diff --git a/Examples/test-suite/python/pybuf_benchmark_runme3.py b/Examples/test-suite/python/pybuf_benchmark_runme3.py new file mode 100644 index 000000000..e412d5993 --- /dev/null +++ b/Examples/test-suite/python/pybuf_benchmark_runme3.py @@ -0,0 +1,16 @@ +import pybuf +import time +k=1000000 +n=7 + +t=time.time() +a = bytearray(b'hello world') +for i in range(k): + pybuf.title1(a) +print("Time used by bytearray:",time.time()-t) + +t=time.time() +b = 'hello world' +for i in range(k): + pybuf.title2(b) +print("Time used by string:",time.time()-t) diff --git a/Examples/test-suite/python/pybuf_runme3.py b/Examples/test-suite/python/pybuf_runme3.py new file mode 100644 index 000000000..462736bf0 --- /dev/null +++ b/Examples/test-suite/python/pybuf_runme3.py @@ -0,0 +1,15 @@ +import pybuf +buf1 = bytearray(10) +buf2 = bytearray(50) + +pybuf.func1(buf1) +assert buf1 == b'a'*10 + +pybuf.func2(buf2) +assert buf2.startswith(b"Hello world!\x00") + +count = pybuf.func3(buf2) +assert count==10 #number of alpha and number in 'Hello world!' + +length = pybuf.func4(buf2) +assert length==12 diff --git a/Examples/test-suite/python/template_typedef_cplx2_runme.py b/Examples/test-suite/python/template_typedef_cplx2_runme.py index 030fe02d8..04c599329 100644 --- a/Examples/test-suite/python/template_typedef_cplx2_runme.py +++ b/Examples/test-suite/python/template_typedef_cplx2_runme.py @@ -1,4 +1,3 @@ -import string from template_typedef_cplx2 import * # @@ -13,7 +12,7 @@ except: raise RuntimeError s = '%s' % d -if string.find(s, 'ArithUnaryFunction') == -1: +if str.find(s, 'ArithUnaryFunction') == -1: print d, "is not an ArithUnaryFunction" raise RuntimeError @@ -25,7 +24,7 @@ except: raise RuntimeError s = '%s' % e -if string.find(s, 'ArithUnaryFunction') == -1: +if str.find(s, 'ArithUnaryFunction') == -1: print e, "is not an ArithUnaryFunction" raise RuntimeError @@ -42,7 +41,7 @@ except: raise RuntimeError s = '%s' % c -if string.find(s, 'ArithUnaryFunction') == -1: +if str.find(s, 'ArithUnaryFunction') == -1: print c, "is not an ArithUnaryFunction" raise RuntimeError @@ -54,7 +53,7 @@ except: raise RuntimeError s = '%s' % f -if string.find(s, 'ArithUnaryFunction') == -1: +if str.find(s, 'ArithUnaryFunction') == -1: print f, "is not an ArithUnaryFunction" raise RuntimeError @@ -70,7 +69,7 @@ except: raise RuntimeError s = '%s' % g -if string.find(s, 'ArithUnaryFunction') == -1: +if str.find(s, 'ArithUnaryFunction') == -1: print g, "is not an ArithUnaryFunction" raise RuntimeError @@ -83,7 +82,7 @@ except: raise RuntimeError s = '%s' % h -if string.find(s, 'ArithUnaryFunction') == -1: +if str.find(s, 'ArithUnaryFunction') == -1: print h, "is not an ArithUnaryFunction" raise RuntimeError diff --git a/Examples/test-suite/python/template_typedef_cplx_runme.py b/Examples/test-suite/python/template_typedef_cplx_runme.py index 99ffcb9aa..2cd9c8348 100644 --- a/Examples/test-suite/python/template_typedef_cplx_runme.py +++ b/Examples/test-suite/python/template_typedef_cplx_runme.py @@ -1,4 +1,3 @@ -import string from template_typedef_cplx import * # @@ -13,7 +12,7 @@ except: raise RuntimeError s = '%s' % d -if string.find(s, 'ArithUnaryFunction') == -1: +if str.find(s, 'ArithUnaryFunction') == -1: print d, "is not an ArithUnaryFunction" raise RuntimeError @@ -25,7 +24,7 @@ except: raise RuntimeError s = '%s' % e -if string.find(s, 'ArithUnaryFunction') == -1: +if str.find(s, 'ArithUnaryFunction') == -1: print e, "is not an ArithUnaryFunction" raise RuntimeError @@ -42,7 +41,7 @@ except: raise RuntimeError s = '%s' % c -if string.find(s, 'ArithUnaryFunction') == -1: +if str.find(s, 'ArithUnaryFunction') == -1: print c, "is not an ArithUnaryFunction" raise RuntimeError @@ -54,7 +53,7 @@ except: raise RuntimeError s = '%s' % f -if string.find(s, 'ArithUnaryFunction') == -1: +if str.find(s, 'ArithUnaryFunction') == -1: print f, "is not an ArithUnaryFunction" raise RuntimeError @@ -70,7 +69,7 @@ except: raise RuntimeError s = '%s' % g -if string.find(s, 'ArithUnaryFunction') == -1: +if str.find(s, 'ArithUnaryFunction') == -1: print g, "is not an ArithUnaryFunction" raise RuntimeError @@ -83,6 +82,6 @@ except: raise RuntimeError s = '%s' % h -if string.find(s, 'ArithUnaryFunction') == -1: +if str.find(s, 'ArithUnaryFunction') == -1: print h, "is not an ArithUnaryFunction" raise RuntimeError diff --git a/Lib/python/file.i b/Lib/python/file.i index c0e7d5ea9..294ab9178 100644 --- a/Lib/python/file.i +++ b/Lib/python/file.i @@ -20,11 +20,13 @@ SWIG_AsValFilePtr(PyObject *obj, FILE **val) { if ((SWIG_ConvertPtr(obj, &vptr, desc, 0)) == SWIG_OK) { if (val) *val = (FILE *)vptr; return SWIG_OK; - } + } +%#if PY_VERSION_HEX < 0x03000000 if (PyFile_Check(obj)) { if (val) *val = PyFile_AsFile(obj); return SWIG_OK; } +%#endif return SWIG_TypeError; } } diff --git a/Lib/python/pyabc.i b/Lib/python/pyabc.i new file mode 100644 index 000000000..3da06b5a9 --- /dev/null +++ b/Lib/python/pyabc.i @@ -0,0 +1,10 @@ +%define %pythonabc(Type, Abc) + %feature("python:abc", #Abc) Type; +%enddef +%pythoncode {import collections}; +%pythonabc(std::vector, collections.MutableSequence); +%pythonabc(std::list, collections.MutableSequence); +%pythonabc(std::map, collections.MutableMapping); +%pythonabc(std::multimap, collections.MutableMapping); +%pythonabc(std::set, collections.MutableSet); +%pythonabc(std::multiset, collections.MutableSet); diff --git a/Lib/python/pyapi.swg b/Lib/python/pyapi.swg index 1d5148dbf..d980f9263 100644 --- a/Lib/python/pyapi.swg +++ b/Lib/python/pyapi.swg @@ -27,6 +27,20 @@ typedef struct swig_const_info { swig_type_info **ptype; } swig_const_info; + +/* ----------------------------------------------------------------------------- + * Wrapper of PyInstanceMethod_New() used in Python 3 + * It is exported to the generated module, used for -fastproxy + * ----------------------------------------------------------------------------- */ +SWIGRUNTIME PyObject* SWIG_PyInstanceMethod_New(PyObject *self, PyObject *func) +{ +#if PY_VERSION_HEX >= 0x03000000 + return PyInstanceMethod_New(func); +#else + return NULL; +#endif +} + #ifdef __cplusplus #if 0 { /* cc-mode */ diff --git a/Lib/python/pybuffer.i b/Lib/python/pybuffer.i new file mode 100644 index 000000000..3dc4c2121 --- /dev/null +++ b/Lib/python/pybuffer.i @@ -0,0 +1,107 @@ +/* Impelementing buffer protocol typemaps */ + +/* %pybuffer_mutable_binary(TYPEMAP, SIZE) + * + * Macro for functions accept mutable buffer pointer with a size. + * This can be used for both input and output. For example: + * + * %pybuffer_mutable_binary(char *buff, int size); + * void foo(char *buff, int size) { + * for(int i=0; i ObjX > ObjB + but ObjA < ObjB + */ + if( PyErr_Occurred() && PyErr_ExceptionMatches(PyExc_TypeError) ) + { + /* Objects can't be compared, this mostly occured in Python 3.0 */ + /* Compare their ptr directly for a workaround */ + res = (v < w); + PyErr_Clear(); + } SWIG_PYTHON_THREAD_END_BLOCK; return res; } @@ -597,6 +608,11 @@ namespace swig return !(self->empty()); } + /* Alias for Python 3 compatibility */ + bool __bool__() const { + return !(self->empty()); + } + size_type __len__() const { return self->size(); } @@ -618,6 +634,14 @@ namespace swig return x; } + /* typemap for slice object support */ + %typemap(in) PySliceObject* { + $1 = (PySliceObject *) $input; + } + %typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER) PySliceObject* { + $1 = PySlice_Check($input); + } + Sequence* __getslice__(difference_type i, difference_type j) throw (std::out_of_range) { return swig::getslice(self, i, j); } @@ -634,6 +658,43 @@ namespace swig void __delitem__(difference_type i) throw (std::out_of_range) { self->erase(swig::getpos(self,i)); } + + + /* Overloaded methods for Python 3 compatibility + * (Also useful in Python 2.x) + */ + Sequence* __getitem__(PySliceObject *slice) throw (std::out_of_range) { + Py_ssize_t i, j, step; + if( !PySlice_Check(slice) ) { + SWIG_Error(SWIG_TypeError, "Slice object expected."); + return NULL; + } + PySlice_GetIndices(slice, self->size(), &i, &j, &step); + return swig::getslice(self, i, j); + } + + void __setitem__(PySliceObject *slice, const Sequence& v) + throw (std::out_of_range, std::invalid_argument) { + Py_ssize_t i, j, step; + if( !PySlice_Check(slice) ) { + SWIG_Error(SWIG_TypeError, "Slice object expected."); + return; + } + PySlice_GetIndices(slice, self->size(), &i, &j, &step); + swig::setslice(self, i, j, v); + } + + void __delitem__(PySliceObject *slice) + throw (std::out_of_range) { + Py_ssize_t i, j, step; + if( !PySlice_Check(slice) ) { + SWIG_Error(SWIG_TypeError, "Slice object expected."); + return; + } + PySlice_GetIndices(slice, self->size(), &i, &j, &step); + swig::delslice(self, i,j); + } + } %enddef diff --git a/Lib/python/pyerrors.swg b/Lib/python/pyerrors.swg index e287e2fc8..01cf53e9b 100644 --- a/Lib/python/pyerrors.swg +++ b/Lib/python/pyerrors.swg @@ -58,12 +58,12 @@ SWIG_Python_AddErrorMsg(const char* mesg) PyObject *old_str = PyObject_Str(value); PyErr_Clear(); Py_XINCREF(type); - PyErr_Format(type, "%s %s", PyString_AsString(old_str), mesg); + + PyErr_Format(type, "%s %s", + SWIG_Python_str_AsChar(old_str), mesg); Py_DECREF(old_str); Py_DECREF(value); } else { PyErr_SetString(PyExc_RuntimeError, mesg); } } - - diff --git a/Lib/python/pyhead.swg b/Lib/python/pyhead.swg index 7839511bc..d73d3d112 100644 --- a/Lib/python/pyhead.swg +++ b/Lib/python/pyhead.swg @@ -1,3 +1,47 @@ +/* Compatibility marcos for Python 3 */ +#if PY_VERSION_HEX >= 0x03000000 + +#define PyClass_Check(obj) PyObject_IsInstance(obj, (PyObject *)&PyType_Type) + +#define PyInt_Check(x) PyLong_Check(x) +#define PyInt_AsLong(x) PyLong_AsLong(x) +#define PyInt_FromLong(x) PyLong_FromLong(x) + +#define PyString_Format(fmt, args) PyUnicode_Format(fmt, args) +#endif + +#ifndef Py_TYPE +# define Py_TYPE(op) ((op)->ob_type) +#endif + +/* SWIG APIs for compatibility of boht Python 2 & 3 */ + +#if PY_VERSION_HEX >= 0x03000000 +# define SWIG_Python_str_FromFormat PyUnicode_FromFormat +#else +# define SWIG_Python_str_FromFormat PyString_FromFormat +#endif + +SWIGINTERN char* +SWIG_Python_str_AsChar(PyObject *str) +{ +#if PY_VERSION_HEX >= 0x03000000 + str = PyUnicode_AsUTF8String(str); + return PyBytes_AsString(str); +#else + return PyString_AsString(str); +#endif +} + +SWIGINTERN PyObject* +SWIG_Python_str_FromChar(const char *c) +{ +#if PY_VERSION_HEX >= 0x03000000 + return PyUnicode_FromString(c); +#else + return PyString_FromString(c); +#endif +} /* Add PyOS_snprintf for old Pythons */ #if PY_VERSION_HEX < 0x02020000 diff --git a/Lib/python/pyinit.swg b/Lib/python/pyinit.swg index e6109b7bd..ab55765ad 100644 --- a/Lib/python/pyinit.swg +++ b/Lib/python/pyinit.swg @@ -33,18 +33,48 @@ typedef struct swig_varlinkobject { SWIGINTERN PyObject * swig_varlink_repr(swig_varlinkobject *SWIGUNUSEDPARM(v)) { +#if PY_VERSION_HEX >= 0x03000000 + return PyUnicode_InternFromString(""); +#else return PyString_FromString(""); +#endif } SWIGINTERN PyObject * swig_varlink_str(swig_varlinkobject *v) { +#if PY_VERSION_HEX >= 0x03000000 + PyObject *str = PyUnicode_InternFromString("("); + PyObject *tail; + PyObject *joined; + swig_globalvar *var; + for (var = v->vars; var; var=var->next) { + tail = PyUnicode_FromString(var->name); + joined = PyUnicode_Concat(str, tail); + Py_DecRef(str); + Py_DecRef(tail); + str = joined; + if (var->next) { + tail = PyUnicode_InternFromString(", "); + joined = PyUnicode_Concat(str, tail); + Py_DecRef(str); + Py_DecRef(tail); + str = joined; + } + } + tail = PyUnicode_InternFromString(")"); + joined = PyUnicode_Concat(str, tail); + Py_DecRef(str); + Py_DecRef(tail); + str = joined; +#else PyObject *str = PyString_FromString("("); - swig_globalvar *var; + swig_globalvar *var; for (var = v->vars; var; var=var->next) { PyString_ConcatAndDel(&str,PyString_FromString(var->name)); if (var->next) PyString_ConcatAndDel(&str,PyString_FromString(", ")); } PyString_ConcatAndDel(&str,PyString_FromString(")")); +#endif return str; } @@ -52,7 +82,7 @@ SWIGINTERN int swig_varlink_print(swig_varlinkobject *v, FILE *fp, int SWIGUNUSEDPARM(flags)) { PyObject *str = swig_varlink_str(v); fprintf(fp,"Swig global variables "); - fprintf(fp,"%s\n", PyString_AsString(str)); + fprintf(fp,"%s\n", SWIG_Python_str_AsChar(str)); Py_DECREF(str); return 0; } @@ -110,8 +140,13 @@ swig_varlink_type(void) { if (!type_init) { const PyTypeObject tmp = { + /* PyObject header changed in Python 3 */ +#if PY_VERSION_HEX >= 0x03000000 + PyVarObject_HEAD_INIT(&PyType_Type, 0) +#else PyObject_HEAD_INIT(NULL) 0, /* Number of items in variable part (ob_size) */ +#endif (char *)"swigvarlink", /* Type name (tp_name) */ sizeof(swig_varlinkobject), /* Basic size (tp_basicsize) */ 0, /* Itemsize (tp_itemsize) */ @@ -147,7 +182,10 @@ swig_varlink_type(void) { #endif }; varlink_type = tmp; + /* for Python 3 we already assigned the ob_type in PyVarObject_HEAD_INIT() */ +#if PY_VERSION_HEX < 0x03000000 varlink_type.ob_type = &PyType_Type; +#endif type_init = 1; } return &varlink_type; @@ -272,13 +310,35 @@ SWIG_Python_FixMethods(PyMethodDef *methods, #ifdef __cplusplus extern "C" #endif -SWIGEXPORT void SWIG_init(void) { + +SWIGEXPORT +#if PY_VERSION_HEX >= 0x03000000 + PyObject* +#else + void +#endif +SWIG_init(void) { PyObject *m, *d; /* Fix SwigMethods to carry the callback ptrs when needed */ SWIG_Python_FixMethods(SwigMethods, swig_const_table, swig_types, swig_type_initial); - +#if PY_VERSION_HEX >= 0x03000000 + static struct PyModuleDef SWIG_module = { + PyModuleDef_HEAD_INIT, + (char *) SWIG_name, + NULL, + -1, + SwigMethods, + NULL, + NULL, + NULL, + NULL + }; + + m = PyModule_Create(&SWIG_module); +#else m = Py_InitModule((char *) SWIG_name, SwigMethods); +#endif d = PyModule_GetDict(m); SWIG_InitializeModule(0); diff --git a/Lib/python/pyiterators.swg b/Lib/python/pyiterators.swg index 38f1791a9..62a7eaf70 100644 --- a/Lib/python/pyiterators.swg +++ b/Lib/python/pyiterators.swg @@ -66,6 +66,12 @@ namespace swig { return obj; } + /* Make an alias for Python 3.x */ + PyObject *__next__() + { + return next(); + } + PyObject *previous() { SWIG_PYTHON_THREAD_BEGIN_BLOCK; // disable threads @@ -335,6 +341,7 @@ namespace swig %catches(swig::stop_iteration) PySwigIterator::decr(size_t n = 1); %catches(std::invalid_argument) PySwigIterator::distance(const PySwigIterator &x) const; %catches(std::invalid_argument) PySwigIterator::equal (const PySwigIterator &x) const; + %catches(swig::stop_iteration) PySwigIterator::__next__(); %catches(swig::stop_iteration) PySwigIterator::next(); %catches(swig::stop_iteration) PySwigIterator::previous(); %catches(swig::stop_iteration) PySwigIterator::advance(ptrdiff_t n); @@ -370,6 +377,7 @@ namespace swig virtual PySwigIterator *copy() const = 0; PyObject *next(); + PyObject *__next__(); PyObject *previous(); PySwigIterator *advance(ptrdiff_t n); diff --git a/Lib/python/pyopers.swg b/Lib/python/pyopers.swg index 76f1e6789..bd5c954f0 100644 --- a/Lib/python/pyopers.swg +++ b/Lib/python/pyopers.swg @@ -33,6 +33,12 @@ /* Special cases */ %rename(__invert__) *::operator~; %rename(__call__) *::operator(); + +%feature("shadow") *::operator bool %{ +def __nonzero__(self): + return $action(self) +__bool__ = __nonzero__ +%}; %rename(__nonzero__) *::operator bool; /* Ignored operators */ diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index 844a66bec..4f51d3a95 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -348,9 +348,13 @@ PySwigObject_format(const char* fmt, PySwigObject *v) PyObject *args = PyTuple_New(1); if (args) { if (PyTuple_SetItem(args, 0, PySwigObject_long(v)) == 0) { - PyObject *ofmt = PyString_FromString(fmt); + PyObject *ofmt = SWIG_Python_str_FromChar(fmt); if (ofmt) { +#if PY_VERSION_HEX >= 0x03000000 + res = PyUnicode_Format(ofmt,args); +#else res = PyString_Format(ofmt,args); +#endif Py_DECREF(ofmt); } Py_DECREF(args); @@ -380,7 +384,7 @@ PySwigObject_repr(PySwigObject *v, PyObject *args) { const char *name = SWIG_TypePrettyName(v->ty); PyObject *hex = PySwigObject_hex(v); - PyObject *repr = PyString_FromFormat("", name, PyString_AsString(hex)); + PyObject *repr = SWIG_Python_str_FromFormat("", name, hex); Py_DECREF(hex); if (v->next) { #ifdef METH_NOARGS @@ -388,7 +392,14 @@ PySwigObject_repr(PySwigObject *v, PyObject *args) #else PyObject *nrep = PySwigObject_repr((PySwigObject *)v->next, args); #endif +#if PY_VERSION_HEX >= 0x03000000 + PyObject *joined = PyUnicode_Concat(repr, nrep); + Py_DecRef(repr); + Py_DecRef(nrep); + repr = joined; +#else PyString_ConcatAndDel(&repr,nrep); +#endif } return repr; } @@ -402,7 +413,7 @@ PySwigObject_print(PySwigObject *v, FILE *fp, int SWIGUNUSEDPARM(flags)) PyObject *repr = PySwigObject_repr(v, NULL); #endif if (repr) { - fputs(PyString_AsString(repr), fp); + fputs(SWIG_Python_str_AsChar(repr), fp); Py_DECREF(repr); return 0; } else { @@ -415,7 +426,7 @@ PySwigObject_str(PySwigObject *v) { char result[SWIG_BUFFER_SIZE]; return SWIG_PackVoidPtr(result, v->ptr, v->ty->name, sizeof(result)) ? - PyString_FromString(result) : 0; + SWIG_Python_str_FromChar(result) : 0; } SWIGRUNTIME int @@ -426,6 +437,24 @@ PySwigObject_compare(PySwigObject *v, PySwigObject *w) return (i < j) ? -1 : ((i > j) ? 1 : 0); } +/* Added for Python 3.x, whould it also useful for Python 2.x? */ +SWIGRUNTIME PyObject* +PySwigObject_richcompare(PySwigObject *v, PySwigObject *w, int op) +{ + PyObject* res; + if( op != Py_EQ && op != Py_NE ) { + Py_INCREF(Py_NotImplemented); + return Py_NotImplemented; + } + if( (PySwigObject_compare(v, w)==0) == (op == Py_EQ) ) + res = Py_True; + else + res = Py_False; + Py_INCREF(res); + return res; +} + + SWIGRUNTIME PyTypeObject* _PySwigObject_type(void); SWIGRUNTIME PyTypeObject* @@ -436,8 +465,8 @@ PySwigObject_type(void) { SWIGRUNTIMEINLINE int PySwigObject_Check(PyObject *op) { - return ((op)->ob_type == PySwigObject_type()) - || (strcmp((op)->ob_type->tp_name,"PySwigObject") == 0); + return (Py_TYPE(op) == PySwigObject_type()) + || (strcmp(Py_TYPE(op)->tp_name,"PySwigObject") == 0); } SWIGRUNTIME PyObject * @@ -610,7 +639,10 @@ _PySwigObject_type(void) { (binaryfunc)0, /*nb_add*/ (binaryfunc)0, /*nb_subtract*/ (binaryfunc)0, /*nb_multiply*/ + /* nb_divide removed in Python 3 */ +#if PY_VERSION_HEX < 0x03000000 (binaryfunc)0, /*nb_divide*/ +#endif (binaryfunc)0, /*nb_remainder*/ (binaryfunc)0, /*nb_divmod*/ (ternaryfunc)0,/*nb_power*/ @@ -624,13 +656,19 @@ _PySwigObject_type(void) { 0, /*nb_and*/ 0, /*nb_xor*/ 0, /*nb_or*/ - (coercion)0, /*nb_coerce*/ +#if PY_VERSION_HEX < 0x03000000 + 0, /*nb_coerce*/ +#endif (unaryfunc)PySwigObject_long, /*nb_int*/ (unaryfunc)PySwigObject_long, /*nb_long*/ (unaryfunc)0, /*nb_float*/ +#if PY_VERSION_HEX < 0x03000000 (unaryfunc)PySwigObject_oct, /*nb_oct*/ (unaryfunc)PySwigObject_hex, /*nb_hex*/ -#if PY_VERSION_HEX >= 0x02050000 /* 2.5.0 */ +#endif +#if PY_VERSION_HEX >= 0x03000000 /* 3.0 */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index, nb_inplace_divide removed */ +#elif PY_VERSION_HEX >= 0x02050000 /* 2.5.0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index */ #elif PY_VERSION_HEX >= 0x02020000 /* 2.2.0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_true_divide */ @@ -644,8 +682,13 @@ _PySwigObject_type(void) { if (!type_init) { const PyTypeObject tmp = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ + /* PyOjbect header changed in Python 3 */ +#if PY_VERSION_HEX >= 0x03000000 + PyVarObject_HEAD_INIT(&PyType_Type, 0) +#else + PyObject_HEAD_INIT(NULL) + 0, /* ob_size */ +#endif (char *)"PySwigObject", /* tp_name */ sizeof(PySwigObject), /* tp_basicsize */ 0, /* tp_itemsize */ @@ -672,7 +715,7 @@ _PySwigObject_type(void) { swigobject_doc, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ - 0, /* tp_richcompare */ + (richcmpfunc)PySwigObject_richcompare, /* tp_richcompare */ 0, /* tp_weaklistoffset */ #if PY_VERSION_HEX >= 0x02020000 0, /* tp_iter */ @@ -704,7 +747,10 @@ _PySwigObject_type(void) { #endif }; pyswigobject_type = tmp; + /* for Python 3 we already assigned the ob_type in PyVarObject_HEAD_INIT() */ +#if PY_VERSION_HEX < 0x03000000 pyswigobject_type.ob_type = &PyType_Type; +#endif type_init = 1; } return &pyswigobject_type; @@ -753,9 +799,9 @@ PySwigPacked_repr(PySwigPacked *v) { char result[SWIG_BUFFER_SIZE]; if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) { - return PyString_FromFormat("", result, v->ty->name); + return SWIG_Python_str_FromFormat("", result, v->ty->name); } else { - return PyString_FromFormat("", v->ty->name); + return SWIG_Python_str_FromFormat("", v->ty->name); } } @@ -764,9 +810,9 @@ PySwigPacked_str(PySwigPacked *v) { char result[SWIG_BUFFER_SIZE]; if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))){ - return PyString_FromFormat("%s%s", result, v->ty->name); + return SWIG_Python_str_FromFormat("%s%s", result, v->ty->name); } else { - return PyString_FromString(v->ty->name); + return SWIG_Python_str_FromChar(v->ty->name); } } @@ -811,8 +857,13 @@ _PySwigPacked_type(void) { if (!type_init) { const PyTypeObject tmp = { + /* PyObject header changed in Python 3 */ +#if PY_VERSION_HEX>=0x03000000 + PyVarObject_HEAD_INIT(&PyType_Type, 0) +#else PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ + 0, /* ob_size */ +#endif (char *)"PySwigPacked", /* tp_name */ sizeof(PySwigPacked), /* tp_basicsize */ 0, /* tp_itemsize */ @@ -867,7 +918,10 @@ _PySwigPacked_type(void) { #endif }; pyswigpacked_type = tmp; + /* for Python 3 the ob_type already assigned in PyVarObject_HEAD_INIT() */ +#if PY_VERSION_HEX < 0x03000000 pyswigpacked_type.ob_type = &PyType_Type; +#endif type_init = 1; } return &pyswigpacked_type; @@ -912,7 +966,7 @@ PySwigPacked_UnpackData(PyObject *obj, void *ptr, size_t size) SWIGRUNTIMEINLINE PyObject * _SWIG_This(void) { - return PyString_FromString("this"); + return SWIG_Python_str_FromChar("this"); } SWIGRUNTIME PyObject * @@ -924,6 +978,11 @@ SWIG_This(void) /* #define SWIG_PYTHON_SLOW_GETSET_THIS */ +/* TODO: I don't know how to implement the fast getset in Python 3 right now */ +#if PY_VERSION_HEX>=0x03000000 +#define SWIG_PYTHON_SLOW_GETSET_THIS +#endif + SWIGRUNTIME PySwigObject * SWIG_Python_GetSwigThis(PyObject *pyobj) { @@ -1161,10 +1220,17 @@ SWIG_Python_NewShadowInstance(PySwigClientData *data, PyObject *swig_this) #endif } } else { +#if PY_VERSION_HEX >= 0x03000000 + inst = PyBaseObject_Type.tp_new((PyTypeObject*) data->newargs, Py_None, Py_None); + Py_INCREF(data->newargs); + PyObject_SetAttr(inst, SWIG_This(), swig_this); + Py_TYPE(inst)->tp_flags &= ~Py_TPFLAGS_VALID_VERSION_TAG; +#else PyObject *dict = PyDict_New(); PyDict_SetItem(dict, SWIG_This(), swig_this); inst = PyInstance_NewRaw(data->newargs, dict); Py_DECREF(dict); +#endif } return inst; #else @@ -1344,8 +1410,13 @@ SWIGRUNTIME void SWIG_Python_SetModule(swig_module_info *swig_module) { static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} };/* Sentinel */ +#if PY_VERSION_HEX >= 0x03000000 + /* Add a dummy module object into sys.modules */ + PyObject *module = PyImport_AddModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION); +#else PyObject *module = Py_InitModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, swig_empty_runtime_method_table); +#endif PyObject *pointer = PyCObject_FromVoidPtr((void *) swig_module, SWIG_Python_DestroyModule); if (pointer && module) { PyModule_AddObject(module, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME, pointer); @@ -1365,7 +1436,7 @@ SWIGRUNTIME swig_type_info * SWIG_Python_TypeQuery(const char *type) { PyObject *cache = SWIG_Python_TypeCache(); - PyObject *key = PyString_FromString(type); + PyObject *key = SWIG_Python_str_FromChar(type); PyObject *obj = PyDict_GetItem(cache, key); swig_type_info *descriptor; if (obj) { @@ -1403,9 +1474,9 @@ SWIG_Python_AddErrMesg(const char* mesg, int infront) Py_XINCREF(type); PyErr_Clear(); if (infront) { - PyErr_Format(type, "%s %s", mesg, PyString_AsString(old_str)); + PyErr_Format(type, "%s %s", mesg, SWIG_Python_str_AsChar(old_str)); } else { - PyErr_Format(type, "%s %s", PyString_AsString(old_str), mesg); + PyErr_Format(type, "%s %s", SWIG_Python_str_AsChar(old_str), mesg); } Py_DECREF(old_str); } @@ -1454,7 +1525,7 @@ SWIG_Python_TypeError(const char *type, PyObject *obj) const char *otype = (obj ? obj->ob_type->tp_name : 0); if (otype) { PyObject *str = PyObject_Str(obj); - const char *cstr = str ? PyString_AsString(str) : 0; + const char *cstr = str ? SWIG_Python_str_AsChar(str) : 0; if (cstr) { PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s(%s)' is received", type, otype, cstr); diff --git a/Lib/python/pystrings.swg b/Lib/python/pystrings.swg index d4d60c42b..5a06792d7 100644 --- a/Lib/python/pystrings.swg +++ b/Lib/python/pystrings.swg @@ -5,10 +5,20 @@ SWIGINTERN int SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc) { - if (PyString_Check(obj)) { +%#if PY_VERSION_HEX>=0x03000000 + if (PyUnicode_Check(obj)) +%#else + if (PyString_Check(obj)) +%#endif + { char *cstr; Py_ssize_t len; +%#if PY_VERSION_HEX>=0x03000000 + obj = PyUnicode_AsUTF8String(obj); + PyBytes_AsStringAndSize(obj, &cstr, &len); +%#else PyString_AsStringAndSize(obj, &cstr, &len); - if (cptr) { +%#endif + if (cptr) { if (alloc) { /* In python the user should not be able to modify the inner @@ -33,7 +43,7 @@ SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc) *alloc = SWIG_OLDOBJ; } } else { - *cptr = PyString_AsString(obj); + *cptr = SWIG_Python_str_AsChar(obj); } } if (psize) *psize = len + 1; @@ -64,7 +74,11 @@ SWIG_FromCharPtrAndSize(const char* carray, size_t size) return pchar_descriptor ? SWIG_NewPointerObj(%const_cast(carray,char *), pchar_descriptor, 0) : SWIG_Py_Void(); } else { +%#if PY_VERSION_HEX >= 0x03000000 + return PyUnicode_FromStringAndSize(carray, %numeric_cast(size,int)); +%#else return PyString_FromStringAndSize(carray, %numeric_cast(size,int)); +%#endif } } else { return SWIG_Py_Void(); diff --git a/Lib/python/pywstrings.swg b/Lib/python/pywstrings.swg index 8254bf8f7..4161dcb0f 100644 --- a/Lib/python/pywstrings.swg +++ b/Lib/python/pywstrings.swg @@ -8,12 +8,14 @@ SWIG_AsWCharPtrAndSize(PyObject *obj, wchar_t **cptr, size_t *psize, int *alloc) { PyObject *tmp = 0; int isunicode = PyUnicode_Check(obj); +%#if PY_VERSION_HEX < 0x03000000 if (!isunicode && PyString_Check(obj)) { if (cptr) { obj = tmp = PyUnicode_FromObject(obj); } isunicode = 1; } +%#endif if (isunicode) { int len = PyUnicode_GetSize(obj); if (cptr) { diff --git a/Lib/python/std_map.i b/Lib/python/std_map.i index 12dc23ccf..b080731f0 100644 --- a/Lib/python/std_map.i +++ b/Lib/python/std_map.i @@ -22,6 +22,10 @@ int res = SWIG_ERROR; if (PyDict_Check(obj)) { PyObject_var 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!"); +%#endif res = traits_asptr_stdseq, std::pair >::asptr(items, val); } else { map_type *p; diff --git a/Source/CParse/cscanner.c b/Source/CParse/cscanner.c index 032c71f7e..871565df8 100644 --- a/Source/CParse/cscanner.c +++ b/Source/CParse/cscanner.c @@ -690,7 +690,15 @@ int yylex(void) { termtoken = SWIG_TOKEN_LPAREN; termvalue = "("; break; - } else if (nexttok == SWIG_TOKEN_SEMI) { + } else if (nexttok == SWIG_TOKEN_CODEBLOCK) { + termtoken = SWIG_TOKEN_CODEBLOCK; + termvalue = Scanner_text(scan); + break; + } else if (nexttok == SWIG_TOKEN_LBRACE) { + termtoken = SWIG_TOKEN_LBRACE; + termvalue = "{"; + break; + } else if (nexttok == SWIG_TOKEN_SEMI) { termtoken = SWIG_TOKEN_SEMI; termvalue = ";"; break; @@ -859,8 +867,14 @@ int yylex(void) { return (INLINE); if (strcmp(yytext, "%typemap") == 0) return (TYPEMAP); - if (strcmp(yytext, "%feature") == 0) + if (strcmp(yytext, "%feature") == 0) { + /* The rename_active indicates we don't need the information of the + * following function's return type. This applied for %rename, so do + * %feature. + */ + rename_active = 1; return (FEATURE); + } if (strcmp(yytext, "%except") == 0) return (EXCEPT); if (strcmp(yytext, "%importfile") == 0) diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index 58e0c0c41..69c2a503d 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -2290,21 +2290,25 @@ feature_directive : FEATURE LPAREN idstring RPAREN declarator cpp_const stringbr String *val = $7 ? NewString($7) : NewString("1"); new_feature($3, val, 0, $5.id, $5.type, $5.parms, $6.qualifier); $$ = 0; + scanner_clear_rename(); } | FEATURE LPAREN idstring COMMA stringnum RPAREN declarator cpp_const SEMI { String *val = Len($5) ? NewString($5) : 0; new_feature($3, val, 0, $7.id, $7.type, $7.parms, $8.qualifier); $$ = 0; + scanner_clear_rename(); } | FEATURE LPAREN idstring featattr RPAREN declarator cpp_const stringbracesemi { String *val = $8 ? NewString($8) : NewString("1"); new_feature($3, val, $4, $6.id, $6.type, $6.parms, $7.qualifier); $$ = 0; + scanner_clear_rename(); } | FEATURE LPAREN idstring COMMA stringnum featattr RPAREN declarator cpp_const SEMI { String *val = Len($5) ? NewString($5) : 0; new_feature($3, val, $6, $8.id, $8.type, $8.parms, $9.qualifier); $$ = 0; + scanner_clear_rename(); } /* Global feature */ @@ -2312,21 +2316,25 @@ feature_directive : FEATURE LPAREN idstring RPAREN declarator cpp_const stringbr String *val = $5 ? NewString($5) : NewString("1"); new_feature($3, val, 0, 0, 0, 0, 0); $$ = 0; + scanner_clear_rename(); } | FEATURE LPAREN idstring COMMA stringnum RPAREN SEMI { String *val = Len($5) ? NewString($5) : 0; new_feature($3, val, 0, 0, 0, 0, 0); $$ = 0; + scanner_clear_rename(); } | FEATURE LPAREN idstring featattr RPAREN stringbracesemi { String *val = $6 ? NewString($6) : NewString("1"); new_feature($3, val, $4, 0, 0, 0, 0); $$ = 0; + scanner_clear_rename(); } | FEATURE LPAREN idstring COMMA stringnum featattr RPAREN SEMI { String *val = Len($5) ? NewString($5) : 0; new_feature($3, val, $6, 0, 0, 0, 0); $$ = 0; + scanner_clear_rename(); } ; diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index ddd23d1f3..7a878b4f8 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -49,10 +49,11 @@ static String *shadow_indent = 0; static int in_class = 0; static int classic = 0; static int modern = 0; -static int apply = 0; static int new_repr = 1; static int no_header_file = 0; +static int py3 = 0; + /* C++ Support + Shadow Classes */ static int have_constructor; @@ -96,7 +97,6 @@ enum autodoc_t { static const char *usage1 = (char *) "\ Python Options (available with -python)\n\ -aliasobj0 - Alias obj0 when using fastunpack, needed for some old typemaps \n\ - -apply - Use apply() in proxy classes\n\ -buildnone - Use Py_BuildValue(" ") to obtain Py_None (default in Windows)\n\ -castmode - Enable the casting mode, which allows implicit cast between types in python\n\ -classic - Use classic classes only\n\ @@ -148,6 +148,8 @@ static const char *usage3 = (char *) "\ -O - Enable all the optimization options: \n\ -modern -fastdispatch -dirvtable -nosafecstrings -fvirtual -noproxydel \n\ -fastproxy -fastinit -fastunpack -fastquery -modernargs -nobuildnone \n\ + -py3 - Generate code with Python 3 specific features:\n\ + Function annotation \n\ \n"; class PYTHON:public Language { @@ -259,9 +261,6 @@ public: } else if ((strcmp(argv[i], "-shadow") == 0) || ((strcmp(argv[i], "-proxy") == 0))) { shadow = 1; Swig_mark_arg(i); - } else if (strcmp(argv[i], "-apply") == 0) { - apply = 1; - Swig_mark_arg(i); } else if ((strcmp(argv[i], "-new_repr") == 0) || (strcmp(argv[i], "-newrepr") == 0)) { new_repr = 1; Swig_mark_arg(i); @@ -284,7 +283,6 @@ public: } else if (strcmp(argv[i], "-classic") == 0) { classic = 1; modernargs = 0; - apply = 1; modern = 0; Swig_mark_arg(i); } else if (strcmp(argv[i], "-cppcast") == 0) { @@ -390,7 +388,6 @@ public: proxydel = 0; Swig_mark_arg(i); } else if (strcmp(argv[i], "-modern") == 0) { - apply = 0; classic = 0; modern = 1; modernargs = 1; @@ -408,7 +405,6 @@ public: no_header_file = 1; Swig_mark_arg(i); } else if (strcmp(argv[i], "-O") == 0) { - apply = 0; classic = 0; modern = 1; dirvtable = 1; @@ -429,8 +425,17 @@ public: fputs(usage1, stdout); fputs(usage2, stdout); fputs(usage3, stdout); - } + } else if (strcmp(argv[i], "-py3") == 0) { + py3 = 1; + Swig_mark_arg(i); + } + } + } /* for */ + + if (py3) { + /* force disable features that not compatible with Python 3.x */ + classic = 0; } if (cppcast) { @@ -691,6 +696,13 @@ public: Printv(f_shadow, "\nfrom sys import version_info\n", NULL); + if(fastproxy) + { + Printv(f_shadow, "if version_info >= (3,0,0):\n", NULL); + Printf(f_shadow, tab4 "new_instancemethod = lambda func, inst, cls: %s.SWIG_PyInstanceMethod_New(func)\n", module); + Printv(f_shadow, "else:\n", NULL); + Printv(f_shadow, tab4, "from new import instancemethod as new_instancemethod\n", NULL); + } /* Import the C-extension module. This should be a relative import, * since the shadow module may also have been imported by a relative * import, and there is thus no guarantee that the C-extension is on @@ -719,11 +731,9 @@ public: * module. */ Printv(f_shadow, "del version_info\n", NULL); - Printv(f_shadow, "import new\n", NULL); - Printv(f_shadow, "new_instancemethod = new.instancemethod\n", NULL); if (modern || !classic) { Printv(f_shadow, "try:\n", tab4, "_swig_property = property\n", "except NameError:\n", tab4, "pass # Python < 2.2 doesn't have 'property'.\n", NULL); - } + } /* if (!modern) */ /* always needed, a class can be forced to be no-modern, such as an exception */ { @@ -750,7 +760,7 @@ public: "def _swig_getattr(self,class_type,name):\n", tab4, "if (name == \"thisown\"): return self.this.own()\n", tab4, "method = class_type.__swig_getmethods__.get(name,None)\n", - tab4, "if method: return method(self)\n", tab4, "raise AttributeError,name\n\n", NIL); + tab4, "if method: return method(self)\n", tab4, "raise AttributeError(name)\n\n", NIL); Printv(f_shadow, "def _swig_repr(self):\n", @@ -758,11 +768,17 @@ public: tab4, "except: strthis = \"\"\n", tab4, "return \"<%s.%s; %s >\" % (self.__class__.__module__, self.__class__.__name__, strthis,)\n\n", NIL); if (!classic) { + /* Usage of types.ObjectType is deprecated. + * But don't sure wether this would broken old Python? + */ Printv(f_shadow, - "import types\n", +// "import types\n", "try:\n", - " _object = types.ObjectType\n", - " _newclass = 1\n", "except AttributeError:\n", " class _object : pass\n", " _newclass = 0\n", "del types\n", "\n\n", NIL); +// " _object = types.ObjectType\n", + " _object = object\n", + " _newclass = 1\n", "except AttributeError:\n", " class _object : pass\n", " _newclass = 0\n", +// "del types\n", + "\n\n", NIL); } } if (modern) { @@ -788,7 +804,11 @@ public: } - Printf(f_header, "#define SWIG_init init%s\n\n", module); + Printf(f_header, "#if PY_VERSION_HEX >= 0x03000000\n"); + Printf(f_header, "# define SWIG_init PyInit_%s\n\n", module); + Printf(f_header, "#else\n"); + Printf(f_header, "# define SWIG_init init%s\n\n", module); + Printf(f_header, "#endif\n"); Printf(f_header, "#define SWIG_name \"%s\"\n", module); Printf(f_wrappers, "#ifdef __cplusplus\n"); @@ -797,6 +817,9 @@ public: Append(const_code, "static swig_const_info swig_const_table[] = {\n"); Append(methods, "static PyMethodDef SwigMethods[] = {\n"); + /* the method exported for replacement of new.instancemethod in Python 3 */ + add_pyinstancemethod_new(); + /* emit code */ Language::top(n); @@ -815,6 +838,12 @@ public: Append(const_code, "{0, 0, 0, 0.0, 0, 0}};\n"); Printf(f_wrappers, "%s\n", const_code); initialize_threads(f_init); + + Printf(f_init, "#if PY_VERSION_HEX >= 0x03000000\n"); + Printf(f_init, " return m;\n"); + Printf(f_init, "#else\n"); + Printf(f_init, " return;\n"); + Printf(f_init, "#endif\n"); Printf(f_init, "}\n"); Printf(f_wrappers, "#ifdef __cplusplus\n"); @@ -822,10 +851,6 @@ public: Printf(f_wrappers, "#endif\n"); if (shadow) { - /* - Printf(f_shadow_imports,"\nimport %s\n", module); - Printv(f_shadow_py, f_shadow_imports, "\n",NIL); - */ Printv(f_shadow_py, f_shadow, "\n", NIL); Printv(f_shadow_py, f_shadow_stubs, "\n", NIL); @@ -859,6 +884,19 @@ public: return SWIG_OK; } + + /* ------------------------------------------------------------ + * Emit the wrapper for PyInstanceMethod_New to MethodDef array. + * This wrapper is used to implement -fastproxy, + * as a replacement of new.instancemethod in Python 3. + * ------------------------------------------------------------ */ + int add_pyinstancemethod_new() + { + String* name = NewString("SWIG_PyInstanceMethod_New"); + Printf(methods, "\t { (char *)\"%s\", (PyCFunction)%s, METH_O, NULL},", name, name); + Delete(name); + return 0; + } /* ------------------------------------------------------------ * importDirective() @@ -902,25 +940,19 @@ public: return Language::importDirective(n); } - /* ------------------------------------------------------------ - * emitFuncCallHelper() - * Write the shadow code to call a function in the extension - * module. Takes into account the -apply flag and whether - * to use keyword args or not. + * funcCall() + * Emit shadow code to call a function in the extension + * module. Using proper argument and calling style for + * given node n. * ------------------------------------------------------------ */ + String *funcCall(String *name, String *parms) { + String *str = NewString(""); - String *funcCallHelper(String *name, int kw) { - String *str; - - str = NewString(""); - if (apply) { - Printv(str, "apply(", module, ".", name, ", args", (kw ? ", kwargs" : ""), ")", NIL); - } else { - Printv(str, module, ".", name, "(*args", (kw ? ", **kwargs" : ""), ")", NIL); - } + Printv(str, module, ".", name, "(", parms, ")", NIL); return str; - } + } + /* ------------------------------------------------------------ * pythoncode() - Output python code into the shadow file @@ -1088,29 +1120,84 @@ public: return doc; } + /* ----------------------------------------------------------------------------- + * makeParameterName() + * Note: the generated name should consist with that in kwnames[] + * + * Inputs: + * n - Node + * p - parameter node + * arg_num - parameter argument number + * Return: + * arg - a unique parameter name + * ----------------------------------------------------------------------------- */ + + String *makeParameterName(ParmList *plist, Parm *p, int arg_num) { + String *arg = 0; + String *pn = Swig_name_make(p, 0, Getattr(p, "name"), 0, 0); + // Use C parameter name unless it is a duplicate or an empty parameter name + int count = 0; + if ( SwigType_isvarargs(Getattr(p, "type")) ) { + return NewString("*args"); + } + while (plist) { + if ((Cmp(pn, Getattr(plist, "name")) == 0)) + count++; + plist = nextSibling(plist); + } + arg = (!pn || !Len(pn) || (count > 1)) ? NewStringf("arg%d", arg_num) : Copy(pn); + return arg; + } + + /* ------------------------------------------------------------ * make_autodocParmList() * Generate the documentation for the function parameters + * Parameters: + * func_annotation: Function annotation support * ------------------------------------------------------------ */ - String *make_autodocParmList(Node *n, bool showTypes) { + String *make_autodocParmList(Node *n, bool showTypes, bool calling=false, bool func_annotation=false) { + + String *doc = NewString(""); String *pdocs = Copy(Getattr(n, "feature:pdocs")); ParmList *plist = CopyParmList(Getattr(n, "parms")); Parm *p; Parm *pnext; - Node *lookup; + Node *lookup; + + int lines = 0; + int arg_num = 0; const int maxwidth = 50; + if(calling) + func_annotation = false; + if (pdocs) Append(pdocs, "\n"); - Swig_typemap_attach_parms("in", plist, 0); Swig_typemap_attach_parms("doc", plist, 0); - + + if (Strcmp(ParmList_protostr(plist), "void")==0) { + //No parameters actually + return doc; + } + for (p = plist; p; p = pnext) { + + String *tm = Getattr(p, "tmap:in"); + if (tm) { + pnext = Getattr(p, "tmap:in:next"); + if (checkAttribute(p, "tmap:in:numinputs", "0")) { + continue; + } + } else { + pnext = nextSibling(p); + } + String *name = 0; String *type = 0; String *value = 0; @@ -1127,12 +1214,14 @@ public: type = type ? type : Getattr(p, "type"); value = value ? value : Getattr(p, "value"); - String *tm = Getattr(p, "tmap:in"); - if (tm) { - pnext = Getattr(p, "tmap:in:next"); - } else { - pnext = nextSibling(p); - } + name = makeParameterName(plist, p, arg_num); + // Reset it for convinient in further use. (mainly for makeParameterName()) + // Since the plist is created by CopyParmList, + // we can hope that the set would have no side effect + Setattr(p, "name", name); + + arg_num++; + if (Len(doc)) { // add a comma to the previous one if any @@ -1144,39 +1233,40 @@ public: lines += 1; } } + + type = SwigType_base(type); + lookup = Swig_symbol_clookup(type, 0); + if (lookup) + type = Getattr(lookup, "sym:name"); + // Do the param type too? - if (showTypes) { - type = SwigType_base(type); - lookup = Swig_symbol_clookup(type, 0); - if (lookup) - type = Getattr(lookup, "sym:name"); - Printf(doc, "%s ", type); + if (showTypes) + Printf(doc, "%s ", type); + + + Append(doc, name); + if (pdoc) { + if (!pdocs) + pdocs = NewString("Parameters:\n"); + Printf(pdocs, " %s\n", pdoc); } - if (name) { - Append(doc, name); - if (pdoc) { - if (!pdocs) - pdocs = NewString("Parameters:\n"); - Printf(pdocs, " %s\n", pdoc); - } - } else { - Append(doc, "?"); - } + // Write the function annoation + if (func_annotation) + Printf(doc, " : '%s'", type); - if (value) { - if (Strcmp(value, "NULL") == 0) - value = NewString("None"); - else if (Strcmp(value, "true") == 0 || Strcmp(value, "TRUE") == 0) - value = NewString("True"); - else if (Strcmp(value, "false") == 0 || Strcmp(value, "FALSE") == 0) - value = NewString("False"); + // Write default value + if (value && !calling) { + String* pv = pyvalue(value, Getattr(p, "type")); + if (pv) + value = pv; else { lookup = Swig_symbol_clookup(value, 0); - if (lookup) + if (lookup) { value = Getattr(lookup, "sym:name"); + } } - Printf(doc, "=%s", value); + Printf(doc, " = %s", value); } } if (pdocs) @@ -1314,6 +1404,132 @@ public: return doc; } + + /* ------------------------------------------------------------ + * pyvalue() + * Check if string v can be a Python value literal, + * (eg. number or string), or translate it to a Python literal. + * ------------------------------------------------------------ */ + String* pyvalue(String *v, SwigType *t) + { + if (v && Len(v)>0) { + char fc = (Char(v))[0]; + if (('0'<=fc && fc<='9') || '\''==fc || '"'==fc) { + /* number or string (or maybe NULL pointer)*/ + if (SwigType_ispointer(t) && Strcmp(v, "0")==0) + return NewString("None"); + else + return v; + } + if (Strcmp(v, "true")==0 || Strcmp(v, "FALSE")==0) + return NewString("True"); + if (Strcmp(v, "false")==0 || Strcmp(v, "FALSE")==0) + return NewString("False"); + if (Strcmp(v, "NULL")==0) + return NewString("None"); + } + return 0; + } + /* ------------------------------------------------------------ + * is_primitive_defaultargs() + * Check if all the default args have primitive type. + * (So we can generate proper parameter list with default + * values..) + * ------------------------------------------------------------ */ + bool is_primitive_defaultargs(Node *n) + { + ParmList *plist = CopyParmList(Getattr(n, "parms")); + Parm *p; + Parm *pnext; + + Swig_typemap_attach_parms("in", plist, 0); + for (p = plist; p; p = pnext) { + String *tm = Getattr(p, "tmap:in"); + if (tm) { + pnext = Getattr(p, "tmap:in:next"); + if (checkAttribute(p, "tmap:in:numinputs", "0")) { + continue; + } + } else { + pnext = nextSibling(p); + } + String *type = Getattr(p, "type"); + String *value = Getattr(p, "value"); + if (!pyvalue(value, type)) + return false; + } + return true; + } + + + /* ------------------------------------------------------------ + * is_real_overloaded() + * Check if the function is overloaded, but not just have some + * siblings generated due to the original function have + * default arguments. + * ------------------------------------------------------------ */ + bool is_real_overloaded(Node *n) + { + Node *h = Getattr(n, "sym:overloaded"); + Node *i; + if (!h) + return false; + + i = Getattr(h, "sym:nextSibling"); + while (i) { + Node *nn = Getattr(i, "defaultargs"); + if (nn != h) { + /* Check if overloaded function has defaultargs and + * pointed to the first overloaded. */ + return true; + } + i = Getattr(i, "sym:nextSibling"); + } + + return false; + } + + /* ------------------------------------------------------------ + * make_pyParmList() + * Generate parameter list for Python functions or methods, + * reuse make_autodocParmList() to do so. + * ------------------------------------------------------------ */ + String* make_pyParmList(Node *n, bool in_class, bool is_calling, int kw) + { + /* Get the original function for a defaultargs copy, + * see default_arguments() in parser.y. */ + Node *nn = Getattr(n, "defaultargs"); + if (nn) n = nn; + + /* For overloaded function, just use *args */ + if (is_real_overloaded(n) || + GetFlag(n, "feature:compactdefaultargs") || + !is_primitive_defaultargs(n)) + { + String *parms = NewString(""); + if(in_class) + Printf(parms, "self, "); + Printf(parms, "*args"); + if (kw) + Printf(parms, ", **kwargs"); + return parms; + } + + bool funcanno = py3 ? true : false; + String *params = NewString(""); + String *_params = make_autodocParmList(n, false, is_calling, funcanno); + + if (in_class) + { + Printf(params, "self"); + if(Len(_params) > 0) + Printf(params, ", "); + } + + Printv(params, _params, NULL); + + return params; + } /* ------------------------------------------------------------ * have_pythonprepend() @@ -1379,6 +1595,40 @@ public: return have_pythonappend(n) || have_pythonprepend(n) || have_docstring(n); } + + /* ------------------------------------------------------------ + * returnTypeAnnotation() + * Helper function for constructing the function annotation + * of the returning type, return a empty string for Python 2.x + * ------------------------------------------------------------ */ + String* returnTypeAnnotation(Node *n) + { + String *ret=0; + Parm *p = Getattr(n, "parms"); + String *tm; + /* Try to guess the returning type by argout typemap, + * however the result may not accurate. */ + while (p) { + if ((tm=Getattr(p, "tmap:argout:match_type"))) { + tm = SwigType_str(tm, 0); + if (ret) + Printv(ret, ", ", tm, NULL); + else + ret = tm; + p = Getattr(p, "tmap:argout:next"); + } else { + p = nextSibling(p); + } + } + /* If no argout typemap, then get the returning type from + * the function prototype. */ + if (!ret) { + ret = Getattr(n, "type"); + if (ret) ret = SwigType_str(ret, 0); + } + return (ret && py3) ? NewStringf(" -> \"%s\" ", ret) + : NewString(""); + } /* ------------------------------------------------------------ * emitFunctionShadowHelper() @@ -1388,24 +1638,26 @@ public: * ------------------------------------------------------------ */ void emitFunctionShadowHelper(Node *n, File *f_dest, String *name, int kw) { - if (Getattr(n, "feature:python:callback") || !have_addtofunc(n)) { - /* If there is no addtofunc directive then just assign from the extension module */ - Printv(f_dest, name, " = ", module, ".", name, "\n", NIL); + String *parms = make_pyParmList(n, false, false, kw); + String *callParms = make_pyParmList(n, false, true, kw); + /* Make a wrapper function to insert the code into */ + Printv(f_dest, "\ndef ", name, "(", parms, ")", returnTypeAnnotation(n), ":\n", NIL); + if (have_docstring(n)) + Printv(f_dest, ctab4, docstring(n, AUTODOC_FUNC, tab4), "\n", NIL); + if (have_pythonprepend(n)) + Printv(f_dest, ctab4, pythonprepend(n), "\n", NIL); + if (have_pythonappend(n)) { + Printv(f_dest, ctab4, "val = ", funcCall(name, callParms), "\n", NIL); + Printv(f_dest, ctab4, pythonappend(n), "\n", NIL); + Printv(f_dest, ctab4, "return val\n", NIL); } else { - /* Otherwise make a wrapper function to insert the code into */ - Printv(f_dest, "\ndef ", name, "(*args", (kw ? ", **kwargs" : ""), "):\n", NIL); - if (have_docstring(n)) - Printv(f_dest, ctab4, docstring(n, AUTODOC_FUNC, tab4), "\n", NIL); - if (have_pythonprepend(n)) - Printv(f_dest, ctab4, pythonprepend(n), "\n", NIL); - if (have_pythonappend(n)) { - Printv(f_dest, ctab4, "val = ", funcCallHelper(name, kw), "\n", NIL); - Printv(f_dest, ctab4, pythonappend(n), "\n", NIL); - Printv(f_dest, ctab4, "return val\n", NIL); - } else { - Printv(f_dest, ctab4, "return ", funcCallHelper(name, kw), "\n", NIL); - } + Printv(f_dest, ctab4, "return ", funcCall(name, callParms), "\n", NIL); } + + if (Getattr(n, "feature:python:callback") || !have_addtofunc(n)) { + /* If there is no addtofunc directive then just assign from the extension module (for speed up) */ + Printv(f_dest, name, " = ", module, ".", name, "\n", NIL); + } } @@ -2488,7 +2740,7 @@ public: Printf(f_directors_h, " PyObject *swig_get_method(size_t method_index, const char *method_name) const {\n"); Printf(f_directors_h, " PyObject *method = vtable[method_index];\n"); Printf(f_directors_h, " if (!method) {\n"); - Printf(f_directors_h, " swig::PyObject_var name = PyString_FromString(method_name);\n"); + Printf(f_directors_h, " swig::PyObject_var name = SWIG_Python_str_FromChar(method_name);\n"); Printf(f_directors_h, " method = PyObject_GetAttr(swig_get_self(), name);\n"); Printf(f_directors_h, " if (method == NULL) {\n"); Printf(f_directors_h, " std::string msg = \"Method in class %s doesn't exist, undefined \";\n", classname); @@ -2623,6 +2875,16 @@ public: } } } + + /* dealing with abstract base class */ + String *abcs = Getattr(n, "feature:python:abc"); + if (py3 && abcs) { + if (Len(base_class)) { + Putc(',', base_class); + } + Printv(base_class, abcs, NIL); + } + Printv(f_shadow, "class ", class_name, NIL); if (Len(base_class)) { @@ -2631,6 +2893,9 @@ public: if (!classic) { Printf(f_shadow, modern ? "(object)" : "(_object)"); } + if (GetFlag(n, "feature:exceptionclass") ) { + Printf(f_shadow, "(Exception)"); + } } Printf(f_shadow, ":\n"); if (have_docstring(n)) { @@ -2721,7 +2986,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\")\n", NIL); } else if (fastinit) { Printv(f_wrappers, "SWIGINTERN PyObject *", class_name, "_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {\n", NIL); @@ -2834,13 +3099,15 @@ public: Delete(pycode); fproxy = 0; } else { + String *parms = make_pyParmList(n, true, false, allow_kwargs); + String *callParms = make_pyParmList(n, true, true, allow_kwargs); if (!have_addtofunc(n)) { if (!fastproxy || olddefs) { - Printv(f_shadow, tab4, "def ", symname, "(*args", (allow_kwargs ? ", **kwargs" : ""), "):", NIL); - Printv(f_shadow, " return ", funcCallHelper(Swig_name_member(class_name, symname), allow_kwargs), "\n", NIL); + Printv(f_shadow, tab4, "def ", symname, "(", parms, ")", returnTypeAnnotation(n), ":", NIL); + Printv(f_shadow, " return ", funcCall(Swig_name_member(class_name, symname), callParms), "\n", NIL); } } else { - Printv(f_shadow, tab4, "def ", symname, "(*args", (allow_kwargs ? ", **kwargs" : ""), "):", NIL); + Printv(f_shadow, tab4, "def ", symname, "(",parms , ")", returnTypeAnnotation(n), ":", NIL); Printv(f_shadow, "\n", NIL); if (have_docstring(n)) Printv(f_shadow, tab8, docstring(n, AUTODOC_METHOD, tab8), "\n", NIL); @@ -2850,11 +3117,11 @@ public: } if (have_pythonappend(n)) { fproxy = 0; - Printv(f_shadow, tab8, "val = ", funcCallHelper(Swig_name_member(class_name, symname), allow_kwargs), "\n", NIL); + Printv(f_shadow, tab8, "val = ", funcCall(Swig_name_member(class_name, symname), callParms), "\n", NIL); Printv(f_shadow, tab8, pythonappend(n), "\n", NIL); Printv(f_shadow, tab8, "return val\n\n", NIL); } else { - Printv(f_shadow, tab8, "return ", funcCallHelper(Swig_name_member(class_name, symname), allow_kwargs), "\n\n", NIL); + Printv(f_shadow, tab8, "return ", funcCall(Swig_name_member(class_name, symname), callParms), "\n\n", NIL); } } } @@ -2887,17 +3154,19 @@ public: if (shadow) { if (!classic && !Getattr(n, "feature:python:callback") && have_addtofunc(n)) { int kw = (check_kwargs(n) && !Getattr(n, "sym:overloaded")) ? 1 : 0; - Printv(f_shadow, tab4, "def ", symname, "(*args", (kw ? ", **kwargs" : ""), "):\n", NIL); + String *parms = make_pyParmList(n, true, false, kw); + String *callParms = make_pyParmList(n, true, true, kw); + Printv(f_shadow, tab4, "def ", symname, "(", parms, ")", returnTypeAnnotation(n), ":\n", NIL); if (have_docstring(n)) Printv(f_shadow, tab8, docstring(n, AUTODOC_STATICFUNC, tab8), "\n", NIL); if (have_pythonprepend(n)) Printv(f_shadow, tab8, pythonprepend(n), "\n", NIL); if (have_pythonappend(n)) { - Printv(f_shadow, tab8, "val = ", funcCallHelper(Swig_name_member(class_name, symname), kw), "\n", NIL); + Printv(f_shadow, tab8, "val = ", funcCall(Swig_name_member(class_name, symname), callParms), "\n", NIL); Printv(f_shadow, tab8, pythonappend(n), "\n", NIL); Printv(f_shadow, tab8, "return val\n\n", NIL); } else { - Printv(f_shadow, tab8, "return ", funcCallHelper(Swig_name_member(class_name, symname), kw), "\n\n", NIL); + Printv(f_shadow, tab8, "return ", funcCall(Swig_name_member(class_name, symname), callParms), "\n\n", NIL); } Printv(f_shadow, tab4, modern ? "" : "if _newclass:", symname, " = staticmethod(", symname, ")\n", NIL); @@ -2969,8 +3238,8 @@ public: handled_as_init = (Strcmp(nname, sname) == 0) || (Strcmp(nname, cname) == 0); Delete(cname); } - - if (!have_constructor && handled_as_init) { + + if (!have_constructor && handled_as_init) { if (Getattr(n, "feature:shadow")) { String *pycode = pythoncode(Getattr(n, "feature:shadow"), tab4); String *pyaction = NewStringf("%s.%s", module, Swig_name_construct(symname)); @@ -2984,23 +3253,30 @@ public: String *classname = Swig_class_name(parent); String *rclassname = Swig_class_name(getCurrentClass()); assert(rclassname); - if (use_director) { + + String *parms = make_pyParmList(n, true, false, allow_kwargs); + /* Pass 'self' only if using director */ + String *callParms = make_pyParmList(n, false, true, allow_kwargs); + + if (use_director) { + Insert(callParms, 0, "_self, "); Printv(pass_self, tab8, NIL); Printf(pass_self, "if self.__class__ == %s:\n", classname); - Printv(pass_self, tab8, tab4, "args = (None,) + args\n", tab8, "else:\n", tab8, tab4, "args = (self,) + args\n", NIL); + //Printv(pass_self, tab8, tab4, "args = (None,) + args\n", tab8, "else:\n", tab8, tab4, "args = (self,) + args\n", NIL); + Printv(pass_self, tab8, tab4, "_self = None\n", tab8, "else:\n", tab8, tab4, "_self = self\n", NIL); } - Printv(f_shadow, tab4, "def __init__(self, *args", (allow_kwargs ? ", **kwargs" : ""), "): \n", NIL); + Printv(f_shadow, tab4, "def __init__(", parms, ")", returnTypeAnnotation(n), ": \n", NIL); if (have_docstring(n)) Printv(f_shadow, tab8, docstring(n, AUTODOC_CTOR, tab8), "\n", NIL); if (have_pythonprepend(n)) Printv(f_shadow, tab8, pythonprepend(n), "\n", NIL); Printv(f_shadow, pass_self, NIL); if (fastinit) { - Printv(f_shadow, tab8, module, ".", class_name, "_swiginit(self,", funcCallHelper(Swig_name_construct(symname), allow_kwargs), ")\n", NIL); + Printv(f_shadow, tab8, module, ".", class_name, "_swiginit(self,", funcCall(Swig_name_construct(symname), callParms), ")\n", NIL); } else { Printv(f_shadow, - tab8, "this = ", funcCallHelper(Swig_name_construct(symname), allow_kwargs), "\n", + tab8, "this = ", funcCall(Swig_name_construct(symname), callParms), "\n", tab8, "try: self.this.append(this)\n", tab8, "except: self.this = this\n", NIL); } if (have_pythonappend(n)) @@ -3020,13 +3296,15 @@ public: Printv(f_shadow_stubs, pycode, "\n", NIL); Delete(pycode); } else { + String *parms = make_pyParmList(n, true, false, allow_kwargs); + String *callParms = make_pyParmList(n, true, true, allow_kwargs); - Printv(f_shadow_stubs, "\ndef ", symname, "(*args", (allow_kwargs ? ", **kwargs" : ""), "):\n", NIL); + Printv(f_shadow_stubs, "\ndef ", symname, "(", parms, ")", returnTypeAnnotation(n), ":\n", NIL); if (have_docstring(n)) Printv(f_shadow_stubs, tab4, docstring(n, AUTODOC_CTOR, tab4), "\n", NIL); if (have_pythonprepend(n)) Printv(f_shadow_stubs, tab4, pythonprepend(n), "\n", NIL); - Printv(f_shadow_stubs, tab4, "val = ", funcCallHelper(Swig_name_construct(symname), allow_kwargs), "\n", NIL); + Printv(f_shadow_stubs, tab4, "val = ", funcCall(Swig_name_construct(symname), callParms), "\n", NIL); #ifdef USE_THISOWN Printv(f_shadow_stubs, tab4, "val.thisown = 1\n", NIL); #endif @@ -3605,15 +3883,15 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) { if (use_parse || !modernargs) { Printf(w->code, "swig::PyObject_var result = PyObject_CallMethod(swig_get_self(), (char *)\"%s\", (char *)\"(%s)\" %s);\n", pyname, parse_args, arglist); - } else { - Printf(w->code, "swig::PyObject_var swig_method_name = PyString_FromString((char *)\"%s\");\n", pyname); + } else { + Printf(w->code, "swig::PyObject_var swig_method_name = SWIG_Python_str_FromChar((char *)\"%s\");\n", pyname); Printf(w->code, "swig::PyObject_var result = PyObject_CallMethodObjArgs(swig_get_self(), (PyObject *) swig_method_name %s, NULL);\n", arglist); } } else { if (!modernargs) { Printf(w->code, "swig::PyObject_var result = PyObject_CallMethod(swig_get_self(), (char *) \"%s\", NULL);\n", pyname); } else { - Printf(w->code, "swig::PyObject_var swig_method_name = PyString_FromString((char *)\"%s\");\n", pyname); + Printf(w->code, "swig::PyObject_var swig_method_name = SWIG_Python_str_FromChar((char *)\"%s\");\n", pyname); Append(w->code, "swig::PyObject_var result = PyObject_CallMethodObjArgs(swig_get_self(), (PyObject *) swig_method_name, NULL);\n"); } } diff --git a/configure.in b/configure.in index 77ff25aee..8a09cd6f7 100644 --- a/configure.in +++ b/configure.in @@ -573,7 +573,7 @@ else # First figure out the name of the Python executable if test "x$PYBIN" = xyes; then -AC_CHECK_PROGS(PYTHON, python python2.8 python2.7 python2.6 python2.5 python2.4 python2.3 python2.2 python2.1 python2.0 python1.6 python1.5 python1.4 python) +AC_CHECK_PROGS(PYTHON, [python python2.8 python2.7 python2.6 python2.5 python2.4 python2.3 python2.2 python2.1 python2.0 python1.6 python1.5 python1.4 python]) else PYTHON="$PYBIN" fi @@ -657,6 +657,103 @@ AC_SUBST(PYLIB) AC_SUBST(PYLINK) AC_SUBST(PYTHONDYNAMICLINKING) + +#---------------------------------------------------------------- +# Look for Python 3.x +#---------------------------------------------------------------- + +# mostly copy & pasted from "Look for Python" section, +# did some trim, fix and rename + +PY3INCLUDE= +PY3LIB= +PY3PACKAGE= + +AC_ARG_WITH(python3, AS_HELP_STRING([--without-python3], [Disable Python 3.x support]) +AS_HELP_STRING([--with-python3=path], [Set location of Python 3.x executable]),[ PY3BIN="$withval"], [PY3BIN=yes]) + +# First, check for "--without-python3" or "--with-python3=no". +if test x"${PY3BIN}" = xno -o x"${with_alllang}" = xno ; then +AC_MSG_NOTICE([Disabling Python 3.x support]) +else +# First figure out the name of the Python3 executable + +if test "x$PY3BIN" = xyes; then +AC_CHECK_PROGS(PYTHON3, [python3 python3.0]) +else +PYTHON3="$PY3BIN" +fi + +# Check for Python 3.x development tools (header files, static library and python3-config) +AC_CHECK_PROGS(PY3CONFIG, [$PYTHON3-config python3-config python3.0-config]) + +if test -n "$PYTHON3" -a -n "$PY3CONFIG"; then + AC_MSG_CHECKING([for Python 3.x prefix]) + PY3PREFIX=`($PY3CONFIG --prefix) 2>/dev/null` + AC_MSG_RESULT($PY3PREFIX) + AC_MSG_CHECKING(for Python 3.x exec-prefix) + PY3EPREFIX=`($PY3CONFIG --exec-prefix) 2>/dev/null` + AC_MSG_RESULT($PY3EPREFIX) + + # Note: I could not think of a standard way to get the version string from different versions. + # This trick pulls it out of the file location for a standard library file. + + AC_MSG_CHECKING([for Python 3.x version]) + + # Need to do this hack since autoconf replaces __file__ with the name of the configure file + filehack="file__" + PY3VERSION=`($PYTHON3 -c "import string,operator,os.path; print(operator.getitem(os.path.split(operator.getitem(os.path.split(string.__$filehack),0)),1))")` + AC_MSG_RESULT($PY3VERSION) + + # Find the directory for libraries this is necessary to deal with + # platforms that can have apps built for multiple archs: e.g. x86_64 + AC_MSG_CHECKING([for Python 3.x lib dir]) + PY3LIBDIR=`($PYTHON3 -c "import sys; print(sys.lib)") 2>/dev/null` + if test -z "$PY3LIBDIR"; then + # some dists don't have sys.lib so the best we can do is assume lib + PY3LIBDIR="lib" + fi + AC_MSG_RESULT($PY3LIBDIR) + + # Set the include directory + + AC_MSG_CHECKING([for Python 3.x header files]) + PY3INCLUDE=`($PY3CONFIG --includes) 2>/dev/null` + AC_MSG_RESULT($PY3INCLUDE) + + # Set the library directory blindly. This probably won't work with older versions + AC_MSG_CHECKING([for Python 3.x library]) + dirs="$PY3VERSION/config $PY3VERSION/$PY3LIBDIR python/$PY3LIBDIR" + for i in $dirs; do + if test -d $PY3EPREFIX/$PY3LIBDIR/$i; then + PY3LIB="$PY3EPREFIX/$PY3LIBDIR/$i" + break + fi + done + if test -z "$PY3LIB"; then + AC_MSG_RESULT([Not found]) + else + AC_MSG_RESULT($PY3LIB) + fi + + PY3LINK="-l$PY3VERSION" +fi + +# Cygwin (Windows) needs the library for dynamic linking +case $host in +*-*-cygwin* | *-*-mingw*) PYTHON3DYNAMICLINKING="-L$PYLIB $PY3LINK" + DEFS="-DUSE_DL_IMPORT $DEFS" PY3INCLUDE="$PY3INCLUDE" + ;; +*)PYTHON3DYNAMICLINKING="";; +esac +fi + +AC_SUBST(PY3INCLUDE) +AC_SUBST(PY3LIB) +AC_SUBST(PY3LINK) +AC_SUBST(PYTHON3DYNAMICLINKING) + + #---------------------------------------------------------------- # Look for Perl5 #---------------------------------------------------------------- @@ -1856,11 +1953,17 @@ AC_SUBST(SKIP_OCTAVE) SKIP_PYTHON= -if test -z "$PYINCLUDE" || test -z "$PYLIB" ; then +if (test -z "$PYINCLUDE" || test -z "$PYLIB") && + (test -z "$PY3INCLUDE" || test -z "PY3LIB") ; then SKIP_PYTHON="1" fi AC_SUBST(SKIP_PYTHON) +SKIP_PYTHON3= +if test -z "$PY3INCLUDE" || test -z "$PY3LIB" ; then + SKIP_PYTHON3="1" +fi +AC_SUBST(SKIP_PYTHON3) SKIP_JAVA= if test -z "$JAVA" || test -z "$JAVAC" || test -z "$JAVAINC" ; then From c4d844abcb91cee226c6bd184cb9ff1e5f294ee1 Mon Sep 17 00:00:00 2001 From: Richard Boulton Date: Fri, 12 Sep 2008 11:33:18 +0000 Subject: [PATCH 0103/1680] Don't blame wsfulton for my recent change (this was a cut-and-paste error). git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10846 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index 6b552c994..b0610cb6f 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,7 +1,7 @@ Version 1.3.37 (in progress) ============================= -2008-09-02: wsfulton +2008-09-02: richardb [Python] Commit patch #2089149: Director exception handling mangles returned exception. Exceptions raised by Python code in directors are now passed through to the caller without change. Also, remove From 32fc296a741d55c5ea6d59cd18ef19d80665bf5c Mon Sep 17 00:00:00 2001 From: Haoyu Bai Date: Fri, 12 Sep 2008 11:52:11 +0000 Subject: [PATCH 0104/1680] A breif descirbe of Python 3 merge in CHANGES.current git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10847 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index b0610cb6f..f1835ccc1 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,12 @@ Version 1.3.37 (in progress) ============================= +2008-09-12: bhy + [Python] Python 3.0 support branch merged into SWIG trunk. Thanks + Google Summer of Code 2008 for support this project! For details of + Python 3 support, please see the "Python 3 Support" section in the + "SWIG and Python" chapter of SWIG documentation. + 2008-09-02: richardb [Python] Commit patch #2089149: Director exception handling mangles returned exception. Exceptions raised by Python code in directors From 2cbb898cff08f0847a69d521ce82a08dafc1ce35 Mon Sep 17 00:00:00 2001 From: Haoyu Bai Date: Fri, 12 Sep 2008 14:43:17 +0000 Subject: [PATCH 0105/1680] some more lines in CHANGES.current for Python 3 merge git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10848 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index f1835ccc1..d13944a80 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -3,9 +3,19 @@ Version 1.3.37 (in progress) 2008-09-12: bhy [Python] Python 3.0 support branch merged into SWIG trunk. Thanks - Google Summer of Code 2008 for support this project! For details of - Python 3 support, please see the "Python 3 Support" section in the - "SWIG and Python" chapter of SWIG documentation. + Google Summer of Code 2008 for support this project! By default + SWIG will generate interface files compatible with boht Python 2.x + and 3.0. And there's also some Python 3 new features could be + enabled by passing a "-py3" command line option to SWIG. These + features are: + + - Function annotation support + - Buffer interface support + - Abstract base class support + + For details of Python 3 support and these features, please see the + "Python 3 Support" section in the "SWIG and Python" chapter of SWIG + documentation. 2008-09-02: richardb [Python] Commit patch #2089149: Director exception handling mangles From c8148015ff634d95d7445b6cfe179810184d4946 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 12 Sep 2008 20:40:57 +0000 Subject: [PATCH 0106/1680] fix for when python3 not installed git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10849 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- configure.in | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/configure.in b/configure.in index 8a09cd6f7..42845a1ce 100644 --- a/configure.in +++ b/configure.in @@ -679,13 +679,17 @@ else # First figure out the name of the Python3 executable if test "x$PY3BIN" = xyes; then -AC_CHECK_PROGS(PYTHON3, [python3 python3.0]) + AC_CHECK_PROGS(PYTHON3, [python3 python3.0]) else -PYTHON3="$PY3BIN" + PYTHON3="$PY3BIN" fi # Check for Python 3.x development tools (header files, static library and python3-config) -AC_CHECK_PROGS(PY3CONFIG, [$PYTHON3-config python3-config python3.0-config]) +if test "x$PYTHON3" = x; then + AC_CHECK_PROGS(PY3CONFIG, [python3-config python3.0-config]) +else + AC_CHECK_PROGS(PY3CONFIG, [$PYTHON3-config python3-config python3.0-config]) +fi if test -n "$PYTHON3" -a -n "$PY3CONFIG"; then AC_MSG_CHECKING([for Python 3.x prefix]) From 875d1668b63ee797cceb736ff37bb97f73637946 Mon Sep 17 00:00:00 2001 From: Haoyu Bai Date: Sat, 13 Sep 2008 11:38:10 +0000 Subject: [PATCH 0107/1680] fix merge problem: remove USE_VALGRIND because it is already moved to common.mk git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10850 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/python/Makefile.in | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Examples/test-suite/python/Makefile.in b/Examples/test-suite/python/Makefile.in index a3a027453..ec9bb7461 100644 --- a/Examples/test-suite/python/Makefile.in +++ b/Examples/test-suite/python/Makefile.in @@ -9,11 +9,7 @@ else endif LANGUAGE = python -ifneq (,$(USE_VALGRIND)) - PYTHON = valgrind --leak-check=full --suppressions=pyswig.supp $(PYBIN) -else - PYTHON = $(PYBIN) -endif +PYTHON = $(PYBIN) #*_runme.py for Python 2.x, *_runme3.py for Python 3.x PY2SCRIPTSUFFIX = _runme.py From dfbcaf884e23f8d67fe9f53a94512e24c7e6e771 Mon Sep 17 00:00:00 2001 From: Haoyu Bai Date: Sat, 13 Sep 2008 12:16:44 +0000 Subject: [PATCH 0108/1680] add removing of 2to3 generated runme3.py in make clean target git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10851 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/Makefile.in | 1 + Examples/test-suite/python/Makefile.in | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Examples/Makefile.in b/Examples/Makefile.in index f85075906..9ac981f6c 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -316,6 +316,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; ################################################################## diff --git a/Examples/test-suite/python/Makefile.in b/Examples/test-suite/python/Makefile.in index ec9bb7461..69ff7ca1b 100644 --- a/Examples/test-suite/python/Makefile.in +++ b/Examples/test-suite/python/Makefile.in @@ -112,15 +112,15 @@ VALGRIND_OPT += --suppressions=pythonswig.supp run_python = env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PYTHONPATH=$(srcdir):$$PYTHONPATH $(RUNTOOL) $(PYTHON) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) +py2_runme = $(srcdir)/$(SCRIPTPREFIX)$*$(PY2SCRIPTSUFFIX) +py3_runme = $(srcdir)/$(SCRIPTPREFIX)$*$(PY3SCRIPTSUFFIX) + ifeq (,$(PY3)) run_testcase = \ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then ( \ $(run_python);)\ fi; else -py2_runme = $(srcdir)/$(SCRIPTPREFIX)$*$(PY2SCRIPTSUFFIX) -py3_runme = $(srcdir)/$(SCRIPTPREFIX)$*$(PY3SCRIPTSUFFIX) - run_testcase = \ if [ -f $(py2_runme) ]; then ( \ $(MAKE) -f $(srcdir)/Makefile $(py3_runme) && \ @@ -134,6 +134,8 @@ endif %.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 From fe3a6192f21e5b6bd2a78fe13d6ee380476b82db Mon Sep 17 00:00:00 2001 From: Haoyu Bai Date: Sat, 13 Sep 2008 12:55:32 +0000 Subject: [PATCH 0109/1680] fix a typo in python/Makefile.in git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10852 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/python/Makefile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/test-suite/python/Makefile.in b/Examples/test-suite/python/Makefile.in index 69ff7ca1b..9026d0815 100644 --- a/Examples/test-suite/python/Makefile.in +++ b/Examples/test-suite/python/Makefile.in @@ -125,7 +125,7 @@ run_testcase = \ if [ -f $(py2_runme) ]; then ( \ $(MAKE) -f $(srcdir)/Makefile $(py3_runme) && \ $(run_python);) \ - elif [ -f $(py3_runme)]; then ( \ + elif [ -f $(py3_runme) ]; then ( \ $(run_python);) \ fi; endif From 98f5993f5060fd669e62cb8e9a50c80fe885f84f Mon Sep 17 00:00:00 2001 From: Haoyu Bai Date: Sat, 13 Sep 2008 13:20:39 +0000 Subject: [PATCH 0110/1680] remove _runme3 file that was checked in by mistake git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10853 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- .../test-suite/python/pybuf_benchmark_runme3.py | 16 ---------------- 1 file changed, 16 deletions(-) delete mode 100644 Examples/test-suite/python/pybuf_benchmark_runme3.py diff --git a/Examples/test-suite/python/pybuf_benchmark_runme3.py b/Examples/test-suite/python/pybuf_benchmark_runme3.py deleted file mode 100644 index e412d5993..000000000 --- a/Examples/test-suite/python/pybuf_benchmark_runme3.py +++ /dev/null @@ -1,16 +0,0 @@ -import pybuf -import time -k=1000000 -n=7 - -t=time.time() -a = bytearray(b'hello world') -for i in range(k): - pybuf.title1(a) -print("Time used by bytearray:",time.time()-t) - -t=time.time() -b = 'hello world' -for i in range(k): - pybuf.title2(b) -print("Time used by string:",time.time()-t) From 82df9bae16b6912e64d4ead74c1d53a2c07ff897 Mon Sep 17 00:00:00 2001 From: Haoyu Bai Date: Sat, 13 Sep 2008 13:39:34 +0000 Subject: [PATCH 0111/1680] more docs for Python 3 merge added in CHANGES.current git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10854 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index d13944a80..58621be38 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -10,13 +10,22 @@ Version 1.3.37 (in progress) features are: - Function annotation support + Also, the parameter list of proxy function will be generated, + even without the "-py3" option. However, the parameter list + will fallback to *args if the function (or method) is overloaded. - Buffer interface support - - Abstract base class support + - Abstract base class support For details of Python 3 support and these features, please see the "Python 3 Support" section in the "SWIG and Python" chapter of SWIG documentation. + This merge also patched SWIG's parser to solve a bug. By the fix, + SWIG features able to be correctly applied on C++ conversion operator, + such like this: + + %feature("shadow") *::operator bool %{ ... %} + 2008-09-02: richardb [Python] Commit patch #2089149: Director exception handling mangles returned exception. Exceptions raised by Python code in directors From 371f40be2d2de85ff40a2801682bc3169176a787 Mon Sep 17 00:00:00 2001 From: Haoyu Bai Date: Sat, 13 Sep 2008 13:42:24 +0000 Subject: [PATCH 0112/1680] fix some typo in CHANGES.current git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10855 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 58621be38..ac854e618 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -4,7 +4,7 @@ Version 1.3.37 (in progress) 2008-09-12: bhy [Python] Python 3.0 support branch merged into SWIG trunk. Thanks Google Summer of Code 2008 for support this project! By default - SWIG will generate interface files compatible with boht Python 2.x + SWIG will generate interface files compatible with both Python 2.x and 3.0. And there's also some Python 3 new features could be enabled by passing a "-py3" command line option to SWIG. These features are: @@ -20,7 +20,7 @@ Version 1.3.37 (in progress) "Python 3 Support" section in the "SWIG and Python" chapter of SWIG documentation. - This merge also patched SWIG's parser to solve a bug. By the fix, + This merge also patched SWIG's parser to solve a bug. By this patch, SWIG features able to be correctly applied on C++ conversion operator, such like this: From 75eb4d20d665fa4e236be92127872a361bce5a84 Mon Sep 17 00:00:00 2001 From: Haoyu Bai Date: Sat, 13 Sep 2008 14:11:49 +0000 Subject: [PATCH 0113/1680] more document for limitation of parameter list, and doc of removal of -apply in CHANGES.current git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10856 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++++ Doc/Manual/Python.html | 21 ++++++++++++++++++--- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index ac854e618..6a3b20f1d 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -20,6 +20,10 @@ Version 1.3.37 (in progress) "Python 3 Support" section in the "SWIG and Python" chapter of SWIG documentation. + The "-apply" command line option and support of generating codes + using apply() is removed. Since this is only required by very old + Python. + This merge also patched SWIG's parser to solve a bug. By this patch, SWIG features able to be correctly applied on C++ conversion operator, such like this: diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html index c0b71b52d..35625b1ca 100644 --- a/Doc/Manual/Python.html +++ b/Doc/Manual/Python.html @@ -4988,8 +4988,7 @@ SWIG.

    The -py3 option will enable function annotation support. When used -SWIG is able to generate proxy method definitions like -this: +SWIG is able to generate proxy method definitions like this:

    @@ -4997,7 +4996,23 @@ this:
     

    -For details of usage of function annotation, see PEP 3107. +Also, even if without passing SWIG the -py3 option, the parameter list +still could be generated: +

    + +
    +  def foo(self, bar = 0): ...
    +
    + +

    +But for overloaded function or method, the parameter list would fallback to +*args or self, *args, and **kwargs may be append +depend on whether you enabled the keyword argument. This fallback is due to +all overloaded functions share the same function in SWIG generated proxy class. +

    + +

    +For detailed usage of function annotation, see PEP 3107.

    30.12.2 Buffer interface

    From cc88c24c3fbe607e6e32773d7ea98cdc5dc16e02 Mon Sep 17 00:00:00 2001 From: Mikel Bancroft Date: Wed, 17 Sep 2008 19:13:12 +0000 Subject: [PATCH 0114/1680] [allegrocl] Fix handling of forward references. Remove code breaking typical code generation. See ChangeLog for more details on the latter. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10860 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 16 +++++++++++ Lib/allegrocl/allegrocl.swg | 30 ++++++++++---------- Source/Modules/allegrocl.cxx | 53 +++++++++++++++++++++++++----------- 3 files changed, 69 insertions(+), 30 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 6a3b20f1d..4f8d3dfa0 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,22 @@ Version 1.3.37 (in progress) ============================= +2008-09-17: mutandiz (Mikel Bancroft) + [allegrocl] + - Fix how forward reference typedefs are handled, so as not to conflict + with other legit typedefs. + - Don't (for now) perform an ffitype typemap lookup when trying to + when calling compose_foreign_type(). This is actually a useful thing + to do in certain cases, the test cases for which I can't currently + locate :/. It's breaking some wrapping behavior that is more commonly + seen, however. I'll readd in a more appropriate way when I can + recreate the needed test case, or a user complains (which means + they probably have a test case). + - document the -isolate command-line arg in the 'swig -help' output. + It was in the html docs, but not there. + - small amount of code cleanup, removed some unused code. + - some minor aesthetic changes. + 2008-09-12: bhy [Python] Python 3.0 support branch merged into SWIG trunk. Thanks Google Summer of Code 2008 for support this project! By default diff --git a/Lib/allegrocl/allegrocl.swg b/Lib/allegrocl/allegrocl.swg index 8132e4628..13790f306 100644 --- a/Lib/allegrocl/allegrocl.swg +++ b/Lib/allegrocl/allegrocl.swg @@ -248,7 +248,7 @@ $body)" %insert("lisphead") %{ ;; $Id$ -(eval-when (compile load eval) +(eval-when (:compile-toplevel :load-toplevel :execute) ;; avoid compiling ef-templates at runtime (excl:find-external-format :fat) @@ -375,7 +375,7 @@ $body)" (defswig2 swig-defconstant (string value) (cl::let ((symbol (id-convert-and-export string :type :constant))) - `(cl::eval-when (compile load eval) + `(cl::eval-when (:compile-toplevel :load-toplevel :execute) (cl::defconstant ,symbol ,value)))) (cl::defun maybe-reorder-args (funcname arglist) @@ -421,7 +421,7 @@ $body)" ) (cl::when (swig-anyvarargs-p ffargs) (cl::setq ffargs '())) - `(cl::eval-when (compile load eval) + `(cl::eval-when (:compile-toplevel :load-toplevel :execute) (excl::compiler-let ((*record-xref-info* nil)) (ff:def-foreign-call (,mangle ,mangled-name) ,ffargs ,@kwargs)) (cl::macrolet ((swig-ff-call (&rest args) @@ -447,7 +447,7 @@ $body)" ffargs (cl::loop for (nil name nil . ffi) in ffargs collect `(,name ,@ffi))))) - `(cl::eval-when (compile load eval) + `(cl::eval-when (:compile-toplevel :load-toplevel :execute) (excl::compiler-let ((*record-xref-info* nil)) (ff:def-foreign-call (,mangle ,mangled-name) ,ffargs ,@kwargs)) (cl::macrolet ((swig-ff-call (&rest args) @@ -459,7 +459,7 @@ $body)" (defswig1 swig-dispatcher ((name &key (type :operator) class arities)) (cl::let ((symbol (id-convert-and-export name :type type :class class))) - `(cl::eval-when (compile load eval) + `(cl::eval-when (:compile-toplevel :load-toplevel :execute) (cl::defun ,symbol (&rest args) (cl::case (cl::length args) ,@(cl::loop for arity in arities @@ -472,14 +472,14 @@ $body)" (defswig2 swig-def-foreign-stub (name) (cl::let ((lsymbol (id-convert-and-export name :type :class)) (symbol (id-convert-and-export name :type :type))) - `(cl::eval-when (compile load eval) + `(cl::eval-when (:compile-toplevel :load-toplevel :execute) (ff:def-foreign-type ,symbol (:class )) (cl::defclass ,lsymbol (ff:foreign-pointer) ())))) (defswig2 swig-def-foreign-class (name supers &rest rest) (cl::let ((lsymbol (id-convert-and-export name :type :class)) (symbol (id-convert-and-export name :type :type))) - `(cl::eval-when (compile load eval) + `(cl::eval-when (:compile-toplevel :load-toplevel :execute) (ff:def-foreign-type ,symbol ,@rest) (cl::defclass ,lsymbol ,supers ((foreign-type :initform ',symbol :initarg :foreign-type @@ -487,11 +487,11 @@ $body)" (defswig2 swig-def-foreign-type (name &rest rest) (cl::let ((symbol (id-convert-and-export name :type :type))) - `(cl::eval-when (compile load eval) + `(cl::eval-when (:compile-toplevel :load-toplevel :execute) (ff:def-foreign-type ,symbol ,@rest)))) (defswig2 swig-def-synonym-type (synonym of ff-synonym) - `(cl::eval-when (compile load eval) + `(cl::eval-when (:compile-toplevel :load-toplevel :execute) (cl::setf (cl::find-class ',synonym) (cl::find-class ',of)) (ff:def-foreign-type ,ff-synonym (:struct )))) @@ -511,24 +511,24 @@ $body)" (parent-strings (cl::mapcar #'package-name-for-namespace parent-namespaces)) (string (package-name-for-namespace namespace))) - `(cl::eval-when (compile load eval) + `(cl::eval-when (:compile-toplevel :load-toplevel :execute) (cl::defpackage ,string (:use :swig :ff #+ignore '(:common-lisp :ff :excl) ,@parent-strings ,*swig-module-name*) (:import-from :cl :* :nil :t))))) (cl::defmacro swig-in-package (namespace) - `(cl::eval-when (compile load eval) + `(cl::eval-when (:compile-toplevel :load-toplevel :execute) (cl::in-package ,(package-name-for-namespace namespace)))) (defswig2 swig-defvar (name mangled-name &key type (ftype :unsigned-natural)) (cl::let ((symbol (id-convert-and-export name :type type))) - `(cl::eval-when (compile load eval) + `(cl::eval-when (:compile-toplevel :load-toplevel :execute) (ff:def-foreign-variable (,symbol ,mangled-name) :type ,ftype)))) ) ;; eval-when -(cl::eval-when (compile eval) +(cl::eval-when (:compile-toplevel :execute) (cl::flet ((starts-with-p (str prefix) (cl::and (cl::>= (cl::length str) (cl::length prefix)) (cl::string= str prefix :end1 (cl::length prefix))))) @@ -539,7 +539,7 @@ $body)" %} - +typedef void *__SWIGACL_FwdReference; %{ @@ -551,6 +551,8 @@ $body)" #define EXPORT EXTERN SWIGEXPORT +typedef void *__SWIGACL_FwdReference; + #include #include %} diff --git a/Source/Modules/allegrocl.cxx b/Source/Modules/allegrocl.cxx index 217c89b1f..63988a868 100644 --- a/Source/Modules/allegrocl.cxx +++ b/Source/Modules/allegrocl.cxx @@ -34,6 +34,8 @@ static bool CWrap = true; // generate wrapper file for C code by default. most c static bool Generate_Wrapper = false; static bool unique_swig_package = false; +static SwigType *fwdref_ffi_type = NewString("__SWIGACL_FwdReference"); + static String *current_namespace = NewString(""); static String *current_package = NewString(""); static Hash *defined_namespace_packages = NewHash(); @@ -725,7 +727,7 @@ String *internal_compose_foreign_type(SwigType *ty) { } else { Printf(stderr, "Unable to compose foreign type of: '%s'\n", tok); } - Printf(ffiType, "(* :void)"); + Printf(ffiType, "%s", get_ffi_type(fwdref_ffi_type, "")); } } } @@ -735,22 +737,33 @@ String *internal_compose_foreign_type(SwigType *ty) { String *compose_foreign_type(SwigType *ty, String *id = 0) { - Hash *lookup_res = Swig_typemap_search("ffitype", ty, id, 0); +/* Hash *lookup_res = Swig_typemap_search("ffitype", ty, id, 0); */ + #ifdef ALLEGROCL_TYPE_DEBUG - Printf(stderr, "compose_foreign_type: ENTER (%s)...\n ", ty); - String *id_ref = SwigType_str(ty, id); + Printf(stderr, "compose_foreign_type: ENTER (%s)(%s)...\n ", ty, (id ? id : 0)); + /* String *id_ref = SwigType_str(ty, id); Printf(stderr, "looking up typemap for %s, found '%s'(%x)\n", id_ref, lookup_res ? Getattr(lookup_res, "code") : 0, lookup_res); + if (lookup_res) Swig_print_node(lookup_res); + */ #endif + /* should we allow named lookups in the typemap here? YES! */ /* unnamed lookups should be found in get_ffi_type, called by internal_compose_foreign_type(), below. */ + + /* I'm reverting to 'no' for the question above. I can no longer + remember why I needed it. If a user needed it, I'll find out + as soon as they upgrade. Sigh. -mutandiz 9/16/2008. */ + +/* if(id && lookup_res) { #ifdef ALLEGROCL_TYPE_DEBUG Printf(stderr, "compose_foreign_type: EXIT-1 (%s)\n ", Getattr(lookup_res, "code")); #endif return NewString(Getattr(lookup_res, "code")); } +*/ SwigType *temp = SwigType_strip_qualifiers(ty); String *res = internal_compose_foreign_type(temp); @@ -1516,7 +1529,10 @@ void ALLEGROCL::main(int argc, char *argv[]) { "\tcalled to convert identifiers to symbols.\n" "\n" " -[no]cwrap\n" - "\tTurn on or turn off generation of an intermediate C file when\n" "\tcreating a C interface. By default this is only done for C++ code.\n"); + "\tTurn on or turn off generation of an intermediate C file when\n" "\tcreating a C interface. By default this is only done for C++ code.\n" + " -isolate\n" + "Define all SWIG helper functions in a package unique to this module. Avoids redefinition warnings when loading multiple SWIGged modules\n" + "into the same running Allegro CL image.\n"); } @@ -1571,7 +1587,7 @@ int ALLEGROCL::top(Node *n) { " (:export #:*swig-identifier-converter* #:*swig-module-name*\n" " #:*void* #:*swig-export-list*))\n" "(in-package :%s)\n\n" - "(eval-when (compile load eval)\n" + "(eval-when (:compile-toplevel :load-toplevel :execute)\n" " (defparameter *swig-identifier-converter* '%s)\n" " (defparameter *swig-module-name* :%s))\n\n", swig_package, swig_package, identifier_converter, module_name); Printf(f_cl, "(defpackage :%s\n" " (:use :common-lisp :%s :ff :excl))\n\n", module_name, swig_package); @@ -2632,13 +2648,18 @@ int ALLEGROCL::functionWrapper(Node *n) { String *tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode); if (!is_void_return && tm) { - Replaceall(tm, "$result", "lresult"); - Printf(f->code, "%s\n", tm); - Printf(f->code, " return lresult;\n"); - Delete(tm); - } else { - Swig_warning(WARN_TYPEMAP_OUT_UNDEF, input_file, line_number, "Unable to use return type %s in function %s.\n", SwigType_str(t, 0), name); + if (tm) { + Replaceall(tm, "$result", "lresult"); + Printf(f->code, "%s\n", tm); + Printf(f->code, " return lresult;\n"); + Delete(tm); + } else { + Swig_warning(WARN_TYPEMAP_OUT_UNDEF, input_file, line_number, + "Unable to use return type %s in function %s.\n", + SwigType_str(t, 0), name); + } } + emit_return_variable(n, t, f); if (CPlusPlus) { @@ -2901,9 +2922,7 @@ int ALLEGROCL::typedefHandler(Node *n) { Printf(stderr, " typedef in class '%s'(%x)\n", Getattr(in_class, "sym:name"), in_class); #endif Setattr(n, "allegrocl:typedef:in-class", in_class); - } - if (in_class) { String *class_name = Getattr(in_class, "name"); name = NewStringf("%s__%s", class_name, sym_name); type_ref = NewStringf("%s::%s", class_name, sym_name); @@ -2917,9 +2936,11 @@ int ALLEGROCL::typedefHandler(Node *n) { String *lookup = lookup_defined_foreign_type(typedef_type); - // Printf(stderr, "** lookup='%s'(%x), ff_type='%s', strstr = '%d'\n", lookup, lookup, ff_type, !Strstr(ff_type,"void")); +#ifdef ALLEGROCL_TYPE_DEBUG + Printf(stderr, "** lookup='%s'(%x), ff_type='%s', !strstr = '%d'\n", lookup, lookup, ff_type, !Strstr(ff_type,"void")); +#endif - if(lookup || (!lookup && !Strstr(ff_type,"void"))) + if(lookup || (!lookup && !Strstr(ff_type,"__SWIGACL_FwdReference"))) add_defined_foreign_type(n, 0, type_ref, name); else add_forward_referenced_type(n); From e9485c0f60c92d9a6b4b6dda63edba1895c2297a Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Thu, 18 Sep 2008 09:54:18 +0000 Subject: [PATCH 0115/1680] [PHP5] Fix wrapping of a renamed enumerated value of an enum class member (SF#2095273). git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10862 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 4f8d3dfa0..ffb3223a2 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,10 @@ Version 1.3.37 (in progress) ============================= +2008-09-18: olly + [PHP5] Fix wrapping of a renamed enumerated value of an enum class + member (SF#2095273). + 2008-09-17: mutandiz (Mikel Bancroft) [allegrocl] - Fix how forward reference typedefs are handled, so as not to conflict diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index 9369c2489..d7c893e07 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -2007,7 +2007,7 @@ public: * ------------------------------------------------------------ */ virtual int memberconstantHandler(Node *n) { - wrapping_member_constant = Getattr(n, "name"); + wrapping_member_constant = Getattr(n, "sym:name"); Language::memberconstantHandler(n); wrapping_member_constant = NULL; return SWIG_OK; From 6029bc8b2dac8630ba93887e13899162ef6046a3 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Thu, 18 Sep 2008 13:01:52 +0000 Subject: [PATCH 0116/1680] [PHP5] Fix extra code added to proxy class constructors in the case where the only constructor takes no arguments. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10863 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++++ Source/Modules/php.cxx | 20 +++++++++++++++----- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index ffb3223a2..c9564c844 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,10 @@ Version 1.3.37 (in progress) ============================= +2008-09-18: olly + [PHP5] Fix extra code added to proxy class constructors in the case + where the only constructor takes no arguments. + 2008-09-18: olly [PHP5] Fix wrapping of a renamed enumerated value of an enum class member (SF#2095273). diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index d7c893e07..70061b56e 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -1358,16 +1358,26 @@ public: Printf(output, "\n"); // If it's a member function or a class constructor... if (wrapperType == memberfn || (newobject && current_class)) { - Printf(output, "\tfunction %s(%s) {\n", methodname, args); // 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")) { + const char * arg0; + if (max_num_of_arguments > 0) { + arg0 = Char(arg_names[0]); + } else { + arg0 = "res"; + Delete(args); + args = NewString("$res=null"); + } SwigType *t = Getattr(current_class, "classtype"); String *mangled_type = SwigType_manglestr(SwigType_ltype(t)); - Printf(s_oowrappers, "\t\tif (is_resource($%s) && get_resource_type($%s) == \"_p%s\") {\n", arg_names[0], arg_names[0], mangled_type); - Printf(s_oowrappers, "\t\t\t$this->%s=$%s;\n", SWIG_PTR, arg_names[0]); - Printf(s_oowrappers, "\t\t\treturn;\n"); - Printf(s_oowrappers, "\t\t}\n"); + 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\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); } } else { Printf(output, "\tstatic function %s(%s) {\n", methodname, args); From 16c8749768f53f54a5b2cbca024c7b572176e9e0 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Thu, 18 Sep 2008 14:02:15 +0000 Subject: [PATCH 0117/1680] [PHP5] Change the default input typemap for char * to turn PHP Null into C NULL (previously it was converted to an empty string). The new behaviour is consistent with how the corresponding output typemap works. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10864 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 15 +++++++++++++++ Lib/php/utils.i | 8 ++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index c9564c844..a6b470c85 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,21 @@ Version 1.3.37 (in progress) ============================= +2008-09-18: olly + [PHP5] Change the default input typemap for char * to turn PHP + Null into C NULL (previously it was converted to an empty string). + The new behaviour is consistent with how the corresponding output + typemap works. + + If you want to keep the old behaviour, add the following typemap + to your interface file (PHP's convert_to_string_ex() function does + the converting from PHP Null to an empty string): + + %typemap(in) char * { + convert_to_string_ex($input); + $1 = Z_STRVAL_PP($input); + } + 2008-09-18: olly [PHP5] Fix extra code added to proxy class constructors in the case where the only constructor takes no arguments. diff --git a/Lib/php/utils.i b/Lib/php/utils.i index 661a48777..facf54196 100644 --- a/Lib/php/utils.i +++ b/Lib/php/utils.i @@ -24,8 +24,12 @@ %enddef %define CONVERT_STRING_IN(lvar,t,invar) - convert_to_string_ex(invar); - lvar = (t) Z_STRVAL_PP(invar); + if ((*invar)->type==IS_NULL) { + lvar = (t) 0; + } else { + convert_to_string_ex(invar); + lvar = (t) Z_STRVAL_PP(invar); + } %enddef %define %pass_by_val( TYPE, CONVERT_IN ) From 971c3e1e84ae24f459755d9892920d9ccf738502 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Thu, 18 Sep 2008 14:03:46 +0000 Subject: [PATCH 0118/1680] Note the SF bug number for the previous fix. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10865 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index a6b470c85..baf68ee4e 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,7 +5,7 @@ Version 1.3.37 (in progress) [PHP5] Change the default input typemap for char * to turn PHP Null into C NULL (previously it was converted to an empty string). The new behaviour is consistent with how the corresponding output - typemap works. + typemap works (SF#2025719). If you want to keep the old behaviour, add the following typemap to your interface file (PHP's convert_to_string_ex() function does From 061e934bbc77d125bb62b0e521e258e55c196aff Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 18 Sep 2008 14:52:52 +0000 Subject: [PATCH 0119/1680] Document the module attribute in %import and add warning to Python for when it should be used git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10866 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 8 +++ Doc/Manual/Modules.html | 79 ++++++++++++++++++++++----- Doc/Manual/Preprocessor.html | 2 +- Examples/test-suite/import_nomodule.i | 3 + Examples/test-suite/imports_b.i | 9 ++- Source/Modules/python.cxx | 7 ++- 6 files changed, 89 insertions(+), 19 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index baf68ee4e..371b280fc 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,14 @@ Version 1.3.37 (in progress) ============================= +2008-09-18: wsfulton + Document the optional module attribute in the %import directive, + see Modules.html. Add a warning for Python wrappers when the + module name for an imported base class is missing, requiring the + module attribute to be added to %import, eg + + %import(module="FooModule") foo.h + 2008-09-18: olly [PHP5] Change the default input typemap for char * to turn PHP Null into C NULL (previously it was converted to an empty string). diff --git a/Doc/Manual/Modules.html b/Doc/Manual/Modules.html index 8971324fb..9b8fd85e5 100644 --- a/Doc/Manual/Modules.html +++ b/Doc/Manual/Modules.html @@ -50,41 +50,90 @@ scripting language runtime as you would do for the single module case.

    A bit more complex is the case in which modules need to share information. -For example, when one module extends the class of the another by deriving from +For example, when one module extends the class of another by deriving from it:

    -%module base
    -
    -%inline %{
    +// File: base.h
     class base {
     public:
    -       int foo(void);
    +  int foo();
     };
    -%}
     
      -
    -%module derived
     
    -%import "base.i"
    +
    +// File: base_module.i
    +%module base_module
    +
    +%{
    +#include "base.h"
    +%}
    +%include "base.h"
    +
    +  + +
    +// File: derived_module.i
    +%module derived_module
    +
    +%import "base_module.i"
     
     %inline %{
     class derived : public base {
     public:
    -       int bar(void);
    +  int bar();
     };
     %}
     
    -

    To create the wrapper properly, module derived needs to know the -base class and that it's interface is covered in another module. The -line %import "base.i" lets SWIG know exactly that. The common mistake here is -to %import the .h file instead of the .i, which sadly won't do the trick. Another issue -to take care of is that multiple dependent wrappers should not be linked/loaded +

    To create the wrapper properly, module derived_module needs to know about the +base class and that its interface is covered in another module. The +line %import "base_module.i" lets SWIG know exactly that. Oftentimes +the .h file is passed to %import instead of the .i, +which unfortunately doesn't work for all language modules. For example, Python requires the +name of module that the base class exists in so that the proxy classes can fully inherit the +base class's methods. Typically you will get a warning when the module name is missing, eg: +

    + +
    +derived_module.i:8: Warning(401): Base class 'base' ignored - unknown module name for base. Either import 
    +the appropriate module interface file or specify the name of the module in the %import directive.
    +
    + +

    +It is sometimes desirable to import the header file rather than the interface file and overcome +the above warning. +For example in the case of the imported interface being quite large, it may be desirable to +simplify matters and just import a small header file of dependent types. +This can be done by specifying the optional module attribute in the %import directive. +The derived_module.i file shown above could be replaced with the following: + +

    +// File: derived_module.i
    +%module derived_module
    +
    +%import(module="base_module") "base.h"
    +
    +%inline %{
    +class derived : public base {
    +public:
    +  int bar();
    +};
    +
    + +

    +Note that "base_module" is the module name and is the same as that specified in %module +in base_module.i as well as the %import in derived_module.i. +

    + +

    +Another issue +to beware of is that multiple dependent wrappers should not be linked/loaded in parallel from multiple threads as SWIG provides no locking - for more on that issue, read on.

    +

    15.2 The SWIG runtime code

    diff --git a/Doc/Manual/Preprocessor.html b/Doc/Manual/Preprocessor.html index a454c8124..d79ad7377 100644 --- a/Doc/Manual/Preprocessor.html +++ b/Doc/Manual/Preprocessor.html @@ -81,7 +81,7 @@ Such information generally includes type declarations (e.g., typedef) a C++ classes that might be used as base-classes for class declarations in the interface. The use of %import is also important when SWIG is used to generate extensions as a collection of related modules. This is an advanced topic and is described -in a later chapter. +in later in the Working with Modules chapter.

    diff --git a/Examples/test-suite/import_nomodule.i b/Examples/test-suite/import_nomodule.i index 5d5115360..a1ba9ad7a 100644 --- a/Examples/test-suite/import_nomodule.i +++ b/Examples/test-suite/import_nomodule.i @@ -3,6 +3,9 @@ #include "import_nomodule.h" %} +// For Python +%warnfilter(SWIGWARN_TYPE_UNDEFINED_CLASS) Bar; // Base class 'Foo' ignored - unknown module name for base. Either import the appropriate module interface file or specify the name of the module in the %import directive. + %import "import_nomodule.h" #if !defined(SWIGJAVA) && !defined(SWIGRUBY) && !defined(SWIGCSHARP) diff --git a/Examples/test-suite/imports_b.i b/Examples/test-suite/imports_b.i index afc573a39..81e84cddd 100644 --- a/Examples/test-suite/imports_b.i +++ b/Examples/test-suite/imports_b.i @@ -34,9 +34,14 @@ */ #if 0 -%import "imports_a.i" + %import "imports_a.i" #else -%import(module="imports_a") "imports_a.h" +# if 0 + // Test Warning 401 (Python only) + %import "imports_a.h" +# else + %import(module="imports_a") "imports_a.h" +# endif #endif %include "imports_b.h" diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 7a878b4f8..7298c5f9e 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -2864,7 +2864,12 @@ public: b = First(baselist); while (b.item) { String *bname = Getattr(b.item, "python:proxy"); - if (!bname || GetFlag(b.item, "feature:ignore")) { + bool ignore = GetFlag(b.item, "feature:ignore") ? true : false; + if (!bname || ignore) { + if (!bname && !ignore) { + Swig_warning(WARN_TYPE_UNDEFINED_CLASS, input_file, line_number, + "Base class '%s' ignored - unknown module name for base. Either import the appropriate module interface file or specify the name of the module in the %%import directive.\n", SwigType_namestr(Getattr(b.item, "name"))); + } b = Next(b); continue; } From 6588eb61f4519ff0a28b813cbbf56803005d1427 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 18 Sep 2008 20:16:03 +0000 Subject: [PATCH 0120/1680] pointer display correction git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10867 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/python/pyrun.swg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index 4f51d3a95..71759e414 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -384,7 +384,7 @@ PySwigObject_repr(PySwigObject *v, PyObject *args) { const char *name = SWIG_TypePrettyName(v->ty); PyObject *hex = PySwigObject_hex(v); - PyObject *repr = SWIG_Python_str_FromFormat("", name, hex); + PyObject *repr = SWIG_Python_str_FromFormat("", name, hex); Py_DECREF(hex); if (v->next) { #ifdef METH_NOARGS From 7ec3c4ae81a5b91c7d6fd545a3c0a1ce3e8149e1 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 18 Sep 2008 20:16:50 +0000 Subject: [PATCH 0121/1680] minor typo and formatting improvements git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10868 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/python/pybuffer.i | 2 +- Lib/python/pyerrors.swg | 3 +-- Lib/python/pyhead.swg | 8 +++----- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/Lib/python/pybuffer.i b/Lib/python/pybuffer.i index 3dc4c2121..5acbb0aa4 100644 --- a/Lib/python/pybuffer.i +++ b/Lib/python/pybuffer.i @@ -1,4 +1,4 @@ -/* Impelementing buffer protocol typemaps */ +/* Implementing buffer protocol typemaps */ /* %pybuffer_mutable_binary(TYPEMAP, SIZE) * diff --git a/Lib/python/pyerrors.swg b/Lib/python/pyerrors.swg index 01cf53e9b..63f0344e4 100644 --- a/Lib/python/pyerrors.swg +++ b/Lib/python/pyerrors.swg @@ -59,8 +59,7 @@ SWIG_Python_AddErrorMsg(const char* mesg) PyErr_Clear(); Py_XINCREF(type); - PyErr_Format(type, "%s %s", - SWIG_Python_str_AsChar(old_str), mesg); + PyErr_Format(type, "%s %s", SWIG_Python_str_AsChar(old_str), mesg); Py_DECREF(old_str); Py_DECREF(value); } else { diff --git a/Lib/python/pyhead.swg b/Lib/python/pyhead.swg index d73d3d112..ecafc46c8 100644 --- a/Lib/python/pyhead.swg +++ b/Lib/python/pyhead.swg @@ -2,19 +2,18 @@ #if PY_VERSION_HEX >= 0x03000000 #define PyClass_Check(obj) PyObject_IsInstance(obj, (PyObject *)&PyType_Type) - #define PyInt_Check(x) PyLong_Check(x) #define PyInt_AsLong(x) PyLong_AsLong(x) #define PyInt_FromLong(x) PyLong_FromLong(x) - #define PyString_Format(fmt, args) PyUnicode_Format(fmt, args) + #endif #ifndef Py_TYPE # define Py_TYPE(op) ((op)->ob_type) #endif -/* SWIG APIs for compatibility of boht Python 2 & 3 */ +/* SWIG APIs for compatibility of both Python 2 & 3 */ #if PY_VERSION_HEX >= 0x03000000 # define SWIG_Python_str_FromFormat PyUnicode_FromFormat @@ -88,6 +87,7 @@ PyString_FromFormat(const char *fmt, ...) { # define PyObject_GenericGetAttr 0 # endif #endif + /* Py_NotImplemented is defined in 2.1 and up. */ #if PY_VERSION_HEX < 0x02010000 # ifndef Py_NotImplemented @@ -95,7 +95,6 @@ PyString_FromFormat(const char *fmt, ...) { # endif #endif - /* A crude PyString_AsStringAndSize implementation for old Pythons */ #if PY_VERSION_HEX < 0x02010000 # ifndef PyString_AsStringAndSize @@ -110,7 +109,6 @@ PyString_FromFormat(const char *fmt, ...) { # endif #endif - /* PyBool_FromLong for old Pythons */ #if PY_VERSION_HEX < 0x02030000 static From 4c6e31430877f20c7447ae69bd9cfe46693aee27 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 18 Sep 2008 20:21:17 +0000 Subject: [PATCH 0122/1680] remove confusion over tab widths git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10869 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/python.cxx | 41 ++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 7298c5f9e..9e6409af6 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -10,11 +10,8 @@ char cvsroot_python_cxx[] = "$Id$"; #include "swigmod.h" -#define ctab2 " " -#define ctab4 " " -#define ctab8 " " - #include "cparse.h" + static int treduce = SWIG_cparse_template_reduce(0); #include @@ -1643,15 +1640,15 @@ public: /* Make a wrapper function to insert the code into */ Printv(f_dest, "\ndef ", name, "(", parms, ")", returnTypeAnnotation(n), ":\n", NIL); if (have_docstring(n)) - Printv(f_dest, ctab4, docstring(n, AUTODOC_FUNC, tab4), "\n", NIL); + Printv(f_dest, " ", docstring(n, AUTODOC_FUNC, tab4), "\n", NIL); if (have_pythonprepend(n)) - Printv(f_dest, ctab4, pythonprepend(n), "\n", NIL); + Printv(f_dest, " ", pythonprepend(n), "\n", NIL); if (have_pythonappend(n)) { - Printv(f_dest, ctab4, "val = ", funcCall(name, callParms), "\n", NIL); - Printv(f_dest, ctab4, pythonappend(n), "\n", NIL); - Printv(f_dest, ctab4, "return val\n", NIL); + Printv(f_dest, " val = ", funcCall(name, callParms), "\n", NIL); + Printv(f_dest, " ", pythonappend(n), "\n", NIL); + Printv(f_dest, " return val\n", NIL); } else { - Printv(f_dest, ctab4, "return ", funcCall(name, callParms), "\n", NIL); + Printv(f_dest, " return ", funcCall(name, callParms), "\n", NIL); } if (Getattr(n, "feature:python:callback") || !have_addtofunc(n)) { @@ -2058,7 +2055,7 @@ public: /* finish argument marshalling */ Append(kwargs, " NULL }"); if (allow_kwargs) { - Printv(f->locals, ctab4, "char * kwnames[] = ", kwargs, ";\n", NIL); + Printv(f->locals, " char * kwnames[] = ", kwargs, ";\n", NIL); } if (use_parse || allow_kwargs || !modernargs) { @@ -2330,7 +2327,7 @@ public: } if (allow_thread) thread_end_block(n, f->code); - Printv(f->code, ctab4, "return NULL;\n", NIL); + Printv(f->code, " return NULL;\n", NIL); if (funpack) { @@ -2462,9 +2459,9 @@ public: } else { Swig_warning(WARN_TYPEMAP_VARIN_UNDEF, input_file, line_number, "Unable to set variable of type %s.\n", SwigType_str(t, 0)); } - Printv(setf->code, ctab4, "return 0;\n", NULL); + Printv(setf->code, " return 0;\n", NULL); Append(setf->code, "fail:\n"); - Printv(setf->code, ctab4, "return 1;\n", NULL); + Printv(setf->code, " return 1;\n", NULL); } else { /* Is a readonly variable. Issue an error */ if (CPlusPlus) { @@ -2472,7 +2469,7 @@ public: } else { Printf(setf->def, "SWIGINTERN int %s(PyObject *_val SWIGUNUSED) {", varsetname); } - Printv(setf->code, ctab4, "SWIG_Error(SWIG_AttributeError,\"Variable ", iname, " is read-only.\");\n", ctab4, "return 1;\n", NIL); + Printv(setf->code, " SWIG_Error(SWIG_AttributeError,\"Variable ", iname, " is read-only.\");\n", " return 1;\n", NIL); } Append(setf->code, "}\n"); @@ -2969,20 +2966,20 @@ public: SwigType_add_pointer(realct); SwigType_remember(realct); Printv(f_wrappers, "SWIGINTERN PyObject *", class_name, "_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {\n", NIL); - Printv(f_wrappers, ctab4, "PyObject *obj;\n", NIL); + Printv(f_wrappers, " PyObject *obj;\n", NIL); if (modernargs) { if (fastunpack) { - Printv(f_wrappers, ctab4, "if (!SWIG_Python_UnpackTuple(args,(char*)\"swigregister\", 1, 1,&obj)) return NULL;\n", NIL); + Printv(f_wrappers, " if (!SWIG_Python_UnpackTuple(args,(char*)\"swigregister\", 1, 1,&obj)) return NULL;\n", NIL); } else { - Printv(f_wrappers, ctab4, "if (!PyArg_UnpackTuple(args,(char*)\"swigregister\", 1, 1,&obj)) return NULL;\n", NIL); + Printv(f_wrappers, " if (!PyArg_UnpackTuple(args,(char*)\"swigregister\", 1, 1,&obj)) return NULL;\n", NIL); } } else { - Printv(f_wrappers, ctab4, "if (!PyArg_ParseTuple(args,(char*)\"O:swigregister\", &obj)) return NULL;\n", NIL); + Printv(f_wrappers, " if (!PyArg_ParseTuple(args,(char*)\"O:swigregister\", &obj)) return NULL;\n", NIL); } Printv(f_wrappers, - ctab4, "SWIG_TypeNewClientData(SWIGTYPE", SwigType_manglestr(ct), ", SWIG_NewClientData(obj));\n", - ctab4, "return SWIG_Py_Void();\n", "}\n\n", NIL); + " SWIG_TypeNewClientData(SWIGTYPE", SwigType_manglestr(ct), ", SWIG_NewClientData(obj));\n", + " return SWIG_Py_Void();\n", "}\n\n", NIL); String *cname = NewStringf("%s_swigregister", class_name); add_method(cname, cname, 0); Delete(smart); @@ -2995,7 +2992,7 @@ public: } else if (fastinit) { Printv(f_wrappers, "SWIGINTERN PyObject *", class_name, "_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {\n", NIL); - Printv(f_wrappers, ctab4, "return SWIG_Python_InitShadowInstance(args);\n", "}\n\n", NIL); + Printv(f_wrappers, " return SWIG_Python_InitShadowInstance(args);\n", "}\n\n", NIL); String *cname = NewStringf("%s_swiginit", class_name); add_method(cname, cname, 0); Delete(cname); From 757d2e2e3758a4f1efa31f2bb2f469da0a94b387 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 18 Sep 2008 20:27:57 +0000 Subject: [PATCH 0123/1680] warning fix git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10870 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 63988a868..7bddabb94 100644 --- a/Source/Modules/allegrocl.cxx +++ b/Source/Modules/allegrocl.cxx @@ -735,12 +735,12 @@ String *internal_compose_foreign_type(SwigType *ty) { return ffiType; } -String *compose_foreign_type(SwigType *ty, String *id = 0) { +String *compose_foreign_type(SwigType *ty, String * /*id*/ = 0) { /* Hash *lookup_res = Swig_typemap_search("ffitype", ty, id, 0); */ #ifdef ALLEGROCL_TYPE_DEBUG - Printf(stderr, "compose_foreign_type: ENTER (%s)(%s)...\n ", ty, (id ? id : 0)); + Printf(stderr, "compose_foreign_type: ENTER (%s)...\n ", ty, (id ? id : 0)); /* String *id_ref = SwigType_str(ty, id); Printf(stderr, "looking up typemap for %s, found '%s'(%x)\n", id_ref, lookup_res ? Getattr(lookup_res, "code") : 0, lookup_res); From 1ebd0466f5cd8dbfd91d2fd7c27d7e68bce11897 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 18 Sep 2008 20:28:40 +0000 Subject: [PATCH 0124/1680] formatting fix git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10871 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/swigmod.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Modules/swigmod.h b/Source/Modules/swigmod.h index 5835c6362..84817a27d 100644 --- a/Source/Modules/swigmod.h +++ b/Source/Modules/swigmod.h @@ -114,8 +114,8 @@ protected: class Language:public Dispatcher { public: - Language (); - virtual ~ Language (); + Language(); + virtual ~Language(); virtual int emit_one(Node *n); /* Parse command line options */ From 09915566bcc6703b0ca645998c722c112d1dbef4 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 18 Sep 2008 20:32:28 +0000 Subject: [PATCH 0125/1680] Add C# array typemaps provided by Antti Karanta. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10872 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 14 +- Doc/Manual/CSharp.html | 7 +- Examples/csharp/arrays/Makefile | 20 +++ Examples/csharp/arrays/example.c | 22 +++ Examples/csharp/arrays/example.h | 4 + Examples/csharp/arrays/example.i | 42 ++++++ Examples/csharp/arrays/runme.cs | 43 ++++++ Examples/csharp/check.list | 1 + Examples/test-suite/csharp/Makefile.in | 12 +- .../csharp/csharp_lib_arrays_runme.cs | 70 +++++++++ Examples/test-suite/csharp_lib_arrays.i | 61 ++++++++ Lib/csharp/arrays_csharp.i | 140 ++++++++++++++++++ 12 files changed, 428 insertions(+), 8 deletions(-) create mode 100644 Examples/csharp/arrays/Makefile create mode 100644 Examples/csharp/arrays/example.c create mode 100644 Examples/csharp/arrays/example.h create mode 100644 Examples/csharp/arrays/example.i create mode 100644 Examples/csharp/arrays/runme.cs create mode 100644 Examples/test-suite/csharp/csharp_lib_arrays_runme.cs create mode 100644 Examples/test-suite/csharp_lib_arrays.i create mode 100644 Lib/csharp/arrays_csharp.i diff --git a/CHANGES.current b/CHANGES.current index 371b280fc..cb31d33c6 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,12 @@ Version 1.3.37 (in progress) ============================= +2008-09-17: wsfulton + [C#] Added C# array typemaps provided by Antti Karanta. + The arrays provide a way to use MarshalAs(UnmanagedType.LPArray) + and pinning the array using 'fixed'. See arrays_csharp.i library file + for details. + 2008-09-18: wsfulton Document the optional module attribute in the %import directive, see Modules.html. Add a warning for Python wrappers when the @@ -49,10 +55,10 @@ Version 1.3.37 (in progress) - some minor aesthetic changes. 2008-09-12: bhy - [Python] Python 3.0 support branch merged into SWIG trunk. Thanks - Google Summer of Code 2008 for support this project! By default + [Python] Python 3.0 support branch merged into SWIG trunk. Thanks to + Google Summer of Code 2008 for supporting this project! By default SWIG will generate interface files compatible with both Python 2.x - and 3.0. And there's also some Python 3 new features could be + and 3.0. And there's also some Python 3 new features that can be enabled by passing a "-py3" command line option to SWIG. These features are: @@ -64,7 +70,7 @@ Version 1.3.37 (in progress) - Abstract base class support For details of Python 3 support and these features, please see the - "Python 3 Support" section in the "SWIG and Python" chapter of SWIG + "Python 3 Support" section in the "SWIG and Python" chapter of the SWIG documentation. The "-apply" command line option and support of generating codes diff --git a/Doc/Manual/CSharp.html b/Doc/Manual/CSharp.html index a712f82f2..a09aa0b93 100644 --- a/Doc/Manual/CSharp.html +++ b/Doc/Manual/CSharp.html @@ -201,7 +201,12 @@ $jnicall -> $imcall

  • -Unlike the "javain" typemap, the "csin" typemap does not support the 'pgcpp' attribute as the C# module does not have a premature garbage collection prevention parameter. The "csin" typemap supports an additional optional attribute called 'cshin'. It should contain the parameter type and name whenever a constructor helper function is generated due to the 'pre' or 'post' attributes. Note that 'pre', 'post' and 'cshin' attributes are not used for marshalling the property set. Please see the Date marshalling example and Date marshalling of properties example for further understanding. +Unlike the "javain" typemap, the "csin" typemap does not support the 'pgcpp' attribute as the C# module does not have a premature garbage collection prevention parameter. +The "csin" typemap supports additional optional attributes called 'cshin' and 'terminator'. +The 'cshin' attribute should contain the parameter type and name whenever a constructor helper function is generated due to the 'pre' or 'post' attributes. +The 'terminator' attribute normally just contains a closing brace for when the 'pre' attribute contains an opening brace, such as when a C# using or fixed block is started. +Note that 'pre', 'post', 'terminator' and 'cshin' attributes are not used for marshalling the property set. +Please see the Date marshalling example and Date marshalling of properties example for further understanding of these "csin" applicable attributes.

  • diff --git a/Examples/csharp/arrays/Makefile b/Examples/csharp/arrays/Makefile new file mode 100644 index 000000000..b3446d895 --- /dev/null +++ b/Examples/csharp/arrays/Makefile @@ -0,0 +1,20 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +SRCS = example.c +TARGET = example +INTERFACE = example.i +SWIGOPT = +CSHARPSRCS = *.cs +CSHARPFLAGS= -nologo -unsafe -out:runme.exe + +all:: csharp + +csharp:: + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp + $(MAKE) -f $(TOP)/Makefile CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile + +clean:: + $(MAKE) -f $(TOP)/Makefile csharp_clean + +check: all diff --git a/Examples/csharp/arrays/example.c b/Examples/csharp/arrays/example.c new file mode 100644 index 000000000..2498e1f4e --- /dev/null +++ b/Examples/csharp/arrays/example.c @@ -0,0 +1,22 @@ +/* File : example.c */ + +#include "example.h" + +/* copy the contents of the first array to the second */ +void myArrayCopy( int* sourceArray, int* targetArray, int nitems ) { + int i; + for ( i = 0; i < nitems; i++ ) { + targetArray[ i ] = sourceArray[ i ]; + } +} + +/* swap the contents of the two arrays */ +void myArraySwap( int* array1, int* array2, int nitems ) { + int i, temp; + for ( i = 0; i < nitems; i++ ) { + temp = array1[ i ]; + array1[ i ] = array2[ i ]; + array2[ i ] = temp; + } +} + diff --git a/Examples/csharp/arrays/example.h b/Examples/csharp/arrays/example.h new file mode 100644 index 000000000..113b92c1b --- /dev/null +++ b/Examples/csharp/arrays/example.h @@ -0,0 +1,4 @@ + +void myArrayCopy( int *sourceArray, int* targetArray, int nitems ); +void myArraySwap( int* array1, int* array2, int nitems ); + diff --git a/Examples/csharp/arrays/example.i b/Examples/csharp/arrays/example.i new file mode 100644 index 000000000..22b9aa19d --- /dev/null +++ b/Examples/csharp/arrays/example.i @@ -0,0 +1,42 @@ +/* File : example.i */ +%module example + +%include "arrays_csharp.i" + +%apply int INPUT[] { int* sourceArray } +%apply int OUTPUT[] { int* targetArray } + +%apply int INOUT[] { int* array1 } +%apply int INOUT[] { int* array2 } + +%include "example.h" + +%clear int* sourceArray; +%clear int* targetArray; + +%clear int* array1; +%clear int* array2; + + +// Below replicates the above array handling but this time using the pinned (fixed) array typemaps +%csmethodmodifiers "public unsafe"; + +%apply int FIXED[] { int* sourceArray } +%apply int FIXED[] { int* targetArray } + +%inline %{ +void myArrayCopyUsingFixedArrays( int *sourceArray, int* targetArray, int nitems ) { + myArrayCopy(sourceArray, targetArray, nitems); +} +%} + +%apply int FIXED[] { int* array1 } +%apply int FIXED[] { int* array2 } + +%inline %{ +void myArraySwapUsingFixedArrays( int* array1, int* array2, int nitems ) { + myArraySwap(array1, array2, nitems); +} +%} + + diff --git a/Examples/csharp/arrays/runme.cs b/Examples/csharp/arrays/runme.cs new file mode 100644 index 000000000..c2b8a6bdd --- /dev/null +++ b/Examples/csharp/arrays/runme.cs @@ -0,0 +1,43 @@ +using System; + +public class runme +{ + static void Main() + { + int[] source = { 1, 2, 3 }; + int[] target = new int[ source.Length ]; + + example.myArrayCopy( source, target, target.Length ); + + Console.WriteLine( "Contents of copy target array using default marshaling" ); + PrintArray( target ); + + target = new int[ source.Length ]; + + example.myArrayCopyUsingFixedArrays( source, target, target.Length ); + Console.WriteLine( "Contents of copy target array using fixed arrays" ); + PrintArray( target ); + + target = new int[] { 4, 5, 6 }; + example.myArraySwap( source, target, target.Length ); + Console.WriteLine( "Contents of arrays after swapping using default marshaling" ); + PrintArray( source ); + PrintArray( target ); + + source = new int[] { 1, 2, 3 }; + target = new int[] { 4, 5, 6 }; + + example.myArraySwapUsingFixedArrays( source, target, target.Length ); + Console.WriteLine( "Contents of arrays after swapping using fixed arrays" ); + PrintArray( source ); + PrintArray( target ); + } + + static void PrintArray( int[] a ) + { + foreach ( int i in a ) + Console.Write( "{0} ", i ); + Console.WriteLine(); + } +} + diff --git a/Examples/csharp/check.list b/Examples/csharp/check.list index c4d92402b..5454d8531 100644 --- a/Examples/csharp/check.list +++ b/Examples/csharp/check.list @@ -1,4 +1,5 @@ # see top-level Makefile.in +arrays callback class enum diff --git a/Examples/test-suite/csharp/Makefile.in b/Examples/test-suite/csharp/Makefile.in index 5fd576ed8..f269b3276 100644 --- a/Examples/test-suite/csharp/Makefile.in +++ b/Examples/test-suite/csharp/Makefile.in @@ -21,13 +21,17 @@ CPP_TEST_CASES = \ enum_thorough_typesafe \ exception_partial_info -CUSTOM_TEST_CASES = intermediary_classname +CUSTOM_TEST_CASES = \ + csharp_lib_arrays \ + intermediary_classname include $(srcdir)/../common.mk # Overridden variables here SWIGOPT += -namespace $*Namespace $(SWIGOPTSPECIAL) +CSHARPFLAGSSPECIAL = + # Rules for the different types of tests %.cpptest: $(setup) @@ -47,6 +51,8 @@ SWIGOPT += -namespace $*Namespace $(SWIGOPTSPECIAL) # Rules for custom tests intermediary_classname.customtest: $(MAKE) intermediary_classname.cpptest SWIGOPTSPECIAL="-dllimport intermediary_classname" +csharp_lib_arrays.customtest: + $(MAKE) csharp_lib_arrays.cpptest CSHARPFLAGSSPECIAL="-unsafe" # Makes a directory for the testcase if it does not exist setup = \ @@ -65,14 +71,14 @@ setup = \ run_testcase = \ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then ( \ $(MAKE) -f $*/$(top_builddir)/$(EXAMPLES)/Makefile \ - CSHARPFLAGS='-nologo -out:$*_runme.exe' \ + 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 ( \ cd $* && \ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile \ - CSHARPFLAGS='-nologo -t:module -out:$*.netmodule' \ + CSHARPFLAGS='-nologo $(CSHARPFLAGSSPECIAL) -t:module -out:$*.netmodule' \ CSHARPSRCS='*.cs' csharp_compile; ); \ fi; diff --git a/Examples/test-suite/csharp/csharp_lib_arrays_runme.cs b/Examples/test-suite/csharp/csharp_lib_arrays_runme.cs new file mode 100644 index 000000000..9f3ea6b88 --- /dev/null +++ b/Examples/test-suite/csharp/csharp_lib_arrays_runme.cs @@ -0,0 +1,70 @@ +using System; +using csharp_lib_arraysNamespace; + +public class runme +{ + static void Main() + { + { + int[] source = { 1, 2, 3, 4, 5 }; + int[] target = new int[ source.Length ]; + + csharp_lib_arrays.myArrayCopy( source, target, target.Length ); + CompareArrays(source, target); + } + + { + int[] source = { 1, 2, 3, 4, 5 }; + int[] target = new int[ source.Length ]; + + csharp_lib_arrays.myArrayCopyUsingFixedArrays( source, target, target.Length ); + CompareArrays(source, target); + } + + { + int[] source = { 1, 2, 3, 4, 5 }; + int[] target = new int[] { 6, 7, 8, 9, 10 }; + + csharp_lib_arrays.myArraySwap( source, target, target.Length ); + + for (int i=0; i Date: Thu, 18 Sep 2008 20:33:37 +0000 Subject: [PATCH 0126/1680] revert debug break in last commit git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10873 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/allegrocl.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Modules/allegrocl.cxx b/Source/Modules/allegrocl.cxx index 7bddabb94..615007c1b 100644 --- a/Source/Modules/allegrocl.cxx +++ b/Source/Modules/allegrocl.cxx @@ -740,7 +740,7 @@ String *compose_foreign_type(SwigType *ty, String * /*id*/ = 0) { /* Hash *lookup_res = Swig_typemap_search("ffitype", ty, id, 0); */ #ifdef ALLEGROCL_TYPE_DEBUG - Printf(stderr, "compose_foreign_type: ENTER (%s)...\n ", ty, (id ? id : 0)); + Printf(stderr, "compose_foreign_type: ENTER (%s)(%s)...\n ", ty, (id ? id : 0)); /* String *id_ref = SwigType_str(ty, id); Printf(stderr, "looking up typemap for %s, found '%s'(%x)\n", id_ref, lookup_res ? Getattr(lookup_res, "code") : 0, lookup_res); From 60622a9c2b08c14d12e7f414e83cfb6ed75bd732 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 18 Sep 2008 20:39:15 +0000 Subject: [PATCH 0127/1680] fix unused variable warning git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10874 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/intermediary_classname.i | 1 + 1 file changed, 1 insertion(+) diff --git a/Examples/test-suite/intermediary_classname.i b/Examples/test-suite/intermediary_classname.i index 0f90f9cdd..94858a5fb 100644 --- a/Examples/test-suite/intermediary_classname.i +++ b/Examples/test-suite/intermediary_classname.i @@ -18,6 +18,7 @@ "new $javaclassname($jniinput, false)/*javadirectorin*/" %typemap(out, throws="IllegalAccessException/*out Base&*/") Base& { // XYZ& typemap out + $result = 0; // remove unused variable warning } %inline %{ From 90a4d04d85c8876d87368a101924eefa2d6c5dc1 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 18 Sep 2008 23:17:52 +0000 Subject: [PATCH 0128/1680] revert entry 2008-09-01 - C# Insert and InsertRange bounds checking git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10875 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 6 +----- Lib/csharp/std_vector.i | 4 ++-- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index cb31d33c6..b50be4f97 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,7 +1,7 @@ Version 1.3.37 (in progress) ============================= -2008-09-17: wsfulton +2008-09-18: wsfulton [C#] Added C# array typemaps provided by Antti Karanta. The arrays provide a way to use MarshalAs(UnmanagedType.LPArray) and pinning the array using 'fixed'. See arrays_csharp.i library file @@ -110,10 +110,6 @@ Version 1.3.37 (in progress) [CFFI] Commit patch #2079381 submitted by Boris Smilga - constant exprs put into no-eval context in DEFCENUM -2008-09-01: wsfulton - [C#] Correct array bounds checking in std::vector typemaps - Insert and InsertRange - methods. - 2008-08-02: wuzzeb [Chicken,Allegro] Commit Patch 2019314 Fixes a build error in chicken, and several build errors and other errors diff --git a/Lib/csharp/std_vector.i b/Lib/csharp/std_vector.i index 2e4d47c00..a04831f75 100755 --- a/Lib/csharp/std_vector.i +++ b/Lib/csharp/std_vector.i @@ -231,14 +231,14 @@ return new std::vector(self->begin()+index, self->begin()+index+count); } void Insert(int index, const value_type& x) throw (std::out_of_range) { - if (index>=0 && index<(int)self->size()) + if (index>=0 && index<(int)self->size()+1) self->insert(self->begin()+index, x); else throw std::out_of_range("index"); } // Takes a deep copy of the elements unlike ArrayList.InsertRange void InsertRange(int index, const std::vector& values) throw (std::out_of_range) { - if (index>=0 && index<(int)self->size()) + if (index>=0 && index<(int)self->size()+1) self->insert(self->begin()+index, values.begin(), values.end()); else throw std::out_of_range("index"); From 03429576fce385f2e4dd31f28e75b9e8d4dba2c8 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Fri, 19 Sep 2008 03:20:59 +0000 Subject: [PATCH 0129/1680] [PHP5] Add typemaps for long long and unsigned long long. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10876 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 3 ++ Lib/php/typemaps.i | 73 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index b50be4f97..1b01507cb 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,9 @@ Version 1.3.37 (in progress) ============================= +2008-09-19: olly + [PHP5] Add typemaps for long long and unsigned long long. + 2008-09-18: wsfulton [C#] Added C# array typemaps provided by Antti Karanta. The arrays provide a way to use MarshalAs(UnmanagedType.LPArray) diff --git a/Lib/php/typemaps.i b/Lib/php/typemaps.i index c5b749578..6c3a25293 100644 --- a/Lib/php/typemaps.i +++ b/Lib/php/typemaps.i @@ -96,16 +96,83 @@ int_typemap(unsigned short); int_typemap(unsigned long); int_typemap(unsigned char); +int_typemap(long long); +%typemap(argout,fragment="t_output_helper") long long *OUTPUT +{ + zval *o; + MAKE_STD_ZVAL(o); + if ((long long)LONG_MIN <= temp$argnum && temp$argnum <= (long long)LONG_MAX) { + ZVAL_LONG(o, temp$argnum); + } else { + char temp[256]; + sprintf(temp, "%lld", temp$argnum); + ZVAL_STRING(o, temp, 1); + } + t_output_helper( &$result, o ); +} +%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; + $1 = &lvalue; +%} +%typemap(argout) long long *REFERENCE +%{ + if ((long long)LONG_MIN <= lvalue$argnum && lvalue$argnum <= (long long)LONG_MAX) { + (*$arg)->value.lval = (long)(lvalue$argnum); + (*$arg)->type = IS_LONG; + } else { + char temp[256]; + sprintf(temp, "%lld", lvalue$argnum); + ZVAL_STRING((*$arg), temp, 1); + } +%} +int_typemap(unsigned long long); +%typemap(argout,fragment="t_output_helper") unsigned long long *OUTPUT +{ + zval *o; + MAKE_STD_ZVAL(o); + if (temp$argnum <= (unsigned long long)LONG_MAX) { + ZVAL_LONG(o, temp$argnum); + } else { + char temp[256]; + sprintf(temp, "%llu", temp$argnum); + ZVAL_STRING(o, temp, 1); + } + t_output_helper( &$result, o ); +} +%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; + $1 = &lvalue; +%} +%typemap(argout) unsigned long long *REFERENCE +%{ + if (lvalue$argnum <= (unsigned long long)LONG_MAX) { + (*$arg)->value.lval = (long)(lvalue$argnum); + (*$arg)->type = IS_LONG; + } else { + char temp[256]; + sprintf(temp, "%llu", lvalue$argnum); + ZVAL_STRING((*$arg), temp, 1); + } +%} + %typemap(in) float *INOUT = float *INPUT; %typemap(in) double *INOUT = double *INPUT; %typemap(in) int *INOUT = int *INPUT; %typemap(in) short *INOUT = short *INPUT; %typemap(in) long *INOUT = long *INPUT; +%typemap(in) long long *INOUT = long long *INPUT; %typemap(in) unsigned *INOUT = unsigned *INPUT; %typemap(in) unsigned short *INOUT = unsigned short *INPUT; %typemap(in) unsigned long *INOUT = unsigned long *INPUT; %typemap(in) unsigned char *INOUT = unsigned char *INPUT; +%typemap(in) unsigned long long *INOUT = unsigned long long *INPUT; %typemap(in) float &INOUT = float *INPUT; %typemap(in) double &INOUT = double *INPUT; @@ -113,10 +180,12 @@ int_typemap(unsigned char); %typemap(in) int &INOUT = int *INPUT; %typemap(in) short &INOUT = short *INPUT; %typemap(in) long &INOUT = long *INPUT; +%typemap(in) long long &INOUT = long long *INPUT; %typemap(in) unsigned &INOUT = unsigned *INPUT; %typemap(in) unsigned short &INOUT = unsigned short *INPUT; %typemap(in) unsigned long &INOUT = unsigned long *INPUT; %typemap(in) unsigned char &INOUT = unsigned char *INPUT; +%typemap(in) unsigned long long &INOUT = unsigned long long *INPUT; %typemap(argout) float *INOUT = float *OUTPUT; %typemap(argout) double *INOUT= double *OUTPUT; @@ -124,9 +193,11 @@ int_typemap(unsigned char); %typemap(argout) int *INOUT = int *OUTPUT; %typemap(argout) short *INOUT = short *OUTPUT; %typemap(argout) long *INOUT= long *OUTPUT; +%typemap(argout) long long *INOUT= long long *OUTPUT; %typemap(argout) unsigned short *INOUT= unsigned short *OUTPUT; %typemap(argout) unsigned long *INOUT = unsigned long *OUTPUT; %typemap(argout) unsigned char *INOUT = unsigned char *OUTPUT; +%typemap(argout) unsigned long long *INOUT = unsigned long long *OUTPUT; %typemap(argout) float &INOUT = float *OUTPUT; %typemap(argout) double &INOUT= double *OUTPUT; @@ -134,9 +205,11 @@ int_typemap(unsigned char); %typemap(argout) int &INOUT = int *OUTPUT; %typemap(argout) short &INOUT = short *OUTPUT; %typemap(argout) long &INOUT= long *OUTPUT; +%typemap(argout) long long &INOUT= long long *OUTPUT; %typemap(argout) unsigned short &INOUT= unsigned short *OUTPUT; %typemap(argout) unsigned long &INOUT = unsigned long *OUTPUT; %typemap(argout) unsigned char &INOUT = unsigned char *OUTPUT; +%typemap(argout) unsigned long long &INOUT = unsigned long long *OUTPUT; %typemap(in) char INPUT[ANY] ( char temp[$1_dim0] ) %{ From 1a0632b35dfeace70bb6b6d926789ab959ddf7c1 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Fri, 19 Sep 2008 06:40:39 +0000 Subject: [PATCH 0130/1680] Clean out more PHP4 stuff. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10877 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/php.cxx | 42 +++++++++++++++++++----------------------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index 70061b56e..e96e64c02 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -2,9 +2,9 @@ * See the LICENSE file for information on copyright, usage and redistribution * of SWIG, and the README file for authors - http://www.swig.org/release.html. * - * php4.cxx + * php.cxx * - * Php language module for SWIG. + * PHP language module for SWIG. * ----------------------------------------------------------------------------- */ @@ -40,7 +40,7 @@ * (may need to add more WARN_PHP_xxx codes...) */ -char cvsroot_php4_cxx[] = "$Id$"; +char cvsroot_php_cxx[] = "$Id$"; #include "swigmod.h" @@ -54,7 +54,7 @@ PHP Options (available with -php5)\n\ -prefix - Prepend to all class names in PHP5 wrappers\n\ \n"; -/* The original class wrappers for PHP4 store the pointer to the C++ class in +/* The original class wrappers for PHP4 stored the pointer to the C++ class in * the object property _cPtr. If we use the same name for the member variable * which we put the pointer to the C++ class in, then the flat function * wrappers will automatically pull it out without any changes being required. @@ -141,7 +141,7 @@ void SwigPHP_emit_resource_registrations() { Printf(s_wrappers, "/* NEW Destructor style */\nstatic ZEND_RSRC_DTOR_FUNC(_wrap_destroy%s) {\n", key); // write out body - if ((class_node != NOTCLASS)) { + if (class_node != NOTCLASS) { String *destructor = Getattr(class_node, "destructor"); human_name = Getattr(class_node, "sym:name"); if (!human_name) @@ -172,12 +172,9 @@ void SwigPHP_emit_resource_registrations() { } } -class PHP:public Language { - int php_version; - +class PHP : public Language { public: - PHP(int php_version_):php_version(php_version_) { - } + PHP() { } /* Test to see if a type corresponds to something wrapped with a shadow class. */ @@ -710,7 +707,7 @@ public: Printf(f->code, "WRONG_PARAM_COUNT;\n}\n\n"); } - /* Now convert from php to C variables */ + /* Now convert from PHP to C variables */ // At this point, argcount if used is the number of deliberately passed args // not including this_ptr even if it is used. // It means error messages may be out by argbase with error @@ -861,7 +858,7 @@ public: Delete(wname); wname = NULL; - if (!(shadow && php_version == 5)) { + if (!shadow) { DelWrapper(f); return SWIG_OK; } @@ -1535,7 +1532,7 @@ public: Printf(s_cinit, "%s\n", tm); } - if (shadow && php_version == 5) { + if (shadow) { String *enumvalue = GetChar(n, "enumvalue"); String *set_to = iname; @@ -1825,7 +1822,7 @@ public: String *iname = Getattr(n, "sym:name"); /* A temporary(!) hack for static member variables. - * Php currently supports class functions, but not class 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. * @@ -1834,7 +1831,7 @@ public: * static int ncount; * }; * - * would be available in php as Example::ncount() + * would be available in PHP as Example::ncount() */ // If the variable is const, then it's wrapped as a constant with set/get @@ -2009,7 +2006,6 @@ public: Wrapper_print(f, s_wrappers); return SWIG_OK; - } /* ------------------------------------------------------------ @@ -2025,10 +2021,6 @@ public: }; /* class PHP */ -/* ----------------------------------------------------------------------------- - * swig_php() - Instantiate module - * ----------------------------------------------------------------------------- */ - static PHP *maininstance = 0; // We use this function to be able to write out zend_register_list_destructor_ex @@ -2055,8 +2047,12 @@ extern "C" void typetrace(SwigType *ty, String *mangled, String *clientdata) { (*r_prevtracefunc) (ty, mangled, (String *) clientdata); } -static Language *new_swig_php(int php_version) { - maininstance = new PHP(php_version); +/* ----------------------------------------------------------------------------- + * new_swig_php() - Instantiate module + * ----------------------------------------------------------------------------- */ + +static Language *new_swig_php() { + maininstance = new PHP; if (!r_prevtracefunc) { r_prevtracefunc = SwigType_remember_trace(typetrace); } else { @@ -2074,5 +2070,5 @@ extern "C" Language *swig_php4(void) { } extern "C" Language *swig_php5(void) { - return new_swig_php(5); + return new_swig_php(); } From e88b502bab1160cb3b042ae41454d2606c4ba411 Mon Sep 17 00:00:00 2001 From: Mikel Bancroft Date: Mon, 22 Sep 2008 18:41:10 +0000 Subject: [PATCH 0131/1680] [allegrocl] Make type and namespace wrapping more compatible with other modules. cpp test-suite work. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10878 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 11 ++ Examples/test-suite/allegrocl/Makefile.in | 31 +++- Examples/test-suite/char_strings.i | 6 + Lib/allegrocl/allegrocl.swg | 4 +- Source/Modules/allegrocl.cxx | 214 +++++++++++++--------- 5 files changed, 178 insertions(+), 88 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 1b01507cb..ee004fb27 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,17 @@ +2008-09-22 Mikel Bancroft + Version 1.3.37 (in progress) ============================= +2008-09-22: mutandiz (Mikel Bancroft) + [allegrocl] + - Support wrapping of types whose definitions are not seen by + SWIG. They are treated as forward-referenced classes and if a + definition is not seen are treated as (* :void). + - Don't wrap the contents of unnamed namespaces. + - More code cleanup. Removed some extraneous warnings. + - start work on having the allegrocl mod pass the cpp test-suite. + 2008-09-19: olly [PHP5] Add typemaps for long long and unsigned long long. diff --git a/Examples/test-suite/allegrocl/Makefile.in b/Examples/test-suite/allegrocl/Makefile.in index 394d2d524..b3ace9130 100644 --- a/Examples/test-suite/allegrocl/Makefile.in +++ b/Examples/test-suite/allegrocl/Makefile.in @@ -9,21 +9,40 @@ srcdir = @srcdir@ top_srcdir = @top_srcdir@ top_builddir = @top_builddir@ + +# these cpp tests generate warnings/errors when compiling +# the wrapper .cxx file. +CPP_TEST_BROKEN_CXX = \ +# might be a problem in our cxx wrapping. not sure. \ + class_scope_weird \ +# works as expected. must muffle warnings if you want none. \ +# 'struct A' is not seen by SWIG, so it's type cannot be \ +# derived \ +# Look into cxx problems, though. + constant_pointers + + # these cpp tests aren't working. Fix 'em # need to further separate these into tests requiring # std libraries, or the $ldestructor problem. CPP_TEST_BROKEN_ACL = \ array_member \ +# seems like a problem with the .i file. not enough includes. \ char_strings \ +# not sure what this one is supposed to do. needs investigation. \ class_ignore \ - constant_pointers \ contract \ +# 'throws' typemap entries. \ cplusplus_throw \ +# not sure. \ cpp_basic \ +# redefinition of enum_members. Looks like a namespace problem. \ cpp_enum \ +# works as expected. Bar is not seen by swig. muffle warning. \ cpp_typedef \ - default_constructor \ +# 'throws' typemap entries. \ default_args \ + default_constructor \ dynamic_cast \ enum_thorough \ extend_variable \ @@ -91,7 +110,13 @@ CPP_TEST_BROKEN_LONGLONG = \ # These are currently unsupported. CPP_TEST_CASES_ACL_UNSUPPORTED = \ +# contract support \ aggregate \ +# directors and allprotected support \ + allprotected \ +# directors support \ + apply_signed_char \ +# contract support \ contract \ director_abstract \ director_basic \ @@ -130,7 +155,7 @@ SKIP_CPP_STD_CASES = Yes C_TEST_CASES = -CPP_TEST_CASES = +CPP_TEST_CASES = include $(srcdir)/../common.mk diff --git a/Examples/test-suite/char_strings.i b/Examples/test-suite/char_strings.i index b06eba773..12e4b5aa2 100644 --- a/Examples/test-suite/char_strings.i +++ b/Examples/test-suite/char_strings.i @@ -9,6 +9,12 @@ below. %warnfilter(SWIGWARN_TYPEMAP_VARIN_UNDEF) global_char_array1; // Unable to set variable of type char[] %warnfilter(SWIGWARN_TYPEMAP_CHARLEAK_MSG) global_const_char; // Setting a const char * variable may leak memory. +#ifdef SWIG_ALLEGRO_CL +%{ +#include +%} +#endif + %{ #define OTHERLAND_MSG "Little message from the safe world." #define CPLUSPLUS_MSG "A message from the deep dark world of C++, where anything is possible." diff --git a/Lib/allegrocl/allegrocl.swg b/Lib/allegrocl/allegrocl.swg index 13790f306..3db739141 100644 --- a/Lib/allegrocl/allegrocl.swg +++ b/Lib/allegrocl/allegrocl.swg @@ -55,7 +55,7 @@ int, signed int, unsigned int, long, signed long, unsigned long, float, double, long double, char *, void *, void, - enum SWIGTYPE, SWIGTYPE *, + enum SWIGTYPE, SWIGTYPE *, SWIGTYPE[], SWIGTYPE[ANY], SWIGTYPE & "$1_ltype"; %typemap(ctype) SWIGTYPE "$&1_type"; @@ -65,7 +65,7 @@ int, signed int, unsigned int, long, signed long, unsigned long, float, double, long double, char *, void *, void, - enum SWIGTYPE, SWIGTYPE *, + enum SWIGTYPE, SWIGTYPE *, SWIGTYPE[], SWIGTYPE[ANY], SWIGTYPE & "$1 = $input;"; %typemap(in) SWIGTYPE "$1 = *$input;"; diff --git a/Source/Modules/allegrocl.cxx b/Source/Modules/allegrocl.cxx index 615007c1b..1273a78af 100644 --- a/Source/Modules/allegrocl.cxx +++ b/Source/Modules/allegrocl.cxx @@ -170,6 +170,7 @@ static String *namespace_of(String *str) { void add_linked_type(Node *n) { #ifdef ALLEGROCL_CLASS_DEBUG Printf(stderr, "Adding linked node of type: %s(%s) %s(%x)\n\n", nodeType(n), Getattr(n, "storage"), Getattr(n, "name"), n); + Swig_print_node(n); #endif if (!first_linked_type) { first_linked_type = n; @@ -299,7 +300,8 @@ void add_forward_referenced_type(Node *n, int overwrite = 0) { } } -void add_defined_foreign_type(Node *n, int overwrite = 0, String *k = 0, String *name = 0, String *ns = current_namespace) { +void add_defined_foreign_type(Node *n, int overwrite = 0, String *k = 0, + String *name = 0, String *ns = current_namespace) { String *val; String *ns_list = listify_namespace(ns); @@ -323,22 +325,34 @@ void add_defined_foreign_type(Node *n, int overwrite = 0, String *k = 0, String /* For typedefs of the form: - typedef __xxx { ... } xxx; + typedef struct __xxx { ... } xxx; + behavior differs between C mode and C++ mode. + + C Mode: add_defined_foreign_type will be called once via classHandler - to define the type for 'struct __xxx', and once via typedefHandler - to associate xxx with 'struct __xxx'. + to define the type for 'struct __xxx' and add the mapping from + 'struct __xxx' -> 'xxx' - We create the following type to identifier mappings: + It will also be called once via typedefHandler to add the + mapping 'xxx' -> 'xxx' - struct __xxx -> (swig-insert-id "xxx") via classHand - xxx -> (swig-insert-id "xxx") via typedefHand + C++ Mode: + add_defined_foreign_type will be called once via classHandler + to define the type for 'xxx'. it also adds the mapping from + 'xxx' -> 'xxx' and also for 'struct xxx' -> 'xxx' - and all references to this typedef'd struct will appear in - generated code as 'xxx'. For non-typedef'd structs, the - classHand mapping will be + In typedefHandler, we again try to add the mapping from + 'xxx' -> 'xxx', which already exists. This second mapping + is ignored. - struct __xxx -> (swig-insert-id "__xxx") + Both modes: + + All references to this typedef'd struct will appear in + generated lisp code as an objectd of type 'xxx'. For + non-typedef'd structs, the classHand mapping will be + + struct __xxx -> (swig-insert-id "__xxx") */ // Swig_print_node(n); String *unnamed = Getattr(n, "unnamed"); @@ -587,7 +601,11 @@ void add_defined_foreign_type(Node *n, int overwrite = 0, String *k = 0, String Delete(mangled_name_gen); Delete(mangled_lname_gen); } else { - Swig_warning(WARN_TYPE_REDEFINED, Getfile(n), Getline(n), "Attempting to store a foreign type that exists: %s (%s)\n", k, val); + if (!CPlusPlus || Strcmp(Getattr(n,"kind"),"typedef")) { + Swig_warning(WARN_TYPE_REDEFINED, Getfile(n), Getline(n), + "Attempting to store a foreign type that exists: %s (%s)\n", + k, val); + } } Delete(ns_list); @@ -622,7 +640,8 @@ String *get_ffi_type(SwigType *ty, const String_or_char *name) { #ifdef ALLEGROCL_TYPE_DEBUG Printf(stderr, "found_type '%s'\n", found_type); #endif - return (Strcmp(found_type, "forward-reference") ? Copy(found_type) : NewString(":void")); + return (Strcmp(found_type, "forward-reference") ? Copy(found_type) : + get_ffi_type(fwdref_ffi_type, "")); } else { Hash *typemap = Swig_typemap_search("ffitype", ty, name, 0); @@ -709,25 +728,39 @@ String *internal_compose_foreign_type(SwigType *ty) { if (res) Printf(ffiType, "%s", res); } -// while(resolved_type) { -// // the resolved_type may expand into something like p.NS1::NS2::SomeType -// // for which get_ffi_type will not find any match (due to the p.). -// // Printf(stderr, "\n in resolved type loop on '%s'\n", resolved_type); -// res = get_ffi_type(resolved_type, ""); -// if (res) { -// Printf(ffiType, "%s", res); -// break; -// } else { -// resolved_type = SwigType_typedef_resolve(resolved_type); -// } -// } + if (!res) { - if (Strstr(tok, "struct ")) { - Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(tok), Getline(tok), "Unable to find definition of '%s', assuming forward reference.\n", tok); - } else { - Printf(stderr, "Unable to compose foreign type of: '%s'\n", tok); + String *is_struct = 0; + String *tok_remove_text = 0; + String *tok_name = Copy(tok); + String *tok_key = SwigType_str(tok,0); + if ((is_struct = Strstr(tok_key, "struct ")) || Strstr(tok_key, "union ")) { + tok_remove_text = NewString(is_struct ? "struct " : "union "); } - Printf(ffiType, "%s", get_ffi_type(fwdref_ffi_type, "")); + + /* be more permissive of opaque types. This is the swig way. + compiles will notice if these types are ultimately not + present. */ + + if(tok_remove_text) { + Replaceall(tok_name,tok_remove_text,""); + } + tok_name = strip_namespaces(tok_name); + Delete(tok_remove_text); + // Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(tok), Getline(tok), "Unable to find definition of '%s', assuming forward reference.\n", tok); + +#ifdef ALLEGROCL_TYPE_DEBUG + Printf(stderr, "i-c-f-t: adding forward reference for unknown type '%s'. mapping: %s -> %s\n", tok, tok_key, tok_name); +#endif + Node *nn = NewHash(); + Setattr(nn,"nodeType","classforward"); + Setattr(nn,"kind","class"); + Setattr(nn,"sym:name",tok_name); + Setattr(nn,"name",tok_key); + Setattr(nn,"allegrocl:package","current_namespace"); + + add_forward_referenced_type(nn, 0); + Printf(ffiType, "%s", get_ffi_type(tok, ""), tok_name); } } } @@ -841,6 +874,10 @@ String *strip_parens(String *string) { } int ALLEGROCL::validIdentifier(String *s) { +#ifdef ALLEGROCL_DEBUG + Printf(stderr, "validIdentifier %s\n", s); +#endif + char *c = Char(s); bool got_dot = false; @@ -967,6 +1004,7 @@ String *convert_literal(String *literal, String *type, bool try_to_split) { Delete(num); num = 0; } + Delete(lisp_exp); } else { String *id = NewStringf("#.(swig-insert-id \"%s\" %s :type :constant)", num, ns); @@ -2354,41 +2392,24 @@ int ALLEGROCL::emit_defun(Node *n, File *fcl) { for (p = pl; p; p = nextSibling(p), argnum++, largnum++) { // SwigType *argtype=Getattr(p, "type"); SwigType *argtype = Swig_cparse_type(Getattr(p, "tmap:ctype")); + SwigType *parmtype = Getattr(p,"type"); if (!first) { Printf(fcl, "\n "); } - if (SwigType_isvarargs(argtype)) { - Printf(stderr, "Function %s (line %d) contains varargs, which is not directly supported. Use %%varargs instead.\n", Getattr(n, "name"), Getline(n)); - } else { + /* by default, skip varargs */ + if (!SwigType_isvarargs(parmtype)) { String *argname = NewStringf("PARM%d_%s", largnum, Getattr(p, "name")); - // Swig_print_node(p); // Printf(stderr,"%s\n", Getattr(p,"tmap:lin")); String *ffitype = compose_foreign_type(argtype, Getattr(p,"name")); - String *deref_ffitype; - - deref_ffitype = dereference_ffitype(ffitype); - -/* - String *temp = Copy(argtype); - - if (SwigType_ispointer(temp)) { - SwigType_pop(temp); - deref_ffitype = compose_foreign_type(temp); - } else { - deref_ffitype = Copy(ffitype); - } - - Delete(temp); -*/ - // String *lisptype=get_lisp_type(argtype, argname); - String *lisptype = get_lisp_type(Getattr(p, "type"), Getattr(p, "name")); + String *deref_ffitype = dereference_ffitype(ffitype); + String *lisptype = get_lisp_type(parmtype, Getattr(p, "name")); #ifdef ALLEGROCL_DEBUG - Printf(stderr, "lisptype of '%s' '%s' = '%s'\n", - Getattr(p, "type"), Getattr(p, "name"), lisptype); + Printf(stderr, "lisptype of '%s' '%s' = '%s'\n", parmtype, + Getattr(p, "name"), lisptype); #endif // while we're walking the parameters, generating LIN @@ -2419,7 +2440,9 @@ int ALLEGROCL::emit_defun(Node *n, File *fcl) { first = 0; } + Delete(argname); Delete(ffitype); + Delete(deref_ffitype); Delete(lisptype); } } @@ -2457,11 +2480,6 @@ int ALLEGROCL::emit_defun(Node *n, File *fcl) { lclass = lookup_defined_foreign_ltype(cl_t); isPtrReturn = 1; } - // if (SwigType_ispointer(cl_t)) { - // isPtrReturn = 1; - // SwigType_pop(cl_t); - // lclass = lookup_defined_foreign_ltype(cl_t); - // } int ff_foreign_ptr = 0; if (!lclass) { @@ -2534,6 +2552,10 @@ int ALLEGROCL::emit_defun(Node *n, File *fcl) { } int ALLEGROCL::functionWrapper(Node *n) { +#ifdef ALLEGROCL_DEBUG + Printf(stderr, "functionWrapper %s\n", Getattr(n,"name")); +#endif + ParmList *parms = CopyParmList(Getattr(n, "parms")); Wrapper *f = NewWrapper(); @@ -2694,13 +2716,15 @@ int ALLEGROCL::functionWrapper(Node *n) { } int ALLEGROCL::namespaceDeclaration(Node *n) { - // Empty namespaces are not worth DEFPACKAGEing. - // Swig_print_node(n); #ifdef ALLEGROCL_DEBUG Printf(stderr, "namespaceDecl: '%s'(0x%x) (fc=0x%x)\n", Getattr(n, "sym:name"), n, firstChild(n)); #endif - if (!firstChild(n)) + /* don't wrap a namespace with no contents. package bloat. + also, test-suite/namespace_class.i claims an unnamed namespace + is 'private' and should not be wrapped. Complying... + */ + if (Getattr(n,"unnamed") || !firstChild(n)) return SWIG_OK; String *name = Getattr(n, "sym:name"); @@ -2727,7 +2751,7 @@ int ALLEGROCL::namespaceDeclaration(Node *n) { int ALLEGROCL::constructorHandler(Node *n) { #ifdef ALLEGROCL_DEBUG - Printf(stderr, "constructor %s\n", Getattr(n, "name")); + Printf(stderr, "constructorHandler %s\n", Getattr(n, "name")); #endif // Swig_print_node(n); Setattr(n, "allegrocl:kind", "constructor"); @@ -2739,7 +2763,7 @@ int ALLEGROCL::constructorHandler(Node *n) { int ALLEGROCL::destructorHandler(Node *n) { #ifdef ALLEGROCL_DEBUG - Printf(stderr, "destructor %s\n", Getattr(n, "name")); + Printf(stderr, "destructorHandler %s\n", Getattr(n, "name")); #endif Setattr(n, "allegrocl:kind", "destructor"); @@ -2750,9 +2774,8 @@ int ALLEGROCL::destructorHandler(Node *n) { } int ALLEGROCL::constantWrapper(Node *n) { - #ifdef ALLEGROCL_DEBUG - Printf(stderr, "constant %s\n", Getattr(n, "name")); + Printf(stderr, "constantWrapper %s\n", Getattr(n, "name")); #endif if (Generate_Wrapper) { @@ -2808,6 +2831,10 @@ int ALLEGROCL::constantWrapper(Node *n) { } int ALLEGROCL::globalvariableHandler(Node *n) { +#ifdef ALLEGROCL_DEBUG + Printf(stderr, "globalvariableHandler %s\n", Getattr(n, "name")); +#endif + if (Generate_Wrapper) return Language::globalvariableHandler(n); @@ -2838,7 +2865,7 @@ int ALLEGROCL::globalvariableHandler(Node *n) { int ALLEGROCL::variableWrapper(Node *n) { #ifdef ALLEGROCL_DEBUG - Printf(stderr, "variable %s\n", Getattr(n, "name")); + Printf(stderr, "variableWrapper %s\n", Getattr(n, "name")); #endif Setattr(n, "allegrocl:kind", "variable"); Setattr(n, "allegrocl:old-sym:name", Getattr(n, "sym:name")); @@ -2863,6 +2890,7 @@ int ALLEGROCL::variableWrapper(Node *n) { } ctype = SwigType_str(type, 0); + // EXPORT ; // = ; Printf(f_cxx, "EXPORT %s %s;\n%s %s = %s%s;\n", ctype, mangled_name, ctype, mangled_name, (pointer_added ? "&" : ""), name); @@ -2873,14 +2901,19 @@ int ALLEGROCL::variableWrapper(Node *n) { Printf(f_cxx, "// vwrap: %s\n", compose_foreign_type(SwigType_strip_qualifiers(Copy(rtype)))); */ + Printf(stderr,"***\n"); Delete(mangled_name); +#ifdef ALLEGROCL_DEBUG + Printf(stderr, "DONE variable %s\n", Getattr(n, "name")); +#endif + return SWIG_OK; } int ALLEGROCL::memberfunctionHandler(Node *n) { #ifdef ALLEGROCL_DEBUG - Printf(stderr, "member function %s::%s\n", Getattr(parent_node_skipping_extends(n), "name"), Getattr(n, "name")); + Printf(stderr, "memberfunctionHandler %s::%s\n", Getattr(parent_node_skipping_extends(n), "name"), Getattr(n, "name")); #endif Setattr(n, "allegrocl:kind", "member function"); Setattr(n, "allegrocl:old-sym:name", Getattr(n, "sym:name")); @@ -2891,7 +2924,7 @@ int ALLEGROCL::memberfunctionHandler(Node *n) { int ALLEGROCL::membervariableHandler(Node *n) { #ifdef ALLEGROCL_DEBUG - Printf(stderr, "member variable %s::%s\n", Getattr(parent_node_skipping_extends(n), "name"), Getattr(n, "name")); + Printf(stderr, "membervariableHandler %s::%s\n", Getattr(parent_node_skipping_extends(n), "name"), Getattr(n, "name")); #endif Setattr(n, "allegrocl:kind", "member variable"); Setattr(n, "allegrocl:old-sym:name", Getattr(n, "sym:name")); @@ -2901,9 +2934,8 @@ int ALLEGROCL::membervariableHandler(Node *n) { } int ALLEGROCL::typedefHandler(Node *n) { - #ifdef ALLEGROCL_TYPE_DEBUG - Printf(stderr, "In typedefHAND\n"); + Printf(stderr, "In typedefHandler\n"); // Swig_print_node(n); #endif @@ -2945,7 +2977,7 @@ int ALLEGROCL::typedefHandler(Node *n) { else add_forward_referenced_type(n); #ifdef ALLEGROCL_TYPE_DEBUG - Printf(stderr, "Out typedefHAND\n"); + Printf(stderr, "Out typedefHandler\n"); #endif Delete(ff_type); @@ -2955,13 +2987,17 @@ int ALLEGROCL::typedefHandler(Node *n) { // forward referenced classes are added specially to defined_foreign_types int ALLEGROCL::classforwardDeclaration(Node *n) { +#ifdef ALLEGROCL_DEBUG + Printf(stderr, "classforwardDeclaration %s\n", Getattr(n, "name")); +#endif + add_forward_referenced_type(n); return SWIG_OK; } int ALLEGROCL::classHandler(Node *n) { #ifdef ALLEGROCL_DEBUG - Printf(stderr, "class %s::%s\n", current_namespace, Getattr(n, "sym:name")); + Printf(stderr, "classHandler %s::%s\n", current_namespace, Getattr(n, "sym:name")); #endif if (Generate_Wrapper) @@ -2971,6 +3007,9 @@ int ALLEGROCL::classHandler(Node *n) { } int ALLEGROCL::cClassHandler(Node *n) { +#ifdef ALLEGROCL_TYPE_DEBUG + Printf(stderr, "In cClassHandler\n"); +#endif // String *cDeclName = Getattr(n,"classDeclaration:name"); // String *name= Getattr(n, "sym:name"); // String *kind = Getattr(n,"kind"); @@ -2980,22 +3019,21 @@ int ALLEGROCL::cClassHandler(Node *n) { // Printf(stderr, "Adding %s foreign type\n", name); String *ns = listify_namespace(current_namespace); -#ifdef ALLEGROCL_TYPE_DEBUG - Printf(stderr, "In cClassHAND\n"); -#endif - add_defined_foreign_type(n); Delete(ns); #ifdef ALLEGROCL_TYPE_DEBUG - Printf(stderr, "Out cClassHAND\n"); + Printf(stderr, "Out cClassHandler\n"); #endif return SWIG_OK; } int ALLEGROCL::cppClassHandler(Node *n) { +#ifdef ALLEGROCL_DEBUG + Printf(stderr, "cppClassHandler %s\n", Getattr(n, "name")); +#endif // String *name=Getattr(n, "sym:name"); // String *kind = Getattr(n,"kind"); @@ -3054,6 +3092,10 @@ int ALLEGROCL::cppClassHandler(Node *n) { // so their types can be added to the linked_type_list. SwigType *childType = NewStringf("%s%s", Getattr(c, "decl"), Getattr(c, "type")); +#ifdef ALLEGROCL_CLASS_DEBUG + Printf(stderr, "looking at child '%x' of type '%s'\n", c, childType); + Swig_print_node(c); +#endif if (!SwigType_isfunction(childType)) Delete(compose_foreign_type(childType)); @@ -3094,6 +3136,9 @@ int ALLEGROCL::emit_one(Node *n) { } int ALLEGROCL::enumDeclaration(Node *n) { +#ifdef ALLEGROCL_DEBUG + Printf(stderr, "enumDeclaration %s\n", Getattr(n, "name")); +#endif if (Getattr(n, "sym:name")) { add_defined_foreign_type(n); @@ -3110,21 +3155,24 @@ int ALLEGROCL::enumDeclaration(Node *n) { int ALLEGROCL::enumvalueDeclaration(Node *n) { - +#ifdef ALLEGROCL_DEBUG + Printf(stderr, "enumvalueDeclaration %s\n", Getattr(n, "name")); +#endif /* print this when in C mode? make this a command-line arg? */ - if (Generate_Wrapper) { String *mangled_name = mangle_name(n, "ACL_ENUM"); - - Printf(f_cxx, "EXPORT const %s %s = %s;\n", Getattr(n, "type"), mangled_name, Getattr(n, "value")); + Printf(f_cxx, "EXPORT const %s %s = %s;\n", Getattr(n, "type"), + mangled_name, Getattr(n, "value")); Delete(mangled_name); } - return SWIG_OK; } int ALLEGROCL::templateDeclaration(Node *n) { +#ifdef ALLEGROCL_DEBUG + Printf(stderr, "templateDeclaration %s\n", Getattr(n, "name")); +#endif String *type = Getattr(n, "templatetype"); From 7d6ee425664fd23dbac52a70d6b9dacf0be5125a Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Tue, 23 Sep 2008 06:52:41 +0000 Subject: [PATCH 0132/1680] Remove stray lines git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10879 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 2 -- 1 file changed, 2 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index ee004fb27..3ab3d41c8 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,5 +1,3 @@ -2008-09-22 Mikel Bancroft - Version 1.3.37 (in progress) ============================= From 1d9f63c8739e7a9592160548fbff1e6032b158e7 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 24 Sep 2008 19:28:15 +0000 Subject: [PATCH 0133/1680] fix clash between php and python when running scripts git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10880 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/Makefile.in | 12 ++++++------ Examples/test-suite/php4/Makefile.in | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Examples/Makefile.in b/Examples/Makefile.in index 9ac981f6c..7f27ce976 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -294,15 +294,15 @@ python_static_cpp: $(SRCS) # ----------------------------------------------------------------- ifeq (,$(PY3)) - SCRIPT = runme.py + PYSCRIPT = runme.py else - SCRIPT = runme3.py + PYSCRIPT = runme3.py endif PY2TO3 = 2to3 `2to3 -l | grep -v -E "Available|import$$" | awk '{print "-f "$$0}'` -python_run: $(SCRIPT) - env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PYTHONPATH=$(srcdir):$$PYTHONPATH $(PYTHON) $(SCRIPT) >/dev/null +python_run: $(PYSCRIPT) + env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PYTHONPATH=$(srcdir):$$PYTHONPATH $(PYTHON) $(PYSCRIPT) >/dev/null runme3.py: runme.py cp $< $@ @@ -769,10 +769,10 @@ php4_cpp: $(SRCS) # ----------------------------------------------------------------- PHP4=@PHP4@ -SCRIPT ?= runme.php4 +PHP4SCRIPT ?= runme.php4 php4_run: - env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(PHP4) -n -q -d extension_dir=. $(SCRIPT) + env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(PHP4) -n -q -d extension_dir=. $(PHP4SCRIPT) # ----------------------------------------------------------------- # Cleaning the PHP4 examples diff --git a/Examples/test-suite/php4/Makefile.in b/Examples/test-suite/php4/Makefile.in index 2e14ef9a2..8adb294ec 100644 --- a/Examples/test-suite/php4/Makefile.in +++ b/Examples/test-suite/php4/Makefile.in @@ -58,7 +58,7 @@ missingtests: missingcpptests missingctests # a file is found which has _runme.php4 appended after the testcase name. run_testcase = \ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then ( \ - $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SCRIPT=$(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) RUNTOOL=$(RUNTOOL) php4_run;) \ + $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile PHP4SCRIPT=$(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) RUNTOOL=$(RUNTOOL) php4_run;) \ fi; # Clean: remove the generated .php file From 7ef2b73a6d794d47b1569c42bafad1336c2db987 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Thu, 25 Sep 2008 07:11:36 +0000 Subject: [PATCH 0134/1680] [PHP5] Fill in typemaps for SWIGTYPE and void * (SF#2095186). git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10881 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 5 ++++- Lib/php/php.swg | 14 ++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 3ab3d41c8..50444a326 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,5 +1,8 @@ Version 1.3.37 (in progress) -============================= +============================ + +2008-09-25: olly + [PHP5] Fill in typemaps for SWIGTYPE and void * (SF#2095186). 2008-09-22: mutandiz (Mikel Bancroft) [allegrocl] diff --git a/Lib/php/php.swg b/Lib/php/php.swg index d30e0b2a9..916a5159e 100644 --- a/Lib/php/php.swg +++ b/Lib/php/php.swg @@ -110,6 +110,7 @@ SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $&1_descriptor"); } } + %typemap(argout) SWIGTYPE *, SWIGTYPE [], SWIGTYPE&; @@ -264,19 +265,24 @@ %php_typecheck(double,SWIG_TYPECHECK_BOOL,IS_DOUBLE) %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE - " /* typecheck SWIGTYPE */ " +{ + void *tmp; + _v = (SWIG_ConvertPtr(*$input, (void **)&tmp, $&1_descriptor, 0) >= 0); +} %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE [], SWIGTYPE & { void *tmp; - _v = (SWIG_ConvertPtr( *$input, (void**)&tmp, $1_descriptor, 0) >= 0); + _v = (SWIG_ConvertPtr(*$input, (void**)&tmp, $1_descriptor, 0) >= 0); } %typecheck(SWIG_TYPECHECK_VOIDPTR) void * - " /* typecheck void * */ " - +{ + void *tmp; + _v = (SWIG_ConvertPtr(*$input, (void**)&tmp, 0, 0) >= 0); +} /* Exception handling */ From 25f6cebe464cded156f15487d90faec91805adcd Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 26 Sep 2008 05:05:23 +0000 Subject: [PATCH 0135/1680] typo fix git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10883 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/csharp/arrays_csharp.i | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Lib/csharp/arrays_csharp.i b/Lib/csharp/arrays_csharp.i index ca663f66a..ea22da584 100644 --- a/Lib/csharp/arrays_csharp.i +++ b/Lib/csharp/arrays_csharp.i @@ -7,7 +7,7 @@ * This file contains a two approaches to marshaling arrays. The first uses * default p/invoke marshaling and the second uses pinning of the arrays. * - * Default marshalling approach + * Default marshaling approach * ---------------------------- * Array typemaps using default p/invoke marshaling. The data is copied to a separately * allocated buffer when passing over the managed-native boundary. @@ -32,13 +32,13 @@ * ---------------- * Array typemaps using pinning. These typemaps pin the managed array given * as parameter and pass a pointer to it to the c/c++ side. This is very - * efficient as no copying is done (unlike in the default array marshalling), + * efficient as no copying is done (unlike in the default array marshaling), * but it makes garbage collection more difficult. When considering using * these typemaps, think carefully whether you have callbacks that may cause * the control to re-enter the managed side from within the call (and produce * garbage for the gc) or whether other threads may produce enough garbage to * trigger gc while the call is being executed. In those cases it may be - * wiser to use. + * wiser to use the default marshaling typemaps. * * Please note that when using fixed arrays, you have to mark your corresponding * module class method unsafe using From 32b01d9559c77c395b40b15d7a71e42e9e0002fd Mon Sep 17 00:00:00 2001 From: Haoyu Bai Date: Sun, 28 Sep 2008 09:36:06 +0000 Subject: [PATCH 0136/1680] merge test case pybuf and benchmark pybuf_benchmark into a single test case git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10884 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/python/pybuf.i | 32 ++++++++++++- Examples/test-suite/python/pybuf_benchmark.i | 31 ------------ .../python/pybuf_benchmark_runme.py | 16 ------- Examples/test-suite/python/pybuf_runme3.py | 47 +++++++++++++++---- 4 files changed, 68 insertions(+), 58 deletions(-) delete mode 100644 Examples/test-suite/python/pybuf_benchmark.i delete mode 100644 Examples/test-suite/python/pybuf_benchmark_runme.py diff --git a/Examples/test-suite/python/pybuf.i b/Examples/test-suite/python/pybuf.i index 207b5b7e9..88dd1aa6a 100644 --- a/Examples/test-suite/python/pybuf.i +++ b/Examples/test-suite/python/pybuf.i @@ -1,6 +1,7 @@ %module pybuf %include - +%include +/*functions for the test case*/ %pybuffer_mutable_binary(char *buf1, int len); %pybuffer_mutable_string(char *buf2); %pybuffer_binary(const char *buf3, int len); @@ -32,3 +33,32 @@ return strlen(buf4); } %} + +/*functions for the benchmark*/ +%pybuffer_mutable_string(char *str1); +%cstring_mutable(char *str2); + +%inline %{ +void title(char *str) { + int outword = 1; + while(*str) { + if (isalnum(*str)) { + if (outword) { + outword = 0; + *str = toupper(*str); + } + } + else { + outword = 0; + } + str++; + } +} + +void title1(char *str1) { + title(str1); +} +void title2(char *str2) { + title(str2); +} +%} diff --git a/Examples/test-suite/python/pybuf_benchmark.i b/Examples/test-suite/python/pybuf_benchmark.i deleted file mode 100644 index 8a793f906..000000000 --- a/Examples/test-suite/python/pybuf_benchmark.i +++ /dev/null @@ -1,31 +0,0 @@ -%module pybuf_benchmark - -%include -%include -%pybuffer_mutable_string(char *str1); -%cstring_mutable(char *str2); - -%inline %{ -void title(char *str) { - int outword = 0; - while(*str) { - if (isalnum(*str)) { - if (outword) { - outword = 1; - *str = toupper(*str); - } - } - else { - outword = 0; - } - str++; - } -} - -void title1(char *str1) { - title(str1); -} -void title2(char *str2) { - title(str2); -} -%} diff --git a/Examples/test-suite/python/pybuf_benchmark_runme.py b/Examples/test-suite/python/pybuf_benchmark_runme.py deleted file mode 100644 index 6676a910b..000000000 --- a/Examples/test-suite/python/pybuf_benchmark_runme.py +++ /dev/null @@ -1,16 +0,0 @@ -import pybuf -import time -k=1000000 -n=7 - -t=time.time() -a = bytearray(b'hello world') -for i in range(k): - pybuf.title1(a) -print "Time used by bytearray:",time.time()-t - -t=time.time() -b = 'hello world' -for i in range(k): - pybuf.title2(b) -print "Time used by string:",time.time()-t diff --git a/Examples/test-suite/python/pybuf_runme3.py b/Examples/test-suite/python/pybuf_runme3.py index 462736bf0..9294c6b72 100644 --- a/Examples/test-suite/python/pybuf_runme3.py +++ b/Examples/test-suite/python/pybuf_runme3.py @@ -1,15 +1,42 @@ +#run: +# python pybuf_runme3.py benchmark +#for the benchmark, other wise the test case will be run import pybuf -buf1 = bytearray(10) -buf2 = bytearray(50) +import sys +if len(sys.argv)>=2 and sys.argv[1]=="benchmark": + #run the benchmark + import time + k=1000000 #number of times to excute the functions -pybuf.func1(buf1) -assert buf1 == b'a'*10 + t=time.time() + a = bytearray(b'hello world') + for i in range(k): + pybuf.title1(a) + print("Time used by bytearray:",time.time()-t) -pybuf.func2(buf2) -assert buf2.startswith(b"Hello world!\x00") + t=time.time() + b = 'hello world' + for i in range(k): + pybuf.title2(b) + print("Time used by string:",time.time()-t) +else: + #run the test case + buf1 = bytearray(10) + buf2 = bytearray(50) -count = pybuf.func3(buf2) -assert count==10 #number of alpha and number in 'Hello world!' + pybuf.func1(buf1) + assert buf1 == b'a'*10 -length = pybuf.func4(buf2) -assert length==12 + pybuf.func2(buf2) + assert buf2.startswith(b"Hello world!\x00") + + count = pybuf.func3(buf2) + assert count==10 #number of alpha and number in 'Hello world!' + + length = pybuf.func4(buf2) + assert length==12 + + buf3 = bytearray(b"hello") + pybuf.title1(buf3) + assert buf3==b'Hello' + From 76828330488a61d11b9f6eacbfb88d314f7e8279 Mon Sep 17 00:00:00 2001 From: Mikel Bancroft Date: Tue, 30 Sep 2008 19:45:13 +0000 Subject: [PATCH 0137/1680] [allegrocl] Various fixes to the generated C wrapper code (enums, constants, function declarations), as I progress through the test-suite. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10885 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 12 +++ Examples/test-suite/allegrocl/Makefile.in | 116 +++++----------------- Examples/test-suite/operator_overload.i | 6 ++ Lib/allegrocl/allegrocl.swg | 85 ++++++++++++---- Source/Modules/allegrocl.cxx | 68 ++++++++----- TODO | 8 ++ 6 files changed, 159 insertions(+), 136 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 50444a326..0a654156a 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,18 @@ +2008-09-26 Mikel Bancroft + Version 1.3.37 (in progress) ============================ +2008-09-26: mutandiz + [allegrocl] + Lots of test-suite work. + - Fix ordering of wrapper output and %{ %} header output. + - Fix declarations of local vars in C wrappers. + - Fix declaration of defined constants in C wrappers. + - Fix declaration of EnumValues in C wrappers. + - add some const typemaps to allegrocl.swg + - add rename for operator bool() overloads. + 2008-09-25: olly [PHP5] Fill in typemaps for SWIGTYPE and void * (SF#2095186). diff --git a/Examples/test-suite/allegrocl/Makefile.in b/Examples/test-suite/allegrocl/Makefile.in index b3ace9130..c4f087f8d 100644 --- a/Examples/test-suite/allegrocl/Makefile.in +++ b/Examples/test-suite/allegrocl/Makefile.in @@ -12,98 +12,46 @@ top_builddir = @top_builddir@ # these cpp tests generate warnings/errors when compiling # the wrapper .cxx file. -CPP_TEST_BROKEN_CXX = \ -# might be a problem in our cxx wrapping. not sure. \ - class_scope_weird \ -# works as expected. must muffle warnings if you want none. \ -# 'struct A' is not seen by SWIG, so it's type cannot be \ -# derived \ -# Look into cxx problems, though. - constant_pointers - +CPP_TEST_BROKEN_CXX = +# the error is wrap:action code generated by swig. \ +# error: can't convert [std::string] 'b' to 'bool' \ +# might just need a bool overload op for std::string. \ + global_vars \ +# same as w/ global_vars but with more errors in cxx file \ + naturalvar \ # these cpp tests aren't working. Fix 'em # need to further separate these into tests requiring # std libraries, or the $ldestructor problem. CPP_TEST_BROKEN_ACL = \ - array_member \ -# seems like a problem with the .i file. not enough includes. \ - char_strings \ -# not sure what this one is supposed to do. needs investigation. \ - class_ignore \ contract \ + allprotected \ # 'throws' typemap entries. \ cplusplus_throw \ -# not sure. \ - cpp_basic \ -# redefinition of enum_members. Looks like a namespace problem. \ - cpp_enum \ -# works as expected. Bar is not seen by swig. muffle warning. \ - cpp_typedef \ # 'throws' typemap entries. \ default_args \ - default_constructor \ +# missing typemaps. suspect module support needed \ dynamic_cast \ - enum_thorough \ extend_variable \ - global_vars \ - import_nomodule \ - kind \ - li_carrays \ +# cdata.i support needed \ li_cdata \ - li_windows \ - namespace_class \ - namespace_spaces \ - naturalvar \ +# warning generated. otherwise all good. \ operator_overload \ - overload_simple \ - register_par \ +# std_common.i support \ sizet \ - smart_pointer_extend \ - smart_pointer_namespace \ - template \ - template_classes \ +# std_vector.i support. \ template_default \ - template_default_inherit \ - template_enum \ - template_explicit \ - template_extend_overload \ - template_ns \ - template_ns4 \ - template_ns_enum \ - template_rename \ - template_retvalue \ - template_static \ - template_tbase_template \ - template_typedef \ - template_typedef_cplx \ - template_typedef_cplx2 \ - template_typedef_cplx3 \ - template_typedef_cplx4 \ - template_typedef_cplx5 \ - template_typedef_ns \ - template_typedef_rec \ - threads \ - typedef_array_member \ - typedef_sizet \ +# *** line 31. can't copy typemap?? \ typemap_namespace \ - union_scope \ - using_pointers \ - valuewrapper_opaque \ - varargs \ - virtual_poly \ - voidtest \ - wrapmacro # these aren't working due to longlong support. (low hanging fruit) CPP_TEST_BROKEN_LONGLONG = \ arrays_dimensionless \ arrays_global \ arrays_global_twodim \ - li_stdint \ li_typemaps \ + li_windows \ long_long_apply \ - mixed_types \ primitive_ref \ reference_global_vars \ template_default_arg @@ -112,38 +60,24 @@ CPP_TEST_BROKEN_LONGLONG = \ CPP_TEST_CASES_ACL_UNSUPPORTED = \ # contract support \ aggregate \ -# directors and allprotected support \ - allprotected \ # directors support \ apply_signed_char \ # contract support \ contract \ - director_abstract \ - director_basic \ - director_constructor \ - director_detect \ - director_default \ - director_enum \ director_exception \ - director_frob \ - director_finalizer \ - director_nested \ director_protected \ - director_redefined \ - director_unroll \ - director_using \ - director_wombat \ exception_order \ +# 'throws' typemap support \ extern_throws \ - throw_exception + throw_exception \ + using_pointers \ C_TEST_CASES_ACL_BROKEN = \ - arrays \ - enums \ - extern_declaration \ - immutable \ - integers \ +# 'cdate.i' module support \ li_cdata \ +# adding an existing type defnition... \ + typedef_struct \ +# swigrun.swg support. \ typemap_subst C_TEST_BROKEN_LONGLONG = \ @@ -153,12 +87,10 @@ C_TEST_BROKEN_LONGLONG = \ # std lib support hasn't been done yet. SKIP_CPP_STD_CASES = Yes -C_TEST_CASES = - -CPP_TEST_CASES = - include $(srcdir)/../common.mk +# SWIGOPT += -debug-module 4 + # Rules for the different types of tests %.cpptest: $(setup) diff --git a/Examples/test-suite/operator_overload.i b/Examples/test-suite/operator_overload.i index b2748f9b4..b62bf5179 100644 --- a/Examples/test-suite/operator_overload.i +++ b/Examples/test-suite/operator_overload.i @@ -71,6 +71,12 @@ see bottom for a set of possible tests %rename(OrOperator) operator ||; #endif +#ifdef SWIG_ALLEGRO_CL +%{ +#include +%} +#endif + %rename(IntCast) operator int(); %rename(DoubleCast) operator double(); diff --git a/Lib/allegrocl/allegrocl.swg b/Lib/allegrocl/allegrocl.swg index 3db739141..4479f6ac2 100644 --- a/Lib/allegrocl/allegrocl.swg +++ b/Lib/allegrocl/allegrocl.swg @@ -26,37 +26,76 @@ %typemap(lout) SWIGTYPE "(cl::let* ((address $body)\n (new-inst (cl::make-instance '$lclass :foreign-address address)))\n (cl::unless (cl::zerop address)\n (excl:schedule-finalization new-inst #'$ldestructor))\n (cl::setq ACL_ffresult new-inst))"; -%typemap(lisptype) bool "cl:boolean"; -%typemap(lisptype) char "cl:character"; -%typemap(lisptype) unsigned char "cl:integer"; -%typemap(lisptype) signed char "cl:integer"; +%typemap(lisptype) bool, const bool "cl:boolean"; +%typemap(lisptype) char, const char "cl:character"; +%typemap(lisptype) unsigned char, const unsigned char "cl:integer"; +%typemap(lisptype) signed char, const signed char "cl:integer"; -%typemap(ffitype) bool ":int"; -%typemap(ffitype) char ":char"; -%typemap(ffitype) unsigned char ":unsigned-char"; -%typemap(ffitype) signed char ":char"; -%typemap(ffitype) short, signed short ":short"; -%typemap(ffitype) unsigned short ":unsigned-short"; -%typemap(ffitype) int, signed int ":int"; -%typemap(ffitype) unsigned int ":unsigned-int"; -%typemap(ffitype) long, signed long ":long"; -%typemap(ffitype) unsigned long ":unsigned-long"; -%typemap(ffitype) float ":float"; -%typemap(ffitype) double ":double"; -%typemap(ffitype) char * "(* :char)"; +%typemap(ffitype) bool, const bool ":int"; +%typemap(ffitype) char, const char, + signed char, const signed char ":char"; +%typemap(ffitype) unsigned char, const unsigned char ":unsigned-char"; +%typemap(ffitype) short, const short, + signed short, const signed short ":short"; +%typemap(ffitype) unsigned short, const unsigned short ":unsigned-short"; +%typemap(ffitype) int, const int, signed int, const signed int ":int"; +%typemap(ffitype) unsigned int, const unsigned int ":unsigned-int"; +%typemap(ffitype) long, const long, signed long, const signed long ":long"; +%typemap(ffitype) unsigned long, const unsigned long ":unsigned-long"; +%typemap(ffitype) float, const float ":float"; +%typemap(ffitype) double, const double ":double"; +%typemap(ffitype) char *, const char *, signed char *, + const signed char *, signed char &, + const signed char & "(* :char)"; +%typemap(ffitype) unsigned char *, const unsigned char *, + unsigned char &, const unsigned char & "(* :unsigned-char)"; +%typemap(ffitype) short *, const short *, short &, + const short & "(* :short)"; +%typemap(ffitype) unsigned short *, const unsigned short *, + unsigned short &, const unsigned short & "(* :unsigned-short)"; +%typemap(ffitype) int *, const int *, int &, const int & "(* :int)"; +%typemap(ffitype) unsigned int *, const unsigned int *, + unsigned int &, const unsigned int & "(* :unsigned-int)"; %typemap(ffitype) void * "(* :void)"; %typemap(ffitype) void ":void"; %typemap(ffitype) enum SWIGTYPE ":int"; %typemap(ffitype) SWIGTYPE & "(* :void)"; -%typemap(ctype) bool "int"; +/* const typemaps +idea: marshall all primitive c types to their respective lisp types +to maintain const corretness. For pointers/references, all bets +are off if you try to modify them. + +idea: add a constant-p slot to the base foreign-pointer class. For +constant pointer/references check this value when setting (around method?) +and error if a setf operation is performed on the address of this object. + +*/ + +/* +%exception %{ + try { + $action + } catch (...) { + return $null; + } +%} + +*/ + +// %typemap(throws) SWIGTYPE { +// (void)$1; +// SWIG_fail; +// } + +%typemap(ctype) bool, const bool "int"; %typemap(ctype) char, unsigned char, signed char, short, signed short, unsigned short, int, signed int, unsigned int, long, signed long, unsigned long, float, double, long double, char *, void *, void, enum SWIGTYPE, SWIGTYPE *, SWIGTYPE[], - SWIGTYPE[ANY], SWIGTYPE & "$1_ltype"; + SWIGTYPE[ANY], SWIGTYPE &, const SWIGTYPE "$1_ltype"; %typemap(ctype) SWIGTYPE "$&1_type"; %typemap(in) bool "$1 = (bool)$input;"; @@ -122,7 +161,8 @@ SWIG_TYPECHECK_STRING_ARRAY 1140 long, signed long, unsigned long, enum SWIGTYPE { $1 = 1; }; %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE &, - SWIGTYPE[ANY], SWIGTYPE { $1 = 1; }; + SWIGTYPE[], SWIGTYPE[ANY], + SWIGTYPE { $1 = 1; }; /* This maps C/C++ types to Lisp classes for overload dispatch */ @@ -147,7 +187,7 @@ SWIG_TYPECHECK_STRING_ARRAY 1140 enum SWIGTYPE, SWIGTYPE *, SWIGTYPE[ANY], SWIGTYPE & "$result = $1;"; #ifdef __cplusplus -%typemap(out) SWIGTYPE "$result = new $1_type($1);"; +%typemap(out) SWIGTYPE "$result = new $1_ltype($1);"; #else %typemap(out) SWIGTYPE { $result = ($&1_ltype) malloc(sizeof($1_type)); @@ -243,6 +283,9 @@ $body)" %rename(__funcall__) *::operator(); %rename(__aref__) *::operator[]; + +%rename(__bool__) *::operator bool(); +%rename(__bool__) *::operator bool() const; #endif %insert("lisphead") %{ diff --git a/Source/Modules/allegrocl.cxx b/Source/Modules/allegrocl.cxx index 1273a78af..302470889 100644 --- a/Source/Modules/allegrocl.cxx +++ b/Source/Modules/allegrocl.cxx @@ -170,7 +170,7 @@ static String *namespace_of(String *str) { void add_linked_type(Node *n) { #ifdef ALLEGROCL_CLASS_DEBUG Printf(stderr, "Adding linked node of type: %s(%s) %s(%x)\n\n", nodeType(n), Getattr(n, "storage"), Getattr(n, "name"), n); - Swig_print_node(n); + // Swig_print_node(n); #endif if (!first_linked_type) { first_linked_type = n; @@ -757,7 +757,7 @@ String *internal_compose_foreign_type(SwigType *ty) { Setattr(nn,"kind","class"); Setattr(nn,"sym:name",tok_name); Setattr(nn,"name",tok_key); - Setattr(nn,"allegrocl:package","current_namespace"); + Setattr(nn,"allegrocl:package",current_namespace); add_forward_referenced_type(nn, 0); Printf(ffiType, "%s", get_ffi_type(tok, ""), tok_name); @@ -773,7 +773,8 @@ String *compose_foreign_type(SwigType *ty, String * /*id*/ = 0) { /* Hash *lookup_res = Swig_typemap_search("ffitype", ty, id, 0); */ #ifdef ALLEGROCL_TYPE_DEBUG - Printf(stderr, "compose_foreign_type: ENTER (%s)(%s)...\n ", ty, (id ? id : 0)); + Printf(stderr, "compose_foreign_type: ENTER (%s)...\n ", ty); + // Printf(stderr, "compose_foreign_type: ENTER (%s)(%s)...\n ", ty, (id ? id : 0)); /* String *id_ref = SwigType_str(ty, id); Printf(stderr, "looking up typemap for %s, found '%s'(%x)\n", id_ref, lookup_res ? Getattr(lookup_res, "code") : 0, lookup_res); @@ -1336,7 +1337,6 @@ void emit_typedef(Node *n) { // leave these in for now. might want to change these to def-foreign-class at some point. // Printf(f_clhead, ";; %s\n", SwigType_typedef_resolve_all(lisp_type)); - // Swig_print_node(n); Printf(f_clhead, "(swig-def-foreign-type \"%s\"\n %s)\n", name, lisp_type); Delete(name); @@ -1659,6 +1659,8 @@ int ALLEGROCL::top(Node *n) { Delete(f_clhead); Delete(f_clwrap); + Printf(f_cxx, "%s\n", f_cxx_wrapper); + Close(f_cxx); Delete(f_cxx); Delete(f_cxx_wrapper); @@ -2554,6 +2556,7 @@ int ALLEGROCL::emit_defun(Node *n, File *fcl) { int ALLEGROCL::functionWrapper(Node *n) { #ifdef ALLEGROCL_DEBUG Printf(stderr, "functionWrapper %s\n", Getattr(n,"name")); + Swig_print_node(n); #endif @@ -2570,11 +2573,13 @@ int ALLEGROCL::functionWrapper(Node *n) { Delete(resolved); if (!is_void_return) { - String *lresult_init = NewStringf("= (%s)0", raw_return_type); - Wrapper_add_localv(f, "lresult", - SwigType_lstr(SwigType_ltype(return_type), "lresult"), - lresult_init, NIL); - Delete(lresult_init); + String *lresult_init = + NewStringf("= (%s)0", + SwigType_str(SwigType_strip_qualifiers(return_type),0)); + Wrapper_add_localv(f, "lresult", + SwigType_lstr(SwigType_ltype(return_type), "lresult"), + lresult_init, NIL); + Delete(lresult_init); } // Emit all of the local variables for holding arguments. emit_parameter_variables(parms, f); @@ -2687,14 +2692,15 @@ int ALLEGROCL::functionWrapper(Node *n) { if (CPlusPlus) { Printf(f->code, " } catch (...) {\n"); if (!is_void_return) - Printf(f->code, " return (%s)0;\n", raw_return_type); + Printf(f->code, " return (%s)0;\n", + SwigType_str(SwigType_strip_qualifiers(return_type),0)); Printf(f->code, " }\n"); } Printf(f->code, "}\n"); /* print this when in C mode? make this a command-line arg? */ if (Generate_Wrapper) - Wrapper_print(f, f_cxx); + Wrapper_print(f, f_cxx_wrapper); String *f_buffer = NewString(""); @@ -2796,8 +2802,9 @@ int ALLEGROCL::constantWrapper(Node *n) { SwigType_add_qualifier(const_type, "const"); SwigType_add_qualifier(const_type, "static"); - String *ppcname = NewStringf("ACLppc_%s", Getattr(n, "name")); - Printf(f_cxx, "static const %s = %s;\n", SwigType_lstr(const_type, ppcname), const_val); + String *ppcname = NewStringf("ACLppc_%s", Getattr(n, "sym:name")); + // Printf(f_cxx, "static const %s = %s;\n", SwigType_lstr(const_type, ppcname), const_val); + Printf(f_cxx, "%s = %s;\n", SwigType_lstr(const_type, ppcname), const_val); Setattr(n, "name", ppcname); SetFlag(n, "feature:immutable"); @@ -2936,7 +2943,6 @@ int ALLEGROCL::membervariableHandler(Node *n) { int ALLEGROCL::typedefHandler(Node *n) { #ifdef ALLEGROCL_TYPE_DEBUG Printf(stderr, "In typedefHandler\n"); - // Swig_print_node(n); #endif SwigType *typedef_type = Getattr(n,"type"); @@ -2969,12 +2975,15 @@ int ALLEGROCL::typedefHandler(Node *n) { String *lookup = lookup_defined_foreign_type(typedef_type); #ifdef ALLEGROCL_TYPE_DEBUG - Printf(stderr, "** lookup='%s'(%x), ff_type='%s', !strstr = '%d'\n", lookup, lookup, ff_type, !Strstr(ff_type,"void")); + Printf(stderr, "** lookup='%s'(%x), typedef_type='%s', strcmp = '%d' strstr = '%d'\n", lookup, lookup, typedef_type, Strcmp(typedef_type,"void"), Strstr(ff_type,"__SWIGACL_FwdReference")); #endif - if(lookup || (!lookup && !Strstr(ff_type,"__SWIGACL_FwdReference"))) + if(lookup || (!lookup && Strcmp(typedef_type,"void")) || + (!lookup && Strstr(ff_type,"__SWIGACL_FwdReference"))) { add_defined_foreign_type(n, 0, type_ref, name); - else add_forward_referenced_type(n); + } else { + add_forward_referenced_type(n); + } #ifdef ALLEGROCL_TYPE_DEBUG Printf(stderr, "Out typedefHandler\n"); @@ -3000,10 +3009,14 @@ int ALLEGROCL::classHandler(Node *n) { Printf(stderr, "classHandler %s::%s\n", current_namespace, Getattr(n, "sym:name")); #endif + int result; + if (Generate_Wrapper) - return cppClassHandler(n); + result = cppClassHandler(n); else - return cClassHandler(n); + result = cClassHandler(n); + + return result; } int ALLEGROCL::cClassHandler(Node *n) { @@ -3094,7 +3107,6 @@ int ALLEGROCL::cppClassHandler(Node *n) { Getattr(c, "type")); #ifdef ALLEGROCL_CLASS_DEBUG Printf(stderr, "looking at child '%x' of type '%s'\n", c, childType); - Swig_print_node(c); #endif if (!SwigType_isfunction(childType)) Delete(compose_foreign_type(childType)); @@ -3160,11 +3172,21 @@ int ALLEGROCL::enumvalueDeclaration(Node *n) { #endif /* print this when in C mode? make this a command-line arg? */ if (Generate_Wrapper) { - String *mangled_name = mangle_name(n, "ACL_ENUM"); - Printf(f_cxx, "EXPORT const %s %s = %s;\n", Getattr(n, "type"), - mangled_name, Getattr(n, "value")); + SwigType *enum_type = Copy(Getattr(n,"type")); + String *mangled_name = + mangle_name(n, "ACL_ENUM", + in_class ? Getattr(in_class,"name") : + current_namespace); + + SwigType_add_qualifier(enum_type,"const"); + + String *enum_decl = SwigType_str(enum_type, mangled_name); + Printf(f_cxx_wrapper, "EXPORT %s;\n", enum_decl); + Printf(f_cxx_wrapper, "%s = %s;\n", enum_decl, Getattr(n, "value")); Delete(mangled_name); + Delete(enum_type); + Delete(enum_decl); } return SWIG_OK; } diff --git a/TODO b/TODO index 103185d23..72aeada7c 100644 --- a/TODO +++ b/TODO @@ -339,6 +339,14 @@ Common Lisp typemaps would be written as Lisp programs that generate Lisp code. +ALLEGROCL +----- +These first three will remove most of the warnings from most of the +remaining checkpartial tests that are failing. +**** Throws typemap support +**** const typemaps +**** long long typemaps + Ocaml ----- ** I've been working with my camlp4 module and type information From 0f0c13204e9e8833da36c5466dec4c8edf15a347 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Wed, 1 Oct 2008 05:28:45 +0000 Subject: [PATCH 0138/1680] Fix non-standard indentation. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10886 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/php/globalvar.i | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/php/globalvar.i b/Lib/php/globalvar.i index a75b1a41e..df8cfade7 100644 --- a/Lib/php/globalvar.i +++ b/Lib/php/globalvar.i @@ -299,7 +299,7 @@ zend_hash_find(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void**)&z_var); if($1) - SWIG_SetPointerZval(*z_var, (void*)$1, $1_descriptor, 0); + SWIG_SetPointerZval(*z_var, (void*)$1, $1_descriptor, 0); } %typemap(varout) char [ANY] From fccd1e294a2ab2e6a5c3a236e915b4e86fbed905 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Wed, 1 Oct 2008 11:54:31 +0000 Subject: [PATCH 0139/1680] Fix indentation. Use %{ %} in a couple of typemaps to avoid adding needless { } to the generated code. Use memcpy() instead of memmove() where the destination is freshly allocated so there's no possibility of overlap. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10887 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/php/php.swg | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Lib/php/php.swg b/Lib/php/php.swg index 916a5159e..28431610a 100644 --- a/Lib/php/php.swg +++ b/Lib/php/php.swg @@ -205,15 +205,15 @@ %typemap(out) SWIGTYPE *, SWIGTYPE [], SWIGTYPE & -{ - SWIG_SetPointerZval(return_value, (void *)$1, $1_descriptor, $owner); -} +%{ + SWIG_SetPointerZval(return_value, (void *)$1, $1_descriptor, $owner); +%} %typemap(out) SWIGTYPE *DYNAMIC, SWIGTYPE &DYNAMIC { - swig_type_info *ty = SWIG_TypeDynamicCast($1_descriptor, (void **) &$1); - SWIG_SetPointerZval(return_value, (void *)$1, ty, $owner); + swig_type_info *ty = SWIG_TypeDynamicCast($1_descriptor, (void **) &$1); + SWIG_SetPointerZval(return_value, (void *)$1, ty, $owner); } %typemap(out) SWIGTYPE @@ -225,7 +225,7 @@ #else { $&1_ltype resultobj = ($&1_ltype) emalloc(sizeof($1_type)); - memmove(resultobj, &$1, sizeof($1_type)); + memcpy(resultobj, &$1, sizeof($1_type)); SWIG_SetPointerZval(return_value, (void *)resultobj, $&1_descriptor, 1); } #endif @@ -233,9 +233,9 @@ %typemap(out) void ""; %typemap(out) char [ANY] -{ +%{ RETVAL_STRINGL($1,$1_dim0,1); -} +%} // This typecheck does hard checking for proper argument type. If you want // an argument to be converted from a different PHP type, you must convert From f2c11f74f915b5b93c30e22e0ecab9f1ca7fdb1d Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 9 Oct 2008 22:42:45 +0000 Subject: [PATCH 0140/1680] suggest starting points for documentation git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10893 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/README | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Doc/README b/Doc/README index 110428199..f7a493933 100644 --- a/Doc/README +++ b/Doc/README @@ -2,4 +2,5 @@ Doc/Manual - Latest version of the SWIG user manual Doc/Devel - Developer documentation concerning SWIG internals. (not necessarily up to date) - \ No newline at end of file +Open the index.html file in each of these directories with a web browser. + From a604f465933462c89ee38ca24eec387d518af7ab Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 1 Nov 2008 22:52:26 +0000 Subject: [PATCH 0141/1680] Add the strip encoder patch from Anatoly Techtonik #2130016 git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10896 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 14 ++++++++ Examples/test-suite/common.mk | 1 + .../python/rename_strip_encoder_runme.py | 6 ++++ Examples/test-suite/rename_strip_encoder.i | 16 ++++++++++ Source/Swig/misc.c | 32 +++++++++++++++++++ 5 files changed, 69 insertions(+) create mode 100644 Examples/test-suite/python/rename_strip_encoder_runme.py create mode 100644 Examples/test-suite/rename_strip_encoder.i diff --git a/CHANGES.current b/CHANGES.current index 0a654156a..34117a214 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -3,6 +3,20 @@ Version 1.3.37 (in progress) ============================ +2008-11-01: wsfulton + Add the strip encoder patch from Anatoly Techtonik #2130016. This enables an + easy way to rename symbols by stripping a commonly used prefix in all the + function/struct names. It works in the same way as the other encoders, such as + title, lower, command etc outlined in CHANGES file dated 12/30/2005. Example + below will rename wxAnotherWidget to AnotherWidget and wxDoSomething to + DoSomething: + + %rename("%(strip:[wx])s") ""; + + struct wxAnotherWidget { + void wxDoSomething(); + }; + 2008-09-26: mutandiz [allegrocl] Lots of test-suite work. diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 57b57c271..8e525d9ed 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -260,6 +260,7 @@ CPP_TEST_CASES += \ rename3 \ rename4 \ rename_scope \ + rename_strip_encoder \ restrict_cplusplus \ return_const_value \ return_value_scope \ diff --git a/Examples/test-suite/python/rename_strip_encoder_runme.py b/Examples/test-suite/python/rename_strip_encoder_runme.py new file mode 100644 index 000000000..64be611d6 --- /dev/null +++ b/Examples/test-suite/python/rename_strip_encoder_runme.py @@ -0,0 +1,6 @@ +from rename_strip_encoder import * + +s = SomeWidget() +a = AnotherWidget() +a.DoSomething() + diff --git a/Examples/test-suite/rename_strip_encoder.i b/Examples/test-suite/rename_strip_encoder.i new file mode 100644 index 000000000..691173b02 --- /dev/null +++ b/Examples/test-suite/rename_strip_encoder.i @@ -0,0 +1,16 @@ +%module rename_strip_encoder + +// strip the wx prefix from all identifiers +%rename("%(strip:[wx])s") ""; + +%inline %{ + +class wxSomeWidget { +}; + +struct wxAnotherWidget { + void wxDoSomething() {} +}; + + +%} diff --git a/Source/Swig/misc.c b/Source/Swig/misc.c index d29250517..ae3129fde 100644 --- a/Source/Swig/misc.c +++ b/Source/Swig/misc.c @@ -926,6 +926,37 @@ String *Swig_string_command(String *s) { } +/* ----------------------------------------------------------------------------- + * Swig_string_strip() + * + * Strip given prefix from identifiers + * + * Printf(stderr,"%(strip:[wx])s","wxHello") -> Hello + * ----------------------------------------------------------------------------- */ + +String *Swig_string_strip(String *s) { + String *ns; + if (!Len(s)) { + ns = NewString(s); + } else { + const char *cs = Char(s); + const char *ce = Strchr(cs, ']'); + if (*cs != '[' || ce == NULL) { + ns = NewString(s); + } else { + String *fmt = NewStringf("%%.%ds", ce-cs-1); + String *prefix = NewStringf(fmt, cs+1); + if (0 == Strncmp(ce+1, prefix, Len(prefix))) { + ns = NewString(ce+1+Len(prefix)); + } else { + ns = NewString(ce+1); + } + } + } + return ns; +} + + /* ----------------------------------------------------------------------------- * Swig_string_rxspencer() * @@ -1053,6 +1084,7 @@ void Swig_init() { DohEncoding("command", Swig_string_command); DohEncoding("rxspencer", Swig_string_rxspencer); DohEncoding("schemify", Swig_string_schemify); + DohEncoding("strip", Swig_string_strip); /* aliases for the case encoders */ DohEncoding("uppercase", Swig_string_upper); From 04a1d9182ff336f38da7d1f04de5a3824d995d21 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 1 Nov 2008 23:09:26 +0000 Subject: [PATCH 0142/1680] Add patch #2128249 from Anatoly Techtonik which corrects the C/C++ proxy class being reported for Python docstrings when %rename is used git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10897 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++++ Source/Modules/python.cxx | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 34117a214..2c59d49ce 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -3,6 +3,10 @@ Version 1.3.37 (in progress) ============================ +2008-11-01: wsfulton + Add patch #2128249 from Anatoly Techtonik which corrects the C/C++ proxy + class being reported for Python docstrings when %rename is used. + 2008-11-01: wsfulton Add the strip encoder patch from Anatoly Techtonik #2130016. This enables an easy way to rename symbols by stripping a commonly used prefix in all the diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 9e6409af6..b455de890 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -1341,9 +1341,9 @@ public: String *str = Getattr(n, "feature:docstring"); if (str == NULL || Len(str) == 0) { if (CPlusPlus) { - Printf(doc, "Proxy of C++ %s class", class_name); + Printf(doc, "Proxy of C++ %s class", real_classname); } else { - Printf(doc, "Proxy of C %s struct", class_name); + Printf(doc, "Proxy of C %s struct", real_classname); } } } From 6fb0f48935f8cc1011a38d1920612c1124b7bc39 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 3 Nov 2008 12:51:45 +0000 Subject: [PATCH 0143/1680] customised ccache support: read the CCACHE_OUTFILES env variable and if exists, the names of all generated files are written to the filename specified in the env variable git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10898 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/DOH/README | 12 ++++----- Source/DOH/doh.h | 2 +- Source/DOH/file.c | 11 +++++--- Source/Modules/allegrocl.cxx | 4 +-- Source/Modules/cffi.cxx | 7 +++--- Source/Modules/chicken.cxx | 4 +-- Source/Modules/clisp.cxx | 2 +- Source/Modules/csharp.cxx | 14 +++++------ Source/Modules/guile.cxx | 8 +++--- Source/Modules/java.cxx | 16 ++++++------ Source/Modules/lua.cxx | 2 +- Source/Modules/main.cxx | 49 ++++++++++++++++++++++++++---------- Source/Modules/modula3.cxx | 8 +++--- Source/Modules/mzscheme.cxx | 2 +- Source/Modules/ocaml.cxx | 6 ++--- Source/Modules/octave.cxx | 2 +- Source/Modules/perl5.cxx | 4 +-- Source/Modules/php.cxx | 6 ++--- Source/Modules/pike.cxx | 2 +- Source/Modules/python.cxx | 6 ++--- Source/Modules/r.cxx | 6 ++--- Source/Modules/ruby.cxx | 4 +-- Source/Modules/s-exp.cxx | 2 +- Source/Modules/swigmod.h | 3 +++ Source/Modules/tcl8.cxx | 4 +-- Source/Modules/uffi.cxx | 2 +- Source/Modules/xml.cxx | 6 ++--- 27 files changed, 111 insertions(+), 83 deletions(-) diff --git a/Source/DOH/README b/Source/DOH/README index 1e948105c..9a42e8b8b 100644 --- a/Source/DOH/README +++ b/Source/DOH/README @@ -92,12 +92,12 @@ DohEncoding(name, fn) Register a format encoding for Printf Currently Available datatypes ------------------------------ -NewString(char *initial) Strings -NewHash() Hash -NewList() List -NewVoid(void *ptr, void (*del)(void *)) Void -NewFile(char *file, char *mode) File -NewCallable(DOH *(*func)(DOH *, DOH *)) Callable object +NewString(char *initial) Strings +NewHash() Hash +NewList() List +NewVoid(void *ptr, void (*del)(void *)) Void +NewFile(char *filename, char *mode, List *newfiles) File +NewCallable(DOH *(*func)(DOH *, DOH *)) Callable object Odds and ends: diff --git a/Source/DOH/doh.h b/Source/DOH/doh.h index 7ab244fab..e6f52438e 100644 --- a/Source/DOH/doh.h +++ b/Source/DOH/doh.h @@ -297,7 +297,7 @@ extern char *DohStrchr(const DOHString_or_char *s1, int ch); * Files * ----------------------------------------------------------------------------- */ -extern DOHFile *DohNewFile(DOH *file, const char *mode); +extern DOHFile *DohNewFile(DOH *filename, const char *mode, DOHList *outfiles); extern DOHFile *DohNewFileFromFile(FILE *f); extern DOHFile *DohNewFileFromFd(int fd); extern void DohFileErrorDisplay(DOHString * filename); diff --git a/Source/DOH/file.c b/Source/DOH/file.c index 8c53978ee..65c2336a4 100644 --- a/Source/DOH/file.c +++ b/Source/DOH/file.c @@ -228,15 +228,16 @@ static DohObjInfo DohFileType = { * NewFile() * * Create a new file from a given filename and mode. + * If newfiles is non-zero, the filename is added to the list of new files. * ----------------------------------------------------------------------------- */ -DOH *DohNewFile(DOH *fn, const char *mode) { +DOH *DohNewFile(DOH *filename, const char *mode, DOHList *newfiles) { DohFile *f; FILE *file; - char *filename; + char *filen; - filename = Char(fn); - file = fopen(filename, mode); + filen = Char(filename); + file = fopen(filen, mode); if (!file) return 0; @@ -245,6 +246,8 @@ DOH *DohNewFile(DOH *fn, const char *mode) { fclose(file); return 0; } + if (newfiles) + Append(newfiles, filename); f->filep = file; f->fd = 0; f->closeondel = 1; diff --git a/Source/Modules/allegrocl.cxx b/Source/Modules/allegrocl.cxx index 302470889..5748a082b 100644 --- a/Source/Modules/allegrocl.cxx +++ b/Source/Modules/allegrocl.cxx @@ -1590,7 +1590,7 @@ int ALLEGROCL::top(Node *n) { Printf(cl_filename, "%s%s.cl", SWIG_output_directory(), module_name); - f_cl = NewFile(cl_filename, "w"); + f_cl = NewFile(cl_filename, "w", SWIG_output_files()); if (!f_cl) { Printf(stderr, "Unable to open %s for writing\n", cl_filename); SWIG_exit(EXIT_FAILURE); @@ -1599,7 +1599,7 @@ int ALLEGROCL::top(Node *n) { Generate_Wrapper = CPlusPlus || CWrap; if (Generate_Wrapper) { - f_cxx = NewFile(cxx_filename, "w"); + f_cxx = NewFile(cxx_filename, "w", SWIG_output_files()); if (!f_cxx) { Close(f_cl); Delete(f_cl); diff --git a/Source/Modules/cffi.cxx b/Source/Modules/cffi.cxx index 4b3ddac70..9d9991ea5 100644 --- a/Source/Modules/cffi.cxx +++ b/Source/Modules/cffi.cxx @@ -119,15 +119,14 @@ int CFFI::top(Node *n) { Printf(lisp_filename, "%s%s.lisp", SWIG_output_directory(), module); - File *f_lisp = NewFile(lisp_filename, "w"); - NewFile(lisp_filename, "w"); + File *f_lisp = NewFile(lisp_filename, "w", SWIG_output_files()); if (!f_lisp) { FileErrorDisplay(lisp_filename); SWIG_exit(EXIT_FAILURE); } if (CPlusPlus || CWrap) { - f_cxx = NewFile(cxx_filename, "w"); + f_cxx = NewFile(cxx_filename, "w", SWIG_output_files()); if (!f_cxx) { Close(f_lisp); Delete(f_lisp); @@ -137,7 +136,7 @@ int CFFI::top(Node *n) { String *clos_filename = NewString(""); Printf(clos_filename, "%s%s-clos.lisp", SWIG_output_directory(), module); - f_clos = NewFile(clos_filename, "w"); + f_clos = NewFile(clos_filename, "w", SWIG_output_files()); if (!f_clos) { Close(f_lisp); Delete(f_lisp); diff --git a/Source/Modules/chicken.cxx b/Source/Modules/chicken.cxx index 2298d2939..5ca340f04 100644 --- a/Source/Modules/chicken.cxx +++ b/Source/Modules/chicken.cxx @@ -188,7 +188,7 @@ int CHICKEN::top(Node *n) { /* Initialize all of the output files */ String *outfile = Getattr(n, "outfile"); - f_runtime = NewFile(outfile, "w"); + f_runtime = NewFile(outfile, "w", SWIG_output_files()); if (!f_runtime) { FileErrorDisplay(outfile); SWIG_exit(EXIT_FAILURE); @@ -251,7 +251,7 @@ int CHICKEN::top(Node *n) { Printf(f_init, "#endif\n"); Printf(chicken_filename, "%s%s.scm", SWIG_output_directory(), module); - if ((f_scm = NewFile(chicken_filename, "w")) == 0) { + if ((f_scm = NewFile(chicken_filename, "w", SWIG_output_files())) == 0) { FileErrorDisplay(chicken_filename); SWIG_exit(EXIT_FAILURE); } diff --git a/Source/Modules/clisp.cxx b/Source/Modules/clisp.cxx index 823f22e2c..5275b9899 100644 --- a/Source/Modules/clisp.cxx +++ b/Source/Modules/clisp.cxx @@ -79,7 +79,7 @@ int CLISP::top(Node *n) { Printf(output_filename, "%s%s.lisp", SWIG_output_directory(), module); } - f_cl = NewFile(output_filename, "w+"); + f_cl = NewFile(output_filename, "w+", SWIG_output_files()); if (!f_cl) { FileErrorDisplay(output_filename); SWIG_exit(EXIT_FAILURE); diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index 431181355..19e006a2a 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -286,7 +286,7 @@ public: SWIG_exit(EXIT_FAILURE); } - f_runtime = NewFile(outfile, "w"); + f_runtime = NewFile(outfile, "w", SWIG_output_files()); if (!f_runtime) { FileErrorDisplay(outfile); SWIG_exit(EXIT_FAILURE); @@ -297,7 +297,7 @@ public: Printf(stderr, "Unable to determine outfile_h\n"); SWIG_exit(EXIT_FAILURE); } - f_runtime_h = NewFile(outfile_h, "w"); + f_runtime_h = NewFile(outfile_h, "w", SWIG_output_files()); if (!f_runtime_h) { FileErrorDisplay(outfile_h); SWIG_exit(EXIT_FAILURE); @@ -396,7 +396,7 @@ public: // Generate the intermediary class { String *filen = NewStringf("%s%s.cs", SWIG_output_directory(), imclass_name); - File *f_im = NewFile(filen, "w"); + File *f_im = NewFile(filen, "w", SWIG_output_files()); if (!f_im) { FileErrorDisplay(filen); SWIG_exit(EXIT_FAILURE); @@ -440,7 +440,7 @@ public: // Generate the C# module class { String *filen = NewStringf("%s%s.cs", SWIG_output_directory(), module_class_name); - File *f_module = NewFile(filen, "w"); + File *f_module = NewFile(filen, "w", SWIG_output_files()); if (!f_module) { FileErrorDisplay(filen); SWIG_exit(EXIT_FAILURE); @@ -1155,7 +1155,7 @@ public: } else { // Global enums are defined in their own file String *filen = NewStringf("%s%s.cs", SWIG_output_directory(), symname); - File *f_enum = NewFile(filen, "w"); + File *f_enum = NewFile(filen, "w", SWIG_output_files()); if (!f_enum) { FileErrorDisplay(filen); SWIG_exit(EXIT_FAILURE); @@ -1734,7 +1734,7 @@ public: } String *filen = NewStringf("%s%s.cs", SWIG_output_directory(), proxy_class_name); - f_proxy = NewFile(filen, "w"); + f_proxy = NewFile(filen, "w", SWIG_output_files()); if (!f_proxy) { FileErrorDisplay(filen); SWIG_exit(EXIT_FAILURE); @@ -2960,7 +2960,7 @@ public: void emitTypeWrapperClass(String *classname, SwigType *type) { String *swigtype = NewString(""); String *filen = NewStringf("%s%s.cs", SWIG_output_directory(), classname); - File *f_swigtype = NewFile(filen, "w"); + File *f_swigtype = NewFile(filen, "w", SWIG_output_files()); if (!f_swigtype) { FileErrorDisplay(filen); SWIG_exit(EXIT_FAILURE); diff --git a/Source/Modules/guile.cxx b/Source/Modules/guile.cxx index f5f080034..df0540235 100644 --- a/Source/Modules/guile.cxx +++ b/Source/Modules/guile.cxx @@ -174,7 +174,7 @@ public: } } else if (strcmp(argv[i], "-procdoc") == 0) { if (argv[i + 1]) { - procdoc = NewFile(argv[i + 1], (char *) "w"); + procdoc = NewFile(argv[i + 1], "w", SWIG_output_files()); if (!procdoc) { FileErrorDisplay(argv[i + 1]); SWIG_exit(EXIT_FAILURE); @@ -299,7 +299,7 @@ public: /* Initialize all of the output files */ String *outfile = Getattr(n, "outfile"); - f_runtime = NewFile(outfile, "w"); + f_runtime = NewFile(outfile, "w", SWIG_output_files()); if (!f_runtime) { FileErrorDisplay(outfile); SWIG_exit(EXIT_FAILURE); @@ -499,7 +499,7 @@ public: SWIG_output_directory(), primitive_name); Delete(primitive_name); - File *scmstubfile = NewFile(fname, (char *) "w"); + File *scmstubfile = NewFile(fname, "w", SWIG_output_files()); if (!scmstubfile) { FileErrorDisplay(fname); SWIG_exit(EXIT_FAILURE); @@ -530,7 +530,7 @@ public: String *fname = NewStringf("%s%s.scm", SWIG_output_directory(), module_name); - File *goopsfile = NewFile(fname, (char *) "w"); + File *goopsfile = NewFile(fname, "w", SWIG_output_files()); if (!goopsfile) { FileErrorDisplay(fname); SWIG_exit(EXIT_FAILURE); diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index b92fccdfb..37ce22377 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -293,7 +293,7 @@ public: SWIG_exit(EXIT_FAILURE); } - f_runtime = NewFile(outfile, "w"); + f_runtime = NewFile(outfile, "w", SWIG_output_files()); if (!f_runtime) { FileErrorDisplay(outfile); SWIG_exit(EXIT_FAILURE); @@ -304,7 +304,7 @@ public: Printf(stderr, "Unable to determine outfile_h\n"); SWIG_exit(EXIT_FAILURE); } - f_runtime_h = NewFile(outfile_h, "w"); + f_runtime_h = NewFile(outfile_h, "w", SWIG_output_files()); if (!f_runtime_h) { FileErrorDisplay(outfile_h); SWIG_exit(EXIT_FAILURE); @@ -420,7 +420,7 @@ public: // Generate the intermediary class { String *filen = NewStringf("%s%s.java", SWIG_output_directory(), imclass_name); - File *f_im = NewFile(filen, "w"); + File *f_im = NewFile(filen, "w", SWIG_output_files()); if (!f_im) { FileErrorDisplay(filen); SWIG_exit(EXIT_FAILURE); @@ -471,7 +471,7 @@ public: // Generate the Java module class { String *filen = NewStringf("%s%s.java", SWIG_output_directory(), module_class_name); - File *f_module = NewFile(filen, "w"); + File *f_module = NewFile(filen, "w", SWIG_output_files()); if (!f_module) { FileErrorDisplay(filen); SWIG_exit(EXIT_FAILURE); @@ -523,7 +523,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); - File *f_module = NewFile(filen, "w"); + File *f_module = NewFile(filen, "w", SWIG_output_files()); if (!f_module) { FileErrorDisplay(filen); SWIG_exit(EXIT_FAILURE); @@ -1210,7 +1210,7 @@ public: } else { // Global enums are defined in their own file String *filen = NewStringf("%s%s.java", SWIG_output_directory(), symname); - File *f_enum = NewFile(filen, "w"); + File *f_enum = NewFile(filen, "w", SWIG_output_files()); if (!f_enum) { FileErrorDisplay(filen); SWIG_exit(EXIT_FAILURE); @@ -1742,7 +1742,7 @@ public: } String *filen = NewStringf("%s%s.java", SWIG_output_directory(), proxy_class_name); - f_proxy = NewFile(filen, "w"); + f_proxy = NewFile(filen, "w", SWIG_output_files()); if (!f_proxy) { FileErrorDisplay(filen); SWIG_exit(EXIT_FAILURE); @@ -2798,7 +2798,7 @@ public: void emitTypeWrapperClass(String *classname, SwigType *type) { String *swigtype = NewString(""); String *filen = NewStringf("%s%s.java", SWIG_output_directory(), classname); - File *f_swigtype = NewFile(filen, "w"); + File *f_swigtype = NewFile(filen, "w", SWIG_output_files()); if (!f_swigtype) { FileErrorDisplay(filen); SWIG_exit(EXIT_FAILURE); diff --git a/Source/Modules/lua.cxx b/Source/Modules/lua.cxx index 6113da960..c17be52c3 100644 --- a/Source/Modules/lua.cxx +++ b/Source/Modules/lua.cxx @@ -213,7 +213,7 @@ public: String *outfile = Getattr(n, "outfile"); /* Open the output file */ - f_runtime = NewFile(outfile, "w"); + f_runtime = NewFile(outfile, "w", SWIG_output_files()); if (!f_runtime) { FileErrorDisplay(outfile); SWIG_exit(EXIT_FAILURE); diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx index 901ee812e..0992d5539 100644 --- a/Source/Modules/main.cxx +++ b/Source/Modules/main.cxx @@ -180,6 +180,7 @@ 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 *all_output_files = 0; // ----------------------------------------------------------------------------- // check_suffix(char *name) @@ -300,6 +301,11 @@ void SWIG_config_cppext(const char *ext) { cpp_extension = (char *) ext; } +List *SWIG_output_files() { + assert(all_output_files); + return all_output_files; +} + void SWIG_setfeature(const char *cfeature, const char *cvalue) { Hash *features_hash = Swig_cparse_features(); String *name = NewString(""); @@ -363,7 +369,7 @@ static void SWIG_dump_runtime() { } } - runtime = NewFile(outfile, "w"); + runtime = NewFile(outfile, "w", SWIG_output_files()); if (!runtime) { FileErrorDisplay(outfile); SWIG_exit(EXIT_FAILURE); @@ -867,6 +873,7 @@ int SWIG_main(int argc, char *argv[], Language *l) { } libfiles = NewList(); + all_output_files = NewList(); /* Check for SWIG_FEATURES environment variable */ @@ -940,20 +947,21 @@ int SWIG_main(int argc, char *argv[], Language *l) { if (!s) { fprintf(stderr, "Unable to locate '%s' in the SWIG library.\n", input_file); } else { - FILE *f = fopen(outfile, "r"); + FILE *f = Swig_open(outfile); if (f) { fclose(f); fprintf(stderr, "File '%s' already exists. Checkout aborted.\n", outfile); } else { - f = fopen(outfile, "w"); - if (!f) { - fprintf(stderr, "Unable to create file '%s'\n", outfile); - } else { - if (Verbose) - fprintf(stdout, "'%s' checked out from the SWIG library.\n", input_file); - fputs(Char(s), f); - fclose(f); - } + File *f_outfile = NewFile(outfile, "w", SWIG_output_files()); + if (!f_outfile) { + FileErrorDisplay(outfile); + SWIG_exit(EXIT_FAILURE); + } else { + if (Verbose) + fprintf(stdout, "'%s' checked out from the SWIG library.\n", outfile); + Printv(f_outfile, s, NIL); + Close(f_outfile); + } } } } else { @@ -1019,14 +1027,14 @@ int SWIG_main(int argc, char *argv[], Language *l) { outfile = NewString(outfile_name); } if (dependencies_file && Len(dependencies_file) != 0) { - f_dependencies_file = NewFile(dependencies_file, "w"); + f_dependencies_file = NewFile(dependencies_file, "w", SWIG_output_files()); if (!f_dependencies_file) { FileErrorDisplay(dependencies_file); SWIG_exit(EXIT_FAILURE); } } else if (!depend_only) { String *filename = NewStringf("%s_wrap.%s", Swig_file_basename(input_file), depends_extension); - f_dependencies_file = NewFile(filename, "w"); + f_dependencies_file = NewFile(filename, "w", SWIG_output_files()); if (!f_dependencies_file) { FileErrorDisplay(filename); SWIG_exit(EXIT_FAILURE); @@ -1173,6 +1181,21 @@ int SWIG_main(int argc, char *argv[], Language *l) { if (memory_debug) DohMemoryDebug(); + char *outfiles = getenv("CCACHE_OUTFILES"); + if (outfiles) { + File *f_outfiles = NewFile(outfiles, "w", 0); + if (!f_outfiles) { + Printf(stderr, "Failed to write list of output files to the filename '%s' specified in CCACHE_OUTFILES environment variable - ", outfiles); + FileErrorDisplay(f_outfiles); + SWIG_exit(EXIT_FAILURE); + } else { + int i; + for (i = 0; i < Len(all_output_files); i++) + Printf(f_outfiles, "%s\n", Getitem(all_output_files, i)); + Close(f_outfiles); + } + } + // Deletes Delete(libfiles); Preprocessor_delete(); diff --git a/Source/Modules/modula3.cxx b/Source/Modules/modula3.cxx index 6cb24d39a..e85ba3a46 100644 --- a/Source/Modules/modula3.cxx +++ b/Source/Modules/modula3.cxx @@ -542,7 +542,7 @@ MODULA3(): * ----------------------------------------------------------------------------- */ File *openWriteFile(String *name) { - File *file = NewFile(name, "w"); + File *file = NewFile(name, "w", SWIG_output_files()); if (!file) { FileErrorDisplay(name); SWIG_exit(EXIT_FAILURE); @@ -902,7 +902,7 @@ MODULA3(): /* Initialize all of the output files */ outfile = Getattr(n, "outfile"); - f_runtime = NewFile(outfile, "w"); + f_runtime = NewFile(outfile, "w", SWIG_output_files()); if (!f_runtime) { FileErrorDisplay(outfile); SWIG_exit(EXIT_FAILURE); @@ -2382,7 +2382,7 @@ MODULA3(): } String *filen = NewStringf("%s%s.m3", Swig_file_dirname(outfile), proxy_class_name); - f_proxy = NewFile(filen, "w"); + f_proxy = NewFile(filen, "w", SWIG_output_files()); if (!f_proxy) { FileErrorDisplay(filen); SWIG_exit(EXIT_FAILURE); @@ -3762,7 +3762,7 @@ MODULA3(): void emitTypeWrapperClass(String *classname, SwigType *type) { String *filen = NewStringf("%s%s.m3", Swig_file_dirname(outfile), classname); - File *f_swigtype = NewFile(filen, "w"); + File *f_swigtype = NewFile(filen, "w", SWIG_output_files()); if (!f_swigtype) { FileErrorDisplay(filen); SWIG_exit(EXIT_FAILURE); diff --git a/Source/Modules/mzscheme.cxx b/Source/Modules/mzscheme.cxx index 78d4a4b65..b0bfbf5ef 100644 --- a/Source/Modules/mzscheme.cxx +++ b/Source/Modules/mzscheme.cxx @@ -129,7 +129,7 @@ public: /* Initialize all of the output files */ String *outfile = Getattr(n, "outfile"); - f_runtime = NewFile(outfile, "w"); + f_runtime = NewFile(outfile, "w", SWIG_output_files()); if (!f_runtime) { FileErrorDisplay(outfile); SWIG_exit(EXIT_FAILURE); diff --git a/Source/Modules/ocaml.cxx b/Source/Modules/ocaml.cxx index 0d0f4c7f2..5c0e4b134 100755 --- a/Source/Modules/ocaml.cxx +++ b/Source/Modules/ocaml.cxx @@ -214,7 +214,7 @@ public: /* Initialize all of the output files */ String *outfile = Getattr(n, "outfile"); - f_runtime = NewFile(outfile, "w"); + f_runtime = NewFile(outfile, "w", SWIG_output_files()); if (!f_runtime) { FileErrorDisplay(outfile); SWIG_exit(EXIT_FAILURE); @@ -293,12 +293,12 @@ public: Printv(mlifile, module, ".mli", NIL); String *mlfilen = NewStringf("%s%s", SWIG_output_directory(), mlfile); - if ((f_mlout = NewFile(mlfilen, "w")) == 0) { + if ((f_mlout = NewFile(mlfilen, "w", SWIG_output_files())) == 0) { FileErrorDisplay(mlfilen); SWIG_exit(EXIT_FAILURE); } String *mlifilen = NewStringf("%s%s", SWIG_output_directory(), mlifile); - if ((f_mliout = NewFile(mlifilen, "w")) == 0) { + if ((f_mliout = NewFile(mlifilen, "w", SWIG_output_files())) == 0) { FileErrorDisplay(mlifilen); SWIG_exit(EXIT_FAILURE); } diff --git a/Source/Modules/octave.cxx b/Source/Modules/octave.cxx index d582e8a6c..5e3cc9d08 100644 --- a/Source/Modules/octave.cxx +++ b/Source/Modules/octave.cxx @@ -87,7 +87,7 @@ public: String *module = Getattr(n, "name"); String *outfile = Getattr(n, "outfile"); - f_runtime = NewFile(outfile, "w"); + f_runtime = NewFile(outfile, "w", SWIG_output_files()); if (!f_runtime) { FileErrorDisplay(outfile); SWIG_exit(EXIT_FAILURE); diff --git a/Source/Modules/perl5.cxx b/Source/Modules/perl5.cxx index 6e706fc8d..3b9585534 100644 --- a/Source/Modules/perl5.cxx +++ b/Source/Modules/perl5.cxx @@ -222,7 +222,7 @@ public: /* Initialize all of the output files */ String *outfile = Getattr(n, "outfile"); - f_runtime = NewFile(outfile, "w"); + f_runtime = NewFile(outfile, "w", SWIG_output_files()); if (!f_runtime) { FileErrorDisplay(outfile); SWIG_exit(EXIT_FAILURE); @@ -315,7 +315,7 @@ public: pmfile = NewStringf("%s.pm", m); } String *filen = NewStringf("%s%s", SWIG_output_directory(), pmfile); - if ((f_pm = NewFile(filen, "w")) == 0) { + if ((f_pm = NewFile(filen, "w", SWIG_output_files())) == 0) { FileErrorDisplay(filen); SWIG_exit(EXIT_FAILURE); } diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index e96e64c02..434456b40 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -258,7 +258,7 @@ public: String *outfile = Getattr(n, "outfile"); /* main output file */ - f_runtime = NewFile(outfile, "w"); + f_runtime = NewFile(outfile, "w", SWIG_output_files()); if (!f_runtime) { FileErrorDisplay(outfile); SWIG_exit(EXIT_FAILURE); @@ -302,7 +302,7 @@ public: Printv(filen, SWIG_output_directory(), module, ".php", NIL); phpfilename = NewString(filen); - f_phpcode = NewFile(filen, "w"); + f_phpcode = NewFile(filen, "w", SWIG_output_files()); if (!f_phpcode) { FileErrorDisplay(filen); SWIG_exit(EXIT_FAILURE); @@ -381,7 +381,7 @@ public: /* Create the .h file too */ filen = NewStringEmpty(); Printv(filen, SWIG_output_directory(), "php_", module, ".h", NIL); - f_h = NewFile(filen, "w"); + f_h = NewFile(filen, "w", SWIG_output_files()); if (!f_h) { FileErrorDisplay(filen); SWIG_exit(EXIT_FAILURE); diff --git a/Source/Modules/pike.cxx b/Source/Modules/pike.cxx index 30f9b3d74..56d1acab2 100644 --- a/Source/Modules/pike.cxx +++ b/Source/Modules/pike.cxx @@ -123,7 +123,7 @@ public: String *outfile = Getattr(n, "outfile"); /* Open the output file */ - f_runtime = NewFile(outfile, "w"); + f_runtime = NewFile(outfile, "w", SWIG_output_files()); if (!f_runtime) { FileErrorDisplay(outfile); SWIG_exit(EXIT_FAILURE); diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index b455de890..870c6f35e 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -513,7 +513,7 @@ public: String *outfile = Getattr(n, "outfile"); String *outfile_h = !no_header_file ? Getattr(n, "outfile_h") : 0; - f_runtime = NewFile(outfile, "w"); + f_runtime = NewFile(outfile, "w", SWIG_output_files()); if (!f_runtime) { FileErrorDisplay(outfile); SWIG_exit(EXIT_FAILURE); @@ -521,7 +521,7 @@ public: if (directorsEnabled()) { if (!no_header_file) { - f_runtime_h = NewFile(outfile_h, "w"); + f_runtime_h = NewFile(outfile_h, "w", SWIG_output_files()); if (!f_runtime_h) { FileErrorDisplay(outfile_h); SWIG_exit(EXIT_FAILURE); @@ -662,7 +662,7 @@ public: module = interface; else Insert(module, 0, "_"); - if ((f_shadow_py = NewFile(filen, "w")) == 0) { + if ((f_shadow_py = NewFile(filen, "w", SWIG_output_files())) == 0) { FileErrorDisplay(filen); SWIG_exit(EXIT_FAILURE); } diff --git a/Source/Modules/r.cxx b/Source/Modules/r.cxx index 49d3ecc89..26b83adea 100644 --- a/Source/Modules/r.cxx +++ b/Source/Modules/r.cxx @@ -878,7 +878,7 @@ int R::DumpCode(Node *n) { Printf(stderr, "Writing S code to %s\n", output_filename); #endif - File *scode = NewFile(output_filename, "w"); + File *scode = NewFile(output_filename, "w", SWIG_output_files()); if (!scode) { FileErrorDisplay(output_filename); SWIG_exit(EXIT_FAILURE); @@ -893,7 +893,7 @@ int R::DumpCode(Node *n) { Close(scode); // Delete(scode); String *outfile = Getattr(n,"outfile"); - File *runtime = NewFile(outfile,"w"); + File *runtime = NewFile(outfile,"w", SWIG_output_files()); if (!runtime) { FileErrorDisplay(outfile); SWIG_exit(EXIT_FAILURE); @@ -920,7 +920,7 @@ int R::DumpCode(Node *n) { if(outputNamespaceInfo) { output_filename = NewString(""); Printf(output_filename, "%sNAMESPACE", SWIG_output_directory()); - File *ns = NewFile(output_filename, "w"); + File *ns = NewFile(output_filename, "w", SWIG_output_files()); if (!ns) { FileErrorDisplay(output_filename); SWIG_exit(EXIT_FAILURE); diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx index ad448d34e..8e4aece84 100644 --- a/Source/Modules/ruby.cxx +++ b/Source/Modules/ruby.cxx @@ -992,7 +992,7 @@ public: SWIG_exit(EXIT_FAILURE); } - f_runtime = NewFile(outfile, "w"); + f_runtime = NewFile(outfile, "w", SWIG_output_files()); if (!f_runtime) { FileErrorDisplay(outfile); SWIG_exit(EXIT_FAILURE); @@ -1003,7 +1003,7 @@ public: Printf(stderr, "Unable to determine outfile_h\n"); SWIG_exit(EXIT_FAILURE); } - f_runtime_h = NewFile(outfile_h, "w"); + f_runtime_h = NewFile(outfile_h, "w", SWIG_output_files()); if (!f_runtime_h) { FileErrorDisplay(outfile_h); SWIG_exit(EXIT_FAILURE); diff --git a/Source/Modules/s-exp.cxx b/Source/Modules/s-exp.cxx index b89b3097f..b492a2add 100644 --- a/Source/Modules/s-exp.cxx +++ b/Source/Modules/s-exp.cxx @@ -59,7 +59,7 @@ public: String *outfile = Getattr(n, "outfile"); Replaceall(outfile, "_wrap.cxx", ".lisp"); Replaceall(outfile, "_wrap.c", ".lisp"); - out = NewFile(outfile, "w"); + out = NewFile(outfile, "w", SWIG_output_files()); if (!out) { FileErrorDisplay(outfile); SWIG_exit(EXIT_FAILURE); diff --git a/Source/Modules/swigmod.h b/Source/Modules/swigmod.h index 84817a27d..8ee97bb2c 100644 --- a/Source/Modules/swigmod.h +++ b/Source/Modules/swigmod.h @@ -317,6 +317,9 @@ void SWIG_config_file(const String_or_char *); const String *SWIG_output_directory(); void SWIG_config_cppext(const char *ext); +/* get the list of generated files */ +List *SWIG_output_files(); + void SWIG_library_directory(const char *); int emit_num_arguments(ParmList *); int emit_num_required(ParmList *); diff --git a/Source/Modules/tcl8.cxx b/Source/Modules/tcl8.cxx index 09bd266c3..fe21cb78a 100644 --- a/Source/Modules/tcl8.cxx +++ b/Source/Modules/tcl8.cxx @@ -136,7 +136,7 @@ public: /* Initialize all of the output files */ String *outfile = Getattr(n, "outfile"); - f_runtime = NewFile(outfile, "w"); + f_runtime = NewFile(outfile, "w", SWIG_output_files()); if (!f_runtime) { FileErrorDisplay(outfile); SWIG_exit(EXIT_FAILURE); @@ -177,7 +177,7 @@ public: Insert(module, 0, "_"); - if ((f_shadow = NewFile(filen, "w")) == 0) { + if ((f_shadow = NewFile(filen, "w", SWIG_output_files())) == 0) { FileErrorDisplay(filen); SWIG_exit(EXIT_FAILURE); } diff --git a/Source/Modules/uffi.cxx b/Source/Modules/uffi.cxx index 5d4affb8c..84155cf2a 100644 --- a/Source/Modules/uffi.cxx +++ b/Source/Modules/uffi.cxx @@ -229,7 +229,7 @@ int UFFI::top(Node *n) { Printf(output_filename, "%s%s.cl", SWIG_output_directory(), module); - f_cl = NewFile(output_filename, "w"); + f_cl = NewFile(output_filename, "w", SWIG_output_files()); if (!f_cl) { FileErrorDisplay(output_filename); SWIG_exit(EXIT_FAILURE); diff --git a/Source/Modules/xml.cxx b/Source/Modules/xml.cxx index c74b48d7c..2edd01cf0 100644 --- a/Source/Modules/xml.cxx +++ b/Source/Modules/xml.cxx @@ -47,7 +47,7 @@ public: iX++; Swig_mark_arg(iX); String *outfile = NewString(argv[iX]); - out = NewFile(outfile, "w"); + out = NewFile(outfile, "w", SWIG_output_files()); if (!out) { FileErrorDisplay(outfile); SWIG_exit(EXIT_FAILURE); @@ -82,7 +82,7 @@ public: Replaceall(outfile, ".cxx", ".xml"); Replaceall(outfile, ".cpp", ".xml"); Replaceall(outfile, ".c", ".xml"); - out = NewFile(outfile, "w"); + out = NewFile(outfile, "w", SWIG_output_files()); if (!out) { FileErrorDisplay(outfile); SWIG_exit(EXIT_FAILURE); @@ -301,7 +301,7 @@ void Swig_print_xml(DOH *obj, String *filename) { if (!filename) { out = stdout; } else { - out = NewFile(filename, "w"); + out = NewFile(filename, "w", SWIG_output_files()); if (!out) { FileErrorDisplay(filename); SWIG_exit(EXIT_FAILURE); From d63f23bb84160ba2c5e77add2d97c8f140f9d687 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 3 Nov 2008 13:32:33 +0000 Subject: [PATCH 0144/1680] update this README git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10899 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/README | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/Source/README b/Source/README index 8d910e405..814ec45bd 100644 --- a/Source/README +++ b/Source/README @@ -1,9 +1,5 @@ SWIG Source directory -This directory currently contains a mix of legacy SWIG1.1 code and -recent development work. As a result, it's still a little messy. -Here is a rough breakdown of the directories: - Source/DOH - A core set of basic datatypes including strings, lists, hashes, and files. Used extensively by the rest of SWIG. @@ -16,8 +12,9 @@ Here is a rough breakdown of the directories: Source/Modules - Language modules. + Source/Include - Include files. -The following directories may be in CVS, but are largely deprecated: +Historic directories which may be in CVS, but have been removed: Source/Modules1.1 - Old SWIG-1.1 modules. Empty. @@ -26,5 +23,3 @@ The following directories may be in CVS, but are largely deprecated: Source/SWIG1.1 - Old SWIG1.1 core. Completely empty now. - - From 482d91951a09969d371ec7b5aa3ec65dd9fbccdb Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 3 Nov 2008 13:37:28 +0000 Subject: [PATCH 0145/1680] Import ccache-2.4 source git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10900 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CCache/.cvsignore | 8 + CCache/COPYING | 339 +++ CCache/Makefile.in | 53 + CCache/README | 31 + CCache/args.c | 91 + CCache/ccache.1 | 396 +++ CCache/ccache.c | 1034 +++++++ CCache/ccache.h | 159 ++ CCache/ccache.yo | 352 +++ CCache/cleanup.c | 193 ++ CCache/config.h.in | 100 + CCache/configure | 4896 ++++++++++++++++++++++++++++++++++ CCache/configure.in | 72 + CCache/execute.c | 129 + CCache/hash.c | 80 + CCache/install-sh | 238 ++ CCache/mdfour.c | 284 ++ CCache/mdfour.h | 36 + CCache/packaging/README | 5 + CCache/packaging/ccache.spec | 37 + CCache/snprintf.c | 962 +++++++ CCache/stats.c | 354 +++ CCache/test.sh | 287 ++ CCache/unify.c | 269 ++ CCache/util.c | 454 ++++ CCache/web/ccache-man.html | 318 +++ CCache/web/index.html | 158 ++ 27 files changed, 11335 insertions(+) create mode 100644 CCache/.cvsignore create mode 100644 CCache/COPYING create mode 100644 CCache/Makefile.in create mode 100644 CCache/README create mode 100644 CCache/args.c create mode 100644 CCache/ccache.1 create mode 100644 CCache/ccache.c create mode 100644 CCache/ccache.h create mode 100644 CCache/ccache.yo create mode 100644 CCache/cleanup.c create mode 100644 CCache/config.h.in create mode 100755 CCache/configure create mode 100644 CCache/configure.in create mode 100644 CCache/execute.c create mode 100644 CCache/hash.c create mode 100755 CCache/install-sh create mode 100644 CCache/mdfour.c create mode 100644 CCache/mdfour.h create mode 100644 CCache/packaging/README create mode 100644 CCache/packaging/ccache.spec create mode 100644 CCache/snprintf.c create mode 100644 CCache/stats.c create mode 100755 CCache/test.sh create mode 100644 CCache/unify.c create mode 100644 CCache/util.c create mode 100644 CCache/web/ccache-man.html create mode 100644 CCache/web/index.html diff --git a/CCache/.cvsignore b/CCache/.cvsignore new file mode 100644 index 000000000..2758f56bc --- /dev/null +++ b/CCache/.cvsignore @@ -0,0 +1,8 @@ +Makefile +ccache +*gz +config.h +config.log +config.status +tca.log +tca.map diff --git a/CCache/COPYING b/CCache/COPYING new file mode 100644 index 000000000..a43ea2126 --- /dev/null +++ b/CCache/COPYING @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 675 Mass Ave, Cambridge, MA 02139, USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + Appendix: How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) 19yy + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) 19yy name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/CCache/Makefile.in b/CCache/Makefile.in new file mode 100644 index 000000000..0bf3eb99d --- /dev/null +++ b/CCache/Makefile.in @@ -0,0 +1,53 @@ +srcdir=@srcdir@ +VPATH=@srcdir@ + +prefix=@prefix@ +exec_prefix=@exec_prefix@ +bindir=@bindir@ +mandir=@mandir@ +INSTALLCMD=@INSTALL@ + +CC=@CC@ +CFLAGS=@CFLAGS@ -I. +EXEEXT=@EXEEXT@ + +OBJS= ccache.o mdfour.o hash.o execute.o util.o args.o stats.o \ + cleanup.o snprintf.o unify.o +HEADERS = ccache.h mdfour.h + +all: ccache$(EXEEXT) + +docs: ccache.1 web/ccache-man.html + +ccache$(EXEEXT): $(OBJS) $(HEADERS) + $(CC) $(CFLAGS) -o $@ $(OBJS) + +ccache.1: ccache.yo + -yodl2man -o ccache.1 ccache.yo + +web/ccache-man.html: ccache.yo + mkdir -p man + yodl2html -o web/ccache-man.html ccache.yo + +install: ccache$(EXEEXT) ccache.1 + ${INSTALLCMD} -d $(DESTDIR)${bindir} + ${INSTALLCMD} -m 755 ccache$(EXEEXT) $(DESTDIR)${bindir} + ${INSTALLCMD} -d $(DESTDIR)${mandir}/man1 + ${INSTALLCMD} -m 644 ${srcdir}/ccache.1 $(DESTDIR)${mandir}/man1/ + +clean: + /bin/rm -f $(OBJS) *~ ccache$(EXEEXT) + +test: test.sh + CC='$(CC)' ./test.sh + +check: test + +distclean: clean + /bin/rm -f Makefile config.h config.sub config.log build-stamp config.status + +# FIXME: To fix this, test.sh needs to be able to take ccache from the +# installed prefix, not from the source dir. +installcheck: + @echo "WARNING! This is not really \"installcheck\" yet." + $(MAKE) check diff --git a/CCache/README b/CCache/README new file mode 100644 index 000000000..6e68a6eb0 --- /dev/null +++ b/CCache/README @@ -0,0 +1,31 @@ +This is a re-implementation of "compilercache" in C + +The original compilercache scripts were by Erik Thiele +(erikyyy@erikyyy.de) and I would like to thank him for an excellent +piece of work. See http://www.erikyyy.de/compilercache/ for the +original shell scripts. + +I wrote ccache because I wanted to get a bit more speed out of a +compiler cache and I wanted to remove some of the limitations of the +shell-script version. + +Please see the manual page and documentation at +http://ccache.samba.org/ + +INSTALLATION +------------ + +Please run: + + ./configure + make + make install + +then read the ccache manual page + +----------- + +Andrew Tridgell +http://samba.org/~tridge/ +bugs@ccache.samba.org + diff --git a/CCache/args.c b/CCache/args.c new file mode 100644 index 000000000..31e5471c1 --- /dev/null +++ b/CCache/args.c @@ -0,0 +1,91 @@ +/* + convenient routines for argument list handling + + Copyright (C) Andrew Tridgell 2002 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "ccache.h" + +ARGS *args_init(int init_argc, char **init_args) +{ + ARGS *args; + int i; + args = (ARGS *)x_malloc(sizeof(ARGS)); + args->argc = 0; + args->argv = (char **)x_malloc(sizeof(char *)); + args->argv[0] = NULL; + for (i=0;iargv = (char**)x_realloc(args->argv, (args->argc + 2) * sizeof(char *)); + args->argv[args->argc] = x_strdup(s); + args->argc++; + args->argv[args->argc] = NULL; +} + +/* pop the last element off the args list */ +void args_pop(ARGS *args, int n) +{ + while (n--) { + args->argc--; + free(args->argv[args->argc]); + args->argv[args->argc] = NULL; + } +} + +/* remove the first element of the argument list */ +void args_remove_first(ARGS *args) +{ + free(args->argv[0]); + memmove(&args->argv[0], + &args->argv[1], + args->argc * sizeof(args->argv[0])); + args->argc--; +} + +/* add an argument into the front of the argument list */ +void args_add_prefix(ARGS *args, const char *s) +{ + args->argv = (char**)x_realloc(args->argv, (args->argc + 2) * sizeof(char *)); + memmove(&args->argv[1], &args->argv[0], + (args->argc+1) * sizeof(args->argv[0])); + args->argv[0] = x_strdup(s); + args->argc++; +} + +/* strip any arguments beginning with the specified prefix */ +void args_strip(ARGS *args, const char *prefix) +{ + int i; + for (i=0; iargc; ) { + if (strncmp(args->argv[i], prefix, strlen(prefix)) == 0) { + free(args->argv[i]); + memmove(&args->argv[i], + &args->argv[i+1], + args->argc * sizeof(args->argv[i])); + args->argc--; + } else { + i++; + } + } +} diff --git a/CCache/ccache.1 b/CCache/ccache.1 new file mode 100644 index 000000000..daec8ee1e --- /dev/null +++ b/CCache/ccache.1 @@ -0,0 +1,396 @@ +.TH "ccache" "1" "April 2002" "" "" +.SH "NAME" +ccache \- a fast compiler cache +.SH "SYNOPSIS" +.PP +ccache [OPTION] +.PP +ccache [COMPILER OPTIONS] +.PP + [COMPILER OPTIONS] +.PP +.SH "DESCRIPTION" +.PP +ccache is a compiler cache\&. It speeds up re-compilation of C/C++ code +by caching previous compiles and detecting when the same compile is +being done again\&. +.PP +.SH "OPTIONS SUMMARY" +.PP +Here is a summary of the options to ccache\&. +.PP + +.nf + + +-s show statistics summary +-z zero statistics +-c run a cache cleanup +-C clear the cache completely +-F set maximum files in cache +-M set maximum size of cache (use G, M or K) +-h this help page +-V print version number + +.fi + + +.PP +.SH "OPTIONS" +.PP +These options only apply when you invoke ccache as "ccache"\&. When +invoked as a compiler none of these options apply\&. In that case your +normal compiler options apply and you should refer to your compilers +documentation\&. +.PP +.IP "\fB-h\fP" +Print a options summary page +.IP +.IP "\fB-s\fP" +Print the current statistics summary for the cache\&. The +statistics are stored spread across the subdirectories of the +cache\&. Using "ccache -s" adds up the statistics across all +subdirectories and prints the totals\&. +.IP +.IP "\fB-z\fP" +Zero the cache statistics\&. +.IP +.IP "\fB-V\fP" +Print the ccache version number +.IP +.IP "\fB-c\fP" +Clean the cache and re-calculate the cache file count and +size totals\&. Normally the -c option should not be necessary as ccache +keeps the cache below the specified limits at runtime and keeps +statistics up to date on each compile\&. This option is mostly useful +if you manually modify the cache contents or believe that the cache +size statistics may be inaccurate\&. +.IP +.IP "\fB-C\fP" +Clear the entire cache, removing all cached files\&. +.IP +.IP "\fB-F maxfiles\fP" +This sets the maximum number of files allowed in +the cache\&. The value is stored inside the cache directory and applies +to all future compiles\&. Due to the way the value is stored the actual +value used is always rounded down to the nearest multiple of 16\&. +.IP +.IP "\fB-M maxsize\fP" +This sets the maximum cache size\&. You can specify +a value in gigabytes, megabytes or kilobytes by appending a G, M or K +to the value\&. The default is gigabytes\&. The actual value stored is +rounded down to the nearest multiple of 16 kilobytes\&. +.IP +.PP +.SH "INSTALLATION" +.PP +There are two ways to use ccache\&. You can either prefix your compile +commands with "ccache" or you can create a symbolic link between +ccache and the names of your compilers\&. The first method is most +convenient if you just want to try out ccache or wish to use it for +some specific projects\&. The second method is most useful for when you +wish to use ccache for all your compiles\&. +.PP +To install for usage by the first method just copy ccache to somewhere +in your path\&. +.PP +To install for the second method do something like this: + +.nf + + + cp ccache /usr/local/bin/ + ln -s /usr/local/bin/ccache /usr/local/bin/gcc + ln -s /usr/local/bin/ccache /usr/local/bin/g++ + ln -s /usr/local/bin/ccache /usr/local/bin/cc + +.fi + + +This will work as long as /usr/local/bin comes before the path to gcc +(which is usually in /usr/bin)\&. After installing you may wish to run +"which gcc" to make sure that the correct link is being used\&. +.PP +Note! Do not use a hard link, use a symbolic link\&. A hardlink will +cause "interesting" problems\&. +.PP +.SH "EXTRA OPTIONS" +.PP +When run as a compiler front end ccache usually just takes the same +command line options as the compiler you are using\&. The only exception +to this is the option \&'--ccache-skip\&'\&. That option can be used to tell +ccache that the next option is definitely not a input filename, and +should be passed along to the compiler as-is\&. +.PP +The reason this can be important is that ccache does need to parse the +command line and determine what is an input filename and what is a +compiler option, as it needs the input filename to determine the name +of the resulting object file (among other things)\&. The heuristic +ccache uses in this parse is that any string on the command line that +exists as a file is treated as an input file name (usually a C +file)\&. By using --ccache-skip you can force an option to not be +treated as an input file name and instead be passed along to the +compiler as a command line option\&. +.PP +.SH "ENVIRONMENT VARIABLES" +.PP +ccache uses a number of environment variables to control operation\&. In +most cases you won\&'t need any of these as the defaults will be fine\&. +.PP +.IP +.IP "\fBCCACHE_DIR\fP" +the CCACHE_DIR environment variable specifies +where ccache will keep its cached compiler output\&. The default is +"$HOME/\&.ccache"\&. +.IP +.IP "\fBCCACHE_TEMPDIR\fP" +the CCACHE_TEMPDIR environment variable specifies +where ccache will put temporary files\&. The default is the same as +CCACHE_DIR\&. Note that the CCACHE_TEMPDIR path must be on the same +filesystem as the CCACHE_DIR path, so that renames of files between +the two directories can work\&. +.IP +.IP "\fBCCACHE_LOGFILE\fP" +If you set the CCACHE_LOGFILE environment +variable then ccache will write some log information on cache hits +and misses in that file\&. This is useful for tracking down problems\&. +.IP +.IP "\fBCCACHE_PATH\fP" +You can optionally set CCACHE_PATH to a colon +separated path where ccache will look for the real compilers\&. If you +don\&'t do this then ccache will look for the first executable matching +the compiler name in the normal PATH that isn\&'t a symbolic link to +ccache itself\&. +.IP +.IP "\fBCCACHE_CC\fP" +You can optionally set CCACHE_CC to force the name +of the compiler to use\&. If you don\&'t do this then ccache works it out +from the command line\&. +.IP +.IP "\fBCCACHE_PREFIX\fP" +This option adds a prefix to the command line +that ccache runs when invoking the compiler\&. Also see the section +below on using ccache with distcc\&. +.IP +.IP "\fBCCACHE_DISABLE\fP" +If you set the environment variable +CCACHE_DISABLE then ccache will just call the real compiler, +bypassing the cache completely\&. +.IP +.IP "\fBCCACHE_READONLY\fP" +the CCACHE_READONLY environment variable +tells ccache to attempt to use existing cached object files, but not +to try to add anything new to the cache\&. If you are using this because +your CCACHE_DIR is read-only, then you may find that you also need to +set CCACHE_TEMPDIR as otherwise ccache will fail to create the +temporary files\&. +.IP +.IP "\fBCCACHE_CPP2\fP" +If you set the environment variable CCACHE_CPP2 +then ccache will not use the optimisation of avoiding the 2nd call to +the pre-processor by compiling the pre-processed output that was used +for finding the hash in the case of a cache miss\&. This is primarily a +debugging option, although it is possible that some unusual compilers +will have problems with the intermediate filename extensions used in +this optimisation, in which case this option could allow ccache to be +used\&. +.IP +.IP "\fBCCACHE_NOSTATS\fP" +If you set the environment variable +CCACHE_NOSTATS then ccache will not update the statistics files on +each compile\&. +.IP +.IP "\fBCCACHE_NLEVELS\fP" +The environment variable CCACHE_NLEVELS allows +you to choose the number of levels of hash in the cache directory\&. The +default is 2\&. The minimum is 1 and the maximum is 8\&. +.IP +.IP "\fBCCACHE_HARDLINK\fP" +If you set the environment variable +CCACHE_HARDLINK then ccache will attempt to use hard links from the +cache directory when creating the compiler output rather than using a +file copy\&. Using hard links is faster, but can confuse programs like +\&'make\&' that rely on modification times\&. +.IP +.IP "\fBCCACHE_RECACHE\fP" +This forces ccache to not use any cached +results, even if it finds them\&. New results are still cached, but +existing cache entries are ignored\&. +.IP +.IP "\fBCCACHE_UMASK\fP" +This sets the umask for ccache and all child +processes (such as the compiler)\&. This is mostly useful when you wish +to share your cache with other users\&. Note that this also affects the +file permissions set on the object files created from your +compilations\&. +.IP +.IP "\fBCCACHE_HASHDIR\fP" +This tells ccache to hash the current working +directory when calculating the hash that is used to distinguish two +compiles\&. This prevents a problem with the storage of the current +working directory in the debug info of a object file, which can lead +ccache to give a cached object file that has the working directory in +the debug info set incorrectly\&. This option is off by default as the +incorrect setting of this debug info rarely causes problems\&. If you +strike problems with gdb not using the correct directory then enable +this option\&. +.IP +.IP "\fBCCACHE_UNIFY\fP" +If you set the environment variable CCACHE_UNIFY +then ccache will use the C/C++ unifier when hashing the pre-processor +output if -g is not used in the compile\&. The unifier is slower than a +normal hash, so setting this environment variable loses a little bit +of speed, but it means that ccache can take advantage of not +recompiling when the changes to the source code consist of +reformatting only\&. Note that using CCACHE_UNIFY changes the hash, so +cached compiles with CCACHE_UNIFY set cannot be used when +CCACHE_UNIFY is not set and vice versa\&. The reason the unifier is off +by default is that it can give incorrect line number information in +compiler warning messages\&. +.IP +.IP "\fBCCACHE_EXTENSION\fP" +Normally ccache tries to automatically +determine the extension to use for intermediate C pre-processor files +based on the type of file being compiled\&. Unfortunately this sometimes +doesn\&'t work, for example when using the aCC compiler on HP-UX\&. On +systems like this you can use the CCACHE_EXTENSION option to override +the default\&. On HP-UX set this environment variable to "i" if you use +the aCC compiler\&. +.IP +.PP +.SH "CACHE SIZE MANAGEMENT" +.PP +By default ccache has a one gigabyte limit on the cache size and no +maximum number of files\&. You can set a different limit using the +"ccache -M" and "ccache -F" options, which set the size and number of +files limits\&. +.PP +When these limits are reached ccache will reduce the cache to 20% +below the numbers you specified in order to avoid doing the cache +clean operation too often\&. +.PP +.SH "HOW IT WORKS" +.PP +The basic idea is to detect when you are compiling exactly the same +code a 2nd time and use the previously compiled output\&. You detect +that it is the same code by forming a hash of: +.PP +.IP o +the pre-processor output from running the compiler with -E +.IP o +the command line options +.IP o +the real compilers size and modification time +.IP o +any stderr output generated by the compiler +.PP +These are hashed using md4 (a strong hash) and a cache file is formed +based on that hash result\&. When the same compilation is done a second +time ccache is able to supply the correct compiler output (including +all warnings etc) from the cache\&. +.PP +ccache has been carefully written to always produce exactly the same +compiler output that you would get without the cache\&. If you ever +discover a case where ccache changes the output of your compiler then +please let me know\&. +.PP +.SH "USING CCACHE WITH DISTCC" +.PP +distcc is a very useful program for distributing compilation across a +range of compiler servers\&. It is often useful to combine distcc with +ccache, so that compiles that are done are sped up by distcc, but that +ccache avoids the compile completely where possible\&. +.PP +To use distcc with ccache I recommend using the CCACHE_PREFIX +option\&. You just need to set the environment variable CCACHE_PREFIX to +\&'distcc\&' and ccache will prefix the command line used with the +compiler with the command \&'distcc\&'\&. +.PP +.SH "SHARING A CACHE" +.PP +A group of developers can increase the cache hit rate by sharing a +cache directory\&. The hard links however cause unwanted side effects, +as all links to a cached file share the file\&'s modification timestamp\&. +This results in false dependencies to be triggered by timestamp-based +build systems whenever another user links to an existing +file\&. Typically, users will see that their libraries and binaries are +relinked without reason\&. To share a cache without side effects, the +following conditions need to be met: +.PP +.IP o +Use the same \fBCCACHE_DIR\fP environment variable setting +.IP o +Set the \fBCCACHE_NOLINK\fP environment variable +.IP o +Make sure everyone sets the CCACHE_UMASK environment variable +to 002, this ensures that cached files are accessible to everyone in +the group\&. +.IP o +Make sure that all users have write permission in the entire +cache directory (and that you trust all users of the shared cache)\&. +.IP o +Make sure that the setgid bit is set on all directories in the +cache\&. This tells the filesystem to inherit group ownership for new +directories\&. The command "chmod g+s `find $CCACHE_DIR -type d`" might +be useful for this\&. +.PP +.SH "HISTORY" +.PP +ccache was inspired by the compilercache shell script script written +by Erik Thiele and I would like to thank him for an excellent piece of +work\&. See +http://www\&.erikyyy\&.de/compilercache/ +for the Erik\&'s scripts\&. +.PP +I wrote ccache because I wanted to get a bit more speed out of a +compiler cache and I wanted to remove some of the limitations of the +shell-script version\&. +.PP +.SH "DIFFERENCES FROM COMPILERCACHE" +.PP +The biggest differences between Erik\&'s compilercache script and ccache +are: +.IP o +ccache is written in C, which makes it a bit faster (calling out to +external programs is mostly what slowed down the scripts)\&. +.IP o +ccache can automatically find the real compiler +.IP o +ccache keeps statistics on hits/misses +.IP o +ccache can do automatic cache management +.IP o +ccache can cache compiler output that includes warnings\&. In many +cases this gives ccache a much higher cache hit rate\&. +.IP o +ccache can handle a much wider ranger of compiler options +.IP o +ccache avoids a double call to cpp on a cache miss +.PP +.SH "BUGS" +.PP +When the cache is stored on an NFS filesystem, the filesystem must be +exported with the \fBno_subtree_check\fP option to make renames between +directories reliable\&. +.PP +.SH "CREDITS" +.PP +Thanks to the following people for their contributions to ccache +.IP o +Erik Thiele for the original compilercache script +.IP o +Luciano Rocha for the idea of compiling the pre-processor output +to avoid a 2nd cpp pass +.IP o +Paul Russell for many suggestions and the debian packaging +.PP +.SH "AUTHOR" +.PP +ccache was written by Andrew Tridgell +http://samba\&.org/~tridge/ +.PP +If you wish to report a problem or make a suggestion then please email +bugs@ccache\&.samba\&.org +.PP +ccache is released under the GNU General Public License version 2 or +later\&. Please see the file COPYING for license details\&. diff --git a/CCache/ccache.c b/CCache/ccache.c new file mode 100644 index 000000000..c15ced54f --- /dev/null +++ b/CCache/ccache.c @@ -0,0 +1,1034 @@ +/* + a re-implementation of the compilercache scripts in C + + The idea is based on the shell-script compilercache by Erik Thiele + + Copyright (C) Andrew Tridgell 2002 + Copyright (C) Martin Pool 2003 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "ccache.h" + +/* the base cache directory */ +char *cache_dir = NULL; + +/* the directory for temporary files */ +static char *temp_dir = NULL; + +/* the debug logfile name, if set */ +char *cache_logfile = NULL; + +/* the argument list after processing */ +static ARGS *stripped_args; + +/* the original argument list */ +static ARGS *orig_args; + +/* the output filename being compiled to */ +static char *output_file; + +/* the source file */ +static char *input_file; + +/* the name of the file containing the cached object code */ +static char *hashname; + +/* the extension of the file after pre-processing */ +static const char *i_extension; + +/* the name of the temporary pre-processor file */ +static char *i_tmpfile; + +/* are we compiling a .i or .ii file directly? */ +static int direct_i_file; + +/* the name of the cpp stderr file */ +static char *cpp_stderr; + +/* the name of the statistics file */ +char *stats_file = NULL; + +/* can we safely use the unification hashing backend? */ +static int enable_unify; + +/* a list of supported file extensions, and the equivalent + extension for code that has been through the pre-processor +*/ +static struct { + char *extension; + char *i_extension; +} extensions[] = { + {"c", "i"}, + {"C", "ii"}, + {"m", "mi"}, + {"cc", "ii"}, + {"CC", "ii"}, + {"cpp", "ii"}, + {"CPP", "ii"}, + {"cxx", "ii"}, + {"CXX", "ii"}, + {"c++", "ii"}, + {"C++", "ii"}, + {"i", "i"}, + {"ii", "ii"}, + {NULL, NULL}}; + +/* + something went badly wrong - just execute the real compiler +*/ +static void failed(void) +{ + char *e; + + /* delete intermediate pre-processor file if needed */ + if (i_tmpfile) { + if (!direct_i_file) { + unlink(i_tmpfile); + } + free(i_tmpfile); + i_tmpfile = NULL; + } + + /* delete the cpp stderr file if necessary */ + if (cpp_stderr) { + unlink(cpp_stderr); + free(cpp_stderr); + cpp_stderr = NULL; + } + + /* strip any local args */ + args_strip(orig_args, "--ccache-"); + + if ((e=getenv("CCACHE_PREFIX"))) { + char *p = find_executable(e, MYNAME); + if (!p) { + perror(e); + exit(1); + } + args_add_prefix(orig_args, p); + } + + execv(orig_args->argv[0], orig_args->argv); + cc_log("execv returned (%s)!\n", strerror(errno)); + perror(orig_args->argv[0]); + exit(1); +} + + +/* return a string to be used to distinguish temporary files + this also tries to cope with NFS by adding the local hostname +*/ +static const char *tmp_string(void) +{ + static char *ret; + + if (!ret) { + char hostname[200]; + strcpy(hostname, "unknown"); +#if HAVE_GETHOSTNAME + gethostname(hostname, sizeof(hostname)-1); +#endif + hostname[sizeof(hostname)-1] = 0; + asprintf(&ret, "%s.%u", hostname, (unsigned)getpid()); + } + + return ret; +} + + +/* run the real compiler and put the result in cache */ +static void to_cache(ARGS *args) +{ + char *path_stderr; + char *tmp_stdout, *tmp_stderr, *tmp_hashname; + struct stat st1, st2; + int status; + + x_asprintf(&tmp_stdout, "%s/tmp.stdout.%s", temp_dir, tmp_string()); + x_asprintf(&tmp_stderr, "%s/tmp.stderr.%s", temp_dir, tmp_string()); + x_asprintf(&tmp_hashname, "%s/tmp.hash.%s.o", temp_dir, tmp_string()); + + args_add(args, "-o"); + args_add(args, tmp_hashname); + + /* Turn off DEPENDENCIES_OUTPUT when running cc1, because + * otherwise it will emit a line like + * + * tmp.stdout.vexed.732.o: /home/mbp/.ccache/tmp.stdout.vexed.732.i + * + * unsetenv() is on BSD and Linux but not portable. */ + putenv("DEPENDENCIES_OUTPUT"); + + if (getenv("CCACHE_CPP2")) { + args_add(args, input_file); + } else { + args_add(args, i_tmpfile); + } + status = execute(args->argv, tmp_stdout, tmp_stderr); + args_pop(args, 3); + + if (stat(tmp_stdout, &st1) != 0 || st1.st_size != 0) { + cc_log("compiler produced stdout for %s\n", output_file); + stats_update(STATS_STDOUT); + unlink(tmp_stdout); + unlink(tmp_stderr); + unlink(tmp_hashname); + failed(); + } + unlink(tmp_stdout); + + if (status != 0) { + int fd; + cc_log("compile of %s gave status = %d\n", output_file, status); + stats_update(STATS_STATUS); + + fd = open(tmp_stderr, O_RDONLY | O_BINARY); + if (fd != -1) { + if (strcmp(output_file, "/dev/null") == 0 || + rename(tmp_hashname, output_file) == 0 || errno == ENOENT) { + if (cpp_stderr) { + /* we might have some stderr from cpp */ + int fd2 = open(cpp_stderr, O_RDONLY | O_BINARY); + if (fd2 != -1) { + copy_fd(fd2, 2); + close(fd2); + unlink(cpp_stderr); + cpp_stderr = NULL; + } + } + + /* we can use a quick method of + getting the failed output */ + copy_fd(fd, 2); + close(fd); + unlink(tmp_stderr); + if (i_tmpfile && !direct_i_file) { + unlink(i_tmpfile); + } + exit(status); + } + } + + unlink(tmp_stderr); + unlink(tmp_hashname); + failed(); + } + + x_asprintf(&path_stderr, "%s.stderr", hashname); + + if (stat(tmp_stderr, &st1) != 0 || + stat(tmp_hashname, &st2) != 0 || + rename(tmp_hashname, hashname) != 0 || + rename(tmp_stderr, path_stderr) != 0) { + cc_log("failed to rename tmp files - %s\n", strerror(errno)); + stats_update(STATS_ERROR); + failed(); + } + + cc_log("Placed %s into cache\n", output_file); + stats_tocache(file_size(&st1) + file_size(&st2)); + + free(tmp_hashname); + free(tmp_stderr); + free(tmp_stdout); + free(path_stderr); +} + +/* find the hash for a command. The hash includes all argument lists, + plus the output from running the compiler with -E */ +static void find_hash(ARGS *args) +{ + int i; + char *path_stdout, *path_stderr; + char *hash_dir; + char *s; + struct stat st; + int status; + int nlevels = 2; + char *input_base; + char *tmp; + + if ((s = getenv("CCACHE_NLEVELS"))) { + nlevels = atoi(s); + if (nlevels < 1) nlevels = 1; + if (nlevels > 8) nlevels = 8; + } + + hash_start(); + + /* when we are doing the unifying tricks we need to include + the input file name in the hash to get the warnings right */ + if (enable_unify) { + hash_string(input_file); + } + + /* we have to hash the extension, as a .i file isn't treated the same + by the compiler as a .ii file */ + hash_string(i_extension); + + /* first the arguments */ + for (i=1;iargc;i++) { + /* some arguments don't contribute to the hash. The + theory is that these arguments will change the + output of -E if they are going to have any effect + at all, or they only affect linking */ + if (i < args->argc-1) { + if (strcmp(args->argv[i], "-I") == 0 || + strcmp(args->argv[i], "-include") == 0 || + strcmp(args->argv[i], "-L") == 0 || + strcmp(args->argv[i], "-D") == 0 || + strcmp(args->argv[i], "-idirafter") == 0 || + strcmp(args->argv[i], "-isystem") == 0) { + i++; + continue; + } + } + if (strncmp(args->argv[i], "-I", 2) == 0 || + strncmp(args->argv[i], "-L", 2) == 0 || + strncmp(args->argv[i], "-D", 2) == 0 || + strncmp(args->argv[i], "-idirafter", 10) == 0 || + strncmp(args->argv[i], "-isystem", 8) == 0) { + continue; + } + + if (strncmp(args->argv[i], "--specs=", 8) == 0 && + stat(args->argv[i]+8, &st) == 0) { + /* if given a explicit specs file, then hash that file, but + don't include the path to it in the hash */ + hash_file(args->argv[i]+8); + continue; + } + + /* all other arguments are included in the hash */ + hash_string(args->argv[i]); + } + + /* the compiler driver size and date. This is a simple minded way + to try and detect compiler upgrades. It is not 100% reliable */ + if (stat(args->argv[0], &st) != 0) { + cc_log("Couldn't stat the compiler!? (argv[0]='%s')\n", args->argv[0]); + stats_update(STATS_COMPILER); + failed(); + } + + /* also include the hash of the compiler name - as some compilers + use hard links and behave differently depending on the real name */ + if (st.st_nlink > 1) { + hash_string(str_basename(args->argv[0])); + } + + hash_int(st.st_size); + hash_int(st.st_mtime); + + /* possibly hash the current working directory */ + if (getenv("CCACHE_HASHDIR")) { + char *cwd = gnu_getcwd(); + if (cwd) { + hash_string(cwd); + free(cwd); + } + } + + /* ~/hello.c -> tmp.hello.123.i + limit the basename to 10 + characters in order to cope with filesystem with small + maximum filename length limits */ + input_base = str_basename(input_file); + tmp = strchr(input_base, '.'); + if (tmp != NULL) { + *tmp = 0; + } + if (strlen(input_base) > 10) { + input_base[10] = 0; + } + + /* now the run */ + x_asprintf(&path_stdout, "%s/%s.tmp.%s.%s", temp_dir, + input_base, tmp_string(), + i_extension); + x_asprintf(&path_stderr, "%s/tmp.cpp_stderr.%s", temp_dir, tmp_string()); + + if (!direct_i_file) { + /* run cpp on the input file to obtain the .i */ + args_add(args, "-E"); + args_add(args, input_file); + status = execute(args->argv, path_stdout, path_stderr); + args_pop(args, 2); + } else { + /* we are compiling a .i or .ii file - that means we + can skip the cpp stage and directly form the + correct i_tmpfile */ + path_stdout = input_file; + if (create_empty_file(path_stderr) != 0) { + stats_update(STATS_ERROR); + cc_log("failed to create empty stderr file\n"); + failed(); + } + status = 0; + } + + if (status != 0) { + if (!direct_i_file) { + unlink(path_stdout); + } + unlink(path_stderr); + cc_log("the preprocessor gave %d\n", status); + stats_update(STATS_PREPROCESSOR); + failed(); + } + + /* if the compilation is with -g then we have to include the whole of the + preprocessor output, which means we are sensitive to line number + information. Otherwise we can discard line number info, which makes + us less sensitive to reformatting changes + + Note! I have now disabled the unification code by default + as it gives the wrong line numbers for warnings. Pity. + */ + if (!enable_unify) { + hash_file(path_stdout); + } else { + if (unify_hash(path_stdout) != 0) { + stats_update(STATS_ERROR); + failed(); + } + } + hash_file(path_stderr); + + i_tmpfile = path_stdout; + + if (!getenv("CCACHE_CPP2")) { + /* if we are using the CPP trick then we need to remember this stderr + data and output it just before the main stderr from the compiler + pass */ + cpp_stderr = path_stderr; + } else { + unlink(path_stderr); + free(path_stderr); + } + + /* we use a N level subdir for the cache path to reduce the impact + on filesystems which are slow for large directories + */ + s = hash_result(); + x_asprintf(&hash_dir, "%s/%c", cache_dir, s[0]); + x_asprintf(&stats_file, "%s/stats", hash_dir); + for (i=1; i %s (%s)\n", + hashname, output_file, strerror(errno)); + stats_update(STATS_ERROR); + failed(); + } + } + if (ret == 0) { + /* update the mtime on the file so that make doesn't get confused */ + utime(output_file, NULL); + } + + /* get rid of the intermediate preprocessor file */ + if (i_tmpfile) { + if (!direct_i_file) { + unlink(i_tmpfile); + } + free(i_tmpfile); + i_tmpfile = NULL; + } + + /* send the cpp stderr, if applicable */ + fd_cpp_stderr = open(cpp_stderr, O_RDONLY | O_BINARY); + if (fd_cpp_stderr != -1) { + copy_fd(fd_cpp_stderr, 2); + close(fd_cpp_stderr); + unlink(cpp_stderr); + free(cpp_stderr); + cpp_stderr = NULL; + } + + /* send the stderr */ + copy_fd(fd_stderr, 2); + close(fd_stderr); + + /* and exit with the right status code */ + if (first) { + cc_log("got cached result for %s\n", output_file); + stats_update(STATS_CACHED); + } + + exit(0); +} + +/* find the real compiler. We just search the PATH to find a executable of the + same name that isn't a link to ourselves */ +static void find_compiler(int argc, char **argv) +{ + char *base; + char *path; + + orig_args = args_init(argc, argv); + + base = str_basename(argv[0]); + + /* we might be being invoked like "ccache gcc -c foo.c" */ + if (strcmp(base, MYNAME) == 0) { + args_remove_first(orig_args); + free(base); + if (strchr(argv[1],'/')) { + /* a full path was given */ + return; + } + base = str_basename(argv[1]); + } + + /* support user override of the compiler */ + if ((path=getenv("CCACHE_CC"))) { + base = strdup(path); + } + + orig_args->argv[0] = find_executable(base, MYNAME); + + /* can't find the compiler! */ + if (!orig_args->argv[0]) { + stats_update(STATS_COMPILER); + perror(base); + exit(1); + } +} + + +/* check a filename for C/C++ extension. Return the pre-processor + extension */ +static const char *check_extension(const char *fname, int *direct_i) +{ + int i; + const char *p; + + if (direct_i) { + *direct_i = 0; + } + + p = strrchr(fname, '.'); + if (!p) return NULL; + p++; + for (i=0; extensions[i].extension; i++) { + if (strcmp(p, extensions[i].extension) == 0) { + if (direct_i && strcmp(p, extensions[i].i_extension) == 0) { + *direct_i = 1; + } + p = getenv("CCACHE_EXTENSION"); + if (p) return p; + return extensions[i].i_extension; + } + } + return NULL; +} + + +/* + process the compiler options to form the correct set of options + for obtaining the preprocessor output +*/ +static void process_args(int argc, char **argv) +{ + int i; + int found_c_opt = 0; + int found_S_opt = 0; + struct stat st; + char *e; + + stripped_args = args_init(0, NULL); + + args_add(stripped_args, argv[0]); + + for (i=1; iargc, orig_args->argv); + + /* run with -E to find the hash */ + find_hash(stripped_args); + + /* if we can return from cache at this point then do */ + from_cache(1); + + if (getenv("CCACHE_READONLY")) { + cc_log("read-only set - doing real compile\n"); + failed(); + } + + /* run real compiler, sending output to cache */ + to_cache(stripped_args); + + /* return from cache */ + from_cache(0); + + /* oh oh! */ + cc_log("secondary from_cache failed!\n"); + stats_update(STATS_ERROR); + failed(); +} + + +static void usage(void) +{ + printf("ccache, a compiler cache. Version %s\n", CCACHE_VERSION); + printf("Copyright Andrew Tridgell, 2002\n\n"); + + printf("Usage:\n"); + printf("\tccache [options]\n"); + printf("\tccache compiler [compile options]\n"); + printf("\tcompiler [compile options] (via symbolic link)\n"); + printf("\nOptions:\n"); + + printf("-s show statistics summary\n"); + printf("-z zero statistics\n"); + printf("-c run a cache cleanup\n"); + printf("-C clear the cache completely\n"); + printf("-F set maximum files in cache\n"); + printf("-M set maximum size of cache (use G, M or K)\n"); + printf("-h this help page\n"); + printf("-V print version number\n"); +} + +/* the main program when not doing a compile */ +static int ccache_main(int argc, char *argv[]) +{ + int c; + size_t v; + + while ((c = getopt(argc, argv, "hszcCF:M:V")) != -1) { + switch (c) { + case 'V': + printf("ccache version %s\n", CCACHE_VERSION); + printf("Copyright Andrew Tridgell 2002\n"); + printf("Released under the GNU GPL v2 or later\n"); + exit(0); + + case 'h': + usage(); + exit(0); + + case 's': + stats_summary(); + break; + + case 'c': + cleanup_all(cache_dir); + printf("Cleaned cache\n"); + break; + + case 'C': + wipe_all(cache_dir); + printf("Cleared cache\n"); + break; + + case 'z': + stats_zero(); + printf("Statistics cleared\n"); + break; + + case 'F': + v = atoi(optarg); + stats_set_limits(v, -1); + printf("Set cache file limit to %u\n", (unsigned)v); + break; + + case 'M': + v = value_units(optarg); + stats_set_limits(-1, v); + printf("Set cache size limit to %uk\n", (unsigned)v); + break; + + default: + usage(); + exit(1); + } + } + + return 0; +} + + +/* Make a copy of stderr that will not be cached, so things like + distcc can send networking errors to it. */ +static void setup_uncached_err(void) +{ + char *buf; + int uncached_fd; + + uncached_fd = dup(2); + if (uncached_fd == -1) { + cc_log("dup(2) failed\n"); + failed(); + } + + /* leak a pointer to the environment */ + x_asprintf(&buf, "UNCACHED_ERR_FD=%d", uncached_fd); + + if (putenv(buf) == -1) { + cc_log("putenv failed\n"); + failed(); + } +} + + +int main(int argc, char *argv[]) +{ + char *p; + + cache_dir = getenv("CCACHE_DIR"); + if (!cache_dir) { + x_asprintf(&cache_dir, "%s/.ccache", get_home_directory()); + } + + temp_dir = getenv("CCACHE_TEMPDIR"); + if (!temp_dir) { + temp_dir = cache_dir; + } + + cache_logfile = getenv("CCACHE_LOGFILE"); + + setup_uncached_err(); + + + /* the user might have set CCACHE_UMASK */ + p = getenv("CCACHE_UMASK"); + if (p) { + mode_t mask; + errno = 0; + mask = strtol(p, NULL, 8); + if (errno == 0) { + umask(mask); + } + } + + + /* check if we are being invoked as "ccache" */ + if (strlen(argv[0]) >= strlen(MYNAME) && + strcmp(argv[0] + strlen(argv[0]) - strlen(MYNAME), MYNAME) == 0) { + if (argc < 2) { + usage(); + exit(1); + } + /* if the first argument isn't an option, then assume we are + being passed a compiler name and options */ + if (argv[1][0] == '-') { + return ccache_main(argc, argv); + } + } + + /* make sure the cache dir exists */ + if (create_dir(cache_dir) != 0) { + fprintf(stderr,"ccache: failed to create %s (%s)\n", + cache_dir, strerror(errno)); + exit(1); + } + + ccache(argc, argv); + return 1; +} diff --git a/CCache/ccache.h b/CCache/ccache.h new file mode 100644 index 000000000..faec5979d --- /dev/null +++ b/CCache/ccache.h @@ -0,0 +1,159 @@ +#define CCACHE_VERSION "2.4" + +#include "config.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef HAVE_PWD_H +#include +#endif + +#define STATUS_NOTFOUND 3 +#define STATUS_FATAL 4 +#define STATUS_NOCACHE 5 + +#define MYNAME "ccache" + +#define LIMIT_MULTIPLE 0.8 + +/* default maximum cache size */ +#ifndef DEFAULT_MAXSIZE +#define DEFAULT_MAXSIZE (1000*1000) +#endif + +enum stats { + STATS_NONE=0, + STATS_STDOUT, + STATS_STATUS, + STATS_ERROR, + STATS_TOCACHE, + STATS_PREPROCESSOR, + STATS_COMPILER, + STATS_MISSING, + STATS_CACHED, + STATS_ARGS, + STATS_LINK, + STATS_NUMFILES, + STATS_TOTALSIZE, + STATS_MAXFILES, + STATS_MAXSIZE, + STATS_NOTC, + STATS_DEVICE, + STATS_NOINPUT, + STATS_MULTIPLE, + STATS_CONFTEST, + STATS_UNSUPPORTED, + STATS_OUTSTDOUT, + + STATS_END +}; + +typedef unsigned uint32; + +#include "mdfour.h" + +void hash_start(void); +void hash_string(const char *s); +void hash_int(int x); +void hash_file(const char *fname); +char *hash_result(void); +void hash_buffer(const char *s, int len); + +void cc_log(const char *format, ...); +void fatal(const char *msg); + +void copy_fd(int fd_in, int fd_out); +int copy_file(const char *src, const char *dest); + +int create_dir(const char *dir); +void x_asprintf(char **ptr, const char *format, ...); +char *x_strdup(const char *s); +void *x_realloc(void *ptr, size_t size); +void *x_malloc(size_t size); +void traverse(const char *dir, void (*fn)(const char *, struct stat *)); +char *str_basename(const char *s); +char *dirname(char *s); +int lock_fd(int fd); +size_t file_size(struct stat *st); +int safe_open(const char *fname); +char *x_realpath(const char *path); +char *gnu_getcwd(void); +int create_empty_file(const char *fname); +const char *get_home_directory(void); + +void stats_update(enum stats stat); +void stats_zero(void); +void stats_summary(void); +void stats_tocache(size_t size); +void stats_read(const char *stats_file, unsigned counters[STATS_END]); +void stats_set_limits(long maxfiles, long maxsize); +size_t value_units(const char *s); +void display_size(unsigned v); +void stats_set_sizes(const char *dir, size_t num_files, size_t total_size); + +int unify_hash(const char *fname); + +#ifndef HAVE_VASPRINTF +int vasprintf(char **, const char *, va_list ); +#endif +#ifndef HAVE_ASPRINTF +int asprintf(char **ptr, const char *format, ...); +#endif + +#ifndef HAVE_SNPRINTF +int snprintf(char *,size_t ,const char *, ...); +#endif + +void cleanup_dir(const char *dir, size_t maxfiles, size_t maxsize); +void cleanup_all(const char *dir); +void wipe_all(const char *dir); + +int execute(char **argv, + const char *path_stdout, + const char *path_stderr); +char *find_executable(const char *name, const char *exclude_name); + +typedef struct { + char **argv; + int argc; +} ARGS; + + +ARGS *args_init(int , char **); +void args_add(ARGS *args, const char *s); +void args_add_prefix(ARGS *args, const char *s); +void args_pop(ARGS *args, int n); +void args_strip(ARGS *args, const char *prefix); +void args_remove_first(ARGS *args); + +#if HAVE_COMPAR_FN_T +#define COMPAR_FN_T __compar_fn_t +#else +typedef int (*COMPAR_FN_T)(const void *, const void *); +#endif + +/* work with silly DOS binary open */ +#ifndef O_BINARY +#define O_BINARY 0 +#endif + +/* mkstemp() on some versions of cygwin don't handle binary files, so + override */ +#ifdef __CYGWIN__ +#undef HAVE_MKSTEMP +#endif diff --git a/CCache/ccache.yo b/CCache/ccache.yo new file mode 100644 index 000000000..12e45a6fb --- /dev/null +++ b/CCache/ccache.yo @@ -0,0 +1,352 @@ +mailto(bugs@ccache.samba.org) +manpage(ccache)(1)(April 2002)()() +manpagename(ccache)(a fast compiler cache) +manpagesynopsis() + +ccache [OPTION] + +ccache [COMPILER OPTIONS] + + [COMPILER OPTIONS] + +manpagedescription() + +ccache is a compiler cache. It speeds up re-compilation of C/C++ code +by caching previous compiles and detecting when the same compile is +being done again. + +manpagesection(OPTIONS SUMMARY) + +Here is a summary of the options to ccache. + +verb( +-s show statistics summary +-z zero statistics +-c run a cache cleanup +-C clear the cache completely +-F set maximum files in cache +-M set maximum size of cache (use G, M or K) +-h this help page +-V print version number +) + +manpageoptions() + +These options only apply when you invoke ccache as "ccache". When +invoked as a compiler none of these options apply. In that case your +normal compiler options apply and you should refer to your compilers +documentation. + +startdit() +dit(bf(-h)) Print a options summary page + +dit(bf(-s)) Print the current statistics summary for the cache. The +statistics are stored spread across the subdirectories of the +cache. Using "ccache -s" adds up the statistics across all +subdirectories and prints the totals. + +dit(bf(-z)) Zero the cache statistics. + +dit(bf(-V)) Print the ccache version number + +dit(bf(-c)) Clean the cache and re-calculate the cache file count and +size totals. Normally the -c option should not be necessary as ccache +keeps the cache below the specified limits at runtime and keeps +statistics up to date on each compile. This option is mostly useful +if you manually modify the cache contents or believe that the cache +size statistics may be inaccurate. + +dit(bf(-C)) Clear the entire cache, removing all cached files. + +dit(bf(-F maxfiles)) This sets the maximum number of files allowed in +the cache. The value is stored inside the cache directory and applies +to all future compiles. Due to the way the value is stored the actual +value used is always rounded down to the nearest multiple of 16. + +dit(bf(-M maxsize)) This sets the maximum cache size. You can specify +a value in gigabytes, megabytes or kilobytes by appending a G, M or K +to the value. The default is gigabytes. The actual value stored is +rounded down to the nearest multiple of 16 kilobytes. + +enddit() + +manpagesection(INSTALLATION) + +There are two ways to use ccache. You can either prefix your compile +commands with "ccache" or you can create a symbolic link between +ccache and the names of your compilers. The first method is most +convenient if you just want to try out ccache or wish to use it for +some specific projects. The second method is most useful for when you +wish to use ccache for all your compiles. + +To install for usage by the first method just copy ccache to somewhere +in your path. + +To install for the second method do something like this: +verb( + cp ccache /usr/local/bin/ + ln -s /usr/local/bin/ccache /usr/local/bin/gcc + ln -s /usr/local/bin/ccache /usr/local/bin/g++ + ln -s /usr/local/bin/ccache /usr/local/bin/cc +) +This will work as long as /usr/local/bin comes before the path to gcc +(which is usually in /usr/bin). After installing you may wish to run +"which gcc" to make sure that the correct link is being used. + +Note! Do not use a hard link, use a symbolic link. A hardlink will +cause "interesting" problems. + +manpagesection(EXTRA OPTIONS) + +When run as a compiler front end ccache usually just takes the same +command line options as the compiler you are using. The only exception +to this is the option '--ccache-skip'. That option can be used to tell +ccache that the next option is definitely not a input filename, and +should be passed along to the compiler as-is. + +The reason this can be important is that ccache does need to parse the +command line and determine what is an input filename and what is a +compiler option, as it needs the input filename to determine the name +of the resulting object file (among other things). The heuristic +ccache uses in this parse is that any string on the command line that +exists as a file is treated as an input file name (usually a C +file). By using --ccache-skip you can force an option to not be +treated as an input file name and instead be passed along to the +compiler as a command line option. + +manpagesection(ENVIRONMENT VARIABLES) + +ccache uses a number of environment variables to control operation. In +most cases you won't need any of these as the defaults will be fine. + +startdit() + +dit(bf(CCACHE_DIR)) the CCACHE_DIR environment variable specifies +where ccache will keep its cached compiler output. The default is +"$HOME/.ccache". + +dit(bf(CCACHE_TEMPDIR)) the CCACHE_TEMPDIR environment variable specifies +where ccache will put temporary files. The default is the same as +CCACHE_DIR. Note that the CCACHE_TEMPDIR path must be on the same +filesystem as the CCACHE_DIR path, so that renames of files between +the two directories can work. + +dit(bf(CCACHE_LOGFILE)) If you set the CCACHE_LOGFILE environment +variable then ccache will write some log information on cache hits +and misses in that file. This is useful for tracking down problems. + +dit(bf(CCACHE_PATH)) You can optionally set CCACHE_PATH to a colon +separated path where ccache will look for the real compilers. If you +don't do this then ccache will look for the first executable matching +the compiler name in the normal PATH that isn't a symbolic link to +ccache itself. + +dit(bf(CCACHE_CC)) You can optionally set CCACHE_CC to force the name +of the compiler to use. If you don't do this then ccache works it out +from the command line. + +dit(bf(CCACHE_PREFIX)) This option adds a prefix to the command line +that ccache runs when invoking the compiler. Also see the section +below on using ccache with distcc. + +dit(bf(CCACHE_DISABLE)) If you set the environment variable +CCACHE_DISABLE then ccache will just call the real compiler, +bypassing the cache completely. + +dit(bf(CCACHE_READONLY)) the CCACHE_READONLY environment variable +tells ccache to attempt to use existing cached object files, but not +to try to add anything new to the cache. If you are using this because +your CCACHE_DIR is read-only, then you may find that you also need to +set CCACHE_TEMPDIR as otherwise ccache will fail to create the +temporary files. + +dit(bf(CCACHE_CPP2)) If you set the environment variable CCACHE_CPP2 +then ccache will not use the optimisation of avoiding the 2nd call to +the pre-processor by compiling the pre-processed output that was used +for finding the hash in the case of a cache miss. This is primarily a +debugging option, although it is possible that some unusual compilers +will have problems with the intermediate filename extensions used in +this optimisation, in which case this option could allow ccache to be +used. + +dit(bf(CCACHE_NOSTATS)) If you set the environment variable +CCACHE_NOSTATS then ccache will not update the statistics files on +each compile. + +dit(bf(CCACHE_NLEVELS)) The environment variable CCACHE_NLEVELS allows +you to choose the number of levels of hash in the cache directory. The +default is 2. The minimum is 1 and the maximum is 8. + +dit(bf(CCACHE_HARDLINK)) If you set the environment variable +CCACHE_HARDLINK then ccache will attempt to use hard links from the +cache directory when creating the compiler output rather than using a +file copy. Using hard links is faster, but can confuse programs like +'make' that rely on modification times. + +dit(bf(CCACHE_RECACHE)) This forces ccache to not use any cached +results, even if it finds them. New results are still cached, but +existing cache entries are ignored. + +dit(bf(CCACHE_UMASK)) This sets the umask for ccache and all child +processes (such as the compiler). This is mostly useful when you wish +to share your cache with other users. Note that this also affects the +file permissions set on the object files created from your +compilations. + +dit(bf(CCACHE_HASHDIR)) This tells ccache to hash the current working +directory when calculating the hash that is used to distinguish two +compiles. This prevents a problem with the storage of the current +working directory in the debug info of a object file, which can lead +ccache to give a cached object file that has the working directory in +the debug info set incorrectly. This option is off by default as the +incorrect setting of this debug info rarely causes problems. If you +strike problems with gdb not using the correct directory then enable +this option. + +dit(bf(CCACHE_UNIFY)) If you set the environment variable CCACHE_UNIFY +then ccache will use the C/C++ unifier when hashing the pre-processor +output if -g is not used in the compile. The unifier is slower than a +normal hash, so setting this environment variable loses a little bit +of speed, but it means that ccache can take advantage of not +recompiling when the changes to the source code consist of +reformatting only. Note that using CCACHE_UNIFY changes the hash, so +cached compiles with CCACHE_UNIFY set cannot be used when +CCACHE_UNIFY is not set and vice versa. The reason the unifier is off +by default is that it can give incorrect line number information in +compiler warning messages. + +dit(bf(CCACHE_EXTENSION)) Normally ccache tries to automatically +determine the extension to use for intermediate C pre-processor files +based on the type of file being compiled. Unfortunately this sometimes +doesn't work, for example when using the aCC compiler on HP-UX. On +systems like this you can use the CCACHE_EXTENSION option to override +the default. On HP-UX set this environment variable to "i" if you use +the aCC compiler. + +enddit() + +manpagesection(CACHE SIZE MANAGEMENT) + +By default ccache has a one gigabyte limit on the cache size and no +maximum number of files. You can set a different limit using the +"ccache -M" and "ccache -F" options, which set the size and number of +files limits. + +When these limits are reached ccache will reduce the cache to 20% +below the numbers you specified in order to avoid doing the cache +clean operation too often. + +manpagesection(HOW IT WORKS) + +The basic idea is to detect when you are compiling exactly the same +code a 2nd time and use the previously compiled output. You detect +that it is the same code by forming a hash of: + +itemize( + it() the pre-processor output from running the compiler with -E + it() the command line options + it() the real compilers size and modification time + it() any stderr output generated by the compiler +) + +These are hashed using md4 (a strong hash) and a cache file is formed +based on that hash result. When the same compilation is done a second +time ccache is able to supply the correct compiler output (including +all warnings etc) from the cache. + +ccache has been carefully written to always produce exactly the same +compiler output that you would get without the cache. If you ever +discover a case where ccache changes the output of your compiler then +please let me know. + +manpagesection(USING CCACHE WITH DISTCC) + +distcc is a very useful program for distributing compilation across a +range of compiler servers. It is often useful to combine distcc with +ccache, so that compiles that are done are sped up by distcc, but that +ccache avoids the compile completely where possible. + +To use distcc with ccache I recommend using the CCACHE_PREFIX +option. You just need to set the environment variable CCACHE_PREFIX to +'distcc' and ccache will prefix the command line used with the +compiler with the command 'distcc'. + +manpagesection(SHARING A CACHE) + +A group of developers can increase the cache hit rate by sharing a +cache directory. The hard links however cause unwanted side effects, +as all links to a cached file share the file's modification timestamp. +This results in false dependencies to be triggered by timestamp-based +build systems whenever another user links to an existing +file. Typically, users will see that their libraries and binaries are +relinked without reason. To share a cache without side effects, the +following conditions need to be met: + +itemize( + it() Use the same bf(CCACHE_DIR) environment variable setting + it() Set the bf(CCACHE_NOLINK) environment variable + it() Make sure everyone sets the CCACHE_UMASK environment variable + to 002, this ensures that cached files are accessible to everyone in + the group. + it() Make sure that all users have write permission in the entire + cache directory (and that you trust all users of the shared cache). + it() Make sure that the setgid bit is set on all directories in the + cache. This tells the filesystem to inherit group ownership for new + directories. The command "chmod g+s `find $CCACHE_DIR -type d`" might + be useful for this. +) + +manpagesection(HISTORY) + +ccache was inspired by the compilercache shell script script written +by Erik Thiele and I would like to thank him for an excellent piece of +work. See +url(http://www.erikyyy.de/compilercache/)(http://www.erikyyy.de/compilercache/) +for the Erik's scripts. + +I wrote ccache because I wanted to get a bit more speed out of a +compiler cache and I wanted to remove some of the limitations of the +shell-script version. + +manpagesection(DIFFERENCES FROM COMPILERCACHE) + +The biggest differences between Erik's compilercache script and ccache +are: +itemize( +it() ccache is written in C, which makes it a bit faster (calling out to + external programs is mostly what slowed down the scripts). +it() ccache can automatically find the real compiler +it() ccache keeps statistics on hits/misses +it() ccache can do automatic cache management +it() ccache can cache compiler output that includes warnings. In many + cases this gives ccache a much higher cache hit rate. +it() ccache can handle a much wider ranger of compiler options +it() ccache avoids a double call to cpp on a cache miss +) + +manpagesection(BUGS) + +When the cache is stored on an NFS filesystem, the filesystem must be +exported with the bf(no_subtree_check) option to make renames between +directories reliable. + +manpagesection(CREDITS) + +Thanks to the following people for their contributions to ccache +itemize( + it() Erik Thiele for the original compilercache script + it() Luciano Rocha for the idea of compiling the pre-processor output + to avoid a 2nd cpp pass + it() Paul Russell for many suggestions and the debian packaging +) + +manpageauthor() + +ccache was written by Andrew Tridgell +url(http://samba.org/~tridge/)(http://samba.org/~tridge/) + +If you wish to report a problem or make a suggestion then please email +bugs@ccache.samba.org + +ccache is released under the GNU General Public License version 2 or +later. Please see the file COPYING for license details. diff --git a/CCache/cleanup.c b/CCache/cleanup.c new file mode 100644 index 000000000..99312283e --- /dev/null +++ b/CCache/cleanup.c @@ -0,0 +1,193 @@ +/* + Copyright (C) Andrew Tridgell 2002 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ +/* + functions to cleanup the cache directory when it gets too large + */ + +#include "ccache.h" + +static struct files { + char *fname; + time_t mtime; + size_t size; +} **files; +static unsigned allocated; +static unsigned num_files; +static size_t total_size; +static size_t total_files; +static size_t size_threshold; +static size_t files_threshold; + +/* file comparison function to try to delete the oldest files first */ +static int files_compare(struct files **f1, struct files **f2) +{ + if ((*f2)->mtime == (*f1)->mtime) { + return strcmp((*f2)->fname, (*f1)->fname); + } + if ((*f2)->mtime > (*f1)->mtime) { + return -1; + } + return 1; +} + +/* this builds the list of files in the cache */ +static void traverse_fn(const char *fname, struct stat *st) +{ + char *p; + + if (!S_ISREG(st->st_mode)) return; + + p = str_basename(fname); + if (strcmp(p, "stats") == 0) { + free(p); + return; + } + free(p); + + if (num_files == allocated) { + allocated = 10000 + num_files*2; + files = (struct files **)x_realloc(files, + sizeof(struct files *)*allocated); + } + + files[num_files] = (struct files *)x_malloc(sizeof(struct files)); + files[num_files]->fname = x_strdup(fname); + files[num_files]->mtime = st->st_mtime; + files[num_files]->size = file_size(st) / 1024; + total_size += files[num_files]->size; + num_files++; +} + +/* sort the files we've found and delete the oldest ones until we are + below the thresholds */ +static void sort_and_clean(void) +{ + unsigned i; + + if (num_files > 1) { + /* sort in ascending data order */ + qsort(files, num_files, sizeof(struct files *), + (COMPAR_FN_T)files_compare); + } + + /* delete enough files to bring us below the threshold */ + for (i=0;ifname) != 0 && errno != ENOENT) { + fprintf(stderr, "unlink %s - %s\n", + files[i]->fname, strerror(errno)); + continue; + } + + total_size -= files[i]->size; + } + + total_files = num_files - i; +} + +/* cleanup in one cache subdir */ +void cleanup_dir(const char *dir, size_t maxfiles, size_t maxsize) +{ + unsigned i; + + size_threshold = maxsize * LIMIT_MULTIPLE; + files_threshold = maxfiles * LIMIT_MULTIPLE; + + num_files = 0; + total_size = 0; + + /* build a list of files */ + traverse(dir, traverse_fn); + + /* clean the cache */ + sort_and_clean(); + + stats_set_sizes(dir, total_files, total_size); + + /* free it up */ + for (i=0;ifname); + free(files[i]); + files[i] = NULL; + } + if (files) free(files); + allocated = 0; + files = NULL; + + num_files = 0; + total_size = 0; +} + +/* cleanup in all cache subdirs */ +void cleanup_all(const char *dir) +{ + unsigned counters[STATS_END]; + char *dname, *sfile; + int i; + + for (i=0;i<=0xF;i++) { + x_asprintf(&dname, "%s/%1x", dir, i); + x_asprintf(&sfile, "%s/%1x/stats", dir, i); + + memset(counters, 0, sizeof(counters)); + stats_read(sfile, counters); + + cleanup_dir(dname, + counters[STATS_MAXFILES], + counters[STATS_MAXSIZE]); + free(dname); + free(sfile); + } +} + + +/* traverse function for wiping files */ +static void wipe_fn(const char *fname, struct stat *st) +{ + char *p; + + if (!S_ISREG(st->st_mode)) return; + + p = str_basename(fname); + if (strcmp(p, "stats") == 0) { + free(p); + return; + } + free(p); + + unlink(fname); +} + + +/* wipe all cached files in all subdirs */ +void wipe_all(const char *dir) +{ + char *dname; + int i; + + for (i=0;i<=0xF;i++) { + x_asprintf(&dname, "%s/%1x", dir, i); + traverse(dir, wipe_fn); + free(dname); + } + + /* and fix the counters */ + cleanup_all(dir); +} diff --git a/CCache/config.h.in b/CCache/config.h.in new file mode 100644 index 000000000..286f0385c --- /dev/null +++ b/CCache/config.h.in @@ -0,0 +1,100 @@ +/* config.h.in. Generated from configure.in by autoheader. */ + +/* Define to 1 if you have the `asprintf' function. */ +#undef HAVE_ASPRINTF + +/* */ +#undef HAVE_C99_VSNPRINTF + +/* */ +#undef HAVE_COMPAR_FN_T + +/* Define to 1 if you have the header file. */ +#undef HAVE_CTYPE_H + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +#undef HAVE_DIRENT_H + +/* Define to 1 if you have the `gethostname' function. */ +#undef HAVE_GETHOSTNAME + +/* Define to 1 if you have the header file. */ +#undef HAVE_INTTYPES_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_MEMORY_H + +/* Define to 1 if you have the `mkstemp' function. */ +#undef HAVE_MKSTEMP + +/* Define to 1 if you have the header file, and it defines `DIR'. */ +#undef HAVE_NDIR_H + +/* Define to 1 if you have the `realpath' function. */ +#undef HAVE_REALPATH + +/* Define to 1 if you have the `snprintf' function. */ +#undef HAVE_SNPRINTF + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDINT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDLIB_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRINGS_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRING_H + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +#undef HAVE_SYS_DIR_H + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +#undef HAVE_SYS_NDIR_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_STAT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TYPES_H + +/* Define to 1 if you have that is POSIX.1 compatible. */ +#undef HAVE_SYS_WAIT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_UNISTD_H + +/* Define to 1 if you have the `vasprintf' function. */ +#undef HAVE_VASPRINTF + +/* Define to 1 if you have the `vsnprintf' function. */ +#undef HAVE_VSNPRINTF + +/* Define to the address where bug reports for this package should be sent. */ +#undef PACKAGE_BUGREPORT + +/* Define to the full name of this package. */ +#undef PACKAGE_NAME + +/* Define to the full name and version of this package. */ +#undef PACKAGE_STRING + +/* Define to the one symbol short name of this package. */ +#undef PACKAGE_TARNAME + +/* Define to the version of this package. */ +#undef PACKAGE_VERSION + +/* Define to 1 if you have the ANSI C header files. */ +#undef STDC_HEADERS + +/* Define to 1 if you can safely include both and . */ +#undef TIME_WITH_SYS_TIME + +/* Define _GNU_SOURCE so that we get all necessary prototypes */ +#undef _GNU_SOURCE diff --git a/CCache/configure b/CCache/configure new file mode 100755 index 000000000..227567798 --- /dev/null +++ b/CCache/configure @@ -0,0 +1,4896 @@ +#! /bin/sh +# Guess values for system-dependent variables and create Makefiles. +# Generated by GNU Autoconf 2.59. +# +# Copyright (C) 2003 Free Software Foundation, Inc. +# This configure script is free software; the Free Software Foundation +# gives unlimited permission to copy, distribute and modify it. +## --------------------- ## +## M4sh Initialization. ## +## --------------------- ## + +# Be Bourne compatible +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' +elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then + set -o posix +fi +DUALCASE=1; export DUALCASE # for MKS sh + +# Support unset when possible. +if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then + as_unset=unset +else + as_unset=false +fi + + +# Work around bugs in pre-3.0 UWIN ksh. +$as_unset ENV MAIL MAILPATH +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +for as_var in \ + LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ + LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ + LC_TELEPHONE LC_TIME +do + if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then + eval $as_var=C; export $as_var + else + $as_unset $as_var + fi +done + +# Required to use basename. +if expr a : '\(a\)' >/dev/null 2>&1; then + as_expr=expr +else + as_expr=false +fi + +if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + + +# Name of the executable. +as_me=`$as_basename "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)$' \| \ + . : '\(.\)' 2>/dev/null || +echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; } + /^X\/\(\/\/\)$/{ s//\1/; q; } + /^X\/\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + + +# PATH needs CR, and LINENO needs CR and PATH. +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh +fi + + + as_lineno_1=$LINENO + as_lineno_2=$LINENO + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x$as_lineno_3" = "x$as_lineno_2" || { + # Find who we are. Look in the path if we contain no path at all + # relative or not. + case $0 in + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break +done + + ;; + esac + # We did not find ourselves, most probably we were run as `sh COMMAND' + # in which case we are not to be found in the path. + if test "x$as_myself" = x; then + as_myself=$0 + fi + if test ! -f "$as_myself"; then + { echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2 + { (exit 1); exit 1; }; } + fi + case $CONFIG_SHELL in + '') + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for as_base in sh bash ksh sh5; do + case $as_dir in + /*) + if ("$as_dir/$as_base" -c ' + as_lineno_1=$LINENO + as_lineno_2=$LINENO + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then + $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; } + $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; } + CONFIG_SHELL=$as_dir/$as_base + export CONFIG_SHELL + exec "$CONFIG_SHELL" "$0" ${1+"$@"} + fi;; + esac + done +done +;; + esac + + # Create $as_me.lineno as a copy of $as_myself, but with $LINENO + # uniformly replaced by the line number. The first 'sed' inserts a + # line-number line before each line; the second 'sed' does the real + # work. The second script uses 'N' to pair each line-number line + # with the numbered line, and appends trailing '-' during + # substitution so that $LINENO is not a special case at line end. + # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the + # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-) + sed '=' <$as_myself | + sed ' + N + s,$,-, + : loop + s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3, + t loop + s,-$,, + s,^['$as_cr_digits']*\n,, + ' >$as_me.lineno && + chmod +x $as_me.lineno || + { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 + { (exit 1); exit 1; }; } + + # Don't try to exec as it changes $[0], causing all sort of problems + # (the dirname of $[0] is not the place where we might find the + # original and so on. Autoconf is especially sensible to this). + . ./$as_me.lineno + # Exit status is that of the last command. + exit +} + + +case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in + *c*,-n*) ECHO_N= ECHO_C=' +' ECHO_T=' ' ;; + *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; + *) ECHO_N= ECHO_C='\c' ECHO_T= ;; +esac + +if expr a : '\(a\)' >/dev/null 2>&1; then + as_expr=expr +else + as_expr=false +fi + +rm -f conf$$ conf$$.exe conf$$.file +echo >conf$$.file +if ln -s conf$$.file conf$$ 2>/dev/null; then + # We could just check for DJGPP; but this test a) works b) is more generic + # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). + if test -f conf$$.exe; then + # Don't use ln at all; we don't have any links + as_ln_s='cp -p' + else + as_ln_s='ln -s' + fi +elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln +else + as_ln_s='cp -p' +fi +rm -f conf$$ conf$$.exe conf$$.file + +if mkdir -p . 2>/dev/null; then + as_mkdir_p=: +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + +as_executable_p="test -f" + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + +# IFS +# We need space, tab and new line, in precisely that order. +as_nl=' +' +IFS=" $as_nl" + +# CDPATH. +$as_unset CDPATH + + +# Name of the host. +# hostname on some systems (SVR3.2, Linux) returns a bogus exit status, +# so uname gets run too. +ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` + +exec 6>&1 + +# +# Initializations. +# +ac_default_prefix=/usr/local +ac_config_libobj_dir=. +cross_compiling=no +subdirs= +MFLAGS= +MAKEFLAGS= +SHELL=${CONFIG_SHELL-/bin/sh} + +# Maximum number of lines to put in a shell here document. +# This variable seems obsolete. It should probably be removed, and +# only ac_max_sed_lines should be used. +: ${ac_max_here_lines=38} + +# Identity of this package. +PACKAGE_NAME= +PACKAGE_TARNAME= +PACKAGE_VERSION= +PACKAGE_STRING= +PACKAGE_BUGREPORT= + +# Factoring default headers for most tests. +ac_includes_default="\ +#include +#if HAVE_SYS_TYPES_H +# include +#endif +#if HAVE_SYS_STAT_H +# include +#endif +#if STDC_HEADERS +# include +# include +#else +# if HAVE_STDLIB_H +# include +# endif +#endif +#if HAVE_STRING_H +# if !STDC_HEADERS && HAVE_MEMORY_H +# include +# endif +# include +#endif +#if HAVE_STRINGS_H +# include +#endif +#if HAVE_INTTYPES_H +# include +#else +# if HAVE_STDINT_H +# include +# endif +#endif +#if HAVE_UNISTD_H +# include +#endif" + +ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CPP INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA EGREP LIBOBJS LTLIBOBJS' +ac_subst_files='' + +# Initialize some variables set by options. +ac_init_help= +ac_init_version=false +# The variables have the same names as the options, with +# dashes changed to underlines. +cache_file=/dev/null +exec_prefix=NONE +no_create= +no_recursion= +prefix=NONE +program_prefix=NONE +program_suffix=NONE +program_transform_name=s,x,x, +silent= +site= +srcdir= +verbose= +x_includes=NONE +x_libraries=NONE + +# Installation directory options. +# These are left unexpanded so users can "make install exec_prefix=/foo" +# and all the variables that are supposed to be based on exec_prefix +# by default will actually change. +# Use braces instead of parens because sh, perl, etc. also accept them. +bindir='${exec_prefix}/bin' +sbindir='${exec_prefix}/sbin' +libexecdir='${exec_prefix}/libexec' +datadir='${prefix}/share' +sysconfdir='${prefix}/etc' +sharedstatedir='${prefix}/com' +localstatedir='${prefix}/var' +libdir='${exec_prefix}/lib' +includedir='${prefix}/include' +oldincludedir='/usr/include' +infodir='${prefix}/info' +mandir='${prefix}/man' + +ac_prev= +for ac_option +do + # If the previous option needs an argument, assign it. + if test -n "$ac_prev"; then + eval "$ac_prev=\$ac_option" + ac_prev= + continue + fi + + ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'` + + # Accept the important Cygnus configure options, so we can diagnose typos. + + case $ac_option in + + -bindir | --bindir | --bindi | --bind | --bin | --bi) + ac_prev=bindir ;; + -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) + bindir=$ac_optarg ;; + + -build | --build | --buil | --bui | --bu) + ac_prev=build_alias ;; + -build=* | --build=* | --buil=* | --bui=* | --bu=*) + build_alias=$ac_optarg ;; + + -cache-file | --cache-file | --cache-fil | --cache-fi \ + | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) + ac_prev=cache_file ;; + -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ + | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) + cache_file=$ac_optarg ;; + + --config-cache | -C) + cache_file=config.cache ;; + + -datadir | --datadir | --datadi | --datad | --data | --dat | --da) + ac_prev=datadir ;; + -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ + | --da=*) + datadir=$ac_optarg ;; + + -disable-* | --disable-*) + ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid feature name: $ac_feature" >&2 + { (exit 1); exit 1; }; } + ac_feature=`echo $ac_feature | sed 's/-/_/g'` + eval "enable_$ac_feature=no" ;; + + -enable-* | --enable-*) + ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid feature name: $ac_feature" >&2 + { (exit 1); exit 1; }; } + ac_feature=`echo $ac_feature | sed 's/-/_/g'` + case $ac_option in + *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; + *) ac_optarg=yes ;; + esac + eval "enable_$ac_feature='$ac_optarg'" ;; + + -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ + | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ + | --exec | --exe | --ex) + ac_prev=exec_prefix ;; + -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ + | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ + | --exec=* | --exe=* | --ex=*) + exec_prefix=$ac_optarg ;; + + -gas | --gas | --ga | --g) + # Obsolete; use --with-gas. + with_gas=yes ;; + + -help | --help | --hel | --he | -h) + ac_init_help=long ;; + -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) + ac_init_help=recursive ;; + -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) + ac_init_help=short ;; + + -host | --host | --hos | --ho) + ac_prev=host_alias ;; + -host=* | --host=* | --hos=* | --ho=*) + host_alias=$ac_optarg ;; + + -includedir | --includedir | --includedi | --included | --include \ + | --includ | --inclu | --incl | --inc) + ac_prev=includedir ;; + -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ + | --includ=* | --inclu=* | --incl=* | --inc=*) + includedir=$ac_optarg ;; + + -infodir | --infodir | --infodi | --infod | --info | --inf) + ac_prev=infodir ;; + -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) + infodir=$ac_optarg ;; + + -libdir | --libdir | --libdi | --libd) + ac_prev=libdir ;; + -libdir=* | --libdir=* | --libdi=* | --libd=*) + libdir=$ac_optarg ;; + + -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ + | --libexe | --libex | --libe) + ac_prev=libexecdir ;; + -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ + | --libexe=* | --libex=* | --libe=*) + libexecdir=$ac_optarg ;; + + -localstatedir | --localstatedir | --localstatedi | --localstated \ + | --localstate | --localstat | --localsta | --localst \ + | --locals | --local | --loca | --loc | --lo) + ac_prev=localstatedir ;; + -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ + | --localstate=* | --localstat=* | --localsta=* | --localst=* \ + | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) + localstatedir=$ac_optarg ;; + + -mandir | --mandir | --mandi | --mand | --man | --ma | --m) + ac_prev=mandir ;; + -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) + mandir=$ac_optarg ;; + + -nfp | --nfp | --nf) + # Obsolete; use --without-fp. + with_fp=no ;; + + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c | -n) + no_create=yes ;; + + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) + no_recursion=yes ;; + + -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ + | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ + | --oldin | --oldi | --old | --ol | --o) + ac_prev=oldincludedir ;; + -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ + | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ + | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) + oldincludedir=$ac_optarg ;; + + -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) + ac_prev=prefix ;; + -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) + prefix=$ac_optarg ;; + + -program-prefix | --program-prefix | --program-prefi | --program-pref \ + | --program-pre | --program-pr | --program-p) + ac_prev=program_prefix ;; + -program-prefix=* | --program-prefix=* | --program-prefi=* \ + | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) + program_prefix=$ac_optarg ;; + + -program-suffix | --program-suffix | --program-suffi | --program-suff \ + | --program-suf | --program-su | --program-s) + ac_prev=program_suffix ;; + -program-suffix=* | --program-suffix=* | --program-suffi=* \ + | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) + program_suffix=$ac_optarg ;; + + -program-transform-name | --program-transform-name \ + | --program-transform-nam | --program-transform-na \ + | --program-transform-n | --program-transform- \ + | --program-transform | --program-transfor \ + | --program-transfo | --program-transf \ + | --program-trans | --program-tran \ + | --progr-tra | --program-tr | --program-t) + ac_prev=program_transform_name ;; + -program-transform-name=* | --program-transform-name=* \ + | --program-transform-nam=* | --program-transform-na=* \ + | --program-transform-n=* | --program-transform-=* \ + | --program-transform=* | --program-transfor=* \ + | --program-transfo=* | --program-transf=* \ + | --program-trans=* | --program-tran=* \ + | --progr-tra=* | --program-tr=* | --program-t=*) + program_transform_name=$ac_optarg ;; + + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + silent=yes ;; + + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) + ac_prev=sbindir ;; + -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ + | --sbi=* | --sb=*) + sbindir=$ac_optarg ;; + + -sharedstatedir | --sharedstatedir | --sharedstatedi \ + | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ + | --sharedst | --shareds | --shared | --share | --shar \ + | --sha | --sh) + ac_prev=sharedstatedir ;; + -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ + | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ + | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ + | --sha=* | --sh=*) + sharedstatedir=$ac_optarg ;; + + -site | --site | --sit) + ac_prev=site ;; + -site=* | --site=* | --sit=*) + site=$ac_optarg ;; + + -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) + ac_prev=srcdir ;; + -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) + srcdir=$ac_optarg ;; + + -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ + | --syscon | --sysco | --sysc | --sys | --sy) + ac_prev=sysconfdir ;; + -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ + | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) + sysconfdir=$ac_optarg ;; + + -target | --target | --targe | --targ | --tar | --ta | --t) + ac_prev=target_alias ;; + -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) + target_alias=$ac_optarg ;; + + -v | -verbose | --verbose | --verbos | --verbo | --verb) + verbose=yes ;; + + -version | --version | --versio | --versi | --vers | -V) + ac_init_version=: ;; + + -with-* | --with-*) + ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid package name: $ac_package" >&2 + { (exit 1); exit 1; }; } + ac_package=`echo $ac_package| sed 's/-/_/g'` + case $ac_option in + *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; + *) ac_optarg=yes ;; + esac + eval "with_$ac_package='$ac_optarg'" ;; + + -without-* | --without-*) + ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid package name: $ac_package" >&2 + { (exit 1); exit 1; }; } + ac_package=`echo $ac_package | sed 's/-/_/g'` + eval "with_$ac_package=no" ;; + + --x) + # Obsolete; use --with-x. + with_x=yes ;; + + -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ + | --x-incl | --x-inc | --x-in | --x-i) + ac_prev=x_includes ;; + -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ + | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) + x_includes=$ac_optarg ;; + + -x-libraries | --x-libraries | --x-librarie | --x-librari \ + | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) + ac_prev=x_libraries ;; + -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ + | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) + x_libraries=$ac_optarg ;; + + -*) { echo "$as_me: error: unrecognized option: $ac_option +Try \`$0 --help' for more information." >&2 + { (exit 1); exit 1; }; } + ;; + + *=*) + ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` + # Reject names that are not valid shell variable names. + expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid variable name: $ac_envvar" >&2 + { (exit 1); exit 1; }; } + ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` + eval "$ac_envvar='$ac_optarg'" + export $ac_envvar ;; + + *) + # FIXME: should be removed in autoconf 3.0. + echo "$as_me: WARNING: you should use --build, --host, --target" >&2 + expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && + echo "$as_me: WARNING: invalid host type: $ac_option" >&2 + : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} + ;; + + esac +done + +if test -n "$ac_prev"; then + ac_option=--`echo $ac_prev | sed 's/_/-/g'` + { echo "$as_me: error: missing argument to $ac_option" >&2 + { (exit 1); exit 1; }; } +fi + +# Be sure to have absolute paths. +for ac_var in exec_prefix prefix +do + eval ac_val=$`echo $ac_var` + case $ac_val in + [\\/$]* | ?:[\\/]* | NONE | '' ) ;; + *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 + { (exit 1); exit 1; }; };; + esac +done + +# Be sure to have absolute paths. +for ac_var in bindir sbindir libexecdir datadir sysconfdir sharedstatedir \ + localstatedir libdir includedir oldincludedir infodir mandir +do + eval ac_val=$`echo $ac_var` + case $ac_val in + [\\/$]* | ?:[\\/]* ) ;; + *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 + { (exit 1); exit 1; }; };; + esac +done + +# There might be people who depend on the old broken behavior: `$host' +# used to hold the argument of --host etc. +# FIXME: To remove some day. +build=$build_alias +host=$host_alias +target=$target_alias + +# FIXME: To remove some day. +if test "x$host_alias" != x; then + if test "x$build_alias" = x; then + cross_compiling=maybe + echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. + If a cross compiler is detected then cross compile mode will be used." >&2 + elif test "x$build_alias" != "x$host_alias"; then + cross_compiling=yes + fi +fi + +ac_tool_prefix= +test -n "$host_alias" && ac_tool_prefix=$host_alias- + +test "$silent" = yes && exec 6>/dev/null + + +# Find the source files, if location was not specified. +if test -z "$srcdir"; then + ac_srcdir_defaulted=yes + # Try the directory containing this script, then its parent. + ac_confdir=`(dirname "$0") 2>/dev/null || +$as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$0" : 'X\(//\)[^/]' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$0" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + srcdir=$ac_confdir + if test ! -r $srcdir/$ac_unique_file; then + srcdir=.. + fi +else + ac_srcdir_defaulted=no +fi +if test ! -r $srcdir/$ac_unique_file; then + if test "$ac_srcdir_defaulted" = yes; then + { echo "$as_me: error: cannot find sources ($ac_unique_file) in $ac_confdir or .." >&2 + { (exit 1); exit 1; }; } + else + { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2 + { (exit 1); exit 1; }; } + fi +fi +(cd $srcdir && test -r ./$ac_unique_file) 2>/dev/null || + { echo "$as_me: error: sources are in $srcdir, but \`cd $srcdir' does not work" >&2 + { (exit 1); exit 1; }; } +srcdir=`echo "$srcdir" | sed 's%\([^\\/]\)[\\/]*$%\1%'` +ac_env_build_alias_set=${build_alias+set} +ac_env_build_alias_value=$build_alias +ac_cv_env_build_alias_set=${build_alias+set} +ac_cv_env_build_alias_value=$build_alias +ac_env_host_alias_set=${host_alias+set} +ac_env_host_alias_value=$host_alias +ac_cv_env_host_alias_set=${host_alias+set} +ac_cv_env_host_alias_value=$host_alias +ac_env_target_alias_set=${target_alias+set} +ac_env_target_alias_value=$target_alias +ac_cv_env_target_alias_set=${target_alias+set} +ac_cv_env_target_alias_value=$target_alias +ac_env_CC_set=${CC+set} +ac_env_CC_value=$CC +ac_cv_env_CC_set=${CC+set} +ac_cv_env_CC_value=$CC +ac_env_CFLAGS_set=${CFLAGS+set} +ac_env_CFLAGS_value=$CFLAGS +ac_cv_env_CFLAGS_set=${CFLAGS+set} +ac_cv_env_CFLAGS_value=$CFLAGS +ac_env_LDFLAGS_set=${LDFLAGS+set} +ac_env_LDFLAGS_value=$LDFLAGS +ac_cv_env_LDFLAGS_set=${LDFLAGS+set} +ac_cv_env_LDFLAGS_value=$LDFLAGS +ac_env_CPPFLAGS_set=${CPPFLAGS+set} +ac_env_CPPFLAGS_value=$CPPFLAGS +ac_cv_env_CPPFLAGS_set=${CPPFLAGS+set} +ac_cv_env_CPPFLAGS_value=$CPPFLAGS +ac_env_CPP_set=${CPP+set} +ac_env_CPP_value=$CPP +ac_cv_env_CPP_set=${CPP+set} +ac_cv_env_CPP_value=$CPP + +# +# Report the --help message. +# +if test "$ac_init_help" = "long"; then + # Omit some internal or obsolete options to make the list less imposing. + # This message is too long to be a string in the A/UX 3.1 sh. + cat <<_ACEOF +\`configure' configures this package to adapt to many kinds of systems. + +Usage: $0 [OPTION]... [VAR=VALUE]... + +To assign environment variables (e.g., CC, CFLAGS...), specify them as +VAR=VALUE. See below for descriptions of some of the useful variables. + +Defaults for the options are specified in brackets. + +Configuration: + -h, --help display this help and exit + --help=short display options specific to this package + --help=recursive display the short help of all the included packages + -V, --version display version information and exit + -q, --quiet, --silent do not print \`checking...' messages + --cache-file=FILE cache test results in FILE [disabled] + -C, --config-cache alias for \`--cache-file=config.cache' + -n, --no-create do not create output files + --srcdir=DIR find the sources in DIR [configure dir or \`..'] + +_ACEOF + + cat <<_ACEOF +Installation directories: + --prefix=PREFIX install architecture-independent files in PREFIX + [$ac_default_prefix] + --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX + [PREFIX] + +By default, \`make install' will install all the files in +\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify +an installation prefix other than \`$ac_default_prefix' using \`--prefix', +for instance \`--prefix=\$HOME'. + +For better control, use the options below. + +Fine tuning of the installation directories: + --bindir=DIR user executables [EPREFIX/bin] + --sbindir=DIR system admin executables [EPREFIX/sbin] + --libexecdir=DIR program executables [EPREFIX/libexec] + --datadir=DIR read-only architecture-independent data [PREFIX/share] + --sysconfdir=DIR read-only single-machine data [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] + --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --libdir=DIR object code libraries [EPREFIX/lib] + --includedir=DIR C header files [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc [/usr/include] + --infodir=DIR info documentation [PREFIX/info] + --mandir=DIR man documentation [PREFIX/man] +_ACEOF + + cat <<\_ACEOF +_ACEOF +fi + +if test -n "$ac_init_help"; then + + cat <<\_ACEOF + +Some influential environment variables: + CC C compiler command + CFLAGS C compiler flags + LDFLAGS linker flags, e.g. -L if you have libraries in a + nonstandard directory + CPPFLAGS C/C++ preprocessor flags, e.g. -I if you have + headers in a nonstandard directory + CPP C preprocessor + +Use these variables to override the choices made by `configure' or to help +it to find libraries and programs with nonstandard names/locations. + +_ACEOF +fi + +if test "$ac_init_help" = "recursive"; then + # If there are subdirs, report their specific --help. + ac_popdir=`pwd` + for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue + test -d $ac_dir || continue + ac_builddir=. + +if test "$ac_dir" != .; then + ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` + # A "../" for each directory in $ac_dir_suffix. + ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` +else + ac_dir_suffix= ac_top_builddir= +fi + +case $srcdir in + .) # No --srcdir option. We are building in place. + ac_srcdir=. + if test -z "$ac_top_builddir"; then + ac_top_srcdir=. + else + ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` + fi ;; + [\\/]* | ?:[\\/]* ) # Absolute path. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir ;; + *) # Relative path. + ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_builddir$srcdir ;; +esac + +# Do not use `cd foo && pwd` to compute absolute paths, because +# the directories may not exist. +case `pwd` in +.) ac_abs_builddir="$ac_dir";; +*) + case "$ac_dir" in + .) ac_abs_builddir=`pwd`;; + [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";; + *) ac_abs_builddir=`pwd`/"$ac_dir";; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_top_builddir=${ac_top_builddir}.;; +*) + case ${ac_top_builddir}. in + .) ac_abs_top_builddir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;; + *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_srcdir=$ac_srcdir;; +*) + case $ac_srcdir in + .) ac_abs_srcdir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;; + *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_top_srcdir=$ac_top_srcdir;; +*) + case $ac_top_srcdir in + .) ac_abs_top_srcdir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;; + *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;; + esac;; +esac + + cd $ac_dir + # Check for guested configure; otherwise get Cygnus style configure. + if test -f $ac_srcdir/configure.gnu; then + echo + $SHELL $ac_srcdir/configure.gnu --help=recursive + elif test -f $ac_srcdir/configure; then + echo + $SHELL $ac_srcdir/configure --help=recursive + elif test -f $ac_srcdir/configure.ac || + test -f $ac_srcdir/configure.in; then + echo + $ac_configure --help + else + echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 + fi + cd "$ac_popdir" + done +fi + +test -n "$ac_init_help" && exit 0 +if $ac_init_version; then + cat <<\_ACEOF + +Copyright (C) 2003 Free Software Foundation, Inc. +This configure script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it. +_ACEOF + exit 0 +fi +exec 5>config.log +cat >&5 <<_ACEOF +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. + +It was created by $as_me, which was +generated by GNU Autoconf 2.59. Invocation command line was + + $ $0 $@ + +_ACEOF +{ +cat <<_ASUNAME +## --------- ## +## Platform. ## +## --------- ## + +hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` + +/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` +hostinfo = `(hostinfo) 2>/dev/null || echo unknown` +/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` +/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` + +_ASUNAME + +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + echo "PATH: $as_dir" +done + +} >&5 + +cat >&5 <<_ACEOF + + +## ----------- ## +## Core tests. ## +## ----------- ## + +_ACEOF + + +# Keep a trace of the command line. +# Strip out --no-create and --no-recursion so they do not pile up. +# Strip out --silent because we don't want to record it for future runs. +# Also quote any args containing shell meta-characters. +# Make two passes to allow for proper duplicate-argument suppression. +ac_configure_args= +ac_configure_args0= +ac_configure_args1= +ac_sep= +ac_must_keep_next=false +for ac_pass in 1 2 +do + for ac_arg + do + case $ac_arg in + -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + continue ;; + *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) + ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + case $ac_pass in + 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;; + 2) + ac_configure_args1="$ac_configure_args1 '$ac_arg'" + if test $ac_must_keep_next = true; then + ac_must_keep_next=false # Got value, back to normal. + else + case $ac_arg in + *=* | --config-cache | -C | -disable-* | --disable-* \ + | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ + | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ + | -with-* | --with-* | -without-* | --without-* | --x) + case "$ac_configure_args0 " in + "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; + esac + ;; + -* ) ac_must_keep_next=true ;; + esac + fi + ac_configure_args="$ac_configure_args$ac_sep'$ac_arg'" + # Get rid of the leading space. + ac_sep=" " + ;; + esac + done +done +$as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; } +$as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; } + +# When interrupted or exit'd, cleanup temporary files, and complete +# config.log. We remove comments because anyway the quotes in there +# would cause problems or look ugly. +# WARNING: Be sure not to use single quotes in there, as some shells, +# such as our DU 5.0 friend, will then `close' the trap. +trap 'exit_status=$? + # Save into config.log some information that might help in debugging. + { + echo + + cat <<\_ASBOX +## ---------------- ## +## Cache variables. ## +## ---------------- ## +_ASBOX + echo + # The following way of writing the cache mishandles newlines in values, +{ + (set) 2>&1 | + case `(ac_space='"'"' '"'"'; set | grep ac_space) 2>&1` in + *ac_space=\ *) + sed -n \ + "s/'"'"'/'"'"'\\\\'"'"''"'"'/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='"'"'\\2'"'"'/p" + ;; + *) + sed -n \ + "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" + ;; + esac; +} + echo + + cat <<\_ASBOX +## ----------------- ## +## Output variables. ## +## ----------------- ## +_ASBOX + echo + for ac_var in $ac_subst_vars + do + eval ac_val=$`echo $ac_var` + echo "$ac_var='"'"'$ac_val'"'"'" + done | sort + echo + + if test -n "$ac_subst_files"; then + cat <<\_ASBOX +## ------------- ## +## Output files. ## +## ------------- ## +_ASBOX + echo + for ac_var in $ac_subst_files + do + eval ac_val=$`echo $ac_var` + echo "$ac_var='"'"'$ac_val'"'"'" + done | sort + echo + fi + + if test -s confdefs.h; then + cat <<\_ASBOX +## ----------- ## +## confdefs.h. ## +## ----------- ## +_ASBOX + echo + sed "/^$/d" confdefs.h | sort + echo + fi + test "$ac_signal" != 0 && + echo "$as_me: caught signal $ac_signal" + echo "$as_me: exit $exit_status" + } >&5 + rm -f core *.core && + rm -rf conftest* confdefs* conf$$* $ac_clean_files && + exit $exit_status + ' 0 +for ac_signal in 1 2 13 15; do + trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal +done +ac_signal=0 + +# confdefs.h avoids OS command line length limits that DEFS can exceed. +rm -rf conftest* confdefs.h +# AIX cpp loses on an empty file, so make sure it contains at least a newline. +echo >confdefs.h + +# Predefined preprocessor variables. + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_NAME "$PACKAGE_NAME" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_TARNAME "$PACKAGE_TARNAME" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_VERSION "$PACKAGE_VERSION" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_STRING "$PACKAGE_STRING" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" +_ACEOF + + +# Let the site file select an alternate cache file if it wants to. +# Prefer explicitly selected file to automatically selected ones. +if test -z "$CONFIG_SITE"; then + if test "x$prefix" != xNONE; then + CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" + else + CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" + fi +fi +for ac_site_file in $CONFIG_SITE; do + if test -r "$ac_site_file"; then + { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5 +echo "$as_me: loading site script $ac_site_file" >&6;} + sed 's/^/| /' "$ac_site_file" >&5 + . "$ac_site_file" + fi +done + +if test -r "$cache_file"; then + # Some versions of bash will fail to source /dev/null (special + # files actually), so we avoid doing that. + if test -f "$cache_file"; then + { echo "$as_me:$LINENO: loading cache $cache_file" >&5 +echo "$as_me: loading cache $cache_file" >&6;} + case $cache_file in + [\\/]* | ?:[\\/]* ) . $cache_file;; + *) . ./$cache_file;; + esac + fi +else + { echo "$as_me:$LINENO: creating cache $cache_file" >&5 +echo "$as_me: creating cache $cache_file" >&6;} + >$cache_file +fi + +# Check that the precious variables saved in the cache have kept the same +# value. +ac_cache_corrupted=false +for ac_var in `(set) 2>&1 | + sed -n 's/^ac_env_\([a-zA-Z_0-9]*\)_set=.*/\1/p'`; do + eval ac_old_set=\$ac_cv_env_${ac_var}_set + eval ac_new_set=\$ac_env_${ac_var}_set + eval ac_old_val="\$ac_cv_env_${ac_var}_value" + eval ac_new_val="\$ac_env_${ac_var}_value" + case $ac_old_set,$ac_new_set in + set,) + { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 +echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,set) + { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5 +echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,);; + *) + if test "x$ac_old_val" != "x$ac_new_val"; then + { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5 +echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} + { echo "$as_me:$LINENO: former value: $ac_old_val" >&5 +echo "$as_me: former value: $ac_old_val" >&2;} + { echo "$as_me:$LINENO: current value: $ac_new_val" >&5 +echo "$as_me: current value: $ac_new_val" >&2;} + ac_cache_corrupted=: + fi;; + esac + # Pass precious variables to config.status. + if test "$ac_new_set" = set; then + case $ac_new_val in + *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) + ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; + *) ac_arg=$ac_var=$ac_new_val ;; + esac + case " $ac_configure_args " in + *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. + *) ac_configure_args="$ac_configure_args '$ac_arg'" ;; + esac + fi +done +if $ac_cache_corrupted; then + { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5 +echo "$as_me: error: changes in the environment can compromise the build" >&2;} + { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5 +echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;} + { (exit 1); exit 1; }; } +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + + + + + + + + + + + + + + + + + + + +{ echo "$as_me:$LINENO: Configuring ccache" >&5 +echo "$as_me: Configuring ccache" >&6;} + + ac_config_headers="$ac_config_headers config.h" + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. +set dummy ${ac_tool_prefix}gcc; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="${ac_tool_prefix}gcc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "gcc", so it can be a program name with args. +set dummy gcc; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="gcc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + CC=$ac_ct_CC +else + CC="$ac_cv_prog_CC" +fi + +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. +set dummy ${ac_tool_prefix}cc; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="${ac_tool_prefix}cc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="cc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + CC=$ac_ct_CC +else + CC="$ac_cv_prog_CC" +fi + +fi +if test -z "$CC"; then + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + ac_prog_rejected=no +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue + fi + ac_cv_prog_CC="cc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +if test $ac_prog_rejected = yes; then + # We found a bogon in the path, so make sure we never use it. + set dummy $ac_cv_prog_CC + shift + if test $# != 0; then + # We chose a different compiler from the bogus one. + # However, it has the same basename, so the bogon will be chosen + # first if we set CC to just the basename; use the full file name. + shift + ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" + fi +fi +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + for ac_prog in cl + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="$ac_tool_prefix$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$CC" && break + done +fi +if test -z "$CC"; then + ac_ct_CC=$CC + for ac_prog in cl +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$ac_ct_CC" && break +done + + CC=$ac_ct_CC +fi + +fi + + +test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH +See \`config.log' for more details." >&5 +echo "$as_me: error: no acceptable C compiler found in \$PATH +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } + +# Provide some information about the compiler. +echo "$as_me:$LINENO:" \ + "checking for C compiler version" >&5 +ac_compiler=`set X $ac_compile; echo $2` +{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version &5\"") >&5 + (eval $ac_compiler --version &5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v &5\"") >&5 + (eval $ac_compiler -v &5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V &5\"") >&5 + (eval $ac_compiler -V &5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } + +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files a.out a.exe b.out" +# Try to create an executable without -o first, disregard a.out. +# It will help us diagnose broken compilers, and finding out an intuition +# of exeext. +echo "$as_me:$LINENO: checking for C compiler default output file name" >&5 +echo $ECHO_N "checking for C compiler default output file name... $ECHO_C" >&6 +ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` +if { (eval echo "$as_me:$LINENO: \"$ac_link_default\"") >&5 + (eval $ac_link_default) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + # Find the output, starting from the most likely. This scheme is +# not robust to junk in `.', hence go to wildcards (a.*) only as a last +# resort. + +# Be careful to initialize this variable, since it used to be cached. +# Otherwise an old cache value of `no' led to `EXEEXT = no' in a Makefile. +ac_cv_exeext= +# b.out is created by i960 compilers. +for ac_file in a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out +do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) + ;; + conftest.$ac_ext ) + # This is the source file. + ;; + [ab].out ) + # We found the default executable, but exeext='' is most + # certainly right. + break;; + *.* ) + ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + # FIXME: I believe we export ac_cv_exeext for Libtool, + # but it would be cool to find out if it's true. Does anybody + # maintain Libtool? --akim. + export ac_cv_exeext + break;; + * ) + break;; + esac +done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { echo "$as_me:$LINENO: error: C compiler cannot create executables +See \`config.log' for more details." >&5 +echo "$as_me: error: C compiler cannot create executables +See \`config.log' for more details." >&2;} + { (exit 77); exit 77; }; } +fi + +ac_exeext=$ac_cv_exeext +echo "$as_me:$LINENO: result: $ac_file" >&5 +echo "${ECHO_T}$ac_file" >&6 + +# Check the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +echo "$as_me:$LINENO: checking whether the C compiler works" >&5 +echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6 +# FIXME: These cross compiler hacks should be removed for Autoconf 3.0 +# If not cross compiling, check that we can run a simple program. +if test "$cross_compiling" != yes; then + if { ac_try='./$ac_file' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + cross_compiling=no + else + if test "$cross_compiling" = maybe; then + cross_compiling=yes + else + { { echo "$as_me:$LINENO: error: cannot run C compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot run C compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } + fi + fi +fi +echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + +rm -f a.out a.exe conftest$ac_cv_exeext b.out +ac_clean_files=$ac_clean_files_save +# Check the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +echo "$as_me:$LINENO: checking whether we are cross compiling" >&5 +echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6 +echo "$as_me:$LINENO: result: $cross_compiling" >&5 +echo "${ECHO_T}$cross_compiling" >&6 + +echo "$as_me:$LINENO: checking for suffix of executables" >&5 +echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6 +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + # If both `conftest.exe' and `conftest' are `present' (well, observable) +# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will +# work properly (i.e., refer to `conftest.exe'), while it won't with +# `rm'. +for ac_file in conftest.exe conftest conftest.*; do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) ;; + *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + export ac_cv_exeext + break;; + * ) break;; + esac +done +else + { { echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi + +rm -f conftest$ac_cv_exeext +echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5 +echo "${ECHO_T}$ac_cv_exeext" >&6 + +rm -f conftest.$ac_ext +EXEEXT=$ac_cv_exeext +ac_exeext=$EXEEXT +echo "$as_me:$LINENO: checking for suffix of object files" >&5 +echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6 +if test "${ac_cv_objext+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.o conftest.obj +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + for ac_file in `(ls conftest.o conftest.obj; ls conftest.*) 2>/dev/null`; do + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg ) ;; + *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` + break;; + esac +done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute suffix of object files: cannot compile +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi + +rm -f conftest.$ac_cv_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_objext" >&5 +echo "${ECHO_T}$ac_cv_objext" >&6 +OBJEXT=$ac_cv_objext +ac_objext=$OBJEXT +echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 +echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6 +if test "${ac_cv_c_compiler_gnu+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_compiler_gnu=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_compiler_gnu=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +ac_cv_c_compiler_gnu=$ac_compiler_gnu + +fi +echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 +echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6 +GCC=`test $ac_compiler_gnu = yes && echo yes` +ac_test_CFLAGS=${CFLAGS+set} +ac_save_CFLAGS=$CFLAGS +CFLAGS="-g" +echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 +echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6 +if test "${ac_cv_prog_cc_g+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_prog_cc_g=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_prog_cc_g=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 +echo "${ECHO_T}$ac_cv_prog_cc_g" >&6 +if test "$ac_test_CFLAGS" = set; then + CFLAGS=$ac_save_CFLAGS +elif test $ac_cv_prog_cc_g = yes; then + if test "$GCC" = yes; then + CFLAGS="-g -O2" + else + CFLAGS="-g" + fi +else + if test "$GCC" = yes; then + CFLAGS="-O2" + else + CFLAGS= + fi +fi +echo "$as_me:$LINENO: checking for $CC option to accept ANSI C" >&5 +echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6 +if test "${ac_cv_prog_cc_stdc+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_prog_cc_stdc=no +ac_save_CC=$CC +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#include +#include +/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ +struct buf { int x; }; +FILE * (*rcsopen) (struct buf *, struct stat *, int); +static char *e (p, i) + char **p; + int i; +{ + return p[i]; +} +static char *f (char * (*g) (char **, int), char **p, ...) +{ + char *s; + va_list v; + va_start (v,p); + s = g (p, va_arg (v,int)); + va_end (v); + return s; +} + +/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has + function prototypes and stuff, but not '\xHH' hex character constants. + These don't provoke an error unfortunately, instead are silently treated + as 'x'. The following induces an error, until -std1 is added to get + proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an + array size at least. It's necessary to write '\x00'==0 to get something + that's true only with -std1. */ +int osf4_cc_array ['\x00' == 0 ? 1 : -1]; + +int test (int i, double x); +struct s1 {int (*f) (int a);}; +struct s2 {int (*f) (double a);}; +int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); +int argc; +char **argv; +int +main () +{ +return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; + ; + return 0; +} +_ACEOF +# Don't try gcc -ansi; that turns off useful extensions and +# breaks some systems' header files. +# AIX -qlanglvl=ansi +# Ultrix and OSF/1 -std1 +# HP-UX 10.20 and later -Ae +# HP-UX older versions -Aa -D_HPUX_SOURCE +# SVR4 -Xc -D__EXTENSIONS__ +for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +do + CC="$ac_save_CC $ac_arg" + rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_prog_cc_stdc=$ac_arg +break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext +done +rm -f conftest.$ac_ext conftest.$ac_objext +CC=$ac_save_CC + +fi + +case "x$ac_cv_prog_cc_stdc" in + x|xno) + echo "$as_me:$LINENO: result: none needed" >&5 +echo "${ECHO_T}none needed" >&6 ;; + *) + echo "$as_me:$LINENO: result: $ac_cv_prog_cc_stdc" >&5 +echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6 + CC="$CC $ac_cv_prog_cc_stdc" ;; +esac + +# Some people use a C++ compiler to compile C. Since we use `exit', +# in C++ we need to declare it. In case someone uses the same compiler +# for both compiling C and C++ we need to have the C++ compiler decide +# the declaration of exit, since it's the most demanding environment. +cat >conftest.$ac_ext <<_ACEOF +#ifndef __cplusplus + choke me +#endif +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + for ac_declaration in \ + '' \ + 'extern "C" void std::exit (int) throw (); using std::exit;' \ + 'extern "C" void std::exit (int); using std::exit;' \ + 'extern "C" void exit (int) throw ();' \ + 'extern "C" void exit (int);' \ + 'void exit (int);' +do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_declaration +#include +int +main () +{ +exit (42); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +continue +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_declaration +int +main () +{ +exit (42); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +done +rm -f conftest* +if test -n "$ac_declaration"; then + echo '#ifdef __cplusplus' >>confdefs.h + echo $ac_declaration >>confdefs.h + echo '#endif' >>confdefs.h +fi + +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5 +echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6 +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then + if test "${ac_cv_prog_CPP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + # Double quotes because CPP needs to be expanded + for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" + do + ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.$ac_ext + + # OK, works on sane cases. Now check whether non-existent headers + # can be detected and how. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + # Broken: success on invalid input. +continue +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.err conftest.$ac_ext +if $ac_preproc_ok; then + break +fi + + done + ac_cv_prog_CPP=$CPP + +fi + CPP=$ac_cv_prog_CPP +else + ac_cv_prog_CPP=$CPP +fi +echo "$as_me:$LINENO: result: $CPP" >&5 +echo "${ECHO_T}$CPP" >&6 +ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.$ac_ext + + # OK, works on sane cases. Now check whether non-existent headers + # can be detected and how. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + # Broken: success on invalid input. +continue +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.err conftest.$ac_ext +if $ac_preproc_ok; then + : +else + { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details." >&5 +echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +ac_aux_dir= +for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do + if test -f $ac_dir/install-sh; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install-sh -c" + break + elif test -f $ac_dir/install.sh; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install.sh -c" + break + elif test -f $ac_dir/shtool; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/shtool install -c" + break + fi +done +if test -z "$ac_aux_dir"; then + { { echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&5 +echo "$as_me: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&2;} + { (exit 1); exit 1; }; } +fi +ac_config_guess="$SHELL $ac_aux_dir/config.guess" +ac_config_sub="$SHELL $ac_aux_dir/config.sub" +ac_configure="$SHELL $ac_aux_dir/configure" # This should be Cygnus configure. + +# Find a good install program. We prefer a C program (faster), +# so one script is as good as another. But avoid the broken or +# incompatible versions: +# SysV /etc/install, /usr/sbin/install +# SunOS /usr/etc/install +# IRIX /sbin/install +# AIX /bin/install +# AmigaOS /C/install, which installs bootblocks on floppy discs +# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag +# AFS /usr/afsws/bin/install, which mishandles nonexistent args +# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" +# OS/2's system install, which has a completely different semantic +# ./install, which can be erroneously created by make from ./install.sh. +echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5 +echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6 +if test -z "$INSTALL"; then +if test "${ac_cv_path_install+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + # Account for people who put trailing slashes in PATH elements. +case $as_dir/ in + ./ | .// | /cC/* | \ + /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ + ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \ + /usr/ucb/* ) ;; + *) + # OSF1 and SCO ODT 3.0 have their own names for install. + # Don't use installbsd from OSF since it installs stuff as root + # by default. + for ac_prog in ginstall scoinst install; do + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then + if test $ac_prog = install && + grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # AIX install. It has an incompatible calling convention. + : + elif test $ac_prog = install && + grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # program-specific install script used by HP pwplus--don't use. + : + else + ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" + break 3 + fi + fi + done + done + ;; +esac +done + + +fi + if test "${ac_cv_path_install+set}" = set; then + INSTALL=$ac_cv_path_install + else + # As a last resort, use the slow shell script. We don't cache a + # path for INSTALL within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the path is relative. + INSTALL=$ac_install_sh + fi +fi +echo "$as_me:$LINENO: result: $INSTALL" >&5 +echo "${ECHO_T}$INSTALL" >&6 + +# Use test -z because SunOS4 sh mishandles braces in ${var-val}. +# It thinks the first close brace ends the variable substitution. +test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' + +test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' + +test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' + + + +cat >>confdefs.h <<\_ACEOF +#define _GNU_SOURCE 1 +_ACEOF + + +# If GCC, turn on warnings. +if test "x$GCC" = "xyes" +then + CFLAGS="$CFLAGS -Wall -W" +else + CFLAGS="$CFLAGS -O" +fi + + + + + + + +ac_header_dirent=no +for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h; do + as_ac_Header=`echo "ac_cv_header_dirent_$ac_hdr" | $as_tr_sh` +echo "$as_me:$LINENO: checking for $ac_hdr that defines DIR" >&5 +echo $ECHO_N "checking for $ac_hdr that defines DIR... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include <$ac_hdr> + +int +main () +{ +if ((DIR *) 0) +return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_Header=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +eval "$as_ac_Header=no" +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_hdr" | $as_tr_cpp` 1 +_ACEOF + +ac_header_dirent=$ac_hdr; break +fi + +done +# Two versions of opendir et al. are in -ldir and -lx on SCO Xenix. +if test $ac_header_dirent = dirent.h; then + echo "$as_me:$LINENO: checking for library containing opendir" >&5 +echo $ECHO_N "checking for library containing opendir... $ECHO_C" >&6 +if test "${ac_cv_search_opendir+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_func_search_save_LIBS=$LIBS +ac_cv_search_opendir=no +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char opendir (); +int +main () +{ +opendir (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_search_opendir="none required" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +if test "$ac_cv_search_opendir" = no; then + for ac_lib in dir; do + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char opendir (); +int +main () +{ +opendir (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_search_opendir="-l$ac_lib" +break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + done +fi +LIBS=$ac_func_search_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_search_opendir" >&5 +echo "${ECHO_T}$ac_cv_search_opendir" >&6 +if test "$ac_cv_search_opendir" != no; then + test "$ac_cv_search_opendir" = "none required" || LIBS="$ac_cv_search_opendir $LIBS" + +fi + +else + echo "$as_me:$LINENO: checking for library containing opendir" >&5 +echo $ECHO_N "checking for library containing opendir... $ECHO_C" >&6 +if test "${ac_cv_search_opendir+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_func_search_save_LIBS=$LIBS +ac_cv_search_opendir=no +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char opendir (); +int +main () +{ +opendir (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_search_opendir="none required" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +if test "$ac_cv_search_opendir" = no; then + for ac_lib in x; do + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char opendir (); +int +main () +{ +opendir (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_search_opendir="-l$ac_lib" +break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + done +fi +LIBS=$ac_func_search_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_search_opendir" >&5 +echo "${ECHO_T}$ac_cv_search_opendir" >&6 +if test "$ac_cv_search_opendir" != no; then + test "$ac_cv_search_opendir" = "none required" || LIBS="$ac_cv_search_opendir $LIBS" + +fi + +fi + +echo "$as_me:$LINENO: checking whether time.h and sys/time.h may both be included" >&5 +echo $ECHO_N "checking whether time.h and sys/time.h may both be included... $ECHO_C" >&6 +if test "${ac_cv_header_time+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#include + +int +main () +{ +if ((struct tm *) 0) +return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_header_time=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_header_time=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_header_time" >&5 +echo "${ECHO_T}$ac_cv_header_time" >&6 +if test $ac_cv_header_time = yes; then + +cat >>confdefs.h <<\_ACEOF +#define TIME_WITH_SYS_TIME 1 +_ACEOF + +fi + +echo "$as_me:$LINENO: checking for sys/wait.h that is POSIX.1 compatible" >&5 +echo $ECHO_N "checking for sys/wait.h that is POSIX.1 compatible... $ECHO_C" >&6 +if test "${ac_cv_header_sys_wait_h+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#ifndef WEXITSTATUS +# define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8) +#endif +#ifndef WIFEXITED +# define WIFEXITED(stat_val) (((stat_val) & 255) == 0) +#endif + +int +main () +{ + int s; + wait (&s); + s = WIFEXITED (s) ? WEXITSTATUS (s) : 1; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_header_sys_wait_h=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_header_sys_wait_h=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_header_sys_wait_h" >&5 +echo "${ECHO_T}$ac_cv_header_sys_wait_h" >&6 +if test $ac_cv_header_sys_wait_h = yes; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_SYS_WAIT_H 1 +_ACEOF + +fi + + + +echo "$as_me:$LINENO: checking for egrep" >&5 +echo $ECHO_N "checking for egrep... $ECHO_C" >&6 +if test "${ac_cv_prog_egrep+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if echo a | (grep -E '(a|b)') >/dev/null 2>&1 + then ac_cv_prog_egrep='grep -E' + else ac_cv_prog_egrep='egrep' + fi +fi +echo "$as_me:$LINENO: result: $ac_cv_prog_egrep" >&5 +echo "${ECHO_T}$ac_cv_prog_egrep" >&6 + EGREP=$ac_cv_prog_egrep + + +echo "$as_me:$LINENO: checking for ANSI C header files" >&5 +echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6 +if test "${ac_cv_header_stdc+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#include +#include + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_header_stdc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_header_stdc=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "memchr" >/dev/null 2>&1; then + : +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "free" >/dev/null 2>&1; then + : +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. + if test "$cross_compiling" = yes; then + : +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#if ((' ' & 0x0FF) == 0x020) +# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#else +# define ISLOWER(c) \ + (('a' <= (c) && (c) <= 'i') \ + || ('j' <= (c) && (c) <= 'r') \ + || ('s' <= (c) && (c) <= 'z')) +# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) +#endif + +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int +main () +{ + int i; + for (i = 0; i < 256; i++) + if (XOR (islower (i), ISLOWER (i)) + || toupper (i) != TOUPPER (i)) + exit(2); + exit (0); +} +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +ac_cv_header_stdc=no +fi +rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi +fi +fi +echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 +echo "${ECHO_T}$ac_cv_header_stdc" >&6 +if test $ac_cv_header_stdc = yes; then + +cat >>confdefs.h <<\_ACEOF +#define STDC_HEADERS 1 +_ACEOF + +fi + +# On IRIX 5.3, sys/types and inttypes.h are conflicting. + + + + + + + + + +for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ + inttypes.h stdint.h unistd.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default + +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_Header=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +eval "$as_ac_Header=no" +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + + + + + + +for ac_header in ctype.h strings.h stdlib.h string.h pwd.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 +else + # Is the header compilable? +echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_header_compiler=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6 + +# Is the header present? +echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi +rm -f conftest.err conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6 + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + ( + cat <<\_ASBOX +## ------------------------------------------ ## +## Report this to the AC_PACKAGE_NAME lists. ## +## ------------------------------------------ ## +_ASBOX + ) | + sed "s/^/$as_me: WARNING: /" >&2 + ;; +esac +echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 + +fi +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + + + + + + + +for ac_func in realpath snprintf vsnprintf vasprintf asprintf mkstemp +do +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 +if eval "test \"\${$as_ac_var+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case declares $ac_func. + For example, HP-UX 11i declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $ac_func + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +{ +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +char (*f) () = $ac_func; +#endif +#ifdef __cplusplus +} +#endif + +int +main () +{ +return f != $ac_func; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +eval "$as_ac_var=no" +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + + + +for ac_func in gethostname getpwuid +do +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 +if eval "test \"\${$as_ac_var+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case declares $ac_func. + For example, HP-UX 11i declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $ac_func + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +{ +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +char (*f) () = $ac_func; +#endif +#ifdef __cplusplus +} +#endif + +int +main () +{ +return f != $ac_func; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +eval "$as_ac_var=no" +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + + +echo "$as_me:$LINENO: checking for compar_fn_t in stdlib.h" >&5 +echo $ECHO_N "checking for compar_fn_t in stdlib.h... $ECHO_C" >&6 +if test "${ccache_cv_COMPAR_FN_T+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +int +main () +{ + +void test_fn(void) { qsort(NULL, 0, 0, (__compar_fn_t)NULL); } + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ccache_cv_COMPAR_FN_T=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ccache_cv_COMPAR_FN_T=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ccache_cv_COMPAR_FN_T" >&5 +echo "${ECHO_T}$ccache_cv_COMPAR_FN_T" >&6 +if test x"$ccache_cv_COMPAR_FN_T" = x"yes"; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_COMPAR_FN_T 1 +_ACEOF + +fi + +echo "$as_me:$LINENO: checking for C99 vsnprintf" >&5 +echo $ECHO_N "checking for C99 vsnprintf... $ECHO_C" >&6 +if test "${ccache_cv_HAVE_C99_VSNPRINTF+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + +if test "$cross_compiling" = yes; then + ccache_cv_HAVE_C99_VSNPRINTF=cross +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +#include +#include +void foo(const char *format, ...) { + va_list ap; + int len; + char buf[5]; + + va_start(ap, format); + len = vsnprintf(0, 0, format, ap); + va_end(ap); + if (len != 5) exit(1); + + if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1); + + exit(0); +} +main() { foo("hello"); } + +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ccache_cv_HAVE_C99_VSNPRINTF=yes +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +ccache_cv_HAVE_C99_VSNPRINTF=no +fi +rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi +fi +echo "$as_me:$LINENO: result: $ccache_cv_HAVE_C99_VSNPRINTF" >&5 +echo "${ECHO_T}$ccache_cv_HAVE_C99_VSNPRINTF" >&6 +if test x"$ccache_cv_HAVE_C99_VSNPRINTF" = x"yes"; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_C99_VSNPRINTF 1 +_ACEOF + +fi + + ac_config_files="$ac_config_files Makefile" + +cat >confcache <<\_ACEOF +# This file is a shell script that caches the results of configure +# tests run on this system so they can be shared between configure +# scripts and configure runs, see configure's option --config-cache. +# It is not useful on other systems. If it contains results you don't +# want to keep, you may remove or edit it. +# +# config.status only pays attention to the cache file if you give it +# the --recheck option to rerun configure. +# +# `ac_cv_env_foo' variables (set or unset) will be overridden when +# loading this file, other *unset* `ac_cv_foo' will be assigned the +# following values. + +_ACEOF + +# The following way of writing the cache mishandles newlines in values, +# but we know of no workaround that is simple, portable, and efficient. +# So, don't put newlines in cache variables' values. +# Ultrix sh set writes to stderr and can't be redirected directly, +# and sets the high bit in the cache file unless we assign to the vars. +{ + (set) 2>&1 | + case `(ac_space=' '; set | grep ac_space) 2>&1` in + *ac_space=\ *) + # `set' does not quote correctly, so add quotes (double-quote + # substitution turns \\\\ into \\, and sed turns \\ into \). + sed -n \ + "s/'/'\\\\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" + ;; + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n \ + "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" + ;; + esac; +} | + sed ' + t clear + : clear + s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ + t end + /^ac_cv_env/!s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ + : end' >>confcache +if diff $cache_file confcache >/dev/null 2>&1; then :; else + if test -w $cache_file; then + test "x$cache_file" != "x/dev/null" && echo "updating cache $cache_file" + cat confcache >$cache_file + else + echo "not updating unwritable cache $cache_file" + fi +fi +rm -f confcache + +test "x$prefix" = xNONE && prefix=$ac_default_prefix +# Let make expand exec_prefix. +test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' + +# VPATH may cause trouble with some makes, so we remove $(srcdir), +# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and +# trailing colons and then remove the whole line if VPATH becomes empty +# (actually we leave an empty line to preserve line numbers). +if test "x$srcdir" = x.; then + ac_vpsub='/^[ ]*VPATH[ ]*=/{ +s/:*\$(srcdir):*/:/; +s/:*\${srcdir}:*/:/; +s/:*@srcdir@:*/:/; +s/^\([^=]*=[ ]*\):*/\1/; +s/:*$//; +s/^[^=]*=[ ]*$//; +}' +fi + +DEFS=-DHAVE_CONFIG_H + +ac_libobjs= +ac_ltlibobjs= +for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue + # 1. Remove the extension, and $U if already installed. + ac_i=`echo "$ac_i" | + sed 's/\$U\././;s/\.o$//;s/\.obj$//'` + # 2. Add them. + ac_libobjs="$ac_libobjs $ac_i\$U.$ac_objext" + ac_ltlibobjs="$ac_ltlibobjs $ac_i"'$U.lo' +done +LIBOBJS=$ac_libobjs + +LTLIBOBJS=$ac_ltlibobjs + + + +: ${CONFIG_STATUS=./config.status} +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files $CONFIG_STATUS" +{ echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5 +echo "$as_me: creating $CONFIG_STATUS" >&6;} +cat >$CONFIG_STATUS <<_ACEOF +#! $SHELL +# Generated by $as_me. +# Run this file to recreate the current configuration. +# Compiler output produced by configure, useful for debugging +# configure, is in config.log if it exists. + +debug=false +ac_cs_recheck=false +ac_cs_silent=false +SHELL=\${CONFIG_SHELL-$SHELL} +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF +## --------------------- ## +## M4sh Initialization. ## +## --------------------- ## + +# Be Bourne compatible +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' +elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then + set -o posix +fi +DUALCASE=1; export DUALCASE # for MKS sh + +# Support unset when possible. +if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then + as_unset=unset +else + as_unset=false +fi + + +# Work around bugs in pre-3.0 UWIN ksh. +$as_unset ENV MAIL MAILPATH +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +for as_var in \ + LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ + LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ + LC_TELEPHONE LC_TIME +do + if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then + eval $as_var=C; export $as_var + else + $as_unset $as_var + fi +done + +# Required to use basename. +if expr a : '\(a\)' >/dev/null 2>&1; then + as_expr=expr +else + as_expr=false +fi + +if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + + +# Name of the executable. +as_me=`$as_basename "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)$' \| \ + . : '\(.\)' 2>/dev/null || +echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; } + /^X\/\(\/\/\)$/{ s//\1/; q; } + /^X\/\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + + +# PATH needs CR, and LINENO needs CR and PATH. +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh +fi + + + as_lineno_1=$LINENO + as_lineno_2=$LINENO + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x$as_lineno_3" = "x$as_lineno_2" || { + # Find who we are. Look in the path if we contain no path at all + # relative or not. + case $0 in + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break +done + + ;; + esac + # We did not find ourselves, most probably we were run as `sh COMMAND' + # in which case we are not to be found in the path. + if test "x$as_myself" = x; then + as_myself=$0 + fi + if test ! -f "$as_myself"; then + { { echo "$as_me:$LINENO: error: cannot find myself; rerun with an absolute path" >&5 +echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2;} + { (exit 1); exit 1; }; } + fi + case $CONFIG_SHELL in + '') + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for as_base in sh bash ksh sh5; do + case $as_dir in + /*) + if ("$as_dir/$as_base" -c ' + as_lineno_1=$LINENO + as_lineno_2=$LINENO + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then + $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; } + $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; } + CONFIG_SHELL=$as_dir/$as_base + export CONFIG_SHELL + exec "$CONFIG_SHELL" "$0" ${1+"$@"} + fi;; + esac + done +done +;; + esac + + # Create $as_me.lineno as a copy of $as_myself, but with $LINENO + # uniformly replaced by the line number. The first 'sed' inserts a + # line-number line before each line; the second 'sed' does the real + # work. The second script uses 'N' to pair each line-number line + # with the numbered line, and appends trailing '-' during + # substitution so that $LINENO is not a special case at line end. + # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the + # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-) + sed '=' <$as_myself | + sed ' + N + s,$,-, + : loop + s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3, + t loop + s,-$,, + s,^['$as_cr_digits']*\n,, + ' >$as_me.lineno && + chmod +x $as_me.lineno || + { { echo "$as_me:$LINENO: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&5 +echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2;} + { (exit 1); exit 1; }; } + + # Don't try to exec as it changes $[0], causing all sort of problems + # (the dirname of $[0] is not the place where we might find the + # original and so on. Autoconf is especially sensible to this). + . ./$as_me.lineno + # Exit status is that of the last command. + exit +} + + +case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in + *c*,-n*) ECHO_N= ECHO_C=' +' ECHO_T=' ' ;; + *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; + *) ECHO_N= ECHO_C='\c' ECHO_T= ;; +esac + +if expr a : '\(a\)' >/dev/null 2>&1; then + as_expr=expr +else + as_expr=false +fi + +rm -f conf$$ conf$$.exe conf$$.file +echo >conf$$.file +if ln -s conf$$.file conf$$ 2>/dev/null; then + # We could just check for DJGPP; but this test a) works b) is more generic + # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). + if test -f conf$$.exe; then + # Don't use ln at all; we don't have any links + as_ln_s='cp -p' + else + as_ln_s='ln -s' + fi +elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln +else + as_ln_s='cp -p' +fi +rm -f conf$$ conf$$.exe conf$$.file + +if mkdir -p . 2>/dev/null; then + as_mkdir_p=: +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + +as_executable_p="test -f" + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + +# IFS +# We need space, tab and new line, in precisely that order. +as_nl=' +' +IFS=" $as_nl" + +# CDPATH. +$as_unset CDPATH + +exec 6>&1 + +# Open the log real soon, to keep \$[0] and so on meaningful, and to +# report actual input values of CONFIG_FILES etc. instead of their +# values after options handling. Logging --version etc. is OK. +exec 5>>config.log +{ + echo + sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX +## Running $as_me. ## +_ASBOX +} >&5 +cat >&5 <<_CSEOF + +This file was extended by $as_me, which was +generated by GNU Autoconf 2.59. Invocation command line was + + CONFIG_FILES = $CONFIG_FILES + CONFIG_HEADERS = $CONFIG_HEADERS + CONFIG_LINKS = $CONFIG_LINKS + CONFIG_COMMANDS = $CONFIG_COMMANDS + $ $0 $@ + +_CSEOF +echo "on `(hostname || uname -n) 2>/dev/null | sed 1q`" >&5 +echo >&5 +_ACEOF + +# Files that config.status was made for. +if test -n "$ac_config_files"; then + echo "config_files=\"$ac_config_files\"" >>$CONFIG_STATUS +fi + +if test -n "$ac_config_headers"; then + echo "config_headers=\"$ac_config_headers\"" >>$CONFIG_STATUS +fi + +if test -n "$ac_config_links"; then + echo "config_links=\"$ac_config_links\"" >>$CONFIG_STATUS +fi + +if test -n "$ac_config_commands"; then + echo "config_commands=\"$ac_config_commands\"" >>$CONFIG_STATUS +fi + +cat >>$CONFIG_STATUS <<\_ACEOF + +ac_cs_usage="\ +\`$as_me' instantiates files from templates according to the +current configuration. + +Usage: $0 [OPTIONS] [FILE]... + + -h, --help print this help, then exit + -V, --version print version number, then exit + -q, --quiet do not print progress messages + -d, --debug don't remove temporary files + --recheck update $as_me by reconfiguring in the same conditions + --file=FILE[:TEMPLATE] + instantiate the configuration file FILE + --header=FILE[:TEMPLATE] + instantiate the configuration header FILE + +Configuration files: +$config_files + +Configuration headers: +$config_headers + +Report bugs to ." +_ACEOF + +cat >>$CONFIG_STATUS <<_ACEOF +ac_cs_version="\\ +config.status +configured by $0, generated by GNU Autoconf 2.59, + with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\" + +Copyright (C) 2003 Free Software Foundation, Inc. +This config.status script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it." +srcdir=$srcdir +INSTALL="$INSTALL" +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF +# If no file are specified by the user, then we need to provide default +# value. By we need to know if files were specified by the user. +ac_need_defaults=: +while test $# != 0 +do + case $1 in + --*=*) + ac_option=`expr "x$1" : 'x\([^=]*\)='` + ac_optarg=`expr "x$1" : 'x[^=]*=\(.*\)'` + ac_shift=: + ;; + -*) + ac_option=$1 + ac_optarg=$2 + ac_shift=shift + ;; + *) # This is not an option, so the user has probably given explicit + # arguments. + ac_option=$1 + ac_need_defaults=false;; + esac + + case $ac_option in + # Handling of the options. +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + ac_cs_recheck=: ;; + --version | --vers* | -V ) + echo "$ac_cs_version"; exit 0 ;; + --he | --h) + # Conflict between --help and --header + { { echo "$as_me:$LINENO: error: ambiguous option: $1 +Try \`$0 --help' for more information." >&5 +echo "$as_me: error: ambiguous option: $1 +Try \`$0 --help' for more information." >&2;} + { (exit 1); exit 1; }; };; + --help | --hel | -h ) + echo "$ac_cs_usage"; exit 0 ;; + --debug | --d* | -d ) + debug=: ;; + --file | --fil | --fi | --f ) + $ac_shift + CONFIG_FILES="$CONFIG_FILES $ac_optarg" + ac_need_defaults=false;; + --header | --heade | --head | --hea ) + $ac_shift + CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg" + ac_need_defaults=false;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil | --si | --s) + ac_cs_silent=: ;; + + # This is an error. + -*) { { echo "$as_me:$LINENO: error: unrecognized option: $1 +Try \`$0 --help' for more information." >&5 +echo "$as_me: error: unrecognized option: $1 +Try \`$0 --help' for more information." >&2;} + { (exit 1); exit 1; }; } ;; + + *) ac_config_targets="$ac_config_targets $1" ;; + + esac + shift +done + +ac_configure_extra_args= + +if $ac_cs_silent; then + exec 6>/dev/null + ac_configure_extra_args="$ac_configure_extra_args --silent" +fi + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF +if \$ac_cs_recheck; then + echo "running $SHELL $0 " $ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6 + exec $SHELL $0 $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion +fi + +_ACEOF + + + + + +cat >>$CONFIG_STATUS <<\_ACEOF +for ac_config_target in $ac_config_targets +do + case "$ac_config_target" in + # Handling of arguments. + "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;; + "config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; + *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 +echo "$as_me: error: invalid argument: $ac_config_target" >&2;} + { (exit 1); exit 1; }; };; + esac +done + +# If the user did not use the arguments to specify the items to instantiate, +# then the envvar interface is used. Set only those that are not. +# We use the long form for the default assignment because of an extremely +# bizarre bug on SunOS 4.1.3. +if $ac_need_defaults; then + test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files + test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers +fi + +# Have a temporary directory for convenience. Make it in the build tree +# simply because there is no reason to put it here, and in addition, +# creating and moving files from /tmp can sometimes cause problems. +# Create a temporary directory, and hook for its removal unless debugging. +$debug || +{ + trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0 + trap '{ (exit 1); exit 1; }' 1 2 13 15 +} + +# Create a (secure) tmp directory for tmp files. + +{ + tmp=`(umask 077 && mktemp -d -q "./confstatXXXXXX") 2>/dev/null` && + test -n "$tmp" && test -d "$tmp" +} || +{ + tmp=./confstat$$-$RANDOM + (umask 077 && mkdir $tmp) +} || +{ + echo "$me: cannot create a temporary directory in ." >&2 + { (exit 1); exit 1; } +} + +_ACEOF + +cat >>$CONFIG_STATUS <<_ACEOF + +# +# CONFIG_FILES section. +# + +# No need to generate the scripts if there are no CONFIG_FILES. +# This happens for instance when ./config.status config.h +if test -n "\$CONFIG_FILES"; then + # Protect against being on the right side of a sed subst in config.status. + sed 's/,@/@@/; s/@,/@@/; s/,;t t\$/@;t t/; /@;t t\$/s/[\\\\&,]/\\\\&/g; + s/@@/,@/; s/@@/@,/; s/@;t t\$/,;t t/' >\$tmp/subs.sed <<\\CEOF +s,@SHELL@,$SHELL,;t t +s,@PATH_SEPARATOR@,$PATH_SEPARATOR,;t t +s,@PACKAGE_NAME@,$PACKAGE_NAME,;t t +s,@PACKAGE_TARNAME@,$PACKAGE_TARNAME,;t t +s,@PACKAGE_VERSION@,$PACKAGE_VERSION,;t t +s,@PACKAGE_STRING@,$PACKAGE_STRING,;t t +s,@PACKAGE_BUGREPORT@,$PACKAGE_BUGREPORT,;t t +s,@exec_prefix@,$exec_prefix,;t t +s,@prefix@,$prefix,;t t +s,@program_transform_name@,$program_transform_name,;t t +s,@bindir@,$bindir,;t t +s,@sbindir@,$sbindir,;t t +s,@libexecdir@,$libexecdir,;t t +s,@datadir@,$datadir,;t t +s,@sysconfdir@,$sysconfdir,;t t +s,@sharedstatedir@,$sharedstatedir,;t t +s,@localstatedir@,$localstatedir,;t t +s,@libdir@,$libdir,;t t +s,@includedir@,$includedir,;t t +s,@oldincludedir@,$oldincludedir,;t t +s,@infodir@,$infodir,;t t +s,@mandir@,$mandir,;t t +s,@build_alias@,$build_alias,;t t +s,@host_alias@,$host_alias,;t t +s,@target_alias@,$target_alias,;t t +s,@DEFS@,$DEFS,;t t +s,@ECHO_C@,$ECHO_C,;t t +s,@ECHO_N@,$ECHO_N,;t t +s,@ECHO_T@,$ECHO_T,;t t +s,@LIBS@,$LIBS,;t t +s,@CC@,$CC,;t t +s,@CFLAGS@,$CFLAGS,;t t +s,@LDFLAGS@,$LDFLAGS,;t t +s,@CPPFLAGS@,$CPPFLAGS,;t t +s,@ac_ct_CC@,$ac_ct_CC,;t t +s,@EXEEXT@,$EXEEXT,;t t +s,@OBJEXT@,$OBJEXT,;t t +s,@CPP@,$CPP,;t t +s,@INSTALL_PROGRAM@,$INSTALL_PROGRAM,;t t +s,@INSTALL_SCRIPT@,$INSTALL_SCRIPT,;t t +s,@INSTALL_DATA@,$INSTALL_DATA,;t t +s,@EGREP@,$EGREP,;t t +s,@LIBOBJS@,$LIBOBJS,;t t +s,@LTLIBOBJS@,$LTLIBOBJS,;t t +CEOF + +_ACEOF + + cat >>$CONFIG_STATUS <<\_ACEOF + # Split the substitutions into bite-sized pieces for seds with + # small command number limits, like on Digital OSF/1 and HP-UX. + ac_max_sed_lines=48 + ac_sed_frag=1 # Number of current file. + ac_beg=1 # First line for current file. + ac_end=$ac_max_sed_lines # Line after last line for current file. + ac_more_lines=: + ac_sed_cmds= + while $ac_more_lines; do + if test $ac_beg -gt 1; then + sed "1,${ac_beg}d; ${ac_end}q" $tmp/subs.sed >$tmp/subs.frag + else + sed "${ac_end}q" $tmp/subs.sed >$tmp/subs.frag + fi + if test ! -s $tmp/subs.frag; then + ac_more_lines=false + else + # The purpose of the label and of the branching condition is to + # speed up the sed processing (if there are no `@' at all, there + # is no need to browse any of the substitutions). + # These are the two extra sed commands mentioned above. + (echo ':t + /@[a-zA-Z_][a-zA-Z_0-9]*@/!b' && cat $tmp/subs.frag) >$tmp/subs-$ac_sed_frag.sed + if test -z "$ac_sed_cmds"; then + ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed" + else + ac_sed_cmds="$ac_sed_cmds | sed -f $tmp/subs-$ac_sed_frag.sed" + fi + ac_sed_frag=`expr $ac_sed_frag + 1` + ac_beg=$ac_end + ac_end=`expr $ac_end + $ac_max_sed_lines` + fi + done + if test -z "$ac_sed_cmds"; then + ac_sed_cmds=cat + fi +fi # test -n "$CONFIG_FILES" + +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF +for ac_file in : $CONFIG_FILES; do test "x$ac_file" = x: && continue + # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". + case $ac_file in + - | *:- | *:-:* ) # input from stdin + cat >$tmp/stdin + ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; + *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; + * ) ac_file_in=$ac_file.in ;; + esac + + # Compute @srcdir@, @top_srcdir@, and @INSTALL@ for subdirectories. + ac_dir=`(dirname "$ac_file") 2>/dev/null || +$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_file" : 'X\(//\)[^/]' \| \ + X"$ac_file" : 'X\(//\)$' \| \ + X"$ac_file" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$ac_file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + { if $as_mkdir_p; then + mkdir -p "$ac_dir" + else + as_dir="$ac_dir" + as_dirs= + while test ! -d "$as_dir"; do + as_dirs="$as_dir $as_dirs" + as_dir=`(dirname "$as_dir") 2>/dev/null || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + done + test ! -n "$as_dirs" || mkdir $as_dirs + fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5 +echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;} + { (exit 1); exit 1; }; }; } + + ac_builddir=. + +if test "$ac_dir" != .; then + ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` + # A "../" for each directory in $ac_dir_suffix. + ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` +else + ac_dir_suffix= ac_top_builddir= +fi + +case $srcdir in + .) # No --srcdir option. We are building in place. + ac_srcdir=. + if test -z "$ac_top_builddir"; then + ac_top_srcdir=. + else + ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` + fi ;; + [\\/]* | ?:[\\/]* ) # Absolute path. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir ;; + *) # Relative path. + ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_builddir$srcdir ;; +esac + +# Do not use `cd foo && pwd` to compute absolute paths, because +# the directories may not exist. +case `pwd` in +.) ac_abs_builddir="$ac_dir";; +*) + case "$ac_dir" in + .) ac_abs_builddir=`pwd`;; + [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";; + *) ac_abs_builddir=`pwd`/"$ac_dir";; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_top_builddir=${ac_top_builddir}.;; +*) + case ${ac_top_builddir}. in + .) ac_abs_top_builddir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;; + *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_srcdir=$ac_srcdir;; +*) + case $ac_srcdir in + .) ac_abs_srcdir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;; + *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_top_srcdir=$ac_top_srcdir;; +*) + case $ac_top_srcdir in + .) ac_abs_top_srcdir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;; + *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;; + esac;; +esac + + + case $INSTALL in + [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; + *) ac_INSTALL=$ac_top_builddir$INSTALL ;; + esac + + # Let's still pretend it is `configure' which instantiates (i.e., don't + # use $as_me), people would be surprised to read: + # /* config.h. Generated by config.status. */ + if test x"$ac_file" = x-; then + configure_input= + else + configure_input="$ac_file. " + fi + configure_input=$configure_input"Generated from `echo $ac_file_in | + sed 's,.*/,,'` by configure." + + # First look for the input files in the build tree, otherwise in the + # src tree. + ac_file_inputs=`IFS=: + for f in $ac_file_in; do + case $f in + -) echo $tmp/stdin ;; + [\\/$]*) + # Absolute (can't be DOS-style, as IFS=:) + test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 +echo "$as_me: error: cannot find input file: $f" >&2;} + { (exit 1); exit 1; }; } + echo "$f";; + *) # Relative + if test -f "$f"; then + # Build tree + echo "$f" + elif test -f "$srcdir/$f"; then + # Source tree + echo "$srcdir/$f" + else + # /dev/null tree + { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 +echo "$as_me: error: cannot find input file: $f" >&2;} + { (exit 1); exit 1; }; } + fi;; + esac + done` || { (exit 1); exit 1; } + + if test x"$ac_file" != x-; then + { echo "$as_me:$LINENO: creating $ac_file" >&5 +echo "$as_me: creating $ac_file" >&6;} + rm -f "$ac_file" + fi +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF + sed "$ac_vpsub +$extrasub +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF +:t +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b +s,@configure_input@,$configure_input,;t t +s,@srcdir@,$ac_srcdir,;t t +s,@abs_srcdir@,$ac_abs_srcdir,;t t +s,@top_srcdir@,$ac_top_srcdir,;t t +s,@abs_top_srcdir@,$ac_abs_top_srcdir,;t t +s,@builddir@,$ac_builddir,;t t +s,@abs_builddir@,$ac_abs_builddir,;t t +s,@top_builddir@,$ac_top_builddir,;t t +s,@abs_top_builddir@,$ac_abs_top_builddir,;t t +s,@INSTALL@,$ac_INSTALL,;t t +" $ac_file_inputs | (eval "$ac_sed_cmds") >$tmp/out + rm -f $tmp/stdin + if test x"$ac_file" != x-; then + mv $tmp/out $ac_file + else + cat $tmp/out + rm -f $tmp/out + fi + +done +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF + +# +# CONFIG_HEADER section. +# + +# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where +# NAME is the cpp macro being defined and VALUE is the value it is being given. +# +# ac_d sets the value in "#define NAME VALUE" lines. +ac_dA='s,^\([ ]*\)#\([ ]*define[ ][ ]*\)' +ac_dB='[ ].*$,\1#\2' +ac_dC=' ' +ac_dD=',;t' +# ac_u turns "#undef NAME" without trailing blanks into "#define NAME VALUE". +ac_uA='s,^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' +ac_uB='$,\1#\2define\3' +ac_uC=' ' +ac_uD=',;t' + +for ac_file in : $CONFIG_HEADERS; do test "x$ac_file" = x: && continue + # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". + case $ac_file in + - | *:- | *:-:* ) # input from stdin + cat >$tmp/stdin + ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; + *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; + * ) ac_file_in=$ac_file.in ;; + esac + + test x"$ac_file" != x- && { echo "$as_me:$LINENO: creating $ac_file" >&5 +echo "$as_me: creating $ac_file" >&6;} + + # First look for the input files in the build tree, otherwise in the + # src tree. + ac_file_inputs=`IFS=: + for f in $ac_file_in; do + case $f in + -) echo $tmp/stdin ;; + [\\/$]*) + # Absolute (can't be DOS-style, as IFS=:) + test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 +echo "$as_me: error: cannot find input file: $f" >&2;} + { (exit 1); exit 1; }; } + # Do quote $f, to prevent DOS paths from being IFS'd. + echo "$f";; + *) # Relative + if test -f "$f"; then + # Build tree + echo "$f" + elif test -f "$srcdir/$f"; then + # Source tree + echo "$srcdir/$f" + else + # /dev/null tree + { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 +echo "$as_me: error: cannot find input file: $f" >&2;} + { (exit 1); exit 1; }; } + fi;; + esac + done` || { (exit 1); exit 1; } + # Remove the trailing spaces. + sed 's/[ ]*$//' $ac_file_inputs >$tmp/in + +_ACEOF + +# Transform confdefs.h into two sed scripts, `conftest.defines' and +# `conftest.undefs', that substitutes the proper values into +# config.h.in to produce config.h. The first handles `#define' +# templates, and the second `#undef' templates. +# And first: Protect against being on the right side of a sed subst in +# config.status. Protect against being in an unquoted here document +# in config.status. +rm -f conftest.defines conftest.undefs +# Using a here document instead of a string reduces the quoting nightmare. +# Putting comments in sed scripts is not portable. +# +# `end' is used to avoid that the second main sed command (meant for +# 0-ary CPP macros) applies to n-ary macro definitions. +# See the Autoconf documentation for `clear'. +cat >confdef2sed.sed <<\_ACEOF +s/[\\&,]/\\&/g +s,[\\$`],\\&,g +t clear +: clear +s,^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*\)\(([^)]*)\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1\2${ac_dC}\3${ac_dD},gp +t end +s,^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD},gp +: end +_ACEOF +# If some macros were called several times there might be several times +# the same #defines, which is useless. Nevertheless, we may not want to +# sort them, since we want the *last* AC-DEFINE to be honored. +uniq confdefs.h | sed -n -f confdef2sed.sed >conftest.defines +sed 's/ac_d/ac_u/g' conftest.defines >conftest.undefs +rm -f confdef2sed.sed + +# This sed command replaces #undef with comments. This is necessary, for +# example, in the case of _POSIX_SOURCE, which is predefined and required +# on some systems where configure will not decide to define it. +cat >>conftest.undefs <<\_ACEOF +s,^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*,/* & */, +_ACEOF + +# Break up conftest.defines because some shells have a limit on the size +# of here documents, and old seds have small limits too (100 cmds). +echo ' # Handle all the #define templates only if necessary.' >>$CONFIG_STATUS +echo ' if grep "^[ ]*#[ ]*define" $tmp/in >/dev/null; then' >>$CONFIG_STATUS +echo ' # If there are no defines, we may have an empty if/fi' >>$CONFIG_STATUS +echo ' :' >>$CONFIG_STATUS +rm -f conftest.tail +while grep . conftest.defines >/dev/null +do + # Write a limited-size here document to $tmp/defines.sed. + echo ' cat >$tmp/defines.sed <>$CONFIG_STATUS + # Speed up: don't consider the non `#define' lines. + echo '/^[ ]*#[ ]*define/!b' >>$CONFIG_STATUS + # Work around the forget-to-reset-the-flag bug. + echo 't clr' >>$CONFIG_STATUS + echo ': clr' >>$CONFIG_STATUS + sed ${ac_max_here_lines}q conftest.defines >>$CONFIG_STATUS + echo 'CEOF + sed -f $tmp/defines.sed $tmp/in >$tmp/out + rm -f $tmp/in + mv $tmp/out $tmp/in +' >>$CONFIG_STATUS + sed 1,${ac_max_here_lines}d conftest.defines >conftest.tail + rm -f conftest.defines + mv conftest.tail conftest.defines +done +rm -f conftest.defines +echo ' fi # grep' >>$CONFIG_STATUS +echo >>$CONFIG_STATUS + +# Break up conftest.undefs because some shells have a limit on the size +# of here documents, and old seds have small limits too (100 cmds). +echo ' # Handle all the #undef templates' >>$CONFIG_STATUS +rm -f conftest.tail +while grep . conftest.undefs >/dev/null +do + # Write a limited-size here document to $tmp/undefs.sed. + echo ' cat >$tmp/undefs.sed <>$CONFIG_STATUS + # Speed up: don't consider the non `#undef' + echo '/^[ ]*#[ ]*undef/!b' >>$CONFIG_STATUS + # Work around the forget-to-reset-the-flag bug. + echo 't clr' >>$CONFIG_STATUS + echo ': clr' >>$CONFIG_STATUS + sed ${ac_max_here_lines}q conftest.undefs >>$CONFIG_STATUS + echo 'CEOF + sed -f $tmp/undefs.sed $tmp/in >$tmp/out + rm -f $tmp/in + mv $tmp/out $tmp/in +' >>$CONFIG_STATUS + sed 1,${ac_max_here_lines}d conftest.undefs >conftest.tail + rm -f conftest.undefs + mv conftest.tail conftest.undefs +done +rm -f conftest.undefs + +cat >>$CONFIG_STATUS <<\_ACEOF + # Let's still pretend it is `configure' which instantiates (i.e., don't + # use $as_me), people would be surprised to read: + # /* config.h. Generated by config.status. */ + if test x"$ac_file" = x-; then + echo "/* Generated by configure. */" >$tmp/config.h + else + echo "/* $ac_file. Generated by configure. */" >$tmp/config.h + fi + cat $tmp/in >>$tmp/config.h + rm -f $tmp/in + if test x"$ac_file" != x-; then + if diff $ac_file $tmp/config.h >/dev/null 2>&1; then + { echo "$as_me:$LINENO: $ac_file is unchanged" >&5 +echo "$as_me: $ac_file is unchanged" >&6;} + else + ac_dir=`(dirname "$ac_file") 2>/dev/null || +$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_file" : 'X\(//\)[^/]' \| \ + X"$ac_file" : 'X\(//\)$' \| \ + X"$ac_file" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$ac_file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + { if $as_mkdir_p; then + mkdir -p "$ac_dir" + else + as_dir="$ac_dir" + as_dirs= + while test ! -d "$as_dir"; do + as_dirs="$as_dir $as_dirs" + as_dir=`(dirname "$as_dir") 2>/dev/null || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + done + test ! -n "$as_dirs" || mkdir $as_dirs + fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5 +echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;} + { (exit 1); exit 1; }; }; } + + rm -f $ac_file + mv $tmp/config.h $ac_file + fi + else + cat $tmp/config.h + rm -f $tmp/config.h + fi +done +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF + +{ (exit 0); exit 0; } +_ACEOF +chmod +x $CONFIG_STATUS +ac_clean_files=$ac_clean_files_save + + +# configure is writing to config.log, and then calls config.status. +# config.status does its own redirection, appending to config.log. +# Unfortunately, on DOS this fails, as config.log is still kept open +# by configure, so config.status won't be able to write to it; its +# output is simply discarded. So we exec the FD to /dev/null, +# effectively closing config.log, so it can be properly (re)opened and +# appended to by config.status. When coming back to configure, we +# need to make the FD available again. +if test "$no_create" != yes; then + ac_cs_success=: + ac_config_status_args= + test "$silent" = yes && + ac_config_status_args="$ac_config_status_args --quiet" + exec 5>/dev/null + $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false + exec 5>>config.log + # Use ||, not &&, to avoid exiting from the if with $? = 1, which + # would make configure fail if this is the last instruction. + $ac_cs_success || { (exit 1); exit 1; } +fi + diff --git a/CCache/configure.in b/CCache/configure.in new file mode 100644 index 000000000..3229ef0b7 --- /dev/null +++ b/CCache/configure.in @@ -0,0 +1,72 @@ +dnl Process this file with autoconf to produce a configure script. + +AC_INIT() +AC_PREREQ(2.52) + +AC_MSG_NOTICE([Configuring ccache]) + +AC_CONFIG_HEADER(config.h) + +dnl Checks for programs. +AC_PROG_CC +AC_PROG_CPP +AC_PROG_INSTALL + +AC_DEFINE([_GNU_SOURCE], 1, + [Define _GNU_SOURCE so that we get all necessary prototypes]) + +# If GCC, turn on warnings. +if test "x$GCC" = "xyes" +then + CFLAGS="$CFLAGS -Wall -W" +else + CFLAGS="$CFLAGS -O" +fi + +AC_HEADER_DIRENT +AC_HEADER_TIME +AC_HEADER_SYS_WAIT + +AC_CHECK_HEADERS(ctype.h strings.h stdlib.h string.h pwd.h) + +AC_CHECK_FUNCS(realpath snprintf vsnprintf vasprintf asprintf mkstemp) +AC_CHECK_FUNCS(gethostname getpwuid) + +AC_CACHE_CHECK([for compar_fn_t in stdlib.h],ccache_cv_COMPAR_FN_T, [ + AC_TRY_COMPILE( +[#include ], +[ +void test_fn(void) { qsort(NULL, 0, 0, (__compar_fn_t)NULL); } +], + ccache_cv_COMPAR_FN_T=yes,ccache_cv_COMPAR_FN_T=no)]) +if test x"$ccache_cv_COMPAR_FN_T" = x"yes"; then + AC_DEFINE(HAVE_COMPAR_FN_T, 1, [ ]) +fi + +AC_CACHE_CHECK([for C99 vsnprintf],ccache_cv_HAVE_C99_VSNPRINTF,[ +AC_TRY_RUN([ +#include +#include +void foo(const char *format, ...) { + va_list ap; + int len; + char buf[5]; + + va_start(ap, format); + len = vsnprintf(0, 0, format, ap); + va_end(ap); + if (len != 5) exit(1); + + if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1); + + exit(0); +} +main() { foo("hello"); } +], +ccache_cv_HAVE_C99_VSNPRINTF=yes,ccache_cv_HAVE_C99_VSNPRINTF=no,ccache_cv_HAVE_C99_VSNPRINTF=cross)]) +if test x"$ccache_cv_HAVE_C99_VSNPRINTF" = x"yes"; then + AC_DEFINE(HAVE_C99_VSNPRINTF, 1, [ ]) +fi + +AC_CONFIG_FILES([Makefile]) +AC_OUTPUT diff --git a/CCache/execute.c b/CCache/execute.c new file mode 100644 index 000000000..4b98ab735 --- /dev/null +++ b/CCache/execute.c @@ -0,0 +1,129 @@ +/* + Copyright (C) Andrew Tridgell 2002 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "ccache.h" + + +/* + execute a compiler backend, capturing all output to the given paths + the full path to the compiler to run is in argv[0] +*/ +int execute(char **argv, + const char *path_stdout, + const char *path_stderr) +{ + pid_t pid; + int status; + + pid = fork(); + if (pid == -1) fatal("Failed to fork"); + + if (pid == 0) { + int fd; + + unlink(path_stdout); + fd = open(path_stdout, O_WRONLY|O_CREAT|O_TRUNC|O_EXCL|O_BINARY, 0666); + if (fd == -1) { + exit(STATUS_NOCACHE); + } + dup2(fd, 1); + close(fd); + + unlink(path_stderr); + fd = open(path_stderr, O_WRONLY|O_CREAT|O_TRUNC|O_EXCL|O_BINARY, 0666); + if (fd == -1) { + exit(STATUS_NOCACHE); + } + dup2(fd, 2); + close(fd); + + exit(execv(argv[0], argv)); + } + + if (waitpid(pid, &status, 0) != pid) { + fatal("waitpid failed"); + } + + if (WEXITSTATUS(status) == 0 && WIFSIGNALED(status)) { + return -1; + } + + return WEXITSTATUS(status); +} + + +/* + find an executable by name in $PATH. Exclude any that are links to exclude_name +*/ +char *find_executable(const char *name, const char *exclude_name) +{ + char *path; + char *tok; + struct stat st1, st2; + + if (*name == '/') { + return x_strdup(name); + } + + path = getenv("CCACHE_PATH"); + if (!path) { + path = getenv("PATH"); + } + if (!path) { + cc_log("no PATH variable!?\n"); + return NULL; + } + + path = x_strdup(path); + + /* search the path looking for the first compiler of the right name + that isn't us */ + for (tok=strtok(path,":"); tok; tok = strtok(NULL, ":")) { + char *fname; + x_asprintf(&fname, "%s/%s", tok, name); + /* look for a normal executable file */ + if (access(fname, X_OK) == 0 && + lstat(fname, &st1) == 0 && + stat(fname, &st2) == 0 && + S_ISREG(st2.st_mode)) { + /* if its a symlink then ensure it doesn't + point at something called exclude_name */ + if (S_ISLNK(st1.st_mode)) { + char *buf = x_realpath(fname); + if (buf) { + char *p = str_basename(buf); + if (strcmp(p, exclude_name) == 0) { + /* its a link to "ccache" ! */ + free(p); + free(buf); + continue; + } + free(buf); + free(p); + } + } + + /* found it! */ + free(path); + return fname; + } + free(fname); + } + + return NULL; +} diff --git a/CCache/hash.c b/CCache/hash.c new file mode 100644 index 000000000..d0ce8a6ba --- /dev/null +++ b/CCache/hash.c @@ -0,0 +1,80 @@ +/* + Copyright (C) Andrew Tridgell 2002 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ +/* + simple front-end functions to mdfour code +*/ + +#include "ccache.h" + +static struct mdfour md; + +void hash_buffer(const char *s, int len) +{ + mdfour_update(&md, (unsigned char *)s, len); +} + +void hash_start(void) +{ + mdfour_begin(&md); +} + +void hash_string(const char *s) +{ + hash_buffer(s, strlen(s)); +} + +void hash_int(int x) +{ + hash_buffer((char *)&x, sizeof(x)); +} + +/* add contents of a file to the hash */ +void hash_file(const char *fname) +{ + char buf[1024]; + int fd, n; + + fd = open(fname, O_RDONLY|O_BINARY); + if (fd == -1) { + cc_log("Failed to open %s\n", fname); + fatal("hash_file"); + } + + while ((n = read(fd, buf, sizeof(buf))) > 0) { + hash_buffer(buf, n); + } + close(fd); +} + +/* return the hash result as a static string */ +char *hash_result(void) +{ + unsigned char sum[16]; + static char ret[53]; + int i; + + hash_buffer(NULL, 0); + mdfour_result(&md, sum); + + for (i=0;i<16;i++) { + sprintf(&ret[i*2], "%02x", (unsigned)sum[i]); + } + sprintf(&ret[i*2], "-%u", (unsigned)md.totalN); + + return ret; +} diff --git a/CCache/install-sh b/CCache/install-sh new file mode 100755 index 000000000..58719246f --- /dev/null +++ b/CCache/install-sh @@ -0,0 +1,238 @@ +#! /bin/sh +# +# install - install a program, script, or datafile +# This comes from X11R5. +# +# Calling this script install-sh is preferred over install.sh, to prevent +# `make' implicit rules from creating a file called install from it +# when there is no Makefile. +# +# This script is compatible with the BSD install script, but was written +# from scratch. +# + + +# set DOITPROG to echo to test this script + +# Don't use :- since 4.3BSD and earlier shells don't like it. +doit="${DOITPROG-}" + + +# put in absolute paths if you don't have them in your path; or use env. vars. + +mvprog="${MVPROG-mv}" +cpprog="${CPPROG-cp}" +chmodprog="${CHMODPROG-chmod}" +chownprog="${CHOWNPROG-chown}" +chgrpprog="${CHGRPPROG-chgrp}" +stripprog="${STRIPPROG-strip}" +rmprog="${RMPROG-rm}" +mkdirprog="${MKDIRPROG-mkdir}" + +transformbasename="" +transform_arg="" +instcmd="$mvprog" +chmodcmd="$chmodprog 0755" +chowncmd="" +chgrpcmd="" +stripcmd="" +rmcmd="$rmprog -f" +mvcmd="$mvprog" +src="" +dst="" +dir_arg="" + +while [ x"$1" != x ]; do + case $1 in + -c) instcmd="$cpprog" + shift + continue;; + + -d) dir_arg=true + shift + continue;; + + -m) chmodcmd="$chmodprog $2" + shift + shift + continue;; + + -o) chowncmd="$chownprog $2" + shift + shift + continue;; + + -g) chgrpcmd="$chgrpprog $2" + shift + shift + continue;; + + -s) stripcmd="$stripprog" + shift + continue;; + + -t=*) transformarg=`echo $1 | sed 's/-t=//'` + shift + continue;; + + -b=*) transformbasename=`echo $1 | sed 's/-b=//'` + shift + continue;; + + *) if [ x"$src" = x ] + then + src=$1 + else + # this colon is to work around a 386BSD /bin/sh bug + : + dst=$1 + fi + shift + continue;; + esac +done + +if [ x"$src" = x ] +then + echo "install: no input file specified" + exit 1 +else + true +fi + +if [ x"$dir_arg" != x ]; then + dst=$src + src="" + + if [ -d $dst ]; then + instcmd=: + else + instcmd=mkdir + fi +else + +# Waiting for this to be detected by the "$instcmd $src $dsttmp" command +# might cause directories to be created, which would be especially bad +# if $src (and thus $dsttmp) contains '*'. + + if [ -f $src -o -d $src ] + then + true + else + echo "install: $src does not exist" + exit 1 + fi + + if [ x"$dst" = x ] + then + echo "install: no destination specified" + exit 1 + else + true + fi + +# If destination is a directory, append the input filename; if your system +# does not like double slashes in filenames, you may need to add some logic + + if [ -d $dst ] + then + dst="$dst"/`basename $src` + else + true + fi +fi + +## this sed command emulates the dirname command +dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` + +# Make sure that the destination directory exists. +# this part is taken from Noah Friedman's mkinstalldirs script + +# Skip lots of stat calls in the usual case. +if [ ! -d "$dstdir" ]; then +defaultIFS=' +' +IFS="${IFS-${defaultIFS}}" + +oIFS="${IFS}" +# Some sh's can't handle IFS=/ for some reason. +IFS='%' +set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` +IFS="${oIFS}" + +pathcomp='' + +while [ $# -ne 0 ] ; do + pathcomp="${pathcomp}${1}" + shift + + if [ ! -d "${pathcomp}" ] ; + then + $mkdirprog "${pathcomp}" + else + true + fi + + pathcomp="${pathcomp}/" +done +fi + +if [ x"$dir_arg" != x ] +then + $doit $instcmd $dst && + + if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && + if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && + if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && + if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi +else + +# If we're going to rename the final executable, determine the name now. + + if [ x"$transformarg" = x ] + then + dstfile=`basename $dst` + else + dstfile=`basename $dst $transformbasename | + sed $transformarg`$transformbasename + fi + +# don't allow the sed command to completely eliminate the filename + + if [ x"$dstfile" = x ] + then + dstfile=`basename $dst` + else + true + fi + +# Make a temp file name in the proper directory. + + dsttmp=$dstdir/#inst.$$# + +# Move or copy the file name to the temp name + + $doit $instcmd $src $dsttmp && + + trap "rm -f ${dsttmp}" 0 && + +# and set any options; do chmod last to preserve setuid bits + +# If any of these fail, we abort the whole thing. If we want to +# ignore errors from any of these, just make sure not to ignore +# errors from the above "$doit $instcmd $src $dsttmp" command. + + if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && + if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && + if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && + if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && + +# Now rename the file to the real destination. + + $doit $rmcmd -f $dstdir/$dstfile && + $doit $mvcmd $dsttmp $dstdir/$dstfile + +fi && + + +exit 0 diff --git a/CCache/mdfour.c b/CCache/mdfour.c new file mode 100644 index 000000000..b098e0215 --- /dev/null +++ b/CCache/mdfour.c @@ -0,0 +1,284 @@ +/* + a implementation of MD4 designed for use in the SMB authentication protocol + Copyright (C) Andrew Tridgell 1997-1998. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "ccache.h" + +/* NOTE: This code makes no attempt to be fast! + + It assumes that a int is at least 32 bits long +*/ + +static struct mdfour *m; + +#define MASK32 (0xffffffff) + +#define F(X,Y,Z) ((((X)&(Y)) | ((~(X))&(Z)))) +#define G(X,Y,Z) ((((X)&(Y)) | ((X)&(Z)) | ((Y)&(Z)))) +#define H(X,Y,Z) (((X)^(Y)^(Z))) +#define lshift(x,s) (((((x)<<(s))&MASK32) | (((x)>>(32-(s)))&MASK32))) + +#define ROUND1(a,b,c,d,k,s) a = lshift((a + F(b,c,d) + M[k])&MASK32, s) +#define ROUND2(a,b,c,d,k,s) a = lshift((a + G(b,c,d) + M[k] + 0x5A827999)&MASK32,s) +#define ROUND3(a,b,c,d,k,s) a = lshift((a + H(b,c,d) + M[k] + 0x6ED9EBA1)&MASK32,s) + +/* this applies md4 to 64 byte chunks */ +static void mdfour64(uint32 *M) +{ + uint32 AA, BB, CC, DD; + uint32 A,B,C,D; + + A = m->A; B = m->B; C = m->C; D = m->D; + AA = A; BB = B; CC = C; DD = D; + + ROUND1(A,B,C,D, 0, 3); ROUND1(D,A,B,C, 1, 7); + ROUND1(C,D,A,B, 2, 11); ROUND1(B,C,D,A, 3, 19); + ROUND1(A,B,C,D, 4, 3); ROUND1(D,A,B,C, 5, 7); + ROUND1(C,D,A,B, 6, 11); ROUND1(B,C,D,A, 7, 19); + ROUND1(A,B,C,D, 8, 3); ROUND1(D,A,B,C, 9, 7); + ROUND1(C,D,A,B, 10, 11); ROUND1(B,C,D,A, 11, 19); + ROUND1(A,B,C,D, 12, 3); ROUND1(D,A,B,C, 13, 7); + ROUND1(C,D,A,B, 14, 11); ROUND1(B,C,D,A, 15, 19); + + + ROUND2(A,B,C,D, 0, 3); ROUND2(D,A,B,C, 4, 5); + ROUND2(C,D,A,B, 8, 9); ROUND2(B,C,D,A, 12, 13); + ROUND2(A,B,C,D, 1, 3); ROUND2(D,A,B,C, 5, 5); + ROUND2(C,D,A,B, 9, 9); ROUND2(B,C,D,A, 13, 13); + ROUND2(A,B,C,D, 2, 3); ROUND2(D,A,B,C, 6, 5); + ROUND2(C,D,A,B, 10, 9); ROUND2(B,C,D,A, 14, 13); + ROUND2(A,B,C,D, 3, 3); ROUND2(D,A,B,C, 7, 5); + ROUND2(C,D,A,B, 11, 9); ROUND2(B,C,D,A, 15, 13); + + ROUND3(A,B,C,D, 0, 3); ROUND3(D,A,B,C, 8, 9); + ROUND3(C,D,A,B, 4, 11); ROUND3(B,C,D,A, 12, 15); + ROUND3(A,B,C,D, 2, 3); ROUND3(D,A,B,C, 10, 9); + ROUND3(C,D,A,B, 6, 11); ROUND3(B,C,D,A, 14, 15); + ROUND3(A,B,C,D, 1, 3); ROUND3(D,A,B,C, 9, 9); + ROUND3(C,D,A,B, 5, 11); ROUND3(B,C,D,A, 13, 15); + ROUND3(A,B,C,D, 3, 3); ROUND3(D,A,B,C, 11, 9); + ROUND3(C,D,A,B, 7, 11); ROUND3(B,C,D,A, 15, 15); + + A += AA; B += BB; + C += CC; D += DD; + + A &= MASK32; B &= MASK32; + C &= MASK32; D &= MASK32; + + m->A = A; m->B = B; m->C = C; m->D = D; +} + +static void copy64(uint32 *M, const unsigned char *in) +{ + int i; + + for (i=0;i<16;i++) + M[i] = (in[i*4+3]<<24) | (in[i*4+2]<<16) | + (in[i*4+1]<<8) | (in[i*4+0]<<0); +} + +static void copy4(unsigned char *out,uint32 x) +{ + out[0] = x&0xFF; + out[1] = (x>>8)&0xFF; + out[2] = (x>>16)&0xFF; + out[3] = (x>>24)&0xFF; +} + +void mdfour_begin(struct mdfour *md) +{ + md->A = 0x67452301; + md->B = 0xefcdab89; + md->C = 0x98badcfe; + md->D = 0x10325476; + md->totalN = 0; + md->tail_len = 0; +} + + +static void mdfour_tail(const unsigned char *in, int n) +{ + unsigned char buf[128]; + uint32 M[16]; + uint32 b; + + m->totalN += n; + + b = m->totalN * 8; + + memset(buf, 0, 128); + if (n) memcpy(buf, in, n); + buf[n] = 0x80; + + if (n <= 55) { + copy4(buf+56, b); + copy64(M, buf); + mdfour64(M); + } else { + copy4(buf+120, b); + copy64(M, buf); + mdfour64(M); + copy64(M, buf+64); + mdfour64(M); + } +} + +void mdfour_update(struct mdfour *md, const unsigned char *in, int n) +{ + uint32 M[16]; + + m = md; + + if (in == NULL) { + mdfour_tail(md->tail, md->tail_len); + return; + } + + if (md->tail_len) { + int len = 64 - md->tail_len; + if (len > n) len = n; + memcpy(md->tail+md->tail_len, in, len); + md->tail_len += len; + n -= len; + in += len; + if (md->tail_len == 64) { + copy64(M, md->tail); + mdfour64(M); + m->totalN += 64; + md->tail_len = 0; + } + } + + while (n >= 64) { + copy64(M, in); + mdfour64(M); + in += 64; + n -= 64; + m->totalN += 64; + } + + if (n) { + memcpy(md->tail, in, n); + md->tail_len = n; + } +} + + +void mdfour_result(struct mdfour *md, unsigned char *out) +{ + m = md; + + copy4(out, m->A); + copy4(out+4, m->B); + copy4(out+8, m->C); + copy4(out+12, m->D); +} + + +void mdfour(unsigned char *out, const unsigned char *in, int n) +{ + struct mdfour md; + mdfour_begin(&md); + mdfour_update(&md, in, n); + mdfour_update(&md, NULL, 0); + mdfour_result(&md, out); +} + +#ifdef TEST_MDFOUR +static void file_checksum1(char *fname) +{ + int fd, i; + struct mdfour md; + unsigned char buf[1024], sum[16]; + unsigned chunk; + + fd = open(fname,O_RDONLY|O_BINARY); + if (fd == -1) { + perror("fname"); + exit(1); + } + + chunk = 1 + random() % (sizeof(buf) - 1); + + mdfour_begin(&md); + + while (1) { + int n = read(fd, buf, chunk); + if (n >= 0) { + mdfour_update(&md, buf, n); + } + if (n < chunk) break; + } + + close(fd); + + mdfour_update(&md, NULL, 0); + + mdfour_result(&md, sum); + + for (i=0;i<16;i++) + printf("%02x", sum[i]); + printf("\n"); +} + +#if 0 +#include "../md4.h" + +static void file_checksum2(char *fname) +{ + int fd, i; + MDstruct md; + unsigned char buf[64], sum[16]; + + fd = open(fname,O_RDONLY|O_BINARY); + if (fd == -1) { + perror("fname"); + exit(1); + } + + MDbegin(&md); + + while (1) { + int n = read(fd, buf, sizeof(buf)); + if (n <= 0) break; + MDupdate(&md, buf, n*8); + } + + if (!md.done) { + MDupdate(&md, buf, 0); + } + + close(fd); + + memcpy(sum, md.buffer, 16); + + for (i=0;i<16;i++) + printf("%02x", sum[i]); + printf("\n"); +} +#endif + + int main(int argc, char *argv[]) +{ + file_checksum1(argv[1]); +#if 0 + file_checksum2(argv[1]); +#endif + return 0; +} +#endif diff --git a/CCache/mdfour.h b/CCache/mdfour.h new file mode 100644 index 000000000..92ef2f831 --- /dev/null +++ b/CCache/mdfour.h @@ -0,0 +1,36 @@ +/* + Unix SMB/Netbios implementation. + Version 1.9. + a implementation of MD4 designed for use in the SMB authentication protocol + Copyright (C) Andrew Tridgell 1997-1998. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +struct mdfour { + uint32 A, B, C, D; + uint32 totalN; + unsigned char tail[64]; + unsigned tail_len; +}; + +void mdfour_begin(struct mdfour *md); +void mdfour_update(struct mdfour *md, const unsigned char *in, int n); +void mdfour_result(struct mdfour *md, unsigned char *out); +void mdfour(unsigned char *out, const unsigned char *in, int n); + + + + diff --git a/CCache/packaging/README b/CCache/packaging/README new file mode 100644 index 000000000..fadc342c4 --- /dev/null +++ b/CCache/packaging/README @@ -0,0 +1,5 @@ +These packaging files are contributd by users of ccache. I do not +maintain them, and they may well need updating before you use them. + +I don't distribute binary packages of ccache myself, but if you wish +to add ccache to a distribution then that's OK diff --git a/CCache/packaging/ccache.spec b/CCache/packaging/ccache.spec new file mode 100644 index 000000000..0972121d7 --- /dev/null +++ b/CCache/packaging/ccache.spec @@ -0,0 +1,37 @@ +Summary: Compiler Cache +Name: ccache +Version: 2.3 +Release: 1 +Group: Development/Languages +License: GPL +URL: http://ccache.samba.org/ +Source: ccache-%{version}.tar.gz +BuildRoot: %{_tmppath}/%{name}-%{version}-root + +%description +ccache caches gcc output files + +%prep +%setup -q + +%build +%configure +make + +install -d -m 0755 $RPM_BUILD_ROOT%{_bindir} +install -m 0755 ccache $RPM_BUILD_ROOT%{_bindir} +install -d -m 0755 $RPM_BUILD_ROOT%{_mandir}/man1 +install -m 0644 ccache.1 $RPM_BUILD_ROOT%{_mandir}/man1 + +%files +%defattr(-,root,root) +%doc README +%{_mandir}/man1/ccache.1* +%{_bindir}/ccache + +%clean +[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT + +%changelog +* Mon Apr 01 2002 Peter Jones +- Created the package diff --git a/CCache/snprintf.c b/CCache/snprintf.c new file mode 100644 index 000000000..32187c1a5 --- /dev/null +++ b/CCache/snprintf.c @@ -0,0 +1,962 @@ +/* + * Copyright Patrick Powell 1995 + * This code is based on code written by Patrick Powell (papowell@astart.com) + * It may be used for any purpose as long as this notice remains intact + * on all source code distributions + */ + +/************************************************************** + * Original: + * Patrick Powell Tue Apr 11 09:48:21 PDT 1995 + * A bombproof version of doprnt (dopr) included. + * Sigh. This sort of thing is always nasty do deal with. Note that + * the version here does not include floating point... + * + * snprintf() is used instead of sprintf() as it does limit checks + * for string length. This covers a nasty loophole. + * + * The other functions are there to prevent NULL pointers from + * causing nast effects. + * + * More Recently: + * Brandon Long 9/15/96 for mutt 0.43 + * This was ugly. It is still ugly. I opted out of floating point + * numbers, but the formatter understands just about everything + * from the normal C string format, at least as far as I can tell from + * the Solaris 2.5 printf(3S) man page. + * + * Brandon Long 10/22/97 for mutt 0.87.1 + * Ok, added some minimal floating point support, which means this + * probably requires libm on most operating systems. Don't yet + * support the exponent (e,E) and sigfig (g,G). Also, fmtint() + * was pretty badly broken, it just wasn't being exercised in ways + * which showed it, so that's been fixed. Also, formated the code + * to mutt conventions, and removed dead code left over from the + * original. Also, there is now a builtin-test, just compile with: + * gcc -DTEST_SNPRINTF -o snprintf snprintf.c -lm + * and run snprintf for results. + * + * Thomas Roessler 01/27/98 for mutt 0.89i + * The PGP code was using unsigned hexadecimal formats. + * Unfortunately, unsigned formats simply didn't work. + * + * Michael Elkins 03/05/98 for mutt 0.90.8 + * The original code assumed that both snprintf() and vsnprintf() were + * missing. Some systems only have snprintf() but not vsnprintf(), so + * the code is now broken down under HAVE_SNPRINTF and HAVE_VSNPRINTF. + * + * Andrew Tridgell (tridge@samba.org) Oct 1998 + * fixed handling of %.0f + * added test for HAVE_LONG_DOUBLE + * + * tridge@samba.org, idra@samba.org, April 2001 + * got rid of fcvt code (twas buggy and made testing harder) + * added C99 semantics + * + **************************************************************/ + +#ifndef NO_CONFIG_H /* for some tests */ +#include "config.h" +#endif + +#ifdef HAVE_STRING_H +#include +#endif + +#ifdef HAVE_STRINGS_H +#include +#endif +#ifdef HAVE_CTYPE_H +#include +#endif +#include +#include +#ifdef HAVE_STDLIB_H +#include +#endif + +#if defined(HAVE_SNPRINTF) && defined(HAVE_VSNPRINTF) && defined(HAVE_C99_VSNPRINTF) +/* only include stdio.h if we are not re-defining snprintf or vsnprintf */ +#include + /* make the compiler happy with an empty file */ + void dummy_snprintf(void) {} +#else + +#ifdef HAVE_LONG_DOUBLE +#define LDOUBLE long double +#else +#define LDOUBLE double +#endif + +#ifdef HAVE_LONG_LONG +#define LLONG long long +#else +#define LLONG long +#endif + +static size_t dopr(char *buffer, size_t maxlen, const char *format, + va_list args); +static void fmtstr(char *buffer, size_t *currlen, size_t maxlen, + char *value, int flags, int min, int max); +static void fmtint(char *buffer, size_t *currlen, size_t maxlen, + long value, int base, int min, int max, int flags); +static void fmtfp(char *buffer, size_t *currlen, size_t maxlen, + LDOUBLE fvalue, int min, int max, int flags); +static void dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c); + +/* + * dopr(): poor man's version of doprintf + */ + +/* format read states */ +#define DP_S_DEFAULT 0 +#define DP_S_FLAGS 1 +#define DP_S_MIN 2 +#define DP_S_DOT 3 +#define DP_S_MAX 4 +#define DP_S_MOD 5 +#define DP_S_CONV 6 +#define DP_S_DONE 7 + +/* format flags - Bits */ +#define DP_F_MINUS (1 << 0) +#define DP_F_PLUS (1 << 1) +#define DP_F_SPACE (1 << 2) +#define DP_F_NUM (1 << 3) +#define DP_F_ZERO (1 << 4) +#define DP_F_UP (1 << 5) +#define DP_F_UNSIGNED (1 << 6) + +/* Conversion Flags */ +#define DP_C_SHORT 1 +#define DP_C_LONG 2 +#define DP_C_LDOUBLE 3 +#define DP_C_LLONG 4 + +#define char_to_int(p) ((p)- '0') +#ifndef MAX +#define MAX(p,q) (((p) >= (q)) ? (p) : (q)) +#endif + +static size_t dopr(char *buffer, size_t maxlen, const char *format, va_list args) +{ + char ch; + LLONG value; + LDOUBLE fvalue; + char *strvalue; + int min; + int max; + int state; + int flags; + int cflags; + size_t currlen; + + state = DP_S_DEFAULT; + currlen = flags = cflags = min = 0; + max = -1; + ch = *format++; + + while (state != DP_S_DONE) { + if (ch == '\0') + state = DP_S_DONE; + + switch(state) { + case DP_S_DEFAULT: + if (ch == '%') + state = DP_S_FLAGS; + else + dopr_outch (buffer, &currlen, maxlen, ch); + ch = *format++; + break; + case DP_S_FLAGS: + switch (ch) { + case '-': + flags |= DP_F_MINUS; + ch = *format++; + break; + case '+': + flags |= DP_F_PLUS; + ch = *format++; + break; + case ' ': + flags |= DP_F_SPACE; + ch = *format++; + break; + case '#': + flags |= DP_F_NUM; + ch = *format++; + break; + case '0': + flags |= DP_F_ZERO; + ch = *format++; + break; + default: + state = DP_S_MIN; + break; + } + break; + case DP_S_MIN: + if (isdigit((unsigned char)ch)) { + min = 10*min + char_to_int (ch); + ch = *format++; + } else if (ch == '*') { + min = va_arg (args, int); + ch = *format++; + state = DP_S_DOT; + } else { + state = DP_S_DOT; + } + break; + case DP_S_DOT: + if (ch == '.') { + state = DP_S_MAX; + ch = *format++; + } else { + state = DP_S_MOD; + } + break; + case DP_S_MAX: + if (isdigit((unsigned char)ch)) { + if (max < 0) + max = 0; + max = 10*max + char_to_int (ch); + ch = *format++; + } else if (ch == '*') { + max = va_arg (args, int); + ch = *format++; + state = DP_S_MOD; + } else { + state = DP_S_MOD; + } + break; + case DP_S_MOD: + switch (ch) { + case 'h': + cflags = DP_C_SHORT; + ch = *format++; + break; + case 'l': + cflags = DP_C_LONG; + ch = *format++; + if (ch == 'l') { /* It's a long long */ + cflags = DP_C_LLONG; + ch = *format++; + } + break; + case 'L': + cflags = DP_C_LDOUBLE; + ch = *format++; + break; + default: + break; + } + state = DP_S_CONV; + break; + case DP_S_CONV: + switch (ch) { + case 'd': + case 'i': + if (cflags == DP_C_SHORT) + value = va_arg (args, int); + else if (cflags == DP_C_LONG) + value = va_arg (args, long int); + else if (cflags == DP_C_LLONG) + value = va_arg (args, LLONG); + else + value = va_arg (args, int); + fmtint (buffer, &currlen, maxlen, value, 10, min, max, flags); + break; + case 'o': + flags |= DP_F_UNSIGNED; + if (cflags == DP_C_SHORT) + value = va_arg (args, unsigned int); + else if (cflags == DP_C_LONG) + value = (long)va_arg (args, unsigned long int); + else if (cflags == DP_C_LLONG) + value = (long)va_arg (args, unsigned LLONG); + else + value = (long)va_arg (args, unsigned int); + fmtint (buffer, &currlen, maxlen, value, 8, min, max, flags); + break; + case 'u': + flags |= DP_F_UNSIGNED; + if (cflags == DP_C_SHORT) + value = va_arg (args, unsigned int); + else if (cflags == DP_C_LONG) + value = (long)va_arg (args, unsigned long int); + else if (cflags == DP_C_LLONG) + value = (LLONG)va_arg (args, unsigned LLONG); + else + value = (long)va_arg (args, unsigned int); + fmtint (buffer, &currlen, maxlen, value, 10, min, max, flags); + break; + case 'X': + flags |= DP_F_UP; + case 'x': + flags |= DP_F_UNSIGNED; + if (cflags == DP_C_SHORT) + value = va_arg (args, unsigned int); + else if (cflags == DP_C_LONG) + value = (long)va_arg (args, unsigned long int); + else if (cflags == DP_C_LLONG) + value = (LLONG)va_arg (args, unsigned LLONG); + else + value = (long)va_arg (args, unsigned int); + fmtint (buffer, &currlen, maxlen, value, 16, min, max, flags); + break; + case 'f': + if (cflags == DP_C_LDOUBLE) + fvalue = va_arg (args, LDOUBLE); + else + fvalue = va_arg (args, double); + /* um, floating point? */ + fmtfp (buffer, &currlen, maxlen, fvalue, min, max, flags); + break; + case 'E': + flags |= DP_F_UP; + case 'e': + if (cflags == DP_C_LDOUBLE) + fvalue = va_arg (args, LDOUBLE); + else + fvalue = va_arg (args, double); + break; + case 'G': + flags |= DP_F_UP; + case 'g': + if (cflags == DP_C_LDOUBLE) + fvalue = va_arg (args, LDOUBLE); + else + fvalue = va_arg (args, double); + break; + case 'c': + dopr_outch (buffer, &currlen, maxlen, va_arg (args, int)); + break; + case 's': + strvalue = va_arg (args, char *); + if (!strvalue) strvalue = "(NULL)"; + if (max == -1) { + max = strlen(strvalue); + } + if (min > 0 && max >= 0 && min > max) max = min; + fmtstr (buffer, &currlen, maxlen, strvalue, flags, min, max); + break; + case 'p': + strvalue = (char *)va_arg(args, void *); + fmtint (buffer, &currlen, maxlen, (long) strvalue, 16, min, max, flags); + break; + case 'n': + if (cflags == DP_C_SHORT) { + short int *num; + num = va_arg (args, short int *); + *num = currlen; + } else if (cflags == DP_C_LONG) { + long int *num; + num = va_arg (args, long int *); + *num = (long int)currlen; + } else if (cflags == DP_C_LLONG) { + LLONG *num; + num = va_arg (args, LLONG *); + *num = (LLONG)currlen; + } else { + int *num; + num = va_arg (args, int *); + *num = currlen; + } + break; + case '%': + dopr_outch (buffer, &currlen, maxlen, ch); + break; + case 'w': + /* not supported yet, treat as next char */ + ch = *format++; + break; + default: + /* Unknown, skip */ + break; + } + ch = *format++; + state = DP_S_DEFAULT; + flags = cflags = min = 0; + max = -1; + break; + case DP_S_DONE: + break; + default: + /* hmm? */ + break; /* some picky compilers need this */ + } + } + if (maxlen != 0) { + if (currlen < maxlen - 1) + buffer[currlen] = '\0'; + else if (maxlen > 0) + buffer[maxlen - 1] = '\0'; + } + + return currlen; +} + +static void fmtstr(char *buffer, size_t *currlen, size_t maxlen, + char *value, int flags, int min, int max) +{ + int padlen, strln; /* amount to pad */ + int cnt = 0; + +#ifdef DEBUG_SNPRINTF + printf("fmtstr min=%d max=%d s=[%s]\n", min, max, value); +#endif + if (value == 0) { + value = ""; + } + + for (strln = 0; value[strln]; ++strln); /* strlen */ + padlen = min - strln; + if (padlen < 0) + padlen = 0; + if (flags & DP_F_MINUS) + padlen = -padlen; /* Left Justify */ + + while ((padlen > 0) && (cnt < max)) { + dopr_outch (buffer, currlen, maxlen, ' '); + --padlen; + ++cnt; + } + while (*value && (cnt < max)) { + dopr_outch (buffer, currlen, maxlen, *value++); + ++cnt; + } + while ((padlen < 0) && (cnt < max)) { + dopr_outch (buffer, currlen, maxlen, ' '); + ++padlen; + ++cnt; + } +} + +/* Have to handle DP_F_NUM (ie 0x and 0 alternates) */ + +static void fmtint(char *buffer, size_t *currlen, size_t maxlen, + long value, int base, int min, int max, int flags) +{ + int signvalue = 0; + unsigned long uvalue; + char convert[20]; + int place = 0; + int spadlen = 0; /* amount to space pad */ + int zpadlen = 0; /* amount to zero pad */ + int caps = 0; + + if (max < 0) + max = 0; + + uvalue = value; + + if(!(flags & DP_F_UNSIGNED)) { + if( value < 0 ) { + signvalue = '-'; + uvalue = -value; + } else { + if (flags & DP_F_PLUS) /* Do a sign (+/i) */ + signvalue = '+'; + else if (flags & DP_F_SPACE) + signvalue = ' '; + } + } + + if (flags & DP_F_UP) caps = 1; /* Should characters be upper case? */ + + do { + convert[place++] = + (caps? "0123456789ABCDEF":"0123456789abcdef") + [uvalue % (unsigned)base ]; + uvalue = (uvalue / (unsigned)base ); + } while(uvalue && (place < 20)); + if (place == 20) place--; + convert[place] = 0; + + zpadlen = max - place; + spadlen = min - MAX (max, place) - (signvalue ? 1 : 0); + if (zpadlen < 0) zpadlen = 0; + if (spadlen < 0) spadlen = 0; + if (flags & DP_F_ZERO) { + zpadlen = MAX(zpadlen, spadlen); + spadlen = 0; + } + if (flags & DP_F_MINUS) + spadlen = -spadlen; /* Left Justifty */ + +#ifdef DEBUG_SNPRINTF + printf("zpad: %d, spad: %d, min: %d, max: %d, place: %d\n", + zpadlen, spadlen, min, max, place); +#endif + + /* Spaces */ + while (spadlen > 0) { + dopr_outch (buffer, currlen, maxlen, ' '); + --spadlen; + } + + /* Sign */ + if (signvalue) + dopr_outch (buffer, currlen, maxlen, signvalue); + + /* Zeros */ + if (zpadlen > 0) { + while (zpadlen > 0) { + dopr_outch (buffer, currlen, maxlen, '0'); + --zpadlen; + } + } + + /* Digits */ + while (place > 0) + dopr_outch (buffer, currlen, maxlen, convert[--place]); + + /* Left Justified spaces */ + while (spadlen < 0) { + dopr_outch (buffer, currlen, maxlen, ' '); + ++spadlen; + } +} + +static LDOUBLE abs_val(LDOUBLE value) +{ + LDOUBLE result = value; + + if (value < 0) + result = -value; + + return result; +} + +static LDOUBLE POW10(int exp) +{ + LDOUBLE result = 1; + + while (exp) { + result *= 10; + exp--; + } + + return result; +} + +static LLONG ROUND(LDOUBLE value) +{ + LLONG intpart; + + intpart = (LLONG)value; + value = value - intpart; + if (value >= 0.5) intpart++; + + return intpart; +} + +/* a replacement for modf that doesn't need the math library. Should + be portable, but slow */ +static double my_modf(double x0, double *iptr) +{ + int i; + long l; + double x = x0; + double f = 1.0; + + for (i=0;i<100;i++) { + l = (long)x; + if (l <= (x+1) && l >= (x-1)) break; + x *= 0.1; + f *= 10.0; + } + + if (i == 100) { + /* yikes! the number is beyond what we can handle. What do we do? */ + (*iptr) = 0; + return 0; + } + + if (i != 0) { + double i2; + double ret; + + ret = my_modf(x0-l*f, &i2); + (*iptr) = l*f + i2; + return ret; + } + + (*iptr) = l; + return x - (*iptr); +} + + +static void fmtfp (char *buffer, size_t *currlen, size_t maxlen, + LDOUBLE fvalue, int min, int max, int flags) +{ + int signvalue = 0; + double ufvalue; + char iconvert[311]; + char fconvert[311]; + int iplace = 0; + int fplace = 0; + int padlen = 0; /* amount to pad */ + int zpadlen = 0; + int caps = 0; + int index; + double intpart; + double fracpart; + double temp; + + /* + * AIX manpage says the default is 0, but Solaris says the default + * is 6, and sprintf on AIX defaults to 6 + */ + if (max < 0) + max = 6; + + ufvalue = abs_val (fvalue); + + if (fvalue < 0) { + signvalue = '-'; + } else { + if (flags & DP_F_PLUS) { /* Do a sign (+/i) */ + signvalue = '+'; + } else { + if (flags & DP_F_SPACE) + signvalue = ' '; + } + } + +#if 0 + if (flags & DP_F_UP) caps = 1; /* Should characters be upper case? */ +#endif + +#if 0 + if (max == 0) ufvalue += 0.5; /* if max = 0 we must round */ +#endif + + /* + * Sorry, we only support 16 digits past the decimal because of our + * conversion method + */ + if (max > 16) + max = 16; + + /* We "cheat" by converting the fractional part to integer by + * multiplying by a factor of 10 + */ + + temp = ufvalue; + my_modf(temp, &intpart); + + fracpart = ROUND((POW10(max)) * (ufvalue - intpart)); + + if (fracpart >= POW10(max)) { + intpart++; + fracpart -= POW10(max); + } + + + /* Convert integer part */ + do { + temp = intpart; + my_modf(intpart*0.1, &intpart); + temp = temp*0.1; + index = (int) ((temp -intpart +0.05)* 10.0); + /* index = (int) (((double)(temp*0.1) -intpart +0.05) *10.0); */ + /* printf ("%llf, %f, %x\n", temp, intpart, index); */ + iconvert[iplace++] = + (caps? "0123456789ABCDEF":"0123456789abcdef")[index]; + } while (intpart && (iplace < 311)); + if (iplace == 311) iplace--; + iconvert[iplace] = 0; + + /* Convert fractional part */ + if (fracpart) + { + do { + temp = fracpart; + my_modf(fracpart*0.1, &fracpart); + temp = temp*0.1; + index = (int) ((temp -fracpart +0.05)* 10.0); + /* index = (int) ((((temp/10) -fracpart) +0.05) *10); */ + /* printf ("%lf, %lf, %ld\n", temp, fracpart, index); */ + fconvert[fplace++] = + (caps? "0123456789ABCDEF":"0123456789abcdef")[index]; + } while(fracpart && (fplace < 311)); + if (fplace == 311) fplace--; + } + fconvert[fplace] = 0; + + /* -1 for decimal point, another -1 if we are printing a sign */ + padlen = min - iplace - max - 1 - ((signvalue) ? 1 : 0); + zpadlen = max - fplace; + if (zpadlen < 0) zpadlen = 0; + if (padlen < 0) + padlen = 0; + if (flags & DP_F_MINUS) + padlen = -padlen; /* Left Justifty */ + + if ((flags & DP_F_ZERO) && (padlen > 0)) { + if (signvalue) { + dopr_outch (buffer, currlen, maxlen, signvalue); + --padlen; + signvalue = 0; + } + while (padlen > 0) { + dopr_outch (buffer, currlen, maxlen, '0'); + --padlen; + } + } + while (padlen > 0) { + dopr_outch (buffer, currlen, maxlen, ' '); + --padlen; + } + if (signvalue) + dopr_outch (buffer, currlen, maxlen, signvalue); + + while (iplace > 0) + dopr_outch (buffer, currlen, maxlen, iconvert[--iplace]); + +#ifdef DEBUG_SNPRINTF + printf("fmtfp: fplace=%d zpadlen=%d\n", fplace, zpadlen); +#endif + + /* + * Decimal point. This should probably use locale to find the correct + * char to print out. + */ + if (max > 0) { + dopr_outch (buffer, currlen, maxlen, '.'); + + while (fplace > 0) + dopr_outch (buffer, currlen, maxlen, fconvert[--fplace]); + } + + while (zpadlen > 0) { + dopr_outch (buffer, currlen, maxlen, '0'); + --zpadlen; + } + + while (padlen < 0) { + dopr_outch (buffer, currlen, maxlen, ' '); + ++padlen; + } +} + +static void dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c) +{ + if (*currlen < maxlen) { + buffer[(*currlen)] = c; + } + (*currlen)++; +} + +/* yes this really must be a ||. Don't muck with this (tridge) */ +#if !defined(HAVE_VSNPRINTF) || !defined(HAVE_C99_VSNPRINTF) + int vsnprintf (char *str, size_t count, const char *fmt, va_list args) +{ + return dopr(str, count, fmt, args); +} +#endif + +/* yes this really must be a ||. Don't muck wiith this (tridge) + * + * The logic for these two is that we need our own definition if the + * OS *either* has no definition of *sprintf, or if it does have one + * that doesn't work properly according to the autoconf test. Perhaps + * these should really be smb_snprintf to avoid conflicts with buggy + * linkers? -- mbp + */ +#if !defined(HAVE_SNPRINTF) || !defined(HAVE_C99_SNPRINTF) + int snprintf(char *str,size_t count,const char *fmt,...) +{ + size_t ret; + va_list ap; + + va_start(ap, fmt); + ret = vsnprintf(str, count, fmt, ap); + va_end(ap); + return ret; +} +#endif + +#endif + +#ifndef HAVE_VASPRINTF + int vasprintf(char **ptr, const char *format, va_list ap) +{ + int ret; + + ret = vsnprintf(0, 0, format, ap); + if (ret <= 0) return ret; + + (*ptr) = (char *)malloc(ret+1); + if (!*ptr) return -1; + ret = vsnprintf(*ptr, ret+1, format, ap); + + return ret; +} +#endif + + +#ifndef HAVE_ASPRINTF + int asprintf(char **ptr, const char *format, ...) +{ + va_list ap; + int ret; + + *ptr = 0; + va_start(ap, format); + ret = vasprintf(ptr, format, ap); + va_end(ap); + + return ret; +} +#endif + +#ifndef HAVE_VSYSLOG +#ifdef HAVE_SYSLOG + void vsyslog (int facility_priority, char *format, va_list arglist) +{ + char *msg = 0; + vasprintf(&msg, format, arglist); + if (!msg) + return; + syslog(facility_priority, "%s", msg); + free(msg); +} +#endif /* HAVE_SYSLOG */ +#endif /* HAVE_VSYSLOG */ + +#ifdef TEST_SNPRINTF + + int sprintf(char *str,const char *fmt,...); + + int main (void) +{ + char buf1[1024]; + char buf2[1024]; + char *fp_fmt[] = { + "%1.1f", + "%-1.5f", + "%1.5f", + "%123.9f", + "%10.5f", + "% 10.5f", + "%+22.9f", + "%+4.9f", + "%01.3f", + "%4f", + "%3.1f", + "%3.2f", + "%.0f", + "%f", + "-16.16f", + 0 + }; + double fp_nums[] = { 6442452944.1234, -1.5, 134.21, 91340.2, 341.1234, 0203.9, 0.96, 0.996, + 0.9996, 1.996, 4.136, 0}; + char *int_fmt[] = { + "%-1.5d", + "%1.5d", + "%123.9d", + "%5.5d", + "%10.5d", + "% 10.5d", + "%+22.33d", + "%01.3d", + "%4d", + "%d", + 0 + }; + long int_nums[] = { -1, 134, 91340, 341, 0203, 0}; + char *str_fmt[] = { + "10.5s", + "5.10s", + "10.1s", + "0.10s", + "10.0s", + "1.10s", + "%s", + "%.1s", + "%.10s", + "%10s", + 0 + }; + char *str_vals[] = {"hello", "a", "", "a longer string", 0}; + int x, y; + int fail = 0; + int num = 0; + + printf ("Testing snprintf format codes against system sprintf...\n"); + + for (x = 0; fp_fmt[x] ; x++) { + for (y = 0; fp_nums[y] != 0 ; y++) { + int l1 = snprintf(0, 0, fp_fmt[x], fp_nums[y]); + int l2 = snprintf(buf1, sizeof(buf1), fp_fmt[x], fp_nums[y]); + sprintf (buf2, fp_fmt[x], fp_nums[y]); + if (strcmp (buf1, buf2)) { + printf("snprintf doesn't match Format: %s\n\tsnprintf = [%s]\n\t sprintf = [%s]\n", + fp_fmt[x], buf1, buf2); + fail++; + } + if (l1 != l2) { + printf("snprintf l1 != l2 (%d %d) %s\n", l1, l2, fp_fmt[x]); + fail++; + } + num++; + } + } + + for (x = 0; int_fmt[x] ; x++) { + for (y = 0; int_nums[y] != 0 ; y++) { + int l1 = snprintf(0, 0, int_fmt[x], int_nums[y]); + int l2 = snprintf(buf1, sizeof(buf1), int_fmt[x], int_nums[y]); + sprintf (buf2, int_fmt[x], int_nums[y]); + if (strcmp (buf1, buf2)) { + printf("snprintf doesn't match Format: %s\n\tsnprintf = [%s]\n\t sprintf = [%s]\n", + int_fmt[x], buf1, buf2); + fail++; + } + if (l1 != l2) { + printf("snprintf l1 != l2 (%d %d) %s\n", l1, l2, int_fmt[x]); + fail++; + } + num++; + } + } + + for (x = 0; str_fmt[x] ; x++) { + for (y = 0; str_vals[y] != 0 ; y++) { + int l1 = snprintf(0, 0, str_fmt[x], str_vals[y]); + int l2 = snprintf(buf1, sizeof(buf1), str_fmt[x], str_vals[y]); + sprintf (buf2, str_fmt[x], str_vals[y]); + if (strcmp (buf1, buf2)) { + printf("snprintf doesn't match Format: %s\n\tsnprintf = [%s]\n\t sprintf = [%s]\n", + str_fmt[x], buf1, buf2); + fail++; + } + if (l1 != l2) { + printf("snprintf l1 != l2 (%d %d) %s\n", l1, l2, str_fmt[x]); + fail++; + } + num++; + } + } + + printf ("%d tests failed out of %d.\n", fail, num); + + printf("seeing how many digits we support\n"); + { + double v0 = 0.12345678901234567890123456789012345678901; + for (x=0; x<100; x++) { + snprintf(buf1, sizeof(buf1), "%1.1f", v0*pow(10, x)); + sprintf(buf2, "%1.1f", v0*pow(10, x)); + if (strcmp(buf1, buf2)) { + printf("we seem to support %d digits\n", x-1); + break; + } + } + } + + return 0; +} +#endif /* SNPRINTF_TEST */ diff --git a/CCache/stats.c b/CCache/stats.c new file mode 100644 index 000000000..e5662fb26 --- /dev/null +++ b/CCache/stats.c @@ -0,0 +1,354 @@ +/* + Copyright (C) Andrew Tridgell 2002 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ +/* + routines to handle the stats files + + the stats file is stored one per cache subdirectory to make this more + scalable + */ + +#include "ccache.h" + +extern char *stats_file; +extern char *cache_dir; + +#define STATS_VERSION 1 + +#define FLAG_NOZERO 1 /* don't zero with the -z option */ +#define FLAG_ALWAYS 2 /* always show, even if zero */ + +static struct { + enum stats stat; + char *message; + void (*fn)(unsigned ); + unsigned flags; +} stats_info[] = { + { STATS_CACHED, "cache hit ", NULL, FLAG_ALWAYS }, + { STATS_TOCACHE, "cache miss ", NULL, FLAG_ALWAYS }, + { STATS_LINK, "called for link ", NULL, 0 }, + { STATS_MULTIPLE, "multiple source files ", NULL, 0 }, + { STATS_STDOUT, "compiler produced stdout ", NULL, 0 }, + { STATS_STATUS, "compile failed ", NULL, 0 }, + { STATS_ERROR, "ccache internal error ", NULL, 0 }, + { STATS_PREPROCESSOR, "preprocessor error ", NULL, 0 }, + { STATS_COMPILER, "couldn't find the compiler ", NULL, 0 }, + { STATS_MISSING, "cache file missing ", NULL, 0 }, + { STATS_ARGS, "bad compiler arguments ", NULL, 0 }, + { STATS_NOTC, "not a C/C++ file ", NULL, 0 }, + { STATS_CONFTEST, "autoconf compile/link ", NULL, 0 }, + { STATS_UNSUPPORTED, "unsupported compiler option ", NULL, 0 }, + { STATS_OUTSTDOUT, "output to stdout ", NULL, 0 }, + { STATS_DEVICE, "output to a non-regular file ", NULL, 0 }, + { STATS_NOINPUT, "no input file ", NULL, 0 }, + { STATS_NUMFILES, "files in cache ", NULL, FLAG_NOZERO|FLAG_ALWAYS }, + { STATS_TOTALSIZE, "cache size ", display_size , FLAG_NOZERO|FLAG_ALWAYS }, + { STATS_MAXFILES, "max files ", NULL, FLAG_NOZERO }, + { STATS_MAXSIZE, "max cache size ", display_size, FLAG_NOZERO }, + { STATS_NONE, NULL, NULL, 0 } +}; + +/* parse a stats file from a buffer - adding to the counters */ +static void parse_stats(unsigned counters[STATS_END], char *buf) +{ + int i; + char *p, *p2; + + p = buf; + for (i=0;i= (int)sizeof(buf)-1) fatal("stats too long?!"); + } + len += snprintf(buf+len, sizeof(buf)-(len+1), "\n"); + if (len >= (int)sizeof(buf)-1) fatal("stats too long?!"); + + lseek(fd, 0, SEEK_SET); + write(fd, buf, len); +} + + +/* fill in some default stats values */ +static void stats_default(unsigned counters[STATS_END]) +{ + counters[STATS_MAXSIZE] += DEFAULT_MAXSIZE / 16; +} + +/* read in the stats from one dir and add to the counters */ +static void stats_read_fd(int fd, unsigned counters[STATS_END]) +{ + char buf[1024]; + int len; + len = read(fd, buf, sizeof(buf)-1); + if (len <= 0) { + stats_default(counters); + return; + } + buf[len] = 0; + parse_stats(counters, buf); +} + +/* update the stats counter for this compile */ +static void stats_update_size(enum stats stat, size_t size) +{ + int fd; + unsigned counters[STATS_END]; + int need_cleanup = 0; + + if (getenv("CCACHE_NOSTATS")) return; + + if (!stats_file) { + if (!cache_dir) return; + x_asprintf(&stats_file, "%s/stats", cache_dir); + } + + /* open safely to try to prevent symlink races */ + fd = safe_open(stats_file); + + /* still can't get it? don't bother ... */ + if (fd == -1) return; + + memset(counters, 0, sizeof(counters)); + + if (lock_fd(fd) != 0) return; + + /* read in the old stats */ + stats_read_fd(fd, counters); + + /* update them */ + counters[stat]++; + + /* on a cache miss we up the file count and size */ + if (stat == STATS_TOCACHE) { + counters[STATS_NUMFILES] += 2; + counters[STATS_TOTALSIZE] += size; + } + + /* and write them out */ + write_stats(fd, counters); + close(fd); + + /* we might need to cleanup if the cache has now got too big */ + if (counters[STATS_MAXFILES] != 0 && + counters[STATS_NUMFILES] > counters[STATS_MAXFILES]) { + need_cleanup = 1; + } + if (counters[STATS_MAXSIZE] != 0 && + counters[STATS_TOTALSIZE] > counters[STATS_MAXSIZE]) { + need_cleanup = 1; + } + + if (need_cleanup) { + char *p = dirname(stats_file); + cleanup_dir(p, counters[STATS_MAXFILES], counters[STATS_MAXSIZE]); + free(p); + } +} + +/* record a cache miss */ +void stats_tocache(size_t size) +{ + /* convert size to kilobytes */ + size = size / 1024; + + stats_update_size(STATS_TOCACHE, size); +} + +/* update a normal stat */ +void stats_update(enum stats stat) +{ + stats_update_size(stat, 0); +} + +/* read in the stats from one dir and add to the counters */ +void stats_read(const char *stats_file, unsigned counters[STATS_END]) +{ + int fd; + + fd = open(stats_file, O_RDONLY|O_BINARY); + if (fd == -1) { + stats_default(counters); + return; + } + lock_fd(fd); + stats_read_fd(fd, counters); + close(fd); +} + +/* sum and display the total stats for all cache dirs */ +void stats_summary(void) +{ + int dir, i; + unsigned counters[STATS_END]; + + memset(counters, 0, sizeof(counters)); + + /* add up the stats in each directory */ + for (dir=-1;dir<=0xF;dir++) { + char *fname; + + if (dir == -1) { + x_asprintf(&fname, "%s/stats", cache_dir); + } else { + x_asprintf(&fname, "%s/%1x/stats", cache_dir, dir); + } + + stats_read(fname, counters); + free(fname); + + /* oh what a nasty hack ... */ + if (dir == -1) { + counters[STATS_MAXSIZE] = 0; + } + + } + + printf("cache directory %s\n", cache_dir); + + /* and display them */ + for (i=0;stats_info[i].message;i++) { + enum stats stat = stats_info[i].stat; + + if (counters[stat] == 0 && + !(stats_info[i].flags & FLAG_ALWAYS)) { + continue; + } + + printf("%s ", stats_info[i].message); + if (stats_info[i].fn) { + stats_info[i].fn(counters[stat]); + printf("\n"); + } else { + printf("%8u\n", counters[stat]); + } + } +} + +/* zero all the stats structures */ +void stats_zero(void) +{ + int dir, fd; + unsigned i; + char *fname; + unsigned counters[STATS_END]; + + x_asprintf(&fname, "%s/stats", cache_dir); + unlink(fname); + free(fname); + + for (dir=0;dir<=0xF;dir++) { + x_asprintf(&fname, "%s/%1x/stats", cache_dir, dir); + fd = safe_open(fname); + if (fd == -1) { + free(fname); + continue; + } + memset(counters, 0, sizeof(counters)); + lock_fd(fd); + stats_read_fd(fd, counters); + for (i=0;stats_info[i].message;i++) { + if (!(stats_info[i].flags & FLAG_NOZERO)) { + counters[stats_info[i].stat] = 0; + } + } + write_stats(fd, counters); + close(fd); + free(fname); + } +} + + +/* set the per directory limits */ +void stats_set_limits(long maxfiles, long maxsize) +{ + int dir; + unsigned counters[STATS_END]; + + if (maxfiles != -1) { + maxfiles /= 16; + } + if (maxsize != -1) { + maxsize /= 16; + } + + create_dir(cache_dir); + + /* set the limits in each directory */ + for (dir=0;dir<=0xF;dir++) { + char *fname, *cdir; + int fd; + + x_asprintf(&cdir, "%s/%1x", cache_dir, dir); + create_dir(cdir); + x_asprintf(&fname, "%s/stats", cdir); + free(cdir); + + memset(counters, 0, sizeof(counters)); + fd = safe_open(fname); + if (fd != -1) { + lock_fd(fd); + stats_read_fd(fd, counters); + if (maxfiles != -1) { + counters[STATS_MAXFILES] = maxfiles; + } + if (maxsize != -1) { + counters[STATS_MAXSIZE] = maxsize; + } + write_stats(fd, counters); + close(fd); + } + free(fname); + } +} + +/* set the per directory sizes */ +void stats_set_sizes(const char *dir, size_t num_files, size_t total_size) +{ + int fd; + unsigned counters[STATS_END]; + char *stats_file; + + create_dir(dir); + x_asprintf(&stats_file, "%s/stats", dir); + + memset(counters, 0, sizeof(counters)); + + fd = safe_open(stats_file); + if (fd != -1) { + lock_fd(fd); + stats_read_fd(fd, counters); + counters[STATS_NUMFILES] = num_files; + counters[STATS_TOTALSIZE] = total_size; + write_stats(fd, counters); + close(fd); + } + + free(stats_file); +} diff --git a/CCache/test.sh b/CCache/test.sh new file mode 100755 index 000000000..ad43f6edd --- /dev/null +++ b/CCache/test.sh @@ -0,0 +1,287 @@ +#!/bin/sh + +# a simple test suite for ccache +# tridge@samba.org + +if test -n "$CC"; then + COMPILER="$CC" +else + COMPILER=cc +fi + +CCACHE=../ccache +TESTDIR=test.$$ + +test_failed() { + reason="$1" + echo $1 + $CCACHE -s + cd .. + rm -rf $TESTDIR + echo TEST FAILED + exit 1 +} + +randcode() { + outfile="$1" + nlines=$2 + i=0; + ( + while [ $i -lt $nlines ]; do + echo "int foo$nlines$i(int x) { return x; }" + i=`expr $i + 1` + done + ) >> "$outfile" +} + + +getstat() { + stat="$1" + value=`$CCACHE -s | grep "$stat" | cut -c34-40` + echo $value +} + +checkstat() { + stat="$1" + expected_value="$2" + value=`getstat "$stat"` + if [ "$expected_value" != "$value" ]; then + test_failed "SUITE: $testsuite TEST: $testname - Expected $stat to be $expected_value got $value" + fi +} + + +basetests() { + echo "starting testsuite $testsuite" + rm -rf .ccache + checkstat 'cache hit' 0 + checkstat 'cache miss' 0 + + j=1 + rm -f *.c + while [ $j -lt 32 ]; do + randcode test$j.c $j + j=`expr $j + 1` + done + + testname="BASIC" + $CCACHE_COMPILE -c test1.c + checkstat 'cache hit' 0 + checkstat 'cache miss' 1 + + testname="BASIC2" + $CCACHE_COMPILE -c test1.c + checkstat 'cache hit' 1 + checkstat 'cache miss' 1 + + testname="debug" + $CCACHE_COMPILE -c test1.c -g + checkstat 'cache hit' 1 + checkstat 'cache miss' 2 + + testname="debug2" + $CCACHE_COMPILE -c test1.c -g + checkstat 'cache hit' 2 + checkstat 'cache miss' 2 + + testname="output" + $CCACHE_COMPILE -c test1.c -o foo.o + checkstat 'cache hit' 3 + checkstat 'cache miss' 2 + + testname="link" + $CCACHE_COMPILE test1.c -o test 2> /dev/null + checkstat 'called for link' 1 + + testname="multiple" + $CCACHE_COMPILE -c test1.c test2.c + checkstat 'multiple source files' 1 + + testname="find" + $CCACHE blahblah -c test1.c 2> /dev/null + checkstat "couldn't find the compiler" 1 + + testname="bad" + $CCACHE_COMPILE -c test1.c -I 2> /dev/null + checkstat 'bad compiler arguments' 1 + + testname="c/c++" + ln -f test1.c test1.ccc + $CCACHE_COMPILE -c test1.ccc 2> /dev/null + checkstat 'not a C/C++ file' 1 + + testname="unsupported" + $CCACHE_COMPILE -M foo -c test1.c > /dev/null 2>&1 + checkstat 'unsupported compiler option' 1 + + testname="stdout" + $CCACHE echo foo -c test1.c > /dev/null + checkstat 'compiler produced stdout' 1 + + testname="non-regular" + mkdir testd + $CCACHE_COMPILE -o testd -c test1.c > /dev/null 2>&1 + rmdir testd + checkstat 'output to a non-regular file' 1 + + testname="no-input" + $CCACHE_COMPILE -c -O2 2> /dev/null + checkstat 'no input file' 1 + + + testname="CCACHE_DISABLE" + CCACHE_DISABLE=1 $CCACHE_COMPILE -c test1.c 2> /dev/null + checkstat 'cache hit' 3 + $CCACHE_COMPILE -c test1.c + checkstat 'cache hit' 4 + + testname="CCACHE_CPP2" + CCACHE_CPP2=1 $CCACHE_COMPILE -c test1.c -O -O + checkstat 'cache hit' 4 + checkstat 'cache miss' 3 + + CCACHE_CPP2=1 $CCACHE_COMPILE -c test1.c -O -O + checkstat 'cache hit' 5 + checkstat 'cache miss' 3 + + testname="CCACHE_NOSTATS" + CCACHE_NOSTATS=1 $CCACHE_COMPILE -c test1.c -O -O + checkstat 'cache hit' 5 + checkstat 'cache miss' 3 + + testname="CCACHE_RECACHE" + CCACHE_RECACHE=1 $CCACHE_COMPILE -c test1.c -O -O + checkstat 'cache hit' 5 + checkstat 'cache miss' 4 + + # strictly speaking should be 6 - RECACHE causes a double counting! + checkstat 'files in cache' 8 + $CCACHE -c > /dev/null + checkstat 'files in cache' 6 + + + testname="CCACHE_HASHDIR" + CCACHE_HASHDIR=1 $CCACHE_COMPILE -c test1.c -O -O + checkstat 'cache hit' 5 + checkstat 'cache miss' 5 + + CCACHE_HASHDIR=1 $CCACHE_COMPILE -c test1.c -O -O + checkstat 'cache hit' 6 + checkstat 'cache miss' 5 + + checkstat 'files in cache' 8 + + testname="comments" + echo '/* a silly comment */' > test1-comment.c + cat test1.c >> test1-comment.c + $CCACHE_COMPILE -c test1-comment.c + rm -f test1-comment* + checkstat 'cache hit' 6 + checkstat 'cache miss' 6 + + testname="CCACHE_UNIFY" + CCACHE_UNIFY=1 $CCACHE_COMPILE -c test1.c + checkstat 'cache hit' 6 + checkstat 'cache miss' 7 + mv test1.c test1-saved.c + echo '/* another comment */' > test1.c + cat test1-saved.c >> test1.c + CCACHE_UNIFY=1 $CCACHE_COMPILE -c test1.c + mv test1-saved.c test1.c + checkstat 'cache hit' 7 + checkstat 'cache miss' 7 + + testname="cache-size" + for f in *.c; do + $CCACHE_COMPILE -c $f + done + checkstat 'cache hit' 8 + checkstat 'cache miss' 37 + checkstat 'files in cache' 72 + $CCACHE -F 48 -c > /dev/null + if [ `getstat 'files in cache'` -gt 48 ]; then + test_failed '-F test failed' + fi + + testname="cpp call" + $CCACHE_COMPILE -c test1.c -E > test1.i + checkstat 'cache hit' 8 + checkstat 'cache miss' 37 + + testname="direct .i compile" + $CCACHE_COMPILE -c test1.c + checkstat 'cache hit' 8 + checkstat 'cache miss' 38 + + $CCACHE_COMPILE -c test1.i + checkstat 'cache hit' 9 + checkstat 'cache miss' 38 + + $CCACHE_COMPILE -c test1.i + checkstat 'cache hit' 10 + checkstat 'cache miss' 38 + + # removed these tests as some compilers (including newer versions of gcc) + # determine which language to use based on .ii/.i extension, and C++ may + # not be installed +# testname="direct .ii file" +# mv test1.i test1.ii +# $CCACHE_COMPILE -c test1.ii +# checkstat 'cache hit' 10 +# checkstat 'cache miss' 39 + +# $CCACHE_COMPILE -c test1.ii +# checkstat 'cache hit' 11 +# checkstat 'cache miss' 39 + + testname="zero-stats" + $CCACHE -z > /dev/null + checkstat 'cache hit' 0 + checkstat 'cache miss' 0 + + testname="clear" + $CCACHE -C > /dev/null + checkstat 'files in cache' 0 + + + rm -f test1.c +} + +###### +# main program +rm -rf $TESTDIR +mkdir $TESTDIR +cd $TESTDIR || exit 1 +mkdir .ccache +CCACHE_DIR=.ccache +export CCACHE_DIR + +testsuite="base" +CCACHE_COMPILE="$CCACHE $COMPILER" +basetests + +testsuite="link" +ln -s ../ccache $COMPILER +CCACHE_COMPILE="./$COMPILER" +basetests + +testsuite="hardlink" +CCACHE_COMPILE="$CCACHE $COMPILER" +CCACHE_HARDLINK=1 basetests + +testsuite="cpp2" +CCACHE_COMPILE="$CCACHE $COMPILER" +CCACHE_CPP2=1 basetests + +testsuite="nlevels4" +CCACHE_COMPILE="$CCACHE $COMPILER" +CCACHE_NLEVELS=4 basetests + +testsuite="nlevels1" +CCACHE_COMPILE="$CCACHE $COMPILER" +CCACHE_NLEVELS=1 basetests + +cd .. +rm -rf $TESTDIR +echo test done - OK +exit 0 diff --git a/CCache/unify.c b/CCache/unify.c new file mode 100644 index 000000000..e436ed7fd --- /dev/null +++ b/CCache/unify.c @@ -0,0 +1,269 @@ +/* + Copyright (C) Andrew Tridgell 2002 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ +/* + C/C++ unifier + + the idea is that changes that don't affect the resulting C code + should not change the hash. This is achieved by folding white-space + and other non-semantic fluff in the input into a single unified format. + + This unifier was design to match the output of the unifier in + compilercache, which is flex based. The major difference is that + this unifier is much faster (about 2x) and more forgiving of + syntactic errors. Continuing on syntactic errors is important to + cope with C/C++ extensions in the local compiler (for example, + inline assembly systems). +*/ + +#include "ccache.h" + +static char *s_tokens[] = { + "...", ">>=", "<<=", "+=", "-=", "*=", "/=", "%=", "&=", "^=", + "|=", ">>", "<<", "++", "--", "->", "&&", "||", "<=", ">=", + "==", "!=", ";", "{", "<%", "}", "%>", ",", ":", "=", + "(", ")", "[", "<:", "]", ":>", ".", "&", "!", "~", + "-", "+", "*", "/", "%", "<", ">", "^", "|", "?", + 0 +}; + +#define C_ALPHA 1 +#define C_SPACE 2 +#define C_TOKEN 4 +#define C_QUOTE 8 +#define C_DIGIT 16 +#define C_HEX 32 +#define C_FLOAT 64 +#define C_SIGN 128 + +static struct { + unsigned char type; + unsigned char num_toks; + char *toks[7]; +} tokens[256]; + +/* build up the table used by the unifier */ +static void build_table(void) +{ + unsigned char c; + int i; + static int done; + + if (done) return; + done = 1; + + memset(tokens, 0, sizeof(tokens)); + for (c=0;c<128;c++) { + if (isalpha(c) || c == '_') tokens[c].type |= C_ALPHA; + if (isdigit(c)) tokens[c].type |= C_DIGIT; + if (isspace(c)) tokens[c].type |= C_SPACE; + if (isxdigit(c)) tokens[c].type |= C_HEX; + } + tokens['\''].type |= C_QUOTE; + tokens['"'].type |= C_QUOTE; + tokens['l'].type |= C_FLOAT; + tokens['L'].type |= C_FLOAT; + tokens['f'].type |= C_FLOAT; + tokens['F'].type |= C_FLOAT; + tokens['U'].type |= C_FLOAT; + tokens['u'].type |= C_FLOAT; + + tokens['-'].type |= C_SIGN; + tokens['+'].type |= C_SIGN; + + for (i=0;s_tokens[i];i++) { + c = s_tokens[i][0]; + tokens[c].type |= C_TOKEN; + tokens[c].toks[tokens[c].num_toks] = s_tokens[i]; + tokens[c].num_toks++; + } +} + +/* buffer up characters before hashing them */ +static void pushchar(unsigned char c) +{ + static unsigned char buf[64]; + static int len; + + if (c == 0) { + if (len > 0) { + hash_buffer((char *)buf, len); + len = 0; + } + hash_buffer(NULL, 0); + return; + } + + buf[len++] = c; + if (len == 64) { + hash_buffer((char *)buf, len); + len = 0; + } +} + +/* hash some C/C++ code after unifying */ +static void unify(unsigned char *p, size_t size) +{ + size_t ofs; + unsigned char q; + int i; + + build_table(); + + for (ofs=0; ofs 2 && p[ofs+1] == ' ' && isdigit(p[ofs+2])) { + do { + ofs++; + } while (ofs < size && p[ofs] != '\n'); + ofs++; + } else { + do { + pushchar(p[ofs]); + ofs++; + } while (ofs < size && p[ofs] != '\n'); + pushchar('\n'); + ofs++; + } + continue; + } + + if (tokens[p[ofs]].type & C_ALPHA) { + do { + pushchar(p[ofs]); + ofs++; + } while (ofs < size && + (tokens[p[ofs]].type & (C_ALPHA|C_DIGIT))); + pushchar('\n'); + continue; + } + + if (tokens[p[ofs]].type & C_DIGIT) { + do { + pushchar(p[ofs]); + ofs++; + } while (ofs < size && + ((tokens[p[ofs]].type & C_DIGIT) || p[ofs] == '.')); + if (ofs < size && (p[ofs] == 'x' || p[ofs] == 'X')) { + do { + pushchar(p[ofs]); + ofs++; + } while (ofs < size && (tokens[p[ofs]].type & C_HEX)); + } + if (ofs < size && (p[ofs] == 'E' || p[ofs] == 'e')) { + pushchar(p[ofs]); + ofs++; + while (ofs < size && + (tokens[p[ofs]].type & (C_DIGIT|C_SIGN))) { + pushchar(p[ofs]); + ofs++; + } + } + while (ofs < size && (tokens[p[ofs]].type & C_FLOAT)) { + pushchar(p[ofs]); + ofs++; + } + pushchar('\n'); + continue; + } + + if (tokens[p[ofs]].type & C_SPACE) { + do { + ofs++; + } while (ofs < size && (tokens[p[ofs]].type & C_SPACE)); + continue; + } + + if (tokens[p[ofs]].type & C_QUOTE) { + q = p[ofs]; + pushchar(p[ofs]); + do { + ofs++; + while (ofs < size-1 && p[ofs] == '\\') { + pushchar(p[ofs]); + pushchar(p[ofs+1]); + ofs+=2; + } + pushchar(p[ofs]); + } while (ofs < size && p[ofs] != q); + pushchar('\n'); + ofs++; + continue; + } + + if (tokens[p[ofs]].type & C_TOKEN) { + q = p[ofs]; + for (i=0;i= ofs+len && memcmp(&p[ofs], s, len) == 0) { + int j; + for (j=0;s[j];j++) { + pushchar(s[j]); + ofs++; + } + pushchar('\n'); + break; + } + } + if (i < tokens[q].num_toks) { + continue; + } + } + + pushchar(p[ofs]); + pushchar('\n'); + ofs++; + } + pushchar(0); +} + + +/* hash a file that consists of preprocessor output, but remove any line + number information from the hash +*/ +int unify_hash(const char *fname) +{ + int fd; + struct stat st; + char *map; + + fd = open(fname, O_RDONLY|O_BINARY); + if (fd == -1 || fstat(fd, &st) != 0) { + cc_log("Failed to open preprocessor output %s\n", fname); + stats_update(STATS_PREPROCESSOR); + return -1; + } + + /* we use mmap() to make it easy to handle arbitrarily long + lines in preprocessor output. I have seen lines of over + 100k in length, so this is well worth it */ + map = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0); + if (map == (char *)-1) { + cc_log("Failed to mmap %s\n", fname); + return -1; + } + close(fd); + + /* pass it through the unifier */ + unify((unsigned char *)map, st.st_size); + + munmap(map, st.st_size); + + return 0; +} + diff --git a/CCache/util.c b/CCache/util.c new file mode 100644 index 000000000..ec5ccdd49 --- /dev/null +++ b/CCache/util.c @@ -0,0 +1,454 @@ +/* + Copyright (C) Andrew Tridgell 2002 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "ccache.h" + +static FILE *logfile; + +/* log a message to the CCACHE_LOGFILE location */ +void cc_log(const char *format, ...) +{ + va_list ap; + extern char *cache_logfile; + + if (!cache_logfile) return; + + if (!logfile) logfile = fopen(cache_logfile, "a"); + if (!logfile) return; + + va_start(ap, format); + vfprintf(logfile, format, ap); + va_end(ap); + fflush(logfile); +} + +/* something went badly wrong! */ +void fatal(const char *msg) +{ + cc_log("FATAL: %s\n", msg); + exit(1); +} + +/* copy all data from one file descriptor to another */ +void copy_fd(int fd_in, int fd_out) +{ + char buf[10240]; + int n; + + while ((n = read(fd_in, buf, sizeof(buf))) > 0) { + if (write(fd_out, buf, n) != n) { + fatal("Failed to copy fd"); + } + } +} + +/* copy a file - used when hard links don't work + the copy is done via a temporary file and atomic rename +*/ +int copy_file(const char *src, const char *dest) +{ + int fd1, fd2; + char buf[10240]; + int n; + char *tmp_name; + mode_t mask; + + x_asprintf(&tmp_name, "%s.XXXXXX", dest); + + fd1 = open(src, O_RDONLY|O_BINARY); + if (fd1 == -1) { + free(tmp_name); + return -1; + } + + fd2 = mkstemp(tmp_name); + if (fd2 == -1) { + close(fd1); + free(tmp_name); + return -1; + } + + while ((n = read(fd1, buf, sizeof(buf))) > 0) { + if (write(fd2, buf, n) != n) { + close(fd2); + close(fd1); + unlink(tmp_name); + free(tmp_name); + return -1; + } + } + + close(fd1); + + /* get perms right on the tmp file */ + mask = umask(0); + fchmod(fd2, 0666 & ~mask); + umask(mask); + + /* the close can fail on NFS if out of space */ + if (close(fd2) == -1) { + unlink(tmp_name); + free(tmp_name); + return -1; + } + + unlink(dest); + + if (rename(tmp_name, dest) == -1) { + unlink(tmp_name); + free(tmp_name); + return -1; + } + + free(tmp_name); + + return 0; +} + + +/* make sure a directory exists */ +int create_dir(const char *dir) +{ + struct stat st; + if (stat(dir, &st) == 0) { + if (S_ISDIR(st.st_mode)) { + return 0; + } + errno = ENOTDIR; + return 1; + } + if (mkdir(dir, 0777) != 0 && errno != EEXIST) { + return 1; + } + return 0; +} + +/* + this is like asprintf() but dies if the malloc fails + note that we use vsnprintf in a rather poor way to make this more portable +*/ +void x_asprintf(char **ptr, const char *format, ...) +{ + va_list ap; + + *ptr = NULL; + va_start(ap, format); + vasprintf(ptr, format, ap); + va_end(ap); + + if (!ptr) fatal("out of memory in x_asprintf"); +} + +/* + this is like strdup() but dies if the malloc fails +*/ +char *x_strdup(const char *s) +{ + char *ret; + ret = strdup(s); + if (!ret) { + fatal("out of memory in strdup\n"); + } + return ret; +} + +/* + this is like malloc() but dies if the malloc fails +*/ +void *x_malloc(size_t size) +{ + void *ret; + ret = malloc(size); + if (!ret) { + fatal("out of memory in malloc\n"); + } + return ret; +} + +/* + this is like realloc() but dies if the malloc fails +*/ +void *x_realloc(void *ptr, size_t size) +{ + void *p2; + if (!ptr) return x_malloc(size); + p2 = malloc(size); + if (!p2) { + fatal("out of memory in x_realloc"); + } + if (ptr) { + memcpy(p2, ptr, size); + free(ptr); + } + return p2; +} + + +/* + revsusive directory traversal - used for cleanup + fn() is called on all files/dirs in the tree + */ +void traverse(const char *dir, void (*fn)(const char *, struct stat *)) +{ + DIR *d; + struct dirent *de; + + d = opendir(dir); + if (!d) return; + + while ((de = readdir(d))) { + char *fname; + struct stat st; + + if (strcmp(de->d_name,".") == 0) continue; + if (strcmp(de->d_name,"..") == 0) continue; + + if (strlen(de->d_name) == 0) continue; + + x_asprintf(&fname, "%s/%s", dir, de->d_name); + if (lstat(fname, &st)) { + if (errno != ENOENT) { + perror(fname); + } + free(fname); + continue; + } + + if (S_ISDIR(st.st_mode)) { + traverse(fname, fn); + } + + fn(fname, &st); + free(fname); + } + + closedir(d); +} + + +/* return the base name of a file - caller frees */ +char *str_basename(const char *s) +{ + char *p = strrchr(s, '/'); + if (p) { + return x_strdup(p+1); + } + + return x_strdup(s); +} + +/* return the dir name of a file - caller frees */ +char *dirname(char *s) +{ + char *p; + s = x_strdup(s); + p = strrchr(s, '/'); + if (p) { + *p = 0; + } + return s; +} + +int lock_fd(int fd) +{ + struct flock fl; + int ret; + + fl.l_type = F_WRLCK; + fl.l_whence = SEEK_SET; + fl.l_start = 0; + fl.l_len = 1; + fl.l_pid = 0; + + /* not sure why we would be getting a signal here, + but one user claimed it is possible */ + do { + ret = fcntl(fd, F_SETLKW, &fl); + } while (ret == -1 && errno == EINTR); + return ret; +} + +/* return size on disk of a file */ +size_t file_size(struct stat *st) +{ + size_t size = st->st_blocks * 512; + if ((size_t)st->st_size > size) { + /* probably a broken stat() call ... */ + size = (st->st_size + 1023) & ~1023; + } + return size; +} + + +/* a safe open/create for read-write */ +int safe_open(const char *fname) +{ + int fd = open(fname, O_RDWR|O_BINARY); + if (fd == -1 && errno == ENOENT) { + fd = open(fname, O_RDWR|O_CREAT|O_EXCL|O_BINARY, 0666); + if (fd == -1 && errno == EEXIST) { + fd = open(fname, O_RDWR|O_BINARY); + } + } + return fd; +} + +/* display a kilobyte unsigned value in M, k or G */ +void display_size(unsigned v) +{ + if (v > 1024*1024) { + printf("%8.1f Gbytes", v/((double)(1024*1024))); + } else if (v > 1024) { + printf("%8.1f Mbytes", v/((double)(1024))); + } else { + printf("%8u Kbytes", v); + } +} + +/* return a value in multiples of 1024 give a string that can end + in K, M or G +*/ +size_t value_units(const char *s) +{ + char m; + double v = atof(s); + m = s[strlen(s)-1]; + switch (m) { + case 'G': + case 'g': + default: + v *= 1024*1024; + break; + case 'M': + case 'm': + v *= 1024; + break; + case 'K': + case 'k': + v *= 1; + break; + } + return (size_t)v; +} + + +/* + a sane realpath() function, trying to cope with stupid path limits and + a broken API +*/ +char *x_realpath(const char *path) +{ + int maxlen; + char *ret, *p; +#ifdef PATH_MAX + maxlen = PATH_MAX; +#elif defined(MAXPATHLEN) + maxlen = MAXPATHLEN; +#elif defined(_PC_PATH_MAX) + maxlen = pathconf(path, _PC_PATH_MAX); +#endif + if (maxlen < 4096) maxlen = 4096; + + ret = x_malloc(maxlen); + +#if HAVE_REALPATH + p = realpath(path, ret); +#else + /* yes, there are such systems. This replacement relies on + the fact that when we call x_realpath we only care about symlinks */ + { + int len = readlink(path, ret, maxlen-1); + if (len == -1) { + free(ret); + return NULL; + } + ret[len] = 0; + p = ret; + } +#endif + if (p) { + p = x_strdup(p); + free(ret); + return p; + } + free(ret); + return NULL; +} + +/* a getcwd that will returns an allocated buffer */ +char *gnu_getcwd(void) +{ + unsigned size = 128; + + while (1) { + char *buffer = (char *)x_malloc(size); + if (getcwd(buffer, size) == buffer) { + return buffer; + } + free(buffer); + if (errno != ERANGE) { + return 0; + } + size *= 2; + } +} + +#ifndef HAVE_MKSTEMP +/* cheap and nasty mkstemp replacement */ +int mkstemp(char *template) +{ + mktemp(template); + return open(template, O_RDWR | O_CREAT | O_EXCL | O_BINARY, 0600); +} +#endif + + +/* create an empty file */ +int create_empty_file(const char *fname) +{ + int fd; + + fd = open(fname, O_WRONLY|O_CREAT|O_TRUNC|O_EXCL|O_BINARY, 0666); + if (fd == -1) { + return -1; + } + close(fd); + return 0; +} + +/* + return current users home directory or die +*/ +const char *get_home_directory(void) +{ + const char *p = getenv("HOME"); + if (p) { + return p; + } +#ifdef HAVE_GETPWUID + { + struct passwd *pwd = getpwuid(getuid()); + if (pwd) { + return pwd->pw_dir; + } + } +#endif + fatal("Unable to determine home directory"); + return NULL; +} + diff --git a/CCache/web/ccache-man.html b/CCache/web/ccache-man.html new file mode 100644 index 000000000..b831e71da --- /dev/null +++ b/CCache/web/ccache-man.html @@ -0,0 +1,318 @@ + + + + + +ccache + + + + + +
    + +

    ccache

    +

    April 2002

    + + + +

    NAME

    + ccache - a fast compiler cache +

    SYNOPSIS

    + +

    ccache [OPTION] +

    ccache <compiler> [COMPILER OPTIONS] +

    <compiler> [COMPILER OPTIONS] +

    DESCRIPTION

    + +

    ccache is a compiler cache. It speeds up re-compilation of C/C++ code +by caching previous compiles and detecting when the same compile is +being done again. +

    OPTIONS SUMMARY

    + +

    Here is a summary of the options to ccache. +

    +
    +-s                      show statistics summary
    +-z                      zero statistics
    +-c                      run a cache cleanup
    +-C                      clear the cache completely
    +-F <maxfiles>           set maximum files in cache
    +-M <maxsize>            set maximum size of cache (use G, M or K)
    +-h                      this help page
    +-V                      print version number
    +
    +
    + +

    OPTIONS

    + +

    These options only apply when you invoke ccache as "ccache". When +invoked as a compiler none of these options apply. In that case your +normal compiler options apply and you should refer to your compilers +documentation. +

    +

    -h
    Print a options summary page +

    -s
    Print the current statistics summary for the cache. The +statistics are stored spread across the subdirectories of the +cache. Using "ccache -s" adds up the statistics across all +subdirectories and prints the totals. +

    -z
    Zero the cache statistics. +

    -V
    Print the ccache version number +

    -c
    Clean the cache and re-calculate the cache file count and +size totals. Normally the -c option should not be necessary as ccache +keeps the cache below the specified limits at runtime and keeps +statistics up to date on each compile. This option is mostly useful +if you manually modify the cache contents or believe that the cache +size statistics may be inaccurate. +

    -C
    Clear the entire cache, removing all cached files. +

    -F maxfiles
    This sets the maximum number of files allowed in +the cache. The value is stored inside the cache directory and applies +to all future compiles. Due to the way the value is stored the actual +value used is always rounded down to the nearest multiple of 16. +

    -M maxsize
    This sets the maximum cache size. You can specify +a value in gigabytes, megabytes or kilobytes by appending a G, M or K +to the value. The default is gigabytes. The actual value stored is +rounded down to the nearest multiple of 16 kilobytes. +

    +

    INSTALLATION

    + +

    There are two ways to use ccache. You can either prefix your compile +commands with "ccache" or you can create a symbolic link between +ccache and the names of your compilers. The first method is most +convenient if you just want to try out ccache or wish to use it for +some specific projects. The second method is most useful for when you +wish to use ccache for all your compiles. +

    To install for usage by the first method just copy ccache to somewhere +in your path. +

    To install for the second method do something like this: +

    +
    +  cp ccache /usr/local/bin/
    +  ln -s /usr/local/bin/ccache /usr/local/bin/gcc
    +  ln -s /usr/local/bin/ccache /usr/local/bin/g++
    +  ln -s /usr/local/bin/ccache /usr/local/bin/cc
    +
    +
    + +This will work as long as /usr/local/bin comes before the path to gcc +(which is usually in /usr/bin). After installing you may wish to run +"which gcc" to make sure that the correct link is being used. +

    Note! Do not use a hard link, use a symbolic link. A hardlink will +cause "interesting" problems. +

    EXTRA OPTIONS

    + +

    When run as a compiler front end ccache usually just takes the same +command line options as the compiler you are using. The only exception +to this is the option '--ccache-skip'. That option can be used to tell +ccache that the next option is definitely not a input filename, and +should be passed along to the compiler as-is. +

    The reason this can be important is that ccache does need to parse the +command line and determine what is an input filename and what is a +compiler option, as it needs the input filename to determine the name +of the resulting object file (among other things). The heuristic +ccache uses in this parse is that any string on the command line that +exists as a file is treated as an input file name (usually a C +file). By using --ccache-skip you can force an option to not be +treated as an input file name and instead be passed along to the +compiler as a command line option. +

    ENVIRONMENT VARIABLES

    + +

    ccache uses a number of environment variables to control operation. In +most cases you won't need any of these as the defaults will be fine. +

    +

    CCACHE_DIR
    the CCACHE_DIR environment variable specifies +where ccache will keep its cached compiler output. The default is +"$HOME/.ccache". +

    CCACHE_TEMPDIR
    the CCACHE_TEMPDIR environment variable specifies +where ccache will put temporary files. The default is the same as +CCACHE_DIR. Note that the CCACHE_TEMPDIR path must be on the same +filesystem as the CCACHE_DIR path, so that renames of files between +the two directories can work. +

    CCACHE_LOGFILE
    If you set the CCACHE_LOGFILE environment +variable then ccache will write some log information on cache hits +and misses in that file. This is useful for tracking down problems. +

    CCACHE_PATH
    You can optionally set CCACHE_PATH to a colon +separated path where ccache will look for the real compilers. If you +don't do this then ccache will look for the first executable matching +the compiler name in the normal PATH that isn't a symbolic link to +ccache itself. +

    CCACHE_CC
    You can optionally set CCACHE_CC to force the name +of the compiler to use. If you don't do this then ccache works it out +from the command line. +

    CCACHE_PREFIX
    This option adds a prefix to the command line +that ccache runs when invoking the compiler. Also see the section +below on using ccache with distcc. +

    CCACHE_DISABLE
    If you set the environment variable +CCACHE_DISABLE then ccache will just call the real compiler, +bypassing the cache completely. +

    CCACHE_READONLY
    the CCACHE_READONLY environment variable +tells ccache to attempt to use existing cached object files, but not +to try to add anything new to the cache. If you are using this because +your CCACHE_DIR is read-only, then you may find that you also need to +set CCACHE_TEMPDIR as otherwise ccache will fail to create the +temporary files. +

    CCACHE_CPP2
    If you set the environment variable CCACHE_CPP2 +then ccache will not use the optimisation of avoiding the 2nd call to +the pre-processor by compiling the pre-processed output that was used +for finding the hash in the case of a cache miss. This is primarily a +debugging option, although it is possible that some unusual compilers +will have problems with the intermediate filename extensions used in +this optimisation, in which case this option could allow ccache to be +used. +

    CCACHE_NOSTATS
    If you set the environment variable +CCACHE_NOSTATS then ccache will not update the statistics files on +each compile. +

    CCACHE_NLEVELS
    The environment variable CCACHE_NLEVELS allows +you to choose the number of levels of hash in the cache directory. The +default is 2. The minimum is 1 and the maximum is 8. +

    CCACHE_HARDLINK
    If you set the environment variable +CCACHE_HARDLINK then ccache will attempt to use hard links from the +cache directory when creating the compiler output rather than using a +file copy. Using hard links is faster, but can confuse programs like +'make' that rely on modification times. +

    CCACHE_RECACHE
    This forces ccache to not use any cached +results, even if it finds them. New results are still cached, but +existing cache entries are ignored. +

    CCACHE_UMASK
    This sets the umask for ccache and all child +processes (such as the compiler). This is mostly useful when you wish +to share your cache with other users. Note that this also affects the +file permissions set on the object files created from your +compilations. +

    CCACHE_HASHDIR
    This tells ccache to hash the current working +directory when calculating the hash that is used to distinguish two +compiles. This prevents a problem with the storage of the current +working directory in the debug info of a object file, which can lead +ccache to give a cached object file that has the working directory in +the debug info set incorrectly. This option is off by default as the +incorrect setting of this debug info rarely causes problems. If you +strike problems with gdb not using the correct directory then enable +this option. +

    CCACHE_UNIFY
    If you set the environment variable CCACHE_UNIFY +then ccache will use the C/C++ unifier when hashing the pre-processor +output if -g is not used in the compile. The unifier is slower than a +normal hash, so setting this environment variable loses a little bit +of speed, but it means that ccache can take advantage of not +recompiling when the changes to the source code consist of +reformatting only. Note that using CCACHE_UNIFY changes the hash, so +cached compiles with CCACHE_UNIFY set cannot be used when +CCACHE_UNIFY is not set and vice versa. The reason the unifier is off +by default is that it can give incorrect line number information in +compiler warning messages. +

    CCACHE_EXTENSION
    Normally ccache tries to automatically +determine the extension to use for intermediate C pre-processor files +based on the type of file being compiled. Unfortunately this sometimes +doesn't work, for example when using the aCC compiler on HP-UX. On +systems like this you can use the CCACHE_EXTENSION option to override +the default. On HP-UX set this environment variable to "i" if you use +the aCC compiler. +

    +

    CACHE SIZE MANAGEMENT

    + +

    By default ccache has a one gigabyte limit on the cache size and no +maximum number of files. You can set a different limit using the +"ccache -M" and "ccache -F" options, which set the size and number of +files limits. +

    When these limits are reached ccache will reduce the cache to 20% +below the numbers you specified in order to avoid doing the cache +clean operation too often. +

    HOW IT WORKS

    + +

    The basic idea is to detect when you are compiling exactly the same +code a 2nd time and use the previously compiled output. You detect +that it is the same code by forming a hash of: +

      +
    • the pre-processor output from running the compiler with -E +
    • the command line options +
    • the real compilers size and modification time +
    • any stderr output generated by the compiler +
    +

    These are hashed using md4 (a strong hash) and a cache file is formed +based on that hash result. When the same compilation is done a second +time ccache is able to supply the correct compiler output (including +all warnings etc) from the cache. +

    ccache has been carefully written to always produce exactly the same +compiler output that you would get without the cache. If you ever +discover a case where ccache changes the output of your compiler then +please let me know. +

    USING CCACHE WITH DISTCC

    + +

    distcc is a very useful program for distributing compilation across a +range of compiler servers. It is often useful to combine distcc with +ccache, so that compiles that are done are sped up by distcc, but that +ccache avoids the compile completely where possible. +

    To use distcc with ccache I recommend using the CCACHE_PREFIX +option. You just need to set the environment variable CCACHE_PREFIX to +'distcc' and ccache will prefix the command line used with the +compiler with the command 'distcc'. +

    SHARING A CACHE

    + +

    A group of developers can increase the cache hit rate by sharing a +cache directory. The hard links however cause unwanted side effects, +as all links to a cached file share the file's modification timestamp. +This results in false dependencies to be triggered by timestamp-based +build systems whenever another user links to an existing +file. Typically, users will see that their libraries and binaries are +relinked without reason. To share a cache without side effects, the +following conditions need to be met: +

      +
    • Use the same CCACHE_DIR environment variable setting +
    • Set the CCACHE_NOLINK environment variable +
    • Make sure everyone sets the CCACHE_UMASK environment variable + to 002, this ensures that cached files are accessible to everyone in + the group. +
    • Make sure that all users have write permission in the entire + cache directory (and that you trust all users of the shared cache). +
    • Make sure that the setgid bit is set on all directories in the + cache. This tells the filesystem to inherit group ownership for new + directories. The command "chmod g+s `find $CCACHE_DIR -type d`" might + be useful for this. +
    +

    HISTORY

    + +

    ccache was inspired by the compilercache shell script script written +by Erik Thiele and I would like to thank him for an excellent piece of +work. See +http://www.erikyyy.de/compilercache/ +for the Erik's scripts. +

    I wrote ccache because I wanted to get a bit more speed out of a +compiler cache and I wanted to remove some of the limitations of the +shell-script version. +

    DIFFERENCES FROM COMPILERCACHE

    + +

    The biggest differences between Erik's compilercache script and ccache +are: +

      +
    • ccache is written in C, which makes it a bit faster (calling out to + external programs is mostly what slowed down the scripts). +
    • ccache can automatically find the real compiler +
    • ccache keeps statistics on hits/misses +
    • ccache can do automatic cache management +
    • ccache can cache compiler output that includes warnings. In many + cases this gives ccache a much higher cache hit rate. +
    • ccache can handle a much wider ranger of compiler options +
    • ccache avoids a double call to cpp on a cache miss +
    +

    BUGS

    + +

    When the cache is stored on an NFS filesystem, the filesystem must be +exported with the no_subtree_check option to make renames between +directories reliable. +

    CREDITS

    + +

    Thanks to the following people for their contributions to ccache +

      +
    • Erik Thiele for the original compilercache script +
    • Luciano Rocha for the idea of compiling the pre-processor output + to avoid a 2nd cpp pass +
    • Paul Russell for many suggestions and the debian packaging +
    +

    AUTHOR

    + +

    ccache was written by Andrew Tridgell +http://samba.org/~tridge/ +

    If you wish to report a problem or make a suggestion then please email +bugs@ccache.samba.org +

    ccache is released under the GNU General Public License version 2 or +later. Please see the file COPYING for license details. + + diff --git a/CCache/web/index.html b/CCache/web/index.html new file mode 100644 index 000000000..cc0289b98 --- /dev/null +++ b/CCache/web/index.html @@ -0,0 +1,158 @@ + + + +ccache + + +

    ccache

    + +ccache is a compiler cache. It acts as a caching pre-processor to +C/C++ compilers, using the -E compiler switch and a hash to detect +when a compilation can be satisfied from cache. This often results in +a 5 to 10 times speedup in common compilations.

    + +The idea came from Erik Thiele wrote the original compilercache program +as a bourne shell script. ccache is a re-implementation of Erik's idea +in C with more features and better performance.

    + +

    Latest release

    + +The latest release is ccache 2.4. + +
      +
    • Added CCACHE_READONLY option +
    • Added CCACHE_TEMPDIR option +
    • fixed handling of hard-linked compilers on AIX +
    • added O_BINARY support, to try and support win32 compiles +
    • show cache directory in stats output +
    • fixed handling of HOME environment variable +
    + +See the manual page for details +on the new options.

    + +You can get this release from the download directory + +

    NOTE! This release changes the hash input slighly, so you will +probably find that you will not get any hits against your existing +cache when you upgrade. + +

    Why bother?

    + +Why bother with a compiler cache? If you ever run "make clean; make" +then you can probably benefit from ccache. It is very common for +developers to do a clean build of a project for a whole host of +reasons, and this throws away all the information from your previous +compiles.

    + +By using ccache you can get exactly the same effect as "make clean; +make" but much faster. It also helps a lot when doing RPM builds, +as RPM can make doing incremental builds tricky.

    + +I put the effort into writing ccache for 2 reasons. The first is the +Samba build farm +(http://build.samba.org/) +which constantly does clean builds of Samba on about 30 machines after each +CVS commit. On some of those machines the build took over an hour. By +using ccache we get the same effect as clean builds but about 6 times +faster.

    + +The second reason is the autobuild system I used to run for +Quantum. That system builds our whole Linux based OS from scratch +after every CVS commit to catch compilation problems quickly. Using +ccache those builds are much faster. + +

    Is it safe?

    + +Yes. The most important aspect of a compiler cache is to always +produce exactly the same output that the real compiler would +produce. The includes providing exactly the same object files and +exactly the same compiler warnings that would be produced if you use +the real compiler. The only way you should be able to tell that you +are using ccache is the speed.

    + +I have coded ccache very carefully to try to provide these guarantees. + +

    Features

    + +
      +
    • keeps statistics on hits/misses +
    • automatic cache size management +
    • can cache compiles that generate warnings +
    • easy installation +
    • very low overhead +
    • uses hard links where possible to avoid copies +
    + +

    Documentation

    + +See the manual page + + +

    Performance

    + +Here are some results for compiling Samba on my Linux laptop. I have +also included the results of using Erik's compilercache program +(version 1.0.10) for comparison.

    + + + + + + +
        ccache  compilercache
    normal 13m 4s 13m 4s
    uncached 13m 15s 15m 41s
    cached 2m 45s 4m 26s
    + +

    How to use it

    + +You can use ccache in two ways. The first is just to prefix your +compile commands with "ccache". For example, you could change the +"CC=gcc" line in your Makefile to be "CC=ccache gcc".

    + +Alternatively, you can create symbolic links from your compilers name +to ccache. This allows you to use ccache without any changes to your +build system. + +

    Download

    + +You can download the latest release from the download directory.

    + +For the bleeding edge, you can fetch ccache via CVS or +rsync. To fetch via cvs use the following command: + +

    +  cvs -d :pserver:cvs@pserver.samba.org:/cvsroot co ccache
    +
    + +To fetch via rsync use this command: + +
    +  rsync -Pavz samba.org::ftp/unpacked/ccache .
    +
    + +

    Related projects

    + +Here are some related programs you may find interesting + +
      +
    • distcc - a distributed compilation system +
    • cachecc1 - a gcc specific cache +
    • gocache - a cross platform compiler cache +
    +

    + +

    Mailing list

    + +

    A mailing +list is available for discussion of ccache. + + +


    + +Andrew Tridgell
    +bugs@ccache.samba.org +
    + + + From db41b96503c39b9809e6a0a3a67f82eb55b5dc67 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 3 Nov 2008 13:40:57 +0000 Subject: [PATCH 0146/1680] cvs -> svn ignores git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10901 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CCache/.cvsignore | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 CCache/.cvsignore diff --git a/CCache/.cvsignore b/CCache/.cvsignore deleted file mode 100644 index 2758f56bc..000000000 --- a/CCache/.cvsignore +++ /dev/null @@ -1,8 +0,0 @@ -Makefile -ccache -*gz -config.h -config.log -config.status -tca.log -tca.map From 5e2812ed093e42b74172500fab23b72ad3dc4171 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 3 Nov 2008 13:49:49 +0000 Subject: [PATCH 0147/1680] Import patches to ccache-2.4 from debian (ccache-2.4-15) git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10902 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CCache/debian/NEWS | 22 + CCache/debian/README.Debian | 59 + CCache/debian/changelog | 221 ++++ CCache/debian/compat | 1 + CCache/debian/control | 20 + CCache/debian/copyright | 29 + CCache/debian/dirs | 3 + CCache/debian/docs | 1 + CCache/debian/examples | 2 + CCache/debian/patches/01_no_home.diff | 100 ++ .../debian/patches/02_ccache-compressed.diff | 1026 +++++++++++++++++ CCache/debian/patches/03_long_options.diff | 133 +++ CCache/debian/patches/04_ignore_profile.diff | 13 + CCache/debian/patches/05_nfs_fix.diff | 45 + CCache/debian/patches/06_md.diff | 77 ++ CCache/debian/patches/07_cachedirtag.diff | 75 ++ CCache/debian/patches/08_manpage_hyphens.diff | 89 ++ CCache/debian/patches/09_respect_ldflags.diff | 11 + CCache/debian/patches/10_lru_cleanup.diff | 23 + CCache/debian/patches/11_utimes.diff | 85 ++ .../patches/12_cachesize_permissions.diff | 83 ++ CCache/debian/patches/CREDITS | 47 + CCache/debian/rules | 141 +++ CCache/debian/update-ccache | 43 + CCache/debian/watch | 2 + 25 files changed, 2351 insertions(+) create mode 100644 CCache/debian/NEWS create mode 100644 CCache/debian/README.Debian create mode 100644 CCache/debian/changelog create mode 100644 CCache/debian/compat create mode 100644 CCache/debian/control create mode 100644 CCache/debian/copyright create mode 100644 CCache/debian/dirs create mode 100644 CCache/debian/docs create mode 100644 CCache/debian/examples create mode 100644 CCache/debian/patches/01_no_home.diff create mode 100644 CCache/debian/patches/02_ccache-compressed.diff create mode 100644 CCache/debian/patches/03_long_options.diff create mode 100644 CCache/debian/patches/04_ignore_profile.diff create mode 100644 CCache/debian/patches/05_nfs_fix.diff create mode 100644 CCache/debian/patches/06_md.diff create mode 100644 CCache/debian/patches/07_cachedirtag.diff create mode 100644 CCache/debian/patches/08_manpage_hyphens.diff create mode 100644 CCache/debian/patches/09_respect_ldflags.diff create mode 100644 CCache/debian/patches/10_lru_cleanup.diff create mode 100644 CCache/debian/patches/11_utimes.diff create mode 100644 CCache/debian/patches/12_cachesize_permissions.diff create mode 100644 CCache/debian/patches/CREDITS create mode 100644 CCache/debian/rules create mode 100644 CCache/debian/update-ccache create mode 100644 CCache/debian/watch diff --git a/CCache/debian/NEWS b/CCache/debian/NEWS new file mode 100644 index 000000000..be245dc7d --- /dev/null +++ b/CCache/debian/NEWS @@ -0,0 +1,22 @@ +ccache (2.4-8) unstable; urgency=high + + zlib compression is now enabled by default in order to increase the amount + of object files that can fit in the cache. + + The impact on performance is supposed to be almost negligible + (see http://www.gustaebel.de/lars/ccache/). If you do want to disable + it however, simply export the CCACHE_NOCOMPRESS environment variable. + + Note that a zlib-enabled ccache will still read your existing + uncompressed cache. If you want to compress/uncompress your cache, + see the manage-cache.sh script under /usr/share/doc/ccache/examples/. + + -- Francois Marier Sun, 20 May 2007 19:45:07 +1200 + +ccache (2.4-1) unstable; urgency=low + + * This release changes the hash input slighly, so you will probably find + that you will not get any hits against your existing cache when you + upgrade. + + -- Francois Marier Sat, 11 Jun 2005 13:54:33 -0400 diff --git a/CCache/debian/README.Debian b/CCache/debian/README.Debian new file mode 100644 index 000000000..5478bb720 --- /dev/null +++ b/CCache/debian/README.Debian @@ -0,0 +1,59 @@ +Installing ccache +----------------- + +The recommended way to use this with Debian is to either create "cc" +and "gcc" symlinks to /usr/bin/ccache in your private bin directory +(which must be before the real cc and gcc in your path), or use +CC="ccache gcc" on the make command line. + +Another option is to just prepend /usr/lib/ccache in your PATH +environment variable, like + + export PATH="/usr/lib/ccache:$PATH" + +Note that ccache works with both native and cross compilers. + +Ignoring whitespace +------------------- + +If you wish to set up ccache so that it ignores blank lines, have a +look at the CCACHE_UNIFY option. However, please note that this +option is off by default since the reported line numbers may not +match the source files anymore. + + +NFS Issues +---------- + +(from John Coiner on the ccache mailing list) + +When CCache creates a hardlinked output file, it calls utime() to update +the timestamp on the object, so that Make realizes that the object has +changed. + +On NFS, utime() has no coherency guarantee, AFAIK. When utime() runs on +host A, and our parallel implementation of Make is running on host B, +sometimes Make doesn't see the new timestamp soon enough -- and neglects +to relink the final binary. That's a one-way ticket to Silent Mysterious +Failure Town. + +Instead of relying on the object file timestamp, we create a dummy file +with a reliable timestamp: + +objs/foo.o objs/foo.o.built : + if ( ccache gcc -o foo.o -c foo.c ) ; \ + then touch objs/foo.o.built ; \ + else exit 1; \ + fi + +binary : objs/foo.o.built + gcc -o binary objs/foo.o + +NFS does make a coherency guarantee, that if a file is written and +close()d on host A, and subsequently open()ed on host B, that the second +open() will reflect all modifications and attributes from the close(). +Since Make does open() when checking timestamps, and the dummy file is +close()d when it's created, the binary will always relink after the +object is recompiled. + + -- Francois Marier Sun, 20 May 2007 17:35:36 +1200 diff --git a/CCache/debian/changelog b/CCache/debian/changelog new file mode 100644 index 000000000..45500d4bd --- /dev/null +++ b/CCache/debian/changelog @@ -0,0 +1,221 @@ +ccache (2.4-15) unstable; urgency=low + + * Add a new patch which improve the consistency of timestamps on cached + objects to make sure clean-up is based on least recently used objects. + * Patch the set_limit call so that non-writable cache directories return + an error when attempting to size the max(files|size) (closes: #332527) + + -- Francois Marier Sun, 13 Apr 2008 15:07:05 +1200 + +ccache (2.4-14) unstable; urgency=low + + * Mention the long options everywhere in the manpage + * Merge Gentoo patches: + - respect user's LDFLAGS + - use utimes() for timestamp if possible + + -- Francois Marier Sun, 23 Mar 2008 16:30:11 +1300 + +ccache (2.4-13) unstable; urgency=low + + * Update CACHEDIR.TAG patch to avoid creating the tag file when the + CCACHE_READONLY environment variable is set. (closes: #464356) + * Mention the GNU-style long options in the manpage + + -- Francois Marier Thu, 07 Feb 2008 10:50:42 +1300 + +ccache (2.4-12) unstable; urgency=low + + * Add symlink for gcc 4.3 (closes: #463590) + * Add support for the CACHEDIR.TAG spec, thanks to Karl Chen. + (see http://www.brynosaurus.com/cachedir/) + * Fix hyphens in manpage (lintian notice) + * Bump Standards-Version up to 3.7.3 (no changes) + * Bump debhelper compatibility to 6 + + -- Francois Marier Sat, 02 Feb 2008 10:37:22 +1300 + +ccache (2.4-11) unstable; urgency=low + + * Add the collab-maint repo to debian/control + + -- Francois Marier Tue, 20 Nov 2007 15:26:37 +1300 + +ccache (2.4-10) unstable; urgency=low + + * Document where the patches are from in debian/patches/CREDITS + * debian/rules: + - Fixed "make distclean" lintian warning + - Removed commented-out entries + * Set debhelper compatibility to 5 + * Add homepage field in debian/control + * Add symlinks for MinGW (closes: #445782) + * Bump the version to 5 in the debhelper dependency + + -- Francois Marier Fri, 19 Oct 2007 16:04:37 +1300 + +ccache (2.4-9) unstable; urgency=low + + * Add a symlink for gcc 4.2 (closes: #431007) + * Fix dependencies when using -o (closes: #217713) + + -- Francois Marier Sat, 30 Jun 2007 17:58:44 +1200 + +ccache (2.4-8) unstable; urgency=low + + * Enable zlib compression of the cache by default (closes: #409848). + Thanks to Sami Liedes for suggesting this. + * Disable ccache when profiling (closes: #215849). + Thanks to Ted Percival for the Patch. + * Fix NFS renaming issues and add instructions to the README. + Thanks to John Coiner and instructions. + * Put all patches in debian/patches and apply them at build time. + + -- Francois Marier Sun, 20 May 2007 19:42:34 +1200 + +ccache (2.4-7) unstable; urgency=low + + * Use the real compiler when HOME is not set (closes: #396350) + * Include user script under doc/examples (closes: #392435) + Thanks to Behan Webster! + * Add support for GNU --long options (closes: #297126) + + -- Francois Marier Sat, 18 Nov 2006 00:50:59 -0500 + +ccache (2.4-6) unstable; urgency=low + + * Include symlinks for gcc 4.1 (closes: #372838) + * Update watch file + + -- Francois Marier Tue, 13 Jun 2006 22:17:37 -0400 + +ccache (2.4-5) unstable; urgency=low + + * Document the fact that cross-compiling is supported (closes: #349221) + * Bump Standards-Version up to 3.7.2 (no changes) + + -- Francois Marier Sun, 4 Jun 2006 01:20:07 -0400 + +ccache (2.4-4) unstable; urgency=low + + * Mention another way to use ccache in README.Debian (thanks to Benjamin + Drieu for the suggestion) (closes: #267632) + * Update FSF address + * Fix watch file + + -- Francois Marier Sat, 26 Nov 2005 00:15:13 -0500 + +ccache (2.4-3) unstable; urgency=low + + * Actually use the configuration flags in debian/rules + * Bump Standards-Version up to 3.6.2 (no changes) + + -- Francois Marier Sun, 26 Jun 2005 13:33:19 -0400 + +ccache (2.4-2) unstable; urgency=low + + * Add gcc and g++ symlinks to /usr/lib/ccache (closes: #313490) + * Remove invalid entry from Depends + + -- Francois Marier Wed, 15 Jun 2005 20:51:03 -0400 + +ccache (2.4-1) unstable; urgency=low + + * New maintainer (closes: #312867) + * New upstream version: (closes: #273753, #239640) + - New CCACHE_READONLY and CCACHE_TEMPDIR options + - Fixed handling of hard-linked compilers on AIX + - Fixed handling of HOME environment variable (closes: #299880) + - Show cache directory in stats output + * Fix copyright file + * Add 'distcc' to Suggests (closes: #269158) + * Add a note about whitespace in README.Debian (closes: #229116) + * Update rules to add symmlinks for gcc 3.4 & 4.0 (closes: #261177) + * Acknowledge NMUs (closes: #200185, #177129, #174417) + + -- Francois Marier Sun, 12 Jun 2005 12:05:34 -0400 + +ccache (2.3-1.1) unstable; urgency=low + + * Non-maintainer upload during BSP + * Re-apply patch for + #200185 ccache: Incorrect symlinks in /usr/lib/ccache + (Closes: #200185) + + -- Frank Lichtenheld Fri, 19 Mar 2004 11:14:50 +0100 + +ccache (2.3-1) unstable; urgency=low + + * New upstream release: obsoletes existing caches. + * Tweak package description in arbitrary way (closes: #181721) + + -- Paul Russell Mon, 29 Sep 2003 02:53:20 +0200 + +ccache (2.2-2) unstable; urgency=low + + * Insert more symlinks in ccache dir (closes: #197468) + + -- Paul Russell Mon, 16 Jun 2003 10:52:50 +0100 + +ccache (2.2-1) unstable; urgency=low + + * New upstream release (closes: #150755) + * Insert more symlinks in ccache dir (closes: #144462) + + -- Paul Russell Mon, 17 Feb 2003 07:19:36 +0100 + +ccache (2.1.1-2) unstable; urgency=low + + * Restored /usr/lib/ccache symlinks (closes: #179393) + * Fixed manpage typo (closes: #179564) + * With thanks to Andreas Rottmann. + + -- Paul Russell Wed, 5 Feb 2003 10:01:10 +0100 + +ccache (2.1.1-1) unstable; urgency=low + + * NMU (with maintainer consent). + * New upstream release (closes: #174417, #177129). + * debian/control: + + Build-Depend on and use dephelper 4 (DH_COMPAT = 4). + + Bumped Standards-Version to 3.5.8. + + No full stop on short package description (fixes linda warning). + * debian/copright: + + Make lintian feel comfortable; fixes warnings: + - copyright-should-refer-to-common-license-file-for-gpl + - copyright-lists-upstream-authors-with-dh_make-boilerplate + * Built with g++ 3.2 :-). + + -- Andreas Rottmann Thu, 16 Jan 2003 11:42:38 +0100 + +ccache (1.9-1) unstable; urgency=low + + * New upstream release (closes: #144920) + + -- Paul Russell Mon, 13 May 2002 10:01:09 +0200 + +ccache (1.8-1) unstable; urgency=low + + * New upstream release (closes: #145401) + + -- Paul Russell Fri, 3 May 2002 02:26:32 +0200 + +ccache (1.7-1) unstable; urgency=low + + * New upstream release + * Install symlinks in /usr/lib/ccache (closes: #141337) + + -- Paul Russell Wed, 10 Apr 2002 17:51:21 +0200 + +ccache (1.4-1) unstable; urgency=low + + * New upstream release + + -- Paul Russell Wed, 3 Apr 2002 03:41:46 +0200 + +ccache (1.2-1) unstable; urgency=low + + * Initial Release. + + -- Paul Russell Sun, 31 Mar 2002 14:08:57 +0200 + diff --git a/CCache/debian/compat b/CCache/debian/compat new file mode 100644 index 000000000..1e8b31496 --- /dev/null +++ b/CCache/debian/compat @@ -0,0 +1 @@ +6 diff --git a/CCache/debian/control b/CCache/debian/control new file mode 100644 index 000000000..0b7e57282 --- /dev/null +++ b/CCache/debian/control @@ -0,0 +1,20 @@ +Source: ccache +Section: devel +Priority: optional +Maintainer: Francois Marier +Build-Depends: debhelper (>> 6), autotools-dev, zlib1g-dev +Standards-Version: 3.7.3 +Homepage: http://ccache.samba.org +Vcs-Svn: svn://svn.debian.org/svn/collab-maint/deb-maint/ccache/ +Vcs-Browser: http://svn.debian.org/wsvn/collab-maint/deb-maint/ccache/ + +Package: ccache +Architecture: any +Depends: ${shlibs:Depends} +Suggests: distcc +Description: Compiler results cacher, for fast recompiles + ccache is a compiler cache. It speeds up re-compilation of C/C++ code + by caching previous compiles and detecting when the same compile is + being done again. + . + This is similar to, but faster than, the compilercache package. diff --git a/CCache/debian/copyright b/CCache/debian/copyright new file mode 100644 index 000000000..7ac791dc5 --- /dev/null +++ b/CCache/debian/copyright @@ -0,0 +1,29 @@ +This package was debianized by Paul Russell on +Sun, 31 Mar 2002 14:08:57 +0200. + +It was downloaded from http://ccache.samba.org/ftp/ccache/ + +The ccache-zlib patch was downloaded from http://www.gustaebel.de/lars/ccache/ + +Upstream Author: Andrew Tridgell + +Copyright: 2002-2005 Andrew Tridgell + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA + +You are free to distribute this software under the terms of the GNU General +Public License. On Debian systems, the complete text of the GNU General +Public License can be found in /usr/share/common-licenses/GPL file. diff --git a/CCache/debian/dirs b/CCache/debian/dirs new file mode 100644 index 000000000..8ceb4c4e8 --- /dev/null +++ b/CCache/debian/dirs @@ -0,0 +1,3 @@ +usr/bin +usr/lib/ccache +usr/share/man/man1 diff --git a/CCache/debian/docs b/CCache/debian/docs new file mode 100644 index 000000000..e845566c0 --- /dev/null +++ b/CCache/debian/docs @@ -0,0 +1 @@ +README diff --git a/CCache/debian/examples b/CCache/debian/examples new file mode 100644 index 000000000..fc549228c --- /dev/null +++ b/CCache/debian/examples @@ -0,0 +1,2 @@ +debian/update-ccache +manage-cache.sh diff --git a/CCache/debian/patches/01_no_home.diff b/CCache/debian/patches/01_no_home.diff new file mode 100644 index 000000000..019634c0c --- /dev/null +++ b/CCache/debian/patches/01_no_home.diff @@ -0,0 +1,100 @@ +--- ccache.c ++++ ccache.c +@@ -836,6 +836,13 @@ + { + /* find the real compiler */ + find_compiler(argc, argv); ++ ++ /* use the real compiler if HOME is not set */ ++ if (!cache_dir) { ++ cc_log("Unable to determine home directory\n"); ++ cc_log("ccache is disabled\n"); ++ failed(); ++ } + + /* we might be disabled */ + if (getenv("CCACHE_DISABLE")) { +@@ -895,6 +902,13 @@ + printf("-V print version number\n"); + } + ++static void check_cache_dir(void) ++{ ++ if (!cache_dir) { ++ fatal("Unable to determine home directory"); ++ } ++} ++ + /* the main program when not doing a compile */ + static int ccache_main(int argc, char *argv[]) + { +@@ -914,31 +928,37 @@ + exit(0); + + case 's': ++ check_cache_dir(); + stats_summary(); + break; + + case 'c': ++ check_cache_dir(); + cleanup_all(cache_dir); + printf("Cleaned cache\n"); + break; + + case 'C': ++ check_cache_dir(); + wipe_all(cache_dir); + printf("Cleared cache\n"); + break; + + case 'z': ++ check_cache_dir(); + stats_zero(); + printf("Statistics cleared\n"); + break; + + case 'F': ++ check_cache_dir(); + v = atoi(optarg); + stats_set_limits(v, -1); + printf("Set cache file limit to %u\n", (unsigned)v); + break; + + case 'M': ++ check_cache_dir(); + v = value_units(optarg); + stats_set_limits(-1, v); + printf("Set cache size limit to %uk\n", (unsigned)v); +@@ -983,7 +1003,10 @@ + + cache_dir = getenv("CCACHE_DIR"); + if (!cache_dir) { +- x_asprintf(&cache_dir, "%s/.ccache", get_home_directory()); ++ const char *home_directory = get_home_directory(); ++ if (home_directory) { ++ x_asprintf(&cache_dir, "%s/.ccache", home_directory); ++ } + } + + temp_dir = getenv("CCACHE_TEMPDIR"); +@@ -1023,7 +1046,7 @@ + } + + /* make sure the cache dir exists */ +- if (create_dir(cache_dir) != 0) { ++ if (cache_dir && (create_dir(cache_dir) != 0)) { + fprintf(stderr,"ccache: failed to create %s (%s)\n", + cache_dir, strerror(errno)); + exit(1); +--- util.c ++++ util.c +@@ -448,7 +448,7 @@ + } + } + #endif +- fatal("Unable to determine home directory"); ++ cc_log("Unable to determine home directory"); + return NULL; + } + diff --git a/CCache/debian/patches/02_ccache-compressed.diff b/CCache/debian/patches/02_ccache-compressed.diff new file mode 100644 index 000000000..5740c2ca4 --- /dev/null +++ b/CCache/debian/patches/02_ccache-compressed.diff @@ -0,0 +1,1026 @@ +Index: ccache.1 +=================================================================== +RCS file: /home/cvsroot/lars/ccache/ccache.1,v +retrieving revision 1.1.1.1.2.1 +retrieving revision 1.6 +diff -u -r1.1.1.1.2.1 -r1.6 +--- ccache.1 21 Nov 2004 17:55:36 -0000 1.1.1.1.2.1 ++++ ccache.1 21 Nov 2004 18:19:28 -0000 1.6 +@@ -210,7 +210,8 @@ + CCACHE_HARDLINK then ccache will attempt to use hard links from the + cache directory when creating the compiler output rather than using a + file copy\&. Using hard links is faster, but can confuse programs like +-\&'make\&' that rely on modification times\&. ++\&'make\&' that rely on modification times\&. Hard links are never made for ++compressed cache files\&. + .IP + .IP "\fBCCACHE_RECACHE\fP" + This forces ccache to not use any cached +@@ -257,6 +258,11 @@ + the default\&. On HP-UX set this environment variable to "i" if you use + the aCC compiler\&. + .IP ++.IP "\fBCCACHE_NOCOMPRESS\fP" ++If you set the environment variable ++CCACHE_NOCOMPRESS then there is no compression used on files that go ++into the cache\&. ++.IP + .PP + .SH "CACHE SIZE MANAGEMENT" + .PP +@@ -269,6 +275,14 @@ + below the numbers you specified in order to avoid doing the cache + clean operation too often\&. + .PP ++.SH "CACHE COMPRESSION" ++.PP ++By default ccache will compress all files it puts into the cache ++using the zlib compression\&. While this involves a negligible ++performance slowdown, it significantly increases the number of files ++that fit in the cache\&. You can turn off compression setting the ++CCACHE_NOCOMPRESS environment variable\&. ++.PP + .SH "HOW IT WORKS" + .PP + The basic idea is to detect when you are compiling exactly the same +Index: ccache.c +=================================================================== +RCS file: /home/cvsroot/lars/ccache/ccache.c,v +retrieving revision 1.1.1.1.2.1 +retrieving revision 1.9 +diff -u -r1.1.1.1.2.1 -r1.9 +--- ccache.c 21 Nov 2004 17:55:36 -0000 1.1.1.1.2.1 ++++ ccache.c 21 Nov 2004 18:19:28 -0000 1.9 +@@ -199,7 +199,7 @@ + fd = open(tmp_stderr, O_RDONLY | O_BINARY); + if (fd != -1) { + if (strcmp(output_file, "/dev/null") == 0 || +- rename(tmp_hashname, output_file) == 0 || errno == ENOENT) { ++ move_file(tmp_hashname, output_file) == 0 || errno == ENOENT) { + if (cpp_stderr) { + /* we might have some stderr from cpp */ + int fd2 = open(cpp_stderr, O_RDONLY | O_BINARY); +@@ -231,14 +231,25 @@ + x_asprintf(&path_stderr, "%s.stderr", hashname); + + if (stat(tmp_stderr, &st1) != 0 || +- stat(tmp_hashname, &st2) != 0 || +- rename(tmp_hashname, hashname) != 0 || +- rename(tmp_stderr, path_stderr) != 0) { ++ stat(tmp_hashname, &st2) != 0 || ++ move_file(tmp_hashname, hashname) != 0 || ++ move_file(tmp_stderr, path_stderr) != 0) { + cc_log("failed to rename tmp files - %s\n", strerror(errno)); + stats_update(STATS_ERROR); + failed(); + } + ++#if ENABLE_ZLIB ++ /* do an extra stat on the cache files for ++ the size statistics */ ++ if (stat(path_stderr, &st1) != 0 || ++ stat(hashname, &st2) != 0) { ++ cc_log("failed to stat cache files - %s\n", strerror(errno)); ++ stats_update(STATS_ERROR); ++ failed(); ++ } ++#endif ++ + cc_log("Placed %s into cache\n", output_file); + stats_tocache(file_size(&st1) + file_size(&st2)); + +@@ -474,7 +485,13 @@ + } + + /* the user might be disabling cache hits */ ++#ifndef ENABLE_ZLIB ++ /* if the cache file is compressed we must recache */ ++ if ((first && getenv("CCACHE_RECACHE")) || ++ test_if_compressed(hashname) == 1) { ++#else + if (first && getenv("CCACHE_RECACHE")) { ++#endif + close(fd_stderr); + unlink(stderr_file); + free(stderr_file); +@@ -487,7 +504,9 @@ + ret = 0; + } else { + unlink(output_file); +- if (getenv("CCACHE_HARDLINK")) { ++ /* only make a hardlink if the cache file is uncompressed */ ++ if (getenv("CCACHE_HARDLINK") && ++ test_if_compressed(hashname) == 0) { + ret = link(hashname, output_file); + } else { + ret = copy_file(hashname, output_file); +Index: ccache.h +=================================================================== +RCS file: /home/cvsroot/lars/ccache/ccache.h,v +retrieving revision 1.1.1.1.2.1 +retrieving revision 1.7 +diff -u -r1.1.1.1.2.1 -r1.7 +--- ccache.h 21 Nov 2004 17:55:36 -0000 1.1.1.1.2.1 ++++ ccache.h 21 Nov 2004 18:19:28 -0000 1.7 +@@ -23,6 +23,10 @@ + #include + #endif + ++#ifdef ENABLE_ZLIB ++#include ++#endif ++ + #define STATUS_NOTFOUND 3 + #define STATUS_FATAL 4 + #define STATUS_NOCACHE 5 +@@ -36,6 +40,13 @@ + #define DEFAULT_MAXSIZE (1000*1000) + #endif + ++/* file copy mode */ ++#ifdef ENABLE_ZLIB ++#define COPY_UNCOMPRESSED 0 ++#define COPY_FROM_CACHE 1 ++#define COPY_TO_CACHE 2 ++#endif ++ + enum stats { + STATS_NONE=0, + STATS_STDOUT, +@@ -79,6 +90,8 @@ + + void copy_fd(int fd_in, int fd_out); + int copy_file(const char *src, const char *dest); ++int move_file(const char *src, const char *dest); ++int test_if_compressed(const char *filename); + + int create_dir(const char *dir); + void x_asprintf(char **ptr, const char *format, ...); +Index: ccache.yo +=================================================================== +RCS file: /home/cvsroot/lars/ccache/ccache.yo,v +retrieving revision 1.1.1.1.2.1 +retrieving revision 1.5 +diff -u -r1.1.1.1.2.1 -r1.5 +--- ccache.yo 21 Nov 2004 17:55:36 -0000 1.1.1.1.2.1 ++++ ccache.yo 21 Nov 2004 18:19:28 -0000 1.5 +@@ -169,6 +169,11 @@ + this optimisation, in which case this option could allow ccache to be + used. + ++dit(bf(CCACHE_NOCOMPRESS)) If you set the environment variable ++CCACHE_NOCOMPRESS then there is no compression used on files that go ++into the cache. However, this setting has no effect on how files are ++retrieved from the cache, compressed results will still be usable. ++ + dit(bf(CCACHE_NOSTATS)) If you set the environment variable + CCACHE_NOSTATS then ccache will not update the statistics files on + each compile. +@@ -181,7 +186,8 @@ + CCACHE_HARDLINK then ccache will attempt to use hard links from the + cache directory when creating the compiler output rather than using a + file copy. Using hard links is faster, but can confuse programs like +-'make' that rely on modification times. ++'make' that rely on modification times. Hard links are never made for ++compressed cache files. + + dit(bf(CCACHE_RECACHE)) This forces ccache to not use any cached + results, even if it finds them. New results are still cached, but +@@ -236,6 +242,14 @@ + below the numbers you specified in order to avoid doing the cache + clean operation too often. + ++manpagesection(CACHE COMPRESSION) ++ ++By default ccache will compress all files it puts into the cache ++using the zlib compression. While this involves a negligible ++performance slowdown, it significantly increases the number of files ++that fit in the cache. You can turn off compression setting the ++CCACHE_NOCOMPRESS environment variable. ++ + manpagesection(HOW IT WORKS) + + The basic idea is to detect when you are compiling exactly the same +@@ -294,6 +308,8 @@ + cache. This tells the filesystem to inherit group ownership for new + directories. The command "chmod g+s `find $CCACHE_DIR -type d`" might + be useful for this. ++ it() Set bf(CCACHE_NOCOMPRESS) for all users, if there are users with ++ versions of ccache that do not support compression. + ) + + manpagesection(HISTORY) +Index: config.h.in +=================================================================== +RCS file: /home/cvsroot/lars/ccache/config.h.in,v +retrieving revision 1.1.1.1 +retrieving revision 1.2 +diff -u -r1.1.1.1 -r1.2 +--- config.h.in 30 Apr 2004 13:13:41 -0000 1.1.1.1 ++++ config.h.in 4 May 2004 20:49:26 -0000 1.2 +@@ -98,3 +98,6 @@ + + /* Define _GNU_SOURCE so that we get all necessary prototypes */ + #undef _GNU_SOURCE ++ ++/* Define to 1 if you like to have zlib compression for the ccache. */ ++#undef ENABLE_ZLIB +Index: configure +=================================================================== +RCS file: /home/cvsroot/lars/ccache/configure,v +retrieving revision 1.1.1.1.2.1 +diff -u -r1.1.1.1.2.1 configure +--- configure 21 Nov 2004 17:55:36 -0000 1.1.1.1.2.1 ++++ configure 21 Nov 2004 18:24:42 -0000 +@@ -836,6 +836,11 @@ + + cat <<\_ACEOF + ++Optional Features: ++ --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) ++ --enable-FEATURE[=ARG] include FEATURE [ARG=yes] ++ --enable-zlib enable zlib support for ccache compression ++ + Some influential environment variables: + CC C compiler command + CFLAGS C compiler flags +@@ -936,7 +941,7 @@ + else + echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 + fi +- cd "$ac_popdir" ++ cd $ac_popdir + done + fi + +@@ -1859,7 +1864,8 @@ + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && +- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' ++ { ac_try='test -z "$ac_c_werror_flag" ++ || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? +@@ -1917,7 +1923,8 @@ + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && +- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' ++ { ac_try='test -z "$ac_c_werror_flag" ++ || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? +@@ -2033,7 +2040,8 @@ + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && +- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' ++ { ac_try='test -z "$ac_c_werror_flag" ++ || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? +@@ -2087,7 +2095,8 @@ + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && +- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' ++ { ac_try='test -z "$ac_c_werror_flag" ++ || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? +@@ -2132,7 +2141,8 @@ + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && +- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' ++ { ac_try='test -z "$ac_c_werror_flag" ++ || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? +@@ -2176,7 +2186,8 @@ + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && +- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' ++ { ac_try='test -z "$ac_c_werror_flag" ++ || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? +@@ -2609,7 +2620,8 @@ + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && +- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' ++ { ac_try='test -z "$ac_c_werror_flag" ++ || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? +@@ -2681,7 +2693,8 @@ + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && +- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' ++ { ac_try='test -z "$ac_c_werror_flag" ++ || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? +@@ -2735,7 +2748,8 @@ + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && +- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' ++ { ac_try='test -z "$ac_c_werror_flag" ++ || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? +@@ -2806,7 +2820,8 @@ + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && +- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' ++ { ac_try='test -z "$ac_c_werror_flag" ++ || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? +@@ -2860,7 +2875,8 @@ + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && +- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' ++ { ac_try='test -z "$ac_c_werror_flag" ++ || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? +@@ -2927,7 +2943,8 @@ + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && +- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' ++ { ac_try='test -z "$ac_c_werror_flag" ++ || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? +@@ -2997,7 +3014,8 @@ + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && +- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' ++ { ac_try='test -z "$ac_c_werror_flag" ++ || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? +@@ -3078,7 +3096,8 @@ + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && +- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' ++ { ac_try='test -z "$ac_c_werror_flag" ++ || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? +@@ -3248,7 +3267,8 @@ + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && +- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' ++ { ac_try='test -z "$ac_c_werror_flag" ++ || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? +@@ -3319,7 +3339,8 @@ + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && +- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' ++ { ac_try='test -z "$ac_c_werror_flag" ++ || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? +@@ -3509,7 +3530,8 @@ + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && +- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' ++ { ac_try='test -z "$ac_c_werror_flag" ++ || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? +@@ -3611,7 +3633,8 @@ + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && +- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' ++ { ac_try='test -z "$ac_c_werror_flag" ++ || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? +@@ -3676,7 +3699,8 @@ + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && +- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' ++ { ac_try='test -z "$ac_c_werror_flag" ++ || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? +@@ -3775,6 +3799,229 @@ + + fi + ++# Check whether --enable-zlib or --disable-zlib was given. ++if test "${enable_zlib+set}" = set; then ++ enableval="$enable_zlib" ++ ++else ++ enable_zlib=yes ++fi; ++ ++if test x"$enable_zlib" = x"yes"; then ++ if test "${ac_cv_header_zlib_h+set}" = set; then ++ echo "$as_me:$LINENO: checking for zlib.h" >&5 ++echo $ECHO_N "checking for zlib.h... $ECHO_C" >&6 ++if test "${ac_cv_header_zlib_h+set}" = set; then ++ echo $ECHO_N "(cached) $ECHO_C" >&6 ++fi ++echo "$as_me:$LINENO: result: $ac_cv_header_zlib_h" >&5 ++echo "${ECHO_T}$ac_cv_header_zlib_h" >&6 ++else ++ # Is the header compilable? ++echo "$as_me:$LINENO: checking zlib.h usability" >&5 ++echo $ECHO_N "checking zlib.h usability... $ECHO_C" >&6 ++cat >conftest.$ac_ext <<_ACEOF ++/* confdefs.h. */ ++_ACEOF ++cat confdefs.h >>conftest.$ac_ext ++cat >>conftest.$ac_ext <<_ACEOF ++/* end confdefs.h. */ ++$ac_includes_default ++#include ++_ACEOF ++rm -f conftest.$ac_objext ++if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 ++ (eval $ac_compile) 2>conftest.er1 ++ ac_status=$? ++ grep -v '^ *+' conftest.er1 >conftest.err ++ rm -f conftest.er1 ++ cat conftest.err >&5 ++ echo "$as_me:$LINENO: \$? = $ac_status" >&5 ++ (exit $ac_status); } && ++ { ac_try='test -z "$ac_c_werror_flag" ++ || test ! -s conftest.err' ++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 ++ (eval $ac_try) 2>&5 ++ ac_status=$? ++ echo "$as_me:$LINENO: \$? = $ac_status" >&5 ++ (exit $ac_status); }; } && ++ { ac_try='test -s conftest.$ac_objext' ++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 ++ (eval $ac_try) 2>&5 ++ ac_status=$? ++ echo "$as_me:$LINENO: \$? = $ac_status" >&5 ++ (exit $ac_status); }; }; then ++ ac_header_compiler=yes ++else ++ echo "$as_me: failed program was:" >&5 ++sed 's/^/| /' conftest.$ac_ext >&5 ++ ++ac_header_compiler=no ++fi ++rm -f conftest.err conftest.$ac_objext conftest.$ac_ext ++echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 ++echo "${ECHO_T}$ac_header_compiler" >&6 ++ ++# Is the header present? ++echo "$as_me:$LINENO: checking zlib.h presence" >&5 ++echo $ECHO_N "checking zlib.h presence... $ECHO_C" >&6 ++cat >conftest.$ac_ext <<_ACEOF ++/* confdefs.h. */ ++_ACEOF ++cat confdefs.h >>conftest.$ac_ext ++cat >>conftest.$ac_ext <<_ACEOF ++/* end confdefs.h. */ ++#include ++_ACEOF ++if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 ++ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ++ ac_status=$? ++ grep -v '^ *+' conftest.er1 >conftest.err ++ rm -f conftest.er1 ++ cat conftest.err >&5 ++ echo "$as_me:$LINENO: \$? = $ac_status" >&5 ++ (exit $ac_status); } >/dev/null; then ++ if test -s conftest.err; then ++ ac_cpp_err=$ac_c_preproc_warn_flag ++ ac_cpp_err=$ac_cpp_err$ac_c_werror_flag ++ else ++ ac_cpp_err= ++ fi ++else ++ ac_cpp_err=yes ++fi ++if test -z "$ac_cpp_err"; then ++ ac_header_preproc=yes ++else ++ echo "$as_me: failed program was:" >&5 ++sed 's/^/| /' conftest.$ac_ext >&5 ++ ++ ac_header_preproc=no ++fi ++rm -f conftest.err conftest.$ac_ext ++echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 ++echo "${ECHO_T}$ac_header_preproc" >&6 ++ ++# So? What about this header? ++case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in ++ yes:no: ) ++ { echo "$as_me:$LINENO: WARNING: zlib.h: accepted by the compiler, rejected by the preprocessor!" >&5 ++echo "$as_me: WARNING: zlib.h: accepted by the compiler, rejected by the preprocessor!" >&2;} ++ { echo "$as_me:$LINENO: WARNING: zlib.h: proceeding with the compiler's result" >&5 ++echo "$as_me: WARNING: zlib.h: proceeding with the compiler's result" >&2;} ++ ac_header_preproc=yes ++ ;; ++ no:yes:* ) ++ { echo "$as_me:$LINENO: WARNING: zlib.h: present but cannot be compiled" >&5 ++echo "$as_me: WARNING: zlib.h: present but cannot be compiled" >&2;} ++ { echo "$as_me:$LINENO: WARNING: zlib.h: check for missing prerequisite headers?" >&5 ++echo "$as_me: WARNING: zlib.h: check for missing prerequisite headers?" >&2;} ++ { echo "$as_me:$LINENO: WARNING: zlib.h: see the Autoconf documentation" >&5 ++echo "$as_me: WARNING: zlib.h: see the Autoconf documentation" >&2;} ++ { echo "$as_me:$LINENO: WARNING: zlib.h: section \"Present But Cannot Be Compiled\"" >&5 ++echo "$as_me: WARNING: zlib.h: section \"Present But Cannot Be Compiled\"" >&2;} ++ { echo "$as_me:$LINENO: WARNING: zlib.h: proceeding with the preprocessor's result" >&5 ++echo "$as_me: WARNING: zlib.h: proceeding with the preprocessor's result" >&2;} ++ { echo "$as_me:$LINENO: WARNING: zlib.h: in the future, the compiler will take precedence" >&5 ++echo "$as_me: WARNING: zlib.h: in the future, the compiler will take precedence" >&2;} ++ ( ++ cat <<\_ASBOX ++## ------------------------------------------ ## ++## Report this to the AC_PACKAGE_NAME lists. ## ++## ------------------------------------------ ## ++_ASBOX ++ ) | ++ sed "s/^/$as_me: WARNING: /" >&2 ++ ;; ++esac ++echo "$as_me:$LINENO: checking for zlib.h" >&5 ++echo $ECHO_N "checking for zlib.h... $ECHO_C" >&6 ++if test "${ac_cv_header_zlib_h+set}" = set; then ++ echo $ECHO_N "(cached) $ECHO_C" >&6 ++else ++ ac_cv_header_zlib_h=$ac_header_preproc ++fi ++echo "$as_me:$LINENO: result: $ac_cv_header_zlib_h" >&5 ++echo "${ECHO_T}$ac_cv_header_zlib_h" >&6 ++ ++fi ++if test $ac_cv_header_zlib_h = yes; then ++ echo "$as_me:$LINENO: checking for gzdopen in -lz" >&5 ++echo $ECHO_N "checking for gzdopen in -lz... $ECHO_C" >&6 ++if test "${ac_cv_lib_z_gzdopen+set}" = set; then ++ echo $ECHO_N "(cached) $ECHO_C" >&6 ++else ++ ac_check_lib_save_LIBS=$LIBS ++LIBS="-lz $LIBS" ++cat >conftest.$ac_ext <<_ACEOF ++/* confdefs.h. */ ++_ACEOF ++cat confdefs.h >>conftest.$ac_ext ++cat >>conftest.$ac_ext <<_ACEOF ++/* end confdefs.h. */ ++ ++/* Override any gcc2 internal prototype to avoid an error. */ ++#ifdef __cplusplus ++extern "C" ++#endif ++/* We use char because int might match the return type of a gcc2 ++ builtin and then its argument prototype would still apply. */ ++char gzdopen (); ++int ++main () ++{ ++gzdopen (); ++ ; ++ return 0; ++} ++_ACEOF ++rm -f conftest.$ac_objext conftest$ac_exeext ++if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 ++ (eval $ac_link) 2>conftest.er1 ++ ac_status=$? ++ grep -v '^ *+' conftest.er1 >conftest.err ++ rm -f conftest.er1 ++ cat conftest.err >&5 ++ echo "$as_me:$LINENO: \$? = $ac_status" >&5 ++ (exit $ac_status); } && ++ { ac_try='test -z "$ac_c_werror_flag" ++ || test ! -s conftest.err' ++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 ++ (eval $ac_try) 2>&5 ++ ac_status=$? ++ echo "$as_me:$LINENO: \$? = $ac_status" >&5 ++ (exit $ac_status); }; } && ++ { ac_try='test -s conftest$ac_exeext' ++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 ++ (eval $ac_try) 2>&5 ++ ac_status=$? ++ echo "$as_me:$LINENO: \$? = $ac_status" >&5 ++ (exit $ac_status); }; }; then ++ ac_cv_lib_z_gzdopen=yes ++else ++ echo "$as_me: failed program was:" >&5 ++sed 's/^/| /' conftest.$ac_ext >&5 ++ ++ac_cv_lib_z_gzdopen=no ++fi ++rm -f conftest.err conftest.$ac_objext \ ++ conftest$ac_exeext conftest.$ac_ext ++LIBS=$ac_check_lib_save_LIBS ++fi ++echo "$as_me:$LINENO: result: $ac_cv_lib_z_gzdopen" >&5 ++echo "${ECHO_T}$ac_cv_lib_z_gzdopen" >&6 ++if test $ac_cv_lib_z_gzdopen = yes; then ++ LIBS="-lz $LIBS"; cat >>confdefs.h <<\_ACEOF ++#define ENABLE_ZLIB 1 ++_ACEOF ++ ++fi ++ ++fi ++ ++ ++fi ++ + ac_config_files="$ac_config_files Makefile" + + cat >confcache <<\_ACEOF +@@ -4568,6 +4815,11 @@ + *) ac_INSTALL=$ac_top_builddir$INSTALL ;; + esac + ++ if test x"$ac_file" != x-; then ++ { echo "$as_me:$LINENO: creating $ac_file" >&5 ++echo "$as_me: creating $ac_file" >&6;} ++ rm -f "$ac_file" ++ fi + # Let's still pretend it is `configure' which instantiates (i.e., don't + # use $as_me), people would be surprised to read: + # /* config.h. Generated by config.status. */ +@@ -4606,12 +4858,6 @@ + fi;; + esac + done` || { (exit 1); exit 1; } +- +- if test x"$ac_file" != x-; then +- { echo "$as_me:$LINENO: creating $ac_file" >&5 +-echo "$as_me: creating $ac_file" >&6;} +- rm -f "$ac_file" +- fi + _ACEOF + cat >>$CONFIG_STATUS <<_ACEOF + sed "$ac_vpsub +Index: configure.in +=================================================================== +RCS file: /home/cvsroot/lars/ccache/configure.in,v +retrieving revision 1.1.1.1.2.1 +retrieving revision 1.4 +diff -u -r1.1.1.1.2.1 -r1.4 +--- configure.in 21 Nov 2004 17:55:36 -0000 1.1.1.1.2.1 ++++ configure.in 21 Nov 2004 18:19:28 -0000 1.4 +@@ -68,5 +68,14 @@ + AC_DEFINE(HAVE_C99_VSNPRINTF, 1, [ ]) + fi + ++dnl Check for zlib. ++AC_ARG_ENABLE([zlib], ++ AS_HELP_STRING([--enable-zlib], [enable zlib support for ccache compression]),, ++ [enable_zlib=yes]) ++ ++if test x"$enable_zlib" = x"yes"; then ++ AC_CHECK_HEADER(zlib.h, AC_CHECK_LIB(z, gzdopen, LIBS="-lz $LIBS"; AC_DEFINE(ENABLE_ZLIB))) ++fi ++ + AC_CONFIG_FILES([Makefile]) + AC_OUTPUT +Index: util.c +=================================================================== +RCS file: /home/cvsroot/lars/ccache/util.c,v +retrieving revision 1.1.1.1.2.1 +retrieving revision 1.11 +diff -u -r1.1.1.1.2.1 -r1.11 +--- util.c 21 Nov 2004 17:55:36 -0000 1.1.1.1.2.1 ++++ util.c 21 Nov 2004 18:19:28 -0000 1.11 +@@ -44,6 +44,7 @@ + exit(1); + } + ++#ifndef ENABLE_ZLIB + /* copy all data from one file descriptor to another */ + void copy_fd(int fd_in, int fd_out) + { +@@ -57,6 +58,11 @@ + } + } + ++/* move a file using rename */ ++int move_file(const char *src, const char *dest) { ++ return rename(src, dest); ++} ++ + /* copy a file - used when hard links don't work + the copy is done via a temporary file and atomic rename + */ +@@ -120,6 +126,174 @@ + return 0; + } + ++#else /* ENABLE_ZLIB */ ++ ++/* copy all data from one file descriptor to another ++ possibly decompressing it ++*/ ++void copy_fd(int fd_in, int fd_out) { ++ char buf[10240]; ++ int n; ++ gzFile gz_in; ++ ++ gz_in = gzdopen(dup(fd_in), "rb"); ++ ++ if (!gz_in) { ++ fatal("Failed to copy fd"); ++ } ++ ++ while ((n = gzread(gz_in, buf, sizeof(buf))) > 0) { ++ if (write(fd_out, buf, n) != n) { ++ fatal("Failed to copy fd"); ++ } ++ } ++} ++ ++static int _copy_file(const char *src, const char *dest, int mode) { ++ int fd_in, fd_out; ++ gzFile gz_in, gz_out = NULL; ++ char buf[10240]; ++ int n, ret; ++ char *tmp_name; ++ mode_t mask; ++ struct stat st; ++ ++ x_asprintf(&tmp_name, "%s.XXXXXX", dest); ++ ++ if (getenv("CCACHE_NOCOMPRESS")) { ++ mode = COPY_UNCOMPRESSED; ++ } ++ ++ /* open source file */ ++ fd_in = open(src, O_RDONLY); ++ if (fd_in == -1) { ++ return -1; ++ } ++ ++ gz_in = gzdopen(fd_in, "rb"); ++ if (!gz_in) { ++ close(fd_in); ++ return -1; ++ } ++ ++ /* open destination file */ ++ fd_out = mkstemp(tmp_name); ++ if (fd_out == -1) { ++ gzclose(gz_in); ++ free(tmp_name); ++ return -1; ++ } ++ ++ if (mode == COPY_TO_CACHE) { ++ /* The gzip file format occupies at least 20 bytes. So ++ it will always occupy an entire filesystem block, ++ even for empty files. ++ Since most stderr files will be empty, we turn off ++ compression in this case to save space. ++ */ ++ if (fstat(fd_in, &st) != 0) { ++ gzclose(gz_in); ++ close(fd_out); ++ free(tmp_name); ++ return -1; ++ } ++ if (file_size(&st) == 0) { ++ mode = COPY_UNCOMPRESSED; ++ } ++ } ++ ++ if (mode == COPY_TO_CACHE) { ++ gz_out = gzdopen(dup(fd_out), "wb"); ++ if (!gz_out) { ++ gzclose(gz_in); ++ close(fd_out); ++ free(tmp_name); ++ return -1; ++ } ++ } ++ ++ while ((n = gzread(gz_in, buf, sizeof(buf))) > 0) { ++ if (mode == COPY_TO_CACHE) { ++ ret = gzwrite(gz_out, buf, n); ++ } else { ++ ret = write(fd_out, buf, n); ++ } ++ if (ret != n) { ++ gzclose(gz_in); ++ if (gz_out) { ++ gzclose(gz_out); ++ } ++ close(fd_out); ++ unlink(tmp_name); ++ free(tmp_name); ++ return -1; ++ } ++ } ++ ++ gzclose(gz_in); ++ if (gz_out) { ++ gzclose(gz_out); ++ } ++ ++ /* get perms right on the tmp file */ ++ mask = umask(0); ++ fchmod(fd_out, 0666 & ~mask); ++ umask(mask); ++ ++ /* the close can fail on NFS if out of space */ ++ if (close(fd_out) == -1) { ++ unlink(tmp_name); ++ free(tmp_name); ++ return -1; ++ } ++ ++ unlink(dest); ++ ++ if (rename(tmp_name, dest) == -1) { ++ unlink(tmp_name); ++ free(tmp_name); ++ return -1; ++ } ++ ++ free(tmp_name); ++ ++ return 0; ++} ++ ++/* move a file to the cache, compressing it */ ++int move_file(const char *src, const char *dest) { ++ int ret; ++ ++ ret = _copy_file(src, dest, COPY_TO_CACHE); ++ if (ret != -1) unlink(src); ++ return ret; ++} ++ ++/* copy a file from the cache, decompressing it */ ++int copy_file(const char *src, const char *dest) { ++ return _copy_file(src, dest, COPY_FROM_CACHE); ++} ++#endif /* ENABLE_ZLIB */ ++ ++/* test if a file is zlib compressed */ ++int test_if_compressed(const char *filename) { ++ FILE *f; ++ ++ f = fopen(filename, "rb"); ++ if (!f) { ++ return 0; ++ } ++ ++ /* test if file starts with 1F8B, which is zlib's ++ * magic number */ ++ if ((fgetc(f) != 0x1f) || (fgetc(f) != 0x8b)) { ++ fclose(f); ++ return 0; ++ } ++ ++ fclose(f); ++ return 1; ++} + + /* make sure a directory exists */ + int create_dir(const char *dir) +Index: manage-cache.sh +=================================================================== +RCS file: manage-cache.sh +diff -N manage-cache.sh +--- manage-cache.sh 1 Jan 1970 00:00:00 -0000 ++++ manage-cache.sh-cache.sh 12 May 2004 19:22:20 -0000 1.1 +@@ -0,0 +1,68 @@ ++#!/bin/bash ++# ++# 2004-05-12 lars@gustaebel.de ++ ++CCACHE_DIR=${CCACHE_DIR:-$HOME/.ccache} ++ ++echo "Do you want to compress or decompress the ccache in $CCACHE_DIR?" ++read -p "Type c or d: " mode ++ ++if [ "$mode" != "c" ] && [ "$mode" != "d" ] ++then ++ exit 1 ++fi ++ ++is_compressed() { ++ test "$(head -c 2 $1)" = $'\x1f\x8b' ++ return $? ++} ++ ++tmpfile=$(mktemp) ++ ++for dir in 0 1 2 3 4 5 6 7 8 9 a b c d e f ++do ++ # process ccache subdir ++ echo -n "$dir " ++ ++ # find cache files ++ find $CCACHE_DIR/$dir -type f -name '*-*' | ++ sort > $tmpfile ++ ++ oldsize=$(cat $CCACHE_DIR/$dir/stats | cut -d ' ' -f 13) ++ newsize=0 ++ ++ while read file ++ do ++ # empty files will be ignored since compressing ++ # them makes them bigger ++ test $(stat -c %s $file) -eq 0 && continue ++ ++ if [ $mode = c ] ++ then ++ if ! is_compressed $file ++ then ++ gzip $file ++ mv $file.gz $file ++ fi ++ else ++ if is_compressed $file ++ then ++ mv $file $file.gz ++ gzip -d $file.gz ++ fi ++ fi ++ ++ # calculate new size statistic for this subdir ++ let newsize=$newsize+$(stat -c "%B*%b" $file)/1024 ++ done < $tmpfile ++ ++ # update statistic file ++ read -a numbers < $CCACHE_DIR/$dir/stats ++ numbers[12]=$newsize ++ echo "${numbers[*]} " > $CCACHE_DIR/$dir/stats ++done ++echo ++ ++# clean up ++rm $tmpfile ++ +Index: Makefile.in +=================================================================== +RCS file: /home/cvsroot/lars/ccache/Makefile.in,v +retrieving revision 1.1.1.1.2.1 +retrieving revision 1.12 +diff -u -r1.1.1.1.2.1 -r1.12 +--- Makefile.in 21 Nov 2004 17:55:36 -0000 1.1.1.1.2.1 ++++ Makefile.in 21 Nov 2004 18:19:28 -0000 1.12 +@@ -11,6 +11,7 @@ + CFLAGS=@CFLAGS@ -I. + EXEEXT=@EXEEXT@ + ++LIBS= @LIBS@ + OBJS= ccache.o mdfour.o hash.o execute.o util.o args.o stats.o \ + cleanup.o snprintf.o unify.o + HEADERS = ccache.h mdfour.h +@@ -20,7 +21,7 @@ + docs: ccache.1 web/ccache-man.html + + ccache$(EXEEXT): $(OBJS) $(HEADERS) +- $(CC) $(CFLAGS) -o $@ $(OBJS) ++ $(CC) $(CFLAGS) -o $@ $(OBJS) $(LIBS) + + ccache.1: ccache.yo + -yodl2man -o ccache.1 ccache.yo diff --git a/CCache/debian/patches/03_long_options.diff b/CCache/debian/patches/03_long_options.diff new file mode 100644 index 000000000..3235c3806 --- /dev/null +++ b/CCache/debian/patches/03_long_options.diff @@ -0,0 +1,133 @@ +Index: ccache.c +=================================================================== +--- ccache.c (révision 7695) ++++ ccache.c (copie de travail) +@@ -22,6 +22,7 @@ + */ + + #include "ccache.h" ++#include + + /* the base cache directory */ + char *cache_dir = NULL; +@@ -885,14 +886,14 @@ + printf("\tcompiler [compile options] (via symbolic link)\n"); + printf("\nOptions:\n"); + +- printf("-s show statistics summary\n"); +- printf("-z zero statistics\n"); +- printf("-c run a cache cleanup\n"); +- printf("-C clear the cache completely\n"); +- printf("-F set maximum files in cache\n"); +- printf("-M set maximum size of cache (use G, M or K)\n"); +- printf("-h this help page\n"); +- printf("-V print version number\n"); ++ printf("-s, --show-stats show statistics summary\n"); ++ printf("-z, --zero-stats zero statistics\n"); ++ printf("-c, --cleanup run a cache cleanup\n"); ++ printf("-C, --clear clear the cache completely\n"); ++ printf("-F , --max-files= set maximum files in cache\n"); ++ printf("-M , --max-size= set maximum size of cache (use G, M or K)\n"); ++ printf("-h, --help this help page\n"); ++ printf("-V, --version print version number\n"); + } + + /* the main program when not doing a compile */ +@@ -901,7 +902,21 @@ + int c; + size_t v; + +- while ((c = getopt(argc, argv, "hszcCF:M:V")) != -1) { ++ static struct option long_options[] = ++ { ++ {"show-stats", no_argument, 0, 's'}, ++ {"zero-stats", no_argument, 0, 'z'}, ++ {"cleanup", no_argument, 0, 'c'}, ++ {"clear", no_argument, 0, 'C'}, ++ {"max-files", required_argument, 0, 'F'}, ++ {"max-size", required_argument, 0, 'M'}, ++ {"help", no_argument, 0, 'h'}, ++ {"version", no_argument, 0, 'V'}, ++ {0, 0, 0, 0} ++ }; ++ int option_index = 0; ++ ++ while ((c = getopt_long(argc, argv, "hszcCF:M:V", long_options, &option_index)) != -1) { + switch (c) { + case 'V': + printf("ccache version %s\n", CCACHE_VERSION); +Index: ccache.1 +=================================================================== +--- ccache.1 (révision 7695) ++++ ccache.1 (copie de travail) +@@ -23,14 +23,14 @@ + .nf + + +--s show statistics summary +--z zero statistics +--c run a cache cleanup +--C clear the cache completely +--F set maximum files in cache +--M set maximum size of cache (use G, M or K) +--h this help page +--V print version number ++\-s, \-\-show-stats show statistics summary ++\-z, \-\-zero-stats zero statistics ++\-c, \-\-cleanup run a cache cleanup ++\-C, \-\-clear clear the cache completely ++\-F , \-\-max-files= set maximum files in cache ++\-M , \-\-max-size= set maximum size of cache (use G, M or K) ++\-h, \-\-help this help page ++\-V, \-\-version print version number + + .fi + +@@ -43,22 +43,22 @@ + normal compiler options apply and you should refer to your compilers + documentation\&. + .PP +-.IP "\fB-h\fP" ++.IP "\fB-h, --help\fP" + Print a options summary page + .IP +-.IP "\fB-s\fP" ++.IP "\fB-s, --show-stats\fP" + Print the current statistics summary for the cache\&. The + statistics are stored spread across the subdirectories of the + cache\&. Using "ccache -s" adds up the statistics across all + subdirectories and prints the totals\&. + .IP +-.IP "\fB-z\fP" ++.IP "\fB-z, --zero-stats\fP" + Zero the cache statistics\&. + .IP +-.IP "\fB-V\fP" ++.IP "\fB-V, --version\fP" + Print the ccache version number + .IP +-.IP "\fB-c\fP" ++.IP "\fB-c, --cleanup\fP" + Clean the cache and re-calculate the cache file count and + size totals\&. Normally the -c option should not be necessary as ccache + keeps the cache below the specified limits at runtime and keeps +@@ -66,16 +66,16 @@ + if you manually modify the cache contents or believe that the cache + size statistics may be inaccurate\&. + .IP +-.IP "\fB-C\fP" ++.IP "\fB-C, --clear\fP" + Clear the entire cache, removing all cached files\&. + .IP +-.IP "\fB-F maxfiles\fP" ++.IP "\fB-F , --max-files=\fP" + This sets the maximum number of files allowed in + the cache\&. The value is stored inside the cache directory and applies + to all future compiles\&. Due to the way the value is stored the actual + value used is always rounded down to the nearest multiple of 16\&. + .IP +-.IP "\fB-M maxsize\fP" ++.IP "\fB-M , --max-size=\fP" + This sets the maximum cache size\&. You can specify + a value in gigabytes, megabytes or kilobytes by appending a G, M or K + to the value\&. The default is gigabytes\&. The actual value stored is diff --git a/CCache/debian/patches/04_ignore_profile.diff b/CCache/debian/patches/04_ignore_profile.diff new file mode 100644 index 000000000..568375092 --- /dev/null +++ b/CCache/debian/patches/04_ignore_profile.diff @@ -0,0 +1,13 @@ +diff -ru ccache-2.4/ccache.c ccache-2.4-tp/ccache.c +--- ccache.c 2007-05-20 03:14:19.000000000 +1000 ++++ ccache.c 2007-05-20 03:17:54.000000000 +1000 +@@ -641,6 +641,9 @@ + + /* these are too hard */ + if (strcmp(argv[i], "-fbranch-probabilities")==0 || ++ strcmp(argv[i], "-fprofile-arcs") == 0 || ++ strcmp(argv[i], "-ftest-coverage") == 0 || ++ strcmp(argv[i], "--coverage") == 0 || + strcmp(argv[i], "-M") == 0 || + strcmp(argv[i], "-MM") == 0 || + strcmp(argv[i], "-x") == 0) { diff --git a/CCache/debian/patches/05_nfs_fix.diff b/CCache/debian/patches/05_nfs_fix.diff new file mode 100644 index 000000000..662d97639 --- /dev/null +++ b/CCache/debian/patches/05_nfs_fix.diff @@ -0,0 +1,45 @@ +--- ccache.1.orig 2007-05-20 17:30:57.000000000 +1200 ++++ ccache.1 2007-05-20 17:31:27.000000000 +1200 +@@ -367,12 +367,6 @@ + .IP o + ccache avoids a double call to cpp on a cache miss + .PP +-.SH "BUGS" +-.PP +-When the cache is stored on an NFS filesystem, the filesystem must be +-exported with the \fBno_subtree_check\fP option to make renames between +-directories reliable\&. +-.PP + .SH "CREDITS" + .PP + Thanks to the following people for their contributions to ccache +--- util.c.patched 2007-05-20 18:19:11.000000000 +1200 ++++ util.c 2007-05-20 18:20:55.000000000 +1200 +@@ -58,9 +58,26 @@ + } + } + ++static int safe_rename(const char* oldpath, const char* newpath) ++{ ++ /* safe_rename is for creating entries in the cache. ++ ++ Works like rename(), but it never overwrites an existing ++ cache entry. This avoids corruption on NFS. */ ++ int status = link( oldpath, newpath ); ++ if( status == 0 || errno == EEXIST ) ++ { ++ return unlink( oldpath ); ++ } ++ else ++ { ++ return -1; ++ } ++} ++ + /* move a file using rename */ + int move_file(const char *src, const char *dest) { +- return rename(src, dest); ++ return safe_rename(src, dest); + } + + /* copy a file - used when hard links don't work diff --git a/CCache/debian/patches/06_md.diff b/CCache/debian/patches/06_md.diff new file mode 100644 index 000000000..3f68850ca --- /dev/null +++ b/CCache/debian/patches/06_md.diff @@ -0,0 +1,77 @@ +--- ccache.c Mon Sep 13 11:38:30 2004 ++++ ccache.c Thu Jun 21 22:17:32 2007 +@@ -627,6 +627,13 @@ static void process_args(int argc, char + int found_S_opt = 0; + struct stat st; + char *e; ++ /* is gcc being asked to output dependencies? */ ++ int generating_dependencies = 0; ++ /* is the dependency makefile name overridden with -MF? */ ++ int dependency_filename_specified = 0; ++ /* is the dependency makefile target name specified with -MQ or -MF? */ ++ int dependency_target_specified = 0; ++ + + stripped_args = args_init(0, NULL); + +@@ -702,6 +709,18 @@ static void process_args(int argc, char + continue; + } + ++ /* These options require special handling, because they ++ behave differently with gcc -E, when the output ++ file is not specified. */ ++ ++ if (strcmp(argv[i], "-MD") == 0 || strcmp(argv[i], "-MMD") == 0) { ++ generating_dependencies = 1; ++ } else if (strcmp(argv[i], "-MF") == 0) { ++ dependency_filename_specified = 1; ++ } else if (strcmp(argv[i], "-MQ") == 0 || strcmp(argv[i], "-MT") == 0) { ++ dependency_target_specified = 1; ++ } ++ + /* options that take an argument */ + { + const char *opts[] = {"-I", "-include", "-imacros", "-iprefix", +@@ -812,6 +831,41 @@ static void process_args(int argc, char + } + p[1] = found_S_opt ? 's' : 'o'; + p[2] = 0; ++ } ++ ++ /* If dependencies are generated, configure the preprocessor */ ++ ++ if (generating_dependencies && output_file) { ++ if (!dependency_filename_specified) { ++ char *default_depfile_name = x_strdup(output_file); ++ char *p = strrchr(default_depfile_name, '.'); ++ ++ if (p) { ++ if (strlen(p) < 2) { ++ stats_update(STATS_ARGS); ++ failed(); ++ return; ++ } ++ *p = 0; ++ } ++ else { ++ int len = p - default_depfile_name; ++ ++ p = x_malloc(len + 3); ++ strncpy(default_depfile_name, p, len - 1); ++ free(default_depfile_name); ++ default_depfile_name = p; ++ } ++ ++ strcat(default_depfile_name, ".d"); ++ args_add(stripped_args, "-MF"); ++ args_add(stripped_args, default_depfile_name); ++ } ++ ++ if (!dependency_target_specified) { ++ args_add(stripped_args, "-MT"); ++ args_add(stripped_args, output_file); ++ } + } + + /* cope with -o /dev/null */ diff --git a/CCache/debian/patches/07_cachedirtag.diff b/CCache/debian/patches/07_cachedirtag.diff new file mode 100644 index 000000000..683b48d14 --- /dev/null +++ b/CCache/debian/patches/07_cachedirtag.diff @@ -0,0 +1,75 @@ +Index: ccache.c +=================================================================== +--- ccache.c (révision 7695) ++++ ccache.c (copie de travail) +@@ -1029,6 +1029,14 @@ + exit(1); + } + ++ if (!getenv("CCACHE_READONLY")) { ++ if (create_cachedirtag(cache_dir) != 0) { ++ fprintf(stderr,"ccache: failed to create %s/CACHEDIR.TAG (%s)\n", ++ cache_dir, strerror(errno)); ++ exit(1); ++ } ++ } ++ + ccache(argc, argv); + return 1; + } +Index: ccache.h +=================================================================== +--- ccache.h (révision 7695) ++++ ccache.h (copie de travail) +@@ -81,6 +81,7 @@ + int copy_file(const char *src, const char *dest); + + int create_dir(const char *dir); ++int create_cachedirtag(const char *dir); + void x_asprintf(char **ptr, const char *format, ...); + char *x_strdup(const char *s); + void *x_realloc(void *ptr, size_t size); +Index: util.c +=================================================================== +--- util.c (révision 7695) ++++ util.c (copie de travail) +@@ -138,6 +138,39 @@ + return 0; + } + ++char const CACHEDIR_TAG[] = ++ "Signature: 8a477f597d28d172789f06886806bc55\n" ++ "# This file is a cache directory tag created by ccache.\n" ++ "# For information about cache directory tags, see:\n" ++ "# http://www.brynosaurus.com/cachedir/\n"; ++ ++int create_cachedirtag(const char *dir) ++{ ++ char *filename; ++ struct stat st; ++ FILE *f; ++ x_asprintf(&filename, "%s/CACHEDIR.TAG", dir); ++ if (stat(filename, &st) == 0) { ++ if (S_ISREG(st.st_mode)) { ++ goto success; ++ } ++ errno = EEXIST; ++ goto error; ++ } ++ f = fopen(filename, "w"); ++ if (!f) goto error; ++ if (fwrite(CACHEDIR_TAG, sizeof(CACHEDIR_TAG)-1, 1, f) != 1) { ++ goto error; ++ } ++ if (fclose(f)) goto error; ++success: ++ free(filename); ++ return 0; ++error: ++ free(filename); ++ return 1; ++} ++ + /* + this is like asprintf() but dies if the malloc fails + note that we use vsnprintf in a rather poor way to make this more portable diff --git a/CCache/debian/patches/08_manpage_hyphens.diff b/CCache/debian/patches/08_manpage_hyphens.diff new file mode 100644 index 000000000..55ced4a23 --- /dev/null +++ b/CCache/debian/patches/08_manpage_hyphens.diff @@ -0,0 +1,89 @@ +Index: ccache.1 +=================================================================== +--- ccache.1 (révision 7695) ++++ ccache.1 (copie de travail) +@@ -49,7 +49,7 @@ + .IP "\fB-s\fP" + Print the current statistics summary for the cache\&. The + statistics are stored spread across the subdirectories of the +-cache\&. Using "ccache -s" adds up the statistics across all ++cache\&. Using "ccache \-s" adds up the statistics across all + subdirectories and prints the totals\&. + .IP + .IP "\fB-z\fP" +@@ -60,7 +60,7 @@ + .IP + .IP "\fB-c\fP" + Clean the cache and re-calculate the cache file count and +-size totals\&. Normally the -c option should not be necessary as ccache ++size totals\&. Normally the \-c option should not be necessary as ccache + keeps the cache below the specified limits at runtime and keeps + statistics up to date on each compile\&. This option is mostly useful + if you manually modify the cache contents or believe that the cache +@@ -100,9 +100,9 @@ + + + cp ccache /usr/local/bin/ +- ln -s /usr/local/bin/ccache /usr/local/bin/gcc +- ln -s /usr/local/bin/ccache /usr/local/bin/g++ +- ln -s /usr/local/bin/ccache /usr/local/bin/cc ++ ln \-s /usr/local/bin/ccache /usr/local/bin/gcc ++ ln \-s /usr/local/bin/ccache /usr/local/bin/g++ ++ ln \-s /usr/local/bin/ccache /usr/local/bin/cc + + .fi + +@@ -118,7 +118,7 @@ + .PP + When run as a compiler front end ccache usually just takes the same + command line options as the compiler you are using\&. The only exception +-to this is the option \&'--ccache-skip\&'\&. That option can be used to tell ++to this is the option \&'\-\-ccache-skip\&'\&. That option can be used to tell + ccache that the next option is definitely not a input filename, and + should be passed along to the compiler as-is\&. + .PP +@@ -128,7 +128,7 @@ + of the resulting object file (among other things)\&. The heuristic + ccache uses in this parse is that any string on the command line that + exists as a file is treated as an input file name (usually a C +-file)\&. By using --ccache-skip you can force an option to not be ++file)\&. By using \-\-ccache-skip you can force an option to not be + treated as an input file name and instead be passed along to the + compiler as a command line option\&. + .PP +@@ -238,7 +238,7 @@ + .IP "\fBCCACHE_UNIFY\fP" + If you set the environment variable CCACHE_UNIFY + then ccache will use the C/C++ unifier when hashing the pre-processor +-output if -g is not used in the compile\&. The unifier is slower than a ++output if \-g is not used in the compile\&. The unifier is slower than a + normal hash, so setting this environment variable loses a little bit + of speed, but it means that ccache can take advantage of not + recompiling when the changes to the source code consist of +@@ -262,7 +262,7 @@ + .PP + By default ccache has a one gigabyte limit on the cache size and no + maximum number of files\&. You can set a different limit using the +-"ccache -M" and "ccache -F" options, which set the size and number of ++"ccache \-M" and "ccache \-F" options, which set the size and number of + files limits\&. + .PP + When these limits are reached ccache will reduce the cache to 20% +@@ -276,7 +276,7 @@ + that it is the same code by forming a hash of: + .PP + .IP o +-the pre-processor output from running the compiler with -E ++the pre-processor output from running the compiler with \-E + .IP o + the command line options + .IP o +@@ -331,7 +331,7 @@ + .IP o + Make sure that the setgid bit is set on all directories in the + cache\&. This tells the filesystem to inherit group ownership for new +-directories\&. The command "chmod g+s `find $CCACHE_DIR -type d`" might ++directories\&. The command "chmod g+s `find $CCACHE_DIR \-type d`" might + be useful for this\&. + .PP + .SH "HISTORY" diff --git a/CCache/debian/patches/09_respect_ldflags.diff b/CCache/debian/patches/09_respect_ldflags.diff new file mode 100644 index 000000000..0ce2c2de3 --- /dev/null +++ b/CCache/debian/patches/09_respect_ldflags.diff @@ -0,0 +1,11 @@ +--- Makefile.in.orig 2008-03-23 17:01:19.000000000 +1300 ++++ Makefile.in 2008-03-23 17:03:03.000000000 +1300 +@@ -21,7 +21,7 @@ + docs: ccache.1 web/ccache-man.html + + ccache$(EXEEXT): $(OBJS) $(HEADERS) +- $(CC) $(CFLAGS) -o $@ $(OBJS) $(LIBS) ++ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) + + ccache.1: ccache.yo + -yodl2man -o ccache.1 ccache.yo diff --git a/CCache/debian/patches/10_lru_cleanup.diff b/CCache/debian/patches/10_lru_cleanup.diff new file mode 100644 index 000000000..24463e529 --- /dev/null +++ b/CCache/debian/patches/10_lru_cleanup.diff @@ -0,0 +1,23 @@ +--- ccache.c (révision 8804) ++++ ccache.c (copie de travail) +@@ -481,6 +481,9 @@ + return; + } + ++ /* update timestamps for LRU cleanup ++ also gives output_file a sensible mtime when hard-linking (for make) */ ++ utime(hashname, NULL); + utime(stderr_file, NULL); + + if (strcmp(output_file, "/dev/null") == 0) { +@@ -513,10 +516,6 @@ + failed(); + } + } +- if (ret == 0) { +- /* update the mtime on the file so that make doesn't get confused */ +- utime(output_file, NULL); +- } + + /* get rid of the intermediate preprocessor file */ + if (i_tmpfile) { diff --git a/CCache/debian/patches/11_utimes.diff b/CCache/debian/patches/11_utimes.diff new file mode 100644 index 000000000..2886bf3d6 --- /dev/null +++ b/CCache/debian/patches/11_utimes.diff @@ -0,0 +1,85 @@ +--- ccache.c 2004-09-13 03:38:30.000000000 -0700 ++++ ccache.c 2006-06-09 16:29:16.695117780 -0700 +@@ -481,8 +481,13 @@ + + /* update timestamps for LRU cleanup + also gives output_file a sensible mtime when hard-linking (for make) */ ++#ifdef HAVE_UTIMES ++ utimes(hashname, NULL); ++ utimes(stderr_file, NULL); ++#else + utime(hashname, NULL); + utime(stderr_file, NULL); ++#endif + + if (strcmp(output_file, "/dev/null") == 0) { + ret = 0; +--- ccache.h 2004-09-13 03:38:30.000000000 -0700 ++++ ccache.h 2006-06-09 16:28:16.601658626 -0700 +@@ -22,6 +22,9 @@ + #ifdef HAVE_PWD_H + #include + #endif ++#ifdef HAVE_SYS_TIME_H ++#include ++#endif + + #define STATUS_NOTFOUND 3 + #define STATUS_FATAL 4 +--- config.h.in 2003-09-27 21:48:17.000000000 -0700 ++++ config.h.in 2006-06-09 16:25:43.000000000 -0700 +@@ -19,6 +19,9 @@ + /* Define to 1 if you have the `gethostname' function. */ + #undef HAVE_GETHOSTNAME + ++/* Define to 1 if you have the `getpwuid' function. */ ++#undef HAVE_GETPWUID ++ + /* Define to 1 if you have the header file. */ + #undef HAVE_INTTYPES_H + +@@ -31,6 +34,9 @@ + /* Define to 1 if you have the header file, and it defines `DIR'. */ + #undef HAVE_NDIR_H + ++/* Define to 1 if you have the header file. */ ++#undef HAVE_PWD_H ++ + /* Define to 1 if you have the `realpath' function. */ + #undef HAVE_REALPATH + +@@ -60,6 +66,9 @@ + /* Define to 1 if you have the header file. */ + #undef HAVE_SYS_STAT_H + ++/* Define to 1 if you have the header file. */ ++#undef HAVE_SYS_TIME_H ++ + /* Define to 1 if you have the header file. */ + #undef HAVE_SYS_TYPES_H + +@@ -69,6 +78,9 @@ + /* Define to 1 if you have the header file. */ + #undef HAVE_UNISTD_H + ++/* Define to 1 if you have the `utimes' function. */ ++#undef HAVE_UTIMES ++ + /* Define to 1 if you have the `vasprintf' function. */ + #undef HAVE_VASPRINTF + +--- configure.in 2004-09-13 03:38:30.000000000 -0700 ++++ configure.in 2006-06-09 16:25:15.541288184 -0700 +@@ -27,10 +27,11 @@ + AC_HEADER_TIME + AC_HEADER_SYS_WAIT + +-AC_CHECK_HEADERS(ctype.h strings.h stdlib.h string.h pwd.h) ++AC_CHECK_HEADERS(ctype.h strings.h stdlib.h string.h pwd.h sys/time.h) + + AC_CHECK_FUNCS(realpath snprintf vsnprintf vasprintf asprintf mkstemp) + AC_CHECK_FUNCS(gethostname getpwuid) ++AC_CHECK_FUNCS(utimes) + + AC_CACHE_CHECK([for compar_fn_t in stdlib.h],ccache_cv_COMPAR_FN_T, [ + AC_TRY_COMPILE( diff --git a/CCache/debian/patches/12_cachesize_permissions.diff b/CCache/debian/patches/12_cachesize_permissions.diff new file mode 100644 index 000000000..28801b771 --- /dev/null +++ b/CCache/debian/patches/12_cachesize_permissions.diff @@ -0,0 +1,83 @@ +--- stats.c (révision 8804) ++++ stats.c (copie de travail) +@@ -286,7 +286,7 @@ + + + /* set the per directory limits */ +-void stats_set_limits(long maxfiles, long maxsize) ++int stats_set_limits(long maxfiles, long maxsize) + { + int dir; + unsigned counters[STATS_END]; +@@ -298,7 +298,9 @@ + maxsize /= 16; + } + +- create_dir(cache_dir); ++ if (create_dir(cache_dir) != 0) { ++ return 1; ++ } + + /* set the limits in each directory */ + for (dir=0;dir<=0xF;dir++) { +@@ -306,7 +308,9 @@ + int fd; + + x_asprintf(&cdir, "%s/%1x", cache_dir, dir); +- create_dir(cdir); ++ if (create_dir(cdir) != 0) { ++ return 1; ++ } + x_asprintf(&fname, "%s/stats", cdir); + free(cdir); + +@@ -326,6 +330,8 @@ + } + free(fname); + } ++ ++ return 0; + } + + /* set the per directory sizes */ +--- ccache.c (révision 8804) ++++ ccache.c (copie de travail) +@@ -935,15 +934,23 @@ + case 'F': + check_cache_dir(); + v = atoi(optarg); +- stats_set_limits(v, -1); +- printf("Set cache file limit to %u\n", (unsigned)v); ++ if (stats_set_limits(v, -1) == 0) { ++ printf("Set cache file limit to %u\n", (unsigned)v); ++ } else { ++ printf("Could not set cache file limit.\n"); ++ exit(1); ++ } + break; + + case 'M': + check_cache_dir(); + v = value_units(optarg); +- stats_set_limits(-1, v); +- printf("Set cache size limit to %uk\n", (unsigned)v); ++ if (stats_set_limits(-1, v) == 0) { ++ printf("Set cache size limit to %uk\n", (unsigned)v); ++ } else { ++ printf("Could not set cache size limit.\n"); ++ exit(1); ++ } + break; + + default: +--- ccache.h (révision 8804) ++++ ccache.h (copie de travail) +@@ -101,7 +101,7 @@ + void stats_summary(void); + void stats_tocache(size_t size); + void stats_read(const char *stats_file, unsigned counters[STATS_END]); +-void stats_set_limits(long maxfiles, long maxsize); ++int stats_set_limits(long maxfiles, long maxsize); + size_t value_units(const char *s); + void display_size(unsigned v); + void stats_set_sizes(const char *dir, size_t num_files, size_t total_size); diff --git a/CCache/debian/patches/CREDITS b/CCache/debian/patches/CREDITS new file mode 100644 index 000000000..c4e323b7b --- /dev/null +++ b/CCache/debian/patches/CREDITS @@ -0,0 +1,47 @@ +01_no_home.diff: + Francois Marier + Made especially for the Debian package. + +02_ccache_compressed.diff: + Lars Gustäbel + http://www.gustaebel.de/lars/ccache/ (downloaded on 2007-05-20) + +03_long_options.diff: + Francois Marier + Made especially for the Debian package. + +04_ignore_profile.diff: + Ted Percival + http://bugs.debian.org/cgi-bin/bugreport.cgi?msg=20;filename=ccache-profile.patch;att=1;bug=215849 + +05_nfs_fix.diff: + John Coiner + http://lists.samba.org/archive/ccache/2007q1/000265.html + +06_md.diff: + Andrea Bittau + http://darkircop.org/ccache/ccache-2.4-md.patch (downloaded on 2007-06-30) + +07_cachedirtag.diff: + Karl Chen + http://lists.samba.org/archive/ccache/2008q1/000316.html (downloaded on 2008-02-02) + +08_manpage_hyphens.diff: + Francois Marier + Made especially for the Debian package. + +09_respect_ldflags.diff: + Lisa Seelye + http://sources.gentoo.org/viewcvs.py/gentoo-x86/dev-util/ccache/files/ccache-2.4-respectflags.patch?rev=1.1&view=markup + +10_lru_cleanup.diff: + RW + http://lists.samba.org/archive/ccache/2008q2/000339.html (downloaded on 2008-04-11) + +11_utimes.diff: + Robin H. Johnson + http://sources.gentoo.org/viewcvs.py/gentoo-x86/dev-util/ccache/files/ccache-2.4-utimes.patch?rev=1.1&view=markup + +12_cachesize_permissions.diff: + Francois Marier + Made especially for the Debian package to fix http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=332527 diff --git a/CCache/debian/rules b/CCache/debian/rules new file mode 100644 index 000000000..c5b538b78 --- /dev/null +++ b/CCache/debian/rules @@ -0,0 +1,141 @@ +#!/usr/bin/make -f +# Sample debian/rules that uses debhelper. +# GNU copyright 1997 to 1999 by Joey Hess. + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + +# These are used for cross-compiling and for saving the configure script +# from having to guess our platform (since we know it already) +export DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) +export DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE) + +ifeq ($(DEB_BUILD_GNU_TYPE), $(DEB_HOST_GNU_TYPE)) + confflags += --build $(DEB_HOST_GNU_TYPE) +else + confflags += --build $(DEB_BUILD_GNU_TYPE) --host $(DEB_HOST_GNU_TYPE) +endif + +ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS))) + CFLAGS += -g +endif +ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS))) + INSTALL_PROGRAM += -s +endif + +config.status: configure + dh_testdir + + # Apply Debian specific patches + cp $(CURDIR)/ccache.c $(CURDIR)/ccache.c.unpatched + cp $(CURDIR)/util.c $(CURDIR)/util.c.unpatched + cp $(CURDIR)/ccache.1 $(CURDIR)/ccache.1.unpatched + cp $(CURDIR)/ccache.h $(CURDIR)/ccache.h.unpatched + cp $(CURDIR)/ccache.yo $(CURDIR)/ccache.yo.unpatched + cp $(CURDIR)/config.h.in $(CURDIR)/config.h.in.unpatched + cp $(CURDIR)/configure $(CURDIR)/configure.unpatched + cp $(CURDIR)/configure.in $(CURDIR)/configure.in.unpatched + cp $(CURDIR)/Makefile.in $(CURDIR)/Makefile.in.unpatched + if test ! -f patch-stamp; then \ + for patch in $(CURDIR)/debian/patches/*.diff ;\ + do \ + echo APPLYING PATCH\: $${patch##*/};\ + patch -p0 < $$patch ;\ + done ;\ + touch patch-stamp ;\ + fi + chmod +x $(CURDIR)/manage-cache.sh + + ./configure $(confflags) --prefix=/usr --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info + +build: build-stamp + +build-stamp: config.status + dh_testdir + + $(MAKE) + + touch build-stamp + +clean: + dh_testdir + dh_testroot + rm -f build-stamp + + # Unapply patches + -test -r $(CURDIR)/ccache.c.unpatched && mv $(CURDIR)/ccache.c.unpatched $(CURDIR)/ccache.c + -test -r $(CURDIR)/util.c.unpatched && mv $(CURDIR)/util.c.unpatched $(CURDIR)/util.c + -test -r $(CURDIR)/ccache.1.unpatched && mv $(CURDIR)/ccache.1.unpatched $(CURDIR)/ccache.1 + -test -r $(CURDIR)/ccache.h.unpatched && mv $(CURDIR)/ccache.h.unpatched $(CURDIR)/ccache.h + -test -r $(CURDIR)/ccache.yo.unpatched && mv $(CURDIR)/ccache.yo.unpatched $(CURDIR)/ccache.yo + -test -r $(CURDIR)/config.h.in.unpatched && mv $(CURDIR)/config.h.in.unpatched $(CURDIR)/config.h.in + -test -r $(CURDIR)/configure.unpatched && mv $(CURDIR)/configure.unpatched $(CURDIR)/configure + -test -r $(CURDIR)/configure.in.unpatched && mv $(CURDIR)/configure.in.unpatched $(CURDIR)/configure.in + -test -r $(CURDIR)/Makefile.in.unpatched && mv $(CURDIR)/Makefile.in.unpatched $(CURDIR)/Makefile.in + -rm -f $(CURDIR)/manage-cache.sh + -rm -f patch-stamp + + [ ! -f Makefile ] || $(MAKE) distclean + + dh_clean + + # Update config.sub and config.guess + -test -r /usr/share/misc/config.sub && \ + cp -f /usr/share/misc/config.sub config.sub + -test -r /usr/share/misc/config.guess && \ + cp -f /usr/share/misc/config.guess config.guess + + +install: build + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs + + # Add here commands to install the package into debian/ccache. + $(MAKE) install prefix=$(CURDIR)/debian/ccache/usr + + ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/$(DEB_BUILD_GNU_TYPE)-gcc + ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/$(DEB_BUILD_GNU_TYPE)-g++ + set -e; for ver in 2.95 3.0 3.2 3.3 3.4 4.0 4.1 4.2 4.3; do \ + ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/$(DEB_BUILD_GNU_TYPE)-gcc-$$ver; \ + ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/gcc-$$ver; \ + ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/$(DEB_BUILD_GNU_TYPE)-g++-$$ver; \ + ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/g++-$$ver; \ + done + ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/cc + ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/c++ + ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/gcc + ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/g++ + ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/i586-mingw32msvc-c++ + ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/i586-mingw32msvc-cc + ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/i586-mingw32msvc-g++ + ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/i586-mingw32msvc-gcc + +# Build architecture-independent files here. +binary-indep: build install +# We have nothing to do by default. + +# Build architecture-dependent files here. +binary-arch: build install + dh_testdir + dh_testroot + dh_installdocs + dh_installexamples + dh_installmenu + dh_installcron + dh_installman + dh_installinfo + dh_installchangelogs + dh_link + dh_strip + dh_compress + dh_fixperms + dh_installdeb + dh_shlibdeps + dh_gencontrol + dh_md5sums + dh_builddeb + +binary: binary-indep binary-arch +.PHONY: build clean binary-indep binary-arch binary install diff --git a/CCache/debian/update-ccache b/CCache/debian/update-ccache new file mode 100644 index 000000000..0ef97a140 --- /dev/null +++ b/CCache/debian/update-ccache @@ -0,0 +1,43 @@ +#!/bin/sh +# +# Update compiler links to ccache (in /usr/local/bin) +# +# The idea is that /usr/local/bin is ahead of /usr/bin in your PATH, so adding +# the link /usr/local/bin/cc -> /usr/bin/ccache means that it is run instead of +# /usr/bin/cc +# +# Written by: Behan Webster +# + +DIRECTORY=/usr/local/bin +CCACHE=/usr/bin/ccache +CCDIR=/usr/lib/ccache + +usage() { + echo "Usage: `basename $0` [--directory ] [--remove]" + exit 0 +} + +while [ $# -gt 0 ] ; do + case "$1" in + -d*|--d*|--directory) DIRECTORY=$2; shift; shift;; + -h*|--h*|--help) usage;; + -r*|--r*|--remove) REMOVE=1; shift;; + -t*|--t*|--test) TEST=echo; shift;; + esac +done + +for FILE in `cd $CCDIR; ls` ; do + LINK=$DIRECTORY/$FILE + if [ -z "$REMOVE" ] ; then + # Add link + $TEST ln -fs $CCACHE $LINK + else + # Remove link + if [ -L "$LINK" ] ; then + $TEST rm -f $LINK + fi + fi +done + +# vim: sw=4 ts=4 diff --git a/CCache/debian/watch b/CCache/debian/watch new file mode 100644 index 000000000..a72959e50 --- /dev/null +++ b/CCache/debian/watch @@ -0,0 +1,2 @@ +version=2 +http://samba.org/ftp/ccache/ccache-(.*)\.tar\.gz From 5236ddf57cef7f81043d2ea10a7c729be6ff8d3c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 3 Nov 2008 13:59:23 +0000 Subject: [PATCH 0148/1680] apply debian/patches/01_no_home.diff git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10903 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CCache/ccache.c | 27 +++++++++++++++++++++++++-- CCache/util.c | 2 +- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/CCache/ccache.c b/CCache/ccache.c index c15ced54f..e7272d5f7 100644 --- a/CCache/ccache.c +++ b/CCache/ccache.c @@ -836,6 +836,13 @@ static void ccache(int argc, char *argv[]) { /* find the real compiler */ find_compiler(argc, argv); + + /* use the real compiler if HOME is not set */ + if (!cache_dir) { + cc_log("Unable to determine home directory\n"); + cc_log("ccache is disabled\n"); + failed(); + } /* we might be disabled */ if (getenv("CCACHE_DISABLE")) { @@ -895,6 +902,13 @@ static void usage(void) printf("-V print version number\n"); } +static void check_cache_dir(void) +{ + if (!cache_dir) { + fatal("Unable to determine home directory"); + } +} + /* the main program when not doing a compile */ static int ccache_main(int argc, char *argv[]) { @@ -914,31 +928,37 @@ static int ccache_main(int argc, char *argv[]) exit(0); case 's': + check_cache_dir(); stats_summary(); break; case 'c': + check_cache_dir(); cleanup_all(cache_dir); printf("Cleaned cache\n"); break; case 'C': + check_cache_dir(); wipe_all(cache_dir); printf("Cleared cache\n"); break; case 'z': + check_cache_dir(); stats_zero(); printf("Statistics cleared\n"); break; case 'F': + check_cache_dir(); v = atoi(optarg); stats_set_limits(v, -1); printf("Set cache file limit to %u\n", (unsigned)v); break; case 'M': + check_cache_dir(); v = value_units(optarg); stats_set_limits(-1, v); printf("Set cache size limit to %uk\n", (unsigned)v); @@ -983,7 +1003,10 @@ int main(int argc, char *argv[]) cache_dir = getenv("CCACHE_DIR"); if (!cache_dir) { - x_asprintf(&cache_dir, "%s/.ccache", get_home_directory()); + const char *home_directory = get_home_directory(); + if (home_directory) { + x_asprintf(&cache_dir, "%s/.ccache", home_directory); + } } temp_dir = getenv("CCACHE_TEMPDIR"); @@ -1023,7 +1046,7 @@ int main(int argc, char *argv[]) } /* make sure the cache dir exists */ - if (create_dir(cache_dir) != 0) { + if (cache_dir && (create_dir(cache_dir) != 0)) { fprintf(stderr,"ccache: failed to create %s (%s)\n", cache_dir, strerror(errno)); exit(1); diff --git a/CCache/util.c b/CCache/util.c index ec5ccdd49..962dd49b6 100644 --- a/CCache/util.c +++ b/CCache/util.c @@ -448,7 +448,7 @@ const char *get_home_directory(void) } } #endif - fatal("Unable to determine home directory"); + cc_log("Unable to determine home directory"); return NULL; } From 72caf5920fc9d7248664ce2c375493b542f8428d Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 3 Nov 2008 14:02:32 +0000 Subject: [PATCH 0149/1680] apply debian/patches/02_ccache-compressed.diff git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10904 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CCache/Makefile.in | 3 +- CCache/ccache.1 | 16 ++- CCache/ccache.c | 29 ++++- CCache/ccache.h | 13 ++ CCache/ccache.yo | 18 ++- CCache/config.h.in | 3 + CCache/configure | 298 ++++++++++++++++++++++++++++++++++++++++---- CCache/configure.in | 9 ++ CCache/util.c | 174 ++++++++++++++++++++++++++ 9 files changed, 529 insertions(+), 34 deletions(-) diff --git a/CCache/Makefile.in b/CCache/Makefile.in index 0bf3eb99d..e32ebe53a 100644 --- a/CCache/Makefile.in +++ b/CCache/Makefile.in @@ -11,6 +11,7 @@ CC=@CC@ CFLAGS=@CFLAGS@ -I. EXEEXT=@EXEEXT@ +LIBS= @LIBS@ OBJS= ccache.o mdfour.o hash.o execute.o util.o args.o stats.o \ cleanup.o snprintf.o unify.o HEADERS = ccache.h mdfour.h @@ -20,7 +21,7 @@ all: ccache$(EXEEXT) docs: ccache.1 web/ccache-man.html ccache$(EXEEXT): $(OBJS) $(HEADERS) - $(CC) $(CFLAGS) -o $@ $(OBJS) + $(CC) $(CFLAGS) -o $@ $(OBJS) $(LIBS) ccache.1: ccache.yo -yodl2man -o ccache.1 ccache.yo diff --git a/CCache/ccache.1 b/CCache/ccache.1 index daec8ee1e..9d1cbcdf9 100644 --- a/CCache/ccache.1 +++ b/CCache/ccache.1 @@ -210,7 +210,8 @@ If you set the environment variable CCACHE_HARDLINK then ccache will attempt to use hard links from the cache directory when creating the compiler output rather than using a file copy\&. Using hard links is faster, but can confuse programs like -\&'make\&' that rely on modification times\&. +\&'make\&' that rely on modification times\&. Hard links are never made for +compressed cache files\&. .IP .IP "\fBCCACHE_RECACHE\fP" This forces ccache to not use any cached @@ -257,6 +258,11 @@ systems like this you can use the CCACHE_EXTENSION option to override the default\&. On HP-UX set this environment variable to "i" if you use the aCC compiler\&. .IP +.IP "\fBCCACHE_NOCOMPRESS\fP" +If you set the environment variable +CCACHE_NOCOMPRESS then there is no compression used on files that go +into the cache\&. +.IP .PP .SH "CACHE SIZE MANAGEMENT" .PP @@ -269,6 +275,14 @@ When these limits are reached ccache will reduce the cache to 20% below the numbers you specified in order to avoid doing the cache clean operation too often\&. .PP +.SH "CACHE COMPRESSION" +.PP +By default ccache will compress all files it puts into the cache +using the zlib compression\&. While this involves a negligible +performance slowdown, it significantly increases the number of files +that fit in the cache\&. You can turn off compression setting the +CCACHE_NOCOMPRESS environment variable\&. +.PP .SH "HOW IT WORKS" .PP The basic idea is to detect when you are compiling exactly the same diff --git a/CCache/ccache.c b/CCache/ccache.c index e7272d5f7..f6be1bc02 100644 --- a/CCache/ccache.c +++ b/CCache/ccache.c @@ -199,7 +199,7 @@ static void to_cache(ARGS *args) fd = open(tmp_stderr, O_RDONLY | O_BINARY); if (fd != -1) { if (strcmp(output_file, "/dev/null") == 0 || - rename(tmp_hashname, output_file) == 0 || errno == ENOENT) { + move_file(tmp_hashname, output_file) == 0 || errno == ENOENT) { if (cpp_stderr) { /* we might have some stderr from cpp */ int fd2 = open(cpp_stderr, O_RDONLY | O_BINARY); @@ -231,14 +231,25 @@ static void to_cache(ARGS *args) x_asprintf(&path_stderr, "%s.stderr", hashname); if (stat(tmp_stderr, &st1) != 0 || - stat(tmp_hashname, &st2) != 0 || - rename(tmp_hashname, hashname) != 0 || - rename(tmp_stderr, path_stderr) != 0) { + stat(tmp_hashname, &st2) != 0 || + move_file(tmp_hashname, hashname) != 0 || + move_file(tmp_stderr, path_stderr) != 0) { cc_log("failed to rename tmp files - %s\n", strerror(errno)); stats_update(STATS_ERROR); failed(); } +#if ENABLE_ZLIB + /* do an extra stat on the cache files for + the size statistics */ + if (stat(path_stderr, &st1) != 0 || + stat(hashname, &st2) != 0) { + cc_log("failed to stat cache files - %s\n", strerror(errno)); + stats_update(STATS_ERROR); + failed(); + } +#endif + cc_log("Placed %s into cache\n", output_file); stats_tocache(file_size(&st1) + file_size(&st2)); @@ -474,7 +485,13 @@ static void from_cache(int first) } /* the user might be disabling cache hits */ +#ifndef ENABLE_ZLIB + /* if the cache file is compressed we must recache */ + if ((first && getenv("CCACHE_RECACHE")) || + test_if_compressed(hashname) == 1) { +#else if (first && getenv("CCACHE_RECACHE")) { +#endif close(fd_stderr); unlink(stderr_file); free(stderr_file); @@ -487,7 +504,9 @@ static void from_cache(int first) ret = 0; } else { unlink(output_file); - if (getenv("CCACHE_HARDLINK")) { + /* only make a hardlink if the cache file is uncompressed */ + if (getenv("CCACHE_HARDLINK") && + test_if_compressed(hashname) == 0) { ret = link(hashname, output_file); } else { ret = copy_file(hashname, output_file); diff --git a/CCache/ccache.h b/CCache/ccache.h index faec5979d..67904cdf7 100644 --- a/CCache/ccache.h +++ b/CCache/ccache.h @@ -23,6 +23,10 @@ #include #endif +#ifdef ENABLE_ZLIB +#include +#endif + #define STATUS_NOTFOUND 3 #define STATUS_FATAL 4 #define STATUS_NOCACHE 5 @@ -36,6 +40,13 @@ #define DEFAULT_MAXSIZE (1000*1000) #endif +/* file copy mode */ +#ifdef ENABLE_ZLIB +#define COPY_UNCOMPRESSED 0 +#define COPY_FROM_CACHE 1 +#define COPY_TO_CACHE 2 +#endif + enum stats { STATS_NONE=0, STATS_STDOUT, @@ -79,6 +90,8 @@ void fatal(const char *msg); void copy_fd(int fd_in, int fd_out); int copy_file(const char *src, const char *dest); +int move_file(const char *src, const char *dest); +int test_if_compressed(const char *filename); int create_dir(const char *dir); void x_asprintf(char **ptr, const char *format, ...); diff --git a/CCache/ccache.yo b/CCache/ccache.yo index 12e45a6fb..311bead43 100644 --- a/CCache/ccache.yo +++ b/CCache/ccache.yo @@ -169,6 +169,11 @@ will have problems with the intermediate filename extensions used in this optimisation, in which case this option could allow ccache to be used. +dit(bf(CCACHE_NOCOMPRESS)) If you set the environment variable +CCACHE_NOCOMPRESS then there is no compression used on files that go +into the cache. However, this setting has no effect on how files are +retrieved from the cache, compressed results will still be usable. + dit(bf(CCACHE_NOSTATS)) If you set the environment variable CCACHE_NOSTATS then ccache will not update the statistics files on each compile. @@ -181,7 +186,8 @@ dit(bf(CCACHE_HARDLINK)) If you set the environment variable CCACHE_HARDLINK then ccache will attempt to use hard links from the cache directory when creating the compiler output rather than using a file copy. Using hard links is faster, but can confuse programs like -'make' that rely on modification times. +'make' that rely on modification times. Hard links are never made for +compressed cache files. dit(bf(CCACHE_RECACHE)) This forces ccache to not use any cached results, even if it finds them. New results are still cached, but @@ -236,6 +242,14 @@ When these limits are reached ccache will reduce the cache to 20% below the numbers you specified in order to avoid doing the cache clean operation too often. +manpagesection(CACHE COMPRESSION) + +By default ccache will compress all files it puts into the cache +using the zlib compression. While this involves a negligible +performance slowdown, it significantly increases the number of files +that fit in the cache. You can turn off compression setting the +CCACHE_NOCOMPRESS environment variable. + manpagesection(HOW IT WORKS) The basic idea is to detect when you are compiling exactly the same @@ -294,6 +308,8 @@ itemize( cache. This tells the filesystem to inherit group ownership for new directories. The command "chmod g+s `find $CCACHE_DIR -type d`" might be useful for this. + it() Set bf(CCACHE_NOCOMPRESS) for all users, if there are users with + versions of ccache that do not support compression. ) manpagesection(HISTORY) diff --git a/CCache/config.h.in b/CCache/config.h.in index 286f0385c..306884521 100644 --- a/CCache/config.h.in +++ b/CCache/config.h.in @@ -98,3 +98,6 @@ /* Define _GNU_SOURCE so that we get all necessary prototypes */ #undef _GNU_SOURCE + +/* Define to 1 if you like to have zlib compression for the ccache. */ +#undef ENABLE_ZLIB diff --git a/CCache/configure b/CCache/configure index 227567798..c96e3ee78 100755 --- a/CCache/configure +++ b/CCache/configure @@ -836,6 +836,11 @@ if test -n "$ac_init_help"; then cat <<\_ACEOF +Optional Features: + --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) + --enable-FEATURE[=ARG] include FEATURE [ARG=yes] + --enable-zlib enable zlib support for ccache compression + Some influential environment variables: CC C compiler command CFLAGS C compiler flags @@ -936,7 +941,7 @@ esac else echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi - cd "$ac_popdir" + cd $ac_popdir done fi @@ -1859,7 +1864,8 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -1917,7 +1923,8 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -2033,7 +2040,8 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -2087,7 +2095,8 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -2132,7 +2141,8 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -2176,7 +2186,8 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -2609,7 +2620,8 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -2681,7 +2693,8 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -2735,7 +2748,8 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -2806,7 +2820,8 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -2860,7 +2875,8 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -2927,7 +2943,8 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -2997,7 +3014,8 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -3078,7 +3096,8 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -3248,7 +3267,8 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -3319,7 +3339,8 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -3509,7 +3530,8 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -3611,7 +3633,8 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -3676,7 +3699,8 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -3773,6 +3797,229 @@ cat >>confdefs.h <<\_ACEOF #define HAVE_C99_VSNPRINTF 1 _ACEOF +fi + +# Check whether --enable-zlib or --disable-zlib was given. +if test "${enable_zlib+set}" = set; then + enableval="$enable_zlib" + +else + enable_zlib=yes +fi; + +if test x"$enable_zlib" = x"yes"; then + if test "${ac_cv_header_zlib_h+set}" = set; then + echo "$as_me:$LINENO: checking for zlib.h" >&5 +echo $ECHO_N "checking for zlib.h... $ECHO_C" >&6 +if test "${ac_cv_header_zlib_h+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +echo "$as_me:$LINENO: result: $ac_cv_header_zlib_h" >&5 +echo "${ECHO_T}$ac_cv_header_zlib_h" >&6 +else + # Is the header compilable? +echo "$as_me:$LINENO: checking zlib.h usability" >&5 +echo $ECHO_N "checking zlib.h usability... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_header_compiler=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6 + +# Is the header present? +echo "$as_me:$LINENO: checking zlib.h presence" >&5 +echo $ECHO_N "checking zlib.h presence... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi +rm -f conftest.err conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6 + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { echo "$as_me:$LINENO: WARNING: zlib.h: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: zlib.h: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: zlib.h: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: zlib.h: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:$LINENO: WARNING: zlib.h: present but cannot be compiled" >&5 +echo "$as_me: WARNING: zlib.h: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: zlib.h: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: zlib.h: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: zlib.h: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: zlib.h: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: zlib.h: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: zlib.h: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: zlib.h: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: zlib.h: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: zlib.h: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: zlib.h: in the future, the compiler will take precedence" >&2;} + ( + cat <<\_ASBOX +## ------------------------------------------ ## +## Report this to the AC_PACKAGE_NAME lists. ## +## ------------------------------------------ ## +_ASBOX + ) | + sed "s/^/$as_me: WARNING: /" >&2 + ;; +esac +echo "$as_me:$LINENO: checking for zlib.h" >&5 +echo $ECHO_N "checking for zlib.h... $ECHO_C" >&6 +if test "${ac_cv_header_zlib_h+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_header_zlib_h=$ac_header_preproc +fi +echo "$as_me:$LINENO: result: $ac_cv_header_zlib_h" >&5 +echo "${ECHO_T}$ac_cv_header_zlib_h" >&6 + +fi +if test $ac_cv_header_zlib_h = yes; then + echo "$as_me:$LINENO: checking for gzdopen in -lz" >&5 +echo $ECHO_N "checking for gzdopen in -lz... $ECHO_C" >&6 +if test "${ac_cv_lib_z_gzdopen+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lz $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char gzdopen (); +int +main () +{ +gzdopen (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_z_gzdopen=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lib_z_gzdopen=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_z_gzdopen" >&5 +echo "${ECHO_T}$ac_cv_lib_z_gzdopen" >&6 +if test $ac_cv_lib_z_gzdopen = yes; then + LIBS="-lz $LIBS"; cat >>confdefs.h <<\_ACEOF +#define ENABLE_ZLIB 1 +_ACEOF + +fi + +fi + + fi ac_config_files="$ac_config_files Makefile" @@ -4568,6 +4815,11 @@ esac *) ac_INSTALL=$ac_top_builddir$INSTALL ;; esac + if test x"$ac_file" != x-; then + { echo "$as_me:$LINENO: creating $ac_file" >&5 +echo "$as_me: creating $ac_file" >&6;} + rm -f "$ac_file" + fi # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ @@ -4606,12 +4858,6 @@ echo "$as_me: error: cannot find input file: $f" >&2;} fi;; esac done` || { (exit 1); exit 1; } - - if test x"$ac_file" != x-; then - { echo "$as_me:$LINENO: creating $ac_file" >&5 -echo "$as_me: creating $ac_file" >&6;} - rm -f "$ac_file" - fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF sed "$ac_vpsub diff --git a/CCache/configure.in b/CCache/configure.in index 3229ef0b7..be77bbf6a 100644 --- a/CCache/configure.in +++ b/CCache/configure.in @@ -68,5 +68,14 @@ if test x"$ccache_cv_HAVE_C99_VSNPRINTF" = x"yes"; then AC_DEFINE(HAVE_C99_VSNPRINTF, 1, [ ]) fi +dnl Check for zlib. +AC_ARG_ENABLE([zlib], + AS_HELP_STRING([--enable-zlib], [enable zlib support for ccache compression]),, + [enable_zlib=yes]) + +if test x"$enable_zlib" = x"yes"; then + AC_CHECK_HEADER(zlib.h, AC_CHECK_LIB(z, gzdopen, LIBS="-lz $LIBS"; AC_DEFINE(ENABLE_ZLIB))) +fi + AC_CONFIG_FILES([Makefile]) AC_OUTPUT diff --git a/CCache/util.c b/CCache/util.c index 962dd49b6..a6b88997c 100644 --- a/CCache/util.c +++ b/CCache/util.c @@ -44,6 +44,7 @@ void fatal(const char *msg) exit(1); } +#ifndef ENABLE_ZLIB /* copy all data from one file descriptor to another */ void copy_fd(int fd_in, int fd_out) { @@ -57,6 +58,11 @@ void copy_fd(int fd_in, int fd_out) } } +/* move a file using rename */ +int move_file(const char *src, const char *dest) { + return rename(src, dest); +} + /* copy a file - used when hard links don't work the copy is done via a temporary file and atomic rename */ @@ -120,6 +126,174 @@ int copy_file(const char *src, const char *dest) return 0; } +#else /* ENABLE_ZLIB */ + +/* copy all data from one file descriptor to another + possibly decompressing it +*/ +void copy_fd(int fd_in, int fd_out) { + char buf[10240]; + int n; + gzFile gz_in; + + gz_in = gzdopen(dup(fd_in), "rb"); + + if (!gz_in) { + fatal("Failed to copy fd"); + } + + while ((n = gzread(gz_in, buf, sizeof(buf))) > 0) { + if (write(fd_out, buf, n) != n) { + fatal("Failed to copy fd"); + } + } +} + +static int _copy_file(const char *src, const char *dest, int mode) { + int fd_in, fd_out; + gzFile gz_in, gz_out = NULL; + char buf[10240]; + int n, ret; + char *tmp_name; + mode_t mask; + struct stat st; + + x_asprintf(&tmp_name, "%s.XXXXXX", dest); + + if (getenv("CCACHE_NOCOMPRESS")) { + mode = COPY_UNCOMPRESSED; + } + + /* open source file */ + fd_in = open(src, O_RDONLY); + if (fd_in == -1) { + return -1; + } + + gz_in = gzdopen(fd_in, "rb"); + if (!gz_in) { + close(fd_in); + return -1; + } + + /* open destination file */ + fd_out = mkstemp(tmp_name); + if (fd_out == -1) { + gzclose(gz_in); + free(tmp_name); + return -1; + } + + if (mode == COPY_TO_CACHE) { + /* The gzip file format occupies at least 20 bytes. So + it will always occupy an entire filesystem block, + even for empty files. + Since most stderr files will be empty, we turn off + compression in this case to save space. + */ + if (fstat(fd_in, &st) != 0) { + gzclose(gz_in); + close(fd_out); + free(tmp_name); + return -1; + } + if (file_size(&st) == 0) { + mode = COPY_UNCOMPRESSED; + } + } + + if (mode == COPY_TO_CACHE) { + gz_out = gzdopen(dup(fd_out), "wb"); + if (!gz_out) { + gzclose(gz_in); + close(fd_out); + free(tmp_name); + return -1; + } + } + + while ((n = gzread(gz_in, buf, sizeof(buf))) > 0) { + if (mode == COPY_TO_CACHE) { + ret = gzwrite(gz_out, buf, n); + } else { + ret = write(fd_out, buf, n); + } + if (ret != n) { + gzclose(gz_in); + if (gz_out) { + gzclose(gz_out); + } + close(fd_out); + unlink(tmp_name); + free(tmp_name); + return -1; + } + } + + gzclose(gz_in); + if (gz_out) { + gzclose(gz_out); + } + + /* get perms right on the tmp file */ + mask = umask(0); + fchmod(fd_out, 0666 & ~mask); + umask(mask); + + /* the close can fail on NFS if out of space */ + if (close(fd_out) == -1) { + unlink(tmp_name); + free(tmp_name); + return -1; + } + + unlink(dest); + + if (rename(tmp_name, dest) == -1) { + unlink(tmp_name); + free(tmp_name); + return -1; + } + + free(tmp_name); + + return 0; +} + +/* move a file to the cache, compressing it */ +int move_file(const char *src, const char *dest) { + int ret; + + ret = _copy_file(src, dest, COPY_TO_CACHE); + if (ret != -1) unlink(src); + return ret; +} + +/* copy a file from the cache, decompressing it */ +int copy_file(const char *src, const char *dest) { + return _copy_file(src, dest, COPY_FROM_CACHE); +} +#endif /* ENABLE_ZLIB */ + +/* test if a file is zlib compressed */ +int test_if_compressed(const char *filename) { + FILE *f; + + f = fopen(filename, "rb"); + if (!f) { + return 0; + } + + /* test if file starts with 1F8B, which is zlib's + * magic number */ + if ((fgetc(f) != 0x1f) || (fgetc(f) != 0x8b)) { + fclose(f); + return 0; + } + + fclose(f); + return 1; +} /* make sure a directory exists */ int create_dir(const char *dir) From 05ec950cc2cb76b5f8dd8c53c6ba9c4ca8b70431 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 3 Nov 2008 14:02:57 +0000 Subject: [PATCH 0150/1680] apply debian/patches/04_ignore_profile.diff git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10905 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CCache/ccache.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CCache/ccache.c b/CCache/ccache.c index f6be1bc02..877e13945 100644 --- a/CCache/ccache.c +++ b/CCache/ccache.c @@ -659,6 +659,9 @@ static void process_args(int argc, char **argv) /* these are too hard */ if (strcmp(argv[i], "-fbranch-probabilities")==0 || + strcmp(argv[i], "-fprofile-arcs") == 0 || + strcmp(argv[i], "-ftest-coverage") == 0 || + strcmp(argv[i], "--coverage") == 0 || strcmp(argv[i], "-M") == 0 || strcmp(argv[i], "-MM") == 0 || strcmp(argv[i], "-x") == 0) { From 55246d6c1cc70e10c6f80b4880bd2cced68aa1dd Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 3 Nov 2008 14:03:21 +0000 Subject: [PATCH 0151/1680] apply debian/patches/05_nfs_fix.diff git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10906 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CCache/ccache.1 | 6 ------ CCache/util.c | 19 ++++++++++++++++++- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/CCache/ccache.1 b/CCache/ccache.1 index 9d1cbcdf9..daf3323f9 100644 --- a/CCache/ccache.1 +++ b/CCache/ccache.1 @@ -381,12 +381,6 @@ ccache can handle a much wider ranger of compiler options .IP o ccache avoids a double call to cpp on a cache miss .PP -.SH "BUGS" -.PP -When the cache is stored on an NFS filesystem, the filesystem must be -exported with the \fBno_subtree_check\fP option to make renames between -directories reliable\&. -.PP .SH "CREDITS" .PP Thanks to the following people for their contributions to ccache diff --git a/CCache/util.c b/CCache/util.c index a6b88997c..70d7ea7d4 100644 --- a/CCache/util.c +++ b/CCache/util.c @@ -58,9 +58,26 @@ void copy_fd(int fd_in, int fd_out) } } +static int safe_rename(const char* oldpath, const char* newpath) +{ + /* safe_rename is for creating entries in the cache. + + Works like rename(), but it never overwrites an existing + cache entry. This avoids corruption on NFS. */ + int status = link( oldpath, newpath ); + if( status == 0 || errno == EEXIST ) + { + return unlink( oldpath ); + } + else + { + return -1; + } +} + /* move a file using rename */ int move_file(const char *src, const char *dest) { - return rename(src, dest); + return safe_rename(src, dest); } /* copy a file - used when hard links don't work From 6f3603a05a351eaaef4e3496e2faa6302e71ee0f Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 3 Nov 2008 14:03:52 +0000 Subject: [PATCH 0152/1680] apply debian/patches/06_md.diff git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10907 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CCache/ccache.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/CCache/ccache.c b/CCache/ccache.c index 877e13945..3a4e8c7b2 100644 --- a/CCache/ccache.c +++ b/CCache/ccache.c @@ -646,6 +646,13 @@ static void process_args(int argc, char **argv) int found_S_opt = 0; struct stat st; char *e; + /* is gcc being asked to output dependencies? */ + int generating_dependencies = 0; + /* is the dependency makefile name overridden with -MF? */ + int dependency_filename_specified = 0; + /* is the dependency makefile target name specified with -MQ or -MF? */ + int dependency_target_specified = 0; + stripped_args = args_init(0, NULL); @@ -724,6 +731,18 @@ static void process_args(int argc, char **argv) continue; } + /* These options require special handling, because they + behave differently with gcc -E, when the output + file is not specified. */ + + if (strcmp(argv[i], "-MD") == 0 || strcmp(argv[i], "-MMD") == 0) { + generating_dependencies = 1; + } else if (strcmp(argv[i], "-MF") == 0) { + dependency_filename_specified = 1; + } else if (strcmp(argv[i], "-MQ") == 0 || strcmp(argv[i], "-MT") == 0) { + dependency_target_specified = 1; + } + /* options that take an argument */ { const char *opts[] = {"-I", "-include", "-imacros", "-iprefix", @@ -836,6 +855,41 @@ static void process_args(int argc, char **argv) p[2] = 0; } + /* If dependencies are generated, configure the preprocessor */ + + if (generating_dependencies && output_file) { + if (!dependency_filename_specified) { + char *default_depfile_name = x_strdup(output_file); + char *p = strrchr(default_depfile_name, '.'); + + if (p) { + if (strlen(p) < 2) { + stats_update(STATS_ARGS); + failed(); + return; + } + *p = 0; + } + else { + int len = p - default_depfile_name; + + p = x_malloc(len + 3); + strncpy(default_depfile_name, p, len - 1); + free(default_depfile_name); + default_depfile_name = p; + } + + strcat(default_depfile_name, ".d"); + args_add(stripped_args, "-MF"); + args_add(stripped_args, default_depfile_name); + } + + if (!dependency_target_specified) { + args_add(stripped_args, "-MT"); + args_add(stripped_args, output_file); + } + } + /* cope with -o /dev/null */ if (strcmp(output_file,"/dev/null") != 0 && stat(output_file, &st) == 0 && !S_ISREG(st.st_mode)) { cc_log("Not a regular file %s\n", output_file); From 0c20caeddcf70d6faf303c3f15ad0b428ae94de9 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 3 Nov 2008 14:04:15 +0000 Subject: [PATCH 0153/1680] apply debian/patches/07_cachedirtag.diff git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10908 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CCache/ccache.c | 8 ++++++++ CCache/ccache.h | 1 + CCache/util.c | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+) diff --git a/CCache/ccache.c b/CCache/ccache.c index 3a4e8c7b2..222fbe70f 100644 --- a/CCache/ccache.c +++ b/CCache/ccache.c @@ -1128,6 +1128,14 @@ int main(int argc, char *argv[]) exit(1); } + if (!getenv("CCACHE_READONLY")) { + if (create_cachedirtag(cache_dir) != 0) { + fprintf(stderr,"ccache: failed to create %s/CACHEDIR.TAG (%s)\n", + cache_dir, strerror(errno)); + exit(1); + } + } + ccache(argc, argv); return 1; } diff --git a/CCache/ccache.h b/CCache/ccache.h index 67904cdf7..71b03ffe9 100644 --- a/CCache/ccache.h +++ b/CCache/ccache.h @@ -94,6 +94,7 @@ int move_file(const char *src, const char *dest); int test_if_compressed(const char *filename); int create_dir(const char *dir); +int create_cachedirtag(const char *dir); void x_asprintf(char **ptr, const char *format, ...); char *x_strdup(const char *s); void *x_realloc(void *ptr, size_t size); diff --git a/CCache/util.c b/CCache/util.c index 70d7ea7d4..6056d36f7 100644 --- a/CCache/util.c +++ b/CCache/util.c @@ -329,6 +329,39 @@ int create_dir(const char *dir) return 0; } +char const CACHEDIR_TAG[] = + "Signature: 8a477f597d28d172789f06886806bc55\n" + "# This file is a cache directory tag created by ccache.\n" + "# For information about cache directory tags, see:\n" + "# http://www.brynosaurus.com/cachedir/\n"; + +int create_cachedirtag(const char *dir) +{ + char *filename; + struct stat st; + FILE *f; + x_asprintf(&filename, "%s/CACHEDIR.TAG", dir); + if (stat(filename, &st) == 0) { + if (S_ISREG(st.st_mode)) { + goto success; + } + errno = EEXIST; + goto error; + } + f = fopen(filename, "w"); + if (!f) goto error; + if (fwrite(CACHEDIR_TAG, sizeof(CACHEDIR_TAG)-1, 1, f) != 1) { + goto error; + } + if (fclose(f)) goto error; +success: + free(filename); + return 0; +error: + free(filename); + return 1; +} + /* this is like asprintf() but dies if the malloc fails note that we use vsnprintf in a rather poor way to make this more portable From d4d8ca71b425b52f8078902b63e5c659e987a442 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 3 Nov 2008 14:04:47 +0000 Subject: [PATCH 0154/1680] apply debian/patches/08_manpage_hyphens.diff git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10909 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CCache/ccache.1 | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/CCache/ccache.1 b/CCache/ccache.1 index daf3323f9..186bb6525 100644 --- a/CCache/ccache.1 +++ b/CCache/ccache.1 @@ -49,7 +49,7 @@ Print a options summary page .IP "\fB-s\fP" Print the current statistics summary for the cache\&. The statistics are stored spread across the subdirectories of the -cache\&. Using "ccache -s" adds up the statistics across all +cache\&. Using "ccache \-s" adds up the statistics across all subdirectories and prints the totals\&. .IP .IP "\fB-z\fP" @@ -60,7 +60,7 @@ Print the ccache version number .IP .IP "\fB-c\fP" Clean the cache and re-calculate the cache file count and -size totals\&. Normally the -c option should not be necessary as ccache +size totals\&. Normally the \-c option should not be necessary as ccache keeps the cache below the specified limits at runtime and keeps statistics up to date on each compile\&. This option is mostly useful if you manually modify the cache contents or believe that the cache @@ -100,9 +100,9 @@ To install for the second method do something like this: cp ccache /usr/local/bin/ - ln -s /usr/local/bin/ccache /usr/local/bin/gcc - ln -s /usr/local/bin/ccache /usr/local/bin/g++ - ln -s /usr/local/bin/ccache /usr/local/bin/cc + ln \-s /usr/local/bin/ccache /usr/local/bin/gcc + ln \-s /usr/local/bin/ccache /usr/local/bin/g++ + ln \-s /usr/local/bin/ccache /usr/local/bin/cc .fi @@ -118,7 +118,7 @@ cause "interesting" problems\&. .PP When run as a compiler front end ccache usually just takes the same command line options as the compiler you are using\&. The only exception -to this is the option \&'--ccache-skip\&'\&. That option can be used to tell +to this is the option \&'\-\-ccache-skip\&'\&. That option can be used to tell ccache that the next option is definitely not a input filename, and should be passed along to the compiler as-is\&. .PP @@ -128,7 +128,7 @@ compiler option, as it needs the input filename to determine the name of the resulting object file (among other things)\&. The heuristic ccache uses in this parse is that any string on the command line that exists as a file is treated as an input file name (usually a C -file)\&. By using --ccache-skip you can force an option to not be +file)\&. By using \-\-ccache-skip you can force an option to not be treated as an input file name and instead be passed along to the compiler as a command line option\&. .PP @@ -239,7 +239,7 @@ this option\&. .IP "\fBCCACHE_UNIFY\fP" If you set the environment variable CCACHE_UNIFY then ccache will use the C/C++ unifier when hashing the pre-processor -output if -g is not used in the compile\&. The unifier is slower than a +output if \-g is not used in the compile\&. The unifier is slower than a normal hash, so setting this environment variable loses a little bit of speed, but it means that ccache can take advantage of not recompiling when the changes to the source code consist of @@ -268,7 +268,7 @@ into the cache\&. .PP By default ccache has a one gigabyte limit on the cache size and no maximum number of files\&. You can set a different limit using the -"ccache -M" and "ccache -F" options, which set the size and number of +"ccache \-M" and "ccache \-F" options, which set the size and number of files limits\&. .PP When these limits are reached ccache will reduce the cache to 20% @@ -290,7 +290,7 @@ code a 2nd time and use the previously compiled output\&. You detect that it is the same code by forming a hash of: .PP .IP o -the pre-processor output from running the compiler with -E +the pre-processor output from running the compiler with \-E .IP o the command line options .IP o @@ -345,7 +345,7 @@ cache directory (and that you trust all users of the shared cache)\&. .IP o Make sure that the setgid bit is set on all directories in the cache\&. This tells the filesystem to inherit group ownership for new -directories\&. The command "chmod g+s `find $CCACHE_DIR -type d`" might +directories\&. The command "chmod g+s `find $CCACHE_DIR \-type d`" might be useful for this\&. .PP .SH "HISTORY" From 82faf3c7d75d241f8998914e3ada4e0a247c6c30 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 3 Nov 2008 14:05:12 +0000 Subject: [PATCH 0155/1680] apply debian/patches/09_respect_ldflags.diff git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10910 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 e32ebe53a..438ec19f5 100644 --- a/CCache/Makefile.in +++ b/CCache/Makefile.in @@ -21,7 +21,7 @@ all: ccache$(EXEEXT) docs: ccache.1 web/ccache-man.html ccache$(EXEEXT): $(OBJS) $(HEADERS) - $(CC) $(CFLAGS) -o $@ $(OBJS) $(LIBS) + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) ccache.1: ccache.yo -yodl2man -o ccache.1 ccache.yo From 7ba7198c28ca20888fdd177878bdb164cd0a3994 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 3 Nov 2008 14:06:06 +0000 Subject: [PATCH 0156/1680] apply debian/patches/10_lru_cleanup.diff git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10911 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CCache/ccache.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/CCache/ccache.c b/CCache/ccache.c index 222fbe70f..55fbed16d 100644 --- a/CCache/ccache.c +++ b/CCache/ccache.c @@ -498,6 +498,9 @@ static void from_cache(int first) return; } + /* update timestamps for LRU cleanup + also gives output_file a sensible mtime when hard-linking (for make) */ + utime(hashname, NULL); utime(stderr_file, NULL); if (strcmp(output_file, "/dev/null") == 0) { @@ -532,10 +535,6 @@ static void from_cache(int first) failed(); } } - if (ret == 0) { - /* update the mtime on the file so that make doesn't get confused */ - utime(output_file, NULL); - } /* get rid of the intermediate preprocessor file */ if (i_tmpfile) { From ac1b517350c7a03ea7ac0e624a03087fa5c07b5b Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 3 Nov 2008 14:07:51 +0000 Subject: [PATCH 0157/1680] apply debian/patches/11_utimes.diff git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10912 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CCache/ccache.c | 5 +++++ CCache/ccache.h | 3 +++ CCache/config.h.in | 12 ++++++++++++ CCache/configure.in | 3 ++- 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/CCache/ccache.c b/CCache/ccache.c index 55fbed16d..4e3049d6c 100644 --- a/CCache/ccache.c +++ b/CCache/ccache.c @@ -500,8 +500,13 @@ static void from_cache(int first) /* update timestamps for LRU cleanup also gives output_file a sensible mtime when hard-linking (for make) */ +#ifdef HAVE_UTIMES + utimes(hashname, NULL); + utimes(stderr_file, NULL); +#else utime(hashname, NULL); utime(stderr_file, NULL); +#endif if (strcmp(output_file, "/dev/null") == 0) { ret = 0; diff --git a/CCache/ccache.h b/CCache/ccache.h index 71b03ffe9..8d3c93c34 100644 --- a/CCache/ccache.h +++ b/CCache/ccache.h @@ -22,6 +22,9 @@ #ifdef HAVE_PWD_H #include #endif +#ifdef HAVE_SYS_TIME_H +#include +#endif #ifdef ENABLE_ZLIB #include diff --git a/CCache/config.h.in b/CCache/config.h.in index 306884521..49ccd8325 100644 --- a/CCache/config.h.in +++ b/CCache/config.h.in @@ -19,6 +19,9 @@ /* Define to 1 if you have the `gethostname' function. */ #undef HAVE_GETHOSTNAME +/* Define to 1 if you have the `getpwuid' function. */ +#undef HAVE_GETPWUID + /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H @@ -31,6 +34,9 @@ /* Define to 1 if you have the header file, and it defines `DIR'. */ #undef HAVE_NDIR_H +/* Define to 1 if you have the header file. */ +#undef HAVE_PWD_H + /* Define to 1 if you have the `realpath' function. */ #undef HAVE_REALPATH @@ -60,6 +66,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STAT_H +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TIME_H + /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H @@ -69,6 +78,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H +/* Define to 1 if you have the `utimes' function. */ +#undef HAVE_UTIMES + /* Define to 1 if you have the `vasprintf' function. */ #undef HAVE_VASPRINTF diff --git a/CCache/configure.in b/CCache/configure.in index be77bbf6a..1ac94d3fd 100644 --- a/CCache/configure.in +++ b/CCache/configure.in @@ -27,10 +27,11 @@ AC_HEADER_DIRENT AC_HEADER_TIME AC_HEADER_SYS_WAIT -AC_CHECK_HEADERS(ctype.h strings.h stdlib.h string.h pwd.h) +AC_CHECK_HEADERS(ctype.h strings.h stdlib.h string.h pwd.h sys/time.h) AC_CHECK_FUNCS(realpath snprintf vsnprintf vasprintf asprintf mkstemp) AC_CHECK_FUNCS(gethostname getpwuid) +AC_CHECK_FUNCS(utimes) AC_CACHE_CHECK([for compar_fn_t in stdlib.h],ccache_cv_COMPAR_FN_T, [ AC_TRY_COMPILE( From 27e03f3f866a0e8653006511761ac95323d46301 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 3 Nov 2008 14:08:28 +0000 Subject: [PATCH 0158/1680] apply debian/patches/12_cachesize_permissions.diff git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10913 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CCache/ccache.c | 16 ++++++++++++---- CCache/ccache.h | 2 +- CCache/stats.c | 12 +++++++++--- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/CCache/ccache.c b/CCache/ccache.c index 4e3049d6c..e87c1516c 100644 --- a/CCache/ccache.c +++ b/CCache/ccache.c @@ -1033,15 +1033,23 @@ static int ccache_main(int argc, char *argv[]) case 'F': check_cache_dir(); v = atoi(optarg); - stats_set_limits(v, -1); - printf("Set cache file limit to %u\n", (unsigned)v); + if (stats_set_limits(v, -1) == 0) { + printf("Set cache file limit to %u\n", (unsigned)v); + } else { + printf("Could not set cache file limit.\n"); + exit(1); + } break; case 'M': check_cache_dir(); v = value_units(optarg); - stats_set_limits(-1, v); - printf("Set cache size limit to %uk\n", (unsigned)v); + if (stats_set_limits(-1, v) == 0) { + printf("Set cache size limit to %uk\n", (unsigned)v); + } else { + printf("Could not set cache size limit.\n"); + exit(1); + } break; default: diff --git a/CCache/ccache.h b/CCache/ccache.h index 8d3c93c34..bd67cbc67 100644 --- a/CCache/ccache.h +++ b/CCache/ccache.h @@ -118,7 +118,7 @@ void stats_zero(void); void stats_summary(void); void stats_tocache(size_t size); void stats_read(const char *stats_file, unsigned counters[STATS_END]); -void stats_set_limits(long maxfiles, long maxsize); +int stats_set_limits(long maxfiles, long maxsize); size_t value_units(const char *s); void display_size(unsigned v); void stats_set_sizes(const char *dir, size_t num_files, size_t total_size); diff --git a/CCache/stats.c b/CCache/stats.c index e5662fb26..ddaf768db 100644 --- a/CCache/stats.c +++ b/CCache/stats.c @@ -286,7 +286,7 @@ void stats_zero(void) /* set the per directory limits */ -void stats_set_limits(long maxfiles, long maxsize) +int stats_set_limits(long maxfiles, long maxsize) { int dir; unsigned counters[STATS_END]; @@ -298,7 +298,9 @@ void stats_set_limits(long maxfiles, long maxsize) maxsize /= 16; } - create_dir(cache_dir); + if (create_dir(cache_dir) != 0) { + return 1; + } /* set the limits in each directory */ for (dir=0;dir<=0xF;dir++) { @@ -306,7 +308,9 @@ void stats_set_limits(long maxfiles, long maxsize) int fd; x_asprintf(&cdir, "%s/%1x", cache_dir, dir); - create_dir(cdir); + if (create_dir(cdir) != 0) { + return 1; + } x_asprintf(&fname, "%s/stats", cdir); free(cdir); @@ -326,6 +330,8 @@ void stats_set_limits(long maxfiles, long maxsize) } free(fname); } + + return 0; } /* set the per directory sizes */ From 59988d94745de4e5940ffe9b516224d4a0191530 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 5 Nov 2008 12:34:15 +0000 Subject: [PATCH 0159/1680] initial modifications for ccache to support SWIG git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10915 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CCache/README.swig | 3 + CCache/ccache.c | 362 ++++++++++++++++++++++++++++++++------------- CCache/ccache.h | 11 +- CCache/execute.c | 18 +++ CCache/stats.c | 10 +- CCache/util.c | 122 ++++++++++++--- 6 files changed, 400 insertions(+), 126 deletions(-) create mode 100644 CCache/README.swig diff --git a/CCache/README.swig b/CCache/README.swig new file mode 100644 index 000000000..24bd4ff24 --- /dev/null +++ b/CCache/README.swig @@ -0,0 +1,3 @@ +This directory contains a version of ccache. The initial version was based on ccache-2.4 plus +debian patches 01-02, 04-12, see the debian/patches subdirectory. Changes have been made to +support cacheing the output from SWIG. The ability to cache c/c++ compiler output has been retained. diff --git a/CCache/ccache.c b/CCache/ccache.c index e87c1516c..b08c4cda1 100644 --- a/CCache/ccache.c +++ b/CCache/ccache.c @@ -23,6 +23,9 @@ #include "ccache.h" +/* verbose mode */ +int ccache_verbose = 0; + /* the base cache directory */ char *cache_dir = NULL; @@ -65,6 +68,9 @@ char *stats_file = NULL; /* can we safely use the unification hashing backend? */ static int enable_unify; +/* customisation for using the SWIG compiler */ +static int swig; + /* a list of supported file extensions, and the equivalent extension for code that has been through the pre-processor */ @@ -122,6 +128,14 @@ static void failed(void) args_add_prefix(orig_args, p); } + if (ccache_verbose) { + display_execute_args(orig_args->argv); + } + + if (swig) { + putenv("CCACHE_OUTFILES"); + } + execv(orig_args->argv[0], orig_args->argv); cc_log("execv returned (%s)!\n", strerror(errno)); perror(orig_args->argv[0]); @@ -149,21 +163,43 @@ static const char *tmp_string(void) return ret; } +/* update cached file sizes and count helper function for to_cache() */ +static void to_cache_stats_helper(struct stat *pstat, char *cached_filename, char *tmp_outfiles, int *files_size, int *cached_files_count) +{ +#if ENABLE_ZLIB + /* do an extra stat on the cache file for the size statistics */ + if (stat(cached_filename, pstat) != 0) { + cc_log("failed to stat cache files - %s\n", strerror(errno)); + stats_update(STATS_ERROR); + if (tmp_outfiles) { + unlink(tmp_outfiles); + } + failed(); + } +#endif + (*files_size) += file_size(pstat); + (*cached_files_count)++; +} /* run the real compiler and put the result in cache */ static void to_cache(ARGS *args) { char *path_stderr; - char *tmp_stdout, *tmp_stderr, *tmp_hashname; - struct stat st1, st2; + char *tmp_stdout, *tmp_stderr, *tmp_outfiles; + struct stat st1; int status; + int cached_files_count = 0; + int files_size = 0; x_asprintf(&tmp_stdout, "%s/tmp.stdout.%s", temp_dir, tmp_string()); x_asprintf(&tmp_stderr, "%s/tmp.stderr.%s", temp_dir, tmp_string()); - x_asprintf(&tmp_hashname, "%s/tmp.hash.%s.o", temp_dir, tmp_string()); + x_asprintf(&tmp_outfiles, "%s/tmp.outfiles.%s", temp_dir, tmp_string()); - args_add(args, "-o"); - args_add(args, tmp_hashname); + /* TODO swig */ + if (output_file) { + args_add(args, "-o"); + args_add(args, output_file); + } /* Turn off DEPENDENCIES_OUTPUT when running cc1, because * otherwise it will emit a line like @@ -172,90 +208,155 @@ static void to_cache(ARGS *args) * * unsetenv() is on BSD and Linux but not portable. */ putenv("DEPENDENCIES_OUTPUT"); + + /* Give SWIG a filename for it to create and populate with a list of files that it generates */ + if (swig) { + char *ccache_outfiles; + x_asprintf(&ccache_outfiles, "CCACHE_OUTFILES=%s", tmp_outfiles); + unlink(tmp_outfiles); + if (getenv("CCACHE_OUTFILES") || putenv(ccache_outfiles) == -1) { + stats_update(STATS_ERROR); + failed(); + } + } if (getenv("CCACHE_CPP2")) { args_add(args, input_file); } else { + if (swig) { + args_add(args, "-nopreprocess"); + } args_add(args, i_tmpfile); } status = execute(args->argv, tmp_stdout, tmp_stderr); args_pop(args, 3); if (stat(tmp_stdout, &st1) != 0 || st1.st_size != 0) { - cc_log("compiler produced stdout for %s\n", output_file); + cc_log("compiler produced stdout for %s\n", input_file); stats_update(STATS_STDOUT); unlink(tmp_stdout); unlink(tmp_stderr); - unlink(tmp_hashname); + unlink(tmp_outfiles); + if (!swig) unlink(output_file); failed(); } unlink(tmp_stdout); if (status != 0) { int fd; - cc_log("compile of %s gave status = %d\n", output_file, status); + cc_log("compile of %s gave status = %d\n", input_file, status); stats_update(STATS_STATUS); fd = open(tmp_stderr, O_RDONLY | O_BINARY); if (fd != -1) { - if (strcmp(output_file, "/dev/null") == 0 || - move_file(tmp_hashname, output_file) == 0 || errno == ENOENT) { - if (cpp_stderr) { - /* we might have some stderr from cpp */ - int fd2 = open(cpp_stderr, O_RDONLY | O_BINARY); - if (fd2 != -1) { - copy_fd(fd2, 2); - close(fd2); - unlink(cpp_stderr); - cpp_stderr = NULL; - } + if (cpp_stderr) { + /* we might have some stderr from cpp */ + int fd2 = open(cpp_stderr, O_RDONLY | O_BINARY); + if (fd2 != -1) { + copy_fd(fd2, 2); + close(fd2); + unlink(cpp_stderr); + cpp_stderr = NULL; } - - /* we can use a quick method of - getting the failed output */ - copy_fd(fd, 2); - close(fd); - unlink(tmp_stderr); - if (i_tmpfile && !direct_i_file) { - unlink(i_tmpfile); - } - exit(status); } + + /* we can use a quick method of + getting the failed output */ + copy_fd(fd, 2); + close(fd); + unlink(tmp_stderr); + if (i_tmpfile && !direct_i_file) { + unlink(i_tmpfile); + } + exit(status); } unlink(tmp_stderr); - unlink(tmp_hashname); + unlink(tmp_outfiles); + if (!swig) unlink(output_file); failed(); + } else { + int hardlink = (getenv("CCACHE_NOCOMPRESS") != 0) && (getenv("CCACHE_HARDLINK") != 0); + if (swig) { + /* read the list of generated files and copy each of them into the cache */ + FILE *file; + file = fopen(tmp_outfiles, "r"); + if (file) { + char out_filename[FILENAME_MAX + 1]; + char out_filename_cache[FILENAME_MAX + 1]; + while (fgets(out_filename, FILENAME_MAX, file)) { + char *linefeed = strchr(out_filename, '\n'); + if (linefeed) { + *linefeed = 0; + + if (cached_files_count == 0) { + strcpy(out_filename_cache, hashname); + } else { + sprintf(out_filename_cache, "%s.%d", hashname, cached_files_count); + } + + if (stat(out_filename, &st1) != 0 || + commit_to_cache(out_filename, out_filename_cache, hardlink) != 0) { + fclose(file); + unlink(tmp_outfiles); + failed(); + } + to_cache_stats_helper(&st1, out_filename_cache, tmp_outfiles, &files_size, &cached_files_count); + } else { + cached_files_count = 0; + break; + } + } + fclose(file); + if (cached_files_count == 0) { + cc_log("failed to copy output files to cache - internal error\n"); + stats_update(STATS_ERROR); + unlink(tmp_outfiles); + failed(); + } + + /* also copy the (uncompressed) file containing the list of generated files into the cache */ + sprintf(out_filename_cache, "%s.outfiles", hashname); + if (stat(tmp_outfiles, &st1) != 0 || + safe_rename(tmp_outfiles, out_filename_cache) != 0) { + cc_log("failed to copy outfiles file to cache - %s\n", strerror(errno)); + stats_update(STATS_ERROR); + unlink(tmp_outfiles); + failed(); + } + to_cache_stats_helper(&st1, out_filename_cache, tmp_outfiles, &files_size, &cached_files_count); + unlink(tmp_outfiles); + } else { + cc_log("failed to open temp outfiles file - %s\n", strerror(errno)); + stats_update(STATS_ERROR); + failed(); + } + } else { + if (stat(output_file, &st1) != 0 || + commit_to_cache(output_file, hashname, hardlink) != 0) { + failed(); + } + to_cache_stats_helper(&st1, hashname, 0, &files_size, &cached_files_count); + } } x_asprintf(&path_stderr, "%s.stderr", hashname); if (stat(tmp_stderr, &st1) != 0 || - stat(tmp_hashname, &st2) != 0 || - move_file(tmp_hashname, hashname) != 0 || move_file(tmp_stderr, path_stderr) != 0) { cc_log("failed to rename tmp files - %s\n", strerror(errno)); stats_update(STATS_ERROR); failed(); } -#if ENABLE_ZLIB - /* do an extra stat on the cache files for - the size statistics */ - if (stat(path_stderr, &st1) != 0 || - stat(hashname, &st2) != 0) { - cc_log("failed to stat cache files - %s\n", strerror(errno)); - stats_update(STATS_ERROR); - failed(); - } -#endif + to_cache_stats_helper(&st1, path_stderr, 0, &files_size, &cached_files_count); - cc_log("Placed %s into cache\n", output_file); - stats_tocache(file_size(&st1) + file_size(&st2)); + cc_log("Placed %d files for %s into cache\n", cached_files_count, input_file); + stats_tocache(files_size, cached_files_count); - free(tmp_hashname); free(tmp_stderr); free(tmp_stdout); + free(tmp_outfiles); free(path_stderr); } @@ -288,7 +389,7 @@ static void find_hash(ARGS *args) } /* we have to hash the extension, as a .i file isn't treated the same - by the compiler as a .ii file */ + by the compiler as a .ii file (Note: not strictly necessary for SWIG) */ hash_string(i_extension); /* first the arguments */ @@ -383,7 +484,7 @@ static void find_hash(ARGS *args) /* we are compiling a .i or .ii file - that means we can skip the cpp stage and directly form the correct i_tmpfile */ - path_stdout = input_file; + path_stdout = x_strdup(input_file); if (create_empty_file(path_stderr) != 0) { stats_update(STATS_ERROR); cc_log("failed to create empty stderr file\n"); @@ -456,7 +557,6 @@ static void find_hash(ARGS *args) free(hash_dir); } - /* try to return the compile result from cache. If we can return from cache then this function exits with the correct status code, @@ -465,7 +565,6 @@ static void from_cache(int first) { int fd_stderr, fd_cpp_stderr; char *stderr_file; - int ret; struct stat st; x_asprintf(&stderr_file, "%s.stderr", hashname); @@ -488,56 +587,81 @@ static void from_cache(int first) #ifndef ENABLE_ZLIB /* if the cache file is compressed we must recache */ if ((first && getenv("CCACHE_RECACHE")) || - test_if_compressed(hashname) == 1) { + test_if_compressed(hashname) == 1) #else - if (first && getenv("CCACHE_RECACHE")) { + if (first && getenv("CCACHE_RECACHE")) #endif + { close(fd_stderr); unlink(stderr_file); free(stderr_file); return; } - /* update timestamps for LRU cleanup - also gives output_file a sensible mtime when hard-linking (for make) */ -#ifdef HAVE_UTIMES - utimes(hashname, NULL); - utimes(stderr_file, NULL); -#else - utime(hashname, NULL); - utime(stderr_file, NULL); -#endif + if (first) { + int hardlink; + int passfail = -1; - if (strcmp(output_file, "/dev/null") == 0) { - ret = 0; - } else { - unlink(output_file); - /* only make a hardlink if the cache file is uncompressed */ - if (getenv("CCACHE_HARDLINK") && - test_if_compressed(hashname) == 0) { - ret = link(hashname, output_file); + /* update timestamps for LRU cleanup + also gives output_file a sensible mtime when hard-linking (for make) */ + x_utimes(stderr_file); + + hardlink = (getenv("CCACHE_HARDLINK") != 0); + + if (swig) { + /* read the list of generated files and copy each of them out of the cache */ + FILE *file; + char *outfiles; + x_asprintf(&outfiles, "%s.outfiles", hashname); + file = fopen(outfiles, "r"); + if (file) { + char out_filename[FILENAME_MAX + 1]; + char out_filename_cache[FILENAME_MAX + 1]; + int retrieved_files_count = 0; + x_utimes(outfiles); + while (fgets(out_filename, FILENAME_MAX, file)) { + char *linefeed = strchr(out_filename, '\n'); + if (linefeed) { + *linefeed = 0; + + if (retrieved_files_count == 0) { + strcpy(out_filename_cache, hashname); + } else { + sprintf(out_filename_cache, "%s.%d", hashname, retrieved_files_count); + } + + passfail = retrieve_from_cache(out_filename_cache, out_filename, hardlink); + if (passfail == -1) { + break; + } + + retrieved_files_count++; + } else { + cc_log("failed to copy output files from cache - internal error\n"); + stats_update(STATS_ERROR); + passfail = -1; + break; + } + } + if (retrieved_files_count == 0) { + cc_log("failed to copy output files from cache - internal error\n"); + stats_update(STATS_ERROR); + passfail = -1; + } + fclose(file); + } else { + cc_log("failed to open cached outfiles file - %s\n", strerror(errno)); + stats_update(STATS_ERROR); + } } else { - ret = copy_file(hashname, output_file); + passfail = retrieve_from_cache(hashname, output_file, hardlink); } - } - /* the hash file might have been deleted by some external process */ - if (ret == -1 && errno == ENOENT) { - cc_log("hashfile missing for %s\n", output_file); - stats_update(STATS_MISSING); - close(fd_stderr); - unlink(stderr_file); - return; - } - free(stderr_file); - - if (ret == -1) { - ret = copy_file(hashname, output_file); - if (ret == -1) { - cc_log("failed to copy %s -> %s (%s)\n", - hashname, output_file, strerror(errno)); - stats_update(STATS_ERROR); - failed(); + free(stderr_file); + if (passfail == -1) { + close(fd_stderr); + unlink(stderr_file); + return; } } @@ -566,7 +690,7 @@ static void from_cache(int first) /* and exit with the right status code */ if (first) { - cc_log("got cached result for %s\n", output_file); + cc_log("got cached result for %s\n", input_file); stats_update(STATS_CACHED); } @@ -597,7 +721,7 @@ static void find_compiler(int argc, char **argv) /* support user override of the compiler */ if ((path=getenv("CCACHE_CC"))) { - base = strdup(path); + base = x_strdup(path); } orig_args->argv[0] = find_executable(base, MYNAME); @@ -622,6 +746,8 @@ static const char *check_extension(const char *fname, int *direct_i) *direct_i = 0; } + if (swig) return "ii"; /* any file extension is acceptable as input for SWIG */ + p = strrchr(fname, '.'); if (!p) return NULL; p++; @@ -662,6 +788,11 @@ static void process_args(int argc, char **argv) args_add(stripped_args, argv[0]); + /* -c not required for SWIG */ + if (swig) { + found_c_opt = 1; + } + for (i=1; iargc, orig_args->argv); @@ -963,7 +1111,7 @@ static void ccache(int argc, char *argv[]) static void usage(void) { - printf("ccache, a compiler cache. Version %s\n", CCACHE_VERSION); + printf("ccache, a compiler cache, with modifications for SWIG. Version %s\n", CCACHE_VERSION); printf("Copyright Andrew Tridgell, 2002\n\n"); printf("Usage:\n"); @@ -998,7 +1146,7 @@ static int ccache_main(int argc, char *argv[]) while ((c = getopt(argc, argv, "hszcCF:M:V")) != -1) { switch (c) { case 'V': - printf("ccache version %s\n", CCACHE_VERSION); + printf("ccache with modifications for SWIG version %s\n", CCACHE_VERSION); printf("Copyright Andrew Tridgell 2002\n"); printf("Released under the GNU GPL v2 or later\n"); exit(0); @@ -1097,13 +1245,12 @@ int main(int argc, char *argv[]) } } - temp_dir = getenv("CCACHE_TEMPDIR"); - if (!temp_dir) { - temp_dir = cache_dir; - } - cache_logfile = getenv("CCACHE_LOGFILE"); + if (getenv("CCACHE_VERBOSE")) { + ccache_verbose = 1; + } + setup_uncached_err(); @@ -1140,6 +1287,17 @@ int main(int argc, char *argv[]) exit(1); } + temp_dir = getenv("CCACHE_TEMPDIR"); + if (!temp_dir) { + x_asprintf(&temp_dir, "%s/temp", cache_dir); + /* make sure temp dir exists if not supplied by user */ + if (temp_dir && create_dir(temp_dir) != 0) { + fprintf(stderr,"ccache: failed to create %s (%s)\n", + temp_dir, strerror(errno)); + exit(1); + } + } + if (!getenv("CCACHE_READONLY")) { if (create_cachedirtag(cache_dir) != 0) { fprintf(stderr,"ccache: failed to create %s/CACHEDIR.TAG (%s)\n", diff --git a/CCache/ccache.h b/CCache/ccache.h index bd67cbc67..07d79f8b0 100644 --- a/CCache/ccache.h +++ b/CCache/ccache.h @@ -92,10 +92,13 @@ void cc_log(const char *format, ...); void fatal(const char *msg); void copy_fd(int fd_in, int fd_out); -int copy_file(const char *src, const char *dest); +int safe_rename(const char* oldpath, const char* newpath); int move_file(const char *src, const char *dest); int test_if_compressed(const char *filename); +int commit_to_cache(const char *src, const char *dest, int hardlink); +int retrieve_from_cache(const char *src, const char *dest, int hardlink); + int create_dir(const char *dir); int create_cachedirtag(const char *dir); void x_asprintf(char **ptr, const char *format, ...); @@ -112,11 +115,12 @@ char *x_realpath(const char *path); char *gnu_getcwd(void); int create_empty_file(const char *fname); const char *get_home_directory(void); +int x_utimes(const char *filename); void stats_update(enum stats stat); void stats_zero(void); void stats_summary(void); -void stats_tocache(size_t size); +void stats_tocache(size_t size, size_t numfiles); void stats_read(const char *stats_file, unsigned counters[STATS_END]); int stats_set_limits(long maxfiles, long maxsize); size_t value_units(const char *s); @@ -144,6 +148,7 @@ int execute(char **argv, const char *path_stdout, const char *path_stderr); char *find_executable(const char *name, const char *exclude_name); +void display_execute_args(char **argv); typedef struct { char **argv; @@ -158,6 +163,8 @@ void args_pop(ARGS *args, int n); void args_strip(ARGS *args, const char *prefix); void args_remove_first(ARGS *args); +extern int ccache_verbose; + #if HAVE_COMPAR_FN_T #define COMPAR_FN_T __compar_fn_t #else diff --git a/CCache/execute.c b/CCache/execute.c index 4b98ab735..1694f6681 100644 --- a/CCache/execute.c +++ b/CCache/execute.c @@ -36,6 +36,11 @@ int execute(char **argv, if (pid == 0) { int fd; + /* TODO: needs moving after possible exit() below, but before stdout is redirected */ + if (ccache_verbose) { + display_execute_args(argv); + } + unlink(path_stdout); fd = open(path_stdout, O_WRONLY|O_CREAT|O_TRUNC|O_EXCL|O_BINARY, 0666); if (fd == -1) { @@ -127,3 +132,16 @@ char *find_executable(const char *name, const char *exclude_name) return NULL; } + +void display_execute_args(char **argv) +{ + if (argv) { + printf("ccache executing: "); + while (*argv) { + printf("%s ", *argv); + ++argv; + } + printf("\n"); + fflush(stdout); + } +} diff --git a/CCache/stats.c b/CCache/stats.c index ddaf768db..8be1879d1 100644 --- a/CCache/stats.c +++ b/CCache/stats.c @@ -116,7 +116,7 @@ static void stats_read_fd(int fd, unsigned counters[STATS_END]) } /* update the stats counter for this compile */ -static void stats_update_size(enum stats stat, size_t size) +static void stats_update_size(enum stats stat, size_t size, size_t numfiles) { int fd; unsigned counters[STATS_END]; @@ -147,7 +147,7 @@ static void stats_update_size(enum stats stat, size_t size) /* on a cache miss we up the file count and size */ if (stat == STATS_TOCACHE) { - counters[STATS_NUMFILES] += 2; + counters[STATS_NUMFILES] += numfiles; counters[STATS_TOTALSIZE] += size; } @@ -173,18 +173,18 @@ static void stats_update_size(enum stats stat, size_t size) } /* record a cache miss */ -void stats_tocache(size_t size) +void stats_tocache(size_t size, size_t numfiles) { /* convert size to kilobytes */ size = size / 1024; - stats_update_size(STATS_TOCACHE, size); + stats_update_size(STATS_TOCACHE, size, numfiles); } /* update a normal stat */ void stats_update(enum stats stat) { - stats_update_size(stat, 0); + stats_update_size(stat, 0, 0); } /* read in the stats from one dir and add to the counters */ diff --git a/CCache/util.c b/CCache/util.c index 6056d36f7..06b290954 100644 --- a/CCache/util.c +++ b/CCache/util.c @@ -44,21 +44,7 @@ void fatal(const char *msg) exit(1); } -#ifndef ENABLE_ZLIB -/* copy all data from one file descriptor to another */ -void copy_fd(int fd_in, int fd_out) -{ - char buf[10240]; - int n; - - while ((n = read(fd_in, buf, sizeof(buf))) > 0) { - if (write(fd_out, buf, n) != n) { - fatal("Failed to copy fd"); - } - } -} - -static int safe_rename(const char* oldpath, const char* newpath) +int safe_rename(const char* oldpath, const char* newpath) { /* safe_rename is for creating entries in the cache. @@ -75,6 +61,20 @@ static int safe_rename(const char* oldpath, const char* newpath) } } +#ifndef ENABLE_ZLIB +/* copy all data from one file descriptor to another */ +void copy_fd(int fd_in, int fd_out) +{ + char buf[10240]; + int n; + + while ((n = read(fd_in, buf, sizeof(buf))) > 0) { + if (write(fd_out, buf, n) != n) { + fatal("Failed to copy fd"); + } + } +} + /* move a file using rename */ int move_file(const char *src, const char *dest) { return safe_rename(src, dest); @@ -83,7 +83,7 @@ int move_file(const char *src, const char *dest) { /* copy a file - used when hard links don't work the copy is done via a temporary file and atomic rename */ -int copy_file(const char *src, const char *dest) +static int copy_file(const char *src, const char *dest) { int fd1, fd2; char buf[10240]; @@ -143,6 +143,16 @@ int copy_file(const char *src, const char *dest) return 0; } +/* copy a file to the cache */ +static int copy_file_to_cache(const char *src, const char *dest) { + return copy_file(src, dest); +} + +/* copy a file from the cache */ +static int copy_file_from_cache(const char *src, const char *dest) { + return copy_file(src, dest); +} + #else /* ENABLE_ZLIB */ /* copy all data from one file descriptor to another @@ -286,8 +296,13 @@ int move_file(const char *src, const char *dest) { return ret; } +/* copy a file to the cache, compressing it */ +static int copy_file_to_cache(const char *src, const char *dest) { + return _copy_file(src, dest, COPY_TO_CACHE); +} + /* copy a file from the cache, decompressing it */ -int copy_file(const char *src, const char *dest) { +static int copy_file_from_cache(const char *src, const char *dest) { return _copy_file(src, dest, COPY_FROM_CACHE); } #endif /* ENABLE_ZLIB */ @@ -312,6 +327,61 @@ int test_if_compressed(const char *filename) { return 1; } +/* copy file to the cache with error checking taking into account compression and hard linking if desired */ +int commit_to_cache(const char *src, const char *dest, int hardlink) +{ + int ret = -1; + unlink(dest); + if (hardlink) { + ret = link(src, dest); + } + if (ret == -1) { + ret = copy_file_to_cache(src, dest); + if (ret == -1) { + cc_log("failed to commit %s -> %s (%s)\n", src, dest, strerror(errno)); + stats_update(STATS_ERROR); + } + } + return ret; +} + +/* copy file out of the cache with error checking taking into account compression and hard linking if desired */ +int retrieve_from_cache(const char *src, const char *dest, int hardlink) +{ + int ret = 0; + + x_utimes(src); + + if (strcmp(dest, "/dev/null") == 0) { + ret = 0; + } else { + unlink(dest); + /* only make a hardlink if the cache file is uncompressed */ + if (hardlink && test_if_compressed(src) == 0) { + ret = link(src, dest); + } else { + ret = copy_file_from_cache(src, dest); + } + } + + /* the cached file might have been deleted by some external process */ + if (ret == -1 && errno == ENOENT) { + cc_log("hashfile missing for %s\n", dest); + stats_update(STATS_MISSING); + return -1; + } + + if (ret == -1) { + ret = copy_file_from_cache(src, dest); + if (ret == -1) { + cc_log("failed to retrieve %s -> %s (%s)\n", src, dest, strerror(errno)); + stats_update(STATS_ERROR); + return -1; + } + } + return ret; +} + /* make sure a directory exists */ int create_dir(const char *dir) { @@ -410,15 +480,24 @@ void *x_malloc(size_t size) void *x_realloc(void *ptr, size_t size) { void *p2; +#if 1 + /* Avoid invalid read in memcpy below */ + p2 = realloc(ptr, size); + if (!p2) { + fatal("out of memory in x_realloc"); + } +#else if (!ptr) return x_malloc(size); p2 = malloc(size); if (!p2) { fatal("out of memory in x_realloc"); } if (ptr) { + /* Note invalid read as the memcpy reads beyond the memory allocated by ptr */ memcpy(p2, ptr, size); free(ptr); } +#endif return p2; } @@ -676,3 +755,12 @@ const char *get_home_directory(void) return NULL; } +int x_utimes(const char *filename) +{ +#ifdef HAVE_UTIMES + return utimes(filename, NULL); +#else + return utime(filename, NULL); +#endif +} + From 54283434f10ff184b658cf7bfe823a4b941e0edd Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 5 Nov 2008 16:53:55 +0000 Subject: [PATCH 0160/1680] fix Makefile for autoconf>2.60 git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10916 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CCache/Makefile.in | 1 + 1 file changed, 1 insertion(+) diff --git a/CCache/Makefile.in b/CCache/Makefile.in index 438ec19f5..07b86f0f4 100644 --- a/CCache/Makefile.in +++ b/CCache/Makefile.in @@ -1,3 +1,4 @@ +datarootdir = @datarootdir@ srcdir=@srcdir@ VPATH=@srcdir@ From 8ce8820c4e8596302baddc582180e503d5ccf923 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 5 Nov 2008 16:55:07 +0000 Subject: [PATCH 0161/1680] fix configure.in when running autoreconf git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10917 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CCache/config.h.in | 6 +++--- CCache/configure.in | 5 ++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CCache/config.h.in b/CCache/config.h.in index 49ccd8325..893f98bd9 100644 --- a/CCache/config.h.in +++ b/CCache/config.h.in @@ -1,5 +1,8 @@ /* config.h.in. Generated from configure.in by autoheader. */ +/* Define to 1 if you would like to have zlib compression for ccache. */ +#undef ENABLE_ZLIB + /* Define to 1 if you have the `asprintf' function. */ #undef HAVE_ASPRINTF @@ -110,6 +113,3 @@ /* Define _GNU_SOURCE so that we get all necessary prototypes */ #undef _GNU_SOURCE - -/* Define to 1 if you like to have zlib compression for the ccache. */ -#undef ENABLE_ZLIB diff --git a/CCache/configure.in b/CCache/configure.in index 1ac94d3fd..7dccd6d2a 100644 --- a/CCache/configure.in +++ b/CCache/configure.in @@ -44,6 +44,7 @@ if test x"$ccache_cv_COMPAR_FN_T" = x"yes"; then AC_DEFINE(HAVE_COMPAR_FN_T, 1, [ ]) fi +dnl Note: This could be replaced by AC_FUNC_SNPRINTF() in the autoconf macro archive AC_CACHE_CHECK([for C99 vsnprintf],ccache_cv_HAVE_C99_VSNPRINTF,[ AC_TRY_RUN([ #include @@ -70,12 +71,14 @@ if test x"$ccache_cv_HAVE_C99_VSNPRINTF" = x"yes"; then fi dnl Check for zlib. +dnl Note: This could be replaced by CHECK_ZLIB() in the autoconf macro archive AC_ARG_ENABLE([zlib], AS_HELP_STRING([--enable-zlib], [enable zlib support for ccache compression]),, [enable_zlib=yes]) if test x"$enable_zlib" = x"yes"; then - AC_CHECK_HEADER(zlib.h, AC_CHECK_LIB(z, gzdopen, LIBS="-lz $LIBS"; AC_DEFINE(ENABLE_ZLIB))) + AC_CHECK_HEADER(zlib.h, AC_CHECK_LIB(z, gzdopen, [LIBS="-lz $LIBS" + AC_DEFINE([ENABLE_ZLIB], 1, [Define to 1 if you would like to have zlib compression for ccache.]) ] )) fi AC_CONFIG_FILES([Makefile]) From e497a9653a99a1f466cdfb124ddf84544fd70a68 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 5 Nov 2008 16:57:21 +0000 Subject: [PATCH 0162/1680] create executable name as ccache-swig instead of ccache to avoid conflict with the official ccache git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10918 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CCache/ccache.c | 8 ++++---- CCache/ccache.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CCache/ccache.c b/CCache/ccache.c index b08c4cda1..4b7c2944f 100644 --- a/CCache/ccache.c +++ b/CCache/ccache.c @@ -1111,12 +1111,12 @@ static void ccache(int argc, char *argv[]) static void usage(void) { - printf("ccache, a compiler cache, with modifications for SWIG. Version %s\n", CCACHE_VERSION); + printf("%s, a compiler cache including support for SWIG. Version %s\n", MYNAME, CCACHE_VERSION); printf("Copyright Andrew Tridgell, 2002\n\n"); printf("Usage:\n"); - printf("\tccache [options]\n"); - printf("\tccache compiler [compile options]\n"); + printf("\t" MYNAME " [options]\n"); + printf("\t" MYNAME " compiler [compile options]\n"); printf("\tcompiler [compile options] (via symbolic link)\n"); printf("\nOptions:\n"); @@ -1146,7 +1146,7 @@ static int ccache_main(int argc, char *argv[]) while ((c = getopt(argc, argv, "hszcCF:M:V")) != -1) { switch (c) { case 'V': - printf("ccache with modifications for SWIG version %s\n", CCACHE_VERSION); + printf("%s version %s\n", MYNAME, CCACHE_VERSION); printf("Copyright Andrew Tridgell 2002\n"); printf("Released under the GNU GPL v2 or later\n"); exit(0); diff --git a/CCache/ccache.h b/CCache/ccache.h index 07d79f8b0..9da406a2e 100644 --- a/CCache/ccache.h +++ b/CCache/ccache.h @@ -34,7 +34,7 @@ #define STATUS_FATAL 4 #define STATUS_NOCACHE 5 -#define MYNAME "ccache" +#define MYNAME "ccache-swig" #define LIMIT_MULTIPLE 0.8 From c8b41eebf83a6380ac79e422bb8b53297f660eae Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 5 Nov 2008 16:59:27 +0000 Subject: [PATCH 0163/1680] remove autotool generated files git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10919 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CCache/config.h.in | 115 - CCache/configure | 5142 -------------------------------------------- 2 files changed, 5257 deletions(-) delete mode 100644 CCache/config.h.in delete mode 100755 CCache/configure diff --git a/CCache/config.h.in b/CCache/config.h.in deleted file mode 100644 index 893f98bd9..000000000 --- a/CCache/config.h.in +++ /dev/null @@ -1,115 +0,0 @@ -/* config.h.in. Generated from configure.in by autoheader. */ - -/* Define to 1 if you would like to have zlib compression for ccache. */ -#undef ENABLE_ZLIB - -/* Define to 1 if you have the `asprintf' function. */ -#undef HAVE_ASPRINTF - -/* */ -#undef HAVE_C99_VSNPRINTF - -/* */ -#undef HAVE_COMPAR_FN_T - -/* Define to 1 if you have the header file. */ -#undef HAVE_CTYPE_H - -/* Define to 1 if you have the header file, and it defines `DIR'. - */ -#undef HAVE_DIRENT_H - -/* Define to 1 if you have the `gethostname' function. */ -#undef HAVE_GETHOSTNAME - -/* Define to 1 if you have the `getpwuid' function. */ -#undef HAVE_GETPWUID - -/* Define to 1 if you have the header file. */ -#undef HAVE_INTTYPES_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_MEMORY_H - -/* Define to 1 if you have the `mkstemp' function. */ -#undef HAVE_MKSTEMP - -/* Define to 1 if you have the header file, and it defines `DIR'. */ -#undef HAVE_NDIR_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_PWD_H - -/* Define to 1 if you have the `realpath' function. */ -#undef HAVE_REALPATH - -/* Define to 1 if you have the `snprintf' function. */ -#undef HAVE_SNPRINTF - -/* Define to 1 if you have the header file. */ -#undef HAVE_STDINT_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STDLIB_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STRINGS_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STRING_H - -/* Define to 1 if you have the header file, and it defines `DIR'. - */ -#undef HAVE_SYS_DIR_H - -/* Define to 1 if you have the header file, and it defines `DIR'. - */ -#undef HAVE_SYS_NDIR_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_STAT_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_TIME_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_TYPES_H - -/* Define to 1 if you have that is POSIX.1 compatible. */ -#undef HAVE_SYS_WAIT_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_UNISTD_H - -/* Define to 1 if you have the `utimes' function. */ -#undef HAVE_UTIMES - -/* Define to 1 if you have the `vasprintf' function. */ -#undef HAVE_VASPRINTF - -/* Define to 1 if you have the `vsnprintf' function. */ -#undef HAVE_VSNPRINTF - -/* Define to the address where bug reports for this package should be sent. */ -#undef PACKAGE_BUGREPORT - -/* Define to the full name of this package. */ -#undef PACKAGE_NAME - -/* Define to the full name and version of this package. */ -#undef PACKAGE_STRING - -/* Define to the one symbol short name of this package. */ -#undef PACKAGE_TARNAME - -/* Define to the version of this package. */ -#undef PACKAGE_VERSION - -/* Define to 1 if you have the ANSI C header files. */ -#undef STDC_HEADERS - -/* Define to 1 if you can safely include both and . */ -#undef TIME_WITH_SYS_TIME - -/* Define _GNU_SOURCE so that we get all necessary prototypes */ -#undef _GNU_SOURCE diff --git a/CCache/configure b/CCache/configure deleted file mode 100755 index c96e3ee78..000000000 --- a/CCache/configure +++ /dev/null @@ -1,5142 +0,0 @@ -#! /bin/sh -# Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.59. -# -# Copyright (C) 2003 Free Software Foundation, Inc. -# This configure script is free software; the Free Software Foundation -# gives unlimited permission to copy, distribute and modify it. -## --------------------- ## -## M4sh Initialization. ## -## --------------------- ## - -# Be Bourne compatible -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then - emulate sh - NULLCMD=: - # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which - # is contrary to our usage. Disable this feature. - alias -g '${1+"$@"}'='"$@"' -elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then - set -o posix -fi -DUALCASE=1; export DUALCASE # for MKS sh - -# Support unset when possible. -if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then - as_unset=unset -else - as_unset=false -fi - - -# Work around bugs in pre-3.0 UWIN ksh. -$as_unset ENV MAIL MAILPATH -PS1='$ ' -PS2='> ' -PS4='+ ' - -# NLS nuisances. -for as_var in \ - LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ - LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ - LC_TELEPHONE LC_TIME -do - if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then - eval $as_var=C; export $as_var - else - $as_unset $as_var - fi -done - -# Required to use basename. -if expr a : '\(a\)' >/dev/null 2>&1; then - as_expr=expr -else - as_expr=false -fi - -if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then - as_basename=basename -else - as_basename=false -fi - - -# Name of the executable. -as_me=`$as_basename "$0" || -$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ - X"$0" : 'X\(//\)$' \| \ - X"$0" : 'X\(/\)$' \| \ - . : '\(.\)' 2>/dev/null || -echo X/"$0" | - sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; } - /^X\/\(\/\/\)$/{ s//\1/; q; } - /^X\/\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` - - -# PATH needs CR, and LINENO needs CR and PATH. -# Avoid depending upon Character Ranges. -as_cr_letters='abcdefghijklmnopqrstuvwxyz' -as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' -as_cr_Letters=$as_cr_letters$as_cr_LETTERS -as_cr_digits='0123456789' -as_cr_alnum=$as_cr_Letters$as_cr_digits - -# The user is always right. -if test "${PATH_SEPARATOR+set}" != set; then - echo "#! /bin/sh" >conf$$.sh - echo "exit 0" >>conf$$.sh - chmod +x conf$$.sh - if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then - PATH_SEPARATOR=';' - else - PATH_SEPARATOR=: - fi - rm -f conf$$.sh -fi - - - as_lineno_1=$LINENO - as_lineno_2=$LINENO - as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` - test "x$as_lineno_1" != "x$as_lineno_2" && - test "x$as_lineno_3" = "x$as_lineno_2" || { - # Find who we are. Look in the path if we contain no path at all - # relative or not. - case $0 in - *[\\/]* ) as_myself=$0 ;; - *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break -done - - ;; - esac - # We did not find ourselves, most probably we were run as `sh COMMAND' - # in which case we are not to be found in the path. - if test "x$as_myself" = x; then - as_myself=$0 - fi - if test ! -f "$as_myself"; then - { echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2 - { (exit 1); exit 1; }; } - fi - case $CONFIG_SHELL in - '') - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for as_base in sh bash ksh sh5; do - case $as_dir in - /*) - if ("$as_dir/$as_base" -c ' - as_lineno_1=$LINENO - as_lineno_2=$LINENO - as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` - test "x$as_lineno_1" != "x$as_lineno_2" && - test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then - $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; } - $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; } - CONFIG_SHELL=$as_dir/$as_base - export CONFIG_SHELL - exec "$CONFIG_SHELL" "$0" ${1+"$@"} - fi;; - esac - done -done -;; - esac - - # Create $as_me.lineno as a copy of $as_myself, but with $LINENO - # uniformly replaced by the line number. The first 'sed' inserts a - # line-number line before each line; the second 'sed' does the real - # work. The second script uses 'N' to pair each line-number line - # with the numbered line, and appends trailing '-' during - # substitution so that $LINENO is not a special case at line end. - # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the - # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-) - sed '=' <$as_myself | - sed ' - N - s,$,-, - : loop - s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3, - t loop - s,-$,, - s,^['$as_cr_digits']*\n,, - ' >$as_me.lineno && - chmod +x $as_me.lineno || - { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 - { (exit 1); exit 1; }; } - - # Don't try to exec as it changes $[0], causing all sort of problems - # (the dirname of $[0] is not the place where we might find the - # original and so on. Autoconf is especially sensible to this). - . ./$as_me.lineno - # Exit status is that of the last command. - exit -} - - -case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in - *c*,-n*) ECHO_N= ECHO_C=' -' ECHO_T=' ' ;; - *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; - *) ECHO_N= ECHO_C='\c' ECHO_T= ;; -esac - -if expr a : '\(a\)' >/dev/null 2>&1; then - as_expr=expr -else - as_expr=false -fi - -rm -f conf$$ conf$$.exe conf$$.file -echo >conf$$.file -if ln -s conf$$.file conf$$ 2>/dev/null; then - # We could just check for DJGPP; but this test a) works b) is more generic - # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). - if test -f conf$$.exe; then - # Don't use ln at all; we don't have any links - as_ln_s='cp -p' - else - as_ln_s='ln -s' - fi -elif ln conf$$.file conf$$ 2>/dev/null; then - as_ln_s=ln -else - as_ln_s='cp -p' -fi -rm -f conf$$ conf$$.exe conf$$.file - -if mkdir -p . 2>/dev/null; then - as_mkdir_p=: -else - test -d ./-p && rmdir ./-p - as_mkdir_p=false -fi - -as_executable_p="test -f" - -# Sed expression to map a string onto a valid CPP name. -as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" - -# Sed expression to map a string onto a valid variable name. -as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" - - -# IFS -# We need space, tab and new line, in precisely that order. -as_nl=' -' -IFS=" $as_nl" - -# CDPATH. -$as_unset CDPATH - - -# Name of the host. -# hostname on some systems (SVR3.2, Linux) returns a bogus exit status, -# so uname gets run too. -ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` - -exec 6>&1 - -# -# Initializations. -# -ac_default_prefix=/usr/local -ac_config_libobj_dir=. -cross_compiling=no -subdirs= -MFLAGS= -MAKEFLAGS= -SHELL=${CONFIG_SHELL-/bin/sh} - -# Maximum number of lines to put in a shell here document. -# This variable seems obsolete. It should probably be removed, and -# only ac_max_sed_lines should be used. -: ${ac_max_here_lines=38} - -# Identity of this package. -PACKAGE_NAME= -PACKAGE_TARNAME= -PACKAGE_VERSION= -PACKAGE_STRING= -PACKAGE_BUGREPORT= - -# Factoring default headers for most tests. -ac_includes_default="\ -#include -#if HAVE_SYS_TYPES_H -# include -#endif -#if HAVE_SYS_STAT_H -# include -#endif -#if STDC_HEADERS -# include -# include -#else -# if HAVE_STDLIB_H -# include -# endif -#endif -#if HAVE_STRING_H -# if !STDC_HEADERS && HAVE_MEMORY_H -# include -# endif -# include -#endif -#if HAVE_STRINGS_H -# include -#endif -#if HAVE_INTTYPES_H -# include -#else -# if HAVE_STDINT_H -# include -# endif -#endif -#if HAVE_UNISTD_H -# include -#endif" - -ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CPP INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA EGREP LIBOBJS LTLIBOBJS' -ac_subst_files='' - -# Initialize some variables set by options. -ac_init_help= -ac_init_version=false -# The variables have the same names as the options, with -# dashes changed to underlines. -cache_file=/dev/null -exec_prefix=NONE -no_create= -no_recursion= -prefix=NONE -program_prefix=NONE -program_suffix=NONE -program_transform_name=s,x,x, -silent= -site= -srcdir= -verbose= -x_includes=NONE -x_libraries=NONE - -# Installation directory options. -# These are left unexpanded so users can "make install exec_prefix=/foo" -# and all the variables that are supposed to be based on exec_prefix -# by default will actually change. -# Use braces instead of parens because sh, perl, etc. also accept them. -bindir='${exec_prefix}/bin' -sbindir='${exec_prefix}/sbin' -libexecdir='${exec_prefix}/libexec' -datadir='${prefix}/share' -sysconfdir='${prefix}/etc' -sharedstatedir='${prefix}/com' -localstatedir='${prefix}/var' -libdir='${exec_prefix}/lib' -includedir='${prefix}/include' -oldincludedir='/usr/include' -infodir='${prefix}/info' -mandir='${prefix}/man' - -ac_prev= -for ac_option -do - # If the previous option needs an argument, assign it. - if test -n "$ac_prev"; then - eval "$ac_prev=\$ac_option" - ac_prev= - continue - fi - - ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'` - - # Accept the important Cygnus configure options, so we can diagnose typos. - - case $ac_option in - - -bindir | --bindir | --bindi | --bind | --bin | --bi) - ac_prev=bindir ;; - -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) - bindir=$ac_optarg ;; - - -build | --build | --buil | --bui | --bu) - ac_prev=build_alias ;; - -build=* | --build=* | --buil=* | --bui=* | --bu=*) - build_alias=$ac_optarg ;; - - -cache-file | --cache-file | --cache-fil | --cache-fi \ - | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) - ac_prev=cache_file ;; - -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ - | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) - cache_file=$ac_optarg ;; - - --config-cache | -C) - cache_file=config.cache ;; - - -datadir | --datadir | --datadi | --datad | --data | --dat | --da) - ac_prev=datadir ;; - -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ - | --da=*) - datadir=$ac_optarg ;; - - -disable-* | --disable-*) - ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && - { echo "$as_me: error: invalid feature name: $ac_feature" >&2 - { (exit 1); exit 1; }; } - ac_feature=`echo $ac_feature | sed 's/-/_/g'` - eval "enable_$ac_feature=no" ;; - - -enable-* | --enable-*) - ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && - { echo "$as_me: error: invalid feature name: $ac_feature" >&2 - { (exit 1); exit 1; }; } - ac_feature=`echo $ac_feature | sed 's/-/_/g'` - case $ac_option in - *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; - *) ac_optarg=yes ;; - esac - eval "enable_$ac_feature='$ac_optarg'" ;; - - -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ - | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ - | --exec | --exe | --ex) - ac_prev=exec_prefix ;; - -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ - | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ - | --exec=* | --exe=* | --ex=*) - exec_prefix=$ac_optarg ;; - - -gas | --gas | --ga | --g) - # Obsolete; use --with-gas. - with_gas=yes ;; - - -help | --help | --hel | --he | -h) - ac_init_help=long ;; - -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) - ac_init_help=recursive ;; - -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) - ac_init_help=short ;; - - -host | --host | --hos | --ho) - ac_prev=host_alias ;; - -host=* | --host=* | --hos=* | --ho=*) - host_alias=$ac_optarg ;; - - -includedir | --includedir | --includedi | --included | --include \ - | --includ | --inclu | --incl | --inc) - ac_prev=includedir ;; - -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ - | --includ=* | --inclu=* | --incl=* | --inc=*) - includedir=$ac_optarg ;; - - -infodir | --infodir | --infodi | --infod | --info | --inf) - ac_prev=infodir ;; - -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) - infodir=$ac_optarg ;; - - -libdir | --libdir | --libdi | --libd) - ac_prev=libdir ;; - -libdir=* | --libdir=* | --libdi=* | --libd=*) - libdir=$ac_optarg ;; - - -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ - | --libexe | --libex | --libe) - ac_prev=libexecdir ;; - -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ - | --libexe=* | --libex=* | --libe=*) - libexecdir=$ac_optarg ;; - - -localstatedir | --localstatedir | --localstatedi | --localstated \ - | --localstate | --localstat | --localsta | --localst \ - | --locals | --local | --loca | --loc | --lo) - ac_prev=localstatedir ;; - -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ - | --localstate=* | --localstat=* | --localsta=* | --localst=* \ - | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) - localstatedir=$ac_optarg ;; - - -mandir | --mandir | --mandi | --mand | --man | --ma | --m) - ac_prev=mandir ;; - -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) - mandir=$ac_optarg ;; - - -nfp | --nfp | --nf) - # Obsolete; use --without-fp. - with_fp=no ;; - - -no-create | --no-create | --no-creat | --no-crea | --no-cre \ - | --no-cr | --no-c | -n) - no_create=yes ;; - - -no-recursion | --no-recursion | --no-recursio | --no-recursi \ - | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) - no_recursion=yes ;; - - -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ - | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ - | --oldin | --oldi | --old | --ol | --o) - ac_prev=oldincludedir ;; - -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ - | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ - | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) - oldincludedir=$ac_optarg ;; - - -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) - ac_prev=prefix ;; - -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) - prefix=$ac_optarg ;; - - -program-prefix | --program-prefix | --program-prefi | --program-pref \ - | --program-pre | --program-pr | --program-p) - ac_prev=program_prefix ;; - -program-prefix=* | --program-prefix=* | --program-prefi=* \ - | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) - program_prefix=$ac_optarg ;; - - -program-suffix | --program-suffix | --program-suffi | --program-suff \ - | --program-suf | --program-su | --program-s) - ac_prev=program_suffix ;; - -program-suffix=* | --program-suffix=* | --program-suffi=* \ - | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) - program_suffix=$ac_optarg ;; - - -program-transform-name | --program-transform-name \ - | --program-transform-nam | --program-transform-na \ - | --program-transform-n | --program-transform- \ - | --program-transform | --program-transfor \ - | --program-transfo | --program-transf \ - | --program-trans | --program-tran \ - | --progr-tra | --program-tr | --program-t) - ac_prev=program_transform_name ;; - -program-transform-name=* | --program-transform-name=* \ - | --program-transform-nam=* | --program-transform-na=* \ - | --program-transform-n=* | --program-transform-=* \ - | --program-transform=* | --program-transfor=* \ - | --program-transfo=* | --program-transf=* \ - | --program-trans=* | --program-tran=* \ - | --progr-tra=* | --program-tr=* | --program-t=*) - program_transform_name=$ac_optarg ;; - - -q | -quiet | --quiet | --quie | --qui | --qu | --q \ - | -silent | --silent | --silen | --sile | --sil) - silent=yes ;; - - -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) - ac_prev=sbindir ;; - -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ - | --sbi=* | --sb=*) - sbindir=$ac_optarg ;; - - -sharedstatedir | --sharedstatedir | --sharedstatedi \ - | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ - | --sharedst | --shareds | --shared | --share | --shar \ - | --sha | --sh) - ac_prev=sharedstatedir ;; - -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ - | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ - | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ - | --sha=* | --sh=*) - sharedstatedir=$ac_optarg ;; - - -site | --site | --sit) - ac_prev=site ;; - -site=* | --site=* | --sit=*) - site=$ac_optarg ;; - - -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) - ac_prev=srcdir ;; - -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) - srcdir=$ac_optarg ;; - - -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ - | --syscon | --sysco | --sysc | --sys | --sy) - ac_prev=sysconfdir ;; - -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ - | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) - sysconfdir=$ac_optarg ;; - - -target | --target | --targe | --targ | --tar | --ta | --t) - ac_prev=target_alias ;; - -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) - target_alias=$ac_optarg ;; - - -v | -verbose | --verbose | --verbos | --verbo | --verb) - verbose=yes ;; - - -version | --version | --versio | --versi | --vers | -V) - ac_init_version=: ;; - - -with-* | --with-*) - ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && - { echo "$as_me: error: invalid package name: $ac_package" >&2 - { (exit 1); exit 1; }; } - ac_package=`echo $ac_package| sed 's/-/_/g'` - case $ac_option in - *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; - *) ac_optarg=yes ;; - esac - eval "with_$ac_package='$ac_optarg'" ;; - - -without-* | --without-*) - ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && - { echo "$as_me: error: invalid package name: $ac_package" >&2 - { (exit 1); exit 1; }; } - ac_package=`echo $ac_package | sed 's/-/_/g'` - eval "with_$ac_package=no" ;; - - --x) - # Obsolete; use --with-x. - with_x=yes ;; - - -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ - | --x-incl | --x-inc | --x-in | --x-i) - ac_prev=x_includes ;; - -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ - | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) - x_includes=$ac_optarg ;; - - -x-libraries | --x-libraries | --x-librarie | --x-librari \ - | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) - ac_prev=x_libraries ;; - -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ - | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) - x_libraries=$ac_optarg ;; - - -*) { echo "$as_me: error: unrecognized option: $ac_option -Try \`$0 --help' for more information." >&2 - { (exit 1); exit 1; }; } - ;; - - *=*) - ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` - # Reject names that are not valid shell variable names. - expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null && - { echo "$as_me: error: invalid variable name: $ac_envvar" >&2 - { (exit 1); exit 1; }; } - ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` - eval "$ac_envvar='$ac_optarg'" - export $ac_envvar ;; - - *) - # FIXME: should be removed in autoconf 3.0. - echo "$as_me: WARNING: you should use --build, --host, --target" >&2 - expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && - echo "$as_me: WARNING: invalid host type: $ac_option" >&2 - : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} - ;; - - esac -done - -if test -n "$ac_prev"; then - ac_option=--`echo $ac_prev | sed 's/_/-/g'` - { echo "$as_me: error: missing argument to $ac_option" >&2 - { (exit 1); exit 1; }; } -fi - -# Be sure to have absolute paths. -for ac_var in exec_prefix prefix -do - eval ac_val=$`echo $ac_var` - case $ac_val in - [\\/$]* | ?:[\\/]* | NONE | '' ) ;; - *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 - { (exit 1); exit 1; }; };; - esac -done - -# Be sure to have absolute paths. -for ac_var in bindir sbindir libexecdir datadir sysconfdir sharedstatedir \ - localstatedir libdir includedir oldincludedir infodir mandir -do - eval ac_val=$`echo $ac_var` - case $ac_val in - [\\/$]* | ?:[\\/]* ) ;; - *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 - { (exit 1); exit 1; }; };; - esac -done - -# There might be people who depend on the old broken behavior: `$host' -# used to hold the argument of --host etc. -# FIXME: To remove some day. -build=$build_alias -host=$host_alias -target=$target_alias - -# FIXME: To remove some day. -if test "x$host_alias" != x; then - if test "x$build_alias" = x; then - cross_compiling=maybe - echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. - If a cross compiler is detected then cross compile mode will be used." >&2 - elif test "x$build_alias" != "x$host_alias"; then - cross_compiling=yes - fi -fi - -ac_tool_prefix= -test -n "$host_alias" && ac_tool_prefix=$host_alias- - -test "$silent" = yes && exec 6>/dev/null - - -# Find the source files, if location was not specified. -if test -z "$srcdir"; then - ac_srcdir_defaulted=yes - # Try the directory containing this script, then its parent. - ac_confdir=`(dirname "$0") 2>/dev/null || -$as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$0" : 'X\(//\)[^/]' \| \ - X"$0" : 'X\(//\)$' \| \ - X"$0" : 'X\(/\)' \| \ - . : '\(.\)' 2>/dev/null || -echo X"$0" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } - /^X\(\/\/\)[^/].*/{ s//\1/; q; } - /^X\(\/\/\)$/{ s//\1/; q; } - /^X\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` - srcdir=$ac_confdir - if test ! -r $srcdir/$ac_unique_file; then - srcdir=.. - fi -else - ac_srcdir_defaulted=no -fi -if test ! -r $srcdir/$ac_unique_file; then - if test "$ac_srcdir_defaulted" = yes; then - { echo "$as_me: error: cannot find sources ($ac_unique_file) in $ac_confdir or .." >&2 - { (exit 1); exit 1; }; } - else - { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2 - { (exit 1); exit 1; }; } - fi -fi -(cd $srcdir && test -r ./$ac_unique_file) 2>/dev/null || - { echo "$as_me: error: sources are in $srcdir, but \`cd $srcdir' does not work" >&2 - { (exit 1); exit 1; }; } -srcdir=`echo "$srcdir" | sed 's%\([^\\/]\)[\\/]*$%\1%'` -ac_env_build_alias_set=${build_alias+set} -ac_env_build_alias_value=$build_alias -ac_cv_env_build_alias_set=${build_alias+set} -ac_cv_env_build_alias_value=$build_alias -ac_env_host_alias_set=${host_alias+set} -ac_env_host_alias_value=$host_alias -ac_cv_env_host_alias_set=${host_alias+set} -ac_cv_env_host_alias_value=$host_alias -ac_env_target_alias_set=${target_alias+set} -ac_env_target_alias_value=$target_alias -ac_cv_env_target_alias_set=${target_alias+set} -ac_cv_env_target_alias_value=$target_alias -ac_env_CC_set=${CC+set} -ac_env_CC_value=$CC -ac_cv_env_CC_set=${CC+set} -ac_cv_env_CC_value=$CC -ac_env_CFLAGS_set=${CFLAGS+set} -ac_env_CFLAGS_value=$CFLAGS -ac_cv_env_CFLAGS_set=${CFLAGS+set} -ac_cv_env_CFLAGS_value=$CFLAGS -ac_env_LDFLAGS_set=${LDFLAGS+set} -ac_env_LDFLAGS_value=$LDFLAGS -ac_cv_env_LDFLAGS_set=${LDFLAGS+set} -ac_cv_env_LDFLAGS_value=$LDFLAGS -ac_env_CPPFLAGS_set=${CPPFLAGS+set} -ac_env_CPPFLAGS_value=$CPPFLAGS -ac_cv_env_CPPFLAGS_set=${CPPFLAGS+set} -ac_cv_env_CPPFLAGS_value=$CPPFLAGS -ac_env_CPP_set=${CPP+set} -ac_env_CPP_value=$CPP -ac_cv_env_CPP_set=${CPP+set} -ac_cv_env_CPP_value=$CPP - -# -# Report the --help message. -# -if test "$ac_init_help" = "long"; then - # Omit some internal or obsolete options to make the list less imposing. - # This message is too long to be a string in the A/UX 3.1 sh. - cat <<_ACEOF -\`configure' configures this package to adapt to many kinds of systems. - -Usage: $0 [OPTION]... [VAR=VALUE]... - -To assign environment variables (e.g., CC, CFLAGS...), specify them as -VAR=VALUE. See below for descriptions of some of the useful variables. - -Defaults for the options are specified in brackets. - -Configuration: - -h, --help display this help and exit - --help=short display options specific to this package - --help=recursive display the short help of all the included packages - -V, --version display version information and exit - -q, --quiet, --silent do not print \`checking...' messages - --cache-file=FILE cache test results in FILE [disabled] - -C, --config-cache alias for \`--cache-file=config.cache' - -n, --no-create do not create output files - --srcdir=DIR find the sources in DIR [configure dir or \`..'] - -_ACEOF - - cat <<_ACEOF -Installation directories: - --prefix=PREFIX install architecture-independent files in PREFIX - [$ac_default_prefix] - --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX - [PREFIX] - -By default, \`make install' will install all the files in -\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify -an installation prefix other than \`$ac_default_prefix' using \`--prefix', -for instance \`--prefix=\$HOME'. - -For better control, use the options below. - -Fine tuning of the installation directories: - --bindir=DIR user executables [EPREFIX/bin] - --sbindir=DIR system admin executables [EPREFIX/sbin] - --libexecdir=DIR program executables [EPREFIX/libexec] - --datadir=DIR read-only architecture-independent data [PREFIX/share] - --sysconfdir=DIR read-only single-machine data [PREFIX/etc] - --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] - --localstatedir=DIR modifiable single-machine data [PREFIX/var] - --libdir=DIR object code libraries [EPREFIX/lib] - --includedir=DIR C header files [PREFIX/include] - --oldincludedir=DIR C header files for non-gcc [/usr/include] - --infodir=DIR info documentation [PREFIX/info] - --mandir=DIR man documentation [PREFIX/man] -_ACEOF - - cat <<\_ACEOF -_ACEOF -fi - -if test -n "$ac_init_help"; then - - cat <<\_ACEOF - -Optional Features: - --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) - --enable-FEATURE[=ARG] include FEATURE [ARG=yes] - --enable-zlib enable zlib support for ccache compression - -Some influential environment variables: - CC C compiler command - CFLAGS C compiler flags - LDFLAGS linker flags, e.g. -L if you have libraries in a - nonstandard directory - CPPFLAGS C/C++ preprocessor flags, e.g. -I if you have - headers in a nonstandard directory - CPP C preprocessor - -Use these variables to override the choices made by `configure' or to help -it to find libraries and programs with nonstandard names/locations. - -_ACEOF -fi - -if test "$ac_init_help" = "recursive"; then - # If there are subdirs, report their specific --help. - ac_popdir=`pwd` - for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue - test -d $ac_dir || continue - ac_builddir=. - -if test "$ac_dir" != .; then - ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` - # A "../" for each directory in $ac_dir_suffix. - ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` -else - ac_dir_suffix= ac_top_builddir= -fi - -case $srcdir in - .) # No --srcdir option. We are building in place. - ac_srcdir=. - if test -z "$ac_top_builddir"; then - ac_top_srcdir=. - else - ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` - fi ;; - [\\/]* | ?:[\\/]* ) # Absolute path. - ac_srcdir=$srcdir$ac_dir_suffix; - ac_top_srcdir=$srcdir ;; - *) # Relative path. - ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix - ac_top_srcdir=$ac_top_builddir$srcdir ;; -esac - -# Do not use `cd foo && pwd` to compute absolute paths, because -# the directories may not exist. -case `pwd` in -.) ac_abs_builddir="$ac_dir";; -*) - case "$ac_dir" in - .) ac_abs_builddir=`pwd`;; - [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";; - *) ac_abs_builddir=`pwd`/"$ac_dir";; - esac;; -esac -case $ac_abs_builddir in -.) ac_abs_top_builddir=${ac_top_builddir}.;; -*) - case ${ac_top_builddir}. in - .) ac_abs_top_builddir=$ac_abs_builddir;; - [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;; - *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;; - esac;; -esac -case $ac_abs_builddir in -.) ac_abs_srcdir=$ac_srcdir;; -*) - case $ac_srcdir in - .) ac_abs_srcdir=$ac_abs_builddir;; - [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;; - *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;; - esac;; -esac -case $ac_abs_builddir in -.) ac_abs_top_srcdir=$ac_top_srcdir;; -*) - case $ac_top_srcdir in - .) ac_abs_top_srcdir=$ac_abs_builddir;; - [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;; - *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;; - esac;; -esac - - cd $ac_dir - # Check for guested configure; otherwise get Cygnus style configure. - if test -f $ac_srcdir/configure.gnu; then - echo - $SHELL $ac_srcdir/configure.gnu --help=recursive - elif test -f $ac_srcdir/configure; then - echo - $SHELL $ac_srcdir/configure --help=recursive - elif test -f $ac_srcdir/configure.ac || - test -f $ac_srcdir/configure.in; then - echo - $ac_configure --help - else - echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 - fi - cd $ac_popdir - done -fi - -test -n "$ac_init_help" && exit 0 -if $ac_init_version; then - cat <<\_ACEOF - -Copyright (C) 2003 Free Software Foundation, Inc. -This configure script is free software; the Free Software Foundation -gives unlimited permission to copy, distribute and modify it. -_ACEOF - exit 0 -fi -exec 5>config.log -cat >&5 <<_ACEOF -This file contains any messages produced by compilers while -running configure, to aid debugging if configure makes a mistake. - -It was created by $as_me, which was -generated by GNU Autoconf 2.59. Invocation command line was - - $ $0 $@ - -_ACEOF -{ -cat <<_ASUNAME -## --------- ## -## Platform. ## -## --------- ## - -hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` -uname -m = `(uname -m) 2>/dev/null || echo unknown` -uname -r = `(uname -r) 2>/dev/null || echo unknown` -uname -s = `(uname -s) 2>/dev/null || echo unknown` -uname -v = `(uname -v) 2>/dev/null || echo unknown` - -/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` -/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` - -/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` -/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` -/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` -hostinfo = `(hostinfo) 2>/dev/null || echo unknown` -/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` -/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` -/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` - -_ASUNAME - -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - echo "PATH: $as_dir" -done - -} >&5 - -cat >&5 <<_ACEOF - - -## ----------- ## -## Core tests. ## -## ----------- ## - -_ACEOF - - -# Keep a trace of the command line. -# Strip out --no-create and --no-recursion so they do not pile up. -# Strip out --silent because we don't want to record it for future runs. -# Also quote any args containing shell meta-characters. -# Make two passes to allow for proper duplicate-argument suppression. -ac_configure_args= -ac_configure_args0= -ac_configure_args1= -ac_sep= -ac_must_keep_next=false -for ac_pass in 1 2 -do - for ac_arg - do - case $ac_arg in - -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; - -q | -quiet | --quiet | --quie | --qui | --qu | --q \ - | -silent | --silent | --silen | --sile | --sil) - continue ;; - *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) - ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; - esac - case $ac_pass in - 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;; - 2) - ac_configure_args1="$ac_configure_args1 '$ac_arg'" - if test $ac_must_keep_next = true; then - ac_must_keep_next=false # Got value, back to normal. - else - case $ac_arg in - *=* | --config-cache | -C | -disable-* | --disable-* \ - | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ - | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ - | -with-* | --with-* | -without-* | --without-* | --x) - case "$ac_configure_args0 " in - "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; - esac - ;; - -* ) ac_must_keep_next=true ;; - esac - fi - ac_configure_args="$ac_configure_args$ac_sep'$ac_arg'" - # Get rid of the leading space. - ac_sep=" " - ;; - esac - done -done -$as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; } -$as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; } - -# When interrupted or exit'd, cleanup temporary files, and complete -# config.log. We remove comments because anyway the quotes in there -# would cause problems or look ugly. -# WARNING: Be sure not to use single quotes in there, as some shells, -# such as our DU 5.0 friend, will then `close' the trap. -trap 'exit_status=$? - # Save into config.log some information that might help in debugging. - { - echo - - cat <<\_ASBOX -## ---------------- ## -## Cache variables. ## -## ---------------- ## -_ASBOX - echo - # The following way of writing the cache mishandles newlines in values, -{ - (set) 2>&1 | - case `(ac_space='"'"' '"'"'; set | grep ac_space) 2>&1` in - *ac_space=\ *) - sed -n \ - "s/'"'"'/'"'"'\\\\'"'"''"'"'/g; - s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='"'"'\\2'"'"'/p" - ;; - *) - sed -n \ - "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" - ;; - esac; -} - echo - - cat <<\_ASBOX -## ----------------- ## -## Output variables. ## -## ----------------- ## -_ASBOX - echo - for ac_var in $ac_subst_vars - do - eval ac_val=$`echo $ac_var` - echo "$ac_var='"'"'$ac_val'"'"'" - done | sort - echo - - if test -n "$ac_subst_files"; then - cat <<\_ASBOX -## ------------- ## -## Output files. ## -## ------------- ## -_ASBOX - echo - for ac_var in $ac_subst_files - do - eval ac_val=$`echo $ac_var` - echo "$ac_var='"'"'$ac_val'"'"'" - done | sort - echo - fi - - if test -s confdefs.h; then - cat <<\_ASBOX -## ----------- ## -## confdefs.h. ## -## ----------- ## -_ASBOX - echo - sed "/^$/d" confdefs.h | sort - echo - fi - test "$ac_signal" != 0 && - echo "$as_me: caught signal $ac_signal" - echo "$as_me: exit $exit_status" - } >&5 - rm -f core *.core && - rm -rf conftest* confdefs* conf$$* $ac_clean_files && - exit $exit_status - ' 0 -for ac_signal in 1 2 13 15; do - trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal -done -ac_signal=0 - -# confdefs.h avoids OS command line length limits that DEFS can exceed. -rm -rf conftest* confdefs.h -# AIX cpp loses on an empty file, so make sure it contains at least a newline. -echo >confdefs.h - -# Predefined preprocessor variables. - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_NAME "$PACKAGE_NAME" -_ACEOF - - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_TARNAME "$PACKAGE_TARNAME" -_ACEOF - - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_VERSION "$PACKAGE_VERSION" -_ACEOF - - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_STRING "$PACKAGE_STRING" -_ACEOF - - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" -_ACEOF - - -# Let the site file select an alternate cache file if it wants to. -# Prefer explicitly selected file to automatically selected ones. -if test -z "$CONFIG_SITE"; then - if test "x$prefix" != xNONE; then - CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" - else - CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" - fi -fi -for ac_site_file in $CONFIG_SITE; do - if test -r "$ac_site_file"; then - { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5 -echo "$as_me: loading site script $ac_site_file" >&6;} - sed 's/^/| /' "$ac_site_file" >&5 - . "$ac_site_file" - fi -done - -if test -r "$cache_file"; then - # Some versions of bash will fail to source /dev/null (special - # files actually), so we avoid doing that. - if test -f "$cache_file"; then - { echo "$as_me:$LINENO: loading cache $cache_file" >&5 -echo "$as_me: loading cache $cache_file" >&6;} - case $cache_file in - [\\/]* | ?:[\\/]* ) . $cache_file;; - *) . ./$cache_file;; - esac - fi -else - { echo "$as_me:$LINENO: creating cache $cache_file" >&5 -echo "$as_me: creating cache $cache_file" >&6;} - >$cache_file -fi - -# Check that the precious variables saved in the cache have kept the same -# value. -ac_cache_corrupted=false -for ac_var in `(set) 2>&1 | - sed -n 's/^ac_env_\([a-zA-Z_0-9]*\)_set=.*/\1/p'`; do - eval ac_old_set=\$ac_cv_env_${ac_var}_set - eval ac_new_set=\$ac_env_${ac_var}_set - eval ac_old_val="\$ac_cv_env_${ac_var}_value" - eval ac_new_val="\$ac_env_${ac_var}_value" - case $ac_old_set,$ac_new_set in - set,) - { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 -echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} - ac_cache_corrupted=: ;; - ,set) - { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5 -echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} - ac_cache_corrupted=: ;; - ,);; - *) - if test "x$ac_old_val" != "x$ac_new_val"; then - { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5 -echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} - { echo "$as_me:$LINENO: former value: $ac_old_val" >&5 -echo "$as_me: former value: $ac_old_val" >&2;} - { echo "$as_me:$LINENO: current value: $ac_new_val" >&5 -echo "$as_me: current value: $ac_new_val" >&2;} - ac_cache_corrupted=: - fi;; - esac - # Pass precious variables to config.status. - if test "$ac_new_set" = set; then - case $ac_new_val in - *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) - ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; - *) ac_arg=$ac_var=$ac_new_val ;; - esac - case " $ac_configure_args " in - *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. - *) ac_configure_args="$ac_configure_args '$ac_arg'" ;; - esac - fi -done -if $ac_cache_corrupted; then - { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5 -echo "$as_me: error: changes in the environment can compromise the build" >&2;} - { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5 -echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;} - { (exit 1); exit 1; }; } -fi - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - - - - - - - - - - - - - - - - - - - - -{ echo "$as_me:$LINENO: Configuring ccache" >&5 -echo "$as_me: Configuring ccache" >&6;} - - ac_config_headers="$ac_config_headers config.h" - - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. -set dummy ${ac_tool_prefix}gcc; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_prog_CC+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_CC="${ac_tool_prefix}gcc" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - echo "$as_me:$LINENO: result: $CC" >&5 -echo "${ECHO_T}$CC" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - -fi -if test -z "$ac_cv_prog_CC"; then - ac_ct_CC=$CC - # Extract the first word of "gcc", so it can be a program name with args. -set dummy gcc; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_prog_ac_ct_CC+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$ac_ct_CC"; then - ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_CC="gcc" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done - -fi -fi -ac_ct_CC=$ac_cv_prog_ac_ct_CC -if test -n "$ac_ct_CC"; then - echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 -echo "${ECHO_T}$ac_ct_CC" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - - CC=$ac_ct_CC -else - CC="$ac_cv_prog_CC" -fi - -if test -z "$CC"; then - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. -set dummy ${ac_tool_prefix}cc; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_prog_CC+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_CC="${ac_tool_prefix}cc" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - echo "$as_me:$LINENO: result: $CC" >&5 -echo "${ECHO_T}$CC" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - -fi -if test -z "$ac_cv_prog_CC"; then - ac_ct_CC=$CC - # Extract the first word of "cc", so it can be a program name with args. -set dummy cc; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_prog_ac_ct_CC+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$ac_ct_CC"; then - ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_CC="cc" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done - -fi -fi -ac_ct_CC=$ac_cv_prog_ac_ct_CC -if test -n "$ac_ct_CC"; then - echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 -echo "${ECHO_T}$ac_ct_CC" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - - CC=$ac_ct_CC -else - CC="$ac_cv_prog_CC" -fi - -fi -if test -z "$CC"; then - # Extract the first word of "cc", so it can be a program name with args. -set dummy cc; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_prog_CC+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else - ac_prog_rejected=no -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then - ac_prog_rejected=yes - continue - fi - ac_cv_prog_CC="cc" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done - -if test $ac_prog_rejected = yes; then - # We found a bogon in the path, so make sure we never use it. - set dummy $ac_cv_prog_CC - shift - if test $# != 0; then - # We chose a different compiler from the bogus one. - # However, it has the same basename, so the bogon will be chosen - # first if we set CC to just the basename; use the full file name. - shift - ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" - fi -fi -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - echo "$as_me:$LINENO: result: $CC" >&5 -echo "${ECHO_T}$CC" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - -fi -if test -z "$CC"; then - if test -n "$ac_tool_prefix"; then - for ac_prog in cl - do - # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. -set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_prog_CC+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_CC="$ac_tool_prefix$ac_prog" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - echo "$as_me:$LINENO: result: $CC" >&5 -echo "${ECHO_T}$CC" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - - test -n "$CC" && break - done -fi -if test -z "$CC"; then - ac_ct_CC=$CC - for ac_prog in cl -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_prog_ac_ct_CC+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$ac_ct_CC"; then - ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_CC="$ac_prog" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done - -fi -fi -ac_ct_CC=$ac_cv_prog_ac_ct_CC -if test -n "$ac_ct_CC"; then - echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 -echo "${ECHO_T}$ac_ct_CC" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - - test -n "$ac_ct_CC" && break -done - - CC=$ac_ct_CC -fi - -fi - - -test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH -See \`config.log' for more details." >&5 -echo "$as_me: error: no acceptable C compiler found in \$PATH -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; } - -# Provide some information about the compiler. -echo "$as_me:$LINENO:" \ - "checking for C compiler version" >&5 -ac_compiler=`set X $ac_compile; echo $2` -{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version &5\"") >&5 - (eval $ac_compiler --version &5) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } -{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v &5\"") >&5 - (eval $ac_compiler -v &5) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } -{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V &5\"") >&5 - (eval $ac_compiler -V &5) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } - -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -ac_clean_files_save=$ac_clean_files -ac_clean_files="$ac_clean_files a.out a.exe b.out" -# Try to create an executable without -o first, disregard a.out. -# It will help us diagnose broken compilers, and finding out an intuition -# of exeext. -echo "$as_me:$LINENO: checking for C compiler default output file name" >&5 -echo $ECHO_N "checking for C compiler default output file name... $ECHO_C" >&6 -ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` -if { (eval echo "$as_me:$LINENO: \"$ac_link_default\"") >&5 - (eval $ac_link_default) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; then - # Find the output, starting from the most likely. This scheme is -# not robust to junk in `.', hence go to wildcards (a.*) only as a last -# resort. - -# Be careful to initialize this variable, since it used to be cached. -# Otherwise an old cache value of `no' led to `EXEEXT = no' in a Makefile. -ac_cv_exeext= -# b.out is created by i960 compilers. -for ac_file in a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out -do - test -f "$ac_file" || continue - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) - ;; - conftest.$ac_ext ) - # This is the source file. - ;; - [ab].out ) - # We found the default executable, but exeext='' is most - # certainly right. - break;; - *.* ) - ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` - # FIXME: I believe we export ac_cv_exeext for Libtool, - # but it would be cool to find out if it's true. Does anybody - # maintain Libtool? --akim. - export ac_cv_exeext - break;; - * ) - break;; - esac -done -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -{ { echo "$as_me:$LINENO: error: C compiler cannot create executables -See \`config.log' for more details." >&5 -echo "$as_me: error: C compiler cannot create executables -See \`config.log' for more details." >&2;} - { (exit 77); exit 77; }; } -fi - -ac_exeext=$ac_cv_exeext -echo "$as_me:$LINENO: result: $ac_file" >&5 -echo "${ECHO_T}$ac_file" >&6 - -# Check the compiler produces executables we can run. If not, either -# the compiler is broken, or we cross compile. -echo "$as_me:$LINENO: checking whether the C compiler works" >&5 -echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6 -# FIXME: These cross compiler hacks should be removed for Autoconf 3.0 -# If not cross compiling, check that we can run a simple program. -if test "$cross_compiling" != yes; then - if { ac_try='./$ac_file' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - cross_compiling=no - else - if test "$cross_compiling" = maybe; then - cross_compiling=yes - else - { { echo "$as_me:$LINENO: error: cannot run C compiled programs. -If you meant to cross compile, use \`--host'. -See \`config.log' for more details." >&5 -echo "$as_me: error: cannot run C compiled programs. -If you meant to cross compile, use \`--host'. -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; } - fi - fi -fi -echo "$as_me:$LINENO: result: yes" >&5 -echo "${ECHO_T}yes" >&6 - -rm -f a.out a.exe conftest$ac_cv_exeext b.out -ac_clean_files=$ac_clean_files_save -# Check the compiler produces executables we can run. If not, either -# the compiler is broken, or we cross compile. -echo "$as_me:$LINENO: checking whether we are cross compiling" >&5 -echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6 -echo "$as_me:$LINENO: result: $cross_compiling" >&5 -echo "${ECHO_T}$cross_compiling" >&6 - -echo "$as_me:$LINENO: checking for suffix of executables" >&5 -echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6 -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; then - # If both `conftest.exe' and `conftest' are `present' (well, observable) -# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will -# work properly (i.e., refer to `conftest.exe'), while it won't with -# `rm'. -for ac_file in conftest.exe conftest conftest.*; do - test -f "$ac_file" || continue - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) ;; - *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` - export ac_cv_exeext - break;; - * ) break;; - esac -done -else - { { echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link -See \`config.log' for more details." >&5 -echo "$as_me: error: cannot compute suffix of executables: cannot compile and link -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; } -fi - -rm -f conftest$ac_cv_exeext -echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5 -echo "${ECHO_T}$ac_cv_exeext" >&6 - -rm -f conftest.$ac_ext -EXEEXT=$ac_cv_exeext -ac_exeext=$EXEEXT -echo "$as_me:$LINENO: checking for suffix of object files" >&5 -echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6 -if test "${ac_cv_objext+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.o conftest.obj -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; then - for ac_file in `(ls conftest.o conftest.obj; ls conftest.*) 2>/dev/null`; do - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg ) ;; - *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` - break;; - esac -done -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -{ { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile -See \`config.log' for more details." >&5 -echo "$as_me: error: cannot compute suffix of object files: cannot compile -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; } -fi - -rm -f conftest.$ac_cv_objext conftest.$ac_ext -fi -echo "$as_me:$LINENO: result: $ac_cv_objext" >&5 -echo "${ECHO_T}$ac_cv_objext" >&6 -OBJEXT=$ac_cv_objext -ac_objext=$OBJEXT -echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 -echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6 -if test "${ac_cv_c_compiler_gnu+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -int -main () -{ -#ifndef __GNUC__ - choke me -#endif - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_compiler_gnu=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_compiler_gnu=no -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -ac_cv_c_compiler_gnu=$ac_compiler_gnu - -fi -echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 -echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6 -GCC=`test $ac_compiler_gnu = yes && echo yes` -ac_test_CFLAGS=${CFLAGS+set} -ac_save_CFLAGS=$CFLAGS -CFLAGS="-g" -echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 -echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6 -if test "${ac_cv_prog_cc_g+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_prog_cc_g=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_cv_prog_cc_g=no -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -fi -echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 -echo "${ECHO_T}$ac_cv_prog_cc_g" >&6 -if test "$ac_test_CFLAGS" = set; then - CFLAGS=$ac_save_CFLAGS -elif test $ac_cv_prog_cc_g = yes; then - if test "$GCC" = yes; then - CFLAGS="-g -O2" - else - CFLAGS="-g" - fi -else - if test "$GCC" = yes; then - CFLAGS="-O2" - else - CFLAGS= - fi -fi -echo "$as_me:$LINENO: checking for $CC option to accept ANSI C" >&5 -echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6 -if test "${ac_cv_prog_cc_stdc+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - ac_cv_prog_cc_stdc=no -ac_save_CC=$CC -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include -#include -#include -#include -/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ -struct buf { int x; }; -FILE * (*rcsopen) (struct buf *, struct stat *, int); -static char *e (p, i) - char **p; - int i; -{ - return p[i]; -} -static char *f (char * (*g) (char **, int), char **p, ...) -{ - char *s; - va_list v; - va_start (v,p); - s = g (p, va_arg (v,int)); - va_end (v); - return s; -} - -/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has - function prototypes and stuff, but not '\xHH' hex character constants. - These don't provoke an error unfortunately, instead are silently treated - as 'x'. The following induces an error, until -std1 is added to get - proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an - array size at least. It's necessary to write '\x00'==0 to get something - that's true only with -std1. */ -int osf4_cc_array ['\x00' == 0 ? 1 : -1]; - -int test (int i, double x); -struct s1 {int (*f) (int a);}; -struct s2 {int (*f) (double a);}; -int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); -int argc; -char **argv; -int -main () -{ -return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; - ; - return 0; -} -_ACEOF -# Don't try gcc -ansi; that turns off useful extensions and -# breaks some systems' header files. -# AIX -qlanglvl=ansi -# Ultrix and OSF/1 -std1 -# HP-UX 10.20 and later -Ae -# HP-UX older versions -Aa -D_HPUX_SOURCE -# SVR4 -Xc -D__EXTENSIONS__ -for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" -do - CC="$ac_save_CC $ac_arg" - rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_prog_cc_stdc=$ac_arg -break -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -fi -rm -f conftest.err conftest.$ac_objext -done -rm -f conftest.$ac_ext conftest.$ac_objext -CC=$ac_save_CC - -fi - -case "x$ac_cv_prog_cc_stdc" in - x|xno) - echo "$as_me:$LINENO: result: none needed" >&5 -echo "${ECHO_T}none needed" >&6 ;; - *) - echo "$as_me:$LINENO: result: $ac_cv_prog_cc_stdc" >&5 -echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6 - CC="$CC $ac_cv_prog_cc_stdc" ;; -esac - -# Some people use a C++ compiler to compile C. Since we use `exit', -# in C++ we need to declare it. In case someone uses the same compiler -# for both compiling C and C++ we need to have the C++ compiler decide -# the declaration of exit, since it's the most demanding environment. -cat >conftest.$ac_ext <<_ACEOF -#ifndef __cplusplus - choke me -#endif -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - for ac_declaration in \ - '' \ - 'extern "C" void std::exit (int) throw (); using std::exit;' \ - 'extern "C" void std::exit (int); using std::exit;' \ - 'extern "C" void exit (int) throw ();' \ - 'extern "C" void exit (int);' \ - 'void exit (int);' -do - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_declaration -#include -int -main () -{ -exit (42); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - : -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -continue -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_declaration -int -main () -{ -exit (42); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - break -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -done -rm -f conftest* -if test -n "$ac_declaration"; then - echo '#ifdef __cplusplus' >>confdefs.h - echo $ac_declaration >>confdefs.h - echo '#endif' >>confdefs.h -fi - -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu -echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5 -echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6 -# On Suns, sometimes $CPP names a directory. -if test -n "$CPP" && test -d "$CPP"; then - CPP= -fi -if test -z "$CPP"; then - if test "${ac_cv_prog_CPP+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - # Double quotes because CPP needs to be expanded - for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" - do - ac_preproc_ok=false -for ac_c_preproc_warn_flag in '' yes -do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # Prefer to if __STDC__ is defined, since - # exists even on freestanding compilers. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#ifdef __STDC__ -# include -#else -# include -#endif - Syntax error -_ACEOF -if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 - (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then - : -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - # Broken: fails on valid input. -continue -fi -rm -f conftest.err conftest.$ac_ext - - # OK, works on sane cases. Now check whether non-existent headers - # can be detected and how. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include -_ACEOF -if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 - (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then - # Broken: success on invalid input. -continue -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - # Passes both tests. -ac_preproc_ok=: -break -fi -rm -f conftest.err conftest.$ac_ext - -done -# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.err conftest.$ac_ext -if $ac_preproc_ok; then - break -fi - - done - ac_cv_prog_CPP=$CPP - -fi - CPP=$ac_cv_prog_CPP -else - ac_cv_prog_CPP=$CPP -fi -echo "$as_me:$LINENO: result: $CPP" >&5 -echo "${ECHO_T}$CPP" >&6 -ac_preproc_ok=false -for ac_c_preproc_warn_flag in '' yes -do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # Prefer to if __STDC__ is defined, since - # exists even on freestanding compilers. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#ifdef __STDC__ -# include -#else -# include -#endif - Syntax error -_ACEOF -if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 - (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then - : -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - # Broken: fails on valid input. -continue -fi -rm -f conftest.err conftest.$ac_ext - - # OK, works on sane cases. Now check whether non-existent headers - # can be detected and how. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include -_ACEOF -if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 - (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then - # Broken: success on invalid input. -continue -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - # Passes both tests. -ac_preproc_ok=: -break -fi -rm -f conftest.err conftest.$ac_ext - -done -# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.err conftest.$ac_ext -if $ac_preproc_ok; then - : -else - { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check -See \`config.log' for more details." >&5 -echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; } -fi - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - -ac_aux_dir= -for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do - if test -f $ac_dir/install-sh; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/install-sh -c" - break - elif test -f $ac_dir/install.sh; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/install.sh -c" - break - elif test -f $ac_dir/shtool; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/shtool install -c" - break - fi -done -if test -z "$ac_aux_dir"; then - { { echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&5 -echo "$as_me: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&2;} - { (exit 1); exit 1; }; } -fi -ac_config_guess="$SHELL $ac_aux_dir/config.guess" -ac_config_sub="$SHELL $ac_aux_dir/config.sub" -ac_configure="$SHELL $ac_aux_dir/configure" # This should be Cygnus configure. - -# Find a good install program. We prefer a C program (faster), -# so one script is as good as another. But avoid the broken or -# incompatible versions: -# SysV /etc/install, /usr/sbin/install -# SunOS /usr/etc/install -# IRIX /sbin/install -# AIX /bin/install -# AmigaOS /C/install, which installs bootblocks on floppy discs -# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag -# AFS /usr/afsws/bin/install, which mishandles nonexistent args -# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" -# OS/2's system install, which has a completely different semantic -# ./install, which can be erroneously created by make from ./install.sh. -echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5 -echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6 -if test -z "$INSTALL"; then -if test "${ac_cv_path_install+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - # Account for people who put trailing slashes in PATH elements. -case $as_dir/ in - ./ | .// | /cC/* | \ - /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ - ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \ - /usr/ucb/* ) ;; - *) - # OSF1 and SCO ODT 3.0 have their own names for install. - # Don't use installbsd from OSF since it installs stuff as root - # by default. - for ac_prog in ginstall scoinst install; do - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then - if test $ac_prog = install && - grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then - # AIX install. It has an incompatible calling convention. - : - elif test $ac_prog = install && - grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then - # program-specific install script used by HP pwplus--don't use. - : - else - ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" - break 3 - fi - fi - done - done - ;; -esac -done - - -fi - if test "${ac_cv_path_install+set}" = set; then - INSTALL=$ac_cv_path_install - else - # As a last resort, use the slow shell script. We don't cache a - # path for INSTALL within a source directory, because that will - # break other packages using the cache if that directory is - # removed, or if the path is relative. - INSTALL=$ac_install_sh - fi -fi -echo "$as_me:$LINENO: result: $INSTALL" >&5 -echo "${ECHO_T}$INSTALL" >&6 - -# Use test -z because SunOS4 sh mishandles braces in ${var-val}. -# It thinks the first close brace ends the variable substitution. -test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' - -test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' - -test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' - - - -cat >>confdefs.h <<\_ACEOF -#define _GNU_SOURCE 1 -_ACEOF - - -# If GCC, turn on warnings. -if test "x$GCC" = "xyes" -then - CFLAGS="$CFLAGS -Wall -W" -else - CFLAGS="$CFLAGS -O" -fi - - - - - - - -ac_header_dirent=no -for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h; do - as_ac_Header=`echo "ac_cv_header_dirent_$ac_hdr" | $as_tr_sh` -echo "$as_me:$LINENO: checking for $ac_hdr that defines DIR" >&5 -echo $ECHO_N "checking for $ac_hdr that defines DIR... $ECHO_C" >&6 -if eval "test \"\${$as_ac_Header+set}\" = set"; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include -#include <$ac_hdr> - -int -main () -{ -if ((DIR *) 0) -return 0; - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - eval "$as_ac_Header=yes" -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -eval "$as_ac_Header=no" -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -fi -echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 -echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 -if test `eval echo '${'$as_ac_Header'}'` = yes; then - cat >>confdefs.h <<_ACEOF -#define `echo "HAVE_$ac_hdr" | $as_tr_cpp` 1 -_ACEOF - -ac_header_dirent=$ac_hdr; break -fi - -done -# Two versions of opendir et al. are in -ldir and -lx on SCO Xenix. -if test $ac_header_dirent = dirent.h; then - echo "$as_me:$LINENO: checking for library containing opendir" >&5 -echo $ECHO_N "checking for library containing opendir... $ECHO_C" >&6 -if test "${ac_cv_search_opendir+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - ac_func_search_save_LIBS=$LIBS -ac_cv_search_opendir=no -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -/* Override any gcc2 internal prototype to avoid an error. */ -#ifdef __cplusplus -extern "C" -#endif -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char opendir (); -int -main () -{ -opendir (); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_search_opendir="none required" -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -if test "$ac_cv_search_opendir" = no; then - for ac_lib in dir; do - LIBS="-l$ac_lib $ac_func_search_save_LIBS" - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -/* Override any gcc2 internal prototype to avoid an error. */ -#ifdef __cplusplus -extern "C" -#endif -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char opendir (); -int -main () -{ -opendir (); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_search_opendir="-l$ac_lib" -break -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - done -fi -LIBS=$ac_func_search_save_LIBS -fi -echo "$as_me:$LINENO: result: $ac_cv_search_opendir" >&5 -echo "${ECHO_T}$ac_cv_search_opendir" >&6 -if test "$ac_cv_search_opendir" != no; then - test "$ac_cv_search_opendir" = "none required" || LIBS="$ac_cv_search_opendir $LIBS" - -fi - -else - echo "$as_me:$LINENO: checking for library containing opendir" >&5 -echo $ECHO_N "checking for library containing opendir... $ECHO_C" >&6 -if test "${ac_cv_search_opendir+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - ac_func_search_save_LIBS=$LIBS -ac_cv_search_opendir=no -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -/* Override any gcc2 internal prototype to avoid an error. */ -#ifdef __cplusplus -extern "C" -#endif -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char opendir (); -int -main () -{ -opendir (); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_search_opendir="none required" -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -if test "$ac_cv_search_opendir" = no; then - for ac_lib in x; do - LIBS="-l$ac_lib $ac_func_search_save_LIBS" - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -/* Override any gcc2 internal prototype to avoid an error. */ -#ifdef __cplusplus -extern "C" -#endif -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char opendir (); -int -main () -{ -opendir (); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_search_opendir="-l$ac_lib" -break -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - done -fi -LIBS=$ac_func_search_save_LIBS -fi -echo "$as_me:$LINENO: result: $ac_cv_search_opendir" >&5 -echo "${ECHO_T}$ac_cv_search_opendir" >&6 -if test "$ac_cv_search_opendir" != no; then - test "$ac_cv_search_opendir" = "none required" || LIBS="$ac_cv_search_opendir $LIBS" - -fi - -fi - -echo "$as_me:$LINENO: checking whether time.h and sys/time.h may both be included" >&5 -echo $ECHO_N "checking whether time.h and sys/time.h may both be included... $ECHO_C" >&6 -if test "${ac_cv_header_time+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include -#include -#include - -int -main () -{ -if ((struct tm *) 0) -return 0; - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_header_time=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_cv_header_time=no -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -fi -echo "$as_me:$LINENO: result: $ac_cv_header_time" >&5 -echo "${ECHO_T}$ac_cv_header_time" >&6 -if test $ac_cv_header_time = yes; then - -cat >>confdefs.h <<\_ACEOF -#define TIME_WITH_SYS_TIME 1 -_ACEOF - -fi - -echo "$as_me:$LINENO: checking for sys/wait.h that is POSIX.1 compatible" >&5 -echo $ECHO_N "checking for sys/wait.h that is POSIX.1 compatible... $ECHO_C" >&6 -if test "${ac_cv_header_sys_wait_h+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include -#include -#ifndef WEXITSTATUS -# define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8) -#endif -#ifndef WIFEXITED -# define WIFEXITED(stat_val) (((stat_val) & 255) == 0) -#endif - -int -main () -{ - int s; - wait (&s); - s = WIFEXITED (s) ? WEXITSTATUS (s) : 1; - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_header_sys_wait_h=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_cv_header_sys_wait_h=no -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -fi -echo "$as_me:$LINENO: result: $ac_cv_header_sys_wait_h" >&5 -echo "${ECHO_T}$ac_cv_header_sys_wait_h" >&6 -if test $ac_cv_header_sys_wait_h = yes; then - -cat >>confdefs.h <<\_ACEOF -#define HAVE_SYS_WAIT_H 1 -_ACEOF - -fi - - - -echo "$as_me:$LINENO: checking for egrep" >&5 -echo $ECHO_N "checking for egrep... $ECHO_C" >&6 -if test "${ac_cv_prog_egrep+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if echo a | (grep -E '(a|b)') >/dev/null 2>&1 - then ac_cv_prog_egrep='grep -E' - else ac_cv_prog_egrep='egrep' - fi -fi -echo "$as_me:$LINENO: result: $ac_cv_prog_egrep" >&5 -echo "${ECHO_T}$ac_cv_prog_egrep" >&6 - EGREP=$ac_cv_prog_egrep - - -echo "$as_me:$LINENO: checking for ANSI C header files" >&5 -echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6 -if test "${ac_cv_header_stdc+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include -#include -#include -#include - -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_header_stdc=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_cv_header_stdc=no -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext - -if test $ac_cv_header_stdc = yes; then - # SunOS 4.x string.h does not declare mem*, contrary to ANSI. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "memchr" >/dev/null 2>&1; then - : -else - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "free" >/dev/null 2>&1; then - : -else - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. - if test "$cross_compiling" = yes; then - : -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include -#if ((' ' & 0x0FF) == 0x020) -# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') -# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) -#else -# define ISLOWER(c) \ - (('a' <= (c) && (c) <= 'i') \ - || ('j' <= (c) && (c) <= 'r') \ - || ('s' <= (c) && (c) <= 'z')) -# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) -#endif - -#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) -int -main () -{ - int i; - for (i = 0; i < 256; i++) - if (XOR (islower (i), ISLOWER (i)) - || toupper (i) != TOUPPER (i)) - exit(2); - exit (0); -} -_ACEOF -rm -f conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - : -else - echo "$as_me: program exited with status $ac_status" >&5 -echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -( exit $ac_status ) -ac_cv_header_stdc=no -fi -rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext -fi -fi -fi -echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 -echo "${ECHO_T}$ac_cv_header_stdc" >&6 -if test $ac_cv_header_stdc = yes; then - -cat >>confdefs.h <<\_ACEOF -#define STDC_HEADERS 1 -_ACEOF - -fi - -# On IRIX 5.3, sys/types and inttypes.h are conflicting. - - - - - - - - - -for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ - inttypes.h stdint.h unistd.h -do -as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` -echo "$as_me:$LINENO: checking for $ac_header" >&5 -echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 -if eval "test \"\${$as_ac_Header+set}\" = set"; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default - -#include <$ac_header> -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - eval "$as_ac_Header=yes" -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -eval "$as_ac_Header=no" -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -fi -echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 -echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 -if test `eval echo '${'$as_ac_Header'}'` = yes; then - cat >>confdefs.h <<_ACEOF -#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - -fi - -done - - - - - - - -for ac_header in ctype.h strings.h stdlib.h string.h pwd.h -do -as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` -if eval "test \"\${$as_ac_Header+set}\" = set"; then - echo "$as_me:$LINENO: checking for $ac_header" >&5 -echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 -if eval "test \"\${$as_ac_Header+set}\" = set"; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -fi -echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 -echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 -else - # Is the header compilable? -echo "$as_me:$LINENO: checking $ac_header usability" >&5 -echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -#include <$ac_header> -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_header_compiler=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_header_compiler=no -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -echo "${ECHO_T}$ac_header_compiler" >&6 - -# Is the header present? -echo "$as_me:$LINENO: checking $ac_header presence" >&5 -echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include <$ac_header> -_ACEOF -if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 - (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then - ac_header_preproc=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_preproc=no -fi -rm -f conftest.err conftest.$ac_ext -echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -echo "${ECHO_T}$ac_header_preproc" >&6 - -# So? What about this header? -case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in - yes:no: ) - { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 -echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 -echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} - ac_header_preproc=yes - ;; - no:yes:* ) - { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 -echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 -echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 -echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 -echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} - ( - cat <<\_ASBOX -## ------------------------------------------ ## -## Report this to the AC_PACKAGE_NAME lists. ## -## ------------------------------------------ ## -_ASBOX - ) | - sed "s/^/$as_me: WARNING: /" >&2 - ;; -esac -echo "$as_me:$LINENO: checking for $ac_header" >&5 -echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 -if eval "test \"\${$as_ac_Header+set}\" = set"; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - eval "$as_ac_Header=\$ac_header_preproc" -fi -echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 -echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 - -fi -if test `eval echo '${'$as_ac_Header'}'` = yes; then - cat >>confdefs.h <<_ACEOF -#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - -fi - -done - - - - - - - - -for ac_func in realpath snprintf vsnprintf vasprintf asprintf mkstemp -do -as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` -echo "$as_me:$LINENO: checking for $ac_func" >&5 -echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 -if eval "test \"\${$as_ac_var+set}\" = set"; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -/* Define $ac_func to an innocuous variant, in case declares $ac_func. - For example, HP-UX 11i declares gettimeofday. */ -#define $ac_func innocuous_$ac_func - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $ac_func (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include -#endif - -#undef $ac_func - -/* Override any gcc2 internal prototype to avoid an error. */ -#ifdef __cplusplus -extern "C" -{ -#endif -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char $ac_func (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined (__stub_$ac_func) || defined (__stub___$ac_func) -choke me -#else -char (*f) () = $ac_func; -#endif -#ifdef __cplusplus -} -#endif - -int -main () -{ -return f != $ac_func; - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - eval "$as_ac_var=yes" -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -eval "$as_ac_var=no" -fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -fi -echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 -echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 -if test `eval echo '${'$as_ac_var'}'` = yes; then - cat >>confdefs.h <<_ACEOF -#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 -_ACEOF - -fi -done - - - -for ac_func in gethostname getpwuid -do -as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` -echo "$as_me:$LINENO: checking for $ac_func" >&5 -echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 -if eval "test \"\${$as_ac_var+set}\" = set"; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -/* Define $ac_func to an innocuous variant, in case declares $ac_func. - For example, HP-UX 11i declares gettimeofday. */ -#define $ac_func innocuous_$ac_func - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $ac_func (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include -#endif - -#undef $ac_func - -/* Override any gcc2 internal prototype to avoid an error. */ -#ifdef __cplusplus -extern "C" -{ -#endif -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char $ac_func (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined (__stub_$ac_func) || defined (__stub___$ac_func) -choke me -#else -char (*f) () = $ac_func; -#endif -#ifdef __cplusplus -} -#endif - -int -main () -{ -return f != $ac_func; - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - eval "$as_ac_var=yes" -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -eval "$as_ac_var=no" -fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -fi -echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 -echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 -if test `eval echo '${'$as_ac_var'}'` = yes; then - cat >>confdefs.h <<_ACEOF -#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 -_ACEOF - -fi -done - - -echo "$as_me:$LINENO: checking for compar_fn_t in stdlib.h" >&5 -echo $ECHO_N "checking for compar_fn_t in stdlib.h... $ECHO_C" >&6 -if test "${ccache_cv_COMPAR_FN_T+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include -int -main () -{ - -void test_fn(void) { qsort(NULL, 0, 0, (__compar_fn_t)NULL); } - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ccache_cv_COMPAR_FN_T=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ccache_cv_COMPAR_FN_T=no -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -fi -echo "$as_me:$LINENO: result: $ccache_cv_COMPAR_FN_T" >&5 -echo "${ECHO_T}$ccache_cv_COMPAR_FN_T" >&6 -if test x"$ccache_cv_COMPAR_FN_T" = x"yes"; then - -cat >>confdefs.h <<\_ACEOF -#define HAVE_COMPAR_FN_T 1 -_ACEOF - -fi - -echo "$as_me:$LINENO: checking for C99 vsnprintf" >&5 -echo $ECHO_N "checking for C99 vsnprintf... $ECHO_C" >&6 -if test "${ccache_cv_HAVE_C99_VSNPRINTF+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - -if test "$cross_compiling" = yes; then - ccache_cv_HAVE_C99_VSNPRINTF=cross -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -#include -#include -void foo(const char *format, ...) { - va_list ap; - int len; - char buf[5]; - - va_start(ap, format); - len = vsnprintf(0, 0, format, ap); - va_end(ap); - if (len != 5) exit(1); - - if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1); - - exit(0); -} -main() { foo("hello"); } - -_ACEOF -rm -f conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ccache_cv_HAVE_C99_VSNPRINTF=yes -else - echo "$as_me: program exited with status $ac_status" >&5 -echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -( exit $ac_status ) -ccache_cv_HAVE_C99_VSNPRINTF=no -fi -rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext -fi -fi -echo "$as_me:$LINENO: result: $ccache_cv_HAVE_C99_VSNPRINTF" >&5 -echo "${ECHO_T}$ccache_cv_HAVE_C99_VSNPRINTF" >&6 -if test x"$ccache_cv_HAVE_C99_VSNPRINTF" = x"yes"; then - -cat >>confdefs.h <<\_ACEOF -#define HAVE_C99_VSNPRINTF 1 -_ACEOF - -fi - -# Check whether --enable-zlib or --disable-zlib was given. -if test "${enable_zlib+set}" = set; then - enableval="$enable_zlib" - -else - enable_zlib=yes -fi; - -if test x"$enable_zlib" = x"yes"; then - if test "${ac_cv_header_zlib_h+set}" = set; then - echo "$as_me:$LINENO: checking for zlib.h" >&5 -echo $ECHO_N "checking for zlib.h... $ECHO_C" >&6 -if test "${ac_cv_header_zlib_h+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -fi -echo "$as_me:$LINENO: result: $ac_cv_header_zlib_h" >&5 -echo "${ECHO_T}$ac_cv_header_zlib_h" >&6 -else - # Is the header compilable? -echo "$as_me:$LINENO: checking zlib.h usability" >&5 -echo $ECHO_N "checking zlib.h usability... $ECHO_C" >&6 -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -#include -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_header_compiler=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_header_compiler=no -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -echo "${ECHO_T}$ac_header_compiler" >&6 - -# Is the header present? -echo "$as_me:$LINENO: checking zlib.h presence" >&5 -echo $ECHO_N "checking zlib.h presence... $ECHO_C" >&6 -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include -_ACEOF -if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 - (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then - ac_header_preproc=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_preproc=no -fi -rm -f conftest.err conftest.$ac_ext -echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -echo "${ECHO_T}$ac_header_preproc" >&6 - -# So? What about this header? -case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in - yes:no: ) - { echo "$as_me:$LINENO: WARNING: zlib.h: accepted by the compiler, rejected by the preprocessor!" >&5 -echo "$as_me: WARNING: zlib.h: accepted by the compiler, rejected by the preprocessor!" >&2;} - { echo "$as_me:$LINENO: WARNING: zlib.h: proceeding with the compiler's result" >&5 -echo "$as_me: WARNING: zlib.h: proceeding with the compiler's result" >&2;} - ac_header_preproc=yes - ;; - no:yes:* ) - { echo "$as_me:$LINENO: WARNING: zlib.h: present but cannot be compiled" >&5 -echo "$as_me: WARNING: zlib.h: present but cannot be compiled" >&2;} - { echo "$as_me:$LINENO: WARNING: zlib.h: check for missing prerequisite headers?" >&5 -echo "$as_me: WARNING: zlib.h: check for missing prerequisite headers?" >&2;} - { echo "$as_me:$LINENO: WARNING: zlib.h: see the Autoconf documentation" >&5 -echo "$as_me: WARNING: zlib.h: see the Autoconf documentation" >&2;} - { echo "$as_me:$LINENO: WARNING: zlib.h: section \"Present But Cannot Be Compiled\"" >&5 -echo "$as_me: WARNING: zlib.h: section \"Present But Cannot Be Compiled\"" >&2;} - { echo "$as_me:$LINENO: WARNING: zlib.h: proceeding with the preprocessor's result" >&5 -echo "$as_me: WARNING: zlib.h: proceeding with the preprocessor's result" >&2;} - { echo "$as_me:$LINENO: WARNING: zlib.h: in the future, the compiler will take precedence" >&5 -echo "$as_me: WARNING: zlib.h: in the future, the compiler will take precedence" >&2;} - ( - cat <<\_ASBOX -## ------------------------------------------ ## -## Report this to the AC_PACKAGE_NAME lists. ## -## ------------------------------------------ ## -_ASBOX - ) | - sed "s/^/$as_me: WARNING: /" >&2 - ;; -esac -echo "$as_me:$LINENO: checking for zlib.h" >&5 -echo $ECHO_N "checking for zlib.h... $ECHO_C" >&6 -if test "${ac_cv_header_zlib_h+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - ac_cv_header_zlib_h=$ac_header_preproc -fi -echo "$as_me:$LINENO: result: $ac_cv_header_zlib_h" >&5 -echo "${ECHO_T}$ac_cv_header_zlib_h" >&6 - -fi -if test $ac_cv_header_zlib_h = yes; then - echo "$as_me:$LINENO: checking for gzdopen in -lz" >&5 -echo $ECHO_N "checking for gzdopen in -lz... $ECHO_C" >&6 -if test "${ac_cv_lib_z_gzdopen+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lz $LIBS" -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -/* Override any gcc2 internal prototype to avoid an error. */ -#ifdef __cplusplus -extern "C" -#endif -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char gzdopen (); -int -main () -{ -gzdopen (); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_lib_z_gzdopen=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_cv_lib_z_gzdopen=no -fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -echo "$as_me:$LINENO: result: $ac_cv_lib_z_gzdopen" >&5 -echo "${ECHO_T}$ac_cv_lib_z_gzdopen" >&6 -if test $ac_cv_lib_z_gzdopen = yes; then - LIBS="-lz $LIBS"; cat >>confdefs.h <<\_ACEOF -#define ENABLE_ZLIB 1 -_ACEOF - -fi - -fi - - -fi - - ac_config_files="$ac_config_files Makefile" - -cat >confcache <<\_ACEOF -# This file is a shell script that caches the results of configure -# tests run on this system so they can be shared between configure -# scripts and configure runs, see configure's option --config-cache. -# It is not useful on other systems. If it contains results you don't -# want to keep, you may remove or edit it. -# -# config.status only pays attention to the cache file if you give it -# the --recheck option to rerun configure. -# -# `ac_cv_env_foo' variables (set or unset) will be overridden when -# loading this file, other *unset* `ac_cv_foo' will be assigned the -# following values. - -_ACEOF - -# The following way of writing the cache mishandles newlines in values, -# but we know of no workaround that is simple, portable, and efficient. -# So, don't put newlines in cache variables' values. -# Ultrix sh set writes to stderr and can't be redirected directly, -# and sets the high bit in the cache file unless we assign to the vars. -{ - (set) 2>&1 | - case `(ac_space=' '; set | grep ac_space) 2>&1` in - *ac_space=\ *) - # `set' does not quote correctly, so add quotes (double-quote - # substitution turns \\\\ into \\, and sed turns \\ into \). - sed -n \ - "s/'/'\\\\''/g; - s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" - ;; - *) - # `set' quotes correctly as required by POSIX, so do not add quotes. - sed -n \ - "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" - ;; - esac; -} | - sed ' - t clear - : clear - s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ - t end - /^ac_cv_env/!s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ - : end' >>confcache -if diff $cache_file confcache >/dev/null 2>&1; then :; else - if test -w $cache_file; then - test "x$cache_file" != "x/dev/null" && echo "updating cache $cache_file" - cat confcache >$cache_file - else - echo "not updating unwritable cache $cache_file" - fi -fi -rm -f confcache - -test "x$prefix" = xNONE && prefix=$ac_default_prefix -# Let make expand exec_prefix. -test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' - -# VPATH may cause trouble with some makes, so we remove $(srcdir), -# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and -# trailing colons and then remove the whole line if VPATH becomes empty -# (actually we leave an empty line to preserve line numbers). -if test "x$srcdir" = x.; then - ac_vpsub='/^[ ]*VPATH[ ]*=/{ -s/:*\$(srcdir):*/:/; -s/:*\${srcdir}:*/:/; -s/:*@srcdir@:*/:/; -s/^\([^=]*=[ ]*\):*/\1/; -s/:*$//; -s/^[^=]*=[ ]*$//; -}' -fi - -DEFS=-DHAVE_CONFIG_H - -ac_libobjs= -ac_ltlibobjs= -for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue - # 1. Remove the extension, and $U if already installed. - ac_i=`echo "$ac_i" | - sed 's/\$U\././;s/\.o$//;s/\.obj$//'` - # 2. Add them. - ac_libobjs="$ac_libobjs $ac_i\$U.$ac_objext" - ac_ltlibobjs="$ac_ltlibobjs $ac_i"'$U.lo' -done -LIBOBJS=$ac_libobjs - -LTLIBOBJS=$ac_ltlibobjs - - - -: ${CONFIG_STATUS=./config.status} -ac_clean_files_save=$ac_clean_files -ac_clean_files="$ac_clean_files $CONFIG_STATUS" -{ echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5 -echo "$as_me: creating $CONFIG_STATUS" >&6;} -cat >$CONFIG_STATUS <<_ACEOF -#! $SHELL -# Generated by $as_me. -# Run this file to recreate the current configuration. -# Compiler output produced by configure, useful for debugging -# configure, is in config.log if it exists. - -debug=false -ac_cs_recheck=false -ac_cs_silent=false -SHELL=\${CONFIG_SHELL-$SHELL} -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF -## --------------------- ## -## M4sh Initialization. ## -## --------------------- ## - -# Be Bourne compatible -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then - emulate sh - NULLCMD=: - # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which - # is contrary to our usage. Disable this feature. - alias -g '${1+"$@"}'='"$@"' -elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then - set -o posix -fi -DUALCASE=1; export DUALCASE # for MKS sh - -# Support unset when possible. -if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then - as_unset=unset -else - as_unset=false -fi - - -# Work around bugs in pre-3.0 UWIN ksh. -$as_unset ENV MAIL MAILPATH -PS1='$ ' -PS2='> ' -PS4='+ ' - -# NLS nuisances. -for as_var in \ - LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ - LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ - LC_TELEPHONE LC_TIME -do - if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then - eval $as_var=C; export $as_var - else - $as_unset $as_var - fi -done - -# Required to use basename. -if expr a : '\(a\)' >/dev/null 2>&1; then - as_expr=expr -else - as_expr=false -fi - -if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then - as_basename=basename -else - as_basename=false -fi - - -# Name of the executable. -as_me=`$as_basename "$0" || -$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ - X"$0" : 'X\(//\)$' \| \ - X"$0" : 'X\(/\)$' \| \ - . : '\(.\)' 2>/dev/null || -echo X/"$0" | - sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; } - /^X\/\(\/\/\)$/{ s//\1/; q; } - /^X\/\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` - - -# PATH needs CR, and LINENO needs CR and PATH. -# Avoid depending upon Character Ranges. -as_cr_letters='abcdefghijklmnopqrstuvwxyz' -as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' -as_cr_Letters=$as_cr_letters$as_cr_LETTERS -as_cr_digits='0123456789' -as_cr_alnum=$as_cr_Letters$as_cr_digits - -# The user is always right. -if test "${PATH_SEPARATOR+set}" != set; then - echo "#! /bin/sh" >conf$$.sh - echo "exit 0" >>conf$$.sh - chmod +x conf$$.sh - if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then - PATH_SEPARATOR=';' - else - PATH_SEPARATOR=: - fi - rm -f conf$$.sh -fi - - - as_lineno_1=$LINENO - as_lineno_2=$LINENO - as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` - test "x$as_lineno_1" != "x$as_lineno_2" && - test "x$as_lineno_3" = "x$as_lineno_2" || { - # Find who we are. Look in the path if we contain no path at all - # relative or not. - case $0 in - *[\\/]* ) as_myself=$0 ;; - *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break -done - - ;; - esac - # We did not find ourselves, most probably we were run as `sh COMMAND' - # in which case we are not to be found in the path. - if test "x$as_myself" = x; then - as_myself=$0 - fi - if test ! -f "$as_myself"; then - { { echo "$as_me:$LINENO: error: cannot find myself; rerun with an absolute path" >&5 -echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2;} - { (exit 1); exit 1; }; } - fi - case $CONFIG_SHELL in - '') - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for as_base in sh bash ksh sh5; do - case $as_dir in - /*) - if ("$as_dir/$as_base" -c ' - as_lineno_1=$LINENO - as_lineno_2=$LINENO - as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` - test "x$as_lineno_1" != "x$as_lineno_2" && - test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then - $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; } - $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; } - CONFIG_SHELL=$as_dir/$as_base - export CONFIG_SHELL - exec "$CONFIG_SHELL" "$0" ${1+"$@"} - fi;; - esac - done -done -;; - esac - - # Create $as_me.lineno as a copy of $as_myself, but with $LINENO - # uniformly replaced by the line number. The first 'sed' inserts a - # line-number line before each line; the second 'sed' does the real - # work. The second script uses 'N' to pair each line-number line - # with the numbered line, and appends trailing '-' during - # substitution so that $LINENO is not a special case at line end. - # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the - # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-) - sed '=' <$as_myself | - sed ' - N - s,$,-, - : loop - s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3, - t loop - s,-$,, - s,^['$as_cr_digits']*\n,, - ' >$as_me.lineno && - chmod +x $as_me.lineno || - { { echo "$as_me:$LINENO: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&5 -echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2;} - { (exit 1); exit 1; }; } - - # Don't try to exec as it changes $[0], causing all sort of problems - # (the dirname of $[0] is not the place where we might find the - # original and so on. Autoconf is especially sensible to this). - . ./$as_me.lineno - # Exit status is that of the last command. - exit -} - - -case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in - *c*,-n*) ECHO_N= ECHO_C=' -' ECHO_T=' ' ;; - *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; - *) ECHO_N= ECHO_C='\c' ECHO_T= ;; -esac - -if expr a : '\(a\)' >/dev/null 2>&1; then - as_expr=expr -else - as_expr=false -fi - -rm -f conf$$ conf$$.exe conf$$.file -echo >conf$$.file -if ln -s conf$$.file conf$$ 2>/dev/null; then - # We could just check for DJGPP; but this test a) works b) is more generic - # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). - if test -f conf$$.exe; then - # Don't use ln at all; we don't have any links - as_ln_s='cp -p' - else - as_ln_s='ln -s' - fi -elif ln conf$$.file conf$$ 2>/dev/null; then - as_ln_s=ln -else - as_ln_s='cp -p' -fi -rm -f conf$$ conf$$.exe conf$$.file - -if mkdir -p . 2>/dev/null; then - as_mkdir_p=: -else - test -d ./-p && rmdir ./-p - as_mkdir_p=false -fi - -as_executable_p="test -f" - -# Sed expression to map a string onto a valid CPP name. -as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" - -# Sed expression to map a string onto a valid variable name. -as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" - - -# IFS -# We need space, tab and new line, in precisely that order. -as_nl=' -' -IFS=" $as_nl" - -# CDPATH. -$as_unset CDPATH - -exec 6>&1 - -# Open the log real soon, to keep \$[0] and so on meaningful, and to -# report actual input values of CONFIG_FILES etc. instead of their -# values after options handling. Logging --version etc. is OK. -exec 5>>config.log -{ - echo - sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX -## Running $as_me. ## -_ASBOX -} >&5 -cat >&5 <<_CSEOF - -This file was extended by $as_me, which was -generated by GNU Autoconf 2.59. Invocation command line was - - CONFIG_FILES = $CONFIG_FILES - CONFIG_HEADERS = $CONFIG_HEADERS - CONFIG_LINKS = $CONFIG_LINKS - CONFIG_COMMANDS = $CONFIG_COMMANDS - $ $0 $@ - -_CSEOF -echo "on `(hostname || uname -n) 2>/dev/null | sed 1q`" >&5 -echo >&5 -_ACEOF - -# Files that config.status was made for. -if test -n "$ac_config_files"; then - echo "config_files=\"$ac_config_files\"" >>$CONFIG_STATUS -fi - -if test -n "$ac_config_headers"; then - echo "config_headers=\"$ac_config_headers\"" >>$CONFIG_STATUS -fi - -if test -n "$ac_config_links"; then - echo "config_links=\"$ac_config_links\"" >>$CONFIG_STATUS -fi - -if test -n "$ac_config_commands"; then - echo "config_commands=\"$ac_config_commands\"" >>$CONFIG_STATUS -fi - -cat >>$CONFIG_STATUS <<\_ACEOF - -ac_cs_usage="\ -\`$as_me' instantiates files from templates according to the -current configuration. - -Usage: $0 [OPTIONS] [FILE]... - - -h, --help print this help, then exit - -V, --version print version number, then exit - -q, --quiet do not print progress messages - -d, --debug don't remove temporary files - --recheck update $as_me by reconfiguring in the same conditions - --file=FILE[:TEMPLATE] - instantiate the configuration file FILE - --header=FILE[:TEMPLATE] - instantiate the configuration header FILE - -Configuration files: -$config_files - -Configuration headers: -$config_headers - -Report bugs to ." -_ACEOF - -cat >>$CONFIG_STATUS <<_ACEOF -ac_cs_version="\\ -config.status -configured by $0, generated by GNU Autoconf 2.59, - with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\" - -Copyright (C) 2003 Free Software Foundation, Inc. -This config.status script is free software; the Free Software Foundation -gives unlimited permission to copy, distribute and modify it." -srcdir=$srcdir -INSTALL="$INSTALL" -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF -# If no file are specified by the user, then we need to provide default -# value. By we need to know if files were specified by the user. -ac_need_defaults=: -while test $# != 0 -do - case $1 in - --*=*) - ac_option=`expr "x$1" : 'x\([^=]*\)='` - ac_optarg=`expr "x$1" : 'x[^=]*=\(.*\)'` - ac_shift=: - ;; - -*) - ac_option=$1 - ac_optarg=$2 - ac_shift=shift - ;; - *) # This is not an option, so the user has probably given explicit - # arguments. - ac_option=$1 - ac_need_defaults=false;; - esac - - case $ac_option in - # Handling of the options. -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF - -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) - ac_cs_recheck=: ;; - --version | --vers* | -V ) - echo "$ac_cs_version"; exit 0 ;; - --he | --h) - # Conflict between --help and --header - { { echo "$as_me:$LINENO: error: ambiguous option: $1 -Try \`$0 --help' for more information." >&5 -echo "$as_me: error: ambiguous option: $1 -Try \`$0 --help' for more information." >&2;} - { (exit 1); exit 1; }; };; - --help | --hel | -h ) - echo "$ac_cs_usage"; exit 0 ;; - --debug | --d* | -d ) - debug=: ;; - --file | --fil | --fi | --f ) - $ac_shift - CONFIG_FILES="$CONFIG_FILES $ac_optarg" - ac_need_defaults=false;; - --header | --heade | --head | --hea ) - $ac_shift - CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg" - ac_need_defaults=false;; - -q | -quiet | --quiet | --quie | --qui | --qu | --q \ - | -silent | --silent | --silen | --sile | --sil | --si | --s) - ac_cs_silent=: ;; - - # This is an error. - -*) { { echo "$as_me:$LINENO: error: unrecognized option: $1 -Try \`$0 --help' for more information." >&5 -echo "$as_me: error: unrecognized option: $1 -Try \`$0 --help' for more information." >&2;} - { (exit 1); exit 1; }; } ;; - - *) ac_config_targets="$ac_config_targets $1" ;; - - esac - shift -done - -ac_configure_extra_args= - -if $ac_cs_silent; then - exec 6>/dev/null - ac_configure_extra_args="$ac_configure_extra_args --silent" -fi - -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF -if \$ac_cs_recheck; then - echo "running $SHELL $0 " $ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6 - exec $SHELL $0 $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion -fi - -_ACEOF - - - - - -cat >>$CONFIG_STATUS <<\_ACEOF -for ac_config_target in $ac_config_targets -do - case "$ac_config_target" in - # Handling of arguments. - "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;; - "config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; - *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 -echo "$as_me: error: invalid argument: $ac_config_target" >&2;} - { (exit 1); exit 1; }; };; - esac -done - -# If the user did not use the arguments to specify the items to instantiate, -# then the envvar interface is used. Set only those that are not. -# We use the long form for the default assignment because of an extremely -# bizarre bug on SunOS 4.1.3. -if $ac_need_defaults; then - test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files - test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers -fi - -# Have a temporary directory for convenience. Make it in the build tree -# simply because there is no reason to put it here, and in addition, -# creating and moving files from /tmp can sometimes cause problems. -# Create a temporary directory, and hook for its removal unless debugging. -$debug || -{ - trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0 - trap '{ (exit 1); exit 1; }' 1 2 13 15 -} - -# Create a (secure) tmp directory for tmp files. - -{ - tmp=`(umask 077 && mktemp -d -q "./confstatXXXXXX") 2>/dev/null` && - test -n "$tmp" && test -d "$tmp" -} || -{ - tmp=./confstat$$-$RANDOM - (umask 077 && mkdir $tmp) -} || -{ - echo "$me: cannot create a temporary directory in ." >&2 - { (exit 1); exit 1; } -} - -_ACEOF - -cat >>$CONFIG_STATUS <<_ACEOF - -# -# CONFIG_FILES section. -# - -# No need to generate the scripts if there are no CONFIG_FILES. -# This happens for instance when ./config.status config.h -if test -n "\$CONFIG_FILES"; then - # Protect against being on the right side of a sed subst in config.status. - sed 's/,@/@@/; s/@,/@@/; s/,;t t\$/@;t t/; /@;t t\$/s/[\\\\&,]/\\\\&/g; - s/@@/,@/; s/@@/@,/; s/@;t t\$/,;t t/' >\$tmp/subs.sed <<\\CEOF -s,@SHELL@,$SHELL,;t t -s,@PATH_SEPARATOR@,$PATH_SEPARATOR,;t t -s,@PACKAGE_NAME@,$PACKAGE_NAME,;t t -s,@PACKAGE_TARNAME@,$PACKAGE_TARNAME,;t t -s,@PACKAGE_VERSION@,$PACKAGE_VERSION,;t t -s,@PACKAGE_STRING@,$PACKAGE_STRING,;t t -s,@PACKAGE_BUGREPORT@,$PACKAGE_BUGREPORT,;t t -s,@exec_prefix@,$exec_prefix,;t t -s,@prefix@,$prefix,;t t -s,@program_transform_name@,$program_transform_name,;t t -s,@bindir@,$bindir,;t t -s,@sbindir@,$sbindir,;t t -s,@libexecdir@,$libexecdir,;t t -s,@datadir@,$datadir,;t t -s,@sysconfdir@,$sysconfdir,;t t -s,@sharedstatedir@,$sharedstatedir,;t t -s,@localstatedir@,$localstatedir,;t t -s,@libdir@,$libdir,;t t -s,@includedir@,$includedir,;t t -s,@oldincludedir@,$oldincludedir,;t t -s,@infodir@,$infodir,;t t -s,@mandir@,$mandir,;t t -s,@build_alias@,$build_alias,;t t -s,@host_alias@,$host_alias,;t t -s,@target_alias@,$target_alias,;t t -s,@DEFS@,$DEFS,;t t -s,@ECHO_C@,$ECHO_C,;t t -s,@ECHO_N@,$ECHO_N,;t t -s,@ECHO_T@,$ECHO_T,;t t -s,@LIBS@,$LIBS,;t t -s,@CC@,$CC,;t t -s,@CFLAGS@,$CFLAGS,;t t -s,@LDFLAGS@,$LDFLAGS,;t t -s,@CPPFLAGS@,$CPPFLAGS,;t t -s,@ac_ct_CC@,$ac_ct_CC,;t t -s,@EXEEXT@,$EXEEXT,;t t -s,@OBJEXT@,$OBJEXT,;t t -s,@CPP@,$CPP,;t t -s,@INSTALL_PROGRAM@,$INSTALL_PROGRAM,;t t -s,@INSTALL_SCRIPT@,$INSTALL_SCRIPT,;t t -s,@INSTALL_DATA@,$INSTALL_DATA,;t t -s,@EGREP@,$EGREP,;t t -s,@LIBOBJS@,$LIBOBJS,;t t -s,@LTLIBOBJS@,$LTLIBOBJS,;t t -CEOF - -_ACEOF - - cat >>$CONFIG_STATUS <<\_ACEOF - # Split the substitutions into bite-sized pieces for seds with - # small command number limits, like on Digital OSF/1 and HP-UX. - ac_max_sed_lines=48 - ac_sed_frag=1 # Number of current file. - ac_beg=1 # First line for current file. - ac_end=$ac_max_sed_lines # Line after last line for current file. - ac_more_lines=: - ac_sed_cmds= - while $ac_more_lines; do - if test $ac_beg -gt 1; then - sed "1,${ac_beg}d; ${ac_end}q" $tmp/subs.sed >$tmp/subs.frag - else - sed "${ac_end}q" $tmp/subs.sed >$tmp/subs.frag - fi - if test ! -s $tmp/subs.frag; then - ac_more_lines=false - else - # The purpose of the label and of the branching condition is to - # speed up the sed processing (if there are no `@' at all, there - # is no need to browse any of the substitutions). - # These are the two extra sed commands mentioned above. - (echo ':t - /@[a-zA-Z_][a-zA-Z_0-9]*@/!b' && cat $tmp/subs.frag) >$tmp/subs-$ac_sed_frag.sed - if test -z "$ac_sed_cmds"; then - ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed" - else - ac_sed_cmds="$ac_sed_cmds | sed -f $tmp/subs-$ac_sed_frag.sed" - fi - ac_sed_frag=`expr $ac_sed_frag + 1` - ac_beg=$ac_end - ac_end=`expr $ac_end + $ac_max_sed_lines` - fi - done - if test -z "$ac_sed_cmds"; then - ac_sed_cmds=cat - fi -fi # test -n "$CONFIG_FILES" - -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF -for ac_file in : $CONFIG_FILES; do test "x$ac_file" = x: && continue - # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". - case $ac_file in - - | *:- | *:-:* ) # input from stdin - cat >$tmp/stdin - ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` - ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; - *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` - ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; - * ) ac_file_in=$ac_file.in ;; - esac - - # Compute @srcdir@, @top_srcdir@, and @INSTALL@ for subdirectories. - ac_dir=`(dirname "$ac_file") 2>/dev/null || -$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$ac_file" : 'X\(//\)[^/]' \| \ - X"$ac_file" : 'X\(//\)$' \| \ - X"$ac_file" : 'X\(/\)' \| \ - . : '\(.\)' 2>/dev/null || -echo X"$ac_file" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } - /^X\(\/\/\)[^/].*/{ s//\1/; q; } - /^X\(\/\/\)$/{ s//\1/; q; } - /^X\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` - { if $as_mkdir_p; then - mkdir -p "$ac_dir" - else - as_dir="$ac_dir" - as_dirs= - while test ! -d "$as_dir"; do - as_dirs="$as_dir $as_dirs" - as_dir=`(dirname "$as_dir") 2>/dev/null || -$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$as_dir" : 'X\(//\)[^/]' \| \ - X"$as_dir" : 'X\(//\)$' \| \ - X"$as_dir" : 'X\(/\)' \| \ - . : '\(.\)' 2>/dev/null || -echo X"$as_dir" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } - /^X\(\/\/\)[^/].*/{ s//\1/; q; } - /^X\(\/\/\)$/{ s//\1/; q; } - /^X\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` - done - test ! -n "$as_dirs" || mkdir $as_dirs - fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5 -echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;} - { (exit 1); exit 1; }; }; } - - ac_builddir=. - -if test "$ac_dir" != .; then - ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` - # A "../" for each directory in $ac_dir_suffix. - ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` -else - ac_dir_suffix= ac_top_builddir= -fi - -case $srcdir in - .) # No --srcdir option. We are building in place. - ac_srcdir=. - if test -z "$ac_top_builddir"; then - ac_top_srcdir=. - else - ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` - fi ;; - [\\/]* | ?:[\\/]* ) # Absolute path. - ac_srcdir=$srcdir$ac_dir_suffix; - ac_top_srcdir=$srcdir ;; - *) # Relative path. - ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix - ac_top_srcdir=$ac_top_builddir$srcdir ;; -esac - -# Do not use `cd foo && pwd` to compute absolute paths, because -# the directories may not exist. -case `pwd` in -.) ac_abs_builddir="$ac_dir";; -*) - case "$ac_dir" in - .) ac_abs_builddir=`pwd`;; - [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";; - *) ac_abs_builddir=`pwd`/"$ac_dir";; - esac;; -esac -case $ac_abs_builddir in -.) ac_abs_top_builddir=${ac_top_builddir}.;; -*) - case ${ac_top_builddir}. in - .) ac_abs_top_builddir=$ac_abs_builddir;; - [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;; - *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;; - esac;; -esac -case $ac_abs_builddir in -.) ac_abs_srcdir=$ac_srcdir;; -*) - case $ac_srcdir in - .) ac_abs_srcdir=$ac_abs_builddir;; - [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;; - *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;; - esac;; -esac -case $ac_abs_builddir in -.) ac_abs_top_srcdir=$ac_top_srcdir;; -*) - case $ac_top_srcdir in - .) ac_abs_top_srcdir=$ac_abs_builddir;; - [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;; - *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;; - esac;; -esac - - - case $INSTALL in - [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; - *) ac_INSTALL=$ac_top_builddir$INSTALL ;; - esac - - if test x"$ac_file" != x-; then - { echo "$as_me:$LINENO: creating $ac_file" >&5 -echo "$as_me: creating $ac_file" >&6;} - rm -f "$ac_file" - fi - # Let's still pretend it is `configure' which instantiates (i.e., don't - # use $as_me), people would be surprised to read: - # /* config.h. Generated by config.status. */ - if test x"$ac_file" = x-; then - configure_input= - else - configure_input="$ac_file. " - fi - configure_input=$configure_input"Generated from `echo $ac_file_in | - sed 's,.*/,,'` by configure." - - # First look for the input files in the build tree, otherwise in the - # src tree. - ac_file_inputs=`IFS=: - for f in $ac_file_in; do - case $f in - -) echo $tmp/stdin ;; - [\\/$]*) - # Absolute (can't be DOS-style, as IFS=:) - test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 -echo "$as_me: error: cannot find input file: $f" >&2;} - { (exit 1); exit 1; }; } - echo "$f";; - *) # Relative - if test -f "$f"; then - # Build tree - echo "$f" - elif test -f "$srcdir/$f"; then - # Source tree - echo "$srcdir/$f" - else - # /dev/null tree - { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 -echo "$as_me: error: cannot find input file: $f" >&2;} - { (exit 1); exit 1; }; } - fi;; - esac - done` || { (exit 1); exit 1; } -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF - sed "$ac_vpsub -$extrasub -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF -:t -/@[a-zA-Z_][a-zA-Z_0-9]*@/!b -s,@configure_input@,$configure_input,;t t -s,@srcdir@,$ac_srcdir,;t t -s,@abs_srcdir@,$ac_abs_srcdir,;t t -s,@top_srcdir@,$ac_top_srcdir,;t t -s,@abs_top_srcdir@,$ac_abs_top_srcdir,;t t -s,@builddir@,$ac_builddir,;t t -s,@abs_builddir@,$ac_abs_builddir,;t t -s,@top_builddir@,$ac_top_builddir,;t t -s,@abs_top_builddir@,$ac_abs_top_builddir,;t t -s,@INSTALL@,$ac_INSTALL,;t t -" $ac_file_inputs | (eval "$ac_sed_cmds") >$tmp/out - rm -f $tmp/stdin - if test x"$ac_file" != x-; then - mv $tmp/out $ac_file - else - cat $tmp/out - rm -f $tmp/out - fi - -done -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF - -# -# CONFIG_HEADER section. -# - -# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where -# NAME is the cpp macro being defined and VALUE is the value it is being given. -# -# ac_d sets the value in "#define NAME VALUE" lines. -ac_dA='s,^\([ ]*\)#\([ ]*define[ ][ ]*\)' -ac_dB='[ ].*$,\1#\2' -ac_dC=' ' -ac_dD=',;t' -# ac_u turns "#undef NAME" without trailing blanks into "#define NAME VALUE". -ac_uA='s,^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' -ac_uB='$,\1#\2define\3' -ac_uC=' ' -ac_uD=',;t' - -for ac_file in : $CONFIG_HEADERS; do test "x$ac_file" = x: && continue - # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". - case $ac_file in - - | *:- | *:-:* ) # input from stdin - cat >$tmp/stdin - ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` - ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; - *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` - ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; - * ) ac_file_in=$ac_file.in ;; - esac - - test x"$ac_file" != x- && { echo "$as_me:$LINENO: creating $ac_file" >&5 -echo "$as_me: creating $ac_file" >&6;} - - # First look for the input files in the build tree, otherwise in the - # src tree. - ac_file_inputs=`IFS=: - for f in $ac_file_in; do - case $f in - -) echo $tmp/stdin ;; - [\\/$]*) - # Absolute (can't be DOS-style, as IFS=:) - test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 -echo "$as_me: error: cannot find input file: $f" >&2;} - { (exit 1); exit 1; }; } - # Do quote $f, to prevent DOS paths from being IFS'd. - echo "$f";; - *) # Relative - if test -f "$f"; then - # Build tree - echo "$f" - elif test -f "$srcdir/$f"; then - # Source tree - echo "$srcdir/$f" - else - # /dev/null tree - { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 -echo "$as_me: error: cannot find input file: $f" >&2;} - { (exit 1); exit 1; }; } - fi;; - esac - done` || { (exit 1); exit 1; } - # Remove the trailing spaces. - sed 's/[ ]*$//' $ac_file_inputs >$tmp/in - -_ACEOF - -# Transform confdefs.h into two sed scripts, `conftest.defines' and -# `conftest.undefs', that substitutes the proper values into -# config.h.in to produce config.h. The first handles `#define' -# templates, and the second `#undef' templates. -# And first: Protect against being on the right side of a sed subst in -# config.status. Protect against being in an unquoted here document -# in config.status. -rm -f conftest.defines conftest.undefs -# Using a here document instead of a string reduces the quoting nightmare. -# Putting comments in sed scripts is not portable. -# -# `end' is used to avoid that the second main sed command (meant for -# 0-ary CPP macros) applies to n-ary macro definitions. -# See the Autoconf documentation for `clear'. -cat >confdef2sed.sed <<\_ACEOF -s/[\\&,]/\\&/g -s,[\\$`],\\&,g -t clear -: clear -s,^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*\)\(([^)]*)\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1\2${ac_dC}\3${ac_dD},gp -t end -s,^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD},gp -: end -_ACEOF -# If some macros were called several times there might be several times -# the same #defines, which is useless. Nevertheless, we may not want to -# sort them, since we want the *last* AC-DEFINE to be honored. -uniq confdefs.h | sed -n -f confdef2sed.sed >conftest.defines -sed 's/ac_d/ac_u/g' conftest.defines >conftest.undefs -rm -f confdef2sed.sed - -# This sed command replaces #undef with comments. This is necessary, for -# example, in the case of _POSIX_SOURCE, which is predefined and required -# on some systems where configure will not decide to define it. -cat >>conftest.undefs <<\_ACEOF -s,^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*,/* & */, -_ACEOF - -# Break up conftest.defines because some shells have a limit on the size -# of here documents, and old seds have small limits too (100 cmds). -echo ' # Handle all the #define templates only if necessary.' >>$CONFIG_STATUS -echo ' if grep "^[ ]*#[ ]*define" $tmp/in >/dev/null; then' >>$CONFIG_STATUS -echo ' # If there are no defines, we may have an empty if/fi' >>$CONFIG_STATUS -echo ' :' >>$CONFIG_STATUS -rm -f conftest.tail -while grep . conftest.defines >/dev/null -do - # Write a limited-size here document to $tmp/defines.sed. - echo ' cat >$tmp/defines.sed <>$CONFIG_STATUS - # Speed up: don't consider the non `#define' lines. - echo '/^[ ]*#[ ]*define/!b' >>$CONFIG_STATUS - # Work around the forget-to-reset-the-flag bug. - echo 't clr' >>$CONFIG_STATUS - echo ': clr' >>$CONFIG_STATUS - sed ${ac_max_here_lines}q conftest.defines >>$CONFIG_STATUS - echo 'CEOF - sed -f $tmp/defines.sed $tmp/in >$tmp/out - rm -f $tmp/in - mv $tmp/out $tmp/in -' >>$CONFIG_STATUS - sed 1,${ac_max_here_lines}d conftest.defines >conftest.tail - rm -f conftest.defines - mv conftest.tail conftest.defines -done -rm -f conftest.defines -echo ' fi # grep' >>$CONFIG_STATUS -echo >>$CONFIG_STATUS - -# Break up conftest.undefs because some shells have a limit on the size -# of here documents, and old seds have small limits too (100 cmds). -echo ' # Handle all the #undef templates' >>$CONFIG_STATUS -rm -f conftest.tail -while grep . conftest.undefs >/dev/null -do - # Write a limited-size here document to $tmp/undefs.sed. - echo ' cat >$tmp/undefs.sed <>$CONFIG_STATUS - # Speed up: don't consider the non `#undef' - echo '/^[ ]*#[ ]*undef/!b' >>$CONFIG_STATUS - # Work around the forget-to-reset-the-flag bug. - echo 't clr' >>$CONFIG_STATUS - echo ': clr' >>$CONFIG_STATUS - sed ${ac_max_here_lines}q conftest.undefs >>$CONFIG_STATUS - echo 'CEOF - sed -f $tmp/undefs.sed $tmp/in >$tmp/out - rm -f $tmp/in - mv $tmp/out $tmp/in -' >>$CONFIG_STATUS - sed 1,${ac_max_here_lines}d conftest.undefs >conftest.tail - rm -f conftest.undefs - mv conftest.tail conftest.undefs -done -rm -f conftest.undefs - -cat >>$CONFIG_STATUS <<\_ACEOF - # Let's still pretend it is `configure' which instantiates (i.e., don't - # use $as_me), people would be surprised to read: - # /* config.h. Generated by config.status. */ - if test x"$ac_file" = x-; then - echo "/* Generated by configure. */" >$tmp/config.h - else - echo "/* $ac_file. Generated by configure. */" >$tmp/config.h - fi - cat $tmp/in >>$tmp/config.h - rm -f $tmp/in - if test x"$ac_file" != x-; then - if diff $ac_file $tmp/config.h >/dev/null 2>&1; then - { echo "$as_me:$LINENO: $ac_file is unchanged" >&5 -echo "$as_me: $ac_file is unchanged" >&6;} - else - ac_dir=`(dirname "$ac_file") 2>/dev/null || -$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$ac_file" : 'X\(//\)[^/]' \| \ - X"$ac_file" : 'X\(//\)$' \| \ - X"$ac_file" : 'X\(/\)' \| \ - . : '\(.\)' 2>/dev/null || -echo X"$ac_file" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } - /^X\(\/\/\)[^/].*/{ s//\1/; q; } - /^X\(\/\/\)$/{ s//\1/; q; } - /^X\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` - { if $as_mkdir_p; then - mkdir -p "$ac_dir" - else - as_dir="$ac_dir" - as_dirs= - while test ! -d "$as_dir"; do - as_dirs="$as_dir $as_dirs" - as_dir=`(dirname "$as_dir") 2>/dev/null || -$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$as_dir" : 'X\(//\)[^/]' \| \ - X"$as_dir" : 'X\(//\)$' \| \ - X"$as_dir" : 'X\(/\)' \| \ - . : '\(.\)' 2>/dev/null || -echo X"$as_dir" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } - /^X\(\/\/\)[^/].*/{ s//\1/; q; } - /^X\(\/\/\)$/{ s//\1/; q; } - /^X\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` - done - test ! -n "$as_dirs" || mkdir $as_dirs - fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5 -echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;} - { (exit 1); exit 1; }; }; } - - rm -f $ac_file - mv $tmp/config.h $ac_file - fi - else - cat $tmp/config.h - rm -f $tmp/config.h - fi -done -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF - -{ (exit 0); exit 0; } -_ACEOF -chmod +x $CONFIG_STATUS -ac_clean_files=$ac_clean_files_save - - -# configure is writing to config.log, and then calls config.status. -# config.status does its own redirection, appending to config.log. -# Unfortunately, on DOS this fails, as config.log is still kept open -# by configure, so config.status won't be able to write to it; its -# output is simply discarded. So we exec the FD to /dev/null, -# effectively closing config.log, so it can be properly (re)opened and -# appended to by config.status. When coming back to configure, we -# need to make the FD available again. -if test "$no_create" != yes; then - ac_cs_success=: - ac_config_status_args= - test "$silent" = yes && - ac_config_status_args="$ac_config_status_args --quiet" - exec 5>/dev/null - $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false - exec 5>>config.log - # Use ||, not &&, to avoid exiting from the if with $? = 1, which - # would make configure fail if this is the last instruction. - $ac_cs_success || { (exit 1); exit 1; } -fi - From a65e8839121f8bac3f4134d327bc93e91a1f7903 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 7 Nov 2008 17:03:57 +0000 Subject: [PATCH 0164/1680] integrate ccache build git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10920 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CCache/Makefile.in | 13 +++++++------ CCache/ccache.h | 6 ++++-- CCache/ccache_swig_config.h.in | 1 + CCache/configure.in | 3 ++- Makefile.in | 15 +++++++++++++-- autogen.sh | 1 + configure.in | 17 ++++++++++++++--- 7 files changed, 42 insertions(+), 14 deletions(-) create mode 100644 CCache/ccache_swig_config.h.in diff --git a/CCache/Makefile.in b/CCache/Makefile.in index 07b86f0f4..27cc1725f 100644 --- a/CCache/Makefile.in +++ b/CCache/Makefile.in @@ -7,6 +7,7 @@ exec_prefix=@exec_prefix@ bindir=@bindir@ mandir=@mandir@ INSTALLCMD=@INSTALL@ +PACKAGE_NAME=@PACKAGE_NAME@ CC=@CC@ CFLAGS=@CFLAGS@ -I. @@ -17,11 +18,11 @@ OBJS= ccache.o mdfour.o hash.o execute.o util.o args.o stats.o \ cleanup.o snprintf.o unify.o HEADERS = ccache.h mdfour.h -all: ccache$(EXEEXT) +all: $(PACKAGE_NAME)$(EXEEXT) docs: ccache.1 web/ccache-man.html -ccache$(EXEEXT): $(OBJS) $(HEADERS) +$(PACKAGE_NAME)$(EXEEXT): $(OBJS) $(HEADERS) $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) ccache.1: ccache.yo @@ -31,14 +32,14 @@ web/ccache-man.html: ccache.yo mkdir -p man yodl2html -o web/ccache-man.html ccache.yo -install: ccache$(EXEEXT) ccache.1 +install: $(PACKAGE_NAME)$(EXEEXT) ccache.1 ${INSTALLCMD} -d $(DESTDIR)${bindir} - ${INSTALLCMD} -m 755 ccache$(EXEEXT) $(DESTDIR)${bindir} + ${INSTALLCMD} -m 755 $(PACKAGE_NAME)$(EXEEXT) $(DESTDIR)${bindir} ${INSTALLCMD} -d $(DESTDIR)${mandir}/man1 ${INSTALLCMD} -m 644 ${srcdir}/ccache.1 $(DESTDIR)${mandir}/man1/ clean: - /bin/rm -f $(OBJS) *~ ccache$(EXEEXT) + /bin/rm -f $(OBJS) *~ $(PACKAGE_NAME)$(EXEEXT) test: test.sh CC='$(CC)' ./test.sh @@ -46,7 +47,7 @@ test: test.sh check: test distclean: clean - /bin/rm -f Makefile config.h config.sub config.log build-stamp config.status + /bin/rm -f Makefile config.h config.sub config.log build-stamp config.status configure config.h # FIXME: To fix this, test.sh needs to be able to take ccache from the # installed prefix, not from the source dir. diff --git a/CCache/ccache.h b/CCache/ccache.h index 9da406a2e..8b988d37a 100644 --- a/CCache/ccache.h +++ b/CCache/ccache.h @@ -1,4 +1,6 @@ -#define CCACHE_VERSION "2.4" +#include "ccache_swig_config.h" + +#define CCACHE_VERSION SWIG_VERSION #include "config.h" @@ -34,7 +36,7 @@ #define STATUS_FATAL 4 #define STATUS_NOCACHE 5 -#define MYNAME "ccache-swig" +#define MYNAME PACKAGE_NAME #define LIMIT_MULTIPLE 0.8 diff --git a/CCache/ccache_swig_config.h.in b/CCache/ccache_swig_config.h.in new file mode 100644 index 000000000..bbb205f77 --- /dev/null +++ b/CCache/ccache_swig_config.h.in @@ -0,0 +1 @@ +#define SWIG_VERSION "@PACKAGE_VERSION@" diff --git a/CCache/configure.in b/CCache/configure.in index 7dccd6d2a..23f2f72ef 100644 --- a/CCache/configure.in +++ b/CCache/configure.in @@ -1,7 +1,8 @@ dnl Process this file with autoconf to produce a configure script. -AC_INIT() +AC_INIT([ccache-swig], [0.0]) # Get version from SWIG in ccache_swig_config.h.in AC_PREREQ(2.52) +AC_CONFIG_SRCDIR([ccache.h]) AC_MSG_NOTICE([Configuring ccache]) diff --git a/Makefile.in b/Makefile.in index ebfc03656..2b22973ce 100644 --- a/Makefile.in +++ b/Makefile.in @@ -14,16 +14,21 @@ datarootdir = @datarootdir@ SHELL = /bin/sh SWIG_LIB = @swig_lib@ BIN_DIR = @bindir@ +ENABLE_CCACHE = @ENABLE_CCACHE@ TARGET_NOEXE= swig TARGET = $(TARGET_NOEXE)@EXEEXT@ SOURCE = Source +CCACHE = CCache DOCS = Doc/Manual -swig: libfiles source +swig: libfiles source ccache source: @cd $(SOURCE) && $(MAKE) +ccache: + test -z "$(ENABLE_CCACHE)" || (cd $(CCACHE) && $(MAKE)) + libfiles: $(srcdir)/Lib/swigwarn.swg # Files required just for the tarball @@ -349,6 +354,9 @@ clean-docs: @echo cleaning Docs @test -d $(DOCS) || exit 0; cd $(DOCS) && $(MAKE) -s clean +clean-ccache: + test -z "$(ENABLE_CCACHE)" || (cd $(CCACHE) && $(MAKE) -s clean) + maintainer-clean: clean-libfiles @cd $(SOURCE) && $(MAKE) maintainer-clean @@ -358,7 +366,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: distclean-objects clean-examples clean-gifplot distclean-test-suite clean-docs distclean-dead distclean-ccache distclean-objects: distclean-source @@ -371,6 +379,9 @@ distclean-test-suite: @echo distcleaning Examples/test-suite @$(MAKE) -k -s noskip-test-suite ACTION=distclean +distclean-ccache: + test -z "$(ENABLE_CCACHE)" || (cd $(CCACHE) && $(MAKE) -s distclean) + noskip-test-suite: \ noskip-tcl-test-suite \ noskip-perl5-test-suite \ diff --git a/autogen.sh b/autogen.sh index 33f54aa7c..de5ded878 100755 --- a/autogen.sh +++ b/autogen.sh @@ -13,3 +13,4 @@ ${ACLOCAL-aclocal} -I Tools/config ${AUTOHEADER-autoheader} ${AUTOMAKE-automake} --add-missing --copy --force-missing ${AUTOCONF-autoconf} +cd CCache && ${AUTORECONF-autoreconf} diff --git a/configure.in b/configure.in index 42845a1ce..99af00da9 100644 --- a/configure.in +++ b/configure.in @@ -2131,7 +2131,6 @@ case $host in esac AC_DEFINE_UNQUOTED(SWIG_LIB_WIN_UNIX, ["$SWIG_LIB_WIN_UNIX"], [Directory for SWIG system-independent libraries (Unix install on native Windows)]) - AC_CONFIG_FILES([ \ Makefile \ swig.spec \ @@ -2164,7 +2163,19 @@ AC_CONFIG_FILES([ \ Lib/ocaml/swigp4.ml ]) AC_CONFIG_FILES([preinst-swig], [chmod +x preinst-swig]) +AC_CONFIG_FILES([CCache/ccache_swig_config.h]) + +# ccache +AC_ARG_ENABLE([ccache], AS_HELP_STRING([--disable-ccache], [disable building and installation of ccache-swig executable (default enabled)]), [enable_ccache=$enableval], [enable_ccache=yes]) +AC_MSG_CHECKING([whether to enable ccache-swig]) +AC_MSG_RESULT([$enable_ccache]) + +if test "$enable_ccache" = yes; then + AC_CONFIG_SUBDIRS(CCache) + ENABLE_CCACHE=1 +fi + +AC_SUBST(ENABLE_CCACHE) + AC_OUTPUT - - dnl configure.in ends here From 4e4a2d8205c877c3fa1de67e8de54972509b36ae Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 7 Nov 2008 21:25:31 +0000 Subject: [PATCH 0165/1680] update some comments git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10921 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- autogen.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/autogen.sh b/autogen.sh index de5ded878..97916d9f3 100755 --- a/autogen.sh +++ b/autogen.sh @@ -2,9 +2,8 @@ # Bootstrap the development environment - add extra files needed to run configure. # Note autoreconf should do what this file achieves, but it has a bug when working with automake! -# The latest config.guess and config.sub should be copied into Tools/config and checked into SVN -# when upgrading the autotools. Otherwise this script will ensure the latest is copied from -# your autotool installation. +# The latest config.guess and config.sub should be copied into Tools/config. +# This script will ensure the latest is copied from your autotool installation. set -e set -x From c5aae96bfb6922b28056dc558e4c02c1257a293e Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 10 Nov 2008 10:34:25 +0000 Subject: [PATCH 0166/1680] ccache clean git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10922 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Makefile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.in b/Makefile.in index 2b22973ce..abaaa59b9 100644 --- a/Makefile.in +++ b/Makefile.in @@ -322,7 +322,7 @@ broken-%-test-suite: clean: clean-objects clean-libfiles clean-examples clean-gifplot clean-test-suite clean-docs -clean-objects: clean-source +clean-objects: clean-source clean-ccache clean-source: @echo cleaning Source From 53ffa27c5d5e32453a6bd3d9e9c164135eb9d8bf Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 10 Nov 2008 12:07:52 +0000 Subject: [PATCH 0167/1680] rename documentation from ccache to ccache-swig git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10923 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CCache/Makefile.in | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/CCache/Makefile.in b/CCache/Makefile.in index 27cc1725f..c085b8b18 100644 --- a/CCache/Makefile.in +++ b/CCache/Makefile.in @@ -20,23 +20,23 @@ HEADERS = ccache.h mdfour.h all: $(PACKAGE_NAME)$(EXEEXT) -docs: ccache.1 web/ccache-man.html +docs: $(PACKAGE_NAME).1 web/$(PACKAGE_NAME)-man.html $(PACKAGE_NAME)$(EXEEXT): $(OBJS) $(HEADERS) $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) -ccache.1: ccache.yo - -yodl2man -o ccache.1 ccache.yo +$(PACKAGE_NAME).1: ccache.yo + -yodl2man -o $(PACKAGE_NAME).1 ccache.yo -web/ccache-man.html: ccache.yo +web/$(PACKAGE_NAME)-man.html: ccache.yo mkdir -p man - yodl2html -o web/ccache-man.html ccache.yo + yodl2html -o web/$(PACKAGE_NAME)-man.html ccache.yo -install: $(PACKAGE_NAME)$(EXEEXT) ccache.1 +install: $(PACKAGE_NAME)$(EXEEXT) $(PACKAGE_NAME).1 ${INSTALLCMD} -d $(DESTDIR)${bindir} ${INSTALLCMD} -m 755 $(PACKAGE_NAME)$(EXEEXT) $(DESTDIR)${bindir} ${INSTALLCMD} -d $(DESTDIR)${mandir}/man1 - ${INSTALLCMD} -m 644 ${srcdir}/ccache.1 $(DESTDIR)${mandir}/man1/ + ${INSTALLCMD} -m 644 ${srcdir}/$(PACKAGE_NAME).1 $(DESTDIR)${mandir}/man1/ clean: /bin/rm -f $(OBJS) *~ $(PACKAGE_NAME)$(EXEEXT) From 087ae33b7cbe623f31d2149132ec1263a69f516c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 10 Nov 2008 14:37:45 +0000 Subject: [PATCH 0168/1680] add in docs about new CCACHE_VERBOSE and CCACHE_SWIG env variables git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10924 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CCache/README.swig | 2 ++ CCache/ccache.yo | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/CCache/README.swig b/CCache/README.swig index 24bd4ff24..b4d0365c1 100644 --- a/CCache/README.swig +++ b/CCache/README.swig @@ -1,3 +1,5 @@ This directory contains a version of ccache. The initial version was based on ccache-2.4 plus debian patches 01-02, 04-12, see the debian/patches subdirectory. Changes have been made to support cacheing the output from SWIG. The ability to cache c/c++ compiler output has been retained. + +Additional features added are the CCACHE_VERBOSE and CCACHE_SWIG environment variables, see docs. diff --git a/CCache/ccache.yo b/CCache/ccache.yo index 311bead43..3996c5184 100644 --- a/CCache/ccache.yo +++ b/CCache/ccache.yo @@ -135,6 +135,10 @@ dit(bf(CCACHE_LOGFILE)) If you set the CCACHE_LOGFILE environment variable then ccache will write some log information on cache hits and misses in that file. This is useful for tracking down problems. +dit(bf(CCACHE_VERBOSE)) If you set the CCACHE_VERBOSE environment +variable then ccache will display on stdout all the compiler invocations +that it makes. This can useful for debugging unexpected problems. + dit(bf(CCACHE_PATH)) You can optionally set CCACHE_PATH to a colon separated path where ccache will look for the real compilers. If you don't do this then ccache will look for the first executable matching @@ -229,6 +233,10 @@ systems like this you can use the CCACHE_EXTENSION option to override the default. On HP-UX set this environment variable to "i" if you use the aCC compiler. +dit(bf(CCACHE_SWIG)) The CCACHE_SWIG environment variable needs to be +set in order for ccache to work with SWIG. Currently the CCACHE_CPP2 +environment variable also needs to be set in order to work with SWIG. + enddit() manpagesection(CACHE SIZE MANAGEMENT) From e4ef0a23d33fc63f7934f0ac8075088360ff4d0b Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 10 Nov 2008 21:53:15 +0000 Subject: [PATCH 0169/1680] Add Antti Karanta's documentation about the new c# array marshalling library plus some docs on the carrays library git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10925 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/CSharp.html | 328 +++++++++++++++++++++++++++++++++++++-- Doc/Manual/Contents.html | 19 ++- Doc/Manual/Library.html | 6 +- Doc/Manual/Php.html | 5 +- 4 files changed, 334 insertions(+), 24 deletions(-) diff --git a/Doc/Manual/CSharp.html b/Doc/Manual/CSharp.html index a09aa0b93..487167cce 100644 --- a/Doc/Manual/CSharp.html +++ b/Doc/Manual/CSharp.html @@ -11,6 +11,12 @@
    • Introduction
    • Differences to the Java module +
    • C# Arrays +
    • C# Exceptions
      • C# exception example using "check" typemap @@ -402,7 +408,297 @@ Windows users can also get the examples working using a Cygwin or MinGW environment for automatic configuration of the example makefiles. Any one of the three C# compilers (Portable.NET, Mono or Microsoft) can be detected from within a Cygwin or Mingw environment if installed in your path. -

        17.3 C# Exceptions

        +

        17.3 C# Arrays

        + + +

        +There are various ways to pass arrays from C# to C/C++. +The default wrapping treats arrays as pointers and as such simple type wrapper classes are generated, +eg SWIGTYPE_p_int when wrapping the C type int [] or int *. +This gives a rather restricted use of the underlying unmanaged code and the most practical way to use arrays is to enhance or customise +with one of the following three approaches; namely the SWIG C arrays library, P/Invoke default array marshalling or +pinned arrays. +

        + +

        17.3.1 The SWIG C arrays library

        + + +

        +The C arrays library keeps all the array memory in the unmanaged layer. +The library is available to all language modules and is documented in the carrays.i library section. +Please refer to this section for details, but for convenience, the C# usage for the two examples outlined there is shown below. +

        + +

        +For the %array_functions example, the equivalent usage would be: +

        + +

        +
        +SWIGTYPE_p_double a = example.new_doubleArray(10);  // Create an array
        +for (int i=0; i<10; i++)
        +  example.doubleArray_setitem(a,i,2*i);             // Set a value
        +example.print_array(a);                             // Pass to C
        +example.delete_doubleArray(a);                      // Destroy array
        +
        +
        + +

        +and for the %array_class example, the equivalent usage would be: +

        + +

        +
        +doubleArray c = new doubleArray(10);    // Create double[10]
        +for (int i=0; i<10; i++)
        +  c.setitem(i, 2*i);                    // Assign values
        +example.print_array(c.cast());          // Pass to C
        +
        +
        + + +

        17.3.2 Managed arrays using P/Invoke default array marshalling

        + + +

        +In the P/Invoke default marshalling scheme, one needs to designate whether the invoked function will treat a managed +array parameter as input, output, or both. When the function is invoked, the CLR allocates a separate chunk of memory as big as the given managed array, +which is automatically released at the end of the function call. If the array parameter is marked as being input, the content of the managed array is copied +into this buffer when the call is made. Correspondingly, if the array parameter is marked as being output, the contents of the reserved buffer are copied +back into the managed array after the call returns. A pointer to to this buffer +is passed to the native function. +

        + +

        +The reason for allocating a separate buffer is to leave the CLR free to relocate the managed array object +during garbage collection. If the overhead caused by the copying is causing a significant performance penalty, consider pinning the managed array and +passing a direct reference as described in the next section. +

        + +

        +For more information on the subject, see the +Default Marshaling for Arrays article +on MSDN. +

        + + +

        +The P/Invoke default marshalling is supported by the arrays_csharp.i library via the INPUT, OUTPUT and INOUT typemaps. +Let's look at some example usage. Consider the following C function: +

        +
        +void myArrayCopy(int *sourceArray, int *targetArray, int nitems);
        +
        +
        +

        + +

        +We can now instruct SWIG to use the default marshalling typemaps by +

        + +

        +

        +
        +%include "arrays_csharp.i"
        +
        +%apply int INPUT[]  {int *sourceArray}
        +%apply int OUTPUT[] {int *targetArray}
        +
        +
        +

        + +

        +As a result, we get the following method in the module class: +

        + +

        +

        +
        +public static void myArrayCopy(int[] sourceArray, int[] targetArray, int nitems) {
        +    examplePINVOKE.myArrayCopy(sourceArray, targetArray, nitems);
        +}
        +
        +
        +

        + +

        +If we look beneath the surface at the corresponding intermediary class code, we see +that SWIG has generated code that uses attributes +(from the System.Runtime.InteropServices namespace) to tell the CLR to use default +marshalling for the arrays: +

        + +

        +

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

        + +

        +As an example of passing an inout array (i.e. the target function will both read from and +write to the array), consider this C function that swaps a given number of elements +in the given arrays: +

        + +

        +

        +
        +void myArraySwap(int *array1, int *array2, int nitems);
        +
        +
        +

        + +

        +Now, we can instruct SWIG to wrap this by +

        + +

        +

        +
        +%include "arrays_csharp.i"
        +
        +%apply int INOUT[] {int *array1}
        +%apply int INOUT[] {int *array2}
        +
        +
        +

        + +

        +This results in the module class method +

        + +

        +

        +
        +  public static void myArraySwap(int[] array1, int[] array2, int nitems) {
        +    examplePINVOKE.myArraySwap(array1, array2, nitems);
        +  }
        +
        +
        +

        + +

        +and intermediate class method +

        + +

        +

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

        + + +

        17.3.3 Managed arrays using pinning

        + + +

        +It is also possible to pin a given array in memory (i.e. fix its location in memory), obtain a +direct pointer to it, and then pass this pointer to the wrapped C/C++ function. This approach +involves no copying, but it makes the work of the garbage collector harder as +the managed array object can not be relocated before the fix on the array is released. You should avoid +fixing arrays in memory in cases where the control may re-enter the managed side via a callback and/or +another thread may produce enough garbage to trigger garbage collection. +

        + +

        +For more information, see the fixed statement in the C# language reference. +

        + + +

        +Now let's look at an example using pinning, thus avoiding the CLR making copies +of the arrays passed as parameters. The arrays_csharp.i library file again provides the required support via the FIXED typemaps. +Let's use the same function from the previous section: +

        + +
        +
        +void myArrayCopy(int *sourceArray, int *targetArray, int nitems);
        +
        +
        + +

        +We now need to declare the module class method unsafe, as we are using pointers: +

        + +

        +

        +
        +%csmethodmodifiers myArrayCopy "public unsafe";
        + 
        +
        +

        + +

        +Apply the appropriate typemaps to the array parameters: +

        + +

        +

        +
        +%include "arrays_csharp.i"
        +
        +%apply int FIXED[] {int *sourceArray}
        +%apply int FIXED[] {int *targetArray}
        +
        +
        +

        + +

        +Notice that there is no need for separate in, out or inout typemaps as is the +case when using P/Invoke default marshalling. +

        + +

        +As a result, we get the following method in the module class: +

        + +

        +

        +
        +  public unsafe static void myArrayCopy(int[] sourceArray, int[] targetArray, int nitems) {
        +    fixed ( int *swig_ptrTo_sourceArray = sourceArray ) {
        +    fixed ( int *swig_ptrTo_targetArray = targetArray ) {
        +    {
        +      examplePINVOKE.myArrayCopy((IntPtr)swig_ptrTo_sourceArray, (IntPtr)swig_ptrTo_targetArray, nitems);
        +    }
        +    }
        +    }
        +  }
        +
        +
        +

        + +

        +On the method signature level the only difference to the version using P/Invoke default +marshalling is the "unsafe" quantifier, which is required because we are handling pointers. +

        + +

        +Also the intermediate class method looks a little different from the default marshalling +example - the method is expecting an IntPtr as the parameter type. +

        + +

        +

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

        + + + +

        17.4 C# Exceptions

        @@ -499,7 +795,7 @@ set so should only be used when a C# exception is not created.

        -

        17.3.1 C# exception example using "check" typemap

        +

        17.4.1 C# exception example using "check" typemap

        @@ -681,7 +977,7 @@ method and C# code does not handle pending exceptions via the canthrow attribute Actually it will issue this warning for any function beginning with SWIG_CSharpSetPendingException.

        -

        17.3.2 C# exception example using %exception

        +

        17.4.2 C# exception example using %exception

        @@ -746,7 +1042,7 @@ The managed code generated does check for the pending exception as mentioned ear

    -

    17.3.3 C# exception example using exception specifications

    +

    17.4.3 C# exception example using exception specifications

    @@ -803,7 +1099,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_evensonly(int jarg1) { Multiple catch handlers are generated should there be more than one exception specifications declared.

    -

    17.3.4 Custom C# ApplicationException example

    +

    17.4.4 Custom C# ApplicationException example

    @@ -937,7 +1233,7 @@ try {

    -

    17.4 C# Directors

    +

    17.5 C# Directors

    @@ -950,7 +1246,7 @@ The following sections provide information on the C# director implementation and However, the Java directors section should also be read in order to gain more insight into directors.

    -

    17.4.1 Directors example

    +

    17.5.1 Directors example

    @@ -1071,7 +1367,7 @@ CSharpDerived - UIntMethod(123) -

    17.4.2 Directors implementation

    +

    17.5.2 Directors implementation

    @@ -1257,7 +1553,7 @@ void SwigDirector_Base::BaseBoolMethod(Base const &b, bool flag) { -

    17.4.3 Director caveats

    +

    17.5.3 Director caveats

    @@ -1305,7 +1601,7 @@ However, a call from C# to CSharpDefaults.DefaultMethod() will of cours should pass the call on to CSharpDefaults.DefaultMethod(int)using the C++ default value, as shown above.

    -

    17.5 C# Typemap examples

    +

    17.6 C# Typemap examples

    This section includes a few examples of typemaps. For more examples, you @@ -1313,7 +1609,7 @@ might look at the files "csharp.swg" and "typemaps.i" in the SWIG library. -

    17.5.1 Memory management when returning references to member variables

    +

    17.6.1 Memory management when returning references to member variables

    @@ -1437,7 +1733,7 @@ public class Bike : IDisposable { Note the addReference call.

    -

    17.5.2 Memory management for objects passed to the C++ layer

    +

    17.6.2 Memory management for objects passed to the C++ layer

    @@ -1556,7 +1852,7 @@ The 'cscode' typemap simply adds in the specified code into the C# proxy class. -

    17.5.3 Date marshalling using the csin typemap and associated attributes

    +

    17.6.3 Date marshalling using the csin typemap and associated attributes

    @@ -1840,7 +2136,7 @@ public class example { -

    17.5.4 A date example demonstrating marshalling of C# properties

    +

    17.6.4 A date example demonstrating marshalling of C# properties

    @@ -1941,7 +2237,7 @@ Some points to note: -

    17.5.5 Turning wrapped classes into partial classes

    +

    17.6.5 Turning wrapped classes into partial classes

    @@ -2041,7 +2337,7 @@ demonstrating that the class contains methods calling both unmanaged code - The following example is an alternative approach to adding managed code to the generated proxy class.

    -

    17.5.6 Extending proxy classes with additional C# code

    +

    17.6.6 Extending proxy classes with additional C# code

    diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index c3197b9dc..a21de7933 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -162,7 +162,7 @@

  • Character strings and structures
  • Array members
  • Structure data members -
  • C constructors and destructors +
  • C constructors and destructors
  • Adding member functions to C structures
  • Nested structures
  • Other things to note about structure wrapping @@ -272,7 +272,7 @@
  • C Arrays and Pointers @@ -588,6 +588,12 @@ diff --git a/Doc/Manual/Library.html b/Doc/Manual/Library.html index 586e1ecab..7293f31fe 100644 --- a/Doc/Manual/Library.html +++ b/Doc/Manual/Library.html @@ -14,7 +14,7 @@
  • C Arrays and Pointers @@ -316,7 +316,7 @@ In this example, the function int_to_uint() would be used to cast type Note: When working with simple pointers, typemaps can often be used to provide more seamless operation.

    -

    8.2.2 carrays.i

    +

    8.2.2 carrays.i

    @@ -419,7 +419,9 @@ delete_doubleArray(a) # Destroy array +

    %array_class(type,name) +

    diff --git a/Doc/Manual/Php.html b/Doc/Manual/Php.html index 8adbc36b1..20530ad86 100644 --- a/Doc/Manual/Php.html +++ b/Doc/Manual/Php.html @@ -14,7 +14,6 @@

  • Generating PHP Extensions
  • Basic PHP interface @@ -119,6 +118,7 @@ this approach, or provide explicit support for it.

    28.1.1 Building a loadable extension

    +

    To build your module as a dynamically loadable extension, use compilation commands like these (if you aren't using GCC, the commands will be different, @@ -131,7 +131,8 @@ least work for Linux though): gcc -shared example_wrap.o -o example.so -

    28.1.3 Using PHP Extensions

    +

    28.1.2 Using PHP Extensions

    +

    To test the extension from a PHP script, you need to load it first. You From 61001d958f9e9b1feb6688caee7275b92994fa04 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 11 Nov 2008 22:17:40 +0000 Subject: [PATCH 0170/1680] add parameter list (or void) to all C functions git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10926 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/CParse/cparse.h | 4 ++-- Source/DOH/doh.h | 6 +++--- Source/DOH/hash.c | 2 +- Source/DOH/list.c | 2 +- Source/DOH/string.c | 2 +- Source/Swig/getopt.c | 2 +- Source/Swig/include.c | 4 ++-- Source/Swig/scanner.c | 2 +- Source/Swig/swigfile.h | 6 +++--- Source/Swig/swigopt.h | 2 +- Source/Swig/swigscan.h | 2 +- Source/Swig/swigwrap.h | 2 +- Source/Swig/wrapfunc.c | 2 +- 13 files changed, 19 insertions(+), 19 deletions(-) diff --git a/Source/CParse/cparse.h b/Source/CParse/cparse.h index 06a901c0d..0b3737463 100644 --- a/Source/CParse/cparse.h +++ b/Source/CParse/cparse.h @@ -38,12 +38,12 @@ extern "C" { extern void Swig_cparse_follow_locators(int); extern void start_inline(char *, int); extern String *scanner_ccode; - extern int yylex(); + extern int yylex(void); /* parser.y */ extern SwigType *Swig_cparse_type(String *); extern Node *Swig_cparse(File *); - extern Hash *Swig_cparse_features(); + extern Hash *Swig_cparse_features(void); extern void SWIG_cparse_set_compact_default_args(int defargs); extern int SWIG_cparse_template_reduce(int treduce); diff --git a/Source/DOH/doh.h b/Source/DOH/doh.h index e6f52438e..aeac3e32f 100644 --- a/Source/DOH/doh.h +++ b/Source/DOH/doh.h @@ -271,7 +271,7 @@ extern int DohGetmark(DOH *obj); * Strings. * ----------------------------------------------------------------------------- */ -extern DOHString *DohNewStringEmpty(); +extern DOHString *DohNewStringEmpty(void); extern DOHString *DohNewString(const DOH *c); extern DOHString *DohNewStringWithSize(const DOH *c, int len); extern DOHString *DohNewStringf(const DOH *fmt, ...); @@ -309,14 +309,14 @@ extern int DohCopyto(DOHFile * input, DOHFile * output); * List * ----------------------------------------------------------------------------- */ -extern DOHList *DohNewList(); +extern DOHList *DohNewList(void); extern void DohSortList(DOH *lo, int (*cmp) (const DOH *, const DOH *)); /* ----------------------------------------------------------------------------- * Hash * ----------------------------------------------------------------------------- */ -extern DOHHash *DohNewHash(); +extern DOHHash *DohNewHash(void); /* ----------------------------------------------------------------------------- * Void diff --git a/Source/DOH/hash.c b/Source/DOH/hash.c index 62aef10f2..045de8b5b 100644 --- a/Source/DOH/hash.c +++ b/Source/DOH/hash.c @@ -535,7 +535,7 @@ DohObjInfo DohHashType = { * Create a new hash table. * ----------------------------------------------------------------------------- */ -DOH *DohNewHash() { +DOH *DohNewHash(void) { Hash *h; int i; h = (Hash *) DohMalloc(sizeof(Hash)); diff --git a/Source/DOH/list.c b/Source/DOH/list.c index a45731de1..7a1786299 100644 --- a/Source/DOH/list.c +++ b/Source/DOH/list.c @@ -345,7 +345,7 @@ DohObjInfo DohListType = { #define MAXLISTITEMS 8 -DOH *DohNewList() { +DOH *DohNewList(void) { List *l; int i; l = (List *) DohMalloc(sizeof(List)); diff --git a/Source/DOH/string.c b/Source/DOH/string.c index 1498d717a..141cd58e8 100644 --- a/Source/DOH/string.c +++ b/Source/DOH/string.c @@ -1056,7 +1056,7 @@ DOHString *DohNewString(const DOH *so) { * NewStringEmpty() - Create a new string * ----------------------------------------------------------------------------- */ -DOHString *DohNewStringEmpty() { +DOHString *DohNewStringEmpty(void) { int max = INIT_MAXSIZE; String *str = (String *) DohMalloc(sizeof(String)); str->hashkey = 0; diff --git a/Source/Swig/getopt.c b/Source/Swig/getopt.c index 87b0f7c9d..cbd051d9f 100644 --- a/Source/Swig/getopt.c +++ b/Source/Swig/getopt.c @@ -100,7 +100,7 @@ void Swig_check_options(int check_input) { * Generates a generic error message and exits. * ----------------------------------------------------------------------------- */ -void Swig_arg_error() { +void Swig_arg_error(void) { Printf(stderr, "SWIG : Unable to parse command line options.\n"); Printf(stderr, "Use 'swig -help' for available options.\n"); exit(1); diff --git a/Source/Swig/include.c b/Source/Swig/include.c index 3f47be15b..4c9bd1bf7 100644 --- a/Source/Swig/include.c +++ b/Source/Swig/include.c @@ -73,7 +73,7 @@ void Swig_push_directory(const String_or_char *dirname) { * the preprocessor. * ----------------------------------------------------------------------------- */ -void Swig_pop_directory() { +void Swig_pop_directory(void) { if (!Swig_get_push_dir()) return; if (!pdirectories) @@ -87,7 +87,7 @@ void Swig_pop_directory() { * Returns the full pathname of the last file opened. * ----------------------------------------------------------------------------- */ -String *Swig_last_file() { +String *Swig_last_file(void) { assert(lastpath); return lastpath; } diff --git a/Source/Swig/scanner.c b/Source/Swig/scanner.c index 06e78db37..7ca5b3ea8 100644 --- a/Source/Swig/scanner.c +++ b/Source/Swig/scanner.c @@ -36,7 +36,7 @@ struct Scanner { * Create a new scanner object * ----------------------------------------------------------------------------- */ -Scanner *NewScanner() { +Scanner *NewScanner(void) { Scanner *s; s = (Scanner *) malloc(sizeof(Scanner)); s->line = 1; diff --git a/Source/Swig/swigfile.h b/Source/Swig/swigfile.h index c945fb1ac..7a7ee12b2 100644 --- a/Source/Swig/swigfile.h +++ b/Source/Swig/swigfile.h @@ -11,9 +11,9 @@ extern List *Swig_add_directory(const String_or_char *dirname); extern void Swig_push_directory(const String_or_char *dirname); -extern void Swig_pop_directory(); -extern String *Swig_last_file(); -extern List *Swig_search_path(); +extern void Swig_pop_directory(void); +extern String *Swig_last_file(void); +extern List *Swig_search_path(int syspathvoid); extern FILE *Swig_open(const String_or_char *name); extern String *Swig_read_file(FILE *f); extern String *Swig_include(const String_or_char *name); diff --git a/Source/Swig/swigopt.h b/Source/Swig/swigopt.h index 428d90dce..11eb5ba99 100644 --- a/Source/Swig/swigopt.h +++ b/Source/Swig/swigopt.h @@ -13,4 +13,4 @@ extern void Swig_mark_arg(int n); extern int Swig_check_marked(int n); extern void Swig_check_options(int check_input); - extern void Swig_arg_error(); + extern void Swig_arg_error(void); diff --git a/Source/Swig/swigscan.h b/Source/Swig/swigscan.h index 2486286a9..e521d3c52 100644 --- a/Source/Swig/swigscan.h +++ b/Source/Swig/swigscan.h @@ -11,7 +11,7 @@ typedef struct Scanner Scanner; -extern Scanner *NewScanner(); +extern Scanner *NewScanner(void); extern void DelScanner(Scanner *); extern void Scanner_clear(Scanner *); extern void Scanner_push(Scanner *, String *); diff --git a/Source/Swig/swigwrap.h b/Source/Swig/swigwrap.h index 25eeb6f7f..e2a011c97 100644 --- a/Source/Swig/swigwrap.h +++ b/Source/Swig/swigwrap.h @@ -16,7 +16,7 @@ typedef struct Wrapper { String *code; } Wrapper; -extern Wrapper *NewWrapper(); +extern Wrapper *NewWrapper(void); extern void DelWrapper(Wrapper *w); extern void Wrapper_compact_print_mode_set(int flag); extern void Wrapper_pretty_print(String *str, File *f); diff --git a/Source/Swig/wrapfunc.c b/Source/Swig/wrapfunc.c index 3778066ce..6a65410c4 100644 --- a/Source/Swig/wrapfunc.c +++ b/Source/Swig/wrapfunc.c @@ -23,7 +23,7 @@ static int Max_line_size = 128; * Create a new wrapper function object. * ----------------------------------------------------------------------------- */ -Wrapper *NewWrapper() { +Wrapper *NewWrapper(void) { Wrapper *w; w = (Wrapper *) malloc(sizeof(Wrapper)); w->localh = NewHash(); From 1fe9876d476bb54130907220c5e82ed9c7cb628c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 11 Nov 2008 22:28:18 +0000 Subject: [PATCH 0171/1680] fix Swig_search_path declaration git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10927 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/CParse/parser.y | 2 +- Source/Swig/include.c | 2 +- Source/Swig/swigfile.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index 69c2a503d..e6a37d4bb 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -203,7 +203,7 @@ static String *yyrename = 0; static String *resolve_node_scope(String *cname); -Hash *Swig_cparse_features() { +Hash *Swig_cparse_features(void) { static Hash *features_hash = 0; if (!features_hash) features_hash = NewHash(); return features_hash; diff --git a/Source/Swig/include.c b/Source/Swig/include.c index 4c9bd1bf7..670c5f5f5 100644 --- a/Source/Swig/include.c +++ b/Source/Swig/include.c @@ -93,7 +93,7 @@ String *Swig_last_file(void) { } /* ----------------------------------------------------------------------------- - * Swig_search_path() + * Swig_search_path_any() * * Returns a list of the current search paths. * ----------------------------------------------------------------------------- */ diff --git a/Source/Swig/swigfile.h b/Source/Swig/swigfile.h index 7a7ee12b2..204eef46c 100644 --- a/Source/Swig/swigfile.h +++ b/Source/Swig/swigfile.h @@ -13,7 +13,7 @@ extern List *Swig_add_directory(const String_or_char *dirname); extern void Swig_push_directory(const String_or_char *dirname); extern void Swig_pop_directory(void); extern String *Swig_last_file(void); -extern List *Swig_search_path(int syspathvoid); +extern List *Swig_search_path(void); extern FILE *Swig_open(const String_or_char *name); extern String *Swig_read_file(FILE *f); extern String *Swig_include(const String_or_char *name); From bfd9e5f3e308182700571f73fdaa48d154c80ac3 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 11 Nov 2008 22:56:36 +0000 Subject: [PATCH 0172/1680] Add patch #2152691 from MATSUURA Takanori which fixes compiles using the Intel compiler git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10928 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++++ Lib/java/javahead.swg | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index 2c59d49ce..c9a620568 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -3,6 +3,10 @@ Version 1.3.37 (in progress) ============================ +2008-11-01: wsfulton + [Java] Add patch #2152691 from MATSUURA Takanori which fixes compiles using the + Intel compiler + 2008-11-01: wsfulton Add patch #2128249 from Anatoly Techtonik which corrects the C/C++ proxy class being reported for Python docstrings when %rename is used. diff --git a/Lib/java/javahead.swg b/Lib/java/javahead.swg index 4aa0c84b5..fc4c4e267 100644 --- a/Lib/java/javahead.swg +++ b/Lib/java/javahead.swg @@ -34,7 +34,7 @@ %insert(runtime) %{ /* Fix for jlong on some versions of gcc on Windows */ -#if defined(__GNUC__) && !defined(__INTELC__) +#if defined(__GNUC__) && !defined(__INTEL_COMPILER) typedef long long __int64; #endif From ef14c8a6f685c5ad47fae2261be5225812ea2256 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 16 Nov 2008 21:13:04 +0000 Subject: [PATCH 0173/1680] Add documentation on typemaps for 'self' based on patch from Art Clarke git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10929 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Typemaps.html | 60 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-) diff --git a/Doc/Manual/Typemaps.html b/Doc/Manual/Typemaps.html index 8f3035dc8..c1e4340f2 100644 --- a/Doc/Manual/Typemaps.html +++ b/Doc/Manual/Typemaps.html @@ -75,6 +75,7 @@

  • More about %apply and %clear
  • Reducing wrapper code size
  • Passing data between typemaps +
  • C++ this pointer
  • Where to go for more information? @@ -3899,8 +3900,65 @@ sure that the typemaps sharing information have exactly the same types and names

    -

    10.15 Where to go for more information?

    +

    10.15 C++ "this" pointer

    +

    +All the rules discussed for Typemaps apply to C++ as well as C. +However in addition C++ passes an extra parameter into every +non-static class method -- the this pointer. Occasionally it can be +useful to apply a typemap to this pointer (for example to check +and make sure this is non-null before deferencing). +Actually, C also has an the equivalent of the this pointer which is used +when accessing variables in a C struct. +

    +

    +In order to customise the this pointer handling, target a variable named self in your typemaps. +self is the name SWIG uses to refer to the extra parameter in wrapped functions. +

    +

    +For example, if wrapping for Java generation: +

    + +
    +
    +%typemap(check) SWIGTYPE *self %{
    +if (!$1) {
    +  SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "swigCPtr null");
    +  return $null;
    +}
    +%}
    +
    +
    + +

    +In the above case, the $1 variable is expanded into the argument +name that SWIG is using as the this pointer. + +SWIG will then insert the check code before the actual C++ class method +is called, and will raise an exception rather than crash +the Java virtual machine. + +The generated code will look something like: +

    + +
    +
    +  if (!arg1) {
    +    SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException,
    +      "invalid native object; delete() likely already called");
    +    return ;
    +  }
    +  (arg1)->wrappedFunction(...);
    +
    +
    + +

    +Note that if you have a parameter named self then it +will also match the typemap. One work around is to create an interface file that wraps +the method, but give the argument a name other than self. +

    + +

    10.16 Where to go for more information?

    The From 8ac9453f62a92bc02cb27802987337006d2646de Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 16 Nov 2008 21:40:28 +0000 Subject: [PATCH 0174/1680] Fix -nopreprocess option to correctly generate output filenames and display filenames in warnings and errors git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10930 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 11 +++-- Source/CParse/cparse.h | 4 +- Source/CParse/cscanner.c | 13 ++++- Source/CParse/parser.y | 2 + Source/Modules/main.cxx | 104 +++++++++++++++++++++------------------ 5 files changed, 81 insertions(+), 53 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index c9a620568..2bfb3742e 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,9 +1,14 @@ -2008-09-26 Mikel Bancroft - Version 1.3.37 (in progress) ============================ -2008-11-01: wsfulton +2008-11-16: wsfulton + Fix -nopreprocess option to: + - correctly report file names in warning and error messages. + - use the original input filename that created the preprocessed output when + determining the C++ wrapper file name (in the absence of -o). Previously + the name of the input file containing the preprocessed output was used. + +2008-11-11: wsfulton [Java] Add patch #2152691 from MATSUURA Takanori which fixes compiles using the Intel compiler diff --git a/Source/CParse/cparse.h b/Source/CParse/cparse.h index 0b3737463..ecaf1a541 100644 --- a/Source/CParse/cparse.h +++ b/Source/CParse/cparse.h @@ -34,7 +34,9 @@ extern "C" { extern void scanner_ignore_typedef(void); extern void scanner_last_id(int); extern void scanner_clear_rename(void); - extern void scanner_set_location(String_or_char *, int line); + extern void scanner_set_location(String_or_char *file, int line); + extern void scanner_set_main_input_file(String *file); + extern String *scanner_get_main_input_file(); extern void Swig_cparse_follow_locators(int); extern void start_inline(char *, int); extern String *scanner_ccode; diff --git a/Source/CParse/cscanner.c b/Source/CParse/cscanner.c index 871565df8..53e02f723 100644 --- a/Source/CParse/cscanner.c +++ b/Source/CParse/cscanner.c @@ -22,7 +22,10 @@ char cvsroot_cscanner_c[] = "$Id$"; static Scanner *scan = 0; /* Global string containing C code. Used by the parser to grab code blocks */ -DOHString *scanner_ccode = 0; +String *scanner_ccode = 0; + +/* The main file being parsed */ +static String *main_input_file = 0; /* Error reporting/location information */ int cparse_line = 1; @@ -467,6 +470,14 @@ void scanner_next_token(int tok) { next_token = tok; } +void scanner_set_main_input_file(String *file) { + main_input_file = file; +} + +String *scanner_get_main_input_file() { + return main_input_file; +} + /* ---------------------------------------------------------------------------- * int yylex() * diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index e6a37d4bb..8b3639dc9 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -1894,6 +1894,8 @@ include_directive: includetype options string LBRACKET { $1.filename = Copy(cparse_file); $1.line = cparse_line; scanner_set_location(NewString($3),1); + if ($2 && GetFlag($2, "maininput")) + scanner_set_main_input_file(NewString($3)); } interface RBRACKET { String *mname = 0; $$ = $6; diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx index 0992d5539..07c4d18a9 100644 --- a/Source/Modules/main.cxx +++ b/Source/Modules/main.cxx @@ -965,11 +965,6 @@ int SWIG_main(int argc, char *argv[], Language *l) { } } } else { - // Check the suffix for a .c file. If so, we're going to - // declare everything we see as "extern" - - ForceExtern = check_suffix(input_file); - // Run the preprocessor if (Verbose) printf("Preprocessing...\n"); @@ -997,7 +992,7 @@ int SWIG_main(int argc, char *argv[], Language *l) { if (lang_config) { Printf(fs, "\n%%include <%s>\n", lang_config); } - Printf(fs, "%%include \"%s\"\n", Swig_last_file()); + Printf(fs, "%%include(maininput=1) \"%s\"\n", Swig_last_file()); for (i = 0; i < Len(libfiles); i++) { Printf(fs, "\n%%include \"%s\"\n", Getitem(libfiles, i)); } @@ -1006,7 +1001,7 @@ int SWIG_main(int argc, char *argv[], Language *l) { Delete(fs); } else { df = Swig_open(input_file); - cpps = NewFileFromFile(df); + cpps = Swig_read_file(df); } if (Swig_error_count()) { SWIG_exit(EXIT_FAILURE); @@ -1016,47 +1011,53 @@ int SWIG_main(int argc, char *argv[], Language *l) { SWIG_exit(EXIT_SUCCESS); } if (depend) { - String *outfile; - if (!outfile_name) { - if (CPlusPlus || lang->cplus_runtime_mode()) { - outfile = NewStringf("%s_wrap.%s", Swig_file_basename(input_file), cpp_extension); + if (!no_cpp) { + String *outfile; + if (!outfile_name) { + if (CPlusPlus || lang->cplus_runtime_mode()) { + outfile = NewStringf("%s_wrap.%s", Swig_file_basename(input_file), cpp_extension); + } else { + outfile = NewStringf("%s_wrap.c", Swig_file_basename(input_file)); + } } else { - outfile = NewStringf("%s_wrap.c", Swig_file_basename(input_file)); + outfile = NewString(outfile_name); } + if (dependencies_file && Len(dependencies_file) != 0) { + f_dependencies_file = NewFile(dependencies_file, "w", SWIG_output_files()); + if (!f_dependencies_file) { + FileErrorDisplay(dependencies_file); + SWIG_exit(EXIT_FAILURE); + } + } else if (!depend_only) { + String *filename = NewStringf("%s_wrap.%s", Swig_file_basename(input_file), depends_extension); + f_dependencies_file = NewFile(filename, "w", SWIG_output_files()); + if (!f_dependencies_file) { + FileErrorDisplay(filename); + SWIG_exit(EXIT_FAILURE); + } + } else + f_dependencies_file = stdout; + if (dependencies_target) { + Printf(f_dependencies_file, "%s: ", dependencies_target); + } else { + Printf(f_dependencies_file, "%s: ", outfile); + } + List *files = Preprocessor_depend(); + 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)); + } + } + Printf(f_dependencies_file, "\n"); + if (f_dependencies_file != stdout) + Close(f_dependencies_file); + if (depend_only) + SWIG_exit(EXIT_SUCCESS); } else { - outfile = NewString(outfile_name); + Printf(stderr, "Cannot generate dependencies with -nopreprocess\n"); + // Actually we could but it would be inefficient when just generating dependencies, as it would be done after Swig_cparse + SWIG_exit(EXIT_FAILURE); } - if (dependencies_file && Len(dependencies_file) != 0) { - f_dependencies_file = NewFile(dependencies_file, "w", SWIG_output_files()); - if (!f_dependencies_file) { - FileErrorDisplay(dependencies_file); - SWIG_exit(EXIT_FAILURE); - } - } else if (!depend_only) { - String *filename = NewStringf("%s_wrap.%s", Swig_file_basename(input_file), depends_extension); - f_dependencies_file = NewFile(filename, "w", SWIG_output_files()); - if (!f_dependencies_file) { - FileErrorDisplay(filename); - SWIG_exit(EXIT_FAILURE); - } - } else - f_dependencies_file = stdout; - if (dependencies_target) { - Printf(f_dependencies_file, "%s: ", dependencies_target); - } else { - Printf(f_dependencies_file, "%s: ", outfile); - } - List *files = Preprocessor_depend(); - 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)); - } - } - Printf(f_dependencies_file, "\n"); - if (f_dependencies_file != stdout) - Close(f_dependencies_file); - if (depend_only) - SWIG_exit(EXIT_SUCCESS); } Seek(cpps, 0, SEEK_SET); } @@ -1138,18 +1139,20 @@ int SWIG_main(int argc, char *argv[], Language *l) { SWIG_exit(EXIT_FAILURE); } else { /* Set some filename information on the object */ - Setattr(top, "infile", input_file); + String *infile = scanner_get_main_input_file(); + Setattr(top, "infile", infile); // Note: if nopreprocess then infile is the original input file, otherwise input_file + Setattr(top, "inputfile", input_file); if (!outfile_name) { if (CPlusPlus || lang->cplus_runtime_mode()) { - Setattr(top, "outfile", NewStringf("%s_wrap.%s", Swig_file_basename(input_file), cpp_extension)); + Setattr(top, "outfile", NewStringf("%s_wrap.%s", Swig_file_basename(infile), cpp_extension)); } else { - Setattr(top, "outfile", NewStringf("%s_wrap.c", Swig_file_basename(input_file))); + Setattr(top, "outfile", NewStringf("%s_wrap.c", Swig_file_basename(infile))); } } else { Setattr(top, "outfile", outfile_name); } if (!outfile_name_h) { - Setattr(top, "outfile_h", NewStringf("%s_wrap.%s", Swig_file_basename(input_file), hpp_extension)); + Setattr(top, "outfile_h", NewStringf("%s_wrap.%s", Swig_file_basename(infile), hpp_extension)); } else { Setattr(top, "outfile_h", outfile_name_h); } @@ -1157,7 +1160,12 @@ int SWIG_main(int argc, char *argv[], Language *l) { if (Swig_contract_mode_get()) { Swig_contracts(top); } + + // Check the suffix for a c/c++ file. If so, we're going to declare everything we see as "extern" + ForceExtern = check_suffix(input_file); + lang->top(top); + if (browse) { Swig_browser(top, 0); } From a5d91ce4f196bff0c6be54c5339d3b255b10cf56 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 17 Nov 2008 22:43:15 +0000 Subject: [PATCH 0175/1680] add input and output files to hash for correct operation when swig is the compiler. Automatically detect when swig is the compiler. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10931 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CCache/ccache.c | 28 ++++++++++++++++++++-------- CCache/ccache.yo | 7 ++++--- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/CCache/ccache.c b/CCache/ccache.c index 4b7c2944f..0c3c15a0f 100644 --- a/CCache/ccache.c +++ b/CCache/ccache.c @@ -195,7 +195,6 @@ static void to_cache(ARGS *args) x_asprintf(&tmp_stderr, "%s/tmp.stderr.%s", temp_dir, tmp_string()); x_asprintf(&tmp_outfiles, "%s/tmp.outfiles.%s", temp_dir, tmp_string()); - /* TODO swig */ if (output_file) { args_add(args, "-o"); args_add(args, output_file); @@ -384,13 +383,19 @@ static void find_hash(ARGS *args) /* when we are doing the unifying tricks we need to include the input file name in the hash to get the warnings right */ - if (enable_unify) { + if (enable_unify || swig) { hash_string(input_file); } - /* we have to hash the extension, as a .i file isn't treated the same - by the compiler as a .ii file (Note: not strictly necessary for SWIG) */ - hash_string(i_extension); + if (swig) { + if (output_file) { + hash_string(output_file); + } + } else { + /* we have to hash the extension, as a .i file isn't treated the same + by the compiler as a .ii file */ + hash_string(i_extension); + } /* first the arguments */ for (i=1;iargc;i++) { @@ -1055,6 +1060,15 @@ static void process_args(int argc, char **argv) } } +static void detect_swig() +{ + char *basename = str_basename(orig_args->argv[0]); + if (strstr(basename, "swig") || getenv("CCACHE_SWIG")) { + swig = 1; + } + free(basename); +} + /* the main ccache driver function */ static void ccache(int argc, char *argv[]) { @@ -1078,9 +1092,7 @@ static void ccache(int argc, char *argv[]) enable_unify = 1; } - if (getenv("CCACHE_SWIG")) { - swig = 1; - } + detect_swig(); /* process argument list, returning a new set of arguments for pre-processing */ process_args(orig_args->argc, orig_args->argv); diff --git a/CCache/ccache.yo b/CCache/ccache.yo index 3996c5184..8960c8498 100644 --- a/CCache/ccache.yo +++ b/CCache/ccache.yo @@ -233,9 +233,10 @@ systems like this you can use the CCACHE_EXTENSION option to override the default. On HP-UX set this environment variable to "i" if you use the aCC compiler. -dit(bf(CCACHE_SWIG)) The CCACHE_SWIG environment variable needs to be -set in order for ccache to work with SWIG. Currently the CCACHE_CPP2 -environment variable also needs to be set in order to work with SWIG. +dit(bf(CCACHE_SWIG)) When using SWIG as the compiler and it does not +have 'swig' in the executable name, then the CCACHE_SWIG environment +variable needs to be set in order for ccache to work correctly with +SWIG. enddit() From 9cf5256b93f2446365eb3d5f7055e3732b1008e2 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 17 Nov 2008 22:47:55 +0000 Subject: [PATCH 0176/1680] rename java run tests from main to runme for consistency across the languages git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10932 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Java.html | 30 +++++++++---------- Examples/GIFPlot/Java/full/README | 6 ++-- .../Java/full/{main.java => runme.java} | 2 +- Examples/GIFPlot/Java/shadow/README | 4 +-- .../Java/shadow/{main.java => runme.java} | 2 +- Examples/GIFPlot/Java/simple/README | 2 +- .../Java/simple/{main.java => runme.java} | 2 +- Examples/Makefile.in | 2 +- .../java/callback/{main.java => runme.java} | 2 +- Examples/java/class/index.html | 2 +- Examples/java/class/{main.java => runme.java} | 2 +- Examples/java/constants/index.html | 2 +- .../java/constants/{main.java => runme.java} | 2 +- Examples/java/enum/index.html | 2 +- Examples/java/enum/{main.java => runme.java} | 2 +- .../java/extend/{main.java => runme.java} | 2 +- Examples/java/funcptr/index.html | 2 +- .../java/funcptr/{main.java => runme.java} | 2 +- Examples/java/index.html | 4 +-- .../java/multimap/{main.java => runme.java} | 2 +- Examples/java/native/index.html | 2 +- .../java/native/{main.java => runme.java} | 2 +- Examples/java/pointer/index.html | 2 +- .../java/pointer/{main.java => runme.java} | 2 +- Examples/java/reference/index.html | 2 +- .../java/reference/{main.java => runme.java} | 2 +- Examples/java/simple/index.html | 8 ++--- .../java/simple/{main.java => runme.java} | 2 +- Examples/java/template/index.html | 2 +- .../java/template/{main.java => runme.java} | 2 +- Examples/java/typemap/index.html | 2 +- .../java/typemap/{main.java => runme.java} | 2 +- Examples/java/variables/index.html | 2 +- .../java/variables/{main.java => runme.java} | 2 +- 34 files changed, 55 insertions(+), 55 deletions(-) rename Examples/GIFPlot/Java/full/{main.java => runme.java} (99%) rename Examples/GIFPlot/Java/shadow/{main.java => runme.java} (99%) rename Examples/GIFPlot/Java/simple/{main.java => runme.java} (98%) rename Examples/java/callback/{main.java => runme.java} (98%) rename Examples/java/class/{main.java => runme.java} (99%) rename Examples/java/constants/{main.java => runme.java} (98%) rename Examples/java/enum/{main.java => runme.java} (98%) rename Examples/java/extend/{main.java => runme.java} (99%) rename Examples/java/funcptr/{main.java => runme.java} (98%) rename Examples/java/multimap/{main.java => runme.java} (97%) rename Examples/java/native/{main.java => runme.java} (96%) rename Examples/java/pointer/{main.java => runme.java} (98%) rename Examples/java/reference/{main.java => runme.java} (99%) rename Examples/java/simple/{main.java => runme.java} (97%) rename Examples/java/template/{main.java => runme.java} (98%) rename Examples/java/typemap/{main.java => runme.java} (96%) rename Examples/java/variables/{main.java => runme.java} (99%) diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html index 518426f5a..99e7f6c59 100644 --- a/Doc/Manual/Java.html +++ b/Doc/Manual/Java.html @@ -353,9 +353,9 @@ The name of the module is specified using the %module directive or To load your shared native library module in Java, simply use Java's System.loadLibrary method in a Java class:

    -// main.java
    +// runme.java
     
    -public class main {
    +public class runme {
       static {
         System.loadLibrary("example");
       }
    @@ -372,7 +372,7 @@ Compile all the Java files and run:
     
     
     $ javac *.java
    -$ java main
    +$ java runme
     24
     $
     
    @@ -394,12 +394,12 @@ You may get an exception similar to this:

    -$ java main
    +$ java runme
     Exception in thread "main" java.lang.UnsatisfiedLinkError: no example in java.library.path
             at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1312)
             at java.lang.Runtime.loadLibrary0(Runtime.java:749)
             at java.lang.System.loadLibrary(System.java:820)
    -        at main.<clinit>(main.java:5)
    +        at runme.<clinit>(runme.java:5)
     

    @@ -426,7 +426,7 @@ The following exception is indicative of this:

    -$ java main
    +$ java runme
     Exception in thread "main" java.lang.UnsatisfiedLinkError: libexample.so: undefined
     symbol: fact
             at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    @@ -434,7 +434,7 @@ symbol: fact
             at java.lang.ClassLoader.loadLibrary(ClassLoader.java, Compiled Code)
             at java.lang.Runtime.loadLibrary0(Runtime.java, Compiled Code)
             at java.lang.System.loadLibrary(System.java, Compiled Code)
    -        at main.<clinit>(main.java:5)
    +        at runme.<clinit>(runme.java:5)
     $
     
    @@ -3760,7 +3760,7 @@ will produce a familiar looking Java exception: Exception in thread "main" java.lang.OutOfMemoryError: Not enough memory at exampleJNI.malloc(Native Method) at example.malloc(example.java:16) - at main.main(main.java:112) + at runme.main(runme.java:112)
    @@ -6168,9 +6168,9 @@ When this module is compiled, our wrapped C functions can be used by the followi

    -// File main.java
    +// File runme.java
     
    -public class main {
    +public class runme {
     
       static {
         try {
    @@ -6196,7 +6196,7 @@ When compiled and run we get:
     

    -$ java main
    +$ java runme
     argv[0] = Cat
     argv[1] = Dog
     argv[2] = Cow
    @@ -6387,9 +6387,9 @@ The following Java program demonstrates this:
     

    -// File: main.java
    +// File: runme.java
     
    -public class main {
    +public class runme {
     
       static {
         try {
    @@ -6414,7 +6414,7 @@ When compiled and run we get:
     

    -$ java main
    +$ java runme
     1 12.0  340.0
     
    @@ -6474,7 +6474,7 @@ We get:
     Ambulance started
     java.lang.ClassCastException
    -        at main.main(main.java:16)
    +        at runme.main(runme.java:16)
     

    diff --git a/Examples/GIFPlot/Java/full/README b/Examples/GIFPlot/Java/full/README index f536864de..93463ea30 100644 --- a/Examples/GIFPlot/Java/full/README +++ b/Examples/GIFPlot/Java/full/README @@ -1,8 +1,8 @@ This example runs the entire gifplot.h header file through SWIG without -any changes. The program 'main.java' does something a little more -interesting. After doing a make, run it using 'java main'. You'll have to go +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 main.java files between this example and the +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/main.java b/Examples/GIFPlot/Java/full/runme.java similarity index 99% rename from Examples/GIFPlot/Java/full/main.java rename to Examples/GIFPlot/Java/full/runme.java index 8fb65c86d..c47c1e672 100644 --- a/Examples/GIFPlot/Java/full/main.java +++ b/Examples/GIFPlot/Java/full/runme.java @@ -1,7 +1,7 @@ // Plot a 3D function import java.lang.Math; -public class main { +public class runme { static { try { diff --git a/Examples/GIFPlot/Java/shadow/README b/Examples/GIFPlot/Java/shadow/README index 4adbde306..b06c5a8f1 100644 --- a/Examples/GIFPlot/Java/shadow/README +++ b/Examples/GIFPlot/Java/shadow/README @@ -1,5 +1,5 @@ This example uses the file in ../../Interface/gifplot.i to build -an interface with shadow classes. After doing a make, run the program main, ie: 'java main'. +an interface with shadow classes. After doing a make, run the program runme, ie: 'java runme'. -Note the differences in the main.java files between this example and the +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/main.java b/Examples/GIFPlot/Java/shadow/runme.java similarity index 99% rename from Examples/GIFPlot/Java/shadow/main.java rename to Examples/GIFPlot/Java/shadow/runme.java index fbcf6e792..91db03898 100644 --- a/Examples/GIFPlot/Java/shadow/main.java +++ b/Examples/GIFPlot/Java/shadow/runme.java @@ -2,7 +2,7 @@ import java.lang.Math; -public class main { +public class runme { static { try { diff --git a/Examples/GIFPlot/Java/simple/README b/Examples/GIFPlot/Java/simple/README index 1fb8453f0..13ff49611 100644 --- a/Examples/GIFPlot/Java/simple/README +++ b/Examples/GIFPlot/Java/simple/README @@ -1,5 +1,5 @@ This is a very minimalistic example in which just a few functions and constants from library are wrapped and used to draw some simple -shapes. After doing a make, run the java program, ie 'java main'. +shapes. After doing a make, run the java program, ie 'java runme'. diff --git a/Examples/GIFPlot/Java/simple/main.java b/Examples/GIFPlot/Java/simple/runme.java similarity index 98% rename from Examples/GIFPlot/Java/simple/main.java rename to Examples/GIFPlot/Java/simple/runme.java index b165a4baa..2d8d2bb48 100644 --- a/Examples/GIFPlot/Java/simple/main.java +++ b/Examples/GIFPlot/Java/simple/runme.java @@ -1,5 +1,5 @@ -public class main { +public class runme { static { try { diff --git a/Examples/Makefile.in b/Examples/Makefile.in index 7f27ce976..c0ced7022 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -489,7 +489,7 @@ java_cpp: $(SRCS) # ----------------------------------------------------------------- java_clean: - rm -f *_wrap* *~ .~* *.class `find . -name \*.java | grep -v main.java` + rm -f *_wrap* *~ .~* *.class `find . -name \*.java | grep -v runme.java` rm -f core @EXTRA_CLEAN@ rm -f *.@OBJEXT@ *@JAVASO@ diff --git a/Examples/java/callback/main.java b/Examples/java/callback/runme.java similarity index 98% rename from Examples/java/callback/main.java rename to Examples/java/callback/runme.java index 4800f8cc9..4090f0ac3 100644 --- a/Examples/java/callback/main.java +++ b/Examples/java/callback/runme.java @@ -1,4 +1,4 @@ -public class main +public class runme { static { try { diff --git a/Examples/java/class/index.html b/Examples/java/class/index.html index e9db7e94a..cf9130c62 100644 --- a/Examples/java/class/index.html +++ b/Examples/java/class/index.html @@ -88,7 +88,7 @@ Note: when creating a C++ extension, you must run SWIG with the -c++ op

    A sample Java program

    -Click here to see a Java program that calls the C++ functions from Java. +Click here to see a Java program that calls the C++ functions from Java.

    Key points

    diff --git a/Examples/java/class/main.java b/Examples/java/class/runme.java similarity index 99% rename from Examples/java/class/main.java rename to Examples/java/class/runme.java index 8ef35db6d..e1ea0d71c 100644 --- a/Examples/java/class/main.java +++ b/Examples/java/class/runme.java @@ -1,7 +1,7 @@ // This example illustrates how C++ classes can be used from Java using SWIG. // The Java class gets mapped onto the C++ class and behaves as if it is a Java class. -public class main { +public class runme { static { try { System.loadLibrary("example"); diff --git a/Examples/java/constants/index.html b/Examples/java/constants/index.html index 8367d0571..9f1e95a03 100644 --- a/Examples/java/constants/index.html +++ b/Examples/java/constants/index.html @@ -20,7 +20,7 @@ to see a SWIG interface with some constant declarations in it. Click here for the section on constants in the SWIG and Java documentation.

    -Click here to see a Java program that prints out the values +Click here to see a Java program that prints out the values of the constants contained in the above file.

    Key points

      diff --git a/Examples/java/constants/main.java b/Examples/java/constants/runme.java similarity index 98% rename from Examples/java/constants/main.java rename to Examples/java/constants/runme.java index 7130c3d70..2c67d86aa 100644 --- a/Examples/java/constants/main.java +++ b/Examples/java/constants/runme.java @@ -1,6 +1,6 @@ import java.lang.reflect.*; -public class main { +public class runme { static { try { System.loadLibrary("example"); diff --git a/Examples/java/enum/index.html b/Examples/java/enum/index.html index 52c06c5d1..20daf2691 100644 --- a/Examples/java/enum/index.html +++ b/Examples/java/enum/index.html @@ -21,7 +21,7 @@ See the documentation for the other approaches for wrapping enums.
      diff --git a/Examples/java/enum/main.java b/Examples/java/enum/runme.java similarity index 98% rename from Examples/java/enum/main.java rename to Examples/java/enum/runme.java index 8646e0087..56e49af91 100644 --- a/Examples/java/enum/main.java +++ b/Examples/java/enum/runme.java @@ -1,5 +1,5 @@ -public class main { +public class runme { static { try { System.loadLibrary("example"); diff --git a/Examples/java/extend/main.java b/Examples/java/extend/runme.java similarity index 99% rename from Examples/java/extend/main.java rename to Examples/java/extend/runme.java index ee3a94ed0..629bb14a6 100644 --- a/Examples/java/extend/main.java +++ b/Examples/java/extend/runme.java @@ -17,7 +17,7 @@ class CEO extends Manager { } -public class main { +public class runme { static { try { System.loadLibrary("example"); diff --git a/Examples/java/funcptr/index.html b/Examples/java/funcptr/index.html index 0ad2be1cf..56d3baa18 100644 --- a/Examples/java/funcptr/index.html +++ b/Examples/java/funcptr/index.html @@ -66,7 +66,7 @@ Here are some files that illustrate this with a simple example:
    • example.c
    • example.h
    • example.i (SWIG interface) -
    • main.java (Sample program) +
    • runme.java (Sample program)

    Notes

    diff --git a/Examples/java/funcptr/main.java b/Examples/java/funcptr/runme.java similarity index 98% rename from Examples/java/funcptr/main.java rename to Examples/java/funcptr/runme.java index cf81f92b4..cd34c1b65 100644 --- a/Examples/java/funcptr/main.java +++ b/Examples/java/funcptr/runme.java @@ -1,5 +1,5 @@ -public class main { +public class runme { static { try { diff --git a/Examples/java/index.html b/Examples/java/index.html index d98f9a393..007e14dbc 100644 --- a/Examples/java/index.html +++ b/Examples/java/index.html @@ -30,7 +30,7 @@ certain C declarations are turned into constants.

    Running the examples

    Please see the Windows page in the main manual for information on using the examples on Windows.

    -On Unix most of the examples work by making the Makefile before executing the program main.java. The Makefile will output the swig generated JNI c code as well as the Java wrapper classes. Additionally the JNI c/c++ code is compiled into the shared object (dynamic link library) which is needed for dynamic linking to the native code. The Makefiles also compile the Java files using javac. +On Unix most of the examples work by making the Makefile before executing the program runme.java. The Makefile will output the swig generated JNI c code as well as the Java wrapper classes. Additionally the JNI c/c++ code is compiled into the shared object (dynamic link library) which is needed for dynamic linking to the native code. The Makefiles also compile the Java files using javac.

    Ensure that the dynamic link library file is in the appropriate path before executing the Java program. For example in Unix, libexample.so must be in the LD_LIBRARY_PATH.

    @@ -39,7 +39,7 @@ A Unix example:

     $ make
     $ export LD_LIBRARY_PATH=. #ksh 
    -$ java main
    +$ java runme
     

    diff --git a/Examples/java/multimap/main.java b/Examples/java/multimap/runme.java similarity index 97% rename from Examples/java/multimap/main.java rename to Examples/java/multimap/runme.java index 331ac6b89..738330e77 100644 --- a/Examples/java/multimap/main.java +++ b/Examples/java/multimap/runme.java @@ -1,5 +1,5 @@ -public class main { +public class runme { static { try { diff --git a/Examples/java/native/index.html b/Examples/java/native/index.html index 7ecf129ce..1ca51c1e9 100644 --- a/Examples/java/native/index.html +++ b/Examples/java/native/index.html @@ -18,7 +18,7 @@ This example compares wrapping a c global function using the manual way and the

    • example.i. Interface file comparing code wrapped by SWIG and wrapped manually. -
    • main.java. Sample Java program showing calls to both manually wrapped and SWIG wrapped c functions. +
    • runme.java. Sample Java program showing calls to both manually wrapped and SWIG wrapped c functions.

    Notes

    diff --git a/Examples/java/native/main.java b/Examples/java/native/runme.java similarity index 96% rename from Examples/java/native/main.java rename to Examples/java/native/runme.java index f4760bb3d..e9a18b21a 100644 --- a/Examples/java/native/main.java +++ b/Examples/java/native/runme.java @@ -1,5 +1,5 @@ -public class main { +public class runme { static { try { diff --git a/Examples/java/pointer/index.html b/Examples/java/pointer/index.html index c30d549e6..e20fe3328 100644 --- a/Examples/java/pointer/index.html +++ b/Examples/java/pointer/index.html @@ -144,7 +144,7 @@ extraction.

    Notes

    diff --git a/Examples/java/pointer/main.java b/Examples/java/pointer/runme.java similarity index 98% rename from Examples/java/pointer/main.java rename to Examples/java/pointer/runme.java index e96e02eaa..f32f980f9 100644 --- a/Examples/java/pointer/main.java +++ b/Examples/java/pointer/runme.java @@ -1,5 +1,5 @@ -public class main { +public class runme { static { try { diff --git a/Examples/java/reference/index.html b/Examples/java/reference/index.html index 64b129cbb..33c80c50f 100644 --- a/Examples/java/reference/index.html +++ b/Examples/java/reference/index.html @@ -121,7 +121,7 @@ Click here to see a SWIG interface file with these addit

    Sample Java program

    -Click here to see a Java program that manipulates some C++ references. +Click here to see a Java program that manipulates some C++ references.

    Notes:

    diff --git a/Examples/java/reference/main.java b/Examples/java/reference/runme.java similarity index 99% rename from Examples/java/reference/main.java rename to Examples/java/reference/runme.java index 4fd354761..6a2d9bf70 100644 --- a/Examples/java/reference/main.java +++ b/Examples/java/reference/runme.java @@ -1,6 +1,6 @@ // This example illustrates the manipulation of C++ references in Java. -public class main { +public class runme { static { try { System.loadLibrary("example"); diff --git a/Examples/java/simple/index.html b/Examples/java/simple/index.html index a363327fe..9729e6dd8 100644 --- a/Examples/java/simple/index.html +++ b/Examples/java/simple/index.html @@ -65,15 +65,15 @@ to create the extension libexample.so (unix).

    Using the extension

    -Click here to see a program that calls our C functions from Java. +Click here to see a program that calls our C functions from Java.

    -Compile the java files example.java and main.java -to create the class files example.class and main.class before running main in the JVM. Ensure that the libexample.so file is in your LD_LIBRARY_PATH before running. For example: +Compile the java files example.java and runme.java +to create the class files example.class and runme.class before running runme in the JVM. Ensure that the libexample.so file is in your LD_LIBRARY_PATH before running. For example:

     export LD_LIBRARY_PATH=. #ksh 
     javac *.java
    -java main
    +java runme
     
    diff --git a/Examples/java/simple/main.java b/Examples/java/simple/runme.java similarity index 97% rename from Examples/java/simple/main.java rename to Examples/java/simple/runme.java index 6d224a4dc..92880e8f9 100644 --- a/Examples/java/simple/main.java +++ b/Examples/java/simple/runme.java @@ -1,5 +1,5 @@ -public class main { +public class runme { static { try { diff --git a/Examples/java/template/index.html b/Examples/java/template/index.html index 1aebd4c2a..f4408e568 100644 --- a/Examples/java/template/index.html +++ b/Examples/java/template/index.html @@ -85,7 +85,7 @@ Note that SWIG parses the templated function max and templated class A sample Java program -Click here to see a Java program that calls the C++ functions from Java. +Click here to see a Java program that calls the C++ functions from Java.

    Notes

    Use templated classes just like you would any other SWIG generated Java class. Use the classnames specified by the %template directive. diff --git a/Examples/java/template/main.java b/Examples/java/template/runme.java similarity index 98% rename from Examples/java/template/main.java rename to Examples/java/template/runme.java index 9129fcf2a..5d1097bba 100644 --- a/Examples/java/template/main.java +++ b/Examples/java/template/runme.java @@ -1,6 +1,6 @@ // This example illustrates how C++ templates can be used from Java. -public class main { +public class runme { static { try { System.loadLibrary("example"); diff --git a/Examples/java/typemap/index.html b/Examples/java/typemap/index.html index 486aa8e79..5dd591941 100644 --- a/Examples/java/typemap/index.html +++ b/Examples/java/typemap/index.html @@ -16,7 +16,7 @@ This example shows how typemaps can be used to modify the default behaviour of t

    Notes

    diff --git a/Examples/java/typemap/main.java b/Examples/java/typemap/runme.java similarity index 96% rename from Examples/java/typemap/main.java rename to Examples/java/typemap/runme.java index bd9a4e1b6..fcbcc3067 100644 --- a/Examples/java/typemap/main.java +++ b/Examples/java/typemap/runme.java @@ -1,5 +1,5 @@ -public class main { +public class runme { static { try { diff --git a/Examples/java/variables/index.html b/Examples/java/variables/index.html index 05aaa2d6e..07b19d4e7 100644 --- a/Examples/java/variables/index.html +++ b/Examples/java/variables/index.html @@ -38,7 +38,7 @@ example.set_foo(12.3);
    -Click here to see the example program that updates and prints +Click here to see the example program that updates and prints out the values of the variables using this technique.

    Key points

    diff --git a/Examples/java/variables/main.java b/Examples/java/variables/runme.java similarity index 99% rename from Examples/java/variables/main.java rename to Examples/java/variables/runme.java index 92745db99..361a30fa6 100644 --- a/Examples/java/variables/main.java +++ b/Examples/java/variables/runme.java @@ -2,7 +2,7 @@ import java.lang.reflect.*; -public class main { +public class runme { static { try { System.loadLibrary("example"); From 1cdc534a653e3e37cd6ce406a229df1c2b1331e7 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 19 Nov 2008 00:57:09 +0000 Subject: [PATCH 0177/1680] dont replicate the -nopreprocess command if it is given when using swig as compiler git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10933 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CCache/ccache.c | 1 - 1 file changed, 1 deletion(-) diff --git a/CCache/ccache.c b/CCache/ccache.c index 0c3c15a0f..2dec72254 100644 --- a/CCache/ccache.c +++ b/CCache/ccache.c @@ -887,7 +887,6 @@ static void process_args(int argc, char **argv) /* the input file is already preprocessed */ if (swig && strcmp(argv[i], "-nopreprocess") == 0) { - args_add(stripped_args, argv[i]); direct_i_file = 1; continue; } From 25c972d919c98b171a5bc759730992ceec6d57da Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 19 Nov 2008 23:47:53 +0000 Subject: [PATCH 0178/1680] added swig regression tests for ccache git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10934 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CCache/test.sh | 149 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 146 insertions(+), 3 deletions(-) diff --git a/CCache/test.sh b/CCache/test.sh index ad43f6edd..459cd301d 100755 --- a/CCache/test.sh +++ b/CCache/test.sh @@ -9,7 +9,13 @@ else COMPILER=cc fi -CCACHE=../ccache +if test -n "$SWIG"; then + SWIG="$SWIG" +else + SWIG=swig +fi + +CCACHE=../ccache-swig TESTDIR=test.$$ test_failed() { @@ -34,6 +40,20 @@ randcode() { ) >> "$outfile" } +genswigcode() { + outfile="$1" + nlines=$2 + i=0; + ( + echo "%module swigtest$2;" + while [ $i -lt $nlines ]; do + echo "int foo$nlines$i(int x);" + echo "struct Bar$nlines$i { int y; };" + i=`expr $i + 1` + done + ) >> "$outfile" +} + getstat() { stat="$1" @@ -247,6 +267,117 @@ basetests() { rm -f test1.c } +swigtests() { + echo "starting swig testsuite $testsuite" + rm -rf .ccache + checkstat 'cache hit' 0 + checkstat 'cache miss' 0 + + j=1 + rm -f *.i + genswigcode testswig1.i 1 + + testname="BASIC" + $CCACHE_COMPILE -java testswig1.i + checkstat 'cache hit' 0 + checkstat 'cache miss' 1 + + checkstat 'files in cache' 6 + + testname="BASIC2" + $CCACHE_COMPILE -java testswig1.i + checkstat 'cache hit' 1 + checkstat 'cache miss' 1 + + testname="output" + $CCACHE_COMPILE -java testswig1.i -o foo_wrap.c + checkstat 'cache hit' 1 + checkstat 'cache miss' 2 + + testname="bad" + $CCACHE_COMPILE -java testswig1.i -I 2> /dev/null + checkstat 'bad compiler arguments' 1 + + testname="stdout" + $CCACHE_COMPILE -v -java testswig1.i > /dev/null + checkstat 'compiler produced stdout' 1 + + testname="non-regular" + mkdir testd + $CCACHE_COMPILE -o testd -java testswig1.i > /dev/null 2>&1 + rmdir testd + checkstat 'output to a non-regular file' 1 + + testname="no-input" + $CCACHE_COMPILE -java 2> /dev/null + checkstat 'no input file' 1 + + + testname="CCACHE_DISABLE" + CCACHE_DISABLE=1 $CCACHE_COMPILE -java testswig1.i 2> /dev/null + checkstat 'cache hit' 1 + $CCACHE_COMPILE -java testswig1.i + checkstat 'cache hit' 2 + + testname="CCACHE_CPP2" + CCACHE_CPP2=1 $CCACHE_COMPILE -java -O -O testswig1.i + checkstat 'cache hit' 2 + checkstat 'cache miss' 3 + + CCACHE_CPP2=1 $CCACHE_COMPILE -java -O -O testswig1.i + checkstat 'cache hit' 3 + checkstat 'cache miss' 3 + + testname="CCACHE_NOSTATS" + CCACHE_NOSTATS=1 $CCACHE_COMPILE -java -O -O testswig1.i + checkstat 'cache hit' 3 + checkstat 'cache miss' 3 + + testname="CCACHE_RECACHE" + CCACHE_RECACHE=1 $CCACHE_COMPILE -java -O -O testswig1.i + checkstat 'cache hit' 3 + checkstat 'cache miss' 4 + + # strictly speaking should be 3x6=18 instead of 4x6=24 - RECACHE causes a double counting! + checkstat 'files in cache' 24 + $CCACHE -c > /dev/null + checkstat 'files in cache' 18 + + + testname="CCACHE_HASHDIR" + CCACHE_HASHDIR=1 $CCACHE_COMPILE -java -O -O testswig1.i + checkstat 'cache hit' 3 + checkstat 'cache miss' 5 + + CCACHE_HASHDIR=1 $CCACHE_COMPILE -java -O -O testswig1.i + checkstat 'cache hit' 4 + checkstat 'cache miss' 5 + + checkstat 'files in cache' 24 + + testname="cpp call" + $CCACHE_COMPILE -java -E testswig1.i > testswig1-preproc.i + checkstat 'cache hit' 4 + checkstat 'cache miss' 5 + + testname="direct .i compile" + $CCACHE_COMPILE -java testswig1.i + checkstat 'cache hit' 5 + checkstat 'cache miss' 5 + + # No cache hit due to different input file name, -nopreprocess should not be given twice to SWIG + $CCACHE_COMPILE -java -nopreprocess testswig1-preproc.i + checkstat 'cache hit' 5 + checkstat 'cache miss' 6 + + $CCACHE_COMPILE -java -nopreprocess testswig1-preproc.i + checkstat 'cache hit' 6 + checkstat 'cache miss' 6 + + rm -f testswig1-preproc.i + rm -f testswig1.i +} + ###### # main program rm -rf $TESTDIR @@ -259,19 +390,31 @@ export CCACHE_DIR testsuite="base" CCACHE_COMPILE="$CCACHE $COMPILER" basetests +CCACHE_COMPILE="$CCACHE $SWIG" +swigtests testsuite="link" -ln -s ../ccache $COMPILER +echo ln -s $CCACHE $COMPILER +ln -s $CCACHE $COMPILER CCACHE_COMPILE="./$COMPILER" basetests +rm "./$COMPILER" +ln -s $CCACHE $SWIG +CCACHE_COMPILE="./$SWIG" +swigtests +rm "./$SWIG" testsuite="hardlink" CCACHE_COMPILE="$CCACHE $COMPILER" -CCACHE_HARDLINK=1 basetests +CCACHE_NOCOMPRESS=1 CCACHE_HARDLINK=1 basetests +CCACHE_COMPILE="$CCACHE $SWIG" +CCACHE_NOCOMPRESS=1 CCACHE_HARDLINK=1 swigtests testsuite="cpp2" CCACHE_COMPILE="$CCACHE $COMPILER" CCACHE_CPP2=1 basetests +CCACHE_COMPILE="$CCACHE $SWIG" +CCACHE_CPP2=1 swigtests testsuite="nlevels4" CCACHE_COMPILE="$CCACHE $COMPILER" From a41c66d9a4ea3a9148b407c24a9ee1d41407c9e2 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 22 Nov 2008 12:17:48 +0000 Subject: [PATCH 0179/1680] fix env variable settings and add swig tests git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10935 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CCache/Makefile.in | 6 +++++- CCache/test.sh | 25 ++++++++++++------------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/CCache/Makefile.in b/CCache/Makefile.in index c085b8b18..6373247e2 100644 --- a/CCache/Makefile.in +++ b/CCache/Makefile.in @@ -11,6 +11,8 @@ PACKAGE_NAME=@PACKAGE_NAME@ CC=@CC@ CFLAGS=@CFLAGS@ -I. +SWIG=swig +SWIG_LIB=../../Lib EXEEXT=@EXEEXT@ LIBS= @LIBS@ @@ -41,8 +43,10 @@ install: $(PACKAGE_NAME)$(EXEEXT) $(PACKAGE_NAME).1 clean: /bin/rm -f $(OBJS) *~ $(PACKAGE_NAME)$(EXEEXT) +check : test + test: test.sh - CC='$(CC)' ./test.sh + SWIG_LIB='$(SWIG_LIB)' PATH=../..:$$PATH SWIG='$(SWIG)' CC='$(CC)' ./test.sh check: test diff --git a/CCache/test.sh b/CCache/test.sh index 459cd301d..051cff92b 100755 --- a/CCache/test.sh +++ b/CCache/test.sh @@ -394,7 +394,6 @@ CCACHE_COMPILE="$CCACHE $SWIG" swigtests testsuite="link" -echo ln -s $CCACHE $COMPILER ln -s $CCACHE $COMPILER CCACHE_COMPILE="./$COMPILER" basetests @@ -405,24 +404,24 @@ swigtests rm "./$SWIG" testsuite="hardlink" -CCACHE_COMPILE="$CCACHE $COMPILER" -CCACHE_NOCOMPRESS=1 CCACHE_HARDLINK=1 basetests -CCACHE_COMPILE="$CCACHE $SWIG" -CCACHE_NOCOMPRESS=1 CCACHE_HARDLINK=1 swigtests +CCACHE_COMPILE="env CCACHE_NOCOMPRESS=1 CCACHE_HARDLINK=1 $CCACHE $COMPILER" +basetests +CCACHE_COMPILE="env CCACHE_NOCOMPRESS=1 CCACHE_HARDLINK=1 $CCACHE $SWIG" +swigtests testsuite="cpp2" -CCACHE_COMPILE="$CCACHE $COMPILER" -CCACHE_CPP2=1 basetests -CCACHE_COMPILE="$CCACHE $SWIG" -CCACHE_CPP2=1 swigtests +CCACHE_COMPILE="env CCACHE_CPP2=1 $CCACHE $COMPILER" +basetests +CCACHE_COMPILE="env CCACHE_CPP2=1 $CCACHE $SWIG" +swigtests testsuite="nlevels4" -CCACHE_COMPILE="$CCACHE $COMPILER" -CCACHE_NLEVELS=4 basetests +CCACHE_COMPILE="env CCACHE_NLEVELS=4 $CCACHE $COMPILER" +basetests testsuite="nlevels1" -CCACHE_COMPILE="$CCACHE $COMPILER" -CCACHE_NLEVELS=1 basetests +CCACHE_COMPILE="env CCACHE_NLEVELS=1 $CCACHE $COMPILER" +basetests cd .. rm -rf $TESTDIR From 533ccb5097b227e3132b0bbf1d62f79386cc14d8 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 22 Nov 2008 12:29:41 +0000 Subject: [PATCH 0180/1680] deprecate use of include path to find the input file for behaviour that is compatible with other compilers and interopability for ccache git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10936 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 5 +++++ Source/CParse/parser.y | 11 +++++++---- Source/Include/swigwarn.h | 1 + Source/Modules/main.cxx | 25 +++++++++++++++---------- Source/Modules/perl5.cxx | 2 +- Source/Swig/include.c | 19 +++++++++++++------ Source/Swig/swigfile.h | 1 + 7 files changed, 43 insertions(+), 21 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 2bfb3742e..752ba3790 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,11 @@ Version 1.3.37 (in progress) ============================ +2008-11-21: wsfulton + The use of the include path to find the input file is now deprecated. + This makes the behaviour of SWIG the same as C/C++ compilers in preparation + for use with ccache. + 2008-11-16: wsfulton Fix -nopreprocess option to: - correctly report file names in warning and error messages. diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index 8b3639dc9..ccdac79d1 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -1886,16 +1886,19 @@ fragment_directive: FRAGMENT LPAREN fname COMMA kwargs RPAREN HBLOCK { ; /* ------------------------------------------------------------ - %includefile "filename" [ declarations ] - %importfile "filename" [ declarations ] + %includefile "filename" [option1="xyz", ...] [ declarations ] + %importfile "filename" [option1="xyz", ...] [ declarations ] ------------------------------------------------------------ */ include_directive: includetype options string LBRACKET { $1.filename = Copy(cparse_file); $1.line = cparse_line; scanner_set_location(NewString($3),1); - if ($2 && GetFlag($2, "maininput")) - scanner_set_main_input_file(NewString($3)); + if ($2) { + String *maininput = Getattr($2, "maininput"); + if (maininput) + scanner_set_main_input_file(NewString(maininput)); + } } interface RBRACKET { String *mname = 0; $$ = $6; diff --git a/Source/Include/swigwarn.h b/Source/Include/swigwarn.h index 8c4678847..da386ee47 100644 --- a/Source/Include/swigwarn.h +++ b/Source/Include/swigwarn.h @@ -49,6 +49,7 @@ #define WARN_DEPRECATED_NOEXTERN 122 #define WARN_DEPRECATED_NODEFAULT 123 #define WARN_DEPRECATED_TYPEMAP_LANG 124 +#define WARN_DEPRECATED_INPUT_FILE 125 /* -- Preprocessor -- */ diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx index 07c4d18a9..8f19504ff 100644 --- a/Source/Modules/main.cxx +++ b/Source/Modules/main.cxx @@ -947,7 +947,7 @@ int SWIG_main(int argc, char *argv[], Language *l) { if (!s) { fprintf(stderr, "Unable to locate '%s' in the SWIG library.\n", input_file); } else { - FILE *f = Swig_open(outfile); + FILE *f = Swig_include_open(outfile); if (f) { fclose(f); fprintf(stderr, "File '%s' already exists. Checkout aborted.\n", outfile); @@ -974,17 +974,22 @@ int SWIG_main(int argc, char *argv[], Language *l) { String *fs = NewString(""); FILE *df = Swig_open(input_file); if (!df) { - char *cfile = Char(input_file); - if (cfile && cfile[0] == '-') { - Printf(stderr, "Unable to find option or file '%s', ", input_file); - Printf(stderr, "use 'swig -help' for more information.\n"); + df = Swig_include_open(input_file); + if (!df) { + char *cfile = Char(input_file); + if (cfile && cfile[0] == '-') { + Printf(stderr, "Unable to find option or file '%s', ", input_file); + Printf(stderr, "use 'swig -help' for more information.\n"); + } else { + Printf(stderr, "Unable to find file '%s'.\n", input_file); + } + SWIG_exit(EXIT_FAILURE); } else { - Printf(stderr, "Unable to find file '%s'.\n", input_file); + Swig_warning(WARN_DEPRECATED_INPUT_FILE, "SWIG", 1, "Use of the include path to find the input file is deprecated and will not work with ccache. Please include the path when specifying the input file.\n"); // so that behaviour is like c/c++ compilers } - SWIG_exit(EXIT_FAILURE); } - fclose(df); if (!no_cpp) { + fclose(df); Printf(fs, "%%include \n"); if (allkw) { Printf(fs, "%%include \n"); @@ -992,7 +997,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=1) \"%s\"\n", Swig_last_file()); + Printf(fs, "%%include(maininput=\"%s\") \"%s\"\n", input_file, Swig_last_file()); for (i = 0; i < Len(libfiles); i++) { Printf(fs, "\n%%include \"%s\"\n", Getitem(libfiles, i)); } @@ -1000,8 +1005,8 @@ int SWIG_main(int argc, char *argv[], Language *l) { cpps = Preprocessor_parse(fs); Delete(fs); } else { - df = Swig_open(input_file); cpps = Swig_read_file(df); + fclose(df); } if (Swig_error_count()) { SWIG_exit(EXIT_FAILURE); diff --git a/Source/Modules/perl5.cxx b/Source/Modules/perl5.cxx index 3b9585534..fd8a03590 100644 --- a/Source/Modules/perl5.cxx +++ b/Source/Modules/perl5.cxx @@ -1624,7 +1624,7 @@ public: } else if (Strcmp(code, "include") == 0) { /* Include a file into the .pm file */ if (value) { - FILE *f = Swig_open(value); + FILE *f = Swig_include_open(value); if (!f) { Printf(stderr, "%s : Line %d. Unable to locate file %s\n", input_file, line_number, value); } else { diff --git a/Source/Swig/include.c b/Source/Swig/include.c index 670c5f5f5..73cb6551e 100644 --- a/Source/Swig/include.c +++ b/Source/Swig/include.c @@ -151,10 +151,11 @@ List *Swig_search_path() { /* ----------------------------------------------------------------------------- * Swig_open() * - * Looks for a file and open it. Returns an open FILE * on success. + * open a file, optionally looking for it in the include path. Returns an open + * FILE * on success. * ----------------------------------------------------------------------------- */ -static FILE *Swig_open_any(const String_or_char *name, int sysfile) { +static FILE *Swig_open_file(const String_or_char *name, int sysfile, int use_include_path) { FILE *f; String *filename; List *spath = 0; @@ -169,7 +170,7 @@ static FILE *Swig_open_any(const String_or_char *name, int sysfile) { filename = NewString(cname); assert(filename); f = fopen(Char(filename), "r"); - if (!f) { + if (!f && use_include_path) { spath = Swig_search_path_any(sysfile); ilen = Len(spath); for (i = 0; i < ilen; i++) { @@ -193,8 +194,14 @@ static FILE *Swig_open_any(const String_or_char *name, int sysfile) { return f; } +/* Open a file - searching the include paths to find it */ +FILE *Swig_include_open(const String_or_char *name) { + return Swig_open_file(name, 0, 1); +} + +/* Open a file - does not use include paths to find it */ FILE *Swig_open(const String_or_char *name) { - return Swig_open_any(name, 0); + return Swig_open_file(name, 0, 0); } @@ -235,7 +242,7 @@ static String *Swig_include_any(const String_or_char *name, int sysfile) { String *str; String *file; - f = Swig_open_any(name, sysfile); + f = Swig_open_file(name, sysfile, 1); if (!f) return 0; str = Swig_read_file(f); @@ -265,7 +272,7 @@ String *Swig_include_sys(const String_or_char *name) { int Swig_insert_file(const String_or_char *filename, File *outfile) { char buffer[4096]; int nbytes; - FILE *f = Swig_open(filename); + FILE *f = Swig_include_open(filename); if (!f) return -1; diff --git a/Source/Swig/swigfile.h b/Source/Swig/swigfile.h index 204eef46c..807b10bc8 100644 --- a/Source/Swig/swigfile.h +++ b/Source/Swig/swigfile.h @@ -14,6 +14,7 @@ extern void Swig_push_directory(const String_or_char *dirname); extern void Swig_pop_directory(void); extern String *Swig_last_file(void); extern List *Swig_search_path(void); +extern FILE *Swig_include_open(const String_or_char *name); extern FILE *Swig_open(const String_or_char *name); extern String *Swig_read_file(FILE *f); extern String *Swig_include(const String_or_char *name); From 905b1cf4e9a5bef329427f44b4f30c456305b79c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 22 Nov 2008 12:32:51 +0000 Subject: [PATCH 0181/1680] add ccache install and rename php4 to php git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10937 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Makefile.in | 30 ++++++++++++++++++------------ configure.in | 8 ++++---- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/Makefile.in b/Makefile.in index abaaa59b9..e2ae16f0f 100644 --- a/Makefile.in +++ b/Makefile.in @@ -49,7 +49,7 @@ skip-guilescm = test -n "@SKIP_GUILESCM@" skip-guile = test -n "@SKIP_GUILE@" skip-mzscheme = test -n "@SKIP_MZSCHEME@" skip-ruby = test -n "@SKIP_RUBY@" -skip-php4 = test -n "@SKIP_PHP4@" +skip-php = test -n "@SKIP_PHP4@" skip-ocaml = test -n "@SKIP_OCAML@" skip-octave = test -n "@SKIP_OCTAVE@" skip-pike = test -n "@SKIP_PIKE@" @@ -89,7 +89,7 @@ check-aliveness: @$(skip-ruby) || ./$(TARGET) -ruby -help @$(skip-ocaml) || ./$(TARGET) -ocaml -help @$(skip-octave) || ./$(TARGET) -octave -help - @$(skip-php4) || ./$(TARGET) -php4 -help + @$(skip-php) || ./$(TARGET) -php -help @$(skip-pike) || ./$(TARGET) -pike -help @$(skip-chicken) || ./$(TARGET) -chicken -help @$(skip-csharp) || ./$(TARGET) -csharp -help @@ -97,6 +97,9 @@ check-aliveness: @$(skip-lua) || ./$(TARGET) -lua -help @$(skip-r) || ./$(TARGET) -r -help +check-ccache: + test -z "$(ENABLE_CCACHE)" || (cd $(CCACHE) && $(MAKE) check) + # Checks examples for compilation (does not run them) check-examples: \ check-tcl-examples \ @@ -108,7 +111,7 @@ check-examples: \ check-ruby-examples \ check-ocaml-examples \ check-octave-examples \ - check-php4-examples \ + check-php-examples \ check-pike-examples \ check-chicken-examples \ check-csharp-examples \ @@ -129,7 +132,7 @@ mzscheme_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/mzscheme/check.list ruby_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/ruby/check.list) ocaml_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/ocaml/check.list) octave_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/octave/check.list) -php4_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/php4/check.list) +php4_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/php/check.list) pike_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/pike/check.list) chicken_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/chicken/check.list) csharp_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/csharp/check.list) @@ -181,7 +184,7 @@ check-gifplot: \ check-ruby-gifplot \ check-ocaml-gifplot \ check-octave-gifplot \ - check-php4-gifplot \ + check-php-gifplot \ check-pike-gifplot \ check-chicken-gifplot \ # check-lua-gifplot \ @@ -223,7 +226,7 @@ check-test-suite: \ check-ruby-test-suite \ check-ocaml-test-suite \ check-octave-test-suite \ - check-php4-test-suite \ + check-php-test-suite \ check-pike-test-suite \ check-csharp-test-suite \ check-modula3-test-suite \ @@ -260,7 +263,7 @@ partialcheck-test-suite: partialcheck-%-test-suite: @$(MAKE) -k -s check-$*-test-suite ACTION=partialcheck -check: check-aliveness check-examples check-gifplot check-test-suite +check: check-aliveness check-ccache check-examples check-gifplot check-test-suite # Run known-to-be-broken as well as not broken testcases in the test-suite all-test-suite: \ @@ -274,7 +277,7 @@ all-test-suite: \ all-ruby-test-suite \ all-ocaml-test-suite \ all-octave-test-suite \ - all-php4-test-suite \ + all-php-test-suite \ all-pike-test-suite \ all-csharp-test-suite \ all-modula3-test-suite \ @@ -301,7 +304,7 @@ broken-test-suite: \ broken-ruby-test-suite \ broken-ocaml-test-suite \ broken-octave-test-suite \ - broken-php4-test-suite \ + broken-php-test-suite \ broken-pike-test-suite \ broken-csharp-test-suite \ broken-modula3-test-suite \ @@ -393,7 +396,7 @@ noskip-test-suite: \ noskip-ruby-test-suite \ noskip-ocaml-test-suite \ noskip-octave-test-suite \ - noskip-php4-test-suite \ + noskip-php-test-suite \ noskip-pike-test-suite \ noskip-csharp-test-suite \ noskip-lua-test-suite \ @@ -441,7 +444,7 @@ MKINSTDIRS = @abs_srcdir@/Tools/config/install-sh -m 0755 -d # Use standard autoconf approach to transform executable name using --program-prefix and --program-suffix transform = @program_transform_name@ -install: install-main install-lib +install: install-main install-lib install-ccache @echo "Installation complete" install-main: @@ -450,7 +453,7 @@ install-main: @echo "Installing $(DESTDIR)$(BIN_DIR)/`echo $(TARGET_NOEXE) | sed '$(transform)'`@EXEEXT@" @$(INSTALL_PROGRAM) $(TARGET) $(DESTDIR)$(BIN_DIR)/`echo $(TARGET_NOEXE) | sed '$(transform)'`@EXEEXT@ -lib-languages = gcj typemaps tcl perl5 python guile java mzscheme ruby php4 ocaml octave \ +lib-languages = gcj typemaps tcl perl5 python guile java mzscheme ruby php ocaml octave \ pike chicken csharp modula3 allegrocl clisp lua cffi uffi r lib-modules = std @@ -485,6 +488,9 @@ install-lib: fi) ; \ done +install-ccache: + test -z "$(ENABLE_CCACHE)" || (cd $(CCACHE) && $(MAKE) install) + ##################################################################### # TARGETS: uninstall & friends diff --git a/configure.in b/configure.in index 99af00da9..16ed08374 100644 --- a/configure.in +++ b/configure.in @@ -1331,10 +1331,10 @@ AC_SUBST(RUBYDYNAMICLINKING) PHP4BIN= -AC_ARG_WITH(php4, AS_HELP_STRING([--without-php4], [Disable PHP]) -AS_HELP_STRING([--with-php4=path], [Set location of PHP executable]),[ PHP4BIN="$withval"], [PHP4BIN=yes]) +AC_ARG_WITH(php, AS_HELP_STRING([--without-php], [Disable PHP]) +AS_HELP_STRING([--with-php=path], [Set location of PHP executable]),[ PHP4BIN="$withval"], [PHP4BIN=yes]) -# First, check for "--without-php4" or "--with-php4=no". +# First, check for "--without-php" or "--with-php=no". if test x"${PHP4BIN}" = xno -o x"${with_alllang}" = xno ; then AC_MSG_NOTICE([Disabling PHP]) PHP4= @@ -2149,7 +2149,7 @@ AC_CONFIG_FILES([ \ Examples/test-suite/ocaml/Makefile \ Examples/test-suite/octave/Makefile \ Examples/test-suite/perl5/Makefile \ - Examples/test-suite/php4/Makefile \ + Examples/test-suite/php/Makefile \ Examples/test-suite/pike/Makefile \ Examples/test-suite/python/Makefile \ Examples/test-suite/ruby/Makefile \ From 4c03864ce975374f6b2e2273316d929a14aaca4f Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 22 Nov 2008 12:35:27 +0000 Subject: [PATCH 0182/1680] rename php4 to php git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10938 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/{php4 => php}/check.list | 0 Examples/{php4 => php}/class/Makefile | 0 Examples/{php4 => php}/class/example.cxx | 0 Examples/{php4 => php}/class/example.h | 0 Examples/{php4 => php}/class/example.i | 0 Examples/{php4 => php}/class/runme.php4 | 0 Examples/{php4 => php}/constants/Makefile | 0 Examples/{php4 => php}/constants/example.i | 0 Examples/{php4 => php}/constants/runme.php4 | 0 Examples/{php4 => php}/cpointer/Makefile | 0 Examples/{php4 => php}/cpointer/example.c | 0 Examples/{php4 => php}/cpointer/example.i | 0 Examples/{php4 => php}/cpointer/runme.php4 | 0 Examples/{php4 => php}/disown/Makefile | 0 Examples/{php4 => php}/disown/example.cxx | 0 Examples/{php4 => php}/disown/example.h | 0 Examples/{php4 => php}/disown/example.i | 0 Examples/{php4 => php}/disown/runme.php4 | 0 Examples/{php4 => php}/enum/Makefile | 0 Examples/{php4 => php}/enum/example.cxx | 0 Examples/{php4 => php}/enum/example.h | 0 Examples/{php4 => php}/enum/example.i | 0 Examples/{php4 => php}/enum/runme.php4 | 0 Examples/{php4 => php}/funcptr/Makefile | 0 Examples/{php4 => php}/funcptr/example.c | 0 Examples/{php4 => php}/funcptr/example.h | 0 Examples/{php4 => php}/funcptr/example.i | 0 Examples/{php4 => php}/funcptr/runme.php4 | 0 Examples/{php4 => php}/overloading/Makefile | 0 Examples/{php4 => php}/overloading/example.cxx | 0 Examples/{php4 => php}/overloading/example.h | 0 Examples/{php4 => php}/overloading/example.i | 0 Examples/{php4 => php}/overloading/runme.php4 | 0 Examples/{php4 => php}/pointer/Makefile | 0 Examples/{php4 => php}/pointer/example.c | 0 Examples/{php4 => php}/pointer/example.i | 0 Examples/{php4 => php}/pointer/runme.php4 | 0 Examples/{php4 => php}/pragmas/Makefile | 0 Examples/{php4 => php}/pragmas/example.i | 0 Examples/{php4 => php}/pragmas/include.php | 0 Examples/{php4 => php}/pragmas/runme.php4 | 0 Examples/{php4 => php}/proxy/Makefile | 0 Examples/{php4 => php}/proxy/example.cxx | 0 Examples/{php4 => php}/proxy/example.h | 0 Examples/{php4 => php}/proxy/example.i | 0 Examples/{php4 => php}/proxy/runme.php4 | 0 Examples/{php4 => php}/reference/Makefile | 0 Examples/{php4 => php}/reference/example.cxx | 0 Examples/{php4 => php}/reference/example.h | 0 Examples/{php4 => php}/reference/example.i | 0 Examples/{php4 => php}/reference/runme-proxy.php4 | 0 Examples/{php4 => php}/reference/runme.php4 | 0 Examples/{php4 => php}/simple/Makefile | 0 Examples/{php4 => php}/simple/example.c | 0 Examples/{php4 => php}/simple/example.i | 0 Examples/{php4 => php}/simple/runme.php4 | 0 Examples/{php4 => php}/sync/Makefile | 0 Examples/{php4 => php}/sync/example.cxx | 0 Examples/{php4 => php}/sync/example.h | 0 Examples/{php4 => php}/sync/example.i | 0 Examples/{php4 => php}/sync/runme.php4 | 0 Examples/{php4 => php}/value/Makefile | 0 Examples/{php4 => php}/value/example.c | 0 Examples/{php4 => php}/value/example.h | 0 Examples/{php4 => php}/value/example.i | 0 Examples/{php4 => php}/value/runme.php4 | 0 Examples/{php4 => php}/variables/Makefile | 0 Examples/{php4 => php}/variables/example.c | 0 Examples/{php4 => php}/variables/example.h | 0 Examples/{php4 => php}/variables/example.i | 0 Examples/{php4 => php}/variables/runme.php4 | 0 Examples/{php4 => php}/variables/runme.php4.old | 0 Examples/test-suite/{php4 => php}/Makefile.in | 0 Examples/test-suite/{php4 => php}/abstract_inherit_ok_runme.php4 | 0 Examples/test-suite/{php4 => php}/abstract_inherit_runme.php4 | 0 Examples/test-suite/{php4 => php}/add_link_runme.php4 | 0 Examples/test-suite/{php4 => php}/argout_runme.php4 | 0 Examples/test-suite/{php4 => php}/arrayptr_runme.php4 | 0 Examples/test-suite/{php4 => php}/arrays_global_runme.php4 | 0 Examples/test-suite/{php4 => php}/arrays_global_twodim_runme.php4 | 0 Examples/test-suite/{php4 => php}/arrays_runme.php4 | 0 Examples/test-suite/{php4 => php}/arrays_scope_runme.php4 | 0 Examples/test-suite/{php4 => php}/casts_runme.php4 | 0 Examples/test-suite/{php4 => php}/class_ignore_runme.php4 | 0 Examples/test-suite/{php4 => php}/conversion_namespace_runme.php4 | 0 .../test-suite/{php4 => php}/conversion_ns_template_runme.php4 | 0 Examples/test-suite/{php4 => php}/conversion_runme.php4 | 0 Examples/test-suite/{php4 => php}/cpp_static_runme.php4 | 0 Examples/test-suite/{php4 => php}/enum_scope_template_runme.php4 | 0 Examples/test-suite/{php4 => php}/evil_diamond_ns_runme.php4 | 0 Examples/test-suite/{php4 => php}/evil_diamond_prop_runme.php4 | 0 Examples/test-suite/{php4 => php}/evil_diamond_runme.php4 | 0 Examples/test-suite/{php4 => php}/extend_template_ns_runme.php4 | 0 Examples/test-suite/{php4 => php}/extend_template_runme.php4 | 0 Examples/test-suite/{php4 => php}/grouping_runme.php4 | 0 Examples/test-suite/{php4 => php}/ignore_parameter_runme.php4 | 0 Examples/test-suite/{php4 => php}/li_carrays_runme.php4 | 0 Examples/test-suite/{php4 => php}/li_std_string_runme.php4 | 0 Examples/test-suite/{php4 => php}/namewarn_rename.i | 0 Examples/test-suite/{php4 => php}/rename_scope_runme.php4 | 0 Examples/test-suite/{php4 => php}/skel.php4 | 0 Examples/test-suite/{php4 => php}/smart_pointer_rename_runme.php4 | 0 Examples/test-suite/{php4 => php}/sym_runme.php4 | 0 .../test-suite/{php4 => php}/template_arg_typename_runme.php4 | 0 Examples/test-suite/{php4 => php}/template_construct_runme.php4 | 0 Examples/test-suite/{php4 => php}/tests.php4 | 0 Examples/test-suite/{php4 => php}/typedef_reference_runme.php4 | 0 Examples/test-suite/{php4 => php}/typemap_ns_using_runme.php4 | 0 Examples/test-suite/{php4 => php}/using1_runme.php4 | 0 Examples/test-suite/{php4 => php}/using2_runme.php4 | 0 Examples/test-suite/{php4 => php}/valuewrapper_base_runme.php4 | 0 111 files changed, 0 insertions(+), 0 deletions(-) rename Examples/{php4 => php}/check.list (100%) rename Examples/{php4 => php}/class/Makefile (100%) rename Examples/{php4 => php}/class/example.cxx (100%) rename Examples/{php4 => php}/class/example.h (100%) rename Examples/{php4 => php}/class/example.i (100%) rename Examples/{php4 => php}/class/runme.php4 (100%) rename Examples/{php4 => php}/constants/Makefile (100%) rename Examples/{php4 => php}/constants/example.i (100%) rename Examples/{php4 => php}/constants/runme.php4 (100%) rename Examples/{php4 => php}/cpointer/Makefile (100%) rename Examples/{php4 => php}/cpointer/example.c (100%) rename Examples/{php4 => php}/cpointer/example.i (100%) rename Examples/{php4 => php}/cpointer/runme.php4 (100%) rename Examples/{php4 => php}/disown/Makefile (100%) rename Examples/{php4 => php}/disown/example.cxx (100%) rename Examples/{php4 => php}/disown/example.h (100%) rename Examples/{php4 => php}/disown/example.i (100%) rename Examples/{php4 => php}/disown/runme.php4 (100%) rename Examples/{php4 => php}/enum/Makefile (100%) rename Examples/{php4 => php}/enum/example.cxx (100%) rename Examples/{php4 => php}/enum/example.h (100%) rename Examples/{php4 => php}/enum/example.i (100%) rename Examples/{php4 => php}/enum/runme.php4 (100%) rename Examples/{php4 => php}/funcptr/Makefile (100%) rename Examples/{php4 => php}/funcptr/example.c (100%) rename Examples/{php4 => php}/funcptr/example.h (100%) rename Examples/{php4 => php}/funcptr/example.i (100%) rename Examples/{php4 => php}/funcptr/runme.php4 (100%) rename Examples/{php4 => php}/overloading/Makefile (100%) rename Examples/{php4 => php}/overloading/example.cxx (100%) rename Examples/{php4 => php}/overloading/example.h (100%) rename Examples/{php4 => php}/overloading/example.i (100%) rename Examples/{php4 => php}/overloading/runme.php4 (100%) rename Examples/{php4 => php}/pointer/Makefile (100%) rename Examples/{php4 => php}/pointer/example.c (100%) rename Examples/{php4 => php}/pointer/example.i (100%) rename Examples/{php4 => php}/pointer/runme.php4 (100%) rename Examples/{php4 => php}/pragmas/Makefile (100%) rename Examples/{php4 => php}/pragmas/example.i (100%) rename Examples/{php4 => php}/pragmas/include.php (100%) rename Examples/{php4 => php}/pragmas/runme.php4 (100%) rename Examples/{php4 => php}/proxy/Makefile (100%) rename Examples/{php4 => php}/proxy/example.cxx (100%) rename Examples/{php4 => php}/proxy/example.h (100%) rename Examples/{php4 => php}/proxy/example.i (100%) rename Examples/{php4 => php}/proxy/runme.php4 (100%) rename Examples/{php4 => php}/reference/Makefile (100%) rename Examples/{php4 => php}/reference/example.cxx (100%) rename Examples/{php4 => php}/reference/example.h (100%) rename Examples/{php4 => php}/reference/example.i (100%) rename Examples/{php4 => php}/reference/runme-proxy.php4 (100%) rename Examples/{php4 => php}/reference/runme.php4 (100%) rename Examples/{php4 => php}/simple/Makefile (100%) rename Examples/{php4 => php}/simple/example.c (100%) rename Examples/{php4 => php}/simple/example.i (100%) rename Examples/{php4 => php}/simple/runme.php4 (100%) rename Examples/{php4 => php}/sync/Makefile (100%) rename Examples/{php4 => php}/sync/example.cxx (100%) rename Examples/{php4 => php}/sync/example.h (100%) rename Examples/{php4 => php}/sync/example.i (100%) rename Examples/{php4 => php}/sync/runme.php4 (100%) rename Examples/{php4 => php}/value/Makefile (100%) rename Examples/{php4 => php}/value/example.c (100%) rename Examples/{php4 => php}/value/example.h (100%) rename Examples/{php4 => php}/value/example.i (100%) rename Examples/{php4 => php}/value/runme.php4 (100%) rename Examples/{php4 => php}/variables/Makefile (100%) rename Examples/{php4 => php}/variables/example.c (100%) rename Examples/{php4 => php}/variables/example.h (100%) rename Examples/{php4 => php}/variables/example.i (100%) rename Examples/{php4 => php}/variables/runme.php4 (100%) rename Examples/{php4 => php}/variables/runme.php4.old (100%) rename Examples/test-suite/{php4 => php}/Makefile.in (100%) rename Examples/test-suite/{php4 => php}/abstract_inherit_ok_runme.php4 (100%) rename Examples/test-suite/{php4 => php}/abstract_inherit_runme.php4 (100%) rename Examples/test-suite/{php4 => php}/add_link_runme.php4 (100%) rename Examples/test-suite/{php4 => php}/argout_runme.php4 (100%) rename Examples/test-suite/{php4 => php}/arrayptr_runme.php4 (100%) rename Examples/test-suite/{php4 => php}/arrays_global_runme.php4 (100%) rename Examples/test-suite/{php4 => php}/arrays_global_twodim_runme.php4 (100%) rename Examples/test-suite/{php4 => php}/arrays_runme.php4 (100%) rename Examples/test-suite/{php4 => php}/arrays_scope_runme.php4 (100%) rename Examples/test-suite/{php4 => php}/casts_runme.php4 (100%) rename Examples/test-suite/{php4 => php}/class_ignore_runme.php4 (100%) rename Examples/test-suite/{php4 => php}/conversion_namespace_runme.php4 (100%) rename Examples/test-suite/{php4 => php}/conversion_ns_template_runme.php4 (100%) rename Examples/test-suite/{php4 => php}/conversion_runme.php4 (100%) rename Examples/test-suite/{php4 => php}/cpp_static_runme.php4 (100%) rename Examples/test-suite/{php4 => php}/enum_scope_template_runme.php4 (100%) rename Examples/test-suite/{php4 => php}/evil_diamond_ns_runme.php4 (100%) rename Examples/test-suite/{php4 => php}/evil_diamond_prop_runme.php4 (100%) rename Examples/test-suite/{php4 => php}/evil_diamond_runme.php4 (100%) rename Examples/test-suite/{php4 => php}/extend_template_ns_runme.php4 (100%) rename Examples/test-suite/{php4 => php}/extend_template_runme.php4 (100%) rename Examples/test-suite/{php4 => php}/grouping_runme.php4 (100%) rename Examples/test-suite/{php4 => php}/ignore_parameter_runme.php4 (100%) rename Examples/test-suite/{php4 => php}/li_carrays_runme.php4 (100%) rename Examples/test-suite/{php4 => php}/li_std_string_runme.php4 (100%) rename Examples/test-suite/{php4 => php}/namewarn_rename.i (100%) rename Examples/test-suite/{php4 => php}/rename_scope_runme.php4 (100%) rename Examples/test-suite/{php4 => php}/skel.php4 (100%) rename Examples/test-suite/{php4 => php}/smart_pointer_rename_runme.php4 (100%) rename Examples/test-suite/{php4 => php}/sym_runme.php4 (100%) rename Examples/test-suite/{php4 => php}/template_arg_typename_runme.php4 (100%) rename Examples/test-suite/{php4 => php}/template_construct_runme.php4 (100%) rename Examples/test-suite/{php4 => php}/tests.php4 (100%) rename Examples/test-suite/{php4 => php}/typedef_reference_runme.php4 (100%) rename Examples/test-suite/{php4 => php}/typemap_ns_using_runme.php4 (100%) rename Examples/test-suite/{php4 => php}/using1_runme.php4 (100%) rename Examples/test-suite/{php4 => php}/using2_runme.php4 (100%) rename Examples/test-suite/{php4 => php}/valuewrapper_base_runme.php4 (100%) diff --git a/Examples/php4/check.list b/Examples/php/check.list similarity index 100% rename from Examples/php4/check.list rename to Examples/php/check.list diff --git a/Examples/php4/class/Makefile b/Examples/php/class/Makefile similarity index 100% rename from Examples/php4/class/Makefile rename to Examples/php/class/Makefile diff --git a/Examples/php4/class/example.cxx b/Examples/php/class/example.cxx similarity index 100% rename from Examples/php4/class/example.cxx rename to Examples/php/class/example.cxx diff --git a/Examples/php4/class/example.h b/Examples/php/class/example.h similarity index 100% rename from Examples/php4/class/example.h rename to Examples/php/class/example.h diff --git a/Examples/php4/class/example.i b/Examples/php/class/example.i similarity index 100% rename from Examples/php4/class/example.i rename to Examples/php/class/example.i diff --git a/Examples/php4/class/runme.php4 b/Examples/php/class/runme.php4 similarity index 100% rename from Examples/php4/class/runme.php4 rename to Examples/php/class/runme.php4 diff --git a/Examples/php4/constants/Makefile b/Examples/php/constants/Makefile similarity index 100% rename from Examples/php4/constants/Makefile rename to Examples/php/constants/Makefile diff --git a/Examples/php4/constants/example.i b/Examples/php/constants/example.i similarity index 100% rename from Examples/php4/constants/example.i rename to Examples/php/constants/example.i diff --git a/Examples/php4/constants/runme.php4 b/Examples/php/constants/runme.php4 similarity index 100% rename from Examples/php4/constants/runme.php4 rename to Examples/php/constants/runme.php4 diff --git a/Examples/php4/cpointer/Makefile b/Examples/php/cpointer/Makefile similarity index 100% rename from Examples/php4/cpointer/Makefile rename to Examples/php/cpointer/Makefile diff --git a/Examples/php4/cpointer/example.c b/Examples/php/cpointer/example.c similarity index 100% rename from Examples/php4/cpointer/example.c rename to Examples/php/cpointer/example.c diff --git a/Examples/php4/cpointer/example.i b/Examples/php/cpointer/example.i similarity index 100% rename from Examples/php4/cpointer/example.i rename to Examples/php/cpointer/example.i diff --git a/Examples/php4/cpointer/runme.php4 b/Examples/php/cpointer/runme.php4 similarity index 100% rename from Examples/php4/cpointer/runme.php4 rename to Examples/php/cpointer/runme.php4 diff --git a/Examples/php4/disown/Makefile b/Examples/php/disown/Makefile similarity index 100% rename from Examples/php4/disown/Makefile rename to Examples/php/disown/Makefile diff --git a/Examples/php4/disown/example.cxx b/Examples/php/disown/example.cxx similarity index 100% rename from Examples/php4/disown/example.cxx rename to Examples/php/disown/example.cxx diff --git a/Examples/php4/disown/example.h b/Examples/php/disown/example.h similarity index 100% rename from Examples/php4/disown/example.h rename to Examples/php/disown/example.h diff --git a/Examples/php4/disown/example.i b/Examples/php/disown/example.i similarity index 100% rename from Examples/php4/disown/example.i rename to Examples/php/disown/example.i diff --git a/Examples/php4/disown/runme.php4 b/Examples/php/disown/runme.php4 similarity index 100% rename from Examples/php4/disown/runme.php4 rename to Examples/php/disown/runme.php4 diff --git a/Examples/php4/enum/Makefile b/Examples/php/enum/Makefile similarity index 100% rename from Examples/php4/enum/Makefile rename to Examples/php/enum/Makefile diff --git a/Examples/php4/enum/example.cxx b/Examples/php/enum/example.cxx similarity index 100% rename from Examples/php4/enum/example.cxx rename to Examples/php/enum/example.cxx diff --git a/Examples/php4/enum/example.h b/Examples/php/enum/example.h similarity index 100% rename from Examples/php4/enum/example.h rename to Examples/php/enum/example.h diff --git a/Examples/php4/enum/example.i b/Examples/php/enum/example.i similarity index 100% rename from Examples/php4/enum/example.i rename to Examples/php/enum/example.i diff --git a/Examples/php4/enum/runme.php4 b/Examples/php/enum/runme.php4 similarity index 100% rename from Examples/php4/enum/runme.php4 rename to Examples/php/enum/runme.php4 diff --git a/Examples/php4/funcptr/Makefile b/Examples/php/funcptr/Makefile similarity index 100% rename from Examples/php4/funcptr/Makefile rename to Examples/php/funcptr/Makefile diff --git a/Examples/php4/funcptr/example.c b/Examples/php/funcptr/example.c similarity index 100% rename from Examples/php4/funcptr/example.c rename to Examples/php/funcptr/example.c diff --git a/Examples/php4/funcptr/example.h b/Examples/php/funcptr/example.h similarity index 100% rename from Examples/php4/funcptr/example.h rename to Examples/php/funcptr/example.h diff --git a/Examples/php4/funcptr/example.i b/Examples/php/funcptr/example.i similarity index 100% rename from Examples/php4/funcptr/example.i rename to Examples/php/funcptr/example.i diff --git a/Examples/php4/funcptr/runme.php4 b/Examples/php/funcptr/runme.php4 similarity index 100% rename from Examples/php4/funcptr/runme.php4 rename to Examples/php/funcptr/runme.php4 diff --git a/Examples/php4/overloading/Makefile b/Examples/php/overloading/Makefile similarity index 100% rename from Examples/php4/overloading/Makefile rename to Examples/php/overloading/Makefile diff --git a/Examples/php4/overloading/example.cxx b/Examples/php/overloading/example.cxx similarity index 100% rename from Examples/php4/overloading/example.cxx rename to Examples/php/overloading/example.cxx diff --git a/Examples/php4/overloading/example.h b/Examples/php/overloading/example.h similarity index 100% rename from Examples/php4/overloading/example.h rename to Examples/php/overloading/example.h diff --git a/Examples/php4/overloading/example.i b/Examples/php/overloading/example.i similarity index 100% rename from Examples/php4/overloading/example.i rename to Examples/php/overloading/example.i diff --git a/Examples/php4/overloading/runme.php4 b/Examples/php/overloading/runme.php4 similarity index 100% rename from Examples/php4/overloading/runme.php4 rename to Examples/php/overloading/runme.php4 diff --git a/Examples/php4/pointer/Makefile b/Examples/php/pointer/Makefile similarity index 100% rename from Examples/php4/pointer/Makefile rename to Examples/php/pointer/Makefile diff --git a/Examples/php4/pointer/example.c b/Examples/php/pointer/example.c similarity index 100% rename from Examples/php4/pointer/example.c rename to Examples/php/pointer/example.c diff --git a/Examples/php4/pointer/example.i b/Examples/php/pointer/example.i similarity index 100% rename from Examples/php4/pointer/example.i rename to Examples/php/pointer/example.i diff --git a/Examples/php4/pointer/runme.php4 b/Examples/php/pointer/runme.php4 similarity index 100% rename from Examples/php4/pointer/runme.php4 rename to Examples/php/pointer/runme.php4 diff --git a/Examples/php4/pragmas/Makefile b/Examples/php/pragmas/Makefile similarity index 100% rename from Examples/php4/pragmas/Makefile rename to Examples/php/pragmas/Makefile diff --git a/Examples/php4/pragmas/example.i b/Examples/php/pragmas/example.i similarity index 100% rename from Examples/php4/pragmas/example.i rename to Examples/php/pragmas/example.i diff --git a/Examples/php4/pragmas/include.php b/Examples/php/pragmas/include.php similarity index 100% rename from Examples/php4/pragmas/include.php rename to Examples/php/pragmas/include.php diff --git a/Examples/php4/pragmas/runme.php4 b/Examples/php/pragmas/runme.php4 similarity index 100% rename from Examples/php4/pragmas/runme.php4 rename to Examples/php/pragmas/runme.php4 diff --git a/Examples/php4/proxy/Makefile b/Examples/php/proxy/Makefile similarity index 100% rename from Examples/php4/proxy/Makefile rename to Examples/php/proxy/Makefile diff --git a/Examples/php4/proxy/example.cxx b/Examples/php/proxy/example.cxx similarity index 100% rename from Examples/php4/proxy/example.cxx rename to Examples/php/proxy/example.cxx diff --git a/Examples/php4/proxy/example.h b/Examples/php/proxy/example.h similarity index 100% rename from Examples/php4/proxy/example.h rename to Examples/php/proxy/example.h diff --git a/Examples/php4/proxy/example.i b/Examples/php/proxy/example.i similarity index 100% rename from Examples/php4/proxy/example.i rename to Examples/php/proxy/example.i diff --git a/Examples/php4/proxy/runme.php4 b/Examples/php/proxy/runme.php4 similarity index 100% rename from Examples/php4/proxy/runme.php4 rename to Examples/php/proxy/runme.php4 diff --git a/Examples/php4/reference/Makefile b/Examples/php/reference/Makefile similarity index 100% rename from Examples/php4/reference/Makefile rename to Examples/php/reference/Makefile diff --git a/Examples/php4/reference/example.cxx b/Examples/php/reference/example.cxx similarity index 100% rename from Examples/php4/reference/example.cxx rename to Examples/php/reference/example.cxx diff --git a/Examples/php4/reference/example.h b/Examples/php/reference/example.h similarity index 100% rename from Examples/php4/reference/example.h rename to Examples/php/reference/example.h diff --git a/Examples/php4/reference/example.i b/Examples/php/reference/example.i similarity index 100% rename from Examples/php4/reference/example.i rename to Examples/php/reference/example.i diff --git a/Examples/php4/reference/runme-proxy.php4 b/Examples/php/reference/runme-proxy.php4 similarity index 100% rename from Examples/php4/reference/runme-proxy.php4 rename to Examples/php/reference/runme-proxy.php4 diff --git a/Examples/php4/reference/runme.php4 b/Examples/php/reference/runme.php4 similarity index 100% rename from Examples/php4/reference/runme.php4 rename to Examples/php/reference/runme.php4 diff --git a/Examples/php4/simple/Makefile b/Examples/php/simple/Makefile similarity index 100% rename from Examples/php4/simple/Makefile rename to Examples/php/simple/Makefile diff --git a/Examples/php4/simple/example.c b/Examples/php/simple/example.c similarity index 100% rename from Examples/php4/simple/example.c rename to Examples/php/simple/example.c diff --git a/Examples/php4/simple/example.i b/Examples/php/simple/example.i similarity index 100% rename from Examples/php4/simple/example.i rename to Examples/php/simple/example.i diff --git a/Examples/php4/simple/runme.php4 b/Examples/php/simple/runme.php4 similarity index 100% rename from Examples/php4/simple/runme.php4 rename to Examples/php/simple/runme.php4 diff --git a/Examples/php4/sync/Makefile b/Examples/php/sync/Makefile similarity index 100% rename from Examples/php4/sync/Makefile rename to Examples/php/sync/Makefile diff --git a/Examples/php4/sync/example.cxx b/Examples/php/sync/example.cxx similarity index 100% rename from Examples/php4/sync/example.cxx rename to Examples/php/sync/example.cxx diff --git a/Examples/php4/sync/example.h b/Examples/php/sync/example.h similarity index 100% rename from Examples/php4/sync/example.h rename to Examples/php/sync/example.h diff --git a/Examples/php4/sync/example.i b/Examples/php/sync/example.i similarity index 100% rename from Examples/php4/sync/example.i rename to Examples/php/sync/example.i diff --git a/Examples/php4/sync/runme.php4 b/Examples/php/sync/runme.php4 similarity index 100% rename from Examples/php4/sync/runme.php4 rename to Examples/php/sync/runme.php4 diff --git a/Examples/php4/value/Makefile b/Examples/php/value/Makefile similarity index 100% rename from Examples/php4/value/Makefile rename to Examples/php/value/Makefile diff --git a/Examples/php4/value/example.c b/Examples/php/value/example.c similarity index 100% rename from Examples/php4/value/example.c rename to Examples/php/value/example.c diff --git a/Examples/php4/value/example.h b/Examples/php/value/example.h similarity index 100% rename from Examples/php4/value/example.h rename to Examples/php/value/example.h diff --git a/Examples/php4/value/example.i b/Examples/php/value/example.i similarity index 100% rename from Examples/php4/value/example.i rename to Examples/php/value/example.i diff --git a/Examples/php4/value/runme.php4 b/Examples/php/value/runme.php4 similarity index 100% rename from Examples/php4/value/runme.php4 rename to Examples/php/value/runme.php4 diff --git a/Examples/php4/variables/Makefile b/Examples/php/variables/Makefile similarity index 100% rename from Examples/php4/variables/Makefile rename to Examples/php/variables/Makefile diff --git a/Examples/php4/variables/example.c b/Examples/php/variables/example.c similarity index 100% rename from Examples/php4/variables/example.c rename to Examples/php/variables/example.c diff --git a/Examples/php4/variables/example.h b/Examples/php/variables/example.h similarity index 100% rename from Examples/php4/variables/example.h rename to Examples/php/variables/example.h diff --git a/Examples/php4/variables/example.i b/Examples/php/variables/example.i similarity index 100% rename from Examples/php4/variables/example.i rename to Examples/php/variables/example.i diff --git a/Examples/php4/variables/runme.php4 b/Examples/php/variables/runme.php4 similarity index 100% rename from Examples/php4/variables/runme.php4 rename to Examples/php/variables/runme.php4 diff --git a/Examples/php4/variables/runme.php4.old b/Examples/php/variables/runme.php4.old similarity index 100% rename from Examples/php4/variables/runme.php4.old rename to Examples/php/variables/runme.php4.old diff --git a/Examples/test-suite/php4/Makefile.in b/Examples/test-suite/php/Makefile.in similarity index 100% rename from Examples/test-suite/php4/Makefile.in rename to Examples/test-suite/php/Makefile.in diff --git a/Examples/test-suite/php4/abstract_inherit_ok_runme.php4 b/Examples/test-suite/php/abstract_inherit_ok_runme.php4 similarity index 100% rename from Examples/test-suite/php4/abstract_inherit_ok_runme.php4 rename to Examples/test-suite/php/abstract_inherit_ok_runme.php4 diff --git a/Examples/test-suite/php4/abstract_inherit_runme.php4 b/Examples/test-suite/php/abstract_inherit_runme.php4 similarity index 100% rename from Examples/test-suite/php4/abstract_inherit_runme.php4 rename to Examples/test-suite/php/abstract_inherit_runme.php4 diff --git a/Examples/test-suite/php4/add_link_runme.php4 b/Examples/test-suite/php/add_link_runme.php4 similarity index 100% rename from Examples/test-suite/php4/add_link_runme.php4 rename to Examples/test-suite/php/add_link_runme.php4 diff --git a/Examples/test-suite/php4/argout_runme.php4 b/Examples/test-suite/php/argout_runme.php4 similarity index 100% rename from Examples/test-suite/php4/argout_runme.php4 rename to Examples/test-suite/php/argout_runme.php4 diff --git a/Examples/test-suite/php4/arrayptr_runme.php4 b/Examples/test-suite/php/arrayptr_runme.php4 similarity index 100% rename from Examples/test-suite/php4/arrayptr_runme.php4 rename to Examples/test-suite/php/arrayptr_runme.php4 diff --git a/Examples/test-suite/php4/arrays_global_runme.php4 b/Examples/test-suite/php/arrays_global_runme.php4 similarity index 100% rename from Examples/test-suite/php4/arrays_global_runme.php4 rename to Examples/test-suite/php/arrays_global_runme.php4 diff --git a/Examples/test-suite/php4/arrays_global_twodim_runme.php4 b/Examples/test-suite/php/arrays_global_twodim_runme.php4 similarity index 100% rename from Examples/test-suite/php4/arrays_global_twodim_runme.php4 rename to Examples/test-suite/php/arrays_global_twodim_runme.php4 diff --git a/Examples/test-suite/php4/arrays_runme.php4 b/Examples/test-suite/php/arrays_runme.php4 similarity index 100% rename from Examples/test-suite/php4/arrays_runme.php4 rename to Examples/test-suite/php/arrays_runme.php4 diff --git a/Examples/test-suite/php4/arrays_scope_runme.php4 b/Examples/test-suite/php/arrays_scope_runme.php4 similarity index 100% rename from Examples/test-suite/php4/arrays_scope_runme.php4 rename to Examples/test-suite/php/arrays_scope_runme.php4 diff --git a/Examples/test-suite/php4/casts_runme.php4 b/Examples/test-suite/php/casts_runme.php4 similarity index 100% rename from Examples/test-suite/php4/casts_runme.php4 rename to Examples/test-suite/php/casts_runme.php4 diff --git a/Examples/test-suite/php4/class_ignore_runme.php4 b/Examples/test-suite/php/class_ignore_runme.php4 similarity index 100% rename from Examples/test-suite/php4/class_ignore_runme.php4 rename to Examples/test-suite/php/class_ignore_runme.php4 diff --git a/Examples/test-suite/php4/conversion_namespace_runme.php4 b/Examples/test-suite/php/conversion_namespace_runme.php4 similarity index 100% rename from Examples/test-suite/php4/conversion_namespace_runme.php4 rename to Examples/test-suite/php/conversion_namespace_runme.php4 diff --git a/Examples/test-suite/php4/conversion_ns_template_runme.php4 b/Examples/test-suite/php/conversion_ns_template_runme.php4 similarity index 100% rename from Examples/test-suite/php4/conversion_ns_template_runme.php4 rename to Examples/test-suite/php/conversion_ns_template_runme.php4 diff --git a/Examples/test-suite/php4/conversion_runme.php4 b/Examples/test-suite/php/conversion_runme.php4 similarity index 100% rename from Examples/test-suite/php4/conversion_runme.php4 rename to Examples/test-suite/php/conversion_runme.php4 diff --git a/Examples/test-suite/php4/cpp_static_runme.php4 b/Examples/test-suite/php/cpp_static_runme.php4 similarity index 100% rename from Examples/test-suite/php4/cpp_static_runme.php4 rename to Examples/test-suite/php/cpp_static_runme.php4 diff --git a/Examples/test-suite/php4/enum_scope_template_runme.php4 b/Examples/test-suite/php/enum_scope_template_runme.php4 similarity index 100% rename from Examples/test-suite/php4/enum_scope_template_runme.php4 rename to Examples/test-suite/php/enum_scope_template_runme.php4 diff --git a/Examples/test-suite/php4/evil_diamond_ns_runme.php4 b/Examples/test-suite/php/evil_diamond_ns_runme.php4 similarity index 100% rename from Examples/test-suite/php4/evil_diamond_ns_runme.php4 rename to Examples/test-suite/php/evil_diamond_ns_runme.php4 diff --git a/Examples/test-suite/php4/evil_diamond_prop_runme.php4 b/Examples/test-suite/php/evil_diamond_prop_runme.php4 similarity index 100% rename from Examples/test-suite/php4/evil_diamond_prop_runme.php4 rename to Examples/test-suite/php/evil_diamond_prop_runme.php4 diff --git a/Examples/test-suite/php4/evil_diamond_runme.php4 b/Examples/test-suite/php/evil_diamond_runme.php4 similarity index 100% rename from Examples/test-suite/php4/evil_diamond_runme.php4 rename to Examples/test-suite/php/evil_diamond_runme.php4 diff --git a/Examples/test-suite/php4/extend_template_ns_runme.php4 b/Examples/test-suite/php/extend_template_ns_runme.php4 similarity index 100% rename from Examples/test-suite/php4/extend_template_ns_runme.php4 rename to Examples/test-suite/php/extend_template_ns_runme.php4 diff --git a/Examples/test-suite/php4/extend_template_runme.php4 b/Examples/test-suite/php/extend_template_runme.php4 similarity index 100% rename from Examples/test-suite/php4/extend_template_runme.php4 rename to Examples/test-suite/php/extend_template_runme.php4 diff --git a/Examples/test-suite/php4/grouping_runme.php4 b/Examples/test-suite/php/grouping_runme.php4 similarity index 100% rename from Examples/test-suite/php4/grouping_runme.php4 rename to Examples/test-suite/php/grouping_runme.php4 diff --git a/Examples/test-suite/php4/ignore_parameter_runme.php4 b/Examples/test-suite/php/ignore_parameter_runme.php4 similarity index 100% rename from Examples/test-suite/php4/ignore_parameter_runme.php4 rename to Examples/test-suite/php/ignore_parameter_runme.php4 diff --git a/Examples/test-suite/php4/li_carrays_runme.php4 b/Examples/test-suite/php/li_carrays_runme.php4 similarity index 100% rename from Examples/test-suite/php4/li_carrays_runme.php4 rename to Examples/test-suite/php/li_carrays_runme.php4 diff --git a/Examples/test-suite/php4/li_std_string_runme.php4 b/Examples/test-suite/php/li_std_string_runme.php4 similarity index 100% rename from Examples/test-suite/php4/li_std_string_runme.php4 rename to Examples/test-suite/php/li_std_string_runme.php4 diff --git a/Examples/test-suite/php4/namewarn_rename.i b/Examples/test-suite/php/namewarn_rename.i similarity index 100% rename from Examples/test-suite/php4/namewarn_rename.i rename to Examples/test-suite/php/namewarn_rename.i diff --git a/Examples/test-suite/php4/rename_scope_runme.php4 b/Examples/test-suite/php/rename_scope_runme.php4 similarity index 100% rename from Examples/test-suite/php4/rename_scope_runme.php4 rename to Examples/test-suite/php/rename_scope_runme.php4 diff --git a/Examples/test-suite/php4/skel.php4 b/Examples/test-suite/php/skel.php4 similarity index 100% rename from Examples/test-suite/php4/skel.php4 rename to Examples/test-suite/php/skel.php4 diff --git a/Examples/test-suite/php4/smart_pointer_rename_runme.php4 b/Examples/test-suite/php/smart_pointer_rename_runme.php4 similarity index 100% rename from Examples/test-suite/php4/smart_pointer_rename_runme.php4 rename to Examples/test-suite/php/smart_pointer_rename_runme.php4 diff --git a/Examples/test-suite/php4/sym_runme.php4 b/Examples/test-suite/php/sym_runme.php4 similarity index 100% rename from Examples/test-suite/php4/sym_runme.php4 rename to Examples/test-suite/php/sym_runme.php4 diff --git a/Examples/test-suite/php4/template_arg_typename_runme.php4 b/Examples/test-suite/php/template_arg_typename_runme.php4 similarity index 100% rename from Examples/test-suite/php4/template_arg_typename_runme.php4 rename to Examples/test-suite/php/template_arg_typename_runme.php4 diff --git a/Examples/test-suite/php4/template_construct_runme.php4 b/Examples/test-suite/php/template_construct_runme.php4 similarity index 100% rename from Examples/test-suite/php4/template_construct_runme.php4 rename to Examples/test-suite/php/template_construct_runme.php4 diff --git a/Examples/test-suite/php4/tests.php4 b/Examples/test-suite/php/tests.php4 similarity index 100% rename from Examples/test-suite/php4/tests.php4 rename to Examples/test-suite/php/tests.php4 diff --git a/Examples/test-suite/php4/typedef_reference_runme.php4 b/Examples/test-suite/php/typedef_reference_runme.php4 similarity index 100% rename from Examples/test-suite/php4/typedef_reference_runme.php4 rename to Examples/test-suite/php/typedef_reference_runme.php4 diff --git a/Examples/test-suite/php4/typemap_ns_using_runme.php4 b/Examples/test-suite/php/typemap_ns_using_runme.php4 similarity index 100% rename from Examples/test-suite/php4/typemap_ns_using_runme.php4 rename to Examples/test-suite/php/typemap_ns_using_runme.php4 diff --git a/Examples/test-suite/php4/using1_runme.php4 b/Examples/test-suite/php/using1_runme.php4 similarity index 100% rename from Examples/test-suite/php4/using1_runme.php4 rename to Examples/test-suite/php/using1_runme.php4 diff --git a/Examples/test-suite/php4/using2_runme.php4 b/Examples/test-suite/php/using2_runme.php4 similarity index 100% rename from Examples/test-suite/php4/using2_runme.php4 rename to Examples/test-suite/php/using2_runme.php4 diff --git a/Examples/test-suite/php4/valuewrapper_base_runme.php4 b/Examples/test-suite/php/valuewrapper_base_runme.php4 similarity index 100% rename from Examples/test-suite/php4/valuewrapper_base_runme.php4 rename to Examples/test-suite/php/valuewrapper_base_runme.php4 From 5d65e1ca926b8a5cd5e5c3085466749fd310989f Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 23 Nov 2008 19:44:29 +0000 Subject: [PATCH 0183/1680] gcc-4.3 warning fixes git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10939 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/modula3.cxx | 6 +++--- Source/Modules/php.cxx | 6 ++++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Source/Modules/modula3.cxx b/Source/Modules/modula3.cxx index e85ba3a46..1df206e62 100644 --- a/Source/Modules/modula3.cxx +++ b/Source/Modules/modula3.cxx @@ -127,7 +127,7 @@ char cvsroot_modula3_cxx[] = "$Id$"; #include // for INT_MAX #include -const char usageArgDir[] = "m3wrapargdir typemap expect values: in, out, inout\n"; +#define USAGE_ARG_DIR "m3wrapargdir typemap expect values: in, out, inout\n" class MODULA3:public Language { public: @@ -374,7 +374,7 @@ MODULA3(): } else if (Strcmp(dir, "out") == 0) { return false; } else { - printf(usageArgDir); + printf(USAGE_ARG_DIR); return false; } } @@ -386,7 +386,7 @@ MODULA3(): } else if ((Strcmp(dir, "out") == 0) || (Strcmp(dir, "inout") == 0)) { return true; } else { - printf(usageArgDir); + printf(USAGE_ARG_DIR); return false; } } diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index 434456b40..0b6036669 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -1101,7 +1101,8 @@ public: case T_LONG: { char *p; errno = 0; - (void) strtol(Char(value), &p, 0); + unsigned int n = strtol(Char(value), &p, 0); + (void) n; if (errno || *p) { Clear(value); Append(value, "?"); @@ -1114,7 +1115,8 @@ public: case T_ULONG: { char *p; errno = 0; - (void) strtoul(Char(value), &p, 0); + unsigned int n = strtoul(Char(value), &p, 0); + (void) n; if (errno || *p) { Clear(value); Append(value, "?"); From 43d1ca8c7eafe3997ea07d7206ac9975c4118163 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 23 Nov 2008 19:45:31 +0000 Subject: [PATCH 0184/1680] php4 rename to php fix git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10940 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Makefile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.in b/Makefile.in index e2ae16f0f..3c41c0394 100644 --- a/Makefile.in +++ b/Makefile.in @@ -132,7 +132,7 @@ mzscheme_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/mzscheme/check.list ruby_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/ruby/check.list) ocaml_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/ocaml/check.list) octave_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/octave/check.list) -php4_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/php/check.list) +php_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/php/check.list) pike_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/pike/check.list) chicken_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/chicken/check.list) csharp_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/csharp/check.list) From a0949cd1fe1d8298e3164cc5b987c2e48f9d0fb8 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 23 Nov 2008 21:47:39 +0000 Subject: [PATCH 0185/1680] =?UTF-8?q?=20error:=20=E2=80=98pthread=5Fonce?= =?UTF-8?q?=E2=80=99=20was=20not=20declared=20in=20this=20scope?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10941 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/swig_examples_lock.h | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Examples/test-suite/swig_examples_lock.h b/Examples/test-suite/swig_examples_lock.h index 7710f9361..07e9057f8 100644 --- a/Examples/test-suite/swig_examples_lock.h +++ b/Examples/test-suite/swig_examples_lock.h @@ -1,10 +1,10 @@ -namespace SwigExamples { - # if defined(_WIN32) || defined(__WIN32__) #include +namespace SwigExamples { + class CriticalSection { public: CriticalSection() { @@ -27,9 +27,14 @@ private: CriticalSection &critical_section; }; +} + #else #include + +namespace SwigExamples { + class CriticalSection { public: CriticalSection() { @@ -55,7 +60,7 @@ private: CriticalSection &critical_section; }; -#endif - } +#endif + From f5fbd95871d0d6d1c6476d7b052a143b30566475 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 23 Nov 2008 21:59:00 +0000 Subject: [PATCH 0186/1680] Apply patch #2319790 from Johan Hake to fix shared_ptr usage in std::tr1 namespace. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10942 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 3 +++ Lib/shared_ptr.i | 10 +++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 752ba3790..b8def93bc 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,9 @@ Version 1.3.37 (in progress) ============================ +2008-11-23: wsfulton + Apply patch #2319790 from Johan Hake to fix shared_ptr usage in std::tr1 namespace. + 2008-11-21: wsfulton The use of the include path to find the input file is now deprecated. This makes the behaviour of SWIG the same as C/C++ compilers in preparation diff --git a/Lib/shared_ptr.i b/Lib/shared_ptr.i index 0ccce64bf..c6749ff9e 100644 --- a/Lib/shared_ptr.i +++ b/Lib/shared_ptr.i @@ -1,4 +1,8 @@ // shared_ptr namespaces could be boost or std or std::tr1 +// For example for std::tr1, use: +// #define SWIG_SHARED_PTR_NAMESPACE std +// #define SWIG_SHARED_PTR_SUBNAMESPACE tr1 + #if !defined(SWIG_SHARED_PTR_NAMESPACE) # define SWIG_SHARED_PTR_NAMESPACE boost #endif @@ -44,12 +48,12 @@ SWIG_SHARED_PTR_TYPEMAPS(PROXYCLASS, const, TYPE) %define SWIG_SHARED_PTR_DERIVED(PROXYCLASS, BASECLASSTYPE, TYPE...) SWIG_SHARED_PTR_TYPEMAPS(PROXYCLASS, , TYPE) SWIG_SHARED_PTR_TYPEMAPS(PROXYCLASS, const, TYPE) -%types(SWIG_SHARED_PTR_NAMESPACE::shared_ptr< TYPE > = SWIG_SHARED_PTR_NAMESPACE::shared_ptr< BASECLASSTYPE >) %{ +%types(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > = SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< BASECLASSTYPE >) %{ *newmemory = SWIG_CAST_NEW_MEMORY; - return (void *) new SWIG_SHARED_PTR_NAMESPACE::shared_ptr< BASECLASSTYPE >(*(SWIG_SHARED_PTR_NAMESPACE::shared_ptr< TYPE > *)$from); + return (void *) new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< BASECLASSTYPE >(*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *)$from); %} %extend TYPE { - static SWIG_SHARED_PTR_NAMESPACE::shared_ptr< BASECLASSTYPE > SWIGSharedPtrUpcast(SWIG_SHARED_PTR_NAMESPACE::shared_ptr< TYPE > swigSharedPtrUpcast) { + static SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< BASECLASSTYPE > SWIGSharedPtrUpcast(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > swigSharedPtrUpcast) { return swigSharedPtrUpcast; } } From f78bdddb9d3e9448da38c32e5a6bdeab708c4d89 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 23 Nov 2008 22:07:15 +0000 Subject: [PATCH 0187/1680] give operator bool() a name git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10943 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/operbool.i | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Examples/test-suite/operbool.i b/Examples/test-suite/operbool.i index d6d7fc706..793c0174e 100644 --- a/Examples/test-suite/operbool.i +++ b/Examples/test-suite/operbool.i @@ -1,5 +1,7 @@ %module operbool +%rename(operbool) operator bool(); + %inline %{ class Test { public: From cd43bd063d98a2309f987dd57cfd9374e156252f Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 23 Nov 2008 22:29:07 +0000 Subject: [PATCH 0188/1680] Apply patch #2263850 to fix ruby/file.i ... rubyio.h filename change in ruby 1.9. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10944 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++++ Lib/ruby/file.i | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index b8def93bc..590e6f47f 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,10 @@ Version 1.3.37 (in progress) ============================ +2008-11-23: wsfulton + [ruby] Apply patch #2263850 to fix ruby/file.i ... rubyio.h filename change in + ruby 1.9. + 2008-11-23: wsfulton Apply patch #2319790 from Johan Hake to fix shared_ptr usage in std::tr1 namespace. diff --git a/Lib/ruby/file.i b/Lib/ruby/file.i index 54ed0a609..d64937ed1 100644 --- a/Lib/ruby/file.i +++ b/Lib/ruby/file.i @@ -3,7 +3,14 @@ #ifdef __cplusplus extern "C" { #endif + +// Ruby 1.9 changed the file name of this header +#ifdef HAVE_RUBY_IO_H +#include "ruby/io.h" +#else #include "rubyio.h" +#endif + #ifdef __cplusplus } #endif From 509ee37f55adca0dd527019672f0167c813032c4 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 23 Nov 2008 23:28:37 +0000 Subject: [PATCH 0189/1680] add sanity check on preprocessed output git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10945 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/main.cxx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx index 8f19504ff..740f71405 100644 --- a/Source/Modules/main.cxx +++ b/Source/Modules/main.cxx @@ -1140,11 +1140,15 @@ int SWIG_main(int argc, char *argv[], Language *l) { } if (top) { if (!Getattr(top, "name")) { - Printf(stderr, "*** No module name specified using %%module or -module.\n"); + Printf(stderr, "No module name specified using %%module or -module.\n"); SWIG_exit(EXIT_FAILURE); } else { /* Set some filename information on the object */ String *infile = scanner_get_main_input_file(); + if (!infile) { + Printf(stderr, "Missing input file in preprocessed output.\n"); + SWIG_exit(EXIT_FAILURE); + } Setattr(top, "infile", infile); // Note: if nopreprocess then infile is the original input file, otherwise input_file Setattr(top, "inputfile", input_file); if (!outfile_name) { From 4633b7a41b8b9cd09f11326fe2747c65804f0498 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 23 Nov 2008 23:29:33 +0000 Subject: [PATCH 0190/1680] remove docs on old php4 switch git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10946 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/SWIG.html | 1 - 1 file changed, 1 deletion(-) diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html index c1ffcff60..890763b11 100644 --- a/Doc/Manual/SWIG.html +++ b/Doc/Manual/SWIG.html @@ -120,7 +120,6 @@ can be obtained by typing swig -help or swig -mzscheme Generate Mzscheme wrappers -ocaml Generate Ocaml wrappers -perl Generate Perl wrappers --php4 Generate PHP4 wrappers -php5 Generate PHP5 wrappers -pike Generate Pike wrappers -python Generate Python wrappers From 6994737f1923f7b4f41f00907231136245fa20b2 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 25 Nov 2008 23:36:23 +0000 Subject: [PATCH 0191/1680] Add -outcurrentdir option git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10947 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 6 ++++++ Doc/Manual/SWIG.html | 1 + Source/Modules/main.cxx | 25 +++++++++++++++++-------- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 590e6f47f..0b7a1e079 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,12 @@ Version 1.3.37 (in progress) ============================ +2008-11-24: wsfulton + Add -outcurrentdir option. This sets the default output directory to the current + directory instead of the path specified by the input file. This option enables + behaviour similar to c/c++ compilers. Note that this controls the output directory, + but only in the absence of the -o and/or -outdir options. + 2008-11-23: wsfulton [ruby] Apply patch #2263850 to fix ruby/file.i ... rubyio.h filename change in ruby 1.9. diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html index 890763b11..95135998b 100644 --- a/Doc/Manual/SWIG.html +++ b/Doc/Manual/SWIG.html @@ -139,6 +139,7 @@ can be obtained by typing swig -help or swig -lfile Include a SWIG library file. -module name Set the name of the SWIG module -o outfile Name of output file +-outcurrentdir Set default output dir to current dir instead of input file's path -outdir dir Set language specific files output directory -swiglib Show location of SWIG library -version Show SWIG version number diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx index 740f71405..a41191bb9 100644 --- a/Source/Modules/main.cxx +++ b/Source/Modules/main.cxx @@ -117,7 +117,8 @@ static const char *usage3 = (const char *) "\ -fastdispatch -fvirtual \n\ -o - Set name of the output file to \n\ -oh - Set name of the output header file to \n\ - -outdir - Set language specific files output directory \n\ + -outcurrentdir - Set default output dir to current dir instead of input file's path\n\ + -outdir - Set language specific files output directory to \n\ -small - Compile in virtual elimination & compact mode\n\ -swiglib - Report location of SWIG library and exit\n\ -templatereduce - Reduce all the typedefs in templates\n\ @@ -153,6 +154,7 @@ static char *cpp_extension = (char *) "cxx"; static char *depends_extension = (char *) "d"; static String *outdir = 0; static String *xmlout = 0; +static int outcurrentdir = 0; static int help = 0; static int checkout = 0; static int cpp_only = 0; @@ -694,6 +696,9 @@ void SWIG_getoptions(int argc, char *argv[]) { } else { Swig_arg_error(); } + } else if (strcmp(argv[i], "-outcurrentdir") == 0) { + Swig_mark_arg(i); + outcurrentdir = 1; } else if (strcmp(argv[i], "-Wall") == 0) { Swig_mark_arg(i); Swig_warnall(); @@ -1018,11 +1023,13 @@ int SWIG_main(int argc, char *argv[], Language *l) { if (depend) { if (!no_cpp) { String *outfile; + + char *basename = Swig_file_basename(outcurrentdir ? Swig_file_filename(input_file): Char(input_file)); if (!outfile_name) { if (CPlusPlus || lang->cplus_runtime_mode()) { - outfile = NewStringf("%s_wrap.%s", Swig_file_basename(input_file), cpp_extension); + outfile = NewStringf("%s_wrap.%s", basename, cpp_extension); } else { - outfile = NewStringf("%s_wrap.c", Swig_file_basename(input_file)); + outfile = NewStringf("%s_wrap.c", basename); } } else { outfile = NewString(outfile_name); @@ -1034,7 +1041,7 @@ int SWIG_main(int argc, char *argv[], Language *l) { SWIG_exit(EXIT_FAILURE); } } else if (!depend_only) { - String *filename = NewStringf("%s_wrap.%s", Swig_file_basename(input_file), depends_extension); + String *filename = NewStringf("%s_wrap.%s", basename, depends_extension); f_dependencies_file = NewFile(filename, "w", SWIG_output_files()); if (!f_dependencies_file) { FileErrorDisplay(filename); @@ -1151,21 +1158,23 @@ int SWIG_main(int argc, char *argv[], Language *l) { } Setattr(top, "infile", infile); // Note: if nopreprocess then infile is the original input file, otherwise input_file Setattr(top, "inputfile", input_file); + + char *basename = Swig_file_basename(outcurrentdir ? Swig_file_filename(infile): Char(infile)); if (!outfile_name) { if (CPlusPlus || lang->cplus_runtime_mode()) { - Setattr(top, "outfile", NewStringf("%s_wrap.%s", Swig_file_basename(infile), cpp_extension)); + Setattr(top, "outfile", NewStringf("%s_wrap.%s", basename, cpp_extension)); } else { - Setattr(top, "outfile", NewStringf("%s_wrap.c", Swig_file_basename(infile))); + Setattr(top, "outfile", NewStringf("%s_wrap.c", basename)); } } else { Setattr(top, "outfile", outfile_name); } if (!outfile_name_h) { - Setattr(top, "outfile_h", NewStringf("%s_wrap.%s", Swig_file_basename(infile), hpp_extension)); + Setattr(top, "outfile_h", NewStringf("%s_wrap.%s", basename, hpp_extension)); } else { Setattr(top, "outfile_h", outfile_name_h); } - set_outdir(Swig_file_dirname(Getattr(top, "outfile"))); + set_outdir(Swig_file_dirname(basename)); if (Swig_contract_mode_get()) { Swig_contracts(top); } From 53f786e5a684c3525be67cbbd480f8582155b943 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 26 Nov 2008 18:37:48 +0000 Subject: [PATCH 0192/1680] gcc-4.3 warning fixes git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10948 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/GIFPlot/Lib/color.c | 5 ++++- Examples/GIFPlot/Lib/gif.c | 6 +++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Examples/GIFPlot/Lib/color.c b/Examples/GIFPlot/Lib/color.c index a4eaf285e..7d79baca9 100644 --- a/Examples/GIFPlot/Lib/color.c +++ b/Examples/GIFPlot/Lib/color.c @@ -132,7 +132,10 @@ int ColorMap_write(ColorMap *cm, char *filename) { f = fopen(filename,"w"); - fwrite(cm->cmap,768,1,f); + if (fwrite(cm->cmap,768,1,f) != 1) { + fclose(f); + return -1; + } fclose(f); return 0; } diff --git a/Examples/GIFPlot/Lib/gif.c b/Examples/GIFPlot/Lib/gif.c index a0cfca1d5..2ade38d38 100644 --- a/Examples/GIFPlot/Lib/gif.c +++ b/Examples/GIFPlot/Lib/gif.c @@ -656,7 +656,11 @@ int FrameBuffer_writeGIF(FrameBuffer *f, ColorMap *c, char *filename) { fclose(file); return -1; } - fwrite(buffer,nbytes,1,file); + if (fwrite(buffer,nbytes,1,file) != 1) { + free(buffer); + fclose(file); + return -1; + } fclose(file); free(buffer); return 0; From db83e514419ac153574f46935ffee69145ba7b05 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 26 Nov 2008 21:35:15 +0000 Subject: [PATCH 0193/1680] modify test-suite (barring python atm) to not rely on the -I path to find the input .i file - removes the new warning 125 and sets up the test-suite for testing with ccache. This change required the use of -outcurrentdir and moving the .i files from the language subdirectories to the directory above along with some .i file name changes. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10949 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/GIFPlot/Java/shadow/Makefile | 5 +- Examples/GIFPlot/Perl5/shadow/Makefile | 7 +- Examples/GIFPlot/Python/shadow/Makefile | 7 +- Examples/GIFPlot/Ruby/shadow/Makefile | 7 +- Examples/Makefile.in | 148 ++++++------ Examples/test-suite/chicken/Makefile.in | 2 +- ...est_runme.ss => chicken_ext_test_runme.ss} | 2 +- .../ext_test.i => chicken_ext_test.i} | 2 +- Examples/test-suite/common.mk | 16 +- Examples/test-suite/csharp/Makefile.in | 1 + Examples/test-suite/guilescm/Makefile.in | 2 +- ..._runme.scm => guilescm_ext_test_runme.scm} | 2 +- .../ext_test.i => guilescm_ext_test.i} | 2 +- .../test-suite/{octave => }/implicittest.i | 0 Examples/test-suite/java/Makefile.in | 3 +- .../test-suite/{ruby => }/li_std_functors.i | 0 Examples/test-suite/{perl5 => }/li_std_list.i | 0 .../li_std_pair.i => li_std_pair_extra.i} | 2 +- .../{ruby => }/li_std_pair_lang_object.i | 0 Examples/test-suite/{ruby => }/li_std_queue.i | 0 Examples/test-suite/{ruby => }/li_std_stack.i | 0 .../li_std_string.i => li_std_string_extra.i} | 4 +- Examples/test-suite/octave/Makefile.in | 4 +- .../octave/li_std_pair_extra_runme.m | 69 ++++++ .../test-suite/octave/li_std_pair_runme.m | 69 ------ Examples/test-suite/octave/li_std_string.i | 55 ----- ...ng_runme.m => li_std_string_extra_runme.m} | 66 +++--- ...eref_runme.m => octave_cell_deref_runme.m} | 2 +- .../cell_deref.i => octave_cell_deref.i} | 2 +- Examples/test-suite/php/Makefile.in | 3 + ...amewarn_rename.i => php_namewarn_rename.i} | 2 +- Examples/test-suite/python/Makefile.in | 2 + Examples/test-suite/python/implicittest.i | 68 ------ Examples/test-suite/python/li_std_pair.i | 210 ------------------ .../python/li_std_pair_extra_runme.py | 59 +++++ .../test-suite/python/li_std_pair_runme.py | 59 ----- ..._runme.py => li_std_string_extra_runme.py} | 66 +++--- Examples/test-suite/r/Makefile.in | 4 +- Examples/test-suite/r/double_delete_runme.R | 12 - ...y_struct_runme.R => r_copy_struct_runme.R} | 4 +- Examples/test-suite/r/r_double_delete_runme.R | 9 + .../r/{legacy_runme.R => r_legacy_runme.R} | 4 +- .../{r/copy_struct.i => r_copy_struct.i} | 2 +- .../{r/double_delete.i => r_double_delete.i} | 3 +- .../test-suite/{r/legacy.i => r_legacy.i} | 2 +- Examples/test-suite/ruby/Makefile.in | 14 +- ...ywords_runme.rb => ruby_keywords_runme.rb} | 4 +- ...ed_runme.rb => ruby_li_std_speed_runme.rb} | 4 +- .../{naming_runme.rb => ruby_naming_runme.rb} | 40 ++-- ... => ruby_track_objects_directors_runme.rb} | 8 +- ...s_runme.rb => ruby_track_objects_runme.rb} | 24 +- .../{ruby/keywords.i => ruby_keywords.i} | 2 +- .../li_std_speed.i => ruby_li_std_speed.i} | 4 +- .../{ruby/naming.i => ruby_naming.i} | 2 +- .../track_objects.i => ruby_track_objects.i} | 2 +- ...ctors.i => ruby_track_objects_directors.i} | 2 +- Examples/test-suite/{r => }/simple_array.i | 0 Examples/test-suite/{ruby => }/stl_new.i | 0 Examples/test-suite/tcl/Makefile.in | 5 +- Examples/test-suite/tcl/union_runme.tcl | 0 Examples/test-suite/{tcl => }/union.i | 0 61 files changed, 390 insertions(+), 709 deletions(-) rename Examples/test-suite/chicken/{ext_test_runme.ss => chicken_ext_test_runme.ss} (57%) rename Examples/test-suite/{chicken/ext_test.i => chicken_ext_test.i} (94%) rename Examples/test-suite/guilescm/{ext_test_runme.scm => guilescm_ext_test_runme.scm} (82%) rename Examples/test-suite/{guilescm/ext_test.i => guilescm_ext_test.i} (93%) rename Examples/test-suite/{octave => }/implicittest.i (100%) rename Examples/test-suite/{ruby => }/li_std_functors.i (100%) rename Examples/test-suite/{perl5 => }/li_std_list.i (100%) rename Examples/test-suite/{octave/li_std_pair.i => li_std_pair_extra.i} (99%) rename Examples/test-suite/{ruby => }/li_std_pair_lang_object.i (100%) rename Examples/test-suite/{ruby => }/li_std_queue.i (100%) rename Examples/test-suite/{ruby => }/li_std_stack.i (100%) rename Examples/test-suite/{python/li_std_string.i => li_std_string_extra.i} (93%) create mode 100644 Examples/test-suite/octave/li_std_pair_extra_runme.m delete mode 100644 Examples/test-suite/octave/li_std_pair_runme.m delete mode 100644 Examples/test-suite/octave/li_std_string.i rename Examples/test-suite/octave/{li_std_string_runme.m => li_std_string_extra_runme.m} (50%) rename Examples/test-suite/octave/{cell_deref_runme.m => octave_cell_deref_runme.m} (85%) rename Examples/test-suite/{octave/cell_deref.i => octave_cell_deref.i} (86%) rename Examples/test-suite/{php/namewarn_rename.i => php_namewarn_rename.i} (81%) delete mode 100644 Examples/test-suite/python/implicittest.i delete mode 100644 Examples/test-suite/python/li_std_pair.i create mode 100644 Examples/test-suite/python/li_std_pair_extra_runme.py delete mode 100644 Examples/test-suite/python/li_std_pair_runme.py rename Examples/test-suite/python/{li_std_string_runme.py => li_std_string_extra_runme.py} (54%) delete mode 100644 Examples/test-suite/r/double_delete_runme.R rename Examples/test-suite/r/{copy_struct_runme.R => r_copy_struct_runme.R} (89%) create mode 100644 Examples/test-suite/r/r_double_delete_runme.R rename Examples/test-suite/r/{legacy_runme.R => r_legacy_runme.R} (86%) rename Examples/test-suite/{r/copy_struct.i => r_copy_struct.i} (97%) rename Examples/test-suite/{r/double_delete.i => r_double_delete.i} (67%) rename Examples/test-suite/{r/legacy.i => r_legacy.i} (98%) rename Examples/test-suite/ruby/{keywords_runme.rb => ruby_keywords_runme.rb} (98%) rename Examples/test-suite/ruby/{li_std_speed_runme.rb => ruby_li_std_speed_runme.rb} (97%) rename Examples/test-suite/ruby/{naming_runme.rb => ruby_naming_runme.rb} (68%) rename Examples/test-suite/ruby/{track_objects_directors_runme.rb => ruby_track_objects_directors_runme.rb} (74%) rename Examples/test-suite/ruby/{track_objects_runme.rb => ruby_track_objects_runme.rb} (78%) rename Examples/test-suite/{ruby/keywords.i => ruby_keywords.i} (98%) rename Examples/test-suite/{ruby/li_std_speed.i => ruby_li_std_speed.i} (90%) rename Examples/test-suite/{ruby/naming.i => ruby_naming.i} (98%) rename Examples/test-suite/{ruby/track_objects.i => ruby_track_objects.i} (98%) rename Examples/test-suite/{ruby/track_objects_directors.i => ruby_track_objects_directors.i} (88%) rename Examples/test-suite/{r => }/simple_array.i (100%) rename Examples/test-suite/{ruby => }/stl_new.i (100%) mode change 100755 => 100644 Examples/test-suite/tcl/union_runme.tcl rename Examples/test-suite/{tcl => }/union.i (100%) diff --git a/Examples/GIFPlot/Java/shadow/Makefile b/Examples/GIFPlot/Java/shadow/Makefile index e513b9b5a..8062c2700 100644 --- a/Examples/GIFPlot/Java/shadow/Makefile +++ b/Examples/GIFPlot/Java/shadow/Makefile @@ -1,8 +1,9 @@ TOP = ../../.. SWIG = $(TOP)/../swig -SWIGOPT = -I../../Interface +SWIGOPT = -outcurrentdir SRCS = TARGET = gifplot +INTERFACEDIR = ../../Interface/ INTERFACE = gifplot.i LIBS = -L../.. -lgifplot INCLUDES = -I../../Include @@ -10,7 +11,7 @@ INCLUDES = -I../../Include all:: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java + TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' INTERFACEDIR='$(INTERFACEDIR)' java javac *.java clean:: diff --git a/Examples/GIFPlot/Perl5/shadow/Makefile b/Examples/GIFPlot/Perl5/shadow/Makefile index c5cb7aec4..c39eac52c 100644 --- a/Examples/GIFPlot/Perl5/shadow/Makefile +++ b/Examples/GIFPlot/Perl5/shadow/Makefile @@ -1,8 +1,9 @@ TOP = ../../.. SWIG = $(TOP)/../swig -SWIGOPT = -I../../Interface +SWIGOPT = -outcurrentdir SRCS = TARGET = gifplot +INTERFACEDIR = ../../Interface/ INTERFACE = gifplot.i LIBS = -L../.. -lgifplot -lm INCLUDES = -I../../Include @@ -10,12 +11,12 @@ INCLUDES = -I../../Include all:: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5 + 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)' perl5_static + TARGET='myperl' INTERFACE='$(INTERFACE)' INTERFACEDIR='$(INTERFACEDIR)' perl5_static clean:: $(MAKE) -f $(TOP)/Makefile perl5_clean diff --git a/Examples/GIFPlot/Python/shadow/Makefile b/Examples/GIFPlot/Python/shadow/Makefile index 73fca9673..3ae9a9897 100644 --- a/Examples/GIFPlot/Python/shadow/Makefile +++ b/Examples/GIFPlot/Python/shadow/Makefile @@ -1,8 +1,9 @@ TOP = ../../.. SWIG = $(TOP)/../preinst-swig -SWIGOPT = -I../../Interface +SWIGOPT = -outcurrentdir SRCS = TARGET = gifplot +INTERFACEDIR = ../../Interface/ INTERFACE = gifplot.i LIBS = -L../.. -lgifplot INCLUDES = -I../../Include @@ -10,12 +11,12 @@ INCLUDES = -I../../Include all:: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python + 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)' python_static + TARGET='mypython' INTERFACE='$(INTERFACE)' INTERFACEDIR='$(INTERFACEDIR)' python_static clean:: $(MAKE) -f $(TOP)/Makefile python_clean diff --git a/Examples/GIFPlot/Ruby/shadow/Makefile b/Examples/GIFPlot/Ruby/shadow/Makefile index ea382ea88..8cbea2a57 100644 --- a/Examples/GIFPlot/Ruby/shadow/Makefile +++ b/Examples/GIFPlot/Ruby/shadow/Makefile @@ -1,8 +1,9 @@ TOP = ../../.. SWIG = $(TOP)/../swig -SWIGOPT = -I../../Interface +SWIGOPT = -outcurrentdir SRCS = TARGET = gifplot +INTERFACEDIR = ../../Interface/ INTERFACE = gifplot.i LIBS = -L../.. -lgifplot INCLUDES = -I../../Include @@ -10,12 +11,12 @@ INCLUDES = -I../../Include all:: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby + 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)' ruby_static + TARGET='myruby' INTERFACE='$(INTERFACE)' INTERFACEDIR='$(INTERFACEDIR)' ruby_static clean:: $(MAKE) -f $(TOP)/Makefile ruby_clean diff --git a/Examples/Makefile.in b/Examples/Makefile.in index c0ced7022..5dbf8b6b7 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -12,11 +12,11 @@ # certain packages have been installed. Set the prefixes # accordingly. # -# 2. To use this makefile, simply set SRCS, INTERFACE, INCLUDES, LIBS, -# TARGET, and do a +# 2. To use this makefile, set required varibles, eg SRCS, INTERFACE, +# INTERFACEDIR, INCLUDES, LIBS, TARGET, and do a # $(MAKE) -f Makefile.template.in SRCS='$(SRCS)' \ # INCLUDES='$(INCLUDES) LIBS='$(LIBS)' INTERFACE='$(INTERFACE)' \ -# TARGET='$(TARGET)' method +# INTERFACEDIR='$(INTERFACEDIR)' TARGET='$(TARGET)' method # # 'method' describes what is being built. #--------------------------------------------------------------- @@ -31,6 +31,8 @@ SRCS = INCLUDES = LIBS = INTERFACE = +INTERFACEDIR = +INTERFACEPATH = $(INTERFACEDIR)$(INTERFACE) SWIGOPT = SWIG = swig @@ -105,12 +107,12 @@ TCLCXXSHARED = @TCLCXXSHARED@ tclsh: $(SRCS) - $(SWIG) -tcl8 $(SWIGOPT) $(TCL_SWIGOPTS) -ltclsh.i $(INTERFACE) + $(SWIG) -tcl8 $(SWIGOPT) $(TCL_SWIGOPTS) -ltclsh.i $(INTERFACEPATH) $(CC) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) $(TCL_INCLUDE) \ $(TCL_LIB) $(TCL_OPTS) $(LIBS) $(SYSLIBS) -o $(TARGET) tclsh_cpp: $(SRCS) - $(SWIG) -tcl8 -c++ $(SWIGOPT) $(TCL_SWIGOPTS) -ltclsh.i $(INTERFACE) + $(SWIG) -tcl8 -c++ $(SWIGOPT) $(TCL_SWIGOPTS) -ltclsh.i $(INTERFACEPATH) $(CXX) $(CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(TCL_INCLUDE) \ $(TCL_LIB) $(TCL_OPTS) $(LIBS) $(SYSLIBS) -o $(TARGET) @@ -119,13 +121,13 @@ tclsh_cpp: $(SRCS) # ----------------------------------------------------------- wish: $(SRCS) - $(SWIG) -tcl8 $(SWIGOPT) $(TCL_SWIGOPTS) -lwish.i $(INTERFACE) + $(SWIG) -tcl8 $(SWIGOPT) $(TCL_SWIGOPTS) -lwish.i $(INTERFACEPATH) $(CC) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) $(TCL_INCLUDE) \ $(XINCLUDE) $(TCL_LIB) $(TK_OPTS) $(XLIB) $(LIBS) $(SYSLIBS) -o $(TARGET) wish_cpp: $(SRCS) - $(SWIG) -tcl8 -c++ $(SWIGOPT) $(TCL_SWIGOPTS) -lwish.i $(INTERFACE) + $(SWIG) -tcl8 -c++ $(SWIGOPT) $(TCL_SWIGOPTS) -lwish.i $(INTERFACEPATH) $(CXX) $(CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(TCL_INCLUDE) \ $(XINCLUDE) $(TCL_LIB) $(TK_OPTS) $(XLIB) $(LIBS) $(SYSLIBS) -o $(TARGET) @@ -134,7 +136,7 @@ wish_cpp: $(SRCS) # ----------------------------------------------------------- tcl: $(SRCS) - $(SWIG) -tcl8 $(SWIGOPT) $(TCL_SWIGOPTS) $(INTERFACE) + $(SWIG) -tcl8 $(SWIGOPT) $(TCL_SWIGOPTS) $(INTERFACEPATH) $(CC) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) $(TCL_INCLUDE) $(TCLLDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(TCL_DLNK) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(TCL_SO) @@ -143,7 +145,7 @@ tcl: $(SRCS) # ----------------------------------------------------------- tcl_cpp: $(SRCS) - $(SWIG) -tcl8 -c++ $(SWIGOPT) $(TCL_SWIGOPTS) $(INTERFACE) + $(SWIG) -tcl8 -c++ $(SWIGOPT) $(TCL_SWIGOPTS) $(INTERFACEPATH) $(CXX) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(TCL_INCLUDE) $(TCLCXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(TCL_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(TCL_SO) @@ -175,7 +177,7 @@ PERL5_CCFLAGS = @PERL5CCFLAGS@ # ---------------------------------------------------------------- perl5: $(SRCS) - $(SWIG) -perl5 $(SWIGOPT) $(INTERFACE) + $(SWIG) -perl5 $(SWIGOPT) $(INTERFACEPATH) $(CC) -c -Dbool=char $(CCSHARED) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) $(PERL5_CCFLAGS) -I$(PERL5_INCLUDE) $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(PERL5_DLNK) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO) @@ -184,7 +186,7 @@ perl5: $(SRCS) # ---------------------------------------------------------------- perl5_cpp: $(SRCS) - $(SWIG) -perl5 -c++ $(SWIGOPT) $(INTERFACE) + $(SWIG) -perl5 -c++ $(SWIGOPT) $(INTERFACEPATH) $(CXX) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(PERL5_CCFLAGS) -I$(PERL5_INCLUDE) $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(PERL5_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO) @@ -202,11 +204,11 @@ perl5_xs: $(SRCS) PERL5_LIB = -L$(PERL5_INCLUDE) -l@PERL5LIB@ @LIBS@ $(SYSLIBS) perl5_static: $(SRCS) - $(SWIG) -perl5 -static -lperlmain.i $(SWIGOPT) $(INTERFACE) + $(SWIG) -perl5 -static -lperlmain.i $(SWIGOPT) $(INTERFACEPATH) $(CC) $(CFLAGS) -Dbool=char $(SRCS) $(ISRCS) $(INCLUDES) -I$(PERL5_INCLUDE) $(PERL5_LIB) $(LIBS) -o $(TARGET) perl5_static_cpp: $(SRCS) - $(SWIG) -perl5 -c++ -static -lperlmain.i $(SWIGOPT) $(INTERFACE) + $(SWIG) -perl5 -c++ -static -lperlmain.i $(SWIGOPT) $(INTERFACEPATH) $(CXX) $(CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) -I$(PERL5_INCLUDE) $(PERL5_LIB) $(LIBS) -o $(TARGET) # ----------------------------------------------------------------- @@ -255,7 +257,7 @@ endif # ---------------------------------------------------------------- python: $(SRCS) - $(SWIGPYTHON) $(SWIGOPT) $(INTERFACE) + $(SWIGPYTHON) $(SWIGOPT) $(INTERFACEPATH) $(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(SRCS) $(INCLUDES) $(PYTHON_INCLUDE) $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(PYTHON_DLNK) $(LIBS) -o $(LIBPREFIX)_$(TARGET)$(PYTHON_SO) @@ -264,7 +266,7 @@ python: $(SRCS) # ----------------------------------------------------------------- python_cpp: $(SRCS) - $(SWIGPYTHON) -c++ $(SWIGOPT) $(INTERFACE) + $(SWIGPYTHON) -c++ $(SWIGOPT) $(INTERFACEPATH) $(CXX) -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) $(PYTHON_INCLUDE) $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(PYTHON_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)_$(TARGET)$(PYTHON_SO) @@ -280,12 +282,12 @@ TKINTER = PYTHON_LIBOPTS = $(PYTHON_LINK) @LIBS@ $(TKINTER) $(SYSLIBS) python_static: $(SRCS) - $(SWIGPYTHON) -lembed.i $(SWIGOPT) $(INTERFACE) + $(SWIGPYTHON) -lembed.i $(SWIGOPT) $(INTERFACEPATH) $(CC) $(CFLAGS) @LINKFORSHARED@ $(ISRCS) $(SRCS) $(INCLUDES) \ $(PYTHON_INCLUDE) $(LIBS) -L$(PYTHON_LIB) $(PYTHON_LIBOPTS) -o $(TARGET) python_static_cpp: $(SRCS) - $(SWIGPYTHON) -c++ -lembed.i $(SWIGOPT) $(INTERFACE) + $(SWIGPYTHON) -c++ -lembed.i $(SWIGOPT) $(INTERFACEPATH) $(CXX) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) \ $(PYTHON_INCLUDE) $(LIBS) -L$(PYTHON_LIB) $(PYTHON_LIBOPTS) -o $(TARGET) @@ -336,7 +338,7 @@ OCTAVE_SO = @OCTAVE_SO@ # ---------------------------------------------------------------- octave: $(SRCS) - $(SWIG) -octave $(SWIGOPT) $(INTERFACE) + $(SWIG) -octave $(SWIGOPT) $(INTERFACEPATH) $(CXX) -g -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(CXXSRCS) $(INCLUDES) -I$(OCTAVE_INCLUDE) $(CC) -g -c $(CCSHARED) $(CFLAGS) $(SRCS) $(INCLUDES) $(OCTAVE_INCLUDE) $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(OCTAVE_DLNK) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(OCTAVE_SO) @@ -346,7 +348,7 @@ octave: $(SRCS) # ----------------------------------------------------------------- octave_cpp: $(SRCS) - $(SWIG) -c++ -octave $(SWIGOPT) $(INTERFACE) + $(SWIG) -c++ -octave $(SWIGOPT) $(INTERFACEPATH) $(CXX) -g -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) -I$(OCTAVE_INCLUDE) $(CXXSHARED) -g $(CFLAGS) $(OBJS) $(IOBJS) $(OCTAVE_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(OCTAVE_SO) @@ -373,12 +375,12 @@ GUILE_LIBPREFIX = lib # Build a dynamically loaded module with passive linkage and the scm interface #------------------------------------------------------------------ guile: $(SRCS) - $(SWIG) -guile -scm -Linkage passive $(SWIGOPT) $(INTERFACE) + $(SWIG) -guile -scm -Linkage passive $(SWIGOPT) $(INTERFACEPATH) $(CC) -c $(CCSHARED) $(CFLAGS) $(INCLUDES) $(GUILE_INCLUDE) $(ISRCS) $(SRCS) $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO) guile_cpp: $(SRCS) - $(SWIG) -c++ -guile -scm -Linkage passive $(SWIGOPT) $(INTERFACE) + $(SWIG) -c++ -guile -scm -Linkage passive $(SWIGOPT) $(INTERFACEPATH) $(CXX) -c $(CCSHARED) $(CFLAGS) $(INCLUDES) $(GUILE_INCLUDE) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO) @@ -389,12 +391,12 @@ guile_externalhdr: # Build a dynamically loaded module with passive linkage and the gh interface #------------------------------------------------------------------ guile_gh: $(SRCS) - $(SWIG) -guile -gh -Linkage passive $(SWIGOPT) $(INTERFACE) + $(SWIG) -guile -gh -Linkage passive $(SWIGOPT) $(INTERFACEPATH) $(CC) -c $(CCSHARED) $(CFLAGS) $(INCLUDES) $(GUILE_INCLUDE) $(ISRCS) $(SRCS) $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO) guile_gh_cpp: $(SRCS) - $(SWIG) -c++ -guile -gh -Linkage passive $(SWIGOPT) $(INTERFACE) + $(SWIG) -c++ -guile -gh -Linkage passive $(SWIGOPT) $(INTERFACEPATH) $(CXX) -c $(CCSHARED) $(CFLAGS) $(INCLUDES) $(GUILE_INCLUDE) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO) @@ -403,12 +405,12 @@ guile_gh_cpp: $(SRCS) # ----------------------------------------------------------------- guile_passive: $(SRCS) - $(SWIG) -guile -Linkage passive $(SWIGOPT) $(INTERFACE) + $(SWIG) -guile -Linkage passive $(SWIGOPT) $(INTERFACEPATH) $(CC) -c $(CCSHARED) $(CFLAGS) $(INCLUDES) $(GUILE_INCLUDE) $(ISRCS) $(SRCS) $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO) guile_passive_cpp: $(SRCS) - $(SWIG) -c++ -guile -Linkage passive $(SWIGOPT) $(INTERFACE) + $(SWIG) -c++ -guile -Linkage passive $(SWIGOPT) $(INTERFACEPATH) $(CXX) -c $(CCSHARED) $(CFLAGS) $(INCLUDES) $(GUILE_INCLUDE) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO) @@ -419,24 +421,24 @@ guile_passive_cpp: $(SRCS) GUILE_LIBOPTS = @GUILELINK@ @LIBS@ $(SYSLIBS) guile_static: $(SRCS) - $(SWIG) -guile -lguilemain.i -Linkage ltdlmod $(SWIGOPT) $(INTERFACE) + $(SWIG) -guile -lguilemain.i -Linkage ltdlmod $(SWIGOPT) $(INTERFACEPATH) $(CC) $(CFLAGS) $(ISRCS) $(SRCS) $(INCLUDES) \ -DSWIGINIT="SCM scm_init_$(TARGET)_module(void); scm_init_$(TARGET)_module();" \ $(GUILE_INCLUDE) $(LIBS) -L$(GUILE_LIB) $(GUILE_LIBOPTS) -o $(TARGET)-guile guile_static_cpp: $(SRCS) - $(SWIG) -c++ -guile -lguilemain.i -Linkage ltdlmod $(SWIGOPT) $(INTERFACE) + $(SWIG) -c++ -guile -lguilemain.i -Linkage ltdlmod $(SWIGOPT) $(INTERFACEPATH) $(CXX) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) \ -DSWIGINIT="SCM scm_init_$(TARGET)_module(void); scm_init_$(TARGET)_module();" \ $(GUILE_INCLUDE) $(LIBS) -L$(GUILE_LIB) $(GUILE_LIBOPTS) -o $(TARGET)-guile guile_simple: $(SRCS) - $(SWIG) -guile -lguilemain.i -Linkage simple $(SWIGOPT) $(INTERFACE) + $(SWIG) -guile -lguilemain.i -Linkage simple $(SWIGOPT) $(INTERFACEPATH) $(CC) $(CFLAGS) $(ISRCS) $(SRCS) $(INCLUDES) \ $(GUILE_INCLUDE) $(LIBS) -L$(GUILE_LIB) $(GUILE_LIBOPTS) -o $(TARGET)-guile guile_simple_cpp: $(SRCS) - $(SWIG) -c++ -guile -lguilemain.i -Linkage simple $(SWIGOPT) $(INTERFACE) + $(SWIG) -c++ -guile -lguilemain.i -Linkage simple $(SWIGOPT) $(INTERFACEPATH) $(CXX) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) \ $(GUILE_INCLUDE) $(LIBS) -L$(GUILE_LIB) $(GUILE_LIBOPTS) -o $(TARGET)-guile @@ -471,7 +473,7 @@ JAVACFLAGS = @JAVACFLAGS@ # ---------------------------------------------------------------- java: $(SRCS) - $(SWIG) -java $(SWIGOPT) $(INTERFACE) + $(SWIG) -java $(SWIGOPT) $(INTERFACEPATH) $(CC) -c $(CCSHARED) $(CFLAGS) $(JAVACFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) $(JAVA_INCLUDE) $(JAVALDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(JAVA_DLNK) $(LIBS) -o $(JAVA_LIBPREFIX)$(TARGET)$(JAVASO) @@ -480,7 +482,7 @@ java: $(SRCS) # ---------------------------------------------------------------- java_cpp: $(SRCS) - $(SWIG) -java -c++ $(SWIGOPT) $(INTERFACE) + $(SWIG) -java -c++ $(SWIGOPT) $(INTERFACEPATH) $(CXX) -c $(CCSHARED) $(CFLAGS) $(JAVACFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(JAVA_INCLUDE) $(JAVACXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(JAVA_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(JAVA_LIBPREFIX)$(TARGET)$(JAVASO) @@ -504,12 +506,12 @@ MODULA3_INCLUDE= @MODULA3INC@ # ---------------------------------------------------------------- modula3: $(SRCS) - $(SWIG) -modula3 $(SWIGOPT) $(INTERFACE) + $(SWIG) -modula3 $(SWIGOPT) $(INTERFACEPATH) # $(CC) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) \ # $(OBJS) $(IOBJS) $(LIBS) modula3_cpp: $(SRCS) - $(SWIG) -modula3 -c++ $(SWIGOPT) $(INTERFACE) + $(SWIG) -modula3 -c++ $(SWIGOPT) $(INTERFACEPATH) # ----------------------------------------------------------------- # Cleaning the modula3 examples @@ -533,12 +535,12 @@ MZSCHEME_SO = @MZSCHEME_SO@ # ---------------------------------------------------------------- mzscheme: $(SRCS) - $(SWIG) -mzscheme $(SWIGOPT) $(INTERFACE) + $(SWIG) -mzscheme $(SWIGOPT) $(INTERFACEPATH) $(MZC) `echo $(INCLUDES) | sed 's/-I/++ccf -I/g'` --cc $(ISRCS) $(SRCS) $(MZC) --ld $(TARGET)$(MZSCHEME_SO) $(OBJS) $(IOBJS) mzscheme_cpp: $(SRCS) - $(SWIG) -mzscheme -c++ $(SWIGOPT) $(INTERFACE) + $(SWIG) -mzscheme -c++ $(SWIGOPT) $(INTERFACEPATH) $(MZC) `echo $(INCLUDES) | sed 's/-I/++ccf -I/g'` --cc $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(CXXSHARED) $(CFLAGS) -o $(LIBPREFIX)$(TARGET)$(MZSCHEME_SO) $(OBJS) $(IOBJS) $(MZDYNOBJ) $(CPP_DLLIBS) @@ -573,7 +575,7 @@ OCAMLCORE=\ ocaml_static: $(SRCS) $(OCAMLCORE) - $(SWIG) -ocaml $(SWIGOPT) $(INTERFACE) + $(SWIG) -ocaml $(SWIGOPT) $(INTERFACEPATH) $(OCC) -g -c -ccopt -g -ccopt "$(INCLUDES)" $(ISRCS) $(SRCS) $(OCC) -g -c $(INTERFACE:%.i=%.mli) $(OCC) -g -c $(INTERFACE:%.i=%.ml) @@ -587,7 +589,7 @@ ocaml_static: $(SRCS) ocaml_dynamic: $(SRCS) $(OCAMLCORE) - $(SWIG) -ocaml $(SWIGOPT) $(INTERFACE) + $(SWIG) -ocaml $(SWIGOPT) $(INTERFACEPATH) $(OCC) -g -c -ccopt -g -ccopt "$(INCLUDES)" $(ISRCS) $(SRCS) $(CXXSHARED) $(CFLAGS) $(CCSHARED) $(CFLAGS) -o $(INTERFACE:%.i=%@SO@) \ $(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) $(LIBS) @@ -606,7 +608,7 @@ ocaml_dynamic: $(SRCS) ocaml_static_toplevel: $(SRCS) $(OCAMLCORE) - $(SWIG) -ocaml $(SWIGOPT) $(INTERFACE) + $(SWIG) -ocaml $(SWIGOPT) $(INTERFACEPATH) $(OCC) -g -c -ccopt -g -ccopt "$(INCLUDES)" $(ISRCS) $(SRCS) $(OCC) -g -c $(INTERFACE:%.i=%.mli) $(OCC) -g -c $(INTERFACE:%.i=%.ml) @@ -621,7 +623,7 @@ ocaml_static_toplevel: $(SRCS) ocaml_static_cpp: $(SRCS) $(OCAMLCORE) - $(SWIG) -ocaml -c++ $(SWIGOPT) $(INTERFACE) + $(SWIG) -ocaml -c++ $(SWIGOPT) $(INTERFACEPATH) cp $(ICXXSRCS) $(ICXXSRCS:%.cxx=%.c) $(OCC) -cc '$(CXX)' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" \ $(ICXXSRCS:%.cxx=%.c) $(SRCS) $(CXXSRCS) @@ -638,7 +640,7 @@ ocaml_static_cpp: $(SRCS) ocaml_static_cpp_toplevel: $(SRCS) $(OCAMLCORE) - $(SWIG) -ocaml -c++ $(SWIGOPT) $(INTERFACE) + $(SWIG) -ocaml -c++ $(SWIGOPT) $(INTERFACEPATH) cp $(ICXXSRCS) $(ICXXSRCS:%.cxx=%.c) $(OCC) -cc '$(CXX)' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" \ $(ICXXSRCS:%.cxx=%.c) $(SRCS) $(CXXSRCS) @@ -656,7 +658,7 @@ ocaml_static_cpp_toplevel: $(SRCS) ocaml_dynamic_cpp: $(SRCS) $(OCAMLCORE) - $(SWIG) -ocaml -c++ $(SWIGOPT) $(INTERFACE) + $(SWIG) -ocaml -c++ $(SWIGOPT) $(INTERFACEPATH) cp $(ICXXSRCS) $(ICXXSRCS:%.cxx=%.c) $(OCC) -cc '$(CXX)' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" \ $(ICXXSRCS:%.cxx=%.c) $(SRCS) $(CXXSRCS) -ccopt -fPIC @@ -697,7 +699,7 @@ RUBY_DLNK = @RUBYDYNAMICLINKING@ # ---------------------------------------------------------------- ruby: $(SRCS) - $(SWIG) -ruby $(SWIGOPT) $(INTERFACE) + $(SWIG) -ruby $(SWIGOPT) $(INTERFACEPATH) $(CC) -c $(CCSHARED) $(CFLAGS) $(RUBY_CFLAGS) $(ISRCS) $(SRCS) $(INCLUDES) $(RUBY_INCLUDE) $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(RUBY_DLNK) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO) @@ -706,7 +708,7 @@ ruby: $(SRCS) # ----------------------------------------------------------------- ruby_cpp: $(SRCS) - $(SWIG) -c++ -ruby $(SWIGOPT) $(INTERFACE) + $(SWIG) -c++ -ruby $(SWIGOPT) $(INTERFACEPATH) $(CXX) -c $(CCSHARED) $(CFLAGS) $(RUBY_CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) $(RUBY_INCLUDE) $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(RUBY_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO) @@ -720,12 +722,12 @@ ruby_cpp: $(SRCS) RUBY_LIBOPTS = @RUBYLINK@ @LIBS@ $(SYSLIBS) ruby_static: $(SRCS) - $(SWIG) -ruby -lembed.i $(SWIGOPT) $(INTERFACE) + $(SWIG) -ruby -lembed.i $(SWIGOPT) $(INTERFACEPATH) $(CC) $(CFLAGS) $(RUBY_CFLAGS) @LINKFORSHARED@ $(ISRCS) $(SRCS) $(INCLUDES) \ $(RUBY_INCLUDE) $(LIBS) -L$(RUBY_LIB) $(RUBY_LIBOPTS) -o $(TARGET) ruby_cpp_static: $(SRCS) - $(SWIG) -c++ -ruby -lembed.i $(SWIGOPT) $(INTERFACE) + $(SWIG) -c++ -ruby -lembed.i $(SWIGOPT) $(INTERFACEPATH) $(CXX) $(CFLAGS) $(RUBY_CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) \ $(RUBY_INCLUDE) $(LIBS) -L$(RUBY_LIB) $(RUBY_LIBOPTS) -o $(TARGET) @@ -751,7 +753,7 @@ PHP4_INCLUDE = @PHP4INC@ PHP4_SO = @PHP4_SO@ php4: $(SRCS) - $(SWIG) -php5 $(SWIGOPT) $(INTERFACE) + $(SWIG) -php5 $(SWIGOPT) $(INTERFACEPATH) $(CC) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) $(PHP4_INCLUDE) $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(PHP4_SO) @@ -760,7 +762,7 @@ php4: $(SRCS) # -------------------------------------------------------------------- php4_cpp: $(SRCS) - $(SWIG) -php5 -cppext cxx -c++ $(SWIGOPT) $(INTERFACE) + $(SWIG) -php5 -cppext cxx -c++ $(SWIGOPT) $(INTERFACEPATH) $(CXX) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(PHP4_INCLUDE) $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(PHP4_SO) @@ -798,7 +800,7 @@ PIKE_DLNK = @PIKEDYNAMICLINKING@ # ---------------------------------------------------------------- pike: $(SRCS) - $(SWIG) -pike $(SWIGOPT) $(INTERFACE) + $(SWIG) -pike $(SWIGOPT) $(INTERFACEPATH) $(CC) -c $(CCSHARED) $(CFLAGS) $(PIKE_CFLAGS) $(ISRCS) $(SRCS) $(INCLUDES) $(PIKE_INCLUDE) $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(PIKE_DLNK) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO) @@ -807,7 +809,7 @@ pike: $(SRCS) # ----------------------------------------------------------------- pike_cpp: $(SRCS) - $(SWIG) -c++ -pike $(SWIGOPT) $(INTERFACE) + $(SWIG) -c++ -pike $(SWIGOPT) $(INTERFACEPATH) $(CXX) -c $(CCSHARED) $(CFLAGS) $(PIKE_CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) $(PIKE_INCLUDE) $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(PIKE_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO) @@ -821,12 +823,12 @@ pike_cpp: $(SRCS) PIKE_LIBOPTS = @PIKELINK@ @LIBS@ $(SYSLIBS) pike_static: $(SRCS) - $(SWIG) -pike -lembed.i $(SWIGOPT) $(INTERFACE) + $(SWIG) -pike -lembed.i $(SWIGOPT) $(INTERFACEPATH) $(CC) $(CFLAGS) $(PIKE_CFLAGS) @LINKFORSHARED@ $(ISRCS) $(SRCS) $(INCLUDES) \ $(PIKE_INCLUDE) $(LIBS) -L$(PIKE_LIB) $(PIKE_LIBOPTS) -o $(TARGET) pike_cpp_static: $(SRCS) - $(SWIG) -c++ -pike -lembed.i $(SWIGOPT) $(INTERFACE) + $(SWIG) -c++ -pike -lembed.i $(SWIGOPT) $(INTERFACEPATH) $(CXX) $(CFLAGS) $(PIKE_CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) \ $(PIKE_INCLUDE) $(LIBS) -L$(PIKE_LIB) $(PIKE_LIBOPTS) -o $(TARGET) @@ -868,7 +870,7 @@ CHICKEN_COMPILED_MAIN_OBJECT = $(CHICKEN_COMPILED_MAIN:.c=.@OBJEXT@) # This is the old way to build chicken, but it does not work correctly with exceptions chicken_direct: $(SRCS) - $(SWIG) -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACE) + $(SWIG) -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACEPATH) $(CHICKEN) $(CHICKEN_GENERATED_SCHEME) $(CHICKENOPTS) \ -dynamic -feature chicken-compile-shared \ -output-file $(CHICKEN_COMPILED_SCHEME) @@ -878,7 +880,7 @@ chicken_direct: $(SRCS) $(LIBS) $(CHICKEN_SHAREDLIBOPTS) -o $(LIBPREFIX)$(TARGET)$(SO) chicken_direct_cpp: $(CXXSRCS) $(CHICKSRCS) - $(SWIG) -c++ -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACE) + $(SWIG) -c++ -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACEPATH) $(CHICKEN) $(CHICKEN_GENERATED_SCHEME) $(CHICKENOPTS) \ -dynamic -feature chicken-compile-shared \ -output-file $(CHICKEN_COMPILED_SCHEME) @@ -893,7 +895,7 @@ chicken_direct_cpp: $(CXXSRCS) $(CHICKSRCS) # The following two targets are also used by the test suite chicken_static: $(SRCS) $(CHICKSRCS) - $(SWIG) -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACE) + $(SWIG) -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACEPATH) $(CHICKEN) $(CHICKEN_GENERATED_SCHEME) $(CHICKENOPTS) \ -output-file $(CHICKEN_COMPILED_SCHEME) $(CHICKEN) $(CHICKEN_MAIN) $(CHICKENOPTS) \ @@ -905,7 +907,7 @@ chicken_static: $(SRCS) $(CHICKSRCS) $(OBJS) $(IOBJS) $(LIBS) $(CHICKEN_SHAREDLIBOPTS) -o $(TARGET) chicken_static_cpp: $(CXXSRCS) $(CHICKSRCS) - $(SWIG) -c++ -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACE) + $(SWIG) -c++ -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACEPATH) $(CHICKEN) $(CHICKEN_GENERATED_SCHEME) $(CHICKENOPTS) \ -output-file $(CHICKEN_COMPILED_SCHEME) $(CHICKEN) $(CHICKEN_MAIN) $(CHICKENOPTS) \ @@ -921,11 +923,11 @@ chicken_static_cpp: $(CXXSRCS) $(CHICKSRCS) # ---------------------------------------------------------------- chicken: - $(SWIG) -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACE) + $(SWIG) -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACEPATH) $(COMPILETOOL) $(CHICKEN_CSC) -s `echo $(INCLUDES) | sed 's/-I/-C -I/g'` $(CHICKEN_GENERATED_SCHEME) $(SRCS) $(ISRCS) -o $(TARGET)$(SO) chicken_cpp: - $(SWIG) -c++ -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACE) + $(SWIG) -c++ -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACEPATH) $(COMPILETOOL) $(CHICKEN_CSC) -s `echo $(INCLUDES) | sed 's/-I/-C -I/g'` $(CHICKEN_GENERATED_SCHEME) $(SRCS) $(ICXXSRCS) $(CXXSRCS) -o $(TARGET)$(SO) chicken_externalhdr: @@ -953,7 +955,7 @@ CSHARPSO = @CSHARPSO@ # ---------------------------------------------------------------- csharp: $(SRCS) - $(SWIG) -csharp $(SWIGOPT) $(INTERFACE) + $(SWIG) -csharp $(SWIGOPT) $(INTERFACEPATH) $(CC) -c $(CCSHARED) $(CFLAGS) $(CSHARPCFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(CSHARP_DLNK) $(LIBS) -o $(CSHARP_LIBPREFIX)$(TARGET)$(CSHARPSO) @@ -962,7 +964,7 @@ csharp: $(SRCS) # ---------------------------------------------------------------- csharp_cpp: $(SRCS) - $(SWIG) -csharp -c++ $(SWIGOPT) $(INTERFACE) + $(SWIG) -csharp -c++ $(SWIGOPT) $(INTERFACEPATH) $(CXX) -c $(CCSHARED) $(CFLAGS) $(CSHARPCFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(CSHARP_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(CSHARP_LIBPREFIX)$(TARGET)$(CSHARPSO) @@ -1002,7 +1004,7 @@ LUA_INTERP = ../lua.c # ---------------------------------------------------------------- lua: $(SRCS) - $(SWIG) -lua $(SWIGOPT) $(INTERFACE) + $(SWIG) -lua $(SWIGOPT) $(INTERFACEPATH) $(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(SRCS) $(INCLUDES) $(LUA_INCLUDE) $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(LUA_LIB) -o $(LIBPREFIX)$(TARGET)$(LUA_SO) @@ -1011,7 +1013,7 @@ lua: $(SRCS) # ----------------------------------------------------------------- lua_cpp: $(SRCS) - $(SWIG) -c++ -lua $(SWIGOPT) $(INTERFACE) + $(SWIG) -c++ -lua $(SWIGOPT) $(INTERFACEPATH) $(CXX) -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) $(LUA_INCLUDE) $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(LUA_LIB) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(LUA_SO) @@ -1020,12 +1022,12 @@ lua_cpp: $(SRCS) # ----------------------------------------------------------------- lua_static: $(SRCS) - $(SWIG) -lua -module example $(SWIGOPT) $(INTERFACE) + $(SWIG) -lua -module example $(SWIGOPT) $(INTERFACEPATH) $(CC) $(CFLAGS) $(ISRCS) $(SRCS) $(LUA_INTERP) $(INCLUDES) \ $(LUA_INCLUDE) $(LIBS) $(LUA_LIB) -o $(TARGET) lua_static_cpp: $(SRCS) - $(SWIG) -c++ -lua -module example $(SWIGOPT) $(INTERFACE) + $(SWIG) -c++ -lua -module example $(SWIGOPT) $(INTERFACEPATH) $(CXX) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(LUA_INTERP) $(INCLUDES) \ $(LUA_INCLUDE) $(LIBS) $(LUA_LIB) -o $(TARGET) @@ -1043,12 +1045,12 @@ lua_clean: ################################################################## allegrocl: $(SRCS) - $(SWIG) -allegrocl -cwrap $(SWIGOPT) $(INTERFACE) + $(SWIG) -allegrocl -cwrap $(SWIGOPT) $(INTERFACEPATH) $(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(INCLUDES) $(SRCS) $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO) allegrocl_cpp: $(SRCS) - $(SWIG) -c++ -allegrocl $(SWIGOPT) $(INTERFACE) + $(SWIG) -c++ -allegrocl $(SWIGOPT) $(INTERFACEPATH) $(CXX) -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO) @@ -1062,10 +1064,10 @@ allegrocl_clean: ################################################################## clisp: $(SRCS) - $(SWIG) -clisp $(SWIGOPT) $(INTERFACE) + $(SWIG) -clisp $(SWIGOPT) $(INTERFACEPATH) clisp_cpp: $(SRCS) - $(SWIG) -c++ -clisp $(SWIGOPT) $(INTERFACE) + $(SWIG) -c++ -clisp $(SWIGOPT) $(INTERFACEPATH) clisp_clean: rm -f *_wrap* *~ .~* @@ -1077,12 +1079,12 @@ clisp_clean: ################################################################## cffi: $(SRCS) - $(SWIG) -cffi $(SWIGOPT) $(INTERFACE) + $(SWIG) -cffi $(SWIGOPT) $(INTERFACEPATH) # $(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(INCLUDES) $(SRCS) # $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO) cffi_cpp: $(SRCS) - $(SWIG) -c++ -cffi $(SWIGOPT) $(INTERFACE) + $(SWIG) -c++ -cffi $(SWIGOPT) $(INTERFACEPATH) $(CXX) -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO) @@ -1096,12 +1098,12 @@ cffi_clean: ################################################################## uffi: $(SRCS) - $(SWIG) -uffi $(SWIGOPT) $(INTERFACE) + $(SWIG) -uffi $(SWIGOPT) $(INTERFACEPATH) # $(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(INCLUDES) $(SRCS) # $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO) uffi_cpp: $(SRCS) - $(SWIG) -c++ -uffi $(SWIGOPT) $(INTERFACE) + $(SWIG) -c++ -uffi $(SWIGOPT) $(INTERFACEPATH) # $(CXX) -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) # $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO) @@ -1119,11 +1121,11 @@ RCXXSRCS = $(INTERFACE:.i=_wrap.cpp) #Need to use _wrap.cpp for R build system a RRSRC = $(INTERFACE:.i=.R) r: $(SRCS) - $(SWIG) -r $(SWIGOPT) $(INTERFACE) + $(SWIG) -r $(SWIGOPT) $(INTERFACEPATH) +( PKG_LIBS="$(SRCS)" PKG_CPPFLAGS="$(INCLUDES)" $(COMPILETOOL) $(R) CMD SHLIB -o $(LIBPREFIX)$(TARGET)$(SO) $(ISRCS) ) r_cpp: $(CXXSRCS) - $(SWIG) -c++ -r $(SWIGOPT) -o $(RCXXSRCS) $(INTERFACE) + $(SWIG) -c++ -r $(SWIGOPT) -o $(RCXXSRCS) $(INTERFACEPATH) +( PKG_LIBS="$(CXXSRCS)" PKG_CPPFLAGS="$(INCLUDES)" $(COMPILETOOL) $(R) CMD SHLIB -o $(LIBPREFIX)$(TARGET)$(SO) $(RCXXSRCS) ) r_clean: diff --git a/Examples/test-suite/chicken/Makefile.in b/Examples/test-suite/chicken/Makefile.in index ef6d7056c..764518880 100644 --- a/Examples/test-suite/chicken/Makefile.in +++ b/Examples/test-suite/chicken/Makefile.in @@ -19,7 +19,7 @@ SKIP_CPP_STD_CASES = Yes CPP_TEST_CASES += li_std_string -EXTRA_TEST_CASES += ext_test.externaltest +EXTRA_TEST_CASES += chicken_ext_test.externaltest include $(srcdir)/../common.mk diff --git a/Examples/test-suite/chicken/ext_test_runme.ss b/Examples/test-suite/chicken/chicken_ext_test_runme.ss similarity index 57% rename from Examples/test-suite/chicken/ext_test_runme.ss rename to Examples/test-suite/chicken/chicken_ext_test_runme.ss index ea3eaa487..65fa4e085 100644 --- a/Examples/test-suite/chicken/ext_test_runme.ss +++ b/Examples/test-suite/chicken/chicken_ext_test_runme.ss @@ -1,4 +1,4 @@ -(load "ext_test.so") +(load "chicken_ext_test.so") (define a (test-create)) diff --git a/Examples/test-suite/chicken/ext_test.i b/Examples/test-suite/chicken_ext_test.i similarity index 94% rename from Examples/test-suite/chicken/ext_test.i rename to Examples/test-suite/chicken_ext_test.i index e8f5930df..b4f726cc7 100644 --- a/Examples/test-suite/chicken/ext_test.i +++ b/Examples/test-suite/chicken_ext_test.i @@ -1,4 +1,4 @@ -%module ext_test +%module chicken_ext_test /* just use the imports_a.h header... for this test we only need a class */ %{ diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 8e525d9ed..4bfd53aba 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -59,11 +59,12 @@ CXXSRCS = CSRCS = TARGETPREFIX = TARGETSUFFIX = -SWIGOPT = -I$(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$(LANGUAGE) -I$(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE) -DSWIG_NOEXTRA_QUALIFICATION -INCLUDES = -I$(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$(LANGUAGE) -I$(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE) +SWIGOPT = -outcurrentdir -I$(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE) +INCLUDES = -I$(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE) LIBS = -L. LIBPREFIX = lib ACTION = check +INTERFACEDIR = ../ # # Please keep test cases in alphabetical order. @@ -405,6 +406,7 @@ CPP_STD_TEST_CASES += \ template_typedef_fnc \ template_type_namespace \ template_opaque +# li_std_list ifndef SKIP_CPP_STD_CASES @@ -441,11 +443,13 @@ C_TEST_CASES += \ overload_extendc \ preproc \ ret_by_value \ + simple_array \ sizeof_pointer \ sneaky1 \ struct_rename \ typedef_struct \ typemap_subst \ + union \ unions @@ -491,14 +495,14 @@ swig_and_compile_cpp = \ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile CXXSRCS="$(CXXSRCS)" \ SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" \ INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT)" NOLINK=true \ - TARGET="$(TARGETPREFIX)$*$(TARGETSUFFIX)" INTERFACE="$*.i" \ + TARGET="$(TARGETPREFIX)$*$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$*.i" \ $(LANGUAGE)$(VARIANT)_cpp swig_and_compile_c = \ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile CSRCS="$(CSRCS)" \ SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" \ INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT)" NOLINK=true \ - TARGET="$(TARGETPREFIX)$*$(TARGETSUFFIX)" INTERFACE="$*.i" \ + TARGET="$(TARGETPREFIX)$*$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$*.i" \ $(LANGUAGE)$(VARIANT) swig_and_compile_multi_cpp = \ @@ -506,7 +510,7 @@ swig_and_compile_multi_cpp = \ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile CXXSRCS="$(CXXSRCS)" \ SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" LIBS='$(LIBS)' \ INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT)" NOLINK=true \ - TARGET="$(TARGETPREFIX)$${f}$(TARGETSUFFIX)" INTERFACE="$$f.i" \ + TARGET="$(TARGETPREFIX)$${f}$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$$f.i" \ $(LANGUAGE)$(VARIANT)_cpp; \ done @@ -518,7 +522,7 @@ swig_and_compile_external = \ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile CXXSRCS="$(CXXSRCS) $*_external.cxx" \ SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" \ INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT)" NOLINK=true \ - TARGET="$(TARGETPREFIX)$*$(TARGETSUFFIX)" INTERFACE="$*.i" \ + TARGET="$(TARGETPREFIX)$*$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$*.i" \ $(LANGUAGE)$(VARIANT)_cpp swig_and_compile_runtime = \ diff --git a/Examples/test-suite/csharp/Makefile.in b/Examples/test-suite/csharp/Makefile.in index f269b3276..5fb547f3f 100644 --- a/Examples/test-suite/csharp/Makefile.in +++ b/Examples/test-suite/csharp/Makefile.in @@ -29,6 +29,7 @@ include $(srcdir)/../common.mk # Overridden variables here SWIGOPT += -namespace $*Namespace $(SWIGOPTSPECIAL) +INTERFACEDIR = ../../ CSHARPFLAGSSPECIAL = diff --git a/Examples/test-suite/guilescm/Makefile.in b/Examples/test-suite/guilescm/Makefile.in index 04de236db..501a387f7 100644 --- a/Examples/test-suite/guilescm/Makefile.in +++ b/Examples/test-suite/guilescm/Makefile.in @@ -2,7 +2,7 @@ # Makefile for guile test-suite (with SCM API) ####################################################################### -EXTRA_TEST_CASES += ext_test.externaltest +EXTRA_TEST_CASES += guilescm_ext_test.externaltest include ../guile/Makefile diff --git a/Examples/test-suite/guilescm/ext_test_runme.scm b/Examples/test-suite/guilescm/guilescm_ext_test_runme.scm similarity index 82% rename from Examples/test-suite/guilescm/ext_test_runme.scm rename to Examples/test-suite/guilescm/guilescm_ext_test_runme.scm index 67add849e..ff3df064b 100644 --- a/Examples/test-suite/guilescm/ext_test_runme.scm +++ b/Examples/test-suite/guilescm/guilescm_ext_test_runme.scm @@ -1,4 +1,4 @@ -(dynamic-call "scm_init_ext_test_module" (dynamic-link "./libext_test.so")) +(dynamic-call "scm_init_guilescm_ext_test_module" (dynamic-link "./libguilescm_ext_test.so")) ; This is a test for SF Bug 1573892 ; If IsPointer is called before TypeQuery, the test-is-pointer will fail diff --git a/Examples/test-suite/guilescm/ext_test.i b/Examples/test-suite/guilescm_ext_test.i similarity index 93% rename from Examples/test-suite/guilescm/ext_test.i rename to Examples/test-suite/guilescm_ext_test.i index 8b117bb5a..fd5655d4f 100644 --- a/Examples/test-suite/guilescm/ext_test.i +++ b/Examples/test-suite/guilescm_ext_test.i @@ -1,4 +1,4 @@ -%module ext_test +%module guilescm_ext_test /* just use the imports_a.h header... for this test we only need a class */ %{ diff --git a/Examples/test-suite/octave/implicittest.i b/Examples/test-suite/implicittest.i similarity index 100% rename from Examples/test-suite/octave/implicittest.i rename to Examples/test-suite/implicittest.i diff --git a/Examples/test-suite/java/Makefile.in b/Examples/test-suite/java/Makefile.in index ace8dee86..a2986258e 100644 --- a/Examples/test-suite/java/Makefile.in +++ b/Examples/test-suite/java/Makefile.in @@ -37,6 +37,7 @@ include $(srcdir)/../common.mk # Overridden variables here SWIGOPT += -package $* +INTERFACEDIR = ../../ # Rules for the different types of tests %.cpptest: @@ -72,7 +73,7 @@ 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;) \ + 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 diff --git a/Examples/test-suite/ruby/li_std_functors.i b/Examples/test-suite/li_std_functors.i similarity index 100% rename from Examples/test-suite/ruby/li_std_functors.i rename to Examples/test-suite/li_std_functors.i diff --git a/Examples/test-suite/perl5/li_std_list.i b/Examples/test-suite/li_std_list.i similarity index 100% rename from Examples/test-suite/perl5/li_std_list.i rename to Examples/test-suite/li_std_list.i diff --git a/Examples/test-suite/octave/li_std_pair.i b/Examples/test-suite/li_std_pair_extra.i similarity index 99% rename from Examples/test-suite/octave/li_std_pair.i rename to Examples/test-suite/li_std_pair_extra.i index 886bf1a4b..4e3b3a571 100644 --- a/Examples/test-suite/octave/li_std_pair.i +++ b/Examples/test-suite/li_std_pair_extra.i @@ -1,4 +1,4 @@ -%module li_std_pair +%module li_std_pair_extra // // activate the automatic comparison methods generation (==,!=,...) diff --git a/Examples/test-suite/ruby/li_std_pair_lang_object.i b/Examples/test-suite/li_std_pair_lang_object.i similarity index 100% rename from Examples/test-suite/ruby/li_std_pair_lang_object.i rename to Examples/test-suite/li_std_pair_lang_object.i diff --git a/Examples/test-suite/ruby/li_std_queue.i b/Examples/test-suite/li_std_queue.i similarity index 100% rename from Examples/test-suite/ruby/li_std_queue.i rename to Examples/test-suite/li_std_queue.i diff --git a/Examples/test-suite/ruby/li_std_stack.i b/Examples/test-suite/li_std_stack.i similarity index 100% rename from Examples/test-suite/ruby/li_std_stack.i rename to Examples/test-suite/li_std_stack.i diff --git a/Examples/test-suite/python/li_std_string.i b/Examples/test-suite/li_std_string_extra.i similarity index 93% rename from Examples/test-suite/python/li_std_string.i rename to Examples/test-suite/li_std_string_extra.i index 822d713c4..aa758532a 100644 --- a/Examples/test-suite/python/li_std_string.i +++ b/Examples/test-suite/li_std_string_extra.i @@ -1,4 +1,4 @@ -%module li_std_string +%module li_std_string_extra %naturalvar A; @@ -51,5 +51,5 @@ std::basic_string,std::allocator > test_value_ %} -%include ../li_std_string.i +%include "li_std_string.i" diff --git a/Examples/test-suite/octave/Makefile.in b/Examples/test-suite/octave/Makefile.in index 534da55c4..b12cf500a 100644 --- a/Examples/test-suite/octave/Makefile.in +++ b/Examples/test-suite/octave/Makefile.in @@ -10,7 +10,9 @@ top_srcdir = @top_srcdir@ top_builddir = @top_builddir@ CPP_TEST_CASES += \ - cell_deref + li_std_pair_extra \ + li_std_string_extra \ + octave_cell_deref CPP_TEST_BROKEN += \ implicittest \ diff --git a/Examples/test-suite/octave/li_std_pair_extra_runme.m b/Examples/test-suite/octave/li_std_pair_extra_runme.m new file mode 100644 index 000000000..0f9e9a23d --- /dev/null +++ b/Examples/test-suite/octave/li_std_pair_extra_runme.m @@ -0,0 +1,69 @@ +li_std_pair_extra + +p = {1,2}; +p1 = li_std_pair_extra.p_inout(p); +assert(all(cell2mat(p1)==[2,1])); +p2 = li_std_pair_extra.p_inoutd(p1); +assert(all(cell2mat(p2)==[1,2])); + +d1 = li_std_pair_extra.d_inout(2); +assert(d1==4); + +[i,d2] = li_std_pair_extra.d_inout2(2); +assert(all([i,d2]==[1,4])); + +[i,p] = li_std_pair_extra.p_inout2(p); +assert(i==1&&all([cell2mat(p)]==[2,1])); +[p3,p4] = li_std_pair_extra.p_inout3(p1,p1); +assert(all(cell2mat(p3)==[2,1])); +assert(all(cell2mat(p4)==[2,1])); + +psi = li_std_pair_extra.SIPair("hello",1); +assert(psi=={"hello",1}); +pci = li_std_pair_extra.CIPair(complex(1,2),1); +assert(pci.first==complex(1,2)&&pci.second==1); + + +psi = li_std_pair_extra.SIPair("hi",1); +assert(psi.first=="hi"&&psi.second==1); + +psii = li_std_pair_extra.SIIPair(psi,1); +assert(psii.first.first=="hi"); +assert(psii.first.second==1); +assert(psii.second==1); + +a = li_std_pair_extra.A(); +b = li_std_pair_extra.B(); + +pab = li_std_pair_extra.ABPair(a,b); + +pab.first = a; +pab.first.val = 2; + +assert(pab.first.val == 2); + +pci = li_std_pair_extra.CIntPair(1,0); +assert(pci.first==1&&pci.second==0); + +a = li_std_pair_extra.A(5); +p1 = li_std_pair_extra.pairP1(1,a); +p2 = li_std_pair_extra.pairP2(a,1); +p3 = li_std_pair_extra.pairP3(a,a); + +assert(a.val == li_std_pair_extra.p_identa(p1){2}.val); + +p = li_std_pair_extra.IntPair(1,10); +assert(p.first==1&&p.second==10); +p.first = 1; +assert(p.first==1); + +p = li_std_pair_extra.paircA1(1,a); +assert(p.first==1); +assert(swig_this(p.second)==swig_this(a)); + +p = li_std_pair_extra.paircA2(1,a); +assert(p.first==1); +assert(swig_this(p.second)==swig_this(a)); +#pp = li_std_pair_extra.pairiiA(1,p); # conversion pb re const of pairA1/A2 +pp = li_std_pair_extra.pairiiA(1,{1,A()}); + diff --git a/Examples/test-suite/octave/li_std_pair_runme.m b/Examples/test-suite/octave/li_std_pair_runme.m deleted file mode 100644 index 83e9fe5b5..000000000 --- a/Examples/test-suite/octave/li_std_pair_runme.m +++ /dev/null @@ -1,69 +0,0 @@ -li_std_pair - -p = {1,2}; -p1 = li_std_pair.p_inout(p); -assert(all(cell2mat(p1)==[2,1])); -p2 = li_std_pair.p_inoutd(p1); -assert(all(cell2mat(p2)==[1,2])); - -d1 = li_std_pair.d_inout(2); -assert(d1==4); - -[i,d2] = li_std_pair.d_inout2(2); -assert(all([i,d2]==[1,4])); - -[i,p] = li_std_pair.p_inout2(p); -assert(i==1&&all([cell2mat(p)]==[2,1])); -[p3,p4] = li_std_pair.p_inout3(p1,p1); -assert(all(cell2mat(p3)==[2,1])); -assert(all(cell2mat(p4)==[2,1])); - -psi = li_std_pair.SIPair("hello",1); -assert(psi=={"hello",1}); -pci = li_std_pair.CIPair(complex(1,2),1); -assert(pci.first==complex(1,2)&&pci.second==1); - - -psi = li_std_pair.SIPair("hi",1); -assert(psi.first=="hi"&&psi.second==1); - -psii = li_std_pair.SIIPair(psi,1); -assert(psii.first.first=="hi"); -assert(psii.first.second==1); -assert(psii.second==1); - -a = li_std_pair.A(); -b = li_std_pair.B(); - -pab = li_std_pair.ABPair(a,b); - -pab.first = a; -pab.first.val = 2; - -assert(pab.first.val == 2); - -pci = li_std_pair.CIntPair(1,0); -assert(pci.first==1&&pci.second==0); - -a = li_std_pair.A(5); -p1 = li_std_pair.pairP1(1,a); -p2 = li_std_pair.pairP2(a,1); -p3 = li_std_pair.pairP3(a,a); - -assert(a.val == li_std_pair.p_identa(p1){2}.val); - -p = li_std_pair.IntPair(1,10); -assert(p.first==1&&p.second==10); -p.first = 1; -assert(p.first==1); - -p = li_std_pair.paircA1(1,a); -assert(p.first==1); -assert(swig_this(p.second)==swig_this(a)); - -p = li_std_pair.paircA2(1,a); -assert(p.first==1); -assert(swig_this(p.second)==swig_this(a)); -#pp = li_std_pair.pairiiA(1,p); # conversion pb re const of pairA1/A2 -pp = li_std_pair.pairiiA(1,{1,A()}); - diff --git a/Examples/test-suite/octave/li_std_string.i b/Examples/test-suite/octave/li_std_string.i deleted file mode 100644 index 822d713c4..000000000 --- a/Examples/test-suite/octave/li_std_string.i +++ /dev/null @@ -1,55 +0,0 @@ -%module li_std_string - -%naturalvar A; - - -%include -%include - - -%inline %{ - -struct A : std::string -{ - A(const std::string& s) : std::string(s) - { - } -}; - -struct B -{ - B(const std::string& s) : cname(0), name(s), a(s) - { - } - - char *cname; - std::string name; - A a; - -}; - - -const char* test_ccvalue(const char* x) { - return x; -} - -char* test_cvalue(char* x) { - return x; -} - -std::basic_string test_value_basic1(std::basic_string x) { - return x; -} - -std::basic_string > test_value_basic2(std::basic_string > x) { - return x; -} - -std::basic_string,std::allocator > test_value_basic3(std::basic_string,std::allocator > x) { - return x; -} - -%} - -%include ../li_std_string.i - diff --git a/Examples/test-suite/octave/li_std_string_runme.m b/Examples/test-suite/octave/li_std_string_extra_runme.m similarity index 50% rename from Examples/test-suite/octave/li_std_string_runme.m rename to Examples/test-suite/octave/li_std_string_extra_runme.m index fa0e260e0..75cec17fe 100644 --- a/Examples/test-suite/octave/li_std_string_runme.m +++ b/Examples/test-suite/octave/li_std_string_extra_runme.m @@ -1,27 +1,27 @@ -li_std_string +li_std_string_extra x="hello"; -if (li_std_string.test_ccvalue(x) != x) +if (li_std_string_extra.test_ccvalue(x) != x) error("bad string mapping") endif -if (li_std_string.test_cvalue(x) != x) +if (li_std_string_extra.test_cvalue(x) != x) error("bad string mapping") endif -if (li_std_string.test_value(x) != x) - error("bad string mapping: %s, %s", x, li_std_string.test_value(x)) +if (li_std_string_extra.test_value(x) != x) + error("bad string mapping: %s, %s", x, li_std_string_extra.test_value(x)) endif -if (li_std_string.test_const_reference(x) != x) +if (li_std_string_extra.test_const_reference(x) != x) error("bad string mapping") endif -s = li_std_string.string("he"); +s = li_std_string_extra.string("he"); #s += "ll" #s.append('o') s = s + "llo"; @@ -34,25 +34,25 @@ if (s[1:4] != x[1:4]) error("bad string mapping") endif -if (li_std_string.test_value(s) != x) +if (li_std_string_extra.test_value(s) != x) error("bad string mapping") endif -if (li_std_string.test_const_reference(s) != x) +if (li_std_string_extra.test_const_reference(s) != x) error("bad string mapping") endif -a = li_std_string.A(s); +a = li_std_string_extra.A(s); -if (li_std_string.test_value(a) != x) +if (li_std_string_extra.test_value(a) != x) error("bad string mapping") endif -if (li_std_string.test_const_reference(a) != x) +if (li_std_string_extra.test_const_reference(a) != x) error("bad string mapping") endif -b = li_std_string.string(" world"); +b = li_std_string_extra.string(" world"); s = a + b; if (a + b != "hello world") @@ -74,48 +74,48 @@ endif s = "hello world"; -b = li_std_string.B("hi"); +b = li_std_string_extra.B("hi"); -b.name = li_std_string.string("hello"); +b.name = li_std_string_extra.string("hello"); if (b.name != "hello") error("bad string mapping") endif -b.a = li_std_string.A("hello"); +b.a = li_std_string_extra.A("hello"); if (b.a != "hello") error("bad string mapping") endif -if (li_std_string.test_value_basic1(x) != x) +if (li_std_string_extra.test_value_basic1(x) != x) error("bad string mapping") endif -if (li_std_string.test_value_basic2(x) != x) +if (li_std_string_extra.test_value_basic2(x) != x) error("bad string mapping") endif -if (li_std_string.test_value_basic3(x) != x) +if (li_std_string_extra.test_value_basic3(x) != x) error("bad string mapping") endif # Global variables s = "initial string"; -if (li_std_string.cvar.GlobalString2 != "global string 2") +if (li_std_string_extra.cvar.GlobalString2 != "global string 2") error("GlobalString2 test 1") endif -li_std_string.cvar.GlobalString2 = s; -if (li_std_string.cvar.GlobalString2 != s) +li_std_string_extra.cvar.GlobalString2 = s; +if (li_std_string_extra.cvar.GlobalString2 != s) error("GlobalString2 test 2") endif -if (li_std_string.cvar.ConstGlobalString != "const global string") +if (li_std_string_extra.cvar.ConstGlobalString != "const global string") error("ConstGlobalString test") endif # Member variables -myStructure = li_std_string.Structure(); +myStructure = li_std_string_extra.Structure(); if (myStructure.MemberString2 != "member string 2") error("MemberString2 test 1") endif @@ -127,36 +127,36 @@ if (myStructure.ConstMemberString != "const member string") error("ConstMemberString test") endif -if (li_std_string.cvar.Structure_StaticMemberString2 != "static member string 2") +if (li_std_string_extra.cvar.Structure_StaticMemberString2 != "static member string 2") error("StaticMemberString2 test 1") endif -li_std_string.cvar.Structure_StaticMemberString2 = s; -if (li_std_string.cvar.Structure_StaticMemberString2 != s) +li_std_string_extra.cvar.Structure_StaticMemberString2 = s; +if (li_std_string_extra.cvar.Structure_StaticMemberString2 != s) error("StaticMemberString2 test 2") endif -if (li_std_string.cvar.Structure_ConstStaticMemberString != "const static member string") +if (li_std_string_extra.cvar.Structure_ConstStaticMemberString != "const static member string") error("ConstStaticMemberString test") endif -if (li_std_string.test_reference_input("hello") != "hello") +if (li_std_string_extra.test_reference_input("hello") != "hello") error endif -s = li_std_string.test_reference_inout("hello"); +s = li_std_string_extra.test_reference_inout("hello"); if (s != "hellohello") error endif -if (li_std_string.stdstring_empty() != "") +if (li_std_string_extra.stdstring_empty() != "") error endif -if (li_std_string.c_empty() != "") +if (li_std_string_extra.c_empty() != "") error endif -if (li_std_string.c_null() != None) +if (li_std_string_extra.c_null() != None) error endif diff --git a/Examples/test-suite/octave/cell_deref_runme.m b/Examples/test-suite/octave/octave_cell_deref_runme.m similarity index 85% rename from Examples/test-suite/octave/cell_deref_runme.m rename to Examples/test-suite/octave/octave_cell_deref_runme.m index 1c370fe85..5a98c0a3b 100644 --- a/Examples/test-suite/octave/cell_deref_runme.m +++ b/Examples/test-suite/octave/octave_cell_deref_runme.m @@ -1,4 +1,4 @@ -cell_deref; +octave_cell_deref; assert(func("hello")); assert(func({"hello"})); diff --git a/Examples/test-suite/octave/cell_deref.i b/Examples/test-suite/octave_cell_deref.i similarity index 86% rename from Examples/test-suite/octave/cell_deref.i rename to Examples/test-suite/octave_cell_deref.i index fddcd80ec..2e92ec4de 100644 --- a/Examples/test-suite/octave/cell_deref.i +++ b/Examples/test-suite/octave_cell_deref.i @@ -1,4 +1,4 @@ -%module cell_deref +%module octave_cell_deref %inline { bool func(const char* s) { diff --git a/Examples/test-suite/php/Makefile.in b/Examples/test-suite/php/Makefile.in index 8adb294ec..9f412bc56 100644 --- a/Examples/test-suite/php/Makefile.in +++ b/Examples/test-suite/php/Makefile.in @@ -8,6 +8,9 @@ srcdir = @srcdir@ top_srcdir = @top_srcdir@ top_builddir = @top_builddir@ +#CPP_TEST_CASES += \ +# php_namewarn_rename \ + include $(srcdir)/../common.mk # Overridden variables here diff --git a/Examples/test-suite/php/namewarn_rename.i b/Examples/test-suite/php_namewarn_rename.i similarity index 81% rename from Examples/test-suite/php/namewarn_rename.i rename to Examples/test-suite/php_namewarn_rename.i index 98de311b9..87877c4f0 100644 --- a/Examples/test-suite/php/namewarn_rename.i +++ b/Examples/test-suite/php_namewarn_rename.i @@ -1,4 +1,4 @@ -%module namewarn_rename +%module php_namewarn_rename %inline %{ diff --git a/Examples/test-suite/python/Makefile.in b/Examples/test-suite/python/Makefile.in index 9026d0815..1fd2f4846 100644 --- a/Examples/test-suite/python/Makefile.in +++ b/Examples/test-suite/python/Makefile.in @@ -52,8 +52,10 @@ CPP_TEST_CASES += \ li_implicit \ li_std_vectora \ li_std_map \ + li_std_pair_extra \ li_std_set \ li_std_stream \ + li_std_string_extra \ li_std_wstream \ li_std_wstring \ nondynamic \ diff --git a/Examples/test-suite/python/implicittest.i b/Examples/test-suite/python/implicittest.i deleted file mode 100644 index 91205aafa..000000000 --- a/Examples/test-suite/python/implicittest.i +++ /dev/null @@ -1,68 +0,0 @@ -%module(naturalvar="1") implicittest - -%implicitconv; - -%inline -{ - struct B { }; -} - -%inline -{ - struct A - { - int ii; - A(int i) { ii = 1; } - A(double d) { ii = 2; } - A(const B& b) { ii = 3; } - explicit A(char *s) { ii = 4; } - - int get() const { return ii; } - - }; - - int get(const A& a) { return a.ii; } - - template - struct A_T - { - int ii; - A_T(int i) { ii = 1; } - A_T(double d) { ii = 2; } - A_T(const B& b) { ii = 3; } - explicit A_T(char *s) { ii = 4; } - - int get() const { return ii; } - - }; -} - -%inline -{ - struct Foo - { - int ii; - Foo(){ ii = 0;} - Foo(int){ ii = 1;} - Foo(double){ ii = 2;} - explicit Foo(char *s){ii = 3;} - Foo(const Foo& f){ ii = f.ii;} - - }; - - struct Bar - { - int ii; - Foo f; - Bar() {ii = -1;} - Bar(const Foo& ff){ ii = ff.ii;} - }; - - - int get_b(const Bar&b) { return b.ii; } - - Foo foo; - -} - -%template(A_int) A_T; diff --git a/Examples/test-suite/python/li_std_pair.i b/Examples/test-suite/python/li_std_pair.i deleted file mode 100644 index 886bf1a4b..000000000 --- a/Examples/test-suite/python/li_std_pair.i +++ /dev/null @@ -1,210 +0,0 @@ -%module li_std_pair - -// -// activate the automatic comparison methods generation (==,!=,...) -// - -%{ -#include // for std::swap -%} - - -%include std_pair.i -%include std_string.i -%include std_complex.i - -%inline -%{ - struct A - { - int val; - - A(int v = 0): val(v) - { - } - - }; - struct B - { - }; -%} - -%std_comp_methods(std::pair); - -namespace std { - %template(CIntPair) pair; - %template() pair; - %template(ShortPair) pair; - - %template(IntPair) pair; - %extend pair - { - %template(pair) pair; - } - - - - %template(SIPair) pair; - %template(CIPair) pair, int>; - %template(SIIPair) pair, int>; - %template(AIntPair) pair; - - %template(CCIntPair) pair >; - - %template(ABPair) pair; - %template(IntAPair) pair; - - %template(pairP1) pair; - %template(pairP2) pair; - %template(pairP3) pair; - %template(pairP4) pair; - %template(pairP5) pair; - %template(pairP6) pair; - -} -%std_comp_methods(std::pair, int>); - -%apply std::pair *INOUT {std::pair *INOUT2}; - -%inline %{ - -/* Test the "out" typemap for pair */ -std::pair makeIntPair(int a, int b) { - return std::make_pair(a, b); -} - -/** - * There is no "out" typemap for a pointer to a pair, so - * this should return a wrapped instance of a std::pair - * instead of the native "array" type for the target language. - */ -std::pair * makeIntPairPtr(int a, int b) { - static std::pair p = std::make_pair(a, b); - return &p; -} - -/** - * There is no "out" typemap for a non-const reference to a pair, so - * this should return a wrapped instance of a std::pair instead of - * the native "array" type for the target language. - */ -std::pair& makeIntPairRef(int a, int b) { - static std::pair p = std::make_pair(a, b); - return p; -} - -/** - * There is no "out" typemap for a const reference to a pair, so - * this should return a wrapped instance of a std::pair - * instead of the native "array" type for the target language. - */ -const std::pair & makeIntPairConstRef(int a, int b) { - static std::pair p = std::make_pair(a, b); - return p; -} - -/* Test the "in" typemap for pair */ -int product1(std::pair p) { - return p.first*p.second; -} - -/* Test the "in" typemap for const pair& */ -int product2(const std::pair& p) { - return p.first*p.second; -} - -std::pair - p_ident(std::pair p, const std::pair& q) { - return p; -} - - -std::pair -p_identa(const std::pair& p) { - return p; -} - -void -d_inout(double *INOUT) { - *INOUT += *INOUT; -} - -void -d_inout(int *INOUT) { - *INOUT += *INOUT; -} - -int -d_inout2(double *INOUT) { - *INOUT += *INOUT; - return 1; -} - -void -p_inout(std::pair *INOUT) { - std::swap(INOUT->first, INOUT->second); -} - -int -p_inout2(std::pair *INOUT) { - std::swap(INOUT->first, INOUT->second); - return 1; -} - -void - p_inout3(std::pair *INOUT, std::pair *INOUT2) { - std::swap(*INOUT, *INOUT2); -} - -void -p_inoutd(std::pair *INOUT) { - std::swap(INOUT->first, INOUT->second); -} - -std::string - s_ident(const std::string& s) { - return s; -} - -#if 0 -std::pair - p_ident(std::pair p, const std::pair& q) { - return p; -} - -/* Test the "in" typemap for const pair* */ -std::pair - p_ident(std::pair p, const std::pair& q) { - return q; -} - -/* Test the "in" typemap for const pair* */ -std::pair - p_ident(std::pair p, const std::pair& q) { - return p; -} - - -std::pair - p_ident(std::pair p, const std::pair& q) { - return p; -} - -std::pair - p_ident(std::pair p, const std::pair& q) { - return p; -} - - - -#endif -%} - - -namespace std -{ - %template(paircA1) pair; - %template(paircA2) pair; - %template(pairiiA) pair >; -} - diff --git a/Examples/test-suite/python/li_std_pair_extra_runme.py b/Examples/test-suite/python/li_std_pair_extra_runme.py new file mode 100644 index 000000000..dc6e31b76 --- /dev/null +++ b/Examples/test-suite/python/li_std_pair_extra_runme.py @@ -0,0 +1,59 @@ +import li_std_pair_extra + +p = (1,2) +p1 = li_std_pair_extra.p_inout(p) +p2 = li_std_pair_extra.p_inoutd(p1) + +d1 = li_std_pair_extra.d_inout(2) + +i,d2 = li_std_pair_extra.d_inout2(2) + +i,p = li_std_pair_extra.p_inout2(p) +p3,p4 = li_std_pair_extra.p_inout3(p1,p1) + +psi = li_std_pair_extra.SIPair("hello",1) +pci = li_std_pair_extra.CIPair(1,1) + + +#psi.first = "hi" + + +psi = li_std_pair_extra.SIPair("hi",1) +if psi != ("hi",1): + raise RuntimeError + +psii = li_std_pair_extra.SIIPair(psi,1) + +a = li_std_pair_extra.A() +b = li_std_pair_extra.B() + +pab = li_std_pair_extra.ABPair(a,b); + +pab.first = a +pab.first.val = 2 + +if pab.first.val != 2: + raise RuntimeError + + +pci = li_std_pair_extra.CIntPair(1,0) + +a = li_std_pair_extra.A(5) +p1 = li_std_pair_extra.pairP1(1,a.this) +p2 = li_std_pair_extra.pairP2(a,1) +p3 = li_std_pair_extra.pairP3(a,a) + + +if a.val != li_std_pair_extra.p_identa(p1.this)[1].val: + raise RuntimeError + +p = li_std_pair_extra.IntPair(1,10) +p.first = 1 + +p = li_std_pair_extra.paircA1(1,a) +p.first +p.second + +p = li_std_pair_extra.paircA2(1,a) +pp = li_std_pair_extra.pairiiA(1,p) + diff --git a/Examples/test-suite/python/li_std_pair_runme.py b/Examples/test-suite/python/li_std_pair_runme.py deleted file mode 100644 index b301f0d24..000000000 --- a/Examples/test-suite/python/li_std_pair_runme.py +++ /dev/null @@ -1,59 +0,0 @@ -import li_std_pair - -p = (1,2) -p1 = li_std_pair.p_inout(p) -p2 = li_std_pair.p_inoutd(p1) - -d1 = li_std_pair.d_inout(2) - -i,d2 = li_std_pair.d_inout2(2) - -i,p = li_std_pair.p_inout2(p) -p3,p4 = li_std_pair.p_inout3(p1,p1) - -psi = li_std_pair.SIPair("hello",1) -pci = li_std_pair.CIPair(1,1) - - -#psi.first = "hi" - - -psi = li_std_pair.SIPair("hi",1) -if psi != ("hi",1): - raise RuntimeError - -psii = li_std_pair.SIIPair(psi,1) - -a = li_std_pair.A() -b = li_std_pair.B() - -pab = li_std_pair.ABPair(a,b); - -pab.first = a -pab.first.val = 2 - -if pab.first.val != 2: - raise RuntimeError - - -pci = li_std_pair.CIntPair(1,0) - -a = li_std_pair.A(5) -p1 = li_std_pair.pairP1(1,a.this) -p2 = li_std_pair.pairP2(a,1) -p3 = li_std_pair.pairP3(a,a) - - -if a.val != li_std_pair.p_identa(p1.this)[1].val: - raise RuntimeError - -p = li_std_pair.IntPair(1,10) -p.first = 1 - -p = li_std_pair.paircA1(1,a) -p.first -p.second - -p = li_std_pair.paircA2(1,a) -pp = li_std_pair.pairiiA(1,p) - diff --git a/Examples/test-suite/python/li_std_string_runme.py b/Examples/test-suite/python/li_std_string_extra_runme.py similarity index 54% rename from Examples/test-suite/python/li_std_string_runme.py rename to Examples/test-suite/python/li_std_string_extra_runme.py index c0dae1e25..cef5921b0 100644 --- a/Examples/test-suite/python/li_std_string_runme.py +++ b/Examples/test-suite/python/li_std_string_extra_runme.py @@ -1,24 +1,24 @@ -import li_std_string +import li_std_string_extra x="hello" -if li_std_string.test_ccvalue(x) != x: +if li_std_string_extra.test_ccvalue(x) != x: raise RuntimeError, "bad string mapping" -if li_std_string.test_cvalue(x) != x: +if li_std_string_extra.test_cvalue(x) != x: raise RuntimeError, "bad string mapping" -if li_std_string.test_value(x) != x: - print x, li_std_string.test_value(x) +if li_std_string_extra.test_value(x) != x: + print x, li_std_string_extra.test_value(x) raise RuntimeError, "bad string mapping" -if li_std_string.test_const_reference(x) != x: +if li_std_string_extra.test_const_reference(x) != x: raise RuntimeError, "bad string mapping" -s = li_std_string.string("he") +s = li_std_string_extra.string("he") #s += "ll" #s.append('o') s = s + "llo" @@ -30,21 +30,21 @@ if s != x: if s[1:4] != x[1:4]: raise RuntimeError, "bad string mapping" -if li_std_string.test_value(s) != x: +if li_std_string_extra.test_value(s) != x: raise RuntimeError, "bad string mapping" -if li_std_string.test_const_reference(s) != x: +if li_std_string_extra.test_const_reference(s) != x: raise RuntimeError, "bad string mapping" -a = li_std_string.A(s) +a = li_std_string_extra.A(s) -if li_std_string.test_value(a) != x: +if li_std_string_extra.test_value(a) != x: raise RuntimeError, "bad string mapping" -if li_std_string.test_const_reference(a) != x: +if li_std_string_extra.test_const_reference(a) != x: raise RuntimeError, "bad string mapping" -b = li_std_string.string(" world") +b = li_std_string_extra.string(" world") s = a + b if a + b != "hello world": @@ -63,40 +63,40 @@ if c.find_last_of("l") != 9: s = "hello world" -b = li_std_string.B("hi") +b = li_std_string_extra.B("hi") -b.name = li_std_string.string("hello") +b.name = li_std_string_extra.string("hello") if b.name != "hello": raise RuntimeError, "bad string mapping" -b.a = li_std_string.A("hello") +b.a = li_std_string_extra.A("hello") if b.a != "hello": raise RuntimeError, "bad string mapping" -if li_std_string.test_value_basic1(x) != x: +if li_std_string_extra.test_value_basic1(x) != x: raise RuntimeError, "bad string mapping" -if li_std_string.test_value_basic2(x) != x: +if li_std_string_extra.test_value_basic2(x) != x: raise RuntimeError, "bad string mapping" -if li_std_string.test_value_basic3(x) != x: +if li_std_string_extra.test_value_basic3(x) != x: raise RuntimeError, "bad string mapping" # Global variables s = "initial string" -if li_std_string.cvar.GlobalString2 != "global string 2": +if li_std_string_extra.cvar.GlobalString2 != "global string 2": raise RuntimeError, "GlobalString2 test 1" -li_std_string.cvar.GlobalString2 = s -if li_std_string.cvar.GlobalString2 != s: +li_std_string_extra.cvar.GlobalString2 = s +if li_std_string_extra.cvar.GlobalString2 != s: raise RuntimeError, "GlobalString2 test 2" -if li_std_string.cvar.ConstGlobalString != "const global string": +if li_std_string_extra.cvar.ConstGlobalString != "const global string": raise RuntimeError, "ConstGlobalString test" # Member variables -myStructure = li_std_string.Structure() +myStructure = li_std_string_extra.Structure() if myStructure.MemberString2 != "member string 2": raise RuntimeError, "MemberString2 test 1" myStructure.MemberString2 = s @@ -105,28 +105,28 @@ if myStructure.MemberString2 != s: if myStructure.ConstMemberString != "const member string": raise RuntimeError, "ConstMemberString test" -if li_std_string.cvar.Structure_StaticMemberString2 != "static member string 2": +if li_std_string_extra.cvar.Structure_StaticMemberString2 != "static member string 2": raise RuntimeError, "StaticMemberString2 test 1" -li_std_string.cvar.Structure_StaticMemberString2 = s -if li_std_string.cvar.Structure_StaticMemberString2 != s: +li_std_string_extra.cvar.Structure_StaticMemberString2 = s +if li_std_string_extra.cvar.Structure_StaticMemberString2 != s: raise RuntimeError, "StaticMemberString2 test 2" -if li_std_string.cvar.Structure_ConstStaticMemberString != "const static member string": +if li_std_string_extra.cvar.Structure_ConstStaticMemberString != "const static member string": raise RuntimeError, "ConstStaticMemberString test" -if li_std_string.test_reference_input("hello") != "hello": +if li_std_string_extra.test_reference_input("hello") != "hello": raise RuntimeError -s = li_std_string.test_reference_inout("hello") +s = li_std_string_extra.test_reference_inout("hello") if s != "hellohello": raise RuntimeError -if li_std_string.stdstring_empty() != "": +if li_std_string_extra.stdstring_empty() != "": raise RuntimeError -if li_std_string.c_empty() != "": +if li_std_string_extra.c_empty() != "": raise RuntimeError -if li_std_string.c_null() != None: +if li_std_string_extra.c_null() != None: raise RuntimeError diff --git a/Examples/test-suite/r/Makefile.in b/Examples/test-suite/r/Makefile.in index 70dd62ec5..98d1f9571 100644 --- a/Examples/test-suite/r/Makefile.in +++ b/Examples/test-suite/r/Makefile.in @@ -10,8 +10,8 @@ srcdir = @srcdir@ top_srcdir = @top_srcdir@ top_builddir = @top_builddir@ -C_TEST_CASES = copy_struct simple_array legacy -CPP_TEST_CASES = double_delete +C_TEST_CASES = r_copy_struct r_legacy +CPP_TEST_CASES = r_double_delete include $(srcdir)/../common.mk diff --git a/Examples/test-suite/r/double_delete_runme.R b/Examples/test-suite/r/double_delete_runme.R deleted file mode 100644 index 8ac6b4344..000000000 --- a/Examples/test-suite/r/double_delete_runme.R +++ /dev/null @@ -1,12 +0,0 @@ -# This file illustrates the proxy class C++ interface generated -# by SWIG. - -dyn.load(paste("double_delete", .Platform$dynlib.ext, sep="")) -source("double_delete.R") -cacheMetaData(1) - -# ----- Object creation ----- - -f <- Foo(2.0) -delete(f); -delete(f); diff --git a/Examples/test-suite/r/copy_struct_runme.R b/Examples/test-suite/r/r_copy_struct_runme.R similarity index 89% rename from Examples/test-suite/r/copy_struct_runme.R rename to Examples/test-suite/r/r_copy_struct_runme.R index 523f1d680..ebf704004 100644 --- a/Examples/test-suite/r/copy_struct_runme.R +++ b/Examples/test-suite/r/r_copy_struct_runme.R @@ -1,6 +1,6 @@ source("unittest.R") -dyn.load(paste("copy_struct", .Platform$dynlib.ext, sep="")) -source("copy_struct.R") +dyn.load(paste("r_copy_struct", .Platform$dynlib.ext, sep="")) +source("r_copy_struct.R") cacheMetaData(1) a <- getA() diff --git a/Examples/test-suite/r/r_double_delete_runme.R b/Examples/test-suite/r/r_double_delete_runme.R new file mode 100644 index 000000000..7b6fdb77f --- /dev/null +++ b/Examples/test-suite/r/r_double_delete_runme.R @@ -0,0 +1,9 @@ +dyn.load(paste("r_double_delete", .Platform$dynlib.ext, sep="")) +source("r_double_delete.R") +cacheMetaData(1) + +# ----- Object creation ----- + +f <- Foo(2.0) +delete(f); +delete(f); diff --git a/Examples/test-suite/r/legacy_runme.R b/Examples/test-suite/r/r_legacy_runme.R similarity index 86% rename from Examples/test-suite/r/legacy_runme.R rename to Examples/test-suite/r/r_legacy_runme.R index a1466e4ce..7e5ade87f 100644 --- a/Examples/test-suite/r/legacy_runme.R +++ b/Examples/test-suite/r/r_legacy_runme.R @@ -1,6 +1,6 @@ source("unittest.R") -dyn.load(paste("legacy", .Platform$dynlib.ext, sep="")) -source("legacy.R") +dyn.load(paste("r_legacy", .Platform$dynlib.ext, sep="")) +source("r_legacy.R") cacheMetaData(1) obj <- getObject(1,3) diff --git a/Examples/test-suite/r/copy_struct.i b/Examples/test-suite/r_copy_struct.i similarity index 97% rename from Examples/test-suite/r/copy_struct.i rename to Examples/test-suite/r_copy_struct.i index db6223303..fda321afb 100644 --- a/Examples/test-suite/r/copy_struct.i +++ b/Examples/test-suite/r_copy_struct.i @@ -1,4 +1,4 @@ -%module copy_struct +%module r_copy_struct %feature("opaque", "yes") B; %feature("opaque", "yes") C; diff --git a/Examples/test-suite/r/double_delete.i b/Examples/test-suite/r_double_delete.i similarity index 67% rename from Examples/test-suite/r/double_delete.i rename to Examples/test-suite/r_double_delete.i index 4f2d1e0a2..9743d0454 100644 --- a/Examples/test-suite/r/double_delete.i +++ b/Examples/test-suite/r_double_delete.i @@ -1,5 +1,4 @@ -/* File : example.i */ -%module double_delete +%module r_double_delete %inline %{ diff --git a/Examples/test-suite/r/legacy.i b/Examples/test-suite/r_legacy.i similarity index 98% rename from Examples/test-suite/r/legacy.i rename to Examples/test-suite/r_legacy.i index 4e2080262..c89263082 100644 --- a/Examples/test-suite/r/legacy.i +++ b/Examples/test-suite/r_legacy.i @@ -1,4 +1,4 @@ -%module legacy +%module r_legacy %inline %{ typedef char *String; diff --git a/Examples/test-suite/ruby/Makefile.in b/Examples/test-suite/ruby/Makefile.in index 7339373fb..33395c006 100644 --- a/Examples/test-suite/ruby/Makefile.in +++ b/Examples/test-suite/ruby/Makefile.in @@ -10,7 +10,6 @@ top_srcdir = @top_srcdir@ top_builddir = @top_builddir@ CPP_TEST_CASES = \ - keywords \ li_cdata \ li_cstring \ li_factory \ @@ -20,11 +19,14 @@ CPP_TEST_CASES = \ li_std_queue \ li_std_set \ li_std_stack \ - naming \ primitive_types \ - std_containers \ - track_objects \ - track_objects_directors + ruby_keywords \ + ruby_naming \ + ruby_track_objects \ + ruby_track_objects_directors \ + std_containers +# ruby_li_std_speed +# stl_new C_TEST_CASES += \ li_cdata \ @@ -39,7 +41,7 @@ SWIGOPT += -w801 -noautorename -features autodoc=4 # Rules for the different types of tests # make sure -autorename is true for the naming test -naming.cpptest: SWIGOPT = -autorename +ruby_naming.cpptest: SWIGOPT += -autorename %.cpptest: $(setup) diff --git a/Examples/test-suite/ruby/keywords_runme.rb b/Examples/test-suite/ruby/ruby_keywords_runme.rb similarity index 98% rename from Examples/test-suite/ruby/keywords_runme.rb rename to Examples/test-suite/ruby/ruby_keywords_runme.rb index cb8bd38bf..9b06ecf1d 100644 --- a/Examples/test-suite/ruby/keywords_runme.rb +++ b/Examples/test-suite/ruby/ruby_keywords_runme.rb @@ -9,9 +9,9 @@ require 'swig_assert' -require 'keywords' +require 'ruby_keywords' -kw = Keywords::Keywords.new +kw = Ruby_keywords::Keywords.new if kw.alias != 'alias' then raise RuntimeError, 'Keyword method did not work: alias' diff --git a/Examples/test-suite/ruby/li_std_speed_runme.rb b/Examples/test-suite/ruby/ruby_li_std_speed_runme.rb similarity index 97% rename from Examples/test-suite/ruby/li_std_speed_runme.rb rename to Examples/test-suite/ruby/ruby_li_std_speed_runme.rb index a67e618a3..825f3c593 100755 --- a/Examples/test-suite/ruby/li_std_speed_runme.rb +++ b/Examples/test-suite/ruby/ruby_li_std_speed_runme.rb @@ -10,8 +10,8 @@ require 'benchmark' require 'mathn' -require 'li_std_speed' -include Li_std_speed +require 'ruby_li_std_speed' +include Ruby_li_std_speed def benchmark(f, phigh, sequences) diff --git a/Examples/test-suite/ruby/naming_runme.rb b/Examples/test-suite/ruby/ruby_naming_runme.rb similarity index 68% rename from Examples/test-suite/ruby/naming_runme.rb rename to Examples/test-suite/ruby/ruby_naming_runme.rb index dab3a50b6..8ea5f13d3 100644 --- a/Examples/test-suite/ruby/naming_runme.rb +++ b/Examples/test-suite/ruby/ruby_naming_runme.rb @@ -9,86 +9,86 @@ require 'swig_assert' -require 'naming' +require 'ruby_naming' # Check class names -if not Naming - raise RuntimeError, 'Invalid module name for Naming' +if not Ruby_naming + raise RuntimeError, 'Invalid module name for Ruby_naming' end -if not Naming::MyClass +if not Ruby_naming::MyClass raise RuntimeError, 'Invalid class name for MyClass' end # Check constant names / values -if Naming::CONSTANT1 != 1 +if Ruby_naming::CONSTANT1 != 1 raise RuntimeError, "Incorrect value for CONSTANT1" end -if Naming::CONSTANT2 != 2 +if Ruby_naming::CONSTANT2 != 2 raise RuntimeError, "Incorrect value for CONSTANT2" end # Check constant names / values -if Naming::CONSTANT3 != 3 +if Ruby_naming::CONSTANT3 != 3 raise RuntimeError, "Incorrect value for CONSTANT3" end -if not Naming::methods.include?("constant4") +if not Ruby_naming::methods.include?("constant4") raise RuntimeError, "Incorrect mapping for constant4" end -if not Naming::methods.include?("constant5") +if not Ruby_naming::methods.include?("constant5") raise RuntimeError, "Incorrect mapping for constant5" end -if not Naming::methods.include?("constant6") +if not Ruby_naming::methods.include?("constant6") raise RuntimeError, "Incorrect mapping for constant6" end -if not Naming::TestConstants.instance_methods.include?("constant7") +if not Ruby_naming::TestConstants.instance_methods.include?("constant7") raise RuntimeError, "Incorrect mapping for constant7" end -if not Naming::TestConstants.methods.include?("constant8") +if not Ruby_naming::TestConstants.methods.include?("constant8") raise RuntimeError, "Incorrect mapping for constant8" end # There is no constant9 because it is illegal C++ -#if not Naming::TestConstants.instance_methods.include?("constant9") +#if not Ruby_naming::TestConstants.instance_methods.include?("constant9") # raise RuntimeError, "Incorrect mapping for constant9" #end -if Naming::TestConstants::CONSTANT10 != 10 +if Ruby_naming::TestConstants::CONSTANT10 != 10 raise RuntimeError, "Incorrect value for CONSTANT10" end -if not Naming::methods.include?("constant11") +if not Ruby_naming::methods.include?("constant11") raise RuntimeError, "Incorrect mapping for constant11" end # Check enums -if Naming::constants.include?("Color") +if Ruby_naming::constants.include?("Color") raise RuntimeError, "Color enum should not be exposed to Ruby" end -if Naming::Red != 0 +if Ruby_naming::Red != 0 raise RuntimeError, "Incorrect value for enum RED" end -if Naming::Green != 1 +if Ruby_naming::Green != 1 raise RuntimeError, "Incorrect value for enum GREEN" end -if Naming::Blue != 2 +if Ruby_naming::Blue != 2 raise RuntimeError, "Incorrect value for enum BLUE" end # Check method names -my_class = Naming::MyClass.new() +my_class = Ruby_naming::MyClass.new() if my_class.method_one != 1 raise RuntimeError, "Incorrect value for method_one" diff --git a/Examples/test-suite/ruby/track_objects_directors_runme.rb b/Examples/test-suite/ruby/ruby_track_objects_directors_runme.rb similarity index 74% rename from Examples/test-suite/ruby/track_objects_directors_runme.rb rename to Examples/test-suite/ruby/ruby_track_objects_directors_runme.rb index 247d3e98b..fb55323a8 100644 --- a/Examples/test-suite/ruby/track_objects_directors_runme.rb +++ b/Examples/test-suite/ruby/ruby_track_objects_directors_runme.rb @@ -9,9 +9,9 @@ require 'swig_assert' -require 'track_objects_directors' +require 'ruby_track_objects_directors' -class MyFoo < Track_objects_directors::Foo +class MyFoo < Ruby_track_objects_directors::Foo def ping "MyFoo::ping()" end @@ -22,12 +22,12 @@ a = MyFoo.new raise RuntimeError if a.ping != "MyFoo::ping()" raise RuntimeError if a.pong != "Foo::pong();MyFoo::ping()" -b = Track_objects_directors::Foo.new +b = Ruby_track_objects_directors::Foo.new raise RuntimeError if b.ping != "Foo::ping()" raise RuntimeError if b.pong != "Foo::pong();Foo::ping()" -container = Track_objects_directors::Container.new +container = Ruby_track_objects_directors::Container.new foo = MyFoo.new container.set_foo(foo) diff --git a/Examples/test-suite/ruby/track_objects_runme.rb b/Examples/test-suite/ruby/ruby_track_objects_runme.rb similarity index 78% rename from Examples/test-suite/ruby/track_objects_runme.rb rename to Examples/test-suite/ruby/ruby_track_objects_runme.rb index 27d8f6da7..7bc67a478 100644 --- a/Examples/test-suite/ruby/track_objects_runme.rb +++ b/Examples/test-suite/ruby/ruby_track_objects_runme.rb @@ -9,7 +9,7 @@ require 'swig_assert' -require 'track_objects' +require 'ruby_track_objects' def test_same_ruby_object(foo1, foo2) if not foo1.equal?(foo2) @@ -23,12 +23,12 @@ def test_same_cpp_object(foo1, foo2) end end -bar = Track_objects::Bar.new -foo1 = Track_objects::Foo.new() +bar = Ruby_track_objects::Bar.new +foo1 = Ruby_track_objects::Foo.new() bar.set_unowned_foo(foo1) # test_simple_identity -foo2 = Track_objects::Foo.new() +foo2 = Ruby_track_objects::Foo.new() foo3 = foo2 test_same_ruby_object(foo2, foo3) @@ -48,8 +48,8 @@ test_same_ruby_object(foo5, foo6) test_same_cpp_object(foo5, foo6) # test_new_foo_identity -foo7 = Track_objects::Bar.get_new_foo() -foo8 = Track_objects::Bar.get_new_foo() +foo7 = Ruby_track_objects::Bar.get_new_foo() +foo8 = Ruby_track_objects::Bar.get_new_foo() if foo7.equal?(foo8) raise "Ruby objects should be different." @@ -60,7 +60,7 @@ if foo7.cpp_equal(foo8) end # test_set_owned_identity -foo9 = Track_objects::Foo.new +foo9 = Ruby_track_objects::Foo.new bar.set_owned_foo(foo9) foo10 = bar.get_owned_foo() @@ -69,7 +69,7 @@ test_same_cpp_object(foo9, foo10) # test_set_owned_identity2 begin - foo11 = Track_objects::Foo.new + foo11 = Ruby_track_objects::Foo.new bar.set_owned_foo(foo11) foo11 = nil end @@ -90,20 +90,20 @@ test_same_ruby_object(foo13, foo14) test_same_cpp_object(foo13, foo14) # Now create the factory -factory = Track_objects::Factory.new +factory = Ruby_track_objects::Factory.new # Create itemA which is really an itemB itemA = factory.createItem # Check class -if itemA.class != Track_objects::ItemA +if itemA.class != Ruby_track_objects::ItemA raise RuntimeError, 'Item should have an ItemA class' end # Now downcast -itemB = Track_objects.downcast(itemA) +itemB = Ruby_track_objects.downcast(itemA) -if itemB.class != Track_objects::ItemB +if itemB.class != Ruby_track_objects::ItemB raise RuntimeError, 'Item should have an ItemB class' end diff --git a/Examples/test-suite/ruby/keywords.i b/Examples/test-suite/ruby_keywords.i similarity index 98% rename from Examples/test-suite/ruby/keywords.i rename to Examples/test-suite/ruby_keywords.i index eb91b4ffa..c87efab33 100644 --- a/Examples/test-suite/ruby/keywords.i +++ b/Examples/test-suite/ruby_keywords.i @@ -1,4 +1,4 @@ -%module keywords +%module ruby_keywords // fix up conflicts with C++ keywords %rename("and") Keywords::and_; diff --git a/Examples/test-suite/ruby/li_std_speed.i b/Examples/test-suite/ruby_li_std_speed.i similarity index 90% rename from Examples/test-suite/ruby/li_std_speed.i rename to Examples/test-suite/ruby_li_std_speed.i index 0dad81690..3c8e60643 100644 --- a/Examples/test-suite/ruby/li_std_speed.i +++ b/Examples/test-suite/ruby_li_std_speed.i @@ -1,5 +1,5 @@ /** - * @file li_std_speed.i + * @file ruby_li_std_speed.i * @author gga * @date Fri May 18 18:03:15 2007 * @@ -8,7 +8,7 @@ * */ -%module li_std_speed +%module ruby_li_std_speed %include %include diff --git a/Examples/test-suite/ruby/naming.i b/Examples/test-suite/ruby_naming.i similarity index 98% rename from Examples/test-suite/ruby/naming.i rename to Examples/test-suite/ruby_naming.i index 75500ae34..d8ef50ad3 100644 --- a/Examples/test-suite/ruby/naming.i +++ b/Examples/test-suite/ruby_naming.i @@ -1,4 +1,4 @@ -%module naming +%module ruby_naming %predicate predicateMethod(); %bang bangMethod(); diff --git a/Examples/test-suite/ruby/track_objects.i b/Examples/test-suite/ruby_track_objects.i similarity index 98% rename from Examples/test-suite/ruby/track_objects.i rename to Examples/test-suite/ruby_track_objects.i index 0a50e1fad..f4bbb37e7 100644 --- a/Examples/test-suite/ruby/track_objects.i +++ b/Examples/test-suite/ruby_track_objects.i @@ -1,4 +1,4 @@ -%module track_objects +%module ruby_track_objects %include typemaps.i diff --git a/Examples/test-suite/ruby/track_objects_directors.i b/Examples/test-suite/ruby_track_objects_directors.i similarity index 88% rename from Examples/test-suite/ruby/track_objects_directors.i rename to Examples/test-suite/ruby_track_objects_directors.i index adac8ae4d..131209828 100644 --- a/Examples/test-suite/ruby/track_objects_directors.i +++ b/Examples/test-suite/ruby_track_objects_directors.i @@ -1,4 +1,4 @@ -%module(directors="1") track_objects_directors +%module(directors="1") ruby_track_objects_directors %{ #include diff --git a/Examples/test-suite/r/simple_array.i b/Examples/test-suite/simple_array.i similarity index 100% rename from Examples/test-suite/r/simple_array.i rename to Examples/test-suite/simple_array.i diff --git a/Examples/test-suite/ruby/stl_new.i b/Examples/test-suite/stl_new.i similarity index 100% rename from Examples/test-suite/ruby/stl_new.i rename to Examples/test-suite/stl_new.i diff --git a/Examples/test-suite/tcl/Makefile.in b/Examples/test-suite/tcl/Makefile.in index e26d77582..7c4b7ed61 100644 --- a/Examples/test-suite/tcl/Makefile.in +++ b/Examples/test-suite/tcl/Makefile.in @@ -11,15 +11,12 @@ top_builddir = @top_builddir@ CPP_TEST_CASES += \ primitive_types \ - li_cdata \ li_cstring \ li_cwstring C_TEST_CASES += \ - li_cdata \ li_cstring \ - li_cwstring \ - union + li_cwstring include $(srcdir)/../common.mk diff --git a/Examples/test-suite/tcl/union_runme.tcl b/Examples/test-suite/tcl/union_runme.tcl old mode 100755 new mode 100644 diff --git a/Examples/test-suite/tcl/union.i b/Examples/test-suite/union.i similarity index 100% rename from Examples/test-suite/tcl/union.i rename to Examples/test-suite/union.i From 8cd10cfe2ad333814ae1caa269b3277d1dbcd9ea Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 26 Nov 2008 21:44:53 +0000 Subject: [PATCH 0194/1680] warning fix for when zlib not available git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10950 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CCache/ccache.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CCache/ccache.c b/CCache/ccache.c index 2dec72254..9b12d3bf7 100644 --- a/CCache/ccache.c +++ b/CCache/ccache.c @@ -176,6 +176,9 @@ static void to_cache_stats_helper(struct stat *pstat, char *cached_filename, cha } failed(); } +#else + (void)cached_filename; + (void)tmp_outfiles; #endif (*files_size) += file_size(pstat); (*cached_files_count)++; From e7f8954bea08ecb9852e917193dfaa642258febb Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 26 Nov 2008 21:54:49 +0000 Subject: [PATCH 0195/1680] remove svn:executable property where applied incorrectly git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10951 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Allegrocl.html | 0 Doc/Manual/swig16.png | Bin Examples/guile/matrix/matrix.scm | 0 Examples/pike/class/Makefile | 0 Examples/pike/class/example.cxx | 0 Examples/pike/class/example.i | 0 Examples/pike/constants/Makefile | 0 Examples/pike/constants/example.i | 0 Examples/pike/overload/example.cxx | 0 Examples/pike/overload/example.h | 0 Examples/ruby/hashargs/Makefile | 0 Examples/ruby/hashargs/example.i | 0 Examples/test-suite/director_classic.i | 0 Examples/test-suite/director_ignore.i | 0 Examples/test-suite/java/allprotected_runme.java | 0 .../test-suite/java/director_classic_runme.java | 0 Examples/test-suite/java/director_ignore_runme.java | 0 .../test-suite/java/overload_complicated_runme.java | 0 Lib/allegrocl/inout_typemaps.i | 0 Lib/allegrocl/longlongs.i | 0 Lib/allegrocl/std_list.i | 0 Lib/allegrocl/std_string.i | 0 Lib/csharp/std_vector.i | 0 Lib/csharp/std_wstring.i | 0 Lib/csharp/wchar.i | 0 Source/Modules/ocaml.cxx | 0 26 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 Doc/Manual/Allegrocl.html mode change 100755 => 100644 Doc/Manual/swig16.png mode change 100755 => 100644 Examples/guile/matrix/matrix.scm mode change 100755 => 100644 Examples/pike/class/Makefile mode change 100755 => 100644 Examples/pike/class/example.cxx mode change 100755 => 100644 Examples/pike/class/example.i mode change 100755 => 100644 Examples/pike/constants/Makefile mode change 100755 => 100644 Examples/pike/constants/example.i mode change 100755 => 100644 Examples/pike/overload/example.cxx mode change 100755 => 100644 Examples/pike/overload/example.h mode change 100755 => 100644 Examples/ruby/hashargs/Makefile mode change 100755 => 100644 Examples/ruby/hashargs/example.i mode change 100755 => 100644 Examples/test-suite/director_classic.i mode change 100755 => 100644 Examples/test-suite/director_ignore.i mode change 100755 => 100644 Examples/test-suite/java/allprotected_runme.java mode change 100755 => 100644 Examples/test-suite/java/director_classic_runme.java mode change 100755 => 100644 Examples/test-suite/java/director_ignore_runme.java mode change 100755 => 100644 Examples/test-suite/java/overload_complicated_runme.java mode change 100755 => 100644 Lib/allegrocl/inout_typemaps.i mode change 100755 => 100644 Lib/allegrocl/longlongs.i mode change 100755 => 100644 Lib/allegrocl/std_list.i mode change 100755 => 100644 Lib/allegrocl/std_string.i mode change 100755 => 100644 Lib/csharp/std_vector.i mode change 100755 => 100644 Lib/csharp/std_wstring.i mode change 100755 => 100644 Lib/csharp/wchar.i mode change 100755 => 100644 Source/Modules/ocaml.cxx diff --git a/Doc/Manual/Allegrocl.html b/Doc/Manual/Allegrocl.html old mode 100755 new mode 100644 diff --git a/Doc/Manual/swig16.png b/Doc/Manual/swig16.png old mode 100755 new mode 100644 diff --git a/Examples/guile/matrix/matrix.scm b/Examples/guile/matrix/matrix.scm old mode 100755 new mode 100644 diff --git a/Examples/pike/class/Makefile b/Examples/pike/class/Makefile old mode 100755 new mode 100644 diff --git a/Examples/pike/class/example.cxx b/Examples/pike/class/example.cxx old mode 100755 new mode 100644 diff --git a/Examples/pike/class/example.i b/Examples/pike/class/example.i old mode 100755 new mode 100644 diff --git a/Examples/pike/constants/Makefile b/Examples/pike/constants/Makefile old mode 100755 new mode 100644 diff --git a/Examples/pike/constants/example.i b/Examples/pike/constants/example.i old mode 100755 new mode 100644 diff --git a/Examples/pike/overload/example.cxx b/Examples/pike/overload/example.cxx old mode 100755 new mode 100644 diff --git a/Examples/pike/overload/example.h b/Examples/pike/overload/example.h old mode 100755 new mode 100644 diff --git a/Examples/ruby/hashargs/Makefile b/Examples/ruby/hashargs/Makefile old mode 100755 new mode 100644 diff --git a/Examples/ruby/hashargs/example.i b/Examples/ruby/hashargs/example.i old mode 100755 new mode 100644 diff --git a/Examples/test-suite/director_classic.i b/Examples/test-suite/director_classic.i old mode 100755 new mode 100644 diff --git a/Examples/test-suite/director_ignore.i b/Examples/test-suite/director_ignore.i old mode 100755 new mode 100644 diff --git a/Examples/test-suite/java/allprotected_runme.java b/Examples/test-suite/java/allprotected_runme.java old mode 100755 new mode 100644 diff --git a/Examples/test-suite/java/director_classic_runme.java b/Examples/test-suite/java/director_classic_runme.java old mode 100755 new mode 100644 diff --git a/Examples/test-suite/java/director_ignore_runme.java b/Examples/test-suite/java/director_ignore_runme.java old mode 100755 new mode 100644 diff --git a/Examples/test-suite/java/overload_complicated_runme.java b/Examples/test-suite/java/overload_complicated_runme.java old mode 100755 new mode 100644 diff --git a/Lib/allegrocl/inout_typemaps.i b/Lib/allegrocl/inout_typemaps.i old mode 100755 new mode 100644 diff --git a/Lib/allegrocl/longlongs.i b/Lib/allegrocl/longlongs.i old mode 100755 new mode 100644 diff --git a/Lib/allegrocl/std_list.i b/Lib/allegrocl/std_list.i old mode 100755 new mode 100644 diff --git a/Lib/allegrocl/std_string.i b/Lib/allegrocl/std_string.i old mode 100755 new mode 100644 diff --git a/Lib/csharp/std_vector.i b/Lib/csharp/std_vector.i old mode 100755 new mode 100644 diff --git a/Lib/csharp/std_wstring.i b/Lib/csharp/std_wstring.i old mode 100755 new mode 100644 diff --git a/Lib/csharp/wchar.i b/Lib/csharp/wchar.i old mode 100755 new mode 100644 diff --git a/Source/Modules/ocaml.cxx b/Source/Modules/ocaml.cxx old mode 100755 new mode 100644 From c3047165d60c0a562963ee1aadd1cc4c9f8a40e1 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 26 Nov 2008 21:56:48 +0000 Subject: [PATCH 0196/1680] remove svn:executable property where applied incorrectly git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10952 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/pike/class/example.h | 0 Examples/pike/template/Makefile | 0 Examples/pike/template/example.h | 0 Examples/pike/template/example.i | 0 4 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 Examples/pike/class/example.h mode change 100755 => 100644 Examples/pike/template/Makefile mode change 100755 => 100644 Examples/pike/template/example.h mode change 100755 => 100644 Examples/pike/template/example.i diff --git a/Examples/pike/class/example.h b/Examples/pike/class/example.h old mode 100755 new mode 100644 diff --git a/Examples/pike/template/Makefile b/Examples/pike/template/Makefile old mode 100755 new mode 100644 diff --git a/Examples/pike/template/example.h b/Examples/pike/template/example.h old mode 100755 new mode 100644 diff --git a/Examples/pike/template/example.i b/Examples/pike/template/example.i old mode 100755 new mode 100644 From b266e1f68cedf1601e386ecedca3cce324803661 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 26 Nov 2008 22:50:35 +0000 Subject: [PATCH 0197/1680] modifying build system not to rely on the -I path to find the input files avoiding warning 125: move python .i files up one directory, some files have been renamed - prepended with python git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10953 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- .../test-suite/{python => }/argcargvtest.i | 0 Examples/test-suite/{python => }/callback.i | 0 .../test-suite/{python => }/complextest.i | 0 .../{python => }/director_profile.i | 0 .../test-suite/{python => }/director_stl.i | 0 Examples/test-suite/{python => }/iadd.i | 0 Examples/test-suite/{python => }/inout.i | 0 Examples/test-suite/{python => }/inplaceadd.i | 0 Examples/test-suite/{python => }/input.i | 0 .../test-suite/{python => }/li_std_carray.i | 0 .../test-suite/{python => }/li_std_vectora.i | 0 .../test-suite/{python => }/li_std_wstream.i | 0 Examples/test-suite/python/Makefile.in | 5 +- ...unme3.py => python_abstractbase_runme3.py} | 2 +- ...kwargs_runme.py => python_kwargs_runme.py} | 2 +- ...ic_runme.py => python_nondynamic_runme.py} | 10 ++-- ...y => python_overload_simple_cast_runme.py} | 2 +- ...pybuf_runme3.py => python_pybuf_runme3.py} | 4 +- .../python/tag_no_clash_with_variable_runme.i | 3 -- Examples/test-suite/python/vector.i | 51 ------------------- .../abstractbase.i => python_abstractbase.i} | 2 +- .../{python/autodoc.i => python_autodoc.i} | 2 +- .../{python/kwargs.i => python_kwargs.i} | 2 +- .../nondynamic.i => python_nondynamic.i} | 2 +- ...e_cast.i => python_overload_simple_cast.i} | 2 +- .../{python/pybuf.i => python_pybuf.i} | 2 +- Examples/test-suite/{python => }/simutry.i | 0 Examples/test-suite/{python => }/swigobject.i | 0 .../test-suite/{python => }/template_matrix.i | 0 29 files changed, 19 insertions(+), 72 deletions(-) rename Examples/test-suite/{python => }/argcargvtest.i (100%) rename Examples/test-suite/{python => }/callback.i (100%) rename Examples/test-suite/{python => }/complextest.i (100%) rename Examples/test-suite/{python => }/director_profile.i (100%) rename Examples/test-suite/{python => }/director_stl.i (100%) rename Examples/test-suite/{python => }/iadd.i (100%) rename Examples/test-suite/{python => }/inout.i (100%) rename Examples/test-suite/{python => }/inplaceadd.i (100%) rename Examples/test-suite/{python => }/input.i (100%) rename Examples/test-suite/{python => }/li_std_carray.i (100%) rename Examples/test-suite/{python => }/li_std_vectora.i (100%) rename Examples/test-suite/{python => }/li_std_wstream.i (100%) rename Examples/test-suite/python/{abstractbase_runme3.py => python_abstractbase_runme3.py} (89%) rename Examples/test-suite/python/{kwargs_runme.py => python_kwargs_runme.py} (97%) rename Examples/test-suite/python/{nondynamic_runme.py => python_nondynamic_runme.py} (67%) rename Examples/test-suite/python/{overload_simple_cast_runme.py => python_overload_simple_cast_runme.py} (98%) rename Examples/test-suite/python/{pybuf_runme3.py => python_pybuf_runme3.py} (93%) delete mode 100644 Examples/test-suite/python/tag_no_clash_with_variable_runme.i delete mode 100644 Examples/test-suite/python/vector.i rename Examples/test-suite/{python/abstractbase.i => python_abstractbase.i} (93%) rename Examples/test-suite/{python/autodoc.i => python_autodoc.i} (97%) rename Examples/test-suite/{python/kwargs.i => python_kwargs.i} (98%) rename Examples/test-suite/{python/nondynamic.i => python_nondynamic.i} (96%) rename Examples/test-suite/{python/overload_simple_cast.i => python_overload_simple_cast.i} (58%) rename Examples/test-suite/{python/pybuf.i => python_pybuf.i} (98%) rename Examples/test-suite/{python => }/simutry.i (100%) rename Examples/test-suite/{python => }/swigobject.i (100%) rename Examples/test-suite/{python => }/template_matrix.i (100%) diff --git a/Examples/test-suite/python/argcargvtest.i b/Examples/test-suite/argcargvtest.i similarity index 100% rename from Examples/test-suite/python/argcargvtest.i rename to Examples/test-suite/argcargvtest.i diff --git a/Examples/test-suite/python/callback.i b/Examples/test-suite/callback.i similarity index 100% rename from Examples/test-suite/python/callback.i rename to Examples/test-suite/callback.i diff --git a/Examples/test-suite/python/complextest.i b/Examples/test-suite/complextest.i similarity index 100% rename from Examples/test-suite/python/complextest.i rename to Examples/test-suite/complextest.i diff --git a/Examples/test-suite/python/director_profile.i b/Examples/test-suite/director_profile.i similarity index 100% rename from Examples/test-suite/python/director_profile.i rename to Examples/test-suite/director_profile.i diff --git a/Examples/test-suite/python/director_stl.i b/Examples/test-suite/director_stl.i similarity index 100% rename from Examples/test-suite/python/director_stl.i rename to Examples/test-suite/director_stl.i diff --git a/Examples/test-suite/python/iadd.i b/Examples/test-suite/iadd.i similarity index 100% rename from Examples/test-suite/python/iadd.i rename to Examples/test-suite/iadd.i diff --git a/Examples/test-suite/python/inout.i b/Examples/test-suite/inout.i similarity index 100% rename from Examples/test-suite/python/inout.i rename to Examples/test-suite/inout.i diff --git a/Examples/test-suite/python/inplaceadd.i b/Examples/test-suite/inplaceadd.i similarity index 100% rename from Examples/test-suite/python/inplaceadd.i rename to Examples/test-suite/inplaceadd.i diff --git a/Examples/test-suite/python/input.i b/Examples/test-suite/input.i similarity index 100% rename from Examples/test-suite/python/input.i rename to Examples/test-suite/input.i diff --git a/Examples/test-suite/python/li_std_carray.i b/Examples/test-suite/li_std_carray.i similarity index 100% rename from Examples/test-suite/python/li_std_carray.i rename to Examples/test-suite/li_std_carray.i diff --git a/Examples/test-suite/python/li_std_vectora.i b/Examples/test-suite/li_std_vectora.i similarity index 100% rename from Examples/test-suite/python/li_std_vectora.i rename to Examples/test-suite/li_std_vectora.i diff --git a/Examples/test-suite/python/li_std_wstream.i b/Examples/test-suite/li_std_wstream.i similarity index 100% rename from Examples/test-suite/python/li_std_wstream.i rename to Examples/test-suite/li_std_wstream.i diff --git a/Examples/test-suite/python/Makefile.in b/Examples/test-suite/python/Makefile.in index 1fd2f4846..7b2f12539 100644 --- a/Examples/test-suite/python/Makefile.in +++ b/Examples/test-suite/python/Makefile.in @@ -64,9 +64,10 @@ CPP_TEST_CASES += \ std_containers \ swigobject \ template_matrix \ - simutry \ - vector + simutry +# li_std_carray +# director_profile C_TEST_CASES += \ file_test \ diff --git a/Examples/test-suite/python/abstractbase_runme3.py b/Examples/test-suite/python/python_abstractbase_runme3.py similarity index 89% rename from Examples/test-suite/python/abstractbase_runme3.py rename to Examples/test-suite/python/python_abstractbase_runme3.py index 13a87ee5e..e34777558 100644 --- a/Examples/test-suite/python/abstractbase_runme3.py +++ b/Examples/test-suite/python/python_abstractbase_runme3.py @@ -1,4 +1,4 @@ -from abstractbase import * +from python_abstractbase import * from collections import * assert issubclass(Mapii, MutableMapping) assert issubclass(Multimapii, MutableMapping) diff --git a/Examples/test-suite/python/kwargs_runme.py b/Examples/test-suite/python/python_kwargs_runme.py similarity index 97% rename from Examples/test-suite/python/kwargs_runme.py rename to Examples/test-suite/python/python_kwargs_runme.py index 91812929d..fb6e191dd 100644 --- a/Examples/test-suite/python/kwargs_runme.py +++ b/Examples/test-suite/python/python_kwargs_runme.py @@ -1,4 +1,4 @@ -from kwargs import * +from python_kwargs import * class MyFoo(Foo): def __init__(self, a , b = 0): diff --git a/Examples/test-suite/python/nondynamic_runme.py b/Examples/test-suite/python/python_nondynamic_runme.py similarity index 67% rename from Examples/test-suite/python/nondynamic_runme.py rename to Examples/test-suite/python/python_nondynamic_runme.py index 18230616d..27755db9c 100644 --- a/Examples/test-suite/python/nondynamic_runme.py +++ b/Examples/test-suite/python/python_nondynamic_runme.py @@ -1,6 +1,6 @@ -import nondynamic +import python_nondynamic -aa = nondynamic.A() +aa = python_nondynamic.A() aa.a = 1 aa.b = 2 @@ -14,10 +14,10 @@ if not err: raise RuntimeError, "A is not static" -class B(nondynamic.A): +class B(python_nondynamic.A): c = 4 def __init__(self): - nondynamic.A.__init__(self) + python_nondynamic.A.__init__(self) pass pass @@ -35,5 +35,5 @@ if not err: raise RuntimeError, "B is not static" -cc = nondynamic.C() +cc = python_nondynamic.C() cc.d = 3 diff --git a/Examples/test-suite/python/overload_simple_cast_runme.py b/Examples/test-suite/python/python_overload_simple_cast_runme.py similarity index 98% rename from Examples/test-suite/python/overload_simple_cast_runme.py rename to Examples/test-suite/python/python_overload_simple_cast_runme.py index 87e6e5d43..1b3a5482c 100644 --- a/Examples/test-suite/python/overload_simple_cast_runme.py +++ b/Examples/test-suite/python/python_overload_simple_cast_runme.py @@ -1,4 +1,4 @@ -from overload_simple_cast import * +from python_overload_simple_cast import * class Ai: def __init__(self,x): diff --git a/Examples/test-suite/python/pybuf_runme3.py b/Examples/test-suite/python/python_pybuf_runme3.py similarity index 93% rename from Examples/test-suite/python/pybuf_runme3.py rename to Examples/test-suite/python/python_pybuf_runme3.py index 9294c6b72..152aecdc0 100644 --- a/Examples/test-suite/python/pybuf_runme3.py +++ b/Examples/test-suite/python/python_pybuf_runme3.py @@ -1,7 +1,7 @@ #run: -# python pybuf_runme3.py benchmark +# python python_pybuf_runme3.py benchmark #for the benchmark, other wise the test case will be run -import pybuf +import python_pybuf import sys if len(sys.argv)>=2 and sys.argv[1]=="benchmark": #run the benchmark diff --git a/Examples/test-suite/python/tag_no_clash_with_variable_runme.i b/Examples/test-suite/python/tag_no_clash_with_variable_runme.i deleted file mode 100644 index 0f8fdafed..000000000 --- a/Examples/test-suite/python/tag_no_clash_with_variable_runme.i +++ /dev/null @@ -1,3 +0,0 @@ -import enum_tag_no_clash_with_variable - -error_action = error_action diff --git a/Examples/test-suite/python/vector.i b/Examples/test-suite/python/vector.i deleted file mode 100644 index 04c961cda..000000000 --- a/Examples/test-suite/python/vector.i +++ /dev/null @@ -1,51 +0,0 @@ -%module vector -%{ -#include -%} - -%define SWIG_STD_VECTOR_MINIMUM(CSTYPE, CTYPE...) - public: - typedef size_t size_type; - typedef CTYPE value_type; - size_type size() const; - vector(); - %extend { - static std::vector *Repeat(const value_type& value, int count) /*throw (std::out_of_range)*/ { -// if (count < 0) -// throw std::out_of_range("count"); - return new std::vector(count, value); - } - } -%enddef - -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) - }; -} - -%define SWIG_STD_VECTOR_SPECIALIZE(CSTYPE, CTYPE...) -namespace std { - template<> class vector { - SWIG_STD_VECTOR_MINIMUM(CSTYPE, CTYPE) - }; -} -%enddef - -SWIG_STD_VECTOR_SPECIALIZE(float, float) - -%inline %{ -typedef float Real; -%} - -#if 1 -//fails -namespace std { - %template(RealVector) vector; -} -#else -//works -%template(RealVector) std::vector; -#endif diff --git a/Examples/test-suite/python/abstractbase.i b/Examples/test-suite/python_abstractbase.i similarity index 93% rename from Examples/test-suite/python/abstractbase.i rename to Examples/test-suite/python_abstractbase.i index 530f21921..f72688237 100644 --- a/Examples/test-suite/python/abstractbase.i +++ b/Examples/test-suite/python_abstractbase.i @@ -1,4 +1,4 @@ -%module abstractbase +%module python_abstractbase %include %include %include diff --git a/Examples/test-suite/python/autodoc.i b/Examples/test-suite/python_autodoc.i similarity index 97% rename from Examples/test-suite/python/autodoc.i rename to Examples/test-suite/python_autodoc.i index c22cc02f0..c363e4384 100644 --- a/Examples/test-suite/python/autodoc.i +++ b/Examples/test-suite/python_autodoc.i @@ -1,4 +1,4 @@ -%module(docstring="hello") autodoc +%module(docstring="hello") python_autodoc %feature("autodoc"); diff --git a/Examples/test-suite/python/kwargs.i b/Examples/test-suite/python_kwargs.i similarity index 98% rename from Examples/test-suite/python/kwargs.i rename to Examples/test-suite/python_kwargs.i index 83713d8c2..28089bbf1 100644 --- a/Examples/test-suite/python/kwargs.i +++ b/Examples/test-suite/python_kwargs.i @@ -1,4 +1,4 @@ -%module kwargs +%module python_kwargs %nocopyctor; %kwargs; diff --git a/Examples/test-suite/python/nondynamic.i b/Examples/test-suite/python_nondynamic.i similarity index 96% rename from Examples/test-suite/python/nondynamic.i rename to Examples/test-suite/python_nondynamic.i index 2acc9bf8b..26c69644d 100644 --- a/Examples/test-suite/python/nondynamic.i +++ b/Examples/test-suite/python_nondynamic.i @@ -1,4 +1,4 @@ -%module nondynamic +%module python_nondynamic /* Use the %pythonnondynamic directuve to make the wrapped class a diff --git a/Examples/test-suite/python/overload_simple_cast.i b/Examples/test-suite/python_overload_simple_cast.i similarity index 58% rename from Examples/test-suite/python/overload_simple_cast.i rename to Examples/test-suite/python_overload_simple_cast.i index d274722c0..e7f58d788 100644 --- a/Examples/test-suite/python/overload_simple_cast.i +++ b/Examples/test-suite/python_overload_simple_cast.i @@ -1,4 +1,4 @@ // Simple tests of overloaded functions -%module("castmode") overload_simple_cast +%module("castmode") python_overload_simple_cast %include overload_simple.i diff --git a/Examples/test-suite/python/pybuf.i b/Examples/test-suite/python_pybuf.i similarity index 98% rename from Examples/test-suite/python/pybuf.i rename to Examples/test-suite/python_pybuf.i index 88dd1aa6a..8e1302582 100644 --- a/Examples/test-suite/python/pybuf.i +++ b/Examples/test-suite/python_pybuf.i @@ -1,4 +1,4 @@ -%module pybuf +%module python_pybuf %include %include /*functions for the test case*/ diff --git a/Examples/test-suite/python/simutry.i b/Examples/test-suite/simutry.i similarity index 100% rename from Examples/test-suite/python/simutry.i rename to Examples/test-suite/simutry.i diff --git a/Examples/test-suite/python/swigobject.i b/Examples/test-suite/swigobject.i similarity index 100% rename from Examples/test-suite/python/swigobject.i rename to Examples/test-suite/swigobject.i diff --git a/Examples/test-suite/python/template_matrix.i b/Examples/test-suite/template_matrix.i similarity index 100% rename from Examples/test-suite/python/template_matrix.i rename to Examples/test-suite/template_matrix.i From 3041db155db096a39c826deb73ccf44485a38529 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 26 Nov 2008 23:04:18 +0000 Subject: [PATCH 0198/1680] modifying build system not to rely on the -I path to find the input files avoiding warning 125: merge .i files that are common between python and the main version git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10954 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/li_std_map.i | 7 + Examples/test-suite/li_std_set.i | 6 + .../li_std_vector.i => li_std_vector_extra.i} | 2 +- Examples/test-suite/python/li_std_map.i | 58 ----- Examples/test-suite/python/li_std_set.i | 17 -- Examples/test-suite/python/li_std_stream.i | 59 ------ ..._runme.py => li_std_vector_extra_runme.py} | 2 +- Examples/test-suite/python/li_std_wstring.i | 89 -------- Examples/test-suite/python/std_containers.i | 199 ------------------ 9 files changed, 15 insertions(+), 424 deletions(-) rename Examples/test-suite/{python/li_std_vector.i => li_std_vector_extra.i} (98%) delete mode 100644 Examples/test-suite/python/li_std_map.i delete mode 100644 Examples/test-suite/python/li_std_set.i delete mode 100644 Examples/test-suite/python/li_std_stream.i rename Examples/test-suite/python/{li_std_vector_runme.py => li_std_vector_extra_runme.py} (98%) delete mode 100644 Examples/test-suite/python/li_std_wstring.i delete mode 100644 Examples/test-suite/python/std_containers.i diff --git a/Examples/test-suite/li_std_map.i b/Examples/test-suite/li_std_map.i index edcb05641..806e732ee 100644 --- a/Examples/test-suite/li_std_map.i +++ b/Examples/test-suite/li_std_map.i @@ -47,8 +47,15 @@ namespace std %template(pairiiAc) pair >; +#ifdef SWIGRUBY %template() pair< swig::LANGUAGE_OBJ, swig::LANGUAGE_OBJ >; %template(LanguageMap) map< swig::LANGUAGE_OBJ, swig::LANGUAGE_OBJ >; +#endif + +#ifdef SWIGPYTHON + %template() pair; + %template(pymap) map; +#endif } diff --git a/Examples/test-suite/li_std_set.i b/Examples/test-suite/li_std_set.i index c2cdc2ebe..6da920a5a 100644 --- a/Examples/test-suite/li_std_set.i +++ b/Examples/test-suite/li_std_set.i @@ -31,4 +31,10 @@ +#if defined(SWIGRUBY) %template(LanguageSet) std::set; +#endif + +#if defined(SWIGPYTHON) +%template(pyset) std::set; +#endif diff --git a/Examples/test-suite/python/li_std_vector.i b/Examples/test-suite/li_std_vector_extra.i similarity index 98% rename from Examples/test-suite/python/li_std_vector.i rename to Examples/test-suite/li_std_vector_extra.i index 06dafce59..17baffe04 100644 --- a/Examples/test-suite/python/li_std_vector.i +++ b/Examples/test-suite/li_std_vector_extra.i @@ -1,4 +1,4 @@ -%module li_std_vector +%module li_std_vector_extra %warnfilter(509) overloaded1; %warnfilter(509) overloaded2; diff --git a/Examples/test-suite/python/li_std_map.i b/Examples/test-suite/python/li_std_map.i deleted file mode 100644 index a8ba4f2e2..000000000 --- a/Examples/test-suite/python/li_std_map.i +++ /dev/null @@ -1,58 +0,0 @@ -%module("templatereduce") li_std_map - -%include std_pair.i -%include std_map.i -%include std_multimap.i - -%inline %{ -struct A{ - int val; - - A(int v = 0): val(v) - { - } - -}; -%} - -namespace std -{ - %template(pairii) pair; - %template(pairAA) pair; - %template(pairA) pair; - %template(mapA) map; - %template(mmapA) multimap; - - %template(paircA1) pair; - %template(paircA2) pair; - %template(pairiiA) pair >; - %template(pairiiAc) pair >; - - - %template() pair; - %template(pymap) map; - -} - - - -%inline -{ -std::pair -p_identa(std::pair p) { - return p; -} - -std::map m_identa(const std::map& v) -{ - return v; -} - -} - - - -namespace std -{ -%template(mapii) map; -} diff --git a/Examples/test-suite/python/li_std_set.i b/Examples/test-suite/python/li_std_set.i deleted file mode 100644 index f0fddb058..000000000 --- a/Examples/test-suite/python/li_std_set.i +++ /dev/null @@ -1,17 +0,0 @@ -%module li_std_set - -%include -%include -%include -%include - -%template(set_string) std::set; -%template(set_int) std::multiset; - - -%template(v_int) std::vector; - - - - -%template(pyset) std::set; diff --git a/Examples/test-suite/python/li_std_stream.i b/Examples/test-suite/python/li_std_stream.i deleted file mode 100644 index 0a999ddbf..000000000 --- a/Examples/test-suite/python/li_std_stream.i +++ /dev/null @@ -1,59 +0,0 @@ -%module li_std_stream - -%inline %{ - struct A; -%} - -%include -%include - - - -%callback(1) A::bar; - -%inline %{ - - struct B { - virtual ~B() - { - } - - }; - - struct A : B - { - void __add__(int a) - { - } - - void __add__(double a) - { - } - - static int bar(int a){ - return a; - } - - static int foo(int a, int (*pf)(int a)) - { - return pf(a); - } - - - std::ostream& __rlshift__(std::ostream& out) - { - out << "A class"; - return out; - } - }; -%} - -%extend std::basic_ostream{ - std::basic_ostream& - operator<<(const A& a) - { - *self << "A class"; - return *self; - } -} - diff --git a/Examples/test-suite/python/li_std_vector_runme.py b/Examples/test-suite/python/li_std_vector_extra_runme.py similarity index 98% rename from Examples/test-suite/python/li_std_vector_runme.py rename to Examples/test-suite/python/li_std_vector_extra_runme.py index a0d96d4aa..ce7b0c737 100644 --- a/Examples/test-suite/python/li_std_vector_runme.py +++ b/Examples/test-suite/python/li_std_vector_extra_runme.py @@ -1,4 +1,4 @@ -from li_std_vector import * +from li_std_vector_extra import * iv = IntVector(4) for i in range(0,4): diff --git a/Examples/test-suite/python/li_std_wstring.i b/Examples/test-suite/python/li_std_wstring.i deleted file mode 100644 index c809e11ec..000000000 --- a/Examples/test-suite/python/li_std_wstring.i +++ /dev/null @@ -1,89 +0,0 @@ -%module li_std_wstring -%include -%include - - -%inline %{ - -struct A : std::wstring -{ - A(const std::wstring& s) : std::wstring(s) - { - } -}; - -struct B -{ - B(const std::wstring& s) : cname(0), name(s), a(s) - { - } - - char *cname; - std::wstring name; - A a; - -}; - - -wchar_t test_wcvalue(wchar_t x) { - return x; -} - -const wchar_t* test_ccvalue(const wchar_t* x) { - return x; -} - -wchar_t* test_cvalue(wchar_t* x) { - return x; -} - - -std::wstring test_value(std::wstring x) { - return x; -} - -const std::wstring& test_const_reference(const std::wstring &x) { - return x; -} - -void test_pointer(std::wstring *x) { -} - -std::wstring *test_pointer_out() { - static std::wstring x = L"x"; - return &x; -} - -void test_const_pointer(const std::wstring *x) { -} - -const std::wstring *test_const_pointer_out() { - static std::wstring x = L"x"; - return &x; -} - -void test_reference(std::wstring &x) { -} - -std::wstring& test_reference_out() { - static std::wstring x = L"x"; - return x; -} - -#if defined(_MSC_VER) - #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) -#endif - -void test_throw() throw(std::wstring){ - static std::wstring x = L"x"; - - throw x; -} - -#if defined(_MSC_VER) - #pragma warning(default: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) -#endif - -%} - - diff --git a/Examples/test-suite/python/std_containers.i b/Examples/test-suite/python/std_containers.i deleted file mode 100644 index a1d39e7ab..000000000 --- a/Examples/test-suite/python/std_containers.i +++ /dev/null @@ -1,199 +0,0 @@ -%module std_containers - -%{ -#include -%} -%include std_vector.i -%include std_string.i -%include std_deque.i -%include std_list.i -%include std_set.i -%include std_multiset.i -%include std_pair.i -%include std_map.i -%include std_multimap.i -%include std_complex.i - -%template() std::vector; -%template() std::pair; -%template() std::pair; - -%template() std::vector< std::vector > ; -%template(ccube) std::vector< std::vector< std::vector > >; - -%inline -{ - typedef - std::vector > > - ccube; - - ccube cident(const ccube& c) - { - return c; - } - - struct C - { - }; -} - - -%template(map_si) std::map; -%template(pair_iC) std::pair; -%template(map_iC) std::map; -%template(mmap_si) std::multimap; -%template(set_i) std::set; -%template(multiset_i) std::multiset; -%template(list_i) std::list; -%template(deque_i) std::deque; - -%template(vector_b) std::vector; -%template(vector_i) std::vector; -%template(vector_c) std::vector >; -%template(vector_ui) std::vector; - -%template(bmatrix) std::vector >; -%template(imatrix) std::vector >; -%template(cmatrix) std::vector > >; - -%apply std::vector *INOUT {std::vector *INOUT2}; - -%inline -{ - typedef std::vector > imatrix; - imatrix midenti(const imatrix& v) - { - return v; - } - - typedef std::vector > bmatrix; - bmatrix midentb(const bmatrix& v) - { - return v; - } - - std::map mapidentc(const std::map& v) - { - return v; - } - - std::map mapidenti(const std::map& v) - { - return v; - } - - std::map mapident(const std::map& v) - { - return v; - } - - std::multimap mapident(const std::multimap& v) - { - return v; - } - - std::vector vident(const std::vector& v) - { - return v; - } - - std::set sident(const std::set& v) - { - return v; - } - - std::vector videntu(const std::vector& v) - { - return v; - } - - - int get_elem(const std::vector& v, int index) - { - return v[index]; - } - - std::pair pident(const std::pair& p) - { - return p; - } - - void - v_inout(std::vector *INOUT) { - *INOUT = *INOUT; - } - - void - v_inout2(std::vector *INOUT, std::vector *INOUT2) { - std::swap(*INOUT, *INOUT2); - } - -} - - -%{ - - template struct Param - { - }; -%} - - -template struct Param -{ -}; - - -%template(Param_c) Param >; -%inline -{ - int hello(Param > c) - { - return 0; - } -} - -%inline -{ - struct A - { - A(int aa = 0) : a(aa) - { - } - int a; - }; -} - -%template() std::pair; -%template(pair_iA) std::pair; -%template(vector_piA) std::vector >; - - -%inline { - std::pair ident(std::pair a, const std::pair& b) - { - return std::pair(); - } - - - std::vector > pia_vident(std::vector > a ) - { - return a; - } - - struct Foo - { - Foo(int i) { - } - }; - -} - - -%std_nodefconst_type(Foo); - -%template(vector_Foo) std::vector; -%template(deque_Foo) std::deque; -%template(list_Foo) std::list; - - From 946f9def37be4bb23c89b4e7763f6957adfd2c66 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 26 Nov 2008 23:25:47 +0000 Subject: [PATCH 0199/1680] fix test names since they were renamed recently git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10955 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/python/Makefile.in | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Examples/test-suite/python/Makefile.in b/Examples/test-suite/python/Makefile.in index 7b2f12539..c72b19941 100644 --- a/Examples/test-suite/python/Makefile.in +++ b/Examples/test-suite/python/Makefile.in @@ -32,9 +32,8 @@ PY2TO3 = 2to3 `2to3 -l | grep -v -E "Available|import$$" | awk '{print "-f "$$0} CPP_TEST_CASES += \ - abstractbase \ argcargvtest \ - autodoc \ + python_autodoc \ callback \ complextest \ director_stl \ @@ -45,12 +44,12 @@ CPP_TEST_CASES += \ input \ inplaceadd \ implicittest \ - kwargs \ li_cstring \ li_cwstring \ li_factory \ li_implicit \ li_std_vectora \ + li_std_vector_extra \ li_std_map \ li_std_pair_extra \ li_std_set \ @@ -58,9 +57,11 @@ CPP_TEST_CASES += \ li_std_string_extra \ li_std_wstream \ li_std_wstring \ - nondynamic \ - overload_simple_cast \ primitive_types \ + python_abstractbase \ + python_kwargs \ + python_nondynamic \ + python_overload_simple_cast \ std_containers \ swigobject \ template_matrix \ @@ -68,12 +69,13 @@ CPP_TEST_CASES += \ # li_std_carray # director_profile +# python_pybuf C_TEST_CASES += \ file_test \ li_cstring \ li_cwstring \ - nondynamic + python_nondynamic # # This test only works with modern C compilers From d26772917b5c752b2f92ab066ce807d8f40dc3ce Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 28 Nov 2008 23:30:45 +0000 Subject: [PATCH 0200/1680] minor fix to formatting in generated types table git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10956 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 870c6f35e..5b20f88a1 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -890,7 +890,7 @@ public: int add_pyinstancemethod_new() { String* name = NewString("SWIG_PyInstanceMethod_New"); - Printf(methods, "\t { (char *)\"%s\", (PyCFunction)%s, METH_O, NULL},", name, name); + Printf(methods, "\t { (char *)\"%s\", (PyCFunction)%s, METH_O, NULL},\n", name, name); Delete(name); return 0; } From 0cfccf817f766757ce0311c8d59b89247059ff47 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 28 Nov 2008 23:33:37 +0000 Subject: [PATCH 0201/1680] move iadd.h contents into iadd.i git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10957 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/iadd.i | 54 ++++++++++++++++++++++++++++--- Examples/test-suite/python/iadd.h | 47 --------------------------- 2 files changed, 50 insertions(+), 51 deletions(-) delete mode 100644 Examples/test-suite/python/iadd.h diff --git a/Examples/test-suite/iadd.i b/Examples/test-suite/iadd.i index 76604c027..514bd3e4f 100644 --- a/Examples/test-suite/iadd.i +++ b/Examples/test-suite/iadd.i @@ -1,12 +1,58 @@ %module iadd %include attribute.i -%{ -#include "iadd.h" -%} class Foo; %attribute_ref(test::Foo, test::A& , AsA); %attribute_ref(test::Foo, long, AsLong); -%include "iadd.h" +%inline %{ +struct B { + int x; + B(const int x) : x(x) {} + + B& get_me() + { + return *this; + } + + B& operator+=(const B& a) { + x += a.x; + return *this; + } +}; + + + +namespace test { + +struct A { + int x; + A(const int x) : x(x) {} + + A& get_me() + { + return *this; + } + + A operator+=(const A& a) { + x += a.x; + return *this; + } +}; + + +class Foo { +public: + Foo(): _a(new A(5)), _n(new long) {} + ~Foo() { delete _a; delete _n; _a = NULL; _n = NULL; } + + A & AsA() const { return *_a; } + long& AsLong() const { return *_n; } +private: + A *_a; + long *_n; +}; +} + +%} diff --git a/Examples/test-suite/python/iadd.h b/Examples/test-suite/python/iadd.h deleted file mode 100644 index 367eda26f..000000000 --- a/Examples/test-suite/python/iadd.h +++ /dev/null @@ -1,47 +0,0 @@ -struct B { - int x; - B(const int x) : x(x) {} - - B& get_me() - { - return *this; - } - - B& operator+=(const B& a) { - x += a.x; - return *this; - } -}; - - - -namespace test { - -struct A { - int x; - A(const int x) : x(x) {} - - A& get_me() - { - return *this; - } - - A operator+=(const A& a) { - x += a.x; - return *this; - } -}; - - -class Foo { -public: - Foo(): _a(new A(5)), _n(new long) {} - ~Foo() { delete _a; delete _n; _a = NULL; _n = NULL; } - - A & AsA() const { return *_a; } - long& AsLong() const { return *_n; } -private: - A *_a; - long *_n; -}; -} From 93f039032204821d4fc363346587c90f640a1109 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 28 Nov 2008 23:35:46 +0000 Subject: [PATCH 0202/1680] UTL - Fix some incorrect acceptance of types in the STL, eg a double * element passed into a vector constructor would be accepted, but the ensuing behaviour was undefined. Now the type conversion correctly raises an exception git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10958 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 5 ++++ Examples/test-suite/common.mk | 1 + Examples/test-suite/keyword_rename.i | 2 +- Examples/test-suite/li_std_vector_extra.i | 8 ++++- Examples/test-suite/li_std_vector_ptr.i | 29 +++++++++++++++++++ .../python/li_std_vector_extra_runme.py | 21 ++++++++++++++ .../python/li_std_vector_ptr_runme.py | 8 +++++ Lib/octave/octstdcommon.swg | 2 +- Lib/python/pystdcommon.swg | 2 +- Lib/r/rstdcommon.swg | 2 +- 10 files changed, 75 insertions(+), 5 deletions(-) create mode 100644 Examples/test-suite/li_std_vector_ptr.i create mode 100644 Examples/test-suite/python/li_std_vector_ptr_runme.py diff --git a/CHANGES.current b/CHANGES.current index 0b7a1e079..c00ae694c 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,11 @@ Version 1.3.37 (in progress) ============================ +2008-11-28: wsfulton + [UTL] Fix some incorrect acceptance of types in the STL, eg a double * element passed + into a vector constructor would be accepted, but the ensuing behaviour was + undefined. Now the type conversion correctly raises an exception. + 2008-11-24: wsfulton Add -outcurrentdir option. This sets the default output directory to the current directory instead of the path specified by the input file. This option enables diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 4bfd53aba..3848601bc 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -77,6 +77,7 @@ CPP_TEST_BROKEN += \ cpp_broken \ exception_partial_info \ extend_variable \ + li_std_vector_ptr \ namespace_union \ nested_comment \ overload_complicated \ diff --git a/Examples/test-suite/keyword_rename.i b/Examples/test-suite/keyword_rename.i index da9328868..244410d60 100644 --- a/Examples/test-suite/keyword_rename.i +++ b/Examples/test-suite/keyword_rename.i @@ -4,7 +4,7 @@ %module keyword_rename -#pragma SWIG nowarn=SWIGWARN_PARSE_KEYWORD +//#pragma SWIG nowarn=SWIGWARN_PARSE_KEYWORD %inline %{ diff --git a/Examples/test-suite/li_std_vector_extra.i b/Examples/test-suite/li_std_vector_extra.i index 17baffe04..5aeb403be 100644 --- a/Examples/test-suite/li_std_vector_extra.i +++ b/Examples/test-suite/li_std_vector_extra.i @@ -123,11 +123,17 @@ std::vector vecStr(std::vector v) { %pointer_class(int,PtrInt) %array_functions(int,ArrInt) +%inline %{ + int *makeIntPtr(int v) { return new int(v); } + double *makeDoublePtr(double v) { return new double(v); } + int extractInt(int *p) { return *p; } +%} %template(pyvector) std::vector; namespace std { - %template(ConstIntVector) vector; + %template(ConstShortVector) vector; +// %template(ConstIntVector) vector; // interferes with vector... see new testcase li_std_vector_ptr } %inline %{ diff --git a/Examples/test-suite/li_std_vector_ptr.i b/Examples/test-suite/li_std_vector_ptr.i new file mode 100644 index 000000000..688cbdd54 --- /dev/null +++ b/Examples/test-suite/li_std_vector_ptr.i @@ -0,0 +1,29 @@ +%module li_std_vector_ptr + +%include "std_vector.i" + +%template(IntPtrVector) std::vector; + +%inline %{ +#include +using namespace std; +int* makeIntPtr(int v) { + return new int(v); +} +double* makeDoublePtr(double v) { + return new double(v); +} + +#if 1 +int** makeIntPtrPtr(int* v) { + return new int*(v); +} +#endif + +void displayVector(std::vector vpi) { + cout << "displayVector..." << endl; + for (int i=0; i does not accept double * element + error = 1 +except: + pass + +if error: + raise RuntimeError + +vi = IntPtrVector((ip, makeIntPtr(22))) +if extractInt(vi[0]) != 11: + raise RuntimeError + +if extractInt(vi[1]) != 22: + raise RuntimeError + diff --git a/Examples/test-suite/python/li_std_vector_ptr_runme.py b/Examples/test-suite/python/li_std_vector_ptr_runme.py new file mode 100644 index 000000000..c5f72fde4 --- /dev/null +++ b/Examples/test-suite/python/li_std_vector_ptr_runme.py @@ -0,0 +1,8 @@ +from li_std_vector_ptr import * + +ip1 = makeIntPtr(11) +ip2 = makeIntPtr(22) + +vi = IntPtrVector((ip1, ip2)) +displayVector(vi) + diff --git a/Lib/octave/octstdcommon.swg b/Lib/octave/octstdcommon.swg index e69c7e629..96923f40a 100644 --- a/Lib/octave/octstdcommon.swg +++ b/Lib/octave/octstdcommon.swg @@ -42,7 +42,7 @@ namespace swig { struct traits_asptr { static int asptr(const octave_value& obj, Type **val) { Type *p; - int res = (SWIG_ConvertPtr(obj, (void**)&p, type_info(), 0) == SWIG_OK) ? SWIG_OLDOBJ : 0; + int res = SWIG_ConvertPtr(obj, (void**)&p, type_info(), 0); if (SWIG_IsOK(res)) { if (val) *val = p; } diff --git a/Lib/python/pystdcommon.swg b/Lib/python/pystdcommon.swg index 48b1fdcd5..7e9720cc0 100644 --- a/Lib/python/pystdcommon.swg +++ b/Lib/python/pystdcommon.swg @@ -46,7 +46,7 @@ namespace swig { struct traits_asptr { static int asptr(PyObject *obj, Type **val) { Type *p; - int res = (SWIG_ConvertPtr(obj, (void**)&p, type_info(), 0) == SWIG_OK) ? SWIG_OLDOBJ : 0; + int res = SWIG_ConvertPtr(obj, (void**)&p, type_info(), 0); if (SWIG_IsOK(res)) { if (val) *val = p; } diff --git a/Lib/r/rstdcommon.swg b/Lib/r/rstdcommon.swg index 223203773..56cbe2cdd 100644 --- a/Lib/r/rstdcommon.swg +++ b/Lib/r/rstdcommon.swg @@ -40,7 +40,7 @@ namespace swig { struct traits_asptr { static int asptr(SWIG_Object obj, Type **val) { Type *p; - int res = (SWIG_ConvertPtr(obj, (void**)&p, type_info(), 0) == SWIG_OK) ? SWIG_OLDOBJ : 0; + int res = SWIG_ConvertPtr(obj, (void**)&p, type_info(), 0); if (SWIG_IsOK(res)) { if (val) *val = p; } From 415186c1f4dc37a5e961c7c6c129dce382bef609 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 28 Nov 2008 23:37:13 +0000 Subject: [PATCH 0203/1680] revert mistaken checkin git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10959 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/keyword_rename.i | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/test-suite/keyword_rename.i b/Examples/test-suite/keyword_rename.i index 244410d60..da9328868 100644 --- a/Examples/test-suite/keyword_rename.i +++ b/Examples/test-suite/keyword_rename.i @@ -4,7 +4,7 @@ %module keyword_rename -//#pragma SWIG nowarn=SWIGWARN_PARSE_KEYWORD +#pragma SWIG nowarn=SWIGWARN_PARSE_KEYWORD %inline %{ From 1c4ec59e450643e641ebe7e8095f8b911bc41fd9 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 2 Dec 2008 20:21:16 +0000 Subject: [PATCH 0204/1680] Apply patch #2143727 for Python from Serge Monkewitz to fix importing base classes when the package option is specified in %module and that module is %import'ed git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10960 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 10 +++++++--- Examples/test-suite/packageoption.h | 9 +++++---- Examples/test-suite/packageoption.list | 1 + Examples/test-suite/packageoption_a.i | 10 ++++++++-- Examples/test-suite/packageoption_b.i | 2 +- Examples/test-suite/packageoption_c.i | 13 +++++++++++++ Examples/test-suite/perl5/packageoption_runme.pl | 8 ++++---- Source/Modules/python.cxx | 6 +++++- 8 files changed, 44 insertions(+), 15 deletions(-) create mode 100644 Examples/test-suite/packageoption_c.i diff --git a/CHANGES.current b/CHANGES.current index c00ae694c..d2d5131dc 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,10 +1,14 @@ Version 1.3.37 (in progress) ============================ +2008-12-02: wsfulton + [Python] Apply patch #2143727 from Serge Monkewitz to fix importing base classes + when the package option is specified in %module and that module is %import'ed. + 2008-11-28: wsfulton - [UTL] Fix some incorrect acceptance of types in the STL, eg a double * element passed - into a vector constructor would be accepted, but the ensuing behaviour was - undefined. Now the type conversion correctly raises an exception. + [UTL] Fix #2080497. Some incorrect acceptance of types in the STL, eg a double * element + passed into a vector constructor would be accepted, but the ensuing behaviour + was undefined. Now the type conversion correctly raises an exception. 2008-11-24: wsfulton Add -outcurrentdir option. This sets the default output directory to the current diff --git a/Examples/test-suite/packageoption.h b/Examples/test-suite/packageoption.h index a7ef499aa..82f29d1c7 100644 --- a/Examples/test-suite/packageoption.h +++ b/Examples/test-suite/packageoption.h @@ -1,5 +1,6 @@ -class A -{ - public: - int testInt() { return 2;} +struct Base { + virtual int vmethod() { return 1; } + int basemethod() { return 1; } + virtual ~Base() {} }; + diff --git a/Examples/test-suite/packageoption.list b/Examples/test-suite/packageoption.list index 4bdabeccf..da125c2a3 100644 --- a/Examples/test-suite/packageoption.list +++ b/Examples/test-suite/packageoption.list @@ -1,2 +1,3 @@ packageoption_a packageoption_b +packageoption_c diff --git a/Examples/test-suite/packageoption_a.i b/Examples/test-suite/packageoption_a.i index e95091b0d..b28278282 100644 --- a/Examples/test-suite/packageoption_a.i +++ b/Examples/test-suite/packageoption_a.i @@ -1,4 +1,4 @@ -%module(package="C") "packageoption_a"; +%module(package="CommonPackage") "packageoption_a"; %inline %{ class A @@ -6,5 +6,11 @@ class A public: int testInt() { return 2;} }; - %} + +%{ +#include "packageoption.h" +%} + +%include "packageoption.h" + diff --git a/Examples/test-suite/packageoption_b.i b/Examples/test-suite/packageoption_b.i index 466853cc0..40a44be14 100644 --- a/Examples/test-suite/packageoption_b.i +++ b/Examples/test-suite/packageoption_b.i @@ -1,4 +1,4 @@ -%module(package="C") "packageoption_b"; +%module(package="CommonPackage") "packageoption_b"; %inline %{ class B diff --git a/Examples/test-suite/packageoption_c.i b/Examples/test-suite/packageoption_c.i new file mode 100644 index 000000000..f43e47002 --- /dev/null +++ b/Examples/test-suite/packageoption_c.i @@ -0,0 +1,13 @@ +%module(package="PackageC") "packageoption_c"; + +%import "packageoption_a.i" + +%inline %{ +#include "packageoption.h" + +struct Derived : Base { + virtual int vmethod() { return 2; } + virtual ~Derived() {} +}; + +%} diff --git a/Examples/test-suite/perl5/packageoption_runme.pl b/Examples/test-suite/perl5/packageoption_runme.pl index debea78e1..d94a7a1fd 100644 --- a/Examples/test-suite/perl5/packageoption_runme.pl +++ b/Examples/test-suite/perl5/packageoption_runme.pl @@ -14,11 +14,11 @@ sub ok_not ($;$) { ok($test, $name); } -my $a = C::A->new(); +my $a = CommonPackage::A->new(); -isa_ok($a, 'C::A'); +isa_ok($a, 'CommonPackage::A'); -my $b = C::B->new(); +my $b = CommonPackage::B->new(); -isa_ok($b, 'C::B'); +isa_ok($b, 'CommonPackage::B'); diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 5b20f88a1..a9a3833ff 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -925,7 +925,11 @@ public: if (!options || (!Getattr(options, "noshadow") && !Getattr(options, "noproxy"))) { Printf(import, "_%s\n", modname); if (!Strstr(f_shadow_imports, import)) { - Printf(f_shadow, "import %s\n", modname); + if (pkg && (!package || Strcmp(pkg, package) != 0)) { + Printf(f_shadow, "import %s.%s\n", pkg, modname); + } else { + Printf(f_shadow, "import %s\n", modname); + } Printv(f_shadow_imports, import, NULL); } } From 8f84447860d253e766b2c8ddaec476e797f7646a Mon Sep 17 00:00:00 2001 From: Haoyu Bai Date: Wed, 3 Dec 2008 18:43:44 +0000 Subject: [PATCH 0205/1680] Commited SF#2158938: change all SWIG symbols start with Py to a new name. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10961 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 32 +++ Examples/python/std_map/example.i | 4 +- Examples/test-suite/li_std_map.i | 6 +- Examples/test-suite/li_std_set.i | 4 +- Examples/test-suite/li_std_vector_extra.i | 2 +- Lib/octave/octcontainer.swg | 6 +- Lib/octave/std_carray.i | 6 +- Lib/octave/std_map.i | 14 +- Lib/python/pyclasses.swg | 62 ++--- Lib/python/pycontainer.swg | 156 ++++++------ Lib/python/pyiterators.swg | 166 ++++++------- Lib/python/pyname_compat.i | 88 +++++++ Lib/python/pyopers.swg | 2 +- Lib/python/pyrun.swg | 286 +++++++++++----------- Lib/python/pytypemaps.swg | 2 +- Lib/python/std_carray.i | 6 +- Lib/python/std_map.i | 44 ++-- Lib/python/std_multimap.i | 14 +- Lib/python/std_multiset.i | 12 +- Lib/python/std_pair.i | 8 +- Lib/python/std_set.i | 12 +- Source/Modules/python.cxx | 36 +-- Tools/pyname_patch.py | 122 +++++++++ 23 files changed, 666 insertions(+), 424 deletions(-) create mode 100644 Lib/python/pyname_compat.i create mode 100644 Tools/pyname_patch.py diff --git a/CHANGES.current b/CHANGES.current index d2d5131dc..915cbc732 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,38 @@ Version 1.3.37 (in progress) ============================ +2008-12-04: bhy + [Python] Applied patch SF#2158938: all the SWIG symbol names started with Py + are changed, since they are inappropriate and discouraged in Python + documentation (from http://www.python.org/doc/2.5.2/api/includes.html): + + "All user visible names defined by Python.h (except those defined by + the included standard headers) have one of the prefixes "Py" or "_Py". + Names beginning with "_Py" are for internal use by the Python implementation + and should not be used by extension writers. Structure member names do + not have a reserved prefix. + + Important: user code should never define names that begin with "Py" or "_Py". + This confuses the reader, and jeopardizes the portability of the user + code to future Python versions, which may define additional names beginning + with one of these prefixes." + + Here is a brief list of what changed: + + PySwig* -> SwigPy* + PyObject_ptr -> SwigPtr_PyObject + PyObject_var -> SwigVar_PyObject + PySequence_Base, PySequence_Cont, PySequence_Ref -> + SwigPySequence_Base, SwigPySequence_Cont, SwigPySequence_Ref + PyMap* -> SwigPyMap* + + We provided a pyname_compat.i for backward compatibility. Users whose code having + these symbols and do not want to change it could simply include this file + at front of your code. A better solution is to run the converting tool on + your code, which has been put in SWIG's SVN trunk (Tools/pyname_patch.py) and + you can download it here: + https://swig.svn.sourceforge.net/svnroot/swig/trunk/Tools/pyname_patch.py + 2008-12-02: wsfulton [Python] Apply patch #2143727 from Serge Monkewitz to fix importing base classes when the package option is specified in %module and that module is %import'ed. diff --git a/Examples/python/std_map/example.i b/Examples/python/std_map/example.i index 36354a882..6a7af7108 100644 --- a/Examples/python/std_map/example.i +++ b/Examples/python/std_map/example.i @@ -23,5 +23,5 @@ namespace std { %template(halfi) half_map; -%template() std::pair; -%template(pymap) std::map; +%template() std::pair; +%template(pymap) std::map; diff --git a/Examples/test-suite/li_std_map.i b/Examples/test-suite/li_std_map.i index 806e732ee..27c1b1a70 100644 --- a/Examples/test-suite/li_std_map.i +++ b/Examples/test-suite/li_std_map.i @@ -10,7 +10,7 @@ * * For example: * swig::LANGUAGE_OBJ is GC_VALUE in Ruby - * swig::LANGUAGE_OBJ is PyObject_ptr in python + * swig::LANGUAGE_OBJ is SwigPtr_PyObject in python * * */ @@ -53,8 +53,8 @@ namespace std #endif #ifdef SWIGPYTHON - %template() pair; - %template(pymap) map; + %template() pair; + %template(pymap) map; #endif } diff --git a/Examples/test-suite/li_std_set.i b/Examples/test-suite/li_std_set.i index 6da920a5a..8c335b24c 100644 --- a/Examples/test-suite/li_std_set.i +++ b/Examples/test-suite/li_std_set.i @@ -10,7 +10,7 @@ * * For example: * swig::LANGUAGE_OBJ is GC_VALUE in Ruby - * swig::LANGUAGE_OBJ is PyObject_ptr in python + * swig::LANGUAGE_OBJ is SwigPtr_PyObject in python * * */ @@ -36,5 +36,5 @@ #endif #if defined(SWIGPYTHON) -%template(pyset) std::set; +%template(pyset) std::set; #endif diff --git a/Examples/test-suite/li_std_vector_extra.i b/Examples/test-suite/li_std_vector_extra.i index 5aeb403be..9c2497f7c 100644 --- a/Examples/test-suite/li_std_vector_extra.i +++ b/Examples/test-suite/li_std_vector_extra.i @@ -129,7 +129,7 @@ std::vector vecStr(std::vector v) { int extractInt(int *p) { return *p; } %} -%template(pyvector) std::vector; +%template(pyvector) std::vector; namespace std { %template(ConstShortVector) vector; diff --git a/Lib/octave/octcontainer.swg b/Lib/octave/octcontainer.swg index bb1122a7b..f3ba01713 100644 --- a/Lib/octave/octcontainer.swg +++ b/Lib/octave/octcontainer.swg @@ -204,7 +204,7 @@ namespace swig operator T () const { - // swig::PyObject_var item = OctSequence_GetItem(_seq, _index); + // swig::SwigVar_PyObject item = OctSequence_GetItem(_seq, _index); octave_value item; // * todo try { return swig::as(item, true); @@ -410,7 +410,7 @@ namespace swig { int s = size(); for (int i = 0; i < s; ++i) { - // swig::PyObject_var item = OctSequence_GetItem(_seq, i); + // swig::SwigVar_PyObject item = OctSequence_GetItem(_seq, i); octave_value item; // * todo if (!swig::check(item)) { if (set_err) { @@ -453,7 +453,7 @@ namespace swig $result = Cell(tmpc); } - %fragment("PyPairBoolOutputIterator","header",fragment=SWIG_From_frag(bool),fragment="OctSequence_Cont") {} + %fragment("SwigPyPairBoolOutputIterator","header",fragment=SWIG_From_frag(bool),fragment="OctSequence_Cont") {} %typemap(out,fragment="OctPairBoolOutputIterator") std::pair, std::pair { diff --git a/Lib/octave/std_carray.i b/Lib/octave/std_carray.i index 1477479da..9e2338a61 100644 --- a/Lib/octave/std_carray.i +++ b/Lib/octave/std_carray.i @@ -17,7 +17,7 @@ namespace swig { %extend std::carray { %fragment(SWIG_Traits_frag(std::carray<_Type, _Size >), "header", - fragment="PySwigIterator_T", + fragment="SwigPyIterator_T", fragment=SWIG_Traits_frag(_Type), fragment="StdCarrayTraits") { namespace swig { @@ -36,7 +36,7 @@ namespace swig { %typemap(out,noblock=1) iterator, const_iterator { $result = SWIG_NewPointerObj(swig::make_output_iterator((const $type &)$1), - swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN); + swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN); } inline size_t __len__() const { return self->size(); } @@ -46,7 +46,7 @@ namespace swig { inline void __setitem__(size_t i, const _Type& v) { (*self)[i] = v; } - swig::PySwigIterator* __iter__(PyObject **PYTHON_SELF) { + swig::SwigPyIterator* __iter__(PyObject **PYTHON_SELF) { return swig::make_output_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF); } } diff --git a/Lib/octave/std_map.i b/Lib/octave/std_map.i index a54e5f753..20003df58 100644 --- a/Lib/octave/std_map.i +++ b/Lib/octave/std_map.i @@ -22,7 +22,7 @@ /* int res = SWIG_ERROR; if (PyDict_Check(obj)) { - PyObject_var items = PyObject_CallMethod(obj,(char *)"items",NULL); + SwigVar_PyObject items = PyObject_CallMethod(obj,(char *)"items",NULL); res = traits_asptr_stdseq, std::pair >::asptr(items, val); } else { map_type *p; @@ -58,8 +58,8 @@ } PyObject *obj = PyDict_New(); for (const_iterator i= map.begin(); i!= map.end(); ++i) { - swig::PyObject_var key = swig::from(i->first); - swig::PyObject_var val = swig::from(i->second); + swig::SwigVar_PyObject key = swig::from(i->first); + swig::SwigVar_PyObject val = swig::from(i->second); PyDict_SetItem(obj, key, val); } return obj; @@ -92,10 +92,10 @@ }; template - struct OctMapIterator_T : PySwigIteratorClosed_T + struct OctMapIterator_T : SwigPyIteratorClosed_T { OctMapIterator_T(OutIterator curr, OutIterator first, OutIterator last, octave_value seq) - : PySwigIteratorClosed_T(curr, first, last, seq) + : SwigPyIteratorClosed_T(curr, first, last, seq) { } }; @@ -112,7 +112,7 @@ }; template - inline PySwigIterator* + inline SwigPyIterator* make_output_key_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, octave_value seq = octave_value()) { return new OctMapKeyIterator_T(current, begin, end, seq); @@ -130,7 +130,7 @@ template - inline PySwigIterator* + inline SwigPyIterator* make_output_value_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, octave_value seq = 0) { return new OctMapValueIterator_T(current, begin, end, seq); diff --git a/Lib/python/pyclasses.swg b/Lib/python/pyclasses.swg index 0caecd697..65f6dec47 100644 --- a/Lib/python/pyclasses.swg +++ b/Lib/python/pyclasses.swg @@ -1,55 +1,55 @@ #ifdef __cplusplus /* - PyObject_ptr is used as a replacement of PyObject *, where + SwigPtr_PyObject is used as a replacement of PyObject *, where the INCREF/DECREF are applied as needed. - You can use PyObject_ptr in a container, such as + You can use SwigPtr_PyObject in a container, such as - std::vector; + std::vector; or as a member variable: struct A { - PyObject_ptr obj; + SwigPtr_PyObject obj; A(PyObject *o) : _obj(o) { } }; or as a input/output value - PyObject_ptr func(PyObject_ptr obj) { - PyObject_ptr out = PyString_FromFormat("hello %s", PyObject_AsString(obj)); + SwigPtr_PyObject func(SwigPtr_PyObject obj) { + SwigPtr_PyObject out = PyString_FromFormat("hello %s", PyObject_AsString(obj)); Py_DECREF(out); return out; } just remember to pair the object creation with the proper DECREF, - the same as with plain PyObject *ptr, since PyObject_ptr always add + the same as with plain PyObject *ptr, since SwigPtr_PyObject always add one reference at construction. - PyObject_ptr is 'visible' at the wrapped side, so you can do: + SwigPtr_PyObject is 'visible' at the wrapped side, so you can do: - %template(pyvector) std::vector; + %template(pyvector) std::vector; and all the proper typemaps will be used. */ namespace swig { - %ignore PyObject_ptr; - struct PyObject_ptr {}; - %apply PyObject * {PyObject_ptr}; - %apply PyObject * const& {PyObject_ptr const&}; + %ignore SwigPtr_PyObject; + struct SwigPtr_PyObject {}; + %apply PyObject * {SwigPtr_PyObject}; + %apply PyObject * const& {SwigPtr_PyObject const&}; /* For output */ - %typemap(out,noblock=1) PyObject_ptr { + %typemap(out,noblock=1) SwigPtr_PyObject { $result = (PyObject *)$1; Py_INCREF($result); } - %typemap(out,noblock=1) PyObject_ptr const & { + %typemap(out,noblock=1) SwigPtr_PyObject const & { $result = (PyObject *)*$1; Py_INCREF($result); } @@ -58,28 +58,28 @@ namespace swig { %{ namespace swig { - class PyObject_ptr { + class SwigPtr_PyObject { protected: PyObject *_obj; public: - PyObject_ptr() :_obj(0) + SwigPtr_PyObject() :_obj(0) { } - PyObject_ptr(const PyObject_ptr& item) : _obj(item._obj) + SwigPtr_PyObject(const SwigPtr_PyObject& item) : _obj(item._obj) { Py_XINCREF(_obj); } - PyObject_ptr(PyObject *obj, bool initial_ref = true) :_obj(obj) + SwigPtr_PyObject(PyObject *obj, bool initial_ref = true) :_obj(obj) { if (initial_ref) { Py_XINCREF(_obj); } } - PyObject_ptr & operator=(const PyObject_ptr& item) + SwigPtr_PyObject & operator=(const SwigPtr_PyObject& item) { Py_XINCREF(item._obj); Py_XDECREF(_obj); @@ -87,7 +87,7 @@ namespace swig { return *this; } - ~PyObject_ptr() + ~SwigPtr_PyObject() { Py_XDECREF(_obj); } @@ -106,33 +106,33 @@ namespace swig { %} /* - PyObject_var is used to manage 'in the scope' PyObject * variables, + SwigVar_PyObject is used to manage 'in the scope' PyObject * variables, as in int func () { - PyObject_var obj = PyString_FromString("hello"); + SwigVar_PyObject obj = PyString_FromString("hello"); } ie, 'obj' is created and destructed in the same scope from a python object that carries at least one reference value. - PyObject_var just take care of applying the proper Py_DECREF. + SwigVar_PyObject just take care of applying the proper Py_DECREF. Hence, this class is purely internal and not visible at the wrapped side. */ namespace swig { - %ignore PyObject_var; - struct PyObject_var {}; - %apply PyObject * {PyObject_var}; - %apply PyObject * const& {PyObject_var const&}; + %ignore SwigVar_PyObject; + struct SwigVar_PyObject {}; + %apply PyObject * {SwigVar_PyObject}; + %apply PyObject * const& {SwigVar_PyObject const&}; } %{ namespace swig { - struct PyObject_var : PyObject_ptr { - PyObject_var(PyObject* obj = 0) : PyObject_ptr(obj, false) { } + struct SwigVar_PyObject : SwigPtr_PyObject { + SwigVar_PyObject(PyObject* obj = 0) : SwigPtr_PyObject(obj, false) { } - PyObject_var & operator = (PyObject* obj) + SwigVar_PyObject & operator = (PyObject* obj) { Py_XDECREF(_obj); _obj = obj; diff --git a/Lib/python/pycontainer.swg b/Lib/python/pycontainer.swg index 58442ef76..5f09357f8 100644 --- a/Lib/python/pycontainer.swg +++ b/Lib/python/pycontainer.swg @@ -36,15 +36,15 @@ %include -%fragment(SWIG_Traits_frag(swig::PyObject_ptr),"header",fragment="StdTraits") { +%fragment(SWIG_Traits_frag(swig::SwigPtr_PyObject),"header",fragment="StdTraits") { namespace swig { - template <> struct traits { + template <> struct traits { typedef value_category category; - static const char* type_name() { return "PyObject_ptr"; } + static const char* type_name() { return "SwigPtr_PyObject"; } }; - template <> struct traits_from { - typedef PyObject_ptr value_type; + template <> struct traits_from { + typedef SwigPtr_PyObject value_type; static PyObject *from(const value_type& val) { PyObject *obj = static_cast(val); Py_XINCREF(obj); @@ -53,14 +53,14 @@ namespace swig { }; template <> - struct traits_check { - static bool check(PyObject_ptr) { + struct traits_check { + static bool check(SwigPtr_PyObject) { return true; } }; - template <> struct traits_asval { - typedef PyObject_ptr value_type; + template <> struct traits_asval { + typedef SwigPtr_PyObject value_type; static int asval(PyObject *obj, value_type *val) { if (val) *val = obj; return SWIG_OK; @@ -69,15 +69,15 @@ namespace swig { } } -%fragment(SWIG_Traits_frag(swig::PyObject_var),"header",fragment="StdTraits") { +%fragment(SWIG_Traits_frag(swig::SwigVar_PyObject),"header",fragment="StdTraits") { namespace swig { - template <> struct traits { + template <> struct traits { typedef value_category category; - static const char* type_name() { return "PyObject_var"; } + static const char* type_name() { return "SwigVar_PyObject"; } }; - template <> struct traits_from { - typedef PyObject_var value_type; + template <> struct traits_from { + typedef SwigVar_PyObject value_type; static PyObject *from(const value_type& val) { PyObject *obj = static_cast(val); Py_XINCREF(obj); @@ -86,14 +86,14 @@ namespace swig { }; template <> - struct traits_check { - static bool check(PyObject_var) { + struct traits_check { + static bool check(SwigVar_PyObject) { return true; } }; - template <> struct traits_asval { - typedef PyObject_var value_type; + template <> struct traits_asval { + typedef SwigVar_PyObject value_type; static int asval(PyObject *obj, value_type *val) { if (val) *val = obj; return SWIG_OK; @@ -102,7 +102,7 @@ namespace swig { } } -%fragment("PySequence_Base","header") +%fragment("SwigPySequence_Base","header") { %#include @@ -133,20 +133,20 @@ namespace std { }; template <> - struct less : public binary_function + struct less : public binary_function { bool - operator()(const swig::PyObject_ptr& v, const swig::PyObject_ptr& w) const + operator()(const swig::SwigPtr_PyObject& v, const swig::SwigPtr_PyObject& w) const { return std::less()(v, w); } }; template <> - struct less : public binary_function + struct less : public binary_function { bool - operator()(const swig::PyObject_var& v, const swig::PyObject_var& w) const + operator()(const swig::SwigVar_PyObject& v, const swig::SwigVar_PyObject& w) const { return std::less()(v, w); } @@ -288,24 +288,24 @@ namespace swig { } } -%fragment("PySequence_Cont","header", +%fragment("SwigPySequence_Cont","header", fragment="StdTraits", - fragment="PySequence_Base", - fragment="PySwigIterator_T") + fragment="SwigPySequence_Base", + fragment="SwigPyIterator_T") { namespace swig { template - struct PySequence_Ref + struct SwigPySequence_Ref { - PySequence_Ref(PyObject* seq, int index) + SwigPySequence_Ref(PyObject* seq, int index) : _seq(seq), _index(index) { } operator T () const { - swig::PyObject_var item = PySequence_GetItem(_seq, _index); + swig::SwigVar_PyObject item = PySequence_GetItem(_seq, _index); try { return swig::as(item, true); } catch (std::exception& e) { @@ -320,7 +320,7 @@ namespace swig } } - PySequence_Ref& operator=(const T& v) + SwigPySequence_Ref& operator=(const T& v) { PySequence_SetItem(_seq, _index, swig::from(v)); return *this; @@ -332,18 +332,18 @@ namespace swig }; template - struct PySequence_ArrowProxy + struct SwigPySequence_ArrowProxy { - PySequence_ArrowProxy(const T& x): m_value(x) {} + SwigPySequence_ArrowProxy(const T& x): m_value(x) {} const T* operator->() const { return &m_value; } operator const T*() const { return &m_value; } T m_value; }; template - struct PySequence_InputIterator + struct SwigPySequence_InputIterator { - typedef PySequence_InputIterator self; + typedef SwigPySequence_InputIterator self; typedef std::random_access_iterator_tag iterator_category; typedef Reference reference; @@ -351,11 +351,11 @@ namespace swig typedef T* pointer; typedef int difference_type; - PySequence_InputIterator() + SwigPySequence_InputIterator() { } - PySequence_InputIterator(PyObject* seq, int index) + SwigPySequence_InputIterator(PyObject* seq, int index) : _seq(seq), _index(index) { } @@ -365,9 +365,9 @@ namespace swig return reference(_seq, _index); } - PySequence_ArrowProxy + SwigPySequence_ArrowProxy operator->() const { - return PySequence_ArrowProxy(operator*()); + return SwigPySequence_ArrowProxy(operator*()); } bool operator==(const self& ri) const @@ -436,19 +436,19 @@ namespace swig }; template - struct PySequence_Cont + struct SwigPySequence_Cont { - typedef PySequence_Ref reference; - typedef const PySequence_Ref const_reference; + typedef SwigPySequence_Ref reference; + typedef const SwigPySequence_Ref const_reference; typedef T value_type; typedef T* pointer; typedef int difference_type; typedef int size_type; typedef const pointer const_pointer; - typedef PySequence_InputIterator iterator; - typedef PySequence_InputIterator const_iterator; + typedef SwigPySequence_InputIterator iterator; + typedef SwigPySequence_InputIterator const_iterator; - PySequence_Cont(PyObject* seq) : _seq(0) + SwigPySequence_Cont(PyObject* seq) : _seq(0) { if (!PySequence_Check(seq)) { throw std::invalid_argument("a sequence is expected"); @@ -457,7 +457,7 @@ namespace swig Py_INCREF(_seq); } - ~PySequence_Cont() + ~SwigPySequence_Cont() { Py_XDECREF(_seq); } @@ -506,7 +506,7 @@ namespace swig { int s = size(); for (int i = 0; i < s; ++i) { - swig::PyObject_var item = PySequence_GetItem(_seq, i); + swig::SwigVar_PyObject item = PySequence_GetItem(_seq, i); if (!swig::check(item)) { if (set_err) { char msg[1024]; @@ -533,40 +533,40 @@ namespace swig class const_iterator; class const_reverse_iterator; - %typemap(out,noblock=1,fragment="PySequence_Cont") + %typemap(out,noblock=1,fragment="SwigPySequence_Cont") iterator, reverse_iterator, const_iterator, const_reverse_iterator { $result = SWIG_NewPointerObj(swig::make_output_iterator(%static_cast($1,const $type &)), - swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN); + swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN); } - %typemap(out,noblock=1,fragment="PySequence_Cont") + %typemap(out,noblock=1,fragment="SwigPySequence_Cont") std::pair, std::pair { $result = PyTuple_New(2); PyTuple_SetItem($result,0,SWIG_NewPointerObj(swig::make_output_iterator(%static_cast($1,const $type &).first), - swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN)); + swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN)); PyTuple_SetItem($result,1,SWIG_NewPointerObj(swig::make_output_iterator(%static_cast($1,const $type &).second), - swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN)); + swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN)); } - %fragment("PyPairBoolOutputIterator","header",fragment=SWIG_From_frag(bool),fragment="PySequence_Cont") {} + %fragment("SwigPyPairBoolOutputIterator","header",fragment=SWIG_From_frag(bool),fragment="SwigPySequence_Cont") {} - %typemap(out,noblock=1,fragment="PyPairBoolOutputIterator") + %typemap(out,noblock=1,fragment="SwigPyPairBoolOutputIterator") std::pair, std::pair { $result = PyTuple_New(2); PyTuple_SetItem($result,0,SWIG_NewPointerObj(swig::make_output_iterator(%static_cast($1,const $type &).first), - swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN)); + swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN)); PyTuple_SetItem($result,1,SWIG_From(bool)(%static_cast($1,const $type &).second)); } - %typemap(in,noblock=1,fragment="PySequence_Cont") - iterator(swig::PySwigIterator *iter = 0, int res), - reverse_iterator(swig::PySwigIterator *iter = 0, int res), - const_iterator(swig::PySwigIterator *iter = 0, int res), - const_reverse_iterator(swig::PySwigIterator *iter = 0, int res) { - res = SWIG_ConvertPtr($input, %as_voidptrptr(&iter), swig::PySwigIterator::descriptor(), 0); + %typemap(in,noblock=1,fragment="SwigPySequence_Cont") + iterator(swig::SwigPyIterator *iter = 0, int res), + reverse_iterator(swig::SwigPyIterator *iter = 0, int res), + const_iterator(swig::SwigPyIterator *iter = 0, int res), + const_reverse_iterator(swig::SwigPyIterator *iter = 0, int res) { + res = SWIG_ConvertPtr($input, %as_voidptrptr(&iter), swig::SwigPyIterator::descriptor(), 0); if (!SWIG_IsOK(res) || !iter) { %argument_fail(SWIG_TypeError, "$type", $symname, $argnum); } else { - swig::PySwigIterator_T<$type > *iter_t = dynamic_cast *>(iter); + swig::SwigPyIterator_T<$type > *iter_t = dynamic_cast *>(iter); if (iter_t) { $1 = iter_t->get_current(); } else { @@ -575,18 +575,18 @@ namespace swig } } - %typecheck(%checkcode(ITERATOR),noblock=1,fragment="PySequence_Cont") + %typecheck(%checkcode(ITERATOR),noblock=1,fragment="SwigPySequence_Cont") iterator, reverse_iterator, const_iterator, const_reverse_iterator { - swig::PySwigIterator *iter = 0; - int res = SWIG_ConvertPtr($input, %as_voidptrptr(&iter), swig::PySwigIterator::descriptor(), 0); - $1 = (SWIG_IsOK(res) && iter && (dynamic_cast *>(iter) != 0)); + swig::SwigPyIterator *iter = 0; + int res = SWIG_ConvertPtr($input, %as_voidptrptr(&iter), swig::SwigPyIterator::descriptor(), 0); + $1 = (SWIG_IsOK(res) && iter && (dynamic_cast *>(iter) != 0)); } - %fragment("PySequence_Cont"); + %fragment("SwigPySequence_Cont"); %newobject iterator(PyObject **PYTHON_SELF); %extend { - swig::PySwigIterator* iterator(PyObject **PYTHON_SELF) { + swig::SwigPyIterator* iterator(PyObject **PYTHON_SELF) { return swig::make_output_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF); } @@ -623,7 +623,7 @@ namespace swig %swig_sequence_iterator(%arg(Sequence)) %swig_container_methods(%arg(Sequence)) - %fragment("PySequence_Base"); + %fragment("SwigPySequence_Base"); %extend { value_type pop() throw (std::out_of_range) { @@ -740,16 +740,16 @@ namespace swig %fragment("StdSequenceTraits","header", fragment="StdTraits", - fragment="PySequence_Cont") + fragment="SwigPySequence_Cont") { namespace swig { - template + template inline void - assign(const PySeq& pyseq, Seq* seq) { - // seq->assign(pyseq.begin(), pyseq.end()); // not used as not always implemented - typedef typename PySeq::value_type value_type; - typename PySeq::const_iterator it = pyseq.begin(); - for (;it != pyseq.end(); ++it) { + assign(const SwigPySeq& swigpyseq, Seq* seq) { + // seq->assign(swigpyseq.begin(), swigpyseq.end()); // not used as not always implemented + typedef typename SwigPySeq::value_type value_type; + typename SwigPySeq::const_iterator it = swigpyseq.begin(); + for (;it != swigpyseq.end(); ++it) { seq->insert(seq->end(),(value_type)(*it)); } } @@ -769,14 +769,14 @@ namespace swig { } } else if (PySequence_Check(obj)) { try { - PySequence_Cont pyseq(obj); + SwigPySequence_Cont swigpyseq(obj); if (seq) { sequence *pseq = new sequence(); - assign(pyseq, pseq); + assign(swigpyseq, pseq); *seq = pseq; return SWIG_NEWOBJ; } else { - return pyseq.check() ? SWIG_OK : SWIG_ERROR; + return swigpyseq.check() ? SWIG_OK : SWIG_ERROR; } } catch (std::exception& e) { if (seq) { diff --git a/Lib/python/pyiterators.swg b/Lib/python/pyiterators.swg index 62a7eaf70..9cd795d7c 100644 --- a/Lib/python/pyiterators.swg +++ b/Lib/python/pyiterators.swg @@ -6,56 +6,56 @@ * * Implement a python 'output' iterator for Python 2.2 or higher. * - * Users can derive form the PySwigIterator to implement their + * Users can derive form the SwigPyIterator to implement their * own iterators. As an example (real one since we use it for STL/STD - * containers), the template PySwigIterator_T does the + * containers), the template SwigPyIterator_T does the * implementation for genereic C++ iterators. * ----------------------------------------------------------------------------- */ %include -%fragment("PySwigIterator","header") { +%fragment("SwigPyIterator","header") { namespace swig { struct stop_iteration { }; - struct PySwigIterator { + struct SwigPyIterator { private: - PyObject_ptr _seq; + SwigPtr_PyObject _seq; protected: - PySwigIterator(PyObject *seq) : _seq(seq) + SwigPyIterator(PyObject *seq) : _seq(seq) { } public: - virtual ~PySwigIterator() {} + virtual ~SwigPyIterator() {} // Access iterator method, required by Python virtual PyObject *value() const = 0; // Forward iterator method, required by Python - virtual PySwigIterator *incr(size_t n = 1) = 0; + virtual SwigPyIterator *incr(size_t n = 1) = 0; // Backward iterator method, very common in C++, but not required in Python - virtual PySwigIterator *decr(size_t /*n*/ = 1) + virtual SwigPyIterator *decr(size_t /*n*/ = 1) { throw stop_iteration(); } // Random access iterator methods, but not required in Python - virtual ptrdiff_t distance(const PySwigIterator &/*x*/) const + virtual ptrdiff_t distance(const SwigPyIterator &/*x*/) const { throw std::invalid_argument("operation not supported"); } - virtual bool equal (const PySwigIterator &/*x*/) const + virtual bool equal (const SwigPyIterator &/*x*/) const { throw std::invalid_argument("operation not supported"); } // C++ common/needed methods - virtual PySwigIterator *copy() const = 0; + virtual SwigPyIterator *copy() const = 0; PyObject *next() { @@ -81,42 +81,42 @@ namespace swig { return obj; } - PySwigIterator *advance(ptrdiff_t n) + SwigPyIterator *advance(ptrdiff_t n) { return (n > 0) ? incr(n) : decr(-n); } - bool operator == (const PySwigIterator& x) const + bool operator == (const SwigPyIterator& x) const { return equal(x); } - bool operator != (const PySwigIterator& x) const + bool operator != (const SwigPyIterator& x) const { return ! operator==(x); } - PySwigIterator& operator += (ptrdiff_t n) + SwigPyIterator& operator += (ptrdiff_t n) { return *advance(n); } - PySwigIterator& operator -= (ptrdiff_t n) + SwigPyIterator& operator -= (ptrdiff_t n) { return *advance(-n); } - PySwigIterator* operator + (ptrdiff_t n) const + SwigPyIterator* operator + (ptrdiff_t n) const { return copy()->advance(n); } - PySwigIterator* operator - (ptrdiff_t n) const + SwigPyIterator* operator - (ptrdiff_t n) const { return copy()->advance(-n); } - ptrdiff_t operator - (const PySwigIterator& x) const + ptrdiff_t operator - (const SwigPyIterator& x) const { return x.distance(*this); } @@ -125,7 +125,7 @@ namespace swig { static int init = 0; static swig_type_info* desc = 0; if (!init) { - desc = SWIG_TypeQuery("swig::PySwigIterator *"); + desc = SWIG_TypeQuery("swig::SwigPyIterator *"); init = 1; } return desc; @@ -134,18 +134,18 @@ namespace swig { } } -%fragment("PySwigIterator_T","header",fragment="PySwigIterator",fragment="StdTraits",fragment="StdIteratorTraits") { +%fragment("SwigPyIterator_T","header",fragment="SwigPyIterator",fragment="StdTraits",fragment="StdIteratorTraits") { namespace swig { template - class PySwigIterator_T : public PySwigIterator + class SwigPyIterator_T : public SwigPyIterator { public: typedef OutIterator out_iterator; typedef typename std::iterator_traits::value_type value_type; - typedef PySwigIterator_T self_type; + typedef SwigPyIterator_T self_type; - PySwigIterator_T(out_iterator curr, PyObject *seq) - : PySwigIterator(seq), current(curr) + SwigPyIterator_T(out_iterator curr, PyObject *seq) + : SwigPyIterator(seq), current(curr) { } @@ -155,7 +155,7 @@ namespace swig { } - bool equal (const PySwigIterator &iter) const + bool equal (const SwigPyIterator &iter) const { const self_type *iters = dynamic_cast(&iter); if (iters) { @@ -165,7 +165,7 @@ namespace swig { } } - ptrdiff_t distance(const PySwigIterator &iter) const + ptrdiff_t distance(const SwigPyIterator &iter) const { const self_type *iters = dynamic_cast(&iter); if (iters) { @@ -193,17 +193,17 @@ namespace swig { template::value_type, typename FromOper = from_oper > - class PySwigIteratorOpen_T : public PySwigIterator_T + class SwigPyIteratorOpen_T : public SwigPyIterator_T { public: FromOper from; typedef OutIterator out_iterator; typedef ValueType value_type; - typedef PySwigIterator_T base; - typedef PySwigIteratorOpen_T self_type; + typedef SwigPyIterator_T base; + typedef SwigPyIteratorOpen_T self_type; - PySwigIteratorOpen_T(out_iterator curr, PyObject *seq) - : PySwigIterator_T(curr, seq) + SwigPyIteratorOpen_T(out_iterator curr, PyObject *seq) + : SwigPyIterator_T(curr, seq) { } @@ -211,12 +211,12 @@ namespace swig { return from(static_cast(*(base::current))); } - PySwigIterator *copy() const + SwigPyIterator *copy() const { return new self_type(*this); } - PySwigIterator *incr(size_t n = 1) + SwigPyIterator *incr(size_t n = 1) { while (n--) { ++base::current; @@ -224,7 +224,7 @@ namespace swig { return this; } - PySwigIterator *decr(size_t n = 1) + SwigPyIterator *decr(size_t n = 1) { while (n--) { --base::current; @@ -236,17 +236,17 @@ namespace swig { template::value_type, typename FromOper = from_oper > - class PySwigIteratorClosed_T : public PySwigIterator_T + class SwigPyIteratorClosed_T : public SwigPyIterator_T { public: FromOper from; typedef OutIterator out_iterator; typedef ValueType value_type; - typedef PySwigIterator_T base; - typedef PySwigIteratorClosed_T self_type; + typedef SwigPyIterator_T base; + typedef SwigPyIteratorClosed_T self_type; - PySwigIteratorClosed_T(out_iterator curr, out_iterator first, out_iterator last, PyObject *seq) - : PySwigIterator_T(curr, seq), begin(first), end(last) + SwigPyIteratorClosed_T(out_iterator curr, out_iterator first, out_iterator last, PyObject *seq) + : SwigPyIterator_T(curr, seq), begin(first), end(last) { } @@ -258,12 +258,12 @@ namespace swig { } } - PySwigIterator *copy() const + SwigPyIterator *copy() const { return new self_type(*this); } - PySwigIterator *incr(size_t n = 1) + SwigPyIterator *incr(size_t n = 1) { while (n--) { if (base::current == end) { @@ -275,7 +275,7 @@ namespace swig { return this; } - PySwigIterator *decr(size_t n = 1) + SwigPyIterator *decr(size_t n = 1) { while (n--) { if (base::current == begin) { @@ -293,23 +293,23 @@ namespace swig { }; template - inline PySwigIterator* + inline SwigPyIterator* make_output_iterator(const OutIter& current, const OutIter& begin,const OutIter& end, PyObject *seq = 0) { - return new PySwigIteratorClosed_T(current, begin, end, seq); + return new SwigPyIteratorClosed_T(current, begin, end, seq); } template - inline PySwigIterator* + inline SwigPyIterator* make_output_iterator(const OutIter& current, PyObject *seq = 0) { - return new PySwigIteratorOpen_T(current, seq); + return new SwigPyIteratorOpen_T(current, seq); } } } -%fragment("PySwigIterator"); +%fragment("SwigPyIterator"); namespace swig { /* @@ -327,67 +327,67 @@ namespace swig /* Mark methods that return new objects */ - %newobject PySwigIterator::copy; - %newobject PySwigIterator::operator + (ptrdiff_t n) const; - %newobject PySwigIterator::operator - (ptrdiff_t n) const; + %newobject SwigPyIterator::copy; + %newobject SwigPyIterator::operator + (ptrdiff_t n) const; + %newobject SwigPyIterator::operator - (ptrdiff_t n) const; - %nodirector PySwigIterator; - %extend PySwigIterator { + %nodirector SwigPyIterator; + %extend SwigPyIterator { %pythoncode {def __iter__(self): return self} } - %catches(swig::stop_iteration) PySwigIterator::value() const; - %catches(swig::stop_iteration) PySwigIterator::incr(size_t n = 1); - %catches(swig::stop_iteration) PySwigIterator::decr(size_t n = 1); - %catches(std::invalid_argument) PySwigIterator::distance(const PySwigIterator &x) const; - %catches(std::invalid_argument) PySwigIterator::equal (const PySwigIterator &x) const; - %catches(swig::stop_iteration) PySwigIterator::__next__(); - %catches(swig::stop_iteration) PySwigIterator::next(); - %catches(swig::stop_iteration) PySwigIterator::previous(); - %catches(swig::stop_iteration) PySwigIterator::advance(ptrdiff_t n); - %catches(swig::stop_iteration) PySwigIterator::operator += (ptrdiff_t n); - %catches(swig::stop_iteration) PySwigIterator::operator -= (ptrdiff_t n); - %catches(swig::stop_iteration) PySwigIterator::operator + (ptrdiff_t n) const; - %catches(swig::stop_iteration) PySwigIterator::operator - (ptrdiff_t n) const; + %catches(swig::stop_iteration) SwigPyIterator::value() const; + %catches(swig::stop_iteration) SwigPyIterator::incr(size_t n = 1); + %catches(swig::stop_iteration) SwigPyIterator::decr(size_t n = 1); + %catches(std::invalid_argument) SwigPyIterator::distance(const SwigPyIterator &x) const; + %catches(std::invalid_argument) SwigPyIterator::equal (const SwigPyIterator &x) const; + %catches(swig::stop_iteration) SwigPyIterator::__next__(); + %catches(swig::stop_iteration) SwigPyIterator::next(); + %catches(swig::stop_iteration) SwigPyIterator::previous(); + %catches(swig::stop_iteration) SwigPyIterator::advance(ptrdiff_t n); + %catches(swig::stop_iteration) SwigPyIterator::operator += (ptrdiff_t n); + %catches(swig::stop_iteration) SwigPyIterator::operator -= (ptrdiff_t n); + %catches(swig::stop_iteration) SwigPyIterator::operator + (ptrdiff_t n) const; + %catches(swig::stop_iteration) SwigPyIterator::operator - (ptrdiff_t n) const; - struct PySwigIterator + struct SwigPyIterator { protected: - PySwigIterator(PyObject *seq); + SwigPyIterator(PyObject *seq); public: - virtual ~PySwigIterator(); + virtual ~SwigPyIterator(); // Access iterator method, required by Python virtual PyObject *value() const = 0; // Forward iterator method, required by Python - virtual PySwigIterator *incr(size_t n = 1) = 0; + virtual SwigPyIterator *incr(size_t n = 1) = 0; // Backward iterator method, very common in C++, but not required in Python - virtual PySwigIterator *decr(size_t n = 1); + virtual SwigPyIterator *decr(size_t n = 1); // Random access iterator methods, but not required in Python - virtual ptrdiff_t distance(const PySwigIterator &x) const; + virtual ptrdiff_t distance(const SwigPyIterator &x) const; - virtual bool equal (const PySwigIterator &x) const; + virtual bool equal (const SwigPyIterator &x) const; // C++ common/needed methods - virtual PySwigIterator *copy() const = 0; + virtual SwigPyIterator *copy() const = 0; PyObject *next(); PyObject *__next__(); PyObject *previous(); - PySwigIterator *advance(ptrdiff_t n); + SwigPyIterator *advance(ptrdiff_t n); - bool operator == (const PySwigIterator& x) const; - bool operator != (const PySwigIterator& x) const; - PySwigIterator& operator += (ptrdiff_t n); - PySwigIterator& operator -= (ptrdiff_t n); - PySwigIterator* operator + (ptrdiff_t n) const; - PySwigIterator* operator - (ptrdiff_t n) const; - ptrdiff_t operator - (const PySwigIterator& x) const; + bool operator == (const SwigPyIterator& x) const; + bool operator != (const SwigPyIterator& x) const; + SwigPyIterator& operator += (ptrdiff_t n); + SwigPyIterator& operator -= (ptrdiff_t n); + SwigPyIterator* operator + (ptrdiff_t n) const; + SwigPyIterator* operator - (ptrdiff_t n) const; + ptrdiff_t operator - (const SwigPyIterator& x) const; }; } diff --git a/Lib/python/pyname_compat.i b/Lib/python/pyname_compat.i new file mode 100644 index 000000000..cdda38f80 --- /dev/null +++ b/Lib/python/pyname_compat.i @@ -0,0 +1,88 @@ +/* +* From SWIG 1.3.37 we deprecated all SWIG symbols that start with Py, +* since they are inappropriate and discouraged in Python documentation +* (from http://www.python.org/doc/2.5.2/api/includes.html): +* +* "All user visible names defined by Python.h (except those defined by the included +* standard headers) have one of the prefixes "Py" or "_Py". Names beginning with +* "_Py" are for internal use by the Python implementation and should not be used +* by extension writers. Structure member names do not have a reserved prefix. +* +* Important: user code should never define names that begin with "Py" or "_Py". +* This confuses the reader, and jeopardizes the portability of the user code to +* future Python versions, which may define additional names beginning with one +* of these prefixes." +* +* This file defined macros to provide backward compatibility for these deprecated +* symbols. In the case you have these symbols in your interface file, you can simply +* include this file at begining of it. +* +* However, this file may be removed in future release of SWIG, so using this file to +* keep these inappropriate names in your SWIG interface file is also not recommanded. +* Instead, we provide a simple tool for converting your interface files to +* the new naming convention. You can download the tool here: +* https://swig.svn.sourceforge.net/svnroot/swig/trunk/Tools/pyname_patch.py +*/ + +%fragment("PySequence_Base", "header", fragment="SwigPySequence_Base") {} +%fragment("PySequence_Cont", "header", fragment="SwigPySequence_Cont") {} +%fragment("PySwigIterator_T", "header", fragment="SwigPyIterator_T") {} +%fragment("PyPairBoolOutputIterator", "header", fragment="SwigPyPairBoolOutputIterator") {} +%fragment("PySwigIterator", "header", fragment="SwigPyIterator") {} +%fragment("PySwigIterator_T", "header", fragment="SwigPyIterator_T") {} + +%inline %{ +#define PyMapIterator_T SwigPyMapIterator_T +#define PyMapKeyIterator_T SwigPyMapKeyIterator_T +#define PyMapValueIterator_T SwigPyMapValueITerator_T +#define PyObject_ptr SwigPtr_PyObject +#define PyObject_var SwigVar_PyObject +#define PyOper SwigPyOper +#define PySeq SwigPySeq +#define PySequence_ArrowProxy SwigPySequence_ArrowProxy +#define PySequence_Cont SwigPySequence_Cont +#define PySequence_InputIterator SwigPySequence_InputIterator +#define PySequence_Ref SwigPySequence_Ref +#define PySwigClientData SwigPyClientData +#define PySwigClientData_Del SwigPyClientData_Del +#define PySwigClientData_New SwigPyClientData_New +#define PySwigIterator SwigPyIterator +#define PySwigIteratorClosed_T SwigPyIteratorClosed_T +#define PySwigIteratorOpen_T SwigPyIteratorOpen_T +#define PySwigIterator_T SwigPyIterator_T +#define PySwigObject SwigPyObject +#define PySwigObject_Check SwigPyObject_Check +#define PySwigObject_GetDesc SwigPyObject_GetDesc +#define PySwigObject_New SwigPyObject_New +#define PySwigObject_acquire SwigPyObject_acquire +#define PySwigObject_append SwigPyObject_append +#define PySwigObject_as_number SwigPyObject_as_number +#define PySwigObject_compare SwigPyObject_compare +#define PySwigObject_dealloc SwigPyObject_dealloc +#define PySwigObject_disown SwigPyObject_disown +#define PySwigObject_format SwigPyObject_format +#define PySwigObject_getattr SwigPyObject_getattr +#define PySwigObject_hex SwigPyObject_hex +#define PySwigObject_long SwigPyObject_long +#define PySwigObject_next SwigPyObject_next +#define PySwigObject_oct SwigPyObject_oct +#define PySwigObject_own SwigPyObject_own +#define PySwigObject_print SwigPyObject_print +#define PySwigObject_repr SwigPyObject_repr +#define PySwigObject_richcompare SwigPyObject_richcompare +#define PySwigObject_str SwigPyObject_str +#define PySwigObject_type SwigPyObject_type +#define PySwigPacked SwigPyPacked +#define PySwigPacked_Check SwigPyPacked_Check +#define PySwigPacked_New SwigPyPacked_New +#define PySwigPacked_UnpackData SwigPyPacked_UnpackData +#define PySwigPacked_compare SwigPyPacked_compare +#define PySwigPacked_dealloc SwigPyPacked_dealloc +#define PySwigPacked_print SwigPyPacked_print +#define PySwigPacked_repr SwigPyPacked_repr +#define PySwigPacked_str SwigPyPacked_str +#define PySwigPacked_type SwigPyPacked_type +#define pyseq swigpyseq +#define pyswigobject_type swigpyobject_type +#define pyswigpacked_type swigpypacked_type +%} diff --git a/Lib/python/pyopers.swg b/Lib/python/pyopers.swg index bd5c954f0..30775b84e 100644 --- a/Lib/python/pyopers.swg +++ b/Lib/python/pyopers.swg @@ -90,7 +90,7 @@ __bool__ = __nonzero__ */ -#define %pyinplaceoper(PyOper, Oper) %delobject Oper; %newobject Oper; %rename(PyOper) Oper +#define %pyinplaceoper(SwigPyOper, Oper) %delobject Oper; %newobject Oper; %rename(SwigPyOper) Oper %pyinplaceoper(__iadd__ , *::operator +=); %pyinplaceoper(__isub__ , *::operator -=); diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index 71759e414..cb1cde5ee 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -42,7 +42,7 @@ #define SWIG_GetModule(clientdata) SWIG_Python_GetModule() #define SWIG_SetModule(clientdata, pointer) SWIG_Python_SetModule(pointer) -#define SWIG_NewClientData(obj) PySwigClientData_New(obj) +#define SWIG_NewClientData(obj) SwigPyClientData_New(obj) #define SWIG_SetErrorObj SWIG_Python_SetErrorObj #define SWIG_SetErrorMsg SWIG_Python_SetErrorMsg @@ -238,7 +238,7 @@ SWIG_Py_Void(void) return none; } -/* PySwigClientData */ +/* SwigPyClientData */ typedef struct { PyObject *klass; @@ -247,30 +247,30 @@ typedef struct { PyObject *destroy; int delargs; int implicitconv; -} PySwigClientData; +} SwigPyClientData; SWIGRUNTIMEINLINE int SWIG_Python_CheckImplicit(swig_type_info *ty) { - PySwigClientData *data = (PySwigClientData *)ty->clientdata; + SwigPyClientData *data = (SwigPyClientData *)ty->clientdata; return data ? data->implicitconv : 0; } SWIGRUNTIMEINLINE PyObject * SWIG_Python_ExceptionType(swig_type_info *desc) { - PySwigClientData *data = desc ? (PySwigClientData *) desc->clientdata : 0; + SwigPyClientData *data = desc ? (SwigPyClientData *) desc->clientdata : 0; PyObject *klass = data ? data->klass : 0; return (klass ? klass : PyExc_RuntimeError); } -SWIGRUNTIME PySwigClientData * -PySwigClientData_New(PyObject* obj) +SWIGRUNTIME SwigPyClientData * +SwigPyClientData_New(PyObject* obj) { if (!obj) { return 0; } else { - PySwigClientData *data = (PySwigClientData *)malloc(sizeof(PySwigClientData)); + SwigPyClientData *data = (SwigPyClientData *)malloc(sizeof(SwigPyClientData)); /* the klass element */ data->klass = obj; Py_INCREF(data->klass); @@ -318,14 +318,14 @@ PySwigClientData_New(PyObject* obj) } SWIGRUNTIME void -PySwigClientData_Del(PySwigClientData* data) +SwigPyClientData_Del(SwigPyClientData* data) { Py_XDECREF(data->newraw); Py_XDECREF(data->newargs); Py_XDECREF(data->destroy); } -/* =============== PySwigObject =====================*/ +/* =============== SwigPyObject =====================*/ typedef struct { PyObject_HEAD @@ -333,21 +333,21 @@ typedef struct { swig_type_info *ty; int own; PyObject *next; -} PySwigObject; +} SwigPyObject; SWIGRUNTIME PyObject * -PySwigObject_long(PySwigObject *v) +SwigPyObject_long(SwigPyObject *v) { return PyLong_FromVoidPtr(v->ptr); } SWIGRUNTIME PyObject * -PySwigObject_format(const char* fmt, PySwigObject *v) +SwigPyObject_format(const char* fmt, SwigPyObject *v) { PyObject *res = NULL; PyObject *args = PyTuple_New(1); if (args) { - if (PyTuple_SetItem(args, 0, PySwigObject_long(v)) == 0) { + if (PyTuple_SetItem(args, 0, SwigPyObject_long(v)) == 0) { PyObject *ofmt = SWIG_Python_str_FromChar(fmt); if (ofmt) { #if PY_VERSION_HEX >= 0x03000000 @@ -364,33 +364,33 @@ PySwigObject_format(const char* fmt, PySwigObject *v) } SWIGRUNTIME PyObject * -PySwigObject_oct(PySwigObject *v) +SwigPyObject_oct(SwigPyObject *v) { - return PySwigObject_format("%o",v); + return SwigPyObject_format("%o",v); } SWIGRUNTIME PyObject * -PySwigObject_hex(PySwigObject *v) +SwigPyObject_hex(SwigPyObject *v) { - return PySwigObject_format("%x",v); + return SwigPyObject_format("%x",v); } SWIGRUNTIME PyObject * #ifdef METH_NOARGS -PySwigObject_repr(PySwigObject *v) +SwigPyObject_repr(SwigPyObject *v) #else -PySwigObject_repr(PySwigObject *v, PyObject *args) +SwigPyObject_repr(SwigPyObject *v, PyObject *args) #endif { const char *name = SWIG_TypePrettyName(v->ty); - PyObject *hex = PySwigObject_hex(v); + PyObject *hex = SwigPyObject_hex(v); PyObject *repr = SWIG_Python_str_FromFormat("", name, hex); Py_DECREF(hex); if (v->next) { #ifdef METH_NOARGS - PyObject *nrep = PySwigObject_repr((PySwigObject *)v->next); + PyObject *nrep = SwigPyObject_repr((SwigPyObject *)v->next); #else - PyObject *nrep = PySwigObject_repr((PySwigObject *)v->next, args); + PyObject *nrep = SwigPyObject_repr((SwigPyObject *)v->next, args); #endif #if PY_VERSION_HEX >= 0x03000000 PyObject *joined = PyUnicode_Concat(repr, nrep); @@ -405,12 +405,12 @@ PySwigObject_repr(PySwigObject *v, PyObject *args) } SWIGRUNTIME int -PySwigObject_print(PySwigObject *v, FILE *fp, int SWIGUNUSEDPARM(flags)) +SwigPyObject_print(SwigPyObject *v, FILE *fp, int SWIGUNUSEDPARM(flags)) { #ifdef METH_NOARGS - PyObject *repr = PySwigObject_repr(v); + PyObject *repr = SwigPyObject_repr(v); #else - PyObject *repr = PySwigObject_repr(v, NULL); + PyObject *repr = SwigPyObject_repr(v, NULL); #endif if (repr) { fputs(SWIG_Python_str_AsChar(repr), fp); @@ -422,7 +422,7 @@ PySwigObject_print(PySwigObject *v, FILE *fp, int SWIGUNUSEDPARM(flags)) } SWIGRUNTIME PyObject * -PySwigObject_str(PySwigObject *v) +SwigPyObject_str(SwigPyObject *v) { char result[SWIG_BUFFER_SIZE]; return SWIG_PackVoidPtr(result, v->ptr, v->ty->name, sizeof(result)) ? @@ -430,7 +430,7 @@ PySwigObject_str(PySwigObject *v) } SWIGRUNTIME int -PySwigObject_compare(PySwigObject *v, PySwigObject *w) +SwigPyObject_compare(SwigPyObject *v, SwigPyObject *w) { void *i = v->ptr; void *j = w->ptr; @@ -439,14 +439,14 @@ PySwigObject_compare(PySwigObject *v, PySwigObject *w) /* Added for Python 3.x, whould it also useful for Python 2.x? */ SWIGRUNTIME PyObject* -PySwigObject_richcompare(PySwigObject *v, PySwigObject *w, int op) +SwigPyObject_richcompare(SwigPyObject *v, SwigPyObject *w, int op) { PyObject* res; if( op != Py_EQ && op != Py_NE ) { Py_INCREF(Py_NotImplemented); return Py_NotImplemented; } - if( (PySwigObject_compare(v, w)==0) == (op == Py_EQ) ) + if( (SwigPyObject_compare(v, w)==0) == (op == Py_EQ) ) res = Py_True; else res = Py_False; @@ -458,35 +458,35 @@ PySwigObject_richcompare(PySwigObject *v, PySwigObject *w, int op) SWIGRUNTIME PyTypeObject* _PySwigObject_type(void); SWIGRUNTIME PyTypeObject* -PySwigObject_type(void) { +SwigPyObject_type(void) { static PyTypeObject *SWIG_STATIC_POINTER(type) = _PySwigObject_type(); return type; } SWIGRUNTIMEINLINE int -PySwigObject_Check(PyObject *op) { - return (Py_TYPE(op) == PySwigObject_type()) - || (strcmp(Py_TYPE(op)->tp_name,"PySwigObject") == 0); +SwigPyObject_Check(PyObject *op) { + return (Py_TYPE(op) == SwigPyObject_type()) + || (strcmp(Py_TYPE(op)->tp_name,"SwigPyObject") == 0); } SWIGRUNTIME PyObject * -PySwigObject_New(void *ptr, swig_type_info *ty, int own); +SwigPyObject_New(void *ptr, swig_type_info *ty, int own); SWIGRUNTIME void -PySwigObject_dealloc(PyObject *v) +SwigPyObject_dealloc(PyObject *v) { - PySwigObject *sobj = (PySwigObject *) v; + SwigPyObject *sobj = (SwigPyObject *) v; PyObject *next = sobj->next; if (sobj->own == SWIG_POINTER_OWN) { swig_type_info *ty = sobj->ty; - PySwigClientData *data = ty ? (PySwigClientData *) ty->clientdata : 0; + SwigPyClientData *data = ty ? (SwigPyClientData *) ty->clientdata : 0; PyObject *destroy = data ? data->destroy : 0; if (destroy) { /* destroy is always a VARARGS method */ PyObject *res; if (data->delargs) { /* we need to create a temporal object to carry the destroy operation */ - PyObject *tmp = PySwigObject_New(sobj->ptr, ty, 0); + PyObject *tmp = SwigPyObject_New(sobj->ptr, ty, 0); res = SWIG_Python_CallFunctor(destroy, tmp); Py_DECREF(tmp); } else { @@ -508,15 +508,15 @@ PySwigObject_dealloc(PyObject *v) } SWIGRUNTIME PyObject* -PySwigObject_append(PyObject* v, PyObject* next) +SwigPyObject_append(PyObject* v, PyObject* next) { - PySwigObject *sobj = (PySwigObject *) v; + SwigPyObject *sobj = (SwigPyObject *) v; #ifndef METH_O PyObject *tmp = 0; if (!PyArg_ParseTuple(next,(char *)"O:append", &tmp)) return NULL; next = tmp; #endif - if (!PySwigObject_Check(next)) { + if (!SwigPyObject_Check(next)) { return NULL; } sobj->next = next; @@ -526,12 +526,12 @@ PySwigObject_append(PyObject* v, PyObject* next) SWIGRUNTIME PyObject* #ifdef METH_NOARGS -PySwigObject_next(PyObject* v) +SwigPyObject_next(PyObject* v) #else -PySwigObject_next(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) +SwigPyObject_next(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) #endif { - PySwigObject *sobj = (PySwigObject *) v; + SwigPyObject *sobj = (SwigPyObject *) v; if (sobj->next) { Py_INCREF(sobj->next); return sobj->next; @@ -542,30 +542,30 @@ PySwigObject_next(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) SWIGINTERN PyObject* #ifdef METH_NOARGS -PySwigObject_disown(PyObject *v) +SwigPyObject_disown(PyObject *v) #else -PySwigObject_disown(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) +SwigPyObject_disown(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) #endif { - PySwigObject *sobj = (PySwigObject *)v; + SwigPyObject *sobj = (SwigPyObject *)v; sobj->own = 0; return SWIG_Py_Void(); } SWIGINTERN PyObject* #ifdef METH_NOARGS -PySwigObject_acquire(PyObject *v) +SwigPyObject_acquire(PyObject *v) #else -PySwigObject_acquire(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) +SwigPyObject_acquire(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) #endif { - PySwigObject *sobj = (PySwigObject *)v; + SwigPyObject *sobj = (SwigPyObject *)v; sobj->own = SWIG_POINTER_OWN; return SWIG_Py_Void(); } SWIGINTERN PyObject* -PySwigObject_own(PyObject *v, PyObject *args) +SwigPyObject_own(PyObject *v, PyObject *args) { PyObject *val = 0; #if (PY_VERSION_HEX < 0x02020000) @@ -578,20 +578,20 @@ PySwigObject_own(PyObject *v, PyObject *args) } else { - PySwigObject *sobj = (PySwigObject *)v; + SwigPyObject *sobj = (SwigPyObject *)v; PyObject *obj = PyBool_FromLong(sobj->own); if (val) { #ifdef METH_NOARGS if (PyObject_IsTrue(val)) { - PySwigObject_acquire(v); + SwigPyObject_acquire(v); } else { - PySwigObject_disown(v); + SwigPyObject_disown(v); } #else if (PyObject_IsTrue(val)) { - PySwigObject_acquire(v,args); + SwigPyObject_acquire(v,args); } else { - PySwigObject_disown(v,args); + SwigPyObject_disown(v,args); } #endif } @@ -602,30 +602,30 @@ PySwigObject_own(PyObject *v, PyObject *args) #ifdef METH_O static PyMethodDef swigobject_methods[] = { - {(char *)"disown", (PyCFunction)PySwigObject_disown, METH_NOARGS, (char *)"releases ownership of the pointer"}, - {(char *)"acquire", (PyCFunction)PySwigObject_acquire, METH_NOARGS, (char *)"aquires ownership of the pointer"}, - {(char *)"own", (PyCFunction)PySwigObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"}, - {(char *)"append", (PyCFunction)PySwigObject_append, METH_O, (char *)"appends another 'this' object"}, - {(char *)"next", (PyCFunction)PySwigObject_next, METH_NOARGS, (char *)"returns the next 'this' object"}, - {(char *)"__repr__",(PyCFunction)PySwigObject_repr, METH_NOARGS, (char *)"returns object representation"}, + {(char *)"disown", (PyCFunction)SwigPyObject_disown, METH_NOARGS, (char *)"releases ownership of the pointer"}, + {(char *)"acquire", (PyCFunction)SwigPyObject_acquire, METH_NOARGS, (char *)"aquires ownership of the pointer"}, + {(char *)"own", (PyCFunction)SwigPyObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"}, + {(char *)"append", (PyCFunction)SwigPyObject_append, METH_O, (char *)"appends another 'this' object"}, + {(char *)"next", (PyCFunction)SwigPyObject_next, METH_NOARGS, (char *)"returns the next 'this' object"}, + {(char *)"__repr__",(PyCFunction)SwigPyObject_repr, METH_NOARGS, (char *)"returns object representation"}, {0, 0, 0, 0} }; #else static PyMethodDef swigobject_methods[] = { - {(char *)"disown", (PyCFunction)PySwigObject_disown, METH_VARARGS, (char *)"releases ownership of the pointer"}, - {(char *)"acquire", (PyCFunction)PySwigObject_acquire, METH_VARARGS, (char *)"aquires ownership of the pointer"}, - {(char *)"own", (PyCFunction)PySwigObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"}, - {(char *)"append", (PyCFunction)PySwigObject_append, METH_VARARGS, (char *)"appends another 'this' object"}, - {(char *)"next", (PyCFunction)PySwigObject_next, METH_VARARGS, (char *)"returns the next 'this' object"}, - {(char *)"__repr__",(PyCFunction)PySwigObject_repr, METH_VARARGS, (char *)"returns object representation"}, + {(char *)"disown", (PyCFunction)SwigPyObject_disown, METH_VARARGS, (char *)"releases ownership of the pointer"}, + {(char *)"acquire", (PyCFunction)SwigPyObject_acquire, METH_VARARGS, (char *)"aquires ownership of the pointer"}, + {(char *)"own", (PyCFunction)SwigPyObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"}, + {(char *)"append", (PyCFunction)SwigPyObject_append, METH_VARARGS, (char *)"appends another 'this' object"}, + {(char *)"next", (PyCFunction)SwigPyObject_next, METH_VARARGS, (char *)"returns the next 'this' object"}, + {(char *)"__repr__",(PyCFunction)SwigPyObject_repr, METH_VARARGS, (char *)"returns object representation"}, {0, 0, 0, 0} }; #endif #if PY_VERSION_HEX < 0x02020000 SWIGINTERN PyObject * -PySwigObject_getattr(PySwigObject *sobj,char *name) +SwigPyObject_getattr(SwigPyObject *sobj,char *name) { return Py_FindMethod(swigobject_methods, (PyObject *)sobj, name); } @@ -635,7 +635,7 @@ SWIGRUNTIME PyTypeObject* _PySwigObject_type(void) { static char swigobject_doc[] = "Swig object carries a C/C++ instance pointer"; - static PyNumberMethods PySwigObject_as_number = { + static PyNumberMethods SwigPyObject_as_number = { (binaryfunc)0, /*nb_add*/ (binaryfunc)0, /*nb_subtract*/ (binaryfunc)0, /*nb_multiply*/ @@ -659,12 +659,12 @@ _PySwigObject_type(void) { #if PY_VERSION_HEX < 0x03000000 0, /*nb_coerce*/ #endif - (unaryfunc)PySwigObject_long, /*nb_int*/ - (unaryfunc)PySwigObject_long, /*nb_long*/ + (unaryfunc)SwigPyObject_long, /*nb_int*/ + (unaryfunc)SwigPyObject_long, /*nb_long*/ (unaryfunc)0, /*nb_float*/ #if PY_VERSION_HEX < 0x03000000 - (unaryfunc)PySwigObject_oct, /*nb_oct*/ - (unaryfunc)PySwigObject_hex, /*nb_hex*/ + (unaryfunc)SwigPyObject_oct, /*nb_oct*/ + (unaryfunc)SwigPyObject_hex, /*nb_hex*/ #endif #if PY_VERSION_HEX >= 0x03000000 /* 3.0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index, nb_inplace_divide removed */ @@ -677,7 +677,7 @@ _PySwigObject_type(void) { #endif }; - static PyTypeObject pyswigobject_type; + static PyTypeObject swigpyobject_type; static int type_init = 0; if (!type_init) { const PyTypeObject tmp @@ -689,25 +689,25 @@ _PySwigObject_type(void) { PyObject_HEAD_INIT(NULL) 0, /* ob_size */ #endif - (char *)"PySwigObject", /* tp_name */ - sizeof(PySwigObject), /* tp_basicsize */ + (char *)"SwigPyObject", /* tp_name */ + sizeof(SwigPyObject), /* tp_basicsize */ 0, /* tp_itemsize */ - (destructor)PySwigObject_dealloc, /* tp_dealloc */ - (printfunc)PySwigObject_print, /* tp_print */ + (destructor)SwigPyObject_dealloc, /* tp_dealloc */ + (printfunc)SwigPyObject_print, /* tp_print */ #if PY_VERSION_HEX < 0x02020000 - (getattrfunc)PySwigObject_getattr, /* tp_getattr */ + (getattrfunc)SwigPyObject_getattr, /* tp_getattr */ #else (getattrfunc)0, /* tp_getattr */ #endif (setattrfunc)0, /* tp_setattr */ - (cmpfunc)PySwigObject_compare, /* tp_compare */ - (reprfunc)PySwigObject_repr, /* tp_repr */ - &PySwigObject_as_number, /* tp_as_number */ + (cmpfunc)SwigPyObject_compare, /* tp_compare */ + (reprfunc)SwigPyObject_repr, /* tp_repr */ + &SwigPyObject_as_number, /* tp_as_number */ 0, /* tp_as_sequence */ 0, /* tp_as_mapping */ (hashfunc)0, /* tp_hash */ (ternaryfunc)0, /* tp_call */ - (reprfunc)PySwigObject_str, /* tp_str */ + (reprfunc)SwigPyObject_str, /* tp_str */ PyObject_GenericGetAttr, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ @@ -715,7 +715,7 @@ _PySwigObject_type(void) { swigobject_doc, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ - (richcmpfunc)PySwigObject_richcompare, /* tp_richcompare */ + (richcmpfunc)SwigPyObject_richcompare, /* tp_richcompare */ 0, /* tp_weaklistoffset */ #if PY_VERSION_HEX >= 0x02020000 0, /* tp_iter */ @@ -746,20 +746,20 @@ _PySwigObject_type(void) { 0,0,0,0 /* tp_alloc -> tp_next */ #endif }; - pyswigobject_type = tmp; + swigpyobject_type = tmp; /* for Python 3 we already assigned the ob_type in PyVarObject_HEAD_INIT() */ #if PY_VERSION_HEX < 0x03000000 - pyswigobject_type.ob_type = &PyType_Type; + swigpyobject_type.ob_type = &PyType_Type; #endif type_init = 1; } - return &pyswigobject_type; + return &swigpyobject_type; } SWIGRUNTIME PyObject * -PySwigObject_New(void *ptr, swig_type_info *ty, int own) +SwigPyObject_New(void *ptr, swig_type_info *ty, int own) { - PySwigObject *sobj = PyObject_NEW(PySwigObject, PySwigObject_type()); + SwigPyObject *sobj = PyObject_NEW(SwigPyObject, SwigPyObject_type()); if (sobj) { sobj->ptr = ptr; sobj->ty = ty; @@ -778,10 +778,10 @@ typedef struct { void *pack; swig_type_info *ty; size_t size; -} PySwigPacked; +} SwigPyPacked; SWIGRUNTIME int -PySwigPacked_print(PySwigPacked *v, FILE *fp, int SWIGUNUSEDPARM(flags)) +SwigPyPacked_print(SwigPyPacked *v, FILE *fp, int SWIGUNUSEDPARM(flags)) { char result[SWIG_BUFFER_SIZE]; fputs("pack, v->size, 0, sizeof(result))) { @@ -806,7 +806,7 @@ PySwigPacked_repr(PySwigPacked *v) } SWIGRUNTIME PyObject * -PySwigPacked_str(PySwigPacked *v) +SwigPyPacked_str(SwigPyPacked *v) { char result[SWIG_BUFFER_SIZE]; if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))){ @@ -817,7 +817,7 @@ PySwigPacked_str(PySwigPacked *v) } SWIGRUNTIME int -PySwigPacked_compare(PySwigPacked *v, PySwigPacked *w) +SwigPyPacked_compare(SwigPyPacked *v, SwigPyPacked *w) { size_t i = v->size; size_t j = w->size; @@ -828,22 +828,22 @@ PySwigPacked_compare(PySwigPacked *v, PySwigPacked *w) SWIGRUNTIME PyTypeObject* _PySwigPacked_type(void); SWIGRUNTIME PyTypeObject* -PySwigPacked_type(void) { +SwigPyPacked_type(void) { static PyTypeObject *SWIG_STATIC_POINTER(type) = _PySwigPacked_type(); return type; } SWIGRUNTIMEINLINE int -PySwigPacked_Check(PyObject *op) { +SwigPyPacked_Check(PyObject *op) { return ((op)->ob_type == _PySwigPacked_type()) - || (strcmp((op)->ob_type->tp_name,"PySwigPacked") == 0); + || (strcmp((op)->ob_type->tp_name,"SwigPyPacked") == 0); } SWIGRUNTIME void -PySwigPacked_dealloc(PyObject *v) +SwigPyPacked_dealloc(PyObject *v) { - if (PySwigPacked_Check(v)) { - PySwigPacked *sobj = (PySwigPacked *) v; + if (SwigPyPacked_Check(v)) { + SwigPyPacked *sobj = (SwigPyPacked *) v; free(sobj->pack); } PyObject_DEL(v); @@ -852,7 +852,7 @@ PySwigPacked_dealloc(PyObject *v) SWIGRUNTIME PyTypeObject* _PySwigPacked_type(void) { static char swigpacked_doc[] = "Swig object carries a C/C++ instance pointer"; - static PyTypeObject pyswigpacked_type; + static PyTypeObject swigpypacked_type; static int type_init = 0; if (!type_init) { const PyTypeObject tmp @@ -864,21 +864,21 @@ _PySwigPacked_type(void) { PyObject_HEAD_INIT(NULL) 0, /* ob_size */ #endif - (char *)"PySwigPacked", /* tp_name */ - sizeof(PySwigPacked), /* tp_basicsize */ + (char *)"SwigPyPacked", /* tp_name */ + sizeof(SwigPyPacked), /* tp_basicsize */ 0, /* tp_itemsize */ - (destructor)PySwigPacked_dealloc, /* tp_dealloc */ - (printfunc)PySwigPacked_print, /* tp_print */ + (destructor)SwigPyPacked_dealloc, /* tp_dealloc */ + (printfunc)SwigPyPacked_print, /* tp_print */ (getattrfunc)0, /* tp_getattr */ (setattrfunc)0, /* tp_setattr */ - (cmpfunc)PySwigPacked_compare, /* tp_compare */ - (reprfunc)PySwigPacked_repr, /* tp_repr */ + (cmpfunc)SwigPyPacked_compare, /* tp_compare */ + (reprfunc)SwigPyPacked_repr, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ 0, /* tp_as_mapping */ (hashfunc)0, /* tp_hash */ (ternaryfunc)0, /* tp_call */ - (reprfunc)PySwigPacked_str, /* tp_str */ + (reprfunc)SwigPyPacked_str, /* tp_str */ PyObject_GenericGetAttr, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ @@ -917,20 +917,20 @@ _PySwigPacked_type(void) { 0,0,0,0 /* tp_alloc -> tp_next */ #endif }; - pyswigpacked_type = tmp; + swigpypacked_type = tmp; /* for Python 3 the ob_type already assigned in PyVarObject_HEAD_INIT() */ #if PY_VERSION_HEX < 0x03000000 - pyswigpacked_type.ob_type = &PyType_Type; + swigpypacked_type.ob_type = &PyType_Type; #endif type_init = 1; } - return &pyswigpacked_type; + return &swigpypacked_type; } SWIGRUNTIME PyObject * -PySwigPacked_New(void *ptr, size_t size, swig_type_info *ty) +SwigPyPacked_New(void *ptr, size_t size, swig_type_info *ty) { - PySwigPacked *sobj = PyObject_NEW(PySwigPacked, PySwigPacked_type()); + SwigPyPacked *sobj = PyObject_NEW(SwigPyPacked, SwigPyPacked_type()); if (sobj) { void *pack = malloc(size); if (pack) { @@ -947,10 +947,10 @@ PySwigPacked_New(void *ptr, size_t size, swig_type_info *ty) } SWIGRUNTIME swig_type_info * -PySwigPacked_UnpackData(PyObject *obj, void *ptr, size_t size) +SwigPyPacked_UnpackData(PyObject *obj, void *ptr, size_t size) { - if (PySwigPacked_Check(obj)) { - PySwigPacked *sobj = (PySwigPacked *)obj; + if (SwigPyPacked_Check(obj)) { + SwigPyPacked *sobj = (SwigPyPacked *)obj; if (sobj->size != size) return 0; memcpy(ptr, sobj->pack, size); return sobj->ty; @@ -983,11 +983,11 @@ SWIG_This(void) #define SWIG_PYTHON_SLOW_GETSET_THIS #endif -SWIGRUNTIME PySwigObject * +SWIGRUNTIME SwigPyObject * SWIG_Python_GetSwigThis(PyObject *pyobj) { - if (PySwigObject_Check(pyobj)) { - return (PySwigObject *) pyobj; + if (SwigPyObject_Check(pyobj)) { + return (SwigPyObject *) pyobj; } else { PyObject *obj = 0; #if (!defined(SWIG_PYTHON_SLOW_GETSET_THIS) && (PY_VERSION_HEX >= 0x02030000)) @@ -1023,12 +1023,12 @@ SWIG_Python_GetSwigThis(PyObject *pyobj) return 0; } #endif - if (obj && !PySwigObject_Check(obj)) { + if (obj && !SwigPyObject_Check(obj)) { /* a PyObject is called 'this', try to get the 'real this' - PySwigObject from it */ + SwigPyObject from it */ return SWIG_Python_GetSwigThis(obj); } - return (PySwigObject *)obj; + return (SwigPyObject *)obj; } } @@ -1037,7 +1037,7 @@ SWIG_Python_GetSwigThis(PyObject *pyobj) SWIGRUNTIME int SWIG_Python_AcquirePtr(PyObject *obj, int own) { if (own == SWIG_POINTER_OWN) { - PySwigObject *sobj = SWIG_Python_GetSwigThis(obj); + SwigPyObject *sobj = SWIG_Python_GetSwigThis(obj); if (sobj) { int oldown = sobj->own; sobj->own = own; @@ -1056,7 +1056,7 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int if (ptr) *ptr = 0; return SWIG_OK; } else { - PySwigObject *sobj = SWIG_Python_GetSwigThis(obj); + SwigPyObject *sobj = SWIG_Python_GetSwigThis(obj); if (own) *own = 0; while (sobj) { @@ -1070,7 +1070,7 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int } else { swig_cast_info *tc = SWIG_TypeCheck(to->name,ty); if (!tc) { - sobj = (PySwigObject *)sobj->next; + sobj = (SwigPyObject *)sobj->next; } else { if (ptr) { int newmemory = 0; @@ -1099,7 +1099,7 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int } else { int res = SWIG_ERROR; if (flags & SWIG_POINTER_IMPLICIT_CONV) { - PySwigClientData *data = ty ? (PySwigClientData *) ty->clientdata : 0; + SwigPyClientData *data = ty ? (SwigPyClientData *) ty->clientdata : 0; if (data && !data->implicitconv) { PyObject *klass = data->klass; if (klass) { @@ -1112,7 +1112,7 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int impconv = 0; } if (impconv) { - PySwigObject *iobj = SWIG_Python_GetSwigThis(impconv); + SwigPyObject *iobj = SWIG_Python_GetSwigThis(impconv); if (iobj) { void *vptr; res = SWIG_Python_ConvertPtrAndOwn((PyObject*)iobj, &vptr, ty, 0, 0); @@ -1174,7 +1174,7 @@ SWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) { SWIGRUNTIME int SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *ty) { - swig_type_info *to = PySwigPacked_UnpackData(obj, ptr, sz); + swig_type_info *to = SwigPyPacked_UnpackData(obj, ptr, sz); if (!to) return SWIG_ERROR; if (ty) { if (to != ty) { @@ -1196,7 +1196,7 @@ SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *t */ SWIGRUNTIME PyObject* -SWIG_Python_NewShadowInstance(PySwigClientData *data, PyObject *swig_this) +SWIG_Python_NewShadowInstance(SwigPyClientData *data, PyObject *swig_this) { #if (PY_VERSION_HEX >= 0x02020000) PyObject *inst = 0; @@ -1293,9 +1293,9 @@ SWIG_Python_InitShadowInstance(PyObject *args) { if (!SWIG_Python_UnpackTuple(args,(char*)"swiginit", 2, 2, obj)) { return NULL; } else { - PySwigObject *sthis = SWIG_Python_GetSwigThis(obj[0]); + SwigPyObject *sthis = SWIG_Python_GetSwigThis(obj[0]); if (sthis) { - PySwigObject_append((PyObject*) sthis, obj[1]); + SwigPyObject_append((PyObject*) sthis, obj[1]); } else { SWIG_Python_SetSwigThis(obj[0], obj[1]); } @@ -1311,8 +1311,8 @@ SWIG_Python_NewPointerObj(void *ptr, swig_type_info *type, int flags) { return SWIG_Py_Void(); } else { int own = (flags & SWIG_POINTER_OWN) ? SWIG_POINTER_OWN : 0; - PyObject *robj = PySwigObject_New(ptr, type, own); - PySwigClientData *clientdata = type ? (PySwigClientData *)(type->clientdata) : 0; + PyObject *robj = SwigPyObject_New(ptr, type, own); + SwigPyClientData *clientdata = type ? (SwigPyClientData *)(type->clientdata) : 0; if (clientdata && !(flags & SWIG_POINTER_NOSHADOW)) { PyObject *inst = SWIG_Python_NewShadowInstance(clientdata, robj); if (inst) { @@ -1328,7 +1328,7 @@ SWIG_Python_NewPointerObj(void *ptr, swig_type_info *type, int flags) { SWIGRUNTIMEINLINE PyObject * SWIG_Python_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) { - return ptr ? PySwigPacked_New((void *) ptr, sz, type) : SWIG_Py_Void(); + return ptr ? SwigPyPacked_New((void *) ptr, sz, type) : SWIG_Py_Void(); } /* -----------------------------------------------------------------------------* @@ -1399,8 +1399,8 @@ SWIG_Python_DestroyModule(void *vptr) for (i =0; i < swig_module->size; ++i) { swig_type_info *ty = types[i]; if (ty->owndata) { - PySwigClientData *data = (PySwigClientData *) ty->clientdata; - if (data) PySwigClientData_Del(data); + SwigPyClientData *data = (SwigPyClientData *) ty->clientdata; + if (data) SwigPyClientData_Del(data); } } Py_DECREF(SWIG_This()); @@ -1500,9 +1500,9 @@ SWIG_Python_ArgFail(int argnum) } SWIGRUNTIMEINLINE const char * -PySwigObject_GetDesc(PyObject *self) +SwigPyObject_GetDesc(PyObject *self) { - PySwigObject *v = (PySwigObject *)self; + SwigPyObject *v = (SwigPyObject *)self; swig_type_info *ty = v ? v->ty : 0; return ty ? ty->str : (char*)""; } @@ -1512,10 +1512,10 @@ SWIG_Python_TypeError(const char *type, PyObject *obj) { if (type) { #if defined(SWIG_COBJECT_TYPES) - if (obj && PySwigObject_Check(obj)) { - const char *otype = (const char *) PySwigObject_GetDesc(obj); + if (obj && SwigPyObject_Check(obj)) { + const char *otype = (const char *) SwigPyObject_GetDesc(obj); if (otype) { - PyErr_Format(PyExc_TypeError, "a '%s' is expected, 'PySwigObject(%s)' is received", + PyErr_Format(PyExc_TypeError, "a '%s' is expected, 'SwigPyObject(%s)' is received", type, otype); return; } diff --git a/Lib/python/pytypemaps.swg b/Lib/python/pytypemaps.swg index 2d0aa576c..e8df069ef 100644 --- a/Lib/python/pytypemaps.swg +++ b/Lib/python/pytypemaps.swg @@ -88,7 +88,7 @@ if ($result) { PyObject *robj = PyObject_CallMethod($result, (char *)"__deref__", NULL); if (robj && !PyErr_Occurred()) { - PySwigObject_append((PyObject *) SWIG_Python_GetSwigThis($result), + SwigPyObject_append((PyObject *) SWIG_Python_GetSwigThis($result), (PyObject *) SWIG_Python_GetSwigThis(robj)); Py_DECREF(robj); } diff --git a/Lib/python/std_carray.i b/Lib/python/std_carray.i index 2e40757f2..680d67115 100644 --- a/Lib/python/std_carray.i +++ b/Lib/python/std_carray.i @@ -17,7 +17,7 @@ namespace swig { %extend std::carray { %fragment(SWIG_Traits_frag(std::carray<_Type, _Size >), "header", - fragment="PySwigIterator_T", + fragment="SwigPyIterator_T", fragment=SWIG_Traits_frag(_Type), fragment="StdCarrayTraits") { namespace swig { @@ -36,7 +36,7 @@ namespace swig { %typemap(out,noblock=1) iterator, const_iterator { $result = SWIG_NewPointerObj(swig::make_output_iterator((const $type &)$1), - swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN); + swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN); } inline size_t __len__() const { return self->size(); } @@ -46,7 +46,7 @@ namespace swig { inline void __setitem__(size_t i, const _Type& v) { (*self)[i] = v; } - swig::PySwigIterator* __iter__(PyObject **PYTHON_SELF) { + swig::SwigPyIterator* __iter__(PyObject **PYTHON_SELF) { return swig::make_output_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF); } } diff --git a/Lib/python/std_map.i b/Lib/python/std_map.i index b080731f0..c93ffe61b 100644 --- a/Lib/python/std_map.i +++ b/Lib/python/std_map.i @@ -5,12 +5,12 @@ %fragment("StdMapTraits","header",fragment="StdSequenceTraits") { namespace swig { - template + template inline void - assign(const PySeq& pyseq, std::map *map) { + assign(const SwigPySeq& swigpyseq, std::map *map) { typedef typename std::map::value_type value_type; - typename PySeq::const_iterator it = pyseq.begin(); - for (;it != pyseq.end(); ++it) { + typename SwigPySeq::const_iterator it = swigpyseq.begin(); + for (;it != swigpyseq.end(); ++it) { map->insert(value_type(it->first, it->second)); } } @@ -21,7 +21,7 @@ static int asptr(PyObject *obj, map_type **val) { int res = SWIG_ERROR; if (PyDict_Check(obj)) { - PyObject_var items = PyObject_CallMethod(obj,(char *)"items",NULL); + 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!"); @@ -58,8 +58,8 @@ } PyObject *obj = PyDict_New(); for (const_iterator i= map.begin(); i!= map.end(); ++i) { - swig::PyObject_var key = swig::from(i->first); - swig::PyObject_var val = swig::from(i->second); + swig::SwigVar_PyObject key = swig::from(i->first); + swig::SwigVar_PyObject val = swig::from(i->second); PyDict_SetItem(obj, key, val); } return obj; @@ -90,10 +90,10 @@ }; template - struct PyMapIterator_T : PySwigIteratorClosed_T + struct SwigPyMapIterator_T : SwigPyIteratorClosed_T { - PyMapIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq) - : PySwigIteratorClosed_T(curr, first, last, seq) + SwigPyMapIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq) + : SwigPyIteratorClosed_T(curr, first, last, seq) { } }; @@ -101,37 +101,37 @@ template > - struct PyMapKeyIterator_T : PyMapIterator_T + struct SwigPyMapKeyIterator_T : SwigPyMapIterator_T { - PyMapKeyIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq) - : PyMapIterator_T(curr, first, last, seq) + SwigPyMapKeyIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq) + : SwigPyMapIterator_T(curr, first, last, seq) { } }; template - inline PySwigIterator* + inline SwigPyIterator* make_output_key_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, PyObject *seq = 0) { - return new PyMapKeyIterator_T(current, begin, end, seq); + return new SwigPyMapKeyIterator_T(current, begin, end, seq); } template > - struct PyMapValueIterator_T : PyMapIterator_T + struct SwigPyMapValueITerator_T : SwigPyMapIterator_T { - PyMapValueIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq) - : PyMapIterator_T(curr, first, last, seq) + SwigPyMapValueITerator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq) + : SwigPyMapIterator_T(curr, first, last, seq) { } }; template - inline PySwigIterator* + inline SwigPyIterator* make_output_value_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, PyObject *seq = 0) { - return new PyMapValueIterator_T(current, begin, end, seq); + return new SwigPyMapValueITerator_T(current, begin, end, seq); } } } @@ -222,12 +222,12 @@ } %newobject key_iterator(PyObject **PYTHON_SELF); - swig::PySwigIterator* key_iterator(PyObject **PYTHON_SELF) { + swig::SwigPyIterator* key_iterator(PyObject **PYTHON_SELF) { return swig::make_output_key_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF); } %newobject value_iterator(PyObject **PYTHON_SELF); - swig::PySwigIterator* value_iterator(PyObject **PYTHON_SELF) { + swig::SwigPyIterator* value_iterator(PyObject **PYTHON_SELF) { return swig::make_output_value_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF); } diff --git a/Lib/python/std_multimap.i b/Lib/python/std_multimap.i index f923af06b..58336bc4b 100644 --- a/Lib/python/std_multimap.i +++ b/Lib/python/std_multimap.i @@ -6,12 +6,12 @@ %fragment("StdMultimapTraits","header",fragment="StdSequenceTraits") { namespace swig { - template + template inline void - assign(const PySeq& pyseq, std::multimap *multimap) { + assign(const SwigPySeq& swigpyseq, std::multimap *multimap) { typedef typename std::multimap::value_type value_type; - typename PySeq::const_iterator it = pyseq.begin(); - for (;it != pyseq.end(); ++it) { + typename SwigPySeq::const_iterator it = swigpyseq.begin(); + for (;it != swigpyseq.end(); ++it) { multimap->insert(value_type(it->first, it->second)); } } @@ -22,7 +22,7 @@ static int asptr(PyObject *obj, std::multimap **val) { int res = SWIG_ERROR; if (PyDict_Check(obj)) { - PyObject_var items = PyObject_CallMethod(obj,(char *)"items",NULL); + SwigVar_PyObject items = PyObject_CallMethod(obj,(char *)"items",NULL); return traits_asptr_stdseq, std::pair >::asptr(items, val); } else { multimap_type *p; @@ -55,8 +55,8 @@ } PyObject *obj = PyDict_New(); for (const_iterator i= multimap.begin(); i!= multimap.end(); ++i) { - swig::PyObject_var key = swig::from(i->first); - swig::PyObject_var val = swig::from(i->second); + swig::SwigVar_PyObject key = swig::from(i->first); + swig::SwigVar_PyObject val = swig::from(i->second); PyDict_SetItem(obj, key, val); } return obj; diff --git a/Lib/python/std_multiset.i b/Lib/python/std_multiset.i index 35a689026..ac430334c 100644 --- a/Lib/python/std_multiset.i +++ b/Lib/python/std_multiset.i @@ -7,13 +7,13 @@ %fragment("StdMultisetTraits","header",fragment="StdSequenceTraits") %{ namespace swig { - template + template inline void - assign(const PySeq& pyseq, std::multiset* seq) { - // seq->insert(pyseq.begin(), pyseq.end()); // not used as not always implemented - typedef typename PySeq::value_type value_type; - typename PySeq::const_iterator it = pyseq.begin(); - for (;it != pyseq.end(); ++it) { + assign(const SwigPySeq& swigpyseq, std::multiset* seq) { + // seq->insert(swigpyseq.begin(), swigpyseq.end()); // not used as not always implemented + typedef typename SwigPySeq::value_type value_type; + typename SwigPySeq::const_iterator it = swigpyseq.begin(); + for (;it != swigpyseq.end(); ++it) { seq->insert(seq->end(),(value_type)(*it)); } } diff --git a/Lib/python/std_pair.i b/Lib/python/std_pair.i index 673e85eef..bc8ccaade 100644 --- a/Lib/python/std_pair.i +++ b/Lib/python/std_pair.i @@ -42,8 +42,8 @@ } } else if (PySequence_Check(obj)) { if (PySequence_Size(obj) == 2) { - swig::PyObject_var first = PySequence_GetItem(obj,0); - swig::PyObject_var second = PySequence_GetItem(obj,1); + swig::SwigVar_PyObject first = PySequence_GetItem(obj,0); + swig::SwigVar_PyObject second = PySequence_GetItem(obj,1); res = get_pair(first, second, val); } } else { @@ -92,8 +92,8 @@ } } else if (PySequence_Check(obj)) { if (PySequence_Size(obj) == 2) { - swig::PyObject_var first = PySequence_GetItem(obj,0); - swig::PyObject_var second = PySequence_GetItem(obj,1); + swig::SwigVar_PyObject first = PySequence_GetItem(obj,0); + swig::SwigVar_PyObject second = PySequence_GetItem(obj,1); res = get_pair(first, second, val); } } else { diff --git a/Lib/python/std_set.i b/Lib/python/std_set.i index 94ef667e2..59f69cdc9 100644 --- a/Lib/python/std_set.i +++ b/Lib/python/std_set.i @@ -5,13 +5,13 @@ %fragment("StdSetTraits","header",fragment="StdSequenceTraits") %{ namespace swig { - template + template inline void - assign(const PySeq& pyseq, std::set* seq) { - // seq->insert(pyseq.begin(), pyseq.end()); // not used as not always implemented - typedef typename PySeq::value_type value_type; - typename PySeq::const_iterator it = pyseq.begin(); - for (;it != pyseq.end(); ++it) { + assign(const SwigPySeq& swigpyseq, std::set* seq) { + // seq->insert(swigpyseq.begin(), swigpyseq.end()); // not used as not always implemented + typedef typename SwigPySeq::value_type value_type; + typename SwigPySeq::const_iterator it = swigpyseq.begin(); + for (;it != swigpyseq.end(); ++it) { seq->insert(seq->end(),(value_type)(*it)); } } diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index a9a3833ff..1a2cf4f16 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -738,7 +738,7 @@ public: Printv(f_shadow, "def _swig_setattr_nondynamic(self,class_type,name,value,static=1):\n", tab4, "if (name == \"thisown\"): return self.this.own(value)\n", - tab4, "if (name == \"this\"):\n", tab4, tab4, "if type(value).__name__ == 'PySwigObject':\n", tab4, tab8, "self.__dict__[name] = value\n", + tab4, "if (name == \"this\"):\n", tab4, tab4, "if type(value).__name__ == 'SwigPyObject':\n", tab4, tab8, "self.__dict__[name] = value\n", #ifdef USE_THISOWN tab4, tab8, "if hasattr(value,\"thisown\"): self.__dict__[\"thisown\"] = value.thisown\n", tab4, tab8, "del value.thisown\n", #endif @@ -2741,7 +2741,7 @@ public: Printf(f_directors_h, " PyObject *swig_get_method(size_t method_index, const char *method_name) const {\n"); Printf(f_directors_h, " PyObject *method = vtable[method_index];\n"); Printf(f_directors_h, " if (!method) {\n"); - Printf(f_directors_h, " swig::PyObject_var name = SWIG_Python_str_FromChar(method_name);\n"); + Printf(f_directors_h, " swig::SwigVar_PyObject name = SWIG_Python_str_FromChar(method_name);\n"); Printf(f_directors_h, " method = PyObject_GetAttr(swig_get_self(), name);\n"); Printf(f_directors_h, " if (method == NULL) {\n"); Printf(f_directors_h, " std::string msg = \"Method in class %s doesn't exist, undefined \";\n", classname); @@ -2753,7 +2753,7 @@ public: Printf(f_directors_h, " return method;\n"); Printf(f_directors_h, " }\n"); Printf(f_directors_h, "private:\n"); - Printf(f_directors_h, " mutable swig::PyObject_var vtable[%d];\n", director_method_index); + Printf(f_directors_h, " mutable swig::SwigVar_PyObject vtable[%d];\n", director_method_index); Printf(f_directors_h, "#endif\n\n"); } @@ -3753,8 +3753,8 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) { Replaceall(tm, "$input", input); Delete(input); Replaceall(tm, "$owner", "0"); - /* Wrapper_add_localv(w, source, "swig::PyObject_var", source, "= 0", NIL); */ - Printv(wrap_args, "swig::PyObject_var ", source, ";\n", NIL); + /* Wrapper_add_localv(w, source, "swig::SwigVar_PyObject", source, "= 0", NIL); */ + Printv(wrap_args, "swig::SwigVar_PyObject ", source, ";\n", NIL); Printv(wrap_args, tm, "\n", NIL); Printv(arglist, "(PyObject *)", source, NIL); @@ -3810,7 +3810,7 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) { if (target) { String *director = NewStringf("director_%s", mangle); Wrapper_add_localv(w, director, "Swig::Director *", director, "= 0", NIL); - Wrapper_add_localv(w, source, "swig::PyObject_var", source, "= 0", NIL); + Wrapper_add_localv(w, source, "swig::SwigVar_PyObject", source, "= 0", NIL); Printf(wrap_args, "%s = SWIG_DIRECTOR_CAST(%s);\n", director, nonconst); Printf(wrap_args, "if (!%s) {\n", director); Printf(wrap_args, "%s = SWIG_NewPointerObj(%s, SWIGTYPE%s, 0);\n", source, nonconst, mangle); @@ -3821,7 +3821,7 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) { Delete(director); Printv(arglist, source, NIL); } else { - Wrapper_add_localv(w, source, "swig::PyObject_var", source, "= 0", NIL); + Wrapper_add_localv(w, source, "swig::SwigVar_PyObject", source, "= 0", NIL); Printf(wrap_args, "%s = SWIG_NewPointerObj(%s, SWIGTYPE%s, 0);\n", source, nonconst, mangle); //Printf(wrap_args, "%s = SWIG_NewPointerObj(%s, SWIGTYPE_p_%s, 0);\n", // source, nonconst, base); @@ -3872,33 +3872,33 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) { Append(w->code, "PyObject* method = swig_get_method(swig_method_index, swig_method_name);\n"); if (Len(parse_args) > 0) { if (use_parse || !modernargs) { - Printf(w->code, "swig::PyObject_var result = PyObject_CallFunction(method, (char *)\"(%s)\" %s);\n", parse_args, arglist); + Printf(w->code, "swig::SwigVar_PyObject result = PyObject_CallFunction(method, (char *)\"(%s)\" %s);\n", parse_args, arglist); } else { - Printf(w->code, "swig::PyObject_var result = PyObject_CallFunctionObjArgs(method %s, NULL);\n", arglist); + Printf(w->code, "swig::SwigVar_PyObject result = PyObject_CallFunctionObjArgs(method %s, NULL);\n", arglist); } } else { if (modernargs) { - Append(w->code, "swig::PyObject_var args = PyTuple_New(0);\n"); - Append(w->code, "swig::PyObject_var result = PyObject_Call(method, (PyObject*) args, NULL);\n"); + Append(w->code, "swig::SwigVar_PyObject args = PyTuple_New(0);\n"); + Append(w->code, "swig::SwigVar_PyObject result = PyObject_Call(method, (PyObject*) args, NULL);\n"); } else { - Printf(w->code, "swig::PyObject_var result = PyObject_CallFunction(method, NULL, NULL);\n"); + Printf(w->code, "swig::SwigVar_PyObject result = PyObject_CallFunction(method, NULL, NULL);\n"); } } Append(w->code, "#else\n"); if (Len(parse_args) > 0) { if (use_parse || !modernargs) { - Printf(w->code, "swig::PyObject_var result = PyObject_CallMethod(swig_get_self(), (char *)\"%s\", (char *)\"(%s)\" %s);\n", + Printf(w->code, "swig::SwigVar_PyObject result = PyObject_CallMethod(swig_get_self(), (char *)\"%s\", (char *)\"(%s)\" %s);\n", pyname, parse_args, arglist); } else { - Printf(w->code, "swig::PyObject_var swig_method_name = SWIG_Python_str_FromChar((char *)\"%s\");\n", pyname); - Printf(w->code, "swig::PyObject_var result = PyObject_CallMethodObjArgs(swig_get_self(), (PyObject *) swig_method_name %s, NULL);\n", arglist); + Printf(w->code, "swig::SwigVar_PyObject swig_method_name = SWIG_Python_str_FromChar((char *)\"%s\");\n", pyname); + Printf(w->code, "swig::SwigVar_PyObject result = PyObject_CallMethodObjArgs(swig_get_self(), (PyObject *) swig_method_name %s, NULL);\n", arglist); } } else { if (!modernargs) { - Printf(w->code, "swig::PyObject_var result = PyObject_CallMethod(swig_get_self(), (char *) \"%s\", NULL);\n", pyname); + Printf(w->code, "swig::SwigVar_PyObject result = PyObject_CallMethod(swig_get_self(), (char *) \"%s\", NULL);\n", pyname); } else { - Printf(w->code, "swig::PyObject_var swig_method_name = SWIG_Python_str_FromChar((char *)\"%s\");\n", pyname); - Append(w->code, "swig::PyObject_var result = PyObject_CallMethodObjArgs(swig_get_self(), (PyObject *) swig_method_name, NULL);\n"); + Printf(w->code, "swig::SwigVar_PyObject swig_method_name = SWIG_Python_str_FromChar((char *)\"%s\");\n", pyname); + Append(w->code, "swig::SwigVar_PyObject result = PyObject_CallMethodObjArgs(swig_get_self(), (PyObject *) swig_method_name, NULL);\n"); } } Append(w->code, "#endif\n"); diff --git a/Tools/pyname_patch.py b/Tools/pyname_patch.py new file mode 100644 index 000000000..d6a693ffb --- /dev/null +++ b/Tools/pyname_patch.py @@ -0,0 +1,122 @@ +""" +From SWIG 1.3.37 we deprecated all SWIG symbols that start with Py, +since they are inappropriate and discouraged in Python documentation +(from http://www.python.org/doc/2.5.2/api/includes.html): + +"All user visible names defined by Python.h (except those defined by the included +standard headers) have one of the prefixes "Py" or "_Py". Names beginning with +"_Py" are for internal use by the Python implementation and should not be used +by extension writers. Structure member names do not have a reserved prefix. + +Important: user code should never define names that begin with "Py" or "_Py". +This confuses the reader, and jeopardizes the portability of the user code to +future Python versions, which may define additional names beginning with one +of these prefixes." + +This file is a simple script used for change all of these symbols, for user code +or SWIG itself. +""" +import re +from shutil import copyfile +import sys + +symbols = [ + #(old name, new name) + ("PySequence_Base", "SwigPySequence_Base"), + ("PySequence_Cont", "SwigPySequence_Cont"), + ("PySwigIterator_T", "SwigPyIterator_T"), + ("PyPairBoolOutputIterator", "SwigPyPairBoolOutputIterator"), + ("PySwigIterator", "SwigPyIterator"), + ("PySwigIterator_T", "SwigPyIterator_T"), + ("PyMapIterator_T", "SwigPyMapIterator_T"), + ("PyMapKeyIterator_T", "SwigPyMapKeyIterator_T"), + ("PyMapValueIterator_T", "SwigPyMapValueITerator_T"), + ("PyObject_ptr", "SwigPtr_PyObject"), + ("PyObject_var", "SwigVar_PyObject"), + ("PyOper", "SwigPyOper"), + ("PySeq", "SwigPySeq"), + ("PySequence_ArrowProxy", "SwigPySequence_ArrowProxy"), + ("PySequence_Cont", "SwigPySequence_Cont"), + ("PySequence_InputIterator", "SwigPySequence_InputIterator"), + ("PySequence_Ref", "SwigPySequence_Ref"), + ("PySwigClientData", "SwigPyClientData"), + ("PySwigClientData_Del", "SwigPyClientData_Del"), + ("PySwigClientData_New", "SwigPyClientData_New"), + ("PySwigIterator", "SwigPyIterator"), + ("PySwigIteratorClosed_T", "SwigPyIteratorClosed_T"), + ("PySwigIteratorOpen_T", "SwigPyIteratorOpen_T"), + ("PySwigIterator_T", "SwigPyIterator_T"), + ("PySwigObject", "SwigPyObject"), + ("PySwigObject_Check", "SwigPyObject_Check"), + ("PySwigObject_GetDesc", "SwigPyObject_GetDesc"), + ("PySwigObject_New", "SwigPyObject_New"), + ("PySwigObject_acquire", "SwigPyObject_acquire"), + ("PySwigObject_append", "SwigPyObject_append"), + ("PySwigObject_as_number", "SwigPyObject_as_number"), + ("PySwigObject_compare", "SwigPyObject_compare"), + ("PySwigObject_dealloc", "SwigPyObject_dealloc"), + ("PySwigObject_disown", "SwigPyObject_disown"), + ("PySwigObject_format", "SwigPyObject_format"), + ("PySwigObject_getattr", "SwigPyObject_getattr"), + ("PySwigObject_hex", "SwigPyObject_hex"), + ("PySwigObject_long", "SwigPyObject_long"), + ("PySwigObject_next", "SwigPyObject_next"), + ("PySwigObject_oct", "SwigPyObject_oct"), + ("PySwigObject_own", "SwigPyObject_own"), + ("PySwigObject_print", "SwigPyObject_print"), + ("PySwigObject_repr", "SwigPyObject_repr"), + ("PySwigObject_richcompare", "SwigPyObject_richcompare"), + ("PySwigObject_str", "SwigPyObject_str"), + ("PySwigObject_type", "SwigPyObject_type"), + ("PySwigPacked", "SwigPyPacked"), + ("PySwigPacked_Check", "SwigPyPacked_Check"), + ("PySwigPacked_New", "SwigPyPacked_New"), + ("PySwigPacked_UnpackData", "SwigPyPacked_UnpackData"), + ("PySwigPacked_compare", "SwigPyPacked_compare"), + ("PySwigPacked_dealloc", "SwigPyPacked_dealloc"), + ("PySwigPacked_print", "SwigPyPacked_print"), + ("PySwigPacked_repr", "SwigPyPacked_repr"), + ("PySwigPacked_str", "SwigPyPacked_str"), + ("PySwigPacked_type", "SwigPyPacked_type"), + ("pyseq", "swigpyseq"), + ("pyswigobject_type", "swigpyobject_type"), + ("pyswigpacked_type", "swigpypacked_type"), + ] + +res = [(re.compile("\\b(%s)\\b"%oldname), newname) for oldname, newname in symbols] + +def patch_file(fn): + newf = [] + changed = False + for line in open(fn): + for r, newname in res: + line, n = r.subn(newname, line) + if n>0: + changed = True + newf.append(line) + + if changed: + copyfile(fn, fn+".bak") + f = open(fn, "w") + f.write("".join(newf)) + f.close() + return changed + +def main(fns): + for fn in fns: + try: + if patch_file(fn): + print "Patched file", fn + except IOError: + print "Error occured during patching", fn + return + +if __name__=="__main__": + if len(sys.argv) > 1: + main(sys.argv[1:]) + else: + print "Patch your interface file for SWIG's Py* symbol name deprecation." + print "Usage:" + print " %s files..."%sys.argv[0] + + From 5070f8d929eef439cb85e3cc0e1be5e6b36d605d Mon Sep 17 00:00:00 2001 From: Haoyu Bai Date: Wed, 3 Dec 2008 19:24:06 +0000 Subject: [PATCH 0206/1680] 2to3 has its way to exclude fixer now, so we nolonger need our hack git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10962 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/python/Makefile.in | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Examples/test-suite/python/Makefile.in b/Examples/test-suite/python/Makefile.in index c72b19941..5237b3f69 100644 --- a/Examples/test-suite/python/Makefile.in +++ b/Examples/test-suite/python/Makefile.in @@ -26,9 +26,7 @@ top_srcdir = @top_srcdir@ top_builddir = @top_builddir@ -#Use the tricky command because we want to disable the "import" fixer, -#but currently 2to3 has no option to let us do it -PY2TO3 = 2to3 `2to3 -l | grep -v -E "Available|import$$" | awk '{print "-f "$$0}'` +PY2TO3 = 2to3 -x import CPP_TEST_CASES += \ From 11b892b4471ec4f617002ce0630a983b6d8199af Mon Sep 17 00:00:00 2001 From: Haoyu Bai Date: Wed, 3 Dec 2008 21:36:53 +0000 Subject: [PATCH 0207/1680] add shebang for pyname_patch.py git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10963 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Tools/pyname_patch.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Tools/pyname_patch.py b/Tools/pyname_patch.py index d6a693ffb..5931269f9 100644 --- a/Tools/pyname_patch.py +++ b/Tools/pyname_patch.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python """ From SWIG 1.3.37 we deprecated all SWIG symbols that start with Py, since they are inappropriate and discouraged in Python documentation From 91ba340a79f9b534f32a8e9ab85494c172469a0b Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 6 Dec 2008 17:10:53 +0000 Subject: [PATCH 0208/1680] add test for inheritance of 3 classes deep which exposes a problem in the python shared_ptr wrappers. Manually added the %types for now. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10964 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- .../csharp/li_boost_shared_ptr_runme.cs | 10 +++++ .../java/li_boost_shared_ptr_runme.java | 10 +++++ Examples/test-suite/li_boost_shared_ptr.i | 38 ++++++++++++++++++- .../python/li_boost_shared_ptr_runme.py | 9 +++++ 4 files changed, 65 insertions(+), 2 deletions(-) diff --git a/Examples/test-suite/csharp/li_boost_shared_ptr_runme.cs b/Examples/test-suite/csharp/li_boost_shared_ptr_runme.cs index 27bc4628f..6ded989b5 100644 --- a/Examples/test-suite/csharp/li_boost_shared_ptr_runme.cs +++ b/Examples/test-suite/csharp/li_boost_shared_ptr_runme.cs @@ -345,6 +345,16 @@ public class runme verifyCount(1, kret); } + // 3rd derived class + { + Klass k = new Klass3rdDerived("me oh my"); + String val = k.getValue(); + verifyValue("me oh my-3rdDerived", val); + verifyCount(3, k); // 3 classes in inheritance chain == 3 swigCPtr values + val = li_boost_shared_ptr.test3rdupcast(k); + verifyValue("me oh my-3rdDerived", val); + verifyCount(3, k); + } ////////////////////////////////// Member variables //////////////////////////////////////// // smart pointer by value diff --git a/Examples/test-suite/java/li_boost_shared_ptr_runme.java b/Examples/test-suite/java/li_boost_shared_ptr_runme.java index a699222e5..02d6d6502 100644 --- a/Examples/test-suite/java/li_boost_shared_ptr_runme.java +++ b/Examples/test-suite/java/li_boost_shared_ptr_runme.java @@ -357,6 +357,16 @@ public class li_boost_shared_ptr_runme { verifyCount(1, kret); } + // 3rd derived class + { + Klass k = new Klass3rdDerived("me oh my"); + String val = k.getValue(); + verifyValue("me oh my-3rdDerived", val); + verifyCount(3, k); // 3 classes in inheritance chain == 3 swigCPtr values + val = li_boost_shared_ptr.test3rdupcast(k); + verifyValue("me oh my-3rdDerived", val); + verifyCount(3, k); + } ////////////////////////////////// Member variables //////////////////////////////////////// // smart pointer by value diff --git a/Examples/test-suite/li_boost_shared_ptr.i b/Examples/test-suite/li_boost_shared_ptr.i index a6225410b..f992a3c08 100644 --- a/Examples/test-suite/li_boost_shared_ptr.i +++ b/Examples/test-suite/li_boost_shared_ptr.i @@ -43,6 +43,14 @@ %include SWIG_SHARED_PTR(Klass, Space::Klass) SWIG_SHARED_PTR_DERIVED(KlassDerived, Space::Klass, Space::KlassDerived) +SWIG_SHARED_PTR_DERIVED(Klass2ndDerived, Space::Klass, Space::Klass2ndDerived) +SWIG_SHARED_PTR_DERIVED(Klass3rdDerived, Space::Klass2ndDerived, Space::Klass3rdDerived) + +// TEMP for python +%types(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< Space::Klass3rdDerived > = SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< Space::Klass >) { + *newmemory = SWIG_CAST_NEW_MEMORY; + return (void *) new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< Space::Klass >(*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< Space::Klass3rdDerived > *)$from); +} #endif @@ -101,7 +109,13 @@ private: }; SwigExamples::CriticalSection Space::Klass::critical_section; -struct IgnoredMultipleInheritBase { virtual ~IgnoredMultipleInheritBase() {} double d; double e;}; +struct IgnoredMultipleInheritBase { + IgnoredMultipleInheritBase() : d(0.0), e(0.0) {} + virtual ~IgnoredMultipleInheritBase() {} + double d; + double e; + virtual void AVirtualMethod() {} +}; // For most compilers, this use of multiple inheritance results in different derived and base class // pointer values ... for some more challenging tests :) @@ -142,7 +156,21 @@ SwigBoost::shared_ptr*& derivedsmartptrpointerreftest(SwigBoost::s return kd; } +// 3 classes in inheritance chain test +struct Klass2ndDerived : Klass { + Klass2ndDerived() : Klass() {} + Klass2ndDerived(const std::string &val) : Klass(val) {} +}; +struct Klass3rdDerived : IgnoredMultipleInheritBase, Klass2ndDerived { + Klass3rdDerived() : Klass2ndDerived() {} + Klass3rdDerived(const std::string &val) : Klass2ndDerived(val) {} + virtual ~Klass3rdDerived() {} + virtual std::string getValue() const { return Klass2ndDerived::getValue() + "-3rdDerived"; } +}; +std::string test3rdupcast( SwigBoost::shared_ptr< Klass > k) { + return k->getValue(); +} @@ -217,8 +245,14 @@ SwigBoost::shared_ptr* smartpointerpointerownertest() { return new SwigBoost::shared_ptr(new Klass("smartpointerpointerownertest")); } -// Provide overloads for Klass and KlassDerived as some language modules, eg Python, create an extra reference in +// Provide overloads for Klass and derived classes as some language modules, eg Python, create an extra reference in // the marshalling if an upcast to a base class is required. +long use_count(const SwigBoost::shared_ptr& sptr) { + return sptr.use_count(); +} +long use_count(const SwigBoost::shared_ptr& sptr) { + return sptr.use_count(); +} long use_count(const SwigBoost::shared_ptr& sptr) { return sptr.use_count(); } diff --git a/Examples/test-suite/python/li_boost_shared_ptr_runme.py b/Examples/test-suite/python/li_boost_shared_ptr_runme.py index 5f6cbd211..f967def14 100644 --- a/Examples/test-suite/python/li_boost_shared_ptr_runme.py +++ b/Examples/test-suite/python/li_boost_shared_ptr_runme.py @@ -304,6 +304,15 @@ class li_boost_shared_ptr_runme: self.verifyValue(li_boost_shared_ptr.overload_smartbyptr(k), "smartbyptr") self.verifyValue(li_boost_shared_ptr.overload_smartbyptrref(k), "smartbyptrref") + # 3rd derived class + k = li_boost_shared_ptr.Klass3rdDerived("me oh my") + val = k.getValue() + self.verifyValue("me oh my-3rdDerived", val) + self.verifyCount(1, k) + val = li_boost_shared_ptr.test3rdupcast(k) + self.verifyValue("me oh my-3rdDerived", val) + self.verifyCount(1, k) + # //////////////////////////////// Member variables //////////////////////////////////////// # smart pointer by value m = li_boost_shared_ptr.MemberVariables() From ffdf269634d40e4b1722a663690cfb5a086ebd16 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 6 Dec 2008 17:12:05 +0000 Subject: [PATCH 0209/1680] minor formatting fix git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10965 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/shared_ptr.i | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/shared_ptr.i b/Lib/shared_ptr.i index c6749ff9e..709791502 100644 --- a/Lib/shared_ptr.i +++ b/Lib/shared_ptr.i @@ -51,7 +51,7 @@ SWIG_SHARED_PTR_TYPEMAPS(PROXYCLASS, const, TYPE) %types(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > = SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< BASECLASSTYPE >) %{ *newmemory = SWIG_CAST_NEW_MEMORY; return (void *) new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< BASECLASSTYPE >(*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *)$from); - %} +%} %extend TYPE { static SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< BASECLASSTYPE > SWIGSharedPtrUpcast(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > swigSharedPtrUpcast) { return swigSharedPtrUpcast; From dfd94424bae7a7849e03562d85f977ae962dc514 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 6 Dec 2008 17:18:38 +0000 Subject: [PATCH 0210/1680] remove SWIG_TypeCheck_Template so that the code within it is debuggable git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10966 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/perl5/perlrun.swg | 25 +++++++++-- Lib/swigrun.swg | 98 ++++++++++++++++++++++++------------------- 2 files changed, 78 insertions(+), 45 deletions(-) diff --git a/Lib/perl5/perlrun.swg b/Lib/perl5/perlrun.swg index 54d098d9b..6fb2968f0 100644 --- a/Lib/perl5/perlrun.swg +++ b/Lib/perl5/perlrun.swg @@ -205,13 +205,32 @@ SWIG_Perl_TypeProxyName(const swig_type_info *type) { } } +/* Identical to SWIG_TypeCheck, except for strcmp comparison */ SWIGRUNTIME swig_cast_info * SWIG_TypeProxyCheck(const char *c, swig_type_info *ty) { - SWIG_TypeCheck_Template(( (!iter->type->clientdata && (strcmp(iter->type->name, c) == 0)) - || (iter->type->clientdata && (strcmp((char*)iter->type->clientdata, c) == 0))), ty); + if (ty) { + swig_cast_info *iter = ty->cast; + while (iter) { + if ( (!iter->type->clientdata && (strcmp(iter->type->name, c) == 0)) || + (iter->type->clientdata && (strcmp((char*)iter->type->clientdata, c) == 0)) ) { + if (iter == ty->cast) + return iter; + /* Move iter to the top of the linked list */ + iter->prev->next = iter->next; + if (iter->next) + iter->next->prev = iter->prev; + iter->next = ty->cast; + iter->prev = 0; + if (ty->cast) ty->cast->prev = iter; + ty->cast = iter; + return iter; + } + iter = iter->next; + } + } + return 0; } - /* Function for getting a pointer value */ SWIGRUNTIME int diff --git a/Lib/swigrun.swg b/Lib/swigrun.swg index 9ee676a2b..a8e9ad74c 100644 --- a/Lib/swigrun.swg +++ b/Lib/swigrun.swg @@ -1,7 +1,7 @@ /* ----------------------------------------------------------------------------- * swigrun.swg * - * This file contains generic CAPI SWIG runtime support for pointer + * This file contains generic C API SWIG runtime support for pointer * type checking. * ----------------------------------------------------------------------------- */ @@ -20,11 +20,11 @@ /* You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for - creating a static or dynamic library from the swig runtime code. - In 99.9% of the cases, swig just needs to declare them as 'static'. + creating a static or dynamic library from the SWIG runtime code. + In 99.9% of the cases, SWIG just needs to declare them as 'static'. - But only do this if is strictly necessary, ie, if you have problems - with your compiler or so. + But only do this if strictly necessary, ie, if you have problems + with your compiler or suchlike. */ #ifndef SWIGRUNTIME @@ -51,14 +51,14 @@ /* Flags/methods for returning states. - The swig conversion methods, as ConvertPtr, return and integer + The SWIG conversion methods, as ConvertPtr, return and integer that tells if the conversion was successful or not. And if not, an error code can be returned (see swigerrors.swg for the codes). Use the following macros/flags to set or process the returning states. - In old swig versions, you usually write code as: + In old versions of SWIG, code such as the following was usually written: if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) { // success code @@ -66,7 +66,7 @@ //fail code } - Now you can be more explicit as: + Now you can be more explicit: int res = SWIG_ConvertPtr(obj,vptr,ty.flags); if (SWIG_IsOK(res)) { @@ -75,7 +75,7 @@ // fail code } - that seems to be the same, but now you can also do + which is the same really, but now you can also do Type *ptr; int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags); @@ -93,7 +93,7 @@ I.e., now SWIG_ConvertPtr can return new objects and you can identify the case and take care of the deallocation. Of course that - requires also to SWIG_ConvertPtr to return new result values, as + also requires SWIG_ConvertPtr to return new result values, such as int SWIG_ConvertPtr(obj, ptr,...) { if () { @@ -111,7 +111,7 @@ Of course, returning the plain '0(success)/-1(fail)' still works, but you can be more explicit by returning SWIG_BADOBJ, SWIG_ERROR or any of the - swig errors code. + SWIG errors code. Finally, if the SWIG_CASTRANK_MODE is enabled, the result code allows to return the 'cast rank', for example, if you have this @@ -125,9 +125,8 @@ fooi(1) // cast rank '0' just use the SWIG_AddCast()/SWIG_CheckState() +*/ - - */ #define SWIG_OK (0) #define SWIG_ERROR (-1) #define SWIG_IsOK(r) (r >= 0) @@ -152,7 +151,6 @@ #define SWIG_DelTmpMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_TMPOBJMASK) : r) #define SWIG_IsTmpObj(r) (SWIG_IsOK(r) && (r & SWIG_TMPOBJMASK)) - /* Cast-Rank Mode */ #if defined(SWIG_CASTRANK_MODE) # ifndef SWIG_TypeRank @@ -175,8 +173,6 @@ SWIGINTERNINLINE int SWIG_CheckState(int r) { #endif - - #include #ifdef __cplusplus @@ -273,40 +269,58 @@ SWIG_TypeCompare(const char *nb, const char *tb) { } -/* think of this as a c++ template<> or a scheme macro */ -#define SWIG_TypeCheck_Template(comparison, ty) \ - if (ty) { \ - swig_cast_info *iter = ty->cast; \ - while (iter) { \ - if (comparison) { \ - if (iter == ty->cast) return iter; \ - /* Move iter to the top of the linked list */ \ - iter->prev->next = iter->next; \ - if (iter->next) \ - iter->next->prev = iter->prev; \ - iter->next = ty->cast; \ - iter->prev = 0; \ - if (ty->cast) ty->cast->prev = iter; \ - ty->cast = iter; \ - return iter; \ - } \ - iter = iter->next; \ - } \ - } \ - return 0 - /* Check the typename */ SWIGRUNTIME swig_cast_info * SWIG_TypeCheck(const char *c, swig_type_info *ty) { - SWIG_TypeCheck_Template(strcmp(iter->type->name, c) == 0, ty); + if (ty) { + swig_cast_info *iter = ty->cast; + while (iter) { + if (strcmp(iter->type->name, c) == 0) { + if (iter == ty->cast) + return iter; + /* Move iter to the top of the linked list */ + iter->prev->next = iter->next; + if (iter->next) + iter->next->prev = iter->prev; + iter->next = ty->cast; + iter->prev = 0; + if (ty->cast) ty->cast->prev = iter; + ty->cast = iter; + return iter; + } + iter = iter->next; + } + } + return 0; } -/* Same as previous function, except strcmp is replaced with a pointer comparison */ +/* + Identical to SWIG_TypeCheck, except strcmp is replaced with a pointer comparison +*/ SWIGRUNTIME swig_cast_info * -SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *into) { - SWIG_TypeCheck_Template(iter->type == from, into); +SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *ty) { + if (ty) { + swig_cast_info *iter = ty->cast; + while (iter) { + if (iter->type == from) { + if (iter == ty->cast) + return iter; + /* Move iter to the top of the linked list */ + iter->prev->next = iter->next; + if (iter->next) + iter->next->prev = iter->prev; + iter->next = ty->cast; + iter->prev = 0; + if (ty->cast) ty->cast->prev = iter; + ty->cast = iter; + return iter; + } + iter = iter->next; + } + } + return 0; } /* From bcc796f676ef7e871cdc44a096d74f1da92e232d Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 6 Dec 2008 21:40:54 +0000 Subject: [PATCH 0211/1680] modify build system to use php instead of php4 git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10967 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/Makefile.in | 34 +++++++------- Examples/php/class/Makefile | 10 ++-- Examples/php/class/{runme.php4 => runme.php} | 0 Examples/php/constants/Makefile | 10 ++-- .../php/constants/{runme.php4 => runme.php} | 0 Examples/php/cpointer/Makefile | 10 ++-- .../php/cpointer/{runme.php4 => runme.php} | 0 Examples/php/disown/Makefile | 10 ++-- Examples/php/disown/{runme.php4 => runme.php} | 0 Examples/php/enum/Makefile | 10 ++-- Examples/php/enum/{runme.php4 => runme.php} | 0 Examples/php/funcptr/Makefile | 10 ++-- .../php/funcptr/{runme.php4 => runme.php} | 0 Examples/php/overloading/Makefile | 10 ++-- .../php/overloading/{runme.php4 => runme.php} | 0 Examples/php/pointer/Makefile | 10 ++-- .../php/pointer/{runme.php4 => runme.php} | 0 Examples/php/pragmas/Makefile | 10 ++-- .../php/pragmas/{runme.php4 => runme.php} | 0 Examples/php/proxy/Makefile | 10 ++-- Examples/php/proxy/{runme.php4 => runme.php} | 0 Examples/php/reference/Makefile | 10 ++-- .../php/reference/{runme.php4 => runme.php} | 0 Examples/php/simple/Makefile | 10 ++-- Examples/php/simple/{runme.php4 => runme.php} | 0 Examples/php/sync/Makefile | 10 ++-- Examples/php/sync/{runme.php4 => runme.php} | 0 Examples/php/value/Makefile | 10 ++-- Examples/php/value/{runme.php4 => runme.php} | 0 Examples/php/variables/Makefile | 10 ++-- .../php/variables/{runme.php4 => runme.php} | 0 Examples/test-suite/php/Makefile.in | 22 ++++----- ...nme.php4 => abstract_inherit_ok_runme.php} | 2 +- ..._runme.php4 => abstract_inherit_runme.php} | 2 +- ...add_link_runme.php4 => add_link_runme.php} | 2 +- .../{argout_runme.php4 => argout_runme.php} | 2 +- ...arrayptr_runme.php4 => arrayptr_runme.php} | 2 +- ...bal_runme.php4 => arrays_global_runme.php} | 2 +- ...me.php4 => arrays_global_twodim_runme.php} | 2 +- .../{arrays_runme.php4 => arrays_runme.php} | 2 +- ...cope_runme.php4 => arrays_scope_runme.php} | 2 +- .../php/{casts_runme.php4 => casts_runme.php} | 2 +- ...nore_runme.php4 => class_ignore_runme.php} | 2 +- ...me.php4 => conversion_namespace_runme.php} | 2 +- ....php4 => conversion_ns_template_runme.php} | 2 +- ...ersion_runme.php4 => conversion_runme.php} | 2 +- ...static_runme.php4 => cpp_static_runme.php} | 2 +- ...nme.php4 => enum_scope_template_runme.php} | 2 +- ...s_runme.php4 => evil_diamond_ns_runme.php} | 2 +- ...runme.php4 => evil_diamond_prop_runme.php} | 2 +- ...mond_runme.php4 => evil_diamond_runme.php} | 2 +- ...unme.php4 => extend_template_ns_runme.php} | 2 +- ...e_runme.php4 => extend_template_runme.php} | 2 +- ...grouping_runme.php4 => grouping_runme.php} | 2 +- ..._runme.php4 => ignore_parameter_runme.php} | 2 +- ...arrays_runme.php4 => li_carrays_runme.php} | 2 +- ...ing_runme.php4 => li_std_string_runme.php} | 2 +- ...cope_runme.php4 => rename_scope_runme.php} | 2 +- .../test-suite/php/{skel.php4 => skel.php} | 2 +- ...me.php4 => smart_pointer_rename_runme.php} | 2 +- .../php/{sym_runme.php4 => sym_runme.php} | 2 +- ...e.php4 => template_arg_typename_runme.php} | 2 +- ...unme.php4 => template_construct_runme.php} | 2 +- .../test-suite/php/{tests.php4 => tests.php} | 0 ...runme.php4 => typedef_reference_runme.php} | 2 +- ..._runme.php4 => typemap_ns_using_runme.php} | 2 +- .../{using1_runme.php4 => using1_runme.php} | 2 +- .../{using2_runme.php4 => using2_runme.php} | 2 +- ...runme.php4 => valuewrapper_base_runme.php} | 2 +- Makefile.in | 2 +- configure.in | 46 +++++++++---------- 71 files changed, 163 insertions(+), 163 deletions(-) rename Examples/php/class/{runme.php4 => runme.php} (100%) rename Examples/php/constants/{runme.php4 => runme.php} (100%) rename Examples/php/cpointer/{runme.php4 => runme.php} (100%) rename Examples/php/disown/{runme.php4 => runme.php} (100%) rename Examples/php/enum/{runme.php4 => runme.php} (100%) rename Examples/php/funcptr/{runme.php4 => runme.php} (100%) rename Examples/php/overloading/{runme.php4 => runme.php} (100%) rename Examples/php/pointer/{runme.php4 => runme.php} (100%) rename Examples/php/pragmas/{runme.php4 => runme.php} (100%) rename Examples/php/proxy/{runme.php4 => runme.php} (100%) rename Examples/php/reference/{runme.php4 => runme.php} (100%) rename Examples/php/simple/{runme.php4 => runme.php} (100%) rename Examples/php/sync/{runme.php4 => runme.php} (100%) rename Examples/php/value/{runme.php4 => runme.php} (100%) rename Examples/php/variables/{runme.php4 => runme.php} (100%) rename Examples/test-suite/php/{abstract_inherit_ok_runme.php4 => abstract_inherit_ok_runme.php} (88%) rename Examples/test-suite/php/{abstract_inherit_runme.php4 => abstract_inherit_runme.php} (93%) rename Examples/test-suite/php/{add_link_runme.php4 => add_link_runme.php} (95%) rename Examples/test-suite/php/{argout_runme.php4 => argout_runme.php} (97%) rename Examples/test-suite/php/{arrayptr_runme.php4 => arrayptr_runme.php} (90%) rename Examples/test-suite/php/{arrays_global_runme.php4 => arrays_global_runme.php} (96%) rename Examples/test-suite/php/{arrays_global_twodim_runme.php4 => arrays_global_twodim_runme.php} (97%) rename Examples/test-suite/php/{arrays_runme.php4 => arrays_runme.php} (95%) rename Examples/test-suite/php/{arrays_scope_runme.php4 => arrays_scope_runme.php} (92%) rename Examples/test-suite/php/{casts_runme.php4 => casts_runme.php} (93%) rename Examples/test-suite/php/{class_ignore_runme.php4 => class_ignore_runme.php} (93%) rename Examples/test-suite/php/{conversion_namespace_runme.php4 => conversion_namespace_runme.php} (90%) rename Examples/test-suite/php/{conversion_ns_template_runme.php4 => conversion_ns_template_runme.php} (89%) rename Examples/test-suite/php/{conversion_runme.php4 => conversion_runme.php} (90%) rename Examples/test-suite/php/{cpp_static_runme.php4 => cpp_static_runme.php} (91%) rename Examples/test-suite/php/{enum_scope_template_runme.php4 => enum_scope_template_runme.php} (96%) rename Examples/test-suite/php/{evil_diamond_ns_runme.php4 => evil_diamond_ns_runme.php} (94%) rename Examples/test-suite/php/{evil_diamond_prop_runme.php4 => evil_diamond_prop_runme.php} (97%) rename Examples/test-suite/php/{evil_diamond_runme.php4 => evil_diamond_runme.php} (93%) rename Examples/test-suite/php/{extend_template_ns_runme.php4 => extend_template_ns_runme.php} (91%) rename Examples/test-suite/php/{extend_template_runme.php4 => extend_template_runme.php} (90%) rename Examples/test-suite/php/{grouping_runme.php4 => grouping_runme.php} (96%) rename Examples/test-suite/php/{ignore_parameter_runme.php4 => ignore_parameter_runme.php} (98%) rename Examples/test-suite/php/{li_carrays_runme.php4 => li_carrays_runme.php} (92%) rename Examples/test-suite/php/{li_std_string_runme.php4 => li_std_string_runme.php} (98%) rename Examples/test-suite/php/{rename_scope_runme.php4 => rename_scope_runme.php} (96%) rename Examples/test-suite/php/{skel.php4 => skel.php} (90%) rename Examples/test-suite/php/{smart_pointer_rename_runme.php4 => smart_pointer_rename_runme.php} (97%) rename Examples/test-suite/php/{sym_runme.php4 => sym_runme.php} (95%) rename Examples/test-suite/php/{template_arg_typename_runme.php4 => template_arg_typename_runme.php} (94%) rename Examples/test-suite/php/{template_construct_runme.php4 => template_construct_runme.php} (88%) rename Examples/test-suite/php/{tests.php4 => tests.php} (100%) rename Examples/test-suite/php/{typedef_reference_runme.php4 => typedef_reference_runme.php} (93%) rename Examples/test-suite/php/{typemap_ns_using_runme.php4 => typemap_ns_using_runme.php} (89%) rename Examples/test-suite/php/{using1_runme.php4 => using1_runme.php} (88%) rename Examples/test-suite/php/{using2_runme.php4 => using2_runme.php} (88%) rename Examples/test-suite/php/{valuewrapper_base_runme.php4 => valuewrapper_base_runme.php} (91%) diff --git a/Examples/Makefile.in b/Examples/Makefile.in index 5dbf8b6b7..b95c7e33d 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -746,41 +746,41 @@ ruby_clean: ################################################################## # ------------------------------------------------------------------- -# Build a PHP4 dynamically loadable module (C) +# Build a PHP dynamically loadable module (C) # ------------------------------------------------------------------- -PHP4_INCLUDE = @PHP4INC@ -PHP4_SO = @PHP4_SO@ +PHP_INCLUDE = @PHPINC@ +PHP_SO = @PHP_SO@ -php4: $(SRCS) +php: $(SRCS) $(SWIG) -php5 $(SWIGOPT) $(INTERFACEPATH) - $(CC) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) $(PHP4_INCLUDE) - $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(PHP4_SO) + $(CC) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) $(PHP_INCLUDE) + $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(PHP_SO) # -------------------------------------------------------------------- -# Build a PHP4 dynamically loadable module (C++) +# Build a PHP dynamically loadable module (C++) # -------------------------------------------------------------------- -php4_cpp: $(SRCS) +php_cpp: $(SRCS) $(SWIG) -php5 -cppext cxx -c++ $(SWIGOPT) $(INTERFACEPATH) - $(CXX) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(PHP4_INCLUDE) - $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(PHP4_SO) + $(CXX) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(PHP_INCLUDE) + $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(PHP_SO) # ----------------------------------------------------------------- -# Running a PHP4 example +# Running a PHP example # ----------------------------------------------------------------- -PHP4=@PHP4@ -PHP4SCRIPT ?= runme.php4 +PHP=@PHP@ +PHPSCRIPT ?= runme.php -php4_run: - env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(PHP4) -n -q -d extension_dir=. $(PHP4SCRIPT) +php_run: + env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(PHP) -n -q -d extension_dir=. $(PHPSCRIPT) # ----------------------------------------------------------------- -# Cleaning the PHP4 examples +# Cleaning the PHP examples # ----------------------------------------------------------------- -php4_clean: +php_clean: rm -f *_wrap* *~ .~* example.php php_example.h rm -f core @EXTRA_CLEAN@ rm -f *.@OBJEXT@ *@SO@ diff --git a/Examples/php/class/Makefile b/Examples/php/class/Makefile index 39c4d2f23..252a72660 100644 --- a/Examples/php/class/Makefile +++ b/Examples/php/class/Makefile @@ -9,16 +9,16 @@ SWIGOPT = -noproxy all:: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ - php4_cpp + php_cpp static:: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='myphp4' INTERFACE='$(INTERFACE)' \ - php4_cpp_static + SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ + php_cpp_static clean:: - $(MAKE) -f $(TOP)/Makefile php4_clean + $(MAKE) -f $(TOP)/Makefile php_clean rm -f $(TARGET).php check: all - $(MAKE) -f $(TOP)/Makefile php4_run + $(MAKE) -f $(TOP)/Makefile php_run diff --git a/Examples/php/class/runme.php4 b/Examples/php/class/runme.php similarity index 100% rename from Examples/php/class/runme.php4 rename to Examples/php/class/runme.php diff --git a/Examples/php/constants/Makefile b/Examples/php/constants/Makefile index aed110eb2..23e2675d7 100644 --- a/Examples/php/constants/Makefile +++ b/Examples/php/constants/Makefile @@ -9,16 +9,16 @@ SWIGOPT = all:: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ - php4 + php static:: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='myphp4' INTERFACE='$(INTERFACE)' \ - php4_static + SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ + php_static clean:: - $(MAKE) -f $(TOP)/Makefile php4_clean + $(MAKE) -f $(TOP)/Makefile php_clean rm -f $(TARGET).php check: all - $(MAKE) -f $(TOP)/Makefile php4_run + $(MAKE) -f $(TOP)/Makefile php_run diff --git a/Examples/php/constants/runme.php4 b/Examples/php/constants/runme.php similarity index 100% rename from Examples/php/constants/runme.php4 rename to Examples/php/constants/runme.php diff --git a/Examples/php/cpointer/Makefile b/Examples/php/cpointer/Makefile index caeec2d73..0862ce5ec 100644 --- a/Examples/php/cpointer/Makefile +++ b/Examples/php/cpointer/Makefile @@ -9,16 +9,16 @@ SWIGOPT = all:: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ - php4 + php static:: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='myphp4' INTERFACE='$(INTERFACE)' \ - php4_static + SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ + php_static clean:: - $(MAKE) -f $(TOP)/Makefile php4_clean + $(MAKE) -f $(TOP)/Makefile php_clean rm -f $(TARGET).php check: all - $(MAKE) -f $(TOP)/Makefile php4_run + $(MAKE) -f $(TOP)/Makefile php_run diff --git a/Examples/php/cpointer/runme.php4 b/Examples/php/cpointer/runme.php similarity index 100% rename from Examples/php/cpointer/runme.php4 rename to Examples/php/cpointer/runme.php diff --git a/Examples/php/disown/Makefile b/Examples/php/disown/Makefile index ef3acc773..1bc0beaab 100644 --- a/Examples/php/disown/Makefile +++ b/Examples/php/disown/Makefile @@ -9,16 +9,16 @@ SWIGOPT = all:: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ - php4_cpp + php_cpp static:: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='myphp4' INTERFACE='$(INTERFACE)' \ - php4_cpp_static + SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ + php_cpp_static clean:: - $(MAKE) -f $(TOP)/Makefile php4_clean + $(MAKE) -f $(TOP)/Makefile php_clean rm -f $(TARGET).php check: all - $(MAKE) -f $(TOP)/Makefile php4_run + $(MAKE) -f $(TOP)/Makefile php_run diff --git a/Examples/php/disown/runme.php4 b/Examples/php/disown/runme.php similarity index 100% rename from Examples/php/disown/runme.php4 rename to Examples/php/disown/runme.php diff --git a/Examples/php/enum/Makefile b/Examples/php/enum/Makefile index 39c4d2f23..252a72660 100644 --- a/Examples/php/enum/Makefile +++ b/Examples/php/enum/Makefile @@ -9,16 +9,16 @@ SWIGOPT = -noproxy all:: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ - php4_cpp + php_cpp static:: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='myphp4' INTERFACE='$(INTERFACE)' \ - php4_cpp_static + SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ + php_cpp_static clean:: - $(MAKE) -f $(TOP)/Makefile php4_clean + $(MAKE) -f $(TOP)/Makefile php_clean rm -f $(TARGET).php check: all - $(MAKE) -f $(TOP)/Makefile php4_run + $(MAKE) -f $(TOP)/Makefile php_run diff --git a/Examples/php/enum/runme.php4 b/Examples/php/enum/runme.php similarity index 100% rename from Examples/php/enum/runme.php4 rename to Examples/php/enum/runme.php diff --git a/Examples/php/funcptr/Makefile b/Examples/php/funcptr/Makefile index caeec2d73..0862ce5ec 100644 --- a/Examples/php/funcptr/Makefile +++ b/Examples/php/funcptr/Makefile @@ -9,16 +9,16 @@ SWIGOPT = all:: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ - php4 + php static:: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='myphp4' INTERFACE='$(INTERFACE)' \ - php4_static + SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ + php_static clean:: - $(MAKE) -f $(TOP)/Makefile php4_clean + $(MAKE) -f $(TOP)/Makefile php_clean rm -f $(TARGET).php check: all - $(MAKE) -f $(TOP)/Makefile php4_run + $(MAKE) -f $(TOP)/Makefile php_run diff --git a/Examples/php/funcptr/runme.php4 b/Examples/php/funcptr/runme.php similarity index 100% rename from Examples/php/funcptr/runme.php4 rename to Examples/php/funcptr/runme.php diff --git a/Examples/php/overloading/Makefile b/Examples/php/overloading/Makefile index ef3acc773..1bc0beaab 100644 --- a/Examples/php/overloading/Makefile +++ b/Examples/php/overloading/Makefile @@ -9,16 +9,16 @@ SWIGOPT = all:: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ - php4_cpp + php_cpp static:: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='myphp4' INTERFACE='$(INTERFACE)' \ - php4_cpp_static + SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ + php_cpp_static clean:: - $(MAKE) -f $(TOP)/Makefile php4_clean + $(MAKE) -f $(TOP)/Makefile php_clean rm -f $(TARGET).php check: all - $(MAKE) -f $(TOP)/Makefile php4_run + $(MAKE) -f $(TOP)/Makefile php_run diff --git a/Examples/php/overloading/runme.php4 b/Examples/php/overloading/runme.php similarity index 100% rename from Examples/php/overloading/runme.php4 rename to Examples/php/overloading/runme.php diff --git a/Examples/php/pointer/Makefile b/Examples/php/pointer/Makefile index caeec2d73..0862ce5ec 100644 --- a/Examples/php/pointer/Makefile +++ b/Examples/php/pointer/Makefile @@ -9,16 +9,16 @@ SWIGOPT = all:: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ - php4 + php static:: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='myphp4' INTERFACE='$(INTERFACE)' \ - php4_static + SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ + php_static clean:: - $(MAKE) -f $(TOP)/Makefile php4_clean + $(MAKE) -f $(TOP)/Makefile php_clean rm -f $(TARGET).php check: all - $(MAKE) -f $(TOP)/Makefile php4_run + $(MAKE) -f $(TOP)/Makefile php_run diff --git a/Examples/php/pointer/runme.php4 b/Examples/php/pointer/runme.php similarity index 100% rename from Examples/php/pointer/runme.php4 rename to Examples/php/pointer/runme.php diff --git a/Examples/php/pragmas/Makefile b/Examples/php/pragmas/Makefile index aed110eb2..23e2675d7 100644 --- a/Examples/php/pragmas/Makefile +++ b/Examples/php/pragmas/Makefile @@ -9,16 +9,16 @@ SWIGOPT = all:: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ - php4 + php static:: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='myphp4' INTERFACE='$(INTERFACE)' \ - php4_static + SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ + php_static clean:: - $(MAKE) -f $(TOP)/Makefile php4_clean + $(MAKE) -f $(TOP)/Makefile php_clean rm -f $(TARGET).php check: all - $(MAKE) -f $(TOP)/Makefile php4_run + $(MAKE) -f $(TOP)/Makefile php_run diff --git a/Examples/php/pragmas/runme.php4 b/Examples/php/pragmas/runme.php similarity index 100% rename from Examples/php/pragmas/runme.php4 rename to Examples/php/pragmas/runme.php diff --git a/Examples/php/proxy/Makefile b/Examples/php/proxy/Makefile index ef3acc773..1bc0beaab 100644 --- a/Examples/php/proxy/Makefile +++ b/Examples/php/proxy/Makefile @@ -9,16 +9,16 @@ SWIGOPT = all:: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ - php4_cpp + php_cpp static:: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='myphp4' INTERFACE='$(INTERFACE)' \ - php4_cpp_static + SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ + php_cpp_static clean:: - $(MAKE) -f $(TOP)/Makefile php4_clean + $(MAKE) -f $(TOP)/Makefile php_clean rm -f $(TARGET).php check: all - $(MAKE) -f $(TOP)/Makefile php4_run + $(MAKE) -f $(TOP)/Makefile php_run diff --git a/Examples/php/proxy/runme.php4 b/Examples/php/proxy/runme.php similarity index 100% rename from Examples/php/proxy/runme.php4 rename to Examples/php/proxy/runme.php diff --git a/Examples/php/reference/Makefile b/Examples/php/reference/Makefile index 39c4d2f23..252a72660 100644 --- a/Examples/php/reference/Makefile +++ b/Examples/php/reference/Makefile @@ -9,16 +9,16 @@ SWIGOPT = -noproxy all:: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ - php4_cpp + php_cpp static:: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='myphp4' INTERFACE='$(INTERFACE)' \ - php4_cpp_static + SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ + php_cpp_static clean:: - $(MAKE) -f $(TOP)/Makefile php4_clean + $(MAKE) -f $(TOP)/Makefile php_clean rm -f $(TARGET).php check: all - $(MAKE) -f $(TOP)/Makefile php4_run + $(MAKE) -f $(TOP)/Makefile php_run diff --git a/Examples/php/reference/runme.php4 b/Examples/php/reference/runme.php similarity index 100% rename from Examples/php/reference/runme.php4 rename to Examples/php/reference/runme.php diff --git a/Examples/php/simple/Makefile b/Examples/php/simple/Makefile index caeec2d73..0862ce5ec 100644 --- a/Examples/php/simple/Makefile +++ b/Examples/php/simple/Makefile @@ -9,16 +9,16 @@ SWIGOPT = all:: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ - php4 + php static:: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='myphp4' INTERFACE='$(INTERFACE)' \ - php4_static + SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ + php_static clean:: - $(MAKE) -f $(TOP)/Makefile php4_clean + $(MAKE) -f $(TOP)/Makefile php_clean rm -f $(TARGET).php check: all - $(MAKE) -f $(TOP)/Makefile php4_run + $(MAKE) -f $(TOP)/Makefile php_run diff --git a/Examples/php/simple/runme.php4 b/Examples/php/simple/runme.php similarity index 100% rename from Examples/php/simple/runme.php4 rename to Examples/php/simple/runme.php diff --git a/Examples/php/sync/Makefile b/Examples/php/sync/Makefile index ef3acc773..1bc0beaab 100644 --- a/Examples/php/sync/Makefile +++ b/Examples/php/sync/Makefile @@ -9,16 +9,16 @@ SWIGOPT = all:: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ - php4_cpp + php_cpp static:: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='myphp4' INTERFACE='$(INTERFACE)' \ - php4_cpp_static + SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ + php_cpp_static clean:: - $(MAKE) -f $(TOP)/Makefile php4_clean + $(MAKE) -f $(TOP)/Makefile php_clean rm -f $(TARGET).php check: all - $(MAKE) -f $(TOP)/Makefile php4_run + $(MAKE) -f $(TOP)/Makefile php_run diff --git a/Examples/php/sync/runme.php4 b/Examples/php/sync/runme.php similarity index 100% rename from Examples/php/sync/runme.php4 rename to Examples/php/sync/runme.php diff --git a/Examples/php/value/Makefile b/Examples/php/value/Makefile index cc383ea3f..9e69d00a4 100644 --- a/Examples/php/value/Makefile +++ b/Examples/php/value/Makefile @@ -9,16 +9,16 @@ SWIGOPT = -noproxy all:: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ - php4 + php static:: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='myphp4' INTERFACE='$(INTERFACE)' \ - php4_static + SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ + php_static clean:: - $(MAKE) -f $(TOP)/Makefile php4_clean + $(MAKE) -f $(TOP)/Makefile php_clean rm -f $(TARGET).php check: all - $(MAKE) -f $(TOP)/Makefile php4_run + $(MAKE) -f $(TOP)/Makefile php_run diff --git a/Examples/php/value/runme.php4 b/Examples/php/value/runme.php similarity index 100% rename from Examples/php/value/runme.php4 rename to Examples/php/value/runme.php diff --git a/Examples/php/variables/Makefile b/Examples/php/variables/Makefile index caeec2d73..0862ce5ec 100644 --- a/Examples/php/variables/Makefile +++ b/Examples/php/variables/Makefile @@ -9,16 +9,16 @@ SWIGOPT = all:: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ - php4 + php static:: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='myphp4' INTERFACE='$(INTERFACE)' \ - php4_static + SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ + php_static clean:: - $(MAKE) -f $(TOP)/Makefile php4_clean + $(MAKE) -f $(TOP)/Makefile php_clean rm -f $(TARGET).php check: all - $(MAKE) -f $(TOP)/Makefile php4_run + $(MAKE) -f $(TOP)/Makefile php_run diff --git a/Examples/php/variables/runme.php4 b/Examples/php/variables/runme.php similarity index 100% rename from Examples/php/variables/runme.php4 rename to Examples/php/variables/runme.php diff --git a/Examples/test-suite/php/Makefile.in b/Examples/test-suite/php/Makefile.in index 9f412bc56..b8aeaaa11 100644 --- a/Examples/test-suite/php/Makefile.in +++ b/Examples/test-suite/php/Makefile.in @@ -1,9 +1,9 @@ ####################################################################### -# Makefile for php4 test-suite +# Makefile for php test-suite ####################################################################### -LANGUAGE = php4 -SCRIPTSUFFIX = _runme.php4 +LANGUAGE = php +SCRIPTSUFFIX = _runme.php srcdir = @srcdir@ top_srcdir = @top_srcdir@ top_builddir = @top_builddir@ @@ -25,19 +25,19 @@ makectests: @bash -ec 'for test in $(C_TEST_CASES) ; do $($(MAKE)) clean && $(MAKE) $${test}.cpptest; done' runcpptests: - @bash -ec 'for test in $(CPP_TEST_CASES) ; do if [ -f $${test}_runme.php4 ] ; then $(MAKE) clean && $(MAKE) $${test}.cpptest; fi ; done' + @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.php4 ] ; then $(MAKE) clean && $(MAKE) $${test}.cpptest; fi; done' + @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.php4 +# write out tests without a _runme.php missingcpptests: - @bash -ec 'for test in $(CPP_TEST_CASES) ; do test -f $${test}_runme.php4 || echo $${test}; done' + @bash -ec '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.php4 || echo $${test}; done' + @bash -ec 'for test in $(C_TEST_CASES) ; do test -f $${test}_runme.php || echo $${test}; done' missingtests: missingcpptests missingctests @@ -58,10 +58,10 @@ missingtests: missingcpptests missingctests +$(run_testcase) # Runs the testcase. A testcase is only run if -# a file is found which has _runme.php4 appended after the testcase name. +# a file is found which has _runme.php appended after the testcase name. run_testcase = \ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then ( \ - $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile PHP4SCRIPT=$(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) RUNTOOL=$(RUNTOOL) php4_run;) \ + $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile PHPSCRIPT=$(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) RUNTOOL=$(RUNTOOL) php_run;) \ fi; # Clean: remove the generated .php file @@ -69,4 +69,4 @@ run_testcase = \ @rm -f $*.php; clean: - $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile php4_clean + $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile php_clean diff --git a/Examples/test-suite/php/abstract_inherit_ok_runme.php4 b/Examples/test-suite/php/abstract_inherit_ok_runme.php similarity index 88% rename from Examples/test-suite/php/abstract_inherit_ok_runme.php4 rename to Examples/test-suite/php/abstract_inherit_ok_runme.php index 1182e4cec..c2d86499b 100644 --- a/Examples/test-suite/php/abstract_inherit_ok_runme.php4 +++ b/Examples/test-suite/php/abstract_inherit_ok_runme.php @@ -1,6 +1,6 @@ /usr/bin/php-config5 - case $PHP4 in + case $PHP in *5) - PHP4CONFIG=`echo "$PHP4"|sed 's/5$/-config5/'` ;; + PHPCONFIG=`echo "$PHP"|sed 's/5$/-config5/'` ;; *) - PHP4CONFIG=$PHP4-config ;; + PHPCONFIG=$PHP-config ;; esac - php_version=`$PHP4CONFIG --version 2>/dev/null` + php_version=`$PHPCONFIG --version 2>/dev/null` case $php_version in 5*) - PHP4INC=`$PHP4CONFIG --includes 2>/dev/null` - if test -n "$PHP4INC"; then - AC_MSG_RESULT($PHP4INC) + PHPINC=`$PHPCONFIG --includes 2>/dev/null` + if test -n "$PHPINC"; then + AC_MSG_RESULT($PHPINC) else AC_MSG_RESULT(not found) fi @@ -1368,8 +1368,8 @@ else AC_MSG_RESULT([found PHP $version, but only PHP 5 is supported]) ;; esac fi -AC_SUBST(PHP4) -AC_SUBST(PHP4INC) +AC_SUBST(PHP) +AC_SUBST(PHPINC) #---------------------------------------------------------------- # Look for ocaml @@ -2003,11 +2003,11 @@ fi AC_SUBST(SKIP_RUBY) -SKIP_PHP4= -if test -z "$PHP4" || test -z "$PHP4INC" ; then - SKIP_PHP4="1" +SKIP_PHP= +if test -z "$PHP" || test -z "$PHPINC" ; then + SKIP_PHP="1" fi -AC_SUBST(SKIP_PHP4) +AC_SUBST(SKIP_PHP) SKIP_OCAML= From a5fcddceca1f55432928af02530c873cb7992382 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 6 Dec 2008 21:55:15 +0000 Subject: [PATCH 0212/1680] modify build system to use php instead of php4 git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10968 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/GIFPlot/{Php4 => Php}/check.list | 0 Examples/GIFPlot/{Php4 => Php}/full/Makefile | 4 ++-- Examples/GIFPlot/{Php4 => Php}/full/README | 0 Examples/GIFPlot/{Php4 => Php}/full/cmap | Bin Examples/GIFPlot/{Php4 => Php}/full/gifplot.i | 0 .../{Php4/full/runme.php4 => Php/full/runme.php} | 0 Examples/GIFPlot/{Php4 => Php}/shadow/Makefile | 4 ++-- Examples/GIFPlot/{Php4 => Php}/shadow/README | 0 Examples/GIFPlot/{Php4 => Php}/shadow/cmap | Bin .../shadow/runme.php4 => Php/shadow/runme.php} | 0 Examples/GIFPlot/{Php4 => Php}/simple/Makefile | 4 ++-- Examples/GIFPlot/{Php4 => Php}/simple/README | 0 .../simple/runme.php4 => Php/simple/runme.php} | 0 Examples/GIFPlot/{Php4 => Php}/simple/simple.i | 0 14 files changed, 6 insertions(+), 6 deletions(-) rename Examples/GIFPlot/{Php4 => Php}/check.list (100%) rename Examples/GIFPlot/{Php4 => Php}/full/Makefile (81%) rename Examples/GIFPlot/{Php4 => Php}/full/README (100%) rename Examples/GIFPlot/{Php4 => Php}/full/cmap (100%) rename Examples/GIFPlot/{Php4 => Php}/full/gifplot.i (100%) rename Examples/GIFPlot/{Php4/full/runme.php4 => Php/full/runme.php} (100%) rename Examples/GIFPlot/{Php4 => Php}/shadow/Makefile (80%) rename Examples/GIFPlot/{Php4 => Php}/shadow/README (100%) rename Examples/GIFPlot/{Php4 => Php}/shadow/cmap (100%) rename Examples/GIFPlot/{Php4/shadow/runme.php4 => Php/shadow/runme.php} (100%) rename Examples/GIFPlot/{Php4 => Php}/simple/Makefile (80%) rename Examples/GIFPlot/{Php4 => Php}/simple/README (100%) rename Examples/GIFPlot/{Php4/simple/runme.php4 => Php/simple/runme.php} (100%) rename Examples/GIFPlot/{Php4 => Php}/simple/simple.i (100%) diff --git a/Examples/GIFPlot/Php4/check.list b/Examples/GIFPlot/Php/check.list similarity index 100% rename from Examples/GIFPlot/Php4/check.list rename to Examples/GIFPlot/Php/check.list diff --git a/Examples/GIFPlot/Php4/full/Makefile b/Examples/GIFPlot/Php/full/Makefile similarity index 81% rename from Examples/GIFPlot/Php4/full/Makefile rename to Examples/GIFPlot/Php/full/Makefile index 3aa632b99..e33e7a730 100644 --- a/Examples/GIFPlot/Php4/full/Makefile +++ b/Examples/GIFPlot/Php/full/Makefile @@ -10,10 +10,10 @@ INCLUDES = -I../../Include all:: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' php4 + TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' php clean:: - $(MAKE) -f $(TOP)/Makefile php4_clean + $(MAKE) -f $(TOP)/Makefile php_clean rm -f *.gif rm -f php_gifplot.h diff --git a/Examples/GIFPlot/Php4/full/README b/Examples/GIFPlot/Php/full/README similarity index 100% rename from Examples/GIFPlot/Php4/full/README rename to Examples/GIFPlot/Php/full/README diff --git a/Examples/GIFPlot/Php4/full/cmap b/Examples/GIFPlot/Php/full/cmap similarity index 100% rename from Examples/GIFPlot/Php4/full/cmap rename to Examples/GIFPlot/Php/full/cmap diff --git a/Examples/GIFPlot/Php4/full/gifplot.i b/Examples/GIFPlot/Php/full/gifplot.i similarity index 100% rename from Examples/GIFPlot/Php4/full/gifplot.i rename to Examples/GIFPlot/Php/full/gifplot.i diff --git a/Examples/GIFPlot/Php4/full/runme.php4 b/Examples/GIFPlot/Php/full/runme.php similarity index 100% rename from Examples/GIFPlot/Php4/full/runme.php4 rename to Examples/GIFPlot/Php/full/runme.php diff --git a/Examples/GIFPlot/Php4/shadow/Makefile b/Examples/GIFPlot/Php/shadow/Makefile similarity index 80% rename from Examples/GIFPlot/Php4/shadow/Makefile rename to Examples/GIFPlot/Php/shadow/Makefile index 5627e53a0..df8ee30c0 100644 --- a/Examples/GIFPlot/Php4/shadow/Makefile +++ b/Examples/GIFPlot/Php/shadow/Makefile @@ -10,10 +10,10 @@ INCLUDES = -I../../Include all:: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' php4 + TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' php clean:: - $(MAKE) -f $(TOP)/Makefile php4_clean + $(MAKE) -f $(TOP)/Makefile php_clean rm -f *.gif check: all diff --git a/Examples/GIFPlot/Php4/shadow/README b/Examples/GIFPlot/Php/shadow/README similarity index 100% rename from Examples/GIFPlot/Php4/shadow/README rename to Examples/GIFPlot/Php/shadow/README diff --git a/Examples/GIFPlot/Php4/shadow/cmap b/Examples/GIFPlot/Php/shadow/cmap similarity index 100% rename from Examples/GIFPlot/Php4/shadow/cmap rename to Examples/GIFPlot/Php/shadow/cmap diff --git a/Examples/GIFPlot/Php4/shadow/runme.php4 b/Examples/GIFPlot/Php/shadow/runme.php similarity index 100% rename from Examples/GIFPlot/Php4/shadow/runme.php4 rename to Examples/GIFPlot/Php/shadow/runme.php diff --git a/Examples/GIFPlot/Php4/simple/Makefile b/Examples/GIFPlot/Php/simple/Makefile similarity index 80% rename from Examples/GIFPlot/Php4/simple/Makefile rename to Examples/GIFPlot/Php/simple/Makefile index 6903bec0b..e60b641fa 100644 --- a/Examples/GIFPlot/Php4/simple/Makefile +++ b/Examples/GIFPlot/Php/simple/Makefile @@ -10,10 +10,10 @@ INCLUDES = -I../../Include all:: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' php4 + TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' php clean:: - $(MAKE) -f $(TOP)/Makefile php4_clean + $(MAKE) -f $(TOP)/Makefile php_clean rm -f *.gif rm -f php_simple.h diff --git a/Examples/GIFPlot/Php4/simple/README b/Examples/GIFPlot/Php/simple/README similarity index 100% rename from Examples/GIFPlot/Php4/simple/README rename to Examples/GIFPlot/Php/simple/README diff --git a/Examples/GIFPlot/Php4/simple/runme.php4 b/Examples/GIFPlot/Php/simple/runme.php similarity index 100% rename from Examples/GIFPlot/Php4/simple/runme.php4 rename to Examples/GIFPlot/Php/simple/runme.php diff --git a/Examples/GIFPlot/Php4/simple/simple.i b/Examples/GIFPlot/Php/simple/simple.i similarity index 100% rename from Examples/GIFPlot/Php4/simple/simple.i rename to Examples/GIFPlot/Php/simple/simple.i From 06b2eca75e456b14b030dd8813e9503ae2961fed Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 6 Dec 2008 23:15:20 +0000 Subject: [PATCH 0213/1680] remove last vestiges of php4 and encourage use of -php rather than -php5 git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10969 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 8 ++++++++ Doc/Manual/Extending.html | 2 +- Doc/Manual/Php.html | 12 ++++++------ Doc/Manual/Preprocessor.html | 1 - Doc/Manual/SWIG.html | 2 +- Doc/Manual/Warnings.html | 2 +- Examples/Makefile.in | 4 ++-- Examples/php/pragmas/example.i | 8 ++++---- Lib/allkw.swg | 2 +- Lib/php/phprun.swg | 8 ++++---- Lib/php/typemaps.i | 2 +- Source/Include/swigwarn.h | 4 ++-- Source/Modules/php.cxx | 16 ++++++++-------- Source/Modules/swigmain.cxx | 6 +++--- 14 files changed, 42 insertions(+), 35 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 915cbc732..8431febfd 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,14 @@ Version 1.3.37 (in progress) ============================ +2008-12-02: wsfulton + [PHP] Deprecate %pragma(php4). Please use %pragma(php) instead. + The following two warnings have been renamed: + WARN_PHP4_MULTIPLE_INHERITANCE -> WARN_PHP_MULTIPLE_INHERITANCE + WARN_PHP4_UNKNOWN_PRAGMA -> WARN_PHP_UNKNOWN_PRAGMA + + *** POTENTIAL INCOMPATIBILITY *** + 2008-12-04: bhy [Python] Applied patch SF#2158938: all the SWIG symbol names started with Py are changed, since they are inappropriate and discouraged in Python diff --git a/Doc/Manual/Extending.html b/Doc/Manual/Extending.html index 5639663a1..e4d5cdb92 100644 --- a/Doc/Manual/Extending.html +++ b/Doc/Manual/Extending.html @@ -3114,7 +3114,7 @@ entirely upcased.

    At the end of the new section is the place to put the aforementioned -nickname kludges (should they be needed). See Perl5 and Php4 for +nickname kludges (should they be needed). See Perl5 for examples of what to do. [If this is still unclear after you've read the code, ping me and I'll expand on this further. --ttn]

    diff --git a/Doc/Manual/Php.html b/Doc/Manual/Php.html index 20530ad86..aeb171b3f 100644 --- a/Doc/Manual/Php.html +++ b/Doc/Manual/Php.html @@ -413,7 +413,7 @@ Overloaded Functions and Methods. +
    + + +)) + + manpagename(ccache-swig)(a fast compiler cache) + +whenhtml(htmlcommand( +ccache-swig - a fast compiler cache +)) + manpagesynopsis() ccache-swig [OPTION] @@ -380,3 +406,10 @@ url(http://www.swig.org/mail.html)(http://www.swig.org/mail.html) ccache is released under the GNU General Public License version 2 or later. Please see the file COPYING for license details. + +whenhtml(htmlcommand( + + + + +)) diff --git a/CHANGES.current b/CHANGES.current index e2dc8ba81..27118706c 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,13 @@ Version 1.3.37 (in progress) ============================ +2008-12-20: wsfulton + The ccache compiler cache has been adapted to work with SWIG and + named ccache-swig. It now works with C/C++ compilers as well as SWIG + and can result in impressive speedups when used to recompile unchanged + code with either a C/C++ compiler or SWIG. Documentation is in CCache.html + or the installed ccache-swig man page. + 2008-12-12: wsfulton Apply patch from Kalyanov Dmitry which fixes parsing of nested structs containing comments. diff --git a/Doc/Manual/Makefile b/Doc/Manual/Makefile index dd11e0c84..4c907791b 100644 --- a/Doc/Manual/Makefile +++ b/Doc/Manual/Makefile @@ -18,15 +18,19 @@ HTMLDOC_OPTIONS = "--book --toclevels 4 --no-numbered --toctitle \"Table of Cont all: maketoc check generate -maketoc: +maketoc: CCache.html python maketoc.py +CCache.html: ../../CCache/ccache.yo + yodl2html -o CCache.html ../../CCache/ccache.yo + # Use htmltidy to warn about some HTML errors. Note that it is not used to clean/tidy the HTML, # it is just used as a primitive HTML checker. +# CCache.html is generated by yodl2html and has a few insignificant problems, so we don't put it through tidy check: tidy -errors --gnu-emacs yes -quiet index.html tidy -errors --gnu-emacs yes -quiet Sections.html - all=`sed '/^#/d' chapters`; for a in $$all; do tidy -errors --gnu-emacs yes -quiet $$a; done; + all=`sed '/^#/d' chapters | grep -v CCache.html`; for a in $$all; do tidy -errors --gnu-emacs yes -quiet $$a; done; generate: swightml.book swigpdf.book htmldoc --batch swightml.book || true @@ -48,6 +52,7 @@ swightml.book: clean: clean-baks rm -f swightml.book rm -f swigpdf.book + rm -f CCache.html rm -f SWIGDocumentation.html rm -f SWIGDocumentation.pdf diff --git a/Tools/mkdist.py b/Tools/mkdist.py index 3123adfea..1ef7c7e5c 100755 --- a/Tools/mkdist.py +++ b/Tools/mkdist.py @@ -57,7 +57,7 @@ os.system("find "+dirname+" -name autom4te.cache -exec rm -rf {} \\;") # Build documentation print "Building documentation" os.system("cd "+dirname+"/Doc/Manual && make all clean-baks") == 0 or failed() -os.system("cd "+dirname+"/CCache && yodl2man -o swig-ccache.1 ccache.yo && mkdir -p man && yodl2html -o web/ccache-man.html ccache.yo") == 0 or failed() +os.system("cd "+dirname+"/CCache && yodl2man -o swig-ccache.1 ccache.yo") == 0 or failed() # Build the tar-ball os.system("tar -cf "+dirname+".tar "+dirname) == 0 or failed() From 9ed9e006bcc5ffbabce51769e8c5238e74d5774d Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 20 Dec 2008 01:49:58 +0000 Subject: [PATCH 0235/1680] new section numbering since adding in ccache chapter git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10991 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Allegrocl.html | 108 ++++++++++---------- Doc/Manual/CSharp.html | 46 ++++----- Doc/Manual/Chicken.html | 40 ++++---- Doc/Manual/Contents.html | 66 ++++++++---- Doc/Manual/Extending.html | 96 +++++++++--------- Doc/Manual/Guile.html | 42 ++++---- Doc/Manual/Java.html | 204 +++++++++++++++++++------------------- Doc/Manual/Lisp.html | 22 ++-- Doc/Manual/Lua.html | 56 +++++------ Doc/Manual/Modula3.html | 46 ++++----- Doc/Manual/Modules.html | 14 +-- Doc/Manual/Mzscheme.html | 4 +- Doc/Manual/Ocaml.html | 62 ++++++------ Doc/Manual/Octave.html | 46 ++++----- Doc/Manual/Perl5.html | 94 +++++++++--------- Doc/Manual/Php.html | 32 +++--- Doc/Manual/Pike.html | 24 ++--- Doc/Manual/Python.html | 152 ++++++++++++++-------------- Doc/Manual/R.html | 16 +-- Doc/Manual/Ruby.html | 196 ++++++++++++++++++------------------ Doc/Manual/Sections.html | 1 + Doc/Manual/Tcl.html | 90 ++++++++--------- Doc/Manual/chapters | 1 + 23 files changed, 743 insertions(+), 715 deletions(-) diff --git a/Doc/Manual/Allegrocl.html b/Doc/Manual/Allegrocl.html index 8981f52b5..41309c9b4 100644 --- a/Doc/Manual/Allegrocl.html +++ b/Doc/Manual/Allegrocl.html @@ -8,7 +8,7 @@ -

    16 SWIG and Allegro Common Lisp

    +

    17 SWIG and Allegro Common Lisp

      @@ -135,10 +135,10 @@ be unhappy to see some enterprising folk use this work to add to it.

      -

      16.1 Basics

      +

      17.1 Basics

      -

      16.1.1 Running Swig

      +

      17.1.1 Running Swig

      @@ -360,7 +360,7 @@ need to link in the Allegro shared library. The library you create from the C++ wrapper will be what you then load into Allegro CL.

      -

      16.1.2 Command Line Options

      +

      17.1.2 Command Line Options

      @@ -396,7 +396,7 @@ See Section 17.5 Identifier converter functions for more details.

      -

      16.1.3 Inserting user code into generated files

      +

      17.1.3 Inserting user code into generated files

      @@ -436,7 +436,7 @@ Note that the block %{ ... %} is effectively a shortcut for

      -

      16.2 Wrapping Overview

      +

      17.2 Wrapping Overview

      @@ -446,7 +446,7 @@ New users to SWIG are encouraged to read interested in generating an interface to C++.

      -

      16.2.1 Function Wrapping

      +

      17.2.1 Function Wrapping

      @@ -499,7 +499,7 @@ interested in generating an interface to C++.

    -

    16.2.2 Foreign Wrappers

    +

    17.2.2 Foreign Wrappers

    @@ -512,7 +512,7 @@ interested in generating an interface to C++. typemap.

    -

    16.2.3 FFI Wrappers

    +

    17.2.3 FFI Wrappers

    @@ -593,7 +593,7 @@ char *xxx(); ff:def-foreign-call's.

    -

    16.2.4 Non-overloaded Defuns

    +

    17.2.4 Non-overloaded Defuns

    @@ -606,7 +606,7 @@ char *xxx(); this function can be manipulated via the lout typemap.

    -

    16.2.5 Overloaded Defuns

    +

    17.2.5 Overloaded Defuns

    @@ -622,7 +622,7 @@ char *xxx(); can be manipulated via the lout typemap.

    -

    16.2.6 What about constant and variable access?

    +

    17.2.6 What about constant and variable access?

    @@ -635,7 +635,7 @@ char *xxx(); into the foreign module.

    -

    16.2.7 Object Wrapping

    +

    17.2.7 Object Wrapping

    @@ -657,7 +657,7 @@ char *xxx(); foreign function interface.

    -

    16.3 Wrapping Details

    +

    17.3 Wrapping Details

    @@ -665,7 +665,7 @@ char *xxx(); translated into lisp.

    -

    16.3.1 Namespaces

    +

    17.3.1 Namespaces

    @@ -742,7 +742,7 @@ namespace car { function such as (car '(1 2 3).

    -

    16.3.2 Constants

    +

    17.3.2 Constants

    @@ -803,7 +803,7 @@ namespace car { not use the -nocwrap command-line option.

    -

    16.3.3 Variables

    +

    17.3.3 Variables

    @@ -881,7 +881,7 @@ globalvar> (globalvar.nnn::glob_float)

    -

    16.3.4 Enumerations

    +

    17.3.4 Enumerations

    @@ -957,7 +957,7 @@ EXPORT const int ACL_ENUM___FOO3__SWIG_0 = FOO3; -

    16.3.5 Arrays

    +

    17.3.5 Arrays

    @@ -1105,10 +1105,10 @@ namespace BAR { -

    16.3.6 Classes and Structs and Unions (oh my!)

    +

    17.3.6 Classes and Structs and Unions (oh my!)

    -

    16.3.6.1 CLOS wrapping of

    +

    17.3.6.1 CLOS wrapping of

    @@ -1123,7 +1123,7 @@ namespace BAR { integer values.

    -

    16.3.6.2 CLOS Inheritance

    +

    17.3.6.2 CLOS Inheritance

    @@ -1136,7 +1136,7 @@ namespace BAR { parameter.

    -

    16.3.6.3 Member fields and functions

    +

    17.3.6.3 Member fields and functions

    @@ -1152,7 +1152,7 @@ namespace BAR { the interface does nothing for friend directives,

    -

    16.3.6.4 Why not directly access C++ classes using foreign types?

    +

    17.3.6.4 Why not directly access C++ classes using foreign types?

    @@ -1170,11 +1170,11 @@ namespace BAR { use the more robust wrapper functions.

    -

    16.3.7 Templates

    +

    17.3.7 Templates

    -

    16.3.7.1 Generating wrapper code for templates

    +

    17.3.7.1 Generating wrapper code for templates

    @@ -1187,7 +1187,7 @@ namespace BAR { directive.

    -

    16.3.7.2 Implicit Template instantiation

    +

    17.3.7.2 Implicit Template instantiation

    @@ -1197,7 +1197,7 @@ namespace BAR { class schema.

    -

    16.3.8 Typedef, Templates, and Synonym Types

    +

    17.3.8 Typedef, Templates, and Synonym Types

    @@ -1277,7 +1277,7 @@ synonym> -

    16.3.8.1 Choosing a primary type

    +

    17.3.8.1 Choosing a primary type

    @@ -1298,7 +1298,7 @@ synonym>

  • -

    16.3.9 Function overloading/Parameter defaulting

    +

    17.3.9 Function overloading/Parameter defaulting

    @@ -1461,7 +1461,7 @@ overload> -

    16.3.10 Operator wrapping and Operator overloading

    +

    17.3.10 Operator wrapping and Operator overloading

    @@ -1607,7 +1607,7 @@ opoverload> -

    16.3.11 Varargs

    +

    17.3.11 Varargs

    @@ -1628,7 +1628,7 @@ opoverload> with other ways such functions can be wrapped.

    -

    16.3.12 C++ Exceptions

    +

    17.3.12 C++ Exceptions

    @@ -1640,7 +1640,7 @@ opoverload> implemented.

    -

    16.3.13 Pass by value, pass by reference

    +

    17.3.13 Pass by value, pass by reference

    @@ -1652,7 +1652,7 @@ opoverload> newly defined types.

    -

    16.4 Typemaps

    +

    17.4 Typemaps

    @@ -1663,7 +1663,7 @@ opoverload> on Typemaps for more information.

    -

    16.4.1 Code Generation in the C++ Wrapper

    +

    17.4.1 Code Generation in the C++ Wrapper

    @@ -1693,7 +1693,7 @@ return-val wrapper-name(parm0, parm1, ..., parmN) -

    16.4.1.1 IN Typemap

    +

    17.4.1.1 IN Typemap

    @@ -1728,7 +1728,7 @@ return-val wrapper-name(parm0, parm1, ..., parmN) -

    16.4.1.2 OUT Typemap

    +

    17.4.1.2 OUT Typemap

    @@ -1752,7 +1752,7 @@ return-val wrapper-name(parm0, parm1, ..., parmN) -

    16.4.1.3 CTYPE Typemap

    +

    17.4.1.3 CTYPE Typemap

    @@ -1784,7 +1784,7 @@ return-val wrapper-name(parm0, parm1, ..., parmN) these common typemaps here.

    -

    16.4.2 Code generation in Lisp wrappers

    +

    17.4.2 Code generation in Lisp wrappers

    @@ -1803,7 +1803,7 @@ return-val wrapper-name(parm0, parm1, ..., parmN) 16.3.1 Namespaces for details.

    -

    16.4.2.1 LIN Typemap

    +

    17.4.2.1 LIN Typemap

    @@ -1846,7 +1846,7 @@ return-val wrapper-name(parm0, parm1, ..., parmN) -

    16.4.2.2 LOUT Typemap

    +

    17.4.2.2 LOUT Typemap

    @@ -1889,7 +1889,7 @@ return-val wrapper-name(parm0, parm1, ..., parmN) -

    16.4.2.3 FFITYPE Typemap

    +

    17.4.2.3 FFITYPE Typemap

    @@ -1939,7 +1939,7 @@ return-val wrapper-name(parm0, parm1, ..., parmN) -

    16.4.2.4 LISPTYPE Typemap

    +

    17.4.2.4 LISPTYPE Typemap

    @@ -1959,7 +1959,7 @@ return-val wrapper-name(parm0, parm1, ..., parmN) -

    16.4.2.5 LISPCLASS Typemap

    +

    17.4.2.5 LISPCLASS Typemap

    @@ -1983,7 +1983,7 @@ return-val wrapper-name(parm0, parm1, ..., parmN) -

    16.4.3 Modifying SWIG behavior using typemaps

    +

    17.4.3 Modifying SWIG behavior using typemaps

    @@ -2017,10 +2017,10 @@ return-val wrapper-name(parm0, parm1, ..., parmN) -

    16.5 Identifier Converter functions

    +

    17.5 Identifier Converter functions

    -

    16.5.1 Creating symbols in the lisp environment

    +

    17.5.1 Creating symbols in the lisp environment

    @@ -2041,11 +2041,11 @@ return-val wrapper-name(parm0, parm1, ..., parmN) of arguments.

    -

    16.5.2 Existing identifier-converter functions

    +

    17.5.2 Existing identifier-converter functions

    Two basic identifier routines have been defined. -

    16.5.2.1 identifier-convert-null

    +

    17.5.2.1 identifier-convert-null

    @@ -2054,7 +2054,7 @@ return-val wrapper-name(parm0, parm1, ..., parmN) strings, from which a symbol will be created.

    -

    16.5.2.2 identifier-convert-lispify

    +

    17.5.2.2 identifier-convert-lispify

    @@ -2063,7 +2063,7 @@ return-val wrapper-name(parm0, parm1, ..., parmN) same symbol transformations.

    -

    16.5.2.3 Default identifier to symbol conversions

    +

    17.5.2.3 Default identifier to symbol conversions

    @@ -2072,7 +2072,7 @@ return-val wrapper-name(parm0, parm1, ..., parmN) default naming conventions.

    -

    16.5.3 Defining your own identifier-converter

    +

    17.5.3 Defining your own identifier-converter

    @@ -2128,7 +2128,7 @@ indicating the number of arguments passed to the routine indicated by this identifier.

    -

    16.5.4 Instructing SWIG to use a particular identifier-converter

    +

    17.5.4 Instructing SWIG to use a particular identifier-converter

    diff --git a/Doc/Manual/CSharp.html b/Doc/Manual/CSharp.html index 452f7fd7c..81c8a232b 100644 --- a/Doc/Manual/CSharp.html +++ b/Doc/Manual/CSharp.html @@ -5,7 +5,7 @@ -

    17 SWIG and C#

    +

    18 SWIG and C#

      @@ -45,7 +45,7 @@ -

      17.1 Introduction

      +

      18.1 Introduction

      @@ -65,7 +65,7 @@ The Microsoft Developer Network (MSDN) h Monodoc, available from the Mono project, has a very useful section titled Interop with native libraries.

      -

      17.2 Differences to the Java module

      +

      18.2 Differences to the Java module

      @@ -408,7 +408,7 @@ Windows users can also get the examples working using a Cygwin or MinGW environment for automatic configuration of the example makefiles. Any one of the three C# compilers (Portable.NET, Mono or Microsoft) can be detected from within a Cygwin or Mingw environment if installed in your path. -

      17.3 C# Arrays

      +

      18.3 C# Arrays

      @@ -420,7 +420,7 @@ with one of the following three approaches; namely the SWIG C arrays library, P/ pinned arrays.

      -

      17.3.1 The SWIG C arrays library

      +

      18.3.1 The SWIG C arrays library

      @@ -457,7 +457,7 @@ example.print_array(c.cast()); // Pass to C

    -

    17.3.2 Managed arrays using P/Invoke default array marshalling

    +

    18.3.2 Managed arrays using P/Invoke default array marshalling

    @@ -582,7 +582,7 @@ and intermediate class method -

    17.3.3 Managed arrays using pinning

    +

    18.3.3 Managed arrays using pinning

    @@ -676,7 +676,7 @@ public static extern void myArrayCopy(IntPtr jarg1, IntPtr jarg2, int jarg3); -

    17.4 C# Exceptions

    +

    18.4 C# Exceptions

    @@ -773,7 +773,7 @@ set so should only be used when a C# exception is not created.

    -

    17.4.1 C# exception example using "check" typemap

    +

    18.4.1 C# exception example using "check" typemap

    @@ -955,7 +955,7 @@ method and C# code does not handle pending exceptions via the canthrow attribute Actually it will issue this warning for any function beginning with SWIG_CSharpSetPendingException.

    -

    17.4.2 C# exception example using %exception

    +

    18.4.2 C# exception example using %exception

    @@ -1020,7 +1020,7 @@ The managed code generated does check for the pending exception as mentioned ear -

    17.4.3 C# exception example using exception specifications

    +

    18.4.3 C# exception example using exception specifications

    @@ -1077,7 +1077,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_evensonly(int jarg1) { Multiple catch handlers are generated should there be more than one exception specifications declared.

    -

    17.4.4 Custom C# ApplicationException example

    +

    18.4.4 Custom C# ApplicationException example

    @@ -1211,7 +1211,7 @@ try { -

    17.5 C# Directors

    +

    18.5 C# Directors

    @@ -1224,7 +1224,7 @@ The following sections provide information on the C# director implementation and However, the Java directors section should also be read in order to gain more insight into directors.

    -

    17.5.1 Directors example

    +

    18.5.1 Directors example

    @@ -1345,7 +1345,7 @@ CSharpDerived - UIntMethod(123) -

    17.5.2 Directors implementation

    +

    18.5.2 Directors implementation

    @@ -1531,7 +1531,7 @@ void SwigDirector_Base::BaseBoolMethod(Base const &b, bool flag) { -

    17.5.3 Director caveats

    +

    18.5.3 Director caveats

    @@ -1579,7 +1579,7 @@ However, a call from C# to CSharpDefaults.DefaultMethod() will of cours should pass the call on to CSharpDefaults.DefaultMethod(int)using the C++ default value, as shown above.

    -

    17.6 C# Typemap examples

    +

    18.6 C# Typemap examples

    This section includes a few examples of typemaps. For more examples, you @@ -1587,7 +1587,7 @@ might look at the files "csharp.swg" and "typemaps.i" in the SWIG library. -

    17.6.1 Memory management when returning references to member variables

    +

    18.6.1 Memory management when returning references to member variables

    @@ -1711,7 +1711,7 @@ public class Bike : IDisposable { Note the addReference call.

    -

    17.6.2 Memory management for objects passed to the C++ layer

    +

    18.6.2 Memory management for objects passed to the C++ layer

    @@ -1830,7 +1830,7 @@ The 'cscode' typemap simply adds in the specified code into the C# proxy class. -

    17.6.3 Date marshalling using the csin typemap and associated attributes

    +

    18.6.3 Date marshalling using the csin typemap and associated attributes

    @@ -2114,7 +2114,7 @@ public class example { -

    17.6.4 A date example demonstrating marshalling of C# properties

    +

    18.6.4 A date example demonstrating marshalling of C# properties

    @@ -2215,7 +2215,7 @@ Some points to note: -

    17.6.5 Turning wrapped classes into partial classes

    +

    18.6.5 Turning wrapped classes into partial classes

    @@ -2315,7 +2315,7 @@ demonstrating that the class contains methods calling both unmanaged code - The following example is an alternative approach to adding managed code to the generated proxy class.

    -

    17.6.6 Extending proxy classes with additional C# code

    +

    18.6.6 Extending proxy classes with additional C# code

    diff --git a/Doc/Manual/Chicken.html b/Doc/Manual/Chicken.html index bd1b3d94b..98372a0f7 100644 --- a/Doc/Manual/Chicken.html +++ b/Doc/Manual/Chicken.html @@ -8,7 +8,7 @@ -

    18 SWIG and Chicken

    +

    19 SWIG and Chicken

      @@ -72,7 +72,7 @@

      -

      18.1 Preliminaries

      +

      19.1 Preliminaries

      @@ -90,7 +90,7 @@ CHICKEN.

      -

      18.1.1 Running SWIG in C mode

      +

      19.1.1 Running SWIG in C mode

      @@ -123,7 +123,7 @@ object files and linked into your project.

      -

      18.1.2 Running SWIG in C++ mode

      +

      19.1.2 Running SWIG in C++ mode

      @@ -152,10 +152,10 @@ object files and linked into your project.

      -

      18.2 Code Generation

      +

      19.2 Code Generation

      -

      18.2.1 Naming Conventions

      +

      19.2.1 Naming Conventions

      @@ -171,7 +171,7 @@ %rename SWIG directive in the SWIG interface file.

      -

      18.2.2 Modules

      +

      19.2.2 Modules

      @@ -193,7 +193,7 @@ (uses modulename)) CHICKEN Scheme form.

      -

      18.2.3 Constants and Variables

      +

      19.2.3 Constants and Variables

      @@ -230,7 +230,7 @@ for info on how to apply the %feature.

      -

      18.2.4 Functions

      +

      19.2.4 Functions

      @@ -249,7 +249,7 @@ parameters). The return values can then be accessed with (call-with-values).

      -

      18.2.5 Exceptions

      +

      19.2.5 Exceptions

      The SWIG chicken module has support for exceptions thrown from @@ -291,7 +291,7 @@

    -

    18.3 TinyCLOS

    +

    19.3 TinyCLOS

    @@ -334,7 +334,7 @@

    -

    18.4 Linkage

    +

    19.4 Linkage

    @@ -355,7 +355,7 @@

    -

    18.4.1 Static binary or shared library linked at compile time

    +

    19.4.1 Static binary or shared library linked at compile time

    We can easily use csc to build a static binary.

    @@ -396,7 +396,7 @@ in which case the test script does not need to be linked with example.so. The t be run with csi.

    -

    18.4.2 Building chicken extension libraries

    +

    19.4.2 Building chicken extension libraries

    Building a shared library like in the above section only works if the library @@ -454,7 +454,7 @@ distributed and used by anyone, even if SWIG is not installed.

    See the Examples/chicken/egg directory in the SWIG source for an example that builds two eggs, one using the first method and one using the second method.

    -

    18.4.3 Linking multiple SWIG modules with TinyCLOS

    +

    19.4.3 Linking multiple SWIG modules with TinyCLOS

    Linking together multiple modules that share type information using the %import @@ -478,7 +478,7 @@ with (declare (uses ...)). To create an extension library or an egg, just create a module_load.scm file that (declare (uses ...)) all the modules.

    -

    18.5 Typemaps

    +

    19.5 Typemaps

    @@ -487,7 +487,7 @@ all the modules.

    Lib/chicken/chicken.swg.

    -

    18.6 Pointers

    +

    19.6 Pointers

    @@ -520,7 +520,7 @@ all the modules.

    type. flags is either zero or SWIG_POINTER_DISOWN (see below).

    -

    18.6.1 Garbage collection

    +

    19.6.1 Garbage collection

    If the owner flag passed to SWIG_NewPointerObj is 1, NewPointerObj will add a @@ -551,7 +551,7 @@ all the modules.

    must be called manually.

    -

    18.7 Unsupported features and known problems

    +

    19.7 Unsupported features and known problems

    -

    18.7.1 TinyCLOS problems with Chicken version <= 1.92

    +

    19.7.1 TinyCLOS problems with Chicken version <= 1.92

    In Chicken versions equal to or below 1.92, TinyCLOS has a limitation such that generic methods do not properly work on methods diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index 913ba7131..fcba1352d 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -483,7 +483,33 @@ -

    15 Working with Modules

    +

    15 swig-ccache(1) manpage

    + + + + + +

    16 Working with Modules

    @@ -498,7 +524,7 @@
    -

    16 SWIG and Allegro Common Lisp

    +

    17 SWIG and Allegro Common Lisp

    @@ -582,7 +608,7 @@
    -

    17 SWIG and C#

    +

    18 SWIG and C#

    @@ -621,7 +647,7 @@
    -

    18 SWIG and Chicken

    +

    19 SWIG and Chicken

    @@ -659,7 +685,7 @@
    -

    19 SWIG and Guile

    +

    20 SWIG and Guile

    @@ -694,7 +720,7 @@
    -

    20 SWIG and Java

    +

    21 SWIG and Java

    @@ -836,7 +862,7 @@
    -

    21 SWIG and Common Lisp

    +

    22 SWIG and Common Lisp

    @@ -859,7 +885,7 @@
    -

    22 SWIG and Lua

    +

    23 SWIG and Lua

    @@ -901,7 +927,7 @@
    -

    23 SWIG and Modula-3

    +

    24 SWIG and Modula-3

    @@ -942,7 +968,7 @@
    -

    24 SWIG and MzScheme

    +

    25 SWIG and MzScheme

    @@ -952,7 +978,7 @@
    -

    25 SWIG and Ocaml

    +

    26 SWIG and Ocaml

    @@ -1003,7 +1029,7 @@
    -

    26 SWIG and Octave

    +

    27 SWIG and Octave

    @@ -1038,7 +1064,7 @@
    -

    27 SWIG and Perl5

    +

    28 SWIG and Perl5

    @@ -1105,7 +1131,7 @@
    -

    28 SWIG and PHP

    +

    29 SWIG and PHP

    @@ -1135,7 +1161,7 @@
    -

    29 SWIG and Pike

    +

    30 SWIG and Pike

    @@ -1159,7 +1185,7 @@
    -

    30 SWIG and Python

    +

    31 SWIG and Python

    @@ -1265,7 +1291,7 @@
    -

    31 SWIG and Ruby

    +

    32 SWIG and Ruby

    @@ -1399,7 +1425,7 @@
    -

    32 SWIG and Tcl

    +

    33 SWIG and Tcl

    @@ -1464,7 +1490,7 @@
    -

    33 SWIG and R

    +

    34 SWIG and R

    @@ -1480,7 +1506,7 @@
    -

    34 Extending SWIG to support new languages

    +

    35 Extending SWIG to support new languages

    diff --git a/Doc/Manual/Extending.html b/Doc/Manual/Extending.html index e4d5cdb92..5c9a439f8 100644 --- a/Doc/Manual/Extending.html +++ b/Doc/Manual/Extending.html @@ -6,7 +6,7 @@ -

    34 Extending SWIG to support new languages

    +

    35 Extending SWIG to support new languages

      @@ -73,7 +73,7 @@ -

      34.1 Introduction

      +

      35.1 Introduction

      @@ -89,7 +89,7 @@ Also, this chapter is not meant to be a hand-holding tutorial. As a starting po you should probably look at one of SWIG's existing modules.

      -

      34.2 Prerequisites

      +

      35.2 Prerequisites

      @@ -119,7 +119,7 @@ obvious, but almost all SWIG directives as well as the low-level generation of wrapper code are driven by C++ datatypes.

      -

      34.3 The Big Picture

      +

      35.3 The Big Picture

      @@ -156,7 +156,7 @@ role in making the system work. For example, both typemaps and declaration anno based on pattern matching and interact heavily with the underlying type system.

      -

      34.4 Execution Model

      +

      35.4 Execution Model

      @@ -201,7 +201,7 @@ latter stage of compilation. The next few sections briefly describe some of these stages.

      -

      34.4.1 Preprocessing

      +

      35.4.1 Preprocessing

      @@ -281,7 +281,7 @@ been expanded as well as everything else that goes into the low-level construction of the wrapper code.

      -

      34.4.2 Parsing

      +

      35.4.2 Parsing

      @@ -382,7 +382,7 @@ returning a foo and taking types a and b as arguments).

      -

      34.4.3 Parse Trees

      +

      35.4.3 Parse Trees

      @@ -637,7 +637,7 @@ $ swig -c++ -python -debug-module 4 example.i

    -

    34.4.4 Attribute namespaces

    +

    35.4.4 Attribute namespaces

    @@ -656,7 +656,7 @@ that matches the name of the target language. For example, python:foo perl:foo.

    -

    34.4.5 Symbol Tables

    +

    35.4.5 Symbol Tables

    @@ -747,7 +747,7 @@ example.i:5. Previous declaration is foo_i(int )

    -

    34.4.6 The %feature directive

    +

    35.4.6 The %feature directive

    @@ -803,7 +803,7 @@ For example, the exception code above is simply stored without any modifications.

    -

    34.4.7 Code Generation

    +

    35.4.7 Code Generation

    @@ -925,7 +925,7 @@ public : The role of these functions is described shortly.

    -

    34.4.8 SWIG and XML

    +

    35.4.8 SWIG and XML

    @@ -938,7 +938,7 @@ internal data structures, it may be useful to keep XML in the back of your mind as a model.

    -

    34.5 Primitive Data Structures

    +

    35.5 Primitive Data Structures

    @@ -984,7 +984,7 @@ typedef Hash Typetab; -

    34.5.1 Strings

    +

    35.5.1 Strings

    @@ -1125,7 +1125,7 @@ Returns the number of replacements made (if any). -

    34.5.2 Hashes

    +

    35.5.2 Hashes

    @@ -1202,7 +1202,7 @@ Returns the list of hash table keys. -

    34.5.3 Lists

    +

    35.5.3 Lists

    @@ -1291,7 +1291,7 @@ If t is not a standard object, it is assumed to be a char * and is used to create a String object. -

    34.5.4 Common operations

    +

    35.5.4 Common operations

    The following operations are applicable to all datatypes. @@ -1346,7 +1346,7 @@ objects and report errors. Gets the line number associated with x. -

    34.5.5 Iterating over Lists and Hashes

    +

    35.5.5 Iterating over Lists and Hashes

    To iterate over the elements of a list or a hash table, the following functions are used: @@ -1391,7 +1391,7 @@ for (j = First(j); j.item; j= Next(j)) { -

    34.5.6 I/O

    +

    35.5.6 I/O

    Special I/O functions are used for all internal I/O. These operations @@ -1527,7 +1527,7 @@ Similarly, the preprocessor and parser all operate on string-files. -

    34.6 Navigating and manipulating parse trees

    +

    35.6 Navigating and manipulating parse trees

    Parse trees are built as collections of hash tables. Each node is a hash table in which @@ -1661,7 +1661,7 @@ Deletes a node from the parse tree. Deletion reconnects siblings and properly u the parent so that sibling nodes are unaffected. -

    34.7 Working with attributes

    +

    35.7 Working with attributes

    @@ -1778,7 +1778,7 @@ the attribute is optional. Swig_restore() must always be called after function. -

    34.8 Type system

    +

    35.8 Type system

    @@ -1787,7 +1787,7 @@ pointers, references, and pointers to members. A detailed discussion of type theory is impossible here. However, let's cover the highlights.

    -

    34.8.1 String encoding of types

    +

    35.8.1 String encoding of types

    @@ -1888,7 +1888,7 @@ make the final type, the two parts are just joined together using string concatenation.

    -

    34.8.2 Type construction

    +

    35.8.2 Type construction

    @@ -2057,7 +2057,7 @@ Returns the prefix of a type. For example, if ty is ty is unmodified. -

    34.8.3 Type tests

    +

    35.8.3 Type tests

    @@ -2144,7 +2144,7 @@ Checks if ty is a varargs type. Checks if ty is a templatized type. -

    34.8.4 Typedef and inheritance

    +

    35.8.4 Typedef and inheritance

    @@ -2246,7 +2246,7 @@ Fully reduces ty according to typedef rules. Resulting datatype will consist only of primitive typenames. -

    34.8.5 Lvalues

    +

    35.8.5 Lvalues

    @@ -2283,7 +2283,7 @@ Literal y; // type = 'Literal', ltype='p.char' -

    34.8.6 Output functions

    +

    35.8.6 Output functions

    @@ -2345,7 +2345,7 @@ SWIG, but is most commonly associated with type-descriptor objects that appear in wrappers (e.g., SWIGTYPE_p_double). -

    34.9 Parameters

    +

    35.9 Parameters

    @@ -2444,7 +2444,7 @@ included. Used to emit prototypes. Returns the number of required (non-optional) arguments in p. -

    34.10 Writing a Language Module

    +

    35.10 Writing a Language Module

    @@ -2459,7 +2459,7 @@ describes the creation of a minimal Python module. You should be able to extra this to other languages.

    -

    34.10.1 Execution model

    +

    35.10.1 Execution model

    @@ -2469,7 +2469,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.

    -

    34.10.2 Starting out

    +

    35.10.2 Starting out

    @@ -2577,7 +2577,7 @@ that activates your module. For example, swig -python foo.i. The messages from your new module should appear.

    -

    34.10.3 Command line options

    +

    35.10.3 Command line options

    @@ -2636,7 +2636,7 @@ to mark the option as valid. If you forget to do this, SWIG will terminate wit unrecognized command line option error.

    -

    34.10.4 Configuration and preprocessing

    +

    35.10.4 Configuration and preprocessing

    @@ -2685,7 +2685,7 @@ an implementation file python.cxx and a configuration file python.swg.

    -

    34.10.5 Entry point to code generation

    +

    35.10.5 Entry point to code generation

    @@ -2743,7 +2743,7 @@ int Python::top(Node *n) { -

    34.10.6 Module I/O and wrapper skeleton

    +

    35.10.6 Module I/O and wrapper skeleton

    @@ -2885,7 +2885,7 @@ functionWrapper : void Shape_y_set(Shape *self,double y) -

    34.10.7 Low-level code generators

    +

    35.10.7 Low-level code generators

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

    -

    34.10.8 Configuration files

    +

    35.10.8 Configuration files

    @@ -3189,7 +3189,7 @@ politely displays the ignoring language message. -

    34.10.9 Runtime support

    +

    35.10.9 Runtime support

    @@ -3198,7 +3198,7 @@ Discuss the kinds of functions typically needed for SWIG runtime support (e.g. the SWIG files that implement those functions.

    -

    34.10.10 Standard library files

    +

    35.10.10 Standard library files

    @@ -3217,7 +3217,7 @@ The following are the minimum that are usually supported: Please copy these and modify for any new language.

    -

    34.10.11 Examples and test cases

    +

    35.10.11 Examples and test cases

    @@ -3246,7 +3246,7 @@ during this process, see the section on configuration files.

    -

    34.10.12 Documentation

    +

    35.10.12 Documentation

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

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

    +

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

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

    -

    34.10.14 Coding style guidelines

    +

    35.10.14 Coding style guidelines

    @@ -3359,13 +3359,13 @@ 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.

    -

    34.11 Typemaps

    +

    35.11 Typemaps

    -

    34.11.1 Proxy classes

    +

    35.11.1 Proxy classes

    -

    34.12 Guide to parse tree nodes

    +

    35.12 Guide to parse tree nodes

    diff --git a/Doc/Manual/Guile.html b/Doc/Manual/Guile.html index 20ab716e4..cf7e8da2c 100644 --- a/Doc/Manual/Guile.html +++ b/Doc/Manual/Guile.html @@ -8,7 +8,7 @@ -

    19 SWIG and Guile

    +

    20 SWIG and Guile

      @@ -47,7 +47,7 @@

      This section details guile-specific support in SWIG. -

      19.1 Meaning of "Module"

      +

      20.1 Meaning of "Module"

      @@ -55,7 +55,7 @@ There are three different concepts of "module" involved, defined separately for SWIG, Guile, and Libtool. To avoid horrible confusion, we explicitly prefix the context, e.g., "guile-module". -

      19.2 Using the SCM or GH Guile API

      +

      20.2 Using the SCM or GH Guile API

      The guile module can currently export wrapper files that use the guile GH interface or the @@ -103,7 +103,7 @@ for the specific API. Currently only the guile language module has created a ma but there is no reason other languages (like mzscheme or chicken) couldn't also use this. If that happens, there is A LOT less code duplication in the standard typemaps.

      -

      19.3 Linkage

      +

      20.3 Linkage

      @@ -111,7 +111,7 @@ Guile support is complicated by a lack of user community cohesiveness, which manifests in multiple shared-library usage conventions. A set of policies implementing a usage convention is called a linkage. -

      19.3.1 Simple Linkage

      +

      20.3.1 Simple Linkage

      @@ -206,7 +206,7 @@ placed between the define-module form and the SWIG_init via a preprocessor define to avoid symbol clashes. For this case, however, passive linkage is available. -

      19.3.2 Passive Linkage

      +

      20.3.2 Passive Linkage

      Passive linkage is just like simple linkage, but it generates an @@ -216,7 +216,7 @@ package name (see below).

      You should use passive linkage rather than simple linkage when you are using multiple modules. -

      19.3.3 Native Guile Module Linkage

      +

      20.3.3 Native Guile Module Linkage

      SWIG can also generate wrapper code that does all the Guile module @@ -257,7 +257,7 @@ Newer Guile versions have a shorthand procedure for this:

    -

    19.3.4 Old Auto-Loading Guile Module Linkage

    +

    20.3.4 Old Auto-Loading Guile Module Linkage

    Guile used to support an autoloading facility for object-code @@ -283,7 +283,7 @@ option, SWIG generates an exported module initialization function with an appropriate name. -

    19.3.5 Hobbit4D Linkage

    +

    20.3.5 Hobbit4D Linkage

    @@ -308,7 +308,7 @@ my/lib/libfoo.so.X.Y.Z and friends. This scheme is still very experimental; the (hobbit4d link) conventions are not well understood.

    -

    19.4 Underscore Folding

    +

    20.4 Underscore Folding

    @@ -320,7 +320,7 @@ complained so far. %rename to specify the Guile name of the wrapped functions and variables (see CHANGES). -

    19.5 Typemaps

    +

    20.5 Typemaps

    @@ -412,7 +412,7 @@ constant will appear as a scheme variable. See Features and the %feature directive for info on how to apply the %feature.

    -

    19.6 Representation of pointers as smobs

    +

    20.6 Representation of pointers as smobs

    @@ -433,7 +433,7 @@ representing the expected pointer type. See also If the Scheme object passed was not a SWIG smob representing a compatible pointer, a wrong-type-arg exception is raised. -

    19.6.1 GH Smobs

    +

    20.6.1 GH Smobs

    @@ -462,7 +462,7 @@ that created them, so the first module we check will most likely be correct. Once we have a swig_type_info structure, we loop through the linked list of casts, using pointer comparisons.

    -

    19.6.2 SCM Smobs

    +

    20.6.2 SCM Smobs

    The SCM interface (using the "-scm" argument to swig) uses swigrun.swg. @@ -477,7 +477,7 @@ in the smob tag. If a generated GOOPS module has been loaded, smobs will be wra GOOPS class.

    -

    19.6.3 Garbage Collection

    +

    20.6.3 Garbage Collection

    Garbage collection is a feature of the new SCM interface, and it is automatically included @@ -491,7 +491,7 @@ is exactly like described in Object ownership and %newobject in the SWIG manual. All typemaps use an $owner var, and the guile module replaces $owner with 0 or 1 depending on feature:new.

    -

    19.7 Exception Handling

    +

    20.7 Exception Handling

    @@ -517,7 +517,7 @@ mapping: The default when not specified here is to use "swig-error". See Lib/exception.i for details. -

    19.8 Procedure documentation

    +

    20.8 Procedure documentation

    If invoked with the command-line option -procdoc @@ -553,7 +553,7 @@ like this: typemap argument doc. See Lib/guile/typemaps.i for details. -

    19.9 Procedures with setters

    +

    20.9 Procedures with setters

    For global variables, SWIG creates a single wrapper procedure @@ -581,7 +581,7 @@ struct members, the procedures (struct-member-get pointer) and (struct-member-set pointer value) are not generated. -

    19.10 GOOPS Proxy Classes

    +

    20.10 GOOPS Proxy Classes

    SWIG can also generate classes and generic functions for use with @@ -730,7 +730,7 @@ Notice that <Foo> is used before it is defined. The fix is to just put th %import "foo.h" before the %inline block.

    -

    19.10.1 Naming Issues

    +

    20.10.1 Naming Issues

    As you can see in the example above, there are potential naming conflicts. The default exported @@ -769,7 +769,7 @@ guile-modules. For example,

    TODO: Renaming class name prefixes?

    -

    19.10.2 Linking

    +

    20.10.2 Linking

    The guile-modules generated above all need to be linked together. GOOPS support requires diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html index 60bca1262..cbdcb5a9e 100644 --- a/Doc/Manual/Java.html +++ b/Doc/Manual/Java.html @@ -5,7 +5,7 @@ -

    20 SWIG and Java

    +

    21 SWIG and Java

      @@ -154,7 +154,7 @@ It covers most SWIG features, but certain low-level details are covered in less

      -

      20.1 Overview

      +

      21.1 Overview

      @@ -189,7 +189,7 @@ Various customisation tips and techniques using SWIG directives are covered. The latter sections cover the advanced techniques of using typemaps for complete control of the wrapping process.

      -

      20.2 Preliminaries

      +

      21.2 Preliminaries

      @@ -205,7 +205,7 @@ Run make -k check from the SWIG root directory after installing SWIG on The Java module requires your system to support shared libraries and dynamic loading. This is the commonly used method to load JNI code so your system will more than likely support this.

      -

      20.2.1 Running SWIG

      +

      21.2.1 Running SWIG

      @@ -258,7 +258,7 @@ The following sections have further practical examples and details on how you mi compiling and using the generated files.

      -

      20.2.2 Additional Commandline Options

      +

      21.2.2 Additional Commandline Options

      @@ -295,7 +295,7 @@ swig -java -help Their use will become clearer by the time you have finished reading this section on SWIG and Java.

      -

      20.2.3 Getting the right header files

      +

      21.2.3 Getting the right header files

      @@ -310,7 +310,7 @@ They are usually in directories like this:

      The exact location may vary on your machine, but the above locations are typical.

      -

      20.2.4 Compiling a dynamic module

      +

      21.2.4 Compiling a dynamic module

      @@ -346,7 +346,7 @@ The name of the shared library output file is important. If the name of your SWIG module is "example", the name of the corresponding shared library file should be "libexample.so" (or equivalent depending on your machine, see Dynamic linking problems for more information). The name of the module is specified using the %module directive or -module command line option.

      -

      20.2.5 Using your module

      +

      21.2.5 Using your module

      @@ -381,7 +381,7 @@ $ If it doesn't work have a look at the following section which discusses problems loading the shared library.

      -

      20.2.6 Dynamic linking problems

      +

      21.2.6 Dynamic linking problems

      @@ -455,7 +455,7 @@ The following section also contains some C++ specific linking problems and solut

      -

      20.2.7 Compilation problems and compiling with C++

      +

      21.2.7 Compilation problems and compiling with C++

      @@ -508,7 +508,7 @@ Finally make sure the version of JDK header files matches the version of Java th

      -

      20.2.8 Building on Windows

      +

      21.2.8 Building on Windows

      @@ -517,7 +517,7 @@ You will want to produce a DLL that can be loaded by the Java Virtual Machine. This section covers the process of using SWIG with Microsoft Visual C++ 6 although the procedure may be similar with other compilers. In order for everything to work, you will need to have a JDK installed on your machine in order to read the JNI header files.

      -

      20.2.8.1 Running SWIG from Visual Studio

      +

      21.2.8.1 Running SWIG from Visual Studio

      @@ -556,7 +556,7 @@ To run the native code in the DLL (example.dll), make sure that it is in your pa If the library fails to load have a look at Dynamic linking problems.

      -

      20.2.8.2 Using NMAKE

      +

      21.2.8.2 Using NMAKE

      @@ -615,7 +615,7 @@ Of course you may want to make changes for it to work for C++ by adding in the -

      -

      20.3 A tour of basic C/C++ wrapping

      +

      21.3 A tour of basic C/C++ wrapping

      @@ -625,7 +625,7 @@ variables are wrapped with JavaBean type getters and setters and so forth. This section briefly covers the essential aspects of this wrapping.

      -

      20.3.1 Modules, packages and generated Java classes

      +

      21.3.1 Modules, packages and generated Java classes

      @@ -659,7 +659,7 @@ swig -java -package com.bloggs.swig -outdir com/bloggs/swig example.i SWIG won't create the directory, so make sure it exists beforehand. -

      20.3.2 Functions

      +

      21.3.2 Functions

      @@ -693,7 +693,7 @@ System.out.println(example.fact(4));

    -

    20.3.3 Global variables

    +

    21.3.3 Global variables

    @@ -780,7 +780,7 @@ extern char *path; // Read-only (due to %immutable) -

    20.3.4 Constants

    +

    21.3.4 Constants

    @@ -920,7 +920,7 @@ Or if you decide this practice isn't so bad and your own class implements ex

    -

    20.3.5 Enumerations

    +

    21.3.5 Enumerations

    @@ -934,7 +934,7 @@ The final two approaches use simple integers for each enum item. Before looking at the various approaches for wrapping named C/C++ enums, anonymous enums are considered.

    -

    20.3.5.1 Anonymous enums

    +

    21.3.5.1 Anonymous enums

    @@ -997,7 +997,7 @@ As in the case of constants, you can access them through either the module class

    -

    20.3.5.2 Typesafe enums

    +

    21.3.5.2 Typesafe enums

    @@ -1090,7 +1090,7 @@ When upgrading to JDK 1.5 or later, proper Java enums could be used instead, wit The following section details proper Java enum generation.

    -

    20.3.5.3 Proper Java enums

    +

    21.3.5.3 Proper Java enums

    @@ -1143,7 +1143,7 @@ The additional support methods need not be generated if none of the enum items h Simpler Java enums for enums without initializers section.

    -

    20.3.5.4 Type unsafe enums

    +

    21.3.5.4 Type unsafe enums

    @@ -1191,7 +1191,7 @@ Note that unlike typesafe enums, this approach requires users to mostly use diff Thus the upgrade path to proper enums provided in JDK 1.5 is more painful.

    -

    20.3.5.5 Simple enums

    +

    21.3.5.5 Simple enums

    @@ -1210,7 +1210,7 @@ SWIG-1.3.21 and earlier versions wrapped all enums using this approach. The type unsafe approach is preferable to this one and this simple approach is only included for backwards compatibility with these earlier versions of SWIG.

    -

    20.3.6 Pointers

    +

    21.3.6 Pointers

    @@ -1298,7 +1298,7 @@ C-style cast may return a bogus result whereas as the C++-style cast will return a NULL pointer if the conversion can't be performed.

    -

    20.3.7 Structures

    +

    21.3.7 Structures

    @@ -1466,7 +1466,7 @@ x.setA(3); // Modify x.a - this is the same as b.f.a -

    20.3.8 C++ classes

    +

    21.3.8 C++ classes

    @@ -1529,7 +1529,7 @@ int bar = Spam.getBar(); -

    20.3.9 C++ inheritance

    +

    21.3.9 C++ inheritance

    @@ -1590,7 +1590,7 @@ Note that Java does not support multiple inheritance so any multiple inheritance A warning is given when multiple inheritance is detected and only the first base class is used.

    -

    20.3.10 Pointers, references, arrays and pass by value

    +

    21.3.10 Pointers, references, arrays and pass by value

    @@ -1645,7 +1645,7 @@ to hold the result and a pointer is returned (Java will release this memory when the returned object's finalizer is run by the garbage collector).

    -

    20.3.10.1 Null pointers

    +

    21.3.10.1 Null pointers

    @@ -1669,7 +1669,7 @@ For spam1 and spam4 above the Java null gets translat The converse also occurs, that is, NULL pointers are translated into null Java objects when returned from a C/C++ function.

    -

    20.3.11 C++ overloaded functions

    +

    21.3.11 C++ overloaded functions

    @@ -1784,7 +1784,7 @@ void spam(unsigned short); // Ignored -

    20.3.12 C++ default arguments

    +

    21.3.12 C++ default arguments

    @@ -1827,7 +1827,7 @@ Further details on default arguments and how to restore this approach are given

    -

    20.3.13 C++ namespaces

    +

    21.3.13 C++ namespaces

    @@ -1887,7 +1887,7 @@ symbols separate, consider wrapping them as separate SWIG modules. Each SWIG module can be placed into a separate package.

    -

    20.3.14 C++ templates

    +

    21.3.14 C++ templates

    @@ -1936,7 +1936,7 @@ Obviously, there is more to template wrapping than shown in this example. More details can be found in the SWIG and C++ chapter.

    -

    20.3.15 C++ Smart Pointers

    +

    21.3.15 C++ Smart Pointers

    @@ -2020,7 +2020,7 @@ Foo f = p.__deref__(); // Returns underlying Foo * -

    20.4 Further details on the generated Java classes

    +

    21.4 Further details on the generated Java classes

    @@ -2035,7 +2035,7 @@ Finally enum classes are covered. First, the crucial intermediary JNI class is considered.

    -

    20.4.1 The intermediary JNI class

    +

    21.4.1 The intermediary JNI class

    @@ -2155,7 +2155,7 @@ If name is the same as modulename then the module class name g from modulename to modulenameModule.

    -

    20.4.1.1 The intermediary JNI class pragmas

    +

    21.4.1.1 The intermediary JNI class pragmas

    @@ -2234,7 +2234,7 @@ For example, let's change the intermediary JNI class access to public. All the methods in the intermediary JNI class will then be callable outside of the package as the method modifiers are public by default.

    -

    20.4.2 The Java module class

    +

    21.4.2 The Java module class

    @@ -2265,7 +2265,7 @@ example.egg(new Foo()); The primary reason for having the module class wrapping the calls in the intermediary JNI class is to implement static type checking. In this case only a Foo can be passed to the egg function, whereas any long can be passed to the egg function in the intermediary JNI class.

    -

    20.4.2.1 The Java module class pragmas

    +

    21.4.2.1 The Java module class pragmas

    @@ -2316,7 +2316,7 @@ See The intermediary JNI class pragmas section fo

    -

    20.4.3 Java proxy classes

    +

    21.4.3 Java proxy classes

    @@ -2392,7 +2392,7 @@ int y = f.spam(5, new Foo()); -

    20.4.3.1 Memory management

    +

    21.4.3.1 Memory management

    @@ -2554,7 +2554,7 @@ and

    -

    20.4.3.2 Inheritance

    +

    21.4.3.2 Inheritance

    @@ -2670,7 +2670,7 @@ However, true cross language polymorphism can be achieved using the 20.4.3.3 Proxy classes and garbage collection +

    21.4.3.3 Proxy classes and garbage collection

    @@ -2753,7 +2753,7 @@ The section on Java typemaps details how to specify See the How to Handle Java Finalization's Memory-Retention Issues article for alternative approaches to managing memory by avoiding finalizers altogether.

    -

    20.4.3.4 The premature garbage collection prevention parameter for proxy class marshalling

    +

    21.4.3.4 The premature garbage collection prevention parameter for proxy class marshalling

    @@ -2875,7 +2875,7 @@ For example: Compatibility note: The generation of this additional parameter did not occur in versions prior to SWIG-1.3.30.

    -

    20.4.3.5 Single threaded applications and thread safety

    +

    21.4.3.5 Single threaded applications and thread safety

    @@ -2963,7 +2963,7 @@ for (int i=0; i<100000; i++) { -

    20.4.4 Type wrapper classes

    +

    21.4.4 Type wrapper classes

    @@ -3050,7 +3050,7 @@ public static void spam(SWIGTYPE_p_int x, SWIGTYPE_p_int y, int z) { ... } -

    20.4.5 Enum classes

    +

    21.4.5 Enum classes

    @@ -3059,7 +3059,7 @@ The Enumerations section discussed these but omitted The following sub-sections detail the various types of enum classes that can be generated.

    -

    20.4.5.1 Typesafe enum classes

    +

    21.4.5.1 Typesafe enum classes

    @@ -3143,7 +3143,7 @@ The swigValue method is used for marshalling in the other direction. The toString method is overridden so that the enum name is available.

    -

    20.4.5.2 Proper Java enum classes

    +

    21.4.5.2 Proper Java enum classes

    @@ -3221,7 +3221,7 @@ These needn't be generated if the enum being wrapped does not have any initializ Simpler Java enums for enums without initializers section describes how typemaps can be used to achieve this.

    -

    20.4.5.3 Type unsafe enum classes

    +

    21.4.5.3 Type unsafe enum classes

    @@ -3252,7 +3252,7 @@ public final class Beverage { -

    20.5 Cross language polymorphism using directors

    +

    21.5 Cross language polymorphism using directors

    @@ -3274,7 +3274,7 @@ The upshot is that C++ classes can be extended in Java and from C++ these extens Neither C++ code nor Java code needs to know where a particular method is implemented: the combination of proxy classes, director classes, and C wrapper functions transparently takes care of all the cross-language method routing.

    -

    20.5.1 Enabling directors

    +

    21.5.1 Enabling directors

    @@ -3345,7 +3345,7 @@ public: -

    20.5.2 Director classes

    +

    21.5.2 Director classes

    @@ -3372,7 +3372,7 @@ If the correct implementation is in Java, the Java API is used to call the metho

    -

    20.5.3 Overhead and code bloat

    +

    21.5.3 Overhead and code bloat

    @@ -3390,7 +3390,7 @@ This situation can be optimized by selectively enabling director methods (using

    -

    20.5.4 Simple directors example

    +

    21.5.4 Simple directors example

    @@ -3455,7 +3455,7 @@ DirectorDerived::upcall_method() invoked. -

    20.5.5 Director threading issues

    +

    21.5.5 Director threading issues

    @@ -3475,7 +3475,7 @@ Macros can be defined on the commandline when compiling your C++ code, or altern -

    20.6 Accessing protected members

    +

    21.6 Accessing protected members

    @@ -3571,7 +3571,7 @@ class MyProtectedBase extends ProtectedBase -

    20.7 Common customization features

    +

    21.7 Common customization features

    @@ -3583,7 +3583,7 @@ be awkward. This section describes some common SWIG features that are used to improve the interface to existing C/C++ code.

    -

    20.7.1 C/C++ helper functions

    +

    21.7.1 C/C++ helper functions

    @@ -3649,7 +3649,7 @@ hard to implement. It is possible to improve on this using Java code, typemaps, customization features as covered in later sections, but sometimes helper functions are a quick and easy solution to difficult cases.

    -

    20.7.2 Class extension with %extend

    +

    21.7.2 Class extension with %extend

    @@ -3712,7 +3712,7 @@ Vector(2,3,4) in any way---the extensions only show up in the Java interface.

    -

    20.7.3 Exception handling with %exception and %javaexception

    +

    21.7.3 Exception handling with %exception and %javaexception

    @@ -3869,7 +3869,7 @@ to raise exceptions. See the SWIG Library ch The typemap example Handling C++ exception specifications as Java exceptions provides further exception handling capabilities.

    -

    20.7.4 Method access with %javamethodmodifiers

    +

    21.7.4 Method access with %javamethodmodifiers

    @@ -3895,7 +3895,7 @@ protected static void protect_me() { -

    20.8 Tips and techniques

    +

    21.8 Tips and techniques

    @@ -3905,7 +3905,7 @@ strings and arrays. This chapter discusses the common techniques for solving these problems.

    -

    20.8.1 Input and output parameters using primitive pointers and references

    +

    21.8.1 Input and output parameters using primitive pointers and references

    @@ -4079,7 +4079,7 @@ void foo(Bar *OUTPUT); will not have the intended effect since typemaps.i does not define an OUTPUT rule for Bar.

    -

    20.8.2 Simple pointers

    +

    21.8.2 Simple pointers

    @@ -4145,7 +4145,7 @@ System.out.println("3 + 4 = " + result); See the SWIG Library chapter for further details.

    -

    20.8.3 Wrapping C arrays with Java arrays

    +

    21.8.3 Wrapping C arrays with Java arrays

    @@ -4212,7 +4212,7 @@ Please be aware that the typemaps in this library are not efficient as all the e There is an alternative approach using the SWIG array library and this is covered in the next section.

    -

    20.8.4 Unbounded C Arrays

    +

    21.8.4 Unbounded C Arrays

    @@ -4357,7 +4357,7 @@ well suited for applications in which you need to create buffers, package binary data, etc.

    -

    20.8.5 Overriding new and delete to allocate from Java heap

    +

    21.8.5 Overriding new and delete to allocate from Java heap

    @@ -4474,7 +4474,7 @@ model and use these functions in place of malloc and free in your own code.

    -

    20.9 Java typemaps

    +

    21.9 Java typemaps

    @@ -4495,7 +4495,7 @@ Before proceeding, it should be stressed that typemaps are not a required part of using SWIG---the default wrapping behavior is enough in most cases. Typemaps are only used if you want to change some aspect of the generated code. -

    20.9.1 Default primitive type mappings

    +

    21.9.1 Default primitive type mappings

    @@ -4647,7 +4647,7 @@ However, the mappings allow the full range of values for each C type from Java.

    -

    20.9.2 Default typemaps for non-primitive types

    +

    21.9.2 Default typemaps for non-primitive types

    @@ -4662,7 +4662,7 @@ So in summary, the C/C++ pointer to non-primitive types is cast into the 64 bit The Java type is either the proxy class or type wrapper class.

    -

    20.9.3 Sixty four bit JVMs

    +

    21.9.3 Sixty four bit JVMs

    @@ -4675,7 +4675,7 @@ Unfortunately it won't of course hold true for JNI code.

    -

    20.9.4 What is a typemap?

    +

    21.9.4 What is a typemap?

    @@ -4798,7 +4798,7 @@ int c = example.count('e',"Hello World"); -

    20.9.5 Typemaps for mapping C/C++ types to Java types

    +

    21.9.5 Typemaps for mapping C/C++ types to Java types

    @@ -5058,7 +5058,7 @@ These are listed below: -

    20.9.6 Java typemap attributes

    +

    21.9.6 Java typemap attributes

    @@ -5104,7 +5104,7 @@ The "javain" typemap has the optional 'pre', 'post' and 'pgcppname' attributes. Note that when the 'pre' or 'post' attributes are specified and the associated type is used in a constructor, a constructor helper function is generated. This is necessary as the Java proxy constructor wrapper makes a call to a support constructor using a this call. In Java the this call must be the first statement in the constructor body. The constructor body thus calls the helper function and the helper function instead makes the JNI call, ensuring the 'pre' code is called before the JNI call is made. There is a Date marshalling example showing 'pre', 'post' and 'pgcppname' attributes in action.

    -

    20.9.7 Java special variables

    +

    21.9.7 Java special variables

    @@ -5247,7 +5247,7 @@ This special variable expands to the intermediary class name. Usually this is th unless the jniclassname attribute is specified in the %module directive.

    -

    20.9.8 Typemaps for both C and C++ compilation

    +

    21.9.8 Typemaps for both C and C++ compilation

    @@ -5284,7 +5284,7 @@ If you do not intend your code to be targeting both C and C++ then your typemaps

    -

    20.9.9 Java code typemaps

    +

    21.9.9 Java code typemaps

    @@ -5480,7 +5480,7 @@ For the typemap to be used in all type wrapper classes, all the different types Again this is the same that is in "java.swg", barring the method modifier for getCPtr.

    -

    20.9.10 Director specific typemaps

    +

    21.9.10 Director specific typemaps

    @@ -5705,7 +5705,7 @@ The basic strategy here is to provide a default package typemap for the majority -

    20.10 Typemap Examples

    +

    21.10 Typemap Examples

    @@ -5715,7 +5715,7 @@ the SWIG library.

    -

    20.10.1 Simpler Java enums for enums without initializers

    +

    21.10.1 Simpler Java enums for enums without initializers

    @@ -5794,7 +5794,7 @@ This would be done by using the original versions of these typemaps in "enums.sw

    -

    20.10.2 Handling C++ exception specifications as Java exceptions

    +

    21.10.2 Handling C++ exception specifications as Java exceptions

    @@ -5919,7 +5919,7 @@ We could alternatively have used %rename to rename what() into

    -

    20.10.3 NaN Exception - exception handling for a particular type

    +

    21.10.3 NaN Exception - exception handling for a particular type

    @@ -6074,7 +6074,7 @@ If we were a martyr to the JNI cause, we could replace the succinct code within If we had, we would have put it in the "in" typemap which, like all JNI and Java typemaps, also supports the 'throws' attribute.

    -

    20.10.4 Converting Java String arrays to char **

    +

    21.10.4 Converting Java String arrays to char **

    @@ -6218,7 +6218,7 @@ Lastly the "jni", "jtype" and "jstype" typemaps are also required to specify what Java types to use.

    -

    20.10.5 Expanding a Java object to multiple arguments

    +

    21.10.5 Expanding a Java object to multiple arguments

    @@ -6300,7 +6300,7 @@ example.foo(new String[]{"red", "green", "blue", "white"}); -

    20.10.6 Using typemaps to return arguments

    +

    21.10.6 Using typemaps to return arguments

    @@ -6418,7 +6418,7 @@ $ java runme 1 12.0 340.0 -

    20.10.7 Adding Java downcasts to polymorphic return types

    +

    21.10.7 Adding Java downcasts to polymorphic return types

    @@ -6624,7 +6624,7 @@ SWIG usually generates code which constructs the proxy classes using Java code a Note that the JNI code above uses a number of string lookups to call a constructor, whereas this would not occur using byte compiled Java code.

    -

    20.10.8 Adding an equals method to the Java classes

    +

    21.10.8 Adding an equals method to the Java classes

    @@ -6668,7 +6668,7 @@ System.out.println("foo1? " + foo1.equals(foo2)); -

    20.10.9 Void pointers and a common Java base class

    +

    21.10.9 Void pointers and a common Java base class

    @@ -6727,7 +6727,7 @@ This example contains some useful functionality which you may want in your code.

  • It also has a function which effectively implements a cast from the type of the proxy/type wrapper class to a void pointer. This is necessary for passing a proxy class or a type wrapper class to a function that takes a void pointer. -

    20.10.10 Struct pointer to pointer

    +

    21.10.10 Struct pointer to pointer

    @@ -6907,7 +6907,7 @@ The C functional interface has been completely morphed into an object-oriented i the Butler class would behave much like any pure Java class and feel more natural to Java users.

    -

    20.10.11 Memory management when returning references to member variables

    +

    21.10.11 Memory management when returning references to member variables

    @@ -7030,7 +7030,7 @@ public class Bike { Note the addReference call.

    -

    20.10.12 Memory management for objects passed to the C++ layer

    +

    21.10.12 Memory management for objects passed to the C++ layer

    @@ -7146,7 +7146,7 @@ The 'javacode' typemap simply adds in the specified code into the Java proxy cla -

    20.10.13 Date marshalling using the javain typemap and associated attributes

    +

    21.10.13 Date marshalling using the javain typemap and associated attributes

    @@ -7323,7 +7323,7 @@ A few things to note: -

    20.11 Living with Java Directors

    +

    21.11 Living with Java Directors

    @@ -7504,10 +7504,10 @@ public abstract class UserVisibleFoo extends Foo {

  • -

    20.12 Odds and ends

    +

    21.12 Odds and ends

    -

    20.12.1 JavaDoc comments

    +

    21.12.1 JavaDoc comments

    @@ -7563,7 +7563,7 @@ public class Barmy { -

    20.12.2 Functional interface without proxy classes

    +

    21.12.2 Functional interface without proxy classes

    @@ -7624,7 +7624,7 @@ All destructors have to be called manually for example the delete_Foo(foo) -

    20.12.3 Using your own JNI functions

    +

    21.12.3 Using your own JNI functions

    @@ -7674,7 +7674,7 @@ This directive is only really useful if you want to mix your own hand crafted JN

    -

    20.12.4 Performance concerns and hints

    +

    21.12.4 Performance concerns and hints

    @@ -7695,7 +7695,7 @@ However, you will have to be careful about memory management and make sure that This method normally calls the C++ destructor or free() for C code.

    -

    20.12.5 Debugging

    +

    21.12.5 Debugging

    @@ -7717,7 +7717,7 @@ The -verbose:jni and -verbose:gc are also useful options for monitoring code beh

    -

    20.13 Examples

    +

    21.13 Examples

    diff --git a/Doc/Manual/Lisp.html b/Doc/Manual/Lisp.html index ca2d0414e..14abead00 100644 --- a/Doc/Manual/Lisp.html +++ b/Doc/Manual/Lisp.html @@ -6,7 +6,7 @@ -

    21 SWIG and Common Lisp

    +

    22 SWIG and Common Lisp

      @@ -41,7 +41,7 @@ Lisp, Common Foreign Function Interface(CFFI), CLisp and UFFI foreign function interfaces.

      -

      21.1 Allegro Common Lisp

      +

      22.1 Allegro Common Lisp

      @@ -50,7 +50,7 @@ here

      -

      21.2 Common Foreign Function Interface(CFFI)

      +

      22.2 Common Foreign Function Interface(CFFI)

      @@ -77,7 +77,7 @@ swig -cffi -module module-name file-name files and the various things which you can do with them.

      -

      21.2.1 Additional Commandline Options

      +

      22.2.1 Additional Commandline Options

      @@ -118,7 +118,7 @@ swig -cffi -help -

      21.2.2 Generating CFFI bindings

      +

      22.2.2 Generating CFFI bindings

      As we mentioned earlier the ideal way to use SWIG is to use interface @@ -392,7 +392,7 @@ The feature intern_function ensures that all C names are
    -

    21.2.3 Generating CFFI bindings for C++ code

    +

    22.2.3 Generating CFFI bindings for C++ code

    This feature to SWIG (for CFFI) is very new and still far from @@ -568,7 +568,7 @@ If you have any questions, suggestions, patches, etc., related to CFFI module feel free to contact us on the SWIG mailing list, and also please add a "[CFFI]" tag in the subject line. -

    21.2.4 Inserting user code into generated files

    +

    22.2.4 Inserting user code into generated files

    @@ -608,7 +608,7 @@ Note that the block %{ ... %} is effectively a shortcut for

    -

    21.3 CLISP

    +

    22.3 CLISP

    @@ -638,7 +638,7 @@ swig -clisp -module module-name file-name interface file for the CLISP module. The CLISP module tries to produce code which is both human readable and easily modifyable.

    -

    21.3.1 Additional Commandline Options

    +

    22.3.1 Additional Commandline Options

    @@ -671,7 +671,7 @@ and global variables will be created otherwise only definitions for
    -

    21.3.2 Details on CLISP bindings

    +

    22.3.2 Details on CLISP bindings

    @@ -795,7 +795,7 @@ struct bar { -

    21.4 UFFI

    +

    22.4 UFFI

    diff --git a/Doc/Manual/Lua.html b/Doc/Manual/Lua.html index 4ebf02349..99c7c9a3c 100644 --- a/Doc/Manual/Lua.html +++ b/Doc/Manual/Lua.html @@ -6,7 +6,7 @@ -

    22 SWIG and Lua

    +

    23 SWIG and Lua

      @@ -52,13 +52,13 @@

      Lua is an extension programming language designed to support general procedural programming with data description facilities. It also offers good support for object-oriented programming, functional programming, and data-driven programming. Lua is intended to be used as a powerful, light-weight configuration language for any program that needs one. Lua is implemented as a library, written in clean C (that is, in the common subset of ANSI C and C++). Its also a really tiny language, less than 6000 lines of code, which compiles to <100 kilobytes of binary code. It can be found at http://www.lua.org

      -

      22.1 Preliminaries

      +

      23.1 Preliminaries

      The current SWIG implementation is designed to work with Lua 5.0.x and Lua 5.1.x. It should work with later versions of Lua, but certainly not with Lua 4.0 due to substantial API changes. ((Currently SWIG generated code has only been tested on Windows with MingW, though given the nature of Lua, is should not have problems on other OS's)). It is possible to either static link or dynamic link a Lua module into the interpreter (normally Lua static links its libraries, as dynamic linking is not available on all platforms).

      -

      22.2 Running SWIG

      +

      23.2 Running SWIG

      @@ -90,7 +90,7 @@ This creates a C/C++ source file example_wrap.c or example_wrap.cxx

      The name of the wrapper file is derived from the name of the input file. For example, if the input file is example.i, the name of the wrapper file is example_wrap.c. To change this, you can use the -o option. The wrappered module will export one function "int luaopen_example(lua_State* L)" which must be called to register the module with the Lua interpreter. The name "luaopen_example" depends upon the name of the module.

      -

      22.2.1 Compiling and Linking and Interpreter

      +

      23.2.1 Compiling and Linking and Interpreter

      @@ -137,7 +137,7 @@ $ gcc -c example.c -o example.o $ gcc -I/usr/include/lua -L/usr/lib/lua min.o example_wrap.o example.o -o my_lua

    -

    22.2.2 Compiling a dynamic module

    +

    23.2.2 Compiling a dynamic module

    @@ -205,7 +205,7 @@ Is quite obvious (Go back and consult the Lua documents on how to enable loadlib -

    22.2.3 Using your module

    +

    23.2.3 Using your module

    @@ -223,19 +223,19 @@ $ ./my_lua > -

    22.3 A tour of basic C/C++ wrapping

    +

    23.3 A tour of basic C/C++ wrapping

    By default, SWIG tries to build a very natural Lua interface to your C/C++ code. This section briefly covers the essential aspects of this wrapping.

    -

    22.3.1 Modules

    +

    23.3.1 Modules

    The SWIG module directive specifies the name of the Lua module. If you specify `module example', then everything is wrapped into a Lua table 'example' containing all the functions and variables. When choosing a module name, make sure you don't use the same name as a built-in Lua command or standard module name.

    -

    22.3.2 Functions

    +

    23.3.2 Functions

    @@ -273,7 +273,7 @@ It is also possible to rename the module with an assignment. 24 -

    22.3.3 Global variables

    +

    23.3.3 Global variables

    @@ -347,7 +347,7 @@ nil 3.142 -

    22.3.4 Constants and enums

    +

    23.3.4 Constants and enums

    @@ -370,7 +370,7 @@ example.SUNDAY=0

    Constants are not guaranteed to remain constant in Lua. The name of the constant could be accidentally reassigned to refer to some other object. Unfortunately, there is no easy way for SWIG to generate code that prevents this. You will just have to be careful.

    -

    22.3.5 Pointers

    +

    23.3.5 Pointers

    @@ -408,7 +408,7 @@ Lua enforces the integrity of its userdata, so it is virtually impossible to cor nil -

    22.3.6 Structures

    +

    23.3.6 Structures

    @@ -494,7 +494,7 @@ Because the pointer points inside the structure, you can modify the contents and > x.a = 3 -- Modifies the same structure -

    22.3.7 C++ classes

    +

    23.3.7 C++ classes

    @@ -555,7 +555,7 @@ It is not (currently) possible to access static members of an instance: -- does NOT work -

    22.3.8 C++ inheritance

    +

    23.3.8 C++ inheritance

    @@ -580,7 +580,7 @@ then the function spam() accepts a Foo pointer or a pointer to any clas

    It is safe to use multiple inheritance with SWIG.

    -

    22.3.9 Pointers, references, values, and arrays

    +

    23.3.9 Pointers, references, values, and arrays

    @@ -611,7 +611,7 @@ Foo spam7();

    then all three functions will return a pointer to some Foo object. Since the third function (spam7) returns a value, newly allocated memory is used to hold the result and a pointer is returned (Lua will release this memory when the return value is garbage collected). The other two are pointers which are assumed to be managed by the C code and so will not be garbage collected.

    -

    22.3.10 C++ overloaded functions

    +

    23.3.10 C++ overloaded functions

    @@ -697,7 +697,7 @@ Please refer to the "SWIG and C++" chapter for more information about overloadin

    Dealing with the Lua coercion mechanism, the priority is roughly (integers, floats, strings, userdata). But it is better to rename the functions rather than rely upon the ordering.

    -

    22.3.11 C++ operators

    +

    23.3.11 C++ operators

    @@ -809,7 +809,7 @@ It is also possible to overload the operator[], but currently this cann }; -

    22.3.12 Class extension with %extend

    +

    23.3.12 Class extension with %extend

    @@ -864,7 +864,7 @@ true

    Extend works with both C and C++ code, on classes and structs. It does not modify the underlying object in any way---the extensions only show up in the Lua interface. The only item to take note of is the code has to use the '$self' instead of 'this', and that you cannot access protected/private members of the code (as you are not officially part of the class).

    -

    22.3.13 C++ templates

    +

    23.3.13 C++ templates

    @@ -899,7 +899,7 @@ In Lua:

    Obviously, there is more to template wrapping than shown in this example. More details can be found in the SWIG and C++ chapter. Some more complicated examples will appear later.

    -

    22.3.14 C++ Smart Pointers

    +

    23.3.14 C++ Smart Pointers

    @@ -951,7 +951,7 @@ If you ever need to access the underlying pointer returned by operator->( > f = p:__deref__() -- Returns underlying Foo * -

    22.3.15 C++ Exceptions

    +

    23.3.15 C++ Exceptions

    @@ -1098,7 +1098,7 @@ add exception specification to functions or globally (respectively).

    -

    22.3.16 Writing your own custom wrappers

    +

    23.3.16 Writing your own custom wrappers

    @@ -1117,7 +1117,7 @@ int native_function(lua_State*L) // my native code The %native directive in the above example, tells SWIG that there is a function int native_function(lua_State*L); which is to be added into the module under the name 'my_func'. SWIG will not add any wrappering for this function, beyond adding it into the function table. How you write your code is entirely up to you.

    -

    22.3.17 Adding additional Lua code

    +

    23.3.17 Adding additional Lua code

    @@ -1155,7 +1155,7 @@ Good uses for this feature is adding of new code, or writing helper functions to See Examples/lua/arrays for an example of this code.

    -

    22.4 Details on the Lua binding

    +

    23.4 Details on the Lua binding

    @@ -1166,7 +1166,7 @@ See Examples/lua/arrays for an example of this code.

    -

    22.4.1 Binding global data into the module.

    +

    23.4.1 Binding global data into the module.

    @@ -1226,7 +1226,7 @@ end

    That way when you call 'a=example.Foo', the interpreter looks at the table 'example' sees that there is no field 'Foo' and calls __index. This will in turn check in '.get' table and find the existence of 'Foo' and then return the value of the C function call 'Foo_get()'. Similarly for the code 'example.Foo=10', the interpreter will check the table, then call the __newindex which will then check the '.set' table and call the C function 'Foo_set(10)'.

    -

    22.4.2 Userdata and Metatables

    +

    23.4.2 Userdata and Metatables

    @@ -1306,7 +1306,7 @@ Note: Both the opaque structures (like the FILE*) and normal wrappered classes/s

    Note: Operator overloads are basically done in the same way, by adding functions such as '__add' & '__call' to the classes metatable. The current implementation is a bit rough as it will add any member function beginning with '__' into the metatable too, assuming its an operator overload.

    -

    22.4.3 Memory management

    +

    23.4.3 Memory management

    diff --git a/Doc/Manual/Modula3.html b/Doc/Manual/Modula3.html index ff70fc143..7a6bacd34 100644 --- a/Doc/Manual/Modula3.html +++ b/Doc/Manual/Modula3.html @@ -5,7 +5,7 @@ -

    23 SWIG and Modula-3

    +

    24 SWIG and Modula-3

      @@ -57,7 +57,7 @@ especially typemaps.

      -

      23.1 Overview

      +

      24.1 Overview

      @@ -90,7 +90,7 @@ So the introduction got a bit longer than it should ... ;-)

      -

      23.1.1 Why not scripting ?

      +

      24.1.1 Why not scripting ?

      @@ -126,7 +126,7 @@ are not advantages of the language itself but can be provided by function libraries.

      -

      23.1.2 Why Modula-3 ?

      +

      24.1.2 Why Modula-3 ?

      @@ -166,7 +166,7 @@ it's statically typed, too.

      -

      23.1.3 Why C / C++ ?

      +

      24.1.3 Why C / C++ ?

      @@ -179,7 +179,7 @@ Even more fortunately even non-C libraries may provide C header files. This is where SWIG becomes helpful.

      -

      23.1.4 Why SWIG ?

      +

      24.1.4 Why SWIG ?

      @@ -252,10 +252,10 @@ integrate Modula-3 code into a C / C++ project.

      -

      23.2 Conception

      +

      24.2 Conception

      -

      23.2.1 Interfaces to C libraries

      +

      24.2.1 Interfaces to C libraries

      @@ -404,7 +404,7 @@ and the principal type must be renamed (%typemap).

      -

      23.2.2 Interfaces to C++ libraries

      +

      24.2.2 Interfaces to C++ libraries

      @@ -505,10 +505,10 @@ There is no C++ library I wrote a SWIG interface for, so I'm not sure if this is possible or sensible, yet.

      -

      23.3 Preliminaries

      +

      24.3 Preliminaries

      -

      23.3.1 Compilers

      +

      24.3.1 Compilers

      @@ -522,7 +522,7 @@ For testing examples I use Critical Mass cm3.

      -

      23.3.2 Additional Commandline Options

      +

      24.3.2 Additional Commandline Options

      @@ -599,10 +599,10 @@ Instead generate templates for some basic typemaps. -

      23.4 Modula-3 typemaps

      +

      24.4 Modula-3 typemaps

      -

      23.4.1 Inputs and outputs

      +

      24.4.1 Inputs and outputs

      @@ -818,7 +818,7 @@ consist of the following parts: -

      23.4.2 Subranges, Enumerations, Sets

      +

      24.4.2 Subranges, Enumerations, Sets

      @@ -870,7 +870,7 @@ that I'd like to automate.

      -

      23.4.3 Objects

      +

      24.4.3 Objects

      @@ -883,7 +883,7 @@ is not really useful, yet.

      -

      23.4.4 Imports

      +

      24.4.4 Imports

      @@ -918,7 +918,7 @@ IMPORT M3toC;

    -

    23.4.5 Exceptions

    +

    24.4.5 Exceptions

    @@ -942,7 +942,7 @@ you should declare %typemap("m3wrapinconv:throws") blah * %{OSError.E%}.

    -

    23.4.6 Example

    +

    24.4.6 Example

    @@ -989,10 +989,10 @@ where almost everything is generated by a typemap: -

    23.5 More hints to the generator

    +

    24.5 More hints to the generator

    -

    23.5.1 Features

    +

    24.5.1 Features

    @@ -1029,7 +1029,7 @@ where almost everything is generated by a typemap:
    -

    23.5.2 Pragmas

    +

    24.5.2 Pragmas

    @@ -1052,7 +1052,7 @@ where almost everything is generated by a typemap:
    -

    23.6 Remarks

    +

    24.6 Remarks

      diff --git a/Doc/Manual/Modules.html b/Doc/Manual/Modules.html index 5ac66dc2e..3fbfc70b0 100644 --- a/Doc/Manual/Modules.html +++ b/Doc/Manual/Modules.html @@ -6,7 +6,7 @@ -

      15 Working with Modules

      +

      16 Working with Modules

        @@ -37,7 +37,7 @@ This chapter describes the problem of using SWIG in programs where you want to create a collection of modules.

        -

        15.1 Basics

        +

        16.1 Basics

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

        -

        15.2 The SWIG runtime code

        +

        16.2 The SWIG runtime code

        @@ -201,7 +201,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

        +

        16.3 External access to the runtime

        As described in The run-time type checker, @@ -238,7 +238,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

        +

        16.4 A word of caution about static libraries

        @@ -249,7 +249,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

        +

        16.5 References

        @@ -257,7 +257,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

        +

        16.6 Reducing the wrapper file size

        diff --git a/Doc/Manual/Mzscheme.html b/Doc/Manual/Mzscheme.html index 699168322..9413bb010 100644 --- a/Doc/Manual/Mzscheme.html +++ b/Doc/Manual/Mzscheme.html @@ -8,7 +8,7 @@ -

        24 SWIG and MzScheme

        +

        25 SWIG and MzScheme

          @@ -22,7 +22,7 @@

          This section contains information on SWIG's support of MzScheme. -

          24.1 Creating native MzScheme structures

          +

          25.1 Creating native MzScheme structures

          diff --git a/Doc/Manual/Ocaml.html b/Doc/Manual/Ocaml.html index 79ede443f..6dbf24c11 100644 --- a/Doc/Manual/Ocaml.html +++ b/Doc/Manual/Ocaml.html @@ -6,7 +6,7 @@ -

          25 SWIG and Ocaml

          +

          26 SWIG and Ocaml

            @@ -80,7 +80,7 @@ If you're not familiar with the Objective Caml language, you can visit The Ocaml Website.

            -

            25.1 Preliminaries

            +

            26.1 Preliminaries

            @@ -99,7 +99,7 @@ file Examples/Makefile illustrate how to compile and link SWIG modules that will be loaded dynamically. This has only been tested on Linux so far.

            -

            25.1.1 Running SWIG

            +

            26.1.1 Running SWIG

            @@ -122,7 +122,7 @@ you will compile the file example_wrap.c with ocamlc or the resulting .ml and .mli files as well, and do the final link with -custom (not needed for native link).

            -

            25.1.2 Compiling the code

            +

            26.1.2 Compiling the code

            @@ -158,7 +158,7 @@ the user more freedom with respect to custom typing.

          -

          25.1.3 The camlp4 module

          +

          26.1.3 The camlp4 module

          @@ -234,7 +234,7 @@ let b = C_string (getenv "PATH") -

          25.1.4 Using your module

          +

          26.1.4 Using your module

          @@ -248,7 +248,7 @@ When linking any ocaml bytecode with your module, use the -custom option is not needed when you build native code.

          -

          25.1.5 Compilation problems and compiling with C++

          +

          26.1.5 Compilation problems and compiling with C++

          @@ -259,7 +259,7 @@ liberal with pointer types may not compile under the C++ compiler. Most code meant to be compiled as C++ will not have problems.

          -

          25.2 The low-level Ocaml/C interface

          +

          26.2 The low-level Ocaml/C interface

          @@ -360,7 +360,7 @@ is that you must append them to the return list with swig_result = caml_list_a signature for a function that uses value in this way.

          -

          25.2.1 The generated module

          +

          26.2.1 The generated module

          @@ -394,7 +394,7 @@ it describes the output SWIG will generate for class definitions. -

          25.2.2 Enums

          +

          26.2.2 Enums

          @@ -457,7 +457,7 @@ val x : Enum_test.c_obj = C_enum `a

        -

        25.2.2.1 Enum typing in Ocaml

        +

        26.2.2.1 Enum typing in Ocaml

        @@ -470,10 +470,10 @@ functions imported from different modules. You must convert values to master values using the swig_val function before sharing them with another module.

        -

        25.2.3 Arrays

        +

        26.2.3 Arrays

        -

        25.2.3.1 Simple types of bounded arrays

        +

        26.2.3.1 Simple types of bounded arrays

        @@ -494,7 +494,7 @@ arrays of simple types with known bounds in your code, but this only works for arrays whose bounds are completely specified.

        -

        25.2.3.2 Complex and unbounded arrays

        +

        26.2.3.2 Complex and unbounded arrays

        @@ -507,7 +507,7 @@ SWIG can't predict which of these methods will be used in the array, so you have to specify it for yourself in the form of a typemap.

        -

        25.2.3.3 Using an object

        +

        26.2.3.3 Using an object

        @@ -521,7 +521,7 @@ Consider writing an object when the ending condition of your array is complex, such as using a required sentinel, etc.

        -

        25.2.3.4 Example typemap for a function taking float * and int

        +

        26.2.3.4 Example typemap for a function taking float * and int

        @@ -572,7 +572,7 @@ void printfloats( float *tab, int len ); -

        25.2.4 C++ Classes

        +

        26.2.4 C++ Classes

        @@ -615,7 +615,7 @@ the underlying pointer, so using create_[x]_from_ptr alters the returned value for the same object.

        -

        25.2.4.1 STL vector and string Example

        +

        26.2.4.1 STL vector and string Example

        @@ -695,7 +695,7 @@ baz #

      -

      25.2.4.2 C++ Class Example

      +

      26.2.4.2 C++ Class Example

      @@ -725,7 +725,7 @@ public: }; -

      25.2.4.3 Compiling the example

      +

      26.2.4.3 Compiling the example

      @@ -743,7 +743,7 @@ bash-2.05a$ ocamlmktop -custom swig.cmo -I `camlp4 -where` \
         -L$QTPATH/lib -cclib -lqt
       
      -

      25.2.4.4 Sample Session

      +

      26.2.4.4 Sample Session

      @@ -770,10 +770,10 @@ Assuming you have a working installation of QT, you will see a window
       containing the string "hi" in a button.  
       

      -

      25.2.5 Director Classes

      +

      26.2.5 Director Classes

      -

      25.2.5.1 Director Introduction

      +

      26.2.5.1 Director Introduction

      @@ -800,7 +800,7 @@ class foo { };

      -

      25.2.5.2 Overriding Methods in Ocaml

      +

      26.2.5.2 Overriding Methods in Ocaml

      @@ -828,7 +828,7 @@ In this example, I'll examine the objective caml code involved in providing an overloaded class. This example is contained in Examples/ocaml/shapes.

      -

      25.2.5.3 Director Usage Example

      +

      26.2.5.3 Director Usage Example

      @@ -887,7 +887,7 @@ in a more effortless style in ocaml, while leaving the "engine" part of the program in C++.

      -

      25.2.5.4 Creating director objects

      +

      26.2.5.4 Creating director objects

      @@ -928,7 +928,7 @@ object from causing a core dump, as long as the object is destroyed properly.

      -

      25.2.5.5 Typemaps for directors, directorin, directorout, directorargout

      +

      26.2.5.5 Typemaps for directors, directorin, directorout, directorargout

      @@ -939,7 +939,7 @@ well as a function return value in the same way you provide function arguments, and to receive arguments the same way you normally receive function returns.

      -

      25.2.5.6 directorin typemap

      +

      26.2.5.6 directorin typemap

      @@ -950,7 +950,7 @@ code receives when you are called. In general, a simple directorin typ can use the same body as a simple out typemap.

      -

      25.2.5.7 directorout typemap

      +

      26.2.5.7 directorout typemap

      @@ -961,7 +961,7 @@ for the same type, except when there are special requirements for object ownership, etc.

      -

      25.2.5.8 directorargout typemap

      +

      26.2.5.8 directorargout typemap

      @@ -978,7 +978,7 @@ In the event that you don't specify all of the necessary values, integral values will read zero, and struct or object returns have undefined results.

      -

      25.2.6 Exceptions

      +

      26.2.6 Exceptions

      diff --git a/Doc/Manual/Octave.html b/Doc/Manual/Octave.html index 97e1be17c..7409d78f1 100644 --- a/Doc/Manual/Octave.html +++ b/Doc/Manual/Octave.html @@ -8,7 +8,7 @@ -

      26 SWIG and Octave

      +

      27 SWIG and Octave

        @@ -54,14 +54,14 @@ More information can be found at www.octave.org< Also, there are a dozen or so examples in the Examples/octave directory, and hundreds in the test suite (Examples/test-suite and Examples/test-suite/octave).

        -

        26.1 Preliminaries

        +

        27.1 Preliminaries

        The current SWIG implemention is based on Octave 2.9.12. Support for other versions (in particular the recent 3.0) has not been tested, nor has support for any OS other than Linux.

        -

        26.2 Running SWIG

        +

        27.2 Running SWIG

        @@ -89,7 +89,7 @@ This creates a C/C++ source file example_wrap.cxx. The generated C++ so The swig command line has a number of options you can use, like to redirect it's output. Use swig --help to learn about these.

        -

        26.2.1 Compiling a dynamic module

        +

        27.2.1 Compiling a dynamic module

        @@ -116,7 +116,7 @@ $ mkoctfile example_wrap.cxx example.c

        octave:1> example
        -

        26.2.2 Using your module

        +

        27.2.2 Using your module

        @@ -134,10 +134,10 @@ octave:4> example.cvar.Foo=4; octave:5> example.cvar.Foo ans = 4

      -

      26.3 A tour of basic C/C++ wrapping

      +

      27.3 A tour of basic C/C++ wrapping

      -

      26.3.1 Modules

      +

      27.3.1 Modules

      @@ -179,7 +179,7 @@ One can also rename it by simple assignment, e.g., octave:1> some_vars = cvar; -

      26.3.2 Functions

      +

      27.3.2 Functions

      @@ -196,7 +196,7 @@ int fact(int n);

      octave:1> example.fact(4)
       24 
      -

      26.3.3 Global variables

      +

      27.3.3 Global variables

      @@ -249,7 +249,7 @@ octave:2> example.PI=3.142; octave:3> example.PI ans = 3.1420 -

      26.3.4 Constants and enums

      +

      27.3.4 Constants and enums

      @@ -271,7 +271,7 @@ example.SCONST="Hello World" example.SUNDAY=0 .... -

      26.3.5 Pointers

      +

      27.3.5 Pointers

      @@ -318,7 +318,7 @@ octave:2> f=example.fopen("not there","r"); error: value on right hand side of assignment is undefined error: evaluating assignment expression near line 2, column 2 -

      26.3.6 Structures and C++ classes

      +

      27.3.6 Structures and C++ classes

      @@ -453,7 +453,7 @@ ans = 1 Depending on the ownership setting of a swig_ref, it may call C++ destructors when its reference count goes to zero. See the section on memory management below for details.

      -

      26.3.7 C++ inheritance

      +

      27.3.7 C++ inheritance

      @@ -462,7 +462,7 @@ This information contains the full class hierarchy. When an indexing operation ( the tree is walked to find a match in the current class as well as any of its bases. The lookup is then cached in the swig_ref.

      -

      26.3.8 C++ overloaded functions

      +

      27.3.8 C++ overloaded functions

      @@ -472,7 +472,7 @@ The dispatch function selects which overload to call (if any) based on the passe typecheck typemaps are used to analyze each argument, as well as assign precedence. See the chapter on typemaps for details.

      -

      26.3.9 C++ operators

      +

      27.3.9 C++ operators

      @@ -572,7 +572,7 @@ On the C++ side, the default mappings are as follows: %rename(__brace) *::operator[]; -

      26.3.10 Class extension with %extend

      +

      27.3.10 Class extension with %extend

      @@ -602,7 +602,7 @@ octave:3> printf("%s\n",a); octave:4> a.__str() 4 -

      26.3.11 C++ templates

      +

      27.3.11 C++ templates

      @@ -679,14 +679,14 @@ ans = -

      26.3.12 C++ Smart Pointers

      +

      27.3.12 C++ Smart Pointers

      C++ smart pointers are fully supported as in other modules.

      -

      26.3.13 Directors (calling Octave from C++ code)

      +

      27.3.13 Directors (calling Octave from C++ code)

      @@ -766,14 +766,14 @@ c-side routine called octave-side routine called -

      26.3.14 Threads

      +

      27.3.14 Threads

      The use of threads in wrapped Director code is not supported; i.e., an Octave-side implementation of a C++ class must be called from the Octave interpreter's thread. Anything fancier (apartment/queue model, whatever) is left to the user. Without anything fancier, this amounts to the limitation that Octave must drive the module... like, for example, an optimization package that calls Octave to evaluate an objective function.

      -

      26.3.15 Memory management

      +

      27.3.15 Memory management

      @@ -807,14 +807,14 @@ The %newobject directive may be used to control this behavior for pointers retur In the case where one wishes for the C++ side to own an object that was created in Octave (especially a Director object), one can use the __disown() method to invert this logic. Then letting the Octave reference count go to zero will not destroy the object, but destroying the object will invalidate the Octave-side object if it still exists (and call destructors of other C++ bases in the case of multiple inheritance/subclass()'ing).

      -

      26.3.16 STL support

      +

      27.3.16 STL support

      This is some skeleton support for various STL containers.

      -

      26.3.17 Matrix typemaps

      +

      27.3.17 Matrix typemaps

      diff --git a/Doc/Manual/Perl5.html b/Doc/Manual/Perl5.html index b7cdaf0e5..1dc8e7d2f 100644 --- a/Doc/Manual/Perl5.html +++ b/Doc/Manual/Perl5.html @@ -6,7 +6,7 @@ -

      27 SWIG and Perl5

      +

      28 SWIG and Perl5

        @@ -87,7 +87,7 @@ later. Earlier versions are problematic and SWIG generated extensions may not compile or run correctly.

        -

        27.1 Overview

        +

        28.1 Overview

        @@ -108,7 +108,7 @@ described. Advanced customization features, typemaps, and other options are found near the end of the chapter.

        -

        27.2 Preliminaries

        +

        28.2 Preliminaries

        @@ -133,7 +133,7 @@ To build the module, you will need to compile the file example_wrap.c and link it with the rest of your program.

        -

        27.2.1 Getting the right header files

        +

        28.2.1 Getting the right header files

        @@ -165,7 +165,7 @@ loaded, an easy way to find out is to run Perl itself.

      -

      27.2.2 Compiling a dynamic module

      +

      28.2.2 Compiling a dynamic module

      @@ -198,7 +198,7 @@ the target should be named `example.so', `example.sl', or the appropriate dynamic module name on your system.

      -

      27.2.3 Building a dynamic module with MakeMaker

      +

      28.2.3 Building a dynamic module with MakeMaker

      @@ -232,7 +232,7 @@ the preferred approach to compilation. More information about MakeMaker can be found in "Programming Perl, 2nd ed." by Larry Wall, Tom Christiansen, and Randal Schwartz.

      -

      27.2.4 Building a static version of Perl

      +

      28.2.4 Building a static version of Perl

      @@ -301,7 +301,7 @@ added to it. Depending on your machine, you may need to link with additional libraries such as -lsocket, -lnsl, -ldl, etc.

      -

      27.2.5 Using the module

      +

      28.2.5 Using the module

      @@ -456,7 +456,7 @@ system configuration (this requires root access and you will need to read the man pages).

      -

      27.2.6 Compilation problems and compiling with C++

      +

      28.2.6 Compilation problems and compiling with C++

      @@ -599,7 +599,7 @@ have to find the macro that conflicts and add an #undef into the .i file. Pleas any conflicting macros you find to swig-user mailing list.

      -

      27.2.7 Compiling for 64-bit platforms

      +

      28.2.7 Compiling for 64-bit platforms

      @@ -626,7 +626,7 @@ also introduce problems on platforms that support more than one linking standard (e.g., -o32 and -n32 on Irix).

      -

      27.3 Building Perl Extensions under Windows

      +

      28.3 Building Perl Extensions under Windows

      @@ -637,7 +637,7 @@ section assumes you are using SWIG with Microsoft Visual C++ although the procedure may be similar with other compilers.

      -

      27.3.1 Running SWIG from Developer Studio

      +

      28.3.1 Running SWIG from Developer Studio

      @@ -700,7 +700,7 @@ print "$a\n"; -

      27.3.2 Using other compilers

      +

      28.3.2 Using other compilers

      @@ -708,7 +708,7 @@ SWIG is known to work with Cygwin and may work with other compilers on Windows. For general hints and suggestions refer to the Windows chapter.

      -

      27.4 The low-level interface

      +

      28.4 The low-level interface

      @@ -718,7 +718,7 @@ can be used to control your application. However, it is also used to construct more user-friendly proxy classes as described in the next section.

      -

      27.4.1 Functions

      +

      28.4.1 Functions

      @@ -741,7 +741,7 @@ use example; $a = &example::fact(2); -

      27.4.2 Global variables

      +

      28.4.2 Global variables

      @@ -811,7 +811,7 @@ extern char *path; // Declared later in the input -

      27.4.3 Constants

      +

      28.4.3 Constants

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

      27.4.4 Pointers

      +

      28.4.4 Pointers

      @@ -947,7 +947,7 @@ as XS and xsubpp. Given the advancement of the SWIG typesystem and the SWIG and XS, this is no longer supported.

      -

      27.4.5 Structures

      +

      28.4.5 Structures

      @@ -1081,7 +1081,7 @@ void Bar_f_set(Bar *b, Foo *val) { -

      27.4.6 C++ classes

      +

      28.4.6 C++ classes

      @@ -1146,7 +1146,7 @@ provides direct access to C++ objects. A higher level interface using Perl prox can be built using these low-level accessors. This is described shortly.

      -

      27.4.7 C++ classes and type-checking

      +

      28.4.7 C++ classes and type-checking

      @@ -1182,7 +1182,7 @@ If necessary, the type-checker also adjusts the value of the pointer (as is nece multiple inheritance is used).

      -

      27.4.8 C++ overloaded functions

      +

      28.4.8 C++ overloaded functions

      @@ -1226,7 +1226,7 @@ example::Spam_foo_d($s,3.14); Please refer to the "SWIG Basics" chapter for more information.

      -

      27.4.9 Operators

      +

      28.4.9 Operators

      @@ -1253,7 +1253,7 @@ The following C++ operators are currently supported by the Perl module:

    • operator or
    • -

      27.4.10 Modules and packages

      +

      28.4.10 Modules and packages

      @@ -1348,7 +1348,7 @@ print Foo::fact(4),"\n"; # Call a function in package FooBar --> -

      27.5 Input and output parameters

      +

      28.5 Input and output parameters

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

      -

      27.6 Exception handling

      +

      28.6 Exception handling

      @@ -1732,7 +1732,7 @@ This is still supported, but it is deprecated. The newer %exception di functionality, but it has additional capabilities that make it more powerful.

      -

      27.7 Remapping datatypes with typemaps

      +

      28.7 Remapping datatypes with typemaps

      @@ -1749,7 +1749,7 @@ Typemaps are only used if you want to change some aspect of the primitive C-Perl interface.

      -

      27.7.1 A simple typemap example

      +

      28.7.1 A simple typemap example

      @@ -1853,7 +1853,7 @@ example::count("e","Hello World"); -

      27.7.2 Perl5 typemaps

      +

      28.7.2 Perl5 typemaps

      @@ -1958,7 +1958,7 @@ Return of C++ member data (all languages). Check value of input parameter. -

      27.7.3 Typemap variables

      +

      28.7.3 Typemap variables

      @@ -2029,7 +2029,7 @@ properly assigned. The Perl name of the wrapper function being created. -

      27.7.4 Useful functions

      +

      28.7.4 Useful functions

      @@ -2098,7 +2098,7 @@ int sv_isa(SV *, char *0; -

      27.8 Typemap Examples

      +

      28.8 Typemap Examples

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

      -

      27.8.1 Converting a Perl5 array to a char **

      +

      28.8.1 Converting a Perl5 array to a char **

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

      27.8.2 Return values

      +

      28.8.2 Return values

      @@ -2228,7 +2228,7 @@ can be done using the EXTEND() macro as in : } -

      27.8.3 Returning values from arguments

      +

      28.8.3 Returning values from arguments

      @@ -2282,7 +2282,7 @@ print "multout(7,13) = @r\n"; ($x,$y) = multout(7,13); -

      27.8.4 Accessing array structure members

      +

      28.8.4 Accessing array structure members

      @@ -2345,7 +2345,7 @@ the "in" typemap in the previous section would be used to convert an to copy the converted array into a C data structure.

      -

      27.8.5 Turning Perl references into C pointers

      +

      28.8.5 Turning Perl references into C pointers

      @@ -2410,7 +2410,7 @@ print "$c\n"; -

      27.8.6 Pointer handling

      +

      28.8.6 Pointer handling

      @@ -2489,7 +2489,7 @@ For example: -

      27.9 Proxy classes

      +

      28.9 Proxy classes

      @@ -2505,7 +2505,7 @@ to the underlying code. This section describes the implementation details of the proxy interface.

      -

      27.9.1 Preliminaries

      +

      28.9.1 Preliminaries

      @@ -2527,7 +2527,7 @@ SWIG creates a collection of high-level Perl wrappers. In your scripts, you wil high level wrappers. The wrappers, in turn, interact with the low-level procedural module.

      -

      27.9.2 Structure and class wrappers

      +

      28.9.2 Structure and class wrappers

      @@ -2653,7 +2653,7 @@ $v->DESTROY(); -

      27.9.3 Object Ownership

      +

      28.9.3 Object Ownership

      @@ -2740,7 +2740,7 @@ counting, garbage collection, or advanced features one might find in sophisticated languages.

      -

      27.9.4 Nested Objects

      +

      28.9.4 Nested Objects

      @@ -2793,7 +2793,7 @@ $p->{f}->{x} = 0.0; %${$p->{v}} = ( x=>0, y=>0, z=>0); -

      27.9.5 Proxy Functions

      +

      28.9.5 Proxy Functions

      @@ -2827,7 +2827,7 @@ This function replaces the original function, but operates in an identical manner.

      -

      27.9.6 Inheritance

      +

      28.9.6 Inheritance

      @@ -2903,7 +2903,7 @@ particular, inheritance of data members is extremely tricky (and I'm not even sure if it really works).

      -

      27.9.7 Modifying the proxy methods

      +

      28.9.7 Modifying the proxy methods

      @@ -2931,7 +2931,7 @@ public: }; -

      27.10 Adding additional Perl code

      +

      28.10 Adding additional Perl code

      diff --git a/Doc/Manual/Php.html b/Doc/Manual/Php.html index aeb171b3f..d56edcb5f 100644 --- a/Doc/Manual/Php.html +++ b/Doc/Manual/Php.html @@ -7,7 +7,7 @@ -

      28 SWIG and PHP

      +

      29 SWIG and PHP

        @@ -69,7 +69,7 @@ your extension into php directly, you will need the complete PHP source tree available.

        -

        28.1 Generating PHP Extensions

        +

        29.1 Generating PHP Extensions

        @@ -116,7 +116,7 @@ and it doesn't play nicely with package system. We don't recommend this approach, or provide explicit support for it.

        -

        28.1.1 Building a loadable extension

        +

        29.1.1 Building a loadable extension

        @@ -131,7 +131,7 @@ least work for Linux though): gcc -shared example_wrap.o -o example.so

      -

      28.1.2 Using PHP Extensions

      +

      29.1.2 Using PHP Extensions

      @@ -162,7 +162,7 @@ attempts to do the dl() call for you: include("example.php"); -

      28.2 Basic PHP interface

      +

      29.2 Basic PHP interface

      @@ -172,7 +172,7 @@ possible for names of symbols in one extension module to clash with other symbols unless care is taken to %rename them.

      -

      28.2.1 Constants

      +

      29.2.1 Constants

      @@ -297,7 +297,7 @@ both point to the same value, without the case test taking place. ( Apologies, this paragraph needs rewriting to make some sense. )

      -

      28.2.2 Global Variables

      +

      29.2.2 Global Variables

      @@ -346,7 +346,7 @@ undefined. At this time SWIG does not support custom accessor methods.

      -

      28.2.3 Functions

      +

      29.2.3 Functions

      @@ -399,7 +399,7 @@ print $s; # The value of $s was not changed. --> -

      28.2.4 Overloading

      +

      29.2.4 Overloading

      @@ -455,7 +455,7 @@ taking the integer argument.

      --> -

      28.2.5 Pointers and References

      +

      29.2.5 Pointers and References

      @@ -587,7 +587,7 @@ PHP in a number of ways: by using unset on an existing variable, or assigning NULL to a variable.

      -

      28.2.6 Structures and C++ classes

      +

      29.2.6 Structures and C++ classes

      @@ -646,7 +646,7 @@ Would be used in the following way from PHP5: Member variables and methods are accessed using the -> operator.

      -

      28.2.6.1 Using -noproxy

      +

      29.2.6.1 Using -noproxy

      @@ -672,7 +672,7 @@ Complex_im_set($obj,$d); Complex_im_get($obj); -

      28.2.6.2 Constructors and Destructors

      +

      29.2.6.2 Constructors and Destructors

      @@ -713,7 +713,7 @@ the programmer can either reassign the variable or call unset($v)

      -

      28.2.6.3 Static Member Variables

      +

      29.2.6.3 Static Member Variables

      @@ -756,7 +756,7 @@ Ko::threats(10); echo "There has now been " . Ko::threats() . " threats\n"; -

      28.2.6.4 Static Member Functions

      +

      29.2.6.4 Static Member Functions

      @@ -778,7 +778,7 @@ Ko::threats(); -

      28.2.7 PHP Pragmas, Startup and Shutdown code

      +

      29.2.7 PHP Pragmas, Startup and Shutdown code

      diff --git a/Doc/Manual/Pike.html b/Doc/Manual/Pike.html index 3e39d4062..a47d07865 100644 --- a/Doc/Manual/Pike.html +++ b/Doc/Manual/Pike.html @@ -6,7 +6,7 @@ -

      29 SWIG and Pike

      +

      30 SWIG and Pike

        @@ -46,10 +46,10 @@ least, make sure you read the "SWIG Basics" chapter.

        -

        29.1 Preliminaries

        +

        30.1 Preliminaries

        -

        29.1.1 Running SWIG

        +

        30.1.1 Running SWIG

        @@ -94,7 +94,7 @@ can use the -o option:

        $ swig -pike -o pseudonym.c example.i
        -

        29.1.2 Getting the right header files

        +

        30.1.2 Getting the right header files

        @@ -114,7 +114,7 @@ You're looking for files with the names global.h, program.h and so on.

        -

        29.1.3 Using your module

        +

        30.1.3 Using your module

        @@ -129,10 +129,10 @@ Pike v7.4 release 10 running Hilfe v3.5 (Incremental Pike Frontend) (1) Result: 24

      -

      29.2 Basic C/C++ Mapping

      +

      30.2 Basic C/C++ Mapping

      -

      29.2.1 Modules

      +

      30.2.1 Modules

      @@ -143,7 +143,7 @@ concerned), SWIG's %module directive doesn't really have any significance.

      -

      29.2.2 Functions

      +

      30.2.2 Functions

      @@ -168,7 +168,7 @@ exactly as you'd expect it to: (1) Result: 24 -

      29.2.3 Global variables

      +

      30.2.3 Global variables

      @@ -197,7 +197,7 @@ will result in two functions, Foo_get() and Foo_set(): (3) Result: 3.141590 -

      29.2.4 Constants and enumerated types

      +

      30.2.4 Constants and enumerated types

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

      -

      29.2.5 Constructors and Destructors

      +

      30.2.5 Constructors and Destructors

      @@ -213,7 +213,7 @@ Constructors are wrapped as create() methods, and destructors are wrapped as destroy() methods, for Pike classes.

      -

      29.2.6 Static Members

      +

      30.2.6 Static Members

      diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html index 35625b1ca..f4867b69d 100644 --- a/Doc/Manual/Python.html +++ b/Doc/Manual/Python.html @@ -6,7 +6,7 @@ -

      30 SWIG and Python

      +

      31 SWIG and Python

        @@ -131,7 +131,7 @@ very least, make sure you read the "SWIG Basics" chapter.

        -

        30.1 Overview

        +

        31.1 Overview

        @@ -158,10 +158,10 @@ described followed by a discussion of low-level implementation details.

        -

        30.2 Preliminaries

        +

        31.2 Preliminaries

        -

        30.2.1 Running SWIG

        +

        31.2.1 Running SWIG

        @@ -259,7 +259,7 @@ The following sections have further practical examples and details on how you might go about compiling and using the generated files.

        -

        30.2.2 Using distutils

        +

        31.2.2 Using distutils

        @@ -351,7 +351,7 @@ This same approach works on all platforms if the appropriate compiler is install can even build extensions to the standard Windows Python using MingGW)

        -

        30.2.3 Hand compiling a dynamic module

        +

        31.2.3 Hand compiling a dynamic module

        @@ -399,7 +399,7 @@ module actually consists of two files; socket.py and

        -

        30.2.4 Static linking

        +

        31.2.4 Static linking

        @@ -478,7 +478,7 @@ If using static linking, you might want to rely on a different approach (perhaps using distutils).

        -

        30.2.5 Using your module

        +

        31.2.5 Using your module

        @@ -635,7 +635,7 @@ system configuration (this requires root access and you will need to read the man pages).

        -

        30.2.6 Compilation of C++ extensions

        +

        31.2.6 Compilation of C++ extensions

        @@ -734,7 +734,7 @@ erratic program behavior. If working with lots of software components, you might want to investigate using a more formal standard such as COM.

        -

        30.2.7 Compiling for 64-bit platforms

        +

        31.2.7 Compiling for 64-bit platforms

        @@ -771,7 +771,7 @@ and -m64 allow you to choose the desired binary format for your python extension.

        -

        30.2.8 Building Python Extensions under Windows

        +

        31.2.8 Building Python Extensions under Windows

        @@ -880,7 +880,7 @@ SWIG Wiki.

        -

        30.3 A tour of basic C/C++ wrapping

        +

        31.3 A tour of basic C/C++ wrapping

        @@ -889,7 +889,7 @@ to your C/C++ code. Functions are wrapped as functions, classes are wrapped as This section briefly covers the essential aspects of this wrapping.

        -

        30.3.1 Modules

        +

        31.3.1 Modules

        @@ -902,7 +902,7 @@ module name, make sure you don't use the same name as a built-in Python command or standard module name.

        -

        30.3.2 Functions

        +

        31.3.2 Functions

        @@ -926,7 +926,7 @@ like you think it does: >>>

      -

      30.3.3 Global variables

      +

      31.3.3 Global variables

      @@ -1064,7 +1064,7 @@ that starts with a leading underscore. SWIG does not create cvar if there are no global variables in a module.

      -

      30.3.4 Constants and enums

      +

      31.3.4 Constants and enums

      @@ -1104,7 +1104,7 @@ other object. Unfortunately, there is no easy way for SWIG to generate code that prevents this. You will just have to be careful.

      -

      30.3.5 Pointers

      +

      31.3.5 Pointers

      @@ -1245,7 +1245,7 @@ C-style cast may return a bogus result whereas as the C++-style cast will return None if the conversion can't be performed.

      -

      30.3.6 Structures

      +

      31.3.6 Structures

      @@ -1434,7 +1434,7 @@ everything works just like you would expect. For example: -

      30.3.7 C++ classes

      +

      31.3.7 C++ classes

      @@ -1523,7 +1523,7 @@ they are accessed through cvar like this: -

      30.3.8 C++ inheritance

      +

      31.3.8 C++ inheritance

      @@ -1578,7 +1578,7 @@ then the function spam() accepts Foo * or a pointer to any cla It is safe to use multiple inheritance with SWIG.

      -

      30.3.9 Pointers, references, values, and arrays

      +

      31.3.9 Pointers, references, values, and arrays

      @@ -1639,7 +1639,7 @@ treated as a returning value, and it will follow the same allocation/deallocation process.

      -

      30.3.10 C++ overloaded functions

      +

      31.3.10 C++ overloaded functions

      @@ -1762,7 +1762,7 @@ first declaration takes precedence. Please refer to the "SWIG and C++" chapter for more information about overloading.

      -

      30.3.11 C++ operators

      +

      31.3.11 C++ operators

      @@ -1851,7 +1851,7 @@ Also, be aware that certain operators don't map cleanly to Python. For instance overloaded assignment operators don't map to Python semantics and will be ignored.

      -

      30.3.12 C++ namespaces

      +

      31.3.12 C++ namespaces

      @@ -1918,7 +1918,7 @@ utilizes thousands of small deeply nested namespaces each with identical symbol names, well, then you get what you deserve.

      -

      30.3.13 C++ templates

      +

      31.3.13 C++ templates

      @@ -1972,7 +1972,7 @@ Some more complicated examples will appear later.

      -

      30.3.14 C++ Smart Pointers

      +

      31.3.14 C++ Smart Pointers

      @@ -2057,7 +2057,7 @@ simply use the __deref__() method. For example: -

      30.3.15 C++ Reference Counted Objects (ref/unref)

      +

      31.3.15 C++ Reference Counted Objects (ref/unref)

      @@ -2219,7 +2219,7 @@ python releases the proxy instance.

      -

      30.4 Further details on the Python class interface

      +

      31.4 Further details on the Python class interface

      @@ -2232,7 +2232,7 @@ of low-level details were omitted. This section provides a brief overview of how the proxy classes work.

      -

      30.4.1 Proxy classes

      +

      31.4.1 Proxy classes

      @@ -2321,7 +2321,7 @@ you can attach new Python methods to the class and you can even inherit from it by Python built-in types until Python 2.2).

      -

      30.4.2 Memory management

      +

      31.4.2 Memory management

      @@ -2513,7 +2513,7 @@ It is also possible to deal with situations like this using typemaps--an advanced topic discussed later.

      -

      30.4.3 Python 2.2 and classic classes

      +

      31.4.3 Python 2.2 and classic classes

      @@ -2550,7 +2550,7 @@ class itself. In Python-2.1 and earlier, they have to be accessed as a global function or through an instance (see the earlier section).

      -

      30.5 Cross language polymorphism

      +

      31.5 Cross language polymorphism

      @@ -2584,7 +2584,7 @@ proxy classes, director classes, and C wrapper functions takes care of all the cross-language method routing transparently.

      -

      30.5.1 Enabling directors

      +

      31.5.1 Enabling directors

      @@ -2677,7 +2677,7 @@ class MyFoo(mymodule.Foo): -

      30.5.2 Director classes

      +

      31.5.2 Director classes

      @@ -2759,7 +2759,7 @@ so there is no need for the extra overhead involved with routing the calls through Python.

      -

      30.5.3 Ownership and object destruction

      +

      31.5.3 Ownership and object destruction

      @@ -2826,7 +2826,7 @@ deleting all the Foo pointers it contains at some point. Note that no hard references to the Foo objects remain in Python.

      -

      30.5.4 Exception unrolling

      +

      31.5.4 Exception unrolling

      @@ -2885,7 +2885,7 @@ Swig::DirectorMethodException is thrown, Python will register the exception as soon as the C wrapper function returns.

      -

      30.5.5 Overhead and code bloat

      +

      31.5.5 Overhead and code bloat

      @@ -2919,7 +2919,7 @@ directive) for only those methods that are likely to be extended in Python.

      -

      30.5.6 Typemaps

      +

      31.5.6 Typemaps

      @@ -2933,7 +2933,7 @@ need to be supported.

      -

      30.5.7 Miscellaneous

      +

      31.5.7 Miscellaneous

      @@ -2980,7 +2980,7 @@ methods that return const references.

      -

      30.6 Common customization features

      +

      31.6 Common customization features

      @@ -2993,7 +2993,7 @@ This section describes some common SWIG features that are used to improve your the interface to an extension module.

      -

      30.6.1 C/C++ helper functions

      +

      31.6.1 C/C++ helper functions

      @@ -3074,7 +3074,7 @@ hard to implement. It is possible to clean this up using Python code, typemaps, customization features as covered in later sections.

      -

      30.6.2 Adding additional Python code

      +

      31.6.2 Adding additional Python code

      @@ -3223,7 +3223,7 @@ public: -

      30.6.3 Class extension with %extend

      +

      31.6.3 Class extension with %extend

      @@ -3312,7 +3312,7 @@ Vector(12,14,16) in any way---the extensions only show up in the Python interface.

      -

      30.6.4 Exception handling with %exception

      +

      31.6.4 Exception handling with %exception

      @@ -3438,7 +3438,7 @@ The language-independent exception.i library file can also be used to raise exceptions. See the SWIG Library chapter.

      -

      30.7 Tips and techniques

      +

      31.7 Tips and techniques

      @@ -3448,7 +3448,7 @@ strings, binary data, and arrays. This chapter discusses the common techniques solving these problems.

      -

      30.7.1 Input and output parameters

      +

      31.7.1 Input and output parameters

      @@ -3661,7 +3661,7 @@ void foo(Bar *OUTPUT); may not have the intended effect since typemaps.i does not define an OUTPUT rule for Bar.

      -

      30.7.2 Simple pointers

      +

      31.7.2 Simple pointers

      @@ -3730,7 +3730,7 @@ If you replace %pointer_functions() by %pointer_class(type,name)SWIG Library chapter for further details.

      -

      30.7.3 Unbounded C Arrays

      +

      31.7.3 Unbounded C Arrays

      @@ -3792,7 +3792,7 @@ well suited for applications in which you need to create buffers, package binary data, etc.

      -

      30.7.4 String handling

      +

      31.7.4 String handling

      @@ -3861,16 +3861,16 @@ If you need to return binary data, you might use the also be used to extra binary data from arbitrary pointers.

      -

      30.7.5 Arrays

      +

      31.7.5 Arrays

      -

      30.7.6 String arrays

      +

      31.7.6 String arrays

      -

      30.7.7 STL wrappers

      +

      31.7.7 STL wrappers

      -

      30.8 Typemaps

      +

      31.8 Typemaps

      @@ -3887,7 +3887,7 @@ Typemaps are only used if you want to change some aspect of the primitive C-Python interface or if you want to elevate your guru status.

      -

      30.8.1 What is a typemap?

      +

      31.8.1 What is a typemap?

      @@ -4003,7 +4003,7 @@ parameter is omitted): -

      30.8.2 Python typemaps

      +

      31.8.2 Python typemaps

      @@ -4044,7 +4044,7 @@ a look at the SWIG library version 1.3.20 or so.

      -

      30.8.3 Typemap variables

      +

      31.8.3 Typemap variables

      @@ -4115,7 +4115,7 @@ properly assigned. The Python name of the wrapper function being created. -

      30.8.4 Useful Python Functions

      +

      31.8.4 Useful Python Functions

      @@ -4243,7 +4243,7 @@ write me -

      30.9 Typemap Examples

      +

      31.9 Typemap Examples

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

      -

      30.9.1 Converting Python list to a char **

      +

      31.9.1 Converting Python list to a char **

      @@ -4332,7 +4332,7 @@ memory allocation is used to allocate memory for the array, the the C function.

      -

      30.9.2 Expanding a Python object into multiple arguments

      +

      31.9.2 Expanding a Python object into multiple arguments

      @@ -4411,7 +4411,7 @@ to supply the argument count. This is automatically set by the typemap code. F -

      30.9.3 Using typemaps to return arguments

      +

      31.9.3 Using typemaps to return arguments

      @@ -4500,7 +4500,7 @@ function can now be used as follows: >>> -

      30.9.4 Mapping Python tuples into small arrays

      +

      31.9.4 Mapping Python tuples into small arrays

      @@ -4549,7 +4549,7 @@ array, such an approach would not be recommended for huge arrays, but for small structures, this approach works fine.

      -

      30.9.5 Mapping sequences to C arrays

      +

      31.9.5 Mapping sequences to C arrays

      @@ -4638,7 +4638,7 @@ static int convert_darray(PyObject *input, double *ptr, int size) { -

      30.9.6 Pointer handling

      +

      31.9.6 Pointer handling

      @@ -4735,7 +4735,7 @@ class object (if applicable). -

      30.10 Docstring Features

      +

      31.10 Docstring Features

      @@ -4763,7 +4763,7 @@ of your users much simpler.

      -

      30.10.1 Module docstring

      +

      31.10.1 Module docstring

      @@ -4797,7 +4797,7 @@ layout of controls on a panel, etc. to be loaded from an XML file." -

      30.10.2 %feature("autodoc")

      +

      31.10.2 %feature("autodoc")

      @@ -4824,7 +4824,7 @@ names, default values if any, and return type if any. There are also three options for autodoc controlled by the value given to the feature, described below. -

      30.10.2.1 %feature("autodoc", "0")

      +

      31.10.2.1 %feature("autodoc", "0")

      @@ -4853,7 +4853,7 @@ def function_name(*args, **kwargs): -

      30.10.2.2 %feature("autodoc", "1")

      +

      31.10.2.2 %feature("autodoc", "1")

      @@ -4878,7 +4878,7 @@ def function_name(*args, **kwargs): -

      30.10.2.3 %feature("autodoc", "docstring")

      +

      31.10.2.3 %feature("autodoc", "docstring")

      @@ -4897,7 +4897,7 @@ void GetPosition(int* OUTPUT, int* OUTPUT); -

      30.10.3 %feature("docstring")

      +

      31.10.3 %feature("docstring")

      @@ -4929,7 +4929,7 @@ with more than one line. -

      30.11 Python Packages

      +

      31.11 Python Packages

      @@ -4956,7 +4956,7 @@ and also in base class declarations, etc. if the package name is different than its own.

      -

      30.12 Python 3 Support

      +

      31.12 Python 3 Support

      @@ -4983,7 +4983,7 @@ The following are Python 3.0 new features that are currently supported by SWIG.

      -

      30.12.1 Function annotation

      +

      31.12.1 Function annotation

      @@ -5015,7 +5015,7 @@ all overloaded functions share the same function in SWIG generated proxy class. For detailed usage of function annotation, see PEP 3107.

      -

      30.12.2 Buffer interface

      +

      31.12.2 Buffer interface

      @@ -5167,7 +5167,7 @@ modify the buffer. -

      30.12.3 Abstract base classes

      +

      31.12.3 Abstract base classes

      diff --git a/Doc/Manual/R.html b/Doc/Manual/R.html index 3b37d53a0..0ed43fc52 100644 --- a/Doc/Manual/R.html +++ b/Doc/Manual/R.html @@ -6,7 +6,7 @@ -

      33 SWIG and R

      +

      34 SWIG and R

        @@ -33,7 +33,7 @@ compile and run an R interface to QuantLib running on Mandriva Linux with gcc. The R bindings also work on Microsoft Windows using Visual C++.

        -

        33.1 Bugs

        +

        34.1 Bugs

        @@ -45,7 +45,7 @@ Currently the following features are not implemented or broken:

      • C Array wrappings
      -

      33.2 Using R and SWIG

      +

      34.2 Using R and SWIG

      @@ -99,7 +99,7 @@ Without it, inheritance of wrapped objects may fail. These two files can be loaded in any order

      -

      33.3 Precompiling large R files

      +

      34.3 Precompiling large R files

      In cases where the R file is large, one make save a lot of loading @@ -117,7 +117,7 @@ will save a large amount of loading time. -

      33.4 General policy

      +

      34.4 General policy

      @@ -126,7 +126,7 @@ wrapping over the underlying functions and rely on the R type system to provide R syntax.

      -

      33.5 Language conventions

      +

      34.5 Language conventions

      @@ -135,7 +135,7 @@ and [ are overloaded to allow for R syntax (one based indices and slices)

      -

      33.6 C++ classes

      +

      34.6 C++ classes

      @@ -147,7 +147,7 @@ keep track of the pointer object which removes the necessity for a lot of the proxy class baggage you see in other languages.

      -

      33.7 Enumerations

      +

      34.7 Enumerations

      diff --git a/Doc/Manual/Ruby.html b/Doc/Manual/Ruby.html index 9cd83d494..7360f732d 100644 --- a/Doc/Manual/Ruby.html +++ b/Doc/Manual/Ruby.html @@ -26,7 +26,7 @@ -

      31 SWIG and Ruby

      +

      32 SWIG and Ruby

        @@ -167,7 +167,7 @@ -

        31.1 Preliminaries

        +

        32.1 Preliminaries

        SWIG 1.3 is known to work with Ruby versions 1.6 and later. @@ -190,7 +190,7 @@ of Ruby.

        -

        31.1.1 Running SWIG

        +

        32.1.1 Running SWIG

        To build a Ruby module, run SWIG using the -ruby @@ -244,7 +244,7 @@ to compile this file and link it with the rest of your program.

        -

        31.1.2 Getting the right header files

        +

        32.1.2 Getting the right header files

        In order to compile the wrapper code, the compiler needs the ruby.h @@ -288,7 +288,7 @@ installed, you can run Ruby to find out. For example:

        -

        31.1.3 Compiling a dynamic module

        +

        32.1.3 Compiling a dynamic module

        Ruby extension modules are typically compiled into shared @@ -443,7 +443,7 @@ manual pages for your compiler and linker to determine the correct set of options. You might also check the SWIG Wiki for additional information.

        -

        31.1.4 Using your module

        +

        32.1.4 Using your module

        Ruby module names must be capitalized, @@ -498,7 +498,7 @@ begins with:

        -

        31.1.5 Static linking

        +

        32.1.5 Static linking

        An alternative approach to dynamic linking is to rebuild the @@ -519,7 +519,7 @@ finally rebuilding Ruby.

        -

        31.1.6 Compilation of C++ extensions

        +

        32.1.6 Compilation of C++ extensions

        On most machines, C++ extension modules should be linked @@ -571,7 +571,7 @@ extension, e.g.

        -

        31.2 Building Ruby Extensions under Windows 95/NT

        +

        32.2 Building Ruby Extensions under Windows 95/NT

        Building a SWIG extension to Ruby under Windows 95/NT is @@ -610,7 +610,7 @@ files.

        -

        31.2.1 Running SWIG from Developer Studio

        +

        32.2.1 Running SWIG from Developer Studio

        If you are developing your application within Microsoft @@ -752,7 +752,7 @@ directory, then run the Ruby script from the DOS/Command prompt:

        -

        31.3 The Ruby-to-C/C++ Mapping

        +

        32.3 The Ruby-to-C/C++ Mapping

        This section describes the basics of how SWIG maps C or C++ @@ -762,7 +762,7 @@ declarations in your SWIG interface files to Ruby constructs.

        -

        31.3.1 Modules

        +

        32.3.1 Modules

        The SWIG %module directive specifies @@ -931,7 +931,7 @@ Ruby's built-in names.

        -

        31.3.2 Functions

        +

        32.3.2 Functions

        Global functions are wrapped as Ruby module methods. For @@ -994,7 +994,7 @@ module that can be used like so:

        -

        31.3.3 Variable Linking

        +

        32.3.3 Variable Linking

        C/C++ global variables are wrapped as a pair of singleton @@ -1094,7 +1094,7 @@ effect until it is explicitly disabled using %mutable. -

        31.3.4 Constants

        +

        32.3.4 Constants

        C/C++ constants are wrapped as module constants initialized @@ -1138,7 +1138,7 @@ constant values, e.g.

        -

        31.3.5 Pointers

        +

        32.3.5 Pointers

        "Opaque" pointers to arbitrary C/C++ types (i.e. types that @@ -1190,7 +1190,7 @@ the Ruby nil object.

        -

        31.3.6 Structures

        +

        32.3.6 Structures

        C/C++ structs are wrapped as Ruby classes, with accessor @@ -1365,7 +1365,7 @@ pointers. For example,

        -

        31.3.7 C++ classes

        +

        32.3.7 C++ classes

        Like structs, C++ classes are wrapped by creating a new Ruby @@ -1451,7 +1451,7 @@ class. -

        31.3.8 C++ Inheritance

        +

        32.3.8 C++ Inheritance

        The SWIG type-checker is fully aware of C++ inheritance. @@ -1682,7 +1682,7 @@ Typing").

        -

        31.3.9 C++ Overloaded Functions

        +

        32.3.9 C++ Overloaded Functions

        C++ overloaded functions, methods, and constructors are @@ -1878,7 +1878,7 @@ and C++" chapter for more information about overloading.

        -

        31.3.10 C++ Operators

        +

        32.3.10 C++ Operators

        For the most part, overloaded operators are handled @@ -1959,7 +1959,7 @@ on operator overloading.

        -

        31.3.11 C++ namespaces

        +

        32.3.11 C++ namespaces

        SWIG is aware of C++ namespaces, but namespace names do not @@ -2035,7 +2035,7 @@ identical symbol names, well, then you get what you deserve.

        -

        31.3.12 C++ templates

        +

        32.3.12 C++ templates

        C++ templates don't present a huge problem for SWIG. However, @@ -2079,7 +2079,7 @@ directive. For example:

        -

        31.3.13 C++ Standard Template Library (STL)

        +

        32.3.13 C++ Standard Template Library (STL)

        On a related note, the standard SWIG library contains a @@ -2332,7 +2332,7 @@ chapter.

        -

        31.3.14 C++ STL Functors

        +

        32.3.14 C++ STL Functors

        Some containers in the STL allow you to modify their default @@ -2532,7 +2532,7 @@ b
        -

        31.3.15 C++ STL Iterators

        +

        32.3.15 C++ STL Iterators

        The STL is well known for the use of iterators.  There @@ -2743,7 +2743,7 @@ i
        -

        31.3.16 C++ Smart Pointers

        +

        32.3.16 C++ Smart Pointers

        In certain C++ programs, it is common to use classes that @@ -2868,7 +2868,7 @@ method. For example:

        -

        31.3.17 Cross-Language Polymorphism

        +

        32.3.17 Cross-Language Polymorphism

        SWIG's Ruby module supports cross-language polymorphism @@ -2881,7 +2881,7 @@ using this feature with Ruby.

        -

        31.3.17.1 Exception Unrolling

        +

        32.3.17.1 Exception Unrolling

        Whenever a C++ director class routes one of its virtual @@ -2919,7 +2919,7 @@ caught here and a C++ exception is raised in its place.

        -

        31.4 Naming

        +

        32.4 Naming

        Ruby has several common naming conventions. Constants are @@ -3015,7 +3015,7 @@ planned to become the default option in future releases.

        -

        31.4.1 Defining Aliases

        +

        32.4.1 Defining Aliases

        It's a fairly common practice in the Ruby built-ins and @@ -3107,7 +3107,7 @@ Features") for more details).

        -

        31.4.2 Predicate Methods

        +

        32.4.2 Predicate Methods

        Ruby methods that return a boolean value and end in a @@ -3196,7 +3196,7 @@ Features") for more details).

        -

        31.4.3 Bang Methods

        +

        32.4.3 Bang Methods

        Ruby methods that modify an object in-place and end in an @@ -3260,7 +3260,7 @@ Features") for more details).

        -

        31.4.4 Getters and Setters

        +

        32.4.4 Getters and Setters

        Often times a C++ library will expose properties through @@ -3330,7 +3330,7 @@ methods to be exposed in Ruby as value and value=. -

        31.5 Input and output parameters

        +

        32.5 Input and output parameters

        A common problem in some C programs is handling parameters @@ -3581,10 +3581,10 @@ of %apply

        -

        31.6 Exception handling

        +

        32.6 Exception handling

        -

        31.6.1 Using the %exception directive

        +

        32.6.1 Using the %exception directive

        The SWIG %exception directive can be @@ -3679,7 +3679,7 @@ Features for more examples.

        -

        31.6.2 Handling Ruby Blocks

        +

        32.6.2 Handling Ruby Blocks

        One of the highlights of Ruby and most of its standard library @@ -3860,7 +3860,7 @@ RUBY_YIELD_SELF );

        For more information on typemaps, see Typemaps.

        -

        31.6.3 Raising exceptions

        +

        32.6.3 Raising exceptions

        There are three ways to raise exceptions from C++ code to @@ -4621,7 +4621,7 @@ the built-in Ruby exception types.

        -

        31.6.4 Exception classes

        +

        32.6.4 Exception classes

        Starting with SWIG 1.3.28, the Ruby module supports the %exceptionclass @@ -4679,7 +4679,7 @@ providing for a more natural integration between C++ code and Ruby code.

        -

        31.7 Typemaps

        +

        32.7 Typemaps

        This section describes how you can modify SWIG's default @@ -4702,7 +4702,7 @@ of the primitive C-Ruby interface.

        -

        31.7.1 What is a typemap?

        +

        32.7.1 What is a typemap?

        A typemap is nothing more than a code generation rule that is @@ -4964,7 +4964,7 @@ to be used as follows (notice how the length parameter is omitted):

        -

        31.7.2 Typemap scope

        +

        32.7.2 Typemap scope

        Once defined, a typemap remains in effect for all of the @@ -5012,7 +5012,7 @@ where the class itself is defined. For example:

        -

        31.7.3 Copying a typemap

        +

        32.7.3 Copying a typemap

        A typemap is copied by using assignment. For example:

        @@ -5114,7 +5114,7 @@ rules as for -

        31.7.4 Deleting a typemap

        +

        32.7.4 Deleting a typemap

        A typemap can be deleted by simply defining no code. For @@ -5166,7 +5166,7 @@ typemaps immediately after the clear operation.

        -

        31.7.5 Placement of typemaps

        +

        32.7.5 Placement of typemaps

        Typemap declarations can be declared in the global scope, @@ -5250,7 +5250,7 @@ string -

        31.7.6 Ruby typemaps

        +

        32.7.6 Ruby typemaps

        The following list details all of the typemap methods that @@ -5260,7 +5260,7 @@ can be used by the Ruby module:

        -

        31.7.6.1  "in" typemap

        +

        32.7.6.1  "in" typemap

        Converts Ruby objects to input @@ -5503,7 +5503,7 @@ arguments to be specified. For example:

        -

        31.7.6.2 "typecheck" typemap

        +

        32.7.6.2 "typecheck" typemap

        The "typecheck" typemap is used to support overloaded @@ -5544,7 +5544,7 @@ on "Typemaps and Overloading."

        -

        31.7.6.3  "out" typemap

        +

        32.7.6.3  "out" typemap

        Converts return value of a C function @@ -5776,7 +5776,7 @@ version of the C datatype matched by the typemap. -

        31.7.6.4 "arginit" typemap

        +

        32.7.6.4 "arginit" typemap

        The "arginit" typemap is used to set the initial value of a @@ -5801,7 +5801,7 @@ applications. For example:

        -

        31.7.6.5 "default" typemap

        +

        32.7.6.5 "default" typemap

        The "default" typemap is used to turn an argument into a @@ -5843,7 +5843,7 @@ default argument wrapping.

        -

        31.7.6.6 "check" typemap

        +

        32.7.6.6 "check" typemap

        The "check" typemap is used to supply value checking code @@ -5867,7 +5867,7 @@ arguments have been converted. For example:

        -

        31.7.6.7 "argout" typemap

        +

        32.7.6.7 "argout" typemap

        The "argout" typemap is used to return values from arguments. @@ -6025,7 +6025,7 @@ some function like SWIG_Ruby_AppendOutput.

        -

        31.7.6.8 "freearg" typemap

        +

        32.7.6.8 "freearg" typemap

        The "freearg" typemap is used to cleanup argument data. It is @@ -6061,7 +6061,7 @@ abort prematurely.

        -

        31.7.6.9 "newfree" typemap

        +

        32.7.6.9 "newfree" typemap

        The "newfree" typemap is used in conjunction with the %newobject @@ -6092,7 +6092,7 @@ ownership and %newobject for further details.

        -

        31.7.6.10 "memberin" typemap

        +

        32.7.6.10 "memberin" typemap

        The "memberin" typemap is used to copy data from an @@ -6125,7 +6125,7 @@ other objects.

        -

        31.7.6.11 "varin" typemap

        +

        32.7.6.11 "varin" typemap

        The "varin" typemap is used to convert objects in the target @@ -6136,7 +6136,7 @@ This is implementation specific.

        -

        31.7.6.12 "varout" typemap

        +

        32.7.6.12 "varout" typemap

        The "varout" typemap is used to convert a C/C++ object to an @@ -6147,7 +6147,7 @@ This is implementation specific.

        -

        31.7.6.13 "throws" typemap

        +

        32.7.6.13 "throws" typemap

        The "throws" typemap is only used when SWIG parses a C++ @@ -6206,7 +6206,7 @@ handling with %exception section.

        -

        31.7.6.14 directorin typemap

        +

        32.7.6.14 directorin typemap

        Converts C++ objects in director @@ -6460,7 +6460,7 @@ referring to the class itself. -

        31.7.6.15 directorout typemap

        +

        32.7.6.15 directorout typemap

        Converts Ruby objects in director @@ -6720,7 +6720,7 @@ exception.
        -

        31.7.6.16 directorargout typemap

        +

        32.7.6.16 directorargout typemap

        Output argument processing in director @@ -6960,7 +6960,7 @@ referring to the instance of the class itself -

        31.7.6.17 ret typemap

        +

        32.7.6.17 ret typemap

        Cleanup of function return values @@ -6970,7 +6970,7 @@ referring to the instance of the class itself -

        31.7.6.18 globalin typemap

        +

        32.7.6.18 globalin typemap

        Setting of C global variables @@ -6980,7 +6980,7 @@ referring to the instance of the class itself -

        31.7.7 Typemap variables

        +

        32.7.7 Typemap variables

        @@ -7090,7 +7090,7 @@ being created.

      -

      31.7.8 Useful Functions

      +

      32.7.8 Useful Functions

      When you write a typemap, you usually have to work directly @@ -7114,7 +7114,7 @@ across multiple languages.

      -

      31.7.8.1 C Datatypes to Ruby Objects

      +

      32.7.8.1 C Datatypes to Ruby Objects

      @@ -7170,7 +7170,7 @@ SWIG_From_float(float) -

      31.7.8.2 Ruby Objects to C Datatypes

      +

      32.7.8.2 Ruby Objects to C Datatypes

      Here, while the Ruby versions return the value directly, the SWIG @@ -7259,7 +7259,7 @@ Ruby_Format_TypeError( "$1_name", "$1_type","$symname", $argnum, $input -

      31.7.8.3 Macros for VALUE

      +

      32.7.8.3 Macros for VALUE

      RSTRING_LEN(str)

      @@ -7322,7 +7322,7 @@ Ruby_Format_TypeError( "$1_name", "$1_type","$symname", $argnum, $input -

      31.7.8.4 Exceptions

      +

      32.7.8.4 Exceptions

      void rb_raise(VALUE exception, const char *fmt, @@ -7489,7 +7489,7 @@ arguments are interpreted as with printf().

      -

      31.7.8.5 Iterators

      +

      32.7.8.5 Iterators

      void rb_iter_break()

      @@ -7591,7 +7591,7 @@ VALUE), VALUE value)

      -

      31.7.9 Typemap Examples

      +

      32.7.9 Typemap Examples

      This section includes a few examples of typemaps. For more @@ -7602,7 +7602,7 @@ directory.

      -

      31.7.10 Converting a Ruby array to a char **

      +

      32.7.10 Converting a Ruby array to a char **

      A common problem in many C programs is the processing of @@ -7657,7 +7657,7 @@ after the execution of the C function.

      -

      31.7.11 Collecting arguments in a hash

      +

      32.7.11 Collecting arguments in a hash

      Ruby's solution to the "keyword arguments" capability of some @@ -7936,7 +7936,7 @@ directory of the SWIG distribution.

      -

      31.7.12 Pointer handling

      +

      32.7.12 Pointer handling

      Occasionally, it might be necessary to convert pointer values @@ -8035,7 +8035,7 @@ For example:

      -

      31.7.12.1 Ruby Datatype Wrapping

      +

      32.7.12.1 Ruby Datatype Wrapping

      VALUE Data_Wrap_Struct(VALUE class, void @@ -8086,7 +8086,7 @@ and assigns that pointer to ptr.

      -

      31.7.13 Example: STL Vector to Ruby Array

      +

      32.7.13 Example: STL Vector to Ruby Array

      Another use for macros and type maps is to create a Ruby array @@ -8195,7 +8195,7 @@ the C++ Standard Template Library.
      -

      31.8 Docstring Features

      +

      32.8 Docstring Features

      @@ -8256,7 +8256,7 @@ generate ri documentation from a c wrap file, you could do:

      -

      31.8.1 Module docstring

      +

      32.8.1 Module docstring

      @@ -8307,7 +8307,7 @@ macro. For example: -

      31.8.2 %feature("autodoc")

      +

      32.8.2 %feature("autodoc")

      Since SWIG does know everything about the function it wraps, @@ -8336,7 +8336,7 @@ feature, described below. -

      31.8.2.1 %feature("autodoc", "0")

      +

      32.8.2.1 %feature("autodoc", "0")

      @@ -8384,7 +8384,7 @@ Then Ruby code like this will be generated: -

      31.8.2.2 %feature("autodoc", "1")

      +

      32.8.2.2 %feature("autodoc", "1")

      @@ -8416,7 +8416,7 @@ this: -

      31.8.2.3 %feature("autodoc", "2")

      +

      32.8.2.3 %feature("autodoc", "2")

      @@ -8432,7 +8432,7 @@ this: -

      31.8.2.4 %feature("autodoc", "3")

      +

      32.8.2.4 %feature("autodoc", "3")

      @@ -8460,7 +8460,7 @@ this: -

      31.8.2.5 %feature("autodoc", "docstring")

      +

      32.8.2.5 %feature("autodoc", "docstring")

      @@ -8488,7 +8488,7 @@ generated string. For example: -

      31.8.3 %feature("docstring")

      +

      32.8.3 %feature("docstring")

      @@ -8503,10 +8503,10 @@ docstring and they are output together.

      -

      31.9 Advanced Topics

      +

      32.9 Advanced Topics

      -

      31.9.1 Operator overloading

      +

      32.9.1 Operator overloading

      SWIG allows operator overloading with, by using the %extend @@ -9523,7 +9523,7 @@ parses the expression a != b as !(a == b). -

      31.9.2 Creating Multi-Module Packages

      +

      32.9.2 Creating Multi-Module Packages

      The chapter on Working @@ -9704,7 +9704,7 @@ initialized:

      -

      31.9.3 Specifying Mixin Modules

      +

      32.9.3 Specifying Mixin Modules

      The Ruby language doesn't support multiple inheritance, but @@ -9802,7 +9802,7 @@ Features") for more details).

      -

      31.10 Memory Management

      +

      32.10 Memory Management

      One of the most common issues in generating SWIG bindings for @@ -9849,7 +9849,7 @@ understanding of how the underlying library manages memory.

      -

      31.10.1 Mark and Sweep Garbage Collector

      +

      32.10.1 Mark and Sweep Garbage Collector

      Ruby uses a mark and sweep garbage collector. When the garbage @@ -9897,7 +9897,7 @@ this memory.

      -

      31.10.2 Object Ownership

      +

      32.10.2 Object Ownership

      As described above, memory management depends on clearly @@ -10124,7 +10124,7 @@ classes is:

      -

      31.10.3 Object Tracking

      +

      32.10.3 Object Tracking

      The remaining parts of this section will use the class library @@ -10338,7 +10338,7 @@ methods.

      -

      31.10.4 Mark Functions

      +

      32.10.4 Mark Functions

      With a bit more testing, we see that our class library still @@ -10456,7 +10456,7 @@ test suite.

      -

      31.10.5 Free Functions

      +

      32.10.5 Free Functions

      By default, SWIG creates a "free" function that is called when @@ -10611,7 +10611,7 @@ been freed, and thus raises a runtime exception.

      -

      31.10.6 Embedded Ruby and the C++ Stack

      +

      32.10.6 Embedded Ruby and the C++ Stack

      As has been said, the Ruby GC runs and marks objects before diff --git a/Doc/Manual/Sections.html b/Doc/Manual/Sections.html index 5406f44ea..9f2c94e0b 100644 --- a/Doc/Manual/Sections.html +++ b/Doc/Manual/Sections.html @@ -35,6 +35,7 @@ to help!).

    • Variable length arguments
    • Warning messages
    • Working with Modules
    • +
    • Using SWIG with ccache
    • Language Module Documentation

      diff --git a/Doc/Manual/Tcl.html b/Doc/Manual/Tcl.html index e837a5b17..b36395cab 100644 --- a/Doc/Manual/Tcl.html +++ b/Doc/Manual/Tcl.html @@ -6,7 +6,7 @@ -

      32 SWIG and Tcl

      +

      33 SWIG and Tcl

        @@ -82,7 +82,7 @@ Tcl 8.0 or a later release. Earlier releases of SWIG supported Tcl 7.x, but this is no longer supported.

        -

        32.1 Preliminaries

        +

        33.1 Preliminaries

        @@ -108,7 +108,7 @@ build a Tcl extension module. To finish building the module, you need to compile this file and link it with the rest of your program.

        -

        32.1.1 Getting the right header files

        +

        33.1.1 Getting the right header files

        @@ -126,7 +126,7 @@ this is the case, you should probably make a symbolic link so that tcl.h -

        32.1.2 Compiling a dynamic module

        +

        33.1.2 Compiling a dynamic module

        @@ -161,7 +161,7 @@ The name of the module is specified using the %module directive or the -module command line option.

        -

        32.1.3 Static linking

        +

        33.1.3 Static linking

        @@ -227,7 +227,7 @@ minimal in most situations (and quite frankly not worth the extra hassle in the opinion of this author).

        -

        32.1.4 Using your module

        +

        33.1.4 Using your module

        @@ -355,7 +355,7 @@ to the default system configuration (this requires root access and you will need the man pages).

        -

        32.1.5 Compilation of C++ extensions

        +

        33.1.5 Compilation of C++ extensions

        @@ -438,7 +438,7 @@ erratic program behavior. If working with lots of software components, you might want to investigate using a more formal standard such as COM.

        -

        32.1.6 Compiling for 64-bit platforms

        +

        33.1.6 Compiling for 64-bit platforms

        @@ -465,7 +465,7 @@ also introduce problems on platforms that support more than one linking standard (e.g., -o32 and -n32 on Irix).

        -

        32.1.7 Setting a package prefix

        +

        33.1.7 Setting a package prefix

        @@ -484,7 +484,7 @@ option will append the prefix to the name when creating a command and call it "Foo_bar".

        -

        32.1.8 Using namespaces

        +

        33.1.8 Using namespaces

        @@ -506,7 +506,7 @@ When the -namespace option is used, objects in the module are always accessed with the namespace name such as Foo::bar.

        -

        32.2 Building Tcl/Tk Extensions under Windows 95/NT

        +

        33.2 Building Tcl/Tk Extensions under Windows 95/NT

        @@ -517,7 +517,7 @@ covers the process of using SWIG with Microsoft Visual C++. although the procedure may be similar with other compilers.

        -

        32.2.1 Running SWIG from Developer Studio

        +

        33.2.1 Running SWIG from Developer Studio

        @@ -575,7 +575,7 @@ MSDOS > tclsh80 %

      -

      32.2.2 Using NMAKE

      +

      33.2.2 Using NMAKE

      @@ -638,7 +638,7 @@ to get you started. With a little practice, you'll be making lots of Tcl extensions.

      -

      32.3 A tour of basic C/C++ wrapping

      +

      33.3 A tour of basic C/C++ wrapping

      @@ -649,7 +649,7 @@ classes. This section briefly covers the essential aspects of this wrapping.

      -

      32.3.1 Modules

      +

      33.3.1 Modules

      @@ -683,7 +683,7 @@ To fix this, supply an extra argument to load like this: -

      32.3.2 Functions

      +

      33.3.2 Functions

      @@ -708,7 +708,7 @@ like you think it does: % -

      32.3.3 Global variables

      +

      33.3.3 Global variables

      @@ -788,7 +788,7 @@ extern char *path; // Read-only (due to %immutable) -

      32.3.4 Constants and enums

      +

      33.3.4 Constants and enums

      @@ -872,7 +872,7 @@ When an identifier name is given, it is used to perform an implicit hash-table l conversion. This allows the global statement to be omitted.

      -

      32.3.5 Pointers

      +

      33.3.5 Pointers

      @@ -968,7 +968,7 @@ C-style cast may return a bogus result whereas as the C++-style cast will return None if the conversion can't be performed.

      -

      32.3.6 Structures

      +

      33.3.6 Structures

      @@ -1250,7 +1250,7 @@ Note: Tcl only destroys the underlying object if it has ownership. See the memory management section that appears shortly.

      -

      32.3.7 C++ classes

      +

      33.3.7 C++ classes

      @@ -1317,7 +1317,7 @@ In Tcl, the static member is accessed as follows: -

      32.3.8 C++ inheritance

      +

      33.3.8 C++ inheritance

      @@ -1366,7 +1366,7 @@ For instance: It is safe to use multiple inheritance with SWIG.

      -

      32.3.9 Pointers, references, values, and arrays

      +

      33.3.9 Pointers, references, values, and arrays

      @@ -1420,7 +1420,7 @@ to hold the result and a pointer is returned (Tcl will release this memory when the return value is garbage collected).

      -

      32.3.10 C++ overloaded functions

      +

      33.3.10 C++ overloaded functions

      @@ -1543,7 +1543,7 @@ first declaration takes precedence. Please refer to the "SWIG and C++" chapter for more information about overloading.

      -

      32.3.11 C++ operators

      +

      33.3.11 C++ operators

      @@ -1645,7 +1645,7 @@ There are ways to make this operator appear as part of the class using the % Keep reading.

      -

      32.3.12 C++ namespaces

      +

      33.3.12 C++ namespaces

      @@ -1709,7 +1709,7 @@ utilizes thousands of small deeply nested namespaces each with identical symbol names, well, then you get what you deserve.

      -

      32.3.13 C++ templates

      +

      33.3.13 C++ templates

      @@ -1761,7 +1761,7 @@ More details can be found in the SWIG and C++ -

      32.3.14 C++ Smart Pointers

      +

      33.3.14 C++ Smart Pointers

      @@ -1845,7 +1845,7 @@ simply use the __deref__() method. For example: -

      32.4 Further details on the Tcl class interface

      +

      33.4 Further details on the Tcl class interface

      @@ -1858,7 +1858,7 @@ of low-level details were omitted. This section provides a brief overview of how the proxy classes work.

      -

      32.4.1 Proxy classes

      +

      33.4.1 Proxy classes

      @@ -1923,7 +1923,7 @@ function. This allows objects to be encapsulated objects that look a lot like as shown in the last section.

      -

      32.4.2 Memory management

      +

      33.4.2 Memory management

      @@ -2111,7 +2111,7 @@ typemaps--an advanced topic discussed later.

      -

      32.5 Input and output parameters

      +

      33.5 Input and output parameters

      @@ -2299,7 +2299,7 @@ set c [lindex $dim 1] -

      32.6 Exception handling

      +

      33.6 Exception handling

      @@ -2433,7 +2433,7 @@ Since SWIG's exception handling is user-definable, you are not limited to C++ ex See the chapter on "Customization Features" for more examples.

      -

      32.7 Typemaps

      +

      33.7 Typemaps

      @@ -2450,7 +2450,7 @@ Typemaps are only used if you want to change some aspect of the primitive C-Tcl interface.

      -

      32.7.1 What is a typemap?

      +

      33.7.1 What is a typemap?

      @@ -2567,7 +2567,7 @@ parameter is omitted): -

      32.7.2 Tcl typemaps

      +

      33.7.2 Tcl typemaps

      @@ -2705,7 +2705,7 @@ Initialize an argument to a value before any conversions occur. Examples of these methods will appear shortly.

      -

      32.7.3 Typemap variables

      +

      33.7.3 Typemap variables

      @@ -2776,7 +2776,7 @@ properly assigned. The Tcl name of the wrapper function being created. -

      32.7.4 Converting a Tcl list to a char **

      +

      33.7.4 Converting a Tcl list to a char **

      @@ -2838,7 +2838,7 @@ argv[2] = Larry 3 -

      32.7.5 Returning values in arguments

      +

      33.7.5 Returning values in arguments

      @@ -2880,7 +2880,7 @@ result, a Tcl function using these typemaps will work like this : % -

      32.7.6 Useful functions

      +

      33.7.6 Useful functions

      @@ -2957,7 +2957,7 @@ int Tcl_IsShared(Tcl_Obj *obj); -

      32.7.7 Standard typemaps

      +

      33.7.7 Standard typemaps

      @@ -3041,7 +3041,7 @@ work) -

      32.7.8 Pointer handling

      +

      33.7.8 Pointer handling

      @@ -3117,7 +3117,7 @@ For example: -

      32.8 Turning a SWIG module into a Tcl Package.

      +

      33.8 Turning a SWIG module into a Tcl Package.

      @@ -3189,7 +3189,7 @@ As a final note, most SWIG examples do not yet use the to use the load command instead.

      -

      32.9 Building new kinds of Tcl interfaces (in Tcl)

      +

      33.9 Building new kinds of Tcl interfaces (in Tcl)

      @@ -3288,7 +3288,7 @@ danger of blowing something up (although it is easily accomplished with an out of bounds array access).

      -

      32.9.1 Proxy classes

      +

      33.9.1 Proxy classes

      diff --git a/Doc/Manual/chapters b/Doc/Manual/chapters index 55a0aec13..7d2b699bd 100644 --- a/Doc/Manual/chapters +++ b/Doc/Manual/chapters @@ -12,6 +12,7 @@ Customization.html Contract.html Varargs.html Warnings.html +CCache.html Modules.html Allegrocl.html CSharp.html From 5e50d29bb3aae3c422732a35b91514debc925826 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 20 Dec 2008 17:20:25 +0000 Subject: [PATCH 0236/1680] Add Win32 ccache locking from Christophe Gisquet patch http://lists.samba.org/archive/ccache/2006q3/000242.html git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10992 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CCache/ccache.h | 1 + CCache/util.c | 21 ++++++++++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/CCache/ccache.h b/CCache/ccache.h index 4b4776dd2..e95a92c43 100644 --- a/CCache/ccache.h +++ b/CCache/ccache.h @@ -5,6 +5,7 @@ #ifndef _WIN32 #include "config.h" #else +#include #define PACKAGE_NAME "ccache-swig.exe" #endif diff --git a/CCache/util.c b/CCache/util.c index fdd832446..f09256dfc 100644 --- a/CCache/util.c +++ b/CCache/util.c @@ -617,9 +617,24 @@ char *dirname(char *s) return s; } +/* + http://www.ecst.csuchico.edu/~beej/guide/ipc/flock.html + http://cvs.php.net/viewvc.cgi/php-src/win32/flock.c?revision=1.2&view=markup + Should return 0 for success, >0 otherwise + */ int lock_fd(int fd) { -#ifndef _WIN32 +#ifdef _WIN32 +# if 1 + return _locking(fd, _LK_NBLCK, 1); +# else + HANDLE fl = (HANDLE)_get_osfhandle(fd); + OVERLAPPED o; + memset(&o, 0, sizeof(o)); + return (LockFileEx(fl, LOCKFILE_EXCLUSIVE_LOCK, 0, 1, 0, &o)) + ? 0 : GetLastError(); +# endif +#else struct flock fl; int ret; @@ -635,10 +650,6 @@ int lock_fd(int fd) ret = fcntl(fd, F_SETLKW, &fl); } while (ret == -1 && errno == EINTR); return ret; -#else - (void)fd; -#warning "missing implementation???" - return 0; #endif } From d115e52bc03d9185f60f16e53e3968c133af2d2e Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 20 Dec 2008 23:59:03 +0000 Subject: [PATCH 0237/1680] possibly slightly faster win32 process spawn from http://lists.samba.org/archive/ccache/2006q3/000242.html git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10993 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CCache/execute.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/CCache/execute.c b/CCache/execute.c index d7d031d83..aef73fba1 100644 --- a/CCache/execute.c +++ b/CCache/execute.c @@ -55,6 +55,8 @@ int execute(char **argv, const char *path_stderr) { #ifdef _WIN32 + +#if 0 PROCESS_INFORMATION pinfo; STARTUPINFO sinfo; BOOL ret; @@ -107,6 +109,55 @@ int execute(char **argv, CloseHandle(pinfo.hThread); return exitcode; +#else /* possibly slightly faster */ + /* Should be portable */ + int status = -2; + int fd, std_od = -1, std_ed = -1; + + /* TODO: needs moving after possible exit() below, but before stdout is redirected */ + if (ccache_verbose) { + display_execute_args(argv); + } + + unlink(path_stdout); + std_od = _dup(1); + fd = _open(path_stdout, O_WRONLY|O_CREAT|O_TRUNC|O_EXCL|O_BINARY, 0666); + if (fd == -1) { + status = STATUS_NOCACHE; + cc_log("stdout error: failed to open %s\n", path_stdout); + goto out; + } + _dup2(fd, 1); + _close(fd); + + unlink(path_stderr); + fd = _open(path_stderr, O_WRONLY|O_CREAT|O_TRUNC|O_EXCL|O_BINARY, 0666); + std_ed = _dup(2); + if (fd == -1) { + status = STATUS_NOCACHE; + cc_log("stderr error: failed to open %s\n", path_stderr); + goto out; + } + _dup2(fd, 2); + _close(fd); + + /* Spawn process (_exec* familly doesn't return) */ + status = _spawnv(_P_WAIT, argv[0], (const char **)argv); + +out: + cc_log("%s:\n stdout -> %s\n stderr -> %s\n process status=%i\n", + argv[0], path_stdout, path_stderr, status); + if (status == -1) cc_log("Error %i: %s\n", errno, strerror(errno)); + + /* Restore descriptors */ + if (std_od != -1) _dup2(std_od, 1); + if (std_ed != -1) _dup2(std_ed, 2); + _flushall(); + + return (status>0); + +#endif + #else pid_t pid; int status; From f9393a0f06b0a79f0d09bee603f2e191741dda4b Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 21 Dec 2008 00:29:48 +0000 Subject: [PATCH 0238/1680] Apply patch #2440046 which fixes possible seg faults for member and global variable char arrays when the strings are larger than the string array size. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10994 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++++ Lib/swig.swg | 16 ++++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 27118706c..53406ea98 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,10 @@ Version 1.3.37 (in progress) ============================ +2008-12-21: wsfulton + Apply patch #2440046 which fixes possible seg faults for member and global + variable char arrays when the strings are larger than the string array size. + 2008-12-20: wsfulton The ccache compiler cache has been adapted to work with SWIG and named ccache-swig. It now works with C/C++ compilers as well as SWIG diff --git a/Lib/swig.swg b/Lib/swig.swg index 6f40a8fe9..d5e32b874 100644 --- a/Lib/swig.swg +++ b/Lib/swig.swg @@ -423,13 +423,21 @@ namespace std { /* Character array handling */ %typemap(memberin) char [ANY] { - if ($input) strncpy((char *)$1, (const char *)$input, $1_dim0); - else $1[0] = 0; + if($input) { + strncpy((char*)$1, (const char *)$input, $1_dim0-1); + $1[$1_dim0-1] = 0; + } else { + $1[0] = 0; + } } %typemap(globalin) char [ANY] { - if ($input) strncpy((char *)$1, (const char *)$input, $1_dim0); - else $1[0] = 0; + if($input) { + strncpy((char*)$1, (const char *)$input, $1_dim0-1); + $1[$1_dim0-1] = 0; + } else { + $1[0] = 0; + } } %typemap(memberin) char [] { From b1e7bbd831d1ae60f04ce4204c0c2a39422f6302 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 21 Dec 2008 00:55:27 +0000 Subject: [PATCH 0239/1680] Fix some make targets not running on cygwin git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10995 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Makefile.in | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile.in b/Makefile.in index a7e62fe49..123c3cd23 100644 --- a/Makefile.in +++ b/Makefile.in @@ -2,6 +2,8 @@ # $Id$ ####################################################################### +.PHONY: ccache source swig + prefix = @prefix@ exec_prefix = @exec_prefix@ srcdir = @srcdir@ From a648bb7f38660ce1acd4803097cf6ba63149da1c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 21 Dec 2008 23:16:56 +0000 Subject: [PATCH 0240/1680] Add CCACHE_STRIPC option to remove an unwarranted warning when using ccache with the Solaris Workshop C++ compiler git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10996 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CCache/ccache.c | 15 ++++++++++++++- CCache/ccache.yo | 7 +++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/CCache/ccache.c b/CCache/ccache.c index ce9717b84..486964377 100644 --- a/CCache/ccache.c +++ b/CCache/ccache.c @@ -68,6 +68,9 @@ char *stats_file = NULL; /* can we safely use the unification hashing backend? */ static int enable_unify; +/* should we strip -c when running the preprocessor only? */ +static int strip_c_option; + /* customisation for using the SWIG compiler */ static int swig; @@ -230,6 +233,10 @@ static void to_cache(ARGS *args) x_asprintf(&tmp_stderr, "%s/tmp.stderr.%s", temp_dir, tmp_string()); x_asprintf(&tmp_outfiles, "%s/tmp.outfiles.%s", temp_dir, tmp_string()); + if (strip_c_option) { + args_add(stripped_args, "-c"); + } + if (output_file) { args_add(args, "-o"); args_add(args, output_file); @@ -859,7 +866,9 @@ static void process_args(int argc, char **argv) /* we must have -c */ if (strcmp(argv[i], "-c") == 0) { - args_add(stripped_args, argv[i]); + if (!strip_c_option) { + args_add(stripped_args, argv[i]); + } found_c_opt = 1; continue; } @@ -1126,6 +1135,10 @@ static void ccache(int argc, char *argv[]) failed(); } + if (getenv("CCACHE_STRIPC")) { + strip_c_option = 1; + } + if (getenv("CCACHE_UNIFY")) { enable_unify = 1; } diff --git a/CCache/ccache.yo b/CCache/ccache.yo index 7f18b9885..08acb843e 100644 --- a/CCache/ccache.yo +++ b/CCache/ccache.yo @@ -261,6 +261,13 @@ systems like this you can use the CCACHE_EXTENSION option to override the default. On HP-UX set this environment variable to "i" if you use the aCC compiler. +dit(bf(CCACHE_STRIPC)) If you set the environment variable +CCACHE_STRIPC then ccache will strip the -c option when invoking +the preprocessor. This option is primarily for the Sun Workshop +C++ compiler as without this option an unwarranted warning is displayed: +CC: Warning: "-E" redefines product from "object" to "source (stdout)" +when -E and -c is used together. + dit(bf(CCACHE_SWIG)) When using SWIG as the compiler and it does not have 'swig' in the executable name, then the CCACHE_SWIG environment variable needs to be set in order for ccache to work correctly with From 7adb84f4487083aa7e4df8a7c2e6ff48e13e8525 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 22 Dec 2008 21:43:48 +0000 Subject: [PATCH 0241/1680] Fix #2432801 - Make SwigValueWrapper exception safe for when copy constructors throw exceptions git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10997 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++++ Lib/swig.swg | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index 53406ea98..7a38f22b4 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,10 @@ Version 1.3.37 (in progress) ============================ +2008-12-22: wsfulton + Fix #2432801 - Make SwigValueWrapper exception safe for when copy constructors + throw exceptions. + 2008-12-21: wsfulton Apply patch #2440046 which fixes possible seg faults for member and global variable char arrays when the strings are larger than the string array size. diff --git a/Lib/swig.swg b/Lib/swig.swg index d5e32b874..0c7bcd4c1 100644 --- a/Lib/swig.swg +++ b/Lib/swig.swg @@ -647,7 +647,7 @@ public: SwigValueWrapper(const SwigValueWrapper& rhs) : tt(new T(*rhs.tt)) { } SwigValueWrapper(const T& t) : tt(new T(t)) { } ~SwigValueWrapper() { delete tt; } - SwigValueWrapper& operator=(const T& t) { delete tt; tt = new T(t); return *this; } + SwigValueWrapper& operator=(const T& t) { T *oldtt = tt; tt = 0; delete oldtt; tt = new T(t); return *this; } operator T&() const { return *tt; } T *operator&() { return tt; } private: From e6f5cdac9f09120032fbff49e79b3ed3c2acd496 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 23 Dec 2008 07:44:59 +0000 Subject: [PATCH 0242/1680] Fix #2153773 - %nojavaexception - disabling and clearing Java checked exceptions git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10998 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 5 +++ Doc/Manual/Customization.html | 14 +++++++ Doc/Manual/Java.html | 4 +- .../test-suite/java/java_throws_runme.java | 15 ++++++++ Examples/test-suite/java_throws.i | 38 +++++++++++++++++++ Lib/java/java.swg | 3 +- Source/Modules/java.cxx | 10 ++++- 7 files changed, 85 insertions(+), 4 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 7a38f22b4..6dda7ff7a 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,11 @@ Version 1.3.37 (in progress) ============================ +2008-12-23: wsfulton + [Java] Fix #2153773 - %nojavaexception was clearing the exception feature + instead of disabling it. Clearing checked Java exceptions also didn't work. + The new %clearjavaexception can be used for clearing the exception feature. + 2008-12-22: wsfulton Fix #2432801 - Make SwigValueWrapper exception safe for when copy constructors throw exceptions. diff --git a/Doc/Manual/Customization.html b/Doc/Manual/Customization.html index e9d70e39a..ec73e5460 100644 --- a/Doc/Manual/Customization.html +++ b/Doc/Manual/Customization.html @@ -1019,6 +1019,20 @@ but this will: +

      +SWIG provides macros for disabling and clearing features. Many of these can be found in the swig.swg library file. +The typical pattern is to define three macros; one to define the feature itself, one to disable the feature and one to clear the feature. +The three macros below show this for the "except" feature: +

      + +
      +
      +#define %exception      %feature("except")
      +#define %noexception    %feature("except","0")
      +#define %clearexception %feature("except","")
      +
      +
      +

      11.3.4 Features and default arguments

      diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html index cbdcb5a9e..c5ff1f906 100644 --- a/Doc/Manual/Java.html +++ b/Doc/Manual/Java.html @@ -3820,7 +3820,9 @@ public: In the example above, java.lang.Exception is a checked exception class and so ought to be declared in the throws clause of getitem. Classes can be specified for adding to the throws clause using %javaexception(classes) instead of %exception, where classes is a string containing one or more comma separated Java classes. -The %nojavaexception feature is the equivalent to %noexception and clears previously declared exception handlers. +The %clearjavaexception feature is the equivalent to %clearexception and clears previously declared exception handlers. +The %nojavaexception feature is the equivalent to %noexception and disables the exception handler. +See Clearing features for the difference on disabling and clearing features.

      diff --git a/Examples/test-suite/java/java_throws_runme.java b/Examples/test-suite/java/java_throws_runme.java index 3538aa6d4..6a73ea563 100644 --- a/Examples/test-suite/java/java_throws_runme.java +++ b/Examples/test-suite/java/java_throws_runme.java @@ -94,5 +94,20 @@ public class java_throws_runme { if (!pass) throw new RuntimeException("Test 7 failed"); + + // Test %nojavaexception + NoExceptTest net = new NoExceptTest(); + + pass = false; + try { + net.exceptionPlease(); + pass = true; + } + catch (MyException e) {} + + if (!pass) + throw new RuntimeException("Test 8 failed"); + + net.noExceptionPlease(); } } diff --git a/Examples/test-suite/java_throws.i b/Examples/test-suite/java_throws.i index 3aa11defb..efa7da571 100644 --- a/Examples/test-suite/java_throws.i +++ b/Examples/test-suite/java_throws.i @@ -143,3 +143,41 @@ try { } %} +// Test %nojavaexception +%javaexception("MyException") %{ +/* global exception handler */ +try { + $action +} catch (MyException) { + jclass excep = jenv->FindClass("java_throws/MyException"); + if (excep) + jenv->ThrowNew(excep, "exception message"); + return $null; +} +%} + +%nojavaexception *::noExceptionPlease(); +%nojavaexception NoExceptTest::NoExceptTest(); + +// Need to handle the checked exception in NoExceptTest.delete() +%typemap(javafinalize) SWIGTYPE %{ + protected void finalize() { + try { + delete(); + } catch (MyException e) { + throw new RuntimeException(e); + } + } +%} + +%inline %{ +struct NoExceptTest { + unsigned int noExceptionPlease() { return 123; } + unsigned int exceptionPlease() { return 456; } + ~NoExceptTest() {} +}; +%} + +// Turn global exceptions off (for the implicit destructors) +%nojavaexception; + diff --git a/Lib/java/java.swg b/Lib/java/java.swg index 7d1808632..f70d3f9cd 100644 --- a/Lib/java/java.swg +++ b/Lib/java/java.swg @@ -1191,7 +1191,8 @@ SWIG_PROXY_CONSTRUCTOR(true, true, SWIGTYPE) #define %javaenum(wrapapproach) %feature("java:enum","wrapapproach") #define %javamethodmodifiers %feature("java:methodmodifiers") #define %javaexception(exceptionclasses) %feature("except",throws=exceptionclasses) -#define %nojavaexception %feature("except","",throws="") +#define %nojavaexception %feature("except","0",throws="") +#define %clearjavaexception %feature("except","",throws="") %pragma(java) jniclassclassmodifiers="class" %pragma(java) moduleclassmodifiers="public class" diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index 37ce22377..742756f63 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -70,6 +70,7 @@ class JAVA:public Language { String *imclass_cppcasts_code; //C++ casts up inheritance hierarchies intermediary class code String *imclass_directors; // Intermediate class director code String *destructor_call; //C++ destructor call if any + String *destructor_throws_clause; //C++ destructor throws clause if any // Director method stuff: List *dmethods_seq; @@ -141,6 +142,7 @@ public: imclass_cppcasts_code(NULL), imclass_directors(NULL), destructor_call(NULL), + destructor_throws_clause(NULL), dmethods_seq(NULL), dmethods_table(NULL), n_dmethods(0), @@ -1654,7 +1656,7 @@ public: else Replaceall(destruct, "$jnicall", "throw new UnsupportedOperationException(\"C++ destructor does not have public access\")"); if (*Char(destruct)) - Printv(proxy_class_def, "\n ", destruct_methodmodifiers, " void ", destruct_methodname, "() ", destruct, "\n", NIL); + Printv(proxy_class_def, "\n ", destruct_methodmodifiers, " void ", destruct_methodname, "()", destructor_throws_clause, " ", destruct, "\n", NIL); } /* Insert directordisconnect typemap, if this class has directors enabled */ @@ -1761,6 +1763,7 @@ public: Clear(proxy_class_code); destructor_call = NewString(""); + destructor_throws_clause = NewString(""); proxy_class_constants_code = NewString(""); } @@ -1819,6 +1822,8 @@ public: proxy_class_name = NULL; Delete(destructor_call); destructor_call = NULL; + Delete(destructor_throws_clause); + destructor_throws_clause = NULL; Delete(proxy_class_constants_code); proxy_class_constants_code = NULL; } @@ -2336,6 +2341,7 @@ public: if (proxy_flag) { Printv(destructor_call, imclass_name, ".", Swig_name_destroy(symname), "(swigCPtr)", NIL); + generateThrowsClause(n, destructor_throws_clause); } return SWIG_OK; } @@ -2870,7 +2876,7 @@ public: String *throws_attribute = NewStringf("%s:throws", attribute); String *throws = Getattr(parameter, throws_attribute); - if (throws) { + if (throws && Len(throws) > 0) { String *throws_list = Getattr(n, "java:throwslist"); if (!throws_list) { throws_list = NewList(); From 5f9e0707b597b9395fdf9f1db151ed25b74558d5 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 23 Dec 2008 22:47:58 +0000 Subject: [PATCH 0243/1680] typo fix git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10999 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 8a718ffad..bc8c8fa51 100644 --- a/Doc/Manual/Windows.html +++ b/Doc/Manual/Windows.html @@ -281,7 +281,7 @@ Execute the steps in the order shown and don't use spaces in path names. In fact
    • - Copy the followig to the MSYS install folder (C:\msys\1.0 is default): + Copy the following to the MSYS install folder (C:\msys\1.0 is default):
      • msys-automake-1.8.2.tar.bz2
      • msys-autoconf-2.59.tar.bz2
      • From 9a94969fdd6f3abaee1c6b3154b8d2067b1ba739 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 24 Dec 2008 13:19:55 +0000 Subject: [PATCH 0244/1680] fix input filename containing a path on windows git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11000 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/main.cxx | 2 +- Source/Swig/include.c | 6 +----- Source/Swig/misc.c | 15 +++++++++++++++ Source/Swig/swig.h | 1 + 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx index a41191bb9..008ce5126 100644 --- a/Source/Modules/main.cxx +++ b/Source/Modules/main.cxx @@ -1002,7 +1002,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", input_file, Swig_last_file()); + Printf(fs, "%%include(maininput=\"%s\") \"%s\"\n", Swig_filename_escape(NewString(input_file)), Swig_last_file()); for (i = 0; i < Len(libfiles); i++) { Printf(fs, "\n%%include \"%s\"\n", Getitem(libfiles, i)); } diff --git a/Source/Swig/include.c b/Source/Swig/include.c index 73cb6551e..cf105c787 100644 --- a/Source/Swig/include.c +++ b/Source/Swig/include.c @@ -183,12 +183,8 @@ static FILE *Swig_open_file(const String_or_char *name, int sysfile, int use_inc Delete(spath); } if (f) { -#if defined(_WIN32) /* Note not on Cygwin else filename is displayed with double '/' */ - Replaceall(filename, "\\\\", "\\"); /* remove double '\' in case any already present */ - Replaceall(filename, "\\", "\\\\"); -#endif Delete(lastpath); - lastpath = Copy(filename); + lastpath = Swig_filename_escape(filename); } Delete(filename); return f; diff --git a/Source/Swig/misc.c b/Source/Swig/misc.c index ae3129fde..dca9774ab 100644 --- a/Source/Swig/misc.c +++ b/Source/Swig/misc.c @@ -117,6 +117,21 @@ String *Swig_strip_c_comments(const String *s) { } +/* ----------------------------------------------------------------------------- + * Swig_filename_escape() + * + * Escapes backslashes in filename - for Windows + * ----------------------------------------------------------------------------- */ + +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, "\\", "\\\\"); +#endif + return adjusted_filename; +} + /* ----------------------------------------------------------------------------- * Swig_string_escape() * diff --git a/Source/Swig/swig.h b/Source/Swig/swig.h index 451de86c4..16966a516 100644 --- a/Source/Swig/swig.h +++ b/Source/Swig/swig.h @@ -286,6 +286,7 @@ extern int ParmList_is_compactdefargs(ParmList *p); extern const char *Swig_package_version(void); extern void Swig_banner(File *f); extern String *Swig_strip_c_comments(const String *s); + extern String *Swig_filename_escape(String *filename); extern String *Swig_string_escape(String *s); extern String *Swig_string_mangle(const String *s); extern void Swig_scopename_split(String *s, String **prefix, String **last); From da0b517a7f1b99689806747bf1380c748b39d7c4 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 24 Dec 2008 14:50:26 +0000 Subject: [PATCH 0245/1680] accept unix directory separators on windows for input file git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11001 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/lang.cxx | 4 ++-- Source/Modules/main.cxx | 12 +++++++----- Source/Modules/modula3.cxx | 3 +-- Source/Modules/php.cxx | 6 ++---- Source/Modules/swigmod.h | 2 +- Source/Preprocessor/cpp.c | 9 +-------- Source/Swig/misc.c | 17 +++++++++++++++++ Source/Swig/swig.h | 1 + 8 files changed, 32 insertions(+), 22 deletions(-) diff --git a/Source/Modules/lang.cxx b/Source/Modules/lang.cxx index 6718903d0..db8923074 100644 --- a/Source/Modules/lang.cxx +++ b/Source/Modules/lang.cxx @@ -61,7 +61,7 @@ static String *AttributeFunctionGet = 0; static String *AttributeFunctionSet = 0; static Node *CurrentClass = 0; int line_number = 0; -char *input_file = 0; +String *input_file = 0; int SmartPointer = 0; static Hash *classhash; @@ -352,7 +352,7 @@ int Language::emit_one(Node *n) { Extend = 1; line_number = Getline(n); - input_file = Char(Getfile(n)); + input_file = Getfile(n); /* symtab = Getattr(n,"symtab"); diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx index 008ce5126..f43d7b295 100644 --- a/Source/Modules/main.cxx +++ b/Source/Modules/main.cxx @@ -185,12 +185,13 @@ enum { STAGE1=1, STAGE2=2, STAGE3=4, STAGE4=8, STAGEOVERFLOW=16 }; static List *all_output_files = 0; // ----------------------------------------------------------------------------- -// check_suffix(char *name) +// check_suffix() // // Checks the suffix of a file to see if we should emit extern declarations. // ----------------------------------------------------------------------------- -static int check_suffix(const char *name) { +static int check_suffix(String *filename) { + const char *name = Char(filename); const char *c; if (!name) return 0; @@ -936,12 +937,13 @@ int SWIG_main(int argc, char *argv[], Language *l) { // If we made it this far, looks good. go for it.... - input_file = argv[argc - 1]; + input_file = NewString(argv[argc - 1]); + Swig_filename_correct(input_file); // If the user has requested to check out a file, handle that if (checkout) { DOH *s; - char *outfile = input_file; + String *outfile = Char(input_file); if (outfile_name) outfile = outfile_name; @@ -1002,7 +1004,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(NewString(input_file)), Swig_last_file()); + Printf(fs, "%%include(maininput=\"%s\") \"%s\"\n", Swig_filename_escape(input_file), Swig_last_file()); for (i = 0; i < Len(libfiles); i++) { Printf(fs, "\n%%include \"%s\"\n", Getitem(libfiles, i)); } diff --git a/Source/Modules/modula3.cxx b/Source/Modules/modula3.cxx index 1df206e62..3f9109082 100644 --- a/Source/Modules/modula3.cxx +++ b/Source/Modules/modula3.cxx @@ -3174,8 +3174,7 @@ MODULA3(): Clear(result_m3wraptype); Printv(result_m3wraptype, tm, NIL); } else { - Swig_warning(WARN_MODULA3_TYPEMAP_MULTIPLE_RETURN, - input_file, line_number, + Swig_warning(WARN_MODULA3_TYPEMAP_MULTIPLE_RETURN, input_file, line_number, "Typemap m3wrapargdir set to 'out' for %s implies a RETURN value, but the routine %s has already one.\nUse %%multiretval feature.\n", SwigType_str(Getattr(p, "type"), 0), raw_name); } diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index fa8757a80..fc4ad8348 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -1489,8 +1489,7 @@ public: Replaceall(tm, "$symname", iname); Printf(f_c->code, "%s\n", tm); } else { - Printf(stderr,"%s: Line %d, Unable to link with type %s\n", - input_file, line_number, SwigType_str(t, 0)); + Printf(stderr,"%s: Line %d, Unable to link with type %s\n", input_file, line_number, SwigType_str(t, 0)); } */ /* Now generate C -> PHP sync blocks */ @@ -1502,8 +1501,7 @@ public: Replaceall(tm, "$symname", iname); Printf(f_php->code, "%s\n", tm); } else { - Printf(stderr,"%s: Line %d, Unable to link with type %s\n", - input_file, line_number, SwigType_str(t, 0)); + Printf(stderr,"%s: Line %d, Unable to link with type %s\n", input_file, line_number, SwigType_str(t, 0)); } } */ diff --git a/Source/Modules/swigmod.h b/Source/Modules/swigmod.h index 8ee97bb2c..21f098325 100644 --- a/Source/Modules/swigmod.h +++ b/Source/Modules/swigmod.h @@ -26,7 +26,7 @@ typedef int bool; #define PLAIN_VIRTUAL 1 #define PURE_VIRTUAL 2 -extern char *input_file; +extern String *input_file; extern int line_number; extern int start_line; extern int CPlusPlus; // C++ mode diff --git a/Source/Preprocessor/cpp.c b/Source/Preprocessor/cpp.c index c04f95f00..2b9e25fef 100644 --- a/Source/Preprocessor/cpp.c +++ b/Source/Preprocessor/cpp.c @@ -650,14 +650,7 @@ static String *get_filename(String *str, int *sysfile) { if (isspace(c)) Ungetc(c, str); } -#if defined(_WIN32) || defined(MACSWIG) - /* accept Unix path separator on non-Unix systems */ - Replaceall(fn, "/", SWIG_FILE_DELIMITER); -#endif -#if defined(__CYGWIN__) - /* accept Windows path separator in addition to Unix path separator */ - Replaceall(fn, "\\", SWIG_FILE_DELIMITER); -#endif + Swig_filename_correct(fn); Seek(fn, 0, SEEK_SET); return fn; } diff --git a/Source/Swig/misc.c b/Source/Swig/misc.c index dca9774ab..4f21d0848 100644 --- a/Source/Swig/misc.c +++ b/Source/Swig/misc.c @@ -117,6 +117,23 @@ String *Swig_strip_c_comments(const String *s) { } +/* ----------------------------------------------------------------------------- + * Swig_filename_correct() + * + * Corrects filenames on non-unix systems + * ----------------------------------------------------------------------------- */ + +void Swig_filename_correct(String *filename) { +#if defined(_WIN32) || defined(MACSWIG) + /* accept Unix path separator on non-Unix systems */ + Replaceall(filename, "/", SWIG_FILE_DELIMITER); +#endif +#if defined(__CYGWIN__) + /* accept Windows path separator in addition to Unix path separator */ + Replaceall(filename, "\\", SWIG_FILE_DELIMITER); +#endif +} + /* ----------------------------------------------------------------------------- * Swig_filename_escape() * diff --git a/Source/Swig/swig.h b/Source/Swig/swig.h index 16966a516..c93740902 100644 --- a/Source/Swig/swig.h +++ b/Source/Swig/swig.h @@ -287,6 +287,7 @@ extern int ParmList_is_compactdefargs(ParmList *p); extern void Swig_banner(File *f); 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_string_escape(String *s); extern String *Swig_string_mangle(const String *s); extern void Swig_scopename_split(String *s, String **prefix, String **last); From 1b485a7ad27b7de075b51dcef820b07cdfbb1153 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 24 Dec 2008 14:54:52 +0000 Subject: [PATCH 0246/1680] minor fixes from last checkin git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11002 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/main.cxx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx index f43d7b295..6ebc50449 100644 --- a/Source/Modules/main.cxx +++ b/Source/Modules/main.cxx @@ -943,7 +943,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; - String *outfile = Char(input_file); + char *outfile = Char(input_file); if (outfile_name) outfile = outfile_name; @@ -952,12 +952,12 @@ int SWIG_main(int argc, char *argv[], Language *l) { s = Swig_include(input_file); if (!s) { - fprintf(stderr, "Unable to locate '%s' in the SWIG library.\n", input_file); + Printf(stderr, "Unable to locate '%s' in the SWIG library.\n", input_file); } else { FILE *f = Swig_include_open(outfile); if (f) { fclose(f); - fprintf(stderr, "File '%s' already exists. Checkout aborted.\n", outfile); + Printf(stderr, "File '%s' already exists. Checkout aborted.\n", outfile); } else { File *f_outfile = NewFile(outfile, "w", SWIG_output_files()); if (!f_outfile) { @@ -965,7 +965,7 @@ int SWIG_main(int argc, char *argv[], Language *l) { SWIG_exit(EXIT_FAILURE); } else { if (Verbose) - fprintf(stdout, "'%s' checked out from the SWIG library.\n", outfile); + Printf(stdout, "'%s' checked out from the SWIG library.\n", outfile); Printv(f_outfile, s, NIL); Close(f_outfile); } From 816cfdb7248b573ca149d62c66140d097e106c83 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 24 Dec 2008 19:17:16 +0000 Subject: [PATCH 0247/1680] warning fixes git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11003 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/php/overloading/example.cxx | 10 +++++----- Examples/php/overloading/example.h | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Examples/php/overloading/example.cxx b/Examples/php/overloading/example.cxx index fc7aff195..2f684f05c 100644 --- a/Examples/php/overloading/example.cxx +++ b/Examples/php/overloading/example.cxx @@ -34,22 +34,22 @@ double Square::perimeter(void) { return 4*width; } -char *overloaded(int i) { +const char *overloaded(int i) { return "Overloaded with int"; } -char *overloaded(double d) { +const char *overloaded(double d) { return "Overloaded with double"; } -char *overloaded(const char * str) { +const char *overloaded(const char * str) { return "Overloaded with char *"; } -char *overloaded( const Circle& ) { +const char *overloaded( const Circle& ) { return "Overloaded with Circle"; } -char *overloaded( const Shape& ) { +const char *overloaded( const Shape& ) { return "Overloaded with Shape"; } diff --git a/Examples/php/overloading/example.h b/Examples/php/overloading/example.h index 39ccc1cb1..01d71dd70 100644 --- a/Examples/php/overloading/example.h +++ b/Examples/php/overloading/example.h @@ -38,9 +38,9 @@ public: virtual double perimeter(void); }; -char *overloaded( int i ); -char *overloaded( double d ); -char *overloaded( const char * str ); -char *overloaded( const Circle& ); -char *overloaded( const Shape& ); +const char *overloaded( int i ); +const char *overloaded( double d ); +const char *overloaded( const char * str ); +const char *overloaded( const Circle& ); +const char *overloaded( const Shape& ); From e9867c661aa92250c4aa45e2aae89b7b2a680c24 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 24 Dec 2008 19:20:54 +0000 Subject: [PATCH 0248/1680] warning fixes git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11004 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/php/sync/example.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/php/sync/example.cxx b/Examples/php/sync/example.cxx index 47378924b..31ed2021b 100644 --- a/Examples/php/sync/example.cxx +++ b/Examples/php/sync/example.cxx @@ -2,7 +2,7 @@ #include int x = 42; -char *s = "Test"; +char *s = (char *)"Test"; void Sync::printer(void) { From 8ed7554802dcca93de72fdc35bfbbf825ded2fa8 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 24 Dec 2008 23:42:39 +0000 Subject: [PATCH 0249/1680] overlooked build system mods now implemented to remove warning 125 git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11005 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/guile/Makefile.in | 2 +- Examples/test-suite/guilescm/Makefile.in | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Examples/test-suite/guile/Makefile.in b/Examples/test-suite/guile/Makefile.in index 97f30e3b2..25d40674d 100644 --- a/Examples/test-suite/guile/Makefile.in +++ b/Examples/test-suite/guile/Makefile.in @@ -36,7 +36,7 @@ swig_and_compile_multi_cpp = \ $(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)" INTERFACE="$$f.i" \ + TARGET="$(TARGETPREFIX)$${f}$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$$f.i" \ $(LANGUAGE)$(VARIANT)_cpp; \ SWIGOPT=" -noruntime "; \ done diff --git a/Examples/test-suite/guilescm/Makefile.in b/Examples/test-suite/guilescm/Makefile.in index 501a387f7..eb53f020e 100644 --- a/Examples/test-suite/guilescm/Makefile.in +++ b/Examples/test-suite/guilescm/Makefile.in @@ -31,7 +31,7 @@ swig_and_compile_multi_cpp = \ $(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)" INTERFACE="$$f.i" \ + TARGET="$(TARGETPREFIX)$${f}$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$$f.i" \ $(LANGUAGE)$(VARIANT)_cpp; \ done From b190c10bf290f99ee6b8b7400aec59e580b29494 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 28 Dec 2008 18:41:16 +0000 Subject: [PATCH 0250/1680] add strong exception guarantee to SwigValueWrapper git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11006 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/swig.swg | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/Lib/swig.swg b/Lib/swig.swg index 0c7bcd4c1..8e14ccfbb 100644 --- a/Lib/swig.swg +++ b/Lib/swig.swg @@ -633,6 +633,10 @@ namespace std { * arg1 = *inarg1; // Assignment from a pointer * arg1 = Vector(1,2,3); // Assignment from a value * + * The class offers a strong guarantee of exception safety. + * With regards to the implementation, the private Pointer nested class is + * a simple smart pointer with move semantics, much like std::auto_ptr. + * * This wrapping technique was suggested by William Fulton and is henceforth * known as the "Fulton Transform" :-). */ @@ -640,18 +644,22 @@ namespace std { #ifdef __cplusplus %insert("runtime") %{ #ifdef __cplusplus +/* SwigValueWrapper is described in swig.swg */ template class SwigValueWrapper { - T *tt; + struct Pointer { + T *ptr; + Pointer(T *p) : ptr(p) { } + ~Pointer() { delete ptr; } + Pointer& operator=(Pointer& rhs) { T* oldptr = ptr; ptr = 0; delete oldptr; ptr = rhs.ptr; rhs.ptr = 0; return *this; } + } pointer; + SwigValueWrapper& operator=(const SwigValueWrapper& rhs); public: - SwigValueWrapper() : tt(0) { } - SwigValueWrapper(const SwigValueWrapper& rhs) : tt(new T(*rhs.tt)) { } - SwigValueWrapper(const T& t) : tt(new T(t)) { } - ~SwigValueWrapper() { delete tt; } - SwigValueWrapper& operator=(const T& t) { T *oldtt = tt; tt = 0; delete oldtt; tt = new T(t); return *this; } - operator T&() const { return *tt; } - T *operator&() { return tt; } -private: - SwigValueWrapper& operator=(const SwigValueWrapper& rhs); + SwigValueWrapper() : pointer(0) { } + SwigValueWrapper(const SwigValueWrapper& rhs) : pointer(new T(*rhs.pointer.ptr)) { } + SwigValueWrapper(const T& t) : pointer(new T(t)) { } + SwigValueWrapper& operator=(const T& t) { Pointer tmp(new T(t)); pointer = tmp; return *this; } + operator T&() const { return *pointer.ptr; } + T *operator&() { return pointer.ptr; } };%} /* From e4c4dedc82e9db22160a2e01d041d928e384ad2b Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 28 Dec 2008 20:16:31 +0000 Subject: [PATCH 0251/1680] SwigValueWrapper - remove two constructors which are not required by the code SWIG generates git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11007 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/swig.swg | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Lib/swig.swg b/Lib/swig.swg index 8e14ccfbb..4e0657587 100644 --- a/Lib/swig.swg +++ b/Lib/swig.swg @@ -653,10 +653,9 @@ template class SwigValueWrapper { Pointer& operator=(Pointer& rhs) { T* oldptr = ptr; ptr = 0; delete oldptr; ptr = rhs.ptr; rhs.ptr = 0; return *this; } } pointer; SwigValueWrapper& operator=(const SwigValueWrapper& rhs); + SwigValueWrapper(const SwigValueWrapper& rhs); public: SwigValueWrapper() : pointer(0) { } - SwigValueWrapper(const SwigValueWrapper& rhs) : pointer(new T(*rhs.pointer.ptr)) { } - SwigValueWrapper(const T& t) : pointer(new T(t)) { } SwigValueWrapper& operator=(const T& t) { Pointer tmp(new T(t)); pointer = tmp; return *this; } operator T&() const { return *pointer.ptr; } T *operator&() { return pointer.ptr; } From 62472ba466aa670d77c11e22081623fdef1733e0 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 28 Dec 2008 20:32:44 +0000 Subject: [PATCH 0252/1680] Add boost::intrusive_ptr wrappers from Mike Rowbotham git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11008 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- .../java/li_boost_intrusive_ptr_runme.java | 701 ++++++++++++++++++ Examples/test-suite/li_boost_intrusive_ptr.i | 492 ++++++++++++ Lib/intrusive_ptr.i | 97 +++ Lib/java/boost_intrusive_ptr.i | 456 ++++++++++++ 4 files changed, 1746 insertions(+) create mode 100644 Examples/test-suite/java/li_boost_intrusive_ptr_runme.java create mode 100644 Examples/test-suite/li_boost_intrusive_ptr.i create mode 100644 Lib/intrusive_ptr.i create mode 100644 Lib/java/boost_intrusive_ptr.i diff --git a/Examples/test-suite/java/li_boost_intrusive_ptr_runme.java b/Examples/test-suite/java/li_boost_intrusive_ptr_runme.java new file mode 100644 index 000000000..f40c28e9e --- /dev/null +++ b/Examples/test-suite/java/li_boost_intrusive_ptr_runme.java @@ -0,0 +1,701 @@ +import li_boost_intrusive_ptr.*; + +public class li_boost_intrusive_ptr_runme { + static { + try { + System.loadLibrary("li_boost_intrusive_ptr"); + } catch (UnsatisfiedLinkError e) { + System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); + System.exit(1); + } + } + + // Debugging flag + public final static boolean debug = false; + + public static void main(String argv[]) + { + if (debug) + System.out.println("Started"); + + li_boost_intrusive_ptr.setDebug_shared(debug); + + // Change loop count to run for a long time to monitor memory + final int loopCount = 5000; //5000; + for (int i=0; i + +// Uncomment macro below to turn on intrusive_ptr memory leak checking as described above +//#define INTRUSIVE_PTR_WRAPPER + +#ifdef INTRUSIVE_PTR_WRAPPER +# include "intrusive_ptr_wrapper.h" +# include "shared_ptr_wrapper.h" +#endif +%} + +%{ +#ifndef INTRUSIVE_PTR_WRAPPER +# define SwigBoost boost +#endif +%} + +%include "std_string.i" +#ifndef INTRUSIVE_PTR_WRAPPER +# define SWIG_INTRUSIVE_PTR_NAMESPACE SwigBoost +#endif + +#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) +#define INTRUSIVE_PTR_WRAPPERS_IMPLEMENTED +#endif + +#if defined(INTRUSIVE_PTR_WRAPPERS_IMPLEMENTED) + +%include +SWIG_INTRUSIVE_PTR(Klass, Space::Klass) +SWIG_INTRUSIVE_PTR_NO_WRAP(KlassWithoutRefCount, Space::KlassWithoutRefCount) +SWIG_INTRUSIVE_PTR_DERIVED(KlassDerived, Space::KlassWithoutRefCount, Space::KlassDerived) +SWIG_INTRUSIVE_PTR_DERIVED(KlassDerivedDerived, Space::KlassDerived, Space::KlassDerivedDerived) + +//For the use_count shared_ptr functions +%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::Klass > & ($*1_ltype tempnull) %{ + $1 = $input ? *($&1_ltype)&$input : &tempnull; +%} +%typemap (jni) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::Klass > & "jlong" +%typemap (jtype) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::Klass > & "long" +%typemap (jstype) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::Klass > & "Klass" +%typemap(javain) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::Klass > & "Klass.getCPtr($javainput)" + +%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerived > & ($*1_ltype tempnull) %{ + $1 = $input ? *($&1_ltype)&$input : &tempnull; +%} +%typemap (jni) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerived > & "jlong" +%typemap (jtype) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerived > & "long" +%typemap (jstype) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerived > & "KlassDerived" +%typemap(javain) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerived > & "KlassDerived.getCPtr($javainput)" + +%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerivedDerived > & ($*1_ltype tempnull) %{ + $1 = $input ? *($&1_ltype)&$input : &tempnull; +%} +%typemap (jni) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerivedDerived > & "jlong" +%typemap (jtype) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerivedDerived > & "long" +%typemap (jstype) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerivedDerived > & "KlassDerivedDerived" +%typemap(javain) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerivedDerived > & "KlassDerivedDerived.getCPtr($javainput)" + +#endif + +// TODO: +// const intrusive_ptr +// std::vector +// Add in generic %extend for the Upcast function for derived classes +// Remove proxy upcast method - implement %feature("shadow") ??? which replaces the proxy method + +%exception { + if (debug_shared) { + cout << "++++++" << endl << flush; + cout << "calling $name" << endl << flush; + } + $action + if (debug_shared) { + cout << "------" << endl << flush; + } +} + +%ignore IgnoredRefCountingBase; +%ignore *::operator=; +%ignore intrusive_ptr_add_ref; +%ignore intrusive_ptr_release; +%newobject pointerownertest(); +%newobject smartpointerpointerownertest(); + +%inline %{ +#include +using namespace std; + +static bool debug_shared = false; + +namespace Space { + +struct Klass { + Klass() : value("EMPTY"), count(0) { if (debug_shared) cout << "Klass() [" << value << "]" << endl << flush; increment(); } + + Klass(const std::string &val) : value(val), count(0) { if (debug_shared) cout << "Klass(string) [" << value << "]" << endl << flush; increment(); } + + virtual ~Klass() { if (debug_shared) cout << "~Klass() [" << value << "]" << endl << flush; decrement(); } + virtual std::string getValue() const { return value; } + void append(const std::string &s) { value += s; } + Klass(const Klass &other) : value(other.value), count(0) { if (debug_shared) cout << "Klass(const Klass&) [" << value << "]" << endl << flush; increment(); } + + Klass &operator=(const Klass &other) { value = other.value; return *this; } + + void addref(void) const { ++count; } + void release(void) const { if (--count == 0) delete this; } + int use_count(void) const { return count; } + static long getTotal_count() { return total_count; } + +private: + static void increment() { ++total_count; if (debug_shared) cout << " ++xxxxx Klass::increment tot: " << total_count << endl;} + static void decrement() { --total_count; if (debug_shared) cout << " --xxxxx Klass::decrement tot: " << total_count << endl;} + static boost::detail::atomic_count total_count; + std::string value; + int array[1024]; + mutable boost::detail::atomic_count count; +}; + +struct KlassWithoutRefCount { + KlassWithoutRefCount() : value("EMPTY") { if (debug_shared) cout << "KlassWithoutRefCount() [" << value << "]" << endl << flush; increment(); } + + KlassWithoutRefCount(const std::string &val) : value(val) { if (debug_shared) cout << "KlassWithoutRefCount(string) [" << value << "]" << endl << flush; increment(); } + + virtual ~KlassWithoutRefCount() { if (debug_shared) cout << "~KlassWithoutRefCount() [" << value << "]" << endl << flush; decrement(); } + virtual std::string getValue() const { return value; } + void append(const std::string &s) { value += s; } + KlassWithoutRefCount(const KlassWithoutRefCount &other) : value(other.value) { if (debug_shared) cout << "KlassWithoutRefCount(const KlassWithoutRefCount&) [" << value << "]" << endl << flush; increment(); } + std::string getSpecialValueFromUnwrappableClass() { return "this class cannot be wrapped by intrusive_ptrs but we can still use it"; } + KlassWithoutRefCount &operator=(const KlassWithoutRefCount &other) { value = other.value; return *this; } + static long getTotal_count() { return total_count; } + +private: + static void increment() { ++total_count; if (debug_shared) cout << " ++xxxxx KlassWithoutRefCount::increment tot: " << total_count << endl;} + static void decrement() { --total_count; if (debug_shared) cout << " --xxxxx KlassWithoutRefCount::decrement tot: " << total_count << endl;} + static boost::detail::atomic_count total_count; + std::string value; + int array[1024]; +}; + +struct IgnoredRefCountingBase { + IgnoredRefCountingBase() : count(0) { if (debug_shared) cout << "IgnoredRefCountingBase()" << endl << flush; increment(); } + + IgnoredRefCountingBase(const IgnoredRefCountingBase &other) : count(0) { if (debug_shared) cout << "IgnoredRefCountingBase(const IgnoredRefCountingBase&)" << endl << flush; increment(); } + + IgnoredRefCountingBase &operator=(const IgnoredRefCountingBase& other) { + return *this; + } + + virtual ~IgnoredRefCountingBase() { if (debug_shared) cout << "~IgnoredRefCountingBase()" << endl << flush; decrement(); } + + void addref(void) const { ++count; } + void release(void) const { if (--count == 0) delete this; } + int use_count(void) const { return count; } + static long getTotal_count() { return total_count; } + + private: + static void increment() { ++total_count; if (debug_shared) cout << " ++xxxxx IgnoredRefCountingBase::increment tot: " << total_count << endl;} + static void decrement() { --total_count; if (debug_shared) cout << " --xxxxx IgnoredRefCountingBase::decrement tot: " << total_count << endl;} + static boost::detail::atomic_count total_count; + double d; + double e; + mutable boost::detail::atomic_count count; +}; + +long getTotal_IgnoredRefCountingBase_count() { + return IgnoredRefCountingBase::getTotal_count(); +} + +// For most compilers, this use of multiple inheritance results in different derived and base class +// pointer values ... for some more challenging tests :) +struct KlassDerived : IgnoredRefCountingBase, KlassWithoutRefCount { + KlassDerived() : KlassWithoutRefCount() { if (debug_shared) cout << "KlassDerived()" << endl << flush; increment(); } + KlassDerived(const std::string &val) : KlassWithoutRefCount(val) { if (debug_shared) cout << "KlassDerived(string) [" << val << "]" << endl << flush; increment(); } + KlassDerived(const KlassDerived &other) : KlassWithoutRefCount(other) { if (debug_shared) cout << "KlassDerived(const KlassDerived&))" << endl << flush; increment(); } + virtual ~KlassDerived() { if (debug_shared) cout << "~KlassDerived()" << endl << flush; decrement(); } + virtual std::string getValue() const { return KlassWithoutRefCount::getValue() + "-Derived"; } + int use_count(void) const { return IgnoredRefCountingBase::use_count(); } + static long getTotal_count() { return total_count; } + + private: + static void increment() { ++total_count; if (debug_shared) cout << " ++xxxxx KlassDerived::increment tot: " << total_count << endl;} + static void decrement() { --total_count; if (debug_shared) cout << " --xxxxx KlassDerived::decrement tot: " << total_count << endl;} + static boost::detail::atomic_count total_count; +}; +struct KlassDerivedDerived : KlassDerived { + KlassDerivedDerived() : KlassDerived() { if (debug_shared) cout << "KlassDerivedDerived()" << endl << flush; increment(); } + KlassDerivedDerived(const std::string &val) : KlassDerived(val) { if (debug_shared) cout << "KlassDerivedDerived(string) [" << val << "]" << endl << flush; increment(); } + KlassDerivedDerived(const KlassDerived &other) : KlassDerived(other) { if (debug_shared) cout << "KlassDerivedDerived(const KlassDerivedDerived&))" << endl << flush; increment(); } + virtual ~KlassDerivedDerived() { if (debug_shared) cout << "~KlassDerivedDerived()" << endl << flush; decrement(); } + virtual std::string getValue() const { return KlassWithoutRefCount::getValue() + "-DerivedDerived"; } + static long getTotal_count() { return total_count; } + + private: + static void increment() { ++total_count; if (debug_shared) cout << " ++xxxxx KlassDerivedDerived::increment tot: " << total_count << endl;} + static void decrement() { --total_count; if (debug_shared) cout << " --xxxxx KlassDerivedDerived::decrement tot: " << total_count << endl;} + static boost::detail::atomic_count total_count; +}; +KlassDerived* derivedpointertest(KlassDerived* kd) { + if (kd) + kd->append(" derivedpointertest"); + return kd; +} +KlassDerived derivedvaluetest(KlassDerived kd) { + kd.append(" derivedvaluetest"); + return kd; +} +KlassDerived& derivedreftest(KlassDerived& kd) { + kd.append(" derivedreftest"); + return kd; +} +SwigBoost::intrusive_ptr derivedsmartptrtest(SwigBoost::intrusive_ptr kd) { + if (kd) + kd->append(" derivedsmartptrtest"); + return kd; +} +SwigBoost::intrusive_ptr* derivedsmartptrpointertest(SwigBoost::intrusive_ptr* kd) { + if (kd && *kd) + (*kd)->append(" derivedsmartptrpointertest"); + return kd; +} +SwigBoost::intrusive_ptr* derivedsmartptrreftest(SwigBoost::intrusive_ptr* kd) { + if (kd && *kd) + (*kd)->append(" derivedsmartptrreftest"); + return kd; +} +SwigBoost::intrusive_ptr*& derivedsmartptrpointerreftest(SwigBoost::intrusive_ptr*& kd) { + if (kd && *kd) + (*kd)->append(" derivedsmartptrpointerreftest"); + return kd; +} + +SwigBoost::intrusive_ptr factorycreate() { + return SwigBoost::intrusive_ptr(new Klass("factorycreate")); +} +// smart pointer +SwigBoost::intrusive_ptr smartpointertest(SwigBoost::intrusive_ptr k) { + if (k) + k->append(" smartpointertest"); + return SwigBoost::intrusive_ptr(k); +} +SwigBoost::intrusive_ptr* smartpointerpointertest(SwigBoost::intrusive_ptr* k) { + if (k && *k) + (*k)->append(" smartpointerpointertest"); + return k; +} +SwigBoost::intrusive_ptr& smartpointerreftest(SwigBoost::intrusive_ptr& k) { + if (k) + k->append(" smartpointerreftest"); + return k; +} +SwigBoost::intrusive_ptr*& smartpointerpointerreftest(SwigBoost::intrusive_ptr*& k) { + if (k && *k) + (*k)->append(" smartpointerpointerreftest"); + return k; +} +// const +SwigBoost::intrusive_ptr constsmartpointertest(SwigBoost::intrusive_ptr k) { + return SwigBoost::intrusive_ptr(k); +} +SwigBoost::intrusive_ptr* constsmartpointerpointertest(SwigBoost::intrusive_ptr* k) { + return k; +} +SwigBoost::intrusive_ptr& constsmartpointerreftest(SwigBoost::intrusive_ptr& k) { + return k; +} +// plain pointer +Klass valuetest(Klass k) { + k.append(" valuetest"); + return k; +} +Klass *pointertest(Klass *k) { + if (k) + k->append(" pointertest"); + return k; +} +Klass& reftest(Klass& k) { + k.append(" reftest"); + return k; +} +Klass*& pointerreftest(Klass*& k) { + k->append(" pointerreftest"); + return k; +} +// null +std::string nullsmartpointerpointertest(SwigBoost::intrusive_ptr* k) { + if (k && *k) + return "not null"; + else if (!k) + return "null smartpointer pointer"; + else if (!*k) + return "null pointer"; + else + return "also not null"; +} +// $owner +Klass *pointerownertest() { + return new Klass("pointerownertest"); +} +SwigBoost::intrusive_ptr* smartpointerpointerownertest() { + return new SwigBoost::intrusive_ptr(new Klass("smartpointerpointerownertest")); +} + +const SwigBoost::intrusive_ptr& ref_1() { + static SwigBoost::intrusive_ptr sptr; + return sptr; +} + +// overloading tests +std::string overload_rawbyval(int i) { return "int"; } +std::string overload_rawbyval(Klass k) { return "rawbyval"; } + +std::string overload_rawbyref(int i) { return "int"; } +std::string overload_rawbyref(Klass &k) { return "rawbyref"; } + +std::string overload_rawbyptr(int i) { return "int"; } +std::string overload_rawbyptr(Klass *k) { return "rawbyptr"; } + +std::string overload_rawbyptrref(int i) { return "int"; } +std::string overload_rawbyptrref(Klass *&k) { return "rawbyptrref"; } + + + +std::string overload_smartbyval(int i) { return "int"; } +std::string overload_smartbyval(SwigBoost::intrusive_ptr k) { return "smartbyval"; } + +std::string overload_smartbyref(int i) { return "int"; } +std::string overload_smartbyref(SwigBoost::intrusive_ptr &k) { return "smartbyref"; } + +std::string overload_smartbyptr(int i) { return "int"; } +std::string overload_smartbyptr(SwigBoost::intrusive_ptr *k) { return "smartbyptr"; } + +std::string overload_smartbyptrref(int i) { return "int"; } +std::string overload_smartbyptrref(SwigBoost::intrusive_ptr *&k) { return "smartbyptrref"; } + +} // namespace Space + +%} +%{ + boost::detail::atomic_count Space::Klass::total_count(0); + boost::detail::atomic_count Space::KlassWithoutRefCount::total_count(0); + boost::detail::atomic_count Space::IgnoredRefCountingBase::total_count(0); + boost::detail::atomic_count Space::KlassDerived::total_count(0); + boost::detail::atomic_count Space::KlassDerivedDerived::total_count(0); +%} + +// Member variables + +%inline %{ +struct MemberVariables { + MemberVariables() : SmartMemberPointer(new SwigBoost::intrusive_ptr()), SmartMemberReference(*(new SwigBoost::intrusive_ptr())), MemberPointer(0), MemberReference(MemberValue) {} + virtual ~MemberVariables() { + delete SmartMemberPointer; + delete &SmartMemberReference; + } + SwigBoost::intrusive_ptr SmartMemberValue; + SwigBoost::intrusive_ptr * SmartMemberPointer; + SwigBoost::intrusive_ptr & SmartMemberReference; + Space::Klass MemberValue; + Space::Klass * MemberPointer; + Space::Klass & MemberReference; +}; + +// Global variables +SwigBoost::intrusive_ptr GlobalSmartValue; +Space::Klass GlobalValue; +Space::Klass * GlobalPointer = 0; +Space::Klass & GlobalReference = GlobalValue; + +%} + +#if defined(INTRUSIVE_PTR_WRAPPERS_IMPLEMENTED) + +// Note: %template after the intrusive_ptr typemaps +SWIG_INTRUSIVE_PTR(BaseIntDouble, Base) +// Note: cannot use Base in the macro below because of the comma in the type, +// so we use a typedef instead. Alternatively use %arg(Base). %arg is defined in swigmacros.swg. +SWIG_INTRUSIVE_PTR_DERIVED(PairIntDouble, BaseIntDouble_t, Pair) + +#endif + +// Templates +%inline %{ +template struct Base { + Space::Klass klassBase; + T1 baseVal1; + T2 baseVal2; + Base(T1 t1, T2 t2) : baseVal1(t1*2), baseVal2(t2*2) {} + virtual std::string getValue() const { return "Base<>"; }; + mutable int count; + void addref(void) const { count++; } + void release(void) const { if (--count == 0) delete this; } + int use_count(void) const { return count; } +}; +typedef Base BaseIntDouble_t; +%} + +%template(BaseIntDouble) Base; + +%inline %{ +template struct Pair : Base { + Space::Klass klassPair; + T1 val1; + T2 val2; + Pair(T1 t1, T2 t2) : Base(t1, t2), val1(t1), val2(t2) {} + virtual std::string getValue() const { return "Pair<>"; }; +}; + +Pair pair_id2(Pair p) { return p; } +SwigBoost::intrusive_ptr< Pair > pair_id1(SwigBoost::intrusive_ptr< Pair > p) { return p; } + +template void intrusive_ptr_add_ref(const T* r) { r->addref(); } + +template void intrusive_ptr_release(const T* r) { r->release(); } + +long use_count(const SwigBoost::shared_ptr& sptr) { + return sptr.use_count(); +} +long use_count(const SwigBoost::shared_ptr& sptr) { + return sptr.use_count(); +} +long use_count(const SwigBoost::shared_ptr& sptr) { + return sptr.use_count(); +} +%} + +%template(PairIntDouble) Pair; + +// For counting the instances of intrusive_ptr (all of which are created on the heap) +// intrusive_ptr_wrapper_count() gives overall count +%inline %{ +namespace SwigBoost { + const int NOT_COUNTING = -123456; + int intrusive_ptr_wrapper_count() { + #ifdef INTRUSIVE_PTR_WRAPPER + return SwigBoost::IntrusivePtrWrapper::getTotalCount(); + #else + return NOT_COUNTING; + #endif + } + #ifdef INTRUSIVE_PTR_WRAPPER + template<> std::string show_message(boost::intrusive_ptr*t) { + if (!t) + return "null intrusive_ptr!!!"; + if (*t) + return "Klass: " + (*t)->getValue(); + else + return "Klass: NULL"; + } + template<> std::string show_message(boost::intrusive_ptr*t) { + if (!t) + return "null intrusive_ptr!!!"; + if (*t) + return "Klass: " + (*t)->getValue(); + else + return "Klass: NULL"; + } + template<> std::string show_message(boost::intrusive_ptr*t) { + if (!t) + return "null intrusive_ptr!!!"; + if (*t) + return "KlassDerived: " + (*t)->getValue(); + else + return "KlassDerived: NULL"; + } + template<> std::string show_message(boost::intrusive_ptr*t) { + if (!t) + return "null intrusive_ptr!!!"; + if (*t) + return "KlassDerived: " + (*t)->getValue(); + else + return "KlassDerived: NULL"; + } + #endif +} +%} + diff --git a/Lib/intrusive_ptr.i b/Lib/intrusive_ptr.i new file mode 100644 index 000000000..9c5f163e5 --- /dev/null +++ b/Lib/intrusive_ptr.i @@ -0,0 +1,97 @@ +// intrusive_ptr namespaces could be boost or std or std::tr1 +#if !defined(SWIG_INTRUSIVE_PTR_NAMESPACE) +# define SWIG_INTRUSIVE_PTR_NAMESPACE boost +#endif + +#if defined(SWIG_INTRUSIVE_PTR_SUBNAMESPACE) +# define SWIG_INTRUSIVE_PTR_QNAMESPACE SWIG_INTRUSIVE_PTR_NAMESPACE::SWIG_INTRUSIVE_PTR_SUBNAMESPACE +#else +# define SWIG_INTRUSIVE_PTR_QNAMESPACE SWIG_INTRUSIVE_PTR_NAMESPACE +#endif + +namespace SWIG_INTRUSIVE_PTR_NAMESPACE { +#if defined(SWIG_INTRUSIVE_PTR_SUBNAMESPACE) + namespace SWIG_INTRUSIVE_PTR_SUBNAMESPACE { +#endif + template class shared_ptr { + }; + + template class intrusive_ptr { + }; +#if defined(SWIG_INTRUSIVE_PTR_SUBNAMESPACE) + } +#endif +} + +%inline %{ + #include "boost/shared_ptr.hpp" +%} + +%fragment("SWIG_intrusive_deleter", "header") { +template struct SWIG_intrusive_deleter +{ + void operator()(T * p) + { + if(p) intrusive_ptr_release(p); + } +}; +} + +%fragment("SWIG_null_deleter", "header") { +struct SWIG_null_deleter { + void operator() (void const *) const { + } +}; +%#define SWIG_NO_NULL_DELETER_0 , SWIG_null_deleter() +%#define SWIG_NO_NULL_DELETER_1 +} + +// Main user macro for defining intrusive_ptr typemaps for both const and non-const pointer types +// For plain classes, do not use for derived classes +%define SWIG_INTRUSIVE_PTR(PROXYCLASS, TYPE...) +SWIG_INTRUSIVE_PTR_TYPEMAPS(PROXYCLASS, , TYPE) +SWIG_INTRUSIVE_PTR_TYPEMAPS(PROXYCLASS, const, TYPE) +%enddef + +// Main user macro for defining intrusive_ptr typemaps for both const and non-const pointer types +// For derived classes +%define SWIG_INTRUSIVE_PTR_DERIVED(PROXYCLASS, BASECLASSTYPE, TYPE...) +SWIG_INTRUSIVE_PTR_TYPEMAPS(PROXYCLASS, , TYPE) +SWIG_INTRUSIVE_PTR_TYPEMAPS(PROXYCLASS, const, TYPE) +%types(SWIG_INTRUSIVE_PTR_NAMESPACE::shared_ptr< TYPE > = SWIG_INTRUSIVE_PTR_NAMESPACE::shared_ptr< BASECLASSTYPE >) %{ + *newmemory = SWIG_CAST_NEW_MEMORY; + return (void *) new SWIG_INTRUSIVE_PTR_NAMESPACE::shared_ptr< BASECLASSTYPE >(*(SWIG_INTRUSIVE_PTR_NAMESPACE::shared_ptr< TYPE > *)$from); + %} +%extend TYPE { + static SWIG_INTRUSIVE_PTR_NAMESPACE::shared_ptr< BASECLASSTYPE > SWIGSharedPtrUpcast(SWIG_INTRUSIVE_PTR_NAMESPACE::shared_ptr< TYPE > swigSharedPtrUpcast) { + return swigSharedPtrUpcast; + } +} +%enddef + +// Extra user macro for including classes in intrusive_ptr typemaps for both const and non-const pointer types +// This caters for classes which cannot be wrapped by intrusive_ptrs but are still part of the class hierarchy +// For plain classes, do not use for derived classes +%define SWIG_INTRUSIVE_PTR_NO_WRAP(PROXYCLASS, TYPE...) +SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP(PROXYCLASS, , TYPE) +SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP(PROXYCLASS, const, TYPE) +%enddef + +// Extra user macro for including classes in intrusive_ptr typemaps for both const and non-const pointer types +// This caters for classes which cannot be wrapped by intrusive_ptrs but are still part of the class hierarchy +// For derived classes +%define SWIG_INTRUSIVE_PTR_DERIVED_NO_WRAP(PROXYCLASS, BASECLASSTYPE, TYPE...) +SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP(PROXYCLASS, , TYPE) +SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP(PROXYCLASS, const, TYPE) +%types(SWIG_INTRUSIVE_PTR_NAMESPACE::shared_ptr< TYPE > = SWIG_INTRUSIVE_PTR_NAMESPACE::shared_ptr< BASECLASSTYPE >) %{ + *newmemory = SWIG_CAST_NEW_MEMORY; + return (void *) new SWIG_INTRUSIVE_PTR_NAMESPACE::shared_ptr< BASECLASSTYPE >(*(SWIG_INTRUSIVE_PTR_NAMESPACE::shared_ptr< TYPE > *)$from); + %} +%extend TYPE { + static SWIG_INTRUSIVE_PTR_NAMESPACE::shared_ptr< BASECLASSTYPE > SWIGSharedPtrUpcast(SWIG_INTRUSIVE_PTR_NAMESPACE::shared_ptr< TYPE > swigSharedPtrUpcast) { + return swigSharedPtrUpcast; + } +} +%enddef + + diff --git a/Lib/java/boost_intrusive_ptr.i b/Lib/java/boost_intrusive_ptr.i new file mode 100644 index 000000000..363451669 --- /dev/null +++ b/Lib/java/boost_intrusive_ptr.i @@ -0,0 +1,456 @@ +%include + +%define SWIG_INTRUSIVE_PTR_TYPEMAPS(PROXYCLASS, CONST, TYPE...) + +%naturalvar TYPE; +%naturalvar SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >; + +// destructor mods +%feature("unref") TYPE "(void)arg1; delete smartarg1;" + + +%typemap(in) CONST TYPE ($&1_type argp = 0, SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{ + // plain value + argp = (*(SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0; + if (!argp) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "Attempt to dereference null $1_type"); + return $null; + } + $1 = *argp; +%} +%typemap(out, fragment="SWIG_intrusive_deleter") CONST TYPE %{ + //plain value(out) + $1_ltype* resultp = new $1_ltype(($1_ltype &)$1); + intrusive_ptr_add_ref(resultp); + *(SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(resultp, SWIG_intrusive_deleter< CONST TYPE >()); +%} + +%typemap(in) CONST TYPE * (SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{ + // plain pointer + smartarg = *(SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input; + $1 = (TYPE *)(smartarg ? smartarg->get() : 0); +%} +%typemap(out, fragment="SWIG_intrusive_deleter,SWIG_null_deleter") CONST TYPE * %{ + //plain pointer(out) + #if ($owner) + if ($1) { + intrusive_ptr_add_ref($1); + *(SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1, SWIG_intrusive_deleter< CONST TYPE >()); + } else { + *(SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0; + } + #else + *(SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = $1 ? new SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_0) : 0; + #endif +%} + +%typemap(in) CONST TYPE & (SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{ + // plain reference + $1 = ($1_ltype)((*(SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0); + if(!$1) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "$1_type reference is null"); + return $null; + } +%} +%typemap(out, fragment="SWIG_intrusive_deleter,SWIG_null_deleter") CONST TYPE & %{ + //plain reference(out) + #if ($owner) + if ($1) { + intrusive_ptr_add_ref($1); + *(SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1, SWIG_intrusive_deleter< CONST TYPE >()); + } else { + *(SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0; + } + #else + *(SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = $1 ? new SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_0) : 0; + #endif +%} + +%typemap(in) CONST TYPE *& ($*1_ltype temp = 0, SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{ + // plain pointer by reference + temp = ((*(SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0); + $1 = &temp; +%} +%typemap(out, fragment="SWIG_intrusive_deleter,SWIG_null_deleter") CONST TYPE *& %{ + // plain pointer by reference(out) + #if ($owner) + if (*$1) { + intrusive_ptr_add_ref(*$1); + *(SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1, SWIG_intrusive_deleter< CONST TYPE >()); + } else { + *(SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0; + } + #else + *(SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_0); + #endif +%} + +%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > ($&1_type argp, SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * smartarg) %{ + // intrusive_ptr by value + smartarg = *(SWIG_INTRUSIVE_PTR_NAMESPACE::shared_ptr< CONST TYPE >**)&$input; + if (smartarg) { + $1 = SWIG_INTRUSIVE_PTR_NAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true); + } +%} +%typemap(out, fragment="SWIG_intrusive_deleter") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > %{ + if ($1) { + intrusive_ptr_add_ref(result.get()); + *(SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(result.get(), SWIG_intrusive_deleter< CONST TYPE >()); + } else { + *(SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0; + } +%} + +%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast ($&1_type smartarg) %{ + // shared_ptr by value + smartarg = *($&1_ltype*)&$input; + if (smartarg) $1 = *smartarg; +%} +%typemap(out) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > ANY_TYPE_SWIGSharedPtrUpcast %{ + *($&1_ltype*)&$result = $1 ? new $1_ltype($1) : 0; +%} + +%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > & ($*1_ltype tempnull, $*1_ltype temp, SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * smartarg) %{ + // intrusive_ptr by reference + if ( $input ) { + smartarg = *(SWIG_INTRUSIVE_PTR_NAMESPACE::shared_ptr< CONST TYPE >**)&$input; + temp = SWIG_INTRUSIVE_PTR_NAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true); + $1 = &temp; + } else { + $1 = &tempnull; + } +%} +%typemap(memberin) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > & %{ + delete &($1); + if ($self) { + SWIG_INTRUSIVE_PTR_NAMESPACE::intrusive_ptr< CONST TYPE > * temp = new SWIG_INTRUSIVE_PTR_NAMESPACE::intrusive_ptr< CONST TYPE >(*$input); + $1 = *temp; + } +%} +%typemap(out, fragment="SWIG_intrusive_deleter") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > & %{ + if (*$1) { + intrusive_ptr_add_ref($1->get()); + *(SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1->get(), SWIG_intrusive_deleter< CONST TYPE >()); + } else { + *(SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0; + } +%} + +%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * ($*1_ltype tempnull, $*1_ltype temp, SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * smartarg) %{ + // intrusive_ptr by pointer + if ( $input ) { + smartarg = *(SWIG_INTRUSIVE_PTR_NAMESPACE::shared_ptr< CONST TYPE >**)&$input; + temp = SWIG_INTRUSIVE_PTR_NAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true); + $1 = &temp; + } else { + $1 = &tempnull; + } +%} +%typemap(memberin) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * %{ + delete $1; + if ($self) $1 = new SWIG_INTRUSIVE_PTR_NAMESPACE::intrusive_ptr< CONST TYPE >(*$input); +%} +%typemap(out, fragment="SWIG_intrusive_deleter") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * %{ + if ($1 && *$1) { + intrusive_ptr_add_ref($1->get()); + *(SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1->get(), SWIG_intrusive_deleter< CONST TYPE >()); + } else { + *(SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0; + } + if ($owner) delete $1; +%} + +%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& (SWIG_INTRUSIVE_PTR_NAMESPACE::intrusive_ptr< CONST TYPE > temp, $*1_ltype tempp = 0, SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * smartarg) %{ + // intrusive_ptr by pointer reference + smartarg = *(SWIG_INTRUSIVE_PTR_NAMESPACE::shared_ptr< CONST TYPE >**)&$input; + if ($input) { + temp = SWIG_INTRUSIVE_PTR_NAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true); + } + tempp = &temp; + $1 = &tempp; +%} +%typemap(memberin) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& %{ + if ($self) $1 = *$input; +%} +%typemap(out, fragment="SWIG_intrusive_deleter") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& %{ + if (*$1 && **$1) { + intrusive_ptr_add_ref((*$1)->get()); + *(SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE >((*$1)->get(), SWIG_intrusive_deleter< CONST TYPE >()); + } else { + *(SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0; + } +%} + +// various missing typemaps - If ever used (unlikely) ensure compilation error rather than runtime bug +%typemap(in) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{ +#error "typemaps for $1_type not available" +%} +%typemap(out) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{ +#error "typemaps for $1_type not available" +%} + + +%typemap (jni) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >, + SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, + SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > &, + SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *, + SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& "jlong" +%typemap (jtype) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >, + SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, + SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > &, + SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *, + SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& "long" +%typemap (jstype) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >, + SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, + SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > &, + SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *, + SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& "PROXYCLASS" +%typemap(javain) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >, + SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, + SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > &, + SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *, + SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& "PROXYCLASS.getCPtr($javainput)" + +%typemap(javaout) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > { + long cPtr = $jnicall; + return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true); + } +%typemap(javaout) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > { + long cPtr = $jnicall; + return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true); + } +%typemap(javaout) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > & { + long cPtr = $jnicall; + return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true); + } +%typemap(javaout) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * { + long cPtr = $jnicall; + return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true); + } +%typemap(javaout) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& { + long cPtr = $jnicall; + return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true); + } + + +%typemap(javaout) CONST TYPE { + return new PROXYCLASS($jnicall, true); + } +%typemap(javaout) CONST TYPE & { + return new PROXYCLASS($jnicall, true); + } +%typemap(javaout) CONST TYPE * { + long cPtr = $jnicall; + return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true); + } +%typemap(javaout) CONST TYPE *& { + long cPtr = $jnicall; + return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true); + } + +// Base proxy classes +%typemap(javabody) TYPE %{ + private long swigCPtr; + private boolean swigCMemOwnBase; + + protected $javaclassname(long cPtr, boolean cMemoryOwn) { + swigCMemOwnBase = cMemoryOwn; + swigCPtr = cPtr; + } + + protected static long getCPtr($javaclassname obj) { + return (obj == null) ? 0 : obj.swigCPtr; + } +%} + +// Derived proxy classes +%typemap(javabody_derived) TYPE %{ + private long swigCPtr; + private boolean swigCMemOwnDerived; + + protected $javaclassname(long cPtr, boolean cMemoryOwn) { + super($imclassname.$javaclassname_SWIGSharedPtrUpcast(cPtr), true); + swigCMemOwnDerived = cMemoryOwn; + swigCPtr = cPtr; + } + + protected static long getCPtr($javaclassname obj) { + return (obj == null) ? 0 : obj.swigCPtr; + } +%} + +%typemap(javadestruct, methodname="delete", methodmodifiers="public synchronized") TYPE { + if(swigCPtr != 0 && swigCMemOwnBase) { + swigCMemOwnBase = false; + $jnicall; + } + swigCPtr = 0; + } + +%typemap(javadestruct_derived, methodname="delete", methodmodifiers="public synchronized") TYPE { + if(swigCPtr != 0 && swigCMemOwnDerived) { + swigCMemOwnDerived = false; + $jnicall; + } + swigCPtr = 0; + super.delete(); + } + +// CONST version needed ???? also for C# +%typemap(jtype, nopgcpp="1") SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< TYPE > swigSharedPtrUpcast "long" +%typemap(jtype, nopgcpp="1") SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast "long" + + +%template() SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; +%template() SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >; +%enddef + + +///////////////////////////////////////////////////////////////////// + + +%include + +%define SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP(PROXYCLASS, CONST, TYPE...) + +%naturalvar TYPE; +%naturalvar SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; + +// destructor mods +%feature("unref") TYPE "(void)arg1; delete smartarg1;" + + +// plain value +%typemap(in) CONST TYPE ($&1_type argp = 0) %{ + argp = (*(SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0; + if (!argp) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "Attempt to dereference null $1_type"); + return $null; + } + $1 = *argp; %} +%typemap(out) CONST TYPE +%{ *(SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1)); %} + +// plain pointer +%typemap(in) CONST TYPE * (SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{ + smartarg = *(SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input; + $1 = (TYPE *)(smartarg ? smartarg->get() : 0); %} +%typemap(out, fragment="SWIG_null_deleter") CONST TYPE * %{ + *(SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = $1 ? new SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner) : 0; +%} + +// plain reference +%typemap(in) CONST TYPE & %{ + $1 = ($1_ltype)((*(SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0); + if(!$1) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "$1_type reference is null"); + return $null; + } %} +%typemap(out, fragment="SWIG_null_deleter") CONST TYPE & +%{ *(SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner); %} + +// plain pointer by reference +%typemap(in) CONST TYPE *& ($*1_ltype temp = 0) +%{ temp = ((*(SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0); + $1 = &temp; %} +%typemap(out, fragment="SWIG_null_deleter") CONST TYPE *& +%{ *(SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_$owner); %} + +%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast ($&1_type smartarg) %{ + // shared_ptr by value + smartarg = *($&1_ltype*)&$input; + if (smartarg) $1 = *smartarg; +%} +%typemap(out) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > ANY_TYPE_SWIGSharedPtrUpcast %{ + *($&1_ltype*)&$result = $1 ? new $1_ltype($1) : 0; +%} + +// various missing typemaps - If ever used (unlikely) ensure compilation error rather than runtime bug +%typemap(in) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{ +#error "typemaps for $1_type not available" +%} +%typemap(out) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{ +#error "typemaps for $1_type not available" +%} + + +%typemap (jni) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > "jlong" +%typemap (jtype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > "long" +%typemap (jstype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > "PROXYCLASS" +%typemap (javain) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > "PROXYCLASS.getCPtr($javainput)" +%typemap(javaout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > { + long cPtr = $jnicall; + return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true); + } + +%typemap(javaout) CONST TYPE { + return new PROXYCLASS($jnicall, true); + } +%typemap(javaout) CONST TYPE & { + return new PROXYCLASS($jnicall, true); + } +%typemap(javaout) CONST TYPE * { + long cPtr = $jnicall; + return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true); + } +%typemap(javaout) CONST TYPE *& { + long cPtr = $jnicall; + return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true); + } + +// Base proxy classes +%typemap(javabody) TYPE %{ + private long swigCPtr; + private boolean swigCMemOwnBase; + + protected $javaclassname(long cPtr, boolean cMemoryOwn) { + swigCMemOwnBase = cMemoryOwn; + swigCPtr = cPtr; + } + + protected static long getCPtr($javaclassname obj) { + return (obj == null) ? 0 : obj.swigCPtr; + } +%} + +// Derived proxy classes +%typemap(javabody_derived) TYPE %{ + private long swigCPtr; + private boolean swigCMemOwnDerived; + + protected $javaclassname(long cPtr, boolean cMemoryOwn) { + super($imclassname.$javaclassname_SWIGSharedPtrUpcast(cPtr), true); + swigCMemOwnDerived = cMemoryOwn; + swigCPtr = cPtr; + } + + protected static long getCPtr($javaclassname obj) { + return (obj == null) ? 0 : obj.swigCPtr; + } +%} + +%typemap(javadestruct, methodname="delete", methodmodifiers="public synchronized") TYPE { + if(swigCPtr != 0 && swigCMemOwnBase) { + swigCMemOwnBase = false; + $jnicall; + } + swigCPtr = 0; + } + +%typemap(javadestruct_derived, methodname="delete", methodmodifiers="public synchronized") TYPE { + if(swigCPtr != 0 && swigCMemOwnDerived) { + swigCMemOwnDerived = false; + $jnicall; + } + swigCPtr = 0; + super.delete(); + } + +// CONST version needed ???? also for C# +%typemap(jtype, nopgcpp="1") SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< TYPE > swigSharedPtrUpcast "long" +%typemap(jtype, nopgcpp="1") SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast "long" + + +%template() SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; +%enddef + From fa2289e4c32ad438c919269e7db63e106d853b3b Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 28 Dec 2008 20:35:22 +0000 Subject: [PATCH 0253/1680] li_intrusive_ptr test - commented out as not fully working git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11009 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/java/Makefile.in | 1 + 1 file changed, 1 insertion(+) diff --git a/Examples/test-suite/java/Makefile.in b/Examples/test-suite/java/Makefile.in index a2986258e..03c10d498 100644 --- a/Examples/test-suite/java/Makefile.in +++ b/Examples/test-suite/java/Makefile.in @@ -32,6 +32,7 @@ CPP_TEST_CASES = \ java_throws \ java_typemaps_proxy \ java_typemaps_typewrapper +# li_boost_intrusive_ptr include $(srcdir)/../common.mk From 9db99bfb3e0ddf7f11eea8dbb35a1ca6b405a61a Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 28 Dec 2008 20:36:21 +0000 Subject: [PATCH 0254/1680] comment correction git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11010 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/java_throws.i | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/test-suite/java_throws.i b/Examples/test-suite/java_throws.i index efa7da571..b020fefcb 100644 --- a/Examples/test-suite/java_throws.i +++ b/Examples/test-suite/java_throws.i @@ -178,6 +178,6 @@ struct NoExceptTest { }; %} -// Turn global exceptions off (for the implicit destructors) +// Turn global exceptions off (for the implicit destructors/constructors) %nojavaexception; From 0f89bff13a746f9be41605fcf56ee5902168f75d Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 29 Dec 2008 00:11:51 +0000 Subject: [PATCH 0255/1680] Compiler warning fix in Perl out typemap for std::vector git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11011 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/ignore_template_constructor.i | 6 ++++++ Lib/perl5/std_vector.i | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Examples/test-suite/ignore_template_constructor.i b/Examples/test-suite/ignore_template_constructor.i index 5225d5183..ffd541986 100644 --- a/Examples/test-suite/ignore_template_constructor.i +++ b/Examples/test-suite/ignore_template_constructor.i @@ -37,3 +37,9 @@ public: #endif %template(VectFlow) std::vector; + +%inline %{ +std::vector inandout(std::vector v) { + return v; +} +%} diff --git a/Lib/perl5/std_vector.i b/Lib/perl5/std_vector.i index b1f722d4b..7c4f72919 100644 --- a/Lib/perl5/std_vector.i +++ b/Lib/perl5/std_vector.i @@ -105,9 +105,9 @@ namespace std { } } %typemap(out) vector { - int len = $1.size(); + size_t len = $1.size(); SV **svs = new SV*[len]; - for (unsigned int i=0; i Date: Mon, 29 Dec 2008 00:13:19 +0000 Subject: [PATCH 0256/1680] couple of minor Perl fixes from Ling Li git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11012 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/perl5/noembed.h | 4 +++- Lib/perl5/perltypemaps.swg | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Lib/perl5/noembed.h b/Lib/perl5/noembed.h index 8d3dc7338..55c3752aa 100644 --- a/Lib/perl5/noembed.h +++ b/Lib/perl5/noembed.h @@ -94,4 +94,6 @@ #ifdef readdir #undef readdir #endif - +#ifdef bind + #undef bind +#endif diff --git a/Lib/perl5/perltypemaps.swg b/Lib/perl5/perltypemaps.swg index c17e410b9..a59f84689 100644 --- a/Lib/perl5/perltypemaps.swg +++ b/Lib/perl5/perltypemaps.swg @@ -43,6 +43,7 @@ /* Perl types */ #define SWIG_Object SV * +#define VOID_Object sv_newmortal() /* Perl $shadow flag */ #define %newpointer_flags $shadow From a9749f3cd7b5a1d236bc1447dc8136b5b3265061 Mon Sep 17 00:00:00 2001 From: Joseph Wang Date: Mon, 29 Dec 2008 07:05:21 +0000 Subject: [PATCH 0257/1680] check for yodl package git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11013 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- configure.in | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/configure.in b/configure.in index 749d95197..a53566d72 100644 --- a/configure.in +++ b/configure.in @@ -31,6 +31,12 @@ AC_PROG_RANLIB AM_PROG_CC_C_O # Needed for subdir-objects in AUTOMAKE_OPTIONS AC_CHECK_PROGS(AR, ar aal, ar) AC_SUBST(AR) +AC_CHECK_PROGS(YODL2MAN, yodl2man) +AC_CHECK_PROGS(YODL2HTML, yodl2html) + +if test -z "$YODL2MAN" +then AC_MSG_ERROR([cannot find yodl executable yodl2man]) +fi AC_COMPILE_WARNINGS # Increase warning levels From 68710cf9d0a03c19864712343c7d4baa595aae0b Mon Sep 17 00:00:00 2001 From: Joseph Wang Date: Mon, 29 Dec 2008 22:06:50 +0000 Subject: [PATCH 0258/1680] allow for compilation with bison 2.4 which is more restrictive about $$ symbols than 2.3 git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11014 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/CParse/parser.y | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index 8ee56a246..a6635ade9 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -3230,15 +3230,15 @@ cpp_class_decl : storage_class cpptype idcolon inherit LBRACE { List *bases = 0; Node *scope = 0; - $$ = new_node("class"); - Setline($$,cparse_start_line); - Setattr($$,"kind",$2); + $$ = new_node("class"); + Setline($$,cparse_start_line); + Setattr($$,"kind",$2); if ($4) { - Setattr($$,"baselist", Getattr($4,"public")); - Setattr($$,"protectedbaselist", Getattr($4,"protected")); - Setattr($$,"privatebaselist", Getattr($4,"private")); + Setattr($$,"baselist", Getattr($4,"public")); + Setattr($$,"protectedbaselist", Getattr($4,"protected")); + Setattr($$,"privatebaselist", Getattr($4,"private")); } - Setattr($$,"allows_typedef","1"); + Setattr($$,"allows_typedef","1"); /* preserve the current scope */ prev_symtab = Swig_symbol_current(); @@ -3267,10 +3267,10 @@ cpp_class_decl : nscope_inner = 0; } } - Setattr($$,"name",$3); + Setattr($$,"name",$3); Delete(class_rename); - class_rename = make_name($$,$3,0); + class_rename = make_name($$,$3,0); Classprefix = NewString($3); /* Deal with inheritance */ if ($4) { @@ -3339,7 +3339,7 @@ cpp_class_decl : Swig_error(cparse_file, cparse_line, "realloc() failed\n"); } } - class_decl[class_level++] = $$; + class_decl[class_level++] = $$; inclass = 1; } cpp_members RBRACE cpp_opt_declarators { Node *p; @@ -3462,14 +3462,14 @@ cpp_class_decl : | storage_class cpptype LBRACE { String *unnamed; unnamed = make_unnamed(); - $$ = new_node("class"); - Setline($$,cparse_start_line); - Setattr($$,"kind",$2); - Setattr($$,"storage",$1); - Setattr($$,"unnamed",unnamed); - Setattr($$,"allows_typedef","1"); + $$ = new_node("class"); + Setline($$,cparse_start_line); + Setattr($$,"kind",$2); + Setattr($$,"storage",$1); + Setattr($$,"unnamed",unnamed); + Setattr($$,"allows_typedef","1"); Delete(class_rename); - class_rename = make_name($$,0,0); + class_rename = make_name($$,0,0); if (strcmp($2,"class") == 0) { cplus_mode = CPLUS_PRIVATE; } else { @@ -3488,7 +3488,7 @@ cpp_class_decl : Swig_error(cparse_file, cparse_line, "realloc() failed\n"); } } - class_decl[class_level++] = $$; + class_decl[class_level++] = $$; inclass = 1; Classprefix = NewStringEmpty(); Delete(Namespaceprefix); From 67e2785cb7c928ed6d925342c15403d91fa71bed Mon Sep 17 00:00:00 2001 From: Joseph Wang Date: Mon, 29 Dec 2008 22:25:55 +0000 Subject: [PATCH 0259/1680] change as(...,"integer") to as.integer to force conversion into integers git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11015 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/r/rtype.swg | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Lib/r/rtype.swg b/Lib/r/rtype.swg index 9206b5e3e..043b7487d 100644 --- a/Lib/r/rtype.swg +++ b/Lib/r/rtype.swg @@ -35,15 +35,18 @@ INTSXP. */ +/* Force coercion of integer, since by default R sets all constants to + numeric, which means that you can't directly call a function with an + integer using an R numercal literal */ %typemap(scoercein) int, int *, int & - %{ $input = as($input, "integer"); %} + %{ $input = as.integer($input); %} %typemap(scoercein) ptrdiff_t, ptrdiff_t *, ptrdiff_t & - %{ $input = as($input, "integer"); %} + %{ $input = as.integer($input); %} %typemap(scoercein) unsigned long, unsigned long *, unsigned long & - %{ $input = as($input, "integer"); %} + %{ $input = as.integer($input); %} %typemap(scoercein) unsigned int, unsigned int *, unsigned int & - %{ $input = as($input, "integer"); %} + %{ $input = as.integer($input); %} %typemap(scoercein) double, double *, double & %{ %} %typemap(scoercein) float, float *, float & From cc522323d76225a7226c4c33796ef3778b9960b8 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 29 Dec 2008 22:56:25 +0000 Subject: [PATCH 0260/1680] create a common banner header for all target language specific files git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11016 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/allegrocl.cxx | 38 +++++++++++++++++++----------------- Source/Modules/cffi.cxx | 21 +++++++++++--------- Source/Modules/chicken.cxx | 7 +++---- Source/Modules/clisp.cxx | 9 +++++---- Source/Modules/csharp.cxx | 6 +----- Source/Modules/guile.cxx | 9 ++++----- Source/Modules/java.cxx | 6 +----- Source/Modules/modula3.cxx | 11 +++-------- Source/Modules/mzscheme.cxx | 1 - Source/Modules/ocaml.cxx | 5 ++--- Source/Modules/octave.cxx | 2 ++ Source/Modules/perl5.cxx | 5 +---- Source/Modules/python.cxx | 5 +---- Source/Modules/r.cxx | 5 ++--- Source/Modules/s-exp.cxx | 3 +++ Source/Modules/tcl8.cxx | 5 +---- Source/Modules/uffi.cxx | 6 ++++-- Source/Swig/misc.c | 17 +++++++++++++++- Source/Swig/swig.h | 1 + 19 files changed, 82 insertions(+), 80 deletions(-) diff --git a/Source/Modules/allegrocl.cxx b/Source/Modules/allegrocl.cxx index 5748a082b..daf19c29a 100644 --- a/Source/Modules/allegrocl.cxx +++ b/Source/Modules/allegrocl.cxx @@ -21,7 +21,7 @@ char cvsroot_allegrocl_cxx[] = "$Id$"; static File *f_cl = 0; String *f_clhead = NewString(""); String *f_clwrap = NewString("(swig-in-package ())\n\n"); -static File *f_cxx; +static File *f_runtime; static File *f_cxx_header = 0; static File *f_cxx_wrapper = 0; @@ -1599,27 +1599,29 @@ int ALLEGROCL::top(Node *n) { Generate_Wrapper = CPlusPlus || CWrap; if (Generate_Wrapper) { - f_cxx = NewFile(cxx_filename, "w", SWIG_output_files()); - if (!f_cxx) { + f_runtime = NewFile(cxx_filename, "w", SWIG_output_files()); + if (!f_runtime) { Close(f_cl); Delete(f_cl); Printf(stderr, "Unable to open %s for writing\n", cxx_filename); SWIG_exit(EXIT_FAILURE); } } else - f_cxx = NewString(""); + f_runtime = NewString(""); - f_cxx_header = f_cxx; + f_cxx_header = f_runtime; f_cxx_wrapper = NewString(""); Swig_register_filebyname("header", f_cxx_header); Swig_register_filebyname("wrapper", f_cxx_wrapper); - Swig_register_filebyname("runtime", f_cxx); + Swig_register_filebyname("runtime", f_runtime); Swig_register_filebyname("lisp", f_clwrap); Swig_register_filebyname("lisphead", f_cl); - Printf(f_cl, ";; This is an automatically generated file. Make changes in\n" - ";; the definition file, not here.\n\n" + Swig_banner(f_runtime); + Swig_banner_target_lang(f_cl, ";;"); + + Printf(f_cl, "\n" "(defpackage :%s\n" " (:use :common-lisp :ff :excl)\n" " (:export #:*swig-identifier-converter* #:*swig-module-name*\n" @@ -1636,7 +1638,7 @@ int ALLEGROCL::top(Node *n) { Language::top(n); - // SwigType_emit_type_table(f_cxx,f_cxx_wrapper); + // SwigType_emit_type_table(f_runtime,f_cxx_wrapper); // Swig_print_tree(n); #ifdef ALLEGROCL_TYPE_DEBUG @@ -1659,10 +1661,10 @@ int ALLEGROCL::top(Node *n) { Delete(f_clhead); Delete(f_clwrap); - Printf(f_cxx, "%s\n", f_cxx_wrapper); + Printf(f_runtime, "%s\n", f_cxx_wrapper); - Close(f_cxx); - Delete(f_cxx); + Close(f_runtime); + Delete(f_runtime); Delete(f_cxx_wrapper); // Swig_print_tree(n); @@ -2803,8 +2805,8 @@ int ALLEGROCL::constantWrapper(Node *n) { SwigType_add_qualifier(const_type, "static"); String *ppcname = NewStringf("ACLppc_%s", Getattr(n, "sym:name")); - // Printf(f_cxx, "static const %s = %s;\n", SwigType_lstr(const_type, ppcname), const_val); - Printf(f_cxx, "%s = %s;\n", SwigType_lstr(const_type, ppcname), const_val); + // Printf(f_runtime, "static const %s = %s;\n", SwigType_lstr(const_type, ppcname), const_val); + Printf(f_runtime, "%s = %s;\n", SwigType_lstr(const_type, ppcname), const_val); Setattr(n, "name", ppcname); SetFlag(n, "feature:immutable"); @@ -2861,7 +2863,7 @@ int ALLEGROCL::globalvariableHandler(Node *n) { ctype = SwigType_str(type, 0); // EXPORT ; // = ; - // Printf(f_cxx, "EXPORT %s %s;\n%s %s = %s%s;\n", ctype, mangled_name, + // Printf(f_runtime, "EXPORT %s %s;\n%s %s = %s%s;\n", ctype, mangled_name, // ctype, mangled_name, (pointer_added ? "&" : ""), name); Printf(f_clwrap, "(swig-defvar \"%s\" \"%s\" :type %s)\n", @@ -2900,12 +2902,12 @@ int ALLEGROCL::variableWrapper(Node *n) { // EXPORT ; // = ; - Printf(f_cxx, "EXPORT %s %s;\n%s %s = %s%s;\n", ctype, mangled_name, ctype, mangled_name, (pointer_added ? "&" : ""), name); + 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_cxx, "// swigtype: %s\n", SwigType_typedef_resolve_all(Getattr(n,"type"))); - Printf(f_cxx, "// vwrap: %s\n", compose_foreign_type(SwigType_strip_qualifiers(Copy(rtype)))); + 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"); diff --git a/Source/Modules/cffi.cxx b/Source/Modules/cffi.cxx index 9d9991ea5..717550ee0 100644 --- a/Source/Modules/cffi.cxx +++ b/Source/Modules/cffi.cxx @@ -22,7 +22,7 @@ public: String *f_clhead; String *f_clwrap; bool CWrap; // generate wrapper file for C code? - File *f_cxx; + File *f_runtime; File *f_cxx_header; File *f_cxx_wrapper; File *f_clos; @@ -126,8 +126,8 @@ int CFFI::top(Node *n) { } if (CPlusPlus || CWrap) { - f_cxx = NewFile(cxx_filename, "w", SWIG_output_files()); - if (!f_cxx) { + f_runtime = NewFile(cxx_filename, "w", SWIG_output_files()); + if (!f_runtime) { Close(f_lisp); Delete(f_lisp); Printf(stderr, "Unable to open %s for writing\n", cxx_filename); @@ -144,22 +144,25 @@ int CFFI::top(Node *n) { SWIG_exit(EXIT_FAILURE); } } else { - f_cxx = NewString(""); + f_runtime = NewString(""); f_clos = NewString(""); } - f_cxx_header = f_cxx; + f_cxx_header = f_runtime; f_cxx_wrapper = NewString(""); Swig_register_filebyname("header", f_cxx_header); Swig_register_filebyname("wrapper", f_cxx_wrapper); - Swig_register_filebyname("runtime", f_cxx); + Swig_register_filebyname("runtime", f_runtime); Swig_register_filebyname("lisphead", f_clhead); if (!no_swig_lisp) Swig_register_filebyname("swiglisp", f_cl); else Swig_register_filebyname("swiglisp", f_null); + Swig_banner(f_runtime); + Swig_banner_target_lang(f_lisp, ";;;"); + Language::top(n); Printf(f_lisp, "%s\n", f_clhead); Printf(f_lisp, "%s\n", f_cl); @@ -170,8 +173,8 @@ int CFFI::top(Node *n) { Delete(f_cl); Delete(f_clhead); Delete(f_clwrap); - Close(f_cxx); - Delete(f_cxx); + Close(f_runtime); + Delete(f_runtime); Delete(f_cxx_wrapper); Delete(f_null); @@ -454,7 +457,7 @@ int CFFI::functionWrapper(Node *n) { Printf(f->code, "}\n"); if (CPlusPlus) - Wrapper_print(f, f_cxx); + Wrapper_print(f, f_runtime); if (CPlusPlus) { emit_defun(n, wname); diff --git a/Source/Modules/chicken.cxx b/Source/Modules/chicken.cxx index 5ca340f04..05c9ccc3f 100644 --- a/Source/Modules/chicken.cxx +++ b/Source/Modules/chicken.cxx @@ -215,7 +215,6 @@ int CHICKEN::top(Node *n) { clos_methods = NewString(""); scm_const_defs = NewString(""); - Printf(f_runtime, "/* -*- buffer-read-only: t -*- vi: set ro: */\n"); Swig_banner(f_runtime); Printf(f_runtime, "/* Implementation : CHICKEN */\n\n"); @@ -256,9 +255,9 @@ int CHICKEN::top(Node *n) { SWIG_exit(EXIT_FAILURE); } - Printv(f_scm, - ";; -*- buffer-read-only: t -*- vi: set ro:\n", - ";; This file was created automatically by SWIG.\n", ";; Don't modify this file, modify the SWIG interface instead.\n", NIL); + Swig_banner_target_lang(f_scm, ";;"); + Printf(f_scm, "\n"); + if (declare_unit) Printv(f_scm, "(declare (unit ", scmmodule, "))\n\n", NIL); Printv(f_scm, "(declare \n", diff --git a/Source/Modules/clisp.cxx b/Source/Modules/clisp.cxx index 5275b9899..29dc4fddc 100644 --- a/Source/Modules/clisp.cxx +++ b/Source/Modules/clisp.cxx @@ -89,10 +89,11 @@ int CLISP::top(Node *n) { Swig_register_filebyname("runtime", f_null); Swig_register_filebyname("wrapper", f_null); - String *header = - NewStringf - (";; This is an automatically generated file. \n;;Make changes as you feel are necessary (but remember if you try to regenerate this file, your changes will be lost). \n\n(defpackage :%s\n (:use :common-lisp :ffi)", - module); + String *header = NewString(""); + + Swig_banner_target_lang(header, ";;"); + + Printf(header, "\n(defpackage :%s\n (:use :common-lisp :ffi)", module); Language::top(n); diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index 19e006a2a..2a75322ea 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -601,11 +601,7 @@ public: void emitBanner(File *f) { Printf(f, "/* ----------------------------------------------------------------------------\n"); - Printf(f, " * This file was automatically generated by SWIG (http://www.swig.org).\n"); - Printf(f, " * Version %s\n", Swig_package_version()); - Printf(f, " *\n"); - Printf(f, " * Do not make changes to this file unless you know what you are doing--modify\n"); - Printf(f, " * the SWIG interface file instead.\n"); + Swig_banner_target_lang(f, " *"); Printf(f, " * ----------------------------------------------------------------------------- */\n\n"); } diff --git a/Source/Modules/guile.cxx b/Source/Modules/guile.cxx index df0540235..e3f4fe711 100644 --- a/Source/Modules/guile.cxx +++ b/Source/Modules/guile.cxx @@ -322,7 +322,6 @@ public: goopscode = NewString(""); goopsexport = NewString(""); - Printf(f_runtime, "/* -*- buffer-read-only: t -*- vi: set ro: */\n"); Swig_banner(f_runtime); Printf(f_runtime, "/* Implementation : GUILE */\n\n"); @@ -506,8 +505,8 @@ public: } Delete(fname); - Printf(scmstubfile, ";;; -*- buffer-read-only: t -*- vi: set ro: */\n"); - Printf(scmstubfile, ";;; Automatically generated by SWIG; do not edit.\n\n"); + Swig_banner_target_lang(scmstubfile, ";;;"); + Printf(scmstubfile, "\n"); if (linkage == GUILE_LSTYLE_SIMPLE || linkage == GUILE_LSTYLE_PASSIVE) Printf(scmstubfile, "(define-module (%s))\n\n", mod); Delete(mod); @@ -536,8 +535,8 @@ public: SWIG_exit(EXIT_FAILURE); } Delete(fname); - Printf(goopsfile, ";;; -*- buffer-read-only: t -*- vi: set ro: */\n"); - Printf(goopsfile, ";;; Automatically generated by SWIG; do not edit.\n\n"); + Swig_banner_target_lang(goopsfile, ";;;"); + Printf(goopsfile, "\n"); Printf(goopsfile, "(define-module (%s))\n", mod); Printf(goopsfile, "%s\n", goopstext); Printf(goopsfile, "(use-modules (oop goops) (Swig common))\n"); diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index 742756f63..f7773a2ef 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -673,11 +673,7 @@ public: void emitBanner(File *f) { Printf(f, "/* ----------------------------------------------------------------------------\n"); - Printf(f, " * This file was automatically generated by SWIG (http://www.swig.org).\n"); - Printf(f, " * Version %s\n", Swig_package_version()); - Printf(f, " *\n"); - Printf(f, " * Do not make changes to this file unless you know what you are doing--modify\n"); - Printf(f, " * the SWIG interface file instead.\n"); + Swig_banner_target_lang(f, " *"); Printf(f, " * ----------------------------------------------------------------------------- */\n\n"); } diff --git a/Source/Modules/modula3.cxx b/Source/Modules/modula3.cxx index 3f9109082..b378c0979 100644 --- a/Source/Modules/modula3.cxx +++ b/Source/Modules/modula3.cxx @@ -1159,14 +1159,9 @@ MODULA3(): * ----------------------------------------------------------------------------- */ void emitBanner(File *f) { - Printf(f, "\ -(*******************************************************************************\n\ - * This file was automatically generated by SWIG (http://www.swig.org/).\n\ - * Version %s\n\ - *\n\ - * Do not make changes to this file unless you know what you are doing --\n\ - * modify the SWIG interface file instead.\n\ - *******************************************************************************)\n\n", Swig_package_version()); + Printf(f, "(*******************************************************************************\n"); + Swig_banner_target_lang(f, " *"); + Printf(f, "*******************************************************************************)\n\n"); } /* ---------------------------------------------------------------------- diff --git a/Source/Modules/mzscheme.cxx b/Source/Modules/mzscheme.cxx index b0bfbf5ef..9481ba1ee 100644 --- a/Source/Modules/mzscheme.cxx +++ b/Source/Modules/mzscheme.cxx @@ -146,7 +146,6 @@ public: init_func_def = NewString(""); Swig_register_filebyname("init", init_func_def); - Printf(f_runtime, "/* -*- buffer-read-only: t -*- vi: set ro: */\n"); Swig_banner(f_runtime); module = Getattr(n, "name"); diff --git a/Source/Modules/ocaml.cxx b/Source/Modules/ocaml.cxx index 5c0e4b134..9a974888b 100644 --- a/Source/Modules/ocaml.cxx +++ b/Source/Modules/ocaml.cxx @@ -262,7 +262,8 @@ public: Swig_name_register("get", "%v__get__"); } - Printf(f_runtime, "/* -*- buffer-read-only: t -*- vi: set ro: */\n"); + Swig_banner(f_runtime); + Printf(f_runtime, "#define SWIG_MODULE \"%s\"\n", module); /* Module name */ Printf(f_mlbody, "let module_name = \"%s\"\n", module); @@ -276,8 +277,6 @@ public: Printf(f_int_to_enum, "let int_to_enum x y =\n" " match (x : c_enum_type) with\n" " `unknown -> C_enum (`Int y)\n"); - Swig_banner(f_runtime); - if (directorsEnabled()) { Printf(f_runtime, "#define SWIG_DIRECTORS\n"); } diff --git a/Source/Modules/octave.cxx b/Source/Modules/octave.cxx index 5e3cc9d08..3a5ca5ed8 100644 --- a/Source/Modules/octave.cxx +++ b/Source/Modules/octave.cxx @@ -108,7 +108,9 @@ public: Swig_register_filebyname("initbeforefunc", f_initbeforefunc); Swig_register_filebyname("director", f_directors); Swig_register_filebyname("director_h", f_directors_h); + Swig_banner(f_runtime); + Printf(f_runtime, "#define SWIG_name_d \"%s\"\n", module); Printf(f_runtime, "#define SWIG_name %s\n", module); diff --git a/Source/Modules/perl5.cxx b/Source/Modules/perl5.cxx index fd8a03590..5a21e835a 100644 --- a/Source/Modules/perl5.cxx +++ b/Source/Modules/perl5.cxx @@ -332,10 +332,7 @@ public: Delete(boot_name); } - Printf(f_pm, "# This file was automatically generated by SWIG (http://www.swig.org).\n"); - Printf(f_pm, "# Version %s\n", Swig_package_version()); - Printf(f_pm, "#\n"); - Printf(f_pm, "# Don't modify this file, modify the SWIG interface instead.\n"); + Swig_banner_target_lang(f_pm, "#"); Printf(f_pm, "\n"); Printf(f_pm, "package %s;\n", module); diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 1a2cf4f16..81e0d0b38 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -676,10 +676,7 @@ public: Swig_register_filebyname("shadow", f_shadow); Swig_register_filebyname("python", f_shadow); - Printf(f_shadow, "# This file was automatically generated by SWIG (http://www.swig.org).\n"); - Printf(f_shadow, "# Version %s\n", Swig_package_version()); - Printf(f_shadow, "#\n"); - Printf(f_shadow, "# Don't modify this file, modify the SWIG interface instead.\n"); + Swig_banner_target_lang(f_shadow, "#"); if (!modern) { Printv(f_shadow, "# This file is compatible with both classic and new-style classes.\n", NIL); diff --git a/Source/Modules/r.cxx b/Source/Modules/r.cxx index 26b83adea..998e80f14 100644 --- a/Source/Modules/r.cxx +++ b/Source/Modules/r.cxx @@ -819,8 +819,7 @@ int R::top(Node *n) { Swig_register_filebyname("sclasses", s_classes); - - Printf(s_init, "# This is an automatically generated file by the R module for SWIG.\n\n"); + Swig_banner_target_lang(s_init, "#"); outputCommandLineArguments(s_init); Printf(f_wrapper, "#ifdef __cplusplus\n"); @@ -2659,7 +2658,7 @@ int R::outputCommandLineArguments(File *out) if(Argc < 1 || !Argv || !Argv[0]) return(-1); - Printf(out, "## Generated via the command line invocation:\n##\t"); + Printf(out, "\n## Generated via the command line invocation:\n##\t"); for(int i = 0; i < Argc ; i++) { Printf(out, " %s", Argv[i]); } diff --git a/Source/Modules/s-exp.cxx b/Source/Modules/s-exp.cxx index b492a2add..833ed49aa 100644 --- a/Source/Modules/s-exp.cxx +++ b/Source/Modules/s-exp.cxx @@ -71,7 +71,10 @@ public: Swig_register_filebyname("runtime", f_sink); Swig_register_filebyname("init", f_sink); + Swig_banner_target_lang(out, ";;;"); + Language::top(n); + Printf(out, "\n"); Printf(out, ";;; Lisp parse tree produced by SWIG\n"); print_circle_hash = DohNewHash(); print_circle_count = 0; diff --git a/Source/Modules/tcl8.cxx b/Source/Modules/tcl8.cxx index fe21cb78a..b4b57fc0f 100644 --- a/Source/Modules/tcl8.cxx +++ b/Source/Modules/tcl8.cxx @@ -186,10 +186,7 @@ public: Swig_register_filebyname("shadow", f_shadow); Swig_register_filebyname("itcl", f_shadow); - Printf(f_shadow, "# This file was automatically generated by SWIG (http://www.swig.org).\n"); - Printf(f_shadow, "# Version %s\n", Swig_package_version()); - Printf(f_shadow, "#\n"); - Printf(f_shadow, "# Don't modify this file, modify the SWIG interface instead.\n"); + Swig_banner_target_lang(f_shadow, "#"); Printv(f_shadow, "\npackage require Itcl\n\n", NIL); Delete(filen); diff --git a/Source/Modules/uffi.cxx b/Source/Modules/uffi.cxx index 84155cf2a..693ee0a58 100644 --- a/Source/Modules/uffi.cxx +++ b/Source/Modules/uffi.cxx @@ -239,8 +239,10 @@ int UFFI::top(Node *n) { Swig_register_filebyname("runtime", f_null); Swig_register_filebyname("wrapper", f_cl); - Printf(f_cl, - ";; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10; package: %s -*-\n;; This is an automatically generated file. Make changes in\n;; the definition file, not here.\n\n(defpackage :%s\n (:use :common-lisp :uffi))\n\n(in-package :%s)\n", + Swig_banner_target_lang(f_cl, ";;"); + + Printf(f_cl, "\n" + ";; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10; package: %s -*-\n\n(defpackage :%s\n (:use :common-lisp :uffi))\n\n(in-package :%s)\n", module, module, module); Printf(f_cl, "(eval-when (compile load eval)\n (defparameter *swig-identifier-converter* '%s))\n", identifier_converter); diff --git a/Source/Swig/misc.c b/Source/Swig/misc.c index 4f21d0848..9e8de8c78 100644 --- a/Source/Swig/misc.c +++ b/Source/Swig/misc.c @@ -54,7 +54,7 @@ const char *Swig_package_version(void) { /* ----------------------------------------------------------------------------- * Swig_banner() * - * Emits the SWIG identifying banner. + * Emits the SWIG identifying banner for the C/C++ wrapper file. * ----------------------------------------------------------------------------- */ void Swig_banner(File *f) { @@ -71,6 +71,20 @@ void Swig_banner(File *f) { } +/* ----------------------------------------------------------------------------- + * Swig_banner_target_lang() + * + * Emits a SWIG identifying banner in the target language + * ----------------------------------------------------------------------------- */ + +void Swig_banner_target_lang(File *f, const String_or_char *commentchar) { + Printf(f, "%s This file was automatically generated by SWIG (http://www.swig.org).\n", commentchar); + Printf(f, "%s Version %s\n", commentchar, Swig_package_version()); + Printf(f, "%s\n", commentchar); + Printf(f, "%s Do not make changes to this file unless you know what you are doing--modify\n", commentchar); + Printf(f, "%s the SWIG interface file instead.\n", commentchar); +} + /* ----------------------------------------------------------------------------- * Swig_strip_c_comments() * @@ -124,6 +138,7 @@ String *Swig_strip_c_comments(const String *s) { * ----------------------------------------------------------------------------- */ void Swig_filename_correct(String *filename) { + (void)filename; #if defined(_WIN32) || defined(MACSWIG) /* accept Unix path separator on non-Unix systems */ Replaceall(filename, "/", SWIG_FILE_DELIMITER); diff --git a/Source/Swig/swig.h b/Source/Swig/swig.h index c93740902..356498511 100644 --- a/Source/Swig/swig.h +++ b/Source/Swig/swig.h @@ -285,6 +285,7 @@ extern int ParmList_is_compactdefargs(ParmList *p); extern void Swig_set_fakeversion(const char *version); extern const char *Swig_package_version(void); extern void Swig_banner(File *f); + extern void Swig_banner_target_lang(File *f, const String_or_char *commentchar); extern String *Swig_strip_c_comments(const String *s); extern String *Swig_filename_escape(String *filename); extern void Swig_filename_correct(String *filename); From d2f69e6a343f3e6869d6f99926869d629bc89f99 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 29 Dec 2008 23:56:03 +0000 Subject: [PATCH 0261/1680] add missing language specific preprocessor define where missing for some languages git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11017 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/allegrocl.cxx | 3 +-- Source/Modules/cffi.cxx | 1 + Source/Modules/clisp.cxx | 1 + Source/Modules/r.cxx | 2 +- Source/Modules/s-exp.cxx | 6 +++--- Source/Modules/uffi.cxx | 1 + 6 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Source/Modules/allegrocl.cxx b/Source/Modules/allegrocl.cxx index daf19c29a..ae4485d4e 100644 --- a/Source/Modules/allegrocl.cxx +++ b/Source/Modules/allegrocl.cxx @@ -1520,6 +1520,7 @@ extern "C" Language *swig_allegrocl(void) { void ALLEGROCL::main(int argc, char *argv[]) { int i; + Preprocessor_define("SWIGALLEGROCL 1", 0); SWIG_library_directory("allegrocl"); SWIG_config_file("allegrocl.swg"); @@ -1576,8 +1577,6 @@ void ALLEGROCL::main(int argc, char *argv[]) { } - Preprocessor_define("SWIGALLEGROCL 1", 0); - allow_overloading(); } diff --git a/Source/Modules/cffi.cxx b/Source/Modules/cffi.cxx index 717550ee0..f20949fc7 100644 --- a/Source/Modules/cffi.cxx +++ b/Source/Modules/cffi.cxx @@ -67,6 +67,7 @@ private: void CFFI::main(int argc, char *argv[]) { int i; + Preprocessor_define("SWIGCFFI 1", 0); SWIG_library_directory("cffi"); SWIG_config_file("cffi.swg"); generate_typedef_flag = 0; diff --git a/Source/Modules/clisp.cxx b/Source/Modules/clisp.cxx index 29dc4fddc..276919627 100644 --- a/Source/Modules/clisp.cxx +++ b/Source/Modules/clisp.cxx @@ -36,6 +36,7 @@ private: void CLISP::main(int argc, char *argv[]) { int i; + Preprocessor_define("SWIGCLISP 1", 0); SWIG_library_directory("clisp"); SWIG_config_file("clisp.swg"); generate_typedef_flag = 0; diff --git a/Source/Modules/r.cxx b/Source/Modules/r.cxx index 998e80f14..fc3d35246 100644 --- a/Source/Modules/r.cxx +++ b/Source/Modules/r.cxx @@ -2573,9 +2573,9 @@ String * R::runtimeCode() { void R::main(int argc, char *argv[]) { bool cppcast = true; init(); + Preprocessor_define("SWIGR 1", 0); SWIG_library_directory("r"); SWIG_config_file("r.swg"); - Preprocessor_define("SWIGR 1", 0); debugMode = false; copyStruct = true; memoryProfile = false; diff --git a/Source/Modules/s-exp.cxx b/Source/Modules/s-exp.cxx index 833ed49aa..cdfaef92e 100644 --- a/Source/Modules/s-exp.cxx +++ b/Source/Modules/s-exp.cxx @@ -29,6 +29,9 @@ public: } virtual void main(int argc, char *argv[]) { + // Add a symbol to the parser for conditional compilation + Preprocessor_define("SWIGSEXP 1", 0); + SWIG_typemap_lang("sexp"); for (int iX = 0; iX < argc; iX++) { if (strcmp(argv[iX], "-typemaplang") == 0) { @@ -42,9 +45,6 @@ public: fputs(usage, stdout); } } - - // Add a symbol to the parser for conditional compilation - Preprocessor_define("SWIGSEXP 1", 0); } DOHHash *print_circle_hash; diff --git a/Source/Modules/uffi.cxx b/Source/Modules/uffi.cxx index 693ee0a58..4feeb58f2 100644 --- a/Source/Modules/uffi.cxx +++ b/Source/Modules/uffi.cxx @@ -180,6 +180,7 @@ static String *get_lisp_type(SwigType *ty, const String_or_char *name) { void UFFI::main(int argc, char *argv[]) { int i; + Preprocessor_define("SWIGUFFI 1", 0); SWIG_library_directory("uffi"); SWIG_config_file("uffi.swg"); From 5ec2d8c166827a483c6770317a1fc47e7a10f4d2 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 30 Dec 2008 00:38:34 +0000 Subject: [PATCH 0262/1680] All languages now define a macro in the generated C/C++ wrapper file indicating which language is being wrapped, eg #define SWIGJAVA git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11018 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 6 ++++++ Doc/Manual/Preprocessor.html | 5 +++++ Source/Modules/allegrocl.cxx | 4 ++++ Source/Modules/cffi.cxx | 4 ++++ Source/Modules/chicken.cxx | 4 +++- Source/Modules/csharp.cxx | 4 ++++ Source/Modules/guile.cxx | 4 +++- Source/Modules/java.cxx | 4 ++++ Source/Modules/lua.cxx | 5 +++++ Source/Modules/modula3.cxx | 3 +++ Source/Modules/mzscheme.cxx | 3 +++ Source/Modules/ocaml.cxx | 3 +++ Source/Modules/octave.cxx | 3 +++ Source/Modules/perl5.cxx | 2 +- Source/Modules/php.cxx | 7 +++++-- Source/Modules/pike.cxx | 3 +++ Source/Modules/python.cxx | 2 ++ Source/Modules/r.cxx | 10 ++++++---- Source/Modules/ruby.cxx | 2 ++ Source/Modules/tcl8.cxx | 3 +++ 20 files changed, 72 insertions(+), 9 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 6dda7ff7a..503e2d183 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,12 @@ Version 1.3.37 (in progress) ============================ +2008-12-30: wsfulton + Bug #2430756. All the languages now define a macro in the generated C/C++ + wrapper file indicating which language is being wrapped. The macro name is the + same as those defined when SWIG is run, eg SWIGJAVA, SWIGOCTAVE, SWIGCSHARP etc + and are listed in the "Conditional Compilation" section in the documentation. + 2008-12-23: wsfulton [Java] Fix #2153773 - %nojavaexception was clearing the exception feature instead of disabling it. Clearing checked Java exceptions also didn't work. diff --git a/Doc/Manual/Preprocessor.html b/Doc/Manual/Preprocessor.html index 5513d4f91..2a0bbcceb 100644 --- a/Doc/Manual/Preprocessor.html +++ b/Doc/Manual/Preprocessor.html @@ -107,7 +107,10 @@ SWIGWIN Defined when running SWIG under Windows SWIG_VERSION Hexadecimal number containing SWIG version, such as 0x010311 (corresponding to SWIG-1.3.11). +SWIGALLEGROCL Defined when using Allegro CL +SWIGCFFI Defined when using CFFI SWIGCHICKEN Defined when using CHICKEN +SWIGCLISP Defined when using CLISP SWIGCSHARP Defined when using C# SWIGGUILE Defined when using Guile SWIGJAVA Defined when using Java @@ -115,12 +118,14 @@ SWIGLUA Defined when using Lua SWIGMODULA3 Defined when using Modula-3 SWIGMZSCHEME Defined when using Mzscheme SWIGOCAML Defined when using Ocaml +SWIGOCTAVE Defined when using Octave SWIGPERL Defined when using Perl SWIGPERL5 Defined when using Perl5 SWIGPHP Defined when using PHP SWIGPHP5 Defined when using PHP5 SWIGPIKE Defined when using Pike SWIGPYTHON Defined when using Python +SWIGR Defined when using R SWIGRUBY Defined when using Ruby SWIGSEXP Defined when using S-expressions SWIGTCL Defined when using Tcl diff --git a/Source/Modules/allegrocl.cxx b/Source/Modules/allegrocl.cxx index ae4485d4e..424a88193 100644 --- a/Source/Modules/allegrocl.cxx +++ b/Source/Modules/allegrocl.cxx @@ -1618,6 +1618,10 @@ int ALLEGROCL::top(Node *n) { Swig_register_filebyname("lisphead", f_cl); Swig_banner(f_runtime); + + Printf(f_runtime, "#define SWIGALLEGROCL\n"); + Printf(f_runtime, "\n"); + Swig_banner_target_lang(f_cl, ";;"); Printf(f_cl, "\n" diff --git a/Source/Modules/cffi.cxx b/Source/Modules/cffi.cxx index f20949fc7..38c9c574f 100644 --- a/Source/Modules/cffi.cxx +++ b/Source/Modules/cffi.cxx @@ -162,6 +162,10 @@ int CFFI::top(Node *n) { Swig_register_filebyname("swiglisp", f_null); Swig_banner(f_runtime); + + Printf(f_runtime, "#define SWIGCFFI\n"); + Printf(f_runtime, "\n"); + Swig_banner_target_lang(f_lisp, ";;;"); Language::top(n); diff --git a/Source/Modules/chicken.cxx b/Source/Modules/chicken.cxx index 05c9ccc3f..f0a1f6164 100644 --- a/Source/Modules/chicken.cxx +++ b/Source/Modules/chicken.cxx @@ -217,11 +217,13 @@ int CHICKEN::top(Node *n) { Swig_banner(f_runtime); - Printf(f_runtime, "/* Implementation : CHICKEN */\n\n"); + Printf(f_runtime, "#define SWIGCHICKEN\n"); if (no_collection) Printf(f_runtime, "#define SWIG_CHICKEN_NO_COLLECTION 1\n"); + Printf(f_runtime, "\n"); + /* Set module name */ module = Swig_copy_string(Char(Getattr(n, "name"))); scmmodule = NewString(module); diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index 2a75322ea..15bbf4323 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -360,6 +360,8 @@ public: Swig_banner(f_runtime); // Print the SWIG banner message + Printf(f_runtime, "#define SWIGCSHARP\n"); + if (directorsEnabled()) { Printf(f_runtime, "#define SWIG_DIRECTORS\n"); @@ -376,6 +378,8 @@ public: Printf(f_directors, "#include \"%s\"\n\n", Swig_file_filename(outfile_h)); } + Printf(f_runtime, "\n"); + Swig_name_register((char *) "wrapper", (char *) "CSharp_%f"); if (old_variable_names) { Swig_name_register((char *) "set", (char *) "set_%v"); diff --git a/Source/Modules/guile.cxx b/Source/Modules/guile.cxx index e3f4fe711..61de06925 100644 --- a/Source/Modules/guile.cxx +++ b/Source/Modules/guile.cxx @@ -324,7 +324,7 @@ public: Swig_banner(f_runtime); - Printf(f_runtime, "/* Implementation : GUILE */\n\n"); + Printf(f_runtime, "#define SWIGGUILE\n"); if (!use_scm_interface) { if (SwigRuntime == 1) @@ -357,6 +357,8 @@ public: Printf(f_runtime, "\n}\n"); } + Printf(f_runtime, "\n"); + Language::top(n); /* Close module */ diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index f7773a2ef..48b9285de 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -369,6 +369,8 @@ public: Swig_banner(f_runtime); // Print the SWIG banner message + Printf(f_runtime, "#define SWIGJAVA\n"); + if (directorsEnabled()) { Printf(f_runtime, "#define SWIG_DIRECTORS\n"); @@ -385,6 +387,8 @@ public: Printf(f_directors, "#include \"%s\"\n\n", Swig_file_filename(outfile_h)); } + Printf(f_runtime, "\n"); + String *wrapper_name = NewString(""); if (Len(package)) { diff --git a/Source/Modules/lua.cxx b/Source/Modules/lua.cxx index c17be52c3..c615bfa9a 100644 --- a/Source/Modules/lua.cxx +++ b/Source/Modules/lua.cxx @@ -250,10 +250,15 @@ public: /* Standard stuff for the SWIG runtime section */ Swig_banner(f_runtime); + + Printf(f_runtime, "#define SWIGLUA\n"); + // if (NoInclude) { // Printf(f_runtime, "#define SWIG_NOINCLUDE\n"); // } + Printf(f_runtime, "\n"); + //String *init_name = NewStringf("%(title)s_Init", module); //Printf(f_header, "#define SWIG_init %s\n", init_name); //Printf(f_header, "#define SWIG_name \"%s\"\n", module); diff --git a/Source/Modules/modula3.cxx b/Source/Modules/modula3.cxx index b378c0979..982d6224d 100644 --- a/Source/Modules/modula3.cxx +++ b/Source/Modules/modula3.cxx @@ -958,6 +958,9 @@ MODULA3(): Swig_banner(f_runtime); // Print the SWIG banner message + Printf(f_runtime, "#define SWIGMODULA3\n"); + Printf(f_runtime, "\n"); + Swig_name_register((char *) "wrapper", (char *) "Modula3_%f"); if (old_variable_names) { Swig_name_register((char *) "set", (char *) "set_%v"); diff --git a/Source/Modules/mzscheme.cxx b/Source/Modules/mzscheme.cxx index 9481ba1ee..99f1024ff 100644 --- a/Source/Modules/mzscheme.cxx +++ b/Source/Modules/mzscheme.cxx @@ -148,6 +148,9 @@ public: Swig_banner(f_runtime); + Printf(f_runtime, "#define SWIGMZSCHEME\n"); + Printf(f_runtime, "\n"); + module = Getattr(n, "name"); Language::top(n); diff --git a/Source/Modules/ocaml.cxx b/Source/Modules/ocaml.cxx index 9a974888b..022611502 100644 --- a/Source/Modules/ocaml.cxx +++ b/Source/Modules/ocaml.cxx @@ -264,6 +264,7 @@ public: Swig_banner(f_runtime); + Printf(f_runtime, "#define SWIGOCAML\n"); Printf(f_runtime, "#define SWIG_MODULE \"%s\"\n", module); /* Module name */ Printf(f_mlbody, "let module_name = \"%s\"\n", module); @@ -281,6 +282,8 @@ public: Printf(f_runtime, "#define SWIG_DIRECTORS\n"); } + Printf(f_runtime, "\n"); + /* Produce the enum_to_int and int_to_enum functions */ Printf(f_enumtypes_type, "open Swig\n" "type c_enum_type = [ \n `unknown\n"); diff --git a/Source/Modules/octave.cxx b/Source/Modules/octave.cxx index 3a5ca5ed8..4ad0a1b96 100644 --- a/Source/Modules/octave.cxx +++ b/Source/Modules/octave.cxx @@ -111,10 +111,12 @@ public: Swig_banner(f_runtime); + 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); if (directorsEnabled()) { + Printf(f_runtime, "#define SWIG_DIRECTORS\n"); Swig_banner(f_directors_h); if (dirprot_mode()) { // Printf(f_directors_h, "#include \n"); @@ -122,6 +124,7 @@ public: } } + Printf(f_runtime, "\n"); Printf(s_global_tab, "\nstatic const struct swig_octave_member swig_globals[] = {\n"); Printf(f_init, "static void SWIG_init_user(octave_swig_type* module_ns)\n{\n"); diff --git a/Source/Modules/perl5.cxx b/Source/Modules/perl5.cxx index 5a21e835a..56f84e046 100644 --- a/Source/Modules/perl5.cxx +++ b/Source/Modules/perl5.cxx @@ -256,7 +256,7 @@ public: Printf(f_runtime, "#define SWIGPERL\n"); Printf(f_runtime, "#define SWIG_CASTRANK_MODE\n"); - + Printf(f_runtime, "\n"); // Is the imported module in another package? (IOW, does it use the // %module(package="name") option and it's different than the package diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index fc4ad8348..c103b6825 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -264,8 +264,6 @@ public: SWIG_exit(EXIT_FAILURE); } - Swig_banner(f_runtime); - /* sections of the output file */ s_init = NewString("/* init section */\n"); r_init = NewString("/* rinit section */\n"); @@ -291,6 +289,11 @@ public: Swig_register_filebyname("header", s_header); Swig_register_filebyname("wrapper", s_wrappers); + Swig_banner(f_runtime); + + Printf(f_runtime, "#define SWIGPHP\n"); + Printf(f_runtime, "\n"); + /* Set the module name */ module = Copy(Getattr(n, "name")); cap_module = NewStringf("%(upper)s", module); diff --git a/Source/Modules/pike.cxx b/Source/Modules/pike.cxx index 56d1acab2..ff9b2bdc3 100644 --- a/Source/Modules/pike.cxx +++ b/Source/Modules/pike.cxx @@ -143,6 +143,9 @@ public: /* Standard stuff for the SWIG runtime section */ Swig_banner(f_runtime); + Printf(f_runtime, "#define SWIGPIKE\n"); + Printf(f_runtime, "\n"); + Printf(f_header, "#define SWIG_init pike_module_init\n"); Printf(f_header, "#define SWIG_name \"%s\"\n\n", module); diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 81e0d0b38..fd4e9be8b 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -601,6 +601,8 @@ public: Printf(f_runtime, "#define SWIG_PYTHON_CLASSIC\n"); } + Printf(f_runtime, "\n"); + Printf(f_header, "#if (PY_VERSION_HEX <= 0x02000000)\n"); Printf(f_header, "# if !defined(SWIG_PYTHON_CLASSIC)\n"); Printf(f_header, "# error \"This python version requires swig to be run with the '-classic' option\"\n"); diff --git a/Source/Modules/r.cxx b/Source/Modules/r.cxx index fc3d35246..ae905a806 100644 --- a/Source/Modules/r.cxx +++ b/Source/Modules/r.cxx @@ -816,9 +816,14 @@ int R::top(Node *n) { Swig_register_filebyname("header", s_header); Swig_register_filebyname("wrapper", f_wrapper); Swig_register_filebyname("s", sfile); - Swig_register_filebyname("sclasses", s_classes); + Swig_banner(f_runtime); + + Printf(f_runtime, "#define SWIGR\n"); + Printf(f_runtime, "\n"); + + Swig_banner_target_lang(s_init, "#"); outputCommandLineArguments(s_init); @@ -898,9 +903,6 @@ int R::DumpCode(Node *n) { SWIG_exit(EXIT_FAILURE); } - Swig_banner(runtime); - - Printf(runtime, "/* Runtime */\n"); Printf(runtime, "%s\n", f_runtime); diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx index 8e4aece84..dffd068af 100644 --- a/Source/Modules/ruby.cxx +++ b/Source/Modules/ruby.cxx @@ -1043,6 +1043,8 @@ public: Printf(f_runtime, "#define SWIG_DIRECTORS\n"); } + Printf(f_runtime, "\n"); + /* typedef void *VALUE */ SwigType *value = NewSwigType(T_VOID); SwigType_add_pointer(value); diff --git a/Source/Modules/tcl8.cxx b/Source/Modules/tcl8.cxx index b4b57fc0f..9689c149b 100644 --- a/Source/Modules/tcl8.cxx +++ b/Source/Modules/tcl8.cxx @@ -160,6 +160,9 @@ public: Swig_banner(f_runtime); + Printf(f_runtime, "#define SWIGTCL\n"); + Printf(f_runtime, "\n"); + /* Set the module name, namespace, and prefix */ module = NewStringf("%(lower)s", Getattr(n, "name")); From 7aa0e29bd9d83501a0a7ae8407f428ee81983c2f Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 30 Dec 2008 01:14:14 +0000 Subject: [PATCH 0263/1680] getting ready for 1.3.37 release candidate git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11019 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- ANNOUNCE | 12 ++++++------ CHANGES.current | 8 +++++--- Doc/Manual/Sections.html | 2 +- README | 14 +++++++++++++- TODO | 2 +- 5 files changed, 26 insertions(+), 12 deletions(-) diff --git a/ANNOUNCE b/ANNOUNCE index 7c0e95e3f..6d27f19e2 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -1,11 +1,11 @@ -*** ANNOUNCE: SWIG 1.3.36 (24 June 2008) *** +*** ANNOUNCE: SWIG 1.3.37 (30 December 2008) *** http://www.swig.org -We're pleased to announce SWIG-1.3.36, the latest installment in the -SWIG development effort. SWIG-1.3.36 includes a number of bug fixes -and large number of enhancements throughout. +We're pleased to announce SWIG-1.3.37, the latest installment in the +SWIG development effort. SWIG-1.3.37 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.36.tar.gz + http://prdownloads.sourceforge.net/swig/swig-1.3.37.tar.gz A Windows version is also available at - http://prdownloads.sourceforge.net/swig/swigwin-1.3.36.zip + http://prdownloads.sourceforge.net/swig/swigwin-1.3.37.zip Release numbers --------------- diff --git a/CHANGES.current b/CHANGES.current index 503e2d183..f9420f284 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,5 +1,5 @@ -Version 1.3.37 (in progress) -============================ +Version 1.3.37 (30 December 2008) +================================= 2008-12-30: wsfulton Bug #2430756. All the languages now define a macro in the generated C/C++ @@ -78,6 +78,8 @@ Version 1.3.37 (in progress) you can download it here: https://swig.svn.sourceforge.net/svnroot/swig/trunk/Tools/pyname_patch.py + *** POTENTIAL INCOMPATIBILITY *** + 2008-12-02: wsfulton [Python] Apply patch #2143727 from Serge Monkewitz to fix importing base classes when the package option is specified in %module and that module is %import'ed. @@ -280,7 +282,7 @@ Version 1.3.37 (in progress) Fix SF #2019156 Configuring with --without-octave or --without-alllang did not disable octave. -2008-07-14: wsfultonn +2008-07-14: wsfulton [Java, C#] Fix director typemaps for pointers so that NULL pointers are correctly marshalled to C#/Java null in director methods. diff --git a/Doc/Manual/Sections.html b/Doc/Manual/Sections.html index 9f2c94e0b..e869e340f 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.37 (in progress) +Last update : SWIG-1.3.37 (30 December 2008)

        Sections

        diff --git a/README b/README index 2898130b0..660e67d30 100644 --- a/README +++ b/README @@ -1,6 +1,6 @@ SWIG (Simplified Wrapper and Interface Generator) -Version: 1.3.36 (24 June 2008) +Version: 1.3.37 (30 December 2008) Tagline: SWIG is a compiler that integrates C and C++ with languages including Perl, Python, Tcl, Ruby, PHP, Java, Ocaml, Lua, @@ -91,6 +91,18 @@ A SWIG FAQ and other hints can be found on the SWIG Wiki: What's New? =========== +SWIG-1.3.37 summary: +- Python 3 support added +- SWIG now ships with a version of ccache that can be used with SWIG. + This enables the files generated by SWIG to be cached so that repeated + use of SWIG on unchanged input files speeds up builds quite considerably. +- PHP 4 support removed and PHP support improved in general +- Improved C# array support +- Numerous Allegro CL improvements +- Bug fixes/enhancements for Python, PHP, Java, C#, Chicken, Allegro CL, + CFFI, Ruby, Tcl, Perl. +- Other minor generic bug fixes and enhancements + SWIG-1.3.36 summary: - Enhancement to directors to wrap all protected members - Optimisation feature for objects returned by value diff --git a/TODO b/TODO index 72aeada7c..56f5c731a 100644 --- a/TODO +++ b/TODO @@ -1,6 +1,6 @@ SWIG TO-DO -Release: SWIG-1.3.36 +Release: SWIG-1.3.37 ----------------------------------------------------------------------------- From 6d564eb55db25f6aa459556c256a18570d13d69a Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 30 Dec 2008 10:46:41 +0000 Subject: [PATCH 0264/1680] remove duplicate SWIGR macro git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11020 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/r/rrun.swg | 2 -- 1 file changed, 2 deletions(-) diff --git a/Lib/r/rrun.swg b/Lib/r/rrun.swg index b5375c213..32946c7b5 100644 --- a/Lib/r/rrun.swg +++ b/Lib/r/rrun.swg @@ -16,8 +16,6 @@ extern "C" { #include #include -#define SWIGR 1 - #if R_VERSION >= R_Version(2,6,0) #define VMAXTYPE void * #else From 2064dff1efbf1a858a3cb59229da713f7e90c39a Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 30 Dec 2008 11:02:59 +0000 Subject: [PATCH 0265/1680] fix for new SWIGCSHARP defn in wrappers git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11021 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/template_inherit_abstract.i | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/test-suite/template_inherit_abstract.i b/Examples/test-suite/template_inherit_abstract.i index 89d983de0..2f83433a5 100644 --- a/Examples/test-suite/template_inherit_abstract.i +++ b/Examples/test-suite/template_inherit_abstract.i @@ -56,7 +56,7 @@ namespace oss %inline %{ namespace oss { -#ifdef SWIGCSHARP +#if defined(SWIG) && defined(SWIGCSHARP) %ignore HModule::get(); // Work around for lack of multiple inheritance support - base ModuleBase is ignored. #endif struct test : HModule From 8c71c0bf21843247dbacac6ec71d73094b6dc4c5 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 30 Dec 2008 11:42:52 +0000 Subject: [PATCH 0266/1680] explicit type warning fix git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11022 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/GIFPlot/Lib/gif.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/GIFPlot/Lib/gif.c b/Examples/GIFPlot/Lib/gif.c index 2ade38d38..7953e5ce9 100644 --- a/Examples/GIFPlot/Lib/gif.c +++ b/Examples/GIFPlot/Lib/gif.c @@ -268,7 +268,7 @@ static int maxmaxcode = 1 << GP_BITS; /* NEVER generate this */ static count_int *htab; static unsigned short *codetab; -static GIFOutBufSize; +static int GIFOutBufSize; /* static count_int htab [HSIZE]; static unsigned short codetab [HSIZE]; */ From 13c981d99270ccc62c94a4b12f914c044e1fc082 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 30 Dec 2008 23:33:35 +0000 Subject: [PATCH 0267/1680] missing yodl2man should not break the configure stage for users as it is not required as the man pages are shipped with the release tarball git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11023 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- configure.in | 4 ---- 1 file changed, 4 deletions(-) diff --git a/configure.in b/configure.in index a53566d72..962adb33b 100644 --- a/configure.in +++ b/configure.in @@ -34,10 +34,6 @@ AC_SUBST(AR) AC_CHECK_PROGS(YODL2MAN, yodl2man) AC_CHECK_PROGS(YODL2HTML, yodl2html) -if test -z "$YODL2MAN" -then AC_MSG_ERROR([cannot find yodl executable yodl2man]) -fi - AC_COMPILE_WARNINGS # Increase warning levels AC_DEFINE_UNQUOTED(SWIG_CXX, ["$CXX"], [Compiler that built SWIG]) From be5c8146c6029a7f14b7261ac3d4dcaf85bc325f Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 30 Dec 2008 23:50:32 +0000 Subject: [PATCH 0268/1680] fix ccache-swig man page generation git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11024 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Tools/mkdist.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tools/mkdist.py b/Tools/mkdist.py index 1ef7c7e5c..a55feda13 100755 --- a/Tools/mkdist.py +++ b/Tools/mkdist.py @@ -57,7 +57,7 @@ os.system("find "+dirname+" -name autom4te.cache -exec rm -rf {} \\;") # Build documentation print "Building documentation" os.system("cd "+dirname+"/Doc/Manual && make all clean-baks") == 0 or failed() -os.system("cd "+dirname+"/CCache && yodl2man -o swig-ccache.1 ccache.yo") == 0 or failed() +os.system("cd "+dirname+"/CCache && yodl2man -o ccache-swig.1 ccache.yo") == 0 or failed() # Build the tar-ball os.system("tar -cf "+dirname+".tar "+dirname) == 0 or failed() From aa9bb3e316042680d836a00173684b2796a3c040 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 31 Dec 2008 01:02:16 +0000 Subject: [PATCH 0269/1680] re-order configure.in into sections for users and developers and requirements for the examples git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11025 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/pure_virtual.i | 4 +- configure.in | 150 ++++++++++++++--------------- 2 files changed, 78 insertions(+), 76 deletions(-) diff --git a/Examples/test-suite/pure_virtual.i b/Examples/test-suite/pure_virtual.i index aab9741a9..5bda283cf 100644 --- a/Examples/test-suite/pure_virtual.i +++ b/Examples/test-suite/pure_virtual.i @@ -62,16 +62,18 @@ class E : public C, public AA { public: virtual void something() { }; }; +%} /* Fill in method from AA. This class should be constructable */ #ifdef SWIGCSHARP %ignore F::method2(); // Work around for lack of multiple inheritance support - base AA is ignored. #endif + +%inline %{ class F : public E { public: virtual void method2() { } }; - %} %{ diff --git a/configure.in b/configure.in index 962adb33b..4655d829f 100644 --- a/configure.in +++ b/configure.in @@ -21,28 +21,83 @@ AH_BOTTOM([ #endif ]) -dnl Checks for programs. +dnl Check for programs that a user requires to build SWIG AC_PROG_CC AC_PROG_CXX -AC_PROG_YACC AC_EXEEXT AC_OBJEXT -AC_PROG_RANLIB AM_PROG_CC_C_O # Needed for subdir-objects in AUTOMAKE_OPTIONS -AC_CHECK_PROGS(AR, ar aal, ar) -AC_SUBST(AR) -AC_CHECK_PROGS(YODL2MAN, yodl2man) -AC_CHECK_PROGS(YODL2HTML, yodl2html) AC_COMPILE_WARNINGS # Increase warning levels AC_DEFINE_UNQUOTED(SWIG_CXX, ["$CXX"], [Compiler that built SWIG]) AC_DEFINE_UNQUOTED(SWIG_PLATFORM, ["$build"], [Platform that SWIG is built for]) - dnl Checks for header files. AC_HEADER_STDC +dnl Checks for types. +AC_LANG_PUSH([C++]) +AC_CHECK_TYPES([bool]) +AC_LANG_POP([C++]) + +dnl Look for popen +AC_ARG_WITH(popen, AS_HELP_STRING([--without-popen], [Disable popen]), with_popen="$withval") +if test x"${with_popen}" = xno ; then +AC_MSG_NOTICE([Disabling popen]) +else +AC_CHECK_FUNC(popen, AC_DEFINE(HAVE_POPEN, 1, [Define if popen is available]), AC_MSG_NOTICE([Disabling popen])) +fi + +dnl Look for RxSpencer +AC_ARG_WITH(rxspencer, AS_HELP_STRING([--with-rxspencer], [Enable RxSpencer]), with_rxspencer="yes") +if test x"${with_rxspencer}" = xyes ; then +#check first for the header + AC_CHECK_HEADER(rxspencer/regex.h,with_rxspencer="yes",with_rxspencer="no") + if test x"${with_rxspencer}" = xyes ; then +# now check for the library + AC_CHECK_LIB(rxspencer, regcomp,with_rxspencer="yes",with_rxspencer="no") + fi + if test x"${with_rxspencer}" = xyes ; then +# library and header are available + AC_DEFINE(HAVE_RXSPENCER, 1,[Define if rxspencer is available]) + LIBS="$LIBS -lrxspencer" + else + AC_MSG_NOTICE([RxSpencer not found. Obtain it at http://arglist.com/regex or http://gnuwin32.sourceforge.net/packages.html]) + fi +fi + +dnl CCache +AC_ARG_ENABLE([ccache], AS_HELP_STRING([--disable-ccache], [disable building and installation of ccache-swig executable (default enabled)]), [enable_ccache=$enableval], [enable_ccache=yes]) +AC_MSG_CHECKING([whether to enable ccache-swig]) +AC_MSG_RESULT([$enable_ccache]) + +if test "$enable_ccache" = yes; then + AC_CONFIG_SUBDIRS(CCache) + ENABLE_CCACHE=1 +fi +AC_SUBST(ENABLE_CCACHE) + + +echo "" +echo "Checking packages required for SWIG developers." +echo "Note : None of the following packages are required for users to compile and install SWIG" +echo "" + +AC_PROG_YACC +AC_PROG_RANLIB +AC_CHECK_PROGS(AR, ar aal, ar) +AC_SUBST(AR) +AC_CHECK_PROGS(YODL2MAN, yodl2man) +AC_CHECK_PROGS(YODL2HTML, yodl2html) + + +echo "" +echo "Checking for installed target languages and other information in order to compile and run the examples." +echo "Note : None of the following packages are required for users to compile and install SWIG" +echo "" + + dnl How to specify include directories that may be system directories. # -I should not be used on system directories (GCC) if test "$GCC" = yes; then @@ -52,21 +107,9 @@ else fi -dnl Checks for types. -AC_LANG_PUSH([C++]) -AC_CHECK_TYPES([bool]) -AC_LANG_POP([C++]) +dnl Info for building shared libraries ... in order to run the examples - -# Set info about shared libraries. -AC_SUBST(SO) -AC_SUBST(LDSHARED) -AC_SUBST(CCSHARED) -AC_SUBST(CXXSHARED) -AC_SUBST(TRYLINKINGWITHCXX) -AC_SUBST(LINKFORSHARED) - -# SO is the extension of shared libraries `(including the dot!) +# SO is the extension of shared libraries (including the dot!) AC_MSG_CHECKING(SO) if test -z "$SO" then @@ -203,7 +246,6 @@ then esac fi AC_MSG_RESULT($RPATH) -AC_SUBST(RPATH) # LINKFORSHARED are the flags passed to the $(CC) command that links # the a few executables -- this is only needed for a few systems @@ -223,6 +265,15 @@ then fi AC_MSG_RESULT($LINKFORSHARED) +# Set info about shared libraries. +AC_SUBST(SO) +AC_SUBST(LDSHARED) +AC_SUBST(CCSHARED) +AC_SUBST(CXXSHARED) +AC_SUBST(TRYLINKINGWITHCXX) +AC_SUBST(LINKFORSHARED) +AC_SUBST(RPATH) + # This variation is needed on OS-X because there is no (apparent) consistency in shared library naming. # Sometimes .bundle works, but sometimes .so is needed. It depends on the target language @@ -271,46 +322,6 @@ case $host in esac - -echo "" -echo "Checking for installed packages." -echo "Note : None of the following packages are required to compile SWIG" -echo "" - -#---------------------------------------------------------------- -# Look for popen -#---------------------------------------------------------------- - -AC_ARG_WITH(popen, AS_HELP_STRING([--without-popen], [Disable popen]), with_popen="$withval") -if test x"${with_popen}" = xno ; then -AC_MSG_NOTICE([Disabling popen]) -else -AC_CHECK_FUNC(popen, AC_DEFINE(HAVE_POPEN, 1, [Define if popen is available]), AC_MSG_NOTICE([Disabling popen])) -fi - -#---------------------------------------------------------------- -# Look for RxSpencer -#---------------------------------------------------------------- - -AC_ARG_WITH(rxspencer, AS_HELP_STRING([--with-rxspencer], [Enable RxSpencer]), with_rxspencer="yes") -if test x"${with_rxspencer}" = xyes ; then -#check first for the header - AC_CHECK_HEADER(rxspencer/regex.h,with_rxspencer="yes",with_rxspencer="no") - if test x"${with_rxspencer}" = xyes ; then -# now check for the library - AC_CHECK_LIB(rxspencer, regcomp,with_rxspencer="yes",with_rxspencer="no") - fi - if test x"${with_rxspencer}" = xyes ; then -# library and header are available - AC_DEFINE(HAVE_RXSPENCER, 1,[Define if rxspencer is available]) - LIBS="$LIBS -lrxspencer" - else - AC_MSG_NOTICE([RxSpencer not found. Obtain it at http://arglist.com/regex or http://gnuwin32.sourceforge.net/packages.html]) - fi -fi - -#---------------------------------------------------------------- - # Check for specific libraries. Used for SWIG examples AC_CHECK_LIB(dl, dlopen) # Dynamic linking for SunOS/Solaris and SYSV AC_CHECK_LIB(dld, shl_load) # Dynamic linking for HP-UX @@ -2101,6 +2112,7 @@ AC_SUBST(SKIP_GCJ) # Miscellaneous #---------------------------------------------------------------- + # Root directory # Translate path for native Windows compilers for use with 'make check' ROOT_DIR=`pwd` @@ -2167,17 +2179,5 @@ AC_CONFIG_FILES([ \ AC_CONFIG_FILES([preinst-swig], [chmod +x preinst-swig]) AC_CONFIG_FILES([CCache/ccache_swig_config.h]) -# ccache -AC_ARG_ENABLE([ccache], AS_HELP_STRING([--disable-ccache], [disable building and installation of ccache-swig executable (default enabled)]), [enable_ccache=$enableval], [enable_ccache=yes]) -AC_MSG_CHECKING([whether to enable ccache-swig]) -AC_MSG_RESULT([$enable_ccache]) - -if test "$enable_ccache" = yes; then - AC_CONFIG_SUBDIRS(CCache) - ENABLE_CCACHE=1 -fi - -AC_SUBST(ENABLE_CCACHE) - AC_OUTPUT dnl configure.in ends here From 30f6b83d126c16d9748ab65e1738b9a2ad1dd8b5 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 31 Dec 2008 01:10:49 +0000 Subject: [PATCH 0270/1680] better #! for finding python git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11026 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Tools/mkdist.py | 2 +- Tools/mkrelease.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Tools/mkdist.py b/Tools/mkdist.py index a55feda13..0e2eafa79 100755 --- a/Tools/mkdist.py +++ b/Tools/mkdist.py @@ -1,4 +1,4 @@ -#!/usr/local/bin/python +#!/usr/bin/env python # This script builds a swig-1.3 distribution. # Usage : mkdist.py version, where version should be 1.3.x diff --git a/Tools/mkrelease.py b/Tools/mkrelease.py index d7927f8e6..fc8b05308 100755 --- a/Tools/mkrelease.py +++ b/Tools/mkrelease.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/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 @@ -34,6 +34,7 @@ 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("") -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 "not labelling...." +#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" From 1e89a662f3a9d9d00949b7a89958cd066c276995 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 31 Dec 2008 01:11:37 +0000 Subject: [PATCH 0271/1680] put tagging back in git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11027 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Tools/mkrelease.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Tools/mkrelease.py b/Tools/mkrelease.py index fc8b05308..edf3b07fe 100755 --- a/Tools/mkrelease.py +++ b/Tools/mkrelease.py @@ -34,7 +34,6 @@ 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 "not labelling...." -#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 + "/") +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" From f70f2760e3baf740cc825a72303070d15b640436 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 3 Jan 2009 01:59:42 +0000 Subject: [PATCH 0272/1680] compile fix on Cygwin git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11028 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/swig_examples_lock.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Examples/test-suite/swig_examples_lock.h b/Examples/test-suite/swig_examples_lock.h index 07e9057f8..feef26d0f 100644 --- a/Examples/test-suite/swig_examples_lock.h +++ b/Examples/test-suite/swig_examples_lock.h @@ -32,6 +32,10 @@ private: #else #include +#ifndef PTHREAD_MUTEX_RECURSIVE_NP + // For Cygwin and possibly other OSs: _NP is "non-portable" + #define PTHREAD_MUTEX_RECURSIVE_NP PTHREAD_MUTEX_RECURSIVE +#endif namespace SwigExamples { From f9c640cd11dc66d8af994ed76cb09be86c18db77 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 5 Jan 2009 17:19:32 +0000 Subject: [PATCH 0273/1680] fix up namespaces so that boost, std or std::tr1 can be used for shared_ptr/intrusive_ptr git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11029 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/li_boost_intrusive_ptr.i | 2 + Lib/intrusive_ptr.i | 29 ++--- Lib/java/boost_intrusive_ptr.i | 130 +++++++++---------- 3 files changed, 81 insertions(+), 80 deletions(-) diff --git a/Examples/test-suite/li_boost_intrusive_ptr.i b/Examples/test-suite/li_boost_intrusive_ptr.i index dced5f2ba..7c37e6843 100644 --- a/Examples/test-suite/li_boost_intrusive_ptr.i +++ b/Examples/test-suite/li_boost_intrusive_ptr.i @@ -12,6 +12,7 @@ %warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK); %inline %{ +#include "boost/shared_ptr.hpp" #include "boost/intrusive_ptr.hpp" #include @@ -33,6 +34,7 @@ %include "std_string.i" #ifndef INTRUSIVE_PTR_WRAPPER # define SWIG_INTRUSIVE_PTR_NAMESPACE SwigBoost +# define SWIG_SHARED_PTR_NAMESPACE SwigBoost #endif #if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) diff --git a/Lib/intrusive_ptr.i b/Lib/intrusive_ptr.i index 9c5f163e5..7a686cfc5 100644 --- a/Lib/intrusive_ptr.i +++ b/Lib/intrusive_ptr.i @@ -1,4 +1,10 @@ -// intrusive_ptr namespaces could be boost or std or std::tr1 +// Allow for different namespaces for shared_ptr / intrusive_ptr - they could be boost or std or std::tr1 +// For example for std::tr1, use: +// #define SWIG_SHARED_PTR_NAMESPACE std +// #define SWIG_SHARED_PTR_SUBNAMESPACE tr1 +// #define SWIG_INTRUSIVE_PTR_NAMESPACE boost +// #define SWIG_INTRUSIVE_PTR_SUBNAMESPACE + #if !defined(SWIG_INTRUSIVE_PTR_NAMESPACE) # define SWIG_INTRUSIVE_PTR_NAMESPACE boost #endif @@ -13,9 +19,6 @@ namespace SWIG_INTRUSIVE_PTR_NAMESPACE { #if defined(SWIG_INTRUSIVE_PTR_SUBNAMESPACE) namespace SWIG_INTRUSIVE_PTR_SUBNAMESPACE { #endif - template class shared_ptr { - }; - template class intrusive_ptr { }; #if defined(SWIG_INTRUSIVE_PTR_SUBNAMESPACE) @@ -23,10 +26,6 @@ namespace SWIG_INTRUSIVE_PTR_NAMESPACE { #endif } -%inline %{ - #include "boost/shared_ptr.hpp" -%} - %fragment("SWIG_intrusive_deleter", "header") { template struct SWIG_intrusive_deleter { @@ -58,12 +57,12 @@ SWIG_INTRUSIVE_PTR_TYPEMAPS(PROXYCLASS, const, TYPE) %define SWIG_INTRUSIVE_PTR_DERIVED(PROXYCLASS, BASECLASSTYPE, TYPE...) SWIG_INTRUSIVE_PTR_TYPEMAPS(PROXYCLASS, , TYPE) SWIG_INTRUSIVE_PTR_TYPEMAPS(PROXYCLASS, const, TYPE) -%types(SWIG_INTRUSIVE_PTR_NAMESPACE::shared_ptr< TYPE > = SWIG_INTRUSIVE_PTR_NAMESPACE::shared_ptr< BASECLASSTYPE >) %{ +%types(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > = SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< BASECLASSTYPE >) %{ *newmemory = SWIG_CAST_NEW_MEMORY; - return (void *) new SWIG_INTRUSIVE_PTR_NAMESPACE::shared_ptr< BASECLASSTYPE >(*(SWIG_INTRUSIVE_PTR_NAMESPACE::shared_ptr< TYPE > *)$from); + return (void *) new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< BASECLASSTYPE >(*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *)$from); %} %extend TYPE { - static SWIG_INTRUSIVE_PTR_NAMESPACE::shared_ptr< BASECLASSTYPE > SWIGSharedPtrUpcast(SWIG_INTRUSIVE_PTR_NAMESPACE::shared_ptr< TYPE > swigSharedPtrUpcast) { + static SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< BASECLASSTYPE > SWIGSharedPtrUpcast(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > swigSharedPtrUpcast) { return swigSharedPtrUpcast; } } @@ -83,12 +82,12 @@ SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP(PROXYCLASS, const, TYPE) %define SWIG_INTRUSIVE_PTR_DERIVED_NO_WRAP(PROXYCLASS, BASECLASSTYPE, TYPE...) SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP(PROXYCLASS, , TYPE) SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP(PROXYCLASS, const, TYPE) -%types(SWIG_INTRUSIVE_PTR_NAMESPACE::shared_ptr< TYPE > = SWIG_INTRUSIVE_PTR_NAMESPACE::shared_ptr< BASECLASSTYPE >) %{ +%types(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > = SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< BASECLASSTYPE >) %{ *newmemory = SWIG_CAST_NEW_MEMORY; - return (void *) new SWIG_INTRUSIVE_PTR_NAMESPACE::shared_ptr< BASECLASSTYPE >(*(SWIG_INTRUSIVE_PTR_NAMESPACE::shared_ptr< TYPE > *)$from); - %} + return (void *) new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< BASECLASSTYPE >(*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *)$from); +%} %extend TYPE { - static SWIG_INTRUSIVE_PTR_NAMESPACE::shared_ptr< BASECLASSTYPE > SWIGSharedPtrUpcast(SWIG_INTRUSIVE_PTR_NAMESPACE::shared_ptr< TYPE > swigSharedPtrUpcast) { + static SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< BASECLASSTYPE > SWIGSharedPtrUpcast(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > swigSharedPtrUpcast) { return swigSharedPtrUpcast; } } diff --git a/Lib/java/boost_intrusive_ptr.i b/Lib/java/boost_intrusive_ptr.i index 363451669..6d390d9d5 100644 --- a/Lib/java/boost_intrusive_ptr.i +++ b/Lib/java/boost_intrusive_ptr.i @@ -9,9 +9,9 @@ %feature("unref") TYPE "(void)arg1; delete smartarg1;" -%typemap(in) CONST TYPE ($&1_type argp = 0, SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{ +%typemap(in) CONST TYPE ($&1_type argp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{ // plain value - argp = (*(SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0; + argp = (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0; if (!argp) { SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "Attempt to dereference null $1_type"); return $null; @@ -22,12 +22,12 @@ //plain value(out) $1_ltype* resultp = new $1_ltype(($1_ltype &)$1); intrusive_ptr_add_ref(resultp); - *(SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(resultp, SWIG_intrusive_deleter< CONST TYPE >()); + *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(resultp, SWIG_intrusive_deleter< CONST TYPE >()); %} -%typemap(in) CONST TYPE * (SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{ +%typemap(in) CONST TYPE * (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{ // plain pointer - smartarg = *(SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input; + smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input; $1 = (TYPE *)(smartarg ? smartarg->get() : 0); %} %typemap(out, fragment="SWIG_intrusive_deleter,SWIG_null_deleter") CONST TYPE * %{ @@ -35,18 +35,18 @@ #if ($owner) if ($1) { intrusive_ptr_add_ref($1); - *(SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1, SWIG_intrusive_deleter< CONST TYPE >()); + *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1, SWIG_intrusive_deleter< CONST TYPE >()); } else { - *(SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0; + *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0; } #else - *(SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = $1 ? new SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_0) : 0; + *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_0) : 0; #endif %} -%typemap(in) CONST TYPE & (SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{ +%typemap(in) CONST TYPE & (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{ // plain reference - $1 = ($1_ltype)((*(SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0); + $1 = ($1_ltype)((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0); if(!$1) { SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "$1_type reference is null"); return $null; @@ -57,18 +57,18 @@ #if ($owner) if ($1) { intrusive_ptr_add_ref($1); - *(SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1, SWIG_intrusive_deleter< CONST TYPE >()); + *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1, SWIG_intrusive_deleter< CONST TYPE >()); } else { - *(SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0; + *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0; } #else - *(SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = $1 ? new SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_0) : 0; + *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_0) : 0; #endif %} -%typemap(in) CONST TYPE *& ($*1_ltype temp = 0, SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{ +%typemap(in) CONST TYPE *& ($*1_ltype temp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{ // plain pointer by reference - temp = ((*(SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0); + temp = ((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0); $1 = &temp; %} %typemap(out, fragment="SWIG_intrusive_deleter,SWIG_null_deleter") CONST TYPE *& %{ @@ -76,45 +76,45 @@ #if ($owner) if (*$1) { intrusive_ptr_add_ref(*$1); - *(SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1, SWIG_intrusive_deleter< CONST TYPE >()); + *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1, SWIG_intrusive_deleter< CONST TYPE >()); } else { - *(SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0; + *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0; } #else - *(SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_0); + *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_0); #endif %} -%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > ($&1_type argp, SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * smartarg) %{ +%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > ($&1_type argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * smartarg) %{ // intrusive_ptr by value - smartarg = *(SWIG_INTRUSIVE_PTR_NAMESPACE::shared_ptr< CONST TYPE >**)&$input; + smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >**)&$input; if (smartarg) { - $1 = SWIG_INTRUSIVE_PTR_NAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true); + $1 = SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true); } %} %typemap(out, fragment="SWIG_intrusive_deleter") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > %{ if ($1) { intrusive_ptr_add_ref(result.get()); - *(SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(result.get(), SWIG_intrusive_deleter< CONST TYPE >()); + *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(result.get(), SWIG_intrusive_deleter< CONST TYPE >()); } else { - *(SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0; + *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0; } %} -%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast ($&1_type smartarg) %{ +%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast ($&1_type smartarg) %{ // shared_ptr by value smartarg = *($&1_ltype*)&$input; if (smartarg) $1 = *smartarg; %} -%typemap(out) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > ANY_TYPE_SWIGSharedPtrUpcast %{ +%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > ANY_TYPE_SWIGSharedPtrUpcast %{ *($&1_ltype*)&$result = $1 ? new $1_ltype($1) : 0; %} -%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > & ($*1_ltype tempnull, $*1_ltype temp, SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * smartarg) %{ +%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > & ($*1_ltype tempnull, $*1_ltype temp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * smartarg) %{ // intrusive_ptr by reference if ( $input ) { - smartarg = *(SWIG_INTRUSIVE_PTR_NAMESPACE::shared_ptr< CONST TYPE >**)&$input; - temp = SWIG_INTRUSIVE_PTR_NAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true); + smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >**)&$input; + temp = SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true); $1 = &temp; } else { $1 = &tempnull; @@ -123,24 +123,24 @@ %typemap(memberin) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > & %{ delete &($1); if ($self) { - SWIG_INTRUSIVE_PTR_NAMESPACE::intrusive_ptr< CONST TYPE > * temp = new SWIG_INTRUSIVE_PTR_NAMESPACE::intrusive_ptr< CONST TYPE >(*$input); + SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * temp = new SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(*$input); $1 = *temp; } %} %typemap(out, fragment="SWIG_intrusive_deleter") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > & %{ if (*$1) { intrusive_ptr_add_ref($1->get()); - *(SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1->get(), SWIG_intrusive_deleter< CONST TYPE >()); + *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1->get(), SWIG_intrusive_deleter< CONST TYPE >()); } else { - *(SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0; + *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0; } %} -%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * ($*1_ltype tempnull, $*1_ltype temp, SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * smartarg) %{ +%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * ($*1_ltype tempnull, $*1_ltype temp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * smartarg) %{ // intrusive_ptr by pointer if ( $input ) { - smartarg = *(SWIG_INTRUSIVE_PTR_NAMESPACE::shared_ptr< CONST TYPE >**)&$input; - temp = SWIG_INTRUSIVE_PTR_NAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true); + smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >**)&$input; + temp = SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true); $1 = &temp; } else { $1 = &tempnull; @@ -148,23 +148,23 @@ %} %typemap(memberin) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * %{ delete $1; - if ($self) $1 = new SWIG_INTRUSIVE_PTR_NAMESPACE::intrusive_ptr< CONST TYPE >(*$input); + if ($self) $1 = new SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(*$input); %} %typemap(out, fragment="SWIG_intrusive_deleter") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * %{ if ($1 && *$1) { intrusive_ptr_add_ref($1->get()); - *(SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1->get(), SWIG_intrusive_deleter< CONST TYPE >()); + *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1->get(), SWIG_intrusive_deleter< CONST TYPE >()); } else { - *(SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0; + *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0; } if ($owner) delete $1; %} -%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& (SWIG_INTRUSIVE_PTR_NAMESPACE::intrusive_ptr< CONST TYPE > temp, $*1_ltype tempp = 0, SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * smartarg) %{ +%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& (SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > temp, $*1_ltype tempp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * smartarg) %{ // intrusive_ptr by pointer reference - smartarg = *(SWIG_INTRUSIVE_PTR_NAMESPACE::shared_ptr< CONST TYPE >**)&$input; + smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >**)&$input; if ($input) { - temp = SWIG_INTRUSIVE_PTR_NAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true); + temp = SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true); } tempp = &temp; $1 = &tempp; @@ -175,9 +175,9 @@ %typemap(out, fragment="SWIG_intrusive_deleter") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& %{ if (*$1 && **$1) { intrusive_ptr_add_ref((*$1)->get()); - *(SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE >((*$1)->get(), SWIG_intrusive_deleter< CONST TYPE >()); + *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >((*$1)->get(), SWIG_intrusive_deleter< CONST TYPE >()); } else { - *(SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0; + *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0; } %} @@ -191,22 +191,22 @@ %typemap (jni) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >, - SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > &, SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *, SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& "jlong" %typemap (jtype) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >, - SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > &, SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *, SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& "long" %typemap (jstype) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >, - SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > &, SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *, SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& "PROXYCLASS" %typemap(javain) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >, - SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > &, SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *, SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& "PROXYCLASS.getCPtr($javainput)" @@ -215,7 +215,7 @@ long cPtr = $jnicall; return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true); } -%typemap(javaout) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > { +%typemap(javaout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > { long cPtr = $jnicall; return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true); } @@ -297,11 +297,11 @@ } // CONST version needed ???? also for C# -%typemap(jtype, nopgcpp="1") SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< TYPE > swigSharedPtrUpcast "long" -%typemap(jtype, nopgcpp="1") SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast "long" +%typemap(jtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > swigSharedPtrUpcast "long" +%typemap(jtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast "long" -%template() SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; +%template() SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; %template() SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >; %enddef @@ -314,7 +314,7 @@ %define SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP(PROXYCLASS, CONST, TYPE...) %naturalvar TYPE; -%naturalvar SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; +%naturalvar SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; // destructor mods %feature("unref") TYPE "(void)arg1; delete smartarg1;" @@ -322,46 +322,46 @@ // plain value %typemap(in) CONST TYPE ($&1_type argp = 0) %{ - argp = (*(SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0; + argp = (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0; if (!argp) { SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "Attempt to dereference null $1_type"); return $null; } $1 = *argp; %} %typemap(out) CONST TYPE -%{ *(SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1)); %} +%{ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1)); %} // plain pointer -%typemap(in) CONST TYPE * (SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{ - smartarg = *(SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input; +%typemap(in) CONST TYPE * (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{ + smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input; $1 = (TYPE *)(smartarg ? smartarg->get() : 0); %} %typemap(out, fragment="SWIG_null_deleter") CONST TYPE * %{ - *(SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = $1 ? new SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner) : 0; + *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner) : 0; %} // plain reference %typemap(in) CONST TYPE & %{ - $1 = ($1_ltype)((*(SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0); + $1 = ($1_ltype)((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0); if(!$1) { SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "$1_type reference is null"); return $null; } %} %typemap(out, fragment="SWIG_null_deleter") CONST TYPE & -%{ *(SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner); %} +%{ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner); %} // plain pointer by reference %typemap(in) CONST TYPE *& ($*1_ltype temp = 0) -%{ temp = ((*(SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0); +%{ temp = ((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0); $1 = &temp; %} %typemap(out, fragment="SWIG_null_deleter") CONST TYPE *& -%{ *(SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_$owner); %} +%{ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_$owner); %} -%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast ($&1_type smartarg) %{ +%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast ($&1_type smartarg) %{ // shared_ptr by value smartarg = *($&1_ltype*)&$input; if (smartarg) $1 = *smartarg; %} -%typemap(out) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > ANY_TYPE_SWIGSharedPtrUpcast %{ +%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > ANY_TYPE_SWIGSharedPtrUpcast %{ *($&1_ltype*)&$result = $1 ? new $1_ltype($1) : 0; %} @@ -447,10 +447,10 @@ } // CONST version needed ???? also for C# -%typemap(jtype, nopgcpp="1") SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< TYPE > swigSharedPtrUpcast "long" -%typemap(jtype, nopgcpp="1") SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast "long" +%typemap(jtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > swigSharedPtrUpcast "long" +%typemap(jtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast "long" -%template() SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; +%template() SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; %enddef From 79f7900968e18909a243eeef9ccba60a1112b5c7 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Mon, 5 Jan 2009 22:40:07 +0000 Subject: [PATCH 0274/1680] Mark SWIGPERL5, SWIGPHP5, and SWIGTCL8 as deprecated in the source code and remove documentation of them. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11030 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++++ Doc/Manual/Preprocessor.html | 3 --- Source/Modules/perl5.cxx | 1 + Source/Modules/php.cxx | 1 + Source/Modules/tcl8.cxx | 1 + 5 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index f9420f284..7eed740b9 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,10 @@ Version 1.3.37 (30 December 2008) ================================= +2009-01-05: olly + Mark SWIGPERL5, SWIGPHP5, and SWIGTCL8 as deprecated in the source + code and remove documentation of them. + 2008-12-30: wsfulton Bug #2430756. All the languages now define a macro in the generated C/C++ wrapper file indicating which language is being wrapped. The macro name is the diff --git a/Doc/Manual/Preprocessor.html b/Doc/Manual/Preprocessor.html index 2a0bbcceb..5afa59243 100644 --- a/Doc/Manual/Preprocessor.html +++ b/Doc/Manual/Preprocessor.html @@ -120,16 +120,13 @@ SWIGMZSCHEME Defined when using Mzscheme SWIGOCAML Defined when using Ocaml SWIGOCTAVE Defined when using Octave SWIGPERL Defined when using Perl -SWIGPERL5 Defined when using Perl5 SWIGPHP Defined when using PHP -SWIGPHP5 Defined when using PHP5 SWIGPIKE Defined when using Pike SWIGPYTHON Defined when using Python SWIGR Defined when using R SWIGRUBY Defined when using Ruby SWIGSEXP Defined when using S-expressions SWIGTCL Defined when using Tcl -SWIGTCL8 Defined when using Tcl8.0 SWIGXML Defined when using XML
    • diff --git a/Source/Modules/perl5.cxx b/Source/Modules/perl5.cxx index 56f84e046..3a8821ac8 100644 --- a/Source/Modules/perl5.cxx +++ b/Source/Modules/perl5.cxx @@ -207,6 +207,7 @@ public: } Preprocessor_define("SWIGPERL 1", 0); + // SWIGPERL5 is deprecated, and no longer documented. Preprocessor_define("SWIGPERL5 1", 0); SWIG_typemap_lang("perl5"); SWIG_config_file("perl5.swg"); diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index c103b6825..18a7fa9e9 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -239,6 +239,7 @@ public: } Preprocessor_define("SWIGPHP 1", 0); + // SWIGPHP5 is deprecated, and no longer documented. Preprocessor_define("SWIGPHP5 1", 0); SWIG_typemap_lang("php"); SWIG_config_file("php.swg"); diff --git a/Source/Modules/tcl8.cxx b/Source/Modules/tcl8.cxx index 9689c149b..24f3739c8 100644 --- a/Source/Modules/tcl8.cxx +++ b/Source/Modules/tcl8.cxx @@ -121,6 +121,7 @@ public: } Preprocessor_define("SWIGTCL 1", 0); + // SWIGTCL8 is deprecated, and no longer documented. Preprocessor_define("SWIGTCL8 1", 0); SWIG_typemap_lang("tcl8"); SWIG_config_file("tcl8.swg"); From ecd75a5c480d7a29ddbc72fb109c0c4c9b73a329 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 6 Jan 2009 18:13:57 +0000 Subject: [PATCH 0275/1680] Fix CCACHE_STRIPC being set when using swig as the compiler. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11031 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CCache/ccache.c | 2 +- CCache/test.sh | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/CCache/ccache.c b/CCache/ccache.c index 486964377..87089167b 100644 --- a/CCache/ccache.c +++ b/CCache/ccache.c @@ -233,7 +233,7 @@ static void to_cache(ARGS *args) x_asprintf(&tmp_stderr, "%s/tmp.stderr.%s", temp_dir, tmp_string()); x_asprintf(&tmp_outfiles, "%s/tmp.outfiles.%s", temp_dir, tmp_string()); - if (strip_c_option) { + if (strip_c_option && !swig) { args_add(stripped_args, "-c"); } diff --git a/CCache/test.sh b/CCache/test.sh index 2720462ba..4c735eb87 100755 --- a/CCache/test.sh +++ b/CCache/test.sh @@ -242,6 +242,15 @@ basetests() { checkstat 'cache hit' 10 checkstat 'cache miss' 38 + testname="stripc" # This test might not be portable + CCACHE_STRIPC=1 $CCACHE_COMPILE -c test1.c + checkstat 'cache hit' 10 + checkstat 'cache miss' 39 + + CCACHE_STRIPC=1 $CCACHE_COMPILE -c test1.c + checkstat 'cache hit' 11 + checkstat 'cache miss' 39 + # removed these tests as some compilers (including newer versions of gcc) # determine which language to use based on .ii/.i extension, and C++ may # not be installed @@ -375,6 +384,15 @@ swigtests() { checkstat 'cache hit' 6 checkstat 'cache miss' 6 + testname="stripc" + CCACHE_STRIPC=1 $CCACHE_COMPILE -java -O -O testswig1.i + checkstat 'cache hit' 7 + checkstat 'cache miss' 6 + + CCACHE_STRIPC=1 $CCACHE_COMPILE -java -O -O -O testswig1.i + checkstat 'cache hit' 7 + checkstat 'cache miss' 7 + rm -f testswig1-preproc.i rm -f testswig1.i } From 46e1ecd2d9dcbe8aeb7248da9fc48c6d3b5715ba Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 7 Jan 2009 00:45:04 +0000 Subject: [PATCH 0276/1680] log internal error wrt CCACHE_OUTFILES env variable git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11032 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CCache/ccache.c | 1 + 1 file changed, 1 insertion(+) diff --git a/CCache/ccache.c b/CCache/ccache.c index 87089167b..e35778147 100644 --- a/CCache/ccache.c +++ b/CCache/ccache.c @@ -256,6 +256,7 @@ static void to_cache(ARGS *args) x_asprintf(&ccache_outfiles, "CCACHE_OUTFILES=%s", tmp_outfiles); unlink(tmp_outfiles); if (getenv("CCACHE_OUTFILES") || putenv(ccache_outfiles) == -1) { + cc_log("CCACHE_OUTFILES env variable already set or could not be set\n"); stats_update(STATS_ERROR); failed(); } From e65ea565300a9c1f6f73fe1c16a9e084d7cce560 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 7 Jan 2009 00:50:06 +0000 Subject: [PATCH 0277/1680] Fix error display when there is a problem with CCACHE_OUTFILES git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11033 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 6ebc50449..6248691fc 100644 --- a/Source/Modules/main.cxx +++ b/Source/Modules/main.cxx @@ -1214,7 +1214,7 @@ int SWIG_main(int argc, char *argv[], Language *l) { File *f_outfiles = NewFile(outfiles, "w", 0); if (!f_outfiles) { Printf(stderr, "Failed to write list of output files to the filename '%s' specified in CCACHE_OUTFILES environment variable - ", outfiles); - FileErrorDisplay(f_outfiles); + FileErrorDisplay(outfiles); SWIG_exit(EXIT_FAILURE); } else { int i; From 7c81201d28a0c4a52f0fb1523e172fedf63f953b Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 7 Jan 2009 02:26:34 +0000 Subject: [PATCH 0278/1680] Fix lack of error logging in some situations and fix failure to work on windows when swig is a pure Win32 (non-cygwin) compile git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11034 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CCache/ccache.c | 12 ++++++++---- CCache/util.c | 26 ++++++++++++++++---------- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/CCache/ccache.c b/CCache/ccache.c index e35778147..0de4e4136 100644 --- a/CCache/ccache.c +++ b/CCache/ccache.c @@ -329,6 +329,9 @@ static void to_cache(ARGS *args) while (fgets(out_filename, FILENAME_MAX, file)) { char *linefeed = strchr(out_filename, '\n'); if (linefeed) { + char *potential_cr = linefeed - 1; + if (potential_cr >= out_filename && *potential_cr == '\r') + *potential_cr = 0; *linefeed = 0; if (cached_files_count == 0) { @@ -337,8 +340,7 @@ static void to_cache(ARGS *args) sprintf(out_filename_cache, "%s.%d", hashname, cached_files_count); } - if (stat(out_filename, &st1) != 0 || - commit_to_cache(out_filename, out_filename_cache, hardlink) != 0) { + if (commit_to_cache(out_filename, out_filename_cache, hardlink) != 0) { fclose(file); unlink(tmp_outfiles); failed(); @@ -374,8 +376,7 @@ static void to_cache(ARGS *args) failed(); } } else { - if (stat(output_file, &st1) != 0 || - commit_to_cache(output_file, hashname, hardlink) != 0) { + if (commit_to_cache(output_file, hashname, hardlink) != 0) { failed(); } to_cache_stats_helper(&st1, hashname, 0, &files_size, &cached_files_count); @@ -670,6 +671,9 @@ static void from_cache(int first) while (fgets(out_filename, FILENAME_MAX, file)) { char *linefeed = strchr(out_filename, '\n'); if (linefeed) { + char *potential_cr = linefeed - 1; + if (potential_cr >= out_filename && *potential_cr == '\r') + *potential_cr = 0; *linefeed = 0; if (retrieved_files_count == 0) { diff --git a/CCache/util.c b/CCache/util.c index f09256dfc..bba232492 100644 --- a/CCache/util.c +++ b/CCache/util.c @@ -349,20 +349,26 @@ int test_if_compressed(const char *filename) { int commit_to_cache(const char *src, const char *dest, int hardlink) { int ret = -1; - unlink(dest); - if (hardlink) { + struct stat st; + if (stat(src, &st) == 0) { + unlink(dest); + if (hardlink) { #ifdef _WIN32 - ret = CreateHardLinkA(dest, src, NULL) ? 0 : -1; + ret = CreateHardLinkA(dest, src, NULL) ? 0 : -1; #else - ret = link(src, dest); + ret = link(src, dest); #endif - } - if (ret == -1) { - ret = copy_file_to_cache(src, dest); - if (ret == -1) { - cc_log("failed to commit %s -> %s (%s)\n", src, dest, strerror(errno)); - stats_update(STATS_ERROR); } + if (ret == -1) { + ret = copy_file_to_cache(src, dest); + if (ret == -1) { + cc_log("failed to commit %s -> %s (%s)\n", src, dest, strerror(errno)); + stats_update(STATS_ERROR); + } + } + } else { + cc_log("failed to put %s in the cache (%s)\n", src, strerror(errno)); + stats_update(STATS_ERROR); } return ret; } From e3f63c33f3a4b3d5b42833be5ae1e053d0a67bae Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 7 Jan 2009 10:36:00 +0000 Subject: [PATCH 0279/1680] remove unnecessary logging on Win32 builds git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11035 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CCache/execute.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/CCache/execute.c b/CCache/execute.c index aef73fba1..214b233b4 100644 --- a/CCache/execute.c +++ b/CCache/execute.c @@ -145,8 +145,6 @@ int execute(char **argv, status = _spawnv(_P_WAIT, argv[0], (const char **)argv); out: - cc_log("%s:\n stdout -> %s\n stderr -> %s\n process status=%i\n", - argv[0], path_stdout, path_stderr, status); if (status == -1) cc_log("Error %i: %s\n", errno, strerror(errno)); /* Restore descriptors */ From a80aa441aa9cfb95bed9ace464aa37e7616b1f9c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 7 Jan 2009 11:24:07 +0000 Subject: [PATCH 0280/1680] reorder new test git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11036 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CCache/test.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/CCache/test.sh b/CCache/test.sh index 4c735eb87..0daa30561 100755 --- a/CCache/test.sh +++ b/CCache/test.sh @@ -242,15 +242,6 @@ basetests() { checkstat 'cache hit' 10 checkstat 'cache miss' 38 - testname="stripc" # This test might not be portable - CCACHE_STRIPC=1 $CCACHE_COMPILE -c test1.c - checkstat 'cache hit' 10 - checkstat 'cache miss' 39 - - CCACHE_STRIPC=1 $CCACHE_COMPILE -c test1.c - checkstat 'cache hit' 11 - checkstat 'cache miss' 39 - # removed these tests as some compilers (including newer versions of gcc) # determine which language to use based on .ii/.i extension, and C++ may # not be installed @@ -264,6 +255,15 @@ basetests() { # checkstat 'cache hit' 11 # checkstat 'cache miss' 39 + testname="stripc" # This test might not be portable + CCACHE_STRIPC=1 $CCACHE_COMPILE -c test1.c + checkstat 'cache hit' 10 + checkstat 'cache miss' 39 + + CCACHE_STRIPC=1 $CCACHE_COMPILE -c test1.c + checkstat 'cache hit' 11 + checkstat 'cache miss' 39 + testname="zero-stats" $CCACHE -z > /dev/null checkstat 'cache hit' 0 From f94edcd85559cec9fb1f409394c8a36a457acebc Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 7 Jan 2009 16:54:54 +0000 Subject: [PATCH 0281/1680] Fix spaces in CCACHE_DIR and probably other places git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11037 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CCache/execute.c | 4 ++-- CCache/test.sh | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/CCache/execute.c b/CCache/execute.c index 214b233b4..5a5592bf5 100644 --- a/CCache/execute.c +++ b/CCache/execute.c @@ -56,7 +56,7 @@ int execute(char **argv, { #ifdef _WIN32 -#if 0 +#if 1 PROCESS_INFORMATION pinfo; STARTUPINFO sinfo; BOOL ret; @@ -110,7 +110,7 @@ int execute(char **argv, return exitcode; #else /* possibly slightly faster */ - /* Should be portable */ + /* needs fixing to quote commandline options to handle spaces in CCACHE_DIR etc */ int status = -2; int fd, std_od = -1, std_ed = -1; diff --git a/CCache/test.sh b/CCache/test.sh index 0daa30561..9581c85e3 100755 --- a/CCache/test.sh +++ b/CCache/test.sh @@ -74,7 +74,7 @@ checkstat() { basetests() { echo "starting testsuite $testsuite" - rm -rf .ccache + rm -rf "$CCACHE_DIR" checkstat 'cache hit' 0 checkstat 'cache miss' 0 @@ -279,7 +279,7 @@ basetests() { swigtests() { echo "starting swig testsuite $testsuite" - rm -rf .ccache + rm -rf "$CCACHE_DIR" checkstat 'cache hit' 0 checkstat 'cache miss' 0 @@ -402,8 +402,8 @@ swigtests() { rm -rf $TESTDIR mkdir $TESTDIR cd $TESTDIR || exit 1 -mkdir .ccache -CCACHE_DIR=.ccache +CCACHE_DIR="ccache dir" # with space in directory name (like Windows default) +mkdir "$CCACHE_DIR" export CCACHE_DIR testsuite="base" From c577ac1a31a8ae385405088e7faf475229f03ab1 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 7 Jan 2009 21:10:46 +0000 Subject: [PATCH 0282/1680] Rename embedded smart pointer in SwigValueWrapper in order to avoid conflicts with the template type git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11038 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/swig.swg | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Lib/swig.swg b/Lib/swig.swg index 4e0657587..05294a9a5 100644 --- a/Lib/swig.swg +++ b/Lib/swig.swg @@ -634,7 +634,7 @@ namespace std { * arg1 = Vector(1,2,3); // Assignment from a value * * The class offers a strong guarantee of exception safety. - * With regards to the implementation, the private Pointer nested class is + * With regards to the implementation, the private SwigMovePointer nested class is * a simple smart pointer with move semantics, much like std::auto_ptr. * * This wrapping technique was suggested by William Fulton and is henceforth @@ -646,17 +646,17 @@ namespace std { #ifdef __cplusplus /* SwigValueWrapper is described in swig.swg */ template class SwigValueWrapper { - struct Pointer { + struct SwigMovePointer { T *ptr; - Pointer(T *p) : ptr(p) { } - ~Pointer() { delete ptr; } - Pointer& operator=(Pointer& rhs) { T* oldptr = ptr; ptr = 0; delete oldptr; ptr = rhs.ptr; rhs.ptr = 0; return *this; } + SwigMovePointer(T *p) : ptr(p) { } + ~SwigMovePointer() { delete ptr; } + SwigMovePointer& operator=(SwigMovePointer& rhs) { T* oldptr = ptr; ptr = 0; delete oldptr; ptr = rhs.ptr; rhs.ptr = 0; return *this; } } pointer; SwigValueWrapper& operator=(const SwigValueWrapper& rhs); SwigValueWrapper(const SwigValueWrapper& rhs); public: SwigValueWrapper() : pointer(0) { } - SwigValueWrapper& operator=(const T& t) { Pointer tmp(new T(t)); pointer = tmp; return *this; } + SwigValueWrapper& operator=(const T& t) { SwigMovePointer tmp(new T(t)); pointer = tmp; return *this; } operator T&() const { return *pointer.ptr; } T *operator&() { return pointer.ptr; } };%} From 2e68619a9f31985b9d45441a46a33e2fdc542141 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 8 Jan 2009 17:52:15 +0000 Subject: [PATCH 0283/1680] add some missing stats and logging git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11039 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CCache/ccache.c | 11 ++++++++++- CCache/ccache.h | 1 + CCache/execute.c | 12 +++--------- CCache/stats.c | 1 + 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/CCache/ccache.c b/CCache/ccache.c index 0de4e4136..d1696da88 100644 --- a/CCache/ccache.c +++ b/CCache/ccache.c @@ -125,6 +125,7 @@ static void failed(void) if ((e=getenv("CCACHE_PREFIX"))) { char *p = find_executable(e, MYNAME); if (!p) { + cc_log("could not find executable (%s)\n", e); perror(e); exit(1); } @@ -535,8 +536,8 @@ static void find_hash(ARGS *args) correct i_tmpfile */ path_stdout = x_strdup(input_file); if (create_empty_file(path_stderr) != 0) { - stats_update(STATS_ERROR); cc_log("failed to create empty stderr file\n"); + stats_update(STATS_ERROR); failed(); } status = 0; @@ -592,6 +593,7 @@ static void find_hash(ARGS *args) char *p; if (create_dir(hash_dir) != 0) { cc_log("failed to create %s\n", hash_dir); + stats_update(STATS_ERROR); failed(); } x_asprintf(&p, "%s/%c", hash_dir, s[i]); @@ -600,6 +602,7 @@ static void find_hash(ARGS *args) } if (create_dir(hash_dir) != 0) { cc_log("failed to create %s\n", hash_dir); + stats_update(STATS_ERROR); failed(); } x_asprintf(&hashname, "%s/%s", hash_dir, s+nlevels); @@ -785,6 +788,7 @@ static void find_compiler(int argc, char **argv) /* can't find the compiler! */ if (!orig_args->argv[0]) { stats_update(STATS_COMPILER); + cc_log("could not find compiler (%s)\n", base); perror(base); exit(1); } @@ -1069,6 +1073,7 @@ static void process_args(int argc, char **argv) if (p) { if (strlen(p) < 2) { + cc_log("badly formed dependency file %s\n", output_file); stats_update(STATS_ARGS); failed(); return; @@ -1105,6 +1110,8 @@ static void process_args(int argc, char **argv) if ((e=getenv("CCACHE_PREFIX"))) { char *p = find_executable(e, MYNAME); if (!p) { + cc_log("could not find executable (%s)\n", e); + stats_update(STATS_ENVIRONMMENT); perror(e); exit(1); } @@ -1288,6 +1295,7 @@ static void setup_uncached_err(void) uncached_fd = dup(2); if (uncached_fd == -1) { cc_log("dup(2) failed\n"); + stats_update(STATS_ERROR); failed(); } @@ -1296,6 +1304,7 @@ static void setup_uncached_err(void) if (putenv(buf) == -1) { cc_log("putenv failed\n"); + stats_update(STATS_ERROR); failed(); } } diff --git a/CCache/ccache.h b/CCache/ccache.h index e95a92c43..668ce8288 100644 --- a/CCache/ccache.h +++ b/CCache/ccache.h @@ -84,6 +84,7 @@ enum stats { STATS_NOTC, STATS_DEVICE, STATS_NOINPUT, + STATS_ENVIRONMMENT, STATS_MULTIPLE, STATS_CONFTEST, STATS_UNSUPPORTED, diff --git a/CCache/execute.c b/CCache/execute.c index 5a5592bf5..165b91e66 100644 --- a/CCache/execute.c +++ b/CCache/execute.c @@ -123,9 +123,7 @@ int execute(char **argv, std_od = _dup(1); fd = _open(path_stdout, O_WRONLY|O_CREAT|O_TRUNC|O_EXCL|O_BINARY, 0666); if (fd == -1) { - status = STATUS_NOCACHE; - cc_log("stdout error: failed to open %s\n", path_stdout); - goto out; + exit(STATUS_NOCACHE); } _dup2(fd, 1); _close(fd); @@ -134,9 +132,7 @@ int execute(char **argv, fd = _open(path_stderr, O_WRONLY|O_CREAT|O_TRUNC|O_EXCL|O_BINARY, 0666); std_ed = _dup(2); if (fd == -1) { - status = STATUS_NOCACHE; - cc_log("stderr error: failed to open %s\n", path_stderr); - goto out; + exit(STATUS_NOCACHE); } _dup2(fd, 2); _close(fd); @@ -144,9 +140,6 @@ int execute(char **argv, /* Spawn process (_exec* familly doesn't return) */ status = _spawnv(_P_WAIT, argv[0], (const char **)argv); -out: - if (status == -1) cc_log("Error %i: %s\n", errno, strerror(errno)); - /* Restore descriptors */ if (std_od != -1) _dup2(std_od, 1); if (std_ed != -1) _dup2(std_ed, 2); @@ -235,6 +228,7 @@ char *find_executable(const char *name, const char *exclude_name) } if (!path) { cc_log("no PATH variable!?\n"); + stats_update(STATS_ENVIRONMMENT); return NULL; } diff --git a/CCache/stats.c b/CCache/stats.c index f87264794..92bc4a835 100644 --- a/CCache/stats.c +++ b/CCache/stats.c @@ -55,6 +55,7 @@ static struct { { STATS_OUTSTDOUT, "output to stdout ", NULL, 0 }, { STATS_DEVICE, "output to a non-regular file ", NULL, 0 }, { STATS_NOINPUT, "no input file ", NULL, 0 }, + { STATS_ENVIRONMMENT, "error due to bad env variable ", NULL, 0 }, { STATS_NUMFILES, "files in cache ", NULL, FLAG_NOZERO|FLAG_ALWAYS }, { STATS_TOTALSIZE, "cache size ", display_size , FLAG_NOZERO|FLAG_ALWAYS }, { STATS_MAXFILES, "max files ", NULL, FLAG_NOZERO }, From a1fdbfd28238d1a2bf914b98e9708605999cb12e Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 8 Jan 2009 19:12:24 +0000 Subject: [PATCH 0284/1680] missing function declaration fix git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11040 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/csharp/arrays/example.i | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Examples/csharp/arrays/example.i b/Examples/csharp/arrays/example.i index 22b9aa19d..488565a74 100644 --- a/Examples/csharp/arrays/example.i +++ b/Examples/csharp/arrays/example.i @@ -1,6 +1,9 @@ /* File : example.i */ %module example +%{ +#include "example.h" +%} %include "arrays_csharp.i" %apply int INPUT[] { int* sourceArray } From e2679a6fd307b5927b911fe9b06485a49cb12608 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 8 Jan 2009 19:20:51 +0000 Subject: [PATCH 0285/1680] correct return type for PyUnicode_GetSize git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11041 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/python/pywstrings.swg | 2 +- Lib/ruby/rubywstrings.swg | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/python/pywstrings.swg b/Lib/python/pywstrings.swg index 4161dcb0f..7c36f248d 100644 --- a/Lib/python/pywstrings.swg +++ b/Lib/python/pywstrings.swg @@ -17,7 +17,7 @@ SWIG_AsWCharPtrAndSize(PyObject *obj, wchar_t **cptr, size_t *psize, int *alloc) } %#endif if (isunicode) { - int len = PyUnicode_GetSize(obj); + Py_ssize_t len = PyUnicode_GetSize(obj); if (cptr) { *cptr = %new_array(len + 1, wchar_t); PyUnicode_AsWideChar((PyUnicodeObject *)obj, *cptr, len); diff --git a/Lib/ruby/rubywstrings.swg b/Lib/ruby/rubywstrings.swg index 0cf9d7ed9..862928c95 100644 --- a/Lib/ruby/rubywstrings.swg +++ b/Lib/ruby/rubywstrings.swg @@ -29,7 +29,7 @@ SWIG_AsWCharPtrAndSize(VALUE obj, wchar_t **cptr, size_t *psize, int *alloc) // } // } // if (ok) { -// int len = PyUnicode_GetSize(obj); +// Py_ssize_t len = PyUnicode_GetSize(obj); // rb_notimplement(); // if (cptr) { // *cptr = %new_array(len + 1, wchar_t); From ed0ae261bfdaa75c7080692d16c3f32d370b45fa Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 8 Jan 2009 19:35:13 +0000 Subject: [PATCH 0286/1680] fix cast of pointer to long git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11042 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/python/swigobject_runme.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Examples/test-suite/python/swigobject_runme.py b/Examples/test-suite/python/swigobject_runme.py index 7f629e1d5..ad78ee4fb 100644 --- a/Examples/test-suite/python/swigobject_runme.py +++ b/Examples/test-suite/python/swigobject_runme.py @@ -12,12 +12,15 @@ if a1.this != a2.this: lthis = long(a.this) -xstr1 = "0x%x" % (lthis,) +# match pointer value, but deal with leading zeros on 8/16 bit systems +xstr8bit = "%08X" % (lthis,) +xstr16bit = "%016X" % (lthis,) xstr2 = pointer_str(a) -if xstr1 != xstr2: - print xstr1, xstr2 - raise RuntimeError +if xstr8bit != xstr2: + if xstr16bit != xstr2: + print xstr8bit, xstr16bit, xstr2 + raise RuntimeError s = str(a.this) r = repr(a.this) From 95ccff69528f5a88f36edd9f66874849797d33dc Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 8 Jan 2009 19:46:38 +0000 Subject: [PATCH 0287/1680] fix cast of pointer to long git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11043 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/swigobject.i | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/test-suite/swigobject.i b/Examples/test-suite/swigobject.i index 2e77969b9..2ec064509 100644 --- a/Examples/test-suite/swigobject.i +++ b/Examples/test-suite/swigobject.i @@ -10,7 +10,7 @@ const char* pointer_str(A *a){ static char result[1024]; - sprintf(result,"0x%lx", (unsigned long)(void *)a); + sprintf(result,"%p", a); return result; } From 3f03858862ebd1a065eb9cb2bf6e6cda4c941f7c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 8 Jan 2009 23:29:33 +0000 Subject: [PATCH 0288/1680] minor formatting git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11044 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/python/pyrun.swg | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index cb1cde5ee..52e5d892b 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -682,12 +682,12 @@ _PySwigObject_type(void) { if (!type_init) { const PyTypeObject tmp = { - /* PyOjbect header changed in Python 3 */ + /* PyOjbect header changed in Python 3 */ #if PY_VERSION_HEX >= 0x03000000 - PyVarObject_HEAD_INIT(&PyType_Type, 0) + PyVarObject_HEAD_INIT(&PyType_Type, 0) #else - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ + PyObject_HEAD_INIT(NULL) + 0, /* ob_size */ #endif (char *)"SwigPyObject", /* tp_name */ sizeof(SwigPyObject), /* tp_basicsize */ @@ -732,11 +732,11 @@ _PySwigObject_type(void) { 0, /* tp_alloc */ 0, /* tp_new */ 0, /* tp_free */ - 0, /* tp_is_gc */ + 0, /* tp_is_gc */ 0, /* tp_bases */ 0, /* tp_mro */ 0, /* tp_cache */ - 0, /* tp_subclasses */ + 0, /* tp_subclasses */ 0, /* tp_weaklist */ #endif #if PY_VERSION_HEX >= 0x02030000 From 9c53670fed145fdc85861c3f69827afbac09b697 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 9 Jan 2009 22:19:06 +0000 Subject: [PATCH 0289/1680] warning fix git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11045 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/python/multimap/example.i | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Examples/python/multimap/example.i b/Examples/python/multimap/example.i index 3d5a09771..f1c4d9990 100644 --- a/Examples/python/multimap/example.i +++ b/Examples/python/multimap/example.i @@ -17,7 +17,6 @@ extern int gcd(int x, int y); %typemap(in,fragment="t_output_helper") (int argc, char *argv[]) { int i; - int l; if (!PyList_Check($input)) { SWIG_exception(SWIG_ValueError, "Expecting a list"); } @@ -38,7 +37,10 @@ extern int gcd(int x, int y); SWIG_exception(SWIG_ValueError, "List items must be strings"); } %#if PY_VERSION_HEX >= 0x03000000 + { + int l; $2[i] = PyUnicode_AsStringAndSize(s, &l); + } %#else $2[i] = PyString_AsString(s); %#endif From 8b857aa9c1ed0f9a1bd209ff2dbbb6a9dee4b31f Mon Sep 17 00:00:00 2001 From: Xavier Delacour Date: Fri, 9 Jan 2009 23:38:14 +0000 Subject: [PATCH 0290/1680] Fix octave tests li_std_pair_extra, arrays_global, grouping, struct_value, unions. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11046 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/octave/octrun.swg | 18 ++++-------------- Lib/octave/octruntime.swg | 1 + 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/Lib/octave/octrun.swg b/Lib/octave/octrun.swg index 07aa47cb5..c98dda984 100644 --- a/Lib/octave/octrun.swg +++ b/Lib/octave/octrun.swg @@ -684,22 +684,9 @@ namespace Swig { return outarg(0).string_value(); } - /* virtual Octave_map map_value() const { - octave_swig_type *nc_this = const_cast < octave_swig_type *>(this); - member_value_pair *m = nc_this->find_member("__str", false); - if (!m) { - error("__map method not defined"); - return std::string(); - } - octave_value_list outarg = nc_this->member_invoke(m, octave_value_list(nc_this->as_value()), 1); - if (outarg.length() < 1 || !outarg(0).is_map()) { - error("__map method did not return a string"); - return std::string(); - } - return outarg(0).map_value(); + return Octave_map(); } - */ virtual string_vector map_keys() const { member_map tmp; @@ -876,6 +863,9 @@ namespace Swig { virtual std::string string_value(bool force = false) const { return ptr->string_value(force); } + virtual Octave_map map_value() const + { return ptr->map_value(); } + virtual string_vector map_keys() const { return ptr->map_keys(); } diff --git a/Lib/octave/octruntime.swg b/Lib/octave/octruntime.swg index dd68ca4c1..82a17285a 100644 --- a/Lib/octave/octruntime.swg +++ b/Lib/octave/octruntime.swg @@ -3,6 +3,7 @@ #include #include #include +#include %} %insert(runtime) "swigrun.swg"; From b6e44f2427c95664d3d77c7d9d8afc79f9acbdc3 Mon Sep 17 00:00:00 2001 From: Xavier Delacour Date: Sat, 10 Jan 2009 00:20:46 +0000 Subject: [PATCH 0291/1680] Octave: add {save,load}_{ascii,binary,hdf} functions that silently do nothing; give default operator mappings a more conventional suffix; fix test li_std_string_extra. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11047 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- .../octave/li_std_string_extra_runme.m | 22 ++-- Lib/octave/octcontainer.swg | 4 +- Lib/octave/octopers.swg | 116 +++++++++--------- Lib/octave/octrun.swg | 99 +++++++++++++-- Lib/octave/std_basic_string.i | 38 ++---- 5 files changed, 173 insertions(+), 106 deletions(-) diff --git a/Examples/test-suite/octave/li_std_string_extra_runme.m b/Examples/test-suite/octave/li_std_string_extra_runme.m index 75cec17fe..8d506af8a 100644 --- a/Examples/test-suite/octave/li_std_string_extra_runme.m +++ b/Examples/test-suite/octave/li_std_string_extra_runme.m @@ -23,16 +23,16 @@ endif s = li_std_string_extra.string("he"); #s += "ll" -#s.append('o') +#s.append("ll") s = s + "llo"; if (s != x) error("bad string mapping: %s, %s", s, x); endif -if (s[1:4] != x[1:4]) - error("bad string mapping") -endif +#if (s(1:4) != x(1:4)) +# error("bad string mapping") +#endif if (li_std_string_extra.test_value(s) != x) error("bad string mapping") @@ -63,11 +63,11 @@ if (a + " world" != "hello world") error("bad string mapping") endif -if ("hello" + b != "hello world") - error("bad string mapping") -endif +#if ("hello" + b != "hello world") +# error("bad string mapping") +#endif -c = ("hello" + b) +c = (li_std_string_extra.string("hello") + b); if (c.find_last_of("l") != 9) error("bad string mapping") endif @@ -157,6 +157,6 @@ if (li_std_string_extra.c_empty() != "") error endif -if (li_std_string_extra.c_null() != None) - error -endif +#if (li_std_string_extra.c_null() != None) +# error +#endif diff --git a/Lib/octave/octcontainer.swg b/Lib/octave/octcontainer.swg index f3ba01713..afc3ed147 100644 --- a/Lib/octave/octcontainer.swg +++ b/Lib/octave/octcontainer.swg @@ -513,11 +513,11 @@ namespace swig return x; } - value_type __paren(difference_type i) throw (std::out_of_range) { + value_type __paren__(difference_type i) throw (std::out_of_range) { return *(swig::cgetpos(self, i)); } - void __paren_asgn(difference_type i, value_type x) throw (std::out_of_range) { + void __paren_asgn__(difference_type i, value_type x) throw (std::out_of_range) { *(swig::getpos(self,i)) = x; } diff --git a/Lib/octave/octopers.swg b/Lib/octave/octopers.swg index a9ccf44b8..c38e64d8c 100644 --- a/Lib/octave/octopers.swg +++ b/Lib/octave/octopers.swg @@ -6,68 +6,68 @@ // operators supported in Octave, and the methods they are routed to -// __brace a{args} -// __brace_asgn a{args} = rhs -// __paren a(args) -// __paren_asgn a(args) = rhs -// __str generates string rep +// __brace__ a{args} +// __brace_asgn__ a{args} = rhs +// __paren__ a(args) +// __paren_asgn__ a(args) = rhs +// __str__ generates string rep -// __not !a -// __uplus +a -// __uminus -a -// __transpose a.' -// __hermitian a' -// __incr a++ -// __decr a-- -// __add a + b -// __sub a - b -// __mul a * b -// __div a / b -// __pow a ^ b -// __ldiv a \ b -// __lshift a << b -// __rshift a >> b -// __lt a < b -// __le a <= b -// __eq a == b -// __ge a >= b -// __gt a > b -// __ne a != b -// __el_mul a .* b -// __el_div a ./ b -// __el_pow a .^ b -// __el_ldiv a .\ b -// __el_and a & b -// __el_or a | b +// __not__ !a +// __uplus__ +a +// __uminus__ -a +// __transpose__ a.' +// __hermitian__ a' +// __incr__ a++ +// __decr__ a-- +// __add__ a + b +// __sub__ a - b +// __mul__ a * b +// __div__ a / b +// __pow__ a ^ b +// __ldiv__ a \ b +// __lshift__ a << b +// __rshift__ a >> b +// __lt__ a < b +// __le__ a <= b +// __eq__ a == b +// __ge__ a >= b +// __gt__ a > b +// __ne__ a != b +// __el_mul__ a .* b +// __el_div__ a ./ b +// __el_pow__ a .^ b +// __el_ldiv__ a .\ b +// __el_and__ a & b +// __el_or__ a | b // operators supported in C++, and the methods that route to them -%rename(__add) *::operator+; -%rename(__add) *::operator+(); -%rename(__add) *::operator+() const; -%rename(__sub) *::operator-; -%rename(__uminus) *::operator-(); -%rename(__uminus) *::operator-() const; -%rename(__mul) *::operator*; -%rename(__div) *::operator/; -%rename(__mod) *::operator%; -%rename(__lshift) *::operator<<; -%rename(__rshift) *::operator>>; -%rename(__el_and) *::operator&&; -%rename(__el_or) *::operator||; -%rename(__xor) *::operator^; -%rename(__invert) *::operator~; -%rename(__lt) *::operator<; -%rename(__le) *::operator<=; -%rename(__gt) *::operator>; -%rename(__ge) *::operator>=; -%rename(__eq) *::operator==; -%rename(__ne) *::operator!=; -%rename(__not) *::operator!; -%rename(__incr) *::operator++; -%rename(__decr) *::operator--; -%rename(__paren) *::operator(); -%rename(__brace) *::operator[]; +%rename(__add__) *::operator+; +%rename(__add__) *::operator+(); +%rename(__add__) *::operator+() const; +%rename(__sub__) *::operator-; +%rename(__uminus__) *::operator-(); +%rename(__uminus__) *::operator-() const; +%rename(__mul__) *::operator*; +%rename(__div__) *::operator/; +%rename(__mod__) *::operator%; +%rename(__lshift__) *::operator<<; +%rename(__rshift__) *::operator>>; +%rename(__el_and__) *::operator&&; +%rename(__el_or__) *::operator||; +%rename(__xor__) *::operator^; +%rename(__invert__) *::operator~; +%rename(__lt__) *::operator<; +%rename(__le__) *::operator<=; +%rename(__gt__) *::operator>; +%rename(__ge__) *::operator>=; +%rename(__eq__) *::operator==; +%rename(__ne__) *::operator!=; +%rename(__not__) *::operator!; +%rename(__incr__) *::operator++; +%rename(__decr__) *::operator--; +%rename(__paren__) *::operator(); +%rename(__brace__) *::operator[]; // Ignored inplace operators %ignoreoperator(PLUSEQ) operator+=; diff --git a/Lib/octave/octrun.swg b/Lib/octave/octrun.swg index c98dda984..c48310e27 100644 --- a/Lib/octave/octrun.swg +++ b/Lib/octave/octrun.swg @@ -589,7 +589,7 @@ namespace Swig { // index operator else { if (ops[skip] == '(' || ops[skip] == '{') { - const char *op_name = ops[skip] == '(' ? "__paren" : "__brace"; + const char *op_name = ops[skip] == '(' ? "__paren__" : "__brace__"; octave_value_list args; args.append(*idx_it++); ++skip; @@ -628,7 +628,7 @@ namespace Swig { } else if (ops[skip] == '(' || ops[skip] == '{') { - const char *op_name = ops[skip] == '(' ? "__paren_asgn" : "__brace_asgn"; + const char *op_name = ops[skip] == '(' ? "__paren_asgn__" : "__brace_asgn__"; member_value_pair *m = find_member(op_name, false); if (m) { octave_value_list args; @@ -666,19 +666,19 @@ namespace Swig { virtual bool is_string() const { octave_swig_type *nc_this = const_cast < octave_swig_type *>(this); - return !!nc_this->find_member("__str", false); + return !!nc_this->find_member("__str__", false); } virtual std::string string_value(bool force = false) const { octave_swig_type *nc_this = const_cast < octave_swig_type *>(this); - member_value_pair *m = nc_this->find_member("__str", false); + member_value_pair *m = nc_this->find_member("__str__", false); if (!m) { - error("__str method not defined"); + error("__str__ method not defined"); return std::string(); } octave_value_list outarg = nc_this->member_invoke(m, octave_value_list(nc_this->as_value()), 1); if (outarg.length() < 1 || !outarg(0).is_string()) { - error("__str method did not return a string"); + error("__str__ method did not return a string"); return std::string(); } return outarg(0).string_value(); @@ -700,6 +700,35 @@ namespace Swig { return keys; } + virtual bool save_ascii (std::ostream& os) { + return true; + } + + virtual bool load_ascii (std::istream& is) { + return true; + } + + virtual bool save_binary (std::ostream& os, bool& save_as_floats) { + return true; + } + + virtual bool load_binary (std::istream& is, bool swap, + oct_mach_info::float_format fmt) { + return true; + } + +#if defined (HAVE_HDF5) + virtual bool + save_hdf5 (hid_t loc_id, const char *name, bool save_as_floats) { + return true; + } + + virtual bool + load_hdf5 (hid_t loc_id, const char *name, bool have_h5giterate_bug) { + return true; + } +#endif + virtual octave_value convert_to_str(bool pad = false, bool force = false, char type = '"') const { return string_value(); } @@ -724,7 +753,7 @@ namespace Swig { assert(ost); octave_value ret; - if (ost->dispatch_unary_op(std::string("__") + op_name, ret)) + if (ost->dispatch_unary_op(std::string("__") + op_name + std::string("__"), ret)) return ret; std::string symbol = "op_" + ost->swig_type_name() + "_" + op_name; octave_value_list args; @@ -741,7 +770,7 @@ namespace Swig { octave_swig_type *rhs_ost = Swig::swig_value_deref(rhs); octave_value ret; - if (lhs_ost && lhs_ost->dispatch_binary_op(std::string("__") + op_name, rhs, ret)) + if (lhs_ost && lhs_ost->dispatch_binary_op(std::string("__") + op_name + std::string("__"), rhs, ret)) return ret; std::string symbol; @@ -869,6 +898,29 @@ namespace Swig { virtual string_vector map_keys() const { return ptr->map_keys(); } + virtual bool save_ascii (std::ostream& os) + { return ptr->save_ascii(os); } + + virtual bool load_ascii (std::istream& is) + { return ptr->load_ascii(is); } + + virtual bool save_binary (std::ostream& os, bool& save_as_floats) + { return ptr->save_binary(os, save_as_floats); } + + virtual bool load_binary (std::istream& is, bool swap, + oct_mach_info::float_format fmt) + { return ptr->load_binary(is, swap, fmt); } + +#if defined (HAVE_HDF5) + virtual bool + save_hdf5 (hid_t loc_id, const char *name, bool save_as_floats) + { return ptr->save_hdf5(loc_id, name, save_as_floats); } + + virtual bool + load_hdf5 (hid_t loc_id, const char *name, bool have_h5giterate_bug) + { return ptr->load_hdf5(loc_id, name, have_h5giterate_bug); } +#endif + virtual octave_value convert_to_str(bool pad = false, bool force = false, char type = '"') const { return ptr->convert_to_str(pad, force, type); } @@ -917,6 +969,37 @@ namespace Swig { void print(std::ostream &os, bool pr_as_read_syntax = false) const { os << "swig packed type: name = " << (type ? type->name : std::string()) << ", len = " << buf.size() << std::endl; } + + + virtual bool save_ascii (std::ostream& os) { + return true; + } + + virtual bool load_ascii (std::istream& is) { + return true; + } + + virtual bool save_binary (std::ostream& os, bool& save_as_floats) { + return true; + } + + virtual bool load_binary (std::istream& is, bool swap, + oct_mach_info::float_format fmt) { + return true; + } + +#if defined (HAVE_HDF5) + virtual bool + save_hdf5 (hid_t loc_id, const char *name, bool save_as_floats) { + return true; + } + + virtual bool + load_hdf5 (hid_t loc_id, const char *name, bool have_h5giterate_bug) { + return true; + } +#endif + private: DECLARE_OCTAVE_ALLOCATOR; DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA; diff --git a/Lib/octave/std_basic_string.i b/Lib/octave/std_basic_string.i index f2dac405a..9fc0b0730 100644 --- a/Lib/octave/std_basic_string.i +++ b/Lib/octave/std_basic_string.i @@ -1,5 +1,6 @@ #if !defined(SWIG_STD_STRING) #define SWIG_STD_BASIC_STRING +#define SWIG_STD_MODERN_STL %include @@ -9,39 +10,22 @@ %fragment(SWIG_AsPtr_frag(std::basic_string),"header", fragment="SWIG_AsCharPtrAndSize") { SWIGINTERN int -SWIG_AsPtr(std::basic_string)(PyObject* obj, std::string **val) +SWIG_AsPtr(std::basic_string)(octave_value obj, std::string **val) { - static swig_type_info* string_info = - SWIG_TypeQuery("std::basic_string *"); - std::string *vptr; - if (SWIG_ConvertPtr(obj, (void**)&vptr, string_info, 0) == SWIG_OK) { - if (val) *val = vptr; - return SWIG_OLDOBJ; - } else { - PyErr_Clear(); - char* buf = 0 ; size_t size = 0; int alloc = 0; - if (SWIG_AsCharPtrAndSize(obj, &buf, &size, &alloc) == SWIG_OK) { - if (buf) { - if (val) *val = new std::string(buf, size - 1); - if (alloc == SWIG_NEWOBJ) %delete_array(buf); - return SWIG_NEWOBJ; - } - } else { - PyErr_Clear(); - } - if (val) { - SWIG_PYTHON_THREAD_BEGIN_BLOCK; - PyErr_SetString(PyExc_TypeError,"a string is expected"); - SWIG_PYTHON_THREAD_END_BLOCK; - } - return 0; + if (obj.is_string()) { + if (val) + *val = new std::string(obj.string_value()); + return SWIG_NEWOBJ; } -} + if (val) + error("a string is expected"); + return 0; +} } %fragment(SWIG_From_frag(std::basic_string),"header", fragment="SWIG_FromCharPtrAndSize") { -SWIGINTERNINLINE PyObject* +SWIGINTERNINLINE octave_value SWIG_From(std::basic_string)(const std::string& s) { return SWIG_FromCharPtrAndSize(s.data(), s.size()); From 63369773503eaf0c76c797182a06395ce5bdb961 Mon Sep 17 00:00:00 2001 From: Xavier Delacour Date: Sat, 10 Jan 2009 00:29:37 +0000 Subject: [PATCH 0292/1680] Fix octave test allprotected. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11048 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/octave.cxx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Source/Modules/octave.cxx b/Source/Modules/octave.cxx index 4ad0a1b96..c9febcbba 100644 --- a/Source/Modules/octave.cxx +++ b/Source/Modules/octave.cxx @@ -40,6 +40,13 @@ public: OCTAVE():f_runtime(0), f_header(0), f_doc(0), f_wrappers(0), f_init(0), f_initbeforefunc(0), f_directors(0), f_directors_h(0), s_global_tab(0), s_members_tab(0), class_name(0) { + /* Add code to manage protected constructors and directors */ + director_prot_ctor_code = NewString(""); + Printv(director_prot_ctor_code, + "if ( $comparison ) { /* subclassed */\n", + " $director_new \n", + "} else {\n", " error(\"accessing abstract class or protected constructor\"); \n", " SWIG_fail;\n", "}\n", NIL); + enable_cplus_runtime_mode(); allow_overloading(); director_multiple_inheritance = 1; From b91631c1305d695f1844b1bfdc5ccf809eedb045 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 10 Jan 2009 01:15:03 +0000 Subject: [PATCH 0293/1680] Patch #1992756 from Colin McDonald - %contract not working for classes in namespace git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11049 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 +++ Examples/test-suite/contract.i | 30 ++++++++++++++++++++ Examples/test-suite/python/contract_runme.py | 8 ++++++ Source/Modules/contract.cxx | 8 ++++++ 4 files changed, 50 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 7eed740b9..0124e6e76 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,10 @@ Version 1.3.37 (30 December 2008) ================================= +2009-01-10: wsfulton + Patch #1992756 from Colin McDonald - %contract not working for classes + in namespace + 2009-01-05: olly Mark SWIGPERL5, SWIGPHP5, and SWIGTCL8 as deprecated in the source code and remove documentation of them. diff --git a/Examples/test-suite/contract.i b/Examples/test-suite/contract.i index a5732105b..b979ef19e 100644 --- a/Examples/test-suite/contract.i +++ b/Examples/test-suite/contract.i @@ -201,3 +201,33 @@ struct E { }; %} + +// Namespace + +%{ +namespace myNames { + +class myClass +{ + public: + myClass(int i) {} +}; + +} +%} + +namespace myNames { + +%contract myClass::myClass( int i ) { +require: + i > 0; +} + +class myClass +{ + public: + myClass(int i) {} +}; + +} + diff --git a/Examples/test-suite/python/contract_runme.py b/Examples/test-suite/python/contract_runme.py index 9ded5bb5b..905bf1196 100644 --- a/Examples/test-suite/python/contract_runme.py +++ b/Examples/test-suite/python/contract_runme.py @@ -133,3 +133,11 @@ try: except: pass +#Namespace +my = contract.myClass(1) +try: + my = contract.myClass(0) + print "Failed! constructor preassertion" +except: + pass + diff --git a/Source/Modules/contract.cxx b/Source/Modules/contract.cxx index 9bf8decf6..518dc2997 100644 --- a/Source/Modules/contract.cxx +++ b/Source/Modules/contract.cxx @@ -46,6 +46,7 @@ public: int extendDirective(Node *n); int importDirective(Node *n); int includeDirective(Node *n); + int namespaceDeclaration(Node *n); int classDeclaration(Node *n); virtual int top(Node *n); }; @@ -320,16 +321,23 @@ int Contracts::constructorDeclaration(Node *n) { int Contracts::externDeclaration(Node *n) { return emit_children(n); } + int Contracts::extendDirective(Node *n) { return emit_children(n); } + int Contracts::importDirective(Node *n) { return emit_children(n); } + int Contracts::includeDirective(Node *n) { return emit_children(n); } +int Contracts::namespaceDeclaration(Node *n) { + return emit_children(n); +} + int Contracts::classDeclaration(Node *n) { int ret = SWIG_OK; InClass = 1; From 0b837574b00a95beb94bcaa64fb6932880d1aee7 Mon Sep 17 00:00:00 2001 From: Xavier Delacour Date: Sat, 10 Jan 2009 02:17:58 +0000 Subject: [PATCH 0294/1680] Octave: fix carrays regression caused by operator suffix change. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11050 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/octave/carrays.i | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/octave/carrays.i b/Lib/octave/carrays.i index 454762aa1..014de37ff 100644 --- a/Lib/octave/carrays.i +++ b/Lib/octave/carrays.i @@ -1,5 +1,5 @@ %define %array_class(TYPE,NAME) - %array_class_wrap(TYPE,NAME,__paren,__paren_asgn) + %array_class_wrap(TYPE,NAME,__paren__,__paren_asgn__) %enddef %include From 98f992e7040d5d0291e94166f44e68d9ed680a07 Mon Sep 17 00:00:00 2001 From: Joseph Wang Date: Sat, 10 Jan 2009 23:30:10 +0000 Subject: [PATCH 0295/1680] add regression test for integers git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11051 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/r/integers_runme.R | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 Examples/test-suite/r/integers_runme.R diff --git a/Examples/test-suite/r/integers_runme.R b/Examples/test-suite/r/integers_runme.R new file mode 100644 index 000000000..e31099a3b --- /dev/null +++ b/Examples/test-suite/r/integers_runme.R @@ -0,0 +1,20 @@ +source("unittest.R") +dyn.load(paste("integers", .Platform$dynlib.ext, sep="")) +source("integers.R") +cacheMetaData(1) + +unittest(signed_char_identity(1), 1) +unittest(unsigned_char_identity(1), 1) +unittest(signed_short_identity(1), 1) +unittest(unsigned_short_identity(1), 1) +unittest(signed_int_identity(1), 1) +unittest(unsigned_int_identity(1), 1) +unittest(signed_long_identity(1), 1) +unittest(unsigned_long_identity(1), 1) +unittest(signed_long_long_identity(1), 1) +unittest(unsigned_long_long_identity(1), 1) + +q(save="no") + + + From 4b5c817793380cc6692d7abebffd664682788808 Mon Sep 17 00:00:00 2001 From: Joseph Wang Date: Sun, 11 Jan 2009 00:08:37 +0000 Subject: [PATCH 0296/1680] Fix integer handling in r. unsigned values where getting handled incorrected as reals leading to crashes git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11052 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 +++ Lib/r/r.swg | 22 +++++++-------- Lib/r/rtype.swg | 73 ++++++++++++------------------------------------- 3 files changed, 33 insertions(+), 66 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 0124e6e76..bd4aa7b8b 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,10 @@ Version 1.3.37 (30 December 2008) ================================= +2009-01-10: drjoe + Fix integer handling in r to deal correctly with signed + and unsigned issues + 2009-01-10: wsfulton Patch #1992756 from Colin McDonald - %contract not working for classes in namespace diff --git a/Lib/r/r.swg b/Lib/r/r.swg index 0a4d0c36e..d7dc04f15 100644 --- a/Lib/r/r.swg +++ b/Lib/r/r.swg @@ -55,7 +55,8 @@ SWIG_InitializeModule(0); %typemap(out) void ""; -%typemap(in) int *, int[ANY] %{ +%typemap(in) int *, int[ANY], + long *, long[ANY] %{ $1 = INTEGER($input); %} @@ -77,7 +78,7 @@ SWIG_InitializeModule(0); %} -%typemap(scheck) int %{ +%typemap(scheck) int, long %{ if(length($input) > 1) { warning("using only the first element of $input") } @@ -157,11 +158,12 @@ $1 = %static_cast(CHAR(STRING_ELT($input, 0))[0],$1_ltype); } -%typemap(in,noblock=1) int { +%typemap(in,noblock=1) int, long +{ $1 = %static_cast(INTEGER($input)[0], $1_ltype); } -%typemap(out,noblock=1) int +%typemap(out,noblock=1) int, long "$result = Rf_ScalarInteger($1);"; @@ -172,18 +174,16 @@ $1 = %static_cast(CHAR(STRING_ELT($input, 0))[0],$1_ltype); %typemap(out,noblock=1) bool "$result = Rf_ScalarLogical($1);"; -%typemap(in,noblock=1) unsigned int, - unsigned long, +%typemap(in,noblock=1) float, - double, - long + double { $1 = %static_cast(REAL($input)[0], $1_ltype); } - -%typemap(out,noblock=1) unsigned int * - "$result = ScalarReal(*($1));"; +/* Why is this here ? */ +/* %typemap(out,noblock=1) unsigned int * + "$result = ScalarReal(*($1));"; */ %Rruntime %{ setMethod('[', "ExternalReference", diff --git a/Lib/r/rtype.swg b/Lib/r/rtype.swg index 043b7487d..504e7cd04 100644 --- a/Lib/r/rtype.swg +++ b/Lib/r/rtype.swg @@ -8,12 +8,18 @@ %apply int {std::size_t} %apply int {ptrdiff_t} %apply int {std::ptrdiff_t} +%apply int {signed int} +%apply int {unsigned int} +%apply int {short} +%apply int {unsigned short} + +%typemap("rtype") long, long *, long & "numeric"; +%apply long {long long} +%apply long {signed long long} +%apply long {unsigned long long} +%apply long {unsigned long} +%apply long {unsigned long} -%typemap("rtype") long, long * "numeric"; -%typemap("rtype") unsigned long, - unsigned long * "numeric"; -%typemap("rtype") unsigned int, - unsigned int * "numeric"; %typemap("rtype") double, double*, double & "numeric"; %typemap("rtype") float, float *, float & "numeric"; %typemap("rtype") char *, char ** "character"; @@ -41,11 +47,7 @@ %typemap(scoercein) int, int *, int & %{ $input = as.integer($input); %} -%typemap(scoercein) ptrdiff_t, ptrdiff_t *, ptrdiff_t & - %{ $input = as.integer($input); %} -%typemap(scoercein) unsigned long, unsigned long *, unsigned long & - %{ $input = as.integer($input); %} -%typemap(scoercein) unsigned int, unsigned int *, unsigned int & +%typemap(scoercein) long, long *, long & %{ $input = as.integer($input); %} %typemap(scoercein) double, double *, double & %{ %} @@ -90,45 +92,16 @@ %typemap(scoercein) bool, bool *, bool & "$input = as.logical($input) "; -/* %typemap(scoercein) int, int *, int &, int[ANY], - size_t, - std::size_t, - size_t &, - std::size_t & + long, + long *, + long &, + long[ANY] "$input = as.integer($input) "; - -%typemap(scoercein) unsigned int, - unsigned long, - double, - float, - long, - long long, - unsigned int[], - unsigned long[], - double[], - float[], - long[], - long long[], - unsigned int[ANY], - unsigned long[ANY], - double[ANY], - float[ANY], - long[ANY], - long long[ANY], - unsigned int *, - unsigned long *, - double*, - float*, - long*, - long long * -%{ $input = as.numeric($input) %} -*/ - %typemap(scoercein) char *, string, std::string, string &, std::string & %{ $input = as($input, "character") %} @@ -156,30 +129,20 @@ string &, std::string & %typemap(scoerceout) char, char *, char &, - unsigned int, - unsigned int &, - unsigned long, - unsigned long &, double, double &, float, float &, - long, - long &, - long long, - long long &, int, int &, + long, + long &, bool, bool &, string, std::string, string &, std::string &, - size_t, - std::size_t, - size_t &, - std::size_t &, void %{ %} From cca31dde4ff9e50162c1f0d309837f5b27c0ef04 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 11 Jan 2009 17:57:21 +0000 Subject: [PATCH 0297/1680] more portable pointer in a string comparison git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11054 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- .../test-suite/python/swigobject_runme.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/Examples/test-suite/python/swigobject_runme.py b/Examples/test-suite/python/swigobject_runme.py index ad78ee4fb..8d77faa80 100644 --- a/Examples/test-suite/python/swigobject_runme.py +++ b/Examples/test-suite/python/swigobject_runme.py @@ -1,5 +1,8 @@ from swigobject import * +from string import replace +from string import upper +from string import lstrip a = A() @@ -12,15 +15,17 @@ if a1.this != a2.this: lthis = long(a.this) -# match pointer value, but deal with leading zeros on 8/16 bit systems -xstr8bit = "%08X" % (lthis,) -xstr16bit = "%016X" % (lthis,) +# match pointer value, but deal with leading zeros on 8/16 bit systems and different C++ compilers interpretation of %p +xstr1 = "%016X" % (lthis,) +xstr1 = lstrip(xstr1, '0') xstr2 = pointer_str(a) +xstr2 = replace(xstr2, "0x", "") +xstr2 = replace(xstr2, "0X", "") +xstr2 = upper(xstr2) -if xstr8bit != xstr2: - if xstr16bit != xstr2: - print xstr8bit, xstr16bit, xstr2 - raise RuntimeError +if xstr1 != xstr2: + print xstr1, xstr2 + raise RuntimeError s = str(a.this) r = repr(a.this) From 3d8f56946691f82207ae5d357989c9c0ac41dfb8 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 11 Jan 2009 21:32:42 +0000 Subject: [PATCH 0298/1680] another portability fix git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11055 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/python/swigobject_runme.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Examples/test-suite/python/swigobject_runme.py b/Examples/test-suite/python/swigobject_runme.py index 8d77faa80..ee9716136 100644 --- a/Examples/test-suite/python/swigobject_runme.py +++ b/Examples/test-suite/python/swigobject_runme.py @@ -19,6 +19,7 @@ lthis = long(a.this) xstr1 = "%016X" % (lthis,) xstr1 = lstrip(xstr1, '0') xstr2 = pointer_str(a) +xstr2 = lstrip(xstr2, '0') xstr2 = replace(xstr2, "0x", "") xstr2 = replace(xstr2, "0X", "") xstr2 = upper(xstr2) From ecdd24a508c859c591a0b063100ed3b8de8b76a7 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 11 Jan 2009 21:37:54 +0000 Subject: [PATCH 0299/1680] yet better pointer string comparison git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11056 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/python/swigobject_runme.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/test-suite/python/swigobject_runme.py b/Examples/test-suite/python/swigobject_runme.py index ee9716136..70219a57c 100644 --- a/Examples/test-suite/python/swigobject_runme.py +++ b/Examples/test-suite/python/swigobject_runme.py @@ -19,9 +19,9 @@ lthis = long(a.this) xstr1 = "%016X" % (lthis,) xstr1 = lstrip(xstr1, '0') xstr2 = pointer_str(a) -xstr2 = lstrip(xstr2, '0') xstr2 = replace(xstr2, "0x", "") xstr2 = replace(xstr2, "0X", "") +xstr2 = lstrip(xstr2, '0') xstr2 = upper(xstr2) if xstr1 != xstr2: From 2854ceef44e758f8cc85f4e0e7822e7bd386d1fc Mon Sep 17 00:00:00 2001 From: Joseph Wang Date: Mon, 12 Jan 2009 07:41:38 +0000 Subject: [PATCH 0300/1680] Add regression tests for R git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11057 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/li_std_vector.i | 2 ++ .../test-suite/r/arrays_dimensionless_runme.R | 20 +++++++++++++++++++ .../test-suite/template_typedef_funcptr.i | 5 +++++ Examples/test-suite/types_directive.i | 8 ++++++++ 4 files changed, 35 insertions(+) create mode 100644 Examples/test-suite/r/arrays_dimensionless_runme.R diff --git a/Examples/test-suite/li_std_vector.i b/Examples/test-suite/li_std_vector.i index 587ea2217..c6e2ea9ad 100644 --- a/Examples/test-suite/li_std_vector.i +++ b/Examples/test-suite/li_std_vector.i @@ -85,8 +85,10 @@ SWIG_STD_VECTOR_SPECIALIZE(SWIGTYPE_p_int, const int *) %template(StructureConstPtrVector) std::vector; #endif +#if !defined(SWIGR) %template(IntPtrVector) std::vector; %template(IntConstPtrVector) std::vector; +#endif %template(StructVector) std::vector; %template(StructPtrVector) std::vector; %template(StructConstPtrVector) std::vector; diff --git a/Examples/test-suite/r/arrays_dimensionless_runme.R b/Examples/test-suite/r/arrays_dimensionless_runme.R new file mode 100644 index 000000000..9b97de2d8 --- /dev/null +++ b/Examples/test-suite/r/arrays_dimensionless_runme.R @@ -0,0 +1,20 @@ +source("unittest.R") +dyn.load(paste("arrays_dimensionless", .Platform$dynlib.ext, sep="")) +source("arrays_dimensionless.R") +cacheMetaData(1) + +unittest(arr_short(1:4, 3), 6) +unittest(arr_ushort(1:4, 3), 6) +unittest(arr_int(1:4, 3), 6) +unittest(arr_uint(1:4, 3), 6) +unittest(arr_long(1:4, 3), 6) +unittest(arr_ulong(1:4, 3), 6) +unittest(arr_ll(1:4, 3), 6) +unittest(arr_ull(1:4, 3), 6) +unittest(arr_float(as.numeric(1:4), 3), 6) +unittest(arr_double(as.numeric(1:4), 3), 6) + +q(save="no") + + + diff --git a/Examples/test-suite/template_typedef_funcptr.i b/Examples/test-suite/template_typedef_funcptr.i index 0175c7516..cec43e7c8 100644 --- a/Examples/test-suite/template_typedef_funcptr.i +++ b/Examples/test-suite/template_typedef_funcptr.i @@ -2,6 +2,10 @@ //Bug #1832613 +#if !defined(SWIGR) +// R Swig fails on this test. Because it tries to return a nil SEXP in +// an error + %include %inline %{ @@ -46,3 +50,4 @@ typedef MCContractPtr* ContractPtrPtr; // Plain pointers were also causing problems... %template(MCContractFactory2) ContractFactory; +#endif diff --git a/Examples/test-suite/types_directive.i b/Examples/test-suite/types_directive.i index 44312263d..26cb6aeeb 100644 --- a/Examples/test-suite/types_directive.i +++ b/Examples/test-suite/types_directive.i @@ -1,5 +1,13 @@ %module types_directive +#if defined(SWIGR) +// Avoid conflict with Date class in R +#define Date DateSwig +%inline %{ +#define Date DateSwig +%} +#endif + %ignore Time2::operator Date *; %inline %{ From 88e60d75c926174a9e8b3397fe8f3cfecbcd90de Mon Sep 17 00:00:00 2001 From: Joseph Wang Date: Mon, 12 Jan 2009 08:54:36 +0000 Subject: [PATCH 0301/1680] fix change to make compatible with integer framework git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11058 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/r/r_copy_struct_runme.R | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Examples/test-suite/r/r_copy_struct_runme.R b/Examples/test-suite/r/r_copy_struct_runme.R index ebf704004..21bd93b64 100644 --- a/Examples/test-suite/r/r_copy_struct_runme.R +++ b/Examples/test-suite/r/r_copy_struct_runme.R @@ -41,7 +41,7 @@ unittest(d$u, 0) la <- new("A"); -la@ui <- 5 +la@ui <- as.integer(5) # Removing the next line makes this fail in R 2.4 la@str <- "" @@ -49,9 +49,10 @@ other = A() foo <- copyToC(la, other) aa = A() -aa$i = 201 +aa$i = as.integer(201) aa$d = pi aa$str = "foo" +aa$ui = as.integer(0) copyToR(aa) From 809bbb89e321573291915343ccf3a01c6b4302fd Mon Sep 17 00:00:00 2001 From: Joseph Wang Date: Mon, 12 Jan 2009 08:57:16 +0000 Subject: [PATCH 0302/1680] put in integer fixes git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11059 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 3 +++ Lib/r/r.swg | 60 +++++++++++++++++++++++++++++++++++++++++++------ Lib/r/rtype.swg | 25 +++++++++++++++++---- 3 files changed, 77 insertions(+), 11 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index bd4aa7b8b..0ddd92cc5 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,9 @@ Version 1.3.37 (30 December 2008) ================================= +2009-01-12: drjoe + Fixed handling of integer arrays + 2009-01-10: drjoe Fix integer handling in r to deal correctly with signed and unsigned issues diff --git a/Lib/r/r.swg b/Lib/r/r.swg index d7dc04f15..7fd6d761f 100644 --- a/Lib/r/r.swg +++ b/Lib/r/r.swg @@ -56,13 +56,61 @@ SWIG_InitializeModule(0); %typemap(out) void ""; %typemap(in) int *, int[ANY], - long *, long[ANY] %{ - $1 = INTEGER($input); + signed int *, signed int[ANY], + unsigned int *, unsigned int[ANY], + short *, short[ANY], + signed short *, signed short[ANY], + unsigned short *, unsigned short[ANY], + long *, long[ANY], + signed long *, signed long[ANY], + unsigned long *, unsigned long[ANY], + long long *, long long[ANY], + signed long long *, signed long long[ANY], + unsigned long long *, unsigned long long[ANY] + +{ +{ int _rswigi; + int _rswiglen = LENGTH($input); + $1 = %static_cast(calloc(sizeof($1_basetype), _rswiglen), $1_ltype); + for (_rswigi=0; _rswigi< _rswiglen; _rswigi++) { + $1[_rswigi] = INTEGER($input)[_rswigi]; + } +} +} + +%typemap(in) float *, float[ANY], + double *, double[ANY] + +{ +{ int _rswigi; + int _rswiglen = LENGTH($input); + $1 = %static_cast(calloc(sizeof($1_basetype), _rswiglen), $1_ltype); + for (_rswigi=0; _rswigi<_rswiglen; _rswigi++) { + $1[_rswigi] = REAL($input)[_rswigi]; + } +} +} + +%typemap(freearg,noblock=1) int *, int[ANY], + signed int *, signed int[ANY], + unsigned int *, unsigned int[ANY], + short *, short[ANY], + signed short *, signed short[ANY], + unsigned short *, unsigned short[ANY], + long *, long[ANY], + signed long *, signed long[ANY], + unsigned long *, unsigned long[ANY], + long long *, long long[ANY], + signed long long *, signed long long[ANY], + unsigned long long *, unsigned long long[ANY], + float *, float[ANY], + double *, double[ANY] +%{ + free($1); %} -%typemap(in) double *, double[ANY] %{ - $1 = REAL($input); -%} + + /* Shoul dwe recycle to make the length correct. And warn if length() > the dimension. @@ -92,8 +140,6 @@ SWIG_InitializeModule(0); %include %include -%apply int[ANY] { enum SWIGTYPE[ANY] }; - %typemap(in,noblock=1) enum SWIGTYPE[ANY] { $1 = %reinterpret_cast(INTEGER($input), $1_ltype); } diff --git a/Lib/r/rtype.swg b/Lib/r/rtype.swg index 504e7cd04..d388d1eae 100644 --- a/Lib/r/rtype.swg +++ b/Lib/r/rtype.swg @@ -3,7 +3,7 @@ for use in class representations. */ -%typemap("rtype") int, int *, int & "numeric"; +%typemap("rtype") int, int *, int & "integer"; %apply int {size_t} %apply int {std::size_t} %apply int {ptrdiff_t} @@ -13,11 +13,11 @@ %apply int {short} %apply int {unsigned short} -%typemap("rtype") long, long *, long & "numeric"; +%typemap("rtype") long, long *, long & "integer"; %apply long {long long} %apply long {signed long long} %apply long {unsigned long long} -%apply long {unsigned long} +%apply long {signed long} %apply long {unsigned long} %typemap("rtype") double, double*, double & "numeric"; @@ -143,7 +143,24 @@ string &, std::string & std::string, string &, std::string &, - void + void, + signed int, + signed int &, + unsigned int, + unsigned int &, + short, + short &, + unsigned short, + unsigned short &, + long long, + signed long long, + signed long long &, + unsigned long long, + unsigned long long &, + signed long, + signed long &, + unsigned long, + unsigned long & %{ %} From c07efac2968fa45ea56b51320d61e156ff872d2a Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 12 Jan 2009 11:42:27 +0000 Subject: [PATCH 0303/1680] Fix union.i module name and rename to union_parameter.i git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11060 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/common.mk | 2 +- .../tcl/{union_runme.tcl => union_parameter_runme.tcl} | 2 +- Examples/test-suite/{union.i => union_parameter.i} | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) rename Examples/test-suite/tcl/{union_runme.tcl => union_parameter_runme.tcl} (92%) rename Examples/test-suite/{union.i => union_parameter.i} (97%) diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 144e67639..90eca082a 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -451,7 +451,7 @@ C_TEST_CASES += \ struct_rename \ typedef_struct \ typemap_subst \ - union \ + union_parameter \ unions diff --git a/Examples/test-suite/tcl/union_runme.tcl b/Examples/test-suite/tcl/union_parameter_runme.tcl similarity index 92% rename from Examples/test-suite/tcl/union_runme.tcl rename to Examples/test-suite/tcl/union_parameter_runme.tcl index 2c47ecef3..fb3e092b8 100644 --- a/Examples/test-suite/tcl/union_runme.tcl +++ b/Examples/test-suite/tcl/union_parameter_runme.tcl @@ -1,4 +1,4 @@ -if [ catch { load ./union[info sharedlibextension] unions} err_msg ] { +if [ catch { load ./union_parameter[info sharedlibextension] union_parameter} err_msg ] { puts stderr "Could not load shared object:\n$err_msg" } diff --git a/Examples/test-suite/union.i b/Examples/test-suite/union_parameter.i similarity index 97% rename from Examples/test-suite/union.i rename to Examples/test-suite/union_parameter.i index d8ac62bfb..bb010d3fa 100644 --- a/Examples/test-suite/union.i +++ b/Examples/test-suite/union_parameter.i @@ -1,4 +1,4 @@ -%module unions +%module union_parameter %inline %{ From e604e46b17213ae0ab64af04000ef8e7246e4d5a Mon Sep 17 00:00:00 2001 From: Mark Gossage Date: Tue, 13 Jan 2009 01:42:25 +0000 Subject: [PATCH 0304/1680] [Lua] Added contract support for requiring that unsigned numbers are >=0 Rewrote much of Examples/Lua/embed3. Added a lot of to the Lua documentation. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11061 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 5 + Doc/Manual/Lua.html | 299 +++++++++++++++++++++++++++++++-- Examples/lua/embed3/embed3.cpp | 7 +- Lib/lua/luatypemaps.swg | 25 ++- 4 files changed, 309 insertions(+), 27 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 0ddd92cc5..9410e51bd 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,11 @@ Version 1.3.37 (30 December 2008) ================================= +2009-01-13: mgossage + [Lua] Added contract support for requiring that unsigned numbers are >=0 + Rewrote much of Examples/Lua/embed3. + Added a lot of to the Lua documentation. + 2009-01-12: drjoe Fixed handling of integer arrays diff --git a/Doc/Manual/Lua.html b/Doc/Manual/Lua.html index 99c7c9a3c..e5fc8217a 100644 --- a/Doc/Manual/Lua.html +++ b/Doc/Manual/Lua.html @@ -34,14 +34,29 @@
    • C++ templates
    • C++ Smart Pointers
    • C++ Exceptions -
    • Writing your own custom wrappers -
    • Adding additional Lua code -
    • Details on the Lua binding +
    • Typemaps +
    • Writing Typemaps + +
    • Customization of your Bindings + +
    • Details on the Lua binding + @@ -1003,8 +1018,9 @@ stack traceback:

      -SWIG is able to throw numeric types, enums, chars, char*'s and std::string's without problem. -However its not so simple for to throw objects. +SWIG is able to throw numeric types, enums, chars, char*'s and std::string's without problem. It has also written typemaps for std::exception and its derived classes, which convert the exception into and error string.

      +

      +However its not so simple for to throw other types of objects. Thrown objects are not valid outside the 'catch' block. Therefore they cannot be returned to the interpreter. The obvious ways to overcome this would be to either return a copy of the object, or so convert the object to a string and @@ -1038,10 +1054,6 @@ To get a more useful behaviour out of SWIG you must either: provide a way to con throw objects which can be copied.

      -SWIG has typemaps for std::exception and its children already written, so a function which throws any of these will -automatically have its exception converted into an error string. -

      -

      If you have your own class which you want output as a string you will need to add a typemap something like this:

      @@ -1098,8 +1110,259 @@ add exception specification to functions or globally (respectively).
       

      -

      23.3.16 Writing your own custom wrappers

      +

      23.4 Typemaps

      +

      This section explains what typemaps are and the usage of them. The default wrappering behaviour of SWIG is enough in most cases. However sometimes SWIG may need a little additional assistance to know which typemap to apply to provide the best wrappering. This section will be explaining how to use typemaps to best effect

      + +

      23.4.1 What is a typemap?

      + +

      A typemap is nothing more than a code generation rule that is attached to a specific C datatype. For example, to convert integers from Lua to C, you might define a typemap like this:

      + +
      %module example
      +
      +%typemap(in) int {
      +	$1 = (int) lua_tonumber(L,$input);
      +	printf("Received an integer : %d\n",$1);
      +}
      +%inline %{
      +extern int fact(int n);
      +%}
      +
      + +

      Note: you shouldn't use this typemap, as SWIG already has a typemap for this task. This is purely for example.

      + +

      Typemaps are always associated with some specific aspect of code generation. In this case, the "in" method refers to the conversion of input arguments to C/C++. The datatype int is the datatype to which the typemap will be applied. The supplied C code is used to convert values. In this code a number of special variable prefaced by a $ are used. The $1 variable is placeholder for a local variable of type int. The $input is the index on the Lua stack for the value to be used.

      + +

      When this example is compiled into a Lua module, it operates as follows:

      + +
      > require "example"
      +> print(example.fact(6))
      +Received an integer : 6
      +720
      +
      + +

      23.4.2 Using typemaps

      + +

      There are many ready written typemaps built into SWIG for all common types (int, float, short, long, char*, enum and more), which SWIG uses automatically, with no effort required on your part.

      + +

      However for more complex functions which use input/output parameters or arrays, you will need to make use of <typemaps.i>, which contains typemaps for these situations. For example, consider these functions:

      + +
      void add(int x, int y, int *result) {
      +   *result = x + y;
      +}
      +
      +int sub(int *x1, int *y1) {
      +   return *x1-*y1;
      +}
      +
      +void swap(int *sx, int *sy) {
      +   int t=*sx;
      +   *sx=*sy;
      +   *sy=t;
      +}
      +
      + +

      It is clear to the programmer, that 'result' is an output parameter, 'x1' and 'y1' are input parameters and 'sx' and 'sy' are input/output parameters. However is not apparent to SWIG, so SWIG must to informed about which kind they are, so it can wrapper accordingly.

      + +

      One means would be to rename the argument name to help SWIG, eg void add(int x, int y, int *OUTPUT), however it is easier to use the %apply to achieve the same result, as shown below.

      + +
      %include <typemaps.i>
      +%apply int* OUTPUT {int *result}; // int *result is output
      +%apply int* INPUT {int *x1, int *y1}; // int *x1 and int *y1 are input
      +%apply int* INOUT {int *sx, int *sy}; // int *sx and int *sy are input and output
      +
      +void add(int x, int y, int *result);
      +int sub(int *x1, int *y1);
      +void swap(int *sx, int *sy);
      +
      + +

      When wrapped, it gives the following results:

      + +
      > require "example"
      +> print(example.add(1,2))
      +3
      +> print(demo.sub(1,2))
      +-1
      +> a,b=1,2
      +> c,d=demo.swap(a,b)
      +> print(a,b,c,d)
      +1       2       2       1
      +
      + +

      Notice, that 'result' is not required in the arguments to call the function, as it an output parameter only. For 'sx' and 'sy' they must be passed in (as they are input), but the original value is not modified (Lua does not have a pass by reference feature). The modified results are then returned as two return values. All INPUT/OUTPUT/INOUT arguments will behave in a similar manner.

      + +

      Note: C++ references must be handled exactly the same way. However SWIG will automatically wrap a const int& as an input parameter (since that it obviously input).

      + +

      23.4.3 Typemaps and arrays

      + +

      Arrays present a challenge for SWIG, because like pointers SWIG does not know whether these are input or output values, nor +does SWIG have any indication of how large an array should be. However with the proper guidance SWIG can easily wrapper +arrays for convenient usage.

      + +

      Given the functions:

      +
      extern void sort_int(int* arr, int len);
      +extern void sort_double(double* arr, int len);
      +
      + +

      There are basically two ways that SWIG can deal with this. The first way, uses the <carrays.i> library +to create an array in C/C++ then this can be filled within Lua and passed into the function. It works, but its a bit tedious. +More details can be found in the carrays.i documention.

      + +

      The second and more intuitive way, would be to pass a Lua table directly into the function, and have SWIG automatically convert between Lua-table and C-array. Within the <typemaps.i> file there are typemaps ready written to perform this task. To use them is again a matter of using %appy in the correct manner.

      + +

      The wrapper file below, shows both the use of carrays as well as the use of the typemap to wrap arrays.

      + +
      // using the C-array
      +%include <carrays.i>
      +// this declares a batch of function for manipulating C integer arrays
      +%array_functions(int,int)
      +
      +extern void sort_int(int* arr, int len); // the function to wrap
      +
      +// using typemaps
      +%include <typemaps.i>
      +%apply (double *INOUT,int) {(double* arr,int len)};
      +
      +extern void sort_double(double* arr, int len); // the function to wrap
      +
      + +

      Once wrappered, the functions can both be called, though with different ease of use:

      + +
      require "example"
      +ARRAY_SIZE=10
      +
      +-- passing a C array to the sort_int()
      +arr=example.new_int(ARRAY_SIZE) -- create the array
      +for i=0,ARRAY_SIZE-1 do -- index 0..9 (just like C)
      +    example.int_setitem(arr,i,math.random(1000))
      +end
      +example.sort_int(arr,ARRAY_SIZE)  -- call the function
      +example.delete_int(arr) -- must delete the allocated memory
      +
      +-- use a typemap to call with a Lua-table
      +-- one item of note: the typemap creates a copy, rather than edit-in-place
      +t={} -- a Lua table
      +for i=1,ARRAY_SIZE do -- index 1..10 (Lua style)
      +    t[i]=math.random(1000)/10
      +end
      +t=example.sort_double(t) -- replace t with the result
      +
      + +

      Obviously the first version could be made less tedious by writing a Lua function to perform the conversion from a table +to a C-array. The %luacode directive is good for this. See SWIG\Examples\lua\arrays for an example of this.

      + +

      Warning: in C indexes start at ZERO, in Lua indexes start at ONE. SWIG expects C-arrays to be filled for 0..N-1 +and Lua tables to be 1..N, (the indexing follows the norm for the language). In the typemap when it converts the table to an array it quietly changes the indexing accordingly. Take note of this behaviour if you have a C function which returns indexes.

      + +

      Note: SWIG also can support arrays of pointers in a similar manner.

      + +

      23.4.4 Typemaps and pointer-pointer functions

      + +

      Several C++ libraries use a pointer-pointer functions to create its objects. These functions require a pointer to a pointer which is then filled with the pointer to the new object. Microsoft's COM and DirectX as well as many other libraries have this kind of function. An example is given below:

      + +
      struct iMath;    // some structure
      +int Create_Math(iMath** pptr); // its creator (assume it mallocs)
      +
      + +

      Which would be used with the following C code:

      + +
      iMath* ptr;
      +int ok;
      +ok=Create_Math(&ptr);
      +// do things with ptr
      +//...
      +free(ptr); // dispose of iMath
      +
      + +

      SWIG has a ready written typemap to deal with such a kind of function in <typemaps.i>. It provides the correct wrappering as well as setting the flag to inform Lua that the object in question should be garbage collected. Therefore the code is simply:

      + +
      %include <typemaps.i>
      +%apply SWIGTYPE** OUTPUT{iMath **pptr }; // tell SWIG its an output
      +
      +struct iMath;    // some structure
      +int Create_Math(iMath** pptr); // its creator (assume it mallocs)
      +
      + +

      The usage is as follows:

      + +
      ok,ptr=Create_Math() -- ptr is a iMath* which is returned with the int (ok)
      +ptr=nil -- the iMath* will be GC'ed as normal
      +
      + +

      23.5 Writing typemaps

      + +

      This section describes how you can modify SWIG's default wrapping behavior for various C/C++ datatypes using the %typemap directive. This is an advanced topic that assumes familiarity with the Lua C API as well as the material in the "Typemaps" chapter.

      + +

      Before proceeding, it should be stressed that writing typemaps is rarely needed unless you want to change some aspect of the wrappering, or to achieve an effect which in not available with the default bindings.

      + +

      Before proceeding, you should read the previous section on using typemaps, as well as read the ready written typemaps found in luatypemaps.swg and typemaps.i. These are both well documented and fairly easy to read. You should not attempt to write your own typemaps until you have read and can understand both of these files (they may well also give you a idea to base your worn on).

      + +

      23.5.1 Typemaps you can write

      + +

      There are many different types of typemap that can be written, the full list can be found in the "Typemaps" chapter. However the following are the most commonly used ones.

      + +
        +
      • in this is for input arguments to functions
      • +
      • out this is for return types from functions
      • +
      • argout this is for a function argument which is actually returning something
      • +
      • typecheck this is used to determine which overloaded function should be called +(the syntax for the typecheck is different from the typemap, see typemaps for details).
      • +
      + +

      23.5.2 SWIG's Lua-C API

      + +

      This section explains the SWIG specific Lua-C API. It does not cover the main Lua-C api, as this is well documented and not worth covering.

      + +

      int SWIG_ConvertPtr(lua_State* L,int index,void** ptr,swig_type_info *type,int flags);

      + +
      +This is the standard function used for converting a Lua userdata to a void*. It takes the value at the given index in the Lua state and converts it to a userdata. It will then provide the neccesary type checks, confirming that the pointer is compatible with the type given in 'type'. Then finally setting '*ptr' to the pointer. +If flags is set to SWIG_POINTER_DISOWN, this is will clear any ownership flag set on the object.
      +The returns a value which can be checked with the macro SWIG_IsOK() +
      + +

      void SWIG_NewPointerObj(lua_State* L,void* ptr,swig_type_info *type,int own);

      + +
      +This is the opposite of SWIG_ConvertPtr, as it pushes a new userdata which wrappers the pointer 'ptr' of type 'type'. +The parameter 'own' specifies if the object is owned be Lua and if it is 1 then Lua will GC the object when the userdata is disposed of. +
      + +

      void* SWIG_MustGetPtr(lua_State* L,int index,swig_type_info *type,int flags,int argnum,const char* func_name);

      + +
      +This function is a version of SWIG_ConvertPtr(), except that it will either work, or it will trigger a lua_error() with a text error message. This function is rarely used, and may be deprecated in the future. +
      + +

      SWIG_fail

      + +
      +This macro, when called within the context of a SWIG wrappered function, will jump to the error handler code. This will call any cleanup code (freeing any temp variables) and then triggers a lua_error.
      +A common use for this code is:
      +if (!SWIG_IsOK(SWIG_ConvertPtr( .....)){
      + lua_pushstring(L,"something bad happened");
      + SWIG_fail;
      +}
      + +

      SWIG_fail_arg(char* func_name,int argnum,char* type)

      + +
      +This macro, when called within the context of a SWIG wrappered function, will display the error message and jump to the error handler code. The error message is of the form "Error in func_name (arg argnum), expected 'type' got 'whatever the type was'"
      + +

      SWIG_fail_ptr(const char* fn_name,int argnum,swig_type_info* type);

      + +
      +Similar to SWIG_fail_arg, except that it will display the swig_type_info information instead.
      + +

      23.6 Customization of your Bindings

      + +

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

      + + + +

      23.6.1 Writing your own custom wrappers

      Sometimes, it may be neccesary to add your own special functions, which bypass the normal SWIG wrappering method, and just use the native Lua API calls. These 'native' functions allow direct adding of your own code into the module. This is performed with the %native directive as follows: @@ -1117,7 +1380,7 @@ int native_function(lua_State*L) // my native code The %native directive in the above example, tells SWIG that there is a function int native_function(lua_State*L); which is to be added into the module under the name 'my_func'. SWIG will not add any wrappering for this function, beyond adding it into the function table. How you write your code is entirely up to you.

      -

      23.3.17 Adding additional Lua code

      +

      23.6.2 Adding additional Lua code

      @@ -1155,7 +1418,7 @@ Good uses for this feature is adding of new code, or writing helper functions to See Examples/lua/arrays for an example of this code.

      -

      23.4 Details on the Lua binding

      +

      23.7 Details on the Lua binding

      @@ -1166,7 +1429,7 @@ See Examples/lua/arrays for an example of this code.

      -

      23.4.1 Binding global data into the module.

      +

      23.7.1 Binding global data into the module.

      @@ -1226,7 +1489,7 @@ end

      That way when you call 'a=example.Foo', the interpreter looks at the table 'example' sees that there is no field 'Foo' and calls __index. This will in turn check in '.get' table and find the existence of 'Foo' and then return the value of the C function call 'Foo_get()'. Similarly for the code 'example.Foo=10', the interpreter will check the table, then call the __newindex which will then check the '.set' table and call the C function 'Foo_set(10)'.

      -

      23.4.2 Userdata and Metatables

      +

      23.7.2 Userdata and Metatables

      @@ -1306,7 +1569,7 @@ Note: Both the opaque structures (like the FILE*) and normal wrappered classes/s

      Note: Operator overloads are basically done in the same way, by adding functions such as '__add' & '__call' to the classes metatable. The current implementation is a bit rough as it will add any member function beginning with '__' into the metatable too, assuming its an operator overload.

      -

      23.4.3 Memory management

      +

      23.7.3 Memory management

      diff --git a/Examples/lua/embed3/embed3.cpp b/Examples/lua/embed3/embed3.cpp index c2424f9af..e5e0e0a7d 100644 --- a/Examples/lua/embed3/embed3.cpp +++ b/Examples/lua/embed3/embed3.cpp @@ -26,7 +26,12 @@ extern "C" { #include #include } - + +/* The SWIG external runtime is generated by using. +swig -lua -externalruntime swigluarun.h +It contains useful function used by SWIG in its wrappering +SWIG_TypeQuery() SWIG_NewPointerObj() +*/ #include "swigluarun.h" // the SWIG external runtime /* the SWIG wrappered library */ diff --git a/Lib/lua/luatypemaps.swg b/Lib/lua/luatypemaps.swg index 0941c9da1..caa2a6ce1 100644 --- a/Lib/lua/luatypemaps.swg +++ b/Lib/lua/luatypemaps.swg @@ -20,11 +20,15 @@ to reflect the number of values returned (normally SWIG_arg++; will do) */ // numbers -%typemap(in,checkfn="lua_isnumber") int,short,long, - unsigned int,unsigned short,unsigned long, - signed char,unsigned char, - float,double +%typemap(in,checkfn="lua_isnumber") int, short, long, + signed char, float, double %{$1 = ($type)lua_tonumber(L, $input);%} + +// additional check for unsigned numbers, to not permit negative input +%typemap(in,checkfn="lua_isnumber") unsigned int, + unsigned short, unsigned long, unsigned char +%{SWIG_contract_assert((lua_tonumber(L,$input)>=0),"number must not be negative") +$1 = ($type)lua_tonumber(L, $input);%} %typemap(out) int,short,long, unsigned int,unsigned short,unsigned long, @@ -41,15 +45,20 @@ %typemap(in,checkfn="lua_isnumber") const int&($basetype temp) %{ temp=($basetype)lua_tonumber(L,$input); $1=&temp;%} -%typemap(out) const int& +%typemap(in,checkfn="lua_isnumber") const unsigned int&($basetype temp) +%{SWIG_contract_assert((lua_tonumber(L,$input)>=0),"number must not be negative") +temp=($basetype)lua_tonumber(L,$input); $1=&temp;%} + +%typemap(out) const int&, const unsigned int& %{ lua_pushnumber(L, (lua_Number) *$1); SWIG_arg++;%} // for the other numbers we can just use an apply statement to cover them -%apply const int & {const short&,const long&, - const unsigned int&,const unsigned short&,const unsigned long&, - const signed char&,const unsigned char&, +%apply const int & {const short&,const long&,const signed char&, const float&,const double&}; +%apply const unsigned int & {const unsigned short&,const unsigned long&, + const unsigned char&}; + /* enums have to be handled slightly differently VC++ .net will not allow a cast from lua_Number(double) to enum directly. */ From d029d0a6275b3968ee7bed3098998d75484b982f Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 13 Jan 2009 07:09:27 +0000 Subject: [PATCH 0305/1680] Fix compilation error when using directors on protected virtual overloaded methods reported by Sam Hendley. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11062 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 8 +++++-- Examples/test-suite/common.mk | 1 + .../director_protected_overloaded.i | 21 +++++++++++++++++++ Source/Modules/lang.cxx | 13 ++++++++---- 4 files changed, 37 insertions(+), 6 deletions(-) create mode 100644 Examples/test-suite/director_protected_overloaded.i diff --git a/CHANGES.current b/CHANGES.current index 9410e51bd..ef8b9d798 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -3,8 +3,12 @@ Version 1.3.37 (30 December 2008) 2009-01-13: mgossage [Lua] Added contract support for requiring that unsigned numbers are >=0 - Rewrote much of Examples/Lua/embed3. - Added a lot of to the Lua documentation. + Rewrote much of Examples/Lua/embed3. + Added a lot to the Lua documentation. + +2009-01-13: wsfulton + Fix compilation error when using directors on protected virtual overloaded + methods reported by Sam Hendley. 2009-01-12: drjoe Fixed handling of integer arrays diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 90eca082a..bca58e75b 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -166,6 +166,7 @@ CPP_TEST_CASES += \ director_overload \ director_primitives \ director_protected \ + director_protected_overloaded \ director_redefined \ director_thread \ director_unroll \ diff --git a/Examples/test-suite/director_protected_overloaded.i b/Examples/test-suite/director_protected_overloaded.i new file mode 100644 index 000000000..a9f786fc7 --- /dev/null +++ b/Examples/test-suite/director_protected_overloaded.i @@ -0,0 +1,21 @@ +%module(directors="1",dirprot="1") director_protected_overloaded + +%director IDataObserver; +%director DerivedDataObserver; + +// protected overloaded methods +%inline %{ + class IDataObserver + { + public: + virtual ~IDataObserver(){} + + protected: + virtual void notoverloaded() = 0; + virtual void isoverloaded() = 0; + virtual void isoverloaded(int i) = 0; + virtual void isoverloaded(int i, double d) = 0; + }; + class DerivedDataObserver : public IDataObserver { + }; +%} diff --git a/Source/Modules/lang.cxx b/Source/Modules/lang.cxx index db8923074..39ede8243 100644 --- a/Source/Modules/lang.cxx +++ b/Source/Modules/lang.cxx @@ -830,9 +830,8 @@ int Language::cDeclaration(Node *n) { if (!(directorsEnabled() && ((is_member_director(CurrentClass, n) && need_nonpublic_member(n)) || is_non_virtual_protected_access(n)))) { return SWIG_NOWRAP; } -#if 0 -// I don't see why this is needed - WSF - /* prevent wrapping the method twice due to overload */ + // Prevent wrapping protected overloaded director methods more than once - + // This bit of code is only needed due to the cDeclaration call in classHandler() String *wrapname = NewStringf("nonpublic_%s%s", symname, Getattr(n, "sym:overname")); if (Getattr(CurrentClass, wrapname)) { Delete(wrapname); @@ -840,7 +839,6 @@ int Language::cDeclaration(Node *n) { } SetFlag(CurrentClass, wrapname); Delete(wrapname); -#endif } } @@ -2476,6 +2474,13 @@ int Language::classHandler(Node *n) { Node *m = Copy(method); Setattr(m, "director", "1"); Setattr(m, "parentNode", n); + /* + * There is a bug that needs fixing still... + * This area of code is creating methods which have not been overidden in a derived class (director methods that are protected in the base) + * If the method is overloaded, then Swig_overload_dispatch() incorrectly generates a call to the base wrapper, _wrap_xxx method + * See director_protected_overloaded.i - Possibly sym:overname needs correcting here. + Printf(stdout, "new method: %s::%s(%s)\n", Getattr(parentNode(m), "name"), Getattr(m, "name"), ParmList_str_defaultargs(Getattr(m, "parms"))); + */ cDeclaration(m); Delete(m); } From 3a23be44344664b1b15b0f9a87de0b2afcb7b3eb Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 13 Jan 2009 07:11:00 +0000 Subject: [PATCH 0306/1680] 1.3.37 final touches git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11063 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- ANNOUNCE | 2 +- CHANGES.current | 8 ++++---- Doc/Manual/Sections.html | 2 +- README | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ANNOUNCE b/ANNOUNCE index 6d27f19e2..9e7af3c20 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -1,4 +1,4 @@ -*** ANNOUNCE: SWIG 1.3.37 (30 December 2008) *** +*** ANNOUNCE: SWIG 1.3.37 (13 January 2009) *** http://www.swig.org diff --git a/CHANGES.current b/CHANGES.current index ef8b9d798..4e3a925a6 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,5 +1,5 @@ -Version 1.3.37 (30 December 2008) -================================= +Version 1.3.37 (13 January 2009) +================================ 2009-01-13: mgossage [Lua] Added contract support for requiring that unsigned numbers are >=0 @@ -11,10 +11,10 @@ Version 1.3.37 (30 December 2008) methods reported by Sam Hendley. 2009-01-12: drjoe - Fixed handling of integer arrays + [R] Fixed handling of integer arrays 2009-01-10: drjoe - Fix integer handling in r to deal correctly with signed + [R] Fix integer handling in r to deal correctly with signed and unsigned issues 2009-01-10: wsfulton diff --git a/Doc/Manual/Sections.html b/Doc/Manual/Sections.html index e869e340f..03fd4aa57 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.37 (30 December 2008) +Last update : SWIG-1.3.37 (13 January 2009)

      Sections

      diff --git a/README b/README index 660e67d30..4c8776f92 100644 --- a/README +++ b/README @@ -1,6 +1,6 @@ SWIG (Simplified Wrapper and Interface Generator) -Version: 1.3.37 (30 December 2008) +Version: 1.3.37 (13 January 2009) Tagline: SWIG is a compiler that integrates C and C++ with languages including Perl, Python, Tcl, Ruby, PHP, Java, Ocaml, Lua, @@ -100,7 +100,7 @@ SWIG-1.3.37 summary: - Improved C# array support - Numerous Allegro CL improvements - Bug fixes/enhancements for Python, PHP, Java, C#, Chicken, Allegro CL, - CFFI, Ruby, Tcl, Perl. + CFFI, Ruby, Tcl, Perl, R, Lua. - Other minor generic bug fixes and enhancements SWIG-1.3.36 summary: From f2c57bd5089f48dbc51b35eb56f860c13d903d8c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 13 Jan 2009 18:21:18 +0000 Subject: [PATCH 0307/1680] bump version to 1.3.38 git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11069 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- ANNOUNCE | 10 +- CHANGES | 342 +++++++++++++++++++++++++++++++++++++++ CHANGES.current | 341 +------------------------------------- Doc/Manual/Sections.html | 2 +- README | 2 +- TODO | 2 +- configure.in | 2 +- 7 files changed, 352 insertions(+), 349 deletions(-) diff --git a/ANNOUNCE b/ANNOUNCE index 9e7af3c20..b426f737b 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -1,10 +1,10 @@ -*** ANNOUNCE: SWIG 1.3.37 (13 January 2009) *** +*** ANNOUNCE: SWIG 1.3.38 (in progress) *** http://www.swig.org -We're pleased to announce SWIG-1.3.37, the latest installment in the -SWIG development effort. SWIG-1.3.37 includes a number of bug fixes +We're pleased to announce SWIG-1.3.38, the latest installment in the +SWIG development effort. SWIG-1.3.38 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.37.tar.gz + http://prdownloads.sourceforge.net/swig/swig-1.3.38.tar.gz A Windows version is also available at - http://prdownloads.sourceforge.net/swig/swigwin-1.3.37.zip + http://prdownloads.sourceforge.net/swig/swigwin-1.3.38.zip Release numbers --------------- diff --git a/CHANGES b/CHANGES index 782849c6f..facb8f0ed 100644 --- a/CHANGES +++ b/CHANGES @@ -2,6 +2,348 @@ SWIG (Simplified Wrapper and Interface Generator) See CHANGES.current for current version. +Version 1.3.37 (13 January 2009) +================================ + +2009-01-13: mgossage + [Lua] Added contract support for requiring that unsigned numbers are >=0 + Rewrote much of Examples/Lua/embed3. + Added a lot to the Lua documentation. + +2009-01-13: wsfulton + Fix compilation error when using directors on protected virtual overloaded + methods reported by Sam Hendley. + +2009-01-12: drjoe + [R] Fixed handling of integer arrays + +2009-01-10: drjoe + [R] Fix integer handling in r to deal correctly with signed + and unsigned issues + +2009-01-10: wsfulton + Patch #1992756 from Colin McDonald - %contract not working for classes + in namespace + +2009-01-05: olly + Mark SWIGPERL5, SWIGPHP5, and SWIGTCL8 as deprecated in the source + code and remove documentation of them. + +2008-12-30: wsfulton + Bug #2430756. All the languages now define a macro in the generated C/C++ + wrapper file indicating which language is being wrapped. The macro name is the + same as those defined when SWIG is run, eg SWIGJAVA, SWIGOCTAVE, SWIGCSHARP etc + and are listed in the "Conditional Compilation" section in the documentation. + +2008-12-23: wsfulton + [Java] Fix #2153773 - %nojavaexception was clearing the exception feature + instead of disabling it. Clearing checked Java exceptions also didn't work. + The new %clearjavaexception can be used for clearing the exception feature. + +2008-12-22: wsfulton + Fix #2432801 - Make SwigValueWrapper exception safe for when copy constructors + throw exceptions. + +2008-12-21: wsfulton + Apply patch #2440046 which fixes possible seg faults for member and global + variable char arrays when the strings are larger than the string array size. + +2008-12-20: wsfulton + The ccache compiler cache has been adapted to work with SWIG and + named ccache-swig. It now works with C/C++ compilers as well as SWIG + and can result in impressive speedups when used to recompile unchanged + code with either a C/C++ compiler or SWIG. Documentation is in CCache.html + or the installed ccache-swig man page. + +2008-12-12: wsfulton + Apply patch from Kalyanov Dmitry which fixes parsing of nested structs + containing comments. + +2008-12-12: wsfulton + Fix error message in some nested struct and %inline parsing error situations + such as unterminated strings and comments. + +2008-12-07: olly + [PHP] Fix warnings when compiling generated wrapper with GCC 4.3. + +2008-12-06: wsfulton + [PHP] Deprecate %pragma(php4). Please use %pragma(php) instead. + The following two warnings have been renamed: + WARN_PHP4_MULTIPLE_INHERITANCE -> WARN_PHP_MULTIPLE_INHERITANCE + WARN_PHP4_UNKNOWN_PRAGMA -> WARN_PHP_UNKNOWN_PRAGMA + + *** POTENTIAL INCOMPATIBILITY *** + +2008-12-04: bhy + [Python] Applied patch SF#2158938: all the SWIG symbol names started with Py + are changed, since they are inappropriate and discouraged in Python + documentation (from http://www.python.org/doc/2.5.2/api/includes.html): + + "All user visible names defined by Python.h (except those defined by + the included standard headers) have one of the prefixes "Py" or "_Py". + Names beginning with "_Py" are for internal use by the Python implementation + and should not be used by extension writers. Structure member names do + not have a reserved prefix. + + Important: user code should never define names that begin with "Py" or "_Py". + This confuses the reader, and jeopardizes the portability of the user + code to future Python versions, which may define additional names beginning + with one of these prefixes." + + Here is a brief list of what changed: + + PySwig* -> SwigPy* + PyObject_ptr -> SwigPtr_PyObject + PyObject_var -> SwigVar_PyObject + PySequence_Base, PySequence_Cont, PySequence_Ref -> + SwigPySequence_Base, SwigPySequence_Cont, SwigPySequence_Ref + PyMap* -> SwigPyMap* + + We provided a pyname_compat.i for backward compatibility. Users whose code having + these symbols and do not want to change it could simply include this file + at front of your code. A better solution is to run the converting tool on + your code, which has been put in SWIG's SVN trunk (Tools/pyname_patch.py) and + you can download it here: + https://swig.svn.sourceforge.net/svnroot/swig/trunk/Tools/pyname_patch.py + + *** POTENTIAL INCOMPATIBILITY *** + +2008-12-02: wsfulton + [Python] Apply patch #2143727 from Serge Monkewitz to fix importing base classes + when the package option is specified in %module and that module is %import'ed. + +2008-11-28: wsfulton + [UTL] Fix #2080497. Some incorrect acceptance of types in the STL, eg a double * element + passed into a vector constructor would be accepted, but the ensuing behaviour + was undefined. Now the type conversion correctly raises an exception. + +2008-11-24: wsfulton + Add -outcurrentdir option. This sets the default output directory to the current + directory instead of the path specified by the input file. This option enables + behaviour similar to c/c++ compilers. Note that this controls the output directory, + but only in the absence of the -o and/or -outdir options. + +2008-11-23: wsfulton + [ruby] Apply patch #2263850 to fix ruby/file.i ... rubyio.h filename change in + ruby 1.9. + +2008-11-23: wsfulton + Apply patch #2319790 from Johan Hake to fix shared_ptr usage in std::tr1 namespace. + +2008-11-21: wsfulton + The use of the include path to find the input file is now deprecated. + This makes the behaviour of SWIG the same as C/C++ compilers in preparation + for use with ccache. + +2008-11-16: wsfulton + Fix -nopreprocess option to: + - correctly report file names in warning and error messages. + - use the original input filename that created the preprocessed output when + determining the C++ wrapper file name (in the absence of -o). Previously + the name of the input file containing the preprocessed output was used. + +2008-11-11: wsfulton + [Java] Add patch #2152691 from MATSUURA Takanori which fixes compiles using the + Intel compiler + +2008-11-01: wsfulton + Add patch #2128249 from Anatoly Techtonik which corrects the C/C++ proxy + class being reported for Python docstrings when %rename is used. + +2008-11-01: wsfulton + Add the strip encoder patch from Anatoly Techtonik #2130016. This enables an + easy way to rename symbols by stripping a commonly used prefix in all the + function/struct names. It works in the same way as the other encoders, such as + title, lower, command etc outlined in CHANGES file dated 12/30/2005. Example + below will rename wxAnotherWidget to AnotherWidget and wxDoSomething to + DoSomething: + + %rename("%(strip:[wx])s") ""; + + struct wxAnotherWidget { + void wxDoSomething(); + }; + +2008-09-26: mutandiz + [allegrocl] + Lots of test-suite work. + - Fix ordering of wrapper output and %{ %} header output. + - Fix declarations of local vars in C wrappers. + - Fix declaration of defined constants in C wrappers. + - Fix declaration of EnumValues in C wrappers. + - add some const typemaps to allegrocl.swg + - add rename for operator bool() overloads. + +2008-09-25: olly + [PHP5] Fill in typemaps for SWIGTYPE and void * (SF#2095186). + +2008-09-22: mutandiz (Mikel Bancroft) + [allegrocl] + - Support wrapping of types whose definitions are not seen by + SWIG. They are treated as forward-referenced classes and if a + definition is not seen are treated as (* :void). + - Don't wrap the contents of unnamed namespaces. + - More code cleanup. Removed some extraneous warnings. + - start work on having the allegrocl mod pass the cpp test-suite. + +2008-09-19: olly + [PHP5] Add typemaps for long long and unsigned long long. + +2008-09-18: wsfulton + [C#] Added C# array typemaps provided by Antti Karanta. + The arrays provide a way to use MarshalAs(UnmanagedType.LPArray) + and pinning the array using 'fixed'. See arrays_csharp.i library file + for details. + +2008-09-18: wsfulton + Document the optional module attribute in the %import directive, + see Modules.html. Add a warning for Python wrappers when the + module name for an imported base class is missing, requiring the + module attribute to be added to %import, eg + + %import(module="FooModule") foo.h + +2008-09-18: olly + [PHP5] Change the default input typemap for char * to turn PHP + Null into C NULL (previously it was converted to an empty string). + The new behaviour is consistent with how the corresponding output + typemap works (SF#2025719). + + If you want to keep the old behaviour, add the following typemap + to your interface file (PHP's convert_to_string_ex() function does + the converting from PHP Null to an empty string): + + %typemap(in) char * { + convert_to_string_ex($input); + $1 = Z_STRVAL_PP($input); + } + +2008-09-18: olly + [PHP5] Fix extra code added to proxy class constructors in the case + where the only constructor takes no arguments. + +2008-09-18: olly + [PHP5] Fix wrapping of a renamed enumerated value of an enum class + member (SF#2095273). + +2008-09-17: mutandiz (Mikel Bancroft) + [allegrocl] + - Fix how forward reference typedefs are handled, so as not to conflict + with other legit typedefs. + - Don't (for now) perform an ffitype typemap lookup when trying to + when calling compose_foreign_type(). This is actually a useful thing + to do in certain cases, the test cases for which I can't currently + locate :/. It's breaking some wrapping behavior that is more commonly + seen, however. I'll readd in a more appropriate way when I can + recreate the needed test case, or a user complains (which means + they probably have a test case). + - document the -isolate command-line arg in the 'swig -help' output. + It was in the html docs, but not there. + - small amount of code cleanup, removed some unused code. + - some minor aesthetic changes. + +2008-09-12: bhy + [Python] Python 3.0 support branch merged into SWIG trunk. Thanks to + Google Summer of Code 2008 for supporting this project! By default + SWIG will generate interface files compatible with both Python 2.x + and 3.0. And there's also some Python 3 new features that can be + enabled by passing a "-py3" command line option to SWIG. These + features are: + + - Function annotation support + Also, the parameter list of proxy function will be generated, + even without the "-py3" option. However, the parameter list + will fallback to *args if the function (or method) is overloaded. + - Buffer interface support + - Abstract base class support + + For details of Python 3 support and these features, please see the + "Python 3 Support" section in the "SWIG and Python" chapter of the SWIG + documentation. + + The "-apply" command line option and support of generating codes + using apply() is removed. Since this is only required by very old + Python. + + This merge also patched SWIG's parser to solve a bug. By this patch, + SWIG features able to be correctly applied on C++ conversion operator, + such like this: + + %feature("shadow") *::operator bool %{ ... %} + +2008-09-02: richardb + [Python] Commit patch #2089149: Director exception handling mangles + returned exception. Exceptions raised by Python code in directors + are now passed through to the caller without change. Also, remove + the ": " prefix which used to be added to other director exceptions + (eg, those due to incorrect return types). + +2008-09-02: wsfulton + [Python] Commit patch #1988296 GCItem multiple module linking issue when using + directors. + +2008-09-02: wsfulton + [C#] Support for 'using' and 'fixed' blocks in the 'csin' typemap is now + possible through the use of the pre attribute and the new terminator attribute, eg + + %typemap(csin, + pre=" using (CDate temp$csinput = new CDate($csinput)) {", + terminator=" } // terminate temp$csinput using block", + ) const CDate & + "$csclassname.getCPtr(temp$csinput)" + + See CSharp.html for more info. + +2008-09-01: wsfulton + [CFFI] Commit patch #2079381 submitted by Boris Smilga - constant exprs put into + no-eval context in DEFCENUM + +2008-08-02: wuzzeb + [Chicken,Allegro] Commit Patch 2019314 + Fixes a build error in chicken, and several build errors and other errors + in Allegro CL + +2008-07-19: wsfulton + Fix building of Tcl examples/test-suite on Mac OSX reported by Gideon Simpson. + +2008-07-17: wsfulton + Fix SF #2019156 Configuring with --without-octave or --without-alllang + did not disable octave. + +2008-07-14: wsfulton + [Java, C#] Fix director typemaps for pointers so that NULL pointers are correctly + marshalled to C#/Java null in director methods. + +2008-07-04: olly + [PHP] For std_vector.i and std_map.i, rename empty() to is_empty() + since "empty" is a PHP reserved word. Based on patch from Mark Klein + in SF#1943417. + +2008-07-04: olly + [PHP] The deprecated command line option "-make" has been removed. + Searches on Google codesearch suggest that nobody is using it now + anyway. + +2008-07-04: olly + [PHP] The SWIG cdata.i library module is now supported. + +2008-07-03: olly + [PHP] The deprecated command line option "-phpfull" has been + removed. We recommend building your extension as a dynamically + loadable module. + +2008-07-02: olly + [PHP4] Support for PHP4 has been removed. The PHP developers are + no longer making new PHP4 releases, and won't even be providing + patches for critical security issues after 2008-08-08. + +2008-07-02: olly + [Python] Import the C extension differently for Python 2.6 and + later so that an implicit relative import doesn't produce a + deprecation warning for 2.6 and a failure for 2.7 and later. + Patch from Richard Boulton in SF#2008229, plus follow-up patches + from Richard and Haoyu Bai. + Version 1.3.36 (24 June 2008) ============================= diff --git a/CHANGES.current b/CHANGES.current index 4e3a925a6..a2ae90755 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,342 +1,3 @@ -Version 1.3.37 (13 January 2009) +Version 1.3.38 (in progress) ================================ -2009-01-13: mgossage - [Lua] Added contract support for requiring that unsigned numbers are >=0 - Rewrote much of Examples/Lua/embed3. - Added a lot to the Lua documentation. - -2009-01-13: wsfulton - Fix compilation error when using directors on protected virtual overloaded - methods reported by Sam Hendley. - -2009-01-12: drjoe - [R] Fixed handling of integer arrays - -2009-01-10: drjoe - [R] Fix integer handling in r to deal correctly with signed - and unsigned issues - -2009-01-10: wsfulton - Patch #1992756 from Colin McDonald - %contract not working for classes - in namespace - -2009-01-05: olly - Mark SWIGPERL5, SWIGPHP5, and SWIGTCL8 as deprecated in the source - code and remove documentation of them. - -2008-12-30: wsfulton - Bug #2430756. All the languages now define a macro in the generated C/C++ - wrapper file indicating which language is being wrapped. The macro name is the - same as those defined when SWIG is run, eg SWIGJAVA, SWIGOCTAVE, SWIGCSHARP etc - and are listed in the "Conditional Compilation" section in the documentation. - -2008-12-23: wsfulton - [Java] Fix #2153773 - %nojavaexception was clearing the exception feature - instead of disabling it. Clearing checked Java exceptions also didn't work. - The new %clearjavaexception can be used for clearing the exception feature. - -2008-12-22: wsfulton - Fix #2432801 - Make SwigValueWrapper exception safe for when copy constructors - throw exceptions. - -2008-12-21: wsfulton - Apply patch #2440046 which fixes possible seg faults for member and global - variable char arrays when the strings are larger than the string array size. - -2008-12-20: wsfulton - The ccache compiler cache has been adapted to work with SWIG and - named ccache-swig. It now works with C/C++ compilers as well as SWIG - and can result in impressive speedups when used to recompile unchanged - code with either a C/C++ compiler or SWIG. Documentation is in CCache.html - or the installed ccache-swig man page. - -2008-12-12: wsfulton - Apply patch from Kalyanov Dmitry which fixes parsing of nested structs - containing comments. - -2008-12-12: wsfulton - Fix error message in some nested struct and %inline parsing error situations - such as unterminated strings and comments. - -2008-12-07: olly - [PHP] Fix warnings when compiling generated wrapper with GCC 4.3. - -2008-12-06: wsfulton - [PHP] Deprecate %pragma(php4). Please use %pragma(php) instead. - The following two warnings have been renamed: - WARN_PHP4_MULTIPLE_INHERITANCE -> WARN_PHP_MULTIPLE_INHERITANCE - WARN_PHP4_UNKNOWN_PRAGMA -> WARN_PHP_UNKNOWN_PRAGMA - - *** POTENTIAL INCOMPATIBILITY *** - -2008-12-04: bhy - [Python] Applied patch SF#2158938: all the SWIG symbol names started with Py - are changed, since they are inappropriate and discouraged in Python - documentation (from http://www.python.org/doc/2.5.2/api/includes.html): - - "All user visible names defined by Python.h (except those defined by - the included standard headers) have one of the prefixes "Py" or "_Py". - Names beginning with "_Py" are for internal use by the Python implementation - and should not be used by extension writers. Structure member names do - not have a reserved prefix. - - Important: user code should never define names that begin with "Py" or "_Py". - This confuses the reader, and jeopardizes the portability of the user - code to future Python versions, which may define additional names beginning - with one of these prefixes." - - Here is a brief list of what changed: - - PySwig* -> SwigPy* - PyObject_ptr -> SwigPtr_PyObject - PyObject_var -> SwigVar_PyObject - PySequence_Base, PySequence_Cont, PySequence_Ref -> - SwigPySequence_Base, SwigPySequence_Cont, SwigPySequence_Ref - PyMap* -> SwigPyMap* - - We provided a pyname_compat.i for backward compatibility. Users whose code having - these symbols and do not want to change it could simply include this file - at front of your code. A better solution is to run the converting tool on - your code, which has been put in SWIG's SVN trunk (Tools/pyname_patch.py) and - you can download it here: - https://swig.svn.sourceforge.net/svnroot/swig/trunk/Tools/pyname_patch.py - - *** POTENTIAL INCOMPATIBILITY *** - -2008-12-02: wsfulton - [Python] Apply patch #2143727 from Serge Monkewitz to fix importing base classes - when the package option is specified in %module and that module is %import'ed. - -2008-11-28: wsfulton - [UTL] Fix #2080497. Some incorrect acceptance of types in the STL, eg a double * element - passed into a vector constructor would be accepted, but the ensuing behaviour - was undefined. Now the type conversion correctly raises an exception. - -2008-11-24: wsfulton - Add -outcurrentdir option. This sets the default output directory to the current - directory instead of the path specified by the input file. This option enables - behaviour similar to c/c++ compilers. Note that this controls the output directory, - but only in the absence of the -o and/or -outdir options. - -2008-11-23: wsfulton - [ruby] Apply patch #2263850 to fix ruby/file.i ... rubyio.h filename change in - ruby 1.9. - -2008-11-23: wsfulton - Apply patch #2319790 from Johan Hake to fix shared_ptr usage in std::tr1 namespace. - -2008-11-21: wsfulton - The use of the include path to find the input file is now deprecated. - This makes the behaviour of SWIG the same as C/C++ compilers in preparation - for use with ccache. - -2008-11-16: wsfulton - Fix -nopreprocess option to: - - correctly report file names in warning and error messages. - - use the original input filename that created the preprocessed output when - determining the C++ wrapper file name (in the absence of -o). Previously - the name of the input file containing the preprocessed output was used. - -2008-11-11: wsfulton - [Java] Add patch #2152691 from MATSUURA Takanori which fixes compiles using the - Intel compiler - -2008-11-01: wsfulton - Add patch #2128249 from Anatoly Techtonik which corrects the C/C++ proxy - class being reported for Python docstrings when %rename is used. - -2008-11-01: wsfulton - Add the strip encoder patch from Anatoly Techtonik #2130016. This enables an - easy way to rename symbols by stripping a commonly used prefix in all the - function/struct names. It works in the same way as the other encoders, such as - title, lower, command etc outlined in CHANGES file dated 12/30/2005. Example - below will rename wxAnotherWidget to AnotherWidget and wxDoSomething to - DoSomething: - - %rename("%(strip:[wx])s") ""; - - struct wxAnotherWidget { - void wxDoSomething(); - }; - -2008-09-26: mutandiz - [allegrocl] - Lots of test-suite work. - - Fix ordering of wrapper output and %{ %} header output. - - Fix declarations of local vars in C wrappers. - - Fix declaration of defined constants in C wrappers. - - Fix declaration of EnumValues in C wrappers. - - add some const typemaps to allegrocl.swg - - add rename for operator bool() overloads. - -2008-09-25: olly - [PHP5] Fill in typemaps for SWIGTYPE and void * (SF#2095186). - -2008-09-22: mutandiz (Mikel Bancroft) - [allegrocl] - - Support wrapping of types whose definitions are not seen by - SWIG. They are treated as forward-referenced classes and if a - definition is not seen are treated as (* :void). - - Don't wrap the contents of unnamed namespaces. - - More code cleanup. Removed some extraneous warnings. - - start work on having the allegrocl mod pass the cpp test-suite. - -2008-09-19: olly - [PHP5] Add typemaps for long long and unsigned long long. - -2008-09-18: wsfulton - [C#] Added C# array typemaps provided by Antti Karanta. - The arrays provide a way to use MarshalAs(UnmanagedType.LPArray) - and pinning the array using 'fixed'. See arrays_csharp.i library file - for details. - -2008-09-18: wsfulton - Document the optional module attribute in the %import directive, - see Modules.html. Add a warning for Python wrappers when the - module name for an imported base class is missing, requiring the - module attribute to be added to %import, eg - - %import(module="FooModule") foo.h - -2008-09-18: olly - [PHP5] Change the default input typemap for char * to turn PHP - Null into C NULL (previously it was converted to an empty string). - The new behaviour is consistent with how the corresponding output - typemap works (SF#2025719). - - If you want to keep the old behaviour, add the following typemap - to your interface file (PHP's convert_to_string_ex() function does - the converting from PHP Null to an empty string): - - %typemap(in) char * { - convert_to_string_ex($input); - $1 = Z_STRVAL_PP($input); - } - -2008-09-18: olly - [PHP5] Fix extra code added to proxy class constructors in the case - where the only constructor takes no arguments. - -2008-09-18: olly - [PHP5] Fix wrapping of a renamed enumerated value of an enum class - member (SF#2095273). - -2008-09-17: mutandiz (Mikel Bancroft) - [allegrocl] - - Fix how forward reference typedefs are handled, so as not to conflict - with other legit typedefs. - - Don't (for now) perform an ffitype typemap lookup when trying to - when calling compose_foreign_type(). This is actually a useful thing - to do in certain cases, the test cases for which I can't currently - locate :/. It's breaking some wrapping behavior that is more commonly - seen, however. I'll readd in a more appropriate way when I can - recreate the needed test case, or a user complains (which means - they probably have a test case). - - document the -isolate command-line arg in the 'swig -help' output. - It was in the html docs, but not there. - - small amount of code cleanup, removed some unused code. - - some minor aesthetic changes. - -2008-09-12: bhy - [Python] Python 3.0 support branch merged into SWIG trunk. Thanks to - Google Summer of Code 2008 for supporting this project! By default - SWIG will generate interface files compatible with both Python 2.x - and 3.0. And there's also some Python 3 new features that can be - enabled by passing a "-py3" command line option to SWIG. These - features are: - - - Function annotation support - Also, the parameter list of proxy function will be generated, - even without the "-py3" option. However, the parameter list - will fallback to *args if the function (or method) is overloaded. - - Buffer interface support - - Abstract base class support - - For details of Python 3 support and these features, please see the - "Python 3 Support" section in the "SWIG and Python" chapter of the SWIG - documentation. - - The "-apply" command line option and support of generating codes - using apply() is removed. Since this is only required by very old - Python. - - This merge also patched SWIG's parser to solve a bug. By this patch, - SWIG features able to be correctly applied on C++ conversion operator, - such like this: - - %feature("shadow") *::operator bool %{ ... %} - -2008-09-02: richardb - [Python] Commit patch #2089149: Director exception handling mangles - returned exception. Exceptions raised by Python code in directors - are now passed through to the caller without change. Also, remove - the ": " prefix which used to be added to other director exceptions - (eg, those due to incorrect return types). - -2008-09-02: wsfulton - [Python] Commit patch #1988296 GCItem multiple module linking issue when using - directors. - -2008-09-02: wsfulton - [C#] Support for 'using' and 'fixed' blocks in the 'csin' typemap is now - possible through the use of the pre attribute and the new terminator attribute, eg - - %typemap(csin, - pre=" using (CDate temp$csinput = new CDate($csinput)) {", - terminator=" } // terminate temp$csinput using block", - ) const CDate & - "$csclassname.getCPtr(temp$csinput)" - - See CSharp.html for more info. - -2008-09-01: wsfulton - [CFFI] Commit patch #2079381 submitted by Boris Smilga - constant exprs put into - no-eval context in DEFCENUM - -2008-08-02: wuzzeb - [Chicken,Allegro] Commit Patch 2019314 - Fixes a build error in chicken, and several build errors and other errors - in Allegro CL - -2008-07-19: wsfulton - Fix building of Tcl examples/test-suite on Mac OSX reported by Gideon Simpson. - -2008-07-17: wsfulton - Fix SF #2019156 Configuring with --without-octave or --without-alllang - did not disable octave. - -2008-07-14: wsfulton - [Java, C#] Fix director typemaps for pointers so that NULL pointers are correctly - marshalled to C#/Java null in director methods. - -2008-07-04: olly - [PHP] For std_vector.i and std_map.i, rename empty() to is_empty() - since "empty" is a PHP reserved word. Based on patch from Mark Klein - in SF#1943417. - -2008-07-04: olly - [PHP] The deprecated command line option "-make" has been removed. - Searches on Google codesearch suggest that nobody is using it now - anyway. - -2008-07-04: olly - [PHP] The SWIG cdata.i library module is now supported. - -2008-07-03: olly - [PHP] The deprecated command line option "-phpfull" has been - removed. We recommend building your extension as a dynamically - loadable module. - -2008-07-02: olly - [PHP4] Support for PHP4 has been removed. The PHP developers are - no longer making new PHP4 releases, and won't even be providing - patches for critical security issues after 2008-08-08. - -2008-07-02: olly - [Python] Import the C extension differently for Python 2.6 and - later so that an implicit relative import doesn't produce a - deprecation warning for 2.6 and a failure for 2.7 and later. - Patch from Richard Boulton in SF#2008229, plus follow-up patches - from Richard and Haoyu Bai. - diff --git a/Doc/Manual/Sections.html b/Doc/Manual/Sections.html index 03fd4aa57..ddca5fed3 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.37 (13 January 2009) +Last update : SWIG-1.3.38 (in progress)

      Sections

      diff --git a/README b/README index 4c8776f92..05da4aa08 100644 --- a/README +++ b/README @@ -1,6 +1,6 @@ SWIG (Simplified Wrapper and Interface Generator) -Version: 1.3.37 (13 January 2009) +Version: 1.3.38 (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/TODO b/TODO index 56f5c731a..bad7a11b9 100644 --- a/TODO +++ b/TODO @@ -1,6 +1,6 @@ SWIG TO-DO -Release: SWIG-1.3.37 +Release: SWIG-1.3.38 ----------------------------------------------------------------------------- diff --git a/configure.in b/configure.in index 4655d829f..0b05df2bc 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.37],[http://www.swig.org]) +AC_INIT([swig],[1.3.38],[http://www.swig.org]) AC_PREREQ(2.58) AC_CONFIG_SRCDIR([Source/Swig/swig.h]) AC_CONFIG_AUX_DIR([Tools/config]) From ff62288c37bc6460acd41345d40749c10afc726e Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 15 Jan 2009 07:29:28 +0000 Subject: [PATCH 0308/1680] Fix segfault when using -perl -v git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11070 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 3 +++ Source/Modules/perl5.cxx | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index a2ae90755..4f43526a1 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,3 +1,6 @@ Version 1.3.38 (in progress) ================================ +2008-01-15: wsfulton + [Perl] Fix seg fault when running with -v option, reported by John Ky. + diff --git a/Source/Modules/perl5.cxx b/Source/Modules/perl5.cxx index 3a8821ac8..e454f5050 100644 --- a/Source/Modules/perl5.cxx +++ b/Source/Modules/perl5.cxx @@ -1139,8 +1139,9 @@ public: /* Do some work on the class name */ if (verbose > 0) { + String *modulename = Getattr(clsmodule, "name"); fprintf(stdout, "setclassname: Found sym:name: %s\n", Char(symname)); - fprintf(stdout, "setclassname: Found module: %s\n", Char(clsmodule)); + fprintf(stdout, "setclassname: Found module: %s\n", Char(modulename)); fprintf(stdout, "setclassname: No package found\n"); } From 1bf93d28c477314ee32b2f2af59fcff8f89931ed Mon Sep 17 00:00:00 2001 From: Haoyu Bai Date: Fri, 16 Jan 2009 01:15:46 +0000 Subject: [PATCH 0309/1680] fix a wrong indent git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11072 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/allegrocl.cxx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Source/Modules/allegrocl.cxx b/Source/Modules/allegrocl.cxx index 424a88193..6e7045054 100644 --- a/Source/Modules/allegrocl.cxx +++ b/Source/Modules/allegrocl.cxx @@ -2148,7 +2148,9 @@ struct IDargs { String *arity; IDargs():name(0), type(0), klass(0), arity(0) { - } String *full_quoted_str() { + } + + String *full_quoted_str() { String *result = no_others_quoted_str(); if (arity) Printf(result, " :arity %s", arity); From 05a2d2dc9dc69efc945806df8bf93543a340c343 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 21 Jan 2009 18:55:32 +0000 Subject: [PATCH 0310/1680] correct ccache-swig title in docs git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11075 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CCache/ccache.yo | 4 ++-- Doc/Manual/Contents.html | 29 ++++++++++++++++++++++------- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/CCache/ccache.yo b/CCache/ccache.yo index 08acb843e..82ac05d2e 100644 --- a/CCache/ccache.yo +++ b/CCache/ccache.yo @@ -8,12 +8,12 @@ whenhtml(htmlcommand( -swig-ccache(1) manpage +ccache-swig(1) manpage -

      swig-ccache(1) manpage

      +

      ccache-swig(1) manpage

      diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index fcba1352d..e764d2828 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -483,7 +483,7 @@
      -

      15 swig-ccache(1) manpage

      +

      15 ccache-swig(1) manpage

      @@ -914,14 +914,29 @@
    • C++ templates
    • C++ Smart Pointers
    • C++ Exceptions -
    • Writing your own custom wrappers -
    • Adding additional Lua code -
    • Details on the Lua binding +
    • Typemaps +
    • Writing typemaps + +
    • Customization of your Bindings + +
    • Details on the Lua binding + From 2a70d76d2eb2ca6b70ef9a30372b1db22edba110 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 21 Jan 2009 19:06:13 +0000 Subject: [PATCH 0311/1680] auto formatting mods git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11076 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Lua.html | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Doc/Manual/Lua.html b/Doc/Manual/Lua.html index e5fc8217a..3856c98ec 100644 --- a/Doc/Manual/Lua.html +++ b/Doc/Manual/Lua.html @@ -42,7 +42,7 @@
    • Typemaps and arrays
    • Typemaps and pointer-pointer functions -
    • Writing Typemaps +
    • Writing typemaps
      • Typemaps you can write
      • SWIG's Lua-C API @@ -1112,10 +1112,12 @@ add exception specification to functions or globally (respectively).

        23.4 Typemaps

        +

        This section explains what typemaps are and the usage of them. The default wrappering behaviour of SWIG is enough in most cases. However sometimes SWIG may need a little additional assistance to know which typemap to apply to provide the best wrappering. This section will be explaining how to use typemaps to best effect

        23.4.1 What is a typemap?

        +

        A typemap is nothing more than a code generation rule that is attached to a specific C datatype. For example, to convert integers from Lua to C, you might define a typemap like this:

        %module example
        @@ -1143,6 +1145,7 @@ Received an integer : 6
         
         

        23.4.2 Using typemaps

        +

        There are many ready written typemaps built into SWIG for all common types (int, float, short, long, char*, enum and more), which SWIG uses automatically, with no effort required on your part.

        However for more complex functions which use input/output parameters or arrays, you will need to make use of <typemaps.i>, which contains typemaps for these situations. For example, consider these functions:

        @@ -1195,6 +1198,7 @@ void swap(int *sx, int *sy);

        23.4.3 Typemaps and arrays

        +

        Arrays present a challenge for SWIG, because like pointers SWIG does not know whether these are input or output values, nor does SWIG have any indication of how large an array should be. However with the proper guidance SWIG can easily wrapper arrays for convenient usage.

        @@ -1258,6 +1262,7 @@ and Lua tables to be 1..N, (the indexing follows the norm for the language). In

        23.4.4 Typemaps and pointer-pointer functions

        +

        Several C++ libraries use a pointer-pointer functions to create its objects. These functions require a pointer to a pointer which is then filled with the pointer to the new object. Microsoft's COM and DirectX as well as many other libraries have this kind of function. An example is given below:

        struct iMath;    // some structure
        @@ -1291,6 +1296,7 @@ ptr=nil -- the iMath* will be GC'ed as normal
         
         

        23.5 Writing typemaps

        +

        This section describes how you can modify SWIG's default wrapping behavior for various C/C++ datatypes using the %typemap directive. This is an advanced topic that assumes familiarity with the Lua C API as well as the material in the "Typemaps" chapter.

        Before proceeding, it should be stressed that writing typemaps is rarely needed unless you want to change some aspect of the wrappering, or to achieve an effect which in not available with the default bindings.

        @@ -1299,6 +1305,7 @@ ptr=nil -- the iMath* will be GC'ed as normal

        23.5.1 Typemaps you can write

        +

        There are many different types of typemap that can be written, the full list can be found in the "Typemaps" chapter. However the following are the most commonly used ones.

          @@ -1311,6 +1318,7 @@ ptr=nil -- the iMath* will be GC'ed as normal

          23.5.2 SWIG's Lua-C API

          +

          This section explains the SWIG specific Lua-C API. It does not cover the main Lua-C api, as this is well documented and not worth covering.

          int SWIG_ConvertPtr(lua_State* L,int index,void** ptr,swig_type_info *type,int flags);

          @@ -1356,6 +1364,7 @@ Similar to SWIG_fail_arg, except that it will display the swig_type_info informa

          23.6 Customization of your Bindings

          +

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

          @@ -1364,6 +1373,7 @@ This section covers adding of some small extra bits to your module to add the la

          23.6.1 Writing your own custom wrappers

          +

          Sometimes, it may be neccesary to add your own special functions, which bypass the normal SWIG wrappering method, and just use the native Lua API calls. These 'native' functions allow direct adding of your own code into the module. This is performed with the %native directive as follows:

          From 061cad9b546a9e4ea90e112de5f0605b44825d05 Mon Sep 17 00:00:00 2001 From: Haoyu Bai Date: Sat, 24 Jan 2009 07:59:46 +0000 Subject: [PATCH 0312/1680] when doing partialcheck, don't skip any test-suite git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11079 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Makefile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.in b/Makefile.in index 123c3cd23..279fa2ca4 100644 --- a/Makefile.in +++ b/Makefile.in @@ -258,7 +258,7 @@ check-%-test-suite: fi @passed=true; \ dir="Examples/test-suite/$*"; \ - if $(skip-$*); then \ + if $(skip-$*) -a $(ACTION) != "partialcheck"; then \ echo skipping $* test-suite $(ACTION); \ elif [ ! -d $$dir ]; then \ echo warning: cannot $(ACTION) $* test-suite "(no dir $$dir)";\ From 6d2aef67d9724358cc842413f6dbcb953d94ab74 Mon Sep 17 00:00:00 2001 From: Haoyu Bai Date: Sat, 24 Jan 2009 13:15:51 +0000 Subject: [PATCH 0313/1680] Replaced all [const] String_or_char * to const_String_or_char_ptr, by the following command: sed -i "s/\(const \)\?String_or_char \*/const_String_or_char_ptr /g" CParse/* Include/* Modules/* Preprocessor/* Swig/* This is a preparation for moving to new DOH, since for strong typed objects we need the const_String_or_char_ptr class to implicit convert to and from String * or const char *. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11080 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/CParse/cparse.h | 2 +- Source/CParse/cscanner.c | 2 +- Source/CParse/parser.y | 4 +- Source/DOH/doh.h | 3 + Source/Modules/allegrocl.cxx | 4 +- Source/Modules/chicken.cxx | 8 +- Source/Modules/csharp.cxx | 2 +- Source/Modules/directors.cxx | 4 +- Source/Modules/guile.cxx | 2 +- Source/Modules/java.cxx | 2 +- Source/Modules/main.cxx | 2 +- Source/Modules/overload.cxx | 8 +- Source/Modules/php.cxx | 2 +- Source/Modules/pike.cxx | 4 +- Source/Modules/ruby.cxx | 16 ++-- Source/Modules/swigmod.h | 12 +-- Source/Modules/uffi.cxx | 4 +- Source/Preprocessor/cpp.c | 13 ++-- Source/Preprocessor/preprocessor.h | 4 +- Source/Swig/cwrap.c | 26 +++---- Source/Swig/error.c | 10 +-- Source/Swig/include.c | 30 ++++---- Source/Swig/misc.c | 2 +- Source/Swig/naming.c | 26 +++---- Source/Swig/parms.c | 2 +- Source/Swig/scanner.c | 4 +- Source/Swig/stype.c | 8 +- Source/Swig/swig.h | 120 ++++++++++++++--------------- Source/Swig/swigfile.h | 26 +++---- Source/Swig/swigparm.h | 2 +- Source/Swig/swigscan.h | 2 +- Source/Swig/swigtree.h | 2 +- Source/Swig/swigwrap.h | 10 +-- Source/Swig/symbol.c | 26 +++---- Source/Swig/tree.c | 2 +- Source/Swig/typemap.c | 28 +++---- Source/Swig/typeobj.c | 10 +-- Source/Swig/typesys.c | 12 +-- Source/Swig/wrapfunc.c | 10 +-- 39 files changed, 230 insertions(+), 226 deletions(-) diff --git a/Source/CParse/cparse.h b/Source/CParse/cparse.h index ecaf1a541..84e66bf91 100644 --- a/Source/CParse/cparse.h +++ b/Source/CParse/cparse.h @@ -34,7 +34,7 @@ extern "C" { extern void scanner_ignore_typedef(void); extern void scanner_last_id(int); extern void scanner_clear_rename(void); - extern void scanner_set_location(String_or_char *file, int line); + extern void scanner_set_location(const_String_or_char_ptr file, int line); extern void scanner_set_main_input_file(String *file); extern String *scanner_get_main_input_file(); extern void Swig_cparse_follow_locators(int); diff --git a/Source/CParse/cscanner.c b/Source/CParse/cscanner.c index cf5b65dd1..476a515e7 100644 --- a/Source/CParse/cscanner.c +++ b/Source/CParse/cscanner.c @@ -442,7 +442,7 @@ int yylook(void) { static int check_typedef = 0; -void scanner_set_location(String_or_char *file, int line) { +void scanner_set_location(const_String_or_char_ptr file, int line) { Scanner_set_location(scan,file,line-1); } diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index a6635ade9..721eb173b 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -66,7 +66,7 @@ static void yyerror (const char *e) { (void)e; } -static Node *new_node(const String_or_char *tag) { +static Node *new_node(const_String_or_char_ptr tag) { Node *n = NewHash(); set_nodeType(n,tag); Setfile(n,cparse_file); @@ -1425,7 +1425,7 @@ static void default_arguments(Node *n) { * Used by the parser to mark subtypes with extra information. * ----------------------------------------------------------------------------- */ -static void tag_nodes(Node *n, const String_or_char *attrname, DOH *value) { +static void tag_nodes(Node *n, const_String_or_char_ptr attrname, DOH *value) { while (n) { Setattr(n, attrname, value); tag_nodes(firstChild(n), attrname, value); diff --git a/Source/DOH/doh.h b/Source/DOH/doh.h index aeac3e32f..c4518a54d 100644 --- a/Source/DOH/doh.h +++ b/Source/DOH/doh.h @@ -144,6 +144,9 @@ typedef void DOH; #define DOHString_or_char DOH #define DOHObj_or_char DOH +typedef const DOHString_or_char * const_String_or_char_ptr; +typedef const DOHString_or_char * DOHconst_String_or_char_ptr; + #define DOH_BEGIN -1 #define DOH_END -2 #define DOH_CUR -3 diff --git a/Source/Modules/allegrocl.cxx b/Source/Modules/allegrocl.cxx index 6e7045054..d21be9364 100644 --- a/Source/Modules/allegrocl.cxx +++ b/Source/Modules/allegrocl.cxx @@ -625,7 +625,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 *name) { +String *get_ffi_type(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 */ @@ -1962,7 +1962,7 @@ int any_varargs(ParmList *pl) { return 0; } -String *get_lisp_type(SwigType *ty, const String_or_char *name) { +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"); diff --git a/Source/Modules/chicken.cxx b/Source/Modules/chicken.cxx index f0a1f6164..d32fabb9e 100644 --- a/Source/Modules/chicken.cxx +++ b/Source/Modules/chicken.cxx @@ -101,12 +101,12 @@ protected: int isPointer(SwigType *t); void dispatchFunction(Node *n); - String *chickenNameMapping(String *, String_or_char *); + String *chickenNameMapping(String *, const_String_or_char_ptr ); String *chickenPrimitiveName(String *); String *runtimeCode(); String *defaultExternalRuntimeFilename(); - String *buildClosFunctionCall(List *types, String_or_char *closname, String_or_char *funcname); + String *buildClosFunctionCall(List *types, const_String_or_char_ptr closname, const_String_or_char_ptr funcname); }; /* ----------------------------------------------------------------------- @@ -1234,7 +1234,7 @@ int CHICKEN::importDirective(Node *n) { return Language::importDirective(n); } -String *CHICKEN::buildClosFunctionCall(List *types, String_or_char *closname, String_or_char *funcname) { +String *CHICKEN::buildClosFunctionCall(List *types, const_String_or_char_ptr closname, const_String_or_char_ptr funcname) { String *method_signature = NewString(""); String *func_args = NewString(""); String *func_call = NewString(""); @@ -1508,7 +1508,7 @@ int CHICKEN::validIdentifier(String *s) { * If class_name = "" that means the mapping is for a function or * variable not attached to any class. * ------------------------------------------------------------ */ -String *CHICKEN::chickenNameMapping(String *name, String_or_char *class_name) { +String *CHICKEN::chickenNameMapping(String *name, const_String_or_char_ptr class_name) { String *n = NewString(""); if (Strcmp(class_name, "") == 0) { diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index 15bbf4323..ca2e23df5 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -85,7 +85,7 @@ class CSHARP:public Language { enum EnumFeature { SimpleEnum, TypeunsafeEnum, TypesafeEnum, ProperEnum }; - static Parm *NewParmFromNode(SwigType *type, const String_or_char *name, Node *n) { + 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)); diff --git a/Source/Modules/directors.cxx b/Source/Modules/directors.cxx index 4363cd813..158b53502 100644 --- a/Source/Modules/directors.cxx +++ b/Source/Modules/directors.cxx @@ -84,7 +84,7 @@ String *Swig_director_declaration(Node *n) { } -String *Swig_method_call(String_or_char *name, ParmList *parms) { +String *Swig_method_call(const_String_or_char_ptr name, ParmList *parms) { String *func; int i = 0; int comma = 0; @@ -128,7 +128,7 @@ String *Swig_method_call(String_or_char *name, ParmList *parms) { * */ -String *Swig_method_decl(SwigType *returntype, SwigType *decl, const String_or_char *id, List *args, int strip, int values) { +String *Swig_method_decl(SwigType *returntype, SwigType *decl, const_String_or_char_ptr id, List *args, int strip, int values) { String *result; List *elements; String *element = 0, *nextelement; diff --git a/Source/Modules/guile.cxx b/Source/Modules/guile.cxx index 61de06925..e3bf2f017 100644 --- a/Source/Modules/guile.cxx +++ b/Source/Modules/guile.cxx @@ -1654,7 +1654,7 @@ public: * If class_name = "" that means the mapping is for a function or * variable not attached to any class. * ------------------------------------------------------------ */ - String *goopsNameMapping(String *name, String_or_char *class_name) { + String *goopsNameMapping(String *name, const_String_or_char_ptr class_name) { String *n = NewString(""); if (Strcmp(class_name, "") == 0) { diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index 48b9285de..48cf66444 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -82,7 +82,7 @@ class JAVA:public Language { enum EnumFeature { SimpleEnum, TypeunsafeEnum, TypesafeEnum, ProperEnum }; - static Parm *NewParmFromNode(SwigType *type, const String_or_char *name, Node *n) { + 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)); diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx index 6248691fc..00596670d 100644 --- a/Source/Modules/main.cxx +++ b/Source/Modules/main.cxx @@ -285,7 +285,7 @@ static void set_outdir(const String *c_wrapper_file_dir) { } /* This function sets the name of the configuration file */ -void SWIG_config_file(const String_or_char *filename) { +void SWIG_config_file(const_String_or_char_ptr filename) { lang_config = NewString(filename); } diff --git a/Source/Modules/overload.cxx b/Source/Modules/overload.cxx index d16913885..511e55004 100644 --- a/Source/Modules/overload.cxx +++ b/Source/Modules/overload.cxx @@ -316,7 +316,7 @@ static bool print_typecheck(String *f, int j, Parm *pj) { * ReplaceFormat() * ----------------------------------------------------------------------------- */ -static String *ReplaceFormat(const String_or_char *fmt, int j) { +static String *ReplaceFormat(const_String_or_char_ptr fmt, int j) { String *lfmt = NewString(fmt); char buf[50]; sprintf(buf, "%d", j); @@ -352,7 +352,7 @@ static String *ReplaceFormat(const String_or_char *fmt, int j) { /* Cast dispatch mechanism. */ -String *Swig_overload_dispatch_cast(Node *n, const String_or_char *fmt, int *maxargs) { +String *Swig_overload_dispatch_cast(Node *n, const_String_or_char_ptr fmt, int *maxargs) { int i, j; *maxargs = 1; @@ -536,7 +536,7 @@ String *Swig_overload_dispatch_cast(Node *n, const String_or_char *fmt, int *max /* Fast dispatch mechanism, provided by Salvador Fandi~no Garc'ia (#930586). */ -String *Swig_overload_dispatch_fast(Node *n, const String_or_char *fmt, int *maxargs) { +String *Swig_overload_dispatch_fast(Node *n, const_String_or_char_ptr fmt, int *maxargs) { int i, j; *maxargs = 1; @@ -695,7 +695,7 @@ String *Swig_overload_dispatch_fast(Node *n, const String_or_char *fmt, int *max return f; } -String *Swig_overload_dispatch(Node *n, const String_or_char *fmt, int *maxargs) { +String *Swig_overload_dispatch(Node *n, const_String_or_char_ptr fmt, int *maxargs) { if (fast_dispatch_mode || GetFlag(n, "feature:fastdispatch")) { return Swig_overload_dispatch_fast(n, fmt, maxargs); diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index 18a7fa9e9..0a0e6d6d4 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -1934,7 +1934,7 @@ public: return NewStringEmpty(); } - String *PhpTypeFromTypemap(char *op, Node *n, String_or_char *lname) { + String *PhpTypeFromTypemap(char *op, Node *n, const_String_or_char_ptr lname) { String *tms = Swig_typemap_lookup(op, n, lname, 0); if (!tms) return 0; diff --git a/Source/Modules/pike.cxx b/Source/Modules/pike.cxx index ff9b2bdc3..800c8f74c 100644 --- a/Source/Modules/pike.cxx +++ b/Source/Modules/pike.cxx @@ -224,7 +224,7 @@ public: * name (i.e. "enum_test"). * ------------------------------------------------------------ */ - String *strip(const DOHString_or_char *name) { + String *strip(const DOHconst_String_or_char_ptr name) { String *s = Copy(name); if (Strncmp(name, PrefixPlusUnderscore, Len(PrefixPlusUnderscore)) != 0) { return s; @@ -237,7 +237,7 @@ public: * add_method() * ------------------------------------------------------------ */ - void add_method(const DOHString_or_char *name, const DOHString_or_char *function, const DOHString_or_char *description) { + void add_method(const DOHconst_String_or_char_ptr name, const DOHconst_String_or_char_ptr function, const DOHconst_String_or_char_ptr description) { String *rename = NULL; switch (current) { case NO_CPP: diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx index dffd068af..dcc778225 100644 --- a/Source/Modules/ruby.cxx +++ b/Source/Modules/ruby.cxx @@ -78,7 +78,7 @@ public: Delete(temp); } - void set_name(const String_or_char *cn, const String_or_char *rn, const String_or_char *valn) { + void set_name(const_String_or_char_ptr cn, const_String_or_char_ptr rn, const_String_or_char_ptr valn) { /* Original C/C++ class (or struct) name */ Clear(cname); Append(cname, cn); @@ -104,7 +104,7 @@ public: Printv(prefix, (rn ? rn : cn), "_", NIL); } - char *strip(const String_or_char *s) { + char *strip(const_String_or_char_ptr s) { Clear(temp); Append(temp, s); if (Strncmp(s, prefix, Len(prefix)) == 0) { @@ -1228,7 +1228,7 @@ public: /** * Process the comma-separated list of aliases (if any). */ - void defineAliases(Node *n, const String_or_char *iname) { + void defineAliases(Node *n, const_String_or_char_ptr iname) { String *aliasv = Getattr(n, "feature:alias"); if (aliasv) { List *aliases = Split(aliasv, ',', INT_MAX); @@ -1262,7 +1262,7 @@ public: * as another instance of the same class. * --------------------------------------------------------------------- */ - void create_command(Node *n, const String_or_char *iname) { + void create_command(Node *n, const_String_or_char_ptr iname) { String *alloc_func = Swig_name_wrapper(iname); String *wname = Swig_name_wrapper(iname); @@ -2566,7 +2566,7 @@ public: /* First wrap the allocate method */ current = CONSTRUCTOR_ALLOCATE; - Swig_name_register((String_or_char *) "construct", (String_or_char *) "%c_allocate"); + Swig_name_register((const_String_or_char_ptr ) "construct", (const_String_or_char_ptr ) "%c_allocate"); Language::constructorHandler(n); @@ -2601,7 +2601,7 @@ public: Delete(docs); current = CONSTRUCTOR_INITIALIZE; - Swig_name_register((String_or_char *) "construct", (String_or_char *) "new_%c"); + Swig_name_register((const_String_or_char_ptr ) "construct", (const_String_or_char_ptr ) "new_%c"); Language::constructorHandler(n); /* Restore original parameter list */ @@ -2609,7 +2609,7 @@ public: Swig_restore(n); /* Done */ - Swig_name_unregister((String_or_char *) "construct"); + Swig_name_unregister((const_String_or_char_ptr ) "construct"); current = NO_CPP; klass->constructor_defined = 1; return SWIG_OK; @@ -2623,7 +2623,7 @@ public: /* First wrap the allocate method */ current = CONSTRUCTOR_ALLOCATE; - Swig_name_register((String_or_char *) "construct", (String_or_char *) "%c_allocate"); + Swig_name_register((const_String_or_char_ptr ) "construct", (const_String_or_char_ptr ) "%c_allocate"); return Language::copyconstructorHandler(n); } diff --git a/Source/Modules/swigmod.h b/Source/Modules/swigmod.h index 21f098325..8dec8d0af 100644 --- a/Source/Modules/swigmod.h +++ b/Source/Modules/swigmod.h @@ -313,7 +313,7 @@ int SWIG_main(int, char **, Language *); void emit_parameter_variables(ParmList *l, Wrapper *f); void emit_return_variable(Node *n, SwigType *rt, Wrapper *f); void SWIG_exit(int); /* use EXIT_{SUCCESS,FAILURE} */ -void SWIG_config_file(const String_or_char *); +void SWIG_config_file(const_String_or_char_ptr ); const String *SWIG_output_directory(); void SWIG_config_cppext(const char *ext); @@ -329,17 +329,17 @@ void emit_mark_varargs(ParmList *l); String *emit_action(Node *n); int emit_action_code(Node *n, String *wrappercode, String *action); void Swig_overload_check(Node *n); -String *Swig_overload_dispatch(Node *n, const String_or_char *fmt, int *); -String *Swig_overload_dispatch_cast(Node *n, const String_or_char *fmt, int *); -String *Swig_overload_dispatch_fast(Node *n, const String_or_char *fmt, int *); +String *Swig_overload_dispatch(Node *n, const_String_or_char_ptr fmt, int *); +String *Swig_overload_dispatch_cast(Node *n, const_String_or_char_ptr fmt, int *); +String *Swig_overload_dispatch_fast(Node *n, const_String_or_char_ptr fmt, int *); SwigType *cplus_value_type(SwigType *t); /* directors.cxx start */ String *Swig_csuperclass_call(String *base, String *method, ParmList *l); String *Swig_class_declaration(Node *n, String *name); String *Swig_class_name(Node *n); -String *Swig_method_call(String_or_char *name, ParmList *parms); -String *Swig_method_decl(SwigType *rtype, SwigType *decl, const String_or_char *id, List *args, int strip, int values); +String *Swig_method_call(const_String_or_char_ptr name, ParmList *parms); +String *Swig_method_decl(SwigType *rtype, SwigType *decl, const_String_or_char_ptr id, List *args, int strip, int values); String *Swig_director_declaration(Node *n); void Swig_director_emit_dynamic_cast(Node *n, Wrapper *f); /* directors.cxx end */ diff --git a/Source/Modules/uffi.cxx b/Source/Modules/uffi.cxx index 4feeb58f2..5fdc6101d 100644 --- a/Source/Modules/uffi.cxx +++ b/Source/Modules/uffi.cxx @@ -131,7 +131,7 @@ static void add_defined_foreign_type(String *type) { } -static String *get_ffi_type(SwigType *ty, const String_or_char *name) { +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"); @@ -167,7 +167,7 @@ static String *get_ffi_type(SwigType *ty, const String_or_char *name) { return 0; } -static String *get_lisp_type(SwigType *ty, const String_or_char *name) { +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"); diff --git a/Source/Preprocessor/cpp.c b/Source/Preprocessor/cpp.c index 2b9e25fef..635186bb5 100644 --- a/Source/Preprocessor/cpp.c +++ b/Source/Preprocessor/cpp.c @@ -74,7 +74,7 @@ static void copy_location(const DOH *s1, DOH *s2) { Setline(s2, Getline((DOH *) s1)); } -static String *cpp_include(String_or_char *fn, int sysfile) { +static String *cpp_include(const_String_or_char_ptr fn, int sysfile) { String *s = sysfile ? Swig_include_sys(fn) : Swig_include(fn); if (s && single_include) { String *file = Getfile(s); @@ -261,8 +261,9 @@ void Preprocessor_error_as_warning(int a) { * ----------------------------------------------------------------------------- */ -String_or_char *Macro_vararg_name(String_or_char *str, String_or_char *line) { - String_or_char *argname, *varargname; +const_String_or_char_ptr Macro_vararg_name(const_String_or_char_ptr str, const_String_or_char_ptr line) { + String *argname; + String *varargname; char *s, *dots; argname = Copy(str); @@ -288,13 +289,13 @@ String_or_char *Macro_vararg_name(String_or_char *str, String_or_char *line) { return varargname; } -Hash *Preprocessor_define(const String_or_char *_str, int swigmacro) { +Hash *Preprocessor_define(const_String_or_char_ptr _str, int swigmacro) { String *macroname = 0, *argstr = 0, *macrovalue = 0, *file = 0, *s = 0; Hash *macro = 0, *symbols = 0, *m1; List *arglist = 0; int c, line; int varargs = 0; - String_or_char *str = (String_or_char *) _str; + const_String_or_char_ptr str = (const_String_or_char_ptr ) _str; assert(cpp); assert(str); @@ -532,7 +533,7 @@ macro_error: * * Undefines a macro. * ----------------------------------------------------------------------------- */ -void Preprocessor_undef(const String_or_char *str) { +void Preprocessor_undef(const_String_or_char_ptr str) { Hash *symbols; assert(cpp); symbols = Getattr(cpp, kpp_symbols); diff --git a/Source/Preprocessor/preprocessor.h b/Source/Preprocessor/preprocessor.h index 4f7ff8804..3579eede2 100644 --- a/Source/Preprocessor/preprocessor.h +++ b/Source/Preprocessor/preprocessor.h @@ -19,8 +19,8 @@ extern "C" { #endif extern int Preprocessor_expr(String *s, int *error); extern char *Preprocessor_expr_error(void); - extern Hash *Preprocessor_define(const String_or_char *str, int swigmacro); - extern void Preprocessor_undef(const String_or_char *name); + extern Hash *Preprocessor_define(const_String_or_char_ptr str, int swigmacro); + extern void Preprocessor_undef(const_String_or_char_ptr name); extern void Preprocessor_init(void); extern void Preprocessor_delete(void); extern String *Preprocessor_parse(String *s); diff --git a/Source/Swig/cwrap.c b/Source/Swig/cwrap.c index 18920ecc2..3bdf2b13e 100644 --- a/Source/Swig/cwrap.c +++ b/Source/Swig/cwrap.c @@ -45,7 +45,7 @@ String *Swig_cparm_name(Parm *p, int i) { * and user defined types to pointers. * ----------------------------------------------------------------------------- */ -static String *Swig_clocal(SwigType *t, const String_or_char *name, const String_or_char *value) { +static String *Swig_clocal(SwigType *t, const_String_or_char_ptr name, const_String_or_char_ptr value) { String *decl; decl = NewStringEmpty(); @@ -147,7 +147,7 @@ String *Swig_wrapped_member_var_type(SwigType *t, int varcref) { } -static String *Swig_wrapped_var_deref(SwigType *t, String_or_char *name, int varcref) { +static String *Swig_wrapped_var_deref(SwigType *t, const_String_or_char_ptr name, int varcref) { if (SwigType_isclass(t)) { if (varcref) { if (cparse_cplusplus) { @@ -163,7 +163,7 @@ static String *Swig_wrapped_var_deref(SwigType *t, String_or_char *name, int var } } -static String *Swig_wrapped_var_assign(SwigType *t, const String_or_char *name, int varcref) { +static String *Swig_wrapped_var_assign(SwigType *t, const_String_or_char_ptr name, int varcref) { if (SwigType_isclass(t)) { if (varcref) { return NewStringf("%s", name); @@ -251,7 +251,7 @@ int Swig_cargs(Wrapper *w, ParmList *p) { * function call. * ----------------------------------------------------------------------------- */ -String *Swig_cresult(SwigType *t, const String_or_char *name, const String_or_char *decl) { +String *Swig_cresult(SwigType *t, const_String_or_char_ptr name, const_String_or_char_ptr decl) { String *fcall; fcall = NewStringEmpty(); @@ -309,7 +309,7 @@ String *Swig_cresult(SwigType *t, const String_or_char *name, const String_or_ch * * ----------------------------------------------------------------------------- */ -String *Swig_cfunction_call(String_or_char *name, ParmList *parms) { +String *Swig_cfunction_call(const_String_or_char_ptr name, ParmList *parms) { String *func; int i = 0; int comma = 0; @@ -376,7 +376,7 @@ String *Swig_cfunction_call(String_or_char *name, ParmList *parms) { * set to "(*this)->" or some similar sequence. * ----------------------------------------------------------------------------- */ -static String *Swig_cmethod_call(String_or_char *name, ParmList *parms, String_or_char *self, String *explicit_qualifier, SwigType *director_type) { +static String *Swig_cmethod_call(const_String_or_char_ptr name, ParmList *parms, const_String_or_char_ptr self, String *explicit_qualifier, SwigType *director_type) { String *func, *nname; int i = 0; Parm *p = parms; @@ -468,7 +468,7 @@ static String *Swig_cmethod_call(String_or_char *name, ParmList *parms, String_o * calloc(1,sizeof(name)); * ----------------------------------------------------------------------------- */ -String *Swig_cconstructor_call(String_or_char *name) { +String *Swig_cconstructor_call(const_String_or_char_ptr name) { DOH *func; func = NewStringEmpty(); @@ -487,7 +487,7 @@ String *Swig_cconstructor_call(String_or_char *name) { * * ----------------------------------------------------------------------------- */ -String *Swig_cppconstructor_base_call(String_or_char *name, ParmList *parms, int skip_self) { +String *Swig_cppconstructor_base_call(const_String_or_char_ptr name, ParmList *parms, int skip_self) { String *func; String *nname; int i = 0; @@ -532,15 +532,15 @@ String *Swig_cppconstructor_base_call(String_or_char *name, ParmList *parms, int return func; } -String *Swig_cppconstructor_call(String_or_char *name, ParmList *parms) { +String *Swig_cppconstructor_call(const_String_or_char_ptr name, ParmList *parms) { return Swig_cppconstructor_base_call(name, parms, 0); } -String *Swig_cppconstructor_nodirector_call(String_or_char *name, ParmList *parms) { +String *Swig_cppconstructor_nodirector_call(const_String_or_char_ptr name, ParmList *parms) { return Swig_cppconstructor_base_call(name, parms, 1); } -String *Swig_cppconstructor_director_call(String_or_char *name, ParmList *parms) { +String *Swig_cppconstructor_director_call(const_String_or_char_ptr name, ParmList *parms) { return Swig_cppconstructor_base_call(name, parms, 0); } @@ -683,7 +683,7 @@ String *Swig_cppdestructor_call(Node *n) { * * ----------------------------------------------------------------------------- */ -String *Swig_cmemberset_call(String_or_char *name, SwigType *type, String_or_char *self, int varcref) { +String *Swig_cmemberset_call(const_String_or_char_ptr name, SwigType *type, const_String_or_char_ptr self, int varcref) { String *func; String *pname0 = Swig_cparm_name(0, 0); String *pname1 = Swig_cparm_name(0, 1); @@ -718,7 +718,7 @@ String *Swig_cmemberset_call(String_or_char *name, SwigType *type, String_or_cha * * ----------------------------------------------------------------------------- */ -String *Swig_cmemberget_call(const String_or_char *name, SwigType *t, String_or_char *self, int varcref) { +String *Swig_cmemberget_call(const_String_or_char_ptr name, SwigType *t, const_String_or_char_ptr self, int varcref) { String *func; String *call; String *pname0 = Swig_cparm_name(0, 0); diff --git a/Source/Swig/error.c b/Source/Swig/error.c index 1eaba1f17..156fe06a7 100644 --- a/Source/Swig/error.c +++ b/Source/Swig/error.c @@ -50,7 +50,7 @@ static char wrn_nnum_fmt[64]; static char err_line_fmt[64]; static char err_eof_fmt[64]; -static String *format_filename(const String_or_char *filename); +static String *format_filename(const_String_or_char_ptr filename); /* ----------------------------------------------------------------------------- * Swig_warning() @@ -58,7 +58,7 @@ static String *format_filename(const String_or_char *filename); * Issue a warning message * ----------------------------------------------------------------------------- */ -void Swig_warning(int wnum, const String_or_char *filename, int line, const char *fmt, ...) { +void Swig_warning(int wnum, const_String_or_char_ptr filename, int line, const char *fmt, ...) { String *out; char *msg; int wrn = 1; @@ -121,7 +121,7 @@ void Swig_warning(int wnum, const String_or_char *filename, int line, const char * Issue an error message * ----------------------------------------------------------------------------- */ -void Swig_error(const String_or_char *filename, int line, const char *fmt, ...) { +void Swig_error(const_String_or_char_ptr filename, int line, const char *fmt, ...) { va_list ap; String *formatted_filename = NULL; @@ -170,7 +170,7 @@ void Swig_error_silent(int s) { * Takes a comma separate list of warning numbers and puts in the filter. * ----------------------------------------------------------------------------- */ -void Swig_warnfilter(const String_or_char *wlist, int add) { +void Swig_warnfilter(const_String_or_char_ptr wlist, int add) { char *c; char *cw; String *s; @@ -268,7 +268,7 @@ void Swig_error_msg_format(ErrorMessageFormat format) { * * Remove double backslashes in Windows filename paths for display * ----------------------------------------------------------------------------- */ -static String *format_filename(const String_or_char *filename) { +static String *format_filename(const_String_or_char_ptr filename) { String *formatted_filename = NewString(filename); #if defined(_WIN32) Replaceall(formatted_filename, "\\\\", "\\"); diff --git a/Source/Swig/include.c b/Source/Swig/include.c index cf105c787..f42eb5d45 100644 --- a/Source/Swig/include.c +++ b/Source/Swig/include.c @@ -33,7 +33,7 @@ int Swig_get_push_dir(void) { * Adds a directory to the SWIG search path. * ----------------------------------------------------------------------------- */ -List *Swig_add_directory(const String_or_char *dirname) { +List *Swig_add_directory(const_String_or_char_ptr dirname) { String *adirname; if (!directories) directories = NewList(); @@ -53,7 +53,7 @@ List *Swig_add_directory(const String_or_char *dirname) { * the preprocessor to grab files in the same directory as other included files. * ----------------------------------------------------------------------------- */ -void Swig_push_directory(const String_or_char *dirname) { +void Swig_push_directory(const_String_or_char_ptr dirname) { String *pdirname; if (!Swig_get_push_dir()) return; @@ -155,7 +155,7 @@ List *Swig_search_path() { * FILE * on success. * ----------------------------------------------------------------------------- */ -static FILE *Swig_open_file(const String_or_char *name, int sysfile, int use_include_path) { +static FILE *Swig_open_file(const_String_or_char_ptr name, int sysfile, int use_include_path) { FILE *f; String *filename; List *spath = 0; @@ -191,12 +191,12 @@ static FILE *Swig_open_file(const String_or_char *name, int sysfile, int use_inc } /* Open a file - searching the include paths to find it */ -FILE *Swig_include_open(const String_or_char *name) { +FILE *Swig_include_open(const_String_or_char_ptr name) { return Swig_open_file(name, 0, 1); } /* Open a file - does not use include paths to find it */ -FILE *Swig_open(const String_or_char *name) { +FILE *Swig_open(const_String_or_char_ptr name) { return Swig_open_file(name, 0, 0); } @@ -233,7 +233,7 @@ String *Swig_read_file(FILE *f) { * Opens a file and returns it as a string. * ----------------------------------------------------------------------------- */ -static String *Swig_include_any(const String_or_char *name, int sysfile) { +static String *Swig_include_any(const_String_or_char_ptr name, int sysfile) { FILE *f; String *str; String *file; @@ -251,11 +251,11 @@ static String *Swig_include_any(const String_or_char *name, int sysfile) { return str; } -String *Swig_include(const String_or_char *name) { +String *Swig_include(const_String_or_char_ptr name) { return Swig_include_any(name, 0); } -String *Swig_include_sys(const String_or_char *name) { +String *Swig_include_sys(const_String_or_char_ptr name) { return Swig_include_any(name, 1); } @@ -265,7 +265,7 @@ String *Swig_include_sys(const String_or_char *name) { * Copies the contents of a file into another file * ----------------------------------------------------------------------------- */ -int Swig_insert_file(const String_or_char *filename, File *outfile) { +int Swig_insert_file(const_String_or_char_ptr filename, File *outfile) { char buffer[4096]; int nbytes; FILE *f = Swig_include_open(filename); @@ -289,7 +289,7 @@ int Swig_insert_file(const String_or_char *filename, File *outfile) { static Hash *named_files = 0; -void Swig_register_filebyname(const String_or_char *filename, File *outfile) { +void Swig_register_filebyname(const_String_or_char_ptr filename, File *outfile) { if (!named_files) named_files = NewHash(); Setattr(named_files, filename, outfile); @@ -301,7 +301,7 @@ void Swig_register_filebyname(const String_or_char *filename, File *outfile) { * Get a named file * ----------------------------------------------------------------------------- */ -File *Swig_filebyname(const String_or_char *filename) { +File *Swig_filebyname(const_String_or_char_ptr filename) { if (!named_files) return 0; return Getattr(named_files, filename); @@ -313,7 +313,7 @@ File *Swig_filebyname(const String_or_char *filename) { * Returns the suffix of a file * ----------------------------------------------------------------------------- */ -char *Swig_file_suffix(const String_or_char *filename) { +char *Swig_file_suffix(const_String_or_char_ptr filename) { char *d; char *c = Char(filename); int len = Len(filename); @@ -335,7 +335,7 @@ char *Swig_file_suffix(const String_or_char *filename) { * Returns the filename with no suffix attached. * ----------------------------------------------------------------------------- */ -char *Swig_file_basename(const String_or_char *filename) { +char *Swig_file_basename(const_String_or_char_ptr filename) { static char tmp[1024]; char *c; strcpy(tmp, Char(filename)); @@ -349,7 +349,7 @@ char *Swig_file_basename(const String_or_char *filename) { * * Return the file with any leading path stripped off * ----------------------------------------------------------------------------- */ -char *Swig_file_filename(const String_or_char *filename) { +char *Swig_file_filename(const_String_or_char_ptr filename) { static char tmp[1024]; const char *delim = SWIG_FILE_DELIMITER; char *c; @@ -367,7 +367,7 @@ char *Swig_file_filename(const String_or_char *filename) { * * Return the name of the directory associated with a file * ----------------------------------------------------------------------------- */ -char *Swig_file_dirname(const String_or_char *filename) { +char *Swig_file_dirname(const_String_or_char_ptr filename) { static char tmp[1024]; const char *delim = SWIG_FILE_DELIMITER; char *c; diff --git a/Source/Swig/misc.c b/Source/Swig/misc.c index 9e8de8c78..8c17d3ddb 100644 --- a/Source/Swig/misc.c +++ b/Source/Swig/misc.c @@ -77,7 +77,7 @@ void Swig_banner(File *f) { * Emits a SWIG identifying banner in the target language * ----------------------------------------------------------------------------- */ -void Swig_banner_target_lang(File *f, const String_or_char *commentchar) { +void Swig_banner_target_lang(File *f, const_String_or_char_ptr commentchar) { Printf(f, "%s This file was automatically generated by SWIG (http://www.swig.org).\n", commentchar); Printf(f, "%s Version %s\n", commentchar, Swig_package_version()); Printf(f, "%s\n", commentchar); diff --git a/Source/Swig/naming.c b/Source/Swig/naming.c index f34a24612..30a8aef0e 100644 --- a/Source/Swig/naming.c +++ b/Source/Swig/naming.c @@ -27,13 +27,13 @@ static Hash *naming_hash = 0; * Register a new naming format. * ----------------------------------------------------------------------------- */ -void Swig_name_register(const String_or_char *method, const String_or_char *format) { +void Swig_name_register(const_String_or_char_ptr method, const_String_or_char_ptr format) { if (!naming_hash) naming_hash = NewHash(); Setattr(naming_hash, method, format); } -void Swig_name_unregister(const String_or_char *method) { +void Swig_name_unregister(const_String_or_char_ptr method) { if (naming_hash) { Delattr(naming_hash, method); } @@ -127,7 +127,7 @@ static int name_mangle(String *r) { * Converts all of the non-identifier characters of a string to underscores. * ----------------------------------------------------------------------------- */ -String *Swig_name_mangle(const String_or_char *s) { +String *Swig_name_mangle(const_String_or_char_ptr s) { #if 0 String *r = NewString(s); name_mangle(r); @@ -143,7 +143,7 @@ String *Swig_name_mangle(const String_or_char *s) { * Returns the name of a wrapper function. * ----------------------------------------------------------------------------- */ -String *Swig_name_wrapper(const String_or_char *fname) { +String *Swig_name_wrapper(const_String_or_char_ptr fname) { String *r; String *f; @@ -168,7 +168,7 @@ String *Swig_name_wrapper(const String_or_char *fname) { * Returns the name of a class method. * ----------------------------------------------------------------------------- */ -String *Swig_name_member(const String_or_char *classname, const String_or_char *mname) { +String *Swig_name_member(const_String_or_char_ptr classname, const_String_or_char_ptr mname) { String *r; String *f; String *rclassname; @@ -201,7 +201,7 @@ String *Swig_name_member(const String_or_char *classname, const String_or_char * * Returns the name of the accessor function used to get a variable. * ----------------------------------------------------------------------------- */ -String *Swig_name_get(const String_or_char *vname) { +String *Swig_name_get(const_String_or_char_ptr vname) { String *r; String *f; @@ -229,7 +229,7 @@ String *Swig_name_get(const String_or_char *vname) { * Returns the name of the accessor function used to set a variable. * ----------------------------------------------------------------------------- */ -String *Swig_name_set(const String_or_char *vname) { +String *Swig_name_set(const_String_or_char_ptr vname) { String *r; String *f; @@ -253,7 +253,7 @@ String *Swig_name_set(const String_or_char *vname) { * Returns the name of the accessor function used to create an object. * ----------------------------------------------------------------------------- */ -String *Swig_name_construct(const String_or_char *classname) { +String *Swig_name_construct(const_String_or_char_ptr classname) { String *r; String *f; String *rclassname; @@ -286,7 +286,7 @@ String *Swig_name_construct(const String_or_char *classname) { * Returns the name of the accessor function used to copy an object. * ----------------------------------------------------------------------------- */ -String *Swig_name_copyconstructor(const String_or_char *classname) { +String *Swig_name_copyconstructor(const_String_or_char_ptr classname) { String *r; String *f; String *rclassname; @@ -319,7 +319,7 @@ String *Swig_name_copyconstructor(const String_or_char *classname) { * Returns the name of the accessor function used to destroy an object. * ----------------------------------------------------------------------------- */ -String *Swig_name_destroy(const String_or_char *classname) { +String *Swig_name_destroy(const_String_or_char_ptr classname) { String *r; String *f; String *rclassname; @@ -351,7 +351,7 @@ String *Swig_name_destroy(const String_or_char *classname) { * Returns the name of the accessor function used to disown an object. * ----------------------------------------------------------------------------- */ -String *Swig_name_disown(const String_or_char *classname) { +String *Swig_name_disown(const_String_or_char_ptr classname) { String *r; String *f; String *rclassname; @@ -727,7 +727,7 @@ void Swig_features_get(Hash *features, String *prefix, String *name, SwigType *d * concatenating the feature name plus ':' plus the attribute name. * ----------------------------------------------------------------------------- */ -void Swig_feature_set(Hash *features, const String_or_char *name, SwigType *decl, const String_or_char *featurename, String *value, Hash *featureattribs) { +void Swig_feature_set(Hash *features, const_String_or_char_ptr name, SwigType *decl, const_String_or_char_ptr featurename, String *value, Hash *featureattribs) { Hash *n; Hash *fhash; @@ -1436,7 +1436,7 @@ static String *apply_rename(String *newname, int fullname, String *prefix, Strin * * ----------------------------------------------------------------------------- */ -String *Swig_name_make(Node *n, String *prefix, String_or_char *cname, SwigType *decl, String *oldname) { +String *Swig_name_make(Node *n, String *prefix, const_String_or_char_ptr cname, SwigType *decl, String *oldname) { String *nname = 0; String *result = 0; String *name = NewString(cname); diff --git a/Source/Swig/parms.c b/Source/Swig/parms.c index baa1dfbf3..9b58f5fcb 100644 --- a/Source/Swig/parms.c +++ b/Source/Swig/parms.c @@ -17,7 +17,7 @@ char cvsroot_parms_c[] = "$Id$"; * Create a new parameter from datatype 'type' and name 'name'. * ------------------------------------------------------------------------ */ -Parm *NewParm(SwigType *type, const String_or_char *name) { +Parm *NewParm(SwigType *type, const_String_or_char_ptr name) { Parm *p = NewHash(); set_nodeType(p, "parm"); if (type) { diff --git a/Source/Swig/scanner.c b/Source/Swig/scanner.c index 28c512683..52d21c79e 100644 --- a/Source/Swig/scanner.c +++ b/Source/Swig/scanner.c @@ -118,7 +118,7 @@ void Scanner_push(Scanner * s, String *txt) { * call to Scanner_token(). * ----------------------------------------------------------------------------- */ -void Scanner_pushtoken(Scanner * s, int nt, const String_or_char *val) { +void Scanner_pushtoken(Scanner * s, int nt, const_String_or_char_ptr val) { assert(s); assert((nt >= 0) && (nt < SWIG_MAXTOKENS)); s->nexttoken = nt; @@ -212,7 +212,7 @@ static char nextchar(Scanner * s) { * Sets error information on the scanner. * ----------------------------------------------------------------------------- */ -static void set_error(Scanner *s, int line, String_or_char *msg) { +static void set_error(Scanner *s, int line, const_String_or_char_ptr msg) { s->error_line = line; s->error = NewString(msg); } diff --git a/Source/Swig/stype.c b/Source/Swig/stype.c index 5ffd28eec..8a7700bec 100644 --- a/Source/Swig/stype.c +++ b/Source/Swig/stype.c @@ -537,7 +537,7 @@ String *SwigType_namestr(const SwigType *t) { * Create a C string representation of a datatype. * ----------------------------------------------------------------------------- */ -String *SwigType_str(SwigType *s, const String_or_char *id) { +String *SwigType_str(SwigType *s, const_String_or_char_ptr id) { String *result; String *element = 0, *nextelement; List *elements; @@ -732,7 +732,7 @@ SwigType *SwigType_ltype(SwigType *s) { * with an equivalent assignable version. * -------------------------------------------------------------------- */ -String *SwigType_lstr(SwigType *s, const String_or_char *id) { +String *SwigType_lstr(SwigType *s, const_String_or_char_ptr id) { String *result; SwigType *tc; @@ -749,7 +749,7 @@ String *SwigType_lstr(SwigType *s, const String_or_char *id) { * datatype printed by str(). * ----------------------------------------------------------------------------- */ -String *SwigType_rcaststr(SwigType *s, const String_or_char *name) { +String *SwigType_rcaststr(SwigType *s, const_String_or_char_ptr name) { String *result, *cast; String *element = 0, *nextelement; SwigType *td, *rs, *tc = 0; @@ -892,7 +892,7 @@ String *SwigType_rcaststr(SwigType *s, const String_or_char *name) { * Casts a variable from the real type to the local datatype. * ----------------------------------------------------------------------------- */ -String *SwigType_lcaststr(SwigType *s, const String_or_char *name) { +String *SwigType_lcaststr(SwigType *s, const_String_or_char_ptr name) { String *result; result = NewStringEmpty(); diff --git a/Source/Swig/swig.h b/Source/Swig/swig.h index 356498511..c44d8f2b5 100644 --- a/Source/Swig/swig.h +++ b/Source/Swig/swig.h @@ -110,15 +110,15 @@ extern "C" { extern SwigType *NewSwigType(int typecode); extern SwigType *SwigType_del_element(SwigType *t); extern SwigType *SwigType_add_pointer(SwigType *t); - extern SwigType *SwigType_add_memberpointer(SwigType *t, const String_or_char *qual); + extern SwigType *SwigType_add_memberpointer(SwigType *t, const_String_or_char_ptr qual); extern SwigType *SwigType_del_memberpointer(SwigType *t); extern SwigType *SwigType_del_pointer(SwigType *t); - extern SwigType *SwigType_add_array(SwigType *t, const String_or_char *size); + extern SwigType *SwigType_add_array(SwigType *t, const_String_or_char_ptr size); extern SwigType *SwigType_del_array(SwigType *t); extern SwigType *SwigType_pop_arrays(SwigType *t); extern SwigType *SwigType_add_reference(SwigType *t); extern SwigType *SwigType_del_reference(SwigType *t); - extern SwigType *SwigType_add_qualifier(SwigType *t, const String_or_char *qual); + extern SwigType *SwigType_add_qualifier(SwigType *t, const_String_or_char_ptr qual); extern SwigType *SwigType_del_qualifier(SwigType *t); extern SwigType *SwigType_add_function(SwigType *t, ParmList *parms); extern SwigType *SwigType_add_template(SwigType *t, ParmList *parms); @@ -129,10 +129,10 @@ extern "C" { extern void SwigType_push(SwigType *t, SwigType *s); extern List *SwigType_parmlist(const SwigType *p); extern String *SwigType_parm(String *p); - extern String *SwigType_str(SwigType *s, const String_or_char *id); - extern String *SwigType_lstr(SwigType *s, const String_or_char *id); - extern String *SwigType_rcaststr(SwigType *s, const String_or_char *id); - extern String *SwigType_lcaststr(SwigType *s, const String_or_char *id); + extern String *SwigType_str(SwigType *s, const_String_or_char_ptr id); + extern String *SwigType_lstr(SwigType *s, const_String_or_char_ptr id); + extern String *SwigType_rcaststr(SwigType *s, const_String_or_char_ptr id); + extern String *SwigType_lcaststr(SwigType *s, const_String_or_char_ptr id); extern String *SwigType_manglestr(SwigType *t); extern SwigType *SwigType_ltype(SwigType *t); extern int SwigType_ispointer(SwigType *t); @@ -151,7 +151,7 @@ extern "C" { extern int SwigType_isvarargs(const SwigType *t); extern int SwigType_istemplate(const SwigType *t); extern int SwigType_isenum(SwigType *t); - extern int SwigType_check_decl(SwigType *t, const String_or_char *decl); + extern int SwigType_check_decl(SwigType *t, const_String_or_char_ptr decl); extern SwigType *SwigType_strip_qualifiers(SwigType *t); extern SwigType *SwigType_functionpointer_decompose(SwigType *t); extern String *SwigType_base(const SwigType *t); @@ -162,7 +162,7 @@ extern "C" { extern String *SwigType_prefix(const SwigType *t); extern int SwigType_array_ndim(SwigType *t); extern String *SwigType_array_getdim(SwigType *t, int n); - extern void SwigType_array_setdim(SwigType *t, int n, const String_or_char *rep); + extern void SwigType_array_setdim(SwigType *t, int n, const_String_or_char_ptr rep); extern SwigType *SwigType_array_type(SwigType *t); extern String *SwigType_default(SwigType *t); extern void SwigType_typename_replace(SwigType *t, String *pat, String *rep); @@ -173,14 +173,14 @@ extern "C" { /* --- Type-system managment --- */ extern void SwigType_typesystem_init(void); - extern int SwigType_typedef(SwigType *type, String_or_char *name); - extern int SwigType_typedef_class(String_or_char *name); - extern int SwigType_typedef_using(String_or_char *qname); + extern int SwigType_typedef(SwigType *type, const_String_or_char_ptr name); + extern int SwigType_typedef_class(const_String_or_char_ptr name); + extern int SwigType_typedef_using(const_String_or_char_ptr qname); extern void SwigType_inherit(String *subclass, String *baseclass, String *cast, String *conversioncode); extern int SwigType_issubtype(SwigType *subtype, SwigType *basetype); extern void SwigType_scope_alias(String *aliasname, Typetab *t); extern void SwigType_using_scope(Typetab *t); - extern void SwigType_new_scope(const String_or_char *name); + extern void SwigType_new_scope(const_String_or_char_ptr name); extern void SwigType_inherit_scope(Typetab *scope); extern Typetab *SwigType_pop_scope(void); extern Typetab *SwigType_set_scope(Typetab *h); @@ -192,8 +192,8 @@ extern "C" { extern int SwigType_isclass(SwigType *t); extern void SwigType_attach_symtab(Symtab *syms); extern void SwigType_remember(SwigType *t); - extern void SwigType_remember_clientdata(SwigType *t, const String_or_char *clientdata); - extern void SwigType_remember_mangleddata(String *mangled, const String_or_char *clientdata); + extern void SwigType_remember_clientdata(SwigType *t, const_String_or_char_ptr clientdata); + extern void SwigType_remember_mangleddata(String *mangled, const_String_or_char_ptr clientdata); extern void (*SwigType_remember_trace(void (*tf) (SwigType *, String *, String *))) (SwigType *, String *, String *); extern void SwigType_emit_type_table(File *f_headers, File *f_table); extern int SwigType_type(SwigType *t); @@ -201,25 +201,25 @@ extern "C" { /* --- Symbol table module --- */ extern void Swig_symbol_init(void); - extern void Swig_symbol_setscopename(const String_or_char *name); + extern void Swig_symbol_setscopename(const_String_or_char_ptr name); extern String *Swig_symbol_getscopename(void); extern String *Swig_symbol_qualifiedscopename(Symtab *symtab); extern Symtab *Swig_symbol_newscope(void); extern Symtab *Swig_symbol_setscope(Symtab *); - extern Symtab *Swig_symbol_getscope(const String_or_char *symname); + extern Symtab *Swig_symbol_getscope(const_String_or_char_ptr symname); extern Symtab *Swig_symbol_current(void); extern Symtab *Swig_symbol_popscope(void); - extern Node *Swig_symbol_add(String_or_char *symname, Node *node); - extern void Swig_symbol_cadd(String_or_char *symname, Node *node); - extern Node *Swig_symbol_clookup(String_or_char *symname, Symtab *tab); - extern Node *Swig_symbol_clookup_check(String_or_char *symname, Symtab *tab, int (*check) (Node *)); - extern Symtab *Swig_symbol_cscope(String_or_char *symname, Symtab *tab); - extern Node *Swig_symbol_clookup_local(String_or_char *symname, Symtab *tab); - extern Node *Swig_symbol_clookup_local_check(String_or_char *symname, Symtab *tab, int (*check) (Node *)); + extern Node *Swig_symbol_add(const_String_or_char_ptr symname, Node *node); + extern void Swig_symbol_cadd(const_String_or_char_ptr symname, Node *node); + extern Node *Swig_symbol_clookup(const_String_or_char_ptr symname, Symtab *tab); + extern Node *Swig_symbol_clookup_check(const_String_or_char_ptr symname, Symtab *tab, int (*check) (Node *)); + extern Symtab *Swig_symbol_cscope(const_String_or_char_ptr symname, Symtab *tab); + extern Node *Swig_symbol_clookup_local(const_String_or_char_ptr symname, Symtab *tab); + extern Node *Swig_symbol_clookup_local_check(const_String_or_char_ptr symname, Symtab *tab, int (*check) (Node *)); extern String *Swig_symbol_qualified(Node *node); extern Node *Swig_symbol_isoverloaded(Node *node); extern void Swig_symbol_remove(Node *node); - extern void Swig_symbol_alias(String_or_char *aliasname, Symtab *tab); + extern void Swig_symbol_alias(const_String_or_char_ptr aliasname, Symtab *tab); extern void Swig_symbol_inherit(Symtab *tab); extern SwigType *Swig_symbol_type_qualify(const SwigType *ty, Symtab *tab); extern String *Swig_symbol_string_qualify(String *s, Symtab *tab); @@ -246,17 +246,17 @@ extern int ParmList_is_compactdefargs(ParmList *p); /* --- Naming functions --- */ - extern void Swig_name_register(const String_or_char *method, const String_or_char *format); - extern void Swig_name_unregister(const String_or_char *method); - extern String *Swig_name_mangle(const String_or_char *s); - extern String *Swig_name_wrapper(const String_or_char *fname); - extern String *Swig_name_member(const String_or_char *classname, const String_or_char *mname); - extern String *Swig_name_get(const String_or_char *vname); - extern String *Swig_name_set(const String_or_char *vname); - extern String *Swig_name_construct(const String_or_char *classname); - extern String *Swig_name_copyconstructor(const String_or_char *classname); - extern String *Swig_name_destroy(const String_or_char *classname); - extern String *Swig_name_disown(const String_or_char *classname); + extern void Swig_name_register(const_String_or_char_ptr method, const_String_or_char_ptr format); + extern void Swig_name_unregister(const_String_or_char_ptr method); + extern String *Swig_name_mangle(const_String_or_char_ptr s); + extern String *Swig_name_wrapper(const_String_or_char_ptr fname); + extern String *Swig_name_member(const_String_or_char_ptr classname, const_String_or_char_ptr mname); + extern String *Swig_name_get(const_String_or_char_ptr vname); + extern String *Swig_name_set(const_String_or_char_ptr vname); + extern String *Swig_name_construct(const_String_or_char_ptr classname); + extern String *Swig_name_copyconstructor(const_String_or_char_ptr classname); + extern String *Swig_name_destroy(const_String_or_char_ptr classname); + extern String *Swig_name_disown(const_String_or_char_ptr classname); extern void Swig_naming_init(void); extern void Swig_name_namewarn_add(String *prefix, String *name, SwigType *decl, Hash *namewrn); @@ -267,25 +267,25 @@ extern int ParmList_is_compactdefargs(ParmList *p); extern int Swig_need_name_warning(Node *n); extern int Swig_need_redefined_warn(Node *a, Node *b, int InClass); - extern String *Swig_name_make(Node *n, String *prefix, String_or_char *cname, SwigType *decl, String *oldname); + extern String *Swig_name_make(Node *n, String *prefix, const_String_or_char_ptr cname, SwigType *decl, String *oldname); extern String *Swig_name_warning(Node *n, String *prefix, String *name, SwigType *decl); extern String *Swig_name_decl(Node *n); extern String *Swig_name_fulldecl(Node *n); /* --- parameterized rename functions --- */ - extern void Swig_name_object_set(Hash *namehash, String_or_char *name, SwigType *decl, DOH *object); - extern DOH *Swig_name_object_get(Hash *namehash, String_or_char *prefix, String_or_char *name, SwigType *decl); + extern void Swig_name_object_set(Hash *namehash, String *name, SwigType *decl, DOH *object); + extern DOH *Swig_name_object_get(Hash *namehash, String *prefix, String *name, SwigType *decl); extern void Swig_name_object_inherit(Hash *namehash, String *base, String *derived); - extern void Swig_features_get(Hash *features, String_or_char *prefix, String_or_char *name, SwigType *decl, Node *n); - extern void Swig_feature_set(Hash *features, const String_or_char *name, SwigType *decl, const String_or_char *featurename, String *value, Hash *featureattribs); + extern void Swig_features_get(Hash *features, String *prefix, String *name, SwigType *decl, Node *n); + extern void Swig_feature_set(Hash *features, const_String_or_char_ptr name, SwigType *decl, const_String_or_char_ptr featurename, String *value, Hash *featureattribs); /* --- Misc --- */ extern char *Swig_copy_string(const char *c); extern void Swig_set_fakeversion(const char *version); extern const char *Swig_package_version(void); extern void Swig_banner(File *f); - extern void Swig_banner_target_lang(File *f, const String_or_char *commentchar); + 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); @@ -311,11 +311,11 @@ extern int ParmList_is_compactdefargs(ParmList *p); typedef enum { EMF_STANDARD, EMF_MICROSOFT } ErrorMessageFormat; - extern void Swig_warning(int num, const String_or_char *filename, int line, const char *fmt, ...); - extern void Swig_error(const String_or_char *filename, int line, const char *fmt, ...); + extern void Swig_warning(int num, const_String_or_char_ptr filename, int line, const char *fmt, ...); + extern void Swig_error(const_String_or_char_ptr filename, int line, const char *fmt, ...); extern int Swig_error_count(void); extern void Swig_error_silent(int s); - extern void Swig_warnfilter(const String_or_char *wlist, int val); + extern void Swig_warnfilter(const_String_or_char_ptr wlist, int val); extern void Swig_warnall(void); extern int Swig_warn_count(void); extern void Swig_error_msg_format(ErrorMessageFormat format); @@ -324,17 +324,17 @@ extern int ParmList_is_compactdefargs(ParmList *p); extern String *Swig_cparm_name(Parm *p, int i); extern String *Swig_wrapped_var_type(SwigType *t, int varcref); extern int Swig_cargs(Wrapper *w, ParmList *l); - extern String *Swig_cresult(SwigType *t, const String_or_char *name, const String_or_char *decl); + extern String *Swig_cresult(SwigType *t, const_String_or_char_ptr name, const_String_or_char_ptr decl); - extern String *Swig_cfunction_call(String_or_char *name, ParmList *parms); - extern String *Swig_cconstructor_call(String_or_char *name); - extern String *Swig_cppconstructor_call(String_or_char *name, ParmList *parms); + extern String *Swig_cfunction_call(const_String_or_char_ptr name, ParmList *parms); + extern String *Swig_cconstructor_call(const_String_or_char_ptr name); + extern String *Swig_cppconstructor_call(const_String_or_char_ptr name, ParmList *parms); extern String *Swig_unref_call(Node *n); extern String *Swig_ref_call(Node *n, const String *lname); extern String *Swig_cdestructor_call(Node *n); extern String *Swig_cppdestructor_call(Node *n); - extern String *Swig_cmemberset_call(String_or_char *name, SwigType *type, String_or_char *self, int varcref); - extern String *Swig_cmemberget_call(const String_or_char *name, SwigType *t, String_or_char *self, int varcref); + extern String *Swig_cmemberset_call(const_String_or_char_ptr name, SwigType *type, const_String_or_char_ptr self, int varcref); + extern String *Swig_cmemberget_call(const_String_or_char_ptr name, SwigType *t, const_String_or_char_ptr self, int varcref); extern int Swig_add_extension_code(Node *n, const String *function_name, ParmList *parms, SwigType *return_type, const String *code, int cplusplus, const String *self); @@ -363,22 +363,22 @@ 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 *op, ParmList *pattern, String_or_char *code, ParmList *locals, ParmList *kwargs); - extern int Swig_typemap_copy(const String_or_char *op, ParmList *srcpattern, ParmList *pattern); - extern void Swig_typemap_clear(const String_or_char *op, ParmList *pattern); + 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 int Swig_typemap_apply(ParmList *srcpat, ParmList *destpat); extern void Swig_typemap_clear_apply(ParmList *pattern); extern void Swig_typemap_debug(void); - extern Hash *Swig_typemap_search(const String_or_char *op, SwigType *type, const String_or_char *pname, SwigType **matchtype); - extern Hash *Swig_typemap_search_multi(const String_or_char *op, ParmList *parms, int *nmatch); - extern String *Swig_typemap_lookup(const String_or_char *op, Node *n, const String_or_char *lname, Wrapper *f); - extern String *Swig_typemap_lookup_out(const String_or_char *op, Node *n, const String_or_char *lname, Wrapper *f, String *actioncode); - extern void Swig_typemap_attach_kwargs(Hash *tm, const String_or_char *op, Parm *p); + 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); - extern void Swig_typemap_attach_parms(const String_or_char *op, ParmList *parms, Wrapper *f); + extern void Swig_typemap_attach_parms(const_String_or_char_ptr op, ParmList *parms, Wrapper *f); /* --- Code fragment support --- */ diff --git a/Source/Swig/swigfile.h b/Source/Swig/swigfile.h index 807b10bc8..92c7945e6 100644 --- a/Source/Swig/swigfile.h +++ b/Source/Swig/swigfile.h @@ -9,25 +9,25 @@ /* $Id: swig.h 9603 2006-12-05 21:47:01Z beazley $ */ -extern List *Swig_add_directory(const String_or_char *dirname); -extern void Swig_push_directory(const String_or_char *dirname); +extern List *Swig_add_directory(const_String_or_char_ptr dirname); +extern void Swig_push_directory(const_String_or_char_ptr dirname); extern void Swig_pop_directory(void); extern String *Swig_last_file(void); extern List *Swig_search_path(void); -extern FILE *Swig_include_open(const String_or_char *name); -extern FILE *Swig_open(const String_or_char *name); +extern FILE *Swig_include_open(const_String_or_char_ptr name); +extern FILE *Swig_open(const_String_or_char_ptr name); extern String *Swig_read_file(FILE *f); -extern String *Swig_include(const String_or_char *name); -extern String *Swig_include_sys(const String_or_char *name); -extern int Swig_insert_file(const String_or_char *name, File *outfile); +extern String *Swig_include(const_String_or_char_ptr name); +extern String *Swig_include_sys(const_String_or_char_ptr name); +extern int Swig_insert_file(const_String_or_char_ptr name, File *outfile); extern void Swig_set_push_dir(int dopush); extern int Swig_get_push_dir(void); -extern void Swig_register_filebyname(const String_or_char *filename, File *outfile); -extern File *Swig_filebyname(const String_or_char *filename); -extern char *Swig_file_suffix(const String_or_char *filename); -extern char *Swig_file_basename(const String_or_char *filename); -extern char *Swig_file_filename(const String_or_char *filename); -extern char *Swig_file_dirname(const String_or_char *filename); +extern void Swig_register_filebyname(const_String_or_char_ptr filename, File *outfile); +extern File *Swig_filebyname(const_String_or_char_ptr filename); +extern char *Swig_file_suffix(const_String_or_char_ptr filename); +extern char *Swig_file_basename(const_String_or_char_ptr filename); +extern char *Swig_file_filename(const_String_or_char_ptr filename); +extern char *Swig_file_dirname(const_String_or_char_ptr filename); /* Delimiter used in accessing files and directories */ diff --git a/Source/Swig/swigparm.h b/Source/Swig/swigparm.h index 529438bae..49ae7992e 100644 --- a/Source/Swig/swigparm.h +++ b/Source/Swig/swigparm.h @@ -11,7 +11,7 @@ /* $Id: swig.h 9629 2006-12-30 18:27:47Z beazley $ */ /* Individual parameters */ -extern Parm *NewParm(SwigType *type, const String_or_char *name); +extern Parm *NewParm(SwigType *type, const_String_or_char_ptr name); extern Parm *CopyParm(Parm *p); /* Parameter lists */ diff --git a/Source/Swig/swigscan.h b/Source/Swig/swigscan.h index e521d3c52..3403098df 100644 --- a/Source/Swig/swigscan.h +++ b/Source/Swig/swigscan.h @@ -15,7 +15,7 @@ extern Scanner *NewScanner(void); extern void DelScanner(Scanner *); extern void Scanner_clear(Scanner *); extern void Scanner_push(Scanner *, String *); -extern void Scanner_pushtoken(Scanner *, int, const String_or_char *value); +extern void Scanner_pushtoken(Scanner *, int, const_String_or_char_ptr value); extern int Scanner_token(Scanner *); extern String *Scanner_text(Scanner *); extern void Scanner_skip_line(Scanner *); diff --git a/Source/Swig/swigtree.h b/Source/Swig/swigtree.h index 2e5c4da36..5b43006a9 100644 --- a/Source/Swig/swigtree.h +++ b/Source/Swig/swigtree.h @@ -31,7 +31,7 @@ /* Utility functions */ -extern int checkAttribute(Node *obj, const String_or_char *name, const String_or_char *value); +extern int checkAttribute(Node *obj, const_String_or_char_ptr name, const_String_or_char_ptr value); extern void appendChild(Node *node, Node *child); extern void prependChild(Node *node, Node *child); extern void removeNode(Node *node); diff --git a/Source/Swig/swigwrap.h b/Source/Swig/swigwrap.h index e2a011c97..0dcf88059 100644 --- a/Source/Swig/swigwrap.h +++ b/Source/Swig/swigwrap.h @@ -22,8 +22,8 @@ extern void Wrapper_compact_print_mode_set(int flag); extern void Wrapper_pretty_print(String *str, File *f); extern void Wrapper_compact_print(String *str, File *f); extern void Wrapper_print(Wrapper *w, File *f); -extern int Wrapper_add_local(Wrapper *w, const String_or_char *name, const String_or_char *decl); -extern int Wrapper_add_localv(Wrapper *w, const String_or_char *name, ...); -extern int Wrapper_check_local(Wrapper *w, const String_or_char *name); -extern char *Wrapper_new_local(Wrapper *w, const String_or_char *name, const String_or_char *decl); -extern char *Wrapper_new_localv(Wrapper *w, const String_or_char *name, ...); +extern int Wrapper_add_local(Wrapper *w, const_String_or_char_ptr name, const_String_or_char_ptr decl); +extern int Wrapper_add_localv(Wrapper *w, const_String_or_char_ptr name, ...); +extern int Wrapper_check_local(Wrapper *w, const_String_or_char_ptr name); +extern char *Wrapper_new_local(Wrapper *w, const_String_or_char_ptr name, const_String_or_char_ptr decl); +extern char *Wrapper_new_localv(Wrapper *w, const_String_or_char_ptr name, ...); diff --git a/Source/Swig/symbol.c b/Source/Swig/symbol.c index c9691fa54..d65ba6ad0 100644 --- a/Source/Swig/symbol.c +++ b/Source/Swig/symbol.c @@ -220,7 +220,7 @@ void Swig_symbol_init() { * Set the C scopename of the current symbol table. * ----------------------------------------------------------------------------- */ -void Swig_symbol_setscopename(const String_or_char *name) { +void Swig_symbol_setscopename(const_String_or_char_ptr name) { String *qname; /* assert(!Getattr(current_symtab,"name")); */ Setattr(current_symtab, "name", name); @@ -250,10 +250,10 @@ String *Swig_symbol_getscopename() { * Given a fully qualified C scopename, this function returns a symbol table * ----------------------------------------------------------------------------- */ -Symtab *Swig_symbol_getscope(const String_or_char *name) { +Symtab *Swig_symbol_getscope(const_String_or_char_ptr name) { if (!symtabs) return 0; - if (Equal("::", (String_or_char *) name)) + if (Equal("::", (const_String_or_char_ptr ) name)) name = ""; return Getattr(symtabs, name); } @@ -373,7 +373,7 @@ Symtab *Swig_symbol_current() { * Makes an alias for a symbol in the global symbol table. * ----------------------------------------------------------------------------- */ -void Swig_symbol_alias(String_or_char *aliasname, Symtab *s) { +void Swig_symbol_alias(const_String_or_char_ptr aliasname, Symtab *s) { String *qname = Swig_symbol_qualifiedscopename(current_symtab); if (qname) { Printf(qname, "::%s", aliasname); @@ -421,7 +421,7 @@ void Swig_symbol_inherit(Symtab *s) { * Adds a node to the C symbol table only. * ----------------------------------------------------------------------------- */ -void Swig_symbol_cadd(String_or_char *name, Node *n) { +void Swig_symbol_cadd(const_String_or_char_ptr name, Node *n) { Node *append = 0; Node *cn; @@ -594,7 +594,7 @@ void Swig_symbol_cadd(String_or_char *name, Node *n) { * for namespace support, type resolution, and other issues. * ----------------------------------------------------------------------------- */ -Node *Swig_symbol_add(String_or_char *symname, Node *n) { +Node *Swig_symbol_add(const_String_or_char_ptr symname, Node *n) { Hash *c, *cn, *cl = 0; SwigType *decl, *ndecl; String *cstorage, *nstorage; @@ -890,7 +890,7 @@ static Node *_symbol_lookup(String *name, Symtab *symtab, int (*check) (Node *n) return 0; } -static Node *symbol_lookup(String_or_char *name, Symtab *symtab, int (*check) (Node *n)) { +static Node *symbol_lookup(const_String_or_char_ptr name, Symtab *symtab, int (*check) (Node *n)) { Node *n = 0; if (DohCheck(name)) { n = _symbol_lookup(name, symtab, check); @@ -908,7 +908,7 @@ static Node *symbol_lookup(String_or_char *name, Symtab *symtab, int (*check) (N * symbol_lookup_qualified() * ----------------------------------------------------------------------------- */ -static Node *symbol_lookup_qualified(String_or_char *name, Symtab *symtab, String *prefix, int local, int (*checkfunc) (Node *n)) { +static Node *symbol_lookup_qualified(const_String_or_char_ptr name, Symtab *symtab, String *prefix, int local, int (*checkfunc) (Node *n)) { /* This is a little funky, we search by fully qualified names */ if (!symtab) @@ -974,7 +974,7 @@ static Node *symbol_lookup_qualified(String_or_char *name, Symtab *symtab, Strin * to get the real node. * ----------------------------------------------------------------------------- */ -Node *Swig_symbol_clookup(String_or_char *name, Symtab *n) { +Node *Swig_symbol_clookup(const_String_or_char_ptr name, Symtab *n) { Hash *hsym = 0; Node *s = 0; @@ -1046,7 +1046,7 @@ Node *Swig_symbol_clookup(String_or_char *name, Symtab *n) { * inheritance hierarchy. * ----------------------------------------------------------------------------- */ -Node *Swig_symbol_clookup_check(String_or_char *name, Symtab *n, int (*checkfunc) (Node *n)) { +Node *Swig_symbol_clookup_check(const_String_or_char_ptr name, Symtab *n, int (*checkfunc) (Node *n)) { Hash *hsym = 0; Node *s = 0; @@ -1110,7 +1110,7 @@ Node *Swig_symbol_clookup_check(String_or_char *name, Symtab *n, int (*checkfunc * Swig_symbol_clookup_local() * ----------------------------------------------------------------------------- */ -Node *Swig_symbol_clookup_local(String_or_char *name, Symtab *n) { +Node *Swig_symbol_clookup_local(const_String_or_char_ptr name, Symtab *n) { Hash *h, *hsym; Node *s = 0; @@ -1158,7 +1158,7 @@ Node *Swig_symbol_clookup_local(String_or_char *name, Symtab *n) { * Swig_symbol_clookup_local_check() * ----------------------------------------------------------------------------- */ -Node *Swig_symbol_clookup_local_check(String_or_char *name, Symtab *n, int (*checkfunc) (Node *)) { +Node *Swig_symbol_clookup_local_check(const_String_or_char_ptr name, Symtab *n, int (*checkfunc) (Node *)) { Hash *h, *hsym; Node *s = 0; @@ -1209,7 +1209,7 @@ Node *Swig_symbol_clookup_local_check(String_or_char *name, Symtab *n, int (*che * Look up a scope name. * ----------------------------------------------------------------------------- */ -Symtab *Swig_symbol_cscope(String_or_char *name, Symtab *symtab) { +Symtab *Swig_symbol_cscope(const_String_or_char_ptr name, Symtab *symtab) { char *cname = Char(name); if (strncmp(cname, "::", 2) == 0) return symbol_lookup_qualified(0, global_scope, name, 0, 0); diff --git a/Source/Swig/tree.c b/Source/Swig/tree.c index 61dca8353..14d231afa 100644 --- a/Source/Swig/tree.c +++ b/Source/Swig/tree.c @@ -229,7 +229,7 @@ Node *copyNode(Node *n) { * checkAttribute() * ----------------------------------------------------------------------------- */ -int checkAttribute(Node *n, const String_or_char *name, const String_or_char *value) { +int checkAttribute(Node *n, const_String_or_char_ptr name, const_String_or_char_ptr value) { String *v = Getattr(n, name); return v ? Equal(v, value) : 0; } diff --git a/Source/Swig/typemap.c b/Source/Swig/typemap.c index 6cbeb67ea..775e459d2 100644 --- a/Source/Swig/typemap.c +++ b/Source/Swig/typemap.c @@ -107,7 +107,7 @@ void Swig_typemap_init() { tm_scope = 0; } -static String *tmop_name(const String_or_char *op) { +static String *tmop_name(const_String_or_char_ptr op) { static Hash *names = 0; String *s; /* Due to "interesting" object-identity semantics of DOH, @@ -164,7 +164,7 @@ Hash *Swig_typemap_pop_scope() { * Add a new multi-valued typemap * ----------------------------------------------------------------------------- */ -void Swig_typemap_register(const String_or_char *op, ParmList *parms, String_or_char *code, ParmList *locals, ParmList *kwargs) { +void Swig_typemap_register(const_String_or_char_ptr op, ParmList *parms, const_String_or_char_ptr code, ParmList *locals, ParmList *kwargs) { Hash *tm; Hash *tm1; Hash *tm2; @@ -270,7 +270,7 @@ void Swig_typemap_register(const String_or_char *op, ParmList *parms, String_or_ * Retrieve typemap information from current scope. * ----------------------------------------------------------------------------- */ -static Hash *Swig_typemap_get(SwigType *type, String_or_char *name, int scope) { +static Hash *Swig_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)) @@ -292,7 +292,7 @@ static Hash *Swig_typemap_get(SwigType *type, String_or_char *name, int scope) { * Copy a typemap * ----------------------------------------------------------------------------- */ -int Swig_typemap_copy(const String_or_char *op, ParmList *srcparms, ParmList *parms) { +int Swig_typemap_copy(const_String_or_char_ptr op, ParmList *srcparms, ParmList *parms) { Hash *tm = 0; String *tmop; Parm *p; @@ -347,7 +347,7 @@ int Swig_typemap_copy(const String_or_char *op, ParmList *srcparms, ParmList *pa * Delete a multi-valued typemap * ----------------------------------------------------------------------------- */ -void Swig_typemap_clear(const String_or_char *op, ParmList *parms) { +void Swig_typemap_clear(const_String_or_char_ptr op, ParmList *parms) { SwigType *type; String *name; Parm *p; @@ -590,7 +590,7 @@ static SwigType *strip_arrays(SwigType *type) { * that includes a 'code' attribute. * ----------------------------------------------------------------------------- */ -Hash *Swig_typemap_search(const String_or_char *op, SwigType *type, const String_or_char *name, SwigType **matchtype) { +Hash *Swig_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; @@ -737,7 +737,7 @@ ret_result: * Search for a multi-valued typemap. * ----------------------------------------------------------------------------- */ -Hash *Swig_typemap_search_multi(const String_or_char *op, ParmList *parms, int *nmatch) { +Hash *Swig_typemap_search_multi(const_String_or_char_ptr op, ParmList *parms, int *nmatch) { SwigType *type; SwigType *mtype = 0; String *name; @@ -1173,7 +1173,7 @@ static void typemap_locals(DOHString * s, ParmList *l, Wrapper *f, int argnum) { * $1 in the out typemap will be replaced by the code in actioncode. * ----------------------------------------------------------------------------- */ -static String *Swig_typemap_lookup_impl(const String_or_char *op, Node *node, const String_or_char *lname, Wrapper *f, String *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) { SwigType *type; SwigType *mtype = 0; String *pname; @@ -1384,13 +1384,13 @@ static String *Swig_typemap_lookup_impl(const String_or_char *op, Node *node, co return s; } -String *Swig_typemap_lookup_out(const String_or_char *op, Node *node, const String_or_char *lname, Wrapper *f, String *actioncode) { +String *Swig_typemap_lookup_out(const_String_or_char_ptr op, 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); } -String *Swig_typemap_lookup(const String_or_char *op, Node *node, const String_or_char *lname, Wrapper *f) { +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); } @@ -1406,7 +1406,7 @@ String *Swig_typemap_lookup(const String_or_char *op, Node *node, const String_o * 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 *op, Parm *p) { +void Swig_typemap_attach_kwargs(Hash *tm, const_String_or_char_ptr op, Parm *p) { String *temp = NewStringEmpty(); Parm *kw = Getattr(tm, "kwargs"); while (kw) { @@ -1438,7 +1438,7 @@ void Swig_typemap_attach_kwargs(Hash *tm, const String_or_char *op, Parm *p) { * attribute, print that warning message. * ----------------------------------------------------------------------------- */ -static void Swig_typemap_warn(const String_or_char *op, Parm *p) { +static void Swig_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 +1447,7 @@ static void Swig_typemap_warn(const String_or_char *op, Parm *p) { } } -static void Swig_typemap_emit_code_fragments(const String_or_char *op, Parm *p) { +static void Swig_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) { @@ -1479,7 +1479,7 @@ String *Swig_typemap_get_option(Hash *tm, String *name) { return 0; } -void Swig_typemap_attach_parms(const String_or_char *op, ParmList *parms, Wrapper *f) { +void Swig_typemap_attach_parms(const_String_or_char_ptr op, ParmList *parms, Wrapper *f) { Parm *p, *firstp; Hash *tm; int nmatch = 0; diff --git a/Source/Swig/typeobj.c b/Source/Swig/typeobj.c index 18d1b2304..8ff31bc0b 100644 --- a/Source/Swig/typeobj.c +++ b/Source/Swig/typeobj.c @@ -110,7 +110,7 @@ char cvsroot_typeobj_c[] = "$Id$"; * ----------------------------------------------------------------------------- */ #ifdef NEW -SwigType *NewSwigType(const String_or_char *initial) { +SwigType *NewSwigType(const_String_or_char_ptr initial) { return NewString(initial); } @@ -419,7 +419,7 @@ int SwigType_isreference(SwigType *t) { * stored in exactly the same way as "q(const volatile)". * ----------------------------------------------------------------------------- */ -SwigType *SwigType_add_qualifier(SwigType *t, const String_or_char *qual) { +SwigType *SwigType_add_qualifier(SwigType *t, const_String_or_char_ptr qual) { char temp[256], newq[256]; int sz, added = 0; char *q, *cqual; @@ -537,7 +537,7 @@ SwigType *SwigType_functionpointer_decompose(SwigType *t) { * Add, remove, and test for C++ pointer to members. * ----------------------------------------------------------------------------- */ -SwigType *SwigType_add_memberpointer(SwigType *t, const String_or_char *name) { +SwigType *SwigType_add_memberpointer(SwigType *t, const_String_or_char_ptr name) { String *temp = NewStringf("m(%s).", name); Insert(t, 0, temp); Delete(temp); @@ -579,7 +579,7 @@ int SwigType_ismemberpointer(SwigType *t) { * SwigType_pop_arrays() - Remove all arrays * ----------------------------------------------------------------------------- */ -SwigType *SwigType_add_array(SwigType *t, const String_or_char *size) { +SwigType *SwigType_add_array(SwigType *t, const_String_or_char_ptr size) { char temp[512]; strcpy(temp, "a("); strcat(temp, Char(size)); @@ -673,7 +673,7 @@ String *SwigType_array_getdim(SwigType *t, int n) { } /* Replace nth array dimension */ -void SwigType_array_setdim(SwigType *t, int n, const String_or_char *rep) { +void SwigType_array_setdim(SwigType *t, int n, const_String_or_char_ptr rep) { String *result = 0; char temp; char *start; diff --git a/Source/Swig/typesys.c b/Source/Swig/typesys.c index a9e2898bd..6d8f4112b 100644 --- a/Source/Swig/typesys.c +++ b/Source/Swig/typesys.c @@ -163,7 +163,7 @@ void SwigType_typesystem_init() { * already defined. * ----------------------------------------------------------------------------- */ -int SwigType_typedef(SwigType *type, String_or_char *name) { +int SwigType_typedef(SwigType *type, const_String_or_char_ptr name) { if (Getattr(current_typetab, name)) return -1; /* Already defined */ if (Strcmp(type, name) == 0) { /* Can't typedef a name to itself */ @@ -193,7 +193,7 @@ int SwigType_typedef(SwigType *type, String_or_char *name) { * Defines a class in the current scope. * ----------------------------------------------------------------------------- */ -int SwigType_typedef_class(String_or_char *name) { +int SwigType_typedef_class(const_String_or_char_ptr name) { String *cname; /* Printf(stdout,"class : '%s'\n", name); */ if (Getattr(current_typetab, name)) @@ -232,7 +232,7 @@ String *SwigType_scope_name(Typetab *ttab) { * Creates a new scope * ----------------------------------------------------------------------------- */ -void SwigType_new_scope(const String_or_char *name) { +void SwigType_new_scope(const_String_or_char_ptr name) { Typetab *s; Hash *ttab; String *qname; @@ -1071,7 +1071,7 @@ int SwigType_istypedef(SwigType *t) { * Name is a qualified name like A::B. * ----------------------------------------------------------------------------- */ -int SwigType_typedef_using(String_or_char *name) { +int SwigType_typedef_using(const_String_or_char_ptr name) { String *base; String *td; String *prefix; @@ -1415,7 +1415,7 @@ static Hash *r_remembered = 0; /* Hash of types we remembered already */ static void (*r_tracefunc) (SwigType *t, String *mangled, String *clientdata) = 0; -void SwigType_remember_mangleddata(String *mangled, const String_or_char *clientdata) { +void SwigType_remember_mangleddata(String *mangled, const_String_or_char_ptr clientdata) { if (!r_mangleddata) { r_mangleddata = NewHash(); } @@ -1423,7 +1423,7 @@ void SwigType_remember_mangleddata(String *mangled, const String_or_char *client } -void SwigType_remember_clientdata(SwigType *t, const String_or_char *clientdata) { +void SwigType_remember_clientdata(SwigType *t, const_String_or_char_ptr clientdata) { String *mt; SwigType *lt; Hash *h; diff --git a/Source/Swig/wrapfunc.c b/Source/Swig/wrapfunc.c index 6a65410c4..11518bfc2 100644 --- a/Source/Swig/wrapfunc.c +++ b/Source/Swig/wrapfunc.c @@ -406,7 +406,7 @@ void Wrapper_print(Wrapper *w, File *f) { * present (which may or may not be okay to the caller). * ----------------------------------------------------------------------------- */ -int Wrapper_add_local(Wrapper *w, const String_or_char *name, const String_or_char *decl) { +int Wrapper_add_local(Wrapper *w, const_String_or_char_ptr name, const_String_or_char_ptr decl) { /* See if the local has already been declared */ if (Getattr(w->localh, name)) { return -1; @@ -424,7 +424,7 @@ int Wrapper_add_local(Wrapper *w, const String_or_char *name, const String_or_ch * to manually construct the 'decl' string before calling. * ----------------------------------------------------------------------------- */ -int Wrapper_add_localv(Wrapper *w, const String_or_char *name, ...) { +int Wrapper_add_localv(Wrapper *w, const_String_or_char_ptr name, ...) { va_list ap; int ret; String *decl; @@ -451,7 +451,7 @@ int Wrapper_add_localv(Wrapper *w, const String_or_char *name, ...) { * Check to see if a local name has already been declared * ----------------------------------------------------------------------------- */ -int Wrapper_check_local(Wrapper *w, const String_or_char *name) { +int Wrapper_check_local(Wrapper *w, const_String_or_char_ptr name) { if (Getattr(w->localh, name)) { return 1; } @@ -465,7 +465,7 @@ int Wrapper_check_local(Wrapper *w, const String_or_char *name) { * used. Returns the name that was actually selected. * ----------------------------------------------------------------------------- */ -char *Wrapper_new_local(Wrapper *w, const String_or_char *name, const String_or_char *decl) { +char *Wrapper_new_local(Wrapper *w, const_String_or_char_ptr name, const_String_or_char_ptr decl) { int i; String *nname = NewString(name); String *ndecl = NewString(decl); @@ -496,7 +496,7 @@ char *Wrapper_new_local(Wrapper *w, const String_or_char *name, const String_or_ * to manually construct the 'decl' string before calling. * ----------------------------------------------------------------------------- */ -char *Wrapper_new_localv(Wrapper *w, const String_or_char *name, ...) { +char *Wrapper_new_localv(Wrapper *w, const_String_or_char_ptr name, ...) { va_list ap; char *ret; String *decl; From 22e4cb8e52c93a2f865043990b56c663eeb0e910 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 28 Jan 2009 18:45:13 +0000 Subject: [PATCH 0314/1680] Fix classLookup and enumLookup when the global scope operator is used on objects passed by value git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11092 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++ Examples/test-suite/common.mk | 1 + Examples/test-suite/global_namespace.i | 60 +++++++++++++++++++ .../java/global_namespace_runme.java | 25 ++++++++ Source/Modules/lang.cxx | 17 ++++-- Source/Swig/typesys.c | 1 + 6 files changed, 103 insertions(+), 5 deletions(-) create mode 100644 Examples/test-suite/global_namespace.i create mode 100644 Examples/test-suite/java/global_namespace_runme.java diff --git a/CHANGES.current b/CHANGES.current index 4f43526a1..b28f4d453 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,10 @@ Version 1.3.38 (in progress) ================================ +2008-01-28: wsfulton + [Java, C#] Fix proxy class not being used when the global scope operator + was used for parameters passed by value. Reported by David Piepgrass. + 2008-01-15: wsfulton [Perl] Fix seg fault when running with -v option, reported by John Ky. diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index bca58e75b..1d43f14ca 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -194,6 +194,7 @@ CPP_TEST_CASES += \ fragments \ friends \ fvirtual \ + global_namespace \ global_ns_arg \ global_vars \ grouping \ diff --git a/Examples/test-suite/global_namespace.i b/Examples/test-suite/global_namespace.i new file mode 100644 index 000000000..02139f6c4 --- /dev/null +++ b/Examples/test-suite/global_namespace.i @@ -0,0 +1,60 @@ +%module global_namespace + +// classes +%inline %{ +class Klass1 {}; +class Klass2 {}; +class Klass3 {}; +class Klass4 {}; +class Klass5 {}; +class Klass6 {}; +class Klass7 {}; + +struct KlassMethods { + static void methodA(::Klass1 v, const ::Klass2 cv, const ::Klass3 *cp, ::Klass4 *p, const ::Klass5 &cr, ::Klass6 &r, Klass7*& pr) {} + static void methodB( Klass1 v, const Klass2 cv, const Klass3 *cp, Klass4 *p, const Klass5 &cr, Klass6 &r, Klass7*& pr) {} +}; +%} + +%inline %{ +namespace Space { +class XYZ1 {}; +class XYZ2 {}; +class XYZ3 {}; +class XYZ4 {}; +class XYZ5 {}; +class XYZ6 {}; +class XYZ7 {}; +} + +struct XYZMethods { + static void methodA(::Space::XYZ1 v, const ::Space::XYZ2 cv, const ::Space::XYZ3 *cp, ::Space::XYZ4 *p, const ::Space::XYZ5 &cr, ::Space::XYZ6 &r, Space::XYZ7*& 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) {} +}; +%} + +//enums +%inline %{ +enum AnEnum1 { anenum1 }; +enum AnEnum2 { anenum2 }; +enum AnEnum3 { anenum3 }; + +struct AnEnumMethods { + static void methodA(::AnEnum1 v, const ::AnEnum2 cv, const ::AnEnum3 &cr) {} + static void methodB( AnEnum1 v, const AnEnum2 cv, const AnEnum3 &cr) {} +}; +%} + +%inline %{ +namespace Space { +enum TheEnum1 { theenum1 }; +enum TheEnum2 { theenum2 }; +enum TheEnum3 { theenum3 }; + +struct TheEnumMethods { + static void methodA(::Space::TheEnum1 v, const ::Space::TheEnum2 cv, const ::Space::TheEnum3 &cr) {} + static void methodB( Space::TheEnum1 v, const Space::TheEnum2 cv, const Space::TheEnum3 &cr) {} +}; +} +%} + diff --git a/Examples/test-suite/java/global_namespace_runme.java b/Examples/test-suite/java/global_namespace_runme.java new file mode 100644 index 000000000..faab7d4ba --- /dev/null +++ b/Examples/test-suite/java/global_namespace_runme.java @@ -0,0 +1,25 @@ +import global_namespace.*; + +public class global_namespace_runme { + + static { + try { + System.loadLibrary("global_namespace"); + } catch (UnsatisfiedLinkError e) { + System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); + System.exit(1); + } + } + + public static void main(String argv[]) { + + KlassMethods.methodA(new Klass1(), new Klass2(), new Klass3(), new Klass4(), new Klass5(), new Klass6(), new Klass7()); + KlassMethods.methodB(new Klass1(), new Klass2(), new Klass3(), new Klass4(), new Klass5(), new Klass6(), new Klass7()); + + XYZMethods.methodA(new XYZ1(), new XYZ2(), new XYZ3(), new XYZ4(), new XYZ5(), new XYZ6(), new XYZ7()); + XYZMethods.methodB(new XYZ1(), new XYZ2(), new XYZ3(), new XYZ4(), new XYZ5(), new XYZ6(), new XYZ7()); + + TheEnumMethods.methodA(TheEnum1.theenum1, TheEnum2.theenum2, TheEnum3.theenum3); + TheEnumMethods.methodA(TheEnum1.theenum1, TheEnum2.theenum2, TheEnum3.theenum3); + } +} diff --git a/Source/Modules/lang.cxx b/Source/Modules/lang.cxx index 39ede8243..72a7ff496 100644 --- a/Source/Modules/lang.cxx +++ b/Source/Modules/lang.cxx @@ -2960,14 +2960,9 @@ Node *Language::classLookup(SwigType *s) { n = Getattr(classtypes, s); if (!n) { Symtab *stab = 0; -// SwigType *lt = SwigType_ltype(s); -// SwigType *ty1 = SwigType_typedef_resolve_all(lt); SwigType *ty1 = SwigType_typedef_resolve_all(s); SwigType *ty2 = SwigType_strip_qualifiers(ty1); -// Printf(stdout, " stages... ty1: %s ty2: %s\n", ty1, ty2); -// Delete(lt); Delete(ty1); -// lt = 0; ty1 = 0; String *base = SwigType_base(ty2); @@ -2976,6 +2971,12 @@ Node *Language::classLookup(SwigType *s) { Replaceall(base, "struct ", ""); Replaceall(base, "union ", ""); + if (strncmp(Char(base), "::", 2) == 0) { + String *oldbase = base; + base = NewString(Char(base) + 2); + Delete(oldbase); + } + String *prefix = SwigType_prefix(ty2); /* Do a symbol table search on the base type */ @@ -3049,6 +3050,12 @@ Node *Language::enumLookup(SwigType *s) { Replaceall(base, "enum ", ""); String *prefix = SwigType_prefix(ty2); + if (strncmp(Char(base), "::", 2) == 0) { + String *oldbase = base; + base = NewString(Char(base) + 2); + Delete(oldbase); + } + /* Look for type in symbol table */ while (!n) { Hash *nstab; diff --git a/Source/Swig/typesys.c b/Source/Swig/typesys.c index 6d8f4112b..042e71972 100644 --- a/Source/Swig/typesys.c +++ b/Source/Swig/typesys.c @@ -840,6 +840,7 @@ 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 * * ----------------------------------------------------------------------------- */ SwigType *SwigType_typedef_qualified(SwigType *t) { From 90ab280f90e95a077bb3caa08ef44090695713d0 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 29 Jan 2009 19:25:37 +0000 Subject: [PATCH 0315/1680] Fix regression introduced in 1.3.37 where the default output directory for target language specific files (in the absence of -outdir) was no longer the same as the generated c/c++ file git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11093 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 5 +++++ Doc/Manual/Modula3.html | 8 ++++---- Doc/Manual/SWIG.html | 11 +++++++++++ Source/Modules/main.cxx | 6 +++++- 4 files changed, 25 insertions(+), 5 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index b28f4d453..42c47b154 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,11 @@ Version 1.3.38 (in progress) ================================ +2008-01-29: wsfulton + Fix regression introduced in 1.3.37 where the default output directory + for target language specific files (in the absence of -outdir) was no + longer the same directory as the generated c/c++ file. + 2008-01-28: wsfulton [Java, C#] Fix proxy class not being used when the global scope operator was used for parameters passed by value. Reported by David Piepgrass. diff --git a/Doc/Manual/Modula3.html b/Doc/Manual/Modula3.html index 7a6bacd34..c4e485202 100644 --- a/Doc/Manual/Modula3.html +++ b/Doc/Manual/Modula3.html @@ -860,8 +860,8 @@ that split the task up into converting the C bit patterns (integer or bit set) into Modula-3 bit patterns (integer or bit set) and change the type as requested. -See the corresponding -example. +See the corresponding example in the +Examples/modula3/enum/example.i file. This is quite messy and not satisfying. So the best what you can currently do is to rewrite constant definitions manually. @@ -877,8 +877,8 @@ that I'd like to automate. Declarations of C++ classes are mapped to OBJECT types while it is tried to retain the access hierarchy "public - protected - private" using partial revelation. -Though the -implementation +Though the example in +Examples/modula3/class/example.i is not really useful, yet.

          diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html index 48c2d9f2b..1c8d74f8c 100644 --- a/Doc/Manual/SWIG.html +++ b/Doc/Manual/SWIG.html @@ -247,6 +247,17 @@ cppfiles/example_wrap.cpp pyfiles/example.py
        +

        +If the -outcurrentdir option is used (without -o) +then SWIG behaves like a typical C/C++ +compiler and the default output directory is then the current directory. Without +this option the default output directory is the path to the input file. +If -o and +-outcurrentdir are used together, -outcurrentdir is effectively ignored +as the output directory for the language files is the same directory as the +generated C/C++ file if not overidden with -outdir. +

        +

        5.1.3 Comments

        diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx index 00596670d..c5e0d0ab5 100644 --- a/Source/Modules/main.cxx +++ b/Source/Modules/main.cxx @@ -273,15 +273,18 @@ static unsigned int decode_numbers_list(String *numlist) { static void set_outdir(const String *c_wrapper_file_dir) { + Printf(stdout, "outdir (10): %s\n", outdir); // Add file delimiter if not present in output directory name if (outdir && Len(outdir) != 0) { const char *outd = Char(outdir); if (strcmp(outd + strlen(outd) - strlen(SWIG_FILE_DELIMITER), SWIG_FILE_DELIMITER) != 0) Printv(outdir, SWIG_FILE_DELIMITER, NIL); } + Printf(stdout, "outdir (20): %s\n", outdir); // Use the C wrapper file's directory if the output directory has not been set by user if (!outdir) outdir = NewString(c_wrapper_file_dir); + Printf(stdout, "outdir (30): %s\n", outdir); } /* This function sets the name of the configuration file */ @@ -1162,6 +1165,7 @@ int SWIG_main(int argc, char *argv[], Language *l) { Setattr(top, "inputfile", input_file); char *basename = Swig_file_basename(outcurrentdir ? Swig_file_filename(infile): Char(infile)); +Printf(stdout, "basename: %s\n", basename); if (!outfile_name) { if (CPlusPlus || lang->cplus_runtime_mode()) { Setattr(top, "outfile", NewStringf("%s_wrap.%s", basename, cpp_extension)); @@ -1176,7 +1180,7 @@ int SWIG_main(int argc, char *argv[], Language *l) { } else { Setattr(top, "outfile_h", outfile_name_h); } - set_outdir(Swig_file_dirname(basename)); + set_outdir(Swig_file_dirname(Getattr(top, "outfile"))); if (Swig_contract_mode_get()) { Swig_contracts(top); } From a6adffe4d918d87c34caffe7a284a3f7c746781c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 29 Jan 2009 21:20:31 +0000 Subject: [PATCH 0316/1680] remove debugging output git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11094 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/main.cxx | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx index c5e0d0ab5..b645e883f 100644 --- a/Source/Modules/main.cxx +++ b/Source/Modules/main.cxx @@ -273,18 +273,15 @@ static unsigned int decode_numbers_list(String *numlist) { static void set_outdir(const String *c_wrapper_file_dir) { - Printf(stdout, "outdir (10): %s\n", outdir); // Add file delimiter if not present in output directory name if (outdir && Len(outdir) != 0) { const char *outd = Char(outdir); if (strcmp(outd + strlen(outd) - strlen(SWIG_FILE_DELIMITER), SWIG_FILE_DELIMITER) != 0) Printv(outdir, SWIG_FILE_DELIMITER, NIL); } - Printf(stdout, "outdir (20): %s\n", outdir); // Use the C wrapper file's directory if the output directory has not been set by user if (!outdir) outdir = NewString(c_wrapper_file_dir); - Printf(stdout, "outdir (30): %s\n", outdir); } /* This function sets the name of the configuration file */ @@ -1165,7 +1162,6 @@ int SWIG_main(int argc, char *argv[], Language *l) { Setattr(top, "inputfile", input_file); char *basename = Swig_file_basename(outcurrentdir ? Swig_file_filename(infile): Char(infile)); -Printf(stdout, "basename: %s\n", basename); if (!outfile_name) { if (CPlusPlus || lang->cplus_runtime_mode()) { Setattr(top, "outfile", NewStringf("%s_wrap.%s", basename, cpp_extension)); From 47b482516807608a088748b403414e094cd239a3 Mon Sep 17 00:00:00 2001 From: Haoyu Bai Date: Fri, 30 Jan 2009 10:27:37 +0000 Subject: [PATCH 0317/1680] Merged revisions 11085-11086,11088-11089 via svnmerge from https://swig.svn.sourceforge.net/svnroot/swig/branches/swig-2.0 ........ r11085 | bhy | 2009-01-25 00:21:55 +0800 (Sun, 25 Jan 2009) | 2 lines Fix const-correctness. ........ r11086 | bhy | 2009-01-25 02:08:50 +0800 (Sun, 25 Jan 2009) | 2 lines Correct some function definition in header files, which implementation changed in previous commit caused mismatch. ........ r11088 | bhy | 2009-01-25 02:38:32 +0800 (Sun, 25 Jan 2009) | 1 line minor fix and now SWIG is alive again ........ r11089 | bhy | 2009-01-25 06:07:07 +0800 (Sun, 25 Jan 2009) | 1 line Correct some bug introduced in previous commits. Now SWIG is pretty good with C++ compiler. ........ git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11097 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/CParse/cparse.h | 2 +- Source/CParse/cscanner.c | 4 ++-- Source/CParse/parser.y | 4 ++-- Source/CParse/templ.c | 2 +- Source/DOH/base.c | 4 ++-- Source/DOH/doh.h | 4 ++-- Source/Preprocessor/cpp.c | 17 +++++++++-------- Source/Swig/cwrap.c | 4 ++-- Source/Swig/misc.c | 12 ++++++------ Source/Swig/naming.c | 2 +- Source/Swig/scanner.c | 2 +- Source/Swig/swig.h | 14 +++++++------- Source/Swig/symbol.c | 10 ++++++---- Source/Swig/typemap.c | 2 +- Source/Swig/typesys.c | 2 +- 15 files changed, 44 insertions(+), 41 deletions(-) diff --git a/Source/CParse/cparse.h b/Source/CParse/cparse.h index 84e66bf91..9be41c60e 100644 --- a/Source/CParse/cparse.h +++ b/Source/CParse/cparse.h @@ -34,7 +34,7 @@ extern "C" { extern void scanner_ignore_typedef(void); extern void scanner_last_id(int); extern void scanner_clear_rename(void); - extern void scanner_set_location(const_String_or_char_ptr file, int line); + extern void scanner_set_location(String *file, int line); extern void scanner_set_main_input_file(String *file); extern String *scanner_get_main_input_file(); extern void Swig_cparse_follow_locators(int); diff --git a/Source/CParse/cscanner.c b/Source/CParse/cscanner.c index 476a515e7..76ea73f57 100644 --- a/Source/CParse/cscanner.c +++ b/Source/CParse/cscanner.c @@ -442,7 +442,7 @@ int yylook(void) { static int check_typedef = 0; -void scanner_set_location(const_String_or_char_ptr file, int line) { +void scanner_set_location(String *file, int line) { Scanner_set_location(scan,file,line-1); } @@ -701,7 +701,7 @@ int yylex(void) { break; } else if (nexttok == SWIG_TOKEN_CODEBLOCK) { termtoken = SWIG_TOKEN_CODEBLOCK; - termvalue = Scanner_text(scan); + termvalue = Char(Scanner_text(scan)); break; } else if (nexttok == SWIG_TOKEN_LBRACE) { termtoken = SWIG_TOKEN_LBRACE; diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index 721eb173b..3f4256718 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -3334,7 +3334,7 @@ cpp_class_decl : } else { max_class_levels *= 2; } - class_decl = realloc(class_decl, sizeof(Node*) * max_class_levels); + class_decl = (Node**) realloc(class_decl, sizeof(Node*) * max_class_levels); if (!class_decl) { Swig_error(cparse_file, cparse_line, "realloc() failed\n"); } @@ -3483,7 +3483,7 @@ cpp_class_decl : } else { max_class_levels *= 2; } - class_decl = realloc(class_decl, sizeof(Node*) * max_class_levels); + class_decl = (Node**) realloc(class_decl, sizeof(Node*) * max_class_levels); if (!class_decl) { Swig_error(cparse_file, cparse_line, "realloc() failed\n"); } diff --git a/Source/CParse/templ.c b/Source/CParse/templ.c index a3e992f83..14886605f 100644 --- a/Source/CParse/templ.c +++ b/Source/CParse/templ.c @@ -15,7 +15,7 @@ char cvsroot_templ_c[] = "$Id$"; static int template_debug = 0; -String *baselists[3]; +const char *baselists[3]; void SwigType_template_init() { baselists[0] = "baselist"; diff --git a/Source/DOH/base.c b/Source/DOH/base.c index dcb0140e0..15827f328 100644 --- a/Source/DOH/base.c +++ b/Source/DOH/base.c @@ -827,7 +827,7 @@ void DohSetfile(DOH *ho, DOH *file) { /* ----------------------------------------------------------------------------- * DohGetFile() * ----------------------------------------------------------------------------- */ -DOH *DohGetfile(DOH *ho) { +DOH *DohGetfile(const DOH *ho) { DohBase *h = (DohBase *) ho; DohObjInfo *objinfo; if (!h) @@ -854,7 +854,7 @@ void DohSetline(DOH *ho, int l) { /* ----------------------------------------------------------------------------- * DohGetLine() * ----------------------------------------------------------------------------- */ -int DohGetline(DOH *ho) { +int DohGetline(const DOH *ho) { DohBase *h = (DohBase *) ho; DohObjInfo *objinfo; if (!h) diff --git a/Source/DOH/doh.h b/Source/DOH/doh.h index c4518a54d..766e12a34 100644 --- a/Source/DOH/doh.h +++ b/Source/DOH/doh.h @@ -237,9 +237,9 @@ extern DohIterator DohNext(DohIterator x); /* Positional */ -extern int DohGetline(DOH *obj); +extern int DohGetline(const DOH *obj); extern void DohSetline(DOH *obj, int line); -extern DOH *DohGetfile(DOH *obj); +extern DOH *DohGetfile(const DOH *obj); extern void DohSetfile(DOH *obj, DOH *file); /* String Methods */ diff --git a/Source/Preprocessor/cpp.c b/Source/Preprocessor/cpp.c index 635186bb5..d93afc09a 100644 --- a/Source/Preprocessor/cpp.c +++ b/Source/Preprocessor/cpp.c @@ -85,7 +85,8 @@ static String *cpp_include(const_String_or_char_ptr fn, int sysfile) { Setattr(included_files, file, file); } if (!s) { - Seek(fn, 0, SEEK_SET); + /* XXX(bhy) may not need the seek */ + // Seek(fn, 0, SEEK_SET); if (ignore_missing) { Swig_warning(WARN_PP_MISSING_FILE, Getfile(fn), Getline(fn), "Unable to find '%s'\n", fn); } else { @@ -261,7 +262,7 @@ void Preprocessor_error_as_warning(int a) { * ----------------------------------------------------------------------------- */ -const_String_or_char_ptr Macro_vararg_name(const_String_or_char_ptr str, const_String_or_char_ptr line) { +String *Macro_vararg_name(const_String_or_char_ptr str, const_String_or_char_ptr line) { String *argname; String *varargname; char *s, *dots; @@ -295,18 +296,18 @@ Hash *Preprocessor_define(const_String_or_char_ptr _str, int swigmacro) { List *arglist = 0; int c, line; int varargs = 0; - const_String_or_char_ptr str = (const_String_or_char_ptr ) _str; + String *str; assert(cpp); - assert(str); + assert(_str); /* First make sure that string is actually a string */ - if (DohCheck(str)) { - s = Copy(str); - copy_location(str, s); + if (DohCheck(_str)) { + s = Copy(_str); + copy_location(_str, s); str = s; } else { - str = NewString((char *) str); + str = NewString((char *) _str); } Seek(str, 0, SEEK_SET); line = Getline(str); diff --git a/Source/Swig/cwrap.c b/Source/Swig/cwrap.c index 3bdf2b13e..49d2c1e9b 100644 --- a/Source/Swig/cwrap.c +++ b/Source/Swig/cwrap.c @@ -683,7 +683,7 @@ String *Swig_cppdestructor_call(Node *n) { * * ----------------------------------------------------------------------------- */ -String *Swig_cmemberset_call(const_String_or_char_ptr name, SwigType *type, const_String_or_char_ptr self, int varcref) { +String *Swig_cmemberset_call(const_String_or_char_ptr name, SwigType *type, String *self, int varcref) { String *func; String *pname0 = Swig_cparm_name(0, 0); String *pname1 = Swig_cparm_name(0, 1); @@ -718,7 +718,7 @@ String *Swig_cmemberset_call(const_String_or_char_ptr name, SwigType *type, cons * * ----------------------------------------------------------------------------- */ -String *Swig_cmemberget_call(const_String_or_char_ptr name, SwigType *t, const_String_or_char_ptr self, int varcref) { +String *Swig_cmemberget_call(const_String_or_char_ptr name, SwigType *t, String *self, int varcref) { String *func; String *call; String *pname0 = Swig_cparm_name(0, 0); diff --git a/Source/Swig/misc.c b/Source/Swig/misc.c index 8c17d3ddb..e97e93abb 100644 --- a/Source/Swig/misc.c +++ b/Source/Swig/misc.c @@ -651,7 +651,7 @@ String *Swig_string_emangle(String *s) { * In this case, "A::B". Returns NULL if there is no base. * ----------------------------------------------------------------------------- */ -void Swig_scopename_split(String *s, String **rprefix, String **rlast) { +void Swig_scopename_split(const String *s, String **rprefix, String **rlast) { char *tmp = Char(s); char *c = tmp; char *cc = c; @@ -705,7 +705,7 @@ void Swig_scopename_split(String *s, String **rprefix, String **rlast) { } -String *Swig_scopename_prefix(String *s) { +String *Swig_scopename_prefix(const String *s) { char *tmp = Char(s); char *c = tmp; char *cc = c; @@ -757,7 +757,7 @@ String *Swig_scopename_prefix(String *s) { * case, "C". * ----------------------------------------------------------------------------- */ -String *Swig_scopename_last(String *s) { +String *Swig_scopename_last(const String *s) { char *tmp = Char(s); char *c = tmp; char *cc = c; @@ -801,7 +801,7 @@ String *Swig_scopename_last(String *s) { * In this case, "A". Returns NULL if there is no base. * ----------------------------------------------------------------------------- */ -String *Swig_scopename_first(String *s) { +String *Swig_scopename_first(const String *s) { char *tmp = Char(s); char *c = tmp; char *co = 0; @@ -851,7 +851,7 @@ String *Swig_scopename_first(String *s) { * In this case, "B::C". Returns NULL if there is no suffix. * ----------------------------------------------------------------------------- */ -String *Swig_scopename_suffix(String *s) { +String *Swig_scopename_suffix(const String *s) { char *tmp = Char(s); char *c = tmp; char *co = 0; @@ -895,7 +895,7 @@ String *Swig_scopename_suffix(String *s) { * Checks to see if a name is qualified with a scope name * ----------------------------------------------------------------------------- */ -int Swig_scopename_check(String *s) { +int Swig_scopename_check(const String *s) { char *c = Char(s); char *co = strstr(c, "operator "); diff --git a/Source/Swig/naming.c b/Source/Swig/naming.c index 30a8aef0e..3e1f46bb1 100644 --- a/Source/Swig/naming.c +++ b/Source/Swig/naming.c @@ -600,7 +600,7 @@ static void merge_features(Hash *features, Node *n) { * ----------------------------------------------------------------------------- */ static -void features_get(Hash *features, String *tname, SwigType *decl, SwigType *ncdecl, Node *node) { +void features_get(Hash *features, const String *tname, SwigType *decl, SwigType *ncdecl, Node *node) { Node *n = Getattr(features, tname); #ifdef SWIG_DEBUG Printf(stdout, " features_get: %s\n", tname); diff --git a/Source/Swig/scanner.c b/Source/Swig/scanner.c index 52d21c79e..53f1ad4a0 100644 --- a/Source/Swig/scanner.c +++ b/Source/Swig/scanner.c @@ -122,7 +122,7 @@ void Scanner_pushtoken(Scanner * s, int nt, const_String_or_char_ptr val) { assert(s); assert((nt >= 0) && (nt < SWIG_MAXTOKENS)); s->nexttoken = nt; - if (val != s->text) { + if ( Char(val) != Char(s->text) ) { Clear(s->text); Append(s->text,val); } diff --git a/Source/Swig/swig.h b/Source/Swig/swig.h index c44d8f2b5..266864f49 100644 --- a/Source/Swig/swig.h +++ b/Source/Swig/swig.h @@ -185,7 +185,7 @@ extern "C" { extern Typetab *SwigType_pop_scope(void); extern Typetab *SwigType_set_scope(Typetab *h); extern void SwigType_print_scope(Typetab *t); - extern SwigType *SwigType_typedef_resolve(SwigType *t); + extern SwigType *SwigType_typedef_resolve(const SwigType *t); extern SwigType *SwigType_typedef_resolve_all(SwigType *t); extern SwigType *SwigType_typedef_qualified(SwigType *t); extern int SwigType_istypedef(SwigType *t); @@ -291,12 +291,12 @@ extern int ParmList_is_compactdefargs(ParmList *p); extern void Swig_filename_correct(String *filename); extern String *Swig_string_escape(String *s); extern String *Swig_string_mangle(const String *s); - extern void Swig_scopename_split(String *s, String **prefix, String **last); - extern String *Swig_scopename_prefix(String *s); - extern String *Swig_scopename_last(String *s); - extern String *Swig_scopename_first(String *s); - extern String *Swig_scopename_suffix(String *s); - extern int Swig_scopename_check(String *s); + extern void Swig_scopename_split(const String *s, String **prefix, String **last); + extern String *Swig_scopename_prefix(const String *s); + extern String *Swig_scopename_last(const String *s); + extern String *Swig_scopename_first(const String *s); + extern String *Swig_scopename_suffix(const String *s); + extern int Swig_scopename_check(const String *s); extern String *Swig_string_lower(String *s); extern String *Swig_string_upper(String *s); extern String *Swig_string_title(String *s); diff --git a/Source/Swig/symbol.c b/Source/Swig/symbol.c index d65ba6ad0..055af854f 100644 --- a/Source/Swig/symbol.c +++ b/Source/Swig/symbol.c @@ -827,7 +827,7 @@ Node *Swig_symbol_add(const_String_or_char_ptr symname, Node *n) { * verifying that a class hierarchy implements all pure virtual methods. * ----------------------------------------------------------------------------- */ -static Node *_symbol_lookup(String *name, Symtab *symtab, int (*check) (Node *n)) { +static Node *_symbol_lookup(const String *name, Symtab *symtab, int (*check) (Node *n)) { Node *n; List *inherit; Hash *sym = Getattr(symtab, "csymtab"); @@ -908,7 +908,7 @@ static Node *symbol_lookup(const_String_or_char_ptr name, Symtab *symtab, int (* * symbol_lookup_qualified() * ----------------------------------------------------------------------------- */ -static Node *symbol_lookup_qualified(const_String_or_char_ptr name, Symtab *symtab, String *prefix, int local, int (*checkfunc) (Node *n)) { +static Node *symbol_lookup_qualified(const_String_or_char_ptr name, Symtab *symtab, const String *prefix, int local, int (*checkfunc) (Node *n)) { /* This is a little funky, we search by fully qualified names */ if (!symtab) @@ -928,6 +928,7 @@ static Node *symbol_lookup_qualified(const_String_or_char_ptr name, Symtab *symt /* Make qualified name of current scope */ String *qalloc = 0; String *qname = Swig_symbol_qualifiedscopename(symtab); + const String *cqname; if (qname) { if (Len(qname)) { if (prefix && Len(prefix)) { @@ -937,10 +938,11 @@ static Node *symbol_lookup_qualified(const_String_or_char_ptr name, Symtab *symt Append(qname, prefix); } qalloc = qname; + cqname = qname; } else { - qname = prefix; + cqname = prefix; } - st = Getattr(symtabs, qname); + st = Getattr(symtabs, cqname); /* Found a scope match */ if (st) { if (!name) { diff --git a/Source/Swig/typemap.c b/Source/Swig/typemap.c index 775e459d2..401a99801 100644 --- a/Source/Swig/typemap.c +++ b/Source/Swig/typemap.c @@ -1467,7 +1467,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, String *name) { +String *Swig_typemap_get_option(Hash *tm, const_String_or_char_ptr name) { Parm *kw = Getattr(tm, "kwargs"); while (kw) { String *kname = Getattr(kw, "name"); diff --git a/Source/Swig/typesys.c b/Source/Swig/typesys.c index 042e71972..2562e12f8 100644 --- a/Source/Swig/typesys.c +++ b/Source/Swig/typesys.c @@ -539,7 +539,7 @@ static SwigType *typedef_resolve(Typetab *s, String *base) { * ----------------------------------------------------------------------------- */ /* #define SWIG_DEBUG */ -SwigType *SwigType_typedef_resolve(SwigType *t) { +SwigType *SwigType_typedef_resolve(const SwigType *t) { String *base; String *type = 0; String *r = 0; From 1d1ee5bae746a74eb9f971f4bff63b9edbbf00ce Mon Sep 17 00:00:00 2001 From: Haoyu Bai Date: Fri, 30 Jan 2009 10:32:59 +0000 Subject: [PATCH 0318/1680] Fix broken caused by merge git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11098 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Preprocessor/cpp.c | 2 +- Source/Swig/cwrap.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/Preprocessor/cpp.c b/Source/Preprocessor/cpp.c index d93afc09a..81646171a 100644 --- a/Source/Preprocessor/cpp.c +++ b/Source/Preprocessor/cpp.c @@ -86,7 +86,7 @@ static String *cpp_include(const_String_or_char_ptr fn, int sysfile) { } if (!s) { /* XXX(bhy) may not need the seek */ - // Seek(fn, 0, SEEK_SET); + /* Seek(fn, 0, SEEK_SET); */ if (ignore_missing) { Swig_warning(WARN_PP_MISSING_FILE, Getfile(fn), Getline(fn), "Unable to find '%s'\n", fn); } else { diff --git a/Source/Swig/cwrap.c b/Source/Swig/cwrap.c index 49d2c1e9b..3bdf2b13e 100644 --- a/Source/Swig/cwrap.c +++ b/Source/Swig/cwrap.c @@ -683,7 +683,7 @@ String *Swig_cppdestructor_call(Node *n) { * * ----------------------------------------------------------------------------- */ -String *Swig_cmemberset_call(const_String_or_char_ptr name, SwigType *type, String *self, int varcref) { +String *Swig_cmemberset_call(const_String_or_char_ptr name, SwigType *type, const_String_or_char_ptr self, int varcref) { String *func; String *pname0 = Swig_cparm_name(0, 0); String *pname1 = Swig_cparm_name(0, 1); @@ -718,7 +718,7 @@ String *Swig_cmemberset_call(const_String_or_char_ptr name, SwigType *type, Stri * * ----------------------------------------------------------------------------- */ -String *Swig_cmemberget_call(const_String_or_char_ptr name, SwigType *t, String *self, int varcref) { +String *Swig_cmemberget_call(const_String_or_char_ptr name, SwigType *t, const_String_or_char_ptr self, int varcref) { String *func; String *call; String *pname0 = Swig_cparm_name(0, 0); From be7fdab62edbba18d9c0442607691c74d3438c8f Mon Sep 17 00:00:00 2001 From: Haoyu Bai Date: Sat, 31 Jan 2009 13:38:39 +0000 Subject: [PATCH 0319/1680] Fix SF#2552048. Remove the 'self' parameter in Python proxy code for static member function. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11099 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++++ Examples/test-suite/python/cpp_static_runme.py | 7 +++++++ Source/Modules/python.cxx | 4 ++-- 3 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 Examples/test-suite/python/cpp_static_runme.py diff --git a/CHANGES.current b/CHANGES.current index 42c47b154..a474e10e1 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,5 +1,9 @@ Version 1.3.38 (in progress) ================================ +2008-01-31: bhy + [Python] Fix SF#2552048 reported by Gaetan Lehmann. The parameter list + of static member function in generated proxy code should not have the + 'self' parameter. 2008-01-29: wsfulton Fix regression introduced in 1.3.37 where the default output directory diff --git a/Examples/test-suite/python/cpp_static_runme.py b/Examples/test-suite/python/cpp_static_runme.py new file mode 100644 index 000000000..ef8623359 --- /dev/null +++ b/Examples/test-suite/python/cpp_static_runme.py @@ -0,0 +1,7 @@ +#!/usr/bin/evn python +from cpp_static import * +StaticFunctionTest.static_func() +StaticFunctionTest.static_func_2(1) +StaticFunctionTest.static_func_3(1,2) +StaticMemberTest.static_int = 10 +assert StaticMemberTest.static_int == 10 diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index fd4e9be8b..000078524 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -3159,8 +3159,8 @@ public: if (shadow) { if (!classic && !Getattr(n, "feature:python:callback") && have_addtofunc(n)) { int kw = (check_kwargs(n) && !Getattr(n, "sym:overloaded")) ? 1 : 0; - String *parms = make_pyParmList(n, true, false, kw); - String *callParms = make_pyParmList(n, true, true, kw); + String *parms = make_pyParmList(n, false, false, kw); + String *callParms = make_pyParmList(n, false, true, kw); Printv(f_shadow, tab4, "def ", symname, "(", parms, ")", returnTypeAnnotation(n), ":\n", NIL); if (have_docstring(n)) Printv(f_shadow, tab8, docstring(n, AUTODOC_STATICFUNC, tab8), "\n", NIL); From afd67f8c674472581fc642511268095b9999192b Mon Sep 17 00:00:00 2001 From: Haoyu Bai Date: Sat, 31 Jan 2009 14:37:54 +0000 Subject: [PATCH 0320/1680] Fix SF#2552488: indentation adjust of %pythonappend and %pythonprepend git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11100 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 10 ++++-- Examples/test-suite/python/Makefile.in | 1 + .../test-suite/python/python_append_runme.py | 4 +++ Examples/test-suite/python_append.i | 32 +++++++++++++++++++ Source/Modules/python.cxx | 26 +++++++-------- 5 files changed, 57 insertions(+), 16 deletions(-) create mode 100644 Examples/test-suite/python/python_append_runme.py create mode 100644 Examples/test-suite/python_append.i diff --git a/CHANGES.current b/CHANGES.current index a474e10e1..ef9e919ef 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,9 +1,13 @@ Version 1.3.38 (in progress) ================================ 2008-01-31: bhy - [Python] Fix SF#2552048 reported by Gaetan Lehmann. The parameter list - of static member function in generated proxy code should not have the - 'self' parameter. + [Python] Fix SF#2552488 reported by Gaetan Lehmann. Now %pythonprepend + and %pythonappend have correct indentation. + +2008-01-31: bhy + [Python] Fix SF#2552048 reported by Gaetan Lehmann. The parameter list + of static member function in generated proxy code should not have the + 'self' parameter. 2008-01-29: wsfulton Fix regression introduced in 1.3.37 where the default output directory diff --git a/Examples/test-suite/python/Makefile.in b/Examples/test-suite/python/Makefile.in index 5237b3f69..f5058df9f 100644 --- a/Examples/test-suite/python/Makefile.in +++ b/Examples/test-suite/python/Makefile.in @@ -32,6 +32,7 @@ PY2TO3 = 2to3 -x import CPP_TEST_CASES += \ argcargvtest \ python_autodoc \ + python_append \ callback \ complextest \ director_stl \ diff --git a/Examples/test-suite/python/python_append_runme.py b/Examples/test-suite/python/python_append_runme.py new file mode 100644 index 000000000..c8e6b2640 --- /dev/null +++ b/Examples/test-suite/python/python_append_runme.py @@ -0,0 +1,4 @@ +from python_append import * +t=Test() +t.func() +t.static_func() diff --git a/Examples/test-suite/python_append.i b/Examples/test-suite/python_append.i new file mode 100644 index 000000000..2dc9cb970 --- /dev/null +++ b/Examples/test-suite/python_append.i @@ -0,0 +1,32 @@ +/* +Testcase to test %pythonprepend and %pythonappend +*/ + +%module python_append + +%pythonappend Test::func %{ + pass +%} + +%pythonprepend Test::func %{ + pass +%} + +%pythonappend Test::static_func %{ +pass +%} + +%pythonprepend Test::static_func { + pass +} + +%inline %{ + +class Test { +public: + static void static_func() {}; + void func() {}; +}; + +%} + diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 000078524..37580bf40 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -958,7 +958,7 @@ public: * pythoncode() - Output python code into the shadow file * ------------------------------------------------------------ */ - String *pythoncode(String *code, const String *indent) { + String *pythoncode(String *code, const_String_or_char_ptr indent) { String *out = NewString(""); String *temp; char *t; @@ -1645,10 +1645,10 @@ public: if (have_docstring(n)) Printv(f_dest, " ", docstring(n, AUTODOC_FUNC, tab4), "\n", NIL); if (have_pythonprepend(n)) - Printv(f_dest, " ", pythonprepend(n), "\n", NIL); + Printv(f_dest, pythoncode(pythonprepend(n), " "), "\n", NIL); if (have_pythonappend(n)) { Printv(f_dest, " val = ", funcCall(name, callParms), "\n", NIL); - Printv(f_dest, " ", pythonappend(n), "\n", NIL); + Printv(f_dest, pythoncode(pythonappend(n), " "), "\n", NIL); Printv(f_dest, " return val\n", NIL); } else { Printv(f_dest, " return ", funcCall(name, callParms), "\n", NIL); @@ -3118,12 +3118,12 @@ public: Printv(f_shadow, tab8, docstring(n, AUTODOC_METHOD, tab8), "\n", NIL); if (have_pythonprepend(n)) { fproxy = 0; - Printv(f_shadow, tab8, pythonprepend(n), "\n", NIL); + Printv(f_shadow, pythoncode(pythonprepend(n), tab8), "\n", NIL); } if (have_pythonappend(n)) { fproxy = 0; Printv(f_shadow, tab8, "val = ", funcCall(Swig_name_member(class_name, symname), callParms), "\n", NIL); - Printv(f_shadow, tab8, pythonappend(n), "\n", NIL); + Printv(f_shadow, pythoncode(pythonappend(n), tab8), "\n", NIL); Printv(f_shadow, tab8, "return val\n\n", NIL); } else { Printv(f_shadow, tab8, "return ", funcCall(Swig_name_member(class_name, symname), callParms), "\n\n", NIL); @@ -3165,10 +3165,10 @@ public: if (have_docstring(n)) Printv(f_shadow, tab8, docstring(n, AUTODOC_STATICFUNC, tab8), "\n", NIL); if (have_pythonprepend(n)) - Printv(f_shadow, tab8, pythonprepend(n), "\n", NIL); + Printv(f_shadow, pythoncode(pythonprepend(n), tab8), "\n", NIL); if (have_pythonappend(n)) { Printv(f_shadow, tab8, "val = ", funcCall(Swig_name_member(class_name, symname), callParms), "\n", NIL); - Printv(f_shadow, tab8, pythonappend(n), "\n", NIL); + Printv(f_shadow, pythoncode(pythonappend(n), tab8), "\n", NIL); Printv(f_shadow, tab8, "return val\n\n", NIL); } else { Printv(f_shadow, tab8, "return ", funcCall(Swig_name_member(class_name, symname), callParms), "\n\n", NIL); @@ -3275,7 +3275,7 @@ public: if (have_docstring(n)) Printv(f_shadow, tab8, docstring(n, AUTODOC_CTOR, tab8), "\n", NIL); if (have_pythonprepend(n)) - Printv(f_shadow, tab8, pythonprepend(n), "\n", NIL); + Printv(f_shadow, pythoncode(pythonprepend(n), tab8), "\n", NIL); Printv(f_shadow, pass_self, NIL); if (fastinit) { Printv(f_shadow, tab8, module, ".", class_name, "_swiginit(self,", funcCall(Swig_name_construct(symname), callParms), ")\n", NIL); @@ -3285,7 +3285,7 @@ public: tab8, "try: self.this.append(this)\n", tab8, "except: self.this = this\n", NIL); } if (have_pythonappend(n)) - Printv(f_shadow, tab8, pythonappend(n), "\n\n", NIL); + Printv(f_shadow, pythoncode(pythonappend(n), tab8), "\n\n", NIL); Delete(pass_self); } have_constructor = 1; @@ -3308,13 +3308,13 @@ public: if (have_docstring(n)) Printv(f_shadow_stubs, tab4, docstring(n, AUTODOC_CTOR, tab4), "\n", NIL); if (have_pythonprepend(n)) - Printv(f_shadow_stubs, tab4, pythonprepend(n), "\n", NIL); + Printv(f_shadow_stubs, pythoncode(pythonprepend(n), tab4), "\n", NIL); Printv(f_shadow_stubs, tab4, "val = ", funcCall(Swig_name_construct(symname), callParms), "\n", NIL); #ifdef USE_THISOWN Printv(f_shadow_stubs, tab4, "val.thisown = 1\n", NIL); #endif if (have_pythonappend(n)) - Printv(f_shadow_stubs, tab4, pythonappend(n), "\n", NIL); + Printv(f_shadow_stubs, pythoncode(pythonappend(n), tab4), "\n", NIL); Printv(f_shadow_stubs, tab4, "return val\n", NIL); } } @@ -3356,7 +3356,7 @@ public: if (have_docstring(n)) Printv(f_shadow, tab8, docstring(n, AUTODOC_DTOR, tab8), "\n", NIL); if (have_pythonprepend(n)) - Printv(f_shadow, tab8, pythonprepend(n), "\n", NIL); + Printv(f_shadow, pythoncode(pythonprepend(n), tab8), "\n", NIL); #ifdef USE_THISOWN Printv(f_shadow, tab8, "try:\n", NIL); Printv(f_shadow, tab8, tab4, "if self.thisown: ", module, ".", Swig_name_destroy(symname), "(self)\n", NIL); @@ -3364,7 +3364,7 @@ public: #else #endif if (have_pythonappend(n)) - Printv(f_shadow, tab8, pythonappend(n), "\n", NIL); + Printv(f_shadow, pythoncode(pythonappend(n), tab8), "\n", NIL); Printv(f_shadow, tab8, "pass\n", NIL); Printv(f_shadow, "\n", NIL); } From 839750da9ac8c0c67c28ef7c2387cde565f39096 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 31 Jan 2009 19:02:10 +0000 Subject: [PATCH 0321/1680] const / non-const warning fix git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11101 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Swig/cwrap.c | 4 ++-- Source/Swig/swig.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/Swig/cwrap.c b/Source/Swig/cwrap.c index 3bdf2b13e..49d2c1e9b 100644 --- a/Source/Swig/cwrap.c +++ b/Source/Swig/cwrap.c @@ -683,7 +683,7 @@ String *Swig_cppdestructor_call(Node *n) { * * ----------------------------------------------------------------------------- */ -String *Swig_cmemberset_call(const_String_or_char_ptr name, SwigType *type, const_String_or_char_ptr self, int varcref) { +String *Swig_cmemberset_call(const_String_or_char_ptr name, SwigType *type, String *self, int varcref) { String *func; String *pname0 = Swig_cparm_name(0, 0); String *pname1 = Swig_cparm_name(0, 1); @@ -718,7 +718,7 @@ String *Swig_cmemberset_call(const_String_or_char_ptr name, SwigType *type, cons * * ----------------------------------------------------------------------------- */ -String *Swig_cmemberget_call(const_String_or_char_ptr name, SwigType *t, const_String_or_char_ptr self, int varcref) { +String *Swig_cmemberget_call(const_String_or_char_ptr name, SwigType *t, String *self, int varcref) { String *func; String *call; String *pname0 = Swig_cparm_name(0, 0); diff --git a/Source/Swig/swig.h b/Source/Swig/swig.h index 266864f49..ade2d04c3 100644 --- a/Source/Swig/swig.h +++ b/Source/Swig/swig.h @@ -333,8 +333,8 @@ extern int ParmList_is_compactdefargs(ParmList *p); extern String *Swig_ref_call(Node *n, const String *lname); extern String *Swig_cdestructor_call(Node *n); extern String *Swig_cppdestructor_call(Node *n); - extern String *Swig_cmemberset_call(const_String_or_char_ptr name, SwigType *type, const_String_or_char_ptr self, int varcref); - extern String *Swig_cmemberget_call(const_String_or_char_ptr name, SwigType *t, const_String_or_char_ptr self, int varcref); + extern String *Swig_cmemberset_call(const_String_or_char_ptr name, SwigType *type, String *self, int varcref); + extern String *Swig_cmemberget_call(const_String_or_char_ptr name, SwigType *t, String *self, int varcref); extern int Swig_add_extension_code(Node *n, const String *function_name, ParmList *parms, SwigType *return_type, const String *code, int cplusplus, const String *self); From 48051b942d55bcc5c3e9d10fd9e8cfb1719e505c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 31 Jan 2009 19:10:55 +0000 Subject: [PATCH 0322/1680] fix tab alignment - all tabs in SWIG are 8 chars git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11102 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index ef9e919ef..6540fab50 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,13 +1,14 @@ Version 1.3.38 (in progress) ================================ -2008-01-31: bhy - [Python] Fix SF#2552488 reported by Gaetan Lehmann. Now %pythonprepend - and %pythonappend have correct indentation. 2008-01-31: bhy - [Python] Fix SF#2552048 reported by Gaetan Lehmann. The parameter list - of static member function in generated proxy code should not have the - 'self' parameter. + [Python] Fix SF#2552488 reported by Gaetan Lehmann. Now %pythonprepend + and %pythonappend have correct indentation. + +2008-01-31: bhy + [Python] Fix SF#2552048 reported by Gaetan Lehmann. The parameter list + of static member function in generated proxy code should not have the + 'self' parameter. 2008-01-29: wsfulton Fix regression introduced in 1.3.37 where the default output directory From 68f97e26e69035a69b49723b401914e08571b3c0 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 31 Jan 2009 19:37:58 +0000 Subject: [PATCH 0323/1680] finishing touches for 1.3.38 git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11103 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- ANNOUNCE | 2 +- CHANGES.current | 2 +- Doc/Manual/Sections.html | 2 +- README | 5 ++++- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/ANNOUNCE b/ANNOUNCE index b426f737b..5dab914da 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -1,4 +1,4 @@ -*** ANNOUNCE: SWIG 1.3.38 (in progress) *** +*** ANNOUNCE: SWIG 1.3.38 (31 January 2009) *** http://www.swig.org diff --git a/CHANGES.current b/CHANGES.current index 6540fab50..ba74bb8fa 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,4 +1,4 @@ -Version 1.3.38 (in progress) +Version 1.3.38 (31 January 2009) ================================ 2008-01-31: bhy diff --git a/Doc/Manual/Sections.html b/Doc/Manual/Sections.html index ddca5fed3..acb2e46d4 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.38 (in progress) +Last update : SWIG-1.3.38 (31 January 2009)

        Sections

        diff --git a/README b/README index 05da4aa08..6f321d949 100644 --- a/README +++ b/README @@ -1,6 +1,6 @@ SWIG (Simplified Wrapper and Interface Generator) -Version: 1.3.38 (in progress) +Version: 1.3.38 (31 January 2009) Tagline: SWIG is a compiler that integrates C and C++ with languages including Perl, Python, Tcl, Ruby, PHP, Java, Ocaml, Lua, @@ -91,6 +91,9 @@ A SWIG FAQ and other hints can be found on the SWIG Wiki: What's New? =========== +SWIG-1.3.38 summary: +- Output directory regression fix and other minor bug fixes + SWIG-1.3.37 summary: - Python 3 support added - SWIG now ships with a version of ccache that can be used with SWIG. From eff5b3452cd7e607d7355ae09fbd567a861e4b8f Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 31 Jan 2009 23:14:02 +0000 Subject: [PATCH 0324/1680] html fix git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11104 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Lua.html | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Doc/Manual/Lua.html b/Doc/Manual/Lua.html index 3856c98ec..e66c1c7f3 100644 --- a/Doc/Manual/Lua.html +++ b/Doc/Manual/Lua.html @@ -1355,12 +1355,15 @@ if (!SWIG_IsOK(SWIG_ConvertPtr( .....)){

        SWIG_fail_arg(char* func_name,int argnum,char* type)

        -This macro, when called within the context of a SWIG wrappered function, will display the error message and jump to the error handler code. The error message is of the form "Error in func_name (arg argnum), expected 'type' got 'whatever the type was'"
        +This macro, when called within the context of a SWIG wrappered function, will display the error message and jump to the error handler code. The error message is of the form +
        +"Error in func_name (arg argnum), expected 'type' got 'whatever the type was'"
        +

        SWIG_fail_ptr(const char* fn_name,int argnum,swig_type_info* type);

        -Similar to SWIG_fail_arg, except that it will display the swig_type_info information instead.
        +Similar to SWIG_fail_arg, except that it will display the swig_type_info information instead.

        23.6 Customization of your Bindings

        From 648fa408b4a128e03aa0e5e9c44c3951403af1d8 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 1 Feb 2009 00:31:19 +0000 Subject: [PATCH 0325/1680] bump version to 1.3.39 git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11107 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- ANNOUNCE | 10 +++++----- CHANGES | 24 ++++++++++++++++++++++++ CHANGES.current | 25 ++----------------------- Doc/Manual/Sections.html | 2 +- TODO | 2 +- configure.in | 2 +- 6 files changed, 34 insertions(+), 31 deletions(-) diff --git a/ANNOUNCE b/ANNOUNCE index 5dab914da..45470f16e 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -1,10 +1,10 @@ -*** ANNOUNCE: SWIG 1.3.38 (31 January 2009) *** +*** ANNOUNCE: SWIG 1.3.39 (in progress) *** http://www.swig.org -We're pleased to announce SWIG-1.3.38, the latest installment in the -SWIG development effort. SWIG-1.3.38 includes a number of bug fixes +We're pleased to announce SWIG-1.3.39, the latest installment in the +SWIG development effort. SWIG-1.3.39 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.38.tar.gz + http://prdownloads.sourceforge.net/swig/swig-1.3.39.tar.gz A Windows version is also available at - http://prdownloads.sourceforge.net/swig/swigwin-1.3.38.zip + http://prdownloads.sourceforge.net/swig/swigwin-1.3.39.zip Release numbers --------------- diff --git a/CHANGES b/CHANGES index facb8f0ed..02b382509 100644 --- a/CHANGES +++ b/CHANGES @@ -2,6 +2,30 @@ SWIG (Simplified Wrapper and Interface Generator) See CHANGES.current for current version. +Version 1.3.38 (31 January 2009) +================================ + +2008-01-31: bhy + [Python] Fix SF#2552488 reported by Gaetan Lehmann. Now %pythonprepend + and %pythonappend have correct indentation. + +2008-01-31: bhy + [Python] Fix SF#2552048 reported by Gaetan Lehmann. The parameter list + of static member function in generated proxy code should not have the + 'self' parameter. + +2008-01-29: wsfulton + Fix regression introduced in 1.3.37 where the default output directory + for target language specific files (in the absence of -outdir) was no + longer the same directory as the generated c/c++ file. + +2008-01-28: wsfulton + [Java, C#] Fix proxy class not being used when the global scope operator + was used for parameters passed by value. Reported by David Piepgrass. + +2008-01-15: wsfulton + [Perl] Fix seg fault when running with -v option, reported by John Ky. + Version 1.3.37 (13 January 2009) ================================ diff --git a/CHANGES.current b/CHANGES.current index ba74bb8fa..ab3c00452 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,24 +1,3 @@ -Version 1.3.38 (31 January 2009) -================================ - -2008-01-31: bhy - [Python] Fix SF#2552488 reported by Gaetan Lehmann. Now %pythonprepend - and %pythonappend have correct indentation. - -2008-01-31: bhy - [Python] Fix SF#2552048 reported by Gaetan Lehmann. The parameter list - of static member function in generated proxy code should not have the - 'self' parameter. - -2008-01-29: wsfulton - Fix regression introduced in 1.3.37 where the default output directory - for target language specific files (in the absence of -outdir) was no - longer the same directory as the generated c/c++ file. - -2008-01-28: wsfulton - [Java, C#] Fix proxy class not being used when the global scope operator - was used for parameters passed by value. Reported by David Piepgrass. - -2008-01-15: wsfulton - [Perl] Fix seg fault when running with -v option, reported by John Ky. +Version 1.3.39 (in progress) +============================ diff --git a/Doc/Manual/Sections.html b/Doc/Manual/Sections.html index acb2e46d4..364be15db 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.38 (31 January 2009) +Last update : SWIG-1.3.39 (in progress)

        Sections

        diff --git a/TODO b/TODO index bad7a11b9..7e6d3f005 100644 --- a/TODO +++ b/TODO @@ -1,6 +1,6 @@ SWIG TO-DO -Release: SWIG-1.3.38 +Release: SWIG-1.3.39 ----------------------------------------------------------------------------- diff --git a/configure.in b/configure.in index 0b05df2bc..80e0ba2a7 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.38],[http://www.swig.org]) +AC_INIT([swig],[1.3.39],[http://www.swig.org]) AC_PREREQ(2.58) AC_CONFIG_SRCDIR([Source/Swig/swig.h]) AC_CONFIG_AUX_DIR([Tools/config]) From 6574067b725d7acc74cd98a7f15a78680f066211 Mon Sep 17 00:00:00 2001 From: Robert Stone Date: Thu, 5 Feb 2009 15:47:42 +0000 Subject: [PATCH 0326/1680] Fix SF#2564192 git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11110 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 3 +++ Examples/test-suite/perl5/char_strings_runme.pl | 5 ++++- Lib/perl5/perlstrings.swg | 5 +++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index ab3c00452..cadf4ba36 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,3 +1,6 @@ Version 1.3.39 (in progress) ============================ +2009-02-04: talby + [Perl] Fix SF#2564192 reported by David Kolovratnk. + SWIG_AsCharPtrAndSize() now handles "get" magic. diff --git a/Examples/test-suite/perl5/char_strings_runme.pl b/Examples/test-suite/perl5/char_strings_runme.pl index 51c227bb9..c4573737e 100644 --- a/Examples/test-suite/perl5/char_strings_runme.pl +++ b/Examples/test-suite/perl5/char_strings_runme.pl @@ -1,6 +1,6 @@ use strict; use warnings; -use Test::More tests => 4; +use Test::More tests => 5; BEGIN { use_ok('char_strings') } require_ok('char_strings'); @@ -10,3 +10,6 @@ is(char_strings::CharPingPong($val1), "100", 'cstr1'); my $val2 = "greetings"; is(char_strings::CharPingPong($val2), "greetings", 'cstr2'); +# SF#2564192 +"this is a test" =~ /(\w+)$/; +is(char_strings::CharPingPong($1), "test", "handles Magical"); diff --git a/Lib/perl5/perlstrings.swg b/Lib/perl5/perlstrings.swg index 2083f0bba..242a9c967 100644 --- a/Lib/perl5/perlstrings.swg +++ b/Lib/perl5/perlstrings.swg @@ -6,6 +6,11 @@ SWIGINTERN int SWIG_AsCharPtrAndSize(SV *obj, char** cptr, size_t* psize, int *alloc) { + if (SvMAGICAL(obj)) { + SV *tmp = sv_newmortal(); + SvSetSV(tmp, obj); + obj = tmp; + } if (SvPOK(obj)) { STRLEN len = 0; char *cstr = SvPV(obj, len); From de17a4bcca38a7b6741332fda7b7455004c2cd84 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 7 Feb 2009 01:58:39 +0000 Subject: [PATCH 0327/1680] Apply #2081967 configure changes for mzscheme configure errors and breaking of swig exe build git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11111 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 5 +++++ configure.in | 46 ++++++++++++++++++++++++++++------------------ 2 files changed, 33 insertions(+), 18 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index cadf4ba36..60f5fdf20 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,11 @@ Version 1.3.39 (in progress) ============================ +2008-02-07: wsfulton + [MzScheme] Apply #2081967 configure changes for examples to build with recent PLT versions. + Also fixes Makefile errors building SWIG executable when mzscheme package is installed + (version 3.72 approx and later). + 2009-02-04: talby [Perl] Fix SF#2564192 reported by David Kolovratnk. SWIG_AsCharPtrAndSize() now handles "get" magic. diff --git a/configure.in b/configure.in index 80e0ba2a7..5e6230bac 100644 --- a/configure.in +++ b/configure.in @@ -1195,25 +1195,35 @@ AC_ARG_WITH(mzc, AS_HELP_STRING([--with-mzc=path], [Set location of MzScheme's m # First, check for "--without-mzscheme" or "--with-mzscheme=no". if test x"${MZSCHEMEBIN}" = xno -o x"${with_alllang}" = xno ; then -AC_MSG_NOTICE([Disabling MzScheme]) -MZC= + AC_MSG_NOTICE([Disabling MzScheme]) + MZC= else + if test "x$MZSCHEMEBIN" = xyes; then + AC_PATH_PROG(MZSCHEME, mzscheme) + else + MZSCHEME="$MZSCHEMEBIN" + fi + + if test -z "$MZCBIN"; then + AC_PATH_PROG(MZC, mzc) + fi -if test "x$MZSCHEMEBIN" = xyes; then - AC_PATH_PROG(MZSCHEME, mzscheme) -else - MZSCHEME="$MZSCHEMEBIN" -fi - -if test -z "$MZCBIN"; then - AC_PATH_PROG(MZC, mzc) -fi - -if test -n "$MZSCHEME"; then -AC_MSG_CHECKING(for MzScheme dynext object) -MZDYNOBJ=`$MZSCHEME --mute-banner --version --eval '(begin (require (lib "link.ss" "dynext")) (with-handlers (((lambda args #t) (lambda args #f))) (for-each (lambda (x) (display x) (display " ")) ((current-make-standard-link-libraries)))) (with-handlers (((lambda args #t) (lambda args #f))) (for-each (lambda (x) (display x) (display " ")) (expand-for-link-variant (current-standard-link-libraries)))))'` -AC_MSG_RESULT($MZDYNOBJ) -fi + if test -n "$MZSCHEME"; then + AC_MSG_CHECKING(for MzScheme dynext object) + MZDYNOBJ=`$MZSCHEME --eval '(begin (require dynext/link) (with-handlers (((lambda args #t) (lambda args #f))) (for-each (lambda (x) (printf "~a" x)) (expand-for-link-variant (current-standard-link-libraries)))))' 2>/dev/null` + if test -f "$MZDYNOBJ"; then + MZDYNOBJ="$MZDYNOBJ" + else + # older versions + MZDYNOBJ=`$MZSCHEME --mute-banner --version --eval '(begin (require (lib "link.ss" "dynext")) (with-handlers (((lambda args #t) (lambda args #f))) (for-each (lambda (x) (display x) (display " ")) ((current-make-standard-link-libraries)))) (with-handlers (((lambda args #t) (lambda args #f))) (for-each (lambda (x) (display x) (display " ")) (expand-for-link-variant (current-standard-link-libraries)))))' 2>/dev/null` + fi + if test -f "$MZDYNOBJ"; then + AC_MSG_RESULT($MZDYNOBJ) + else + AC_MSG_RESULT(not found) + MZDYNOBJ="" + fi + fi fi AC_SUBST(MZDYNOBJ) @@ -2003,7 +2013,7 @@ AC_SUBST(SKIP_GUILESCM) SKIP_MZSCHEME= -if test -z "$MZC" ; then +if test -z "$MZC" || test -z "$MZDYNOBJ" ; then SKIP_MZSCHEME="1" fi AC_SUBST(SKIP_MZSCHEME) From 3b27d574e208fa828b014c27b5eac5044a11ea14 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 7 Feb 2009 20:25:54 +0000 Subject: [PATCH 0328/1680] fix older versions of mzscheme detection git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11116 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- configure.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.in b/configure.in index 5e6230bac..000496fed 100644 --- a/configure.in +++ b/configure.in @@ -1214,8 +1214,8 @@ else if test -f "$MZDYNOBJ"; then MZDYNOBJ="$MZDYNOBJ" else - # older versions - MZDYNOBJ=`$MZSCHEME --mute-banner --version --eval '(begin (require (lib "link.ss" "dynext")) (with-handlers (((lambda args #t) (lambda args #f))) (for-each (lambda (x) (display x) (display " ")) ((current-make-standard-link-libraries)))) (with-handlers (((lambda args #t) (lambda args #f))) (for-each (lambda (x) (display x) (display " ")) (expand-for-link-variant (current-standard-link-libraries)))))' 2>/dev/null` + # older versions (3.72 approx and earlier) + MZDYNOBJ=`$MZSCHEME --mute-banner --version --eval '(begin (require (lib "link.ss" "dynext")) (with-handlers (((lambda args #t) (lambda args #f))) (for-each (lambda (x) (display x) (display " ")) ((current-make-standard-link-libraries)))) (with-handlers (((lambda args #t) (lambda args #f))) (for-each (lambda (x) (display x)) (expand-for-link-variant (current-standard-link-libraries)))))' 2>/dev/null` fi if test -f "$MZDYNOBJ"; then AC_MSG_RESULT($MZDYNOBJ) From a4906b81829a1d2b1b44da0dcbf2d42c2edaaa3f Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 7 Feb 2009 23:44:12 +0000 Subject: [PATCH 0329/1680] remove gcc warning when using -Wunreachable-code git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11117 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/python/pyrun.swg | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index 52e5d892b..bc5490960 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -1550,10 +1550,12 @@ SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int argnum, int flags) void *result; if (SWIG_Python_ConvertPtr(obj, &result, ty, flags) == -1) { PyErr_Clear(); - if (flags & SWIG_POINTER_EXCEPTION) { +#if SWIG_POINTER_EXCEPTION + if (flags) { SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj); SWIG_Python_ArgFail(argnum); } +#endif } return result; } From 30d73c82cd827f7dfd36dad70d664d7d112eec1b Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 8 Feb 2009 22:30:10 +0000 Subject: [PATCH 0330/1680] Fix %feature not working for conversion operators git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11123 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++++ Examples/test-suite/features.i | 17 +++++++++++++++++ Source/CParse/cscanner.c | 4 ++++ Source/Swig/naming.c | 4 ++-- 4 files changed, 27 insertions(+), 2 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 60f5fdf20..816c0a4e4 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,10 @@ Version 1.3.39 (in progress) ============================ +2008-02-08: wsfulton + Fix %feature not working for conversion operators, reported by Matt Sprague, for example: + %feature("cs:methodmodifiers") operator bool "protected"; + 2008-02-07: wsfulton [MzScheme] Apply #2081967 configure changes for examples to build with recent PLT versions. Also fixes Makefile errors building SWIG executable when mzscheme package is installed diff --git a/Examples/test-suite/features.i b/Examples/test-suite/features.i index 2db51ae6b..2ccbe725a 100644 --- a/Examples/test-suite/features.i +++ b/Examples/test-suite/features.i @@ -162,3 +162,20 @@ namespace Space { } %} +// Test 8 conversion operators +%rename(opbool) operator bool; +%rename(opuint) operator unsigned int; + +%exception ConversionOperators::ConversionOperators() "$action /* ConversionOperators::ConversionOperators() */"; +%exception ConversionOperators::~ConversionOperators() "$action /* ConversionOperators::~ConversionOperators() */"; +%exception ConversionOperators::operator bool "$action /* ConversionOperators::operator bool */"; +%exception ConversionOperators::operator unsigned int "$action /* ConversionOperators::unsigned int*/"; + +%inline %{ + class ConversionOperators { + public: + operator bool() { return false; } + operator unsigned int() { return 0; } + }; +%} + diff --git a/Source/CParse/cscanner.c b/Source/CParse/cscanner.c index 76ea73f57..8734c7d0e 100644 --- a/Source/CParse/cscanner.c +++ b/Source/CParse/cscanner.c @@ -711,6 +711,10 @@ int yylex(void) { termtoken = SWIG_TOKEN_SEMI; termvalue = ";"; break; + } else if (nexttok == SWIG_TOKEN_STRING) { + termtoken = SWIG_TOKEN_STRING; + termvalue = Swig_copy_string(Char(Scanner_text(scan))); + break; } else if (nexttok == SWIG_TOKEN_ID) { if (needspace) { Append(s," "); diff --git a/Source/Swig/naming.c b/Source/Swig/naming.c index 3e1f46bb1..013ce5929 100644 --- a/Source/Swig/naming.c +++ b/Source/Swig/naming.c @@ -655,7 +655,7 @@ void Swig_features_get(Hash *features, String *prefix, String *name, SwigType *d } #ifdef SWIG_DEBUG - Printf(stdout, "Swig_features_get: %s %s %s\n", prefix, name, decl); + Printf(stdout, "Swig_features_get: '%s' '%s' '%s'\n", prefix, name, decl); #endif /* Global features */ @@ -732,7 +732,7 @@ void Swig_feature_set(Hash *features, const_String_or_char_ptr name, SwigType *d Hash *fhash; #ifdef SWIG_DEBUG - Printf(stdout, "Swig_feature_set: %s %s %s %s\n", name, decl, featurename, value); + Printf(stdout, "Swig_feature_set: '%s' '%s' '%s' '%s'\n", name, decl, featurename, value); #endif n = Getattr(features, name); From 6d03b7ce6a35c4b549a1df8f99a91a9565282170 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 8 Feb 2009 22:54:58 +0000 Subject: [PATCH 0331/1680] update old syntax to new _dim0 git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11124 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/swig.swg | 16 ++++++++-------- Lib/typemaps/swigtype.swg | 20 ++++++++++---------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Lib/swig.swg b/Lib/swig.swg index 05294a9a5..e096f8492 100644 --- a/Lib/swig.swg +++ b/Lib/swig.swg @@ -467,26 +467,26 @@ namespace std { /* memberin/globalin typemap for double arrays. */ %typemap(memberin) SWIGTYPE [ANY][ANY] { - $basetype (*inp)[$dim1] = ($basetype (*)[$dim1])($input); - $basetype (*dest)[$dim1] = ($basetype (*)[$dim1])($1); + $basetype (*inp)[$1_dim1] = ($basetype (*)[$1_dim1])($input); + $basetype (*dest)[$1_dim1] = ($basetype (*)[$1_dim1])($1); size_t ii = 0; - for (; ii < $dim0; ++ii) { + for (; ii < $1_dim0; ++ii) { $basetype *ip = inp[ii]; $basetype *dp = dest[ii]; size_t jj = 0; - for (; jj < $dim1; ++jj) dp[jj] = ip[jj]; + for (; jj < $1_dim1; ++jj) dp[jj] = ip[jj]; } } %typemap(globalin) SWIGTYPE [ANY][ANY] { - $basetype (*inp)[$dim1] = ($basetype (*)[$dim1])($input); - $basetype (*dest)[$dim1] = ($basetype (*)[$dim1])($1); + $basetype (*inp)[$1_dim1] = ($basetype (*)[$1_dim1])($input); + $basetype (*dest)[$1_dim1] = ($basetype (*)[$1_dim1])($1); size_t ii = 0; - for (; ii < $dim0; ++ii) { + for (; ii < $1_dim0; ++ii) { $basetype *ip = inp[ii]; $basetype *dp = dest[ii]; size_t jj = 0; - for (; jj < $dim1; ++jj) dp[jj] = ip[jj]; + for (; jj < $1_dim1; ++jj) dp[jj] = ip[jj]; } } diff --git a/Lib/typemaps/swigtype.swg b/Lib/typemaps/swigtype.swg index f5c88a717..15f2f9b41 100644 --- a/Lib/typemaps/swigtype.swg +++ b/Lib/typemaps/swigtype.swg @@ -124,7 +124,7 @@ %typemap(memberin) SWIGTYPE [ANY] { if ($input) { size_t ii = 0; - for (; ii < (size_t)$dim0; ++ii) $1[ii] = $input[ii]; + for (; ii < (size_t)$1_dim0; ++ii) $1[ii] = $input[ii]; } else { %variable_nullref("$type","$name"); } @@ -133,7 +133,7 @@ %typemap(globalin) SWIGTYPE [ANY] { if ($input) { size_t ii = 0; - for (; ii < (size_t)$dim0; ++ii) $1[ii] = $input[ii]; + for (; ii < (size_t)$1_dim0; ++ii) $1[ii] = $input[ii]; } else { %variable_nullref("$type","$name"); } @@ -146,7 +146,7 @@ %variable_fail(res, "$type", "$name"); } else if (inp) { size_t ii = 0; - for (; ii < (size_t)$dim0; ++ii) $1[ii] = inp[ii]; + for (; ii < (size_t)$1_dim0; ++ii) $1[ii] = inp[ii]; } else { %variable_nullref("$type", "$name"); } @@ -158,10 +158,10 @@ %typemap(memberin) SWIGTYPE [ANY][ANY] { if ($input) { size_t ii = 0; - for (; ii < (size_t)$dim0; ++ii) { + for (; ii < (size_t)$1_dim0; ++ii) { if ($input[ii]) { size_t jj = 0; - for (; jj < (size_t)$dim1; ++jj) $1[ii][jj] = $input[ii][jj]; + for (; jj < (size_t)$1_dim1; ++jj) $1[ii][jj] = $input[ii][jj]; } else { %variable_nullref("$type","$name"); } @@ -174,10 +174,10 @@ %typemap(globalin) SWIGTYPE [ANY][ANY] { if ($input) { size_t ii = 0; - for (; ii < (size_t)$dim0; ++ii) { + for (; ii < (size_t)$1_dim0; ++ii) { if ($input[ii]) { size_t jj = 0; - for (; jj < (size_t)$dim1; ++jj) $1[ii][jj] = $input[ii][jj]; + for (; jj < (size_t)$1_dim1; ++jj) $1[ii][jj] = $input[ii][jj]; } else { %variable_nullref("$type","$name"); } @@ -188,16 +188,16 @@ } %typemap(varin) SWIGTYPE [ANY][ANY] { - $basetype (*inp)[$dim1] = 0; + $basetype (*inp)[$1_dim1] = 0; int res = SWIG_ConvertPtr($input, %as_voidptrptr(&inp), $descriptor, %convertptr_flags); if (!SWIG_IsOK(res)) { %variable_fail(res, "$type", "$name"); } else if (inp) { size_t ii = 0; - for (; ii < (size_t)$dim0; ++ii) { + for (; ii < (size_t)$1_dim0; ++ii) { if (inp[ii]) { size_t jj = 0; - for (; jj < (size_t)$dim1; ++jj) $1[ii][jj] = inp[ii][jj]; + for (; jj < (size_t)$1_dim1; ++jj) $1[ii][jj] = inp[ii][jj]; } else { %variable_nullref("$type", "$name"); } From 03e840f3ecf292eabb58cea7cebb49267358c446 Mon Sep 17 00:00:00 2001 From: Haoyu Bai Date: Tue, 10 Feb 2009 14:21:43 +0000 Subject: [PATCH 0332/1680] changed the mapped 'SIZE' of buffer interface from the length of raw buffer to number of items in the buffer. So it would be easier to use with type other than 'char' git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11125 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++++ Lib/python/pybuffer.i | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 816c0a4e4..1b1352296 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,10 @@ Version 1.3.39 (in progress) ============================ +2008-02-08: bhy + Change the SIZE mapped by %pybuffer_mutable_binary and %pybuffer_binary in pybuffer.i from + the length of the buffer to the number of items in the buffer. + 2008-02-08: wsfulton Fix %feature not working for conversion operators, reported by Matt Sprague, for example: %feature("cs:methodmodifiers") operator bool "protected"; diff --git a/Lib/python/pybuffer.i b/Lib/python/pybuffer.i index 5acbb0aa4..121cd709f 100644 --- a/Lib/python/pybuffer.i +++ b/Lib/python/pybuffer.i @@ -21,7 +21,7 @@ %argument_fail(res, "(TYPEMAP, SIZE)", $symname, $argnum); } $1 = ($1_ltype) buf; - $2 = ($2_ltype) size; + $2 = ($2_ltype) (size/sizeof($*1_type)); } %enddef @@ -73,7 +73,7 @@ %argument_fail(res, "(TYPEMAP, SIZE)", $symname, $argnum); } $1 = ($1_ltype) buf; - $2 = ($2_ltype) size; + $2 = ($2_ltype) (size / sizeof($*1_type)); } %enddef From f9abd71f7685812260f07dc85f8cad8522bd814b Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 12 Feb 2009 21:16:03 +0000 Subject: [PATCH 0333/1680] remove unnecessary temporary variable when wrapping return by reference git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11126 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 23 +++++++++++++++++++++++ Source/Swig/cwrap.c | 13 +++---------- 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 1b1352296..345257e62 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,29 @@ Version 1.3.39 (in progress) ============================ +2008-02-12: wsfulton + Remove unnecessary temporary variable when wrapping return values that are references. + Example of generated code for wrapping: + + struct XYZ { + std::string& refReturn(); + }; + + used to be: + + std::string *result = 0 ; + ... + { + std::string &_result_ref = (arg1)->refReturn(); + result = (std::string *) &_result_ref; + } + + Now it is: + + std::string *result = 0 ; + ... + result = (std::string *) &(arg1)->refReturn(); + 2008-02-08: bhy Change the SIZE mapped by %pybuffer_mutable_binary and %pybuffer_binary in pybuffer.i from the length of the buffer to the number of items in the buffer. diff --git a/Source/Swig/cwrap.c b/Source/Swig/cwrap.c index 49d2c1e9b..3ed736f54 100644 --- a/Source/Swig/cwrap.c +++ b/Source/Swig/cwrap.c @@ -260,10 +260,9 @@ String *Swig_cresult(SwigType *t, const_String_or_char_ptr name, const_String_or break; case T_REFERENCE: { - String *str = SwigType_str(t, "_result_ref"); - Printf(fcall, "{\n"); - Printf(fcall, "%s = ", str); - Delete(str); + String *lstr = SwigType_lstr(t, 0); + Printf(fcall, "%s = (%s) &", name, lstr); + Delete(lstr); } break; case T_USER: @@ -290,12 +289,6 @@ String *Swig_cresult(SwigType *t, const_String_or_char_ptr name, const_String_or Append(fcall, ";"); } - if (SwigType_type(t) == T_REFERENCE) { - String *lstr = SwigType_lstr(t, 0); - Printf(fcall, "\n%s = (%s) &_result_ref;\n", name, lstr); - Append(fcall, "}"); - Delete(lstr); - } return fcall; } From 9be7fe899d6c5ad77a32a9ab5bc80f09a5c4854c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 13 Feb 2009 07:26:06 +0000 Subject: [PATCH 0334/1680] Add support for %extend and memberin typemaps git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11127 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++++ Source/Modules/lang.cxx | 45 ++++++++++++++++++++++------------------- Source/Swig/cwrap.c | 14 ++++++------- Source/Swig/swig.h | 2 +- 4 files changed, 35 insertions(+), 30 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 345257e62..349b69707 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,10 @@ Version 1.3.39 (in progress) ============================ +2008-02-13: wsfulton + Add support for %extend and memberin typemaps. Previously the memberin typemaps were + ignored for member variables within a %extend block. + 2008-02-12: wsfulton Remove unnecessary temporary variable when wrapping return values that are references. Example of generated code for wrapping: diff --git a/Source/Modules/lang.cxx b/Source/Modules/lang.cxx index 72a7ff496..38658ce9c 100644 --- a/Source/Modules/lang.cxx +++ b/Source/Modules/lang.cxx @@ -1422,36 +1422,39 @@ int Language::membervariableHandler(Node *n) { target = NewStringf("%s->%s", pname, name); Delete(pname); } - tm = Swig_typemap_lookup("memberin", n, target, 0); + } else { + target = NewStringf("$extendgetcall"); // member variable access expanded later } + 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; - Swig_MembersetToFunction(n, ClassType, flags); + String *call = 0; + Swig_MembersetToFunction(n, ClassType, flags, &call); Setattr(n, "memberset", "1"); - if (!Extend) { - /* Check for a member in typemap here */ - if (!tm) { - if (SwigType_isarray(type)) { - Swig_warning(WARN_TYPEMAP_VARIN_UNDEF, input_file, line_number, "Unable to set variable of type %s.\n", SwigType_str(type, 0)); - make_set_wrapper = 0; - } - } else { - String *pname0 = Swig_cparm_name(0, 0); - String *pname1 = Swig_cparm_name(0, 1); - Replace(tm, "$source", pname1, DOH_REPLACE_ANY); - Replace(tm, "$target", target, DOH_REPLACE_ANY); - Replace(tm, "$input", pname1, DOH_REPLACE_ANY); - Replace(tm, "$self", pname0, DOH_REPLACE_ANY); - Setattr(n, "wrap:action", tm); - Delete(tm); - Delete(pname0); - Delete(pname1); + 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; } - Delete(target); + } 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(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 3ed736f54..7c6837a2b 100644 --- a/Source/Swig/cwrap.c +++ b/Source/Swig/cwrap.c @@ -1203,7 +1203,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) { +int Swig_MembersetToFunction(Node *n, String *classname, int flags, String **call) { String *name; ParmList *parms; Parm *p; @@ -1251,23 +1251,21 @@ int Swig_MembersetToFunction(Node *n, String *classname, int flags) { 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 *call = Swig_cmemberset_call(name, type, self, varcref); - String *cres = NewStringf("%s;", call); + String *cres; + *call = Swig_cmemberset_call(name, type, self, varcref); + 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 ade2d04c3..2b2c797c9 100644 --- a/Source/Swig/swig.h +++ b/Source/Swig/swig.h @@ -343,7 +343,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); + extern int Swig_MembersetToFunction(Node *n, String *classname, int flags, String **call); 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 589eb8e50959cbabfde2ed1451264ea1b4ca5260 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 13 Feb 2009 22:42:45 +0000 Subject: [PATCH 0335/1680] Add %attributeval and %attributestring to attribute.swg library git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11128 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 6 ++ .../test-suite/csharp/li_attribute_runme.cs | 78 +++++++++++++++++ Examples/test-suite/li_attribute.i | 31 +++++++ .../test-suite/octave/li_attribute_runme.m | 38 ++++++-- .../test-suite/python/li_attribute_runme.py | 36 ++++++-- Lib/typemaps/attribute.swg | 87 ++++++++++++++++++- 6 files changed, 261 insertions(+), 15 deletions(-) create mode 100644 Examples/test-suite/csharp/li_attribute_runme.cs diff --git a/CHANGES.current b/CHANGES.current index 349b69707..e60bdc1d2 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,12 @@ Version 1.3.39 (in progress) ============================ +2008-02-14: wsfulton + Extend attribute library support for structs/classes and the accessor functions use + pass/return by value semantics. Two new macros are available and usage is identical + to %attribute. These are %attributeval for structs/classes and %attributestring for + string classes, like std::string. See attribute.swg for more details. + 2008-02-13: wsfulton Add support for %extend and memberin typemaps. Previously the memberin typemaps were ignored for member variables within a %extend block. diff --git a/Examples/test-suite/csharp/li_attribute_runme.cs b/Examples/test-suite/csharp/li_attribute_runme.cs new file mode 100644 index 000000000..46f982637 --- /dev/null +++ b/Examples/test-suite/csharp/li_attribute_runme.cs @@ -0,0 +1,78 @@ +// Ported from Python li_attribute_runme.py + +using System; +using li_attributeNamespace; + +public class li_attribute_runme { + + public static void Main() { + A aa = new A(1,2,3); + + if (aa.a != 1) + throw new ApplicationException("error"); + aa.a = 3; + if (aa.a != 3) + throw new ApplicationException("error"); + + if (aa.b != 2) + throw new ApplicationException("error"); + aa.b = 5; + if (aa.b != 5) + throw new ApplicationException("error"); + + if (aa.d != aa.b) + throw new ApplicationException("error"); + + if (aa.c != 3) + throw new ApplicationException("error"); + //aa.c = 5; + //if (aa.c != 3) + // throw new ApplicationException("error"); + + Param_i pi = new Param_i(7); + if (pi.value != 7) + throw new ApplicationException("error"); + + pi.value=3; + if (pi.value != 3) + throw new ApplicationException("error"); + + B b = new B(aa); + + if (b.a.c != 3) + throw new ApplicationException("error"); + + // class/struct attribute with get/set methods using return/pass by reference + MyFoo myFoo = new MyFoo(); + myFoo.x = 8; + MyClass myClass = new MyClass(); + myClass.Foo = myFoo; + if (myClass.Foo.x != 8) + throw new ApplicationException("error"); + + // class/struct attribute with get/set methods using return/pass by value + MyClassVal myClassVal = new MyClassVal(); + if (myClassVal.ReadWriteFoo.x != -1) + throw new ApplicationException("error"); + if (myClassVal.ReadOnlyFoo.x != -1) + throw new ApplicationException("error"); + myClassVal.ReadWriteFoo = myFoo; + if (myClassVal.ReadWriteFoo.x != 8) + throw new ApplicationException("error"); + if (myClassVal.ReadOnlyFoo.x != 8) + throw new ApplicationException("error"); + + // string attribute with get/set methods using return/pass by value + MyStringyClass myStringClass = new MyStringyClass("initial string"); + if (myStringClass.ReadWriteString != "initial string") + throw new ApplicationException("error"); + if (myStringClass.ReadOnlyString != "initial string") + throw new ApplicationException("error"); + myStringClass.ReadWriteString = "changed string"; + if (myStringClass.ReadWriteString != "changed string") + throw new ApplicationException("error"); + if (myStringClass.ReadOnlyString != "changed string") + throw new ApplicationException("error"); + } +} + diff --git a/Examples/test-suite/li_attribute.i b/Examples/test-suite/li_attribute.i index 5b4379ebf..4f9497afb 100644 --- a/Examples/test-suite/li_attribute.i +++ b/Examples/test-suite/li_attribute.i @@ -93,9 +93,11 @@ struct MyFoo; // %attribute2 does not work with templates %template(Param_i) Param; +// class/struct attribute with get/set methods using return/pass by reference %attribute2(MyClass, MyFoo, Foo, GetFoo, SetFoo); %inline %{ struct MyFoo { + MyFoo() : x(-1) {} int x; }; class MyClass { @@ -106,3 +108,32 @@ struct MyFoo; // %attribute2 does not work with templates }; %} + +// class/struct attribute with get/set methods using return/pass by value +%attributeval(MyClassVal, MyFoo, ReadWriteFoo, GetFoo, SetFoo); +%attributeval(MyClassVal, MyFoo, ReadOnlyFoo, GetFoo); +%inline %{ + class MyClassVal { + MyFoo foo; + public: + MyFoo GetFoo() { return foo; } + void SetFoo(MyFoo other) { foo = other; } + }; +%} + + +// string attribute with get/set methods using return/pass by value +%include +%attributestring(MyStringyClass, std::string, ReadWriteString, GetString, SetString); +%attributestring(MyStringyClass, std::string, ReadOnlyString, GetString); +%inline %{ + class MyStringyClass { + std::string str; + public: + MyStringyClass(const std::string &val) : str(val) {} + std::string GetString() { return str; } + void SetString(std::string other) { str = other; } + }; +%} + + diff --git a/Examples/test-suite/octave/li_attribute_runme.m b/Examples/test-suite/octave/li_attribute_runme.m index c66e27c5b..548e733ed 100644 --- a/Examples/test-suite/octave/li_attribute_runme.m +++ b/Examples/test-suite/octave/li_attribute_runme.m @@ -10,7 +10,6 @@ if (aa.a != 3) error("aa.a = %i",aa.a) endif - if (aa.b != 2) error(aa.b) endif @@ -19,8 +18,6 @@ if (aa.b != 5) error endif - - if (aa.d != aa.b) error endif @@ -39,14 +36,13 @@ if (pi.value != 3) error endif - b = li_attribute.B(aa); if (b.a.c != 3) error endif - +# class/struct attribute with get/set methods using return/pass by reference myFoo = li_attribute.MyFoo(); myFoo.x = 8; myClass = li_attribute.MyClass(); @@ -55,3 +51,35 @@ if (myClass.Foo.x != 8) error endif +# class/struct attribute with get/set methods using return/pass by value +myClassVal = li_attribute.MyClassVal(); +if (myClassVal.ReadWriteFoo.x != -1) + error +endif +if (myClassVal.ReadOnlyFoo.x != -1) + error +endif +myClassVal.ReadWriteFoo = myFoo; +if (myClassVal.ReadWriteFoo.x != 8) + error +endif +if (myClassVal.ReadOnlyFoo.x != 8) + error +endif + +# string attribute with get/set methods using return/pass by value +myStringyClass = li_attribute.MyStringyClass("initial string"); +if (myStringyClass.ReadWriteString != "initial string") + error +endif +if (myStringyClass.ReadOnlyString != "initial string") + error +endif +myStringyClass.ReadWriteString = "changed string"; +if (myStringyClass.ReadWriteString != "changed string") + error +endif +if (myStringyClass.ReadOnlyString != "changed string") + error +endif + diff --git a/Examples/test-suite/python/li_attribute_runme.py b/Examples/test-suite/python/li_attribute_runme.py index 5eeec299b..db40b9b2a 100644 --- a/Examples/test-suite/python/li_attribute_runme.py +++ b/Examples/test-suite/python/li_attribute_runme.py @@ -1,3 +1,5 @@ +# Ported to C# li_attribute_runme.cs + import li_attribute aa = li_attribute.A(1,2,3) @@ -9,7 +11,6 @@ if aa.a != 3: print aa.a raise RuntimeError - if aa.b != 2: print aa.b raise RuntimeError @@ -17,8 +18,6 @@ aa.b = 5 if aa.b != 5: raise RuntimeError - - if aa.d != aa.b: raise RuntimeError @@ -36,17 +35,40 @@ pi.value=3 if pi.value != 3: raise RuntimeError - b = li_attribute.B(aa) if b.a.c != 3: raise RuntimeError - -myFoo = li_attribute.MyFoo +# class/struct attribute with get/set methods using return/pass by reference +myFoo = li_attribute.MyFoo() myFoo.x = 8 -myClass = li_attribute.MyClass +myClass = li_attribute.MyClass() myClass.Foo = myFoo if myClass.Foo.x != 8: raise RuntimeError +# class/struct attribute with get/set methods using return/pass by value +myClassVal = li_attribute.MyClassVal() +if myClassVal.ReadWriteFoo.x != -1: + raise RuntimeError +if myClassVal.ReadOnlyFoo.x != -1: + raise RuntimeError +myClassVal.ReadWriteFoo = myFoo +if myClassVal.ReadWriteFoo.x != 8: + raise RuntimeError +if myClassVal.ReadOnlyFoo.x != 8: + raise RuntimeError + +# string attribute with get/set methods using return/pass by value +myStringyClass = li_attribute.MyStringyClass("initial string") +if myStringyClass.ReadWriteString != "initial string": + raise RuntimeError +if myStringyClass.ReadOnlyString != "initial string": + raise RuntimeError +myStringyClass.ReadWriteString = "changed string" +if myStringyClass.ReadWriteString != "changed string": + raise RuntimeError +if myStringyClass.ReadOnlyString != "changed string": + raise RuntimeError + diff --git a/Lib/typemaps/attribute.swg b/Lib/typemaps/attribute.swg index f6335be82..4bc6315b7 100644 --- a/Lib/typemaps/attribute.swg +++ b/Lib/typemaps/attribute.swg @@ -11,7 +11,7 @@ The following macros convert a pair of set/get methods into a "native" attribute. - Use %attribute when you have a pair of get/set methods + Use %attribute when you have a pair of get/set methods to a primitive type like in: %attribute(A, int, a, get_a, set_a); @@ -27,8 +27,8 @@ %attribute(A, int, c, get_c); - Use %attributeref when you have const/non-const reference - access methods, like in: + Use %attributeref when you have const/non-const reference access methods + for primitive types or class/structs, like in: %attributeref(A, int, b); @@ -99,6 +99,40 @@ where %arg() 'normalizes' the type to be understood as a single argument, otherwise the macro will get confused by the comma. + + The %attributeval is the same as %attribute, but should be used when the type + is a class/struct (ie a non-primitive type) and when the get and set methods + return/pass by value. The following is very similar to the above example, but + note that the access is by value rather than reference. + + %attributeval(MyClassVal, MyFoo, ReadWriteFoo, GetFoo, SetFoo); + %attributeval(MyClassVal, MyFoo, ReadOnlyFoo, GetFoo); + %inline %{ + class MyClassVal { + MyFoo foo; + public: + MyFoo GetFoo() { return foo; } + void SetFoo(MyFoo other) { foo = other; } + }; + %} + + The %attributestring is the same as %attributeval, but should be used for string + class types, which are unusual as they are a class on the C++ side, but normally an + immutable/primitive type in the target language. Example usage for std::string: + + %include + %attributestring(MyStringyClass, std::string, ReadWriteString, GetString, SetString); + %attributestring(MyStringyClass, std::string, ReadOnlyString, GetString); + %inline %{ + class MyStringyClass { + std::string str; + public: + MyStringyClass(const std::string &val) : str(val) {} + std::string GetString() { return str; } + void SetString(std::string other) { str = other; } + }; + %} + */ // @@ -203,3 +237,50 @@ #endif %enddef + +%define %attributeval(Class, AttributeType, AttributeName, GetMethod, SetMethod...) + %{ + #define %mangle(Class) ##_## AttributeName ## _get(self_) new AttributeType(self_->GetMethod()) + %} + #if #SetMethod != "" + %{ + #define %mangle(Class) ##_## AttributeName ## _set(self_, val_) self_->SetMethod(*val_) + %} + #if #SetMethod != #AttributeName + %ignore Class::SetMethod; + #endif + #else + %immutable Class::AttributeName; + #endif + %ignore Class::GetMethod(); + %ignore Class::GetMethod() const; + %newobject Class::AttributeName; + %extend Class { + AttributeType AttributeName; + } +%enddef + + +%define %attributestring(Class, AttributeType, AttributeName, GetMethod, SetMethod...) + %{ + #define %mangle(Class) ##_## AttributeName ## _get(self_) *new AttributeType(self_->GetMethod()) + %} + #if #SetMethod != "" + %{ + #define %mangle(Class) ##_## AttributeName ## _set(self_, val_) self_->SetMethod(val_) + %} + #if #SetMethod != #AttributeName + %ignore Class::SetMethod; + #endif + #else + %immutable Class::AttributeName; + #endif + %ignore Class::GetMethod(); + %ignore Class::GetMethod() const; + %newobject Class::AttributeName; + %typemap(newfree) const AttributeType &AttributeName "delete $1;// my newfree override" + %extend Class { + AttributeType AttributeName; + } +%enddef + From 7a13f920381bbade2541350e554e17c7252227ce Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 17 Feb 2009 08:03:22 +0000 Subject: [PATCH 0336/1680] make clean-test-suite now cleans all languages, not just languages detected at configure time git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11129 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 5 +++++ Makefile.in | 44 +++++++------------------------------------- 2 files changed, 12 insertions(+), 37 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index e60bdc1d2..d7d16a79b 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,11 @@ Version 1.3.39 (in progress) ============================ +2008-02-17: wsfulton + 'make clean-test-suite' will now run clean on ALL languages. Previously it only + ran the correctly configured languages. This way it is now possible to clean up + properly after running 'make partialcheck-test-suite'. + 2008-02-14: wsfulton Extend attribute library support for structs/classes and the accessor functions use pass/return by value semantics. Two new macros are available and usage is identical diff --git a/Makefile.in b/Makefile.in index 279fa2ca4..42fa935d6 100644 --- a/Makefile.in +++ b/Makefile.in @@ -84,6 +84,7 @@ skip-gcj = test -n "@SKIP_GCJ@" ##################################################################### ACTION = check +NOSKIP = chk-set-swiglib = SWIG_LIB=@ROOT_DIR@/Lib chk-set-swig = SWIG=@ROOT_DIR@/$(TARGET) @@ -258,7 +259,7 @@ check-%-test-suite: fi @passed=true; \ dir="Examples/test-suite/$*"; \ - if $(skip-$*) -a $(ACTION) != "partialcheck"; then \ + if $(skip-$*) -a "$(NOSKIP)" != "1"; then \ echo skipping $* test-suite $(ACTION); \ elif [ ! -d $$dir ]; then \ echo warning: cannot $(ACTION) $* test-suite "(no dir $$dir)";\ @@ -271,10 +272,10 @@ check-%-test-suite: # Partial test-suite check - it only invokes SWIG, ie no compilation and no runtime testing partialcheck-test-suite: - @$(MAKE) -k -s check-test-suite ACTION=partialcheck + @$(MAKE) -k -s check-test-suite ACTION=partialcheck NOSKIP=1 partialcheck-%-test-suite: - @$(MAKE) -k -s check-$*-test-suite ACTION=partialcheck + @$(MAKE) -k -s check-$*-test-suite ACTION=partialcheck NOSKIP=1 check: check-aliveness check-ccache check-examples check-gifplot check-test-suite @@ -355,13 +356,13 @@ clean-gifplot: @$(MAKE) -k -s check-gifplot ACTION=clean clean-test-suite: - @$(MAKE) -k -s check-test-suite ACTION=clean + @$(MAKE) -k -s check-test-suite ACTION=clean NOSKIP=1 clean-%-examples: @$(MAKE) -k -s check-$*-examples ACTION=clean clean-%-test-suite: - @$(MAKE) -k -s check-$*-test-suite ACTION=clean + @$(MAKE) -k -s check-$*-test-suite ACTION=clean NOSKIP=1 clean-%-gifplot: @$(MAKE) -k -s check-$*-gifplot ACTION=clean @@ -398,42 +399,11 @@ distclean-source: distclean-test-suite: @echo distcleaning Examples/test-suite - @$(MAKE) -k -s noskip-test-suite ACTION=distclean + @$(MAKE) -k -s check-test-suite ACTION=distclean NOSKIP=1 distclean-ccache: test -z "$(ENABLE_CCACHE)" || (cd $(CCACHE) && $(MAKE) -s distclean) -noskip-test-suite: \ - noskip-tcl-test-suite \ - noskip-perl5-test-suite \ - noskip-python-test-suite \ - noskip-java-test-suite \ - noskip-guilescm-test-suite \ - noskip-guile-test-suite \ - noskip-mzscheme-test-suite \ - noskip-ruby-test-suite \ - noskip-ocaml-test-suite \ - noskip-octave-test-suite \ - noskip-php-test-suite \ - noskip-pike-test-suite \ - noskip-csharp-test-suite \ - noskip-lua-test-suite \ - noskip-allegrocl-test-suite \ - noskip-clisp-test-suite \ - noskip-uffi-test-suite \ - noskip-cffi-test-suite \ - noskip-chicken-test-suite \ - noskip-r-test-suite - -noskip-%-test-suite: - dir="Examples/test-suite/$*"; \ - if [ ! -d $$dir ]; then \ - echo warning: cannot $(ACTION) $* test-suite "(no dir $$dir)";\ - else \ - echo $(ACTION)ing $$dir; \ - (cd $$dir && $(MAKE) -k -s $(ACTION)) \ - fi; - distclean-dead: rm -f $(DISTCLEAN-DEAD) From b590c515f7a367e547cb0a752d1144566f74aed2 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 17 Feb 2009 18:54:56 +0000 Subject: [PATCH 0337/1680] typemap_namespace.i fix for mzscheme git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11130 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/typemap_namespace.i | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/test-suite/typemap_namespace.i b/Examples/test-suite/typemap_namespace.i index 5375c43b6..91349a2a5 100644 --- a/Examples/test-suite/typemap_namespace.i +++ b/Examples/test-suite/typemap_namespace.i @@ -27,7 +27,7 @@ namespace Foo { %typemap(javaout) Str1 * = char *; #endif %typemap(in) Str1 * = char *; -#if !(defined(SWIGCSHARP) || defined(SWIGLUA) || defined(SWIGPHP)) +#if !(defined(SWIGCSHARP) || defined(SWIGLUA) || defined(SWIGPHP) || defined(SWIGMZSCHEME)) %typemap(freearg) Str1 * = char *; #endif %typemap(typecheck) Str1 * = char *; From fc33c676b49cdde852a6ecb7e5bd43cb1b20ee15 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 17 Feb 2009 19:02:04 +0000 Subject: [PATCH 0338/1680] Fix make partialcheck-mzscheme-test-suite git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11131 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/Makefile.in | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Examples/Makefile.in b/Examples/Makefile.in index 03ab789dc..82a5f7cdb 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -526,7 +526,7 @@ modula3_clean: ##### MZSCHEME ###### ################################################################## -MZC = test -n "@MZC@" && @MZC@ +MZC = @MZC@ MZDYNOBJ = @MZDYNOBJ@ MZSCHEME_SO = @MZSCHEME_SO@ @@ -536,12 +536,12 @@ MZSCHEME_SO = @MZSCHEME_SO@ mzscheme: $(SRCS) $(SWIG) -mzscheme $(SWIGOPT) $(INTERFACEPATH) - $(MZC) `echo $(INCLUDES) | sed 's/-I/++ccf -I/g'` --cc $(ISRCS) $(SRCS) - $(MZC) --ld $(TARGET)$(MZSCHEME_SO) $(OBJS) $(IOBJS) + $(COMPILETOOL) $(MZC) `echo $(INCLUDES) | sed 's/-I/++ccf -I/g'` --cc $(ISRCS) $(SRCS) + $(COMPILETOOL) $(MZC) --ld $(TARGET)$(MZSCHEME_SO) $(OBJS) $(IOBJS) mzscheme_cpp: $(SRCS) $(SWIG) -mzscheme -c++ $(SWIGOPT) $(INTERFACEPATH) - $(MZC) `echo $(INCLUDES) | sed 's/-I/++ccf -I/g'` --cc $(ICXXSRCS) $(SRCS) $(CXXSRCS) + $(COMPILETOOL) $(MZC) `echo $(INCLUDES) | sed 's/-I/++ccf -I/g'` --cc $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(CXXSHARED) $(CFLAGS) -o $(LIBPREFIX)$(TARGET)$(MZSCHEME_SO) $(OBJS) $(IOBJS) $(MZDYNOBJ) $(CPP_DLLIBS) # ----------------------------------------------------------------- From a1933f7bbca8cc26e393d6281afab459c8d032fd Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 17 Feb 2009 20:08:57 +0000 Subject: [PATCH 0339/1680] Fix make partialcheck-ocaml-test-suite git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11132 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/Makefile.in | 7 ++++--- Examples/test-suite/ocaml/Makefile.in | 2 +- Examples/test-suite/typemap_namespace.i | 2 +- Lib/ocaml/std_deque.i | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Examples/Makefile.in b/Examples/Makefile.in index 82a5f7cdb..58c0212d5 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -563,6 +563,7 @@ OCAMLFIND=@OCAMLFIND@ OCAMLMKTOP=@OCAMLMKTOP@ $(SWIGWHERE) NOLINK ?= false OCAMLPP= -pp "camlp4o ./swigp4.cmo" +OCAMLP4WHERE=`$(COMPILETOOL) camlp4 -where` OCAMLCORE=\ rm -rf swig.mli swig.ml swigp4.ml && \ $(SWIG) -ocaml -co swig.mli 2>/dev/null && \ @@ -570,7 +571,7 @@ OCAMLCORE=\ $(SWIG) -ocaml -co swigp4.ml 2>/dev/null && \ $(OCC) -c swig.mli && \ $(OCC) -c swig.ml && \ - $(OCC) -I `camlp4 -where` -pp "camlp4o pa_extend.cmo q_MLast.cmo" \ + $(OCC) -I $(OCAMLP4WHERE) -pp "camlp4o pa_extend.cmo q_MLast.cmo" \ -c swigp4.ml ocaml_static: $(SRCS) @@ -616,7 +617,7 @@ ocaml_static_toplevel: $(SRCS) $(OCC) $(OCAMLPP) -c $(PROGFILE) $(NOLINK) || $(OCAMLMKTOP) \ swig.cmo \ - -I `camlp4 -where` camlp4o.cma swigp4.cmo \ + -I $(OCAMLP4WHERE) camlp4o.cma swigp4.cmo \ -g -ccopt -g -cclib -g -custom -o $(TARGET)_top \ $(INTERFACE:%.i=%.cmo) \ $(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) -cclib "$(LIBS)" @@ -650,7 +651,7 @@ ocaml_static_cpp_toplevel: $(SRCS) $(OCC) $(OCAMLPP) -c $(PROGFILE) $(NOLINK) || $(OCAMLMKTOP) \ swig.cmo \ - -I `camlp4 -where` camlp4o.cma swigp4.cmo \ + -I $(OCAMLP4WHERE) camlp4o.cma swigp4.cmo \ -g -ccopt -g -cclib -g -custom -o $(TARGET)_top \ $(INTERFACE:%.i=%.cmo) \ $(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) \ diff --git a/Examples/test-suite/ocaml/Makefile.in b/Examples/test-suite/ocaml/Makefile.in index 6f0b65489..0e6235f94 100644 --- a/Examples/test-suite/ocaml/Makefile.in +++ b/Examples/test-suite/ocaml/Makefile.in @@ -16,7 +16,7 @@ run_testcase = \ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) -a \ -f $(top_srcdir)/Examples/test-suite/$*.list ] ; then ( \ $(COMPILETOOL) $(OCAMLC) -c $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ - $(COMPILETOOL) $(OCAMLC) swig.cmo -custom -g -cc '$(CXX)' -o runme `cat $(top_srcdir)/Examples/test-suite/$(*).list | sed -e 's/\(.*\)/\1_wrap.o \1.cmo/g'`&& ./runme) ; \ + $(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 && \ diff --git a/Examples/test-suite/typemap_namespace.i b/Examples/test-suite/typemap_namespace.i index 91349a2a5..b3fa1a733 100644 --- a/Examples/test-suite/typemap_namespace.i +++ b/Examples/test-suite/typemap_namespace.i @@ -27,7 +27,7 @@ namespace Foo { %typemap(javaout) Str1 * = char *; #endif %typemap(in) Str1 * = char *; -#if !(defined(SWIGCSHARP) || defined(SWIGLUA) || defined(SWIGPHP) || defined(SWIGMZSCHEME)) +#if !(defined(SWIGCSHARP) || defined(SWIGLUA) || defined(SWIGPHP) || defined(SWIGMZSCHEME) || defined(SWIGOCAML)) %typemap(freearg) Str1 * = char *; #endif %typemap(typecheck) Str1 * = char *; diff --git a/Lib/ocaml/std_deque.i b/Lib/ocaml/std_deque.i index 44815ebda..baadb4e53 100644 --- a/Lib/ocaml/std_deque.i +++ b/Lib/ocaml/std_deque.i @@ -28,4 +28,4 @@ } }; -%include <_std_deque.i> +%include From efa11dee52ae8568993f5273b02d24b6b146816e Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 20 Feb 2009 07:52:24 +0000 Subject: [PATCH 0340/1680] add new %begin directive for inserting code at top of wrapper file git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11133 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 6 ++++ Doc/Manual/Allegrocl.html | 4 +-- Doc/Manual/Extending.html | 7 ++-- Doc/Manual/Lisp.html | 4 +-- Doc/Manual/SWIG.html | 11 +++++-- Examples/test-suite/common.mk | 1 + Examples/test-suite/insert_directive.i | 38 ++++++++++++++++++++++ Lib/swig.swg | 7 ++-- Source/Modules/allegrocl.cxx | 18 +++++++---- Source/Modules/cffi.cxx | 16 +++++++--- Source/Modules/chicken.cxx | 20 ++++++++---- Source/Modules/clisp.cxx | 1 + Source/Modules/csharp.cxx | 24 +++++++++----- Source/Modules/guile.cxx | 20 ++++++++---- Source/Modules/java.cxx | 17 +++++++--- Source/Modules/lua.cxx | 25 +++++++++------ Source/Modules/main.cxx | 1 + Source/Modules/modula3.cxx | 21 ++++++++---- Source/Modules/mzscheme.cxx | 20 ++++++++---- Source/Modules/ocaml.cxx | 20 ++++++++---- Source/Modules/octave.cxx | 30 +++++++++++------- Source/Modules/perl5.cxx | 20 ++++++++---- Source/Modules/php.cxx | 24 +++++++++----- Source/Modules/pike.cxx | 21 ++++++++---- Source/Modules/python.cxx | 36 ++++++++++++--------- Source/Modules/r.cxx | 17 +++++----- Source/Modules/ruby.cxx | 44 +++++++++++++++----------- Source/Modules/s-exp.cxx | 1 + Source/Modules/tcl8.cxx | 19 +++++++---- Source/Modules/uffi.cxx | 1 + Source/Swig/misc.c | 2 +- 31 files changed, 334 insertions(+), 162 deletions(-) create mode 100644 Examples/test-suite/insert_directive.i diff --git a/CHANGES.current b/CHANGES.current index d7d16a79b..9c1c2ae83 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,12 @@ Version 1.3.39 (in progress) ============================ +2008-02-20: wsfulton + New %insert("begin") section added. Also can be used as %begin. This is a new + code section reserved entirely for users and the code within the section is generated + at the top of the C/C++ wrapper file and so provides a means to put custom code + into the wrapper file before anything else that SWIG generates. + 2008-02-17: wsfulton 'make clean-test-suite' will now run clean on ALL languages. Previously it only ran the correctly configured languages. This way it is now possible to clean up diff --git a/Doc/Manual/Allegrocl.html b/Doc/Manual/Allegrocl.html index 41309c9b4..cc950db7c 100644 --- a/Doc/Manual/Allegrocl.html +++ b/Doc/Manual/Allegrocl.html @@ -411,7 +411,7 @@ using the SWIG %insert(section) %{ ...code... %} directive:
         %module example
         
        -%insert("runtime") %{
        +%{
         #include "header.h"
         %}
         
        @@ -432,7 +432,7 @@ generated lisp interface file
         

      Note that the block %{ ... %} is effectively a shortcut for -%insert("runtime") %{ ... %}. +%insert("header") %{ ... %}.

      diff --git a/Doc/Manual/Extending.html b/Doc/Manual/Extending.html index 5c9a439f8..73f1a6673 100644 --- a/Doc/Manual/Extending.html +++ b/Doc/Manual/Extending.html @@ -232,10 +232,11 @@ of swig.swg looks like this: ... /* Code insertion directives such as %wrapper %{ ... %} */ -#define %init %insert("init") -#define %wrapper %insert("wrapper") -#define %header %insert("header") +#define %begin %insert("begin") #define %runtime %insert("runtime") +#define %header %insert("header") +#define %wrapper %insert("wrapper") +#define %init %insert("init") /* Access control directives */ diff --git a/Doc/Manual/Lisp.html b/Doc/Manual/Lisp.html index 14abead00..53cddab83 100644 --- a/Doc/Manual/Lisp.html +++ b/Doc/Manual/Lisp.html @@ -583,7 +583,7 @@ using the SWIG %insert(section) %{ ...code... %} directive:
       %module example
       
      -%insert("runtime") %{
      +%{
       #include "header.h"
       %}
       
      @@ -604,7 +604,7 @@ generated lisp interface file:
       
       

      Note that the block %{ ... %} is effectively a shortcut for -%insert("runtime") %{ ... %}. +%insert("header") %{ ... %}.

      diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html index 1c8d74f8c..11cd4f66e 100644 --- a/Doc/Manual/SWIG.html +++ b/Doc/Manual/SWIG.html @@ -2737,11 +2737,16 @@ the module upon loading.

      Code is inserted into the appropriate code section by using one -of the following code insertion directives: +of the code insertion directives listed below. The order of the sections in +the wrapper file is as shown:

      +%begin %{
      +   ... code in begin section ...
      +%}
      +
       %runtime %{
          ... code in runtime section ...
       %}
      @@ -2762,10 +2767,12 @@ of the following code insertion directives:
       
       

      The bare %{ ... %} directive is a shortcut that is the same as -%header %{ ... %}. +%header %{ ... %}.

      +The %begin section is empty by default +and is provided as a way for users to insert code at the top of the wrapper file. Everything in a code insertion block is copied verbatim into the output file and is not parsed by SWIG. Most SWIG input files have at least one such block to include header files and support C code. Additional code blocks may be placed anywhere in a diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 1d43f14ca..afcb87159 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -206,6 +206,7 @@ CPP_TEST_CASES += \ inherit_target_language \ inherit_void_arg \ inline_initializer \ + insert_directive \ keyword_rename \ kind \ langobj \ diff --git a/Examples/test-suite/insert_directive.i b/Examples/test-suite/insert_directive.i new file mode 100644 index 000000000..8ad966a99 --- /dev/null +++ b/Examples/test-suite/insert_directive.i @@ -0,0 +1,38 @@ +%module insert_directive + +// check %insert and the order of each insert section is correct + +%begin %{ +// %inserted code %begin +int inserted_begin(int i) { return i; } +%} + +%runtime %{ +// %inserted code %runtime +int inserted_runtime(int i) { return inserted_begin(i); } +%} + +%{ +// %inserted code %header +int inserted_header1(int i) { return inserted_runtime(i); } +%} + +%header %{ +// %inserted code %header +int inserted_header2(int i) { return inserted_header1(i); } +%} + +%{ +// %inserted code %header +int inserted_header3(int i) { return inserted_header2(i); } +%} + +%wrapper %{ +// %inserted code %wrapper +int inserted_wrapper(int i) { return inserted_header3(i); } +%} + +%init %{ +// %inserted code %init +int inserted_init_value = inserted_wrapper(0); +%} diff --git a/Lib/swig.swg b/Lib/swig.swg index e096f8492..77308e080 100644 --- a/Lib/swig.swg +++ b/Lib/swig.swg @@ -25,10 +25,11 @@ /* Code insertion directives such as %wrapper %{ ... %} */ -#define %init %insert("init") -#define %wrapper %insert("wrapper") -#define %header %insert("header") +#define %begin %insert("begin") #define %runtime %insert("runtime") +#define %header %insert("header") +#define %wrapper %insert("wrapper") +#define %init %insert("init") /* Class extension */ diff --git a/Source/Modules/allegrocl.cxx b/Source/Modules/allegrocl.cxx index d21be9364..4799d31db 100644 --- a/Source/Modules/allegrocl.cxx +++ b/Source/Modules/allegrocl.cxx @@ -21,6 +21,7 @@ char cvsroot_allegrocl_cxx[] = "$Id$"; static File *f_cl = 0; String *f_clhead = NewString(""); String *f_clwrap = NewString("(swig-in-package ())\n\n"); +static File *f_begin; static File *f_runtime; static File *f_cxx_header = 0; static File *f_cxx_wrapper = 0; @@ -1598,27 +1599,30 @@ int ALLEGROCL::top(Node *n) { Generate_Wrapper = CPlusPlus || CWrap; if (Generate_Wrapper) { - f_runtime = NewFile(cxx_filename, "w", SWIG_output_files()); - if (!f_runtime) { + f_begin = NewFile(cxx_filename, "w", SWIG_output_files()); + if (!f_begin) { Close(f_cl); Delete(f_cl); Printf(stderr, "Unable to open %s for writing\n", cxx_filename); SWIG_exit(EXIT_FAILURE); } } else - f_runtime = NewString(""); + f_begin = NewString(""); + f_runtime = NewString(""); f_cxx_header = f_runtime; f_cxx_wrapper = NewString(""); Swig_register_filebyname("header", f_cxx_header); Swig_register_filebyname("wrapper", f_cxx_wrapper); + Swig_register_filebyname("begin", f_begin); Swig_register_filebyname("runtime", f_runtime); Swig_register_filebyname("lisp", f_clwrap); Swig_register_filebyname("lisphead", f_cl); - Swig_banner(f_runtime); + Swig_banner(f_begin); + Printf(f_runtime, "\n"); Printf(f_runtime, "#define SWIGALLEGROCL\n"); Printf(f_runtime, "\n"); @@ -1664,10 +1668,12 @@ int ALLEGROCL::top(Node *n) { Delete(f_clhead); Delete(f_clwrap); - Printf(f_runtime, "%s\n", f_cxx_wrapper); + Dump(f_runtime, f_begin); + Printf(f_begin, "%s\n", f_cxx_wrapper); - Close(f_runtime); + Close(f_begin); Delete(f_runtime); + Delete(f_begin); Delete(f_cxx_wrapper); // Swig_print_tree(n); diff --git a/Source/Modules/cffi.cxx b/Source/Modules/cffi.cxx index 38c9c574f..a26e2b5d2 100644 --- a/Source/Modules/cffi.cxx +++ b/Source/Modules/cffi.cxx @@ -22,6 +22,7 @@ public: String *f_clhead; String *f_clwrap; bool CWrap; // generate wrapper file for C code? + File *f_begin; File *f_runtime; File *f_cxx_header; File *f_cxx_wrapper; @@ -127,8 +128,8 @@ int CFFI::top(Node *n) { } if (CPlusPlus || CWrap) { - f_runtime = NewFile(cxx_filename, "w", SWIG_output_files()); - if (!f_runtime) { + f_begin = NewFile(cxx_filename, "w", SWIG_output_files()); + if (!f_begin) { Close(f_lisp); Delete(f_lisp); Printf(stderr, "Unable to open %s for writing\n", cxx_filename); @@ -145,15 +146,17 @@ int CFFI::top(Node *n) { SWIG_exit(EXIT_FAILURE); } } else { - f_runtime = NewString(""); + f_begin = NewString(""); f_clos = NewString(""); } + f_runtime = NewString(""); f_cxx_header = f_runtime; f_cxx_wrapper = NewString(""); Swig_register_filebyname("header", f_cxx_header); Swig_register_filebyname("wrapper", f_cxx_wrapper); + Swig_register_filebyname("begin", f_begin); Swig_register_filebyname("runtime", f_runtime); Swig_register_filebyname("lisphead", f_clhead); if (!no_swig_lisp) @@ -161,8 +164,9 @@ int CFFI::top(Node *n) { else Swig_register_filebyname("swiglisp", f_null); - Swig_banner(f_runtime); + Swig_banner(f_begin); + Printf(f_runtime, "\n"); Printf(f_runtime, "#define SWIGCFFI\n"); Printf(f_runtime, "\n"); @@ -178,8 +182,10 @@ int CFFI::top(Node *n) { Delete(f_cl); Delete(f_clhead); Delete(f_clwrap); - Close(f_runtime); + Dump(f_runtime, f_begin); + Close(f_begin); Delete(f_runtime); + Delete(f_begin); Delete(f_cxx_wrapper); Delete(f_null); diff --git a/Source/Modules/chicken.cxx b/Source/Modules/chicken.cxx index d32fabb9e..12ef4b454 100644 --- a/Source/Modules/chicken.cxx +++ b/Source/Modules/chicken.cxx @@ -30,6 +30,7 @@ static char *module = 0; static char *chicken_path = (char *) "chicken"; static int num_methods = 0; +static File *f_begin = 0; static File *f_runtime = 0; static File *f_header = 0; static File *f_wrappers = 0; @@ -188,11 +189,12 @@ int CHICKEN::top(Node *n) { /* Initialize all of the output files */ String *outfile = Getattr(n, "outfile"); - f_runtime = NewFile(outfile, "w", SWIG_output_files()); - 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(""); @@ -205,6 +207,7 @@ int CHICKEN::top(Node *n) { /* Register file targets with the SWIG file handler */ Swig_register_filebyname("header", f_header); Swig_register_filebyname("wrapper", f_wrappers); + Swig_register_filebyname("begin", f_begin); Swig_register_filebyname("runtime", f_runtime); Swig_register_filebyname("init", f_init); @@ -215,8 +218,9 @@ int CHICKEN::top(Node *n) { clos_methods = NewString(""); scm_const_defs = NewString(""); - Swig_banner(f_runtime); + Swig_banner(f_begin); + Printf(f_runtime, "\n"); Printf(f_runtime, "#define SWIGCHICKEN\n"); if (no_collection) @@ -308,15 +312,17 @@ int CHICKEN::top(Node *n) { /* Close all of the files */ Delete(primitive_names); Delete(scmmodule); - 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); Delete(f_header); Delete(f_wrappers); Delete(f_sym_size); Delete(f_init); - Close(f_runtime); + Close(f_begin); Delete(f_runtime); + Delete(f_begin); return SWIG_OK; } diff --git a/Source/Modules/clisp.cxx b/Source/Modules/clisp.cxx index 276919627..fa73b3a0b 100644 --- a/Source/Modules/clisp.cxx +++ b/Source/Modules/clisp.cxx @@ -87,6 +87,7 @@ int CLISP::top(Node *n) { } Swig_register_filebyname("header", f_null); + Swig_register_filebyname("begin", f_null); Swig_register_filebyname("runtime", f_null); Swig_register_filebyname("wrapper", f_null); diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index ca2e23df5..2730b55d4 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -24,6 +24,7 @@ class CSHARP:public Language { const String *protected_string; Hash *swig_types_hash; + File *f_begin; File *f_runtime; File *f_runtime_h; File *f_header; @@ -102,6 +103,7 @@ public: public_string(NewString("public")), protected_string(NewString("protected")), swig_types_hash(NULL), + f_begin(NULL), f_runtime(NULL), f_runtime_h(NULL), f_header(NULL), @@ -286,8 +288,8 @@ public: SWIG_exit(EXIT_FAILURE); } - f_runtime = NewFile(outfile, "w", SWIG_output_files()); - if (!f_runtime) { + f_begin = NewFile(outfile, "w", SWIG_output_files()); + if (!f_begin) { FileErrorDisplay(outfile); SWIG_exit(EXIT_FAILURE); } @@ -304,6 +306,7 @@ public: } } + f_runtime = NewString(""); f_init = NewString(""); f_header = NewString(""); f_wrappers = NewString(""); @@ -313,6 +316,7 @@ public: /* Register file targets with the SWIG file handler */ Swig_register_filebyname("header", f_header); Swig_register_filebyname("wrapper", f_wrappers); + Swig_register_filebyname("begin", f_begin); Swig_register_filebyname("runtime", f_runtime); Swig_register_filebyname("init", f_init); Swig_register_filebyname("director", f_directors); @@ -358,8 +362,9 @@ public: if (!dllimport) dllimport = Copy(module_class_name); - Swig_banner(f_runtime); // Print the SWIG banner message + Swig_banner(f_begin); + Printf(f_runtime, "\n"); Printf(f_runtime, "#define SWIGCSHARP\n"); if (directorsEnabled()) { @@ -367,6 +372,7 @@ public: /* Emit initial director header and director code: */ Swig_banner(f_directors_h); + Printf(f_directors_h, "\n"); Printf(f_directors_h, "#ifndef SWIG_%s_WRAP_H_\n", module_class_name); Printf(f_directors_h, "#define SWIG_%s_WRAP_H_\n\n", module_class_name); @@ -571,10 +577,11 @@ public: n_dmethods = 0; /* Close all of the files */ - Dump(f_header, f_runtime); + Dump(f_runtime, f_begin); + Dump(f_header, f_begin); if (directorsEnabled()) { - Dump(f_directors, f_runtime); + Dump(f_directors, f_begin); Dump(f_directors_h, f_runtime_h); Printf(f_runtime_h, "\n"); @@ -589,13 +596,14 @@ public: f_directors_h = NULL; } - Dump(f_wrappers, f_runtime); - Wrapper_pretty_print(f_init, f_runtime); + Dump(f_wrappers, f_begin); + Wrapper_pretty_print(f_init, f_begin); Delete(f_header); Delete(f_wrappers); Delete(f_init); - Close(f_runtime); + Close(f_begin); Delete(f_runtime); + Delete(f_begin); return SWIG_OK; } diff --git a/Source/Modules/guile.cxx b/Source/Modules/guile.cxx index e3bf2f017..0c72de8d0 100644 --- a/Source/Modules/guile.cxx +++ b/Source/Modules/guile.cxx @@ -47,6 +47,7 @@ Guile Options (available with -guile)\n\ -exportprimitive - Add the (export ...) code from scmstub into the\n\ GOOPS file.\n"; +static File *f_begin = 0; static File *f_runtime = 0; static File *f_header = 0; static File *f_wrappers = 0; @@ -299,11 +300,12 @@ public: /* Initialize all of the output files */ String *outfile = Getattr(n, "outfile"); - f_runtime = NewFile(outfile, "w", SWIG_output_files()); - 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(""); @@ -311,6 +313,7 @@ public: /* Register file targets with the SWIG file handler */ Swig_register_filebyname("header", f_header); Swig_register_filebyname("wrapper", f_wrappers); + Swig_register_filebyname("begin", f_begin); Swig_register_filebyname("runtime", f_runtime); Swig_register_filebyname("init", f_init); @@ -322,8 +325,9 @@ public: goopscode = NewString(""); goopsexport = NewString(""); - Swig_banner(f_runtime); + Swig_banner(f_begin); + Printf(f_runtime, "\n"); Printf(f_runtime, "#define SWIGGUILE\n"); if (!use_scm_interface) { @@ -393,14 +397,16 @@ public: Delete(goopstext); /* Close all of the files */ - 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); Delete(f_header); Delete(f_wrappers); Delete(f_init); - Close(f_runtime); + Close(f_begin); Delete(f_runtime); + Delete(f_begin); return SWIG_OK; } diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index 48cf66444..8dfa19624 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -24,6 +24,7 @@ class JAVA:public Language { const String *protected_string; Hash *swig_types_hash; + File *f_begin; File *f_runtime; File *f_runtime_h; File *f_header; @@ -99,6 +100,7 @@ public: public_string(NewString("public")), protected_string(NewString("protected")), swig_types_hash(NULL), + f_begin(NULL), f_runtime(NULL), f_runtime_h(NULL), f_header(NULL), @@ -295,8 +297,8 @@ public: SWIG_exit(EXIT_FAILURE); } - f_runtime = NewFile(outfile, "w", SWIG_output_files()); - if (!f_runtime) { + f_begin = NewFile(outfile, "w", SWIG_output_files()); + if (!f_begin) { FileErrorDisplay(outfile); SWIG_exit(EXIT_FAILURE); } @@ -313,6 +315,7 @@ public: } } + f_runtime = NewString(""); f_init = NewString(""); f_header = NewString(""); f_wrappers = NewString(""); @@ -320,6 +323,7 @@ public: f_directors = NewString(""); /* Register file targets with the SWIG file handler */ + Swig_register_filebyname("begin", f_begin); Swig_register_filebyname("header", f_header); Swig_register_filebyname("wrapper", f_wrappers); Swig_register_filebyname("runtime", f_runtime); @@ -367,15 +371,16 @@ public: jnipackage = NewString(""); package_path = NewString(""); - Swig_banner(f_runtime); // Print the SWIG banner message + Swig_banner(f_begin); - Printf(f_runtime, "#define SWIGJAVA\n"); + Printf(f_runtime, "\n#define SWIGJAVA\n"); if (directorsEnabled()) { Printf(f_runtime, "#define SWIG_DIRECTORS\n"); /* Emit initial director header and director code: */ Swig_banner(f_directors_h); + Printf(f_directors_h, "\n"); Printf(f_directors_h, "#ifndef SWIG_%s_WRAP_H_\n", module_class_name); Printf(f_directors_h, "#define SWIG_%s_WRAP_H_\n\n", module_class_name); @@ -666,8 +671,10 @@ public: Delete(f_header); Delete(f_wrappers); Delete(f_init); - Close(f_runtime); + Dump(f_runtime, f_begin); Delete(f_runtime); + Close(f_begin); + Delete(f_begin); return SWIG_OK; } diff --git a/Source/Modules/lua.cxx b/Source/Modules/lua.cxx index c615bfa9a..78cd7ce96 100644 --- a/Source/Modules/lua.cxx +++ b/Source/Modules/lua.cxx @@ -92,6 +92,7 @@ NEW LANGUAGE NOTE:END ************************************************/ class LUA:public Language { private: + File *f_begin; File *f_runtime; File *f_header; File *f_wrappers; @@ -132,6 +133,7 @@ public: * --------------------------------------------------------------------- */ LUA() { + f_begin = 0; f_runtime = 0; f_header = 0; f_wrappers = 0; @@ -213,11 +215,12 @@ public: String *outfile = Getattr(n, "outfile"); /* Open the output file */ - f_runtime = NewFile(outfile, "w", SWIG_output_files()); - 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(""); @@ -226,6 +229,7 @@ public: /* Register file targets with the SWIG file handler */ Swig_register_filebyname("header", f_header); Swig_register_filebyname("wrapper", f_wrappers); + Swig_register_filebyname("begin", f_begin); Swig_register_filebyname("runtime", f_runtime); Swig_register_filebyname("init", f_init); Swig_register_filebyname("initbeforefunc", f_initbeforefunc); @@ -249,8 +253,9 @@ public: current=NO_CPP; /* Standard stuff for the SWIG runtime section */ - Swig_banner(f_runtime); + Swig_banner(f_begin); + Printf(f_runtime, "\n"); Printf(f_runtime, "#define SWIGLUA\n"); // if (NoInclude) { @@ -293,13 +298,14 @@ public: this basically combines several of the strings together and then writes it all to a file NEW LANGUAGE NOTE:END ************************************************/ - Dump(f_header, f_runtime); - Dump(f_wrappers, f_runtime); - Dump(f_initbeforefunc, f_runtime); + Dump(f_runtime, f_begin); + Dump(f_header, f_begin); + Dump(f_wrappers, f_begin); + Dump(f_initbeforefunc, f_begin); /* for the Lua code it needs to be properly excaped to be added into the C/C++ code */ EscapeCode(s_luacode); - Printf(f_runtime, "const char* SWIG_LUACODE=\n \"%s\";\n\n",s_luacode); - Wrapper_pretty_print(f_init, f_runtime); + Printf(f_begin, "const char* SWIG_LUACODE=\n \"%s\";\n\n",s_luacode); + Wrapper_pretty_print(f_init, f_begin); /* Close all of the files */ Delete(s_luacode); Delete(s_cmd_tab); @@ -309,8 +315,9 @@ public: Delete(f_wrappers); Delete(f_init); Delete(f_initbeforefunc); - Close(f_runtime); + Close(f_begin); Delete(f_runtime); + Delete(f_begin); /* Done */ return SWIG_OK; diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx index b645e883f..4603ac339 100644 --- a/Source/Modules/main.cxx +++ b/Source/Modules/main.cxx @@ -379,6 +379,7 @@ static void SWIG_dump_runtime() { } Swig_banner(runtime); + Printf(runtime, "\n"); s = Swig_include_sys("swiglabels.swg"); if (!s) { diff --git a/Source/Modules/modula3.cxx b/Source/Modules/modula3.cxx index 982d6224d..df44ab94a 100644 --- a/Source/Modules/modula3.cxx +++ b/Source/Modules/modula3.cxx @@ -172,6 +172,7 @@ private: const String *empty_string; Hash *swig_types_hash; + File *f_begin; File *f_runtime; File *f_header; File *f_wrappers; @@ -237,6 +238,7 @@ public: MODULA3(): empty_string(NewString("")), swig_types_hash(NULL), + f_begin(NULL), f_runtime(NULL), f_header(NULL), f_wrappers(NULL), @@ -902,11 +904,12 @@ MODULA3(): /* Initialize all of the output files */ outfile = Getattr(n, "outfile"); - f_runtime = NewFile(outfile, "w", SWIG_output_files()); - 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(""); @@ -916,6 +919,7 @@ MODULA3(): /* Register file targets with the SWIG file handler */ Swig_register_filebyname("header", f_header); Swig_register_filebyname("wrapper", f_wrappers); + Swig_register_filebyname("begin", f_begin); Swig_register_filebyname("runtime", f_runtime); Swig_register_filebyname("init", f_init); @@ -956,8 +960,9 @@ MODULA3(): module_imports = NewString(""); upcasts_code = NewString(""); - Swig_banner(f_runtime); // Print the SWIG banner message + Swig_banner(f_begin); + Printf(f_runtime, "\n"); Printf(f_runtime, "#define SWIGMODULA3\n"); Printf(f_runtime, "\n"); @@ -1146,14 +1151,16 @@ MODULA3(): typemapfilename = NULL; /* Close all of the files */ - 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); Delete(f_header); Delete(f_wrappers); Delete(f_init); - Close(f_runtime); + Close(f_begin); Delete(f_runtime); + Delete(f_begin); return SWIG_OK; } diff --git a/Source/Modules/mzscheme.cxx b/Source/Modules/mzscheme.cxx index 99f1024ff..28dd8ecd2 100644 --- a/Source/Modules/mzscheme.cxx +++ b/Source/Modules/mzscheme.cxx @@ -39,6 +39,7 @@ static String *module = 0; static char *mzscheme_path = (char *) "mzscheme"; static String *init_func_def = 0; +static File *f_begin = 0; static File *f_runtime = 0; static File *f_header = 0; static File *f_wrappers = 0; @@ -129,11 +130,12 @@ public: /* Initialize all of the output files */ String *outfile = Getattr(n, "outfile"); - f_runtime = NewFile(outfile, "w", SWIG_output_files()); - 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(""); @@ -141,13 +143,15 @@ public: /* Register file targets with the SWIG file handler */ Swig_register_filebyname("header", f_header); Swig_register_filebyname("wrapper", f_wrappers); + Swig_register_filebyname("begin", f_begin); Swig_register_filebyname("runtime", f_runtime); init_func_def = NewString(""); Swig_register_filebyname("init", init_func_def); - Swig_banner(f_runtime); + Swig_banner(f_begin); + Printf(f_runtime, "\n"); Printf(f_runtime, "#define SWIGMZSCHEME\n"); Printf(f_runtime, "\n"); @@ -188,14 +192,16 @@ public: } /* Close all of the files */ - 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); Delete(f_header); Delete(f_wrappers); Delete(f_init); - Close(f_runtime); + Close(f_begin); Delete(f_runtime); + Delete(f_begin); return SWIG_OK; } diff --git a/Source/Modules/ocaml.cxx b/Source/Modules/ocaml.cxx index 022611502..b925328a3 100644 --- a/Source/Modules/ocaml.cxx +++ b/Source/Modules/ocaml.cxx @@ -38,6 +38,7 @@ static Hash *seen_enumvalues = 0; static Hash *seen_constructors = 0; static File *f_header = 0; +static File *f_begin = 0; static File *f_runtime = 0; static File *f_wrappers = 0; static File *f_directors = 0; @@ -214,11 +215,12 @@ public: /* Initialize all of the output files */ String *outfile = Getattr(n, "outfile"); - f_runtime = NewFile(outfile, "w", SWIG_output_files()); - 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(""); @@ -247,6 +249,7 @@ public: Swig_register_filebyname("init", init_func_def); Swig_register_filebyname("header", f_header); Swig_register_filebyname("wrapper", f_wrappers); + Swig_register_filebyname("begin", f_begin); Swig_register_filebyname("runtime", f_runtime); Swig_register_filebyname("mli", f_mlibody); Swig_register_filebyname("ml", f_mlbody); @@ -262,8 +265,9 @@ public: Swig_name_register("get", "%v__get__"); } - Swig_banner(f_runtime); + Swig_banner(f_begin); + Printf(f_runtime, "\n"); Printf(f_runtime, "#define SWIGOCAML\n"); Printf(f_runtime, "#define SWIG_MODULE \"%s\"\n", module); /* Module name */ @@ -324,16 +328,18 @@ public: SwigType_emit_type_table(f_runtime, f_wrappers); /* Close all of the files */ + Dump(f_runtime, f_begin); Dump(f_directors_h, f_header); - Dump(f_header, f_runtime); + Dump(f_header, f_begin); Dump(f_directors, f_wrappers); - Dump(f_wrappers, f_runtime); - Wrapper_pretty_print(f_init, f_runtime); + Dump(f_wrappers, f_begin); + Wrapper_pretty_print(f_init, f_begin); Delete(f_header); Delete(f_wrappers); Delete(f_init); - Close(f_runtime); + Close(f_begin); Delete(f_runtime); + Delete(f_begin); Dump(f_enumtypes_type, f_mlout); Dump(f_enumtypes_value, f_mlout); diff --git a/Source/Modules/octave.cxx b/Source/Modules/octave.cxx index c9febcbba..39b61e93b 100644 --- a/Source/Modules/octave.cxx +++ b/Source/Modules/octave.cxx @@ -18,6 +18,7 @@ Octave Options (available with -octave)\n\ class OCTAVE:public Language { private: + File *f_begin; File *f_runtime; File *f_header; File *f_doc; @@ -37,7 +38,7 @@ private: Hash *docs; public: - OCTAVE():f_runtime(0), f_header(0), f_doc(0), f_wrappers(0), + OCTAVE():f_begin(0), f_runtime(0), f_header(0), f_doc(0), f_wrappers(0), f_init(0), f_initbeforefunc(0), f_directors(0), f_directors_h(0), s_global_tab(0), s_members_tab(0), class_name(0) { /* Add code to manage protected constructors and directors */ @@ -94,11 +95,12 @@ public: String *module = Getattr(n, "name"); String *outfile = Getattr(n, "outfile"); - f_runtime = NewFile(outfile, "w", SWIG_output_files()); - if (!f_runtime) { + f_begin = NewFile(outfile, "w", SWIG_output_files()); + if (!f_begin) { FileErrorDisplay(outfile); SWIG_exit(EXIT_FAILURE); } + f_runtime = NewString(""); f_header = NewString(""); f_doc = NewString(""); f_wrappers = NewString(""); @@ -107,6 +109,7 @@ public: f_directors_h = NewString(""); f_directors = NewString(""); s_global_tab = NewString(""); + Swig_register_filebyname("begin", f_begin); Swig_register_filebyname("runtime", f_runtime); Swig_register_filebyname("header", f_header); Swig_register_filebyname("doc", f_doc); @@ -116,8 +119,9 @@ public: Swig_register_filebyname("director", f_directors); Swig_register_filebyname("director_h", f_directors_h); - Swig_banner(f_runtime); + Swig_banner(f_begin); + Printf(f_runtime, "\n"); Printf(f_runtime, "#define SWIGOCTAVE\n"); Printf(f_runtime, "#define SWIG_name_d \"%s\"\n", module); Printf(f_runtime, "#define SWIG_name %s\n", module); @@ -155,15 +159,16 @@ public: Printv(f_wrappers, s_global_tab, NIL); SwigType_emit_type_table(f_runtime, f_wrappers); - Dump(f_header, f_runtime); - Dump(f_doc, f_runtime); + Dump(f_runtime, f_begin); + Dump(f_header, f_begin); + Dump(f_doc, f_begin); if (directorsEnabled()) { - Dump(f_directors_h, f_runtime); - Dump(f_directors, f_runtime); + Dump(f_directors_h, f_begin); + Dump(f_directors, f_begin); } - Dump(f_wrappers, f_runtime); - Dump(f_initbeforefunc, f_runtime); - Wrapper_pretty_print(f_init, f_runtime); + Dump(f_wrappers, f_begin); + Dump(f_initbeforefunc, f_begin); + Wrapper_pretty_print(f_init, f_begin); Delete(s_global_tab); Delete(f_initbeforefunc); @@ -173,8 +178,9 @@ public: Delete(f_header); Delete(f_directors); Delete(f_directors_h); - Close(f_runtime); + Close(f_begin); Delete(f_runtime); + Delete(f_begin); return SWIG_OK; } diff --git a/Source/Modules/perl5.cxx b/Source/Modules/perl5.cxx index e454f5050..eace179a7 100644 --- a/Source/Modules/perl5.cxx +++ b/Source/Modules/perl5.cxx @@ -78,6 +78,7 @@ static String *command_tab = 0; static String *constant_tab = 0; static String *variable_tab = 0; +static File *f_begin = 0; static File *f_runtime = 0; static File *f_header = 0; static File *f_wrappers = 0; @@ -223,11 +224,12 @@ public: /* Initialize all of the output files */ String *outfile = Getattr(n, "outfile"); - f_runtime = NewFile(outfile, "w", SWIG_output_files()); - 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(""); @@ -235,6 +237,7 @@ public: /* Register file targets with the SWIG file handler */ Swig_register_filebyname("header", f_header); Swig_register_filebyname("wrapper", f_wrappers); + Swig_register_filebyname("begin", f_begin); Swig_register_filebyname("runtime", f_runtime); Swig_register_filebyname("init", f_init); @@ -253,8 +256,9 @@ public: constant_tab = NewString("static swig_constant_info swig_constants[] = {\n"); variable_tab = NewString("static swig_variable_info swig_variables[] = {\n"); - Swig_banner(f_runtime); + Swig_banner(f_begin); + Printf(f_runtime, "\n"); Printf(f_runtime, "#define SWIGPERL\n"); Printf(f_runtime, "#define SWIG_CASTRANK_MODE\n"); Printf(f_runtime, "\n"); @@ -522,14 +526,16 @@ public: Delete(underscore_module); /* Close all of the files */ - 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); Delete(f_header); Delete(f_wrappers); Delete(f_init); - Close(f_runtime); + Close(f_begin); Delete(f_runtime); + Delete(f_begin); return SWIG_OK; } diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index 0a0e6d6d4..ee69c1864 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -71,6 +71,7 @@ static String *prefix = 0; static String *shadow_classname = 0; +static File *f_begin = 0; static File *f_runtime = 0; static File *f_h = 0; static File *f_phpcode = 0; @@ -259,11 +260,12 @@ public: String *outfile = Getattr(n, "outfile"); /* main output file */ - f_runtime = NewFile(outfile, "w", SWIG_output_files()); - if (!f_runtime) { + f_begin = NewFile(outfile, "w", SWIG_output_files()); + if (!f_begin) { FileErrorDisplay(outfile); SWIG_exit(EXIT_FAILURE); } + f_runtime = NewString(""); /* sections of the output file */ s_init = NewString("/* init section */\n"); @@ -282,6 +284,7 @@ public: s_phpclasses = NewString("/* PHP Proxy Classes */\n"); /* Register file targets with the SWIG file handler */ + Swig_register_filebyname("begin", f_begin); Swig_register_filebyname("runtime", f_runtime); Swig_register_filebyname("init", s_init); Swig_register_filebyname("rinit", r_init); @@ -290,8 +293,9 @@ public: Swig_register_filebyname("header", s_header); Swig_register_filebyname("wrapper", s_wrappers); - Swig_banner(f_runtime); + Swig_banner(f_begin); + Printf(f_runtime, "\n"); Printf(f_runtime, "#define SWIGPHP\n"); Printf(f_runtime, "\n"); @@ -316,6 +320,7 @@ public: Swig_banner(f_phpcode); + 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 (strtolower(substr(PHP_OS, 0, 3)) === 'win') {\n"); @@ -393,7 +398,7 @@ public: Swig_banner(f_h); - Printf(f_h, "\n\n"); + Printf(f_h, "\n"); Printf(f_h, "#ifndef PHP_%s_H\n", cap_module); Printf(f_h, "#define PHP_%s_H\n\n", cap_module); Printf(f_h, "extern zend_module_entry %s_module_entry;\n", module); @@ -522,16 +527,19 @@ public: Printf(s_wrappers, "/* end wrapper section */\n"); Printf(s_vdecl, "/* end vdecl subsection */\n"); - Printv(f_runtime, s_header, s_vdecl, s_wrappers, NIL); - Printv(f_runtime, all_cs_entry, "\n\n", s_entry, "{NULL, NULL, NULL}\n};\n\n", NIL); - Printv(f_runtime, s_init, NIL); + 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_init, NIL); Delete(s_header); Delete(s_wrappers); Delete(s_init); Delete(s_vdecl); Delete(all_cs_entry); Delete(s_entry); - Close(f_runtime); + Close(f_begin); + Delete(f_runtime); + Delete(f_begin); Printf(f_phpcode, "%s\n%s\n", pragma_incl, pragma_code); if (s_fakeoowrappers) { diff --git a/Source/Modules/pike.cxx b/Source/Modules/pike.cxx index 800c8f74c..98f63056c 100644 --- a/Source/Modules/pike.cxx +++ b/Source/Modules/pike.cxx @@ -39,6 +39,7 @@ Pike Options (available with -pike)\n\ class PIKE:public Language { private: + File *f_begin; File *f_runtime; File *f_header; File *f_wrappers; @@ -69,6 +70,7 @@ public: * --------------------------------------------------------------------- */ PIKE() { + f_begin = 0; f_runtime = 0; f_header = 0; f_wrappers = 0; @@ -123,11 +125,12 @@ public: String *outfile = Getattr(n, "outfile"); /* Open the output file */ - f_runtime = NewFile(outfile, "w", SWIG_output_files()); - 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_classInit = NewString(""); f_header = NewString(""); @@ -136,13 +139,15 @@ public: /* Register file targets with the SWIG file handler */ Swig_register_filebyname("header", f_header); Swig_register_filebyname("wrapper", f_wrappers); + Swig_register_filebyname("begin", f_begin); Swig_register_filebyname("runtime", f_runtime); Swig_register_filebyname("init", f_init); Swig_register_filebyname("classInit", f_classInit); /* Standard stuff for the SWIG runtime section */ - Swig_banner(f_runtime); + Swig_banner(f_begin); + Printf(f_runtime, "\n"); Printf(f_runtime, "#define SWIGPIKE\n"); Printf(f_runtime, "\n"); @@ -164,17 +169,19 @@ public: SwigType_emit_type_table(f_runtime, f_wrappers); /* Close all of the files */ - 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); Delete(f_header); Delete(f_wrappers); Delete(f_init); Delete(f_classInit); - Close(f_runtime); + Close(f_begin); Delete(f_runtime); + Delete(f_begin); /* Done */ return SWIG_OK; diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 37580bf40..946a37d9e 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -28,6 +28,7 @@ static int shadow = 1; static int use_kw = 0; static int director_method_index = 0; +static File *f_begin = 0; static File *f_runtime = 0; static File *f_runtime_h = 0; static File *f_header = 0; @@ -513,11 +514,17 @@ public: String *outfile = Getattr(n, "outfile"); String *outfile_h = !no_header_file ? Getattr(n, "outfile_h") : 0; - f_runtime = NewFile(outfile, "w", SWIG_output_files()); - 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(""); + f_directors_h = NewString(""); + f_directors = NewString(""); if (directorsEnabled()) { if (!no_header_file) { @@ -531,15 +538,10 @@ public: } } - f_init = NewString(""); - f_header = NewString(""); - f_wrappers = NewString(""); - f_directors_h = NewString(""); - f_directors = NewString(""); - /* Register file targets with the SWIG file handler */ Swig_register_filebyname("header", f_header); Swig_register_filebyname("wrapper", f_wrappers); + Swig_register_filebyname("begin", f_begin); Swig_register_filebyname("runtime", f_runtime); Swig_register_filebyname("init", f_init); Swig_register_filebyname("director", f_directors); @@ -548,8 +550,9 @@ public: const_code = NewString(""); methods = NewString(""); - Swig_banner(f_runtime); + Swig_banner(f_begin); + Printf(f_runtime, "\n"); Printf(f_runtime, "#define SWIGPYTHON\n"); if (directorsEnabled()) { @@ -641,6 +644,7 @@ public: if (directorsEnabled()) { Swig_banner(f_directors_h); + Printf(f_directors_h, "\n"); Printf(f_directors_h, "#ifndef SWIG_%s_WRAP_H_\n", module); Printf(f_directors_h, "#define SWIG_%s_WRAP_H_\n\n", module); if (dirprot_mode()) { @@ -855,19 +859,20 @@ public: } /* Close all of the files */ - Dump(f_header, f_runtime); + Dump(f_runtime, f_begin); + Dump(f_header, f_begin); if (directorsEnabled()) { Dump(f_directors_h, f_runtime_h); Printf(f_runtime_h, "\n"); Printf(f_runtime_h, "#endif\n"); - if (f_runtime_h != f_runtime) + if (f_runtime_h != f_begin) Close(f_runtime_h); - Dump(f_directors, f_runtime); + Dump(f_directors, f_begin); } - Dump(f_wrappers, f_runtime); - Wrapper_pretty_print(f_init, f_runtime); + Dump(f_wrappers, f_begin); + Wrapper_pretty_print(f_init, f_begin); Delete(f_header); Delete(f_wrappers); @@ -875,8 +880,9 @@ public: Delete(f_directors); Delete(f_directors_h); - Close(f_runtime); + Close(f_begin); Delete(f_runtime); + Delete(f_begin); return SWIG_OK; } diff --git a/Source/Modules/r.cxx b/Source/Modules/r.cxx index ae905a806..8e9aa557d 100644 --- a/Source/Modules/r.cxx +++ b/Source/Modules/r.cxx @@ -424,6 +424,7 @@ protected: String *sfile; String *f_init; String *s_classes; + String *f_begin; String *f_runtime; String *f_wrapper; String *s_header; @@ -487,6 +488,7 @@ R::R() : sfile(0), f_init(0), s_classes(0), + f_begin(0), f_runtime(0), f_wrapper(0), s_header(0), @@ -767,6 +769,7 @@ void R::init() { sfile = NewString(""); f_init = NewString(""); s_header = NewString(""); + f_begin = NewString(""); f_runtime = NewString(""); f_wrapper = NewString(""); s_classes = NewString(""); @@ -811,6 +814,7 @@ int R::top(Node *n) { Swig_register_filebyname("sinit", s_init); Swig_register_filebyname("sinitroutine", s_init_routine); + Swig_register_filebyname("begin", f_begin); Swig_register_filebyname("runtime", f_runtime); Swig_register_filebyname("init", f_init); Swig_register_filebyname("header", s_header); @@ -818,8 +822,9 @@ int R::top(Node *n) { Swig_register_filebyname("s", sfile); Swig_register_filebyname("sclasses", s_classes); - Swig_banner(f_runtime); + Swig_banner(f_begin); + Printf(f_runtime, "\n"); Printf(f_runtime, "#define SWIGR\n"); Printf(f_runtime, "\n"); @@ -862,7 +867,9 @@ int R::top(Node *n) { Delete(f_init); Delete(s_header); + Close(f_begin); Delete(f_runtime); + Delete(f_begin); return SWIG_OK; } @@ -903,16 +910,10 @@ int R::DumpCode(Node *n) { SWIG_exit(EXIT_FAILURE); } - Printf(runtime, "/* Runtime */\n"); + Printf(runtime, "%s", f_begin); Printf(runtime, "%s\n", f_runtime); - - Printf(runtime, "/* Header */\n"); Printf(runtime, "%s\n", s_header); - - Printf(runtime, "/* Wrapper */\n"); Printf(runtime, "%s\n", f_wrapper); - - Printf(runtime, "/* Init code */\n"); Printf(runtime, "%s\n", f_init); Close(runtime); diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx index dcc778225..85bf98c13 100644 --- a/Source/Modules/ruby.cxx +++ b/Source/Modules/ruby.cxx @@ -158,6 +158,7 @@ private: File *f_directors; File *f_directors_h; File *f_directors_helpers; + File *f_begin; File *f_runtime; File *f_runtime_h; File *f_header; @@ -762,6 +763,7 @@ public: classes = 0; klass = 0; special_methods = 0; + f_begin = 0; f_runtime = 0; f_header = 0; f_wrappers = 0; @@ -992,12 +994,21 @@ public: SWIG_exit(EXIT_FAILURE); } - f_runtime = NewFile(outfile, "w", SWIG_output_files()); - 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(""); + f_directors_h = NewString(""); + f_directors = NewString(""); + f_directors_helpers = NewString(""); + f_initbeforefunc = NewString(""); + if (directorsEnabled()) { if (!outfile_h) { Printf(stderr, "Unable to determine outfile_h\n"); @@ -1010,17 +1021,10 @@ public: } } - f_init = NewString(""); - f_header = NewString(""); - f_wrappers = NewString(""); - f_directors_h = NewString(""); - f_directors = NewString(""); - f_directors_helpers = NewString(""); - f_initbeforefunc = NewString(""); - /* Register file targets with the SWIG file handler */ Swig_register_filebyname("header", f_header); Swig_register_filebyname("wrapper", f_wrappers); + Swig_register_filebyname("begin", f_begin); Swig_register_filebyname("runtime", f_runtime); Swig_register_filebyname("init", f_init); Swig_register_filebyname("director", f_directors); @@ -1035,8 +1039,9 @@ public: registerMagicMethods(); - Swig_banner(f_runtime); + Swig_banner(f_begin); + Printf(f_runtime, "\n"); Printf(f_runtime, "#define SWIGRUBY\n"); if (directorsEnabled()) { @@ -1060,6 +1065,7 @@ public: Replaceall(module_macro, "::", "__"); Swig_banner(f_directors_h); + Printf(f_directors_h, "\n"); Printf(f_directors_h, "#ifndef SWIG_%s_WRAP_H_\n", module_macro); Printf(f_directors_h, "#define SWIG_%s_WRAP_H_\n\n", module_macro); Printf(f_directors_h, "namespace Swig {\n"); @@ -1112,27 +1118,29 @@ public: SwigType_emit_type_table(f_runtime, f_wrappers); /* Close all of the files */ - Dump(f_header, f_runtime); + Dump(f_runtime, f_begin); + Dump(f_header, f_begin); if (directorsEnabled()) { - Dump(f_directors_helpers, f_runtime); - Dump(f_directors, f_runtime); + Dump(f_directors_helpers, f_begin); + Dump(f_directors, f_begin); Dump(f_directors_h, f_runtime_h); Printf(f_runtime_h, "\n"); Printf(f_runtime_h, "#endif\n"); Close(f_runtime_h); } - Dump(f_wrappers, f_runtime); - Dump(f_initbeforefunc, f_runtime); - Wrapper_pretty_print(f_init, f_runtime); + Dump(f_wrappers, f_begin); + Dump(f_initbeforefunc, f_begin); + Wrapper_pretty_print(f_init, f_begin); Delete(f_header); Delete(f_wrappers); Delete(f_init); Delete(f_initbeforefunc); - Close(f_runtime); + Close(f_begin); Delete(f_runtime); + Delete(f_begin); return SWIG_OK; } diff --git a/Source/Modules/s-exp.cxx b/Source/Modules/s-exp.cxx index cdfaef92e..90791ec70 100644 --- a/Source/Modules/s-exp.cxx +++ b/Source/Modules/s-exp.cxx @@ -68,6 +68,7 @@ public: String *f_sink = NewString(""); Swig_register_filebyname("header", f_sink); Swig_register_filebyname("wrapper", f_sink); + Swig_register_filebyname("begin", f_sink); Swig_register_filebyname("runtime", f_sink); Swig_register_filebyname("init", f_sink); diff --git a/Source/Modules/tcl8.cxx b/Source/Modules/tcl8.cxx index 24f3739c8..015ac5e45 100644 --- a/Source/Modules/tcl8.cxx +++ b/Source/Modules/tcl8.cxx @@ -46,6 +46,7 @@ static int nosafe = 0; static File *f_header = 0; static File *f_wrappers = 0; static File *f_init = 0; +static File *f_begin = 0; static File *f_runtime = 0; @@ -137,11 +138,12 @@ public: /* Initialize all of the output files */ String *outfile = Getattr(n, "outfile"); - f_runtime = NewFile(outfile, "w", SWIG_output_files()); - 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(""); @@ -149,6 +151,7 @@ public: /* Register file targets with the SWIG file handler */ Swig_register_filebyname("header", f_header); Swig_register_filebyname("wrapper", f_wrappers); + Swig_register_filebyname("begin", f_begin); Swig_register_filebyname("runtime", f_runtime); Swig_register_filebyname("init", f_init); @@ -159,8 +162,9 @@ public: methods_tab = NewString(""); const_tab = NewString(""); - Swig_banner(f_runtime); + Swig_banner(f_begin); + Printf(f_runtime, "\n"); Printf(f_runtime, "#define SWIGTCL\n"); Printf(f_runtime, "\n"); @@ -245,12 +249,15 @@ public: } /* Close all of the files */ - Printv(f_runtime, f_header, f_wrappers, NIL); - Wrapper_pretty_print(f_init, f_runtime); + Dump(f_runtime, f_begin); + Printv(f_begin, f_header, f_wrappers, NIL); + Wrapper_pretty_print(f_init, f_begin); Delete(f_header); Delete(f_wrappers); Delete(f_init); - Close(f_runtime); + Close(f_begin); + Delete(f_runtime); + Delete(f_begin); return SWIG_OK; } diff --git a/Source/Modules/uffi.cxx b/Source/Modules/uffi.cxx index 5fdc6101d..d3f8401f0 100644 --- a/Source/Modules/uffi.cxx +++ b/Source/Modules/uffi.cxx @@ -237,6 +237,7 @@ int UFFI::top(Node *n) { } Swig_register_filebyname("header", f_null); + Swig_register_filebyname("begin", f_null); Swig_register_filebyname("runtime", f_null); Swig_register_filebyname("wrapper", f_cl); diff --git a/Source/Swig/misc.c b/Source/Swig/misc.c index e97e93abb..050e5357a 100644 --- a/Source/Swig/misc.c +++ b/Source/Swig/misc.c @@ -67,7 +67,7 @@ void Swig_banner(File *f) { * changes to this file unless you know what you are doing--modify the SWIG \n\ * interface file instead. \n", Swig_package_version()); /* String too long for ISO compliance */ - Printf(f, " * ----------------------------------------------------------------------------- */\n\n"); + Printf(f, " * ----------------------------------------------------------------------------- */\n"); } From e92d7f897b0087f1a14b41cf256b16d2d5f5ccc6 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 20 Feb 2009 08:03:49 +0000 Subject: [PATCH 0341/1680] minor correction about %begin git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11134 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/SWIG.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html index 11cd4f66e..d52f0441c 100644 --- a/Doc/Manual/SWIG.html +++ b/Doc/Manual/SWIG.html @@ -2771,8 +2771,8 @@ The bare %{ ... %} directive is a shortcut that is the same as

      -The %begin section is empty by default -and is provided as a way for users to insert code at the top of the wrapper file. +The %begin section is effectively empty as it just contains the SWIG banner by default. +This section is provided as a way for users to insert code at the top of the wrapper file before any other code is generated. Everything in a code insertion block is copied verbatim into the output file and is not parsed by SWIG. Most SWIG input files have at least one such block to include header files and support C code. Additional code blocks may be placed anywhere in a From 531c4454b8b4ffffcda7ffd62811a83a6f364d10 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 20 Feb 2009 20:55:16 +0000 Subject: [PATCH 0342/1680] Fix -co option which broke in 1.3.37 SF #2605955 git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11135 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 3 +++ Source/Modules/main.cxx | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index 9c1c2ae83..3cb7b2de4 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,9 @@ Version 1.3.39 (in progress) ============================ +2008-02-20: wsfulton + Fix SF #2605955: -co option which broke in 1.3.37. + 2008-02-20: wsfulton New %insert("begin") section added. Also can be used as %begin. This is a new code section reserved entirely for users and the code within the section is generated diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx index 4603ac339..c824db6f9 100644 --- a/Source/Modules/main.cxx +++ b/Source/Modules/main.cxx @@ -955,7 +955,7 @@ int SWIG_main(int argc, char *argv[], Language *l) { if (!s) { Printf(stderr, "Unable to locate '%s' in the SWIG library.\n", input_file); } else { - FILE *f = Swig_include_open(outfile); + FILE *f = Swig_open(outfile); if (f) { fclose(f); Printf(stderr, "File '%s' already exists. Checkout aborted.\n", outfile); From 3d05f50eabb97dc15dcfa0b969884b6f551e20f1 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 20 Feb 2009 23:55:37 +0000 Subject: [PATCH 0343/1680] CFFI - Fix seg faults when for %extend and using statements git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11136 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 3 +++ Source/Modules/cffi.cxx | 12 ++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 3cb7b2de4..b10920a3e 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,9 @@ Version 1.3.39 (in progress) ============================ +2008-02-20: wsfulton + [CFFI] Fix seg faults when for %extend and using statements. + 2008-02-20: wsfulton Fix SF #2605955: -co option which broke in 1.3.37. diff --git a/Source/Modules/cffi.cxx b/Source/Modules/cffi.cxx index a26e2b5d2..0aa933c56 100644 --- a/Source/Modules/cffi.cxx +++ b/Source/Modules/cffi.cxx @@ -245,7 +245,7 @@ void CFFI::emit_defmethod(Node *n) { ParmList *pl = Getattr(n, "parms"); int argnum = 0; - Node *parent = parentNode(n); + Node *parent = getCurrentClass(); bool first = 0; for (Parm *p = pl; p; p = nextSibling(p), argnum++) { @@ -300,7 +300,7 @@ void CFFI::emit_initialize_instance(Node *n) { ParmList *pl = Getattr(n, "parms"); int argnum = 0; - Node *parent = parentNode(n); + Node *parent = getCurrentClass(); for (Parm *p = pl; p; p = nextSibling(p), argnum++) { String *argname = Getattr(p, "name"); @@ -337,18 +337,18 @@ void CFFI::emit_initialize_instance(Node *n) { } void CFFI::emit_setter(Node *n) { - Node *p = parentNode(n); + Node *parent = getCurrentClass(); Printf(f_clos, "(cl:defmethod (cl:setf %s) (arg0 (obj %s))\n (%s (ff-pointer obj) arg0))\n\n", lispify_name(n, Getattr(n, "name"), "'method"), - lispify_name(p, lispy_name(Char(Getattr(p, "sym:name"))), "'class"), lispify_name(n, Getattr(n, "sym:name"), "'function")); + lispify_name(parent, lispy_name(Char(Getattr(parent, "sym:name"))), "'class"), lispify_name(n, Getattr(n, "sym:name"), "'function")); } void CFFI::emit_getter(Node *n) { - Node *p = parentNode(n); + Node *parent = getCurrentClass(); Printf(f_clos, "(cl:defmethod %s ((obj %s))\n (%s (ff-pointer obj)))\n\n", lispify_name(n, Getattr(n, "name"), "'method"), - lispify_name(p, lispy_name(Char(Getattr(p, "sym:name"))), "'class"), lispify_name(n, Getattr(n, "sym:name"), "'function")); + lispify_name(parent, lispy_name(Char(Getattr(parent, "sym:name"))), "'class"), lispify_name(n, Getattr(n, "sym:name"), "'function")); } int CFFI::memberfunctionHandler(Node *n) { From 1f69806cbb949126b0e33543427241231a0373fc Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 21 Feb 2009 00:56:41 +0000 Subject: [PATCH 0344/1680] Fix seg fault wrapping some constant variable (%constant) types git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11137 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 3 +++ Examples/test-suite/allegrocl/Makefile.in | 3 +-- Source/Modules/allegrocl.cxx | 3 +-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index b10920a3e..66f3a87b7 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,9 @@ Version 1.3.39 (in progress) ============================ +2008-02-21: wsfulton + [Allegrocl] Fix seg fault wrapping some constant variable (%constant) types. + 2008-02-20: wsfulton [CFFI] Fix seg faults when for %extend and using statements. diff --git a/Examples/test-suite/allegrocl/Makefile.in b/Examples/test-suite/allegrocl/Makefile.in index c4f087f8d..df7193389 100644 --- a/Examples/test-suite/allegrocl/Makefile.in +++ b/Examples/test-suite/allegrocl/Makefile.in @@ -114,9 +114,8 @@ run_testcase = \ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(ALLEGROCLBIN) -batch -s $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX);) \ fi; -# Clean: (does nothing, we dont generate extra allegrocl code) %.clean: - + @rm -f $*.cl clean: $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile allegrocl_clean diff --git a/Source/Modules/allegrocl.cxx b/Source/Modules/allegrocl.cxx index 4799d31db..878e30a67 100644 --- a/Source/Modules/allegrocl.cxx +++ b/Source/Modules/allegrocl.cxx @@ -2813,11 +2813,10 @@ int ALLEGROCL::constantWrapper(Node *n) { } SwigType_add_qualifier(const_type, "const"); - SwigType_add_qualifier(const_type, "static"); String *ppcname = NewStringf("ACLppc_%s", Getattr(n, "sym:name")); // Printf(f_runtime, "static const %s = %s;\n", SwigType_lstr(const_type, ppcname), const_val); - Printf(f_runtime, "%s = %s;\n", SwigType_lstr(const_type, ppcname), const_val); + Printf(f_runtime, "static %s = %s;\n", SwigType_lstr(const_type, ppcname), const_val); Setattr(n, "name", ppcname); SetFlag(n, "feature:immutable"); From fdcea43ba466366bff4e3bd3c8b1c9485a694014 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Thu, 26 Feb 2009 05:53:37 +0000 Subject: [PATCH 0345/1680] Fix several heading underlines to be the same length as the headings. Add a newline after a few headings which were missing it. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11139 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/CHANGES b/CHANGES index 02b382509..7ffb490da 100644 --- a/CHANGES +++ b/CHANGES @@ -843,7 +843,7 @@ Version 1.3.34 (27 February 2008) }; Version 1.3.33 (November 23, 2007) -================================= +================================== 11/21/2007: mikel [allegrocl] omit private slot type info in the classes/types @@ -1775,7 +1775,7 @@ Version 1.3.31 (November 20, 2006) [lua] update to typemap for object by value, to make it c89 compliant Version 1.3.30 (November 13, 2006) -================================= +================================== 11/12/2006: wsfulton [java] Remove DetachCurrentThread patch from 08/11/2006 - it causes segfaults @@ -6098,7 +6098,7 @@ Version 1.3.24 (December 14, 2004) compile with no errors, java shows some problems. Version 1.3.23 (November 11, 2004) -================================= +================================== 11/05/2004: wsfulton Patch #982753 from Fabrice Salvaire: Adds dependencies generation for @@ -8349,7 +8349,8 @@ Version 1.3.22 (September 4, 2004) exception instead. Version 1.3.21 (January 11, 2004) -================================== +================================= + 01/10/2004: cheetah (William Fulton) The output format for both warnings and errors can be selected for integration with your favourite IDE/editor. Editors and IDEs can usually @@ -10123,6 +10124,7 @@ Version 1.3.20 (December 17, 2003) Version 1.3.19 (March 28, 2003) =============================== + 03/28/2003: beazley Variety of minor bug fixes to the 1.3.18 release including: @@ -10709,6 +10711,7 @@ Version 1.3.18 (March 23, 2003) Version 1.3.17 (November 22, 2002) ================================== + 11/19/2002: beazley Fixed [ 613922 ] preprocessor errors with HAVE_LONG_LONG. @@ -11064,6 +11067,7 @@ Version 1.3.16 (October 14, 2002) Version 1.3.15 (September 9, 2002) ================================== + 09/09/2002: beazley Fixed nasty runtime type checking bug with subtypes and inheritance and templates. @@ -12756,6 +12760,7 @@ Version 1.3.14 (August 12, 2002) Version 1.3.13 (June 17, 2002) ============================== + 06/16/2002: beazley Fixed a bug with __FILE__ expansion in the preprocessor. On Windows, the backslash (\) is now converted to (\\) in the string literal @@ -15887,6 +15892,7 @@ Version 1.3.10 (December 10, 2001) Version 1.3.9 (September 25, 2001) ================================== + 9/25/2001: beazley Fixed parsing problem with type declarations like 'char ** const'. SWIG parsed this correctly, but the @@ -15899,6 +15905,7 @@ Version 1.3.9 (September 25, 2001) Version 1.3.8 (September 23, 2001) ================================== + 9/23/2001: beazley Included improved distutils setup.py file in the Tools directory (look for the setup.py.tmpl file). Contributed by @@ -17271,7 +17278,7 @@ Version 1.3 Alpha 5 and function bodies. Preprocessor bug. Version 1.3 Alpha 4 (September 4, 2000) -====================================== +======================================= 9/3/00 : ttn Added instructions for maintainers in Examples/README on how @@ -18357,6 +18364,7 @@ Version 1.3 Alpha 1 (February 11, 2000) Version 1.1 Patch 5 (February 5, 1998) ====================================== + 2/4/98 : Fixed a bug in the configure script when different package locations are specified (--with-tclincl, etc...). @@ -18609,6 +18617,7 @@ Version 1.1 Patch 3 (November 24, 1997) Version 1.1 Patch 2 (September 4, 1997) ======================================= + 9/4/97 : Fixed problem with handling of virtual functions that was introduced by some changes in the C++ module. @@ -19744,7 +19753,7 @@ This release should fix most, if not all, of those problems. it generated alot of unnecessary code). Version 1.1 Beta3 (January 9, 1997) -==================================== +=================================== Note : A *huge* number of changes related to ongoing modifications. @@ -19867,6 +19876,7 @@ Version 1.1 Beta1 (October 30, 1996) Version 1.0 Final (August 31, 1996) =================================== + 1. Fixed minor bug in C++ module 2. Fixed minor bug in pointer type-checker when using @@ -19950,7 +19960,7 @@ number of immediate problems : 3. A few minor fixes were made in the Makefile Version 1.0 Beta 3 (June 14, 1996) -=================================== +================================== There are lots of changes in this release : @@ -20040,6 +20050,7 @@ let me know. Version 1.0 Beta 2 (April 26, 1996) =================================== + This release is identical to Beta1 except a few minor bugs are fixed and the SWIG library has been updated to work with Tcl 7.5/Tk 4.1. A tcl7.5 examples directory is now included. @@ -20054,6 +20065,7 @@ A tcl7.5 examples directory is now included. Version 1.0 Beta 1 (April 10, 1996). ===================================== + This is the first "semi-official" release of SWIG. It has a number of substantial improvements over the Alpha release. These notes are in no particular order--hope I remembered everything.... From c74c467a09b857a7202590abe25b7c1e2af66ea6 Mon Sep 17 00:00:00 2001 From: Haoyu Bai Date: Sat, 28 Feb 2009 14:02:02 +0000 Subject: [PATCH 0346/1680] Fix SF#2637352, move declaration of SWIG_module before the call of SWIG_Python_FixMethods, since some C compiler don't allow declaration in middle of function body. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11140 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 5 +++++ Lib/python/pyinit.swg | 10 ++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 66f3a87b7..bffefbb2b 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,11 @@ Version 1.3.39 (in progress) ============================ +2008-02-28: bhy + [Python] Fix SF#2637352. Move struct declaration of SWIG_module in pyinit.swg before + the method calls, since some C compiler don't allow declaration in middle of function + body. + 2008-02-21: wsfulton [Allegrocl] Fix seg fault wrapping some constant variable (%constant) types. diff --git a/Lib/python/pyinit.swg b/Lib/python/pyinit.swg index ab55765ad..5fa50ecb8 100644 --- a/Lib/python/pyinit.swg +++ b/Lib/python/pyinit.swg @@ -318,10 +318,7 @@ SWIGEXPORT void #endif SWIG_init(void) { - PyObject *m, *d; - - /* Fix SwigMethods to carry the callback ptrs when needed */ - SWIG_Python_FixMethods(SwigMethods, swig_const_table, swig_types, swig_type_initial); + PyObject *m, *d; #if PY_VERSION_HEX >= 0x03000000 static struct PyModuleDef SWIG_module = { PyModuleDef_HEAD_INIT, @@ -334,7 +331,12 @@ SWIG_init(void) { NULL, NULL }; +#endif + /* Fix SwigMethods to carry the callback ptrs when needed */ + SWIG_Python_FixMethods(SwigMethods, swig_const_table, swig_types, swig_type_initial); + +#if PY_VERSION_HEX >= 0x03000000 m = PyModule_Create(&SWIG_module); #else m = Py_InitModule((char *) SWIG_name, SwigMethods); From 5d64541c4430d21d8140f09cdda8edb0a0694d8c Mon Sep 17 00:00:00 2001 From: Haoyu Bai Date: Sun, 1 Mar 2009 09:37:21 +0000 Subject: [PATCH 0347/1680] Fix SF#2583160. Make swig_import_helper() in shadow wrapper able to deal with the case that module already imported at other place. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11141 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++++ Source/Modules/python.cxx | 15 +++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index bffefbb2b..1c37bc20d 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,10 @@ Version 1.3.39 (in progress) ============================ +2008-03-01: bhy + [Python] Fix SF#2583160. Now the importer in Python shadow wrapper take care of the + case that module already imported at other place. + 2008-02-28: bhy [Python] Fix SF#2637352. Move struct declaration of SWIG_module in pyinit.swg before the method calls, since some C compiler don't allow declaration in middle of function diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 946a37d9e..ffeea430d 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -716,12 +716,19 @@ public: Printv(f_shadow, tab4, "def swig_import_helper():\n", NULL); Printv(f_shadow, tab8, "from os.path import dirname\n", NULL); Printv(f_shadow, tab8, "import imp\n", NULL); + Printv(f_shadow, tab8, "fp = None\n", NULL); Printv(f_shadow, tab8, "try:\n", NULL); Printf(f_shadow, tab4 tab8 "fp, pathname, description = imp.find_module('%s', [dirname(__file__)])\n", module); - Printf(f_shadow, tab4 tab8 "_mod = imp.load_module('%s', fp, pathname, description)\n", module); - Printv(f_shadow, tab8, "finally:\n", NULL); - Printv(f_shadow, tab4 tab8, "if fp is not None: fp.close()\n", NULL); - Printv(f_shadow, tab8, "return _mod\n", NULL); + Printf(f_shadow, tab8 "except ImportError:\n"); + /* At here, the module may already loaded, so simply import it. */ + Printf(f_shadow, tab4 tab8 "import %s\n", module); + Printf(f_shadow, tab4 tab8 "return %s\n", module); + Printv(f_shadow, tab8 "if fp is not None:\n", NULL); + Printv(f_shadow, tab4 tab8 "try:\n", NULL); + Printf(f_shadow, tab8 tab8 "_mod = imp.load_module('%s', fp, pathname, description)\n", module); + Printv(f_shadow, tab4 tab8, "finally:\n", NULL); + Printv(f_shadow, tab8 tab8, "fp.close()\n", NULL); + Printv(f_shadow, tab8 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 fcf2d3ddb8425348d2737bef91d3d011448867da Mon Sep 17 00:00:00 2001 From: Haoyu Bai Date: Mon, 2 Mar 2009 16:35:12 +0000 Subject: [PATCH 0348/1680] Add searching for Python 3.1 in configure.in git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11142 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- configure.in | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.in b/configure.in index 000496fed..f841db230 100644 --- a/configure.in +++ b/configure.in @@ -692,16 +692,16 @@ else # First figure out the name of the Python3 executable if test "x$PY3BIN" = xyes; then - AC_CHECK_PROGS(PYTHON3, [python3 python3.0]) + AC_CHECK_PROGS(PYTHON3, [python3 python3.0 python3.1]) else PYTHON3="$PY3BIN" fi # Check for Python 3.x development tools (header files, static library and python3-config) if test "x$PYTHON3" = x; then - AC_CHECK_PROGS(PY3CONFIG, [python3-config python3.0-config]) + AC_CHECK_PROGS(PY3CONFIG, [python3-config python3.0-config python3.1-config]) else - AC_CHECK_PROGS(PY3CONFIG, [$PYTHON3-config python3-config python3.0-config]) + AC_CHECK_PROGS(PY3CONFIG, [$PYTHON3-config python3-config python3.0-config python3.1-config]) fi if test -n "$PYTHON3" -a -n "$PY3CONFIG"; then From caa6f2b9fa8577bb86646268e99250b0b06dc8aa Mon Sep 17 00:00:00 2001 From: Haoyu Bai Date: Mon, 2 Mar 2009 17:56:29 +0000 Subject: [PATCH 0349/1680] Fixes to support Python 3.0.1 and higher. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11143 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 6 ++++ .../test-suite/python/swigobject_runme.py | 13 ++++----- Lib/python/pycontainer.swg | 2 +- Lib/python/pyrun.swg | 28 +++++++++++++------ 4 files changed, 32 insertions(+), 17 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 1c37bc20d..085a80bca 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,12 @@ Version 1.3.39 (in progress) ============================ +2008-03-01: bhy + [Python] Some fixes for Python 3.0.1 and higher support. In 3.0.1, the C API function + PyObject_Compare is removed, so PyObject_RichCompareBool is used for replacement. + Struct initilization of SwigPyObject and SwigPyObject_as_number changed to reflect + the drop of tp_compare and nb_long. + 2008-03-01: bhy [Python] Fix SF#2583160. Now the importer in Python shadow wrapper take care of the case that module already imported at other place. diff --git a/Examples/test-suite/python/swigobject_runme.py b/Examples/test-suite/python/swigobject_runme.py index 70219a57c..a906108e3 100644 --- a/Examples/test-suite/python/swigobject_runme.py +++ b/Examples/test-suite/python/swigobject_runme.py @@ -1,8 +1,5 @@ from swigobject import * -from string import replace -from string import upper -from string import lstrip a = A() @@ -17,12 +14,12 @@ if a1.this != a2.this: lthis = long(a.this) # match pointer value, but deal with leading zeros on 8/16 bit systems and different C++ compilers interpretation of %p xstr1 = "%016X" % (lthis,) -xstr1 = lstrip(xstr1, '0') +xstr1 = str.lstrip(xstr1, '0') xstr2 = pointer_str(a) -xstr2 = replace(xstr2, "0x", "") -xstr2 = replace(xstr2, "0X", "") -xstr2 = lstrip(xstr2, '0') -xstr2 = upper(xstr2) +xstr2 = str.replace(xstr2, "0x", "") +xstr2 = str.replace(xstr2, "0X", "") +xstr2 = str.lstrip(xstr2, '0') +xstr2 = str.upper(xstr2) if xstr1 != xstr2: print xstr1, xstr2 diff --git a/Lib/python/pycontainer.swg b/Lib/python/pycontainer.swg index 5f09357f8..b74c18e99 100644 --- a/Lib/python/pycontainer.swg +++ b/Lib/python/pycontainer.swg @@ -115,7 +115,7 @@ namespace std { { bool res; SWIG_PYTHON_THREAD_BEGIN_BLOCK; - res = PyObject_Compare(v, w) < 0; + res = PyObject_RichCompareBool(v, w, Py_LT); /* This may fall into a case of inconsistent eg. ObjA > ObjX > ObjB but ObjA < ObjB diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index bc5490960..897fa7fb3 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -660,7 +660,11 @@ _PySwigObject_type(void) { 0, /*nb_coerce*/ #endif (unaryfunc)SwigPyObject_long, /*nb_int*/ +#if PY_VERSION_HEX < 0x03000000 (unaryfunc)SwigPyObject_long, /*nb_long*/ +#else + 0, /*nb_reserved*/ +#endif (unaryfunc)0, /*nb_float*/ #if PY_VERSION_HEX < 0x03000000 (unaryfunc)SwigPyObject_oct, /*nb_oct*/ @@ -700,7 +704,11 @@ _PySwigObject_type(void) { (getattrfunc)0, /* tp_getattr */ #endif (setattrfunc)0, /* tp_setattr */ - (cmpfunc)SwigPyObject_compare, /* tp_compare */ +#if PY_VERSION_HEX >= 0x03000000 + 0, /* tp_reserved in 3.0.1 */ +#else + (cmpfunc)SwigPyObject_compare, /* tp_compare */ +#endif (reprfunc)SwigPyObject_repr, /* tp_repr */ &SwigPyObject_as_number, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -871,14 +879,18 @@ _PySwigPacked_type(void) { (printfunc)SwigPyPacked_print, /* tp_print */ (getattrfunc)0, /* tp_getattr */ (setattrfunc)0, /* tp_setattr */ - (cmpfunc)SwigPyPacked_compare, /* tp_compare */ - (reprfunc)SwigPyPacked_repr, /* tp_repr */ - 0, /* tp_as_number */ +#if PY_VERSION_HEX>=0x03000000 + 0, /* tp_reserved in 3.0.1 */ +#else + (cmpfunc)SwigPyPacked_compare, /* tp_compare */ +#endif + (reprfunc)SwigPyPacked_repr, /* tp_repr */ + 0, /* tp_as_number */ 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - (hashfunc)0, /* tp_hash */ - (ternaryfunc)0, /* tp_call */ - (reprfunc)SwigPyPacked_str, /* tp_str */ + 0, /* tp_as_mapping */ + (hashfunc)0, /* tp_hash */ + (ternaryfunc)0, /* tp_call */ + (reprfunc)SwigPyPacked_str, /* tp_str */ PyObject_GenericGetAttr, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ From ed68b295a03e5462ef9b5b101488f5d180b0b9d2 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 11 Mar 2009 21:01:55 +0000 Subject: [PATCH 0350/1680] undef bind for win32, problem reported by vondruch git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11148 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/ruby/rubyhead.swg | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Lib/ruby/rubyhead.swg b/Lib/ruby/rubyhead.swg index 8e6e2e7d0..d17fdbaae 100644 --- a/Lib/ruby/rubyhead.swg +++ b/Lib/ruby/rubyhead.swg @@ -7,6 +7,9 @@ #ifdef read # undef read #endif +#ifdef bind +# undef bind +#endif /* Ruby 1.7 defines NUM2LL(), LL2NUM() and ULL2NUM() macros */ From 025d4c03c7ba65b1626644250ea585876cc154ee Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 12 Mar 2009 20:41:56 +0000 Subject: [PATCH 0351/1680] Fix #2676738 SWIG generated symbol name clashes. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11150 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 3 +++ Source/Modules/ruby.cxx | 24 ++++++++++++------------ 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 085a80bca..f17090bf5 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,9 @@ Version 1.3.39 (in progress) ============================ +2008-03-12: wsfulton + [Ruby] Fix #2676738 SWIG generated symbol name clashes. + 2008-03-01: bhy [Python] Some fixes for Python 3.0.1 and higher support. In 3.0.1, the C API function PyObject_Compare is removed, so PyObject_RichCompareBool is used for replacement. diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx index 85bf98c13..1c13747e5 100644 --- a/Source/Modules/ruby.cxx +++ b/Source/Modules/ruby.cxx @@ -30,7 +30,7 @@ public: /** * The C variable name used in the SWIG-generated wrapper code to refer to - * this class; usually it is of the form "cClassName.klass", where cClassName + * this class; usually it is of the form "SwigClassXXX.klass", where SwigClassXXX * is a swig_class struct instance and klass is a member of that struct. */ String *vname; @@ -39,7 +39,7 @@ public: * The C variable name used in the SWIG-generated wrapper code to refer to * the module that implements this class's methods (when we're trying to * support C++ multiple inheritance). Usually it is of the form - * "cClassName.mImpl", where cClassName is a swig_class struct instance + * "SwigClassClassName.mImpl", where SwigClassXXX is a swig_class struct instance * and mImpl is a member of that struct. */ String *mImpl; @@ -93,11 +93,11 @@ public: /* Variable name for the VALUE that refers to the Ruby Class object */ Clear(vname); - Printf(vname, "c%s.klass", name); + Printf(vname, "SwigClass%s.klass", name); /* Variable name for the VALUE that refers to the Ruby Class object */ Clear(mImpl); - Printf(mImpl, "c%s.mImpl", name); + Printf(mImpl, "SwigClass%s.mImpl", name); /* Prefix */ Clear(prefix); @@ -2402,9 +2402,9 @@ public: void handleMarkFuncDirective(Node *n) { String *markfunc = Getattr(n, "feature:markfunc"); if (markfunc) { - Printf(klass->init, "c%s.mark = (void (*)(void *)) %s;\n", klass->name, markfunc); + Printf(klass->init, "SwigClass%s.mark = (void (*)(void *)) %s;\n", klass->name, markfunc); } else { - Printf(klass->init, "c%s.mark = 0;\n", klass->name); + Printf(klass->init, "SwigClass%s.mark = 0;\n", klass->name); } } @@ -2414,10 +2414,10 @@ public: void handleFreeFuncDirective(Node *n) { String *freefunc = Getattr(n, "feature:freefunc"); if (freefunc) { - Printf(klass->init, "c%s.destroy = (void (*)(void *)) %s;\n", klass->name, freefunc); + Printf(klass->init, "SwigClass%s.destroy = (void (*)(void *)) %s;\n", klass->name, freefunc); } else { if (klass->destructor_defined) { - Printf(klass->init, "c%s.destroy = (void (*)(void *)) free_%s;\n", klass->name, klass->mname); + Printf(klass->init, "SwigClass%s.destroy = (void (*)(void *)) free_%s;\n", klass->name, klass->mname); } } } @@ -2428,9 +2428,9 @@ public: void handleTrackDirective(Node *n) { int trackObjects = GetFlag(n, "feature:trackobjects"); if (trackObjects) { - Printf(klass->init, "c%s.trackObjects = 1;\n", klass->name); + Printf(klass->init, "SwigClass%s.trackObjects = 1;\n", klass->name); } else { - Printf(klass->init, "c%s.trackObjects = 0;\n", klass->name); + Printf(klass->init, "SwigClass%s.trackObjects = 0;\n", klass->name); } } @@ -2455,7 +2455,7 @@ public: Clear(klass->type); Printv(klass->type, Getattr(n, "classtype"), NIL); - Printv(f_wrappers, "swig_class c", valid_name, ";\n\n", NIL); + Printv(f_wrappers, "swig_class SwigClass", valid_name, ";\n\n", NIL); Printv(klass->init, "\n", tab4, NIL); if (!useGlobalModule) { @@ -2473,7 +2473,7 @@ public: SwigType_add_pointer(tt); SwigType_remember(tt); String *tm = SwigType_manglestr(tt); - Printf(klass->init, "SWIG_TypeClientData(SWIGTYPE%s, (void *) &c%s);\n", tm, valid_name); + Printf(klass->init, "SWIG_TypeClientData(SWIGTYPE%s, (void *) &SwigClass%s);\n", tm, valid_name); Delete(tm); Delete(tt); Delete(valid_name); From 94a788c30f3ca295a9c99d99ae84b20eb6a3da58 Mon Sep 17 00:00:00 2001 From: Haoyu Bai Date: Mon, 16 Mar 2009 11:10:29 +0000 Subject: [PATCH 0352/1680] Remove an nonsense Py_INCREF. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11151 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/python/pyrun.swg | 1 - 1 file changed, 1 deletion(-) diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index 897fa7fb3..30021bb48 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -1234,7 +1234,6 @@ SWIG_Python_NewShadowInstance(SwigPyClientData *data, PyObject *swig_this) } else { #if PY_VERSION_HEX >= 0x03000000 inst = PyBaseObject_Type.tp_new((PyTypeObject*) data->newargs, Py_None, Py_None); - Py_INCREF(data->newargs); PyObject_SetAttr(inst, SWIG_This(), swig_this); Py_TYPE(inst)->tp_flags &= ~Py_TPFLAGS_VALID_VERSION_TAG; #else From e8e85276426b69960b7560c3ddab8fc600492b33 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 16 Mar 2009 17:42:30 +0000 Subject: [PATCH 0353/1680] vc++ warning fixes git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11152 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/python/pycontainer.swg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/python/pycontainer.swg b/Lib/python/pycontainer.swg index b74c18e99..6fd1d56f9 100644 --- a/Lib/python/pycontainer.swg +++ b/Lib/python/pycontainer.swg @@ -115,7 +115,7 @@ namespace std { { bool res; SWIG_PYTHON_THREAD_BEGIN_BLOCK; - res = PyObject_RichCompareBool(v, w, Py_LT); + res = PyObject_RichCompareBool(v, w, Py_LT) ? true : false; /* This may fall into a case of inconsistent eg. ObjA > ObjX > ObjB but ObjA < ObjB From 956c57bb0340d19720667922fadd806fe40a8690 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 16 Mar 2009 19:33:38 +0000 Subject: [PATCH 0354/1680] add in correct specialization for std::vector to follow C++ standard - to create compileable wrappers with vc++ and recent return by reference changes git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11153 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/csharp/std_vector.i | 22 +++++++++++++++++----- Lib/java/std_vector.i | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 5 deletions(-) diff --git a/Lib/csharp/std_vector.i b/Lib/csharp/std_vector.i index a04831f75..64b169572 100644 --- a/Lib/csharp/std_vector.i +++ b/Lib/csharp/std_vector.i @@ -24,7 +24,7 @@ // 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(CSTYPE, CTYPE...) +%define SWIG_STD_VECTOR_MINIMUM_INTERNAL(CONST_REFERENCE_TYPE, CSTYPE, CTYPE...) %typemap(csinterfaces) std::vector "IDisposable, System.Collections.IEnumerable"; %typemap(cscode) std::vector %{ public $csclassname(System.Collections.ICollection c) : this() { @@ -176,7 +176,7 @@ public: typedef size_t size_type; typedef CTYPE value_type; - typedef const value_type& const_reference; + typedef CONST_REFERENCE_TYPE const_reference; %rename(Clear) clear; void clear(); %rename(Add) push_back; @@ -286,6 +286,11 @@ } %enddef +%define SWIG_STD_VECTOR_MINIMUM(CSTYPE, CTYPE...) +SWIG_STD_VECTOR_MINIMUM_INTERNAL(const value_type&, CSTYPE, 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 %define SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(CSTYPE, CTYPE...) @@ -334,7 +339,6 @@ namespace std { } %enddef - %{ #include #include @@ -365,7 +369,16 @@ namespace std { // template specializations for std::vector // these provide extra collections methods as operator== is defined -SWIG_STD_VECTOR_SPECIALIZE(bool, bool) + +// extra specialization for bool +namespace std { + template<> class vector { + SWIG_STD_VECTOR_MINIMUM_INTERNAL(bool, bool, bool) + SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(bool, bool) + }; +} + +// primitive types specialization SWIG_STD_VECTOR_SPECIALIZE(char, char) SWIG_STD_VECTOR_SPECIALIZE(sbyte, signed char) SWIG_STD_VECTOR_SPECIALIZE(byte, unsigned char) @@ -381,4 +394,3 @@ SWIG_STD_VECTOR_SPECIALIZE(float, float) SWIG_STD_VECTOR_SPECIALIZE(double, double) SWIG_STD_VECTOR_SPECIALIZE(string, std::string) // also requires a %include - diff --git a/Lib/java/std_vector.i b/Lib/java/std_vector.i index 92fa25ac2..29439606b 100644 --- a/Lib/java/std_vector.i +++ b/Lib/java/std_vector.i @@ -46,6 +46,40 @@ namespace std { } } }; + + // bool specialization + template<> class vector { + public: + typedef size_t size_type; + typedef bool value_type; + typedef bool const_reference; + vector(); + vector(size_type n); + size_type size() const; + size_type capacity() const; + void reserve(size_type n); + %rename(isEmpty) empty; + bool empty() const; + void clear(); + %rename(add) push_back; + void push_back(const value_type& x); + %extend { + const_reference get(int i) throw (std::out_of_range) { + int size = int(self->size()); + if (i>=0 && isize()); + if (i>=0 && i Date: Mon, 16 Mar 2009 21:39:36 +0000 Subject: [PATCH 0355/1680] minor rewrite git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11154 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/csharp/std_vector.i | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/Lib/csharp/std_vector.i b/Lib/csharp/std_vector.i index 64b169572..285581a86 100644 --- a/Lib/csharp/std_vector.i +++ b/Lib/csharp/std_vector.i @@ -365,20 +365,15 @@ namespace std { template class vector { SWIG_STD_VECTOR_MINIMUM(T, const T*) }; -} - -// template specializations for std::vector -// these provide extra collections methods as operator== is defined - -// extra specialization for bool -namespace std { - template<> class vector { + // bool is a bit different in the C++ standard + template<> class vector { SWIG_STD_VECTOR_MINIMUM_INTERNAL(bool, bool, bool) SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(bool, bool) }; } -// primitive types specialization +// 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) From 6975ecd65c52543bd630730e62a30f42a1ad1bb6 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 18 Mar 2009 23:30:57 +0000 Subject: [PATCH 0356/1680] std::vector wrapper improvements for .NET 2 implementing IEnumerable git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11156 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 10 +++ .../test-suite/csharp/li_std_vector_runme.cs | 34 ++++++++-- Lib/csharp/std_vector.i | 66 +++++++++++++++---- 3 files changed, 93 insertions(+), 17 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index f17090bf5..de41577f8 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,16 @@ Version 1.3.39 (in progress) ============================ +2008-03-18: wsfulton + [C#] std::vector wrapper improvements for .NET 2 and also providing the + necessary machinery to use the std::vector wrappers with more advanced features such + as LINQ - the C# proxy class now derives from IEnumerable<>. The default is now to + generate code requiring .NET 2 as a minimum, although the C# code can be compiled + for .NET 1 by defining the SWIG_DOTNET_1 C# preprocessor constant. See the + std_vector.i file for more details. + + *** POTENTIAL INCOMPATIBILITY *** + 2008-03-12: wsfulton [Ruby] Fix #2676738 SWIG generated symbol name clashes. diff --git a/Examples/test-suite/csharp/li_std_vector_runme.cs b/Examples/test-suite/csharp/li_std_vector_runme.cs index 718087336..6d6def05d 100644 --- a/Examples/test-suite/csharp/li_std_vector_runme.cs +++ b/Examples/test-suite/csharp/li_std_vector_runme.cs @@ -82,14 +82,17 @@ public class li_std_vector_runme { } catch (ArgumentException) { } } +#if SWIG_DOTNET_1 { + // runtime check that 2D arrays fail double[,] outputarray = new double[collectionSize,collectionSize]; try { vect.CopyTo(outputarray); - throw new Exception("CopyTo (5) test failed"); + throw new Exception("CopyTo (5a) test failed"); } catch (ArgumentException) { } } +#endif { StructVector inputvector = new StructVector(); int arrayLen = 10; @@ -154,6 +157,9 @@ public class li_std_vector_runme { throw new Exception("ICollection constructor null test failed"); } catch (ArgumentNullException) { } + { + myDoubleVector = new DoubleVector() { 123.4, 567.8, 901.2 }; + } // IndexOf() test for (int i=0; i myEnumerator = dv.GetEnumerator(); + while ( myEnumerator.MoveNext() ) { + if (myEnumerator.Current != 77.7) + throw new Exception("Repeat (2) test failed"); + } + } +#endif } { @@ -516,6 +533,13 @@ public class li_std_vector_runme { li_std_vector.halve_in_place(dvec); } + // Dispose() + { + using (StructVector vs = new StructVector() { new Struct(0.0), new Struct(11.1) } ) + using (DoubleVector vd = new DoubleVector() { 0.0, 11.1 } ) { + } + } + // More wrapped methods { RealVector v0 = li_std_vector.vecreal(new RealVector()); diff --git a/Lib/csharp/std_vector.i b/Lib/csharp/std_vector.i index 285581a86..f4ad88bae 100644 --- a/Lib/csharp/std_vector.i +++ b/Lib/csharp/std_vector.i @@ -6,15 +6,22 @@ * * SWIG typemaps for std::vector * C# implementation - * 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. - * Warning: heavy macro usage in this file. Use swig -E to get a sane view on the real file contents! + * 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; + * + * Note that IEnumerable<> is implemented in the proxy class which is useful for using LINQ with + * C++ std::vector wrappers. + * + * Warning: heavy macro usage in this file. Use swig -E to get a sane view on the real file contents! * ----------------------------------------------------------------------------- */ // Warning: Use the typemaps here in the expectation that the macros they are in will change name. @@ -25,7 +32,7 @@ // 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(CONST_REFERENCE_TYPE, CSTYPE, CTYPE...) -%typemap(csinterfaces) std::vector "IDisposable, System.Collections.IEnumerable"; +%typemap(csinterfaces) std::vector "IDisposable, System.Collections.IEnumerable\n#if !SWIG_DOTNET_1\n , System.Collections.Generic.IEnumerable\n#endif\n"; %typemap(cscode) std::vector %{ public $csclassname(System.Collections.ICollection c) : this() { if (c == null) @@ -79,15 +86,30 @@ } } - public void CopyTo(System.Array array) { +#if SWIG_DOTNET_1 + public void CopyTo(System.Array array) +#else + public void CopyTo(CSTYPE[] array) +#endif + { CopyTo(0, array, 0, this.Count); } - public void CopyTo(System.Array array, int arrayIndex) { +#if SWIG_DOTNET_1 + public void CopyTo(System.Array array, int arrayIndex) +#else + public void CopyTo(CSTYPE[] array, int arrayIndex) +#endif + { CopyTo(0, array, arrayIndex, this.Count); } - public void CopyTo(int index, System.Array array, int arrayIndex, int count) { +#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) +#endif + { if (array == null) throw new ArgumentNullException("array"); if (index < 0) @@ -97,14 +119,19 @@ if (count < 0) throw new ArgumentOutOfRangeException("count", "Value is less than zero"); if (array.Rank > 1) - throw new ArgumentException("Multi dimensional array."); + throw new ArgumentException("Multi dimensional array.", "array"); if (index+count > this.Count || arrayIndex+count > array.Length) throw new ArgumentException("Number of elements to copy is too large."); for (int i=0; i System.Collections.Generic.IEnumerable.GetEnumerator() { + return new $csclassnameEnumerator(this); + } +#endif + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { return new $csclassnameEnumerator(this); } @@ -118,7 +145,11 @@ /// whenever the collection is modified. This has been done for changes in the size of the /// collection but not when one of the elements of the collection is modified as it is a bit /// tricky to detect unmanaged code that modifies the collection under our feet. - public sealed class $csclassnameEnumerator : System.Collections.IEnumerator { + public sealed class $csclassnameEnumerator : System.Collections.IEnumerator +#if !SWIG_DOTNET_1 + , System.Collections.Generic.IEnumerator +#endif + { private $csclassname collectionRef; private int currentIndex; private object currentObject; @@ -170,6 +201,13 @@ throw new InvalidOperationException("Collection modified."); } } + +#if !SWIG_DOTNET_1 + public void Dispose() { + currentIndex = -1; + currentObject = null; + } +#endif } %} @@ -293,6 +331,7 @@ SWIG_STD_VECTOR_MINIMUM_INTERNAL(const value_type&, CSTYPE, CTYPE) // 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...) %extend { bool Contains(const value_type& value) { @@ -312,10 +351,13 @@ SWIG_STD_VECTOR_MINIMUM_INTERNAL(const value_type&, CSTYPE, CTYPE) index = (int)(self->rend() - 1 - rit); return index; } - void Remove(const value_type& value) { + bool Remove(const value_type& value) { std::vector::iterator it = std::find(self->begin(), self->end(), value); - if (it != self->end()) + if (it != self->end()) { self->erase(it); + return true; + } + return false; } } %enddef From 51a723aa85c91b36dff1240ca58e9790f1bf260a Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 18 Mar 2009 23:54:09 +0000 Subject: [PATCH 0357/1680] Add possibility of using when using shared_ptr and wrapping pointers git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11157 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/python/boost_shared_ptr.i | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Lib/python/boost_shared_ptr.i b/Lib/python/boost_shared_ptr.i index 2e34290ac..6b43ca685 100644 --- a/Lib/python/boost_shared_ptr.i +++ b/Lib/python/boost_shared_ptr.i @@ -1,5 +1,11 @@ %include +// Set SHARED_PTR_DISOWN to $disown if required, for example +// #define SHARED_PTR_DISOWN $disown +#if !defined(SHARED_PTR_DISOWN) +#define SHARED_PTR_DISOWN 0 +#endif + %define SWIG_SHARED_PTR_TYPEMAPS(PROXYCLASS, CONST, TYPE...) %naturalvar TYPE; @@ -51,10 +57,11 @@ } // plain pointer -// Note: $disown not implemented as it will lead to a memory leak of the shared_ptr instance +// Note: $disown not implemented by default as it will lead to a memory leak of the shared_ptr instance %typemap(in) CONST TYPE * (void *argp = 0, int res = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) { int newmem = 0; - res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); +/*overhere*/ + res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SHARED_PTR_DISOWN | %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } @@ -139,10 +146,10 @@ } // plain pointer by reference -// Note: $disown not implemented as it will lead to a memory leak of the shared_ptr instance +// Note: $disown not implemented by default as it will lead to a memory leak of the shared_ptr instance %typemap(in) CONST TYPE *& (void *argp = 0, int res = 0, $*1_ltype temp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared) { int newmem = 0; - res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); + res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SHARED_PTR_DISOWN | %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } From f630911352f9b84c31118ca7ccea224c042c73a5 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 19 Mar 2009 00:04:28 +0000 Subject: [PATCH 0358/1680] remove debug comment git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11158 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/python/boost_shared_ptr.i | 1 - 1 file changed, 1 deletion(-) diff --git a/Lib/python/boost_shared_ptr.i b/Lib/python/boost_shared_ptr.i index 6b43ca685..b4c0b5b83 100644 --- a/Lib/python/boost_shared_ptr.i +++ b/Lib/python/boost_shared_ptr.i @@ -60,7 +60,6 @@ // Note: $disown not implemented by default as it will lead to a memory leak of the shared_ptr instance %typemap(in) CONST TYPE * (void *argp = 0, int res = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) { int newmem = 0; -/*overhere*/ res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SHARED_PTR_DISOWN | %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); From 359c4f786d1b31abcf64922b3c0b7d99d14fcbe5 Mon Sep 17 00:00:00 2001 From: Haoyu Bai Date: Thu, 19 Mar 2009 14:20:38 +0000 Subject: [PATCH 0359/1680] Fix wrong year in changelog date git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11159 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES | 10 +++++----- CHANGES.current | 32 ++++++++++++++++---------------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/CHANGES b/CHANGES index 7ffb490da..7fff2c3f0 100644 --- a/CHANGES +++ b/CHANGES @@ -5,25 +5,25 @@ See CHANGES.current for current version. Version 1.3.38 (31 January 2009) ================================ -2008-01-31: bhy +2009-01-31: bhy [Python] Fix SF#2552488 reported by Gaetan Lehmann. Now %pythonprepend and %pythonappend have correct indentation. -2008-01-31: bhy +2009-01-31: bhy [Python] Fix SF#2552048 reported by Gaetan Lehmann. The parameter list of static member function in generated proxy code should not have the 'self' parameter. -2008-01-29: wsfulton +2009-01-29: wsfulton Fix regression introduced in 1.3.37 where the default output directory for target language specific files (in the absence of -outdir) was no longer the same directory as the generated c/c++ file. -2008-01-28: wsfulton +2009-01-28: wsfulton [Java, C#] Fix proxy class not being used when the global scope operator was used for parameters passed by value. Reported by David Piepgrass. -2008-01-15: wsfulton +2009-01-15: wsfulton [Perl] Fix seg fault when running with -v option, reported by John Ky. Version 1.3.37 (13 January 2009) diff --git a/CHANGES.current b/CHANGES.current index de41577f8..65cc144bb 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,7 +1,7 @@ Version 1.3.39 (in progress) ============================ -2008-03-18: wsfulton +2009-03-18: wsfulton [C#] std::vector wrapper improvements for .NET 2 and also providing the necessary machinery to use the std::vector wrappers with more advanced features such as LINQ - the C# proxy class now derives from IEnumerable<>. The default is now to @@ -11,55 +11,55 @@ Version 1.3.39 (in progress) *** POTENTIAL INCOMPATIBILITY *** -2008-03-12: wsfulton +2009-03-12: wsfulton [Ruby] Fix #2676738 SWIG generated symbol name clashes. -2008-03-01: bhy +2009-03-01: bhy [Python] Some fixes for Python 3.0.1 and higher support. In 3.0.1, the C API function PyObject_Compare is removed, so PyObject_RichCompareBool is used for replacement. Struct initilization of SwigPyObject and SwigPyObject_as_number changed to reflect the drop of tp_compare and nb_long. -2008-03-01: bhy +2009-03-01: bhy [Python] Fix SF#2583160. Now the importer in Python shadow wrapper take care of the case that module already imported at other place. -2008-02-28: bhy +2009-02-28: bhy [Python] Fix SF#2637352. Move struct declaration of SWIG_module in pyinit.swg before the method calls, since some C compiler don't allow declaration in middle of function body. -2008-02-21: wsfulton +2009-02-21: wsfulton [Allegrocl] Fix seg fault wrapping some constant variable (%constant) types. -2008-02-20: wsfulton +2009-02-20: wsfulton [CFFI] Fix seg faults when for %extend and using statements. -2008-02-20: wsfulton +2009-02-20: wsfulton Fix SF #2605955: -co option which broke in 1.3.37. -2008-02-20: wsfulton +2009-02-20: wsfulton New %insert("begin") section added. Also can be used as %begin. This is a new code section reserved entirely for users and the code within the section is generated at the top of the C/C++ wrapper file and so provides a means to put custom code into the wrapper file before anything else that SWIG generates. -2008-02-17: wsfulton +2009-02-17: wsfulton 'make clean-test-suite' will now run clean on ALL languages. Previously it only ran the correctly configured languages. This way it is now possible to clean up properly after running 'make partialcheck-test-suite'. -2008-02-14: wsfulton +2009-02-14: wsfulton Extend attribute library support for structs/classes and the accessor functions use pass/return by value semantics. Two new macros are available and usage is identical to %attribute. These are %attributeval for structs/classes and %attributestring for string classes, like std::string. See attribute.swg for more details. -2008-02-13: wsfulton +2009-02-13: wsfulton Add support for %extend and memberin typemaps. Previously the memberin typemaps were ignored for member variables within a %extend block. -2008-02-12: wsfulton +2009-02-12: wsfulton Remove unnecessary temporary variable when wrapping return values that are references. Example of generated code for wrapping: @@ -82,15 +82,15 @@ Version 1.3.39 (in progress) ... result = (std::string *) &(arg1)->refReturn(); -2008-02-08: bhy +2009-02-08: bhy Change the SIZE mapped by %pybuffer_mutable_binary and %pybuffer_binary in pybuffer.i from the length of the buffer to the number of items in the buffer. -2008-02-08: wsfulton +2009-02-08: wsfulton Fix %feature not working for conversion operators, reported by Matt Sprague, for example: %feature("cs:methodmodifiers") operator bool "protected"; -2008-02-07: wsfulton +2009-02-07: wsfulton [MzScheme] Apply #2081967 configure changes for examples to build with recent PLT versions. Also fixes Makefile errors building SWIG executable when mzscheme package is installed (version 3.72 approx and later). From a863d31e81c8081db581d366fcce1a35cdd0bfe1 Mon Sep 17 00:00:00 2001 From: Haoyu Bai Date: Thu, 19 Mar 2009 15:26:57 +0000 Subject: [PATCH 0360/1680] Fix the memory leak related to Python 3 unicode and char * conversion. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11160 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 15 +++++++++++++++ Lib/python/pyerrors.swg | 4 +++- Lib/python/pyhead.swg | 20 +++++++++++++++++++- Lib/python/pyinit.swg | 4 +++- Lib/python/pyrun.swg | 14 ++++++++++---- Lib/python/pystrings.swg | 20 +++++++++++++++++--- 6 files changed, 67 insertions(+), 10 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 65cc144bb..0b6e2efe4 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,21 @@ Version 1.3.39 (in progress) ============================ +2009-03-19: bhy + [Python] Fix the memory leak related to Python 3 unicode and C char* conversion, + which can be shown in the following example before this fix: + + from li_cstring import * + i=0 + while True: + i += 1 + n = str(i)*10 + test3(n) + + This fix affected SWIG_AsCharPtrAndSize() so you cannot call this function with + a null alloc and non-null cptr argument in Python 3, otherwise a runtime error + will be raised. + 2009-03-18: wsfulton [C#] std::vector wrapper improvements for .NET 2 and also providing the necessary machinery to use the std::vector wrappers with more advanced features such diff --git a/Lib/python/pyerrors.swg b/Lib/python/pyerrors.swg index 63f0344e4..fe7313554 100644 --- a/Lib/python/pyerrors.swg +++ b/Lib/python/pyerrors.swg @@ -55,11 +55,13 @@ SWIG_Python_AddErrorMsg(const char* mesg) if (PyErr_Occurred()) PyErr_Fetch(&type, &value, &traceback); if (value) { + char *tmp; PyObject *old_str = PyObject_Str(value); PyErr_Clear(); Py_XINCREF(type); - PyErr_Format(type, "%s %s", SWIG_Python_str_AsChar(old_str), mesg); + PyErr_Format(type, "%s %s", tmp = SWIG_Python_str_AsChar(old_str), mesg); + SWIG_Python_str_DelForPy3(tmp); Py_DECREF(old_str); Py_DECREF(value); } else { diff --git a/Lib/python/pyhead.swg b/Lib/python/pyhead.swg index ecafc46c8..732d4689e 100644 --- a/Lib/python/pyhead.swg +++ b/Lib/python/pyhead.swg @@ -21,17 +21,35 @@ # define SWIG_Python_str_FromFormat PyString_FromFormat #endif + +/* Warning: This function will allocate a new string in Python 3, + * so please call SWIG_Python_str_DelForPy3(x) to free the space. + */ SWIGINTERN char* SWIG_Python_str_AsChar(PyObject *str) { #if PY_VERSION_HEX >= 0x03000000 + char *cstr; + char *newstr; + int len; str = PyUnicode_AsUTF8String(str); - return PyBytes_AsString(str); + PyBytes_AsStringAndSize(str, &cstr, &len); + newstr = (char *) malloc(len+1); + memcpy(newstr, cstr, len+1); + Py_XDECREF(str); + return newstr; #else return PyString_AsString(str); #endif } +#if PY_VERSION_HEX >= 0x03000000 +# define SWIG_Python_str_DelForPy3(x) free( (void*) (x) ) +#else +# define SWIG_Python_str_DelForPy3(x) +#endif + + SWIGINTERN PyObject* SWIG_Python_str_FromChar(const char *c) { diff --git a/Lib/python/pyinit.swg b/Lib/python/pyinit.swg index 5fa50ecb8..286e7fb68 100644 --- a/Lib/python/pyinit.swg +++ b/Lib/python/pyinit.swg @@ -80,9 +80,11 @@ swig_varlink_str(swig_varlinkobject *v) { SWIGINTERN int swig_varlink_print(swig_varlinkobject *v, FILE *fp, int SWIGUNUSEDPARM(flags)) { + char *tmp; PyObject *str = swig_varlink_str(v); fprintf(fp,"Swig global variables "); - fprintf(fp,"%s\n", SWIG_Python_str_AsChar(str)); + fprintf(fp,"%s\n", tmp = SWIG_Python_str_AsChar(str)); + SWIG_Python_str_DelForPy3(tmp); Py_DECREF(str); return 0; } diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index 30021bb48..5a1b1230e 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -407,13 +407,16 @@ SwigPyObject_repr(SwigPyObject *v, PyObject *args) SWIGRUNTIME int SwigPyObject_print(SwigPyObject *v, FILE *fp, int SWIGUNUSEDPARM(flags)) { + char *str; #ifdef METH_NOARGS PyObject *repr = SwigPyObject_repr(v); #else PyObject *repr = SwigPyObject_repr(v, NULL); #endif if (repr) { - fputs(SWIG_Python_str_AsChar(repr), fp); + str = SWIG_Python_str_AsChar(repr); + fputs(str, fp); + SWIG_Python_str_DelForPy3(str); Py_DECREF(repr); return 0; } else { @@ -1474,21 +1477,23 @@ SWIG_Python_TypeQuery(const char *type) SWIGRUNTIME int SWIG_Python_AddErrMesg(const char* mesg, int infront) -{ +{ if (PyErr_Occurred()) { PyObject *type = 0; PyObject *value = 0; PyObject *traceback = 0; PyErr_Fetch(&type, &value, &traceback); if (value) { + char *tmp; PyObject *old_str = PyObject_Str(value); Py_XINCREF(type); PyErr_Clear(); if (infront) { - PyErr_Format(type, "%s %s", mesg, SWIG_Python_str_AsChar(old_str)); + PyErr_Format(type, "%s %s", mesg, tmp = SWIG_Python_str_AsChar(old_str)); } else { - PyErr_Format(type, "%s %s", SWIG_Python_str_AsChar(old_str), mesg); + PyErr_Format(type, "%s %s", tmp = SWIG_Python_str_AsChar(old_str), mesg); } + SWIG_Python_str_DelForPy3(tmp); Py_DECREF(old_str); } return 1; @@ -1540,6 +1545,7 @@ SWIG_Python_TypeError(const char *type, PyObject *obj) if (cstr) { PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s(%s)' is received", type, otype, cstr); + SWIG_Python_str_DelForPy3(cstr); } else { PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s' is received", type, otype); diff --git a/Lib/python/pystrings.swg b/Lib/python/pystrings.swg index 5a06792d7..1983037a5 100644 --- a/Lib/python/pystrings.swg +++ b/Lib/python/pystrings.swg @@ -6,19 +6,27 @@ SWIGINTERN int SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc) { %#if PY_VERSION_HEX>=0x03000000 - if (PyUnicode_Check(obj)) + if (PyUnicode_Check(obj)) %#else - if (PyString_Check(obj)) + if (PyString_Check(obj)) %#endif { char *cstr; Py_ssize_t len; %#if PY_VERSION_HEX>=0x03000000 + if (!alloc && cptr) { + /* We can't allow converting without allocation, since the internal + representation of string in Python 3 is UCS-2/UCS-4 but we require + a UTF-8 representation. + TODO(bhy) More detailed explanation */ + return SWIG_RuntimeError; + } obj = PyUnicode_AsUTF8String(obj); PyBytes_AsStringAndSize(obj, &cstr, &len); + if(alloc) *alloc = SWIG_NEWOBJ; %#else PyString_AsStringAndSize(obj, &cstr, &len); %#endif - if (cptr) { + if (cptr) { if (alloc) { /* In python the user should not be able to modify the inner @@ -43,10 +51,16 @@ SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc) *alloc = SWIG_OLDOBJ; } } else { + %#if PY_VERSION_HEX>=0x03000000 + assert(0); /* Should never reach here in Python 3 */ + %#endif *cptr = SWIG_Python_str_AsChar(obj); } } if (psize) *psize = len + 1; +%#if PY_VERSION_HEX>=0x03000000 + Py_XDECREF(obj); +%#endif return SWIG_OK; } else { swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); From 0c5979a8d81bf222be65ef9f21d214ca34a29b6c Mon Sep 17 00:00:00 2001 From: Haoyu Bai Date: Thu, 19 Mar 2009 16:56:01 +0000 Subject: [PATCH 0361/1680] Fix problem caused by thread not properly terminated in director_thread test. This was cause crash in Python 3 git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11161 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/director_thread.i | 19 ++++++++++++++++++- .../python/director_thread_runme.py | 2 ++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/Examples/test-suite/director_thread.i b/Examples/test-suite/director_thread.i index 4f4e55cfe..2732eb907 100644 --- a/Examples/test-suite/director_thread.i +++ b/Examples/test-suite/director_thread.i @@ -13,6 +13,7 @@ #include #else #include +#include #include #endif @@ -27,6 +28,8 @@ extern "C" { void* working(void* t); pthread_t thread; #endif + static int thread_terminate = 0; + } %} @@ -51,6 +54,15 @@ extern "C" { virtual ~Foo() { } + void stop() { + thread_terminate = 1; + %#ifdef _WIN32 + /*TODO(bhy) what to do for win32? */ + %#else + pthread_join(thread, NULL); + %#endif + } + void run() { %#ifdef _WIN32 _beginthreadex(NULL,0,working,this,0,&thread_id); @@ -75,10 +87,15 @@ extern "C" { #endif { Foo* f = static_cast(t); - while (1) { + while ( ! thread_terminate ) { MilliSecondSleep(50); f->do_foo(); } +#ifdef _WIN32 + /* TODO(bhy) what's the corresponding of pthread_exit in win32? */ +#else + pthread_exit(0); +#endif return 0; } } diff --git a/Examples/test-suite/python/director_thread_runme.py b/Examples/test-suite/python/director_thread_runme.py index e66817e17..15a12ab80 100644 --- a/Examples/test-suite/python/director_thread_runme.py +++ b/Examples/test-suite/python/director_thread_runme.py @@ -14,3 +14,5 @@ d.run() if d.val >= 0: print d.val raise RuntimeError + +d.stop() From 128884b428cc63a0fcec641ba9912c5a01762222 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 20 Mar 2009 23:29:36 +0000 Subject: [PATCH 0362/1680] final touches for 1.3.39 release git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11163 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- ANNOUNCE | 2 +- CHANGES.current | 4 ++-- Doc/Manual/Sections.html | 2 +- README | 2 +- TODO | 2 -- 5 files changed, 5 insertions(+), 7 deletions(-) diff --git a/ANNOUNCE b/ANNOUNCE index 45470f16e..ded11fbb5 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -1,4 +1,4 @@ -*** ANNOUNCE: SWIG 1.3.39 (in progress) *** +*** ANNOUNCE: SWIG 1.3.39 (21 March 2009) *** http://www.swig.org diff --git a/CHANGES.current b/CHANGES.current index 0b6e2efe4..9d74353eb 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,5 +1,5 @@ -Version 1.3.39 (in progress) -============================ +Version 1.3.39 (21 March 2009) +============================== 2009-03-19: bhy [Python] Fix the memory leak related to Python 3 unicode and C char* conversion, diff --git a/Doc/Manual/Sections.html b/Doc/Manual/Sections.html index 364be15db..b6f5402f6 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.39 (in progress) +Last update : SWIG-1.3.39 (21 March 2009)

      Sections

      diff --git a/README b/README index 6f321d949..6648bd67e 100644 --- a/README +++ b/README @@ -1,6 +1,6 @@ SWIG (Simplified Wrapper and Interface Generator) -Version: 1.3.38 (31 January 2009) +Version: 1.3.39 (21 March 2009) Tagline: SWIG is a compiler that integrates C and C++ with languages including Perl, Python, Tcl, Ruby, PHP, Java, Ocaml, Lua, diff --git a/TODO b/TODO index 7e6d3f005..879e65f1f 100644 --- a/TODO +++ b/TODO @@ -1,7 +1,5 @@ SWIG TO-DO -Release: SWIG-1.3.39 - ----------------------------------------------------------------------------- **** = High Priority From 2c71ee47fb50cb2f88bbc41237dae1dc511d7985 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 20 Mar 2009 23:35:52 +0000 Subject: [PATCH 0363/1680] add summary for 1.3.39 release git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11164 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- README | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README b/README index 6648bd67e..9657a03c3 100644 --- a/README +++ b/README @@ -91,6 +91,12 @@ A SWIG FAQ and other hints can be found on the SWIG Wiki: What's New? =========== +SWIG-1.3.39 summary: +- Some new small feature enhancements. +- Improved C# std::vector wrappers. +- Bug fixes: mainly Python, but also Perl, MzScheme, CFFI, Allegrocl + and Ruby + SWIG-1.3.38 summary: - Output directory regression fix and other minor bug fixes From 65f79a952cc244ba33f2de1e59dbbf3377576009 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 20 Mar 2009 23:40:39 +0000 Subject: [PATCH 0364/1680] Apply small documentation fix - patch #2579863 git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11165 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Ruby.html | 2 +- Examples/ruby/free_function/example.i | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Doc/Manual/Ruby.html b/Doc/Manual/Ruby.html index 7360f732d..2070db0c0 100644 --- a/Doc/Manual/Ruby.html +++ b/Doc/Manual/Ruby.html @@ -10567,7 +10567,7 @@ existing Ruby object to the destroyed C++ object and raise an exception.
      -
      %module example

      %{
      #include "example.h"
      %}

      /* Specify that ownership is transferred to the zoo
      when calling add_animal */
      %apply SWIGTYPE *DISOWN { Animal* animal };

      /* Track objects */
      %trackobjects;

      /* Specify the mark function */
      %freefunc Zoo "free_Zoo";

      %include "example.h"

      %header %{
      static void free_Zoo(void* ptr) {
      Zoo* zoo = (Zoo*) ptr;

      /* Loop over each animal */
      int count = zoo->get_num_animals();

      for(int i = 0; i < count; ++i) {
      /* Get an animal */
      Animal* animal = zoo->get_animal(i);

      /* Unlink the Ruby object from the C++ object */
      SWIG_RubyUnlinkObjects(animal);

      /* Now remove the tracking for this animal */
      SWIG_RubyRemoveTracking(animal);
      }

      /* Now call SWIG_RemoveMapping for the zoo */
      SWIG_RemoveMapping(ptr);

      /* Now free the zoo which will free the animals it contains */
      delete zoo;
      }
      %}
      +
      %module example

      %{
      #include "example.h"
      %}

      /* Specify that ownership is transferred to the zoo
      when calling add_animal */
      %apply SWIGTYPE *DISOWN { Animal* animal };

      /* Track objects */
      %trackobjects;

      /* Specify the mark function */
      %freefunc Zoo "free_Zoo";

      %include "example.h"

      %header %{
      static void free_Zoo(void* ptr) {
      Zoo* zoo = (Zoo*) ptr;

      /* Loop over each animal */
      int count = zoo->get_num_animals();

      for(int i = 0; i < count; ++i) {
      /* Get an animal */
      Animal* animal = zoo->get_animal(i);

      /* Unlink the Ruby object from the C++ object */
      SWIG_RubyUnlinkObjects(animal);

      /* Now remove the tracking for this animal */
      SWIG_RubyRemoveTracking(animal);
      }

      /* Now call SWIG_RubyRemoveTracking for the zoo */
      SWIG_RubyRemoveTracking(ptr);

      /* Now free the zoo which will free the animals it contains */
      delete zoo;
      }
      %}
      diff --git a/Examples/ruby/free_function/example.i b/Examples/ruby/free_function/example.i index 5ab29bd58..a446b3f99 100644 --- a/Examples/ruby/free_function/example.i +++ b/Examples/ruby/free_function/example.i @@ -20,7 +20,7 @@ static void free_Zoo(void* ptr) { Zoo* zoo = (Zoo*) ptr; - /* Loop over each object and call SWIG_RemoveMapping */ + /* Loop over each object and call SWIG_RubyRemoveTracking */ int count = zoo->get_num_animals(); for(int i = 0; i < count; ++i) { @@ -32,7 +32,7 @@ SWIG_RubyRemoveTracking(animal); } - /* Now call SWIG_RemoveMapping for the zoo */ + /* Now call SWIG_RubyRemoveTracking for the zoo */ SWIG_RubyRemoveTracking(ptr); /* Now free the zoo which will free the animals it contains */ From 48203afbd0bac33a0ce8176d681ad33ff5c50217 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 20 Mar 2009 23:54:43 +0000 Subject: [PATCH 0365/1680] invoke using swig.exe instead of just swig in Visual Studio project files git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11166 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/perl5/class/example.dsp | 4 ++-- Examples/perl5/import/bar.dsp | 4 ++-- Examples/perl5/import/base.dsp | 4 ++-- Examples/perl5/import/foo.dsp | 4 ++-- Examples/perl5/import/spam.dsp | 4 ++-- Examples/perl5/multimap/example.dsp | 4 ++-- Examples/perl5/simple/example.dsp | 4 ++-- Examples/python/class/example.dsp | 4 ++-- Examples/python/contract/example.dsp | 4 ++-- Examples/python/import/bar.dsp | 4 ++-- Examples/python/import/base.dsp | 4 ++-- Examples/python/import/foo.dsp | 4 ++-- Examples/python/import/spam.dsp | 4 ++-- Examples/python/multimap/example.dsp | 4 ++-- Examples/python/simple/example.dsp | 4 ++-- Examples/r/class/example.dsp | 4 ++-- Examples/r/simple/example.dsp | 4 ++-- Examples/ruby/class/example.dsp | 4 ++-- Examples/ruby/free_function/example.dsp | 4 ++-- Examples/ruby/import/bar.dsp | 4 ++-- Examples/ruby/import/base.dsp | 4 ++-- Examples/ruby/import/foo.dsp | 4 ++-- Examples/ruby/import/spam.dsp | 4 ++-- Examples/ruby/mark_function/example.dsp | 4 ++-- Examples/ruby/multimap/example.dsp | 4 ++-- Examples/ruby/simple/example.dsp | 4 ++-- Examples/tcl/class/example.dsp | 4 ++-- Examples/tcl/contract/example.dsp | 4 ++-- Examples/tcl/import/bar.dsp | 4 ++-- Examples/tcl/import/base.dsp | 4 ++-- Examples/tcl/import/foo.dsp | 4 ++-- Examples/tcl/import/spam.dsp | 4 ++-- Examples/tcl/multimap/example.dsp | 4 ++-- Examples/tcl/simple/example.dsp | 4 ++-- 34 files changed, 68 insertions(+), 68 deletions(-) diff --git a/Examples/perl5/class/example.dsp b/Examples/perl5/class/example.dsp index bbdedc094..b5ccd1928 100644 --- a/Examples/perl5/class/example.dsp +++ b/Examples/perl5/class/example.dsp @@ -126,7 +126,7 @@ InputName=example echo PERL5_INCLUDE: %PERL5_INCLUDE% echo PERL5_LIB: %PERL5_LIB% echo on - ..\..\..\swig -c++ -perl5 $(InputPath) + ..\..\..\swig.exe -c++ -perl5 $(InputPath) # End Custom Build @@ -141,7 +141,7 @@ InputName=example echo PERL5_INCLUDE: %PERL5_INCLUDE% echo PERL5_LIB: %PERL5_LIB% echo on - ..\..\..\swig -c++ -perl5 $(InputPath) + ..\..\..\swig.exe -c++ -perl5 $(InputPath) # End Custom Build diff --git a/Examples/perl5/import/bar.dsp b/Examples/perl5/import/bar.dsp index 682c21757..64786b8f6 100644 --- a/Examples/perl5/import/bar.dsp +++ b/Examples/perl5/import/bar.dsp @@ -118,7 +118,7 @@ InputName=bar echo PERL5_INCLUDE: %PERL5_INCLUDE% echo PERL5_LIB: %PERL5_LIB% echo on - ..\..\..\swig -c++ -perl5 $(InputPath) + ..\..\..\swig.exe -c++ -perl5 $(InputPath) # End Custom Build @@ -133,7 +133,7 @@ InputName=bar echo PERL5_INCLUDE: %PERL5_INCLUDE% echo PERL5_LIB: %PERL5_LIB% echo on - ..\..\..\swig -c++ -perl5 $(InputPath) + ..\..\..\swig.exe -c++ -perl5 $(InputPath) # End Custom Build diff --git a/Examples/perl5/import/base.dsp b/Examples/perl5/import/base.dsp index 7a0ea8027..920891cbf 100644 --- a/Examples/perl5/import/base.dsp +++ b/Examples/perl5/import/base.dsp @@ -118,7 +118,7 @@ InputName=base echo PERL5_INCLUDE: %PERL5_INCLUDE% echo PERL5_LIB: %PERL5_LIB% echo on - ..\..\..\swig -c++ -perl5 $(InputPath) + ..\..\..\swig.exe -c++ -perl5 $(InputPath) # End Custom Build @@ -133,7 +133,7 @@ InputName=base echo PERL5_INCLUDE: %PERL5_INCLUDE% echo PERL5_LIB: %PERL5_LIB% echo on - ..\..\..\swig -c++ -perl5 $(InputPath) + ..\..\..\swig.exe -c++ -perl5 $(InputPath) # End Custom Build diff --git a/Examples/perl5/import/foo.dsp b/Examples/perl5/import/foo.dsp index 755560165..d519a5316 100644 --- a/Examples/perl5/import/foo.dsp +++ b/Examples/perl5/import/foo.dsp @@ -118,7 +118,7 @@ InputName=foo echo PERL5_INCLUDE: %PERL5_INCLUDE% echo PERL5_LIB: %PERL5_LIB% echo on - ..\..\..\swig -c++ -perl5 $(InputPath) + ..\..\..\swig.exe -c++ -perl5 $(InputPath) # End Custom Build @@ -133,7 +133,7 @@ InputName=foo echo PERL5_INCLUDE: %PERL5_INCLUDE% echo PERL5_LIB: %PERL5_LIB% echo on - ..\..\..\swig -c++ -perl5 $(InputPath) + ..\..\..\swig.exe -c++ -perl5 $(InputPath) # End Custom Build diff --git a/Examples/perl5/import/spam.dsp b/Examples/perl5/import/spam.dsp index ed41de36b..e5c8046eb 100644 --- a/Examples/perl5/import/spam.dsp +++ b/Examples/perl5/import/spam.dsp @@ -118,7 +118,7 @@ InputName=spam echo PERL5_INCLUDE: %PERL5_INCLUDE% echo PERL5_LIB: %PERL5_LIB% echo on - ..\..\..\swig -c++ -perl5 $(InputPath) + ..\..\..\swig.exe -c++ -perl5 $(InputPath) # End Custom Build @@ -133,7 +133,7 @@ InputName=spam echo PERL5_INCLUDE: %PERL5_INCLUDE% echo PERL5_LIB: %PERL5_LIB% echo on - ..\..\..\swig -c++ -perl5 $(InputPath) + ..\..\..\swig.exe -c++ -perl5 $(InputPath) # End Custom Build diff --git a/Examples/perl5/multimap/example.dsp b/Examples/perl5/multimap/example.dsp index 2d295763b..be8a0070e 100644 --- a/Examples/perl5/multimap/example.dsp +++ b/Examples/perl5/multimap/example.dsp @@ -122,7 +122,7 @@ InputName=example echo PERL5_INCLUDE: %PERL5_INCLUDE% echo PERL5_LIB: %PERL5_LIB% echo on - ..\..\..\swig -perl5 $(InputPath) + ..\..\..\swig.exe -perl5 $(InputPath) # End Custom Build @@ -137,7 +137,7 @@ InputName=example echo PERL5_INCLUDE: %PERL5_INCLUDE% echo PERL5_LIB: %PERL5_LIB% echo on - ..\..\..\swig -perl5 $(InputPath) + ..\..\..\swig.exe -perl5 $(InputPath) # End Custom Build diff --git a/Examples/perl5/simple/example.dsp b/Examples/perl5/simple/example.dsp index 2d295763b..be8a0070e 100644 --- a/Examples/perl5/simple/example.dsp +++ b/Examples/perl5/simple/example.dsp @@ -122,7 +122,7 @@ InputName=example echo PERL5_INCLUDE: %PERL5_INCLUDE% echo PERL5_LIB: %PERL5_LIB% echo on - ..\..\..\swig -perl5 $(InputPath) + ..\..\..\swig.exe -perl5 $(InputPath) # End Custom Build @@ -137,7 +137,7 @@ InputName=example echo PERL5_INCLUDE: %PERL5_INCLUDE% echo PERL5_LIB: %PERL5_LIB% echo on - ..\..\..\swig -perl5 $(InputPath) + ..\..\..\swig.exe -perl5 $(InputPath) # End Custom Build diff --git a/Examples/python/class/example.dsp b/Examples/python/class/example.dsp index dccba46b0..fd7bf8c06 100644 --- a/Examples/python/class/example.dsp +++ b/Examples/python/class/example.dsp @@ -126,7 +126,7 @@ InputName=example echo PYTHON_INCLUDE: %PYTHON_INCLUDE% echo PYTHON_LIB: %PYTHON_LIB% echo on - ..\..\..\swig -c++ -python $(InputPath) + ..\..\..\swig.exe -c++ -python $(InputPath) # End Custom Build @@ -141,7 +141,7 @@ InputName=example echo PYTHON_INCLUDE: %PYTHON_INCLUDE% echo PYTHON_LIB: %PYTHON_LIB% echo on - ..\..\..\swig -c++ -python $(InputPath) + ..\..\..\swig.exe -c++ -python $(InputPath) # End Custom Build diff --git a/Examples/python/contract/example.dsp b/Examples/python/contract/example.dsp index 7a32f4dc1..32845e0e8 100644 --- a/Examples/python/contract/example.dsp +++ b/Examples/python/contract/example.dsp @@ -122,7 +122,7 @@ InputName=example echo PYTHON_INCLUDE: %PYTHON_INCLUDE% echo PYTHON_LIB: %PYTHON_LIB% echo on - ..\..\..\swig -python $(InputPath) + ..\..\..\swig.exe -python $(InputPath) # End Custom Build @@ -137,7 +137,7 @@ InputName=example echo PYTHON_INCLUDE: %PYTHON_INCLUDE% echo PYTHON_LIB: %PYTHON_LIB% echo on - ..\..\..\swig -python $(InputPath) + ..\..\..\swig.exe -python $(InputPath) # End Custom Build diff --git a/Examples/python/import/bar.dsp b/Examples/python/import/bar.dsp index edb45811b..17b05cc39 100644 --- a/Examples/python/import/bar.dsp +++ b/Examples/python/import/bar.dsp @@ -118,7 +118,7 @@ InputName=bar echo PYTHON_INCLUDE: %PYTHON_INCLUDE% echo PYTHON_LIB: %PYTHON_LIB% echo on - ..\..\..\swig -c++ -python $(InputPath) + ..\..\..\swig.exe -c++ -python $(InputPath) # End Custom Build @@ -133,7 +133,7 @@ InputName=bar echo PYTHON_INCLUDE: %PYTHON_INCLUDE% echo PYTHON_LIB: %PYTHON_LIB% echo on - ..\..\..\swig -c++ -python $(InputPath) + ..\..\..\swig.exe -c++ -python $(InputPath) # End Custom Build diff --git a/Examples/python/import/base.dsp b/Examples/python/import/base.dsp index 0ddb65157..2bc9736d1 100644 --- a/Examples/python/import/base.dsp +++ b/Examples/python/import/base.dsp @@ -118,7 +118,7 @@ InputName=base echo PYTHON_INCLUDE: %PYTHON_INCLUDE% echo PYTHON_LIB: %PYTHON_LIB% echo on - ..\..\..\swig -c++ -python $(InputPath) + ..\..\..\swig.exe -c++ -python $(InputPath) # End Custom Build @@ -133,7 +133,7 @@ InputName=base echo PYTHON_INCLUDE: %PYTHON_INCLUDE% echo PYTHON_LIB: %PYTHON_LIB% echo on - ..\..\..\swig -c++ -python $(InputPath) + ..\..\..\swig.exe -c++ -python $(InputPath) # End Custom Build diff --git a/Examples/python/import/foo.dsp b/Examples/python/import/foo.dsp index 86e11699f..9a92c4b85 100644 --- a/Examples/python/import/foo.dsp +++ b/Examples/python/import/foo.dsp @@ -118,7 +118,7 @@ InputName=foo echo PYTHON_INCLUDE: %PYTHON_INCLUDE% echo PYTHON_LIB: %PYTHON_LIB% echo on - ..\..\..\swig -c++ -python $(InputPath) + ..\..\..\swig.exe -c++ -python $(InputPath) # End Custom Build @@ -133,7 +133,7 @@ InputName=foo echo PYTHON_INCLUDE: %PYTHON_INCLUDE% echo PYTHON_LIB: %PYTHON_LIB% echo on - ..\..\..\swig -c++ -python $(InputPath) + ..\..\..\swig.exe -c++ -python $(InputPath) # End Custom Build diff --git a/Examples/python/import/spam.dsp b/Examples/python/import/spam.dsp index 7245f7a7c..0a6595bfe 100644 --- a/Examples/python/import/spam.dsp +++ b/Examples/python/import/spam.dsp @@ -118,7 +118,7 @@ InputName=spam echo PYTHON_INCLUDE: %PYTHON_INCLUDE% echo PYTHON_LIB: %PYTHON_LIB% echo on - ..\..\..\swig -c++ -python $(InputPath) + ..\..\..\swig.exe -c++ -python $(InputPath) # End Custom Build @@ -133,7 +133,7 @@ InputName=spam echo PYTHON_INCLUDE: %PYTHON_INCLUDE% echo PYTHON_LIB: %PYTHON_LIB% echo on - ..\..\..\swig -c++ -python $(InputPath) + ..\..\..\swig.exe -c++ -python $(InputPath) # End Custom Build diff --git a/Examples/python/multimap/example.dsp b/Examples/python/multimap/example.dsp index 7a32f4dc1..32845e0e8 100644 --- a/Examples/python/multimap/example.dsp +++ b/Examples/python/multimap/example.dsp @@ -122,7 +122,7 @@ InputName=example echo PYTHON_INCLUDE: %PYTHON_INCLUDE% echo PYTHON_LIB: %PYTHON_LIB% echo on - ..\..\..\swig -python $(InputPath) + ..\..\..\swig.exe -python $(InputPath) # End Custom Build @@ -137,7 +137,7 @@ InputName=example echo PYTHON_INCLUDE: %PYTHON_INCLUDE% echo PYTHON_LIB: %PYTHON_LIB% echo on - ..\..\..\swig -python $(InputPath) + ..\..\..\swig.exe -python $(InputPath) # End Custom Build diff --git a/Examples/python/simple/example.dsp b/Examples/python/simple/example.dsp index 7a32f4dc1..32845e0e8 100644 --- a/Examples/python/simple/example.dsp +++ b/Examples/python/simple/example.dsp @@ -122,7 +122,7 @@ InputName=example echo PYTHON_INCLUDE: %PYTHON_INCLUDE% echo PYTHON_LIB: %PYTHON_LIB% echo on - ..\..\..\swig -python $(InputPath) + ..\..\..\swig.exe -python $(InputPath) # End Custom Build @@ -137,7 +137,7 @@ InputName=example echo PYTHON_INCLUDE: %PYTHON_INCLUDE% echo PYTHON_LIB: %PYTHON_LIB% echo on - ..\..\..\swig -python $(InputPath) + ..\..\..\swig.exe -python $(InputPath) # End Custom Build diff --git a/Examples/r/class/example.dsp b/Examples/r/class/example.dsp index 682b156fb..b831989cc 100644 --- a/Examples/r/class/example.dsp +++ b/Examples/r/class/example.dsp @@ -126,7 +126,7 @@ InputName=example echo R_INCLUDE: %R_INCLUDE% echo R_LIB: %R_LIB% echo on - ..\..\..\swig -c++ -r -o example_wrap.cpp $(InputPath) + ..\..\..\swig.exe -c++ -r -o example_wrap.cpp $(InputPath) # End Custom Build @@ -141,7 +141,7 @@ InputName=example echo R_INCLUDE: %R_INCLUDE% echo R_LIB: %R_LIB% echo on - ..\..\..\swig -c++ -r -o example_wrap.cpp $(InputPath) + ..\..\..\swig.exe -c++ -r -o example_wrap.cpp $(InputPath) # End Custom Build diff --git a/Examples/r/simple/example.dsp b/Examples/r/simple/example.dsp index aaa5ef8e0..356815d19 100644 --- a/Examples/r/simple/example.dsp +++ b/Examples/r/simple/example.dsp @@ -122,7 +122,7 @@ InputName=example echo R_INCLUDE: %R_INCLUDE% echo R_LIB: %R_LIB% echo on - ..\..\..\swig -r $(InputPath) + ..\..\..\swig.exe -r $(InputPath) # End Custom Build @@ -137,7 +137,7 @@ InputName=example echo R_INCLUDE: %R_INCLUDE% echo R_LIB: %R_LIB% echo on - ..\..\..\swig -r $(InputPath) + ..\..\..\swig.exe -r $(InputPath) # End Custom Build diff --git a/Examples/ruby/class/example.dsp b/Examples/ruby/class/example.dsp index 9a26322ec..2adab787a 100644 --- a/Examples/ruby/class/example.dsp +++ b/Examples/ruby/class/example.dsp @@ -128,7 +128,7 @@ InputName=example echo RUBY_INCLUDE: %RUBY_INCLUDE% echo RUBY_LIB: %RUBY_LIB% echo on - ..\..\..\swig -c++ -ruby $(InputPath) + ..\..\..\swig.exe -c++ -ruby $(InputPath) # End Custom Build @@ -143,7 +143,7 @@ InputName=example echo RUBY_INCLUDE: %RUBY_INCLUDE% echo RUBY_LIB: %RUBY_LIB% echo on - ..\..\..\swig -c++ -ruby $(InputPath) + ..\..\..\swig.exe -c++ -ruby $(InputPath) # End Custom Build diff --git a/Examples/ruby/free_function/example.dsp b/Examples/ruby/free_function/example.dsp index 9a26322ec..2adab787a 100644 --- a/Examples/ruby/free_function/example.dsp +++ b/Examples/ruby/free_function/example.dsp @@ -128,7 +128,7 @@ InputName=example echo RUBY_INCLUDE: %RUBY_INCLUDE% echo RUBY_LIB: %RUBY_LIB% echo on - ..\..\..\swig -c++ -ruby $(InputPath) + ..\..\..\swig.exe -c++ -ruby $(InputPath) # End Custom Build @@ -143,7 +143,7 @@ InputName=example echo RUBY_INCLUDE: %RUBY_INCLUDE% echo RUBY_LIB: %RUBY_LIB% echo on - ..\..\..\swig -c++ -ruby $(InputPath) + ..\..\..\swig.exe -c++ -ruby $(InputPath) # End Custom Build diff --git a/Examples/ruby/import/bar.dsp b/Examples/ruby/import/bar.dsp index dd09ca021..29d9abf2f 100644 --- a/Examples/ruby/import/bar.dsp +++ b/Examples/ruby/import/bar.dsp @@ -120,7 +120,7 @@ InputName=bar echo RUBY_INCLUDE: %RUBY_INCLUDE% echo RUBY_LIB: %RUBY_LIB% echo on - ..\..\..\swig -c++ -ruby $(InputPath) + ..\..\..\swig.exe -c++ -ruby $(InputPath) # End Custom Build @@ -135,7 +135,7 @@ InputName=bar echo RUBY_INCLUDE: %RUBY_INCLUDE% echo RUBY_LIB: %RUBY_LIB% echo on - ..\..\..\swig -c++ -ruby $(InputPath) + ..\..\..\swig.exe -c++ -ruby $(InputPath) # End Custom Build diff --git a/Examples/ruby/import/base.dsp b/Examples/ruby/import/base.dsp index 2bd4fa243..174afef3e 100644 --- a/Examples/ruby/import/base.dsp +++ b/Examples/ruby/import/base.dsp @@ -120,7 +120,7 @@ InputName=base echo RUBY_INCLUDE: %RUBY_INCLUDE% echo RUBY_LIB: %RUBY_LIB% echo on - ..\..\..\swig -c++ -ruby $(InputPath) + ..\..\..\swig.exe -c++ -ruby $(InputPath) # End Custom Build @@ -135,7 +135,7 @@ InputName=base echo RUBY_INCLUDE: %RUBY_INCLUDE% echo RUBY_LIB: %RUBY_LIB% echo on - ..\..\..\swig -c++ -ruby $(InputPath) + ..\..\..\swig.exe -c++ -ruby $(InputPath) # End Custom Build diff --git a/Examples/ruby/import/foo.dsp b/Examples/ruby/import/foo.dsp index 2a764bbd7..7f4754915 100644 --- a/Examples/ruby/import/foo.dsp +++ b/Examples/ruby/import/foo.dsp @@ -120,7 +120,7 @@ InputName=foo echo RUBY_INCLUDE: %RUBY_INCLUDE% echo RUBY_LIB: %RUBY_LIB% echo on - ..\..\..\swig -c++ -ruby $(InputPath) + ..\..\..\swig.exe -c++ -ruby $(InputPath) # End Custom Build @@ -135,7 +135,7 @@ InputName=foo echo RUBY_INCLUDE: %RUBY_INCLUDE% echo RUBY_LIB: %RUBY_LIB% echo on - ..\..\..\swig -c++ -ruby $(InputPath) + ..\..\..\swig.exe -c++ -ruby $(InputPath) # End Custom Build diff --git a/Examples/ruby/import/spam.dsp b/Examples/ruby/import/spam.dsp index d2d7158bb..72729f290 100644 --- a/Examples/ruby/import/spam.dsp +++ b/Examples/ruby/import/spam.dsp @@ -120,7 +120,7 @@ InputName=spam echo RUBY_INCLUDE: %RUBY_INCLUDE% echo RUBY_LIB: %RUBY_LIB% echo on - ..\..\..\swig -c++ -ruby $(InputPath) + ..\..\..\swig.exe -c++ -ruby $(InputPath) # End Custom Build @@ -135,7 +135,7 @@ InputName=spam echo RUBY_INCLUDE: %RUBY_INCLUDE% echo RUBY_LIB: %RUBY_LIB% echo on - ..\..\..\swig -c++ -ruby $(InputPath) + ..\..\..\swig.exe -c++ -ruby $(InputPath) # End Custom Build diff --git a/Examples/ruby/mark_function/example.dsp b/Examples/ruby/mark_function/example.dsp index 9a26322ec..2adab787a 100644 --- a/Examples/ruby/mark_function/example.dsp +++ b/Examples/ruby/mark_function/example.dsp @@ -128,7 +128,7 @@ InputName=example echo RUBY_INCLUDE: %RUBY_INCLUDE% echo RUBY_LIB: %RUBY_LIB% echo on - ..\..\..\swig -c++ -ruby $(InputPath) + ..\..\..\swig.exe -c++ -ruby $(InputPath) # End Custom Build @@ -143,7 +143,7 @@ InputName=example echo RUBY_INCLUDE: %RUBY_INCLUDE% echo RUBY_LIB: %RUBY_LIB% echo on - ..\..\..\swig -c++ -ruby $(InputPath) + ..\..\..\swig.exe -c++ -ruby $(InputPath) # End Custom Build diff --git a/Examples/ruby/multimap/example.dsp b/Examples/ruby/multimap/example.dsp index ccb99d44d..4888299f5 100644 --- a/Examples/ruby/multimap/example.dsp +++ b/Examples/ruby/multimap/example.dsp @@ -124,7 +124,7 @@ InputName=example echo RUBY_INCLUDE: %RUBY_INCLUDE% echo RUBY_LIB: %RUBY_LIB% echo on - ..\..\..\swig -ruby $(InputPath) + ..\..\..\swig.exe -ruby $(InputPath) # End Custom Build @@ -139,7 +139,7 @@ InputName=example echo RUBY_INCLUDE: %RUBY_INCLUDE% echo RUBY_LIB: %RUBY_LIB% echo on - ..\..\..\swig -ruby $(InputPath) + ..\..\..\swig.exe -ruby $(InputPath) # End Custom Build diff --git a/Examples/ruby/simple/example.dsp b/Examples/ruby/simple/example.dsp index ccb99d44d..4888299f5 100644 --- a/Examples/ruby/simple/example.dsp +++ b/Examples/ruby/simple/example.dsp @@ -124,7 +124,7 @@ InputName=example echo RUBY_INCLUDE: %RUBY_INCLUDE% echo RUBY_LIB: %RUBY_LIB% echo on - ..\..\..\swig -ruby $(InputPath) + ..\..\..\swig.exe -ruby $(InputPath) # End Custom Build @@ -139,7 +139,7 @@ InputName=example echo RUBY_INCLUDE: %RUBY_INCLUDE% echo RUBY_LIB: %RUBY_LIB% echo on - ..\..\..\swig -ruby $(InputPath) + ..\..\..\swig.exe -ruby $(InputPath) # End Custom Build diff --git a/Examples/tcl/class/example.dsp b/Examples/tcl/class/example.dsp index bf6149407..0ff54829f 100644 --- a/Examples/tcl/class/example.dsp +++ b/Examples/tcl/class/example.dsp @@ -126,7 +126,7 @@ InputName=example echo TCL_INCLUDE: %TCL_INCLUDE% echo TCL_LIB: %TCL_LIB% echo on - ..\..\..\swig -c++ -tcl8 $(InputPath) + ..\..\..\swig.exe -c++ -tcl8 $(InputPath) # End Custom Build @@ -141,7 +141,7 @@ InputName=example echo TCL_INCLUDE: %TCL_INCLUDE% echo TCL_LIB: %TCL_LIB% echo on - ..\..\..\swig -c++ -tcl8 $(InputPath) + ..\..\..\swig.exe -c++ -tcl8 $(InputPath) # End Custom Build diff --git a/Examples/tcl/contract/example.dsp b/Examples/tcl/contract/example.dsp index 296cb313b..c1568f2c5 100644 --- a/Examples/tcl/contract/example.dsp +++ b/Examples/tcl/contract/example.dsp @@ -122,7 +122,7 @@ InputName=example echo TCL_INCLUDE: %TCL_INCLUDE% echo TCL_LIB: %TCL_LIB% echo on - ..\..\..\swig -tcl8 $(InputPath) + ..\..\..\swig.exe -tcl8 $(InputPath) # End Custom Build @@ -137,7 +137,7 @@ InputName=example echo TCL_INCLUDE: %TCL_INCLUDE% echo TCL_LIB: %TCL_LIB% echo on - ..\..\..\swig -tcl8 $(InputPath) + ..\..\..\swig.exe -tcl8 $(InputPath) # End Custom Build diff --git a/Examples/tcl/import/bar.dsp b/Examples/tcl/import/bar.dsp index 35b4e608b..d22b6a6fa 100644 --- a/Examples/tcl/import/bar.dsp +++ b/Examples/tcl/import/bar.dsp @@ -118,7 +118,7 @@ InputName=bar echo TCL_INCLUDE: %TCL_INCLUDE% echo TCL_LIB: %TCL_LIB% echo on - ..\..\..\swig -c++ -tcl8 $(InputPath) + ..\..\..\swig.exe -c++ -tcl8 $(InputPath) # End Custom Build @@ -133,7 +133,7 @@ InputName=bar echo TCL_INCLUDE: %TCL_INCLUDE% echo TCL_LIB: %TCL_LIB% echo on - ..\..\..\swig -c++ -tcl8 $(InputPath) + ..\..\..\swig.exe -c++ -tcl8 $(InputPath) # End Custom Build diff --git a/Examples/tcl/import/base.dsp b/Examples/tcl/import/base.dsp index 74870ccb0..b27bbfdb6 100644 --- a/Examples/tcl/import/base.dsp +++ b/Examples/tcl/import/base.dsp @@ -118,7 +118,7 @@ InputName=base echo TCL_INCLUDE: %TCL_INCLUDE% echo TCL_LIB: %TCL_LIB% echo on - ..\..\..\swig -c++ -tcl8 $(InputPath) + ..\..\..\swig.exe -c++ -tcl8 $(InputPath) # End Custom Build @@ -133,7 +133,7 @@ InputName=base echo TCL_INCLUDE: %TCL_INCLUDE% echo TCL_LIB: %TCL_LIB% echo on - ..\..\..\swig -c++ -tcl8 $(InputPath) + ..\..\..\swig.exe -c++ -tcl8 $(InputPath) # End Custom Build diff --git a/Examples/tcl/import/foo.dsp b/Examples/tcl/import/foo.dsp index ac7f09f06..4d3765bd7 100644 --- a/Examples/tcl/import/foo.dsp +++ b/Examples/tcl/import/foo.dsp @@ -118,7 +118,7 @@ InputName=foo echo TCL_INCLUDE: %TCL_INCLUDE% echo TCL_LIB: %TCL_LIB% echo on - ..\..\..\swig -c++ -tcl8 $(InputPath) + ..\..\..\swig.exe -c++ -tcl8 $(InputPath) # End Custom Build @@ -133,7 +133,7 @@ InputName=foo echo TCL_INCLUDE: %TCL_INCLUDE% echo TCL_LIB: %TCL_LIB% echo on - ..\..\..\swig -c++ -tcl8 $(InputPath) + ..\..\..\swig.exe -c++ -tcl8 $(InputPath) # End Custom Build diff --git a/Examples/tcl/import/spam.dsp b/Examples/tcl/import/spam.dsp index db9ade0a3..5674c4373 100644 --- a/Examples/tcl/import/spam.dsp +++ b/Examples/tcl/import/spam.dsp @@ -118,7 +118,7 @@ InputName=spam echo TCL_INCLUDE: %TCL_INCLUDE% echo TCL_LIB: %TCL_LIB% echo on - ..\..\..\swig -c++ -tcl8 $(InputPath) + ..\..\..\swig.exe -c++ -tcl8 $(InputPath) # End Custom Build @@ -133,7 +133,7 @@ InputName=spam echo TCL_INCLUDE: %TCL_INCLUDE% echo TCL_LIB: %TCL_LIB% echo on - ..\..\..\swig -c++ -tcl8 $(InputPath) + ..\..\..\swig.exe -c++ -tcl8 $(InputPath) # End Custom Build diff --git a/Examples/tcl/multimap/example.dsp b/Examples/tcl/multimap/example.dsp index 296cb313b..c1568f2c5 100644 --- a/Examples/tcl/multimap/example.dsp +++ b/Examples/tcl/multimap/example.dsp @@ -122,7 +122,7 @@ InputName=example echo TCL_INCLUDE: %TCL_INCLUDE% echo TCL_LIB: %TCL_LIB% echo on - ..\..\..\swig -tcl8 $(InputPath) + ..\..\..\swig.exe -tcl8 $(InputPath) # End Custom Build @@ -137,7 +137,7 @@ InputName=example echo TCL_INCLUDE: %TCL_INCLUDE% echo TCL_LIB: %TCL_LIB% echo on - ..\..\..\swig -tcl8 $(InputPath) + ..\..\..\swig.exe -tcl8 $(InputPath) # End Custom Build diff --git a/Examples/tcl/simple/example.dsp b/Examples/tcl/simple/example.dsp index 296cb313b..c1568f2c5 100644 --- a/Examples/tcl/simple/example.dsp +++ b/Examples/tcl/simple/example.dsp @@ -122,7 +122,7 @@ InputName=example echo TCL_INCLUDE: %TCL_INCLUDE% echo TCL_LIB: %TCL_LIB% echo on - ..\..\..\swig -tcl8 $(InputPath) + ..\..\..\swig.exe -tcl8 $(InputPath) # End Custom Build @@ -137,7 +137,7 @@ InputName=example echo TCL_INCLUDE: %TCL_INCLUDE% echo TCL_LIB: %TCL_LIB% echo on - ..\..\..\swig -tcl8 $(InputPath) + ..\..\..\swig.exe -tcl8 $(InputPath) # End Custom Build From 1717a0de48b90cdf017f35d6cc057873d08a4e2a Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 21 Mar 2009 01:42:37 +0000 Subject: [PATCH 0366/1680] remove out of date info git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11169 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- ANNOUNCE | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/ANNOUNCE b/ANNOUNCE index ded11fbb5..9b930fda0 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -30,16 +30,6 @@ A Windows version is also available at http://prdownloads.sourceforge.net/swig/swigwin-1.3.39.zip -Release numbers ---------------- -With SWIG-1.3, we are adopting an odd/even version numbering scheme for -SWIG. Odd version numbers (1.3, 1.5, 1.7, etc...) are considered to -be development releases. Even numbers (1.4,1.6,1.8) are stable -releases. The current 1.3 effort is working to produce a stable 2.0 -release. A stable 2.0 release will not be made until it can -accompanied by fully updated documentation. In the meantime, we will -continue to make periodic 1.3.x releases. - Please report problems with this release to the swig-dev mailing list, details at http://www.swig.org/mail.html. From 0c454e7bcf3eefdbc3ee16a5aeeb19910adab76d Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 21 Mar 2009 01:45:41 +0000 Subject: [PATCH 0367/1680] bump version to 1.3.40 git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11170 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- ANNOUNCE | 10 ++-- CHANGES | 116 +++++++++++++++++++++++++++++++++++++++ CHANGES.current | 116 +-------------------------------------- Doc/Manual/Sections.html | 2 +- README | 2 +- configure.in | 2 +- 6 files changed, 126 insertions(+), 122 deletions(-) diff --git a/ANNOUNCE b/ANNOUNCE index 9b930fda0..9ef41142a 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -1,10 +1,10 @@ -*** ANNOUNCE: SWIG 1.3.39 (21 March 2009) *** +*** ANNOUNCE: SWIG 1.3.40 (in progress) *** http://www.swig.org -We're pleased to announce SWIG-1.3.39, the latest installment in the -SWIG development effort. SWIG-1.3.39 includes a number of bug fixes +We're pleased to announce SWIG-1.3.40, the latest installment in the +SWIG development effort. SWIG-1.3.40 includes a number of bug fixes and enhancements. What is SWIG? @@ -24,11 +24,11 @@ Availability: ------------- The release is available for download on Sourceforge at - http://prdownloads.sourceforge.net/swig/swig-1.3.39.tar.gz + http://prdownloads.sourceforge.net/swig/swig-1.3.40.tar.gz A Windows version is also available at - http://prdownloads.sourceforge.net/swig/swigwin-1.3.39.zip + http://prdownloads.sourceforge.net/swig/swigwin-1.3.40.zip Please report problems with this release to the swig-dev mailing list, details at http://www.swig.org/mail.html. diff --git a/CHANGES b/CHANGES index 7fff2c3f0..d9426512b 100644 --- a/CHANGES +++ b/CHANGES @@ -2,6 +2,122 @@ SWIG (Simplified Wrapper and Interface Generator) See CHANGES.current for current version. +Version 1.3.39 (21 March 2009) +============================== + +2009-03-19: bhy + [Python] Fix the memory leak related to Python 3 unicode and C char* conversion, + which can be shown in the following example before this fix: + + from li_cstring import * + i=0 + while True: + i += 1 + n = str(i)*10 + test3(n) + + This fix affected SWIG_AsCharPtrAndSize() so you cannot call this function with + a null alloc and non-null cptr argument in Python 3, otherwise a runtime error + will be raised. + +2009-03-18: wsfulton + [C#] std::vector wrapper improvements for .NET 2 and also providing the + necessary machinery to use the std::vector wrappers with more advanced features such + as LINQ - the C# proxy class now derives from IEnumerable<>. The default is now to + generate code requiring .NET 2 as a minimum, although the C# code can be compiled + for .NET 1 by defining the SWIG_DOTNET_1 C# preprocessor constant. See the + std_vector.i file for more details. + + *** POTENTIAL INCOMPATIBILITY *** + +2009-03-12: wsfulton + [Ruby] Fix #2676738 SWIG generated symbol name clashes. + +2009-03-01: bhy + [Python] Some fixes for Python 3.0.1 and higher support. In 3.0.1, the C API function + PyObject_Compare is removed, so PyObject_RichCompareBool is used for replacement. + Struct initilization of SwigPyObject and SwigPyObject_as_number changed to reflect + the drop of tp_compare and nb_long. + +2009-03-01: bhy + [Python] Fix SF#2583160. Now the importer in Python shadow wrapper take care of the + case that module already imported at other place. + +2009-02-28: bhy + [Python] Fix SF#2637352. Move struct declaration of SWIG_module in pyinit.swg before + the method calls, since some C compiler don't allow declaration in middle of function + body. + +2009-02-21: wsfulton + [Allegrocl] Fix seg fault wrapping some constant variable (%constant) types. + +2009-02-20: wsfulton + [CFFI] Fix seg faults when for %extend and using statements. + +2009-02-20: wsfulton + Fix SF #2605955: -co option which broke in 1.3.37. + +2009-02-20: wsfulton + New %insert("begin") section added. Also can be used as %begin. This is a new + code section reserved entirely for users and the code within the section is generated + at the top of the C/C++ wrapper file and so provides a means to put custom code + into the wrapper file before anything else that SWIG generates. + +2009-02-17: wsfulton + 'make clean-test-suite' will now run clean on ALL languages. Previously it only + ran the correctly configured languages. This way it is now possible to clean up + properly after running 'make partialcheck-test-suite'. + +2009-02-14: wsfulton + Extend attribute library support for structs/classes and the accessor functions use + pass/return by value semantics. Two new macros are available and usage is identical + to %attribute. These are %attributeval for structs/classes and %attributestring for + string classes, like std::string. See attribute.swg for more details. + +2009-02-13: wsfulton + Add support for %extend and memberin typemaps. Previously the memberin typemaps were + ignored for member variables within a %extend block. + +2009-02-12: wsfulton + Remove unnecessary temporary variable when wrapping return values that are references. + Example of generated code for wrapping: + + struct XYZ { + std::string& refReturn(); + }; + + used to be: + + std::string *result = 0 ; + ... + { + std::string &_result_ref = (arg1)->refReturn(); + result = (std::string *) &_result_ref; + } + + Now it is: + + std::string *result = 0 ; + ... + result = (std::string *) &(arg1)->refReturn(); + +2009-02-08: bhy + Change the SIZE mapped by %pybuffer_mutable_binary and %pybuffer_binary in pybuffer.i from + the length of the buffer to the number of items in the buffer. + +2009-02-08: wsfulton + Fix %feature not working for conversion operators, reported by Matt Sprague, for example: + %feature("cs:methodmodifiers") operator bool "protected"; + +2009-02-07: wsfulton + [MzScheme] Apply #2081967 configure changes for examples to build with recent PLT versions. + Also fixes Makefile errors building SWIG executable when mzscheme package is installed + (version 3.72 approx and later). + +2009-02-04: talby + [Perl] Fix SF#2564192 reported by David Kolovratnk. + SWIG_AsCharPtrAndSize() now handles "get" magic. + Version 1.3.38 (31 January 2009) ================================ diff --git a/CHANGES.current b/CHANGES.current index 9d74353eb..e9dced782 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,115 +1,3 @@ -Version 1.3.39 (21 March 2009) -============================== +Version 1.3.40 (in progress) +============================ -2009-03-19: bhy - [Python] Fix the memory leak related to Python 3 unicode and C char* conversion, - which can be shown in the following example before this fix: - - from li_cstring import * - i=0 - while True: - i += 1 - n = str(i)*10 - test3(n) - - This fix affected SWIG_AsCharPtrAndSize() so you cannot call this function with - a null alloc and non-null cptr argument in Python 3, otherwise a runtime error - will be raised. - -2009-03-18: wsfulton - [C#] std::vector wrapper improvements for .NET 2 and also providing the - necessary machinery to use the std::vector wrappers with more advanced features such - as LINQ - the C# proxy class now derives from IEnumerable<>. The default is now to - generate code requiring .NET 2 as a minimum, although the C# code can be compiled - for .NET 1 by defining the SWIG_DOTNET_1 C# preprocessor constant. See the - std_vector.i file for more details. - - *** POTENTIAL INCOMPATIBILITY *** - -2009-03-12: wsfulton - [Ruby] Fix #2676738 SWIG generated symbol name clashes. - -2009-03-01: bhy - [Python] Some fixes for Python 3.0.1 and higher support. In 3.0.1, the C API function - PyObject_Compare is removed, so PyObject_RichCompareBool is used for replacement. - Struct initilization of SwigPyObject and SwigPyObject_as_number changed to reflect - the drop of tp_compare and nb_long. - -2009-03-01: bhy - [Python] Fix SF#2583160. Now the importer in Python shadow wrapper take care of the - case that module already imported at other place. - -2009-02-28: bhy - [Python] Fix SF#2637352. Move struct declaration of SWIG_module in pyinit.swg before - the method calls, since some C compiler don't allow declaration in middle of function - body. - -2009-02-21: wsfulton - [Allegrocl] Fix seg fault wrapping some constant variable (%constant) types. - -2009-02-20: wsfulton - [CFFI] Fix seg faults when for %extend and using statements. - -2009-02-20: wsfulton - Fix SF #2605955: -co option which broke in 1.3.37. - -2009-02-20: wsfulton - New %insert("begin") section added. Also can be used as %begin. This is a new - code section reserved entirely for users and the code within the section is generated - at the top of the C/C++ wrapper file and so provides a means to put custom code - into the wrapper file before anything else that SWIG generates. - -2009-02-17: wsfulton - 'make clean-test-suite' will now run clean on ALL languages. Previously it only - ran the correctly configured languages. This way it is now possible to clean up - properly after running 'make partialcheck-test-suite'. - -2009-02-14: wsfulton - Extend attribute library support for structs/classes and the accessor functions use - pass/return by value semantics. Two new macros are available and usage is identical - to %attribute. These are %attributeval for structs/classes and %attributestring for - string classes, like std::string. See attribute.swg for more details. - -2009-02-13: wsfulton - Add support for %extend and memberin typemaps. Previously the memberin typemaps were - ignored for member variables within a %extend block. - -2009-02-12: wsfulton - Remove unnecessary temporary variable when wrapping return values that are references. - Example of generated code for wrapping: - - struct XYZ { - std::string& refReturn(); - }; - - used to be: - - std::string *result = 0 ; - ... - { - std::string &_result_ref = (arg1)->refReturn(); - result = (std::string *) &_result_ref; - } - - Now it is: - - std::string *result = 0 ; - ... - result = (std::string *) &(arg1)->refReturn(); - -2009-02-08: bhy - Change the SIZE mapped by %pybuffer_mutable_binary and %pybuffer_binary in pybuffer.i from - the length of the buffer to the number of items in the buffer. - -2009-02-08: wsfulton - Fix %feature not working for conversion operators, reported by Matt Sprague, for example: - %feature("cs:methodmodifiers") operator bool "protected"; - -2009-02-07: wsfulton - [MzScheme] Apply #2081967 configure changes for examples to build with recent PLT versions. - Also fixes Makefile errors building SWIG executable when mzscheme package is installed - (version 3.72 approx and later). - -2009-02-04: talby - [Perl] Fix SF#2564192 reported by David Kolovratnk. - SWIG_AsCharPtrAndSize() now handles "get" magic. diff --git a/Doc/Manual/Sections.html b/Doc/Manual/Sections.html index b6f5402f6..789efc129 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.39 (21 March 2009) +Last update : SWIG-1.3.40 (in progress)

      Sections

      diff --git a/README b/README index 9657a03c3..3df9e506a 100644 --- a/README +++ b/README @@ -1,6 +1,6 @@ SWIG (Simplified Wrapper and Interface Generator) -Version: 1.3.39 (21 March 2009) +Version: 1.3.40 (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 f841db230..4edc8e1ae 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.39],[http://www.swig.org]) +AC_INIT([swig],[1.3.40],[http://www.swig.org]) AC_PREREQ(2.58) AC_CONFIG_SRCDIR([Source/Swig/swig.h]) AC_CONFIG_AUX_DIR([Tools/config]) From ed4d6ddec16586c4f4cf2261c9968067685338c3 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Sun, 29 Mar 2009 23:38:19 +0000 Subject: [PATCH 0368/1680] Some distros (e.g. frugalware) build PHP with --enable-safe-mode, so as we need to explicitly disable it to avoid the testsuite failing with: Warning: dl(): Dynamically loaded extensions aren't allowed when running in Safe Mode Patch from Miklos Vajna. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11174 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 58c0212d5..d6dbfdeeb 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -775,7 +775,7 @@ PHP=@PHP@ PHPSCRIPT ?= runme.php php_run: - env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(PHP) -n -q -d extension_dir=. $(PHPSCRIPT) + env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(PHP) -n -q -d extension_dir=. -d safe_mode=Off $(PHPSCRIPT) # ----------------------------------------------------------------- # Cleaning the PHP examples From c05ddc9d149623d677e22e900041e31da7bf8b49 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Mon, 30 Mar 2009 02:01:12 +0000 Subject: [PATCH 0369/1680] check::equal() now reports the values if they aren't equal. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11175 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/php/tests.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/test-suite/php/tests.php b/Examples/test-suite/php/tests.php index 36e9f4163..b62e878fc 100644 --- a/Examples/test-suite/php/tests.php +++ b/Examples/test-suite/php/tests.php @@ -185,7 +185,7 @@ class check { } function equal($a,$b,$message) { - if (! ($a===$b)) return check::fail($message); + if (! ($a===$b)) return check::fail($message . ": '$a'!=='$b'"); return TRUE; } From 64843143f1ae839229c59bfb6273b6c2f4868cda Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Mon, 30 Mar 2009 02:22:14 +0000 Subject: [PATCH 0370/1680] The default out typemap for char[ANY] now returns 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. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11176 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/php/arrays_global_runme.php | 10 ++++++++-- Lib/php/php.swg | 8 +++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Examples/test-suite/php/arrays_global_runme.php b/Examples/test-suite/php/arrays_global_runme.php index 59ff7bf2a..baa5521ed 100644 --- a/Examples/test-suite/php/arrays_global_runme.php +++ b/Examples/test-suite/php/arrays_global_runme.php @@ -7,8 +7,14 @@ 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::set(array_c,"hac"); -check::equal("ha",check::get(array_c,"ha"),"set array_c"); +// The size of array_c is 2, but the last byte is \0, so we can only store a +// single byte string in it. +check::set(array_c,"Z"); +check::equal("Z",check::get(array_c),"set array_c"); +check::set(array_c,"xy"); +check::equal("x",check::get(array_c),"set array_c"); +check::set(array_c,"h"); +check::equal("h",check::get(array_c),"set array_c"); check::done(); ?> diff --git a/Lib/php/php.swg b/Lib/php/php.swg index 28431610a..087525be4 100644 --- a/Lib/php/php.swg +++ b/Lib/php/php.swg @@ -233,9 +233,11 @@ %typemap(out) void ""; %typemap(out) char [ANY] -%{ - RETVAL_STRINGL($1,$1_dim0,1); -%} +{ + int len = 0; + while (len < $1_dim0 && $1[len]) ++len; + RETVAL_STRINGL($1, len, 1); +} // This typecheck does hard checking for proper argument type. If you want // an argument to be converted from a different PHP type, you must convert From 69afd6f1b8896df311949d6f0125492804f51ff6 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Mon, 30 Mar 2009 02:49:13 +0000 Subject: [PATCH 0371/1680] Document the previous change. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11177 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index e9dced782..024bbfdc9 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,3 +1,15 @@ Version 1.3.40 (in progress) ============================ +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); + %} From 084a168a0ff306b32a3277ba4418f1a29c7215e8 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Tue, 31 Mar 2009 10:25:54 +0000 Subject: [PATCH 0372/1680] printf(string) -> printf("%s", string) git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11178 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/modula3.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Modules/modula3.cxx b/Source/Modules/modula3.cxx index df44ab94a..b3568c0bf 100644 --- a/Source/Modules/modula3.cxx +++ b/Source/Modules/modula3.cxx @@ -376,7 +376,7 @@ MODULA3(): } else if (Strcmp(dir, "out") == 0) { return false; } else { - printf(USAGE_ARG_DIR); + printf("%s", USAGE_ARG_DIR); return false; } } @@ -388,7 +388,7 @@ MODULA3(): } else if ((Strcmp(dir, "out") == 0) || (Strcmp(dir, "inout") == 0)) { return true; } else { - printf(USAGE_ARG_DIR); + printf("%s", USAGE_ARG_DIR); return false; } } From be73d28ad76a7e703334e71c860a49cc1b1382f6 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 31 Mar 2009 12:23:47 +0000 Subject: [PATCH 0373/1680] don't unnecessarily set swigCPtr to zero again if Dispose/delete called multiple times git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11179 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/csharp/boost_shared_ptr.i | 22 +++++++++++++--------- Lib/csharp/csharp.swg | 22 +++++++++++++--------- Lib/java/boost_intrusive_ptr.i | 22 +++++++++++++--------- Lib/java/boost_shared_ptr.i | 22 +++++++++++++--------- Lib/java/java.swg | 28 ++++++++++++++++------------ 5 files changed, 68 insertions(+), 48 deletions(-) diff --git a/Lib/csharp/boost_shared_ptr.i b/Lib/csharp/boost_shared_ptr.i index 47fbaba1d..2cb687356 100644 --- a/Lib/csharp/boost_shared_ptr.i +++ b/Lib/csharp/boost_shared_ptr.i @@ -33,7 +33,7 @@ // plain reference %typemap(in, canthrow=1) CONST TYPE & %{ $1 = ($1_ltype)(((SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)$input) ? ((SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)$input)->get() : 0); - if(!$1) { + if (!$1) { SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "$1_type reference is null", 0); return $null; } %} @@ -199,22 +199,26 @@ %typemap(csdestruct, methodname="Dispose", methodmodifiers="public") TYPE { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwnBase) { - swigCMemOwnBase = false; - $imcall; + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwnBase) { + swigCMemOwnBase = false; + $imcall; + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } %typemap(csdestruct_derived, methodname="Dispose", methodmodifiers="public") TYPE { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwnDerived) { - swigCMemOwnDerived = false; - $imcall; + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwnDerived) { + swigCMemOwnDerived = false; + $imcall; + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); base.Dispose(); } diff --git a/Lib/csharp/csharp.swg b/Lib/csharp/csharp.swg index e381ff9ae..94f76a3ad 100644 --- a/Lib/csharp/csharp.swg +++ b/Lib/csharp/csharp.swg @@ -396,7 +396,7 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) { SWIG_UnpackData($input, (void *)&$1, sizeof($1)); %} %typemap(in, canthrow=1) SWIGTYPE & %{ $1 = ($1_ltype)$input; - if(!$1) { + if (!$1) { SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "$1_type type is null", 0); return $null; } %} @@ -885,22 +885,26 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) { %typemap(csdestruct, methodname="Dispose", methodmodifiers="public") SWIGTYPE { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - $imcall; + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + $imcall; + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } %typemap(csdestruct_derived, methodname="Dispose", methodmodifiers="public") SWIGTYPE { lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - $imcall; + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + $imcall; + } + swigCPtr = new HandleRef(null, IntPtr.Zero); } - swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); base.Dispose(); } diff --git a/Lib/java/boost_intrusive_ptr.i b/Lib/java/boost_intrusive_ptr.i index 6d390d9d5..48f6c317b 100644 --- a/Lib/java/boost_intrusive_ptr.i +++ b/Lib/java/boost_intrusive_ptr.i @@ -342,7 +342,7 @@ // plain reference %typemap(in) CONST TYPE & %{ $1 = ($1_ltype)((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0); - if(!$1) { + if (!$1) { SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "$1_type reference is null"); return $null; } %} @@ -430,19 +430,23 @@ %} %typemap(javadestruct, methodname="delete", methodmodifiers="public synchronized") TYPE { - if(swigCPtr != 0 && swigCMemOwnBase) { - swigCMemOwnBase = false; - $jnicall; + if (swigCPtr != 0) { + if (swigCMemOwnBase) { + swigCMemOwnBase = false; + $jnicall; + } + swigCPtr = 0; } - swigCPtr = 0; } %typemap(javadestruct_derived, methodname="delete", methodmodifiers="public synchronized") TYPE { - if(swigCPtr != 0 && swigCMemOwnDerived) { - swigCMemOwnDerived = false; - $jnicall; + if (swigCPtr != 0) { + if (swigCMemOwnDerived) { + swigCMemOwnDerived = false; + $jnicall; + } + swigCPtr = 0; } - swigCPtr = 0; super.delete(); } diff --git a/Lib/java/boost_shared_ptr.i b/Lib/java/boost_shared_ptr.i index 1f555bf85..75762f84f 100644 --- a/Lib/java/boost_shared_ptr.i +++ b/Lib/java/boost_shared_ptr.i @@ -33,7 +33,7 @@ // plain reference %typemap(in) CONST TYPE & %{ $1 = ($1_ltype)((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0); - if(!$1) { + if (!$1) { SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "$1_type reference is null"); return $null; } %} @@ -166,19 +166,23 @@ %} %typemap(javadestruct, methodname="delete", methodmodifiers="public synchronized") TYPE { - if(swigCPtr != 0 && swigCMemOwnBase) { - swigCMemOwnBase = false; - $jnicall; + if (swigCPtr != 0) { + if (swigCMemOwnBase) { + swigCMemOwnBase = false; + $jnicall; + } + swigCPtr = 0; } - swigCPtr = 0; } %typemap(javadestruct_derived, methodname="delete", methodmodifiers="public synchronized") TYPE { - if(swigCPtr != 0 && swigCMemOwnDerived) { - swigCMemOwnDerived = false; - $jnicall; + if (swigCPtr != 0) { + if (swigCMemOwnDerived) { + swigCMemOwnDerived = false; + $jnicall; + } + swigCPtr = 0; } - swigCPtr = 0; super.delete(); } diff --git a/Lib/java/java.swg b/Lib/java/java.swg index f70d3f9cd..bd2357a86 100644 --- a/Lib/java/java.swg +++ b/Lib/java/java.swg @@ -364,7 +364,7 @@ } %typemap(freearg, noblock=1) char * { if ($1) JCALL2(ReleaseStringUTFChars, jenv, $input, (const char *)$1); } -%typemap(out, noblock=1) char * { if($1) $result = JCALL1(NewStringUTF, jenv, (const char *)$1); } +%typemap(out, noblock=1) char * { if ($1) $result = JCALL1(NewStringUTF, jenv, (const char *)$1); } %typemap(javadirectorin) char * "$jniinput" %typemap(javadirectorout) char * "$javacall" @@ -378,7 +378,7 @@ $1 = &temp; } %typemap(freearg, noblock=1) char *& { if ($1 && *$1) JCALL2(ReleaseStringUTFChars, jenv, $input, (const char *)*$1); } -%typemap(out, noblock=1) char *& { if(*$1) $result = JCALL1(NewStringUTF, jenv, (const char *)*$1); } +%typemap(out, noblock=1) char *& { if (*$1) $result = JCALL1(NewStringUTF, jenv, (const char *)*$1); } %typemap(out) void "" %typemap(javadirectorin) void "$jniinput" @@ -597,7 +597,7 @@ /* Generic pointers and references */ %typemap(in) SWIGTYPE *, SWIGTYPE (CLASS::*) %{ $1 = *($&1_ltype)&$input; %} %typemap(in) SWIGTYPE & %{ $1 = *($&1_ltype)&$input; - if(!$1) { + if (!$1) { SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "$1_type reference is null"); return $null; } %} @@ -656,7 +656,7 @@ %typemap(argout) char[ANY], char[] "" %typemap(freearg, noblock=1) char[ANY], char[] { if ($1) JCALL2(ReleaseStringUTFChars, jenv, $input, (const char *)$1); } -%typemap(out, noblock=1) char[ANY], char[] { if($1) $result = JCALL1(NewStringUTF, jenv, (const char *)$1); } +%typemap(out, noblock=1) char[ANY], char[] { if ($1) $result = JCALL1(NewStringUTF, jenv, (const char *)$1); } %typemap(javadirectorin) char[ANY], char[] "$jniinput" %typemap(javadirectorout) char[ANY], char[] "$javacall" @@ -1148,19 +1148,23 @@ SWIG_PROXY_CONSTRUCTOR(true, false, TYPENAME) SWIG_PROXY_CONSTRUCTOR(true, true, SWIGTYPE) %typemap(javadestruct, methodname="delete", methodmodifiers="public synchronized") SWIGTYPE { - if(swigCPtr != 0 && swigCMemOwn) { - swigCMemOwn = false; - $jnicall; + if (swigCPtr != 0) { + if (swigCMemOwn) { + swigCMemOwn = false; + $jnicall; + } + swigCPtr = 0; } - swigCPtr = 0; } %typemap(javadestruct_derived, methodname="delete", methodmodifiers="public synchronized") SWIGTYPE { - if(swigCPtr != 0 && swigCMemOwn) { - swigCMemOwn = false; - $jnicall; + if (swigCPtr != 0) { + if (swigCMemOwn) { + swigCMemOwn = false; + $jnicall; + } + swigCPtr = 0; } - swigCPtr = 0; super.delete(); } From de9513b374d958b10fccbb5e415bed00211e885b Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 1 Apr 2009 08:41:41 +0000 Subject: [PATCH 0374/1680] update .dll -> .pyd for python git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11182 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Introduction.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Doc/Manual/Introduction.html b/Doc/Manual/Introduction.html index 491204d1d..099454cf0 100644 --- a/Doc/Manual/Introduction.html +++ b/Doc/Manual/Introduction.html @@ -414,7 +414,8 @@ SWIG_LINK_LIBRARIES(example ${PYTHON_LIBRARIES})

      The above example will generate native build files such as makefiles, nmake files and Visual Studio projects -which will invoke SWIG and compile the generated C++ files into _example.so (UNIX) or _example.dll (Windows). +which will invoke SWIG and compile the generated C++ files into _example.so (UNIX) or _example.pyd (Windows). +For other target languages on Windows a dll, instead of a .pyd file, is usually generated.

      2.7 Hands off code generation

      From 4a1b29a394254238bea86b6a44f6e23228365aa5 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 1 Apr 2009 12:46:26 +0000 Subject: [PATCH 0375/1680] fix ordering of chapters git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11183 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CCache/ccache.yo | 2 +- Doc/Manual/Contents.html | 32 ++++++++++++++++---------------- Doc/Manual/Modules.html | 14 +++++++------- Doc/Manual/chapters | 2 +- 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/CCache/ccache.yo b/CCache/ccache.yo index 82ac05d2e..2477662dc 100644 --- a/CCache/ccache.yo +++ b/CCache/ccache.yo @@ -13,7 +13,7 @@ whenhtml(htmlcommand( -

      ccache-swig(1) manpage

      +

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

      diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index e764d2828..c135b7c6f 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -483,7 +483,22 @@
      -

      15 ccache-swig(1) manpage

      +

      15 Working with Modules

      + + + + + +

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

      @@ -509,21 +524,6 @@
      -

      16 Working with Modules

      - - - - -

      17 SWIG and Allegro Common Lisp

      diff --git a/Doc/Manual/Modules.html b/Doc/Manual/Modules.html index 3fbfc70b0..5ac66dc2e 100644 --- a/Doc/Manual/Modules.html +++ b/Doc/Manual/Modules.html @@ -6,7 +6,7 @@ -

      16 Working with Modules

      +

      15 Working with Modules

        @@ -37,7 +37,7 @@ This chapter describes the problem of using SWIG in programs where you want to create a collection of modules.

        -

        16.1 Basics

        +

        15.1 Basics

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

        -

        16.2 The SWIG runtime code

        +

        15.2 The SWIG runtime code

        @@ -201,7 +201,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.

        -

        16.3 External access to the runtime

        +

        15.3 External access to the runtime

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

        -

        16.4 A word of caution about static libraries

        +

        15.4 A word of caution about static libraries

        @@ -249,7 +249,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.

        -

        16.5 References

        +

        15.5 References

        @@ -257,7 +257,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.

        -

        16.6 Reducing the wrapper file size

        +

        15.6 Reducing the wrapper file size

        diff --git a/Doc/Manual/chapters b/Doc/Manual/chapters index 7d2b699bd..bf180f1b4 100644 --- a/Doc/Manual/chapters +++ b/Doc/Manual/chapters @@ -12,8 +12,8 @@ Customization.html Contract.html Varargs.html Warnings.html -CCache.html Modules.html +CCache.html Allegrocl.html CSharp.html Chicken.html From bd46f03b6fcb7617c4ba47c608abc01d846ab5fb Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 9 Apr 2009 17:51:59 +0000 Subject: [PATCH 0376/1680] Fix #2746858 - C macro expression using floating point numbers git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11185 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 3 +++ Examples/test-suite/preproc.i | 5 +++++ Source/CParse/parser.y | 13 ++++++++++++- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index 024bbfdc9..fcf35a6b5 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,9 @@ Version 1.3.40 (in progress) ============================ +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 diff --git a/Examples/test-suite/preproc.i b/Examples/test-suite/preproc.i index 9491fc1d2..b9f357b90 100644 --- a/Examples/test-suite/preproc.i +++ b/Examples/test-suite/preproc.i @@ -313,6 +313,11 @@ int test(int defined) #define MASK(shift, size) (((1 << (size)) - 1) <<(shift)) #define SOME_MASK_DEF (80*MASK(8, 10)) +/* some constants */ +#define BOLTZMANN (1.380658e-23) +#define AVOGADRO (6.0221367e23) +#define RGAS (BOLTZMANN*AVOGADRO) +#define RGASX (BOLTZMANN*AVOGADRO*BOLTZMANN) %{ #define TEUCHOS_TYPE_NAME_TRAITS_BUILTIN_TYPE_SPECIALIZATION(TYPE) \ diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index 3f4256718..0babfbbb8 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -5492,7 +5492,18 @@ valexpr : exprnum { $$ = $1; } | LPAREN expr RPAREN expr %prec CAST { $$ = $4; if ($4.type != T_STRING) { - $$.val = NewStringf("(%s) %s", SwigType_str($2.val,0), $4.val); + switch ($2.type) { + case T_FLOAT: + case T_DOUBLE: + case T_LONGDOUBLE: + case T_FLTCPLX: + case T_DBLCPLX: + $$.val = NewStringf("(%s)%s", $2.val, $4.val); /* SwigType_str and decimal points don't mix! */ + break; + default: + $$.val = NewStringf("(%s) %s", SwigType_str($2.val,0), $4.val); + break; + } } } | LPAREN expr pointer RPAREN expr %prec CAST { From 60f0c7e56b815bb38a4fdbf85afa561a12ab01d0 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 21 Apr 2009 20:09:15 +0000 Subject: [PATCH 0377/1680] Fix #2753469 - bool &OUTPUT and bool *OUTPUT typemaps initialisation. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11191 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 3 +++ Lib/csharp/typemaps.i | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index fcf35a6b5..efca7023b 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,9 @@ Version 1.3.40 (in progress) ============================ +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 diff --git a/Lib/csharp/typemaps.i b/Lib/csharp/typemaps.i index ddfbd1b0c..56cc6cb61 100644 --- a/Lib/csharp/typemaps.i +++ b/Lib/csharp/typemaps.i @@ -192,6 +192,10 @@ OUTPUT_TYPEMAP(double, double, double, DOUBLE_PTR) #undef OUTPUT_TYPEMAP +%typemap(in) bool *OUTPUT, bool &OUTPUT +%{ *$input = 0; + $1 = ($1_ltype)$input; %} + /* INOUT typemaps From 38f00d3544facb8954b2809f81487a768f481d44 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Wed, 29 Apr 2009 09:35:58 +0000 Subject: [PATCH 0378/1680] [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). git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11192 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 8 ++++++++ Source/Modules/python.cxx | 24 +----------------------- 2 files changed, 9 insertions(+), 23 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index efca7023b..84c5c6035 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,14 @@ Version 1.3.40 (in progress) ============================ +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. diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index ffeea430d..bd22e79a6 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -1739,7 +1739,6 @@ public: /* Last node in overloaded chain */ int maxargs; - int allow_thread = threads_enable(n); String *tmp = NewString(""); String *dispatch; @@ -1762,8 +1761,6 @@ public: Wrapper_add_local(f, "argc", "int argc"); Printf(tmp, "PyObject *argv[%d]", maxargs + 1); Wrapper_add_local(f, "argv", tmp); - if (allow_thread) - thread_begin_block(n, f->code); if (!fastunpack) { Wrapper_add_local(f, "ii", "int ii"); @@ -1780,19 +1777,8 @@ public: Replaceall(dispatch, "$args", "self,args"); - if (allow_thread) { - String *ret = NewStringEmpty(); - thread_end_block(n, ret); - Append(ret, "return "); - Replaceall(dispatch, "return ", ret); - Delete(ret); - } - Printv(f->code, dispatch, "\n", NIL); - if (allow_thread) - thread_end_block(n, f->code); - if (GetFlag(n, "feature:python:maybecall")) { Append(f->code, "fail:\n"); Append(f->code, "Py_INCREF(Py_NotImplemented);\n"); @@ -1899,8 +1885,6 @@ public: kwargs = NewString(""); int allow_thread = threads_enable(n); - if (allow_thread) - thread_begin_block(n, f->code); Wrapper_add_local(f, "resultobj", "PyObject *resultobj = 0"); @@ -2331,8 +2315,6 @@ public: } } - if (allow_thread) - thread_end_block(n, f->code); Append(f->code, " return resultobj;\n"); /* Error handling code */ @@ -2341,8 +2323,6 @@ public: if (need_cleanup) { Printv(f->code, cleanup, NIL); } - if (allow_thread) - thread_end_block(n, f->code); Printv(f->code, " return NULL;\n", NIL); @@ -3858,10 +3838,8 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) { int allow_thread = threads_enable(n); - if (allow_thread) - thread_begin_block(n, w->code); - if (allow_thread) { + thread_begin_block(n, w->code); Append(w->code, "{\n"); } From 6d8ea4f7fac8dd54e8efea46239ab5e826a73b40 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Wed, 29 Apr 2009 12:00:38 +0000 Subject: [PATCH 0379/1680] Fix comment typos git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11193 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/python/director.swg | 2 +- Lib/python/embed.i | 4 ++-- Lib/python/embed15.i | 2 +- Lib/python/pycomplex.swg | 8 ++++---- Lib/python/pycontainer.swg | 2 +- Lib/python/pyhead.swg | 2 +- Lib/python/pyinit.swg | 6 +++--- Lib/python/pyiterators.swg | 2 +- Lib/python/pyname_compat.i | 4 ++-- Lib/python/pyrun.swg | 10 +++++----- 10 files changed, 21 insertions(+), 21 deletions(-) diff --git a/Lib/python/director.swg b/Lib/python/director.swg index 836d107ce..ba9144539 100644 --- a/Lib/python/director.swg +++ b/Lib/python/director.swg @@ -47,7 +47,7 @@ /* Use -DSWIG_DIRECTOR_STATIC if you prefer to avoid the use of the - 'Swig' namespace. This could be usefull for multi-modules projects. + 'Swig' namespace. This could be useful for multi-modules projects. */ #ifdef SWIG_DIRECTOR_STATIC /* Force anonymous (static) namespace */ diff --git a/Lib/python/embed.i b/Lib/python/embed.i index 4855e3dbb..c29e8fd9f 100644 --- a/Lib/python/embed.i +++ b/Lib/python/embed.i @@ -1,11 +1,11 @@ // -// embed15.i +// embed.i // SWIG file embedding the Python interpreter in something else. // This file is based on Python-1.5. It will not work with // earlier versions. // // This file makes it possible to extend Python and all of its -// built-in functions without having to hack it's setup script. +// built-in functions without having to hack its setup script. // diff --git a/Lib/python/embed15.i b/Lib/python/embed15.i index f677d166e..32808b1aa 100644 --- a/Lib/python/embed15.i +++ b/Lib/python/embed15.i @@ -9,7 +9,7 @@ * earlier versions. * * This file makes it possible to extend Python and all of its - * built-in functions without having to hack it's setup script. + * built-in functions without having to hack its setup script. * ----------------------------------------------------------------------------- */ #ifdef AUTODOC diff --git a/Lib/python/pycomplex.swg b/Lib/python/pycomplex.swg index 7914b0e91..74be5b970 100644 --- a/Lib/python/pycomplex.swg +++ b/Lib/python/pycomplex.swg @@ -1,13 +1,13 @@ /* - Defines the As/From conversors for double/float complex, you need to - provide complex Type, the Name you want to use in the conversors, + Defines the As/From converters for double/float complex, you need to + provide complex Type, the Name you want to use in the converters, the complex Constructor method, and the Real and Imag complex - accesor methods. + accessor methods. See the std_complex.i and ccomplex.i for concret examples. */ -/* the common from conversor */ +/* the common from converter */ %define %swig_fromcplx_conv(Type, Real, Imag) %fragment(SWIG_From_frag(Type),"header") { diff --git a/Lib/python/pycontainer.swg b/Lib/python/pycontainer.swg index 6fd1d56f9..7d7fdfc72 100644 --- a/Lib/python/pycontainer.swg +++ b/Lib/python/pycontainer.swg @@ -122,7 +122,7 @@ namespace std { */ if( PyErr_Occurred() && PyErr_ExceptionMatches(PyExc_TypeError) ) { - /* Objects can't be compared, this mostly occured in Python 3.0 */ + /* Objects can't be compared, this mostly occurred in Python 3.0 */ /* Compare their ptr directly for a workaround */ res = (v < w); PyErr_Clear(); diff --git a/Lib/python/pyhead.swg b/Lib/python/pyhead.swg index 732d4689e..bac702bb0 100644 --- a/Lib/python/pyhead.swg +++ b/Lib/python/pyhead.swg @@ -1,4 +1,4 @@ -/* Compatibility marcos for Python 3 */ +/* Compatibility macros for Python 3 */ #if PY_VERSION_HEX >= 0x03000000 #define PyClass_Check(obj) PyObject_IsInstance(obj, (PyObject *)&PyType_Type) diff --git a/Lib/python/pyinit.swg b/Lib/python/pyinit.swg index 286e7fb68..058934b04 100644 --- a/Lib/python/pyinit.swg +++ b/Lib/python/pyinit.swg @@ -152,7 +152,7 @@ swig_varlink_type(void) { (char *)"swigvarlink", /* Type name (tp_name) */ sizeof(swig_varlinkobject), /* Basic size (tp_basicsize) */ 0, /* Itemsize (tp_itemsize) */ - (destructor) swig_varlink_dealloc, /* Deallocator (tp_dealloc) */ + (destructor) swig_varlink_dealloc, /* Deallocator (tp_dealloc) */ (printfunc) swig_varlink_print, /* Print (tp_print) */ (getattrfunc) swig_varlink_getattr, /* get attr (tp_getattr) */ (setattrfunc) swig_varlink_setattr, /* Set attr (tp_setattr) */ @@ -163,7 +163,7 @@ swig_varlink_type(void) { 0, /* tp_as_mapping */ 0, /* tp_hash */ 0, /* tp_call */ - (reprfunc)swig_varlink_str, /* tp_str */ + (reprfunc) swig_varlink_str, /* tp_str */ 0, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ @@ -184,7 +184,7 @@ swig_varlink_type(void) { #endif }; varlink_type = tmp; - /* for Python 3 we already assigned the ob_type in PyVarObject_HEAD_INIT() */ + /* for Python 3 we already assigned ob_type in PyVarObject_HEAD_INIT() */ #if PY_VERSION_HEX < 0x03000000 varlink_type.ob_type = &PyType_Type; #endif diff --git a/Lib/python/pyiterators.swg b/Lib/python/pyiterators.swg index 9cd795d7c..8719f73ce 100644 --- a/Lib/python/pyiterators.swg +++ b/Lib/python/pyiterators.swg @@ -9,7 +9,7 @@ * Users can derive form the SwigPyIterator to implement their * own iterators. As an example (real one since we use it for STL/STD * containers), the template SwigPyIterator_T does the - * implementation for genereic C++ iterators. + * implementation for generic C++ iterators. * ----------------------------------------------------------------------------- */ %include diff --git a/Lib/python/pyname_compat.i b/Lib/python/pyname_compat.i index cdda38f80..b5acca955 100644 --- a/Lib/python/pyname_compat.i +++ b/Lib/python/pyname_compat.i @@ -15,10 +15,10 @@ * * This file defined macros to provide backward compatibility for these deprecated * symbols. In the case you have these symbols in your interface file, you can simply -* include this file at begining of it. +* include this file at beginning of it. * * However, this file may be removed in future release of SWIG, so using this file to -* keep these inappropriate names in your SWIG interface file is also not recommanded. +* keep these inappropriate names in your SWIG interface file is also not recommended. * Instead, we provide a simple tool for converting your interface files to * the new naming convention. You can download the tool here: * https://swig.svn.sourceforge.net/svnroot/swig/trunk/Tools/pyname_patch.py diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index 5a1b1230e..0a3adff5d 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -440,7 +440,7 @@ SwigPyObject_compare(SwigPyObject *v, SwigPyObject *w) return (i < j) ? -1 : ((i > j) ? 1 : 0); } -/* Added for Python 3.x, whould it also useful for Python 2.x? */ +/* Added for Python 3.x, would it also be useful for Python 2.x? */ SWIGRUNTIME PyObject* SwigPyObject_richcompare(SwigPyObject *v, SwigPyObject *w, int op) { @@ -488,7 +488,7 @@ SwigPyObject_dealloc(PyObject *v) /* destroy is always a VARARGS method */ PyObject *res; if (data->delargs) { - /* we need to create a temporal object to carry the destroy operation */ + /* we need to create a temporary object to carry the destroy operation */ PyObject *tmp = SwigPyObject_New(sobj->ptr, ty, 0); res = SWIG_Python_CallFunctor(destroy, tmp); Py_DECREF(tmp); @@ -689,7 +689,7 @@ _PySwigObject_type(void) { if (!type_init) { const PyTypeObject tmp = { - /* PyOjbect header changed in Python 3 */ + /* PyObject header changed in Python 3 */ #if PY_VERSION_HEX >= 0x03000000 PyVarObject_HEAD_INIT(&PyType_Type, 0) #else @@ -758,7 +758,7 @@ _PySwigObject_type(void) { #endif }; swigpyobject_type = tmp; - /* for Python 3 we already assigned the ob_type in PyVarObject_HEAD_INIT() */ + /* for Python 3 we already assigned ob_type in PyVarObject_HEAD_INIT() */ #if PY_VERSION_HEX < 0x03000000 swigpyobject_type.ob_type = &PyType_Type; #endif @@ -1206,7 +1206,7 @@ SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *t * ----------------------------------------------------------------------------- */ /* - Create a new instance object, whitout calling __init__, and set the + Create a new instance object, without calling __init__, and set the 'this' attribute. */ From e8aa9d87031752d39a00b09b7b64b2c8fd6fe3c4 Mon Sep 17 00:00:00 2001 From: Haoyu Bai Date: Wed, 29 Apr 2009 12:05:33 +0000 Subject: [PATCH 0380/1680] fix of unclear comment regarding Python 3 tp_compare removal git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11194 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/python/pyrun.swg | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index 0a3adff5d..09b629483 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -708,7 +708,7 @@ _PySwigObject_type(void) { #endif (setattrfunc)0, /* tp_setattr */ #if PY_VERSION_HEX >= 0x03000000 - 0, /* tp_reserved in 3.0.1 */ + 0, /* tp_reserved in 3.0.1, tp_compare in 3.0.0 but not used */ #else (cmpfunc)SwigPyObject_compare, /* tp_compare */ #endif @@ -1236,9 +1236,12 @@ SWIG_Python_NewShadowInstance(SwigPyClientData *data, PyObject *swig_this) } } else { #if PY_VERSION_HEX >= 0x03000000 + fprintf(stderr, "<<<<"); inst = PyBaseObject_Type.tp_new((PyTypeObject*) data->newargs, Py_None, Py_None); PyObject_SetAttr(inst, SWIG_This(), swig_this); Py_TYPE(inst)->tp_flags &= ~Py_TPFLAGS_VALID_VERSION_TAG; + fprintf(stderr, ">>>>"); + #else PyObject *dict = PyDict_New(); PyDict_SetItem(dict, SWIG_This(), swig_this); From 1c91a4a9b997775d43099764cec3d278eb07d240 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Wed, 29 Apr 2009 13:43:23 +0000 Subject: [PATCH 0381/1680] int -> Py_ssize_t to fix 64 bit Python 3 failure to compile generated code git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11195 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/python/pyhead.swg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/python/pyhead.swg b/Lib/python/pyhead.swg index bac702bb0..2edbf631f 100644 --- a/Lib/python/pyhead.swg +++ b/Lib/python/pyhead.swg @@ -31,7 +31,7 @@ SWIG_Python_str_AsChar(PyObject *str) #if PY_VERSION_HEX >= 0x03000000 char *cstr; char *newstr; - int len; + Py_ssize_t len; str = PyUnicode_AsUTF8String(str); PyBytes_AsStringAndSize(str, &cstr, &len); newstr = (char *) malloc(len+1); From 7e8d19cec08ea7b26f1ed8c8c5bffe63c224b59f Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 29 Apr 2009 17:58:32 +0000 Subject: [PATCH 0382/1680] Add the 'notderived' attribute to the javabase and csbase typemaps git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11196 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 7 +++++++ Doc/Manual/Java.html | 3 +++ Source/Modules/csharp.cxx | 10 ++++++++-- Source/Modules/java.cxx | 8 +++++++- 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 84c5c6035..ac448395a 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,12 @@ Version 1.3.40 (in progress) ============================ +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 @@ -9,6 +15,7 @@ Version 1.3.40 (in progress) 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). +>>>>>>> .r11195 2009-04-21: wsfulton [C#] Fix #2753469 - bool &OUTPUT and bool *OUTPUT typemaps initialisation. diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html index c5ff1f906..a19cc5e84 100644 --- a/Doc/Manual/Java.html +++ b/Doc/Manual/Java.html @@ -5302,6 +5302,9 @@ base (extends) for Java class: empty default Note that this typemap accepts a replace attribute as an optional flag. When set to "1", it will replace/override any C++ base classes that might have been parsed. If this flag is not specified and there are C++ base classes, then a multiple inheritance warning is issued and the code in the typemap is ignored. +The typemap also accepts a notderived attribute as an optional flag. When set to "1", it will not apply to classes that +are derived from a C++ base. +When used with the SWIGTYPE type, it is useful for giving a common base for all proxy classes, that is, providing a base class that sits in between all proxy classes and the Java base class Object for example: %typemap(javabase, notderived="1") SWIGTYPE "CommonBase".

      %typemap(javabody)

      diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index 2730b55d4..05d5c72e1 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -1497,6 +1497,7 @@ public: Node *attributes = NewHash(); const String *pure_baseclass = typemapLookup("csbase", typemap_lookup_type, WARN_NONE, attributes); bool purebase_replace = GetFlag(attributes, "tmap:csbase:replace") ? true : false; + bool purebase_notderived = GetFlag(attributes, "tmap:csbase:notderived") ? true : false; Delete(attributes); // C++ inheritance @@ -1529,17 +1530,22 @@ public: } } - const String *wanted_base = baseclass ? baseclass : pure_baseclass; bool derived = baseclass && getProxyName(c_baseclassname); + if (derived && purebase_notderived) + pure_baseclass = empty_string; + const String *wanted_base = baseclass ? baseclass : pure_baseclass; if (purebase_replace) { wanted_base = pure_baseclass; derived = false; Delete(baseclass); baseclass = NULL; + if (purebase_notderived) + Swig_error(input_file, line_number, "The csbase typemap for proxy %s must contain just one of the 'replace' or 'notderived' attributes.\n", typemap_lookup_type); } else if (Len(pure_baseclass) > 0 && Len(baseclass) > 0) { Swig_warning(WARN_CSHARP_MULTIPLE_INHERITANCE, input_file, line_number, - "Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in C#. Perhaps you need the replace attribute in the csbase typemap?\n", typemap_lookup_type, pure_baseclass); + "Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in C#. " + "Perhaps you need one of the 'replace' or 'notderived' attributes in the csbase typemap?\n", typemap_lookup_type, pure_baseclass); } // Pure C# interfaces diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index 8dfa19624..72556a04b 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -1567,6 +1567,7 @@ public: Node *attributes = NewHash(); const String *pure_baseclass = typemapLookup("javabase", typemap_lookup_type, WARN_NONE, attributes); bool purebase_replace = GetFlag(attributes, "tmap:javabase:replace") ? true : false; + bool purebase_notderived = GetFlag(attributes, "tmap:javabase:notderived") ? true : false; Delete(attributes); // C++ inheritance @@ -1600,6 +1601,8 @@ public: } bool derived = baseclass && getProxyName(c_baseclassname); + if (derived && purebase_notderived) + pure_baseclass = empty_string; const String *wanted_base = baseclass ? baseclass : pure_baseclass; if (purebase_replace) { @@ -1607,9 +1610,12 @@ public: derived = false; Delete(baseclass); baseclass = NULL; + if (purebase_notderived) + Swig_error(input_file, line_number, "The javabase typemap for proxy %s must contain just one of the 'replace' or 'notderived' attributes.\n", typemap_lookup_type); } else if (Len(pure_baseclass) > 0 && Len(baseclass) > 0) { Swig_warning(WARN_JAVA_MULTIPLE_INHERITANCE, input_file, line_number, - "Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Java. Perhaps you need the replace attribute in the javabase typemap?\n", typemap_lookup_type, pure_baseclass); + "Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Java. " + "Perhaps you need one of the 'replace' or 'notderived' attributes in the csbase typemap?\n", typemap_lookup_type, pure_baseclass); } // Pure Java interfaces From feb1e6de94162206df76aa09c6f587494d033622 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Wed, 29 Apr 2009 23:59:06 +0000 Subject: [PATCH 0383/1680] Remove two accidentally committed debug fprintf() calls. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11197 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/python/pyrun.swg | 3 --- 1 file changed, 3 deletions(-) diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index 09b629483..83dd569b0 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -1236,12 +1236,9 @@ SWIG_Python_NewShadowInstance(SwigPyClientData *data, PyObject *swig_this) } } else { #if PY_VERSION_HEX >= 0x03000000 - fprintf(stderr, "<<<<"); inst = PyBaseObject_Type.tp_new((PyTypeObject*) data->newargs, Py_None, Py_None); PyObject_SetAttr(inst, SWIG_This(), swig_this); Py_TYPE(inst)->tp_flags &= ~Py_TPFLAGS_VALID_VERSION_TAG; - fprintf(stderr, ">>>>"); - #else PyObject *dict = PyDict_New(); PyDict_SetItem(dict, SWIG_This(), swig_this); From 81f2687f6028fcaf2525a9bc33446cb2a3315526 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Thu, 30 Apr 2009 00:13:14 +0000 Subject: [PATCH 0384/1680] Remove accidentally committed conflict marker. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11198 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index ac448395a..506ba08be 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -15,7 +15,6 @@ Version 1.3.40 (in progress) 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). ->>>>>>> .r11195 2009-04-21: wsfulton [C#] Fix #2753469 - bool &OUTPUT and bool *OUTPUT typemaps initialisation. From 90b1578d65491cac9b50626ca92fbae1d7fa2450 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 30 Apr 2009 06:12:32 +0000 Subject: [PATCH 0385/1680] add test for optimal attribute in out typemap git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11199 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/common.mk | 1 + .../csharp/typemap_out_optimal_runme.cs | 13 +++++++ .../java/typemap_out_optimal_runme.java | 21 ++++++++++ .../python/typemap_out_optimal_runme.py | 5 +++ Examples/test-suite/typemap_out_optimal.i | 38 +++++++++++++++++++ 5 files changed, 78 insertions(+) create mode 100755 Examples/test-suite/csharp/typemap_out_optimal_runme.cs create mode 100644 Examples/test-suite/java/typemap_out_optimal_runme.java create mode 100644 Examples/test-suite/python/typemap_out_optimal_runme.py create mode 100644 Examples/test-suite/typemap_out_optimal.i diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index afcb87159..5c6a332a4 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -371,6 +371,7 @@ CPP_TEST_CASES += \ typemap_namespace \ typemap_ns_using \ typemap_numinputs \ + typemap_out_optimal \ typemap_variables \ typemap_various \ typename \ diff --git a/Examples/test-suite/csharp/typemap_out_optimal_runme.cs b/Examples/test-suite/csharp/typemap_out_optimal_runme.cs new file mode 100755 index 000000000..5bc1d14be --- /dev/null +++ b/Examples/test-suite/csharp/typemap_out_optimal_runme.cs @@ -0,0 +1,13 @@ +using System; +using typemap_out_optimalNamespace; + +public class typemap_out_optimal_runme { + + public static XX x = null; + public static void Main() { + XX.debug = false; + x = XX.create(); + } + +} + diff --git a/Examples/test-suite/java/typemap_out_optimal_runme.java b/Examples/test-suite/java/typemap_out_optimal_runme.java new file mode 100644 index 000000000..8a87f0c4b --- /dev/null +++ b/Examples/test-suite/java/typemap_out_optimal_runme.java @@ -0,0 +1,21 @@ + +import typemap_out_optimal.*; + +public class typemap_out_optimal_runme { + + static { + try { + System.loadLibrary("typemap_out_optimal"); + } catch (UnsatisfiedLinkError e) { + System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); + System.exit(1); + } + } + + public static XX x = null; + public static void main(String argv[]) { + XX.setDebug(false); + x = XX.create(); + } +} + diff --git a/Examples/test-suite/python/typemap_out_optimal_runme.py b/Examples/test-suite/python/typemap_out_optimal_runme.py new file mode 100644 index 000000000..b148f2d06 --- /dev/null +++ b/Examples/test-suite/python/typemap_out_optimal_runme.py @@ -0,0 +1,5 @@ +from typemap_out_optimal import * + +cvar.XX_debug = False +x = XX.create() + diff --git a/Examples/test-suite/typemap_out_optimal.i b/Examples/test-suite/typemap_out_optimal.i new file mode 100644 index 000000000..8bac2fa89 --- /dev/null +++ b/Examples/test-suite/typemap_out_optimal.i @@ -0,0 +1,38 @@ +// Test the optimal attribute in the out typemap +%module typemap_out_optimal + +// Just the following languages tested +#if defined (SWIGCSHARP) +%typemap(out, optimal="1") SWIGTYPE %{ + $result = new $1_ltype((const $1_ltype &)$1); +%} +#elif defined (SWIGJAVA) +%typemap(out, optimal="1") SWIGTYPE %{ + *($&1_ltype*)&$result = new $1_ltype((const $1_ltype &)$1); +%} +#elif defined (SWIGUTL) +%typemap(out,noblock="1", optimal="1") SWIGTYPE { + %set_output(SWIG_NewPointerObj(%new_copy($1, $ltype), $&descriptor, SWIG_POINTER_OWN | %newpointer_flags)); +} +#endif + +%ignore XX::operator=; + +%inline %{ +#include +using namespace std; + +struct XX { + XX() { 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() { if (debug) cout << "~XX()" << endl; } + static XX create() { + return XX(123); + } + static bool debug; +}; +bool XX::debug = true; +%} + From 410f7d59138ea46a9e6384465461889f1b8b1da8 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 1 May 2009 06:21:56 +0000 Subject: [PATCH 0386/1680] remove executable bits git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11200 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/csharp/bools_runme.cs | 0 Examples/test-suite/csharp/director_classic_runme.cs | 0 Examples/test-suite/csharp/enum_thorough_runme.cs | 0 Examples/test-suite/csharp/li_std_wstring_runme.cs | 0 Examples/test-suite/csharp/overload_complicated_runme.cs | 0 Examples/test-suite/csharp/typemap_out_optimal_runme.cs | 0 6 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 Examples/test-suite/csharp/bools_runme.cs mode change 100755 => 100644 Examples/test-suite/csharp/director_classic_runme.cs mode change 100755 => 100644 Examples/test-suite/csharp/enum_thorough_runme.cs mode change 100755 => 100644 Examples/test-suite/csharp/li_std_wstring_runme.cs mode change 100755 => 100644 Examples/test-suite/csharp/overload_complicated_runme.cs mode change 100755 => 100644 Examples/test-suite/csharp/typemap_out_optimal_runme.cs diff --git a/Examples/test-suite/csharp/bools_runme.cs b/Examples/test-suite/csharp/bools_runme.cs old mode 100755 new mode 100644 diff --git a/Examples/test-suite/csharp/director_classic_runme.cs b/Examples/test-suite/csharp/director_classic_runme.cs old mode 100755 new mode 100644 diff --git a/Examples/test-suite/csharp/enum_thorough_runme.cs b/Examples/test-suite/csharp/enum_thorough_runme.cs old mode 100755 new mode 100644 diff --git a/Examples/test-suite/csharp/li_std_wstring_runme.cs b/Examples/test-suite/csharp/li_std_wstring_runme.cs old mode 100755 new mode 100644 diff --git a/Examples/test-suite/csharp/overload_complicated_runme.cs b/Examples/test-suite/csharp/overload_complicated_runme.cs old mode 100755 new mode 100644 diff --git a/Examples/test-suite/csharp/typemap_out_optimal_runme.cs b/Examples/test-suite/csharp/typemap_out_optimal_runme.cs old mode 100755 new mode 100644 From 083d106bc4edb4a29362e0bcd71e3c0d6438f3cf Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 1 May 2009 06:26:42 +0000 Subject: [PATCH 0387/1680] Add test for notderived attribute in csbase/javabase typemap git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11201 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- .../csharp/inherit_target_language_runme.cs | 24 +++++++++++++++++++ Examples/test-suite/inherit_target_language.i | 10 ++++++++ .../java/inherit_target_language_runme.java | 9 +++++++ 3 files changed, 43 insertions(+) create mode 100644 Examples/test-suite/csharp/inherit_target_language_runme.cs diff --git a/Examples/test-suite/csharp/inherit_target_language_runme.cs b/Examples/test-suite/csharp/inherit_target_language_runme.cs new file mode 100644 index 000000000..2f9e2a75d --- /dev/null +++ b/Examples/test-suite/csharp/inherit_target_language_runme.cs @@ -0,0 +1,24 @@ +using System; +using inherit_target_languageNamespace; + +public class inherit_target_language_runme { + public static void Main() { + new Derived1().targetLanguageBaseMethod(); + new Derived2().targetLanguageBaseMethod(); + + new MultipleDerived1().targetLanguageBaseMethod(); + new MultipleDerived2().targetLanguageBaseMethod(); + new MultipleDerived3().f(); + new MultipleDerived4().g(); + + BaseX baseX = new BaseX(); + baseX.basex(); + baseX.targetLanguageBase2Method(); + + DerivedX derivedX = new DerivedX(); + derivedX.basex(); + derivedX.derivedx(); + derivedX.targetLanguageBase2Method(); + } +} + diff --git a/Examples/test-suite/inherit_target_language.i b/Examples/test-suite/inherit_target_language.i index 770e11d36..20fb93fda 100644 --- a/Examples/test-suite/inherit_target_language.i +++ b/Examples/test-suite/inherit_target_language.i @@ -12,10 +12,12 @@ using System; using System.Runtime.InteropServices; public class TargetLanguageBase { public virtual void targetLanguageBaseMethod() {} }; +public class TargetLanguageBase2 { public virtual void targetLanguageBase2Method() {} }; %} %pragma(java) moduleimports=%{ class TargetLanguageBase { public void targetLanguageBaseMethod() {} }; +class TargetLanguageBase2 { public void targetLanguageBase2Method() {} }; %} @@ -61,3 +63,11 @@ struct MultipleDerived3 : MBase3a, MBase3b {}; struct MultipleDerived4 : MBase4a, MBase4b {}; %} +// Replace a C++ base, but only classes that do not have a C++ base +%typemap(csbase, notderived="1") SWIGTYPE "TargetLanguageBase2" + +%inline %{ +struct BaseX { virtual ~BaseX() {}; void basex() {} }; +struct DerivedX : BaseX { void derivedx() {} }; +%} + diff --git a/Examples/test-suite/java/inherit_target_language_runme.java b/Examples/test-suite/java/inherit_target_language_runme.java index 6c7c1bf33..184272fe2 100644 --- a/Examples/test-suite/java/inherit_target_language_runme.java +++ b/Examples/test-suite/java/inherit_target_language_runme.java @@ -21,6 +21,15 @@ public class inherit_target_language_runme { new MultipleDerived2().targetLanguageBaseMethod(); new MultipleDerived3().f(); new MultipleDerived4().g(); + + BaseX baseX = new BaseX(); + baseX.basex(); + baseX.targetLanguageBase2Method(); + + DerivedX derivedX = new DerivedX(); + derivedX.basex(); + derivedX.derivedx(); + derivedX.targetLanguageBase2Method(); } } From a16a599a43c536c3d82a93ade0b44fc4425d2d32 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 5 May 2009 21:03:25 +0000 Subject: [PATCH 0388/1680] minor formatting mod git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11205 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.current b/CHANGES.current index 506ba08be..20e8decad 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,7 @@ Version 1.3.40 (in progress) [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 From 2b5560d267ec6743fbd32c9062e0a9f758ce19cd Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 5 May 2009 21:11:11 +0000 Subject: [PATCH 0389/1680] minor formatting mod 2 git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11206 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index 20e8decad..506ba08be 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,7 +5,6 @@ Version 1.3.40 (in progress) [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 From 13cbd90553f4bb4254c677ff05078b2bc49e8fca Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 11 May 2009 17:46:51 +0000 Subject: [PATCH 0390/1680] Improved std::vector wrappers on the C# proxy side from Yuval Baror to implement IList<> instead of IEnumerable<> where possible. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11209 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++++ Lib/csharp/std_vector.i | 14 +++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 506ba08be..4ddef0fee 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,10 @@ Version 1.3.40 (in progress) ============================ +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 diff --git a/Lib/csharp/std_vector.i b/Lib/csharp/std_vector.i index f4ad88bae..07a24dfd6 100644 --- a/Lib/csharp/std_vector.i +++ b/Lib/csharp/std_vector.i @@ -19,7 +19,8 @@ * %template(VectKlass) std::vector; * * Note that IEnumerable<> is implemented in the proxy class which is useful for using LINQ with - * C++ std::vector wrappers. + * C++ std::vector wrappers. IEnumerable<> is replaced by IList<> wherever we are confident that the + * required C++ operator== is available for correct compilation. * * Warning: heavy macro usage in this file. Use swig -E to get a sane view on the real file contents! * ----------------------------------------------------------------------------- */ @@ -31,8 +32,8 @@ // 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(CONST_REFERENCE_TYPE, CSTYPE, CTYPE...) -%typemap(csinterfaces) std::vector "IDisposable, System.Collections.IEnumerable\n#if !SWIG_DOTNET_1\n , System.Collections.Generic.IEnumerable\n#endif\n"; +%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"; %typemap(cscode) std::vector %{ public $csclassname(System.Collections.ICollection c) : this() { if (c == null) @@ -325,10 +326,9 @@ %enddef %define SWIG_STD_VECTOR_MINIMUM(CSTYPE, CTYPE...) -SWIG_STD_VECTOR_MINIMUM_INTERNAL(const value_type&, CSTYPE, CTYPE) +SWIG_STD_VECTOR_MINIMUM_INTERNAL(IEnumerable, const value_type&, CSTYPE, 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 @@ -367,7 +367,7 @@ SWIG_STD_VECTOR_MINIMUM_INTERNAL(const value_type&, CSTYPE, CTYPE) %define SWIG_STD_VECTOR_SPECIALIZE(CSTYPE, CTYPE...) namespace std { template<> class vector { - SWIG_STD_VECTOR_MINIMUM(CSTYPE, CTYPE) + SWIG_STD_VECTOR_MINIMUM_INTERNAL(IList, const value_type&, CSTYPE, CTYPE) SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(CSTYPE, CTYPE) }; } @@ -409,7 +409,7 @@ namespace std { }; // bool is a bit different in the C++ standard template<> class vector { - SWIG_STD_VECTOR_MINIMUM_INTERNAL(bool, bool, bool) + SWIG_STD_VECTOR_MINIMUM_INTERNAL(IList, bool, bool, bool) SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(bool, bool) }; } From 267ffd6ce687df7d3495ceca097a03b74cfa8974 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 12 May 2009 17:24:01 +0000 Subject: [PATCH 0391/1680] move std::multimap tests from li_std_map.i into new li_std_multimap.i git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11210 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/li_std_map.i | 3 +-- Examples/test-suite/python/Makefile.in | 1 + Examples/test-suite/ruby/Makefile.in | 1 + Examples/test-suite/ruby/li_std_map_runme.rb | 11 +------- .../test-suite/ruby/li_std_multimap_runme.rb | 27 +++++++++++++++++++ 5 files changed, 31 insertions(+), 12 deletions(-) create mode 100755 Examples/test-suite/ruby/li_std_multimap_runme.rb diff --git a/Examples/test-suite/li_std_map.i b/Examples/test-suite/li_std_map.i index 27c1b1a70..847a6e0b2 100644 --- a/Examples/test-suite/li_std_map.i +++ b/Examples/test-suite/li_std_map.i @@ -16,11 +16,11 @@ */ %module("templatereduce") li_std_map + %feature("trackobjects"); %include std_pair.i %include std_map.i -%include std_multimap.i %inline %{ struct A{ @@ -39,7 +39,6 @@ namespace std %template(pairAA) pair; %template(pairA) pair; %template(mapA) map; - %template(mmapA) multimap; %template(paircA1) pair; %template(paircA2) pair; diff --git a/Examples/test-suite/python/Makefile.in b/Examples/test-suite/python/Makefile.in index f5058df9f..b8bd8944c 100644 --- a/Examples/test-suite/python/Makefile.in +++ b/Examples/test-suite/python/Makefile.in @@ -50,6 +50,7 @@ CPP_TEST_CASES += \ li_std_vectora \ li_std_vector_extra \ li_std_map \ + li_std_multimap \ li_std_pair_extra \ li_std_set \ li_std_stream \ diff --git a/Examples/test-suite/ruby/Makefile.in b/Examples/test-suite/ruby/Makefile.in index 33395c006..d50b478be 100644 --- a/Examples/test-suite/ruby/Makefile.in +++ b/Examples/test-suite/ruby/Makefile.in @@ -15,6 +15,7 @@ CPP_TEST_CASES = \ li_factory \ li_std_functors \ li_std_map \ + li_std_multimap \ li_std_pair_lang_object \ li_std_queue \ li_std_set \ diff --git a/Examples/test-suite/ruby/li_std_map_runme.rb b/Examples/test-suite/ruby/li_std_map_runme.rb index 319fdec52..bd93b9170 100755 --- a/Examples/test-suite/ruby/li_std_map_runme.rb +++ b/Examples/test-suite/ruby/li_std_map_runme.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby # -# Tests for std::map and std::multimap +# Tests for std::map # # # @@ -41,15 +41,6 @@ m["foo"] = "hello" pm = Li_std_map::LanguageMap.new m.each_key { |k| pm[k] = m[k] } m.each_key { |k| swig_assert_equal("pm[#{k.inspect}]", "m[#{k.inspect}]", binding) } - -m = Li_std_map::MmapA.new -m[0] = a1 -m[0] = a2 -m[0].size == 2 -m.respond_to?(:each) == true -m.respond_to?(:each_key) == true -m.respond_to?(:each_value) == true -m.values_at(0)[0] == m[0] EOF mii = Li_std_map::Mapii.new diff --git a/Examples/test-suite/ruby/li_std_multimap_runme.rb b/Examples/test-suite/ruby/li_std_multimap_runme.rb new file mode 100755 index 000000000..b0c2bb359 --- /dev/null +++ b/Examples/test-suite/ruby/li_std_multimap_runme.rb @@ -0,0 +1,27 @@ +#!/usr/bin/env ruby +# +# Tests for std::multimap +# +# +# +# +# + +require 'swig_assert' +require 'li_std_multimap' + +swig_assert_each_line(<<'EOF', binding) + +a1 = Li_std_multimap::A.new(3) +a2 = Li_std_multimap::A.new(7) + +m = Li_std_multimap::MultimapA.new +m[0] = a1 +m[0] = a2 +m[0].size == 2 +m.respond_to?(:each) == true +m.respond_to?(:each_key) == true +m.respond_to?(:each_value) == true +m.values_at(0)[0] == m[0] +EOF + From 88ffb89c2b18fdef5796c0455c0e31e0ae9db75b Mon Sep 17 00:00:00 2001 From: Mikel Bancroft Date: Thu, 14 May 2009 00:35:17 +0000 Subject: [PATCH 0392/1680] [allegrocl] Minor tweak to improve wrapping in -nocwrap mode. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11212 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 3 +++ Source/Modules/allegrocl.cxx | 21 ++++++++++++++++----- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 4ddef0fee..5c9a6fe00 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,9 @@ Version 1.3.40 (in progress) ============================ +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. diff --git a/Source/Modules/allegrocl.cxx b/Source/Modules/allegrocl.cxx index 878e30a67..1eb12630c 100644 --- a/Source/Modules/allegrocl.cxx +++ b/Source/Modules/allegrocl.cxx @@ -483,7 +483,7 @@ void add_defined_foreign_type(Node *n, int overwrite = 0, String *k = 0, if (!Strcmp(nodeType(n), "cdecl") && !Strcmp(Getattr(n, "storage"), "typedef")) { SwigType *type = SwigType_strip_qualifiers(Getattr(n, "type")); #ifdef ALLEGROCL_CLASS_DEBUG - Printf(stderr, "Examining typedef '%s' for class references.\n", type); + Printf(stderr, "Examining typedef '%s' for class references. (%d)\n", type, SwigType_isclass(type)); #endif if (SwigType_isclass(type)) { #ifdef ALLEGROCL_CLASS_DEBUG @@ -761,6 +761,7 @@ String *internal_compose_foreign_type(SwigType *ty) { Setattr(nn,"allegrocl:package",current_namespace); add_forward_referenced_type(nn, 0); + // tok_name is dangling here, unused. ouch. why? Printf(ffiType, "%s", get_ffi_type(tok, ""), tok_name); } } @@ -934,9 +935,8 @@ String *infix_to_prefix(String *val, char split_op, const String *op, String *ty Printf(result, ")"); Delete(ored); return part_failed ? 0 : result; - } else { - Delete(ored); } + Delete(ored); return 0; } @@ -955,7 +955,7 @@ String *convert_literal(String *literal, String *type, bool try_to_split) { String *ns = listify_namespace(current_namespace); // very basic parsing of infix expressions. - if (try_to_split) { + if (try_to_split && SwigType_type(type) != T_STRING) { if ((res = infix_to_prefix(num, '|', "logior", type))) return res; if ((res = infix_to_prefix(num, '&', "logand", type))) @@ -970,9 +970,20 @@ String *convert_literal(String *literal, String *type, bool try_to_split) { return res; if ((res = infix_to_prefix(num, '-', "-", type))) return res; + // if ((res = infix_to_prefix(num, '~', "lognot", type))) return res; // if( (res = infix_to_prefix(num, '<<', "ash", type)) ) return res; } + // unary complement... + if (s[0] == '~' && Len(num) >= 2) { + String *id = NewString(++s); + String *id_conv = convert_literal(id, type, false); + Delete(id); + if (id_conv) + return NewStringf("(lognot %s)", id_conv); + s--; + } + if (SwigType_type(type) == T_FLOAT || SwigType_type(type) == T_DOUBLE || SwigType_type(type) == T_LONGDOUBLE) { // Use CL syntax for float literals String *oldnum = Copy(num); @@ -1136,7 +1147,7 @@ void emit_synonym(Node *synonym) { of_ltype = lookup_defined_foreign_ltype(of_name); - // Printf(f_clhead,";; from emit-synonym\n"); + // Printf(stderr,";; from emit-synonym syn='%s' of_ltype='%s'\n", syn_ltype, of_ltype); if( of_ltype ) Printf(f_clhead, "(swig-def-synonym-type %s\n %s\n %s)\n", syn_ltype, of_ltype, syn_type); From 6c96148de53ee6afdf065591e8abe9abc26df3d5 Mon Sep 17 00:00:00 2001 From: Haoyu Bai Date: Thu, 14 May 2009 15:58:09 +0000 Subject: [PATCH 0393/1680] fixed the wrong pointer value returned by SwigPyObject_repr() git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11213 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 3 +++ Lib/python/pyrun.swg | 4 +--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 5c9a6fe00..214c34386 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,9 @@ Version 1.3.40 (in progress) ============================ +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. diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index 83dd569b0..38632e1ab 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -383,9 +383,7 @@ SwigPyObject_repr(SwigPyObject *v, PyObject *args) #endif { const char *name = SWIG_TypePrettyName(v->ty); - PyObject *hex = SwigPyObject_hex(v); - PyObject *repr = SWIG_Python_str_FromFormat("", name, hex); - Py_DECREF(hex); + PyObject *repr = SWIG_Python_str_FromFormat("", name, v); if (v->next) { #ifdef METH_NOARGS PyObject *nrep = SwigPyObject_repr((SwigPyObject *)v->next); From b6c869be0f899337f0dea144db69fd53ff42ca4a Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 17 May 2009 20:28:43 +0000 Subject: [PATCH 0394/1680] fix link git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11214 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/CSharp.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/Manual/CSharp.html b/Doc/Manual/CSharp.html index 81c8a232b..3e17ee7f1 100644 --- a/Doc/Manual/CSharp.html +++ b/Doc/Manual/CSharp.html @@ -212,7 +212,7 @@ The "csin" typemap supports additional optional attributes called 'cshin' and 't The 'cshin' attribute should contain the parameter type and name whenever a constructor helper function is generated due to the 'pre' or 'post' attributes. The 'terminator' attribute normally just contains a closing brace for when the 'pre' attribute contains an opening brace, such as when a C# using or fixed block is started. Note that 'pre', 'post', 'terminator' and 'cshin' attributes are not used for marshalling the property set. -Please see the Date marshalling example and Date marshalling of properties example for further understanding of these "csin" applicable attributes. +Please see the Date marshalling example and Date marshalling of properties example for further understanding of these "csin" applicable attributes.

    • From d2c38bb56991f56ceabb8c1d5915515d9e48f024 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Tue, 19 May 2009 11:54:40 +0000 Subject: [PATCH 0395/1680] Snip nonsensical comment left over from cut and paste from other examples. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11215 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/python/callback/runme.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/Examples/python/callback/runme.py b/Examples/python/callback/runme.py index 5d93e8223..026e9520b 100644 --- a/Examples/python/callback/runme.py +++ b/Examples/python/callback/runme.py @@ -5,8 +5,6 @@ import example -# CEO class, which overrides Employee::getPosition(). - class PyCallback(example.Callback): def __init__(self): example.Callback.__init__(self) From 6ae7ce1cf198923fe6aae769da1d31d02fe59ab1 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Tue, 19 May 2009 12:00:48 +0000 Subject: [PATCH 0396/1680] Remove note which is no longer relevant. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11216 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Php.html | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Doc/Manual/Php.html b/Doc/Manual/Php.html index d56edcb5f..6e87a29a2 100644 --- a/Doc/Manual/Php.html +++ b/Doc/Manual/Php.html @@ -781,12 +781,6 @@ Ko::threats();

      29.2.7 PHP Pragmas, Startup and Shutdown code

      -

      -Note: Currently pragmas for PHP need to be specified using -%pragma(php) but also apply for PHP5! This is just a historical -oddity because SWIG's PHP support predates PHP5. -

      -

      To place PHP code in the generated "example.php" file one can use the code pragma. The code is inserted after loading the shared From 30335a0198adc03e020cfe8044bbffd31834f65e Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 22 May 2009 06:10:52 +0000 Subject: [PATCH 0397/1680] std::map improvements based on patch from Yuval Baror git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11230 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 6 +- .../test-suite/csharp/li_std_map_runme.cs | 239 ++++++ Examples/test-suite/li_std_map.i | 125 +-- Examples/test-suite/octave/li_std_map_runme.m | 2 +- .../test-suite/python/li_std_map_runme.py | 2 +- Examples/test-suite/ruby/li_std_map_runme.rb | 2 +- Lib/csharp/csharp.swg | 13 + Lib/csharp/std_map.i | 763 ++++++++++++++---- 8 files changed, 946 insertions(+), 206 deletions(-) create mode 100644 Examples/test-suite/csharp/li_std_map_runme.cs diff --git a/CHANGES.current b/CHANGES.current index 214c34386..b200a912d 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,8 +1,12 @@ Version 1.3.40 (in progress) ============================ +2009-05-11: wsfulton + [C#] Improved std::map wrappers based on patch from Yuval Baror. The C# proxy + now implements System.Collections.Generic.IDictionary<>. + 2009-05-14: bhy - [Python] Fix the wrong pointer value returned by SwigPyObject_repr(). + [Python] Fix the wrong pointer value returned by SwigPyObject_repr(). 2009-05-13: mutandiz (Mikel Bancroft) [allegrocl] Minor tweak when wrapping in -nocwrap mode. diff --git a/Examples/test-suite/csharp/li_std_map_runme.cs b/Examples/test-suite/csharp/li_std_map_runme.cs new file mode 100644 index 000000000..56ea197f1 --- /dev/null +++ b/Examples/test-suite/csharp/li_std_map_runme.cs @@ -0,0 +1,239 @@ +/* ----------------------------------------------------------------------------- + * See 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. + * ----------------------------------------------------------------------------- */ + +using System; +using System.Collections.Generic; +using li_std_mapNamespace; + +public class li_std_map_runme { + + private static readonly int collectionSize = 20; + private static readonly int midCollection = collectionSize / 2; + + public static void Main() + { + // Set up an int int map + IntIntMap iimap = new IntIntMap(); + for (int i = 0; i < collectionSize; i++) + { + int val = i * 18; + iimap.Add(i, val); + } + + // Count property test + if (iimap.Count != collectionSize) + throw new Exception("Count test failed"); + + // IsReadOnly property test + if (iimap.IsReadOnly) + throw new Exception("IsReadOnly test failed"); + + // Item indexing test + iimap[0] = 200; + if (iimap[0] != 200) + throw new Exception("Item property test failed"); + iimap[0] = 0 * 18; + + // ContainsKey() test + for (int i = 0; i < collectionSize; i++) + { + if (!iimap.ContainsKey(i)) + throw new Exception("ContainsKey test " + i + " failed"); + } + + // ContainsKey() test + for (int i = 0; i < collectionSize; i++) + { + if (!iimap.Contains(new KeyValuePair(i, i * 18))) + throw new Exception("Contains test " + i + " failed"); + } + + // TryGetValue() test + int value; + bool rc = iimap.TryGetValue(3, out value); + if (rc != true || value != (3 * 18)) + throw new Exception("TryGetValue test 1 failed"); + + rc = iimap.TryGetValue(-1, out value); + if (rc != false) + throw new Exception("TryGetValue test 2 failed"); + + // Keys and Values test + { + IList keys = new List(iimap.Keys); + IList values = new List(iimap.Values); + if (keys.Count != collectionSize) + throw new Exception("Keys count test failed"); + + if (values.Count != collectionSize) + throw new Exception("Values count test failed"); + + for (int i = 0; i < keys.Count; i++) + { + if (iimap[keys[i]] != values[i]) + throw new Exception("Keys and values test failed for index " + i); + } + } + + // Add and Remove test + for (int i = 100; i < 103; i++) + { + iimap.Add(i, i * 18); + if (!iimap.ContainsKey(i) || iimap[i] != (i * 18)) + throw new Exception("Add test failed for index " + i); + + iimap.Remove(i); + if (iimap.ContainsKey(i)) + throw new Exception("Remove test failed for index " + i); + } + + for (int i = 200; i < 203; i++) + { + iimap.Add(new KeyValuePair(i, i * 18)); + if (!iimap.ContainsKey(i) || iimap[i] != (i * 18)) + throw new Exception("Add explicit test failed for index " + i); + + iimap.Remove(new KeyValuePair(i, i * 18)); + if (iimap.ContainsKey(i)) + throw new Exception("Remove explicit test failed for index " + i); + } + + // Duplicate key test + try + { + iimap.Add(3, 0); + throw new Exception("Adding duplicate key test failed"); + } + catch (ArgumentException) + { + } + + // CopyTo() test + { + KeyValuePair[] outputarray = new KeyValuePair[collectionSize]; + iimap.CopyTo(outputarray); + foreach (KeyValuePair val in outputarray) + { + if (iimap[val.Key] != val.Value) + throw new Exception("CopyTo (1) test failed, index:" + val.Key); + } + } + { + KeyValuePair[] outputarray = new KeyValuePair[midCollection + collectionSize]; + iimap.CopyTo(outputarray, midCollection); + for (int i = midCollection; i < midCollection + collectionSize; i++) + { + KeyValuePair val = outputarray[i]; + if (iimap[val.Key] != val.Value) + throw new Exception("CopyTo (2) test failed, index:" + val.Key); + } + } + { + KeyValuePair[] outputarray = new KeyValuePair[collectionSize - 1]; + try + { + iimap.CopyTo(outputarray); + throw new Exception("CopyTo (4) test failed"); + } + catch (ArgumentException) + { + } + } + + // Clear test + iimap.Clear(); + if (iimap.Count != 0) + throw new Exception("Clear test failed"); + + // Test wrapped methods + for (int i = 1; i <= 5; i++) + { + iimap[i] = i; + } + double avg = li_std_map.keyAverage(iimap); + if (avg != 3.0) + throw new Exception("Wrapped method keyAverage test failed. Got " + avg); + + // Test a map with a new specialized type (Struct) + { + IntStructMap ismap = new IntStructMap(); + for (int i = 0; i < 10; i++) + { + ismap.Add(i, new Struct(i * 10.1)); + } + + if (ismap.Count != 10) + throw new Exception("Count test on specialized 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); + } + } + + // Test a map of pointers + { + IntStructPtrMap ispmap = new IntStructPtrMap(); + for (int i = 0; i < 10; i++) + { + ispmap.Add(i, new Struct(i * 10.1)); + } + + if (ispmap.Count != 10) + throw new Exception("Count test on specialized 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); + } + } + { + IntStructConstPtrMap iscpmap = new IntStructConstPtrMap(); + for (int i = 0; i < 10; i++) + { + iscpmap.Add(i, new Struct(i * 10.1)); + } + + if (iscpmap.Count != 10) + throw new Exception("Count test on specialized 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); + } + } + + // Test non-specialized map + { + StructIntMap limap = new StructIntMap(); + Struct s7 = new Struct(7); + Struct s8 = new Struct(8); + limap.set(s7 , 8); + if (limap.get(s7) != 8) + throw new Exception("Assignment test on non-specialized map failed"); + + if (!limap.has_key(s7)) + throw new Exception("Key test (1) on non-specialized map failed"); + + if (limap.has_key(s8)) + throw new Exception("Key test (2) on non-specialized map failed"); + } + + // All done + } +} + diff --git a/Examples/test-suite/li_std_map.i b/Examples/test-suite/li_std_map.i index 847a6e0b2..39e034bfa 100644 --- a/Examples/test-suite/li_std_map.i +++ b/Examples/test-suite/li_std_map.i @@ -1,40 +1,84 @@ -/** - * @file li_std_map.i - * @author gga - * @date Mon Apr 30 15:03:58 2007 - * - * @brief a test of map containers. - * Languages should define swig::LANGUAGE_OBJ to be - * an entity of their native pointer type which can be - * included in a STL container. - * - * For example: - * swig::LANGUAGE_OBJ is GC_VALUE in Ruby - * swig::LANGUAGE_OBJ is SwigPtr_PyObject in python - * - * - */ - %module("templatereduce") li_std_map - %feature("trackobjects"); -%include std_pair.i -%include std_map.i +%include "std_pair.i" +%include "std_map.i" +%include "std_string.i" +// Declare some maps to play around with +%template(IntIntMap) std::map; +%template(StringIntMap) std::map; + +%ignore Struct::operator<; +%ignore Struct::operator==; + +// Add an inline function to test %inline %{ -struct A{ - int val; - - A(int v = 0): val(v) - { - } +double keyAverage(std::map m) { + if (m.size() == 0) { + return 0.0; + } + + double a = 0.0; + for (std::map::iterator i = m.begin(); i != m.end(); i++) { + a += i->first; + } + + return a / m.size(); +} + +struct Struct { + double num; + Struct() : num(0.0) {} + Struct(double d) : num(d) {} + bool operator<(const Struct &other) const { return num < other.num; } + bool operator==(const Struct &other) const { return num == other.num; } }; + %} -namespace std -{ +#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 +%template(IntIntPtrMap) std::map; +%template(IntConstIntPtrMap) std::map; + +//#endif + + +// Test out some maps with non-basic types and non-basic pointer types +%template(IntStructMap) std::map; +%template(IntStructPtrMap) std::map; +%template(IntStructConstPtrMap) std::map; +%template(StructPtrIntMap) std::map; + +// Test out a non-specialized map +%template(StructIntMap) std::map; + +// Additional map definitions for Ruby, Python and Octave tests +%inline %{ + struct A{ + int val; + + A(int v = 0): val(v) { + } + }; +%} + +namespace std { %template(pairii) pair; %template(pairAA) pair; %template(pairA) pair; @@ -58,25 +102,14 @@ namespace std } +%inline { + std::pair p_identa(std::pair p) { + return p; + } - -%inline -{ -std::pair -p_identa(std::pair p) { - return p; -} - -std::map m_identa(const std::map& v) -{ - return v; -} - + std::map m_identa(const std::map& v) { + return v; + } } - -namespace std -{ -%template(mapii) map; -} diff --git a/Examples/test-suite/octave/li_std_map_runme.m b/Examples/test-suite/octave/li_std_map_runme.m index e74fc79fc..f37c78012 100644 --- a/Examples/test-suite/octave/li_std_map_runme.m +++ b/Examples/test-suite/octave/li_std_map_runme.m @@ -49,7 +49,7 @@ for k in pm, endif endfor -mii = li_std_map.mapii(); +mii = li_std_map.IntIntMap(); mii{1} = 1; mii{1} = 2; diff --git a/Examples/test-suite/python/li_std_map_runme.py b/Examples/test-suite/python/li_std_map_runme.py index 461421a54..ae75bdda0 100644 --- a/Examples/test-suite/python/li_std_map_runme.py +++ b/Examples/test-suite/python/li_std_map_runme.py @@ -48,7 +48,7 @@ for k in pm: -mii = li_std_map.mapii() +mii = li_std_map.IntIntMap() mii[1] = 1 mii[1] = 2 diff --git a/Examples/test-suite/ruby/li_std_map_runme.rb b/Examples/test-suite/ruby/li_std_map_runme.rb index bd93b9170..0ec8cac84 100755 --- a/Examples/test-suite/ruby/li_std_map_runme.rb +++ b/Examples/test-suite/ruby/li_std_map_runme.rb @@ -43,7 +43,7 @@ m.each_key { |k| pm[k] = m[k] } m.each_key { |k| swig_assert_equal("pm[#{k.inspect}]", "m[#{k.inspect}]", binding) } EOF -mii = Li_std_map::Mapii.new +mii = Li_std_map::IntIntMap.new mii[1] = 1 mii[1] = 2 diff --git a/Lib/csharp/csharp.swg b/Lib/csharp/csharp.swg index 94f76a3ad..fe459547c 100644 --- a/Lib/csharp/csharp.swg +++ b/Lib/csharp/csharp.swg @@ -803,6 +803,19 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) { /* Array reference typemaps */ %apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) } +/* Marshal C/C++ pointer to IntPtr */ +%typemap(ctype) void *VOID_INT_PTR "void *" +%typemap(imtype) void *VOID_INT_PTR "IntPtr" +%typemap(cstype) void *VOID_INT_PTR "IntPtr" +%typemap(in) void *VOID_INT_PTR %{ $1 = ($1_ltype)$input; %} +%typemap(out) void *VOID_INT_PTR %{ $result = (void *)$1; %} +%typemap(csin) void *VOID_INT_PTR "$csinput" +%typemap(csout, excode=SWIGEXCODE) void *VOID_INT_PTR { + IntPtr ret = $imcall;$excode + return ret; + } + + /* Typemaps used for the generation of proxy and type wrapper class code */ %typemap(csbase) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "" %typemap(csclassmodifiers) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "public class" diff --git a/Lib/csharp/std_map.i b/Lib/csharp/std_map.i index c35f21dc7..69ddb2cbb 100644 --- a/Lib/csharp/std_map.i +++ b/Lib/csharp/std_map.i @@ -5,13 +5,36 @@ * std_map.i * * SWIG typemaps for std::map + * C# implementation by Yuval Baror (http://yuval.bar-or.org) + * + * 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; + * + * Notes: + * 1) For .NET 1 compatibility, define SWIG_DOTNET_1 when compiling the C# code. In this case + * the C# wrapper has only basic functionality. + * 2) IEnumerable<> is implemented in the proxy class which is useful for using LINQ with + * C++ std::map wrappers. + * + * Warning: heavy macro usage in this file. Use swig -E to get a sane view on the real file contents! * ----------------------------------------------------------------------------- */ -%include - -// ------------------------------------------------------------------------ -// std::map -// ------------------------------------------------------------------------ +//%include %{ #include @@ -19,157 +42,585 @@ #include %} -// exported class +// A minimal implementation to be used when no specialization exists. +%define SWIG_STD_MAP_MINIMAL_INTERNAL(K, T) + public: + map(); + map(const map &); + + typedef size_t size_type; +// size_type size() const; + bool empty() const; + %rename(Clear) clear; + void clear(); + %extend { + T get(const K& key) throw (std::out_of_range) { + std::map::iterator i = self->find(key); + if (i != self->end()) + return i->second; + else + throw std::out_of_range("key not found"); + } + + void set(const K& key, const T& x) { + (*self)[key] = x; + } + + void del(const K& key) throw (std::out_of_range) { + std::map::iterator i = self->find(key); + if (i != self->end()) + self->erase(i); + else + throw std::out_of_range("key not found"); + } + + bool has_key(const K& key) { + std::map::iterator i = self->find(key); + return i != self->end(); + } + } + +%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(cscode) std::map %{ + + public CSVALUETYPE this[CSKEYTYPE key] { + get { + return getitem(key); + } + + set { + setitem(key, value); + } + } + + public bool TryGetValue(CSKEYTYPE key, out CSVALUETYPE value) { + if (this.ContainsKey(key)) { + value = this[key]; + return true; + } + value = default(CSVALUETYPE); + return false; + } + + public int Count { + get { + return (int)size(); + } + } + + public bool IsReadOnly { + get { + return false; + } + } + +#if !SWIG_DOTNET_1 + + public System.Collections.Generic.ICollection Keys { + get { + System.Collections.Generic.ICollection keys = new System.Collections.Generic.List(); + IntPtr iter = create_iterator_begin(); + try { + while (true) { + keys.Add(get_next_key(iter)); + } + } catch (ArgumentOutOfRangeException) { + } + return keys; + } + } + + public System.Collections.Generic.ICollection Values { + get { + System.Collections.Generic.ICollection vals = new System.Collections.Generic.List(); + foreach (System.Collections.Generic.KeyValuePair pair in this) { + vals.Add(pair.Value); + } + return vals; + } + } + + public void Add(System.Collections.Generic.KeyValuePair item) { + Add(item.Key, item.Value); + } + + public bool Remove(System.Collections.Generic.KeyValuePair item) { + if (Contains(item)) { + return Remove(item.Key); + } else { + return false; + } + } + + public bool Contains(System.Collections.Generic.KeyValuePair item) { + if (this[item.Key] == item.Value) { + return true; + } else { + return false; + } + } + + public void CopyTo(System.Collections.Generic.KeyValuePair[] array) { + CopyTo(array, 0); + } + + public void CopyTo(System.Collections.Generic.KeyValuePair[] array, int arrayIndex) { + if (array == null) + throw new ArgumentNullException("array"); + if (arrayIndex < 0) + throw new ArgumentOutOfRangeException("arrayIndex", "Value is less than zero"); + if (array.Rank > 1) + throw new ArgumentException("Multi dimensional array.", "array"); + if (arrayIndex+this.Count > array.Length) + throw new ArgumentException("Number of elements to copy is too large."); + + System.Collections.Generic.IList keyList = new System.Collections.Generic.List(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); + } + } + + System.Collections.Generic.IEnumerator> System.Collections.Generic.IEnumerable>.GetEnumerator() { + return new $csclassnameEnumerator(this); + } + + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { + return new $csclassnameEnumerator(this); + } + + public $csclassnameEnumerator GetEnumerator() { + return new $csclassnameEnumerator(this); + } + + // Type-safe enumerator + /// Note that the IEnumerator documentation requires an InvalidOperationException to be thrown + /// whenever the collection is modified. This has been done for changes in the size of the + /// collection but not when one of the elements of the collection is modified as it is a bit + /// tricky to detect unmanaged code that modifies the collection under our feet. + public sealed class $csclassnameEnumerator : System.Collections.IEnumerator, + System.Collections.Generic.IEnumerator> + { + private $csclassname collectionRef; + private System.Collections.Generic.IList keyCollection; + private int currentIndex; + private object currentObject; + private int currentSize; + + public $csclassnameEnumerator($csclassname collection) { + collectionRef = collection; + keyCollection = new System.Collections.Generic.List(collection.Keys); + currentIndex = -1; + currentObject = null; + currentSize = collectionRef.Count; + } + + // Type-safe iterator Current + public System.Collections.Generic.KeyValuePair Current { + get { + if (currentIndex == -1) + throw new InvalidOperationException("Enumeration not started."); + if (currentIndex > currentSize - 1) + throw new InvalidOperationException("Enumeration finished."); + if (currentObject == null) + throw new InvalidOperationException("Collection modified."); + return (System.Collections.Generic.KeyValuePair)currentObject; + } + } + + // Type-unsafe IEnumerator.Current + object System.Collections.IEnumerator.Current { + get { + return Current; + } + } + + public bool MoveNext() { + int size = collectionRef.Count; + bool moveOkay = (currentIndex+1 < size) && (size == currentSize); + if (moveOkay) { + currentIndex++; + CSKEYTYPE currentKey = keyCollection[currentIndex]; + currentObject = new System.Collections.Generic.KeyValuePair(currentKey, collectionRef[currentKey]); + } else { + currentObject = null; + } + return moveOkay; + } + + public void Reset() { + currentIndex = -1; + currentObject = null; + if (collectionRef.Count != currentSize) { + throw new InvalidOperationException("Collection modified."); + } + } + + public void Dispose() { + currentIndex = -1; + currentObject = null; + } + } +#endif + +%} + + public: + + map(); + map(const map &); + + typedef size_t size_type; + size_type size() const; + bool empty() const; + %rename(Clear) clear; + void clear(); + %extend { + T getitem(K key) throw (std::out_of_range) { + std::map::iterator i = self->find(key); + if (i != self->end()) + return i->second; + else + throw std::out_of_range("key not found"); + } + + void setitem(K key, T x) { + (*self)[key] = x; + } + + // 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 } + + std::map::iterator *create_iterator_begin() { + return new std::map::iterator(self->begin()); + } + + K get_next_key(std::map::iterator *swigiterator) throw (std::out_of_range) { + std::map::iterator iter = *swigiterator; + if (iter == self->end()) { + delete swigiterator; + throw std::out_of_range("no more map elements"); + } + (*swigiterator)++; + return (*iter).first; + } + + bool ContainsKey(K key) { + std::map::iterator iter = self->find(key); + if (iter != self->end()) { + return true; + } + return false; + } + + void Add(K key, T 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(K key) { + std::map::iterator iter = self->find(key); + if (iter != self->end()) { + self->erase(iter); + return true; + } + return false; + } + } + +%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" + + +%define SWIG_STD_MAP_SPECIALIZED(K, T, CSKEY, CSVAL) namespace std { - - template class map { - // add typemaps here - public: - map(); - map(const map &); - - unsigned int size() const; - bool empty() const; - void clear(); - %extend { - T& get(const K& key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); - if (i != self->end()) - return i->second; - else - throw std::out_of_range("key not found"); - } - void set(const K& key, const T& x) { - (*self)[key] = x; - } - void del(const K& key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); - if (i != self->end()) - self->erase(i); - else - throw std::out_of_range("key not found"); - } - bool has_key(const K& key) { - std::map::iterator i = self->find(key); - return i != self->end(); - } - } - }; - - - // specializations for built-ins - - %define specialize_std_map_on_key(K,CHECK,CONVERT_FROM,CONVERT_TO) - - template class map { - // add typemaps here - public: - map(); - map(const map &); - - unsigned int size() const; - bool empty() const; - void clear(); - %extend { - T& get(K key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); - if (i != self->end()) - return i->second; - else - throw std::out_of_range("key not found"); - } - void set(K key, const T& x) { - (*self)[key] = x; - } - void del(K key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); - if (i != self->end()) - self->erase(i); - else - throw std::out_of_range("key not found"); - } - bool has_key(K key) { - std::map::iterator i = self->find(key); - return i != self->end(); - } - } - }; - %enddef - - %define specialize_std_map_on_value(T,CHECK,CONVERT_FROM,CONVERT_TO) - template class map { - // add typemaps here - public: - map(); - map(const map &); - - unsigned int size() const; - bool empty() const; - void clear(); - %extend { - T get(const K& key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); - if (i != self->end()) - return i->second; - else - throw std::out_of_range("key not found"); - } - void set(const K& key, T x) { - (*self)[key] = x; - } - void del(const K& key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); - if (i != self->end()) - self->erase(i); - else - throw std::out_of_range("key not found"); - } - bool has_key(const K& key) { - std::map::iterator i = self->find(key); - return i != self->end(); - } - } - }; - %enddef - - %define specialize_std_map_on_both(K,CHECK_K,CONVERT_K_FROM,CONVERT_K_TO, - T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO) - template<> class map { - // add typemaps here - public: - map(); - map(const map &); - - unsigned int size() const; - bool empty() const; - void clear(); - %extend { - T get(K key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); - if (i != self->end()) - return i->second; - else - throw std::out_of_range("key not found"); - } - void set(K key, T x) { - (*self)[key] = x; - } - void del(K key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); - if (i != self->end()) - self->erase(i); - else - throw std::out_of_range("key not found"); - } - bool has_key(K key) { - std::map::iterator i = self->find(key); - return i != self->end(); - } - } - }; - %enddef - - // add specializations here - + 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 + +// Backwards compatibility macros +%define specialize_std_map_on_key(K,CHECK,CONVERT_FROM,CONVERT_TO) + template class map { + SWIG_STD_MAP_MINIMAL_INTERNAL(K, T) + }; +%enddef + +%define specialize_std_map_on_value(T,CHECK,CONVERT_FROM,CONVERT_TO) + template class map { + SWIG_STD_MAP_MINIMAL_INTERNAL(K, T) + }; +%enddef + +%define specialize_std_map_on_both(K,CHECK_K,CONVERT_K_FROM,CONVERT_K_TO, + T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO) + template<> class map { + SWIG_STD_MAP_MINIMAL_INTERNAL(K, T) + }; +%enddef + +// exported class +namespace std { + // Regular implementation + template class map { + SWIG_STD_MAP_MINIMAL_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 + + From 07ed699ef3a7ff1bdb69cb27b8b65885c988836d Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 22 May 2009 06:11:45 +0000 Subject: [PATCH 0398/1680] use instead of self git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11231 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/csharp/std_map.i | 42 +++++++++++++-------------- Lib/csharp/std_vector.i | 64 ++++++++++++++++++++--------------------- 2 files changed, 53 insertions(+), 53 deletions(-) diff --git a/Lib/csharp/std_map.i b/Lib/csharp/std_map.i index 69ddb2cbb..32d3a8c21 100644 --- a/Lib/csharp/std_map.i +++ b/Lib/csharp/std_map.i @@ -56,28 +56,28 @@ void clear(); %extend { T get(const K& key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); - if (i != self->end()) + std::map::iterator i = $self->find(key); + if (i != $self->end()) return i->second; else throw std::out_of_range("key not found"); } void set(const K& key, const T& x) { - (*self)[key] = x; + (*$self)[key] = x; } void del(const K& key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); - if (i != self->end()) - self->erase(i); + std::map::iterator i = $self->find(key); + if (i != $self->end()) + $self->erase(i); else throw std::out_of_range("key not found"); } bool has_key(const K& key) { - std::map::iterator i = self->find(key); - return i != self->end(); + std::map::iterator i = $self->find(key); + return i != $self->end(); } } @@ -288,15 +288,15 @@ void clear(); %extend { T getitem(K key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); - if (i != self->end()) + std::map::iterator i = $self->find(key); + if (i != $self->end()) return i->second; else throw std::out_of_range("key not found"); } void setitem(K key, T x) { - (*self)[key] = x; + (*$self)[key] = x; } // create_iterator_begin() and get_next_key() work together to provide a collection of keys to C# @@ -304,12 +304,12 @@ %apply void *VOID_INT_PTR { std::map::iterator *swigiterator } std::map::iterator *create_iterator_begin() { - return new std::map::iterator(self->begin()); + return new std::map::iterator($self->begin()); } K get_next_key(std::map::iterator *swigiterator) throw (std::out_of_range) { std::map::iterator iter = *swigiterator; - if (iter == self->end()) { + if (iter == $self->end()) { delete swigiterator; throw std::out_of_range("no more map elements"); } @@ -318,25 +318,25 @@ } bool ContainsKey(K key) { - std::map::iterator iter = self->find(key); - if (iter != self->end()) { + std::map::iterator iter = $self->find(key); + if (iter != $self->end()) { return true; } return false; } void Add(K key, T val) throw (std::out_of_range) { - std::map::iterator iter = self->find(key); - if (iter != self->end()) { + 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)); + $self->insert(std::pair(key, val)); } bool Remove(K key) { - std::map::iterator iter = self->find(key); - if (iter != self->end()) { - self->erase(iter); + std::map::iterator iter = $self->find(key); + if (iter != $self->end()) { + $self->erase(iter); return true; } return false; diff --git a/Lib/csharp/std_vector.i b/Lib/csharp/std_vector.i index 07a24dfd6..fa422cfee 100644 --- a/Lib/csharp/std_vector.i +++ b/Lib/csharp/std_vector.i @@ -238,26 +238,26 @@ return pv; } CTYPE getitemcopy(int index) throw (std::out_of_range) { - if (index>=0 && index<(int)self->size()) - return (*self)[index]; + if (index>=0 && index<(int)$self->size()) + return (*$self)[index]; else throw std::out_of_range("index"); } const_reference getitem(int index) throw (std::out_of_range) { - if (index>=0 && index<(int)self->size()) - return (*self)[index]; + if (index>=0 && index<(int)$self->size()) + return (*$self)[index]; else throw std::out_of_range("index"); } void setitem(int index, const value_type& val) throw (std::out_of_range) { - if (index>=0 && index<(int)self->size()) - (*self)[index] = val; + if (index>=0 && index<(int)$self->size()) + (*$self)[index] = val; else throw std::out_of_range("index"); } // Takes a deep copy of the elements unlike ArrayList.AddRange void AddRange(const std::vector& values) { - self->insert(self->end(), values.begin(), values.end()); + $self->insert($self->end(), values.begin(), values.end()); } // Takes a deep copy of the elements unlike ArrayList.GetRange std::vector *GetRange(int index, int count) throw (std::out_of_range, std::invalid_argument) { @@ -265,26 +265,26 @@ throw std::out_of_range("index"); if (count < 0) throw std::out_of_range("count"); - if (index >= (int)self->size()+1 || index+count > (int)self->size()) + if (index >= (int)$self->size()+1 || index+count > (int)$self->size()) throw std::invalid_argument("invalid range"); - return new std::vector(self->begin()+index, self->begin()+index+count); + return new std::vector($self->begin()+index, $self->begin()+index+count); } void Insert(int index, const value_type& x) throw (std::out_of_range) { - if (index>=0 && index<(int)self->size()+1) - self->insert(self->begin()+index, x); + if (index>=0 && index<(int)$self->size()+1) + $self->insert($self->begin()+index, x); else throw std::out_of_range("index"); } // Takes a deep copy of the elements unlike ArrayList.InsertRange void InsertRange(int index, const std::vector& values) throw (std::out_of_range) { - if (index>=0 && index<(int)self->size()+1) - self->insert(self->begin()+index, values.begin(), values.end()); + if (index>=0 && index<(int)$self->size()+1) + $self->insert($self->begin()+index, values.begin(), values.end()); else throw std::out_of_range("index"); } void RemoveAt(int index) throw (std::out_of_range) { - if (index>=0 && index<(int)self->size()) - self->erase(self->begin() + index); + if (index>=0 && index<(int)$self->size()) + $self->erase($self->begin() + index); else throw std::out_of_range("index"); } @@ -293,9 +293,9 @@ throw std::out_of_range("index"); if (count < 0) throw std::out_of_range("count"); - if (index >= (int)self->size()+1 || index+count > (int)self->size()) + if (index >= (int)$self->size()+1 || index+count > (int)$self->size()) throw std::invalid_argument("invalid range"); - self->erase(self->begin()+index, self->begin()+index+count); + $self->erase($self->begin()+index, $self->begin()+index+count); } static std::vector *Repeat(const value_type& value, int count) throw (std::out_of_range) { if (count < 0) @@ -303,24 +303,24 @@ return new std::vector(count, value); } void Reverse() { - std::reverse(self->begin(), self->end()); + std::reverse($self->begin(), $self->end()); } void Reverse(int index, int count) throw (std::out_of_range, std::invalid_argument) { if (index < 0) throw std::out_of_range("index"); if (count < 0) throw std::out_of_range("count"); - if (index >= (int)self->size()+1 || index+count > (int)self->size()) + if (index >= (int)$self->size()+1 || index+count > (int)$self->size()) throw std::invalid_argument("invalid range"); - std::reverse(self->begin()+index, self->begin()+index+count); + std::reverse($self->begin()+index, $self->begin()+index+count); } // Takes a deep copy of the elements unlike ArrayList.SetRange void SetRange(int index, const std::vector& values) throw (std::out_of_range) { if (index < 0) throw std::out_of_range("index"); - if (index+values.size() > self->size()) + if (index+values.size() > $self->size()) throw std::out_of_range("index"); - std::copy(values.begin(), values.end(), self->begin()+index); + std::copy(values.begin(), values.end(), $self->begin()+index); } } %enddef @@ -335,26 +335,26 @@ SWIG_STD_VECTOR_MINIMUM_INTERNAL(IEnumerable, const value_type&, CSTYPE, CTYPE) %define SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(CSTYPE, CTYPE...) %extend { bool Contains(const value_type& value) { - return std::find(self->begin(), self->end(), value) != self->end(); + return std::find($self->begin(), $self->end(), value) != $self->end(); } int IndexOf(const value_type& value) { int index = -1; - std::vector::iterator it = std::find(self->begin(), self->end(), value); - if (it != self->end()) - index = (int)(it - self->begin()); + std::vector::iterator it = std::find($self->begin(), $self->end(), value); + if (it != $self->end()) + index = (int)(it - $self->begin()); return index; } int LastIndexOf(const value_type& value) { int index = -1; - std::vector::reverse_iterator rit = std::find(self->rbegin(), self->rend(), value); - if (rit != self->rend()) - index = (int)(self->rend() - 1 - rit); + std::vector::reverse_iterator rit = std::find($self->rbegin(), $self->rend(), value); + if (rit != $self->rend()) + index = (int)($self->rend() - 1 - rit); return index; } bool Remove(const value_type& value) { - std::vector::iterator it = std::find(self->begin(), self->end(), value); - if (it != self->end()) { - self->erase(it); + std::vector::iterator it = std::find($self->begin(), $self->end(), value); + if (it != $self->end()) { + $self->erase(it); return true; } return false; From f3a70a1a03391718735af3c922a4ace4852518d1 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 22 May 2009 06:53:20 +0000 Subject: [PATCH 0399/1680] Improve C# std::map tests to do the bulk of the testing on a map where the key and value types are different git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11232 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- .../test-suite/csharp/li_std_map_runme.cs | 80 ++++++++++--------- Examples/test-suite/li_std_map.i | 14 +++- 2 files changed, 53 insertions(+), 41 deletions(-) diff --git a/Examples/test-suite/csharp/li_std_map_runme.cs b/Examples/test-suite/csharp/li_std_map_runme.cs index 56ea197f1..f1a98d2d5 100644 --- a/Examples/test-suite/csharp/li_std_map_runme.cs +++ b/Examples/test-suite/csharp/li_std_map_runme.cs @@ -24,55 +24,55 @@ public class li_std_map_runme { public static void Main() { // Set up an int int map - IntIntMap iimap = new IntIntMap(); + StringIntMap simap = new StringIntMap(); for (int i = 0; i < collectionSize; i++) { int val = i * 18; - iimap.Add(i, val); + simap.Add(i.ToString(), val); } // Count property test - if (iimap.Count != collectionSize) + if (simap.Count != collectionSize) throw new Exception("Count test failed"); // IsReadOnly property test - if (iimap.IsReadOnly) + if (simap.IsReadOnly) throw new Exception("IsReadOnly test failed"); // Item indexing test - iimap[0] = 200; - if (iimap[0] != 200) + simap["0"] = 200; + if (simap["0"] != 200) throw new Exception("Item property test failed"); - iimap[0] = 0 * 18; + simap["0"] = 0 * 18; // ContainsKey() test for (int i = 0; i < collectionSize; i++) { - if (!iimap.ContainsKey(i)) + if (!simap.ContainsKey(i.ToString())) throw new Exception("ContainsKey test " + i + " failed"); } // ContainsKey() test for (int i = 0; i < collectionSize; i++) { - if (!iimap.Contains(new KeyValuePair(i, i * 18))) + if (!simap.Contains(new KeyValuePair(i.ToString(), i * 18))) throw new Exception("Contains test " + i + " failed"); } // TryGetValue() test int value; - bool rc = iimap.TryGetValue(3, out value); + bool rc = simap.TryGetValue("3", out value); if (rc != true || value != (3 * 18)) throw new Exception("TryGetValue test 1 failed"); - rc = iimap.TryGetValue(-1, out value); + rc = simap.TryGetValue("-1", out value); if (rc != false) throw new Exception("TryGetValue test 2 failed"); // Keys and Values test { - IList keys = new List(iimap.Keys); - IList values = new List(iimap.Values); + IList keys = new List(simap.Keys); + IList values = new List(simap.Values); if (keys.Count != collectionSize) throw new Exception("Keys count test failed"); @@ -81,7 +81,7 @@ public class li_std_map_runme { for (int i = 0; i < keys.Count; i++) { - if (iimap[keys[i]] != values[i]) + if (simap[keys[i]] != values[i]) throw new Exception("Keys and values test failed for index " + i); } } @@ -89,30 +89,30 @@ public class li_std_map_runme { // Add and Remove test for (int i = 100; i < 103; i++) { - iimap.Add(i, i * 18); - if (!iimap.ContainsKey(i) || iimap[i] != (i * 18)) + simap.Add(i.ToString(), i * 18); + if (!simap.ContainsKey(i.ToString()) || simap[i.ToString()] != (i * 18)) throw new Exception("Add test failed for index " + i); - iimap.Remove(i); - if (iimap.ContainsKey(i)) + simap.Remove(i.ToString()); + if (simap.ContainsKey(i.ToString())) throw new Exception("Remove test failed for index " + i); } for (int i = 200; i < 203; i++) { - iimap.Add(new KeyValuePair(i, i * 18)); - if (!iimap.ContainsKey(i) || iimap[i] != (i * 18)) + simap.Add(new KeyValuePair(i.ToString(), i * 18)); + if (!simap.ContainsKey(i.ToString()) || simap[i.ToString()] != (i * 18)) throw new Exception("Add explicit test failed for index " + i); - iimap.Remove(new KeyValuePair(i, i * 18)); - if (iimap.ContainsKey(i)) + simap.Remove(new KeyValuePair(i.ToString(), i * 18)); + if (simap.ContainsKey(i.ToString())) throw new Exception("Remove explicit test failed for index " + i); } // Duplicate key test try { - iimap.Add(3, 0); + simap.Add("3", 0); throw new Exception("Adding duplicate key test failed"); } catch (ArgumentException) @@ -121,29 +121,29 @@ public class li_std_map_runme { // CopyTo() test { - KeyValuePair[] outputarray = new KeyValuePair[collectionSize]; - iimap.CopyTo(outputarray); - foreach (KeyValuePair val in outputarray) + KeyValuePair[] outputarray = new KeyValuePair[collectionSize]; + simap.CopyTo(outputarray); + foreach (KeyValuePair val in outputarray) { - if (iimap[val.Key] != val.Value) + if (simap[val.Key] != val.Value) throw new Exception("CopyTo (1) test failed, index:" + val.Key); } } { - KeyValuePair[] outputarray = new KeyValuePair[midCollection + collectionSize]; - iimap.CopyTo(outputarray, midCollection); + KeyValuePair[] outputarray = new KeyValuePair[midCollection + collectionSize]; + simap.CopyTo(outputarray, midCollection); for (int i = midCollection; i < midCollection + collectionSize; i++) { - KeyValuePair val = outputarray[i]; - if (iimap[val.Key] != val.Value) + KeyValuePair val = outputarray[i]; + if (simap[val.Key] != val.Value) throw new Exception("CopyTo (2) test failed, index:" + val.Key); } } { - KeyValuePair[] outputarray = new KeyValuePair[collectionSize - 1]; + KeyValuePair[] outputarray = new KeyValuePair[collectionSize - 1]; try { - iimap.CopyTo(outputarray); + simap.CopyTo(outputarray); throw new Exception("CopyTo (4) test failed"); } catch (ArgumentException) @@ -152,18 +152,22 @@ public class li_std_map_runme { } // Clear test - iimap.Clear(); - if (iimap.Count != 0) + simap.Clear(); + if (simap.Count != 0) throw new Exception("Clear test failed"); // Test wrapped methods for (int i = 1; i <= 5; i++) { - iimap[i] = i; + simap[i.ToString()] = i; } - double avg = li_std_map.keyAverage(iimap); + double avg = li_std_map.valueAverage(simap); if (avg != 3.0) - throw new Exception("Wrapped method keyAverage test failed. Got " + avg); + throw new Exception("Wrapped method valueAverage test failed. Got " + avg); + + string keyStringified = li_std_map.stringifyKeys(simap); + if (keyStringified != " 1 2 3 4 5") + throw new Exception("Wrapped method stringifyKeys test failed. Got " + keyStringified); // Test a map with a new specialized type (Struct) { diff --git a/Examples/test-suite/li_std_map.i b/Examples/test-suite/li_std_map.i index 39e034bfa..356e86df3 100644 --- a/Examples/test-suite/li_std_map.i +++ b/Examples/test-suite/li_std_map.i @@ -15,19 +15,27 @@ // Add an inline function to test %inline %{ -double keyAverage(std::map m) { +double valueAverage(std::map m) { if (m.size() == 0) { return 0.0; } double a = 0.0; - for (std::map::iterator i = m.begin(); i != m.end(); i++) { - a += i->first; + for (std::map::iterator i = m.begin(); i != m.end(); i++) { + a += i->second; } return a / m.size(); } +std::string stringifyKeys(std::map m) { + std::string a; + for (std::map::iterator i = m.begin(); i != m.end(); i++) { + a += " " + i->first; + } + return a; +} + struct Struct { double num; Struct() : num(0.0) {} From 7841adc67586001024726712c22e133cedbf52ed Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 26 May 2009 06:23:39 +0000 Subject: [PATCH 0400/1680] Add std::vector copy constructor to proxy git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11233 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/csharp/li_std_vector_runme.cs | 9 ++++++++- Lib/csharp/std_vector.i | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Examples/test-suite/csharp/li_std_vector_runme.cs b/Examples/test-suite/csharp/li_std_vector_runme.cs index 6d6def05d..a2da91e15 100644 --- a/Examples/test-suite/csharp/li_std_vector_runme.cs +++ b/Examples/test-suite/csharp/li_std_vector_runme.cs @@ -153,7 +153,7 @@ public class li_std_vector_runme { } } try { - new DoubleVector(null); + new DoubleVector((System.Collections.ICollection)null); throw new Exception("ICollection constructor null test failed"); } catch (ArgumentNullException) { } @@ -180,6 +180,13 @@ public class li_std_vector_runme { throw new Exception("LastIndexOf non-existent test failed"); if (dv.LastIndexOf(33.3) != 6) throw new Exception("LastIndexOf position test failed"); + + // Copy constructor test + DoubleVector dvCopy = new DoubleVector(dv); + for (int i=0; i* pv = 0; From 936114496415d8f299bcc6717858a29028f91f40 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 26 May 2009 06:28:20 +0000 Subject: [PATCH 0401/1680] Add copy constructor to std::map and make more efficient by passing keys and mapped type by reference instead of value git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11234 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/csharp/std_map.i | 142 ++++++++++++++++++++----------------------- 1 file changed, 65 insertions(+), 77 deletions(-) diff --git a/Lib/csharp/std_map.i b/Lib/csharp/std_map.i index 32d3a8c21..f26cd6b25 100644 --- a/Lib/csharp/std_map.i +++ b/Lib/csharp/std_map.i @@ -34,8 +34,6 @@ * Warning: heavy macro usage in this file. Use swig -E to get a sane view on the real file contents! * ----------------------------------------------------------------------------- */ -//%include - %{ #include #include @@ -45,39 +43,40 @@ // A minimal implementation to be used when no specialization exists. %define SWIG_STD_MAP_MINIMAL_INTERNAL(K, T) public: - map(); - map(const map &); + map(const map &other); + typedef K key_type; + typedef T mapped_type; typedef size_t size_type; -// size_type size() const; + size_type size() const; bool empty() const; %rename(Clear) clear; void clear(); %extend { - T get(const K& key) throw (std::out_of_range) { - std::map::iterator i = $self->find(key); - if (i != $self->end()) - return i->second; + const mapped_type& get(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 set(const K& key, const T& x) { + void set(const key_type& key, const mapped_type& x) { (*$self)[key] = x; } - void del(const K& key) throw (std::out_of_range) { - std::map::iterator i = $self->find(key); - if (i != $self->end()) - $self->erase(i); + void del(const key_type& key) throw (std::out_of_range) { + std::map::iterator iter = $self->find(key); + if (iter != $self->end()) + $self->erase(iter); else throw std::out_of_range("key not found"); } - bool has_key(const K& key) { - std::map::iterator i = $self->find(key); - return i != $self->end(); + bool has_key(const key_type& key) { + std::map::iterator iter = $self->find(key); + return iter != $self->end(); } } @@ -91,8 +90,8 @@ */ %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(cscode) std::map %{ +%typemap(csinterfaces) std::map "IDisposable \n#if !SWIG_DOTNET_1\n , System.Collections.Generic.IDictionary\n#endif\n"; +%typemap(cscode) std::map %{ public CSVALUETYPE this[CSKEYTYPE key] { get { @@ -277,28 +276,50 @@ %} public: - map(); - map(const map &); + map(const map &other); + 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 { - T getitem(K key) throw (std::out_of_range) { - std::map::iterator i = $self->find(key); - if (i != $self->end()) - return i->second; + 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(K key, T x) { + 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; + } + // 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 } @@ -307,7 +328,7 @@ return new std::map::iterator($self->begin()); } - K get_next_key(std::map::iterator *swigiterator) throw (std::out_of_range) { + const key_type& get_next_key(std::map::iterator *swigiterator) throw (std::out_of_range) { std::map::iterator iter = *swigiterator; if (iter == $self->end()) { delete swigiterator; @@ -316,43 +337,19 @@ (*swigiterator)++; return (*iter).first; } - - bool ContainsKey(K key) { - std::map::iterator iter = $self->find(key); - if (iter != $self->end()) { - return true; - } - return false; - } - - void Add(K key, T 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(K key) { - std::map::iterator iter = $self->find(key); - if (iter != $self->end()) { - $self->erase(iter); - return true; - } - return false; - } } + +%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 -%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" - - +// Main specialization macros %define SWIG_STD_MAP_SPECIALIZED(K, T, CSKEY, CSVAL) namespace std { template<> class map { @@ -361,36 +358,27 @@ namespace std { } %enddef - %define SWIG_STD_MAP_SPECIALIZED_SIMPLE(K, T) SWIG_STD_MAP_SPECIALIZED(K, T, K, T) %enddef -// Backwards compatibility macros +// Old macros (deprecated) %define specialize_std_map_on_key(K,CHECK,CONVERT_FROM,CONVERT_TO) - template class map { - SWIG_STD_MAP_MINIMAL_INTERNAL(K, T) - }; +#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) - template class map { - SWIG_STD_MAP_MINIMAL_INTERNAL(K, T) - }; +#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) - template<> class map { - SWIG_STD_MAP_MINIMAL_INTERNAL(K, T) - }; + +%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 - -// exported class + +// Default implementation namespace std { - // Regular implementation template class map { - SWIG_STD_MAP_MINIMAL_INTERNAL(K, T) + SWIG_STD_MAP_MINIMAL_INTERNAL(K, T) }; } From 3ffdfee64ad32119196c2d8f34454fabce7804f4 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 26 May 2009 06:31:04 +0000 Subject: [PATCH 0402/1680] remove authors - these are in the CHANGES files and README files git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11235 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/csharp/std_map.i | 1 - 1 file changed, 1 deletion(-) diff --git a/Lib/csharp/std_map.i b/Lib/csharp/std_map.i index f26cd6b25..32914affe 100644 --- a/Lib/csharp/std_map.i +++ b/Lib/csharp/std_map.i @@ -5,7 +5,6 @@ * std_map.i * * SWIG typemaps for std::map - * C# implementation by Yuval Baror (http://yuval.bar-or.org) * * The C# wrapper is made to look and feel like a C# System.Collections.Generic.IDictionary<>. * From 25bcb4d5e60933b787f077c68837343fa27b38f9 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 26 May 2009 17:08:53 +0000 Subject: [PATCH 0403/1680] std::map C# improvements git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11236 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 17 +++++++++- .../test-suite/csharp/li_std_map_runme.cs | 8 ++--- Lib/csharp/std_map.i | 33 ++++++++++++------- 3 files changed, 41 insertions(+), 17 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index b200a912d..b7fde04cc 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,10 +1,25 @@ Version 1.3.40 (in progress) ============================ -2009-05-11: wsfulton +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-14: bhy [Python] Fix the wrong pointer value returned by SwigPyObject_repr(). diff --git a/Examples/test-suite/csharp/li_std_map_runme.cs b/Examples/test-suite/csharp/li_std_map_runme.cs index f1a98d2d5..685b20e47 100644 --- a/Examples/test-suite/csharp/li_std_map_runme.cs +++ b/Examples/test-suite/csharp/li_std_map_runme.cs @@ -226,14 +226,14 @@ public class li_std_map_runme { StructIntMap limap = new StructIntMap(); Struct s7 = new Struct(7); Struct s8 = new Struct(8); - limap.set(s7 , 8); - if (limap.get(s7) != 8) + limap.setitem(s7 , 8); + if (limap.getitem(s7) != 8) throw new Exception("Assignment test on non-specialized map failed"); - if (!limap.has_key(s7)) + if (!limap.ContainsKey(s7)) throw new Exception("Key test (1) on non-specialized map failed"); - if (limap.has_key(s8)) + if (limap.ContainsKey(s8)) throw new Exception("Key test (2) on non-specialized map failed"); } diff --git a/Lib/csharp/std_map.i b/Lib/csharp/std_map.i index 32914affe..3b09861a2 100644 --- a/Lib/csharp/std_map.i +++ b/Lib/csharp/std_map.i @@ -53,7 +53,7 @@ %rename(Clear) clear; void clear(); %extend { - const mapped_type& get(const key_type& key) throw (std::out_of_range) { + 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; @@ -61,22 +61,31 @@ throw std::out_of_range("key not found"); } - void set(const key_type& key, const mapped_type& x) { + void setitem(const key_type& key, const mapped_type& x) { (*$self)[key] = x; } - void del(const key_type& key) throw (std::out_of_range) { - std::map::iterator iter = $self->find(key); - if (iter != $self->end()) - $self->erase(iter); - else - throw std::out_of_range("key not found"); - } - - bool has_key(const key_type& key) { - std::map::iterator iter = $self->find(key); + 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 From 096aaddfcf9c74189536eba11f35caad47ffa337 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 27 May 2009 22:04:19 +0000 Subject: [PATCH 0404/1680] add test for $descriptor() macro git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11237 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/typemap_subst.i | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Examples/test-suite/typemap_subst.i b/Examples/test-suite/typemap_subst.i index 67d412442..d5a8416db 100644 --- a/Examples/test-suite/typemap_subst.i +++ b/Examples/test-suite/typemap_subst.i @@ -50,6 +50,14 @@ (void)stardesc; (void)ampdesc; } + { /* Test descriptor macro */ + void *desc = $descriptor(const struct xyzzy **); + void *stardesc = $descriptor(const struct xyzzy *); + void *ampdesc = $descriptor(const struct xyzzy ***); + (void)desc; + (void)stardesc; + (void)ampdesc; + } $1 = ($ltype) temp; } From 69890f4957f7db7904e92465736bfa0194111b0c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 27 May 2009 22:55:14 +0000 Subject: [PATCH 0405/1680] add missing file omitted in earlier commit git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11238 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/li_std_multimap.i | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 Examples/test-suite/li_std_multimap.i diff --git a/Examples/test-suite/li_std_multimap.i b/Examples/test-suite/li_std_multimap.i new file mode 100644 index 000000000..a29417919 --- /dev/null +++ b/Examples/test-suite/li_std_multimap.i @@ -0,0 +1,25 @@ +%module("templatereduce") li_std_multimap + +%feature("trackobjects"); + +%include std_pair.i +%include std_map.i +%include std_multimap.i + +%inline %{ +struct A{ + int val; + + A(int v = 0): val(v) + { + } + +}; +%} + +namespace std +{ + %template(pairA) pair; + %template(mapA) map; + %template(multimapA) multimap; +} From baffa067dc9bf59d3fcb319b8898716c77fa7f4a Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 27 May 2009 23:39:46 +0000 Subject: [PATCH 0406/1680] minor formatting git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11239 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/intrusive_ptr.i | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Lib/intrusive_ptr.i b/Lib/intrusive_ptr.i index 7a686cfc5..43e78f986 100644 --- a/Lib/intrusive_ptr.i +++ b/Lib/intrusive_ptr.i @@ -27,11 +27,10 @@ namespace SWIG_INTRUSIVE_PTR_NAMESPACE { } %fragment("SWIG_intrusive_deleter", "header") { -template struct SWIG_intrusive_deleter -{ - void operator()(T * p) - { - if(p) intrusive_ptr_release(p); +template struct SWIG_intrusive_deleter { + void operator()(T *p) { + if (p) + intrusive_ptr_release(p); } }; } From 4bfec466e82bd7e22eb92bc8424a5b1c95c77a77 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 29 May 2009 17:42:49 +0000 Subject: [PATCH 0407/1680] trailing comma fix for ISOC89 compliance - patch from Ben Schmeckpeper git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11240 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/csharp/csharphead.swg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/csharp/csharphead.swg b/Lib/csharp/csharphead.swg index ffff70372..927a54b3b 100644 --- a/Lib/csharp/csharphead.swg +++ b/Lib/csharp/csharphead.swg @@ -68,7 +68,7 @@ static SWIG_CSharpException_t SWIG_csharp_exceptions[] = { static SWIG_CSharpExceptionArgument_t SWIG_csharp_exceptions_argument[] = { { SWIG_CSharpArgumentException, NULL }, { SWIG_CSharpArgumentNullException, NULL }, - { SWIG_CSharpArgumentOutOfRangeException, NULL }, + { SWIG_CSharpArgumentOutOfRangeException, NULL } }; static void SWIGUNUSED SWIG_CSharpSetPendingException(SWIG_CSharpExceptionCodes code, const char *msg) { From 3e0fc9f7b95f63c51d1f35e0733151a31320623a Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 29 May 2009 17:44:20 +0000 Subject: [PATCH 0408/1680] minor format improvment git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11241 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/java/javahead.swg | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Lib/java/javahead.swg b/Lib/java/javahead.swg index fc4c4e267..7626bf50d 100644 --- a/Lib/java/javahead.swg +++ b/Lib/java/javahead.swg @@ -83,7 +83,8 @@ static void SWIGUNUSED SWIG_JavaThrowException(JNIEnv *jenv, SWIG_JavaExceptionC { SWIG_JavaNullPointerException, "java/lang/NullPointerException" }, { SWIG_JavaDirectorPureVirtual, "java/lang/RuntimeException" }, { SWIG_JavaUnknownError, "java/lang/UnknownError" }, - { (SWIG_JavaExceptionCodes)0, "java/lang/UnknownError" } }; + { (SWIG_JavaExceptionCodes)0, "java/lang/UnknownError" } + }; const SWIG_JavaExceptions_t *except_ptr = java_exceptions; while (except_ptr->code != code && except_ptr->code) From 5f1e95ff67573bd3b9855eee4179034067b69e21 Mon Sep 17 00:00:00 2001 From: Robert Stone Date: Tue, 2 Jun 2009 21:13:03 +0000 Subject: [PATCH 0409/1680] 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 0410/1680] 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 0411/1680] 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 0412/1680] 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 0413/1680] 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 0414/1680] 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 0415/1680] 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 0416/1680] 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 0417/1680] 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"
       
    • 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 0418/1680] 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 0419/1680] 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 0420/1680] 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 0421/1680] 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 0422/1680] 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 0423/1680] [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 0424/1680] 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 0425/1680] [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 0426/1680] 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 0427/1680] 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 0428/1680] 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 0429/1680] 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 0430/1680] 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 0431/1680] 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 0432/1680] 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 0433/1680] 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 0434/1680] 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 0435/1680] 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 0436/1680] [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 0437/1680] 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 0438/1680] 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 0439/1680] 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 0440/1680] 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 0441/1680] 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 0442/1680] 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 0443/1680] 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 0444/1680] 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 0445/1680] 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 0446/1680] [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 0447/1680] 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 0448/1680] 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 0449/1680] 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 0450/1680] 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 0451/1680] 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 0452/1680] 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 0453/1680] 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 0454/1680] 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

      -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 0455/1680] [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 0456/1680] 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 0457/1680] 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 0458/1680] 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 @@

    • PHP Pragmas, Startup and Shutdown code +
    • 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 0459/1680] 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 0460/1680] 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 0461/1680] 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 0462/1680] [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 0463/1680] [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 0464/1680] [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 0465/1680] [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 0466/1680] 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 0467/1680] -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 0468/1680] 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 0469/1680] (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 @@

    • Typemap specifications -
    • Pattern matching rules +
    • Pattern matching rules
    • 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 @@
    • Typemap specifications -
    • Pattern matching rules +
    • Pattern matching rules
    • 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 0470/1680] 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 0471/1680] 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
    • Input and output parameters -
    • Exception handling +
    • Exception handling
    • Remapping datatypes with typemaps
    • Typemap Examples
    • PHP Pragmas, Startup and Shutdown code +
    • 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 0472/1680] 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 0473/1680] 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 0474/1680] 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 0475/1680] 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 0476/1680] 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 0477/1680] 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 0478/1680] 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 0479/1680] () 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 0480/1680] 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 0481/1680] [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 0482/1680] 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 0483/1680] 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 0484/1680] 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 0485/1680] 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 0486/1680] 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 0487/1680] [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 0488/1680] 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 0489/1680] 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 0490/1680] 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 0491/1680] 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 0492/1680] 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 0493/1680] 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 0494/1680] 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 0495/1680] 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 0496/1680] 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 0497/1680] 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 0498/1680] 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 0499/1680] 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 0500/1680] 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 0501/1680] 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 0502/1680] 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 0503/1680] 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 0504/1680] 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 0505/1680] 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 0506/1680] 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 0507/1680] 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 0508/1680] 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 0509/1680] 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 0510/1680] 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 0511/1680] 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 0512/1680] 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 0513/1680] 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 0514/1680] 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 0515/1680] 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 0516/1680] 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 0517/1680] 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 0518/1680] 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 0519/1680] 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 0520/1680] 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 0521/1680] 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 0522/1680] 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 0523/1680] 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 0524/1680] 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 0525/1680] 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 0526/1680] 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 0527/1680] 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 0528/1680] 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 0529/1680] 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 0530/1680] 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 0531/1680] 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 0532/1680] 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 0533/1680] [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 0534/1680] 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 0535/1680] [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 0536/1680] 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 0537/1680] 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 0538/1680] 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 0539/1680] 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 0540/1680] 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 0541/1680] 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 0542/1680] 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 0543/1680] 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 0544/1680] 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 0545/1680] 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 0546/1680] 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 0547/1680] 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 0548/1680] 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 0549/1680] 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 0550/1680] 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 0551/1680] 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 0552/1680] 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 0553/1680] 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 0554/1680] 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 0555/1680] 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 0556/1680] 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 0557/1680] 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 0558/1680] 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 0559/1680] 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 0560/1680] 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 0561/1680] 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 0562/1680] 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 0563/1680] 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 0564/1680] 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 0565/1680] 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 0566/1680] 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 0567/1680] 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 0568/1680] 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 0569/1680] 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 0570/1680] 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 0571/1680] 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 0572/1680] [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 0573/1680] [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 0574/1680] 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 0575/1680] 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 0576/1680] 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 0577/1680] 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 0578/1680] 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 0579/1680] 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 0580/1680] 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 0581/1680] 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 0582/1680] 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 0583/1680] 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 0584/1680] 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 0585/1680] 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 0586/1680] 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 0587/1680] 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 0588/1680] 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 0589/1680] 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 0590/1680] 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 0591/1680] 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 0592/1680] 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 0593/1680] 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.

    • - + 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 0594/1680] [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 0595/1680] 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 0596/1680] 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 0597/1680] 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 0598/1680] 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 0599/1680] 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 0600/1680] 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 0601/1680] 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 0602/1680] 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 0603/1680] 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 0604/1680] 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 0605/1680] 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 0606/1680] 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 0607/1680] 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 0608/1680] 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 0609/1680] 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 0610/1680] 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 0611/1680] 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 0612/1680] 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 0613/1680] 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 0614/1680] 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 0615/1680] 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 -
    • Typemaps - +
    • Debugging Options
    • Guide to parse tree nodes +
    • 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 0616/1680] 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 0617/1680] 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.
    • 320. Explicit template instantiation ignored.
    • 321. identifier conflicts with a built-in name.
    • 322. Redundant redeclaration of 'name'. +
    • 323. Recursive scope inheritance of 'name'. +
    • 324. Named nested template instantiations not supported. Processing as if no name was given to %template().
    • 350. operator new ignored.
    • 351. operator delete ignored.
    • 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 0618/1680] 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 0619/1680] 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 0620/1680] 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 0621/1680] [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 0622/1680] 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 0623/1680] 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 0624/1680] 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 0625/1680] 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 0626/1680] 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 0627/1680] 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 0628/1680] 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 0629/1680] 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 0630/1680] 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.
       
    • 308. Namespace alias 'name' not allowed here. Assuming 'name'
    • 309. [private | protected] inheritance ignored.
    • 310. Template 'name' was already wrapped as 'name' (ignored) -
    • 311. Template partial specialization not supported. -
    • 312. Nested classes not currently supported (ignored). +
    • 312. Nested class not currently supported (name ignored).
    • 313. Unrecognized extern type "name" (ignored).
    • 314. 'identifier' is a lang keyword.
    • 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 0631/1680] 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 0632/1680] 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 0633/1680] 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 0634/1680] 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 0635/1680] 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 0636/1680] 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) {
       }
       
      +

    • 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); };
    • -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 0637/1680] 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.
    • 308. Namespace alias 'name' not allowed here. Assuming 'name'
    • 309. [private | protected] inheritance ignored.
    • 310. Template 'name' was already wrapped as 'name' (ignored) -
    • 312. Nested class not currently supported (name ignored). +
    • 312. Unnamed nested class not currently supported (ignored).
    • 313. Unrecognized extern type "name" (ignored).
    • 314. 'identifier' is a lang keyword.
    • 315. Nothing known about 'identifier'. @@ -412,6 +412,7 @@ example.i(4): Syntax error in input.
    • 322. Redundant redeclaration of 'name'.
    • 323. Recursive scope inheritance of 'name'.
    • 324. Named nested template instantiations not supported. Processing as if no name was given to %template(). +
    • 325. Nested class not currently supported (name ignored).
    • 350. operator new ignored.
    • 351. operator delete ignored.
    • 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 0638/1680] [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 0639/1680] 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 0640/1680] 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 0641/1680] 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 0642/1680] 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
       

    • String *s;

    • -(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

    • SwigType *t;

    • -(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

      -

    • String_or_char *sc;
    • +
    • const_String_or_char_ptr sc;
    • 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 0643/1680] 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 0644/1680] 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 0645/1680] 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 0646/1680] 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 0647/1680] 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 0648/1680] 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 0649/1680] 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 0650/1680] 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 0651/1680] 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 0652/1680] 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 0653/1680] 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 0654/1680] 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 0655/1680] 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 0656/1680] 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 0657/1680] 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 0658/1680] 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 0659/1680] 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 0660/1680] 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 0661/1680] 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 0662/1680] 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 0663/1680] 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 0664/1680] [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 0665/1680] 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 0666/1680] 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 0667/1680] [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 0668/1680] 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 0669/1680] 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 0670/1680] 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 0671/1680] 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 0672/1680] 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 0673/1680] [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 0674/1680] 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 0675/1680] 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 0676/1680] [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 0677/1680] 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 0678/1680] "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 0679/1680] 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 0680/1680] 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 0681/1680] 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 0682/1680] 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 0683/1680] 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 0684/1680] 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 0685/1680] 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 0686/1680] 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 0687/1680] 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 0688/1680] 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 0689/1680] 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 0690/1680] 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 0691/1680] 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 @@

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

      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.
    • 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 0692/1680] 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 0693/1680] 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 @@

    • Pattern matching rules
    • Code generation rules -
    • Typemaps for multiple languages +
    • Typemaps for multiple target languages
    • Optimal code generation when returning by value
    • Multi-argument typemaps
    • The run-time type checker @@ -1280,9 +1281,6 @@
    • Simple pointers
    • Unbounded C Arrays
    • String handling -
    • Arrays -
    • String arrays -
    • STL wrappers
    • Typemaps
    • 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 0694/1680] -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 0695/1680] 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) {

    • +

      +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 0696/1680] 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 @@

    • Smart pointers and operator->()
    • Using declarations and inheritance
    • Nested classes -
    • A brief rant about const-correctness +
    • A brief rant about const-correctness
    • 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 0697/1680] 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 0698/1680] 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 0699/1680] 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 0700/1680] 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 0701/1680] 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 0702/1680] 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 0703/1680] 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 0704/1680] 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 0705/1680] 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 0706/1680] 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 0707/1680] 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 0708/1680] 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 0709/1680] 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): +

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

      +

      10.4 Code generation rules

      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 0710/1680] 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 0711/1680] 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 0712/1680] 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 0713/1680] 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 0714/1680] 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 0715/1680] 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.
    • 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. +
    • 508. Declaration of 'name' shadows declaration accessible via operator->(), previous declaration of'declaration'.
    • 509. Overloaded method declaration effectively ignored, as it is shadowed by declaration.
    • 510. Friend function 'name' ignored.
    • 511. Can't use keyword arguments with overloaded functions. 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 0716/1680] 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 0717/1680] 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.
    • 315. Nothing known about 'identifier'.
    • 316. Repeated %module directive.
    • 317. Specialization of non-template 'name'. -
    • 318. Instantiation of template name is ambiguous. Using templ at file:line +
    • 318. Instantiation of template 'name' is ambiguous, instantiation templ used, instantiation templ ignored.
    • 319. No access specifier given for base class name (ignored).
    • 320. Explicit template instantiation ignored.
    • 321. identifier conflicts with a built-in name. From 237f64a6e13ee31362f2a341cbaec48befcb7cc4 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 10 Jan 2010 22:37:28 +0000 Subject: [PATCH 0718/1680] 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 0719/1680] 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.
    • 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 0720/1680] 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 0721/1680] [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 0722/1680] 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 0723/1680] 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 0724/1680] 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 0725/1680] 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 0726/1680] 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 0727/1680] 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 0728/1680] 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 0729/1680] 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:
    • 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 0730/1680] 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 0731/1680] 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 0732/1680] 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 0733/1680] 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 0734/1680] 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 0735/1680] 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 0736/1680] 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 0737/1680] 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 0738/1680] 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 0739/1680] 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 0740/1680] 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 0741/1680] 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 0742/1680] 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 0743/1680] 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 0744/1680] 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 0745/1680] 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 0746/1680] 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 0747/1680] 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 0748/1680] 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 0749/1680] 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 0750/1680] 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 0751/1680] 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 0752/1680] 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 0753/1680] 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 0754/1680] 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 0755/1680] 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 0756/1680] 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 0757/1680] 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 0758/1680] 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 0759/1680] 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 0760/1680] 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 * From 931628f8b245ecbed4a3f020715bff123cacd1b1 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 28 Feb 2010 00:09:20 +0000 Subject: [PATCH 0761/1680] Remove the svn/cvs Id string in the headers git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11877 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Devel/engineering.html | 17 ++++++++++------- Makefile.in | 2 +- Source/CParse/cparse.h | 2 -- Source/Modules/swigmod.h | 2 -- Source/Preprocessor/preprocessor.h | 2 -- Source/Swig/swig.h | 2 -- Source/Swig/swigfile.h | 2 -- Source/Swig/swigopt.h | 2 -- Source/Swig/swigparm.h | 2 -- Source/Swig/swigscan.h | 2 -- Source/Swig/swigtree.h | 2 -- Source/Swig/swigwrap.h | 2 -- 12 files changed, 11 insertions(+), 28 deletions(-) diff --git a/Doc/Devel/engineering.html b/Doc/Devel/engineering.html index 5ccfb7858..7dfef2ad3 100644 --- a/Doc/Devel/engineering.html +++ b/Doc/Devel/engineering.html @@ -119,22 +119,25 @@ are case-insensitive on Windows so this convention will prevent you from inadver creating two files that differ in case-only.

      -Each file should include a short abstract, author information, copyright information, and +Each file should include a short abstract, license information and a SVN revision tag like this:

       /* -----------------------------------------------------------------------------
      - * See 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
      + * xxx.c
        *
      - * This file defines a variety of wrapping rules for C/C++ handling including
      - * the naming of local variables, calling conventions, and so forth.
      + * This file defines ...
        * ----------------------------------------------------------------------------- */
       
      -char cvsroot_cwrap_c[] = "$Id$";
      +static char cvs[] = "$Id$ xxx.c";
       
       #include "swig.h"
       
      diff --git a/Makefile.in b/Makefile.in
      index bdfec746e..6effe59b9 100644
      --- a/Makefile.in
      +++ b/Makefile.in
      @@ -1,5 +1,5 @@
       #######################################################################
      -# $Id$
      +# SWIG top level Makefile
       #######################################################################
       
       .PHONY: ccache source swig
      diff --git a/Source/CParse/cparse.h b/Source/CParse/cparse.h
      index ddc5d05dc..922bbfcdc 100644
      --- a/Source/CParse/cparse.h
      +++ b/Source/CParse/cparse.h
      @@ -11,8 +11,6 @@
        * SWIG parser module.
        * ----------------------------------------------------------------------------- */
       
      -/* $Id$ */
      -
       #ifndef SWIG_CPARSE_H_
       #define SWIG_CPARSE_H_
       
      diff --git a/Source/Modules/swigmod.h b/Source/Modules/swigmod.h
      index 813c56cb9..a6b5234d4 100644
      --- a/Source/Modules/swigmod.h
      +++ b/Source/Modules/swigmod.h
      @@ -11,8 +11,6 @@
        * Main header file for SWIG modules.
        * ----------------------------------------------------------------------------- */
       
      -/* $Id$ */
      -
       #ifndef SWIG_SWIGMOD_H_
       #define SWIG_SWIGMOD_H_
       
      diff --git a/Source/Preprocessor/preprocessor.h b/Source/Preprocessor/preprocessor.h
      index 8f98dae15..b08ff31b9 100644
      --- a/Source/Preprocessor/preprocessor.h
      +++ b/Source/Preprocessor/preprocessor.h
      @@ -11,8 +11,6 @@
        * SWIG preprocessor module.
        * ----------------------------------------------------------------------------- */
       
      -/* $Id$ */
      -
       #ifndef SWIG_PREPROCESSOR_H_
       #define SWIG_PREPROCESSOR_H_
       
      diff --git a/Source/Swig/swig.h b/Source/Swig/swig.h
      index 6aff97955..ec5ecb271 100644
      --- a/Source/Swig/swig.h
      +++ b/Source/Swig/swig.h
      @@ -11,8 +11,6 @@
        * Header file for the SWIG core.
        * ----------------------------------------------------------------------------- */
       
      -/* $Id$ */
      -
       #ifndef SWIGCORE_H_
       #define SWIGCORE_H_
       
      diff --git a/Source/Swig/swigfile.h b/Source/Swig/swigfile.h
      index 632e821e2..cdf23cddc 100644
      --- a/Source/Swig/swigfile.h
      +++ b/Source/Swig/swigfile.h
      @@ -11,8 +11,6 @@
        * File handling functions in the SWIG core
        * ----------------------------------------------------------------------------- */
       
      -/* $Id: swig.h 9603 2006-12-05 21:47:01Z beazley $ */
      -
       extern List   *Swig_add_directory(const_String_or_char_ptr dirname);
       extern void    Swig_push_directory(const_String_or_char_ptr dirname);
       extern void    Swig_pop_directory(void);
      diff --git a/Source/Swig/swigopt.h b/Source/Swig/swigopt.h
      index 586f8bbc4..543bfb819 100644
      --- a/Source/Swig/swigopt.h
      +++ b/Source/Swig/swigopt.h
      @@ -11,8 +11,6 @@
        * Header file for the SWIG command line processing functions
        * ----------------------------------------------------------------------------- */
       
      -/* $Id: swig.h 9622 2006-12-19 03:49:17Z beazley $ */
      -
        extern void  Swig_init_args(int argc, char **argv);
        extern void  Swig_mark_arg(int n);
        extern int   Swig_check_marked(int n);
      diff --git a/Source/Swig/swigparm.h b/Source/Swig/swigparm.h
      index 060225f6b..70a39390e 100644
      --- a/Source/Swig/swigparm.h
      +++ b/Source/Swig/swigparm.h
      @@ -12,8 +12,6 @@
        * parameter lists.  
        * ----------------------------------------------------------------------------- */
       
      -/* $Id: swig.h 9629 2006-12-30 18:27:47Z beazley $ */
      -
       /* Individual parameters */
       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);
      diff --git a/Source/Swig/swigscan.h b/Source/Swig/swigscan.h
      index d52124c60..b07812fbe 100644
      --- a/Source/Swig/swigscan.h
      +++ b/Source/Swig/swigscan.h
      @@ -11,8 +11,6 @@
        * C/C++ scanner. 
        * ----------------------------------------------------------------------------- */
       
      -/* $Id: swig.h 9633 2007-01-10 23:43:07Z beazley $ */
      -
       typedef struct Scanner Scanner;
       
       extern Scanner     *NewScanner(void);
      diff --git a/Source/Swig/swigtree.h b/Source/Swig/swigtree.h
      index 6799398c9..5decb79e3 100644
      --- a/Source/Swig/swigtree.h
      +++ b/Source/Swig/swigtree.h
      @@ -13,8 +13,6 @@
        * and function names are meant to be similar.
        * ----------------------------------------------------------------------------- */
       
      -/* $Id: swig.h 9622 2006-12-19 03:49:17Z beazley $ */
      -
       /* Macros to traverse the DOM tree */
       
       #define  nodeType(x)               Getattr(x,"nodeType")
      diff --git a/Source/Swig/swigwrap.h b/Source/Swig/swigwrap.h
      index b1f596f72..e44cb5344 100644
      --- a/Source/Swig/swigwrap.h
      +++ b/Source/Swig/swigwrap.h
      @@ -11,8 +11,6 @@
        * Functions related to wrapper objects.
        * ----------------------------------------------------------------------------- */
       
      -/* $Id: swig.h 9635 2007-01-12 01:44:16Z beazley $ */
      -
       typedef struct Wrapper {
           Hash *localh;
           String *def;
      
      From 9c541c340ad9103836fbdbed9658d84c9eccbef5 Mon Sep 17 00:00:00 2001
      From: William S Fulton 
      Date: Sun, 28 Feb 2010 00:16:39 +0000
      Subject: [PATCH 0762/1680] remove final vestiges of gifplot example
      
      git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11878 626c5289-ae23-0410-ae9c-e8d60b6d4f22
      ---
       Doc/Devel/internals.html  |  5 ++--
       Doc/Manual/Chicken.html   |  3 +-
       Doc/Manual/Extending.html | 10 ++-----
       Examples/README           |  4 +--
       Examples/guile/README     |  3 --
       Examples/index.html       |  6 ----
       Examples/s-exp/uffi.lisp  | 61 ---------------------------------------
       7 files changed, 6 insertions(+), 86 deletions(-)
      
      diff --git a/Doc/Devel/internals.html b/Doc/Devel/internals.html
      index 63a8626ff..5f774c095 100644
      --- a/Doc/Devel/internals.html
      +++ b/Doc/Devel/internals.html
      @@ -76,9 +76,8 @@ to code).
       
    • diff --git a/Doc/Manual/Chicken.html b/Doc/Manual/Chicken.html index 98372a0f7..d1d83aafa 100644 --- a/Doc/Manual/Chicken.html +++ b/Doc/Manual/Chicken.html @@ -86,8 +86,7 @@

      You may want to look at any of the examples in Examples/chicken/ - or Examples/GIFPlot/Chicken for the basic steps to run SWIG - CHICKEN. + directory for the basic steps to run SWIG CHICKEN.

      19.1.1 Running SWIG in C mode

      diff --git a/Doc/Manual/Extending.html b/Doc/Manual/Extending.html index cc40024e6..bdf5e8478 100644 --- a/Doc/Manual/Extending.html +++ b/Doc/Manual/Extending.html @@ -3090,8 +3090,6 @@ The nickname is used in four places:
      - -
      This example is in Examples/ocaml/stl
      RUBYSwigSWIG
      Examples This subdir tree contains examples of using SWIG w/ different scripting languages, including makefiles. Typically, there are the -"simple" and "matrix" examples, w/ some languages offering additional -examples. The GIFPlot example has its own set of per-language -subdirectories. See the README more index.html file in each directory +"simple" and "class" examples, w/ some languages offering additional +examples. See the README more index.html file in each directory for more info. [FIXME: Ref SWIG user manual.]
      usagetransform
      "skip" tag(none)
      Examples/ subdir name(none)
      Examples/GIFPlot/ subdir namecapitalize (upcase first letter)
      Examples/test-suite/ subdir name(none)
      @@ -3159,8 +3157,8 @@ skip-qux = $(skip-qux99)

      Lastly, you need to modify each of check-aliveness, -check-examples, check-test-suite, -check-gifplot (all targets) and lib-languages (var). +check-examples, check-test-suite +and lib-languages (var). Use the nickname for these, not the alias. Note that you can do this even before you have any tests or examples set up; the Makefile rules do some sanity checking and skip around @@ -3175,10 +3173,6 @@ and look to the existing languages for examples.

      Do cp ../python/check.list . and modify to taste. One subdir per line. -
      Examples/GIFPlot/Qux99/check.list -
      Do cp ../Python/check.list . and modify to taste. -One subdir per line. -
      Lib/qux99/extra-install.list
      If you add your language to the top-level Makefile.in var lib-languages, then make install will install diff --git a/Examples/README b/Examples/README index 0747547cb..4dda3222d 100644 --- a/Examples/README +++ b/Examples/README @@ -2,9 +2,7 @@ SWIG Examples The "perl5", "python", "tcl", "guile", "java", "mzscheme", "ruby", and "chicken" directories contain a number of simple examples that are -primarily used for testing. The "GIFPlot" directory contains a more -complicated example that illustrates some of SWIG's more advanced -capabilities. +primarily used for testing. The file 'index.html' is the top of a hyperlinked document that contains information about all of the examples along with various diff --git a/Examples/guile/README b/Examples/guile/README index acec7773b..7d726619e 100644 --- a/Examples/guile/README +++ b/Examples/guile/README @@ -12,6 +12,3 @@ std_vector -- C++ STL vector and vector Note that the examples in this directory build a special version of Guile which includes the wrapped functions in the top-level module. -If you want to put the wrapped functions into an own module, -statically or dynamically linked, see the Examples/GIFPlot/Guile -directory. diff --git a/Examples/index.html b/Examples/index.html index f8b614a89..66885b6a0 100644 --- a/Examples/index.html +++ b/Examples/index.html @@ -46,12 +46,6 @@ language: If your target platform is Windows, make sure you also see the Windows page in the main manual. -

      Real Life

      - -The GIFPlot directory contains examples that illustrate the use of SWIG with -a moderately complex C library for creating GIF images. Many of these -examples illustrate more advanced SWIG features. - diff --git a/Examples/s-exp/uffi.lisp b/Examples/s-exp/uffi.lisp index 5ddb4c20f..253f85aba 100644 --- a/Examples/s-exp/uffi.lisp +++ b/Examples/s-exp/uffi.lisp @@ -312,67 +312,6 @@ is no representation." ;; Test instances -#|| - -#+ignore -(defvar *gifplot-interface* - (run-swig (merge-pathnames "Examples/GIFPlot/Interface/gifplot.i" - *swig-source-directory*) - :directory-search-list (list (merge-pathnames "Examples/GIFPlot/Interface/" *swig-source-directory*)))) - -(defvar *simple-gifplot-interface* - (run-swig (merge-pathnames "Examples/GIFPlot/Include/gifplot.h" - *swig-source-directory*) - :directory-search-list (list (merge-pathnames "Examples/GIFPlot/Interface/" *swig-source-directory*)) - :module "gifplot")) - -(defvar *cplex-glue-directory* #p"/home/mkoeppe/cvs/cplex-glue/") - -(defvar *cplex-glue-interface* - (run-swig (merge-pathnames "cplex.i" *cplex-glue-directory*) - :directory-search-list (list (merge-pathnames "Lib/guile" - *swig-source-directory*) - *cplex-glue-directory*) - :ignore-errors t)) - - - -(require 'uffi) - -;;(let ((*uffi-primitive-type-alist* (cons '("Pixel" . :unsigned-int) *uffi-default-primitive-type-alist*))) -;; (eval (cons 'progn (compute-uffi-definitions *simple-gifplot-interface*)))) - - -(with-open-file (f "/tmp/swig-uffi.lisp" :direction :output - :if-exists :supersede) - (let ((*uffi-definitions* '()) - (*uffi-output* f) - (*uffi-primitive-type-alist* - (cons '("Pixel" . :unsigned-int) *uffi-default-primitive-type-alist*))) - (apply 'handle-node *simple-gifplot-interface*))) - -#+cplex -(with-open-file (f "/tmp/swig-uffi.lisp" :direction :output) - (let ((*uffi-definitions* '()) - (*uffi-output* f) - (*uffi-primitive-type-alist* - (cons '("Pixel" . :unsigned-int) *uffi-default-primitive-type-alist*))) - (apply 'handle-node *cplex-glue-interface*))) - -(compile-file "/tmp/swig-uffi.lisp") - -(uffi:load-foreign-library (merge-pathnames "Examples/GIFPlot/libgifplot.a" - *swig-source-directory*)) - -(load "/tmp/swig-uffi.lisp") - -(load (merge-pathnames "Examples/GIFPlot/Common-Lisp/full/runme.lisp" *swig-source-directory*)) - -(action (namestring (merge-pathnames "Examples/GIFPlot/Common-Lisp/full/cmap" - *swig-source-directory*))) - -||# - ;;; Link to SWIG itself #|| From d0ecd9cb517279d46f66d52aa81b01f196ba6c9d Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 28 Feb 2010 00:26:20 +0000 Subject: [PATCH 0763/1680] Correct svn Id git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11879 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Devel/engineering.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/Devel/engineering.html b/Doc/Devel/engineering.html index 7dfef2ad3..2e78fbe35 100644 --- a/Doc/Devel/engineering.html +++ b/Doc/Devel/engineering.html @@ -137,7 +137,7 @@ a SVN revision tag like this: * This file defines ... * ----------------------------------------------------------------------------- */ -static char cvs[] = "$Id$ xxx.c"; +static char cvs[] = "$Id$"; #include "swig.h" From faf8fee8772c8d26ce184854aede993edc728676 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 4 Mar 2010 18:27:23 +0000 Subject: [PATCH 0764/1680] minor comment added git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11894 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/extend_template.i | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/test-suite/extend_template.i b/Examples/test-suite/extend_template.i index a39ac546d..265c87675 100644 --- a/Examples/test-suite/extend_template.i +++ b/Examples/test-suite/extend_template.i @@ -1,5 +1,5 @@ %module extend_template -%module xxx +%module xxx // should be ignored namespace oss { // this doesn't %extend Foo<0> { int test1(int x) { return x; } From 24422112920c58b433ba39df4cd8d5e51f7dce09 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 4 Mar 2010 18:28:23 +0000 Subject: [PATCH 0765/1680] unnecessary cast removed git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11895 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/CParse/parser.y | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index 9622ce9f3..1990a66c6 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -3729,7 +3729,7 @@ cpp_class_decl : storage_class cpptype idcolon inherit LBRACE { Setattr(classes,scpname,$$); Delete(scpname); } else { - Swig_symbol_setscopename((char*)""); + Swig_symbol_setscopename(""); } } appendChild($$,$5); From 1253657bb43075c6862ad8205805864f9dae44ce Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 4 Mar 2010 21:27:23 +0000 Subject: [PATCH 0766/1680] Add improved namespace support - the nspace feature, working for Java only at the moment. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11896 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 30 ++- Examples/test-suite/common.mk | 1 + Examples/test-suite/java/Makefile.in | 23 +-- Examples/test-suite/nspace.i | 93 +++++++++ Source/Modules/chicken.cxx | 6 +- Source/Modules/csharp.cxx | 30 +-- Source/Modules/java.cxx | 275 +++++++++++++++++++-------- Source/Modules/lang.cxx | 62 +++--- Source/Modules/lua.cxx | 14 +- Source/Modules/modula3.cxx | 10 +- Source/Modules/octave.cxx | 18 +- Source/Modules/perl5.cxx | 28 +-- Source/Modules/pike.cxx | 8 +- Source/Modules/python.cxx | 60 +++--- Source/Modules/ruby.cxx | 4 +- Source/Modules/swigmod.h | 5 +- Source/Modules/tcl8.cxx | 12 +- Source/Modules/typepass.cxx | 15 ++ Source/Swig/cwrap.c | 57 +++--- Source/Swig/misc.c | 51 +++++ Source/Swig/naming.c | 68 +++++-- Source/Swig/swig.h | 26 ++- Source/Swig/symbol.c | 15 ++ 23 files changed, 645 insertions(+), 266 deletions(-) create mode 100644 Examples/test-suite/nspace.i diff --git a/CHANGES.current b/CHANGES.current index 902308847..ec0473bee 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,34 @@ -Version 1.3.41 (in progress) +Version 2.0.0 (in progress) ============================ +2010-03-04: wsfulton + Added the nspace feature. This adds some improved namespace support. Currently only Java + is supported for target languages, where C++ namespaces are automatically translated into + Java packages. The feature only applies to classes,struct,unions and enums declared within + a namespace. Methods and variables declared in namespaces still effectively have their + namespaces flattened. Example usage: + + %feature(nspace) Outer::Inner1::Color; + %feature(nspace) Outer::Inner2::Color; + + namespace Outer { + namespace Inner1 { + struct Color { + ... + }; + } + namespace Inner2 { + struct Color { + ... + }; + } + } + + For Java, the -package option is also required when using the nspace feature. Say + we use -package com.myco, the two classes can then be accessed as follows from Java: + + com.myco.Outer.Inner1.Color and com.myco.Outer.Inner2.Color. + 2010-02-27: wsfulton [Python] Remove -dirvtable from the optimizations included by -O as it this option currently leads to memory leaks as reported by Johan Blake. diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index d15451aca..2b4ab0701 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -242,6 +242,7 @@ CPP_TEST_CASES += \ namespace_typemap \ namespace_union \ namespace_virtual_method \ + nspace \ naturalvar \ nested_class \ nested_comment \ diff --git a/Examples/test-suite/java/Makefile.in b/Examples/test-suite/java/Makefile.in index 5c96ca154..119b50868 100644 --- a/Examples/test-suite/java/Makefile.in +++ b/Examples/test-suite/java/Makefile.in @@ -37,26 +37,27 @@ CPP_TEST_CASES = \ include $(srcdir)/../common.mk # Overridden variables here -SWIGOPT += -package $* +JAVA_PACKAGE = $* +SWIGOPT += -package $(JAVA_PACKAGE) INTERFACEDIR = ../../ # Custom tests - tests with additional commandline options -# none! +nspace.%: JAVA_PACKAGE = $*Package # Rules for the different types of tests %.cpptest: $(setup) - +(cd $* && $(swig_and_compile_cpp)) + +(cd $(JAVA_PACKAGE) && $(swig_and_compile_cpp)) $(run_testcase) %.ctest: $(setup) - +(cd $* && $(swig_and_compile_c)) + +(cd $(JAVA_PACKAGE) && $(swig_and_compile_c)) $(run_testcase) %.multicpptest: $(setup) - +(cd $* && $(swig_and_compile_multi_cpp)) + +(cd $(JAVA_PACKAGE) && $(swig_and_compile_multi_cpp)) $(run_testcase) # Makes a directory for the testcase if it does not exist @@ -66,24 +67,24 @@ setup = \ else \ echo "$(ACTION)ing testcase $* under $(LANGUAGE)" ; \ fi; \ - if [ ! -d $* ]; then \ - mkdir $*; \ + if [ ! -d $(JAVA_PACKAGE) ]; then \ + mkdir $(JAVA_PACKAGE); \ fi # Compiles java files then runs the testcase. A testcase is only run if # a file is found which has _runme.java appended after the testcase name. # Note Java uses LD_LIBRARY_PATH under Unix, PATH under Cygwin/Windows, SHLIB_PATH on HPUX and DYLD_LIBRARY_PATH on Mac OS X. run_testcase = \ - cd $* && $(COMPILETOOL) $(JAVAC) -classpath . *.java && cd .. && \ + cd $(JAVA_PACKAGE) && $(COMPILETOOL) $(JAVAC) -classpath . `find . -name "*.java"` && cd .. && \ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ $(COMPILETOOL) $(JAVAC) -classpath . -d . $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \ - env LD_LIBRARY_PATH="$*:$$LD_LIBRARY_PATH" PATH="$*:$$PATH" SHLIB_PATH="$*:$$SHLIB_PATH" DYLD_LIBRARY_PATH="$*:$$DYLD_LIBRARY_PATH" $(RUNTOOL) $(JAVA) -classpath . $*_runme; \ + env LD_LIBRARY_PATH="$(JAVA_PACKAGE):$$LD_LIBRARY_PATH" PATH="$(JAVA_PACKAGE):$$PATH" SHLIB_PATH="$(JAVA_PACKAGE):$$SHLIB_PATH" DYLD_LIBRARY_PATH="$(JAVA_PACKAGE):$$DYLD_LIBRARY_PATH" $(RUNTOOL) $(JAVA) -classpath . $*_runme; \ fi # Clean: remove testcase directories %.clean: - @if [ -d $* ]; then \ - rm -rf $*; \ + @if [ -d $(JAVA_PACKAGE) ]; then \ + rm -rf $(JAVA_PACKAGE); \ fi clean: diff --git a/Examples/test-suite/nspace.i b/Examples/test-suite/nspace.i new file mode 100644 index 000000000..26a3273b2 --- /dev/null +++ b/Examples/test-suite/nspace.i @@ -0,0 +1,93 @@ +// Test the nspace feature +%module nspace + +#if defined(SWIGJAVA) +SWIG_JAVABODY_METHODS(public, public, SWIGTYPE) +%pragma(java) jniclassclassmodifiers = "public class" + +%feature("nspace"); +%feature("nspace", "0") Outer::Inner2::NoNSpacePlease; + +%copyctor; +%ignore Outer::Inner2::Color::Color(); + +%inline %{ + +namespace Outer { + class nspace { + }; + namespace Inner1 { + enum Channel { + Diffuse, + Specular = 0x10, + Transmission1 + }; + + struct Color { + static Color* create() { return new Color(); } + + enum Channel { + Diffuse, + Specular = 0x20, + Transmission + }; + + int instanceMemberVariable; + static int staticMemberVariable; + void colorInstanceMethod(double d) {} + static void colorStaticMethod(double d) {} + }; // Color + int Color::staticMemberVariable = 0; + + Color namespaceFunction(Color k) { return k; } + int namespaceVar = 0; + } // Inner1 + + namespace Inner2 { + enum Channel { + Diffuse, + Specular /* = 0x30*/, + Transmission2 + }; + + struct Color { + Color() : instanceMemberVariable(0) {} + static Color* create() { return new Color(); } + + enum Channel { + Diffuse, + Specular/* = 0x40*/, + Transmission + }; + + int instanceMemberVariable; + static int staticMemberVariable; + void colorInstanceMethod(double d) {} + static void colorStaticMethod(double d) {} + }; // Color + int Color::staticMemberVariable = 0; + class NoNSpacePlease {}; + } // Inner2 + + class SomeClass { + public: + Inner1::Color::Channel GetInner1ColorChannel() { return Inner1::Color::Transmission; } + Inner2::Color::Channel GetInner2ColorChannel() { return Inner2::Color::Transmission; } + Inner1::Channel GetInner1Channel() { return Inner1::Transmission1; } + Inner2::Channel GetInner2Channel() { return Inner2::Transmission2; } + }; // SomeClass + +} // Outer + +namespace Outer { + struct MyWorldPart2 {}; +} + +struct GlobalClass { + void gmethod() {} +}; + +void test_classes(Outer::SomeClass c, Outer::Inner2::Color cc) {} +%} + +#endif diff --git a/Source/Modules/chicken.cxx b/Source/Modules/chicken.cxx index 1d9e9c620..9cac92dcb 100644 --- a/Source/Modules/chicken.cxx +++ b/Source/Modules/chicken.cxx @@ -1152,9 +1152,9 @@ int CHICKEN::membervariableHandler(Node *n) { //String *getfunc = NewStringf("%s-%s-get", short_class_name, proc); //String *setfunc = NewStringf("%s-%s-set", short_class_name, proc); - String *getfunc = Swig_name_get(Swig_name_member(c_class_name, iname)); + String *getfunc = Swig_name_get(NSPACE_TODO, Swig_name_member(NSPACE_TODO, c_class_name, iname)); Replaceall(getfunc, "_", "-"); - String *setfunc = Swig_name_set(Swig_name_member(c_class_name, iname)); + String *setfunc = Swig_name_set(NSPACE_TODO, Swig_name_member(NSPACE_TODO, c_class_name, iname)); Replaceall(setfunc, "_", "-"); Printv(clos_class_defines, " (list '", proc, " ':swig-virtual ':swig-get ", chickenPrimitiveName(getfunc), NIL); @@ -1201,7 +1201,7 @@ int CHICKEN::constructorHandler(Node *n) { has_constructor_args = 1; String *iname = Getattr(n, "sym:name"); - constructor_name = Swig_name_construct(iname); + constructor_name = Swig_name_construct(NSPACE_TODO, iname); Replaceall(constructor_name, "_", "-"); return SWIG_OK; } diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index d813c2e56..6d3d09ea4 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -162,7 +162,7 @@ public: /* ----------------------------------------------------------------------------- * getProxyName() * - * Test to see if a type corresponds to something wrapped with a proxy class + * Test to see if a type corresponds to something wrapped with a proxy class. * Return NULL if not otherwise the proxy class name * ----------------------------------------------------------------------------- */ @@ -1033,7 +1033,7 @@ public: */ if (proxy_flag && wrapping_member_flag && !enum_constant_flag) { // Capitalize the first letter in the variable in the getter/setter function name - bool getter_flag = Cmp(symname, Swig_name_set(Swig_name_member(proxy_class_name, variable_name))) != 0; + bool getter_flag = Cmp(symname, Swig_name_set(NSPACE_TODO, Swig_name_member(NSPACE_TODO, proxy_class_name, variable_name))) != 0; String *getter_setter_name = NewString(""); if (!getter_flag) @@ -1381,13 +1381,13 @@ public: if (classname_substituted_flag) { if (SwigType_isenum(t)) { // This handles wrapping of inline initialised const enum static member variables (not when wrapping enum items - ignored later on) - Printf(constants_code, "(%s)%s.%s();\n", return_type, imclass_name, Swig_name_get(symname)); + Printf(constants_code, "(%s)%s.%s();\n", return_type, imclass_name, Swig_name_get(NSPACE_TODO, symname)); } else { // This handles function pointers using the %constant directive - Printf(constants_code, "new %s(%s.%s(), false);\n", return_type, imclass_name, Swig_name_get(symname)); + Printf(constants_code, "new %s(%s.%s(), false);\n", return_type, imclass_name, Swig_name_get(NSPACE_TODO, symname)); } } else - Printf(constants_code, "%s.%s();\n", imclass_name, Swig_name_get(symname)); + Printf(constants_code, "%s.%s();\n", imclass_name, Swig_name_get(NSPACE_TODO, symname)); // Each constant and enum value is wrapped with a separate PInvoke function call SetFlag(n, "feature:immutable"); @@ -1862,7 +1862,7 @@ public: if (proxy_flag) { String *overloaded_name = getOverloadedName(n); - String *intermediary_function_name = Swig_name_member(proxy_class_name, overloaded_name); + String *intermediary_function_name = Swig_name_member(NSPACE_TODO, proxy_class_name, overloaded_name); Setattr(n, "proxyfuncname", Getattr(n, "sym:name")); Setattr(n, "imfuncname", intermediary_function_name); proxyClassFunctionHandler(n); @@ -1882,7 +1882,7 @@ public: if (proxy_flag) { String *overloaded_name = getOverloadedName(n); - String *intermediary_function_name = Swig_name_member(proxy_class_name, overloaded_name); + String *intermediary_function_name = Swig_name_member(NSPACE_TODO, proxy_class_name, overloaded_name); Setattr(n, "proxyfuncname", Getattr(n, "sym:name")); Setattr(n, "imfuncname", intermediary_function_name); proxyClassFunctionHandler(n); @@ -1962,7 +1962,7 @@ public: if (wrapping_member_flag && !enum_constant_flag) { // Properties - setter_flag = (Cmp(Getattr(n, "sym:name"), Swig_name_set(Swig_name_member(proxy_class_name, variable_name))) == 0); + setter_flag = (Cmp(Getattr(n, "sym:name"), Swig_name_set(NSPACE_TODO, Swig_name_member(NSPACE_TODO, proxy_class_name, variable_name))) == 0); if (setter_flag) Swig_typemap_attach_parms("csvarin", l, NULL); } @@ -2132,7 +2132,7 @@ public: Node *explicit_n = Getattr(n, "explicitcallnode"); if (explicit_n) { String *ex_overloaded_name = getOverloadedName(explicit_n); - String *ex_intermediary_function_name = Swig_name_member(proxy_class_name, ex_overloaded_name); + String *ex_intermediary_function_name = Swig_name_member(NSPACE_TODO, proxy_class_name, ex_overloaded_name); String *ex_imcall = Copy(imcall); Replaceall(ex_imcall, "$imfuncname", ex_intermediary_function_name); @@ -2250,7 +2250,7 @@ public: if (proxy_flag) { String *overloaded_name = getOverloadedName(n); - String *mangled_overname = Swig_name_construct(overloaded_name); + String *mangled_overname = Swig_name_construct(NSPACE_TODO, overloaded_name); String *imcall = NewString(""); const String *csattributes = Getattr(n, "feature:cs:attributes"); @@ -2451,7 +2451,7 @@ public: String *symname = Getattr(n, "sym:name"); if (proxy_flag) { - Printv(destructor_call, imclass_name, ".", Swig_name_destroy(symname), "(swigCPtr)", NIL); + Printv(destructor_call, imclass_name, ".", Swig_name_destroy(NSPACE_TODO, symname), "(swigCPtr)", NIL); } return SWIG_OK; } @@ -2577,7 +2577,7 @@ public: if (proxy_flag && global_variable_flag) { // Capitalize the first letter in the variable to create the getter/setter function name func_name = NewString(""); - setter_flag = (Cmp(Getattr(n, "sym:name"), Swig_name_set(variable_name)) == 0); + setter_flag = (Cmp(Getattr(n, "sym:name"), Swig_name_set(NSPACE_TODO, variable_name)) == 0); if (setter_flag) Printf(func_name, "set"); else @@ -2848,10 +2848,10 @@ public: // Strange hack to change the name Setattr(n, "name", Getattr(n, "value")); /* for wrapping of enums in a namespace when emit_action is used */ constantWrapper(n); - value = NewStringf("%s.%s()", imclass_name, Swig_name_get(symname)); + value = NewStringf("%s.%s()", imclass_name, Swig_name_get(NSPACE_TODO, symname)); } else { memberconstantHandler(n); - value = NewStringf("%s.%s()", imclass_name, Swig_name_get(Swig_name_member(proxy_class_name, symname))); + value = NewStringf("%s.%s()", imclass_name, Swig_name_get(NSPACE_TODO, Swig_name_member(NSPACE_TODO, proxy_class_name, symname))); } } } @@ -3279,7 +3279,7 @@ public: // we're consistent with the sym:overload name in functionWrapper. (?? when // does the overloaded method name get set?) - imclass_dmethod = NewStringf("SwigDirector_%s", Swig_name_member(classname, overloaded_name)); + imclass_dmethod = NewStringf("SwigDirector_%s", Swig_name_member(NSPACE_TODO, classname, overloaded_name)); if (returntype) { diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index 7a9d739f1..1bb9532ee 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -56,7 +56,9 @@ class JAVA:public Language { String *proxy_class_def; String *proxy_class_code; String *module_class_code; - String *proxy_class_name; + String *proxy_class_name; // proxy class name + String *full_proxy_class_name;// fully qualified proxy class name when using nspace feature, otherwise same as proxy_class_name + String *full_imclass_name; // fully qualified intermediary class name when using nspace feature, otherwise same as imclass_name String *variable_name; //Name of a variable being wrapped String *proxy_class_constants_code; String *module_class_constants_code; @@ -125,6 +127,8 @@ public: proxy_class_code(NULL), module_class_code(NULL), proxy_class_name(NULL), + full_proxy_class_name(NULL), + full_imclass_name(NULL), variable_name(NULL), proxy_class_constants_code(NULL), module_class_constants_code(NULL), @@ -157,19 +161,35 @@ public: /* ----------------------------------------------------------------------------- * getProxyName() * - * Test to see if a type corresponds to something wrapped with a proxy class - * Return NULL if not otherwise the proxy class name + * Test to see if a type corresponds to something wrapped with a proxy class. + * Return NULL if not otherwise the proxy class name, fully qualified with + * package name if the nspace feature is used. * ----------------------------------------------------------------------------- */ String *getProxyName(SwigType *t) { - if (proxy_flag) { - Node *n = classLookup(t); - if (n) { - return Getattr(n, "sym:name"); - } - } - return NULL; - } + String *proxyname = NULL; + if (proxy_flag) { + Node *n = classLookup(t); + if (n) { + proxyname = Getattr(n, "proxyname"); + if (!proxyname) { + String *nspace = Getattr(n, "sym:nspace"); + String *symname = Getattr(n, "sym:name"); + if (nspace) { + if (Len(package) > 0) + proxyname = NewStringf("%s.%s.%s", package, nspace, symname); + else + proxyname = NewStringf("%s.%s", nspace, symname); + } else { + proxyname = Copy(symname); + } + Setattr(n, "proxyname", proxyname); + Delete(proxyname); + } + } + } + return proxyname; + } /* ----------------------------------------------------------------------------- * makeValidJniName() @@ -410,7 +430,7 @@ public: Replaceall(package_path, ".", "/"); } String *jniname = makeValidJniName(imclass_name); - Printf(wrapper_name, "Java_%s%s_%%f", Char(jnipackage), jniname); + Printf(wrapper_name, "Java_%s%s_%%f", jnipackage, jniname); Delete(jniname); Swig_name_register("wrapper", Char(wrapper_name)); @@ -1099,7 +1119,7 @@ public: */ if (proxy_flag && wrapping_member_flag && !enum_constant_flag) { // Capitalize the first letter in the variable to create a JavaBean type getter/setter function name - bool getter_flag = Cmp(symname, Swig_name_set(Swig_name_member(proxy_class_name, variable_name))) != 0; + bool getter_flag = Cmp(symname, Swig_name_set(getNSpace(), Swig_name_member(0, proxy_class_name, variable_name))) != 0; String *getter_setter_name = NewString(""); if (!getter_flag) @@ -1167,6 +1187,24 @@ public: if (getCurrentClass() && (cplus_mode != PUBLIC)) return SWIG_NOWRAP; + if (proxy_flag && !is_wrapping_class()) { + // Global enums / enums in a namespace + String *nspace = Getattr(n, "sym:nspace"); + assert(!full_imclass_name); + + if (!nspace) { + full_imclass_name = NewStringf("%s", imclass_name); + } else { + if (Len(package) > 0) { + full_imclass_name = NewStringf("%s.%s", package, imclass_name); + } else { + full_imclass_name = NewStringf("%s", imclass_name); + Printf(stderr, "The nspace feature used on %s is not supported unless a package is specified with -package - Java does not support types declared in the unnamed package accessing types declared in a package.\n", Getattr(n, "name")); + SWIG_exit(EXIT_FAILURE); + } + } + } + enum_code = NewString(""); String *symname = Getattr(n, "sym:name"); String *constants_code = (proxy_flag && is_wrapping_class())? proxy_class_constants_code : module_class_constants_code; @@ -1224,7 +1262,9 @@ public: Printv(proxy_class_constants_code, " ", enum_code, "\n\n", NIL); } else { // Global enums are defined in their own file - String *filen = NewStringf("%s%s.java", SWIG_output_directory(), symname); + String *nspace = Getattr(n, "sym:nspace"); + String *output_directory = outputDirectory(nspace); + String *filen = NewStringf("%s%s.java", output_directory, symname); File *f_enum = NewFile(filen, "w", SWIG_output_files()); if (!f_enum) { FileErrorDisplay(filen); @@ -1237,14 +1277,21 @@ public: // Start writing out the enum file emitBanner(f_enum); - if (Len(package) > 0) - Printf(f_enum, "package %s;\n", package); + if (Len(package) > 0 || nspace) { + Printf(f_enum, "package "); + if (Len(package) > 0) + Printv(f_enum, package, nspace ? "." : "", NIL); + if (nspace) + Printv(f_enum, nspace, NIL); + Printf(f_enum, ";\n"); + } Printv(f_enum, typemapLookup(n, "javaimports", typemap_lookup_type, WARN_NONE), // Import statements "\n", enum_code, "\n", NIL); Printf(f_enum, "\n"); Close(f_enum); + Delete(output_directory); } } else { // Wrap C++ enum with simple constant @@ -1257,6 +1304,11 @@ public: Delete(enum_code); enum_code = NULL; + + if (proxy_flag && !is_wrapping_class()) { + Delete(full_imclass_name); + full_imclass_name = 0; + } } return SWIG_OK; } @@ -1418,13 +1470,13 @@ public: if (classname_substituted_flag) { if (SwigType_isenum(t)) { // This handles wrapping of inline initialised const enum static member variables (not when wrapping enum items - ignored later on) - Printf(constants_code, "%s.swigToEnum(%s.%s());\n", return_type, imclass_name, Swig_name_get(symname)); + Printf(constants_code, "%s.swigToEnum(%s.%s());\n", return_type, imclass_name, Swig_name_get(getNSpace(), symname)); } else { // This handles function pointers using the %constant directive - Printf(constants_code, "new %s(%s.%s(), false);\n", return_type, imclass_name, Swig_name_get(symname)); + Printf(constants_code, "new %s(%s.%s(), false);\n", return_type, imclass_name, Swig_name_get(getNSpace(), symname)); } } else - Printf(constants_code, "%s.%s();\n", imclass_name, Swig_name_get(symname)); + Printf(constants_code, "%s.%s();\n", imclass_name, Swig_name_get(getNSpace(), symname)); // Each constant and enum value is wrapped with a separate JNI function call SetFlag(n, "feature:immutable"); @@ -1691,16 +1743,18 @@ public: /* Also insert the swigTakeOwnership and swigReleaseOwnership methods */ if (feature_director) { String *destruct_jnicall, *release_jnicall, *take_jnicall; + String *changeown_method_name = Swig_name_member(getNSpace(), proxy_class_name, "change_ownership"); destruct_jnicall = NewStringf("%s()", destruct_methodname); - release_jnicall = NewStringf("%s.%s_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); + release_jnicall = NewStringf("%s.%s(this, swigCPtr, false)", full_imclass_name, changeown_method_name); + take_jnicall = NewStringf("%s.%s(this, swigCPtr, true)", full_imclass_name, changeown_method_name); emitCodeTypemap(n, false, typemap_lookup_type, "directordisconnect", "methodname", destruct_jnicall); emitCodeTypemap(n, false, typemap_lookup_type, "directorowner_release", "methodname", release_jnicall); emitCodeTypemap(n, false, typemap_lookup_type, "directorowner_take", "methodname", take_jnicall); Delete(destruct_jnicall); + Delete(changeown_method_name); Delete(release_jnicall); Delete(take_jnicall); } @@ -1719,14 +1773,14 @@ public: Replaceall(proxy_class_def, "$module", module_class_name); Replaceall(proxy_class_code, "$module", module_class_name); - Replaceall(proxy_class_def, "$imclassname", imclass_name); - Replaceall(proxy_class_code, "$imclassname", imclass_name); + Replaceall(proxy_class_def, "$imclassname", full_imclass_name); + Replaceall(proxy_class_code, "$imclassname", full_imclass_name); // Add code to do C++ casting to base class (only for classes in an inheritance hierarchy) if (derived) { Printv(imclass_cppcasts_code, " public final static native long SWIG$javaclassnameUpcast(long jarg1);\n", NIL); - Replaceall(imclass_cppcasts_code, "$javaclassname", proxy_class_name); + Replaceall(imclass_cppcasts_code, "$javaclassname", full_proxy_class_name); Printv(upcasts_code, "SWIGEXPORT jlong JNICALL Java_$jnipackage$imimclass_SWIG$imclazznameUpcast", @@ -1735,7 +1789,7 @@ public: " (void)jenv;\n" " (void)jcls;\n" " *($cbaseclass **)&baseptr = *($cclass **)&jarg1;\n" " return baseptr;\n" "}\n", "\n", NIL); String *imimclass = makeValidJniName(imclass_name); - String *imclazzname = makeValidJniName(proxy_class_name); + String *imclazzname = makeValidJniName(full_proxy_class_name); Replaceall(upcasts_code, "$cbaseclass", c_baseclass); Replaceall(upcasts_code, "$imclazzname", imclazzname); Replaceall(upcasts_code, "$cclass", c_classname); @@ -1757,21 +1811,37 @@ public: File *f_proxy = NULL; if (proxy_flag) { proxy_class_name = NewString(Getattr(n, "sym:name")); + String *nspace = getNSpace(); - if (!addSymbol(proxy_class_name, n)) + if (!nspace) { + full_proxy_class_name = NewStringf("%s", proxy_class_name); + full_imclass_name = NewStringf("%s", imclass_name); + if (Cmp(proxy_class_name, imclass_name) == 0) { + Printf(stderr, "Class name cannot be equal to intermediary class name: %s\n", proxy_class_name); + SWIG_exit(EXIT_FAILURE); + } + + if (Cmp(proxy_class_name, module_class_name) == 0) { + Printf(stderr, "Class name cannot be equal to module class name: %s\n", proxy_class_name); + SWIG_exit(EXIT_FAILURE); + } + } else { + if (Len(package) > 0) { + full_proxy_class_name = NewStringf("%s.%s.%s", package, nspace, proxy_class_name); + full_imclass_name = NewStringf("%s.%s", package, imclass_name); + } else { + full_proxy_class_name = NewStringf("%s.%s", nspace, proxy_class_name); + full_imclass_name = NewStringf("%s", imclass_name); + Printf(stderr, "The nspace feature used on %s is not supported unless a package is specified with -package - Java does not support types declared in the unnamed package accessing types declared in a package.\n", Getattr(n, "name")); + SWIG_exit(EXIT_FAILURE); + } + } + + if (!addSymbol(proxy_class_name, n, nspace)) return SWIG_ERROR; - if (Cmp(proxy_class_name, imclass_name) == 0) { - Printf(stderr, "Class name cannot be equal to intermediary class name: %s\n", proxy_class_name); - SWIG_exit(EXIT_FAILURE); - } - - if (Cmp(proxy_class_name, module_class_name) == 0) { - Printf(stderr, "Class name cannot be equal to module class name: %s\n", proxy_class_name); - SWIG_exit(EXIT_FAILURE); - } - - String *filen = NewStringf("%s%s.java", SWIG_output_directory(), proxy_class_name); + String *output_directory = outputDirectory(nspace); + String *filen = NewStringf("%s%s.java", output_directory, proxy_class_name); f_proxy = NewFile(filen, "w", SWIG_output_files()); if (!f_proxy) { FileErrorDisplay(filen); @@ -1784,8 +1854,14 @@ public: // Start writing out the proxy class file emitBanner(f_proxy); - if (Len(package) > 0) - Printf(f_proxy, "package %s;\n", package); + if (Len(package) > 0 || nspace) { + Printf(f_proxy, "package "); + if (Len(package) > 0) + Printv(f_proxy, package, nspace ? "." : "", NIL); + if (nspace) + Printv(f_proxy, nspace, NIL); + Printf(f_proxy, ";\n"); + } Clear(proxy_class_def); Clear(proxy_class_code); @@ -1793,6 +1869,7 @@ public: destructor_call = NewString(""); destructor_throws_clause = NewString(""); proxy_class_constants_code = NewString(""); + Delete(output_directory); } Language::classHandler(n); @@ -1804,9 +1881,9 @@ public: Replaceall(proxy_class_def, "$module", module_class_name); Replaceall(proxy_class_code, "$module", module_class_name); Replaceall(proxy_class_constants_code, "$module", module_class_name); - Replaceall(proxy_class_def, "$imclassname", imclass_name); - Replaceall(proxy_class_code, "$imclassname", imclass_name); - Replaceall(proxy_class_constants_code, "$imclassname", imclass_name); + Replaceall(proxy_class_def, "$imclassname", full_imclass_name); + Replaceall(proxy_class_code, "$imclassname", full_imclass_name); + Replaceall(proxy_class_constants_code, "$imclassname", full_imclass_name); Printv(f_proxy, proxy_class_def, proxy_class_code, NIL); // Write out all the constants @@ -1848,6 +1925,10 @@ public: Delete(proxy_class_name); proxy_class_name = NULL; + Delete(full_proxy_class_name); + full_proxy_class_name = NULL; + Delete(full_imclass_name); + full_imclass_name = NULL; Delete(destructor_call); destructor_call = NULL; Delete(destructor_throws_clause); @@ -1869,7 +1950,7 @@ public: if (proxy_flag) { String *overloaded_name = getOverloadedName(n); - String *intermediary_function_name = Swig_name_member(proxy_class_name, overloaded_name); + String *intermediary_function_name = Swig_name_member(getNSpace(), proxy_class_name, overloaded_name); Setattr(n, "proxyfuncname", Getattr(n, "sym:name")); Setattr(n, "imfuncname", intermediary_function_name); proxyClassFunctionHandler(n); @@ -1891,7 +1972,7 @@ public: if (proxy_flag) { String *overloaded_name = getOverloadedName(n); - String *intermediary_function_name = Swig_name_member(proxy_class_name, overloaded_name); + String *intermediary_function_name = Swig_name_member(getNSpace(), proxy_class_name, overloaded_name); Setattr(n, "proxyfuncname", Getattr(n, "sym:name")); Setattr(n, "imfuncname", intermediary_function_name); proxyClassFunctionHandler(n); @@ -1967,7 +2048,7 @@ public: if (wrapping_member_flag && !enum_constant_flag) { // For wrapping member variables (Javabean setter) - setter_flag = (Cmp(Getattr(n, "sym:name"), Swig_name_set(Swig_name_member(proxy_class_name, variable_name))) == 0); + setter_flag = (Cmp(Getattr(n, "sym:name"), Swig_name_set(getNSpace(), Swig_name_member(0, proxy_class_name, variable_name))) == 0); } /* Start generating the proxy function */ @@ -1978,7 +2059,7 @@ public: Printf(function_code, "static "); Printf(function_code, "%s %s(", return_type, proxy_function_name); - Printv(imcall, imclass_name, ".$imfuncname(", NIL); + Printv(imcall, full_imclass_name, ".$imfuncname(", NIL); if (!static_flag) { Printf(imcall, "swigCPtr"); @@ -2121,7 +2202,7 @@ public: Node *explicit_n = Getattr(n, "explicitcallnode"); if (explicit_n) { String *ex_overloaded_name = getOverloadedName(explicit_n); - String *ex_intermediary_function_name = Swig_name_member(proxy_class_name, ex_overloaded_name); + String *ex_intermediary_function_name = Swig_name_member(getNSpace(), proxy_class_name, ex_overloaded_name); String *ex_imcall = Copy(imcall); Replaceall(ex_imcall, "$imfuncname", ex_intermediary_function_name); @@ -2183,7 +2264,7 @@ public: if (proxy_flag) { String *overloaded_name = getOverloadedName(n); - String *mangled_overname = Swig_name_construct(overloaded_name); + String *mangled_overname = Swig_name_construct(getNSpace(), overloaded_name); String *imcall = NewString(""); const String *methodmods = Getattr(n, "feature:java:methodmodifiers"); @@ -2195,7 +2276,7 @@ public: Printf(function_code, " %s %s(", methodmods, proxy_class_name); Printf(helper_code, " static private %s SwigConstruct%s(", im_return_type, proxy_class_name); - Printv(imcall, imclass_name, ".", mangled_overname, "(", NIL); + Printv(imcall, full_imclass_name, ".", mangled_overname, "(", NIL); /* Attach the non-standard typemaps to the parameter list */ Swig_typemap_attach_parms("in", l, NULL); @@ -2368,7 +2449,7 @@ public: String *symname = Getattr(n, "sym:name"); if (proxy_flag) { - Printv(destructor_call, imclass_name, ".", Swig_name_destroy(symname), "(swigCPtr)", NIL); + Printv(destructor_call, full_imclass_name, ".", Swig_name_destroy(getNSpace(), symname), "(swigCPtr)", NIL); generateThrowsClause(n, destructor_throws_clause); } return SWIG_OK; @@ -2476,7 +2557,7 @@ public: if (proxy_flag && global_variable_flag) { // Capitalize the first letter in the variable to create a JavaBean type getter/setter function name func_name = NewString(""); - setter_flag = (Cmp(Getattr(n, "sym:name"), Swig_name_set(variable_name)) == 0); + setter_flag = (Cmp(Getattr(n, "sym:name"), Swig_name_set(getNSpace(), variable_name)) == 0); if (setter_flag) Printf(func_name, "set"); else @@ -2681,10 +2762,10 @@ public: // Strange hack to change the name Setattr(n, "name", Getattr(n, "value")); /* for wrapping of enums in a namespace when emit_action is used */ constantWrapper(n); - value = NewStringf("%s.%s()", imclass_name, Swig_name_get(symname)); + value = NewStringf("%s.%s()", full_imclass_name ? full_imclass_name : imclass_name, Swig_name_get(getNSpace(), symname)); } else { memberconstantHandler(n); - value = NewStringf("%s.%s()", imclass_name, Swig_name_get(Swig_name_member(proxy_class_name, symname))); + value = NewStringf("%s.%s()", full_imclass_name ? full_imclass_name : imclass_name, Swig_name_get(getNSpace(), Swig_name_member(getNSpace(), proxy_class_name, symname))); } } } @@ -2698,28 +2779,44 @@ public: * ----------------------------------------------------------------------------- */ String *getEnumName(SwigType *t, bool jnidescriptor) { - Node *enum_name = NULL; + Node *enumname = NULL; Node *n = enumLookup(t); if (n) { - String *symname = Getattr(n, "sym:name"); - if (symname) { - // Add in class scope when referencing enum if not a global enum - String *scopename_prefix = Swig_scopename_prefix(Getattr(n, "name")); - String *proxyname = 0; - if (scopename_prefix) { - proxyname = getProxyName(scopename_prefix); + enumname = Getattr(n, "enumname"); + if (!enumname || jnidescriptor) { + String *symname = Getattr(n, "sym:name"); + if (symname) { + // Add in class scope when referencing enum if not a global enum + String *scopename_prefix = Swig_scopename_prefix(Getattr(n, "name")); + String *proxyname = 0; + if (scopename_prefix) { + proxyname = getProxyName(scopename_prefix); + } + if (proxyname) { + const char *class_separator = jnidescriptor ? "$" : "."; + enumname = NewStringf("%s%s%s", proxyname, class_separator, symname); + } else { + // global enum or enum in a namespace + String *nspace = Getattr(n, "sym:nspace"); + if (nspace) { + if (Len(package) > 0) + enumname = NewStringf("%s.%s.%s", package, nspace, symname); + else + enumname = NewStringf("%s.%s", nspace, symname); + } else { + enumname = Copy(symname); + } + } + if (!jnidescriptor) { // not cached + Setattr(n, "enumname", enumname); + Delete(enumname); + } + Delete(scopename_prefix); } - if (proxyname) { - const char *class_separator = jnidescriptor ? "$" : "."; - enum_name = NewStringf("%s%s%s", proxyname, class_separator, symname); - } else { - enum_name = NewStringf("%s", symname); - } - Delete(scopename_prefix); } } - return enum_name; + return enumname; } /* ----------------------------------------------------------------------------- @@ -3004,10 +3101,10 @@ public: if (Cmp(jtype, "long") == 0) { if (proxy_flag) { if (!GetFlag(p, "tmap:jtype:nopgcpp") && !nopgcpp_flag) { - Node *n = classLookup(t); - if (n) { + String *proxyname = getProxyName(t); + if (proxyname) { // Found a struct/class parameter passed by value, reference, pointer, or pointer reference - proxyClassName = Getattr(n, "sym:name"); + proxyClassName = proxyname; } else { // Look for proxy class parameters passed to C++ layer using non-default typemaps, ie not one of above types String *jstype = NewString(Getattr(p, "tmap:jstype")); @@ -3045,6 +3142,30 @@ public: return proxyClassName; } + /* ----------------------------------------------------------------------------- + * outputDirectory() + * + * Return the directory to use for generating Java classes/enums and create the + * subdirectory (does not create if language specific outdir does not exist). + * ----------------------------------------------------------------------------- */ + + String *outputDirectory(String *nspace) { + String *output_directory = Copy(SWIG_output_directory()); + if (nspace) { + String *nspace_subdirectory = Copy(nspace); + Replaceall(nspace_subdirectory, ".", SWIG_FILE_DELIMITER); + String *newdir_error = Swig_new_subdirectory(output_directory, nspace_subdirectory); + if (newdir_error) { + Printf(stderr, "%s\n", newdir_error); + Delete(newdir_error); + SWIG_exit(EXIT_FAILURE); + } + Printv(output_directory, nspace_subdirectory, SWIG_FILE_DELIMITER, 0); + Delete(nspace_subdirectory); + } + return output_directory; + } + /*---------------------------------------------------------------------- * Start of director methods *--------------------------------------------------------------------*/ @@ -3155,13 +3276,13 @@ public: // Output the director connect method: String *jni_imclass_name = makeValidJniName(imclass_name); String *norm_name = SwigType_namestr(Getattr(n, "name")); - String *swig_director_connect = NewStringf("%s_director_connect", proxy_class_name); + String *swig_director_connect = Swig_name_member(getNSpace(), proxy_class_name, "director_connect"); String *swig_director_connect_jni = makeValidJniName(swig_director_connect); String *sym_name = Getattr(n, "sym:name"); Wrapper *code_wrap; Printf(imclass_class_code, " public final static native void %s(%s obj, long cptr, boolean mem_own, boolean weak_global);\n", - swig_director_connect, proxy_class_name); + swig_director_connect, full_proxy_class_name); code_wrap = NewWrapper(); Printf(code_wrap->def, @@ -3183,10 +3304,10 @@ public: Delete(swig_director_connect); // Output the swigReleaseOwnership, swigTakeOwnership methods: - String *changeown_method_name = NewStringf("%s_change_ownership", proxy_class_name); + String *changeown_method_name = Swig_name_member(getNSpace(), proxy_class_name, "change_ownership"); String *changeown_jnimethod_name = makeValidJniName(changeown_method_name); - Printf(imclass_class_code, " public final static native void %s(%s obj, long cptr, boolean take_or_release);\n", changeown_method_name, proxy_class_name); + Printf(imclass_class_code, " public final static native void %s(%s obj, long cptr, boolean take_or_release);\n", changeown_method_name, full_proxy_class_name); code_wrap = NewWrapper(); Printf(code_wrap->def, @@ -3342,7 +3463,7 @@ public: // we're consistent with the sym:overload name in functionWrapper. (?? when // does the overloaded method name get set?) - imclass_dmethod = NewStringf("SwigDirector_%s", Swig_name_member(classname, overloaded_name)); + imclass_dmethod = NewStringf("SwigDirector_%s", Swig_name_member(getNSpace(), classname, overloaded_name)); if (returntype) { diff --git a/Source/Modules/lang.cxx b/Source/Modules/lang.cxx index a22c06dd0..2ccefb619 100644 --- a/Source/Modules/lang.cxx +++ b/Source/Modules/lang.cxx @@ -60,6 +60,7 @@ extern "C" { static int InClass = 0; /* Parsing C++ or not */ static String *ClassName = 0; /* This is the real name of the current class */ static String *ClassPrefix = 0; /* Class prefix */ +static String *NSpace = 0; /* Namespace for the nspace feature */ static String *ClassType = 0; /* Fully qualified type name to use */ static String *DirectorClassName = 0; /* Director name of the current class */ int Abstract = 0; @@ -1198,7 +1199,7 @@ int Language::memberfunctionHandler(Node *n) { Setline(cbn, Getline(n)); memberconstantHandler(cbn); - Setattr(n, "feature:callback:name", Swig_name_member(ClassPrefix, cbname)); + Setattr(n, "feature:callback:name", Swig_name_member(NSpace, ClassPrefix, cbname)); Delete(cb); Delete(cbn); @@ -1211,7 +1212,7 @@ int Language::memberfunctionHandler(Node *n) { } } - String *fname = Swig_name_member(ClassPrefix, symname); + String *fname = Swig_name_member(NSpace, ClassPrefix, symname); if (Extend && SmartPointer) { if (!Getattr(n, "classname")) { Setattr(n, "classname", Getattr(CurrentClass, "allocate:smartpointerbase")); @@ -1236,7 +1237,7 @@ int Language::memberfunctionHandler(Node *n) { if (GetFlag(n, "explicitcall")) DirectorExtraCall = CWRAP_DIRECTOR_ONE_CALL; - Swig_MethodToFunction(n, ClassType, Getattr(n, "template") ? SmartPointer : Extend | SmartPointer | DirectorExtraCall, director_type, + Swig_MethodToFunction(n, NSpace, ClassType, Getattr(n, "template") ? SmartPointer : Extend | SmartPointer | DirectorExtraCall, director_type, is_member_director(CurrentClass, n)); Setattr(n, "sym:name", fname); @@ -1272,10 +1273,10 @@ int Language::staticmemberfunctionHandler(Node *n) { cname = NewStringf("%s::%s", sname, name); } else { String *mname = Swig_name_mangle(ClassName); - cname = Swig_name_member(mname, name); + cname = Swig_name_member(NSpace, mname, name); Delete(mname); } - mrename = Swig_name_member(ClassPrefix, symname); + mrename = Swig_name_member(NSpace, ClassPrefix, symname); if (Extend) { String *code = Getattr(n, "code"); @@ -1299,7 +1300,7 @@ int Language::staticmemberfunctionHandler(Node *n) { if (cb) { String *cbname = NewStringf(cb, symname); - Setattr(n, "feature:callback:name", Swig_name_member(ClassPrefix, cbname)); + Setattr(n, "feature:callback:name", Swig_name_member(NSpace, ClassPrefix, cbname)); Setattr(n, "feature:callback:staticname", name); } Delattr(n, "storage"); @@ -1380,9 +1381,9 @@ int Language::membervariableHandler(Node *n) { SwigType *type = Getattr(n, "type"); if (!AttributeFunctionGet) { - String *mname = Swig_name_member(ClassPrefix, symname); - String *mrename_get = Swig_name_get(mname); - String *mrename_set = Swig_name_set(mname); + String *mname = Swig_name_member(0, ClassPrefix, symname); + String *mrename_get = Swig_name_get(NSpace, mname); + String *mrename_set = Swig_name_set(NSpace, mname); Delete(mname); /* Create a function to set the value of the variable */ @@ -1493,7 +1494,7 @@ int Language::membervariableHandler(Node *n) { cpp_member_func(Char(gname), Char(gname), type, 0); Delete(ActionFunc); } else { - String *cname = Swig_name_get(name); + String *cname = Swig_name_get(NSpace, name); cpp_member_func(Char(cname), Char(gname), type, 0); Delete(cname); } @@ -1506,7 +1507,7 @@ int Language::membervariableHandler(Node *n) { cpp_member_func(Char(gname), Char(gname), vty, p); Delete(ActionFunc); } else { - String *cname = Swig_name_set(name); + String *cname = Swig_name_set(NSpace, name); cpp_member_func(Char(cname), Char(gname), vty, p); Delete(cname); } @@ -1534,7 +1535,7 @@ int Language::staticmembervariableHandler(Node *n) { String *cname, *mrename; /* Create the variable name */ - mrename = Swig_name_member(ClassPrefix, symname); + mrename = Swig_name_member(0, ClassPrefix, symname); cname = NewStringf("%s::%s", classname, name); Setattr(n, "sym:name", mrename); @@ -1676,7 +1677,7 @@ int Language::memberconstantHandler(Node *n) { String *symname = Getattr(n, "sym:name"); String *value = Getattr(n, "value"); - String *mrename = Swig_name_member(ClassPrefix, symname); + String *mrename = Swig_name_member(NSpace, ClassPrefix, symname); Setattr(n, "sym:name", mrename); String *new_name = 0; @@ -1908,7 +1909,7 @@ int Language::classDirectorDisown(Node *n) { Node *disown = NewHash(); String *mrename; String *symname = Getattr(n, "sym:name"); - mrename = Swig_name_disown(symname); //Getattr(n, "name")); + mrename = Swig_name_disown(NSpace, symname); String *type = NewString(ClassType); String *name = NewString("self"); SwigType_add_pointer(type); @@ -2315,6 +2316,7 @@ int Language::classDeclaration(Node *n) { String *name = Getattr(n, "name"); String *tdname = Getattr(n, "tdname"); String *symname = Getattr(n, "sym:name"); + String *symnspace = Getattr(n, "sym:nspace"); char *classname = tdname ? Char(tdname) : Char(name); char *iname = Char(symname); @@ -2343,6 +2345,7 @@ int Language::classDeclaration(Node *n) { ClassName = NewString(classname); ClassPrefix = NewString(iname); + NSpace = symnspace; if (strip) { ClassType = NewString(classname); } else { @@ -2403,6 +2406,7 @@ int Language::classDeclaration(Node *n) { Language::classHandler(n); } + NSpace = 0; InClass = 0; CurrentClass = 0; Delete(ClassType); @@ -2635,7 +2639,7 @@ static String *get_director_ctor_code(Node *n, String *director_ctor_code, Strin int Language::constructorHandler(Node *n) { Swig_require("constructorHandler", n, "?name", "*sym:name", "?type", "?parms", NIL); String *symname = Getattr(n, "sym:name"); - String *mrename = Swig_name_construct(symname); + String *mrename = Swig_name_construct(NSpace, symname); String *nodeType = Getattr(n, "nodeType"); int constructor = (!Cmp(nodeType, "constructor")); List *abstract = 0; @@ -2647,7 +2651,7 @@ int Language::constructorHandler(Node *n) { Setattr(n, "handled_as_constructor", "1"); } - Swig_ConstructorToFunction(n, ClassType, none_comparison, director_ctor, CPlusPlus, Getattr(n, "template") ? 0 : Extend); + Swig_ConstructorToFunction(n, NSpace, ClassType, none_comparison, director_ctor, CPlusPlus, Getattr(n, "template") ? 0 : Extend); Setattr(n, "sym:name", mrename); functionWrapper(n); Delete(mrename); @@ -2664,12 +2668,12 @@ int Language::constructorHandler(Node *n) { int Language::copyconstructorHandler(Node *n) { Swig_require("copyconstructorHandler", n, "?name", "*sym:name", "?type", "?parms", NIL); String *symname = Getattr(n, "sym:name"); - String *mrename = Swig_name_copyconstructor(symname); + String *mrename = Swig_name_copyconstructor(NSpace, symname); List *abstract = 0; String *director_ctor = get_director_ctor_code(n, director_ctor_code, director_prot_ctor_code, abstract); - Swig_ConstructorToFunction(n, ClassType, none_comparison, director_ctor, CPlusPlus, Getattr(n, "template") ? 0 : Extend); + Swig_ConstructorToFunction(n, NSpace, ClassType, none_comparison, director_ctor, CPlusPlus, Getattr(n, "template") ? 0 : Extend); Setattr(n, "sym:name", mrename); functionWrapper(n); Delete(mrename); @@ -2739,9 +2743,9 @@ int Language::destructorHandler(Node *n) { if (csymname && (*csymname == '~')) csymname += 1; - mrename = Swig_name_destroy(csymname); + mrename = Swig_name_destroy(NSpace, csymname); - Swig_DestructorToFunction(n, ClassType, CPlusPlus, Extend); + Swig_DestructorToFunction(n, NSpace, ClassType, CPlusPlus, Extend); Setattr(n, "sym:name", mrename); functionWrapper(n); Delete(mrename); @@ -2844,7 +2848,7 @@ int Language::variableWrapper(Node *n) { String *tm = Swig_typemap_lookup("globalin", n, name, 0); Swig_VarsetToFunction(n, flags); - String *sname = Swig_name_set(symname); + String *sname = Swig_name_set(NSpace, symname); Setattr(n, "sym:name", sname); Delete(sname); @@ -2879,7 +2883,7 @@ int Language::variableWrapper(Node *n) { } Swig_VargetToFunction(n, flags); - String *gname = Swig_name_get(symname); + String *gname = Swig_name_get(NSpace, symname); Setattr(n, "sym:name", gname); Delete(gname); functionWrapper(n); @@ -2922,11 +2926,11 @@ void Language::main(int argc, char *argv[]) { * 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. + * qualified scope and the symbol s must not contain any scope qualifiers. * ----------------------------------------------------------------------------- */ int Language::addSymbol(const String *s, const Node *n, const_String_or_char_ptr scope) { - Hash *symbols = Getattr(symtabs, scope); + Hash *symbols = Getattr(symtabs, scope ? scope : ""); if (!symbols) { // New scope which has not been added by the target language - lazily created. symbols = NewHash(); @@ -3306,7 +3310,7 @@ bool Language::extraDirectorProtectedCPPMethodsRequired() const { * Language::is_wrapping_class() * ----------------------------------------------------------------------------- */ -int Language::is_wrapping_class() { +int Language::is_wrapping_class() const { return InClass; } @@ -3318,6 +3322,14 @@ Node *Language::getCurrentClass() const { return CurrentClass; } +/* ----------------------------------------------------------------------------- + * Language::getNSpace() + * ----------------------------------------------------------------------------- */ + +String *Language::getNSpace() const { + return NSpace; +} + /* ----------------------------------------------------------------------------- * Language::getClassName() * ----------------------------------------------------------------------------- */ diff --git a/Source/Modules/lua.cxx b/Source/Modules/lua.cxx index 4640d9ed7..d240d3d6f 100644 --- a/Source/Modules/lua.cxx +++ b/Source/Modules/lua.cxx @@ -758,7 +758,7 @@ public: current=NO_CPP; // normally SWIG will generate 2 wrappers, a get and a set // but in certain scenarios (immutable, or if its arrays), it will not - String *getName = Swig_name_wrapper(Swig_name_get(iname)); + String *getName = Swig_name_wrapper(Swig_name_get(NSPACE_TODO, iname)); String *setName = 0; // checking whether it can be set to or not appears to be a very error prone issue // I refered to the Language::variableWrapper() to find this out @@ -770,7 +770,7 @@ public: Delete(tm); if (assignable) { - setName = Swig_name_wrapper(Swig_name_set(iname)); + setName = Swig_name_wrapper(Swig_name_set(NSPACE_TODO, iname)); } else { // how about calling a 'this is not settable' error message? setName = NewString("SWIG_Lua_set_immutable"); // error message @@ -790,7 +790,6 @@ public: // REPORT("constantWrapper", 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 = Copy(iname); SwigType *type = Getattr(n, "type"); String *rawval = Getattr(n, "rawval"); @@ -799,7 +798,6 @@ public: if (!addSymbol(iname, n)) return SWIG_ERROR; - //if (nspace) Setattr(n,"sym:name",nsname); /* Special hook for member pointer */ if (SwigType_type(type) == T_MPOINTER) { @@ -997,7 +995,7 @@ public: Printv(f_wrappers, "static swig_lua_class _wrap_class_", mangled_classname, " = { \"", class_name, "\", &SWIGTYPE", SwigType_manglestr(t), ",", NIL); if (have_constructor) { - Printf(f_wrappers, "%s", Swig_name_wrapper(Swig_name_construct(constructor_name))); + Printf(f_wrappers, "%s", Swig_name_wrapper(Swig_name_construct(NSPACE_TODO, constructor_name))); Delete(constructor_name); constructor_name = 0; } else { @@ -1043,7 +1041,7 @@ public: current = NO_CPP; realname = iname ? iname : name; - rname = Swig_name_wrapper(Swig_name_member(class_name, realname)); + rname = Swig_name_wrapper(Swig_name_member(NSPACE_TODO, class_name, realname)); if (!Getattr(n, "sym:nextSibling")) { Printv(s_methods_tab, tab4, "{\"", realname, "\", ", rname, "}, \n", NIL); } @@ -1063,9 +1061,9 @@ public: current = MEMBER_VAR; Language::membervariableHandler(n); current = NO_CPP; - gname = Swig_name_wrapper(Swig_name_get(Swig_name_member(class_name, symname))); + gname = Swig_name_wrapper(Swig_name_get(NSPACE_TODO, Swig_name_member(NSPACE_TODO, class_name, symname))); if (!GetFlag(n, "feature:immutable")) { - sname = Swig_name_wrapper(Swig_name_set(Swig_name_member(class_name, symname))); + sname = Swig_name_wrapper(Swig_name_set(NSPACE_TODO, Swig_name_member(NSPACE_TODO, class_name, symname))); } else { //sname = NewString("0"); sname = NewString("SWIG_Lua_set_immutable"); // error message diff --git a/Source/Modules/modula3.cxx b/Source/Modules/modula3.cxx index d1e10b974..252e92a7d 100644 --- a/Source/Modules/modula3.cxx +++ b/Source/Modules/modula3.cxx @@ -2620,7 +2620,7 @@ MODULA3(): if (proxy_flag) { String *overloaded_name = getOverloadedName(n); - String *intermediary_function_name = Swig_name_member(proxy_class_name, overloaded_name); + String *intermediary_function_name = Swig_name_member(NSPACE_TODO, proxy_class_name, overloaded_name); Setattr(n, "proxyfuncname", Getattr(n, "sym:name")); Setattr(n, "imfuncname", intermediary_function_name); proxyClassFunctionHandler(n); @@ -2641,7 +2641,7 @@ MODULA3(): if (proxy_flag) { String *overloaded_name = getOverloadedName(n); - String *intermediary_function_name = Swig_name_member(proxy_class_name, overloaded_name); + String *intermediary_function_name = Swig_name_member(NSPACE_TODO, proxy_class_name, overloaded_name); Setattr(n, "proxyfuncname", Getattr(n, "sym:name")); Setattr(n, "imfuncname", intermediary_function_name); proxyClassFunctionHandler(n); @@ -2699,7 +2699,7 @@ MODULA3(): if (proxy_flag && wrapping_member_flag && !enum_constant_flag) { // Properties - setter_flag = (Cmp(Getattr(n, "sym:name"), Swig_name_set(Swig_name_member(proxy_class_name, variable_name))) + setter_flag = (Cmp(Getattr(n, "sym:name"), Swig_name_set(NSPACE_TODO, Swig_name_member(NSPACE_TODO, proxy_class_name, variable_name))) == 0); } @@ -2844,7 +2844,7 @@ MODULA3(): String *imcall = NewString(""); Printf(proxy_class_code, " %s %s(", Getattr(n, "feature:modula3:methodmodifiers"), proxy_class_name); - Printv(imcall, " : this(", m3raw_name, ".", Swig_name_construct(overloaded_name), "(", NIL); + Printv(imcall, " : this(", m3raw_name, ".", Swig_name_construct(NSPACE_TODO, overloaded_name), "(", NIL); /* Attach the non-standard typemaps to the parameter list */ Swig_typemap_attach_parms("in", l, NULL); @@ -2935,7 +2935,7 @@ MODULA3(): String *symname = Getattr(n, "sym:name"); if (proxy_flag) { - Printv(destructor_call, m3raw_name, ".", Swig_name_destroy(symname), "(swigCPtr)", NIL); + Printv(destructor_call, m3raw_name, ".", Swig_name_destroy(NSPACE_TODO, symname), "(swigCPtr)", NIL); } return SWIG_OK; } diff --git a/Source/Modules/octave.cxx b/Source/Modules/octave.cxx index ab001a48b..16adddcce 100644 --- a/Source/Modules/octave.cxx +++ b/Source/Modules/octave.cxx @@ -701,8 +701,8 @@ public: Wrapper *getf = NewWrapper(); Wrapper *setf = NewWrapper(); - String *getname = Swig_name_get(iname); - String *setname = Swig_name_set(iname); + String *getname = Swig_name_get(NSPACE_TODO, iname); + String *setname = Swig_name_set(NSPACE_TODO, iname); Printf(setf->def, "static octave_value_list _wrap_%s(const octave_value_list& args,int nargout) {", setname); Printf(setf->def, "if (!SWIG_check_num_args(\"%s_set\",args.length(),1,1,0)) return octave_value_list();", iname); @@ -882,7 +882,7 @@ public: Printv(f_wrappers, "static swig_octave_class _wrap_class_", class_name, " = {\"", class_name, "\", &SWIGTYPE", SwigType_manglestr(t), ",", NIL); Printv(f_wrappers, Swig_directorclass(n) ? "1," : "0,", NIL); if (have_constructor) { - String *cname = Swig_name_construct(constructor_name); + String *cname = Swig_name_construct(NSPACE_TODO, constructor_name); String *wcname = Swig_name_wrapper(cname); String *tname = texinfo_name(n); Printf(f_wrappers, "%s,%s,", wcname, tname); @@ -915,7 +915,7 @@ public: String *name = Getattr(n, "name"); String *iname = GetChar(n, "sym:name"); String *realname = iname ? iname : name; - String *rname = Swig_name_wrapper(Swig_name_member(class_name, realname)); + String *rname = Swig_name_wrapper(Swig_name_member(NSPACE_TODO, class_name, realname)); if (!Getattr(n, "sym:nextSibling")) { String *tname = texinfo_name(n); @@ -936,9 +936,9 @@ public: assert(s_members_tab); assert(class_name); String *symname = Getattr(n, "sym:name"); - String *getname = Swig_name_wrapper(Swig_name_get(Swig_name_member(class_name, symname))); + String *getname = Swig_name_wrapper(Swig_name_get(NSPACE_TODO, Swig_name_member(NSPACE_TODO, class_name, symname))); String *setname = GetFlag(n, "feature:immutable") ? - NewString("octave_set_immutable") : Swig_name_wrapper(Swig_name_set(Swig_name_member(class_name, symname))); + NewString("octave_set_immutable") : Swig_name_wrapper(Swig_name_set(NSPACE_TODO, Swig_name_member(NSPACE_TODO, class_name, symname))); assert(s_members_tab); Printf(s_members_tab, "{\"%s\",0,%s,%s,0,0},\n", symname, getname, setname); @@ -988,7 +988,7 @@ public: String *name = Getattr(n, "name"); String *iname = GetChar(n, "sym:name"); String *realname = iname ? iname : name; - String *rname = Swig_name_wrapper(Swig_name_member(class_name, realname)); + String *rname = Swig_name_wrapper(Swig_name_member(NSPACE_TODO, class_name, realname)); if (!Getattr(n, "sym:nextSibling")) { String *tname = texinfo_name(n); @@ -1014,9 +1014,9 @@ public: assert(s_members_tab); assert(class_name); String *symname = Getattr(n, "sym:name"); - String *getname = Swig_name_wrapper(Swig_name_get(Swig_name_member(class_name, symname))); + String *getname = Swig_name_wrapper(Swig_name_get(NSPACE_TODO, Swig_name_member(NSPACE_TODO, class_name, symname))); String *setname = GetFlag(n, "feature:immutable") ? - NewString("octave_set_immutable") : Swig_name_wrapper(Swig_name_set(Swig_name_member(class_name, symname))); + NewString("octave_set_immutable") : Swig_name_wrapper(Swig_name_set(NSPACE_TODO, Swig_name_member(NSPACE_TODO, class_name, symname))); assert(s_members_tab); Printf(s_members_tab, "{\"%s\",0,%s,%s,1,0},\n", symname, getname, setname); diff --git a/Source/Modules/perl5.cxx b/Source/Modules/perl5.cxx index 4c7dba1eb..4be759194 100644 --- a/Source/Modules/perl5.cxx +++ b/Source/Modules/perl5.cxx @@ -840,8 +840,8 @@ public: SwigType *t = Getattr(n, "type"); Wrapper *getf, *setf; String *tm; - String *getname = Swig_name_get(iname); - String *setname = Swig_name_set(iname); + String *getname = Swig_name_get(NSPACE_TODO, iname); + String *setname = Swig_name_set(NSPACE_TODO, iname); String *get_name = Swig_name_wrapper(getname); String *set_name = Swig_name_wrapper(setname); @@ -1432,12 +1432,12 @@ public: if (Getattr(n, "feature:shadow")) { String *plcode = perlcode(Getattr(n, "feature:shadow"), 0); - String *plaction = NewStringf("%s::%s", cmodule, Swig_name_member(class_name, symname)); + String *plaction = NewStringf("%s::%s", cmodule, Swig_name_member(NSPACE_TODO, class_name, symname)); Replaceall(plcode, "$action", plaction); Delete(plaction); Printv(pcode, plcode, NIL); } else { - Printv(pcode, "*", symname, " = *", cmodule, "::", Swig_name_member(class_name, symname), ";\n", NIL); + Printv(pcode, "*", symname, " = *", cmodule, "::", Swig_name_member(NSPACE_TODO, class_name, symname), ";\n", NIL); } } return SWIG_OK; @@ -1462,8 +1462,8 @@ public: if (blessed) { - Printv(pcode, "*swig_", symname, "_get = *", cmodule, "::", Swig_name_get(Swig_name_member(class_name, symname)), ";\n", NIL); - Printv(pcode, "*swig_", symname, "_set = *", cmodule, "::", Swig_name_set(Swig_name_member(class_name, symname)), ";\n", NIL); + Printv(pcode, "*swig_", symname, "_get = *", cmodule, "::", Swig_name_get(NSPACE_TODO, Swig_name_member(NSPACE_TODO, class_name, symname)), ";\n", NIL); + Printv(pcode, "*swig_", symname, "_set = *", cmodule, "::", Swig_name_set(NSPACE_TODO, Swig_name_member(NSPACE_TODO, class_name, symname)), ";\n", NIL); /* Now we need to generate a little Perl code for this */ @@ -1501,7 +1501,7 @@ public: if ((blessed) && (!Getattr(n, "sym:nextSibling"))) { if (Getattr(n, "feature:shadow")) { String *plcode = perlcode(Getattr(n, "feature:shadow"), 0); - String *plaction = NewStringf("%s::%s", module, Swig_name_member(class_name, symname)); + String *plaction = NewStringf("%s::%s", module, Swig_name_member(NSPACE_TODO, class_name, symname)); Replaceall(plcode, "$action", plaction); Delete(plaction); Printv(pcode, plcode, NIL); @@ -1511,12 +1511,12 @@ 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(NSPACE_TODO, symname), " {\n", NIL); } Printv(pcode, tab4, "my $pkg = shift;\n", - tab4, "my $self = ", cmodule, "::", Swig_name_construct(symname), "(@_);\n", tab4, "bless $self, $pkg if defined($self);\n", "}\n\n", NIL); + tab4, "my $self = ", cmodule, "::", Swig_name_construct(NSPACE_TODO, symname), "(@_);\n", tab4, "bless $self, $pkg if defined($self);\n", "}\n\n", NIL); have_constructor = 1; } @@ -1536,7 +1536,7 @@ public: if (blessed) { if (Getattr(n, "feature:shadow")) { String *plcode = perlcode(Getattr(n, "feature:shadow"), 0); - String *plaction = NewStringf("%s::%s", module, Swig_name_member(class_name, symname)); + String *plaction = NewStringf("%s::%s", module, Swig_name_member(NSPACE_TODO, class_name, symname)); Replaceall(plcode, "$action", plaction); Delete(plaction); Printv(pcode, plcode, NIL); @@ -1548,7 +1548,7 @@ public: tab4, "return unless defined $self;\n", tab4, "delete $ITERATORS{$self};\n", tab4, "if (exists $OWNER{$self}) {\n", - tab8, cmodule, "::", Swig_name_destroy(symname), "($self);\n", tab8, "delete $OWNER{$self};\n", tab4, "}\n}\n\n", NIL); + tab8, cmodule, "::", Swig_name_destroy(NSPACE_TODO, symname), "($self);\n", tab8, "delete $OWNER{$self};\n", tab4, "}\n}\n\n", NIL); have_destructor = 1; } } @@ -1566,7 +1566,7 @@ public: member_func = 0; if ((blessed) && (!Getattr(n, "sym:nextSibling"))) { String *symname = Getattr(n, "sym:name"); - Printv(pcode, "*", symname, " = *", cmodule, "::", Swig_name_member(class_name, symname), ";\n", NIL); + Printv(pcode, "*", symname, " = *", cmodule, "::", Swig_name_member(NSPACE_TODO, class_name, symname), ";\n", NIL); } return SWIG_OK; } @@ -1579,7 +1579,7 @@ public: Language::staticmembervariableHandler(n); if (blessed) { String *symname = Getattr(n, "sym:name"); - Printv(pcode, "*", symname, " = *", cmodule, "::", Swig_name_member(class_name, symname), ";\n", NIL); + Printv(pcode, "*", symname, " = *", cmodule, "::", Swig_name_member(NSPACE_TODO, class_name, symname), ";\n", NIL); } return SWIG_OK; } @@ -1598,7 +1598,7 @@ public: blessed = oldblessed; if (blessed) { - Printv(pcode, "*", symname, " = *", cmodule, "::", Swig_name_member(class_name, symname), ";\n", NIL); + Printv(pcode, "*", symname, " = *", cmodule, "::", Swig_name_member(NSPACE_TODO, class_name, symname), ";\n", NIL); } return SWIG_OK; } diff --git a/Source/Modules/pike.cxx b/Source/Modules/pike.cxx index 6913596d3..51758ae46 100644 --- a/Source/Modules/pike.cxx +++ b/Source/Modules/pike.cxx @@ -766,7 +766,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(), "`->="); + String *setter = Swig_name_member(NSPACE_TODO, getClassPrefix(), "`->="); String *wname = Swig_name_wrapper(setter); Printv(wrapper->def, "static void ", wname, "(INT32 args) {", NIL); Printf(wrapper->locals, "char *name = (char *) STR0(Pike_sp[0-args].u.string);\n"); @@ -775,7 +775,7 @@ public: while (i.item) { if (!GetFlag(i.item, "feature:immutable")) { name = Getattr(i.item, "name"); - funcname = Swig_name_wrapper(Swig_name_set(Swig_name_member(getClassPrefix(), name))); + funcname = Swig_name_wrapper(Swig_name_set(NSPACE_TODO, Swig_name_member(NSPACE_TODO, getClassPrefix(), name))); Printf(wrapper->code, "if (!strcmp(name, \"%s\")) {\n", name); Printf(wrapper->code, "%s(args);\n", funcname); Printf(wrapper->code, "return;\n"); @@ -805,7 +805,7 @@ public: /* Create a function to get the values of the (mutable) variables */ Wrapper *wrapper = NewWrapper(); - String *getter = Swig_name_member(getClassPrefix(), "`->"); + String *getter = Swig_name_member(NSPACE_TODO, getClassPrefix(), "`->"); String *wname = Swig_name_wrapper(getter); Printv(wrapper->def, "static void ", wname, "(INT32 args) {", NIL); Printf(wrapper->locals, "char *name = (char *) STR0(Pike_sp[0-args].u.string);\n"); @@ -813,7 +813,7 @@ public: i = First(membervariables); while (i.item) { name = Getattr(i.item, "name"); - funcname = Swig_name_wrapper(Swig_name_get(Swig_name_member(getClassPrefix(), name))); + funcname = Swig_name_wrapper(Swig_name_get(NSPACE_TODO, Swig_name_member(NSPACE_TODO, getClassPrefix(), name))); Printf(wrapper->code, "if (!strcmp(name, \"%s\")) {\n", name); Printf(wrapper->code, "%s(args);\n", funcname); Printf(wrapper->code, "return;\n"); diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index bafd567e0..3215d29aa 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -1866,7 +1866,7 @@ public: && ((shadow & PYSHADOW_MEMBER))) { String *nname = Getattr(n, "sym:name"); String *sname = Getattr(getCurrentClass(), "sym:name"); - String *cname = Swig_name_construct(sname); + String *cname = Swig_name_construct(NSPACE_TODO, sname); handled_as_init = (Strcmp(nname, sname) == 0) || (Strcmp(nname, cname) == 0); Delete(cname); } @@ -2437,8 +2437,8 @@ public: } } - String *getname = Swig_name_get(iname); - String *setname = Swig_name_set(iname); + String *getname = Swig_name_get(NSPACE_TODO, iname); + String *setname = Swig_name_set(NSPACE_TODO, iname); String *vargetname = NewStringf("Swig_var_%s", getname); String *varsetname = NewStringf("Swig_var_%s", setname); @@ -2771,7 +2771,7 @@ public: shadow = oldshadow; if (shadow) { String *symname = Getattr(n, "sym:name"); - String *mrename = Swig_name_disown(symname); //Getattr(n, "name")); + String *mrename = Swig_name_disown(NSPACE_TODO, symname); //Getattr(n, "name")); Printv(f_shadow, tab4, "def __disown__(self):\n", NIL); #ifdef USE_THISOWN Printv(f_shadow, tab8, "self.thisown = 0\n", NIL); @@ -3029,7 +3029,7 @@ public: List *shadow_list = Getattr(n, "shadow_methods"); for (int i = 0; i < Len(shadow_list); ++i) { String *symname = Getitem(shadow_list, i); - Printf(f_shadow_file, "%s.%s = new_instancemethod(%s.%s,None,%s)\n", class_name, symname, module, Swig_name_member(class_name, symname), class_name); + Printf(f_shadow_file, "%s.%s = new_instancemethod(%s.%s,None,%s)\n", class_name, symname, module, Swig_name_member(NSPACE_TODO, class_name, symname), class_name); } } Printf(f_shadow_file, "%s_swigregister = %s.%s_swigregister\n", class_name, module, class_name); @@ -3093,7 +3093,7 @@ public: } if (Getattr(n, "feature:shadow")) { String *pycode = pythoncode(Getattr(n, "feature:shadow"), tab4); - String *pyaction = NewStringf("%s.%s", module, Swig_name_member(class_name, symname)); + String *pyaction = NewStringf("%s.%s", module, Swig_name_member(NSPACE_TODO, class_name, symname)); Replaceall(pycode, "$action", pyaction); Delete(pyaction); Printv(f_shadow, pycode, "\n", NIL); @@ -3105,7 +3105,7 @@ public: if (!have_addtofunc(n)) { if (!fastproxy || olddefs) { Printv(f_shadow, tab4, "def ", symname, "(", parms, ")", returnTypeAnnotation(n), ":", NIL); - Printv(f_shadow, " return ", funcCall(Swig_name_member(class_name, symname), callParms), "\n", NIL); + Printv(f_shadow, " return ", funcCall(Swig_name_member(NSPACE_TODO, class_name, symname), callParms), "\n", NIL); } } else { Printv(f_shadow, tab4, "def ", symname, "(",parms , ")", returnTypeAnnotation(n), ":", NIL); @@ -3118,11 +3118,11 @@ public: } if (have_pythonappend(n)) { fproxy = 0; - Printv(f_shadow, tab8, "val = ", funcCall(Swig_name_member(class_name, symname), callParms), "\n", NIL); + Printv(f_shadow, tab8, "val = ", funcCall(Swig_name_member(NSPACE_TODO, class_name, symname), callParms), "\n", NIL); Printv(f_shadow, pythoncode(pythonappend(n), tab8), "\n", NIL); Printv(f_shadow, tab8, "return val\n\n", NIL); } else { - Printv(f_shadow, tab8, "return ", funcCall(Swig_name_member(class_name, symname), callParms), "\n\n", NIL); + Printv(f_shadow, tab8, "return ", funcCall(Swig_name_member(NSPACE_TODO, class_name, symname), callParms), "\n\n", NIL); } } } @@ -3163,11 +3163,11 @@ public: if (have_pythonprepend(n)) Printv(f_shadow, pythoncode(pythonprepend(n), tab8), "\n", NIL); if (have_pythonappend(n)) { - Printv(f_shadow, tab8, "val = ", funcCall(Swig_name_member(class_name, symname), callParms), "\n", NIL); + Printv(f_shadow, tab8, "val = ", funcCall(Swig_name_member(NSPACE_TODO, class_name, symname), callParms), "\n", NIL); Printv(f_shadow, pythoncode(pythonappend(n), tab8), "\n", NIL); Printv(f_shadow, tab8, "return val\n\n", NIL); } else { - Printv(f_shadow, tab8, "return ", funcCall(Swig_name_member(class_name, symname), callParms), "\n\n", NIL); + Printv(f_shadow, tab8, "return ", funcCall(Swig_name_member(NSPACE_TODO, class_name, symname), callParms), "\n\n", NIL); } Printv(f_shadow, tab4, modern ? "" : "if _newclass:", symname, " = staticmethod(", symname, ")\n", NIL); @@ -3177,10 +3177,10 @@ public: } else { if (!modern) { - Printv(f_shadow, tab4, "__swig_getmethods__[\"", symname, "\"] = lambda x: ", module, ".", Swig_name_member(class_name, symname), "\n", NIL); + Printv(f_shadow, tab4, "__swig_getmethods__[\"", symname, "\"] = lambda x: ", module, ".", Swig_name_member(NSPACE_TODO, class_name, symname), "\n", NIL); } if (!classic) { - Printv(f_shadow, tab4, modern ? "" : "if _newclass:", symname, " = staticmethod(", module, ".", Swig_name_member(class_name, symname), ")\n", NIL); + Printv(f_shadow, tab4, modern ? "" : "if _newclass:", symname, " = staticmethod(", module, ".", Swig_name_member(NSPACE_TODO, class_name, symname), ")\n", NIL); } } } @@ -3235,7 +3235,7 @@ public: if (!have_constructor) { String *nname = Getattr(n, "sym:name"); String *sname = Getattr(getCurrentClass(), "sym:name"); - String *cname = Swig_name_construct(sname); + String *cname = Swig_name_construct(NSPACE_TODO, sname); handled_as_init = (Strcmp(nname, sname) == 0) || (Strcmp(nname, cname) == 0); Delete(cname); } @@ -3243,7 +3243,7 @@ public: if (!have_constructor && handled_as_init) { if (Getattr(n, "feature:shadow")) { String *pycode = pythoncode(Getattr(n, "feature:shadow"), tab4); - String *pyaction = NewStringf("%s.%s", module, Swig_name_construct(symname)); + String *pyaction = NewStringf("%s.%s", module, Swig_name_construct(NSPACE_TODO, symname)); Replaceall(pycode, "$action", pyaction); Delete(pyaction); Printv(f_shadow, pycode, "\n", NIL); @@ -3274,10 +3274,10 @@ public: Printv(f_shadow, pythoncode(pythonprepend(n), tab8), "\n", NIL); Printv(f_shadow, pass_self, NIL); if (fastinit) { - Printv(f_shadow, tab8, module, ".", class_name, "_swiginit(self,", funcCall(Swig_name_construct(symname), callParms), ")\n", NIL); + Printv(f_shadow, tab8, module, ".", class_name, "_swiginit(self,", funcCall(Swig_name_construct(NSPACE_TODO, symname), callParms), ")\n", NIL); } else { Printv(f_shadow, - tab8, "this = ", funcCall(Swig_name_construct(symname), callParms), "\n", + tab8, "this = ", funcCall(Swig_name_construct(NSPACE_TODO, symname), callParms), "\n", tab8, "try: self.this.append(this)\n", tab8, "except: self.this = this\n", NIL); } if (have_pythonappend(n)) @@ -3291,7 +3291,7 @@ public: if (Getattr(n, "feature:shadow")) { String *pycode = pythoncode(Getattr(n, "feature:shadow"), ""); - String *pyaction = NewStringf("%s.%s", module, Swig_name_construct(symname)); + String *pyaction = NewStringf("%s.%s", module, Swig_name_construct(NSPACE_TODO, symname)); Replaceall(pycode, "$action", pyaction); Delete(pyaction); Printv(f_shadow_stubs, pycode, "\n", NIL); @@ -3305,7 +3305,7 @@ public: Printv(f_shadow_stubs, tab4, docstring(n, AUTODOC_CTOR, tab4), "\n", NIL); if (have_pythonprepend(n)) Printv(f_shadow_stubs, pythoncode(pythonprepend(n), tab4), "\n", NIL); - Printv(f_shadow_stubs, tab4, "val = ", funcCall(Swig_name_construct(symname), callParms), "\n", NIL); + Printv(f_shadow_stubs, tab4, "val = ", funcCall(Swig_name_construct(NSPACE_TODO, symname), callParms), "\n", NIL); #ifdef USE_THISOWN Printv(f_shadow_stubs, tab4, "val.thisown = 1\n", NIL); #endif @@ -3335,13 +3335,13 @@ public: if (shadow) { if (Getattr(n, "feature:shadow")) { String *pycode = pythoncode(Getattr(n, "feature:shadow"), tab4); - String *pyaction = NewStringf("%s.%s", module, Swig_name_destroy(symname)); + String *pyaction = NewStringf("%s.%s", module, Swig_name_destroy(NSPACE_TODO, symname)); Replaceall(pycode, "$action", pyaction); Delete(pyaction); Printv(f_shadow, pycode, "\n", NIL); Delete(pycode); } else { - Printv(f_shadow, tab4, "__swig_destroy__ = ", module, ".", Swig_name_destroy(symname), "\n", NIL); + Printv(f_shadow, tab4, "__swig_destroy__ = ", module, ".", Swig_name_destroy(NSPACE_TODO, symname), "\n", NIL); if (!have_pythonprepend(n) && !have_pythonappend(n)) { if (proxydel) { Printv(f_shadow, tab4, "__del__ = lambda self : None;\n", NIL); @@ -3355,7 +3355,7 @@ public: Printv(f_shadow, pythoncode(pythonprepend(n), tab8), "\n", NIL); #ifdef USE_THISOWN Printv(f_shadow, tab8, "try:\n", NIL); - Printv(f_shadow, tab8, tab4, "if self.thisown: ", module, ".", Swig_name_destroy(symname), "(self)\n", NIL); + Printv(f_shadow, tab8, tab4, "if self.thisown: ", module, ".", Swig_name_destroy(NSPACE_TODO, symname), "(self)\n", NIL); Printv(f_shadow, tab8, "except: pass\n", NIL); #else #endif @@ -3382,9 +3382,9 @@ public: shadow = oldshadow; if (shadow) { - String *mname = Swig_name_member(class_name, symname); - String *setname = Swig_name_set(mname); - String *getname = Swig_name_get(mname); + String *mname = Swig_name_member(NSPACE_TODO, class_name, symname); + String *setname = Swig_name_set(NSPACE_TODO, mname); + String *getname = Swig_name_get(NSPACE_TODO, mname); if (shadow) { int assignable = is_assignable(n); if (!modern) { @@ -3419,15 +3419,15 @@ public: if (shadow && !GetFlag(n, "wrappedasconstant")) { String *symname = Getattr(n, "sym:name"); if (GetFlag(n, "hasconsttype")) { - String *mname = Swig_name_member(class_name, symname); + String *mname = Swig_name_member(NSPACE_TODO, class_name, symname); Printf(f_shadow_stubs, "%s.%s = %s.%s.%s\n", class_name, symname, module, global_name, mname); Delete(mname); } else { - String *mname = Swig_name_member(class_name, symname); - String *getname = Swig_name_get(mname); + String *mname = Swig_name_member(NSPACE_TODO, class_name, symname); + String *getname = Swig_name_get(NSPACE_TODO, mname); String *wrapgetname = Swig_name_wrapper(getname); String *vargetname = NewStringf("Swig_var_%s", getname); - String *setname = Swig_name_set(mname); + String *setname = Swig_name_set(NSPACE_TODO, mname); String *wrapsetname = Swig_name_wrapper(setname); String *varsetname = NewStringf("Swig_var_%s", setname); @@ -3490,7 +3490,7 @@ public: shadow = oldshadow; if (shadow) { - Printv(f_shadow, tab4, symname, " = ", module, ".", Swig_name_member(class_name, symname), "\n", NIL); + Printv(f_shadow, tab4, symname, " = ", module, ".", Swig_name_member(NSPACE_TODO, class_name, symname), "\n", NIL); } return SWIG_OK; } diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx index 82808b154..043df02f2 100644 --- a/Source/Modules/ruby.cxx +++ b/Source/Modules/ruby.cxx @@ -2115,7 +2115,7 @@ public: /* create getter */ int addfail = 0; - String *getname = Swig_name_get(iname); + String *getname = Swig_name_get(NSPACE_TODO, iname); getfname = Swig_name_wrapper(getname); Setattr(n, "wrap:name", getfname); Printv(getf->def, "SWIGINTERN VALUE\n", getfname, "(", NIL); @@ -2150,7 +2150,7 @@ public: Printf(f_wrappers, "%s", docs); Delete(docs); - String *setname = Swig_name_set(iname); + String *setname = Swig_name_set(NSPACE_TODO, iname); setfname = Swig_name_wrapper(setname); Setattr(n, "wrap:name", setfname); Printv(setf->def, "SWIGINTERN VALUE\n", setfname, "(VALUE self, ", NIL); diff --git a/Source/Modules/swigmod.h b/Source/Modules/swigmod.h index a6b5234d4..016ccc8d4 100644 --- a/Source/Modules/swigmod.h +++ b/Source/Modules/swigmod.h @@ -265,7 +265,7 @@ protected: void allow_overloading(int val = 1); /* Wrapping class query */ - int is_wrapping_class(); + int is_wrapping_class() const; /* Return the node for the current class */ Node *getCurrentClass() const; @@ -273,6 +273,9 @@ protected: /* Return C++ mode */ int getCPlusMode() const; + /* Return the namespace for the class/enum - the nspace feature */ + String *getNSpace() const; + /* Return the real name of the current class */ String *getClassName() const; diff --git a/Source/Modules/tcl8.cxx b/Source/Modules/tcl8.cxx index 94191abcc..b6b4c6965 100644 --- a/Source/Modules/tcl8.cxx +++ b/Source/Modules/tcl8.cxx @@ -573,7 +573,7 @@ public: /* Create a function for getting a variable */ int addfail = 0; getf = NewWrapper(); - String *getname = Swig_name_get(iname); + String *getname = Swig_name_get(NSPACE_TODO, iname); String *getfname = Swig_name_wrapper(getname); Setattr(n, "wrap:name", getfname); Printv(getf->def, "SWIGINTERN const char *", getfname, "(ClientData clientData SWIGUNUSED, Tcl_Interp *interp, char *name1, char *name2, int flags) {", NIL); @@ -605,7 +605,7 @@ public: /* Try to create a function setting a variable */ if (is_assignable(n)) { setf = NewWrapper(); - setname = Swig_name_set(iname); + setname = Swig_name_set(NSPACE_TODO, iname); setfname = Swig_name_wrapper(setname); Setattr(n, "wrap:name", setfname); if (setf) { @@ -951,7 +951,7 @@ public: Printv(f_wrappers, "static swig_class _wrap_class_", mangled_classname, " = { \"", class_name, "\", &SWIGTYPE", SwigType_manglestr(t), ",", NIL); if (have_constructor) { - Printf(f_wrappers, "%s", Swig_name_wrapper(Swig_name_construct(constructor_name))); + Printf(f_wrappers, "%s", Swig_name_wrapper(Swig_name_construct(NSPACE_TODO, constructor_name))); Delete(constructor_name); constructor_name = 0; } else { @@ -989,7 +989,7 @@ public: Language::memberfunctionHandler(n); realname = iname ? iname : name; - rname = Swig_name_wrapper(Swig_name_member(class_name, realname)); + rname = Swig_name_wrapper(Swig_name_member(NSPACE_TODO, class_name, realname)); if (!Getattr(n, "sym:nextSibling")) { Printv(methods_tab, tab4, "{\"", realname, "\", ", rname, "}, \n", NIL); } @@ -1082,11 +1082,11 @@ public: Language::membervariableHandler(n); Printv(attr_tab, tab4, "{ \"-", symname, "\",", NIL); - rname = Swig_name_wrapper(Swig_name_get(Swig_name_member(class_name, symname))); + rname = Swig_name_wrapper(Swig_name_get(NSPACE_TODO, Swig_name_member(NSPACE_TODO, class_name, symname))); Printv(attr_tab, rname, ", ", NIL); Delete(rname); if (!GetFlag(n, "feature:immutable")) { - rname = Swig_name_wrapper(Swig_name_set(Swig_name_member(class_name, symname))); + rname = Swig_name_wrapper(Swig_name_set(NSPACE_TODO, Swig_name_member(NSPACE_TODO, class_name, symname))); Printv(attr_tab, rname, "},\n", NIL); Delete(rname); } else { diff --git a/Source/Modules/typepass.cxx b/Source/Modules/typepass.cxx index 8d4ddda11..a975e350c 100644 --- a/Source/Modules/typepass.cxx +++ b/Source/Modules/typepass.cxx @@ -36,6 +36,7 @@ class TypePass:private Dispatcher { Node *module; int importmode; String *nsname; + String *nssymname; Hash *classhash; List *normalize; @@ -296,6 +297,7 @@ class TypePass:private Dispatcher { inclass = 0; normalize = 0; nsname = 0; + nssymname = 0; classhash = Getattr(n, "classes"); emit_children(n); normalize_list(); @@ -415,6 +417,10 @@ class TypePass:private Dispatcher { Setattr(n, "tdname", tdname); } } + if (nssymname) { + if (GetFlag(n, "feature:nspace")) + Setattr(n, "sym:nspace", nssymname); + } SwigType_new_scope(scopename); SwigType_attach_symtab(Getattr(n, "symtab")); @@ -535,7 +541,9 @@ class TypePass:private Dispatcher { } } String *oldnsname = nsname; + String *oldnssymname = nssymname; nsname = Swig_symbol_qualified(Getattr(n, "symtab")); + nssymname = Swig_symbol_qualified_language_scopename(Getattr(n, "symtab")); symtab = Swig_symbol_setscope(Getattr(n, "symtab")); emit_children(n); Swig_symbol_setscope(symtab); @@ -557,6 +565,8 @@ class TypePass:private Dispatcher { } normalize = olist; + Delete(nssymname); + nssymname = oldnssymname; Delete(nsname); nsname = oldnsname; return SWIG_OK; @@ -734,6 +744,11 @@ class TypePass:private Dispatcher { } Setattr(n, "enumtype", enumtype); + if (nssymname) { + if (GetFlag(n, "feature:nspace")) + Setattr(n, "sym:nspace", nssymname); + } + // This block of code is for dealing with %ignore on an enum item where the target language // attempts to use the C enum value in the target language itself and expects the previous enum value // to be one more than the previous value... the previous enum item might not exist if it is ignored! diff --git a/Source/Swig/cwrap.c b/Source/Swig/cwrap.c index 4fe7236c5..539ae6e18 100644 --- a/Source/Swig/cwrap.c +++ b/Source/Swig/cwrap.c @@ -782,7 +782,7 @@ int Swig_add_extension_code(Node *n, const String *function_name, ParmList *parm * Converts a C++ method node to a function accessor function. * ----------------------------------------------------------------------------- */ -int Swig_MethodToFunction(Node *n, String *classname, int flags, SwigType *director_type, int is_director) { +int Swig_MethodToFunction(Node *n, const_String_or_char_ptr nspace, String *classname, int flags, SwigType *director_type, int is_director) { String *name, *qualifier; ParmList *parms; SwigType *type; @@ -896,7 +896,7 @@ int Swig_MethodToFunction(Node *n, String *classname, int flags, SwigType *direc String *defaultargs = Getattr(n, "defaultargs"); String *code = Getattr(n, "code"); String *cname = Getattr(n, "classname") ? Getattr(n, "classname") : classname; - String *membername = Swig_name_member(cname, name); + String *membername = Swig_name_member(nspace, cname, name); String *mangled = Swig_name_mangle(membername); int is_smart_pointer = flags & CWRAP_SMART_POINTER; @@ -1009,7 +1009,7 @@ Node *Swig_directormap(Node *module, String *type) { * This function creates a C wrapper for a C constructor function. * ----------------------------------------------------------------------------- */ -int Swig_ConstructorToFunction(Node *n, String *classname, String *none_comparison, String *director_ctor, int cplus, int flags) { +int Swig_ConstructorToFunction(Node *n, const_String_or_char_ptr nspace, String *classname, String *none_comparison, String *director_ctor, int cplus, int flags) { ParmList *parms; Parm *prefix_args; Parm *p; @@ -1049,7 +1049,7 @@ int Swig_ConstructorToFunction(Node *n, String *classname, String *none_comparis String *cres; String *defaultargs = Getattr(n, "defaultargs"); String *code = Getattr(n, "code"); - String *membername = Swig_name_construct(classname); + String *membername = Swig_name_construct(nspace, classname); String *mangled = Swig_name_mangle(membername); /* Check if the constructor is overloaded. If so, and it has code attached, we append an extra suffix @@ -1153,7 +1153,7 @@ int Swig_ConstructorToFunction(Node *n, String *classname, String *none_comparis * This function creates a C wrapper for a destructor function. * ----------------------------------------------------------------------------- */ -int Swig_DestructorToFunction(Node *n, String *classname, int cplus, int flags) { +int Swig_DestructorToFunction(Node *n, const_String_or_char_ptr nspace, String *classname, int cplus, int flags) { SwigType *type; Parm *p; @@ -1170,7 +1170,7 @@ int Swig_DestructorToFunction(Node *n, String *classname, int cplus, int flags) String *cres; String *call; String *membername, *mangled, *code; - membername = Swig_name_destroy(classname); + membername = Swig_name_destroy(nspace, classname); mangled = Swig_name_mangle(membername); code = Getattr(n, "code"); if (code) { @@ -1219,10 +1219,7 @@ int Swig_MembersetToFunction(Node *n, String *classname, int flags) { SwigType *ty; SwigType *type; SwigType *void_type = NewString("void"); - String *membername; - String *mangled; String *self = 0; - String *sname; int varcref = flags & CWRAP_NATURAL_VAR; @@ -1236,10 +1233,6 @@ int Swig_MembersetToFunction(Node *n, String *classname, int flags) { name = Getattr(n, "name"); type = Getattr(n, "type"); - sname = Swig_name_set(name); - membername = Swig_name_member(classname, sname); - mangled = Swig_name_mangle(membername); - t = NewString(classname); SwigType_add_pointer(t); parms = NewParm(t, "self", n); @@ -1262,6 +1255,11 @@ int Swig_MembersetToFunction(Node *n, String *classname, int flags) { String *call; String *cres; String *code = Getattr(n, "code"); + + String *sname = Swig_name_set(0, name); + String *membername = Swig_name_member(0, classname, sname); + String *mangled = Swig_name_mangle(membername); + if (code) { /* I don't think this ever gets run - WSF */ Swig_add_extension_code(n, mangled, parms, void_type, code, cparse_cplusplus, "self"); @@ -1269,8 +1267,12 @@ int Swig_MembersetToFunction(Node *n, String *classname, int flags) { call = Swig_cfunction_call(mangled, parms); cres = NewStringf("%s;", call); Setattr(n, "wrap:action", cres); - Delete(call); + Delete(cres); + Delete(call); + Delete(mangled); + Delete(membername); + Delete(sname); } else { String *call = Swig_cmemberset_call(name, type, self, varcref); String *cres = NewStringf("%s;", call); @@ -1283,9 +1285,6 @@ int Swig_MembersetToFunction(Node *n, String *classname, int flags) { Delete(parms); Delete(ty); Delete(void_type); - Delete(membername); - Delete(sname); - Delete(mangled); Delete(self); return SWIG_OK; } @@ -1302,10 +1301,7 @@ int Swig_MembergetToFunction(Node *n, String *classname, int flags) { SwigType *t; SwigType *ty; SwigType *type; - String *membername; - String *mangled; String *self = 0; - String *gname; int varcref = flags & CWRAP_NATURAL_VAR; @@ -1325,10 +1321,6 @@ int Swig_MembergetToFunction(Node *n, String *classname, int flags) { name = Getattr(n, "name"); type = Getattr(n, "type"); - gname = Swig_name_get(name); - membername = Swig_name_member(classname, gname); - mangled = Swig_name_mangle(membername); - t = NewString(classname); SwigType_add_pointer(t); parms = NewParm(t, "self", n); @@ -1340,8 +1332,12 @@ int Swig_MembergetToFunction(Node *n, String *classname, int flags) { if (flags & CWRAP_EXTEND) { String *call; String *cres; - String *code = Getattr(n, "code"); + + String *gname = Swig_name_get(0, name); + String *membername = Swig_name_member(0, classname, gname); + String *mangled = Swig_name_mangle(membername); + if (code) { /* I don't think this ever gets run - WSF */ Swig_add_extension_code(n, mangled, parms, ty, code, cparse_cplusplus, "self"); @@ -1349,8 +1345,12 @@ int Swig_MembergetToFunction(Node *n, String *classname, int flags) { call = Swig_cfunction_call(mangled, parms); cres = Swig_cresult(ty, "result", call); Setattr(n, "wrap:action", cres); + Delete(cres); Delete(call); + Delete(mangled); + Delete(membername); + Delete(gname); } else { String *call = Swig_cmemberget_call(name, type, self, varcref); String *cres = Swig_cresult(ty, "result", call); @@ -1362,9 +1362,6 @@ int Swig_MembergetToFunction(Node *n, String *classname, int flags) { Setattr(n, "parms", parms); Delete(parms); Delete(ty); - Delete(membername); - Delete(gname); - Delete(mangled); return SWIG_OK; } @@ -1390,7 +1387,7 @@ int Swig_VarsetToFunction(Node *n, int flags) { parms = NewParm(ty, name, n); if (flags & CWRAP_EXTEND) { - String *sname = Swig_name_set(name); + String *sname = Swig_name_set(0, name); String *mangled = Swig_name_mangle(sname); String *call = Swig_cfunction_call(mangled, parms); String *cres = NewStringf("%s;", call); @@ -1444,7 +1441,7 @@ int Swig_VargetToFunction(Node *n, int flags) { ty = Swig_wrapped_var_type(type, varcref); if (flags & CWRAP_EXTEND) { - String *sname = Swig_name_get(name); + String *sname = Swig_name_get(0, name); String *mangled = Swig_name_mangle(sname); call = Swig_cfunction_call(mangled, 0); cres = Swig_cresult(ty, "result", call); diff --git a/Source/Swig/misc.c b/Source/Swig/misc.c index 19050fd51..7085f3b4a 100644 --- a/Source/Swig/misc.c +++ b/Source/Swig/misc.c @@ -17,6 +17,9 @@ char cvsroot_misc_c[] = "$Id$"; #include #include #include +#include +#include + static char *fake_version = 0; @@ -135,6 +138,54 @@ String *Swig_strip_c_comments(const String *s) { return stripped; } +/* ----------------------------------------------------------------------------- + * Swig_new_subdirectory() + * + * Create the subdirectory only if the basedirectory already exists as a directory. + * basedirectory can be NULL or empty to indicate current directory. + * ----------------------------------------------------------------------------- */ + +String *Swig_new_subdirectory(String *basedirectory, String *subdirectory) { + String *error = 0; + struct stat st; + int current_directory = basedirectory ? (Len(basedirectory) == 0 ? 1 : 0) : 0; + + if (current_directory || ((stat(Char(basedirectory), &st) == 0) && S_ISDIR(st.st_mode))) { + Iterator it; + String *dir = basedirectory ? NewString(basedirectory) : NewString(""); + List *subdirs = Split(subdirectory, SWIG_FILE_DELIMITER[0], INT_MAX); + + for (it = First(subdirs); it.item; it = Next(it)) { + int statdir; + String *subdirectory = it.item; + Printf(dir, "%s", subdirectory); + statdir = stat(Char(dir), &st); + if (statdir == 0) { + Printf(dir, SWIG_FILE_DELIMITER); + if (S_ISDIR(st.st_mode)) { + continue; + } else { + error = NewStringf("Cannot create directory %s", dir); + break; + } + } else { +#ifdef _WIN32 + int result = mkdir(Char(dir)); +#else + int result = mkdir(Char(dir), 0777); +#endif + Printf(dir, SWIG_FILE_DELIMITER); + if (result != 0 && errno != EEXIST) { + error = NewStringf("Cannot create directory %s", dir); + break; + } + } + } + } else { + error = NewStringf("Cannot create subdirectory %s under the base directory %s", subdirectory, basedirectory); + } + return error; +} /* ----------------------------------------------------------------------------- * Swig_filename_correct() diff --git a/Source/Swig/naming.c b/Source/Swig/naming.c index 08c4f6b5d..07e42f2d4 100644 --- a/Source/Swig/naming.c +++ b/Source/Swig/naming.c @@ -9,6 +9,15 @@ * naming.c * * Functions for generating various kinds of names during code generation. + * + * Swig_name_register is used to register a format string for generating names. + * The format string makes use of the following format specifiers: + * + * %c - class name is substituted + * %f - function name is substituted + * %m - member name is substituted + * %n - namespace is substituted + * %v - variable name is substituted * ----------------------------------------------------------------------------- */ char cvsroot_naming_c[] = "$Id$"; @@ -125,6 +134,23 @@ static int name_mangle(String *r) { return special; } +/* ----------------------------------------------------------------------------- + * replace_nspace() + * + * Mangles in the namespace from nspace by replacing %n in name if nspace feature required. + * ----------------------------------------------------------------------------- */ + +static void replace_nspace(String *name, const_String_or_char_ptr nspace) { + if (nspace) { + String *namspace = NewStringf("%s_", nspace); + Replaceall(namspace, NSPACE_SEPARATOR, "_"); + Replace(name, "%n", namspace, DOH_REPLACE_ANY); + Delete(namspace); + } else { + Replace(name, "%n", "", DOH_REPLACE_ANY); + } +} + /* ----------------------------------------------------------------------------- * Swig_name_mangle() * @@ -172,7 +198,7 @@ String *Swig_name_wrapper(const_String_or_char_ptr fname) { * Returns the name of a class method. * ----------------------------------------------------------------------------- */ -String *Swig_name_member(const_String_or_char_ptr classname, const_String_or_char_ptr mname) { +String *Swig_name_member(const_String_or_char_ptr nspace, const_String_or_char_ptr classname, const_String_or_char_ptr membername) { String *r; String *f; String *rclassname; @@ -184,7 +210,7 @@ String *Swig_name_member(const_String_or_char_ptr classname, const_String_or_cha naming_hash = NewHash(); f = Getattr(naming_hash, "member"); if (!f) { - Append(r, "%c_%m"); + Append(r, "%n%c_%m"); } else { Append(r, f); } @@ -192,8 +218,9 @@ String *Swig_name_member(const_String_or_char_ptr classname, const_String_or_cha if ((strncmp(cname, "struct ", 7) == 0) || ((strncmp(cname, "class ", 6) == 0)) || ((strncmp(cname, "union ", 6) == 0))) { cname = strchr(cname, ' ') + 1; } + replace_nspace(r, nspace); Replace(r, "%c", cname, DOH_REPLACE_ANY); - Replace(r, "%m", mname, DOH_REPLACE_ANY); + Replace(r, "%m", membername, DOH_REPLACE_ANY); /* name_mangle(r); */ Delete(rclassname); return r; @@ -205,7 +232,7 @@ String *Swig_name_member(const_String_or_char_ptr classname, const_String_or_cha * Returns the name of the accessor function used to get a variable. * ----------------------------------------------------------------------------- */ -String *Swig_name_get(const_String_or_char_ptr vname) { +String *Swig_name_get(const_String_or_char_ptr nspace, const_String_or_char_ptr vname) { String *r; String *f; @@ -218,10 +245,12 @@ String *Swig_name_get(const_String_or_char_ptr vname) { naming_hash = NewHash(); f = Getattr(naming_hash, "get"); if (!f) { - Append(r, "%v_get"); + Append(r, "%n%v_get"); } else { Append(r, f); } + + replace_nspace(r, nspace); Replace(r, "%v", vname, DOH_REPLACE_ANY); /* name_mangle(r); */ return r; @@ -233,7 +262,7 @@ String *Swig_name_get(const_String_or_char_ptr vname) { * Returns the name of the accessor function used to set a variable. * ----------------------------------------------------------------------------- */ -String *Swig_name_set(const_String_or_char_ptr vname) { +String *Swig_name_set(const_String_or_char_ptr nspace, const_String_or_char_ptr vname) { String *r; String *f; @@ -242,10 +271,12 @@ String *Swig_name_set(const_String_or_char_ptr vname) { naming_hash = NewHash(); f = Getattr(naming_hash, "set"); if (!f) { - Append(r, "%v_set"); + Append(r, "%n%v_set"); } else { Append(r, f); } + + replace_nspace(r, nspace); Replace(r, "%v", vname, DOH_REPLACE_ANY); /* name_mangle(r); */ return r; @@ -257,7 +288,7 @@ String *Swig_name_set(const_String_or_char_ptr vname) { * Returns the name of the accessor function used to create an object. * ----------------------------------------------------------------------------- */ -String *Swig_name_construct(const_String_or_char_ptr classname) { +String *Swig_name_construct(const_String_or_char_ptr nspace, const_String_or_char_ptr classname) { String *r; String *f; String *rclassname; @@ -269,7 +300,7 @@ String *Swig_name_construct(const_String_or_char_ptr classname) { naming_hash = NewHash(); f = Getattr(naming_hash, "construct"); if (!f) { - Append(r, "new_%c"); + Append(r, "new_%n%c"); } else { Append(r, f); } @@ -278,6 +309,8 @@ String *Swig_name_construct(const_String_or_char_ptr classname) { if ((strncmp(cname, "struct ", 7) == 0) || ((strncmp(cname, "class ", 6) == 0)) || ((strncmp(cname, "union ", 6) == 0))) { cname = strchr(cname, ' ') + 1; } + + replace_nspace(r, nspace); Replace(r, "%c", cname, DOH_REPLACE_ANY); Delete(rclassname); return r; @@ -290,7 +323,7 @@ String *Swig_name_construct(const_String_or_char_ptr classname) { * Returns the name of the accessor function used to copy an object. * ----------------------------------------------------------------------------- */ -String *Swig_name_copyconstructor(const_String_or_char_ptr classname) { +String *Swig_name_copyconstructor(const_String_or_char_ptr nspace, const_String_or_char_ptr classname) { String *r; String *f; String *rclassname; @@ -302,7 +335,7 @@ String *Swig_name_copyconstructor(const_String_or_char_ptr classname) { naming_hash = NewHash(); f = Getattr(naming_hash, "copy"); if (!f) { - Append(r, "copy_%c"); + Append(r, "copy_%n%c"); } else { Append(r, f); } @@ -312,6 +345,7 @@ String *Swig_name_copyconstructor(const_String_or_char_ptr classname) { cname = strchr(cname, ' ') + 1; } + replace_nspace(r, nspace); Replace(r, "%c", cname, DOH_REPLACE_ANY); Delete(rclassname); return r; @@ -323,7 +357,7 @@ String *Swig_name_copyconstructor(const_String_or_char_ptr classname) { * Returns the name of the accessor function used to destroy an object. * ----------------------------------------------------------------------------- */ -String *Swig_name_destroy(const_String_or_char_ptr classname) { +String *Swig_name_destroy(const_String_or_char_ptr nspace, const_String_or_char_ptr classname) { String *r; String *f; String *rclassname; @@ -334,7 +368,7 @@ String *Swig_name_destroy(const_String_or_char_ptr classname) { naming_hash = NewHash(); f = Getattr(naming_hash, "destroy"); if (!f) { - Append(r, "delete_%c"); + Append(r, "delete_%n%c"); } else { Append(r, f); } @@ -343,6 +377,8 @@ String *Swig_name_destroy(const_String_or_char_ptr classname) { if ((strncmp(cname, "struct ", 7) == 0) || ((strncmp(cname, "class ", 6) == 0)) || ((strncmp(cname, "union ", 6) == 0))) { cname = strchr(cname, ' ') + 1; } + + replace_nspace(r, nspace); Replace(r, "%c", cname, DOH_REPLACE_ANY); Delete(rclassname); return r; @@ -355,7 +391,7 @@ String *Swig_name_destroy(const_String_or_char_ptr classname) { * Returns the name of the accessor function used to disown an object. * ----------------------------------------------------------------------------- */ -String *Swig_name_disown(const_String_or_char_ptr classname) { +String *Swig_name_disown(const_String_or_char_ptr nspace, const_String_or_char_ptr classname) { String *r; String *f; String *rclassname; @@ -366,7 +402,7 @@ String *Swig_name_disown(const_String_or_char_ptr classname) { naming_hash = NewHash(); f = Getattr(naming_hash, "disown"); if (!f) { - Append(r, "disown_%c"); + Append(r, "disown_%n%c"); } else { Append(r, f); } @@ -375,6 +411,8 @@ String *Swig_name_disown(const_String_or_char_ptr classname) { if ((strncmp(cname, "struct ", 7) == 0) || ((strncmp(cname, "class ", 6) == 0)) || ((strncmp(cname, "union ", 6) == 0))) { cname = strchr(cname, ' ') + 1; } + + replace_nspace(r, nspace); Replace(r, "%c", cname, DOH_REPLACE_ANY); Delete(rclassname); return r; diff --git a/Source/Swig/swig.h b/Source/Swig/swig.h index ec5ecb271..b3cb0f158 100644 --- a/Source/Swig/swig.h +++ b/Source/Swig/swig.h @@ -35,6 +35,10 @@ extern "C" { #define SWIG_ERROR 0 #define SWIG_NOWRAP 0 +/* Global macros */ +#define NSPACE_SEPARATOR "." /* Namespace separator for the nspace feature - this should be changed to a target language configurable variable */ +#define NSPACE_TODO 0 /* temporary TODO hack */ + /* Short names for common data types */ typedef DOH String; @@ -212,6 +216,7 @@ extern "C" { extern void Swig_symbol_setscopename(const_String_or_char_ptr name); extern String *Swig_symbol_getscopename(void); extern String *Swig_symbol_qualifiedscopename(Symtab *symtab); + extern String *Swig_symbol_qualified_language_scopename(Symtab *symtab); extern Symtab *Swig_symbol_newscope(void); extern Symtab *Swig_symbol_setscope(Symtab *); extern Symtab *Swig_symbol_getscope(const_String_or_char_ptr symname); @@ -259,13 +264,13 @@ extern int ParmList_is_compactdefargs(ParmList *p); extern void Swig_name_unregister(const_String_or_char_ptr method); extern String *Swig_name_mangle(const_String_or_char_ptr s); extern String *Swig_name_wrapper(const_String_or_char_ptr fname); - extern String *Swig_name_member(const_String_or_char_ptr classname, const_String_or_char_ptr mname); - extern String *Swig_name_get(const_String_or_char_ptr vname); - extern String *Swig_name_set(const_String_or_char_ptr vname); - extern String *Swig_name_construct(const_String_or_char_ptr classname); - extern String *Swig_name_copyconstructor(const_String_or_char_ptr classname); - extern String *Swig_name_destroy(const_String_or_char_ptr classname); - extern String *Swig_name_disown(const_String_or_char_ptr classname); + extern String *Swig_name_member(const_String_or_char_ptr nspace, const_String_or_char_ptr classname, const_String_or_char_ptr membername); + extern String *Swig_name_get(const_String_or_char_ptr nspace, const_String_or_char_ptr vname); + extern String *Swig_name_set(const_String_or_char_ptr nspace, const_String_or_char_ptr vname); + extern String *Swig_name_construct(const_String_or_char_ptr nspace, const_String_or_char_ptr classname); + extern String *Swig_name_copyconstructor(const_String_or_char_ptr nspace, const_String_or_char_ptr classname); + extern String *Swig_name_destroy(const_String_or_char_ptr nspace, const_String_or_char_ptr classname); + extern String *Swig_name_disown(const_String_or_char_ptr nspace, const_String_or_char_ptr classname); extern void Swig_naming_init(void); extern void Swig_name_namewarn_add(String *prefix, String *name, SwigType *decl, Hash *namewrn); @@ -296,6 +301,7 @@ 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_new_subdirectory(String *basedirectory, String *subdirectory); extern void Swig_filename_correct(String *filename); extern String *Swig_filename_escape(String *filename); extern void Swig_filename_unescape(String *filename); @@ -346,9 +352,9 @@ extern int ParmList_is_compactdefargs(ParmList *p); /* --- Transformations --- */ - 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_MethodToFunction(Node *n, const_String_or_char_ptr nspace, String *classname, int flags, SwigType *director_type, int is_director); + extern int Swig_ConstructorToFunction(Node *n, const_String_or_char_ptr nspace, String *classname, String *none_comparison, String *director_ctor, int cplus, int flags); + extern int Swig_DestructorToFunction(Node *n, const_String_or_char_ptr nspace, String *classname, int cplus, int flags); extern int Swig_MembersetToFunction(Node *n, String *classname, int flags); extern int Swig_MembergetToFunction(Node *n, String *classname, int flags); extern int Swig_VargetToFunction(Node *n, int flags); diff --git a/Source/Swig/symbol.c b/Source/Swig/symbol.c index 73a136a4a..b5e114683 100644 --- a/Source/Swig/symbol.c +++ b/Source/Swig/symbol.c @@ -353,6 +353,21 @@ String *Swig_symbol_qualifiedscopename(Symtab *symtab) { return result; } +/* ----------------------------------------------------------------------------- + * Swig_symbol_qualified_language_scopename() + * + * Get the fully qualified C scopename of a symbol table but using a language + * specific separator for the scopenames. Basically the same as + * Swig_symbol_qualifiedscopename() but using the different separator. + * ----------------------------------------------------------------------------- */ + +String *Swig_symbol_qualified_language_scopename(Symtab *n) { + /* TODO: fix for %rename to work */ + String *result = Swig_symbol_qualifiedscopename(n); + Replaceall(result, "::", NSPACE_SEPARATOR); + return result; +} + /* ----------------------------------------------------------------------------- * Swig_symbol_newscope() * From d399c1a04cd7300ee164b28eeaee6431f5e60431 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 4 Mar 2010 21:45:26 +0000 Subject: [PATCH 0767/1680] DohDelete and DohCopy assertions called if not a DOH object git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11897 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/DOH/base.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Source/DOH/base.c b/Source/DOH/base.c index 245004f87..36ceb7ae3 100644 --- a/Source/DOH/base.c +++ b/Source/DOH/base.c @@ -30,12 +30,15 @@ void DohDelete(DOH *obj) { if (!obj) return; -#if SWIG_DEBUG_DELETE if (!DohCheck(b)) { +#if SWIG_DEBUG_DELETE fputs("DOH: Fatal error. Attempt to delete a non-doh object.\n", stderr); abort(); - } +#else + assert(0); #endif + return; + } if (b->flag_intern) return; assert(b->refcount > 0); @@ -62,6 +65,15 @@ DOH *DohCopy(const DOH *obj) { if (!obj) return 0; + if (!DohCheck(b)) { +#if SWIG_DEBUG_DELETE + fputs("DOH: Fatal error. Attempt to copy a non-doh object.\n", stderr); + abort(); +#else + assert(0); +#endif + return 0; + } objinfo = b->type; if (objinfo->doh_copy) { DohBase *bc = (DohBase *) (objinfo->doh_copy) (b); From d7695d4f10498909907590de17d116b098625f59 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Fri, 5 Mar 2010 03:43:41 +0000 Subject: [PATCH 0768/1680] Fix typo. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11898 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- COPYRIGHT | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/COPYRIGHT b/COPYRIGHT index 45f9d6b45..0e660ba3a 100644 --- a/COPYRIGHT +++ b/COPYRIGHT @@ -29,7 +29,7 @@ Past SWIG developers and major contributors include: 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) + Sam Liddicott - Ananova Ltd (saml@liddicott.com) (PHP) Tim Hockin - Sun Microsystems (thockin@sun.com) (PHP) Kevin Ruland (PHP) Shibukawa Yoshiki (Japanese Translation) From cfcafc807a435c6c9afccda2cc5ef8d99cded9d6 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 5 Mar 2010 18:37:05 +0000 Subject: [PATCH 0769/1680] Add java run test for nspace test and extend the test a bit git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11899 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/java/nspace_runme.java | 64 ++++++++++++++++++++++ Examples/test-suite/nspace.i | 14 ++++- 2 files changed, 76 insertions(+), 2 deletions(-) create mode 100644 Examples/test-suite/java/nspace_runme.java diff --git a/Examples/test-suite/java/nspace_runme.java b/Examples/test-suite/java/nspace_runme.java new file mode 100644 index 000000000..ca83b7d04 --- /dev/null +++ b/Examples/test-suite/java/nspace_runme.java @@ -0,0 +1,64 @@ +// This tests changes the package name from nspace to nspacePackage as javac can't seem to resolve classes and packages having the same name +public class nspace_runme { + + static { + try { + System.loadLibrary("nspace"); + } catch (UnsatisfiedLinkError e) { + System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); + System.exit(1); + } + } + + public static void main(String argv[]) { + // constructors and destructors + nspacePackage.Outer.Inner1.Color color1 = new nspacePackage.Outer.Inner1.Color(); + nspacePackage.Outer.Inner1.Color color = new nspacePackage.Outer.Inner1.Color(color1); + color1.delete(); + color1 = null; + + // class methods + color.colorInstanceMethod(20.0); + nspacePackage.Outer.Inner1.Color.colorStaticMethod(20.0); + nspacePackage.Outer.Inner1.Color created = nspacePackage.Outer.Inner1.Color.create(); + + // class enums + nspacePackage.Outer.SomeClass someClass = new nspacePackage.Outer.SomeClass(); + nspacePackage.Outer.Inner1.Color.Channel channel = someClass.GetInner1ColorChannel(); + if (channel != nspacePackage.Outer.Inner1.Color.Channel.Transmission) + throw new RuntimeException("Transmission wrong"); + + // static member variables + nspacePackage.Outer.Inner1.Color.setStaticMemberVariable(789); + if (nspacePackage.Outer.Inner1.Color.getStaticMemberVariable() != 789) + throw new RuntimeException("static member variable failed"); + + // instance member variables + color.setInstanceMemberVariable(123); + if (color.getInstanceMemberVariable() != 123) + throw new RuntimeException("instance member variable failed"); + + // Same class different namespaces + nspacePackage.Outer.Inner1.Color col1 = new nspacePackage.Outer.Inner1.Color(); + nspacePackage.Outer.Inner2.Color col2 = nspacePackage.Outer.Inner2.Color.create(); + col2.colors(col1, col1, col2, col2, col2); + + // check globals in a namespace don't get mangled with the nspacePackage option + nspacePackage.nspace.namespaceFunction(color); + nspacePackage.nspace.setNamespaceVar(111); + if (nspacePackage.nspace.getNamespaceVar() != 111) + throw new RuntimeException("global var failed"); + + // global enums + nspacePackage.Outer.Inner1.Channel outerChannel1 = someClass.GetInner1Channel(); + if (outerChannel1 != nspacePackage.Outer.Inner1.Channel.Transmission1) + throw new RuntimeException("Transmission1 wrong"); + nspacePackage.Outer.Inner2.Channel outerChannel2 = someClass.GetInner2Channel(); + if (outerChannel2 != nspacePackage.Outer.Inner2.Channel.Transmission2) + throw new RuntimeException("Transmission2 wrong"); + + // turn feature off / ignoring + nspacePackage.Outer.nspace ns = new nspacePackage.Outer.nspace(); + nspacePackage.NoNSpacePlease nons = new nspacePackage.NoNSpacePlease(); + } +} diff --git a/Examples/test-suite/nspace.i b/Examples/test-suite/nspace.i index 26a3273b2..eb63f342d 100644 --- a/Examples/test-suite/nspace.i +++ b/Examples/test-suite/nspace.i @@ -4,9 +4,13 @@ #if defined(SWIGJAVA) SWIG_JAVABODY_METHODS(public, public, SWIGTYPE) %pragma(java) jniclassclassmodifiers = "public class" +#endif -%feature("nspace"); -%feature("nspace", "0") Outer::Inner2::NoNSpacePlease; +// nspace feature only supported by these languages +#if defined(SWIGJAVA) || defined(SWIGCSHARP) + +%nspace; +%nonspace Outer::Inner2::NoNSpacePlease; %copyctor; %ignore Outer::Inner2::Color::Color(); @@ -64,6 +68,11 @@ namespace Outer { static int staticMemberVariable; void colorInstanceMethod(double d) {} static void colorStaticMethod(double d) {} + void colors(const Inner1::Color& col1a, + const Outer::Inner1::Color& col1b, + const Color &col2a, + const Inner2::Color& col2b, + const Outer::Inner2::Color& col2c) {} }; // Color int Color::staticMemberVariable = 0; class NoNSpacePlease {}; @@ -91,3 +100,4 @@ void test_classes(Outer::SomeClass c, Outer::Inner2::Color cc) {} %} #endif + From 8e1f9274cc53b754aac2781ca6fe2b4ce05cd6a1 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 6 Mar 2010 00:11:40 +0000 Subject: [PATCH 0770/1680] remove weave python example - license is unclear git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11902 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/python/weave/Makefile | 22 - Examples/python/weave/README | 25 - Examples/python/weave/example.h | 18 - Examples/python/weave/example.i | 15 - Examples/python/weave/runme.py | 72 - Examples/python/weave/swigptr2.py | 3556 ----------------------------- 6 files changed, 3708 deletions(-) delete mode 100644 Examples/python/weave/Makefile delete mode 100644 Examples/python/weave/README delete mode 100644 Examples/python/weave/example.h delete mode 100644 Examples/python/weave/example.i delete mode 100644 Examples/python/weave/runme.py delete mode 100644 Examples/python/weave/swigptr2.py diff --git a/Examples/python/weave/Makefile b/Examples/python/weave/Makefile deleted file mode 100644 index 88f95c095..000000000 --- a/Examples/python/weave/Makefile +++ /dev/null @@ -1,22 +0,0 @@ -TOP = ../.. -SWIG = $(TOP)/../preinst-swig -CXXSRCS = -TARGET = example -INTERFACE = example.i -LIBS = -lm -SWIGOPT = - -all:: - $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp - -static:: - $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static - -clean:: - $(MAKE) -f $(TOP)/Makefile python_clean - rm -f $(TARGET).py - -check: all - $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/weave/README b/Examples/python/weave/README deleted file mode 100644 index a616a4f46..000000000 --- a/Examples/python/weave/README +++ /dev/null @@ -1,25 +0,0 @@ -This directory contains a simple example to test weave support for -SWIG wrapped objects. - -The weave package provides tools for including C/C++ code in Python -code. This offers both another level of optimization to those who need -it, and an easy way to modify and extend any supported extension -libraries. Weave automatically builds an extension module from the -given C/C++ code and runs that. This can result in very significant -speedups (of upto 500x) depending on the problem. Weave also supports -inlining SWIG-1.3.x wrapped objects. - -The example in this directory requires that weave be installed. Weave -is distributed as part of SciPy (http://www.scipy.org). More -information on Weave may be had from here: - - http://www.scipy.org/documentation/weave - -As of November 22, 2004, this example only works with weave from CVS. -If there is a more recent release of SciPy after this date, it should -work fine. - - -Also, you need to replace the weave file swigptr2.py by the one -provided here. - diff --git a/Examples/python/weave/example.h b/Examples/python/weave/example.h deleted file mode 100644 index d09d60850..000000000 --- a/Examples/python/weave/example.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef _EXAMPLE_H -#define _EXAMPLE_H - -class Foo { - public: - int x; -}; - -class Bar { - public: - int y; -}; - -class FooBar : public Foo, public Bar { - public: - int z; -}; -#endif diff --git a/Examples/python/weave/example.i b/Examples/python/weave/example.i deleted file mode 100644 index 5d71eaa93..000000000 --- a/Examples/python/weave/example.i +++ /dev/null @@ -1,15 +0,0 @@ -%module(directors="1") example - -%{ -#include "example.h" -%} - -%include "std_vector.i" - -%director Foo; -%director Bar; -%include "example.h" - - -%template(VectorBar) std::vector; -%template(VectorFoo) std::vector; diff --git a/Examples/python/weave/runme.py b/Examples/python/weave/runme.py deleted file mode 100644 index 529b4fc4b..000000000 --- a/Examples/python/weave/runme.py +++ /dev/null @@ -1,72 +0,0 @@ -""" -Test weave support for SWIG wrapped objects. - -This example requires that one has weave installed. Weave is -distributed as part of SciPy (http://www.scipy.org). More information -on Weave may be had from here: - - http://www.scipy.org/documentation/weave - -As of November 22, 2004, this only works with weave from CVS. If -there is a more recent release of SciPy after this date, it should -work fine. - -""" - -import example -import weave -from weave import converters -from weave import swig2_spec - -# Weave does not support swig2 by default (yet). So add this to the -# list of default converters to test. -converters.default.insert(0, swig2_spec.swig2_converter()) - -def test(): - """ A simple test case for weave.""" - a = example.Foo() - a.x = 1 - b = example.Bar() - b.y = 2 - c = example.FooBar() - c.x = 1 - c.y = 2 - c.z = 3 - v = example.VectorBar() - v.append(b) - v.append(c) - d = v[0] - e = v[1] - v = example.VectorFoo() - v.append(a) - v.append(c) - f = v[0] - g = v[1] - - code = """ - std::cout << a->x << std::endl; - assert(a->x == 1); - std::cout << b->y << std::endl; - assert(b->y == 2); - std::cout << c->x << std::endl; - std::cout << c->y << std::endl; - std::cout << c->z << std::endl; - assert(c->x == 1); - assert(c->y == 2); - assert(c->z == 3); - std::cout << d->y << std::endl; - assert(d->y == 2); - std::cout << e->y << std::endl; - assert(e->y == 2); - std::cout << f->x << std::endl; - assert(f->x == 1); - std::cout << g->x << std::endl; - assert(g->x == 1); - """ - weave.inline(code, ['a', 'b', 'c', 'd', 'e', 'f', 'g'], - include_dirs=['.'], - headers=['"example.h"'], - verbose=2) - -if __name__ == "__main__": - test() diff --git a/Examples/python/weave/swigptr2.py b/Examples/python/weave/swigptr2.py deleted file mode 100644 index 7ffe0fb65..000000000 --- a/Examples/python/weave/swigptr2.py +++ /dev/null @@ -1,3556 +0,0 @@ -# This code allows one to use SWIG wrapped objects from weave. This -# code is specific to SWIG-1.3 and above where things are different. -# The code is basically all copied out from the SWIG wrapper code but -# it has been hand edited for brevity. -# -# Prabhu Ramachandran - -###################################################################### -# This is for SWIG-1.3.x where x < 22. -# Essentially, SWIG_RUNTIME_VERSION was not yet used. -swigptr2_code_v0 = """ - -#include "Python.h" - -/*************************************************************** -*- c -*- - * python/precommon.swg - * - * Rename all exported symbols from common.swg, to avoid symbol - * clashes if multiple interpreters are included - * - ************************************************************************/ - -#define SWIG_TypeCheck SWIG_Python_TypeCheck -#define SWIG_TypeCast SWIG_Python_TypeCast -#define SWIG_TypeName SWIG_Python_TypeName -#define SWIG_TypeQuery SWIG_Python_TypeQuery -#define SWIG_PackData SWIG_Python_PackData -#define SWIG_UnpackData SWIG_Python_UnpackData - - -/*********************************************************************** - * common.swg - * - * This file contains generic SWIG runtime support for pointer - * type checking as well as a few commonly used macros to control - * external linkage. - * - * Author : David Beazley (beazley@cs.uchicago.edu) - * - * Copyright (c) 1999-2000, The University of Chicago - * - * This file may be freely redistributed without license or fee provided - * this copyright message remains intact. - ************************************************************************/ - -#include - -#if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) -# if defined(_MSC_VER) || defined(__GNUC__) -# if defined(STATIC_LINKED) -# define SWIGEXPORT(a) a -# define SWIGIMPORT(a) extern a -# else -# define SWIGEXPORT(a) __declspec(dllexport) a -# define SWIGIMPORT(a) extern a -# endif -# else -# if defined(__BORLANDC__) -# define SWIGEXPORT(a) a _export -# define SWIGIMPORT(a) a _export -# else -# define SWIGEXPORT(a) a -# define SWIGIMPORT(a) a -# endif -# endif -#else -# define SWIGEXPORT(a) a -# define SWIGIMPORT(a) a -#endif - -#ifdef SWIG_GLOBAL -# define SWIGRUNTIME(a) SWIGEXPORT(a) -#else -# define SWIGRUNTIME(a) static a -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -typedef void *(*swig_converter_func)(void *); -typedef struct swig_type_info *(*swig_dycast_func)(void **); - -typedef struct swig_type_info { - const char *name; - swig_converter_func converter; - const char *str; - void *clientdata; - swig_dycast_func dcast; - struct swig_type_info *next; - struct swig_type_info *prev; -} swig_type_info; - -#ifdef SWIG_NOINCLUDE - -SWIGIMPORT(swig_type_info *) SWIG_TypeCheck(char *c, swig_type_info *); -SWIGIMPORT(void *) SWIG_TypeCast(swig_type_info *, void *); -SWIGIMPORT(const char *) SWIG_TypeName(const swig_type_info *); -SWIGIMPORT(swig_type_info *) SWIG_TypeQuery(const char *); -SWIGIMPORT(char *) SWIG_PackData(char *, void *, int); -SWIGIMPORT(char *) SWIG_UnpackData(char *, void *, int); - -#else - -static swig_type_info *swig_type_list = 0; - -/* Check the typename */ -SWIGRUNTIME(swig_type_info *) -SWIG_TypeCheck(char *c, swig_type_info *ty) { - swig_type_info *s; - if (!ty) return 0; /* Void pointer */ - s = ty->next; /* First element always just a name */ - do { - if (strcmp(s->name,c) == 0) { - if (s == ty->next) return s; - /* Move s to the top of the linked list */ - s->prev->next = s->next; - if (s->next) { - s->next->prev = s->prev; - } - /* Insert s as second element in the list */ - s->next = ty->next; - if (ty->next) ty->next->prev = s; - ty->next = s; - s->prev = ty; - return s; - } - s = s->next; - } while (s && (s != ty->next)); - return 0; -} - -/* Cast a pointer up an inheritance hierarchy */ -SWIGRUNTIME(void *) -SWIG_TypeCast(swig_type_info *ty, void *ptr) { - if ((!ty) || (!ty->converter)) return ptr; - return (*ty->converter)(ptr); -} - -/* Return the name associated with this type */ -SWIGRUNTIME(const char *) -SWIG_TypeName(const swig_type_info *ty) { - return ty->name; -} - -/* - Compare two type names skipping the space characters, therefore - "char*" == "char *" and "Class" == "Class", etc. - - Return 0 when the two name types are equivalent, as in - strncmp, but skipping ' '. -*/ -static int -SWIG_TypeNameComp(const char *f1, const char *l1, - const char *f2, const char *l2) { - for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) { - while ((*f1 == ' ') && (f1 != l1)) ++f1; - while ((*f2 == ' ') && (f2 != l2)) ++f2; - if (*f1 != *f2) return *f1 - *f2; - } - return (l1 - f1) - (l2 - f2); -} - -/* - Check type equivalence in a name list like ||... -*/ -static int -SWIG_TypeEquiv(const char *nb, const char *tb) { - int equiv = 0; - const char* te = tb + strlen(tb); - const char* ne = nb; - while (!equiv && *ne) { - for (nb = ne; *ne; ++ne) { - if (*ne == '|') break; - } - equiv = SWIG_TypeNameComp(nb, ne, tb, te) == 0; - if (*ne) ++ne; - } - return equiv; -} - - -/* Search for a swig_type_info structure */ -SWIGRUNTIME(swig_type_info *) -SWIG_TypeQuery(const char *name) { - swig_type_info *ty = swig_type_list; - while (ty) { - if (ty->str && (SWIG_TypeEquiv(ty->str,name))) return ty; - if (ty->name && (strcmp(name,ty->name) == 0)) return ty; - ty = ty->prev; - } - return 0; -} - -/* Pack binary data into a string */ -SWIGRUNTIME(char *) -SWIG_PackData(char *c, void *ptr, int sz) { - static char hex[17] = "0123456789abcdef"; - int i; - unsigned char *u = (unsigned char *) ptr; - register unsigned char uu; - for (i = 0; i < sz; i++,u++) { - uu = *u; - *(c++) = hex[(uu & 0xf0) >> 4]; - *(c++) = hex[uu & 0xf]; - } - return c; -} - -/* Unpack binary data from a string */ -SWIGRUNTIME(char *) -SWIG_UnpackData(char *c, void *ptr, int sz) { - register unsigned char uu = 0; - register int d; - unsigned char *u = (unsigned char *) ptr; - int i; - for (i = 0; i < sz; i++, u++) { - d = *(c++); - if ((d >= '0') && (d <= '9')) - uu = ((d - '0') << 4); - else if ((d >= 'a') && (d <= 'f')) - uu = ((d - ('a'-10)) << 4); - d = *(c++); - if ((d >= '0') && (d <= '9')) - uu |= (d - '0'); - else if ((d >= 'a') && (d <= 'f')) - uu |= (d - ('a'-10)); - *u = uu; - } - return c; -} - -#endif - -#ifdef __cplusplus -} -#endif - -/*********************************************************************** - * python.swg - * - * This file contains the runtime support for Python modules - * and includes code for managing global variables and pointer - * type checking. - * - * Author : David Beazley (beazley@cs.uchicago.edu) - ************************************************************************/ - -#include "Python.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define SWIG_PY_INT 1 -#define SWIG_PY_FLOAT 2 -#define SWIG_PY_STRING 3 -#define SWIG_PY_POINTER 4 -#define SWIG_PY_BINARY 5 - -/* Flags for pointer conversion */ - -#define SWIG_POINTER_EXCEPTION 0x1 -#define SWIG_POINTER_DISOWN 0x2 - -/* Exception handling in wrappers */ -#define SWIG_fail goto fail - -/* Constant information structure */ -typedef struct swig_const_info { - int type; - char *name; - long lvalue; - double dvalue; - void *pvalue; - swig_type_info **ptype; -} swig_const_info; - -/* Common SWIG API */ -#define SWIG_ConvertPtr(obj, pp, type, flags) \ - SWIG_Python_ConvertPtr(obj, pp, type, flags) -#define SWIG_NewPointerObj(p, type, flags) \ - SWIG_Python_NewPointerObj(p, type, flags) -#define SWIG_MustGetPtr(p, type, argnum, flags) \ - SWIG_Python_MustGetPtr(p, type, argnum, flags) - - -typedef double (*py_objasdbl_conv)(PyObject *obj); - -#ifdef SWIG_NOINCLUDE - -SWIGIMPORT(int) SWIG_Python_ConvertPtr(PyObject *, void **, swig_type_info *, int); -SWIGIMPORT(PyObject *) SWIG_Python_NewPointerObj(void *, swig_type_info *,int own); -SWIGIMPORT(void *) SWIG_Python_MustGetPtr(PyObject *, swig_type_info *, int, int); - -#else - - -/* Convert a pointer value */ -SWIGRUNTIME(int) -SWIG_Python_ConvertPtr(PyObject *obj, void **ptr, swig_type_info *ty, int flags) { - swig_type_info *tc; - char *c = 0; - static PyObject *SWIG_this = 0; - int newref = 0; - PyObject *pyobj = 0; - - if (!obj) return 0; - if (obj == Py_None) { - *ptr = 0; - return 0; - } -#ifdef SWIG_COBJECT_TYPES - if (!(PyCObject_Check(obj))) { - if (!SWIG_this) - SWIG_this = PyString_FromString("this"); - pyobj = obj; - obj = PyObject_GetAttr(obj,SWIG_this); - newref = 1; - if (!obj) goto type_error; - if (!PyCObject_Check(obj)) { - Py_DECREF(obj); - goto type_error; - } - } - *ptr = PyCObject_AsVoidPtr(obj); - c = (char *) PyCObject_GetDesc(obj); - if (newref) Py_DECREF(obj); - goto cobject; -#else - if (!(PyString_Check(obj))) { - if (!SWIG_this) - SWIG_this = PyString_FromString("this"); - pyobj = obj; - obj = PyObject_GetAttr(obj,SWIG_this); - newref = 1; - if (!obj) goto type_error; - if (!PyString_Check(obj)) { - Py_DECREF(obj); - goto type_error; - } - } - c = PyString_AsString(obj); - /* Pointer values must start with leading underscore */ - if (*c != '_') { - *ptr = (void *) 0; - if (strcmp(c,"NULL") == 0) { - if (newref) { Py_DECREF(obj); } - return 0; - } else { - if (newref) { Py_DECREF(obj); } - goto type_error; - } - } - c++; - c = SWIG_UnpackData(c,ptr,sizeof(void *)); - if (newref) { Py_DECREF(obj); } -#endif - -#ifdef SWIG_COBJECT_TYPES -cobject: -#endif - - if (ty) { - tc = SWIG_TypeCheck(c,ty); - if (!tc) goto type_error; - *ptr = SWIG_TypeCast(tc,(void*) *ptr); - } - - if ((pyobj) && (flags & SWIG_POINTER_DISOWN)) { - PyObject *zero = PyInt_FromLong(0); - PyObject_SetAttrString(pyobj,(char*)"thisown",zero); - Py_DECREF(zero); - } - return 0; - -type_error: - PyErr_Clear(); - if (flags & SWIG_POINTER_EXCEPTION) { - if (ty && c) { - PyErr_Format(PyExc_TypeError, - "Type error. Got %s, expected %s", - c, ty->name); - } else { - PyErr_SetString(PyExc_TypeError,"Expected a pointer"); - } - } - return -1; -} - -/* Convert a pointer value, signal an exception on a type mismatch */ -SWIGRUNTIME(void *) -SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int argnum, int flags) { - void *result; - SWIG_Python_ConvertPtr(obj, &result, ty, flags | SWIG_POINTER_EXCEPTION); - return result; -} - -/* Create a new pointer object */ -SWIGRUNTIME(PyObject *) -SWIG_Python_NewPointerObj(void *ptr, swig_type_info *type, int own) { - PyObject *robj; - if (!ptr) { - Py_INCREF(Py_None); - return Py_None; - } -#ifdef SWIG_COBJECT_TYPES - robj = PyCObject_FromVoidPtrAndDesc((void *) ptr, (char *) type->name, NULL); -#else - { - char result[1024]; - char *r = result; - *(r++) = '_'; - r = SWIG_PackData(r,&ptr,sizeof(void *)); - strcpy(r,type->name); - robj = PyString_FromString(result); - } -#endif - if (!robj || (robj == Py_None)) return robj; - if (type->clientdata) { - PyObject *inst; - PyObject *args = Py_BuildValue((char*)"(O)", robj); - Py_DECREF(robj); - inst = PyObject_CallObject((PyObject *) type->clientdata, args); - Py_DECREF(args); - if (inst) { - if (own) { - PyObject *n = PyInt_FromLong(1); - PyObject_SetAttrString(inst,(char*)"thisown",n); - Py_DECREF(n); - } - robj = inst; - } - } - return robj; -} - -#endif - -#ifdef __cplusplus -} -#endif - -""" - - -###################################################################### -# This is for SWIG-1.3.x where x >= 23. -# SWIG_RUNTIME_VERSION == "1" - -# All this does is to include (cut/paste): -# and -swigptr2_code_v1 = """ -/*********************************************************************** - * swigrun.swg - * - * This file contains generic CAPI SWIG runtime support for pointer - * type checking. - * - ************************************************************************/ - -/* This should only be incremented when either the layout of swig_type_info changes, - or for whatever reason, the runtime changes incompatibly */ -#define SWIG_RUNTIME_VERSION "1" - -/* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */ -#ifdef SWIG_TYPE_TABLE -#define SWIG_QUOTE_STRING(x) #x -#define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x) -#define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE) -#else -#define SWIG_TYPE_TABLE_NAME -#endif - -#include - -#ifndef SWIGINLINE -#if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) -# define SWIGINLINE inline -#else -# define SWIGINLINE -#endif -#endif - -/* - You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for - creating a static or dynamic library from the swig runtime code. - In 99.9% of the cases, swig just needs to declare them as 'static'. - - But only do this if is strictly necessary, ie, if you have problems - with your compiler or so. -*/ -#ifndef SWIGRUNTIME -#define SWIGRUNTIME static -#endif -#ifndef SWIGRUNTIMEINLINE -#define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -typedef void *(*swig_converter_func)(void *); -typedef struct swig_type_info *(*swig_dycast_func)(void **); - -typedef struct swig_type_info { - const char *name; - swig_converter_func converter; - const char *str; - void *clientdata; - swig_dycast_func dcast; - struct swig_type_info *next; - struct swig_type_info *prev; -} swig_type_info; - -/* - Compare two type names skipping the space characters, therefore - "char*" == "char *" and "Class" == "Class", etc. - - Return 0 when the two name types are equivalent, as in - strncmp, but skipping ' '. -*/ -SWIGRUNTIME int -SWIG_TypeNameComp(const char *f1, const char *l1, - const char *f2, const char *l2) { - for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) { - while ((*f1 == ' ') && (f1 != l1)) ++f1; - while ((*f2 == ' ') && (f2 != l2)) ++f2; - if (*f1 != *f2) return *f1 - *f2; - } - return (l1 - f1) - (l2 - f2); -} - -/* - Check type equivalence in a name list like ||... -*/ -SWIGRUNTIME int -SWIG_TypeEquiv(const char *nb, const char *tb) { - int equiv = 0; - const char* te = tb + strlen(tb); - const char* ne = nb; - while (!equiv && *ne) { - for (nb = ne; *ne; ++ne) { - if (*ne == '|') break; - } - equiv = SWIG_TypeNameComp(nb, ne, tb, te) == 0; - if (*ne) ++ne; - } - return equiv; -} - -/* - Register a type mapping with the type-checking -*/ -SWIGRUNTIME swig_type_info * -SWIG_TypeRegisterTL(swig_type_info **tl, swig_type_info *ti) { - swig_type_info *tc, *head, *ret, *next; - /* Check to see if this type has already been registered */ - tc = *tl; - while (tc) { - /* check simple type equivalence */ - int typeequiv = (strcmp(tc->name, ti->name) == 0); - /* check full type equivalence, resolving typedefs */ - if (!typeequiv) { - /* only if tc is not a typedef (no '|' on it) */ - if (tc->str && ti->str && !strstr(tc->str,"|")) { - typeequiv = SWIG_TypeEquiv(ti->str,tc->str); - } - } - if (typeequiv) { - /* Already exists in the table. Just add additional types to the list */ - if (ti->clientdata) tc->clientdata = ti->clientdata; - head = tc; - next = tc->next; - goto l1; - } - tc = tc->prev; - } - head = ti; - next = 0; - - /* Place in list */ - ti->prev = *tl; - *tl = ti; - - /* Build linked lists */ - l1: - ret = head; - tc = ti + 1; - /* Patch up the rest of the links */ - while (tc->name) { - head->next = tc; - tc->prev = head; - head = tc; - tc++; - } - if (next) next->prev = head; - head->next = next; - - return ret; -} - -/* - Check the typename -*/ -SWIGRUNTIME swig_type_info * -SWIG_TypeCheck(const char *c, swig_type_info *ty) { - swig_type_info *s; - if (!ty) return 0; /* Void pointer */ - s = ty->next; /* First element always just a name */ - do { - if (strcmp(s->name,c) == 0) { - if (s == ty->next) return s; - /* Move s to the top of the linked list */ - s->prev->next = s->next; - if (s->next) { - s->next->prev = s->prev; - } - /* Insert s as second element in the list */ - s->next = ty->next; - if (ty->next) ty->next->prev = s; - ty->next = s; - s->prev = ty; - return s; - } - s = s->next; - } while (s && (s != ty->next)); - return 0; -} - -/* - Cast a pointer up an inheritance hierarchy -*/ -SWIGRUNTIMEINLINE void * -SWIG_TypeCast(swig_type_info *ty, void *ptr) { - return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr); -} - -/* - Dynamic pointer casting. Down an inheritance hierarchy -*/ -SWIGRUNTIME swig_type_info * -SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) { - swig_type_info *lastty = ty; - if (!ty || !ty->dcast) return ty; - while (ty && (ty->dcast)) { - ty = (*ty->dcast)(ptr); - if (ty) lastty = ty; - } - return lastty; -} - -/* - Return the name associated with this type -*/ -SWIGRUNTIMEINLINE const char * -SWIG_TypeName(const swig_type_info *ty) { - return ty->name; -} - -/* - Return the pretty name associated with this type, - that is an unmangled type name in a form presentable to the user. -*/ -SWIGRUNTIME const char * -SWIG_TypePrettyName(const swig_type_info *type) { - /* The "str" field contains the equivalent pretty names of the - type, separated by vertical-bar characters. We choose - to print the last name, as it is often (?) the most - specific. */ - if (type->str != NULL) { - const char *last_name = type->str; - const char *s; - for (s = type->str; *s; s++) - if (*s == '|') last_name = s+1; - return last_name; - } - else - return type->name; -} - -/* - Search for a swig_type_info structure -*/ -SWIGRUNTIME swig_type_info * -SWIG_TypeQueryTL(swig_type_info *tl, const char *name) { - swig_type_info *ty = tl; - while (ty) { - if (ty->str && (SWIG_TypeEquiv(ty->str,name))) return ty; - if (ty->name && (strcmp(name,ty->name) == 0)) return ty; - ty = ty->prev; - } - return 0; -} - -/* - Set the clientdata field for a type -*/ -SWIGRUNTIME void -SWIG_TypeClientDataTL(swig_type_info *tl, swig_type_info *ti, void *clientdata) { - swig_type_info *tc, *equiv; - if (ti->clientdata) return; - /* if (ti->clientdata == clientdata) return; */ - ti->clientdata = clientdata; - equiv = ti->next; - while (equiv) { - if (!equiv->converter) { - tc = tl; - while (tc) { - if ((strcmp(tc->name, equiv->name) == 0)) - SWIG_TypeClientDataTL(tl,tc,clientdata); - tc = tc->prev; - } - } - equiv = equiv->next; - } -} - -/* - Pack binary data into a string -*/ -SWIGRUNTIME char * -SWIG_PackData(char *c, void *ptr, size_t sz) { - static char hex[17] = "0123456789abcdef"; - unsigned char *u = (unsigned char *) ptr; - const unsigned char *eu = u + sz; - register unsigned char uu; - for (; u != eu; ++u) { - uu = *u; - *(c++) = hex[(uu & 0xf0) >> 4]; - *(c++) = hex[uu & 0xf]; - } - return c; -} - -/* - Unpack binary data from a string -*/ -SWIGRUNTIME const char * -SWIG_UnpackData(const char *c, void *ptr, size_t sz) { - register unsigned char *u = (unsigned char *) ptr; - register const unsigned char *eu = u + sz; - for (; u != eu; ++u) { - register int d = *(c++); - register unsigned char uu = 0; - if ((d >= '0') && (d <= '9')) - uu = ((d - '0') << 4); - else if ((d >= 'a') && (d <= 'f')) - uu = ((d - ('a'-10)) << 4); - else - return (char *) 0; - d = *(c++); - if ((d >= '0') && (d <= '9')) - uu |= (d - '0'); - else if ((d >= 'a') && (d <= 'f')) - uu |= (d - ('a'-10)); - else - return (char *) 0; - *u = uu; - } - return c; -} - -/* - This function will propagate the clientdata field of type to any new - swig_type_info structures that have been added into the list of - equivalent types. It is like calling SWIG_TypeClientData(type, - clientdata) a second time. -*/ -SWIGRUNTIME void -SWIG_PropagateClientDataTL(swig_type_info *tl, swig_type_info *type) { - swig_type_info *equiv = type->next; - swig_type_info *tc; - if (!type->clientdata) return; - while (equiv) { - if (!equiv->converter) { - tc = tl; - while (tc) { - if ((strcmp(tc->name, equiv->name) == 0) && !tc->clientdata) - SWIG_TypeClientDataTL(tl,tc, type->clientdata); - tc = tc->prev; - } - } - equiv = equiv->next; - } -} - -/* - Pack 'void *' into a string buffer. -*/ -SWIGRUNTIME char * -SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) { - char *r = buff; - if ((2*sizeof(void *) + 2) > bsz) return 0; - *(r++) = '_'; - r = SWIG_PackData(r,&ptr,sizeof(void *)); - if (strlen(name) + 1 > (bsz - (r - buff))) return 0; - strcpy(r,name); - return buff; -} - -SWIGRUNTIME const char * -SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) { - if (*c != '_') { - if (strcmp(c,"NULL") == 0) { - *ptr = (void *) 0; - return name; - } else { - return 0; - } - } - return SWIG_UnpackData(++c,ptr,sizeof(void *)); -} - -SWIGRUNTIME char * -SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) { - char *r = buff; - size_t lname = (name ? strlen(name) : 0); - if ((2*sz + 2 + lname) > bsz) return 0; - *(r++) = '_'; - r = SWIG_PackData(r,ptr,sz); - if (lname) { - strncpy(r,name,lname+1); - } else { - *r = 0; - } - return buff; -} - -SWIGRUNTIME const char * -SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) { - if (*c != '_') { - if (strcmp(c,"NULL") == 0) { - memset(ptr,0,sz); - return name; - } else { - return 0; - } - } - return SWIG_UnpackData(++c,ptr,sz); -} - -#ifdef __cplusplus -} -#endif - -/*********************************************************************** - * pyrun.swg - * - * This file contains the runtime support for Python modules - * and includes code for managing global variables and pointer - * type checking. - * - * Author : David Beazley (beazley@cs.uchicago.edu) - ************************************************************************/ - -/* Common SWIG API */ -#define SWIG_ConvertPtr(obj, pp, type, flags) SWIG_Python_ConvertPtr(obj, pp, type, flags) -#define SWIG_NewPointerObj(p, type, flags) SWIG_Python_NewPointerObj(p, type, flags) -#define SWIG_MustGetPtr(p, type, argnum, flags) SWIG_Python_MustGetPtr(p, type, argnum, flags) - - -/* Python-specific SWIG API */ -#define SWIG_ConvertPacked(obj, ptr, sz, ty, flags) SWIG_Python_ConvertPacked(obj, ptr, sz, ty, flags) -#define SWIG_NewPackedObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type) - - -/* ----------------------------------------------------------------------------- - * Pointer declarations - * ----------------------------------------------------------------------------- */ -/* - Use SWIG_NO_COBJECT_TYPES to force the use of strings to represent - C/C++ pointers in the python side. Very useful for debugging, but - not always safe. -*/ -#if !defined(SWIG_NO_COBJECT_TYPES) && !defined(SWIG_COBJECT_TYPES) -# define SWIG_COBJECT_TYPES -#endif - -/* Flags for pointer conversion */ -#define SWIG_POINTER_EXCEPTION 0x1 -#define SWIG_POINTER_DISOWN 0x2 - - -#ifdef __cplusplus -extern "C" { -#endif - -/* ----------------------------------------------------------------------------- - * Create a new pointer string - * ----------------------------------------------------------------------------- */ - -#ifndef SWIG_BUFFER_SIZE -#define SWIG_BUFFER_SIZE 1024 -#endif - -#if defined(SWIG_COBJECT_TYPES) -#if !defined(SWIG_COBJECT_PYTHON) -/* ----------------------------------------------------------------------------- - * Implements a simple Swig Object type, and use it instead of PyCObject - * ----------------------------------------------------------------------------- */ - -typedef struct { - PyObject_HEAD - void *ptr; - const char *desc; -} PySwigObject; - -/* Declarations for objects of type PySwigObject */ - -SWIGRUNTIME int -PySwigObject_print(PySwigObject *v, FILE *fp, int flags) -{ - char result[SWIG_BUFFER_SIZE]; - if (SWIG_PackVoidPtr(result, v->ptr, v->desc, sizeof(result))) { - fputs("", fp); - return 0; - } else { - return 1; - } -} - -SWIGRUNTIME PyObject * -PySwigObject_repr(PySwigObject *v) -{ - char result[SWIG_BUFFER_SIZE]; - return SWIG_PackVoidPtr(result, v->ptr, v->desc, sizeof(result)) ? - PyString_FromFormat("", result) : 0; -} - -SWIGRUNTIME PyObject * -PySwigObject_str(PySwigObject *v) -{ - char result[SWIG_BUFFER_SIZE]; - return SWIG_PackVoidPtr(result, v->ptr, v->desc, sizeof(result)) ? - PyString_FromString(result) : 0; -} - -SWIGRUNTIME PyObject * -PySwigObject_long(PySwigObject *v) -{ - return PyLong_FromUnsignedLong((unsigned long) v->ptr); -} - -SWIGRUNTIME PyObject * -PySwigObject_oct(PySwigObject *v) -{ - char buf[100]; - unsigned long x = (unsigned long)v->ptr; - if (x == 0) - strcpy(buf, "0"); - else - PyOS_snprintf(buf, sizeof(buf), "0%lo", x); - return PyString_FromString(buf); -} - -SWIGRUNTIME PyObject * -PySwigObject_hex(PySwigObject *v) -{ - char buf[100]; - PyOS_snprintf(buf, sizeof(buf), "0x%lx", (unsigned long)v->ptr); - return PyString_FromString(buf); -} - -SWIGRUNTIME int -PySwigObject_compare(PySwigObject *v, PySwigObject *w) -{ - int c = strcmp(v->desc, w->desc); - if (c) { - return c; - } else { - void *i = v->ptr; - void *j = w->ptr; - return (i < j) ? -1 : (i > j) ? 1 : 0; - } -} - -SWIGRUNTIME void -PySwigObject_dealloc(PySwigObject *self) -{ - PyObject_DEL(self); -} - -SWIGRUNTIME PyTypeObject* -PySwigObject_GetType() { - static char PySwigObject_Type__doc__[] = - "Swig object carries a C/C++ instance pointer"; - - static PyNumberMethods PySwigObject_as_number = { - (binaryfunc)0, /*nb_add*/ - (binaryfunc)0, /*nb_subtract*/ - (binaryfunc)0, /*nb_multiply*/ - (binaryfunc)0, /*nb_divide*/ - (binaryfunc)0, /*nb_remainder*/ - (binaryfunc)0, /*nb_divmod*/ - (ternaryfunc)0,/*nb_power*/ - (unaryfunc)0, /*nb_negative*/ - (unaryfunc)0, /*nb_positive*/ - (unaryfunc)0, /*nb_absolute*/ - (inquiry)0, /*nb_nonzero*/ - 0, /*nb_invert*/ - 0, /*nb_lshift*/ - 0, /*nb_rshift*/ - 0, /*nb_and*/ - 0, /*nb_xor*/ - 0, /*nb_or*/ - (coercion)0, /*nb_coerce*/ - (unaryfunc)PySwigObject_long, /*nb_int*/ - (unaryfunc)PySwigObject_long, /*nb_long*/ - (unaryfunc)0, /*nb_float*/ - (unaryfunc)PySwigObject_oct, /*nb_oct*/ - (unaryfunc)PySwigObject_hex, /*nb_hex*/ -#if PY_VERSION_HEX >= 0x02000000 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_true_divide */ -#endif - }; - - static PyTypeObject PySwigObject_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, /*ob_size*/ - "PySwigObject", /*tp_name*/ - sizeof(PySwigObject), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor)PySwigObject_dealloc, /*tp_dealloc*/ - (printfunc)PySwigObject_print, /*tp_print*/ - (getattrfunc)0, /*tp_getattr*/ - (setattrfunc)0, /*tp_setattr*/ - (cmpfunc)PySwigObject_compare, /*tp_compare*/ - (reprfunc)PySwigObject_repr, /*tp_repr*/ - &PySwigObject_as_number, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - (hashfunc)0, /*tp_hash*/ - (ternaryfunc)0, /*tp_call*/ - (reprfunc)PySwigObject_str, /*tp_str*/ - /* Space for future expansion */ - 0L,0L,0L,0L, - PySwigObject_Type__doc__, /* Documentation string */ -#if PY_VERSION_HEX >= 0x02000000 - 0, /* tp_traverse */ - 0, /* tp_clear */ -#endif -#if PY_VERSION_HEX >= 0x02010000 - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ -#endif -#if PY_VERSION_HEX >= 0x02020000 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* tp_iter -> tp_weaklist */ -#endif -#if PY_VERSION_HEX >= 0x02030000 - 0, /* tp_del */ -#endif -#ifdef COUNT_ALLOCS - 0,0,0,0 /* tp_alloc -> tp_next */ -#endif - }; - - return &PySwigObject_Type; -} - -SWIGRUNTIME PyObject * -PySwigObject_FromVoidPtrAndDesc(void *ptr, const char *desc) -{ - PySwigObject *self = PyObject_NEW(PySwigObject, PySwigObject_GetType()); - if (self == NULL) return NULL; - self->ptr = ptr; - self->desc = desc; - return (PyObject *)self; -} - -SWIGRUNTIMEINLINE void * -PySwigObject_AsVoidPtr(PyObject *self) -{ - return ((PySwigObject *)self)->ptr; -} - -SWIGRUNTIMEINLINE const char * -PySwigObject_GetDesc(PyObject *self) -{ - return ((PySwigObject *)self)->desc; -} - -SWIGRUNTIMEINLINE int -PySwigObject_Check(PyObject *op) { - return ((op)->ob_type == PySwigObject_GetType()) - || (strcmp((op)->ob_type->tp_name,"PySwigObject") == 0); -} - -/* ----------------------------------------------------------------------------- - * Implements a simple Swig Packed type, and use it instead of string - * ----------------------------------------------------------------------------- */ - -typedef struct { - PyObject_HEAD - void *pack; - const char *desc; - size_t size; -} PySwigPacked; - -SWIGRUNTIME int -PySwigPacked_print(PySwigPacked *v, FILE *fp, int flags) -{ - char result[SWIG_BUFFER_SIZE]; - fputs("pack, v->size, 0, sizeof(result))) { - fputs("at ", fp); - fputs(result, fp); - } - fputs(v->desc,fp); - fputs(">", fp); - return 0; -} - -SWIGRUNTIME PyObject * -PySwigPacked_repr(PySwigPacked *v) -{ - char result[SWIG_BUFFER_SIZE]; - if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) { - return PyString_FromFormat("", result, v->desc); - } else { - return PyString_FromFormat("", v->desc); - } -} - -SWIGRUNTIME PyObject * -PySwigPacked_str(PySwigPacked *v) -{ - char result[SWIG_BUFFER_SIZE]; - if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))){ - return PyString_FromFormat("%s%s", result, v->desc); - } else { - return PyString_FromFormat("%s", v->desc); - } -} - -SWIGRUNTIME int -PySwigPacked_compare(PySwigPacked *v, PySwigPacked *w) -{ - int c = strcmp(v->desc, w->desc); - if (c) { - return c; - } else { - size_t i = v->size; - size_t j = w->size; - int s = (i < j) ? -1 : (i > j) ? 1 : 0; - return s ? s : strncmp((char *)v->pack, (char *)w->pack, 2*v->size); - } -} - -SWIGRUNTIME void -PySwigPacked_dealloc(PySwigPacked *self) -{ - free(self->pack); - PyObject_DEL(self); -} - -SWIGRUNTIME PyTypeObject* -PySwigPacked_GetType() { - static char PySwigPacked_Type__doc__[] = - "Swig object carries a C/C++ instance pointer"; - - static PyTypeObject PySwigPacked_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, /*ob_size*/ - "PySwigPacked", /*tp_name*/ - sizeof(PySwigPacked), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor)PySwigPacked_dealloc, /*tp_dealloc*/ - (printfunc)PySwigPacked_print, /*tp_print*/ - (getattrfunc)0, /*tp_getattr*/ - (setattrfunc)0, /*tp_setattr*/ - (cmpfunc)PySwigPacked_compare, /*tp_compare*/ - (reprfunc)PySwigPacked_repr, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - (hashfunc)0, /*tp_hash*/ - (ternaryfunc)0, /*tp_call*/ - (reprfunc)PySwigPacked_str, /*tp_str*/ - /* Space for future expansion */ - 0L,0L,0L,0L, - PySwigPacked_Type__doc__, /* Documentation string */ -#if PY_VERSION_HEX >= 0x02000000 - 0, /* tp_traverse */ - 0, /* tp_clear */ -#endif -#if PY_VERSION_HEX >= 0x02010000 - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ -#endif -#if PY_VERSION_HEX >= 0x02020000 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* tp_iter -> tp_weaklist */ -#endif -#if PY_VERSION_HEX >= 0x02030000 - 0, /* tp_del */ -#endif -#ifdef COUNT_ALLOCS - 0,0,0,0 /* tp_alloc -> tp_next */ -#endif - }; - - return &PySwigPacked_Type; -} - -SWIGRUNTIME PyObject * -PySwigPacked_FromDataAndDesc(void *ptr, size_t size, const char *desc) -{ - PySwigPacked *self = PyObject_NEW(PySwigPacked, PySwigPacked_GetType()); - if (self == NULL) { - return NULL; - } else { - void *pack = malloc(size); - memcpy(pack, ptr, size); - self->pack = pack; - self->desc = desc; - self->size = size; - return (PyObject *) self; - } -} - -SWIGRUNTIMEINLINE const char * -PySwigPacked_UnpackData(PyObject *obj, void *ptr, size_t size) -{ - PySwigPacked *self = (PySwigPacked *)obj; - if (self->size != size) return 0; - memcpy(ptr, self->pack, size); - return self->desc; -} - -SWIGRUNTIMEINLINE const char * -PySwigPacked_GetDesc(PyObject *self) -{ - return ((PySwigPacked *)self)->desc; -} - -SWIGRUNTIMEINLINE int -PySwigPacked_Check(PyObject *op) { - return ((op)->ob_type == PySwigPacked_GetType()) - || (strcmp((op)->ob_type->tp_name,"PySwigPacked") == 0); -} - -#else -/* ----------------------------------------------------------------------------- - * Use the old Python PyCObject instead of PySwigObject - * ----------------------------------------------------------------------------- */ - -#define PySwigObject_GetDesc(obj) PyCObject_GetDesc(obj) -#define PySwigObject_Check(obj) PyCObject_Check(obj) -#define PySwigObject_AsVoidPtr(obj) PyCObject_AsVoidPtr(obj) -#define PySwigObject_FromVoidPtrAndDesc(p, d) PyCObject_FromVoidPtrAndDesc(p, d, NULL) - -#endif - -#endif - -/* ----------------------------------------------------------------------------- - * errors manipulation - * ----------------------------------------------------------------------------- */ - -SWIGRUNTIME void -SWIG_Python_TypeError(const char *type, PyObject *obj) -{ - if (type) { -#if defined(SWIG_COBJECT_TYPES) - if (PySwigObject_Check(obj)) { - const char *otype = (const char *) PySwigObject_GetDesc(obj); - if (otype) { - PyErr_Format(PyExc_TypeError, "a '%s' is expected, 'PySwigObject(%s)' is received", - type, otype); - return; - } - } else -#endif - { - const char *otype = (obj ? obj->ob_type->tp_name : 0); - if (otype) { - PyObject *str = PyObject_Str(obj); - const char *cstr = str ? PyString_AsString(str) : 0; - if (cstr) { - PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s(%s)' is received", - type, otype, cstr); - } else { - PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s' is received", - type, otype); - } - Py_DECREF(str); - return; - } - } - PyErr_Format(PyExc_TypeError, "a '%s' is expected", type); - } else { - PyErr_Format(PyExc_TypeError, "unexpected type is received"); - } -} - -SWIGRUNTIMEINLINE void -SWIG_Python_NullRef(const char *type) -{ - if (type) { - PyErr_Format(PyExc_TypeError, "null reference of type '%s' was received",type); - } else { - PyErr_Format(PyExc_TypeError, "null reference was received"); - } -} - -SWIGRUNTIME int -SWIG_Python_AddErrMesg(const char* mesg, int infront) -{ - if (PyErr_Occurred()) { - PyObject *type = 0; - PyObject *value = 0; - PyObject *traceback = 0; - PyErr_Fetch(&type, &value, &traceback); - if (value) { - PyObject *old_str = PyObject_Str(value); - Py_XINCREF(type); - PyErr_Clear(); - if (infront) { - PyErr_Format(type, "%s %s", mesg, PyString_AsString(old_str)); - } else { - PyErr_Format(type, "%s %s", PyString_AsString(old_str), mesg); - } - Py_DECREF(old_str); - } - return 1; - } else { - return 0; - } -} - -SWIGRUNTIME int -SWIG_Python_ArgFail(int argnum) -{ - if (PyErr_Occurred()) { - /* add information about failing argument */ - char mesg[256]; - sprintf(mesg, "argument number %d:", argnum); - return SWIG_Python_AddErrMesg(mesg, 1); - } else { - return 0; - } -} - - -/* ----------------------------------------------------------------------------- - * pointers/data manipulation - * ----------------------------------------------------------------------------- */ - -/* Convert a pointer value */ -SWIGRUNTIME int -SWIG_Python_ConvertPtr(PyObject *obj, void **ptr, swig_type_info *ty, int flags) { - swig_type_info *tc; - const char *c = 0; - static PyObject *SWIG_this = 0; - int newref = 0; - PyObject *pyobj = 0; - void *vptr; - - if (!obj) return 0; - if (obj == Py_None) { - *ptr = 0; - return 0; - } - -#ifdef SWIG_COBJECT_TYPES - if (!(PySwigObject_Check(obj))) { - if (!SWIG_this) - SWIG_this = PyString_FromString("this"); - pyobj = obj; - obj = PyObject_GetAttr(obj,SWIG_this); - newref = 1; - if (!obj) goto type_error; - if (!PySwigObject_Check(obj)) { - Py_DECREF(obj); - goto type_error; - } - } - vptr = PySwigObject_AsVoidPtr(obj); - c = (const char *) PySwigObject_GetDesc(obj); - if (newref) { Py_DECREF(obj); } - goto type_check; -#else - if (!(PyString_Check(obj))) { - if (!SWIG_this) - SWIG_this = PyString_FromString("this"); - pyobj = obj; - obj = PyObject_GetAttr(obj,SWIG_this); - newref = 1; - if (!obj) goto type_error; - if (!PyString_Check(obj)) { - Py_DECREF(obj); - goto type_error; - } - } - c = PyString_AS_STRING(obj); - /* Pointer values must start with leading underscore */ - c = SWIG_UnpackVoidPtr(c, &vptr, ty->name); - if (newref) { Py_DECREF(obj); } - if (!c) goto type_error; -#endif - -type_check: - - if (ty) { - tc = SWIG_TypeCheck(c,ty); - if (!tc) goto type_error; - *ptr = SWIG_TypeCast(tc,vptr); - } - - if ((pyobj) && (flags & SWIG_POINTER_DISOWN)) { - PyObject_SetAttrString(pyobj,(char*)"thisown",Py_False); - } - return 0; - -type_error: - PyErr_Clear(); - if (pyobj && !obj) { - obj = pyobj; - if (PyCFunction_Check(obj)) { - /* here we get the method pointer for callbacks */ - char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc); - c = doc ? strstr(doc, "swig_ptr: ") : 0; - if (c) { - c = SWIG_UnpackVoidPtr(c + 10, &vptr, ty->name); - if (!c) goto type_error; - goto type_check; - } - } - } - if (flags & SWIG_POINTER_EXCEPTION) { - if (ty) { - SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj); - } else { - SWIG_Python_TypeError("C/C++ pointer", obj); - } - } - return -1; -} - -/* Convert a pointer value, signal an exception on a type mismatch */ -SWIGRUNTIME void * -SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int argnum, int flags) { - void *result; - if (SWIG_Python_ConvertPtr(obj, &result, ty, flags) == -1) { - PyErr_Clear(); - if (flags & SWIG_POINTER_EXCEPTION) { - SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj); - SWIG_Python_ArgFail(argnum); - } - } - return result; -} - -/* Convert a packed value value */ -SWIGRUNTIME int -SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *ty, int flags) { - swig_type_info *tc; - const char *c = 0; - -#if defined(SWIG_COBJECT_TYPES) && !defined(SWIG_COBJECT_PYTHON) - c = PySwigPacked_UnpackData(obj, ptr, sz); -#else - if ((!obj) || (!PyString_Check(obj))) goto type_error; - c = PyString_AS_STRING(obj); - /* Pointer values must start with leading underscore */ - c = SWIG_UnpackDataName(c, ptr, sz, ty->name); -#endif - if (!c) goto type_error; - if (ty) { - tc = SWIG_TypeCheck(c,ty); - if (!tc) goto type_error; - } - return 0; - -type_error: - PyErr_Clear(); - if (flags & SWIG_POINTER_EXCEPTION) { - if (ty) { - SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj); - } else { - SWIG_Python_TypeError("C/C++ packed data", obj); - } - } - return -1; -} - -/* Create a new array object */ -SWIGRUNTIME PyObject * -SWIG_Python_NewPointerObj(void *ptr, swig_type_info *type, int own) { - PyObject *robj = 0; - if (!ptr) { - Py_INCREF(Py_None); - return Py_None; - } -#ifdef SWIG_COBJECT_TYPES - robj = PySwigObject_FromVoidPtrAndDesc((void *) ptr, (char *)type->name); -#else - { - char result[SWIG_BUFFER_SIZE]; - robj = SWIG_PackVoidPtr(result, ptr, type->name, sizeof(result)) ? - PyString_FromString(result) : 0; - } -#endif - if (!robj || (robj == Py_None)) return robj; - if (type->clientdata) { - PyObject *inst; - PyObject *args = Py_BuildValue((char*)"(O)", robj); - Py_DECREF(robj); - inst = PyObject_CallObject((PyObject *) type->clientdata, args); - Py_DECREF(args); - if (inst) { - if (own) { - PyObject_SetAttrString(inst,(char*)"thisown",Py_True); - } - robj = inst; - } - } - return robj; -} - -SWIGRUNTIME PyObject * -SWIG_Python_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) { - PyObject *robj = 0; - if (!ptr) { - Py_INCREF(Py_None); - return Py_None; - } -#if defined(SWIG_COBJECT_TYPES) && !defined(SWIG_COBJECT_PYTHON) - robj = PySwigPacked_FromDataAndDesc((void *) ptr, sz, (char *)type->name); -#else - { - char result[SWIG_BUFFER_SIZE]; - robj = SWIG_PackDataName(result, ptr, sz, type->name, sizeof(result)) ? - PyString_FromString(result) : 0; - } -#endif - return robj; -} - -/* -----------------------------------------------------------------------------* - * Get type list - * -----------------------------------------------------------------------------*/ - -#ifdef SWIG_LINK_RUNTIME -void *SWIG_ReturnGlobalTypeList(void *); -#endif - -SWIGRUNTIME swig_type_info ** -SWIG_Python_GetTypeListHandle() { - static void *type_pointer = (void *)0; - /* first check if module already created */ - if (!type_pointer) { -#ifdef SWIG_LINK_RUNTIME - type_pointer = SWIG_ReturnGlobalTypeList((void *)0); -#else - type_pointer = PyCObject_Import((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, - (char*)"type_pointer" SWIG_TYPE_TABLE_NAME); - if (PyErr_Occurred()) { - PyErr_Clear(); - type_pointer = (void *)0; - } - } -#endif - return (swig_type_info **) type_pointer; -} - -/* - Search for a swig_type_info structure - */ -SWIGRUNTIMEINLINE swig_type_info * -SWIG_Python_GetTypeList() { - swig_type_info **tlh = SWIG_Python_GetTypeListHandle(); - return tlh ? *tlh : (swig_type_info*)0; -} - -#define SWIG_Runtime_GetTypeList SWIG_Python_GetTypeList - -#ifdef __cplusplus -} -#endif - -/* -----------------------------------------------------------------------------* - Standard SWIG API for use inside user code. - - You need to include in your code as follow: - -#include // or using your favorite language -#include -#include // or using your favorite language -#include - - * -----------------------------------------------------------------------------*/ - -SWIGRUNTIMEINLINE swig_type_info * -SWIG_Runtime_TypeQuery(const char *name) { - swig_type_info *tl = SWIG_Runtime_GetTypeList(); - return SWIG_TypeQueryTL(tl, name); -} - -SWIGRUNTIMEINLINE swig_type_info * -SWIG_Runtime_TypeRegister(swig_type_info *ti) { - swig_type_info *tl = SWIG_Runtime_GetTypeList(); - return SWIG_TypeRegisterTL(&tl, ti); -} - -SWIGRUNTIMEINLINE void -SWIG_Runtime_TypeClientData(swig_type_info *ti, void *clientdata) { - swig_type_info *tl = SWIG_Runtime_GetTypeList(); - SWIG_TypeClientDataTL(tl, ti, clientdata); -} - -SWIGRUNTIMEINLINE void -SWIG_Runtime_PropagateClientData(swig_type_info *type) { - swig_type_info *tl = SWIG_Runtime_GetTypeList(); - SWIG_PropagateClientDataTL(tl, type); -} - -#define SWIG_GetTypeList() SWIG_Runtime_GetTypeList() -#define SWIG_TypeQuery(name) SWIG_Runtime_TypeQuery(name) -#define SWIG_TypeRegister(ti) SWIG_Runtime_TypeRegister(ti) -#define SWIG_TypeClientData(ti, cd) SWIG_Runtime_TypeClientData(ti, cd) -#define SWIG_PropagateClientData(ti) SWIG_Runtime_PropagateClientData(ti) - -""" - -###################################################################### -# This is for SWIG-1.3.x where x >= 25. -# SWIG_RUNTIME_VERSION == "2" - -# All this does is to include the contents of the file generated by -# this command: -# swig -python -external-runtime -swigptr2_code_v2 = """ -/* ---------------------------------------------------------------------------- - * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.28 - * - * This file is not intended to be easily readable and contains a number of - * coding conventions designed to improve portability and efficiency. Do not make - * changes to this file unless you know what you are doing--modify the SWIG - * interface file instead. - * ----------------------------------------------------------------------------- */ - -/*********************************************************************** - * - * This section contains generic SWIG labels for method/variable - * declarations/attributes, and other compiler dependent labels. - * - ************************************************************************/ - -/* template workaround for compilers that cannot correctly implement the C++ standard */ -#ifndef SWIGTEMPLATEDISAMBIGUATOR -# if defined(__SUNPRO_CC) -# if (__SUNPRO_CC <= 0x560) -# define SWIGTEMPLATEDISAMBIGUATOR template -# else -# define SWIGTEMPLATEDISAMBIGUATOR -# endif -# else -# define SWIGTEMPLATEDISAMBIGUATOR -# endif -#endif - -/* inline attribute */ -#ifndef SWIGINLINE -# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) -# define SWIGINLINE inline -# else -# define SWIGINLINE -# endif -#endif - -/* attribute recognised by some compilers to avoid 'unused' warnings */ -#ifndef SWIGUNUSED -# if defined(__GNUC__) -# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) -# define SWIGUNUSED __attribute__ ((__unused__)) -# else -# define SWIGUNUSED -# endif -# elif defined(__ICC) -# define SWIGUNUSED __attribute__ ((__unused__)) -# else -# define SWIGUNUSED -# endif -#endif - -#ifndef SWIGUNUSEDPARM -# ifdef __cplusplus -# define SWIGUNUSEDPARM(p) -# else -# define SWIGUNUSEDPARM(p) p SWIGUNUSED -# endif -#endif - -/* internal SWIG method */ -#ifndef SWIGINTERN -# define SWIGINTERN static SWIGUNUSED -#endif - -/* internal inline SWIG method */ -#ifndef SWIGINTERNINLINE -# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE -#endif - -/* exporting methods for Windows DLLs */ -#ifndef SWIGEXPORT -# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) -# if defined(STATIC_LINKED) -# define SWIGEXPORT -# else -# define SWIGEXPORT __declspec(dllexport) -# endif -# else -# define SWIGEXPORT -# endif -#endif - -/* calling conventions for Windows */ -#ifndef SWIGSTDCALL -# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) -# define SWIGSTDCALL __stdcall -# else -# define SWIGSTDCALL -# endif -#endif - - -/* Errors in SWIG */ -#define SWIG_UnknownError -1 -#define SWIG_IOError -2 -#define SWIG_RuntimeError -3 -#define SWIG_IndexError -4 -#define SWIG_TypeError -5 -#define SWIG_DivisionByZero -6 -#define SWIG_OverflowError -7 -#define SWIG_SyntaxError -8 -#define SWIG_ValueError -9 -#define SWIG_SystemError -10 -#define SWIG_AttributeError -11 -#define SWIG_MemoryError -12 -#define SWIG_NullReferenceError -13 - - - -/*********************************************************************** - * swigrun.swg - * - * This file contains generic CAPI SWIG runtime support for pointer - * type checking. - * - ************************************************************************/ - -/* This should only be incremented when either the layout of swig_type_info changes, - or for whatever reason, the runtime changes incompatibly */ -#define SWIG_RUNTIME_VERSION "2" - -/* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */ -#ifdef SWIG_TYPE_TABLE -# define SWIG_QUOTE_STRING(x) #x -# define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x) -# define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE) -#else -# define SWIG_TYPE_TABLE_NAME -#endif - -/* - You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for - creating a static or dynamic library from the swig runtime code. - In 99.9% of the cases, swig just needs to declare them as 'static'. - - But only do this if is strictly necessary, ie, if you have problems - with your compiler or so. -*/ - -#ifndef SWIGRUNTIME -# define SWIGRUNTIME SWIGINTERN -#endif - -#ifndef SWIGRUNTIMEINLINE -# define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE -#endif - -/* Generic buffer size */ -#ifndef SWIG_BUFFER_SIZE -# define SWIG_BUFFER_SIZE 1024 -#endif - -/* Flags for pointer conversions */ -#define SWIG_POINTER_DISOWN 0x1 - -/* Flags for new pointer objects */ -#define SWIG_POINTER_OWN 0x1 - - -/* - Flags/methods for returning states. - - The swig conversion methods, as ConvertPtr, return and integer - that tells if the conversion was successful or not. And if not, - an error code can be returned (see swigerrors.swg for the codes). - - Use the following macros/flags to set or process the returning - states. - - In old swig versions, you usually write code as: - - if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) { - // success code - } else { - //fail code - } - - Now you can be more explicit as: - - int res = SWIG_ConvertPtr(obj,vptr,ty.flags); - if (SWIG_IsOK(res)) { - // success code - } else { - // fail code - } - - that seems to be the same, but now you can also do - - Type *ptr; - int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags); - if (SWIG_IsOK(res)) { - // success code - if (SWIG_IsNewObj(res) { - ... - delete *ptr; - } else { - ... - } - } else { - // fail code - } - - I.e., now SWIG_ConvertPtr can return new objects and you can - identify the case and take care of the deallocation. Of course that - requires also to SWIG_ConvertPtr to return new result values, as - - int SWIG_ConvertPtr(obj, ptr,...) { - if () { - if () { - *ptr = ; - return SWIG_NEWOBJ; - } else { - *ptr = ; - return SWIG_OLDOBJ; - } - } else { - return SWIG_BADOBJ; - } - } - - Of course, returning the plain '0(success)/-1(fail)' still works, but you can be - more explicit by returning SWIG_BADOBJ, SWIG_ERROR or any of the - swig errors code. - - Finally, if the SWIG_CASTRANK_MODE is enabled, the result code - allows to return the 'cast rank', for example, if you have this - - int food(double) - int fooi(int); - - and you call - - food(1) // cast rank '1' (1 -> 1.0) - fooi(1) // cast rank '0' - - just use the SWIG_AddCast()/SWIG_CheckState() - - - */ -#define SWIG_OK (0) -#define SWIG_ERROR (-1) -#define SWIG_IsOK(r) (r >= 0) - -/* The CastRankLimit says how many bits are used for the cast rank */ -#define SWIG_CASTRANKLIMIT (1 << 8) -/* The NewMask denotes the object was created (using new/malloc) */ -#define SWIG_NEWOBJMASK (SWIG_CASTRANKLIMIT << 1) -/* The TmpMask is for in/out typemaps that use temporal objects */ -#define SWIG_TMPOBJMASK (SWIG_NEWOBJMASK << 1) -/* Simple returning values */ -#define SWIG_BADOBJ (SWIG_ERROR) -#define SWIG_OLDOBJ (SWIG_OK) -#define SWIG_NEWOBJ (SWIG_OK | SWIG_NEWOBJMASK) -#define SWIG_TMPOBJ (SWIG_OK | SWIG_TMPOBJMASK) -/* Check, add and del mask methods */ -#define SWIG_AddNewMask(r) (SWIG_IsOK(r) ? (r | SWIG_NEWOBJMASK) : r) -#define SWIG_DelNewMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_NEWOBJMASK) : r) -#define SWIG_IsNewObj(r) (SWIG_IsOK(r) && (r & SWIG_NEWOBJMASK)) -#define SWIG_AddTmpMask(r) (SWIG_IsOK(r) ? (r | SWIG_TMPOBJMASK) : r) -#define SWIG_DelTmpMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_TMPOBJMASK) : r) -#define SWIG_IsTmpObj(r) (SWIG_IsOK(r) && (r & SWIG_TMPOBJMASK)) - - -/* Cast-Rank Mode */ -#if defined(SWIG_CASTRANK_MODE) -# ifndef SWIG_TypeRank -# define SWIG_TypeRank unsigned long -# endif -# ifndef SWIG_MAXCASTRANK /* Default cast allowed */ -# define SWIG_MAXCASTRANK (2) -# endif -# define SWIG_CASTRANKMASK ((SWIG_CASTRANKLIMIT) -1) -# define SWIG_CastRank(r) (r & SWIG_CASTRANKMASK) -SWIGINTERNINLINE int SWIG_AddCast(int r) { - return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r; -} -SWIGINTERNINLINE int SWIG_CheckState(int r) { - return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0; -} -#else /* no cast-rank mode */ -# define SWIG_AddCast -# define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0) -#endif - - - - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef void *(*swig_converter_func)(void *); -typedef struct swig_type_info *(*swig_dycast_func)(void **); - -/* Structure to store inforomation on one type */ -typedef struct swig_type_info { - const char *name; /* mangled name of this type */ - const char *str; /* human readable name of this type */ - swig_dycast_func dcast; /* dynamic cast function down a hierarchy */ - struct swig_cast_info *cast; /* linked list of types that can cast into this type */ - void *clientdata; /* language specific type data */ - int owndata; /* flag if the structure owns the clientdata */ -} swig_type_info; - -/* Structure to store a type and conversion function used for casting */ -typedef struct swig_cast_info { - swig_type_info *type; /* pointer to type that is equivalent to this type */ - swig_converter_func converter; /* function to cast the void pointers */ - struct swig_cast_info *next; /* pointer to next cast in linked list */ - struct swig_cast_info *prev; /* pointer to the previous cast */ -} swig_cast_info; - -/* Structure used to store module information - * Each module generates one structure like this, and the runtime collects - * all of these structures and stores them in a circularly linked list.*/ -typedef struct swig_module_info { - swig_type_info **types; /* Array of pointers to swig_type_info structures that are in this module */ - size_t size; /* Number of types in this module */ - struct swig_module_info *next; /* Pointer to next element in circularly linked list */ - swig_type_info **type_initial; /* Array of initially generated type structures */ - swig_cast_info **cast_initial; /* Array of initially generated casting structures */ - void *clientdata; /* Language specific module data */ -} swig_module_info; - -/* - Compare two type names skipping the space characters, therefore - "char*" == "char *" and "Class" == "Class", etc. - - Return 0 when the two name types are equivalent, as in - strncmp, but skipping ' '. -*/ -SWIGRUNTIME int -SWIG_TypeNameComp(const char *f1, const char *l1, - const char *f2, const char *l2) { - for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) { - while ((*f1 == ' ') && (f1 != l1)) ++f1; - while ((*f2 == ' ') && (f2 != l2)) ++f2; - if (*f1 != *f2) return (int)(*f1 - *f2); - } - return (l1 - f1) - (l2 - f2); -} - -/* - Check type equivalence in a name list like ||... - Return 0 if not equal, 1 if equal -*/ -SWIGRUNTIME int -SWIG_TypeEquiv(const char *nb, const char *tb) { - int equiv = 0; - const char* te = tb + strlen(tb); - const char* ne = nb; - while (!equiv && *ne) { - for (nb = ne; *ne; ++ne) { - if (*ne == '|') break; - } - equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; - if (*ne) ++ne; - } - return equiv; -} - -/* - Check type equivalence in a name list like ||... - Return 0 if equal, -1 if nb < tb, 1 if nb > tb -*/ -SWIGRUNTIME int -SWIG_TypeCompare(const char *nb, const char *tb) { - int equiv = 0; - const char* te = tb + strlen(tb); - const char* ne = nb; - while (!equiv && *ne) { - for (nb = ne; *ne; ++ne) { - if (*ne == '|') break; - } - equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; - if (*ne) ++ne; - } - return equiv; -} - - -/* think of this as a c++ template<> or a scheme macro */ -#define SWIG_TypeCheck_Template(comparison, ty) \ - if (ty) { \ - swig_cast_info *iter = ty->cast; \ - while (iter) { \ - if (comparison) { \ - if (iter == ty->cast) return iter; \ - /* Move iter to the top of the linked list */ \ - iter->prev->next = iter->next; \ - if (iter->next) \ - iter->next->prev = iter->prev; \ - iter->next = ty->cast; \ - iter->prev = 0; \ - if (ty->cast) ty->cast->prev = iter; \ - ty->cast = iter; \ - return iter; \ - } \ - iter = iter->next; \ - } \ - } \ - return 0 - -/* - Check the typename -*/ -SWIGRUNTIME swig_cast_info * -SWIG_TypeCheck(const char *c, swig_type_info *ty) { - SWIG_TypeCheck_Template(strcmp(iter->type->name, c) == 0, ty); -} - -/* Same as previous function, except strcmp is replaced with a pointer comparison */ -SWIGRUNTIME swig_cast_info * -SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *into) { - SWIG_TypeCheck_Template(iter->type == from, into); -} - -/* - Cast a pointer up an inheritance hierarchy -*/ -SWIGRUNTIMEINLINE void * -SWIG_TypeCast(swig_cast_info *ty, void *ptr) { - return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr); -} - -/* - Dynamic pointer casting. Down an inheritance hierarchy -*/ -SWIGRUNTIME swig_type_info * -SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) { - swig_type_info *lastty = ty; - if (!ty || !ty->dcast) return ty; - while (ty && (ty->dcast)) { - ty = (*ty->dcast)(ptr); - if (ty) lastty = ty; - } - return lastty; -} - -/* - Return the name associated with this type -*/ -SWIGRUNTIMEINLINE const char * -SWIG_TypeName(const swig_type_info *ty) { - return ty->name; -} - -/* - Return the pretty name associated with this type, - that is an unmangled type name in a form presentable to the user. -*/ -SWIGRUNTIME const char * -SWIG_TypePrettyName(const swig_type_info *type) { - /* The "str" field contains the equivalent pretty names of the - type, separated by vertical-bar characters. We choose - to print the last name, as it is often (?) the most - specific. */ - if (!type) return NULL; - if (type->str != NULL) { - const char *last_name = type->str; - const char *s; - for (s = type->str; *s; s++) - if (*s == '|') last_name = s+1; - return last_name; - } - else - return type->name; -} - -/* - Set the clientdata field for a type -*/ -SWIGRUNTIME void -SWIG_TypeClientData(swig_type_info *ti, void *clientdata) { - swig_cast_info *cast = ti->cast; - /* if (ti->clientdata == clientdata) return; */ - ti->clientdata = clientdata; - - while (cast) { - if (!cast->converter) { - swig_type_info *tc = cast->type; - if (!tc->clientdata) { - SWIG_TypeClientData(tc, clientdata); - } - } - cast = cast->next; - } -} -SWIGRUNTIME void -SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) { - SWIG_TypeClientData(ti, clientdata); - ti->owndata = 1; -} - -/* - Search for a swig_type_info structure only by mangled name - Search is a O(log #types) - - We start searching at module start, and finish searching when start == end. - Note: if start == end at the beginning of the function, we go all the way around - the circular list. -*/ -SWIGRUNTIME swig_type_info * -SWIG_MangledTypeQueryModule(swig_module_info *start, - swig_module_info *end, - const char *name) { - swig_module_info *iter = start; - do { - if (iter->size) { - register size_t l = 0; - register size_t r = iter->size - 1; - do { - /* since l+r >= 0, we can (>> 1) instead (/ 2) */ - register size_t i = (l + r) >> 1; - const char *iname = iter->types[i]->name; - if (iname) { - register int compare = strcmp(name, iname); - if (compare == 0) { - return iter->types[i]; - } else if (compare < 0) { - if (i) { - r = i - 1; - } else { - break; - } - } else if (compare > 0) { - l = i + 1; - } - } else { - break; /* should never happen */ - } - } while (l <= r); - } - iter = iter->next; - } while (iter != end); - return 0; -} - -/* - Search for a swig_type_info structure for either a mangled name or a human readable name. - It first searches the mangled names of the types, which is a O(log #types) - If a type is not found it then searches the human readable names, which is O(#types). - - We start searching at module start, and finish searching when start == end. - Note: if start == end at the beginning of the function, we go all the way around - the circular list. -*/ -SWIGRUNTIME swig_type_info * -SWIG_TypeQueryModule(swig_module_info *start, - swig_module_info *end, - const char *name) { - /* STEP 1: Search the name field using binary search */ - swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name); - if (ret) { - return ret; - } else { - /* STEP 2: If the type hasn't been found, do a complete search - of the str field (the human readable name) */ - swig_module_info *iter = start; - do { - register size_t i = 0; - for (; i < iter->size; ++i) { - if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name))) - return iter->types[i]; - } - iter = iter->next; - } while (iter != end); - } - - /* neither found a match */ - return 0; -} - -/* - Pack binary data into a string -*/ -SWIGRUNTIME char * -SWIG_PackData(char *c, void *ptr, size_t sz) { - static const char hex[17] = "0123456789abcdef"; - register const unsigned char *u = (unsigned char *) ptr; - register const unsigned char *eu = u + sz; - for (; u != eu; ++u) { - register unsigned char uu = *u; - *(c++) = hex[(uu & 0xf0) >> 4]; - *(c++) = hex[uu & 0xf]; - } - return c; -} - -/* - Unpack binary data from a string -*/ -SWIGRUNTIME const char * -SWIG_UnpackData(const char *c, void *ptr, size_t sz) { - register unsigned char *u = (unsigned char *) ptr; - register const unsigned char *eu = u + sz; - for (; u != eu; ++u) { - register char d = *(c++); - register unsigned char uu; - if ((d >= '0') && (d <= '9')) - uu = ((d - '0') << 4); - else if ((d >= 'a') && (d <= 'f')) - uu = ((d - ('a'-10)) << 4); - else - return (char *) 0; - d = *(c++); - if ((d >= '0') && (d <= '9')) - uu |= (d - '0'); - else if ((d >= 'a') && (d <= 'f')) - uu |= (d - ('a'-10)); - else - return (char *) 0; - *u = uu; - } - return c; -} - -/* - Pack 'void *' into a string buffer. -*/ -SWIGRUNTIME char * -SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) { - char *r = buff; - if ((2*sizeof(void *) + 2) > bsz) return 0; - *(r++) = '_'; - r = SWIG_PackData(r,&ptr,sizeof(void *)); - if (strlen(name) + 1 > (bsz - (r - buff))) return 0; - strcpy(r,name); - return buff; -} - -SWIGRUNTIME const char * -SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) { - if (*c != '_') { - if (strcmp(c,"NULL") == 0) { - *ptr = (void *) 0; - return name; - } else { - return 0; - } - } - return SWIG_UnpackData(++c,ptr,sizeof(void *)); -} - -SWIGRUNTIME char * -SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) { - char *r = buff; - size_t lname = (name ? strlen(name) : 0); - if ((2*sz + 2 + lname) > bsz) return 0; - *(r++) = '_'; - r = SWIG_PackData(r,ptr,sz); - if (lname) { - strncpy(r,name,lname+1); - } else { - *r = 0; - } - return buff; -} - -SWIGRUNTIME const char * -SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) { - if (*c != '_') { - if (strcmp(c,"NULL") == 0) { - memset(ptr,0,sz); - return name; - } else { - return 0; - } - } - return SWIG_UnpackData(++c,ptr,sz); -} - -#ifdef __cplusplus -} -#endif - -/*********************************************************************** - * pyrun.swg - * - * This file contains the runtime support for Python modules - * and includes code for managing global variables and pointer - * type checking. - * - * Author : David Beazley (beazley@cs.uchicago.edu) - ************************************************************************/ - -/* Common SWIG API */ - -/* for raw pointers */ -#define SWIG_Python_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, 0) -#define SWIG_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtr(obj, pptr, type, flags) -#define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, own) -#define SWIG_NewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(ptr, type, flags) -#define SWIG_CheckImplicit(ty) SWIG_Python_CheckImplicit(ty) -#define SWIG_AcquirePtr(ptr, src) SWIG_Python_AcquirePtr(ptr, src) -#define swig_owntype int - -/* for raw packed data */ -#define SWIG_ConvertPacked(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty) -#define SWIG_NewPackedObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type) - -/* for class or struct pointers */ -#define SWIG_ConvertInstance(obj, pptr, type, flags) SWIG_ConvertPtr(obj, pptr, type, flags) -#define SWIG_NewInstanceObj(ptr, type, flags) SWIG_NewPointerObj(ptr, type, flags) - -/* for C or C++ function pointers */ -#define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_Python_ConvertFunctionPtr(obj, pptr, type) -#define SWIG_NewFunctionPtrObj(ptr, type) SWIG_Python_NewPointerObj(ptr, type, 0) - -/* for C++ member pointers, ie, member methods */ -#define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty) -#define SWIG_NewMemberObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type) - - -/* Runtime API */ - -#define SWIG_GetModule(clientdata) SWIG_Python_GetModule() -#define SWIG_SetModule(clientdata, pointer) SWIG_Python_SetModule(pointer) -#define SWIG_NewClientData(obj) PySwigClientData_New(obj) - -/* A functor is a function object with one single object argument */ -#if PY_VERSION_HEX >= 0x02020000 -#define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunctionObjArgs(functor, obj, NULL); -#else -#define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunction(functor, "O", obj); -#endif - -/* Error manipulation */ -#define SWIG_SetErrorObj(type, obj) {SWIG_PYTHON_THREAD_BEGIN_BLOCK; PyErr_SetObject(type, obj); SWIG_PYTHON_THREAD_END_BLOCK; } -#define SWIG_SetErrorMsg(type, msg) {SWIG_PYTHON_THREAD_BEGIN_BLOCK; PyErr_SetString(type, msg); SWIG_PYTHON_THREAD_END_BLOCK; } -#define SWIG_ErrorType(code) SWIG_Python_ErrorType(code) -#define SWIG_Error(code, msg) SWIG_SetErrorMsg(SWIG_Python_ErrorType(code), msg) -#define SWIG_fail goto fail - - -/* - Helper for static pointer initialization for both C and C++ code, for example - static PyObject *SWIG_STATIC_POINTER(MyVar) = NewSomething(...); -*/ -#ifdef __cplusplus -#define SWIG_STATIC_POINTER(var) var -#else -#define SWIG_STATIC_POINTER(var) var = 0; if (!var) var -#endif - -/* ----------------------------------------------------------------------------- - * Pointer declarations - * ----------------------------------------------------------------------------- */ - -/* Flags for new pointer objects */ -#define SWIG_POINTER_NOSHADOW (SWIG_POINTER_OWN << 1) -#define SWIG_POINTER_NEW (SWIG_POINTER_NOSHADOW | SWIG_POINTER_OWN) - -#define SWIG_POINTER_IMPLICIT_CONV (SWIG_POINTER_DISOWN << 1) - -/* For backward compatibility only */ -#define SWIG_POINTER_EXCEPTION 0 - -#ifdef __cplusplus -extern "C" { -#if 0 -} /* cc-mode */ -#endif -#endif - -/* Safe Py_None and Py_Void accessors */ - -#if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) -# ifndef SWIG_PYTHON_NO_SAFE_NONE -# ifndef SWIG_PYTHON_SAFE_NONE -# define SWIG_PYTHON_SAFE_NONE -# endif -# endif -#endif - -#ifdef SWIG_PYTHON_SAFE_NONE -SWIGRUNTIMEINLINE PyObject * -_SWIG_Py_None(void) -{ - PyObject *none = Py_BuildValue(""); - Py_DECREF(none); - return none; -} -SWIGRUNTIME PyObject * -SWIG_Py_None(void) -{ - static PyObject *SWIG_STATIC_POINTER(none) = _SWIG_Py_None(); - return none; -} -# ifdef Py_None -# undef Py_None -# define Py_None SWIG_Py_None() -# endif -#endif - -SWIGRUNTIMEINLINE PyObject * -SWIG_Py_Void(void) -{ - PyObject *none = Py_None; - Py_INCREF(none); - return none; -} - -/* Append a value to the result obj */ - -SWIGINTERN PyObject* -SWIG_Python_AppendOutput(PyObject* result, PyObject* obj) { - if (!result) { - result = obj; - } else if (result == Py_None) { - Py_DECREF(result); - result = obj; - } else { - if (!PyList_Check(result)) { - PyObject *o2 = result; - result = PyList_New(1); - PyList_SetItem(result, 0, o2); - } - PyList_Append(result,obj); - Py_DECREF(obj); - } - return result; -} - -SWIGINTERN int -SWIG_Python_UnpackTuple(PyObject *args, const char *name, int min, int max, PyObject **objs) -{ - if (!PyTuple_Check(args)) { - PyErr_SetString(PyExc_SystemError, "UnpackTuple() argument list is not a tuple"); - return 0; - } else { - register int l = PyTuple_GET_SIZE(args); - if (l < min) { - PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", - name, (min == max ? "" : "at least "), min, l); - return 0; - } else if (l > max) { - PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", - name, (min == max ? "" : "at most "), max, l); - return 0; - } else { - register int i; - for (i = 0; i < l; ++i) { - objs[i] = PyTuple_GET_ITEM(args, i); - } - for (; l < max; ++l) { - objs[l] = 0; - } - return i + 1; - } - } -} - -/* PySwigClientData */ - -typedef struct { - PyObject *klass; - PyObject *newraw; - PyObject *newargs; - PyObject *destroy; - int delargs; - int implicitconv; -} PySwigClientData; - -SWIGRUNTIMEINLINE int -SWIG_Python_CheckImplicit(swig_type_info *ty) -{ - PySwigClientData *data = (PySwigClientData *)ty->clientdata; - return data ? data->implicitconv : 0; -} - - -SWIGRUNTIME PySwigClientData * -PySwigClientData_New(PyObject* obj) -{ - if (!obj) { - return 0; - } else { - PySwigClientData *data = (PySwigClientData *)malloc(sizeof(PySwigClientData)); - /* the klass element */ - data->klass = obj; - Py_INCREF(obj); - /* the newraw method and newargs arguments used to create a new raw instance */ - if (PyClass_Check(obj)) { - data->newraw = 0; - data->newargs = obj; - Py_INCREF(obj); - } else { -#if (PY_VERSION_HEX < 0x02020000) - data->newraw = 0; - data->newargs = obj; - Py_INCREF(obj); -#else - data->newraw = PyObject_GetAttrString((PyObject*)&PyBaseObject_Type, "__new__"); - Py_INCREF(data->newraw); - data->newargs = PyTuple_New(1); - PyTuple_SetItem(data->newargs, 0, obj); - Py_INCREF(data->newargs); -#endif - } - /* the destroy method, aka as the C++ delete method */ - data->destroy = PyObject_GetAttrString(data->klass, "__swig_destroy__"); - if (PyErr_Occurred()) { - PyErr_Clear(); - data->destroy = 0; - } - if (data->destroy) { - Py_INCREF(data->destroy); - int flags = PyCFunction_GET_FLAGS(data->destroy); -#ifdef METH_O - data->delargs = !(flags & (METH_O)); -#else - data->delargs = 0; -#endif - } else { - data->delargs = 0; - } - data->implicitconv = 0; - return data; - } -} - -SWIGRUNTIME void -PySwigClientData_Del(PySwigClientData* data) -{ - Py_XDECREF(data->klass); - Py_XDECREF(data->newraw); - Py_XDECREF(data->newargs); - Py_XDECREF(data->destroy); - free(data); -} - -/* =============== PySwigObject =====================*/ - -typedef struct { - PyObject_HEAD - void *ptr; - swig_type_info *ty; - int own; - PyObject *next; -} PySwigObject; - -SWIGRUNTIME PyObject * -PySwigObject_long(PySwigObject *v) -{ - return PyLong_FromVoidPtr(v->ptr); -} - -SWIGRUNTIME PyObject * -PySwigObject_format(const char* fmt, PySwigObject *v) -{ - PyObject *res = NULL; - PyObject *args = PyTuple_New(1); - if (args) { - if (PyTuple_SetItem(args, 0, PySwigObject_long(v)) == 0) { - PyObject *ofmt = PyString_FromString(fmt); - if (ofmt) { - res = PyString_Format(ofmt,args); - Py_DECREF(ofmt); - } - Py_DECREF(args); - } - } - return res; -} - -SWIGRUNTIME PyObject * -PySwigObject_oct(PySwigObject *v) -{ - return PySwigObject_format("%o",v); -} - -SWIGRUNTIME PyObject * -PySwigObject_hex(PySwigObject *v) -{ - return PySwigObject_format("%x",v); -} - -SWIGRUNTIME PyObject * -PySwigObject_repr(PySwigObject *v) -{ - const char *name = SWIG_TypePrettyName(v->ty); - PyObject *hex = PySwigObject_hex(v); - PyObject *repr = PyString_FromFormat("", name, PyString_AsString(hex)); - Py_DECREF(hex); - if (v->next) { - PyObject *nrep = PySwigObject_repr((PySwigObject *)v->next); - PyString_ConcatAndDel(&repr,nrep); - } - return repr; -} - -SWIGRUNTIME int -PySwigObject_print(PySwigObject *v, FILE *fp, int SWIGUNUSEDPARM(flags)) -{ - PyObject *repr = PySwigObject_repr(v); - if (repr) { - fputs(PyString_AsString(repr), fp); - Py_DECREF(repr); - return 0; - } else { - return 1; - } -} - -SWIGRUNTIME PyObject * -PySwigObject_str(PySwigObject *v) -{ - char result[SWIG_BUFFER_SIZE]; - return SWIG_PackVoidPtr(result, v->ptr, v->ty->name, sizeof(result)) ? - PyString_FromString(result) : 0; -} - -SWIGRUNTIME int -PySwigObject_compare(PySwigObject *v, PySwigObject *w) -{ - void *i = v->ptr; - void *j = w->ptr; - return (i < j) ? -1 : ((i > j) ? 1 : 0); -} - -SWIGRUNTIME PyTypeObject* _PySwigObject_type(void); - -SWIGRUNTIME PyTypeObject* -PySwigObject_type(void) { - static PyTypeObject *SWIG_STATIC_POINTER(type) = _PySwigObject_type(); - return type; -} - -SWIGRUNTIMEINLINE int -PySwigObject_Check(PyObject *op) { - return ((op)->ob_type == PySwigObject_type()) - || (strcmp((op)->ob_type->tp_name,"PySwigObject") == 0); -} - - -SWIGRUNTIME PyObject * -PySwigObject_New(void *ptr, swig_type_info *ty, int own); - -SWIGRUNTIME void -PySwigObject_dealloc(PyObject *v) -{ - PySwigObject *sobj = (PySwigObject *) v; - PyObject *next = sobj->next; - if (sobj->own) { - swig_type_info *ty = sobj->ty; - PySwigClientData *data = ty ? (PySwigClientData *) ty->clientdata : 0; - PyObject *destroy = data ? data->destroy : 0; - if (destroy) { - /* destroy is always a VARARGS method */ - PyObject *res; - if (data->delargs) { - /* we need to create a temporal object to carry the destroy operation */ - PyObject *tmp = PySwigObject_New(sobj->ptr, ty, 0); - res = SWIG_Python_CallFunctor(destroy, tmp); - Py_DECREF(tmp); - } else { - PyCFunction meth = PyCFunction_GET_FUNCTION(destroy); - PyObject *mself = PyCFunction_GET_SELF(destroy); - res = ((*meth)(mself, v)); - } - Py_XDECREF(res); - } else { - const char *name = SWIG_TypePrettyName(ty); -#if (PY_VERSION_HEX >= 0x02020000) - PyObject *wrn = PyString_FromFormat("swig/python detected a memory leak of type '%s'.", name); - PyErr_Warn(PyExc_RuntimeWarning, PyString_AsString(wrn)); - Py_DECREF(wrn); -#else - printf("swig/python detected a memory leak of type '%s'.", name); -#endif - } - } - Py_XDECREF(next); - PyObject_DEL(v); -} - -SWIGRUNTIME PyObject* -PySwigObject_append(PyObject* v, PyObject* next) -{ - PySwigObject *sobj = (PySwigObject *) v; -#ifndef METH_O - PyObject *tmp = 0; - if (!PyArg_ParseTuple(next,(char *)"O:append", &tmp)) return NULL; - next = tmp; -#endif - if (!PySwigObject_Check(next)) { - return NULL; - } - sobj->next = next; - Py_INCREF(next); - return SWIG_Py_Void(); -} - -SWIGRUNTIME PyObject* -#ifdef METH_NOARGS -PySwigObject_next(PyObject* v) -#else -PySwigObject_next(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) -#endif -{ - PySwigObject *sobj = (PySwigObject *) v; - if (sobj->next) { - Py_INCREF(sobj->next); - return sobj->next; - } else { - return SWIG_Py_Void(); - } -} - -SWIGINTERN PyObject* -#ifdef METH_NOARGS -PySwigObject_disown(PyObject *v) -#else -PySwigObject_disown(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) -#endif -{ - PySwigObject *sobj = (PySwigObject *)v; - sobj->own = 0; - return SWIG_Py_Void(); -} - -SWIGINTERN PyObject* -#ifdef METH_NOARGS -PySwigObject_acquire(PyObject *v) -#else -PySwigObject_acquire(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) -#endif -{ - PySwigObject *sobj = (PySwigObject *)v; - sobj->own = SWIG_POINTER_OWN; - return SWIG_Py_Void(); -} - -SWIGINTERN PyObject* -PySwigObject_own(PyObject *v, PyObject *args) -{ - PyObject *val = 0; -#if (PY_VERSION_HEX < 0x02020000) - if (!PyArg_ParseTuple(args,(char *)"O:own",&val)) -#else - if (!PyArg_UnpackTuple(args, (char *)"own", 0, 1, &val)) -#endif - { - return NULL; - } - else - { - PySwigObject *sobj = (PySwigObject *)v; - PyObject *obj = sobj->own ? Py_True : Py_False; - if (val) { -#ifdef METH_NOARGS - if (PyObject_IsTrue(val)) { - PySwigObject_acquire(v); - } else { - PySwigObject_disown(v); - } -#else - if (PyObject_IsTrue(val)) { - PySwigObject_acquire(v,args); - } else { - PySwigObject_disown(v,args); - } -#endif - } - Py_INCREF(obj); - return obj; - } -} - -SWIGRUNTIME PyTypeObject* -_PySwigObject_type(void) { - static char swigobject_doc[] = "Swig object carries a C/C++ instance pointer"; - static PyMethodDef -#ifdef METH_O - swigobject_methods[] = { - {"disown", (PyCFunction)PySwigObject_disown, METH_NOARGS, "releases ownership of the pointer"}, - {"acquire", (PyCFunction)PySwigObject_acquire, METH_NOARGS, "aquires ownership of the pointer"}, - {"own", (PyCFunction)PySwigObject_own, METH_VARARGS, "returns/sets ownership of the pointer"}, - {"append", (PyCFunction)PySwigObject_append, METH_O, "appends another 'this' object"}, - {"next", (PyCFunction)PySwigObject_next, METH_NOARGS, "returns the next 'this' object"}, - {0, 0, 0, 0} - }; -#else - swigobject_methods[] = { - {"disown", (PyCFunction)PySwigObject_disown, METH_VARARGS, "releases ownership of the pointer"}, - {"acquire", (PyCFunction)PySwigObject_acquire, METH_VARARGS, "aquires ownership of the pointer"}, - {"own", (PyCFunction)PySwigObject_own, METH_VARARGS, "returns/sets ownership of the pointer"}, - {"append", (PyCFunction)PySwigObject_append, METH_VARARGS, "appends another 'this' object"}, - {"next", (PyCFunction)PySwigObject_next, METH_VARARGS, "returns the next 'this' object"}, - {0, 0, 0, 0} - }; -#endif - - static PyNumberMethods PySwigObject_as_number = { - (binaryfunc)0, /*nb_add*/ - (binaryfunc)0, /*nb_subtract*/ - (binaryfunc)0, /*nb_multiply*/ - (binaryfunc)0, /*nb_divide*/ - (binaryfunc)0, /*nb_remainder*/ - (binaryfunc)0, /*nb_divmod*/ - (ternaryfunc)0,/*nb_power*/ - (unaryfunc)0, /*nb_negative*/ - (unaryfunc)0, /*nb_positive*/ - (unaryfunc)0, /*nb_absolute*/ - (inquiry)0, /*nb_nonzero*/ - 0, /*nb_invert*/ - 0, /*nb_lshift*/ - 0, /*nb_rshift*/ - 0, /*nb_and*/ - 0, /*nb_xor*/ - 0, /*nb_or*/ - (coercion)0, /*nb_coerce*/ - (unaryfunc)PySwigObject_long, /*nb_int*/ - (unaryfunc)PySwigObject_long, /*nb_long*/ - (unaryfunc)0, /*nb_float*/ - (unaryfunc)PySwigObject_oct, /*nb_oct*/ - (unaryfunc)PySwigObject_hex, /*nb_hex*/ -#if PY_VERSION_HEX >= 0x02020000 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_true_divide */ -#elif PY_VERSION_HEX >= 0x02000000 - 0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_or */ -#endif - }; - - static PyTypeObject pyswigobject_type; - static int type_init = 0; - if (!type_init) { - const PyTypeObject tmp - = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ - (char *)"PySwigObject", /* tp_name */ - sizeof(PySwigObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor)PySwigObject_dealloc, /* tp_dealloc */ - (printfunc)PySwigObject_print, /* tp_print */ - (getattrfunc)0, /* tp_getattr */ - (setattrfunc)0, /* tp_setattr */ - (cmpfunc)PySwigObject_compare, /* tp_compare */ - (reprfunc)PySwigObject_repr, /* tp_repr */ - &PySwigObject_as_number, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - (hashfunc)0, /* tp_hash */ - (ternaryfunc)0, /* tp_call */ - (reprfunc)PySwigObject_str, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - swigobject_doc, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ -#if PY_VERSION_HEX >= 0x02020000 - 0, /* tp_iter */ - 0, /* tp_iternext */ - swigobject_methods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - PyObject_Del, /* tp_free */ - 0, /* tp_is_gc */ - 0, /* tp_bases */ - 0, /* tp_mro */ - 0, /* tp_cache */ - 0, /* tp_subclasses */ - 0, /* tp_weaklist */ -#endif -#if PY_VERSION_HEX >= 0x02030000 - 0, /* tp_del */ -#endif -#ifdef COUNT_ALLOCS - 0,0,0,0 /* tp_alloc -> tp_next */ -#endif - }; - pyswigobject_type = tmp; - pyswigobject_type.ob_type = &PyType_Type; - type_init = 1; - } - return &pyswigobject_type; -} - -SWIGRUNTIME PyObject * -PySwigObject_New(void *ptr, swig_type_info *ty, int own) -{ - PySwigObject *sobj = PyObject_NEW(PySwigObject, PySwigObject_type()); - if (sobj) { - sobj->ptr = ptr; - sobj->ty = ty; - sobj->own = own; - sobj->next = 0; - } - return (PyObject *)sobj; -} - -/* ----------------------------------------------------------------------------- - * Implements a simple Swig Packed type, and use it instead of string - * ----------------------------------------------------------------------------- */ - -typedef struct { - PyObject_HEAD - void *pack; - swig_type_info *ty; - size_t size; -} PySwigPacked; - -SWIGRUNTIME int -PySwigPacked_print(PySwigPacked *v, FILE *fp, int SWIGUNUSEDPARM(flags)) -{ - char result[SWIG_BUFFER_SIZE]; - fputs("pack, v->size, 0, sizeof(result))) { - fputs("at ", fp); - fputs(result, fp); - } - fputs(v->ty->name,fp); - fputs(">", fp); - return 0; -} - -SWIGRUNTIME PyObject * -PySwigPacked_repr(PySwigPacked *v) -{ - char result[SWIG_BUFFER_SIZE]; - if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) { - return PyString_FromFormat("", result, v->ty->name); - } else { - return PyString_FromFormat("", v->ty->name); - } -} - -SWIGRUNTIME PyObject * -PySwigPacked_str(PySwigPacked *v) -{ - char result[SWIG_BUFFER_SIZE]; - if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))){ - return PyString_FromFormat("%s%s", result, v->ty->name); - } else { - return PyString_FromString(v->ty->name); - } -} - -SWIGRUNTIME int -PySwigPacked_compare(PySwigPacked *v, PySwigPacked *w) -{ - size_t i = v->size; - size_t j = w->size; - int s = (i < j) ? -1 : ((i > j) ? 1 : 0); - return s ? s : strncmp((char *)v->pack, (char *)w->pack, 2*v->size); -} - -SWIGRUNTIME PyTypeObject* _PySwigPacked_type(void); - -SWIGRUNTIME PyTypeObject* -PySwigPacked_type(void) { - static PyTypeObject *SWIG_STATIC_POINTER(type) = _PySwigPacked_type(); - return type; -} - -SWIGRUNTIMEINLINE int -PySwigPacked_Check(PyObject *op) { - return ((op)->ob_type == _PySwigPacked_type()) - || (strcmp((op)->ob_type->tp_name,"PySwigPacked") == 0); -} - -SWIGRUNTIME void -PySwigPacked_dealloc(PyObject *v) -{ - if (PySwigPacked_Check(v)) { - PySwigPacked *sobj = (PySwigPacked *) v; - free(sobj->pack); - } - PyObject_DEL(v); -} - -SWIGRUNTIME PyTypeObject* -_PySwigPacked_type(void) { - static char swigpacked_doc[] = "Swig object carries a C/C++ instance pointer"; - static PyTypeObject pyswigpacked_type; - static int type_init = 0; - if (!type_init) { - const PyTypeObject tmp - = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ - (char *)"PySwigPacked", /* tp_name */ - sizeof(PySwigPacked), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor)PySwigPacked_dealloc, /* tp_dealloc */ - (printfunc)PySwigPacked_print, /* tp_print */ - (getattrfunc)0, /* tp_getattr */ - (setattrfunc)0, /* tp_setattr */ - (cmpfunc)PySwigPacked_compare, /* tp_compare */ - (reprfunc)PySwigPacked_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - (hashfunc)0, /* tp_hash */ - (ternaryfunc)0, /* tp_call */ - (reprfunc)PySwigPacked_str, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - swigpacked_doc, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ -#if PY_VERSION_HEX >= 0x02020000 - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - PyObject_Del, /* tp_free */ - 0, /* tp_is_gc */ - 0, /* tp_bases */ - 0, /* tp_mro */ - 0, /* tp_cache */ - 0, /* tp_subclasses */ - 0, /* tp_weaklist */ -#endif -#if PY_VERSION_HEX >= 0x02030000 - 0, /* tp_del */ -#endif -#ifdef COUNT_ALLOCS - 0,0,0,0 /* tp_alloc -> tp_next */ -#endif - }; - pyswigpacked_type = tmp; - pyswigpacked_type.ob_type = &PyType_Type; - type_init = 1; - } - return &pyswigpacked_type; -} - -SWIGRUNTIME PyObject * -PySwigPacked_New(void *ptr, size_t size, swig_type_info *ty) -{ - PySwigPacked *sobj = PyObject_NEW(PySwigPacked, PySwigPacked_type()); - if (sobj) { - void *pack = malloc(size); - if (pack) { - memcpy(pack, ptr, size); - sobj->pack = pack; - sobj->ty = ty; - sobj->size = size; - } else { - PyObject_DEL((PyObject *) sobj); - sobj = 0; - } - } - return (PyObject *) sobj; -} - -SWIGRUNTIME swig_type_info * -PySwigPacked_UnpackData(PyObject *obj, void *ptr, size_t size) -{ - if (PySwigPacked_Check(obj)) { - PySwigPacked *sobj = (PySwigPacked *)obj; - if (sobj->size != size) return 0; - memcpy(ptr, sobj->pack, size); - return sobj->ty; - } else { - return 0; - } -} - -/* ----------------------------------------------------------------------------- - * pointers/data manipulation - * ----------------------------------------------------------------------------- */ - -SWIGRUNTIME PyObject * -_SWIG_This(void) -{ - static PyObject *_this = 0; - if (!_this) { - _this = PyString_FromString("this"); - } - return _this; -} - -SWIGRUNTIME PyObject * -SWIG_This(void) -{ - static PyObject *SWIG_STATIC_POINTER(swig_this) = _SWIG_This(); - return swig_this; -} - -/* #define SWIG_PYTHON_SLOW_GETSET_THIS */ - -SWIGRUNTIME PySwigObject * -SWIG_Python_GetSwigThis(PyObject *pyobj) -{ - if (PySwigObject_Check(pyobj)) { - return (PySwigObject *) pyobj; - } else { - PyObject *obj = 0; -#if (!defined(SWIG_PYTHON_SLOW_GETSET_THIS) && !(PY_VERSION_HEX < 0x02020000)) - if (PyInstance_Check(pyobj)) { - obj = _PyInstance_Lookup(pyobj, SWIG_This()); - } else { - PyObject **dictptr = _PyObject_GetDictPtr(pyobj); - if (dictptr != NULL) { - PyObject *dict = *dictptr; - obj = dict ? PyDict_GetItem(dict, SWIG_This()) : 0; - } -#ifdef PyWeakref_CheckProxy - else if (PyWeakref_CheckProxy(pyobj)) { - PyObject *wobj = PyWeakref_GET_OBJECT(pyobj); - return wobj ? SWIG_Python_GetSwigThis(wobj) : 0; - } -#endif - if (!obj) { - obj = PyObject_GetAttr(pyobj,SWIG_This()); - if (obj) { - Py_DECREF(obj); - } else { - if (PyErr_Occurred()) PyErr_Clear(); - return 0; - } - } - } -#else - obj = PyObject_GetAttr(pyobj,SWIG_This()); - if (obj) { - Py_DECREF(obj); - } else { - if (PyErr_Occurred()) PyErr_Clear(); - return 0; - } -#endif - return (PySwigObject *)obj; - } -} - - -/* Acquire a pointer value */ - -SWIGRUNTIME int -SWIG_Python_AcquirePtr(PyObject *obj, int own) { - if (own) { - PySwigObject *sobj = SWIG_Python_GetSwigThis(obj); - if (sobj) { - int oldown = sobj->own; - sobj->own = own; - return oldown; - } - } - return 0; -} - -/* Convert a pointer value */ - -SWIGRUNTIME int -SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int flags, int *own) { - if (!obj) return SWIG_ERROR; - if (obj == Py_None) { - if (ptr) *ptr = 0; - return SWIG_OK; - } else { - PySwigObject *sobj = SWIG_Python_GetSwigThis(obj); - while (sobj) { - void *vptr = sobj->ptr; - if (ty) { - swig_type_info *to = sobj->ty; - if (to == ty) { - /* no type cast needed */ - if (ptr) *ptr = vptr; - break; - } else { - swig_cast_info *tc = SWIG_TypeCheck(to->name,ty); - if (!tc) { - sobj = (PySwigObject *)sobj->next; - } else { - if (ptr) *ptr = SWIG_TypeCast(tc,vptr); - break; - } - } - } else { - if (ptr) *ptr = vptr; - break; - } - } - if (sobj) { - if (own) *own = sobj->own; - if (flags & SWIG_POINTER_DISOWN) { - sobj->own = 0; - } - return SWIG_OK; - } else { - int res = SWIG_ERROR; - if (flags & SWIG_POINTER_IMPLICIT_CONV) { - PySwigClientData *data = ty ? (PySwigClientData *) ty->clientdata : 0; - if (data && !data->implicitconv) { - PyObject *klass = data->klass; - if (klass) { - PyObject *impconv; - data->implicitconv = 1; /* avoid recursion and call 'explicit' constructors*/ - impconv = SWIG_Python_CallFunctor(klass, obj); - data->implicitconv = 0; - if (PyErr_Occurred()) { - PyErr_Clear(); - impconv = 0; - } - if (impconv) { - PySwigObject *sobj = SWIG_Python_GetSwigThis(impconv); - if (sobj) { - void *vptr; - res = SWIG_Python_ConvertPtrAndOwn((PyObject*)sobj, &vptr, ty, 0, 0); - if (SWIG_IsOK(res)) { - if (ptr) { - *ptr = vptr; - /* transfer the ownership to 'ptr' */ - sobj->own = 0; - res = SWIG_AddNewMask(SWIG_AddCast(res)); - } else { - res = SWIG_AddCast(res); - } - } - } - Py_DECREF(impconv); - } - } - } - } - return res; - } - } -} - -/* Convert a function ptr value */ - -SWIGRUNTIME int -SWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) { - if (!PyCFunction_Check(obj)) { - return SWIG_ConvertPtr(obj, ptr, ty, 0); - } else { - void *vptr = 0; - - /* here we get the method pointer for callbacks */ - char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc); - const char *desc = doc ? strstr(doc, "swig_ptr: ") : 0; - if (desc) { - desc = ty ? SWIG_UnpackVoidPtr(desc + 10, &vptr, ty->name) : 0; - if (!desc) return SWIG_ERROR; - } - if (ty) { - swig_cast_info *tc = SWIG_TypeCheck(desc,ty); - if (!tc) return SWIG_ERROR; - *ptr = SWIG_TypeCast(tc,vptr); - } else { - *ptr = vptr; - } - return SWIG_OK; - } -} - -/* Convert a packed value value */ - -SWIGRUNTIME int -SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *ty) { - swig_type_info *to = PySwigPacked_UnpackData(obj, ptr, sz); - if (!to) return SWIG_ERROR; - if (ty) { - if (to != ty) { - /* check type cast? */ - swig_cast_info *tc = SWIG_TypeCheck(to->name,ty); - if (!tc) return SWIG_ERROR; - } - } - return SWIG_OK; -} - -/* ----------------------------------------------------------------------------- - * Create a new pointer object - * ----------------------------------------------------------------------------- */ - -/* - Create a new instance object, whitout calling __init__, and set the - 'this' attribute. -*/ - -SWIGRUNTIME PyObject* -SWIG_Python_NewShadowInstance(PySwigClientData *data, PyObject *swig_this) -{ -#if (PY_VERSION_HEX >= 0x02020000) - PyObject *inst = 0; - PyObject *newraw = data->newraw; - if (newraw) { - inst = PyObject_Call(newraw, data->newargs, NULL); - if (inst) { -#if !defined(SWIG_PYTHON_SLOW_GETSET_THIS) - PyObject **dictptr = _PyObject_GetDictPtr(inst); - if (dictptr != NULL) { - PyObject *dict = *dictptr; - if (dict == NULL) { - dict = PyDict_New(); - *dictptr = dict; - PyDict_SetItem(dict, SWIG_This(), swig_this); - } - } -#else - PyObject *key = SWIG_This(); - PyObject_SetAttr(inst, key, swig_this); -#endif - } - } else { - PyObject *dict = PyDict_New(); - PyDict_SetItem(dict, SWIG_This(), swig_this); - inst = PyInstance_NewRaw(data->newargs, dict); - Py_DECREF(dict); - } - return inst; -#else - PyInstanceObject *inst = PyObject_NEW(PyInstanceObject, &PyInstance_Type); - if (inst == NULL) { - return NULL; - } - inst->in_class = (PyClassObject *)data->newargs; - Py_INCREF(inst->in_class); - inst->in_dict = PyDict_New(); - if (inst->in_dict == NULL) { - Py_DECREF(inst); - return NULL; - } - PyDict_SetItem(inst->in_dict, SWIG_This(), swig_this); - return (PyObject *) inst; -#endif -} - -/* Create a new pointer object */ - -SWIGRUNTIME PyObject * -SWIG_Python_NewPointerObj(void *ptr, swig_type_info *type, int flags) { - if (!ptr) { - return SWIG_Py_Void(); - } else { - int own = (flags & SWIG_POINTER_OWN) ? SWIG_POINTER_OWN : 0; - PyObject *robj = PySwigObject_New(ptr, type, own); - PySwigClientData *clientdata = type ? (PySwigClientData *)(type->clientdata) : 0; - if (clientdata && !(flags & SWIG_POINTER_NOSHADOW)) { - PyObject *inst = SWIG_Python_NewShadowInstance(clientdata, robj); - if (inst) { - Py_DECREF(robj); - robj = inst; - } - } - return robj; - } -} - -/* Create a new packed object */ - -SWIGRUNTIMEINLINE PyObject * -SWIG_Python_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) { - return ptr ? PySwigPacked_New((void *) ptr, sz, type) : SWIG_Py_Void(); -} - -/* -----------------------------------------------------------------------------* - * Get type list - * -----------------------------------------------------------------------------*/ - -#ifdef SWIG_LINK_RUNTIME -void *SWIG_ReturnGlobalTypeList(void *); -#endif - -SWIGRUNTIME swig_module_info * -SWIG_Python_GetModule(void) { - static void *type_pointer = (void *)0; - /* first check if module already created */ - if (!type_pointer) { -#ifdef SWIG_LINK_RUNTIME - type_pointer = SWIG_ReturnGlobalTypeList((void *)0); -#else - type_pointer = PyCObject_Import((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, - (char*)"type_pointer" SWIG_TYPE_TABLE_NAME); - if (PyErr_Occurred()) { - PyErr_Clear(); - type_pointer = (void *)0; - } -#endif - } - return (swig_module_info *) type_pointer; -} - -#if PY_MAJOR_VERSION < 2 -/* PyModule_AddObject function was introduced in Python 2.0. The following function - is copied out of Python/modsupport.c in python version 2.3.4 */ -SWIGINTERN int -PyModule_AddObject(PyObject *m, char *name, PyObject *o) -{ - PyObject *dict; - if (!PyModule_Check(m)) { - PyErr_SetString(PyExc_TypeError, - "PyModule_AddObject() needs module as first arg"); - return SWIG_ERROR; - } - if (!o) { - PyErr_SetString(PyExc_TypeError, - "PyModule_AddObject() needs non-NULL value"); - return SWIG_ERROR; - } - - dict = PyModule_GetDict(m); - if (dict == NULL) { - /* Internal error -- modules must have a dict! */ - PyErr_Format(PyExc_SystemError, "module '%s' has no __dict__", - PyModule_GetName(m)); - return SWIG_ERROR; - } - if (PyDict_SetItemString(dict, name, o)) - return SWIG_ERROR; - Py_DECREF(o); - return SWIG_OK; -} -#endif - -SWIGRUNTIME void -SWIG_Python_DestroyModule(void *vptr) -{ - swig_module_info *swig_module = (swig_module_info *) vptr; - swig_type_info **types = swig_module->types; - size_t i; - for (i =0; i < swig_module->size; ++i) { - swig_type_info *ty = types[i]; - if (ty->owndata) { - PySwigClientData *data = (PySwigClientData *) ty->clientdata; - if (data) PySwigClientData_Del(data); - ty->clientdata = 0; - } - } - Py_DECREF(SWIG_This()); -} - -SWIGRUNTIME void -SWIG_Python_SetModule(swig_module_info *swig_module) { - static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} };/* Sentinel */ - - PyObject *module = Py_InitModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, - swig_empty_runtime_method_table); - PyObject *pointer = PyCObject_FromVoidPtr((void *) swig_module, SWIG_Python_DestroyModule); - if (pointer && module) { - PyModule_AddObject(module, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME, pointer); - } else { - Py_XDECREF(pointer); - } -} - -#ifdef __cplusplus -#if 0 -{ /* cc-mode */ -#endif -} -#endif - -/* -----------------------------------------------------------------------------* - Standard SWIG API for use inside user code. - - Don't include this file directly, run the command - swig -python -external-runtime - Also, read the Modules chapter of the SWIG Manual. - - * -----------------------------------------------------------------------------*/ - -#ifdef SWIG_MODULE_CLIENTDATA_TYPE - -SWIGRUNTIMEINLINE swig_type_info * -SWIG_TypeQuery(SWIG_MODULE_CLIENTDATA_TYPE clientdata, const char *name) { - swig_module_info *module = SWIG_GetModule(clientdata); - return SWIG_TypeQueryModule(module, module, name); -} - -SWIGRUNTIMEINLINE swig_type_info * -SWIG_MangledTypeQuery(SWIG_MODULE_CLIENTDATA_TYPE clientdata, const char *name) { - swig_module_info *module = SWIG_GetModule(clientdata); - return SWIG_MangledTypeQueryModule(module, module, name); -} - -#else - -SWIGRUNTIMEINLINE swig_type_info * -SWIG_TypeQuery(const char *name) { - swig_module_info *module = SWIG_GetModule(NULL); - return SWIG_TypeQueryModule(module, module, name); -} - -SWIGRUNTIMEINLINE swig_type_info * -SWIG_MangledTypeQuery(const char *name) { - swig_module_info *module = SWIG_GetModule(NULL); - return SWIG_MangledTypeQueryModule(module, module, name); -} - -#endif - -""" From 73d24ca59e3a714a934d02058e9411ebda906e59 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 6 Mar 2010 00:51:32 +0000 Subject: [PATCH 0771/1680] Fix html errors git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11904 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Typemaps.html | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Doc/Manual/Typemaps.html b/Doc/Manual/Typemaps.html index 14623b37d..c815b31d0 100644 --- a/Doc/Manual/Typemaps.html +++ b/Doc/Manual/Typemaps.html @@ -34,7 +34,7 @@
    • Typedef reductions
    • Default typemaps
    • Mixed default typemaps -
    • Multi-arguments typemaps +
    • Multi-arguments typemaps
    • Debugging typemap pattern matching
  • Code generation rules @@ -1406,7 +1406,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

    @@ -1543,7 +1543,7 @@ SWIGINTERN PyObject *_wrap_foo(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {

    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: +For example, the output for the code in the previous section is as follows:

    @@ -1623,6 +1623,8 @@ example.i:21: Typemap for void set_value (out) : %typemap(out) void

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

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

      +

    10.4 Code generation rules

    From 51d433ee0ab0f677bbf20b4321369b82e3c91f02 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 6 Mar 2010 19:09:10 +0000 Subject: [PATCH 0772/1680] fix nspace error message for Java git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11919 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/java.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index 1bb9532ee..50b80dc8b 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -1199,7 +1199,7 @@ public: full_imclass_name = NewStringf("%s.%s", package, imclass_name); } else { full_imclass_name = NewStringf("%s", imclass_name); - Printf(stderr, "The nspace feature used on %s is not supported unless a package is specified with -package - Java does not support types declared in the unnamed package accessing types declared in a package.\n", Getattr(n, "name")); + Printf(stderr, "The nspace feature used on %s is not supported unless a package is specified with -package - Java does not support types declared in a named package accessing types declared in an unnamed package.\n", Getattr(n, "name")); SWIG_exit(EXIT_FAILURE); } } @@ -1832,7 +1832,7 @@ public: } else { full_proxy_class_name = NewStringf("%s.%s", nspace, proxy_class_name); full_imclass_name = NewStringf("%s", imclass_name); - Printf(stderr, "The nspace feature used on %s is not supported unless a package is specified with -package - Java does not support types declared in the unnamed package accessing types declared in a package.\n", Getattr(n, "name")); + Printf(stderr, "The nspace feature used on %s is not supported unless a package is specified with -package - Java does not support types declared in a named package accessing types declared in an unnamed package.\n", Getattr(n, "name")); SWIG_exit(EXIT_FAILURE); } } From b6b99bb1486d9709378bd37333c4c930affe5ad3 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 6 Mar 2010 19:11:32 +0000 Subject: [PATCH 0773/1680] Add nspace feature for C# and add documentation on nspace git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11920 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 3 + Doc/Manual/CSharp.html | 5 + Doc/Manual/Contents.html | 9 +- Doc/Manual/Java.html | 13 +- Doc/Manual/SWIGPlus.html | 96 +++++++- Examples/test-suite/csharp/Makefile.in | 4 +- Examples/test-suite/csharp/nspace_runme.cs | 60 +++++ Lib/swig.swg | 5 + Source/Modules/csharp.cxx | 263 +++++++++++++++------ 9 files changed, 371 insertions(+), 87 deletions(-) create mode 100644 Examples/test-suite/csharp/nspace_runme.cs diff --git a/CHANGES.current b/CHANGES.current index ec0473bee..1e9704783 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,9 @@ Version 2.0.0 (in progress) ============================ +2010-03-06: wsfulton + [C#] Added the nspace feature for C#. Documentation for the nspace feature is now available. + 2010-03-04: wsfulton Added the nspace feature. This adds some improved namespace support. Currently only Java is supported for target languages, where C++ namespaces are automatically translated into diff --git a/Doc/Manual/CSharp.html b/Doc/Manual/CSharp.html index 324be63ec..3281bc268 100644 --- a/Doc/Manual/CSharp.html +++ b/Doc/Manual/CSharp.html @@ -102,6 +102,11 @@ namespace com.bloggs.widget { Note that by default, the generated C# classes have no namespace and the module name is unrelated to namespaces. The module name is just like in Java and is merely used to name some of the generated classes.
  • +
  • +The nspace feature is also supported as described in this general section with a C# example. +Unlike Java which requires the use of the -package option when using the nspace feature, the -namespace option is not mandatory for C#. +
  • +
  • The -dllimport <name> commandline option specifies the name of the DLL for the DllImport attribute for every PInvoke method. If this commandline option is not given, the DllImport DLL name is the same as the module name. This option is useful for when one wants to invoke SWIG multiple times on different modules, yet compile all the resulting code into a single DLL.
  • diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index 0cda0b8f4..266d8210c 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -229,7 +229,10 @@
  • Wrapping overloaded operators
  • Class extension
  • Templates -
  • Namespaces +
  • Namespaces +
  • Renaming templated types in namespaces
  • Exception specifications
  • Exception handling with %catches @@ -237,7 +240,7 @@
  • Smart pointers and operator->()
  • Using declarations and inheritance
  • Nested classes -
  • A brief rant about const-correctness +
  • A brief rant about const-correctness
  • Where to go for more information @@ -349,7 +352,7 @@
  • Typedef reductions
  • Default typemaps
  • Mixed default typemaps -
  • Multi-arguments typemaps +
  • Multi-arguments typemaps
  • Debugging typemap pattern matching
  • Code generation rules diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html index 7869c5269..7ae802998 100644 --- a/Doc/Manual/Java.html +++ b/Doc/Manual/Java.html @@ -1852,7 +1852,9 @@ Further details on default arguments and how to restore this approach are given

    -SWIG is aware of C++ namespaces, but namespace names do not appear in +SWIG is aware of named C++ namespaces and they can be mapped to Java packages, however, +the default wrapping flattens the namespaces, effectively ignoring them. +So by default, the namespace names do not appear in the module nor do namespaces result in a module that is broken up into submodules or packages. For example, if you have a file like this,

    @@ -1908,6 +1910,15 @@ symbols separate, consider wrapping them as separate SWIG modules. Each SWIG module can be placed into a separate package.

    +

    +The default behaviour described above can be improved via the nspace feature. +Note that it only works for classes, structs, unions and enums declared within a named C++ namespace. +When the nspace feature is used, the C++ namespaces are converted into Java packages of the same name. +Proxy classes are thus declared within a package and this proxy makes numerous calls to the JNI intermediary class which is declared in the unnamed package by default. +As Java does not support types declared in a named package accessing types declared in an unnamed package, the -package commandline option described earlier must be used to provide a parent package. +So if SWIG is run using the -package com.myco option, a wrapped class, MyWorld::Material::Color, can then be accessed as com.myco.MyWorld.Material.Color. +

    +

    21.3.14 C++ templates

    diff --git a/Doc/Manual/SWIGPlus.html b/Doc/Manual/SWIGPlus.html index d1498224f..bcded9166 100644 --- a/Doc/Manual/SWIGPlus.html +++ b/Doc/Manual/SWIGPlus.html @@ -48,7 +48,10 @@
  • Wrapping overloaded operators
  • Class extension
  • Templates -
  • Namespaces +
  • Namespaces +
  • Renaming templated types in namespaces
  • Exception specifications
  • Exception handling with %catches @@ -3647,12 +3650,16 @@ as the class name. For example: Similar changes apply to typemaps and other customization features.

    -

    6.19 Namespaces

    +

    6.19 Namespaces

    -Support for C++ namespaces is a relatively late addition to SWIG, -first appearing in SWIG-1.3.12. Before describing the implementation, +Support for C++ namespaces is comprehensive, but by default simple, however, +some target languages can turn on more advanced namespace support via the +nspace feature, described later. +Code within unnamed namespaces is ignored as there is no external +access to symbols declared within the unnamed namespace. +Before detailing the default implementation for named namespaces, it is worth noting that the semantics of C++ namespaces is extremely non-trivial--especially with regard to the C++ type system and class machinery. At a most basic level, namespaces are sometimes used to @@ -4092,6 +4099,87 @@ with any namespace awareness. In the future, language modules may or may not p more advanced namespace support.

    +

    6.19.1 The nspace feature for namespaces

    + + +

    +Some target languages provide support for the nspace feature. +The feature can be applied to any class, struct, union or enum declared within a named namespace. +The feature wraps the type within the target language specific concept of a namespace, +for example, a Java package or C# namespace. +Please see the language specific sections to see if the target language you are interested in supports the nspace feature. +

    + +

    +The feature is demonstrated below for C# using the following example: +

    + +
    +
    +%feature("nspace") MyWorld::Material::Color;
    +%nspace MyWorld::Wrapping::Color; // %nspace is a macro for %feature("nspace")
    +
    +namespace MyWorld {
    +  namespace Material {
    +    class Color {
    +    ...
    +    };
    +  }
    +  namespace Wrapping {
    +    class Color {
    +    ...
    +    };
    +  }
    +}
    +
    +
    + +

    +Without the nspace feature directives above or %rename, you would get the following warning resulting in just one of the Color classes being available for use from the target language: +

    + +
    +
    +example.i:9: Error: 'Color' is multiply defined in the generated target language module.
    +example.i:5: Error: Previous declaration of 'Color'
    +
    +
    + +

    +With the nspace feature the two Color classes are wrapped into the equivalent C# namespaces. +A fully qualified constructor call of each these two types in C# is then: +

    + +
    +
    +MyWorld.Material.Color materialColor = new MyWorld.Material.Color();
    +MyWorld.Wrapping.Color wrappingColor = new MyWorld.Wrapping.Color();
    +
    +
    + +

    +Note that the nspace feature does not apply to variables and functions simply declared in a namespace. For example, the following symbols cannot co-exist in the target language without renaming. This may change in a future version. +

    + +
    +
    +namespace MyWorld {
    +  namespace Material {
    +    int quantity;
    +    void dispatch();
    +  }
    +  namespace Wrapping {
    +    int quantity;
    +    void dispatch();
    +  }
    +}
    +
    +
    + +

    +Compatibility Note: The nspace feature was first introduced in SWIG-2.0.0. +

    +

    6.20 Renaming templated types in namespaces

    diff --git a/Examples/test-suite/csharp/Makefile.in b/Examples/test-suite/csharp/Makefile.in index 1545eb30d..0f44b3335 100644 --- a/Examples/test-suite/csharp/Makefile.in +++ b/Examples/test-suite/csharp/Makefile.in @@ -70,13 +70,13 @@ run_testcase = \ $(MAKE) -f $*/$(top_builddir)/$(EXAMPLES)/Makefile \ CSHARPFLAGS='-nologo $(CSHARPFLAGSSPECIAL) -out:$*_runme.exe' \ CSHARPSRCS='`$(CSHARPCYGPATH_W) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX)` \ - $*$(CSHARPPATHSEPARATOR)*.cs' csharp_compile && \ + `find $* -name "*.cs"`' csharp_compile && \ env LD_LIBRARY_PATH="$*:$$LD_LIBRARY_PATH" PATH="$*:$$PATH" SHLIB_PATH="$*:$$SHLIB_PATH" $(RUNTOOL) $(INTERPRETER) $*_runme.exe; \ else \ cd $* && \ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile \ CSHARPFLAGS='-nologo $(CSHARPFLAGSSPECIAL) -t:module -out:$*.netmodule' \ - CSHARPSRCS='*.cs' csharp_compile && cd .. ; \ + CSHARPSRCS='`find . -name "*.cs"`' csharp_compile && cd .. ; \ fi # Clean: remove testcase directories diff --git a/Examples/test-suite/csharp/nspace_runme.cs b/Examples/test-suite/csharp/nspace_runme.cs new file mode 100644 index 000000000..91baf6a0f --- /dev/null +++ b/Examples/test-suite/csharp/nspace_runme.cs @@ -0,0 +1,60 @@ +using System; + +public class runme +{ + static void Main() + { + // constructors and destructors + nspaceNamespace.Outer.Inner1.Color color1 = new nspaceNamespace.Outer.Inner1.Color(); + nspaceNamespace.Outer.Inner1.Color color = new nspaceNamespace.Outer.Inner1.Color(color1); + color1.Dispose(); + color1 = null; + + // class methods + color.colorInstanceMethod(20.0); + nspaceNamespace.Outer.Inner1.Color.colorStaticMethod(20.0); + nspaceNamespace.Outer.Inner1.Color created = nspaceNamespace.Outer.Inner1.Color.create(); + created.Dispose(); + + // class enums + nspaceNamespace.Outer.SomeClass someClass = new nspaceNamespace.Outer.SomeClass(); + nspaceNamespace.Outer.Inner1.Color.Channel channel = someClass.GetInner1ColorChannel(); + if (channel != nspaceNamespace.Outer.Inner1.Color.Channel.Transmission) + throw new ApplicationException("Transmission wrong"); + + // static member variables + nspaceNamespace.Outer.Inner1.Color.staticMemberVariable = 789; + if (nspaceNamespace.Outer.Inner1.Color.staticMemberVariable != 789) + throw new ApplicationException("static member variable failed"); + + // instance member variables + color.instanceMemberVariable = 123; + if (color.instanceMemberVariable != 123) + throw new ApplicationException("instance member variable failed"); + + // check globals in a namespace don't get mangled with the nspaceNamespace option + nspaceNamespace.nspace.namespaceFunction(color); + nspaceNamespace.nspace.namespaceVar = 111; + if (nspaceNamespace.nspace.namespaceVar != 111) + throw new ApplicationException("global var failed"); + + // Same class different namespaces + nspaceNamespace.Outer.Inner1.Color col1 = new nspaceNamespace.Outer.Inner1.Color(); + nspaceNamespace.Outer.Inner2.Color col2 = nspaceNamespace.Outer.Inner2.Color.create(); + col2.colors(col1, col1, col2, col2, col2); + + // global enums + nspaceNamespace.Outer.Inner1.Channel outerChannel1 = someClass.GetInner1Channel(); + if (outerChannel1 != nspaceNamespace.Outer.Inner1.Channel.Transmission1) + throw new ApplicationException("Transmission1 wrong"); + nspaceNamespace.Outer.Inner2.Channel outerChannel2 = someClass.GetInner2Channel(); + if (outerChannel2 != nspaceNamespace.Outer.Inner2.Channel.Transmission2) + throw new ApplicationException("Transmission2 wrong"); + + // turn feature off / ignoring + nspaceNamespace.Outer.nspace ns = new nspaceNamespace.Outer.nspace(); + ns.Dispose(); + nspaceNamespace.NoNSpacePlease nons = new nspaceNamespace.NoNSpacePlease(); + nons.Dispose(); + } +} diff --git a/Lib/swig.swg b/Lib/swig.swg index af7fa6a30..ec903533c 100644 --- a/Lib/swig.swg +++ b/Lib/swig.swg @@ -156,6 +156,11 @@ #define %nonaturalvar %feature("naturalvar","0") #define %clearnaturalvar %feature("naturalvar","") +/* nspace directives */ +#define %nspace %feature("nspace") +#define %nonspace %feature("nspace","0") +#define %clearnspace %feature("nspace","") + /* valuewrapper directives */ #define %valuewrapper %feature("valuewrapper") #define %clearvaluewrapper %feature("valuewrapper","") diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index 6d3d09ea4..0dbed4d1e 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -54,7 +54,9 @@ class CSHARP:public Language { String *proxy_class_def; String *proxy_class_code; String *module_class_code; - String *proxy_class_name; + String *proxy_class_name; // proxy class name + String *full_proxy_class_name;// fully qualified proxy class name when using nspace feature, otherwise same as proxy_class_name + String *full_imclass_name; // fully qualified intermediary class name when using nspace feature, otherwise same as imclass_name String *variable_name; //Name of a variable being wrapped String *proxy_class_constants_code; String *module_class_constants_code; @@ -125,6 +127,8 @@ public: proxy_class_code(NULL), module_class_code(NULL), proxy_class_name(NULL), + full_proxy_class_name(NULL), + full_imclass_name(NULL), variable_name(NULL), proxy_class_constants_code(NULL), module_class_constants_code(NULL), @@ -163,18 +167,34 @@ public: * getProxyName() * * Test to see if a type corresponds to something wrapped with a proxy class. - * Return NULL if not otherwise the proxy class name + * Return NULL if not otherwise the proxy class name, fully qualified with + * a namespace if the nspace feature is used. * ----------------------------------------------------------------------------- */ String *getProxyName(SwigType *t) { - if (proxy_flag) { - Node *n = classLookup(t); - if (n) { - return Getattr(n, "sym:name"); - } - } - return NULL; - } + String *proxyname = NULL; + if (proxy_flag) { + Node *n = classLookup(t); + if (n) { + proxyname = Getattr(n, "proxyname"); + if (!proxyname) { + String *nspace = Getattr(n, "sym:nspace"); + String *symname = Getattr(n, "sym:name"); + if (nspace) { + if (Len(namespce) > 0) + proxyname = NewStringf("%s.%s.%s", namespce, nspace, symname); + else + proxyname = NewStringf("%s.%s", nspace, symname); + } else { + proxyname = Copy(symname); + } + Setattr(n, "proxyname", proxyname); + Delete(proxyname); + } + } + } + return proxyname; + } /* ----------------------------------------------------------------------------- * directorClassName() @@ -419,7 +439,7 @@ public: // Start writing out the intermediary class file emitBanner(f_im); - addOpenNamespace(namespce, f_im); + addOpenNamespace(namespce, 0, f_im); if (imclass_imports) Printf(f_im, "%s\n", imclass_imports); @@ -443,7 +463,7 @@ public: // Finish off the class Printf(f_im, "}\n"); - addCloseNamespace(namespce, f_im); + addCloseNamespace(namespce, 0, f_im); Close(f_im); } @@ -463,7 +483,7 @@ public: // Start writing out the module class file emitBanner(f_module); - addOpenNamespace(namespce, f_module); + addOpenNamespace(namespce, 0, f_module); if (module_imports) Printf(f_module, "%s\n", module_imports); @@ -495,7 +515,7 @@ public: // Finish off the class Printf(f_module, "}\n"); - addCloseNamespace(namespce, f_module); + addCloseNamespace(namespce, 0, f_module); Close(f_module); } @@ -1033,7 +1053,7 @@ public: */ if (proxy_flag && wrapping_member_flag && !enum_constant_flag) { // Capitalize the first letter in the variable in the getter/setter function name - bool getter_flag = Cmp(symname, Swig_name_set(NSPACE_TODO, Swig_name_member(NSPACE_TODO, proxy_class_name, variable_name))) != 0; + bool getter_flag = Cmp(symname, Swig_name_set(getNSpace(), Swig_name_member(0, proxy_class_name, variable_name))) != 0; String *getter_setter_name = NewString(""); if (!getter_flag) @@ -1106,6 +1126,22 @@ public: if (getCurrentClass() && (cplus_mode != PUBLIC)) return SWIG_NOWRAP; + if (proxy_flag && !is_wrapping_class()) { + // Global enums / enums in a namespace + String *nspace = Getattr(n, "sym:nspace"); + assert(!full_imclass_name); + + if (!nspace) { + full_imclass_name = NewStringf("%s", imclass_name); + } else { + if (Len(namespce) > 0) { + full_imclass_name = NewStringf("%s.%s", namespce, imclass_name); + } else { + full_imclass_name = NewStringf("%s", imclass_name); + } + } + } + enum_code = NewString(""); String *symname = Getattr(n, "sym:name"); String *constants_code = (proxy_flag && is_wrapping_class())? proxy_class_constants_code : module_class_constants_code; @@ -1163,7 +1199,9 @@ public: Printv(proxy_class_constants_code, " ", enum_code, "\n\n", NIL); } else { // Global enums are defined in their own file - String *filen = NewStringf("%s%s.cs", SWIG_output_directory(), symname); + String *nspace = Getattr(n, "sym:nspace"); + String *output_directory = outputDirectory(nspace); + String *filen = NewStringf("%s%s.cs", output_directory, symname); File *f_enum = NewFile(filen, "w", SWIG_output_files()); if (!f_enum) { FileErrorDisplay(filen); @@ -1176,14 +1214,14 @@ public: // Start writing out the enum file emitBanner(f_enum); - addOpenNamespace(namespce, f_enum); + addOpenNamespace(namespce, nspace, f_enum); Printv(f_enum, typemapLookup(n, "csimports", typemap_lookup_type, WARN_NONE), // Import statements "\n", enum_code, "\n", NIL); - addCloseNamespace(namespce, f_enum); - + addCloseNamespace(namespce, nspace, f_enum); Close(f_enum); + Delete(output_directory); } } else { // Wrap C++ enum with simple constant @@ -1196,6 +1234,11 @@ public: Delete(enum_code); enum_code = NULL; + + if (proxy_flag && !is_wrapping_class()) { + Delete(full_imclass_name); + full_imclass_name = 0; + } } return SWIG_OK; } @@ -1381,13 +1424,13 @@ public: if (classname_substituted_flag) { if (SwigType_isenum(t)) { // This handles wrapping of inline initialised const enum static member variables (not when wrapping enum items - ignored later on) - Printf(constants_code, "(%s)%s.%s();\n", return_type, imclass_name, Swig_name_get(NSPACE_TODO, symname)); + Printf(constants_code, "(%s)%s.%s();\n", return_type, imclass_name, Swig_name_get(getNSpace(), symname)); } else { // This handles function pointers using the %constant directive - Printf(constants_code, "new %s(%s.%s(), false);\n", return_type, imclass_name, Swig_name_get(NSPACE_TODO, symname)); + Printf(constants_code, "new %s(%s.%s(), false);\n", return_type, imclass_name, Swig_name_get(getNSpace(), symname)); } } else - Printf(constants_code, "%s.%s();\n", imclass_name, Swig_name_get(NSPACE_TODO, symname)); + Printf(constants_code, "%s.%s();\n", imclass_name, Swig_name_get(getNSpace(), symname)); // Each constant and enum value is wrapped with a separate PInvoke function call SetFlag(n, "feature:immutable"); @@ -1641,7 +1684,8 @@ public: Printf(proxy_class_code, " if (SwigDerivedClassHasMethod(\"%s\", swigMethodTypes%s))\n", method, methid); Printf(proxy_class_code, " swigDelegate%s = new SwigDelegate%s_%s(SwigDirector%s);\n", methid, proxy_class_name, methid, overname); } - Printf(proxy_class_code, " %s.%s_director_connect(swigCPtr", imclass_name, proxy_class_name); + String *director_connect_method_name = Swig_name_member(getNSpace(), proxy_class_name, "director_connect"); + Printf(proxy_class_code, " %s.%s(swigCPtr", imclass_name, director_connect_method_name); for (i = first_class_dmethod; i < curr_class_dmethod; ++i) { UpcallData *udata = Getitem(dmethods_seq, i); String *methid = Getattr(udata, "class_methodidx"); @@ -1703,6 +1747,7 @@ public: director_method_types = NULL; Delete(director_connect_parms); director_connect_parms = NULL; + Delete(director_connect_method_name); } Delete(attributes); @@ -1719,8 +1764,8 @@ public: Replaceall(proxy_class_def, "$module", module_class_name); Replaceall(proxy_class_code, "$module", module_class_name); - Replaceall(proxy_class_def, "$imclassname", imclass_name); - Replaceall(proxy_class_code, "$imclassname", imclass_name); + Replaceall(proxy_class_def, "$imclassname", full_imclass_name); + Replaceall(proxy_class_code, "$imclassname", full_imclass_name); Replaceall(proxy_class_def, "$dllimport", dllimport); Replaceall(proxy_class_code, "$dllimport", dllimport); @@ -1749,24 +1794,38 @@ public: virtual int classHandler(Node *n) { + String *nspace = getNSpace(); File *f_proxy = NULL; if (proxy_flag) { proxy_class_name = NewString(Getattr(n, "sym:name")); - if (!addSymbol(proxy_class_name, n)) + if (!nspace) { + full_proxy_class_name = NewStringf("%s", proxy_class_name); + full_imclass_name = NewStringf("%s", imclass_name); + if (Cmp(proxy_class_name, imclass_name) == 0) { + Printf(stderr, "Class name cannot be equal to intermediary class name: %s\n", proxy_class_name); + SWIG_exit(EXIT_FAILURE); + } + + if (Cmp(proxy_class_name, module_class_name) == 0) { + Printf(stderr, "Class name cannot be equal to module class name: %s\n", proxy_class_name); + SWIG_exit(EXIT_FAILURE); + } + } else { + if (Len(namespce) > 0) { + full_proxy_class_name = NewStringf("%s.%s.%s", namespce, nspace, proxy_class_name); + full_imclass_name = NewStringf("%s.%s", namespce, imclass_name); + } else { + full_proxy_class_name = NewStringf("%s.%s", nspace, proxy_class_name); + full_imclass_name = NewStringf("%s", imclass_name); + } + } + + if (!addSymbol(proxy_class_name, n, nspace)) return SWIG_ERROR; - if (Cmp(proxy_class_name, imclass_name) == 0) { - Printf(stderr, "Class name cannot be equal to intermediary class name: %s\n", proxy_class_name); - SWIG_exit(EXIT_FAILURE); - } - - if (Cmp(proxy_class_name, module_class_name) == 0) { - Printf(stderr, "Class name cannot be equal to module class name: %s\n", proxy_class_name); - SWIG_exit(EXIT_FAILURE); - } - - String *filen = NewStringf("%s%s.cs", SWIG_output_directory(), proxy_class_name); + String *output_directory = outputDirectory(nspace); + String *filen = NewStringf("%s%s.cs", output_directory, proxy_class_name); f_proxy = NewFile(filen, "w", SWIG_output_files()); if (!f_proxy) { FileErrorDisplay(filen); @@ -1779,7 +1838,7 @@ public: // Start writing out the proxy class file emitBanner(f_proxy); - addOpenNamespace(namespce, f_proxy); + addOpenNamespace(namespce, nspace, f_proxy); Clear(proxy_class_def); Clear(proxy_class_code); @@ -1797,9 +1856,9 @@ public: Replaceall(proxy_class_def, "$module", module_class_name); Replaceall(proxy_class_code, "$module", module_class_name); Replaceall(proxy_class_constants_code, "$module", module_class_name); - Replaceall(proxy_class_def, "$imclassname", imclass_name); - Replaceall(proxy_class_code, "$imclassname", imclass_name); - Replaceall(proxy_class_constants_code, "$imclassname", imclass_name); + Replaceall(proxy_class_def, "$imclassname", full_imclass_name); + Replaceall(proxy_class_code, "$imclassname", full_imclass_name); + Replaceall(proxy_class_constants_code, "$imclassname", full_imclass_name); Replaceall(proxy_class_def, "$dllimport", dllimport); Replaceall(proxy_class_code, "$dllimport", dllimport); Replaceall(proxy_class_constants_code, "$dllimport", dllimport); @@ -1811,7 +1870,7 @@ public: Printv(f_proxy, proxy_class_constants_code, NIL); Printf(f_proxy, "}\n"); - addCloseNamespace(namespce, f_proxy); + addCloseNamespace(namespce, nspace, f_proxy); Close(f_proxy); f_proxy = NULL; @@ -1844,6 +1903,10 @@ public: Delete(proxy_class_name); proxy_class_name = NULL; + Delete(full_proxy_class_name); + full_proxy_class_name = NULL; + Delete(full_imclass_name); + full_imclass_name = NULL; Delete(destructor_call); destructor_call = NULL; Delete(proxy_class_constants_code); @@ -1862,7 +1925,7 @@ public: if (proxy_flag) { String *overloaded_name = getOverloadedName(n); - String *intermediary_function_name = Swig_name_member(NSPACE_TODO, proxy_class_name, overloaded_name); + String *intermediary_function_name = Swig_name_member(getNSpace(), proxy_class_name, overloaded_name); Setattr(n, "proxyfuncname", Getattr(n, "sym:name")); Setattr(n, "imfuncname", intermediary_function_name); proxyClassFunctionHandler(n); @@ -1882,7 +1945,7 @@ public: if (proxy_flag) { String *overloaded_name = getOverloadedName(n); - String *intermediary_function_name = Swig_name_member(NSPACE_TODO, proxy_class_name, overloaded_name); + String *intermediary_function_name = Swig_name_member(getNSpace(), proxy_class_name, overloaded_name); Setattr(n, "proxyfuncname", Getattr(n, "sym:name")); Setattr(n, "imfuncname", intermediary_function_name); proxyClassFunctionHandler(n); @@ -1962,7 +2025,7 @@ public: if (wrapping_member_flag && !enum_constant_flag) { // Properties - setter_flag = (Cmp(Getattr(n, "sym:name"), Swig_name_set(NSPACE_TODO, Swig_name_member(NSPACE_TODO, proxy_class_name, variable_name))) == 0); + setter_flag = (Cmp(Getattr(n, "sym:name"), Swig_name_set(getNSpace(), Swig_name_member(0, proxy_class_name, variable_name))) == 0); if (setter_flag) Swig_typemap_attach_parms("csvarin", l, NULL); } @@ -2005,7 +2068,7 @@ public: Printf(function_code, "static "); Printf(function_code, "%s %s(", return_type, proxy_function_name); - Printv(imcall, imclass_name, ".$imfuncname(", NIL); + Printv(imcall, full_imclass_name, ".$imfuncname(", NIL); if (!static_flag) Printf(imcall, "swigCPtr"); @@ -2132,7 +2195,7 @@ public: Node *explicit_n = Getattr(n, "explicitcallnode"); if (explicit_n) { String *ex_overloaded_name = getOverloadedName(explicit_n); - String *ex_intermediary_function_name = Swig_name_member(NSPACE_TODO, proxy_class_name, ex_overloaded_name); + String *ex_intermediary_function_name = Swig_name_member(getNSpace(), proxy_class_name, ex_overloaded_name); String *ex_imcall = Copy(imcall); Replaceall(ex_imcall, "$imfuncname", ex_intermediary_function_name); @@ -2250,7 +2313,7 @@ public: if (proxy_flag) { String *overloaded_name = getOverloadedName(n); - String *mangled_overname = Swig_name_construct(NSPACE_TODO, overloaded_name); + String *mangled_overname = Swig_name_construct(getNSpace(), overloaded_name); String *imcall = NewString(""); const String *csattributes = Getattr(n, "feature:cs:attributes"); @@ -2270,7 +2333,7 @@ public: Printf(function_code, " %s %s(", methodmods, proxy_class_name); Printf(helper_code, " static private %s SwigConstruct%s(", im_return_type, proxy_class_name); - Printv(imcall, imclass_name, ".", mangled_overname, "(", NIL); + Printv(imcall, full_imclass_name, ".", mangled_overname, "(", NIL); /* Attach the non-standard typemaps to the parameter list */ Swig_typemap_attach_parms("in", l, NULL); @@ -2451,7 +2514,7 @@ public: String *symname = Getattr(n, "sym:name"); if (proxy_flag) { - Printv(destructor_call, imclass_name, ".", Swig_name_destroy(NSPACE_TODO, symname), "(swigCPtr)", NIL); + Printv(destructor_call, full_imclass_name, ".", Swig_name_destroy(getNSpace(), symname), "(swigCPtr)", NIL); } return SWIG_OK; } @@ -2577,7 +2640,7 @@ public: if (proxy_flag && global_variable_flag) { // Capitalize the first letter in the variable to create the getter/setter function name func_name = NewString(""); - setter_flag = (Cmp(Getattr(n, "sym:name"), Swig_name_set(NSPACE_TODO, variable_name)) == 0); + setter_flag = (Cmp(Getattr(n, "sym:name"), Swig_name_set(getNSpace(), variable_name)) == 0); if (setter_flag) Printf(func_name, "set"); else @@ -2848,10 +2911,10 @@ public: // Strange hack to change the name Setattr(n, "name", Getattr(n, "value")); /* for wrapping of enums in a namespace when emit_action is used */ constantWrapper(n); - value = NewStringf("%s.%s()", imclass_name, Swig_name_get(NSPACE_TODO, symname)); + value = NewStringf("%s.%s()", full_imclass_name ? full_imclass_name : imclass_name, Swig_name_get(getNSpace(), symname)); } else { memberconstantHandler(n); - value = NewStringf("%s.%s()", imclass_name, Swig_name_get(NSPACE_TODO, Swig_name_member(NSPACE_TODO, proxy_class_name, symname))); + value = NewStringf("%s.%s()", full_imclass_name ? full_imclass_name : imclass_name, Swig_name_get(getNSpace(), Swig_name_member(getNSpace(), proxy_class_name, symname))); } } } @@ -2863,26 +2926,41 @@ public: * ----------------------------------------------------------------------------- */ String *getEnumName(SwigType *t) { - Node *enum_name = NULL; + Node *enumname = NULL; Node *n = enumLookup(t); if (n) { - String *symname = Getattr(n, "sym:name"); - if (symname) { - // Add in class scope when referencing enum if not a global enum - String *scopename_prefix = Swig_scopename_prefix(Getattr(n, "name")); - String *proxyname = 0; - if (scopename_prefix) { - proxyname = getProxyName(scopename_prefix); + enumname = Getattr(n, "enumname"); + if (!enumname) { + String *symname = Getattr(n, "sym:name"); + if (symname) { + // Add in class scope when referencing enum if not a global enum + String *scopename_prefix = Swig_scopename_prefix(Getattr(n, "name")); + String *proxyname = 0; + if (scopename_prefix) { + proxyname = getProxyName(scopename_prefix); + } + if (proxyname) { + enumname = NewStringf("%s.%s", proxyname, symname); + } else { + // global enum or enum in a namespace + String *nspace = Getattr(n, "sym:nspace"); + if (nspace) { + if (Len(namespce) > 0) + enumname = NewStringf("%s.%s.%s", namespce, nspace, symname); + else + enumname = NewStringf("%s.%s", nspace, symname); + } else { + enumname = Copy(symname); + } + } + Setattr(n, "enumname", enumname); + Delete(enumname); + Delete(scopename_prefix); } - if (proxyname) - enum_name = NewStringf("%s.%s", proxyname, symname); - else - enum_name = NewStringf("%s", symname); - Delete(scopename_prefix); } } - return enum_name; + return enumname; } /* ----------------------------------------------------------------------------- @@ -3019,7 +3097,7 @@ public: // Start writing out the type wrapper class file emitBanner(f_swigtype); - addOpenNamespace(namespce, f_swigtype); + addOpenNamespace(namespce, 0, f_swigtype); // Pure C# baseclass and interfaces const String *pure_baseclass = typemapLookup(n, "csbase", type, WARN_NONE); @@ -3048,7 +3126,7 @@ public: Printv(f_swigtype, swigtype, NIL); - addCloseNamespace(namespce, f_swigtype); + addCloseNamespace(namespce, 0, f_swigtype); Close(f_swigtype); Delete(swigtype); @@ -3123,22 +3201,53 @@ public: * addOpenNamespace() * ----------------------------------------------------------------------------- */ - void addOpenNamespace(String *namspace, File *file) { - if (namspace) - if (Len(namspace) > 0) - Printf(file, "namespace %s {\n", namspace); + void addOpenNamespace(const String *namspace, const String *nspace, File *file) { + if (namspace) { + if (Len(namspace) > 0 || nspace) { + Printf(file, "namespace "); + if (Len(namspace) > 0) + Printv(file, namspace, nspace ? "." : "", NIL); + if (nspace) + Printv(file, nspace, NIL); + Printf(file, " {\n"); + } + } } /* ----------------------------------------------------------------------------- * addCloseNamespace() * ----------------------------------------------------------------------------- */ - void addCloseNamespace(String *namspace, File *file) { + void addCloseNamespace(const String *namspace, const String *nspace, File *file) { if (namspace) - if (Len(namspace) > 0) + if (Len(namspace) > 0 || nspace) Printf(file, "\n}\n"); } + /* ----------------------------------------------------------------------------- + * outputDirectory() + * + * Return the directory to use for generating Java classes/enums and create the + * subdirectory (does not create if language specific outdir does not exist). + * ----------------------------------------------------------------------------- */ + + String *outputDirectory(String *nspace) { + String *output_directory = Copy(SWIG_output_directory()); + if (nspace) { + String *nspace_subdirectory = Copy(nspace); + Replaceall(nspace_subdirectory, ".", SWIG_FILE_DELIMITER); + String *newdir_error = Swig_new_subdirectory(output_directory, nspace_subdirectory); + if (newdir_error) { + Printf(stderr, "%s\n", newdir_error); + Delete(newdir_error); + SWIG_exit(EXIT_FAILURE); + } + Printv(output_directory, nspace_subdirectory, SWIG_FILE_DELIMITER, 0); + Delete(nspace_subdirectory); + } + return output_directory; + } + /*---------------------------------------------------------------------- * Start of director methods *--------------------------------------------------------------------*/ @@ -3189,7 +3298,7 @@ public: // Output the director connect method: String *norm_name = SwigType_namestr(Getattr(n, "name")); - String *swig_director_connect = NewStringf("%s_director_connect", proxy_class_name); + String *swig_director_connect = Swig_name_member(getNSpace(), proxy_class_name, "director_connect"); String *sym_name = Getattr(n, "sym:name"); Wrapper *code_wrap; @@ -3279,7 +3388,7 @@ public: // we're consistent with the sym:overload name in functionWrapper. (?? when // does the overloaded method name get set?) - imclass_dmethod = NewStringf("SwigDirector_%s", Swig_name_member(NSPACE_TODO, classname, overloaded_name)); + imclass_dmethod = NewStringf("SwigDirector_%s", Swig_name_member(getNSpace(), classname, overloaded_name)); if (returntype) { From 9006dc90ce5c87b384e14929d155adecaa9b5a46 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 6 Mar 2010 19:35:25 +0000 Subject: [PATCH 0774/1680] Correctly mangle the html section names to prevent name clashes in the pdf document git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11921 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/CSharp.html | 6 +++--- Doc/Manual/Chicken.html | 12 ++++++------ Doc/Manual/Contents.html | 16 ++++++++-------- Doc/Manual/Customization.html | 18 +++++++++--------- Doc/Manual/Guile.html | 4 ++-- Doc/Manual/Java.html | 6 +++--- Doc/Manual/Library.html | 2 +- Doc/Manual/Lisp.html | 2 +- Doc/Manual/Lua.html | 2 +- Doc/Manual/Modula3.html | 4 ++-- Doc/Manual/Modules.html | 4 ++-- Doc/Manual/Perl5.html | 2 +- Doc/Manual/Ruby.html | 8 ++++---- Doc/Manual/SWIG.html | 4 ++-- Doc/Manual/SWIGPlus.html | 10 +++++----- Doc/Manual/Typemaps.html | 8 ++++---- Doc/Manual/Warnings.html | 2 +- 17 files changed, 55 insertions(+), 55 deletions(-) diff --git a/Doc/Manual/CSharp.html b/Doc/Manual/CSharp.html index 3281bc268..34d441b35 100644 --- a/Doc/Manual/CSharp.html +++ b/Doc/Manual/CSharp.html @@ -310,7 +310,7 @@ The directorinattributes and directoroutattributes typemap att
  • Support for attaching C# attributes to wrapped methods, variables and enum values. -This is done using the %csattributes feature, see %feature directives. +This is done using the %csattributes feature, see %feature directives. Note that C# attributes are attached to proxy classes and enums using the csattributes typemap. For example, imagine we have a custom attribute class, ThreadSafeAttribute, for labelling thread safety. The following SWIG code shows how to attach this C# attribute to some methods and the class declaration itself: @@ -729,7 +729,7 @@ It is possible to throw a C# Exception from C/C++ code. SWIG already provides the framework for throwing C# exceptions if it is able to detect that a C++ exception could be thrown. Automatically detecting that a C++ exception could be thrown is only possible when a C++ exception specification is used, see Exception specifications. -The Exception handling with %exception section details the %exception feature. +The Exception handling with %exception section details the %exception feature. Customised code for handling exceptions with or without a C++ exception specification is possible and the details follow. However anyone wishing to do this should be familiar with the contents of the sections referred to above.

    @@ -1005,7 +1005,7 @@ Actually it will issue this warning for any function beginning with SWIG_CSh

    Let's consider a similar, but more common example that throws a C++ exception from within a wrapped function. -We can use %exception as mentioned in Exception handling with %exception. +We can use %exception as mentioned in Exception handling with %exception.

    diff --git a/Doc/Manual/Chicken.html b/Doc/Manual/Chicken.html index d1d83aafa..693e08e62 100644 --- a/Doc/Manual/Chicken.html +++ b/Doc/Manual/Chicken.html @@ -35,7 +35,7 @@
  • Typemaps
  • Pointers
  • Unsupported features and known problems
      @@ -80,7 +80,7 @@ relies on some recent additions to CHICKEN, which are only present in releases of CHICKEN with version number greater than or equal to 1.89. - To use a chicken version between 1.40 and 1.89, see the Garbage collection + To use a chicken version between 1.40 and 1.89, see the Garbage collection section below.

      @@ -225,7 +225,7 @@ a function that must be called, the constant will appear as a scheme variable. This causes the generated .scm file to just contain the code (set! MYCONSTANT1 (MYCONSTANT1)). See - Features and the %feature directive + Features and the %feature directive for info on how to apply the %feature.

      @@ -253,7 +253,7 @@

      The SWIG chicken module has support for exceptions thrown from C or C++ code to be caught in scheme. - See Exception handling with %exception + See Exception handling with %exception for more information about declaring exceptions in the interface file.

      @@ -519,7 +519,7 @@ all the modules.

      type. flags is either zero or SWIG_POINTER_DISOWN (see below).

      -

      19.6.1 Garbage collection

      +

      19.6.1 Garbage collection

      If the owner flag passed to SWIG_NewPointerObj is 1, NewPointerObj will add a @@ -530,7 +530,7 @@ all the modules.

      be garbage collected, SWIG will automatically set the owner flag to 1. For other functions, the %newobject directive must be specified for functions whose return values should be garbage collected. See - Object ownership and %newobject for more information. + Object ownership and %newobject for more information.

      In situations where a C or C++ function will assume ownership of a pointer, and thus diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index 266d8210c..6ef9acf89 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -223,7 +223,7 @@

    • Wrapping overloaded operators @@ -410,7 +410,7 @@ @@ -500,7 +500,7 @@
    • Modules Introduction
    • Basics
    • The SWIG runtime code -
    • External access to the runtime +
    • External access to the runtime
    • A word of caution about static libraries
    • References
    • Reducing the wrapper file size @@ -685,7 +685,7 @@
    • Typemaps
    • Pointers
    • Unsupported features and known problems
        @@ -1356,7 +1356,7 @@
      • C++ namespaces
      • C++ templates
      • C++ Standard Template Library (STL) -
      • C++ STL Functors +
      • C++ STL Functors
      • C++ STL Iterators
      • C++ Smart Pointers
      • Cross-Language Polymorphism diff --git a/Doc/Manual/Customization.html b/Doc/Manual/Customization.html index 82e1c411f..2d1486b89 100644 --- a/Doc/Manual/Customization.html +++ b/Doc/Manual/Customization.html @@ -10,7 +10,7 @@ @@ -45,7 +45,7 @@ of exception handling is presented. Then, a more general-purpose customization mechanism known as "features" is described.

        -

        11.1 Exception handling with %exception

        +

        11.1 Exception handling with %exception

        @@ -351,7 +351,7 @@ In this case, the exception handler is only attached to declarations named "allocate". This would include both global and member functions. The names supplied to %exception follow the same rules as for %rename described in the section on -Ambiguity resolution and renaming. +Ambiguity resolution and renaming. For example, if you wanted to define an exception handler for a specific class, you might write this:

        @@ -582,7 +582,7 @@ it can be used elsewhere in SWIG. This includes typemaps and helper functions.

        -

        11.2 Object ownership and %newobject

        +

        11.2 Object ownership and %newobject

        @@ -734,7 +734,7 @@ char *strdup(const char *s); The results might not be what you expect.

        -

        11.3 Features and the %feature directive

        +

        11.3 Features and the %feature directive

        @@ -1123,7 +1123,7 @@ specifying or not specifying default arguments in a feature is not applicable as in SWIG-1.3.23 when the approach to wrapping methods with default arguments was changed.

        -

        11.3.5 Feature example

        +

        11.3.5 Feature example

        diff --git a/Doc/Manual/Guile.html b/Doc/Manual/Guile.html index 61b5ba7d6..c39abcb46 100644 --- a/Doc/Manual/Guile.html +++ b/Doc/Manual/Guile.html @@ -409,7 +409,7 @@ See also the "multivalue" example. %feature("constasvar") can be applied to any constant, immutable variable, or enum. Instead of exporting the constant as a function that must be called, the constant will appear as a scheme variable. See -Features and the %feature directive +Features and the %feature directive for info on how to apply the %feature.

        20.6 Representation of pointers as smobs

        @@ -487,7 +487,7 @@ to the destructor for this type. The destructor is the generated wrapper around So swig still exports a wrapper for the destructor, it just does not call scm_c_define_gsubr() for the wrapped delete function. So the only way to delete an object is from the garbage collector, since the delete function is not available to scripts. How swig determines if a type should be garbage collected -is exactly like described in +is exactly like described in Object ownership and %newobject in the SWIG manual. All typemaps use an $owner var, and the guile module replaces $owner with 0 or 1 depending on feature:new.

        diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html index 7ae802998..5b457030e 100644 --- a/Doc/Manual/Java.html +++ b/Doc/Manual/Java.html @@ -250,7 +250,7 @@ rest of your C/C++ application. The name of the wrapper file is derived from the name of the input file. For example, if the input file is example.i, the name of the wrapper file is example_wrap.c. To change this, you can use the -o option. -It is also possible to change the output directory that the Java files are generated into using -outdir. +It is also possible to change the output directory that the Java files are generated into using -outdir.

        @@ -837,7 +837,7 @@ public interface exampleConstants { Note that SWIG has inferred the C type and used an appropriate Java type that will fit the range of all possible values for the C type. By default SWIG generates runtime constants. They are not compiler constants that can, for example, be used in a switch statement. This can be changed by using the %javaconst(flag) directive. It works like all -the other %feature directives. The default is %javaconst(0). +the other %feature directives. The default is %javaconst(0). It is possible to initialize all wrapped constants from pure Java code by placing a %javaconst(1) before SWIG parses the constants. Putting it at the top of your interface file would ensure this. Here is an example: @@ -3751,7 +3751,7 @@ in any way---the extensions only show up in the Java interface. If a C or C++ function throws an error, you may want to convert that error into a Java exception. To do this, you can use the %exception directive. The %exception directive simply lets you rewrite part of the generated wrapper code to include an error check. -It is detailed in full in the Exception handling with %exception section. +It is detailed in full in the Exception handling with %exception section.

        diff --git a/Doc/Manual/Library.html b/Doc/Manual/Library.html index 833a38393..c003151ac 100644 --- a/Doc/Manual/Library.html +++ b/Doc/Manual/Library.html @@ -893,7 +893,7 @@ char *foo(); This will release the result if the appropriate target language support is available. SWIG provides the appropriate "newfree" typemap for char * so that the memory is released, however, you may need to provide your own "newfree" typemap for other types. -See Object ownership and %newobject for more details. +See Object ownership and %newobject for more details.

        8.3.4 cstring.i

        diff --git a/Doc/Manual/Lisp.html b/Doc/Manual/Lisp.html index 53cddab83..0f1b45721 100644 --- a/Doc/Manual/Lisp.html +++ b/Doc/Manual/Lisp.html @@ -269,7 +269,7 @@ The generated SWIG Code will be: want to lispify the names, also, before we forget you want to export the generated lisp names. To do this, we will use the SWIG feature directive. + href="Customization.html#Customization_features">feature directive. Let's edit the interface file such that the C type "div_t*" is changed to Lisp type ":my-pointer", we lispify all names, export everything, and do some more stuff. diff --git a/Doc/Manual/Lua.html b/Doc/Manual/Lua.html index b236ab9f7..382e03fb6 100644 --- a/Doc/Manual/Lua.html +++ b/Doc/Manual/Lua.html @@ -1105,7 +1105,7 @@ will require a pcall, followed by a set of if statements checking the type of th

        All of this code assumes that your C++ code uses exception specification (which a lot doesn't). If it doesn't consult the "Exception handling with %catches" section -and the "Exception handling with %exception" section, for more details on how to +and the "Exception handling with %exception" section, for more details on how to add exception specification to functions or globally (respectively).

        diff --git a/Doc/Manual/Modula3.html b/Doc/Manual/Modula3.html index c4e485202..70d99c305 100644 --- a/Doc/Manual/Modula3.html +++ b/Doc/Manual/Modula3.html @@ -483,7 +483,7 @@ like
      • How to manage storage with the garbage collector of Modula-3? Support for - + %newobject and %typemap(newfree) isn't implemented, yet. What's about resources that are managed by the garbage collector @@ -494,7 +494,7 @@ as far as I know.
      • How to turn C++ exceptions into Modula-3 exceptions? There's also no support for - + %exception, yet.
      diff --git a/Doc/Manual/Modules.html b/Doc/Manual/Modules.html index 406bdeaef..094d4fd5d 100644 --- a/Doc/Manual/Modules.html +++ b/Doc/Manual/Modules.html @@ -13,7 +13,7 @@
    • Modules Introduction
    • Basics
    • The SWIG runtime code -
    • External access to the runtime +
    • External access to the runtime
    • A word of caution about static libraries
    • References
    • Reducing the wrapper file size @@ -241,7 +241,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.4 External access to the runtime

      +

      15.4 External access to the runtime

      As described in The run-time type checker, diff --git a/Doc/Manual/Perl5.html b/Doc/Manual/Perl5.html index 40500dc5a..777c2f6a2 100644 --- a/Doc/Manual/Perl5.html +++ b/Doc/Manual/Perl5.html @@ -2921,7 +2921,7 @@ not even sure if it really works).

      It is possible to override the SWIG generated proxy/shadow methods, using %feature("shadow"). -It works like all the other %feature directives. +It works like all the other %feature directives. Here is a simple example showing how to add some Perl debug code to the constructor:

      diff --git a/Doc/Manual/Ruby.html b/Doc/Manual/Ruby.html index 3b1e5c45c..c10702559 100644 --- a/Doc/Manual/Ruby.html +++ b/Doc/Manual/Ruby.html @@ -58,7 +58,7 @@
    • C++ namespaces
    • C++ templates
    • C++ Standard Template Library (STL) -
    • C++ STL Functors +
    • C++ STL Functors
    • C++ STL Iterators
    • C++ Smart Pointers
    • Cross-Language Polymorphism @@ -2336,7 +2336,7 @@ chapter.

      -

      32.3.14 C++ STL Functors

      +

      32.3.14 C++ STL Functors

      Some containers in the STL allow you to modify their default @@ -6089,7 +6089,7 @@ a function. For example:

      -

      See Object +

      See Object ownership and %newobject for further details.

      @@ -10050,7 +10050,7 @@ above. For example:

      In this case, the default SWIG behavior for calling member functions is incorrect. The Ruby object should assume ownership of the returned object. This can be done by using the %newobject directive. -See +See Object ownership and %newobject for more information.

      diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html index 02d0ca3a4..0479f30d7 100644 --- a/Doc/Manual/SWIG.html +++ b/Doc/Manual/SWIG.html @@ -1618,7 +1618,7 @@ double y; // Read-write

      The %mutable and %immutable directives are actually -%feature directives defined like this: +%feature directives defined like this:

      @@ -1742,7 +1742,7 @@ declarations.  If you need to remove a whole section of problematic code, the SW
       

      More powerful variants of %rename and %ignore directives can be used to help wrap C++ overloaded functions and methods or C++ methods which use default arguments. This is described in the -Ambiguity resolution and renaming section in the C++ chapter. +Ambiguity resolution and renaming section in the C++ chapter.

      diff --git a/Doc/Manual/SWIGPlus.html b/Doc/Manual/SWIGPlus.html index bcded9166..47ed38186 100644 --- a/Doc/Manual/SWIGPlus.html +++ b/Doc/Manual/SWIGPlus.html @@ -42,7 +42,7 @@

    • Wrapping overloaded operators @@ -1128,7 +1128,7 @@ For example if a method has ten default arguments, then eleven wrapper methods a

      Please see the Features and default arguments section for more information on using %feature with functions with default arguments. -The Ambiguity resolution and renaming section +The Ambiguity resolution and renaming section also deals with using %rename and %ignore on methods with default arguments. If you are writing your own typemaps for types used in methods with default arguments, you may also need to write a typecheck typemap. See the Typemaps and overloading section for details or otherwise @@ -2127,7 +2127,7 @@ it means that the target language module has not yet implemented support for ove functions and methods. The only way to fix the problem is to read the next section.

      -

      6.15.3 Ambiguity resolution and renaming

      +

      6.15.3 Ambiguity resolution and renaming

      @@ -4103,7 +4103,7 @@ more advanced namespace support.

      -Some target languages provide support for the nspace feature. +Some target languages provide support for the nspace feature. The feature can be applied to any class, struct, union or enum declared within a named namespace. The feature wraps the type within the target language specific concept of a namespace, for example, a Java package or C# namespace. @@ -4304,7 +4304,7 @@ is outlined in the "throws" typemap s

      Since exception specifications are sometimes only used sparingly, this alone may not be enough to properly handle C++ exceptions. To do that, a different set of special SWIG directives are used. -Consult the "Exception handling with %exception" section for details. +Consult the "Exception handling with %exception" section for details. The next section details a way of simulating an exception specification or replacing an existing one.

      diff --git a/Doc/Manual/Typemaps.html b/Doc/Manual/Typemaps.html index c815b31d0..dee2bcf7f 100644 --- a/Doc/Manual/Typemaps.html +++ b/Doc/Manual/Typemaps.html @@ -2503,7 +2503,7 @@ string *foo();
    • -See Object ownership and %newobject for further details. +See Object ownership and %newobject for further details.

      10.5.10 "memberin" typemap

      @@ -2587,7 +2587,7 @@ catch(char const *_e) {

      Note that if your methods do not have an exception specification yet they do throw exceptions, SWIG cannot know how to deal with them. -For a neat way to handle these, see the Exception handling with %exception section. +For a neat way to handle these, see the Exception handling with %exception section.

      10.6 Some typemap examples

      @@ -3075,7 +3075,7 @@ what the "optimal" attribute is telling SWIG to do.

      The "optimal" attribute optimisation is not turned on by default as it has a number of restrictions. Firstly, some code cannot be condensed into a simple call for passing into the copy constructor. -One common occurrence is when %exception is used. +One common occurrence is when %exception is used. Consider adding the following %exception to the example:

      @@ -3610,7 +3610,7 @@ structures are chained together in a circularly linked list.

      This section covers how to use these functions from typemaps. To learn how to call these functions from external files (not the generated _wrap.c file), see -the External access to the run-time system +the External access to the run-time system section.

      When pointers are converted in a typemap, the typemap code often looks diff --git a/Doc/Manual/Warnings.html b/Doc/Manual/Warnings.html index 5409248c9..96e35902a 100644 --- a/Doc/Manual/Warnings.html +++ b/Doc/Manual/Warnings.html @@ -102,7 +102,7 @@ int foo(double); // Silently ignored.

      The %warnfilter directive has the same semantics as other declaration modifiers like %rename, %ignore and %feature, see the -%feature directive section. For example, if you wanted to +%feature directive section. For example, if you wanted to suppress a warning for a method in a class hierarchy, you could do this:

      From c979cf55b04652a965b91fce642d3f17a7eccedf Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 6 Mar 2010 20:42:53 +0000 Subject: [PATCH 0775/1680] Correctly mangle the html section names to prevent name clashes in the pdf document git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11922 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/CSharp.html | 94 +++---- Doc/Manual/Contents.html | 280 +++++++++---------- Doc/Manual/Customization.html | 2 +- Doc/Manual/Java.html | 500 +++++++++++++++++----------------- Doc/Manual/Modula3.html | 92 +++---- 5 files changed, 484 insertions(+), 484 deletions(-) diff --git a/Doc/Manual/CSharp.html b/Doc/Manual/CSharp.html index 34d441b35..d489ebf09 100644 --- a/Doc/Manual/CSharp.html +++ b/Doc/Manual/CSharp.html @@ -9,35 +9,35 @@ @@ -45,7 +45,7 @@ -

      18.1 Introduction

      +

      18.1 Introduction

      @@ -65,7 +65,7 @@ The Microsoft Developer Network (MSDN) h Monodoc, available from the Mono project, has a very useful section titled Interop with native libraries.

      -

      18.2 Differences to the Java module

      +

      18.2 Differences to the Java module

      @@ -137,7 +137,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.

    • @@ -215,10 +215,10 @@ $jnicall -> $imcall

      Unlike the "javain" typemap, the "csin" typemap does not support the 'pgcpp' attribute as the C# module does not have a premature garbage collection prevention parameter. The "csin" typemap supports additional optional attributes called 'cshin' and 'terminator'. -The 'cshin' attribute should contain the parameter type and name whenever a constructor helper function is generated due to the 'pre' or 'post' attributes. +The 'cshin' attribute should contain the parameter type and name whenever a constructor helper function is generated due to the 'pre' or 'post' attributes. The 'terminator' attribute normally just contains a closing brace for when the 'pre' attribute contains an opening brace, such as when a C# using or fixed block is started. Note that 'pre', 'post', 'terminator' and 'cshin' attributes are not used for marshalling the property set. -Please see the Date marshalling example and Date marshalling of properties example for further understanding of these "csin" applicable attributes. +Please see the Date marshalling example and Date marshalling of properties example for further understanding of these "csin" applicable attributes.

    • @@ -255,7 +255,7 @@ public static extern IntPtr function(string jarg1); Support for type attributes. The 'imtype' and 'cstype' typemaps can have an optional inattributes and outattributes typemap attribute. The 'imtype' typemap can also have an optional directorinattributes and directoroutattributes -typemap attribute which attaches to director delegates, an implementation detail of directors, see directors implementation. +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. @@ -406,7 +406,7 @@ This feature is useful for some obscure cases where SWIG might get the virtu
    • - +

      The name of the intermediary class can be changed from its default, that is, the module name with PINVOKE appended after it. The module directive attribute imclassname is used to achieve this: @@ -441,7 +441,7 @@ if specified, otherwise it is equivalent to the $module special variable.

      $imclassname
      This special variable expands to the intermediary class name. For C# this is usually the same as '$modulePINVOKE' ('$moduleJNI' for Java), -unless the imclassname attribute is specified in the %module directive. +unless the imclassname attribute is specified in the %module directive.

      @@ -721,7 +721,7 @@ public static extern void myArrayCopy(IntPtr jarg1, IntPtr jarg2, int jarg3); -

      18.4 C# Exceptions

      +

      18.4 C# Exceptions

      @@ -818,7 +818,7 @@ set so should only be used when a C# exception is not created.

      -

      18.4.1 C# exception example using "check" typemap

      +

      18.4.1 C# exception example using "check" typemap

      @@ -1000,7 +1000,7 @@ method and C# code does not handle pending exceptions via the canthrow attribute Actually it will issue this warning for any function beginning with SWIG_CSharpSetPendingException.

      -

      18.4.2 C# exception example using %exception

      +

      18.4.2 C# exception example using %exception

      @@ -1065,7 +1065,7 @@ The managed code generated does check for the pending exception as mentioned ear -

      18.4.3 C# exception example using exception specifications

      +

      18.4.3 C# exception example using exception specifications

      @@ -1122,7 +1122,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_evensonly(int jarg1) { Multiple catch handlers are generated should there be more than one exception specifications declared.

      -

      18.4.4 Custom C# ApplicationException example

      +

      18.4.4 Custom C# ApplicationException example

      @@ -1256,7 +1256,7 @@ try { -

      18.5 C# Directors

      +

      18.5 C# Directors

      @@ -1266,10 +1266,10 @@ Essentially, it enables unmanaged C++ code to call back into managed code for vi

      The following sections provide information on the C# director implementation and contain most of the information required to use the C# directors. -However, the Java directors section should also be read in order to gain more insight into directors. +However, the Java directors section should also be read in order to gain more insight into directors.

      -

      18.5.1 Directors example

      +

      18.5.1 Directors example

      @@ -1390,7 +1390,7 @@ CSharpDerived - UIntMethod(123) -

      18.5.2 Directors implementation

      +

      18.5.2 Directors implementation

      @@ -1576,7 +1576,7 @@ void SwigDirector_Base::BaseBoolMethod(Base const &b, bool flag) { -

      18.5.3 Director caveats

      +

      18.5.3 Director caveats

      @@ -1624,7 +1624,7 @@ However, a call from C# to CSharpDefaults.DefaultMethod() will of cours should pass the call on to CSharpDefaults.DefaultMethod(int)using the C++ default value, as shown above.

      -

      18.6 C# Typemap examples

      +

      18.6 C# Typemap examples

      This section includes a few examples of typemaps. For more examples, you @@ -1632,12 +1632,12 @@ might look at the files "csharp.swg" and "typemaps.i" in the SWIG library. -

      18.6.1 Memory management when returning references to member variables

      +

      18.6.1 Memory management when returning references to member variables

      This example shows how to prevent premature garbage collection of objects when the underlying C++ class returns a pointer or reference to a member variable. -The example is a direct equivalent to this Java equivalent. +The example is a direct equivalent to this Java equivalent.

      @@ -1756,11 +1756,11 @@ public class Bike : IDisposable { Note the addReference call.

      -

      18.6.2 Memory management for objects passed to the C++ layer

      +

      18.6.2 Memory management for objects passed to the C++ layer

      -The example is a direct equivalent to this Java equivalent. +The example is a direct equivalent to this Java equivalent. Managing memory can be tricky when using C++ and C# proxy classes. The previous example shows one such case and this example looks at memory management for a class passed to a C++ method which expects the object to remain in scope after the function has returned. Consider the following two C++ classes: @@ -1875,14 +1875,14 @@ The 'cscode' typemap simply adds in the specified code into the C# proxy class. -

      18.6.3 Date marshalling using the csin typemap and associated attributes

      +

      18.6.3 Date marshalling using the csin typemap and associated attributes

      -The NaN Exception example is a simple example of the "javain" typemap and its 'pre' attribute. +The NaN Exception example is a simple example of the "javain" typemap and its 'pre' attribute. This example demonstrates how a C++ date class, say CDate, can be mapped onto the standard .NET date class, System.DateTime by using the 'pre', 'post' and 'pgcppname' attributes of the "csin" typemap (the C# equivalent to the "javain" typemap). -The example is an equivalent to the Java Date marshalling example. +The example is an equivalent to the Java Date marshalling example. The idea is that the System.DateTime is used wherever the C++ API uses a CDate. Let's assume the code being wrapped is as follows:

      @@ -2159,7 +2159,7 @@ public class example { -

      18.6.4 A date example demonstrating marshalling of C# properties

      +

      18.6.4 A date example demonstrating marshalling of C# properties

      @@ -2260,7 +2260,7 @@ Some points to note:

    -

    18.6.5 Turning wrapped classes into partial classes

    +

    18.6.5 Turning wrapped classes into partial classes

    @@ -2360,7 +2360,7 @@ demonstrating that the class contains methods calling both unmanaged code - The following example is an alternative approach to adding managed code to the generated proxy class.

    -

    18.6.6 Extending proxy classes with additional C# code

    +

    18.6.6 Extending proxy classes with additional C# code

    diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index 6ef9acf89..b5fda3b8d 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -623,35 +623,35 @@

    @@ -735,139 +735,139 @@
    @@ -957,38 +957,38 @@ diff --git a/Doc/Manual/Customization.html b/Doc/Manual/Customization.html index 2d1486b89..48f1fd476 100644 --- a/Doc/Manual/Customization.html +++ b/Doc/Manual/Customization.html @@ -854,7 +854,7 @@ In the following example, MyExceptionClass is the name of the Java clas

    -Further details can be obtained from the Java exception handling section. +Further details can be obtained from the Java exception handling section.

    11.3.2 Feature flags

    diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html index 5b457030e..902657220 100644 --- a/Doc/Manual/Java.html +++ b/Doc/Manual/Java.html @@ -9,139 +9,139 @@
    @@ -154,7 +154,7 @@ It covers most SWIG features, but certain low-level details are covered in less

    -

    21.1 Overview

    +

    21.1 Overview

    @@ -181,7 +181,7 @@ However, the "SWIG Basics" chapter will be a useful

    This chapter starts with a few practicalities on running SWIG and compiling the generated code. If you are looking for the minimum amount to read, have a look at the sections up to and including the -tour of basic C/C++ wrapping section which explains how to call the various C/C++ code constructs from Java. +tour of basic C/C++ wrapping section which explains how to call the various C/C++ code constructs from Java. Following this section are details of the C/C++ code and Java classes that SWIG generates. Due to the complexities of C and C++ there are different ways in which C/C++ code could be wrapped and called from Java. SWIG is a powerful tool and the rest of the chapter details how the default code wrapping can be tailored. @@ -189,7 +189,7 @@ Various customisation tips and techniques using SWIG directives are covered. The latter sections cover the advanced techniques of using typemaps for complete control of the wrapping process.

    -

    21.2 Preliminaries

    +

    21.2 Preliminaries

    @@ -205,7 +205,7 @@ Run make -k check from the SWIG root directory after installing SWIG on The Java module requires your system to support shared libraries and dynamic loading. This is the commonly used method to load JNI code so your system will more than likely support this.

    -

    21.2.1 Running SWIG

    +

    21.2.1 Running SWIG

    @@ -254,7 +254,7 @@ It is also possible to change the output directo

    -The module name, specified with %module, determines the name of various generated classes as discussed later. +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.

    @@ -264,7 +264,7 @@ The following sections have further practical examples and details on how you mi compiling and using the generated files.

    -

    21.2.2 Additional Commandline Options

    +

    21.2.2 Additional Commandline Options

    @@ -301,7 +301,7 @@ swig -java -help Their use will become clearer by the time you have finished reading this section on SWIG and Java.

    -

    21.2.3 Getting the right header files

    +

    21.2.3 Getting the right header files

    @@ -316,7 +316,7 @@ They are usually in directories like this:

    The exact location may vary on your machine, but the above locations are typical.

    -

    21.2.4 Compiling a dynamic module

    +

    21.2.4 Compiling a dynamic module

    @@ -344,15 +344,15 @@ is a useful reference for compiling on different platforms.

    Important
    If you are going to use optimisations turned on with gcc (for example -O2), ensure you also compile with -fno-strict-aliasing. The GCC optimisations have become -more aggressive from gcc-4.0 onwards and will result in code that fails with strict aliasing optimisations turned on. See the C/C++ to Java typemaps section for more details. +more aggressive from gcc-4.0 onwards and will result in code that fails with strict aliasing optimisations turned on. See the C/C++ to Java typemaps section for more details.

    The name of the shared library output file is important. -If the name of your SWIG module is "example", the name of the corresponding shared library file should be "libexample.so" (or equivalent depending on your machine, see Dynamic linking problems for more information). +If the name of your SWIG module is "example", the name of the corresponding shared library file should be "libexample.so" (or equivalent depending on your machine, see Dynamic linking problems for more information). The name of the module is specified using the %module directive or -module command line option.

    -

    21.2.5 Using your module

    +

    21.2.5 Using your module

    @@ -387,7 +387,7 @@ $ If it doesn't work have a look at the following section which discusses problems loading the shared library.

    -

    21.2.6 Dynamic linking problems

    +

    21.2.6 Dynamic linking problems

    @@ -474,7 +474,7 @@ The following section also contains some C++ specific linking problems and solut

    -

    21.2.7 Compilation problems and compiling with C++

    +

    21.2.7 Compilation problems and compiling with C++

    @@ -527,7 +527,7 @@ Finally make sure the version of JDK header files matches the version of Java th

    -

    21.2.8 Building on Windows

    +

    21.2.8 Building on Windows

    @@ -536,7 +536,7 @@ You will want to produce a DLL that can be loaded by the Java Virtual Machine. This section covers the process of using SWIG with Microsoft Visual C++ 6 although the procedure may be similar with other compilers. In order for everything to work, you will need to have a JDK installed on your machine in order to read the JNI header files.

    -

    21.2.8.1 Running SWIG from Visual Studio

    +

    21.2.8.1 Running SWIG from Visual Studio

    @@ -572,10 +572,10 @@ When doing a build, any changes made to the interface file will result in SWIG b

    The Java classes that SWIG output should also be compiled into .class files. To run the native code in the DLL (example.dll), make sure that it is in your path then run your Java program which uses it, as described in the previous section. -If the library fails to load have a look at Dynamic linking problems. +If the library fails to load have a look at Dynamic linking problems.

    -

    21.2.8.2 Using NMAKE

    +

    21.2.8.2 Using NMAKE

    @@ -634,7 +634,7 @@ Of course you may want to make changes for it to work for C++ by adding in the -

    -

    21.3 A tour of basic C/C++ wrapping

    +

    21.3 A tour of basic C/C++ wrapping

    @@ -644,7 +644,7 @@ variables are wrapped with JavaBean type getters and setters and so forth. This section briefly covers the essential aspects of this wrapping.

    -

    21.3.1 Modules, packages and generated Java classes

    +

    21.3.1 Modules, packages and generated Java classes

    @@ -680,7 +680,7 @@ 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

    +

    21.3.2 Functions

    @@ -714,7 +714,7 @@ System.out.println(example.fact(4)); -

    21.3.3 Global variables

    +

    21.3.3 Global variables

    @@ -801,7 +801,7 @@ extern char *path; // Read-only (due to %immutable) -

    21.3.4 Constants

    +

    21.3.4 Constants

    @@ -941,7 +941,7 @@ Or if you decide this practice isn't so bad and your own class implements ex

    -

    21.3.5 Enumerations

    +

    21.3.5 Enumerations

    @@ -955,7 +955,7 @@ The final two approaches use simple integers for each enum item. Before looking at the various approaches for wrapping named C/C++ enums, anonymous enums are considered.

    -

    21.3.5.1 Anonymous enums

    +

    21.3.5.1 Anonymous enums

    @@ -1018,7 +1018,7 @@ As in the case of constants, you can access them through either the module class

    -

    21.3.5.2 Typesafe enums

    +

    21.3.5.2 Typesafe enums

    @@ -1053,7 +1053,7 @@ public final class Beverage {

    -See Typesafe enum classes to see the omitted support methods. +See Typesafe enum classes to see the omitted support methods. Note that the enum item with an initializer (LAGER) is initialized with the enum value obtained via a JNI call. However, as with anonymous enums and constants, use of the %javaconst directive is strongly recommended to change this behaviour:

    @@ -1111,7 +1111,7 @@ When upgrading to JDK 1.5 or later, proper Java enums could be used instead, wit The following section details proper Java enum generation.

    -

    21.3.5.3 Proper Java enums

    +

    21.3.5.3 Proper Java enums

    @@ -1152,19 +1152,19 @@ public enum Beverage {

    -See Proper Java enum classes to see the omitted support methods. +See Proper Java enum classes to see the omitted support methods. The generated Java enum has numerous additional methods to support enums with initializers, such as LAGER above. Note that as with the typesafe enum pattern, enum items with initializers are by default initialized with the enum value obtained via a JNI call. However, this is not the case above as we have used the recommended %javaconst(1) to avoid the JNI call. -The %javaconstvalue(value) directive covered in the Constants section can also be used for proper Java enums. +The %javaconstvalue(value) directive covered in the Constants section can also be used for proper Java enums.

    The additional support methods need not be generated if none of the enum items have initializers and this is covered later in the -Simpler Java enums for enums without initializers section. +Simpler Java enums for enums without initializers section.

    -

    21.3.5.4 Type unsafe enums

    +

    21.3.5.4 Type unsafe enums

    @@ -1202,7 +1202,7 @@ public final class Beverage {

    As is the case previously, the default is %javaconst(0) as not all C/C++ values will compile as Java code. However, again it is recommended to add in a %javaconst(1) directive. -and the %javaconstvalue(value) directive covered in the Constants section can also be used for type unsafe enums. +and the %javaconstvalue(value) directive covered in the Constants section can also be used for type unsafe enums. Note that global enums are generated into a Java class within whatever package you are using. C++ enums defined within a C++ class are generated into a static final inner Java class within the Java proxy class.

    @@ -1212,7 +1212,7 @@ Note that unlike typesafe enums, this approach requires users to mostly use diff Thus the upgrade path to proper enums provided in JDK 1.5 is more painful.

    -

    21.3.5.5 Simple enums

    +

    21.3.5.5 Simple enums

    @@ -1221,7 +1221,7 @@ Each enum item is also wrapped as a static final integer. However, these integers are not generated into a class named after the C/C++ enum. Instead, global enums are generated into the constants interface. Also, enums defined in a C++ class have their enum items generated directly into the Java proxy class rather than an inner class within the Java proxy class. -In fact, this approach is effectively wrapping the enums as if they were anonymous enums and the resulting code is as per anonymous enums. +In fact, this approach is effectively wrapping the enums as if they were anonymous enums and the resulting code is as per anonymous enums. The implementation is in the "enumsimple.swg" file.

    @@ -1231,7 +1231,7 @@ SWIG-1.3.21 and earlier versions wrapped all enums using this approach. The type unsafe approach is preferable to this one and this simple approach is only included for backwards compatibility with these earlier versions of SWIG.

    -

    21.3.6 Pointers

    +

    21.3.6 Pointers

    @@ -1319,7 +1319,7 @@ C-style cast may return a bogus result whereas as the C++-style cast will return a NULL pointer if the conversion can't be performed.

    -

    21.3.7 Structures

    +

    21.3.7 Structures

    @@ -1428,8 +1428,8 @@ to by b.x. In this example, 16 integers would be copied. Like C, SWI no assumptions about bounds checking---if you pass a bad pointer, you may get a segmentation fault or access violation. The default wrapping makes it hard to set or get just one element of the array and so array access from Java is somewhat limited. -This can be changed easily though by using the approach outlined later in the Wrapping C arrays with Java arrays and -Unbounded C Arrays sections. +This can be changed easily though by using the approach outlined later in the Wrapping C arrays with Java arrays and +Unbounded C Arrays sections.

    @@ -1487,7 +1487,7 @@ x.setA(3); // Modify x.a - this is the same as b.f.a -

    21.3.8 C++ classes

    +

    21.3.8 C++ classes

    @@ -1550,7 +1550,7 @@ int bar = Spam.getBar(); -

    21.3.9 C++ inheritance

    +

    21.3.9 C++ inheritance

    @@ -1611,7 +1611,7 @@ Note that Java does not support multiple inheritance so any multiple inheritance A warning is given when multiple inheritance is detected and only the first base class is used.

    -

    21.3.10 Pointers, references, arrays and pass by value

    +

    21.3.10 Pointers, references, arrays and pass by value

    @@ -1666,7 +1666,7 @@ to hold the result and a pointer is returned (Java will release this memory when the returned object's finalizer is run by the garbage collector).

    -

    21.3.10.1 Null pointers

    +

    21.3.10.1 Null pointers

    @@ -1690,7 +1690,7 @@ For spam1 and spam4 above the Java null gets translat The converse also occurs, that is, NULL pointers are translated into null Java objects when returned from a C/C++ function.

    -

    21.3.11 C++ overloaded functions

    +

    21.3.11 C++ overloaded functions

    @@ -1805,7 +1805,7 @@ void spam(unsigned short); // Ignored -

    21.3.12 C++ default arguments

    +

    21.3.12 C++ default arguments

    @@ -1848,7 +1848,7 @@ Further details on default arguments and how to restore this approach are given

    -

    21.3.13 C++ namespaces

    +

    21.3.13 C++ namespaces

    @@ -1919,7 +1919,7 @@ As Java does not support types declared in a named package accessing types decla So if SWIG is run using the -package com.myco option, a wrapped class, MyWorld::Material::Color, can then be accessed as com.myco.MyWorld.Material.Color.

    -

    21.3.14 C++ templates

    +

    21.3.14 C++ templates

    @@ -1968,7 +1968,7 @@ Obviously, there is more to template wrapping than shown in this example. More details can be found in the SWIG and C++ chapter.

    -

    21.3.15 C++ Smart Pointers

    +

    21.3.15 C++ Smart Pointers

    @@ -2052,7 +2052,7 @@ Foo f = p.__deref__(); // Returns underlying Foo * -

    21.4 Further details on the generated Java classes

    +

    21.4 Further details on the generated Java classes

    @@ -2067,7 +2067,7 @@ Finally enum classes are covered. First, the crucial intermediary JNI class is considered.

    -

    21.4.1 The intermediary JNI class

    +

    21.4.1 The intermediary JNI class

    @@ -2154,7 +2154,7 @@ class exampleJNI {

    This class contains the complete Java - C/C++ interface so all function calls go via this class. -As this class acts as a go-between for all JNI calls to C/C++ code from the Java proxy classes, type wrapper classes and module class, it is known as the intermediary JNI class. +As this class acts as a go-between for all JNI calls to C/C++ code from the Java proxy classes, type wrapper classes and module class, it is known as the intermediary JNI class.

    @@ -2163,14 +2163,14 @@ This approach leads to minimal JNI code which makes for better performance as JN SWIG favours generating Java code over JNI code as Java code is compiled into byte code and avoids the costly string operations needed in JNI code. This approach has a downside though as the proxy class might get collected before the native method has completed. You might notice above that there is an additional parameters with a underscore postfix, eg jarg1_. -These are added in order to prevent premature garbage collection when marshalling proxy classes. +These are added in order to prevent premature garbage collection when marshalling proxy classes.

    The functions in the intermediary JNI class cannot be accessed outside of its package. Access to them is gained through the module class for globals otherwise the appropriate proxy class.

    - +

    The name of the intermediary JNI class can be changed from its default, that is, the module name with JNI appended after it. The module directive attribute jniclassname is used to achieve this: @@ -2187,7 +2187,7 @@ If name is the same as modulename then the module class name g from modulename to modulenameModule.

    -

    21.4.1.1 The intermediary JNI class pragmas

    +

    21.4.1.1 The intermediary JNI class pragmas

    @@ -2266,7 +2266,7 @@ For example, let's change the intermediary JNI class access to public. All the methods in the intermediary JNI class will then be callable outside of the package as the method modifiers are public by default.

    -

    21.4.2 The Java module class

    +

    21.4.2 The Java module class

    @@ -2297,7 +2297,7 @@ example.egg(new Foo()); The primary reason for having the module class wrapping the calls in the intermediary JNI class is to implement static type checking. In this case only a Foo can be passed to the egg function, whereas any long can be passed to the egg function in the intermediary JNI class.

    -

    21.4.2.1 The Java module class pragmas

    +

    21.4.2.1 The Java module class pragmas

    @@ -2344,11 +2344,11 @@ The pragma code appears in the generated module class like this:

    -See The intermediary JNI class pragmas section for further details on using pragmas. +See The intermediary JNI class pragmas section for further details on using pragmas.

    -

    21.4.3 Java proxy classes

    +

    21.4.3 Java proxy classes

    @@ -2424,7 +2424,7 @@ int y = f.spam(5, new Foo()); -

    21.4.3.1 Memory management

    +

    21.4.3.1 Memory management

    @@ -2518,7 +2518,7 @@ you're lucky, you will only get a segmentation fault. To work around this, the ownership flag of o needs changing to false. The ownership flag is a private member variable of the proxy class so this is not possible without some customization of the proxy class. This can be achieved by using a typemap to customise the proxy class with pure Java code as detailed later in the section on -Java typemaps. +Java typemaps.

    @@ -2580,13 +2580,13 @@ Obj obj = Factory.createObj(); // obj.swigCMemOwn = true; Some memory management issues are quite tricky to fix and may only be noticeable after using for a long time. One such issue is premature garbage collection of an object created from Java and resultant usage from C++ code. The section on typemap examples cover two such scenarios, -Memory management for objects passed to the C++ layer +Memory management for objects passed to the C++ layer and -Memory management when returning references to member variables +Memory management when returning references to member variables

    -

    21.4.3.2 Inheritance

    +

    21.4.3.2 Inheritance

    @@ -2698,11 +2698,11 @@ This is a necessity as C++ compilers are free to implement pointers in the inher It is of course possible to extend Base using your own Java classes. If Derived is provided by the C++ code, you could for example add in a pure Java class Extended derived from Base. There is a caveat and that is any C++ code will not know about your pure Java class Extended so this type of derivation is restricted. -However, true cross language polymorphism can be achieved using the directors feature. +However, true cross language polymorphism can be achieved using the directors feature.

    -

    21.4.3.3 Proxy classes and garbage collection

    +

    21.4.3.3 Proxy classes and garbage collection

    @@ -2776,7 +2776,7 @@ The SWIG generated code ensures that the memory is not deleted twice, in the eve

    Write your own object manager in Java. You could derive all SWIG classes from a single base class which could track which objects have had their finalizers run, then call the rest of them on program termination. -The section on Java typemaps details how to specify a pure Java base class. +The section on Java typemaps details how to specify a pure Java base class.

  • @@ -2785,7 +2785,7 @@ The section on Java typemaps details how to specify See the How to Handle Java Finalization's Memory-Retention Issues article for alternative approaches to managing memory by avoiding finalizers altogether.

    -

    21.4.3.4 The premature garbage collection prevention parameter for proxy class marshalling

    +

    21.4.3.4 The premature garbage collection prevention parameter for proxy class marshalling

    @@ -2894,7 +2894,7 @@ The implementation for this extra parameter generation requires the "jtype" type

    The additional parameter does impose a slight performance overhead and the parameter generation can be suppressed globally with the -nopgcpp commandline option. -More selective suppression is possible with the 'nopgcpp' attribute in the "jtype" Java typemap. +More selective suppression is possible with the 'nopgcpp' attribute in the "jtype" Java typemap. The attribute is a flag and so should be set to "1" to enable the suppression, or it can be omitted or set to "0" to disable. For example:

    @@ -2907,7 +2907,7 @@ For example: Compatibility note: The generation of this additional parameter did not occur in versions prior to SWIG-1.3.30.

    -

    21.4.3.5 Single threaded applications and thread safety

    +

    21.4.3.5 Single threaded applications and thread safety

    @@ -2995,7 +2995,7 @@ for (int i=0; i<100000; i++) { -

    21.4.4 Type wrapper classes

    +

    21.4.4 Type wrapper classes

    @@ -3024,7 +3024,7 @@ public class SWIGTYPE_p_int { The methods do not have public access, so by default it is impossible to do anything with objects of this class other than pass them around. The methods in the class are part of the inner workings of SWIG. If you need to mess around with pointers you will have to use some typemaps specific to the Java module to achieve this. -The section on Java typemaps details how to modify the generated code. +The section on Java typemaps details how to modify the generated code.

    @@ -3082,16 +3082,16 @@ public static void spam(SWIGTYPE_p_int x, SWIGTYPE_p_int y, int z) { ... } -

    21.4.5 Enum classes

    +

    21.4.5 Enum classes

    SWIG can generate three types of enum classes. -The Enumerations section discussed these but omitted all the details. +The Enumerations section discussed these but omitted all the details. The following sub-sections detail the various types of enum classes that can be generated.

    -

    21.4.5.1 Typesafe enum classes

    +

    21.4.5.1 Typesafe enum classes

    @@ -3175,7 +3175,7 @@ The swigValue method is used for marshalling in the other direction. The toString method is overridden so that the enum name is available.

    -

    21.4.5.2 Proper Java enum classes

    +

    21.4.5.2 Proper Java enum classes

    @@ -3250,10 +3250,10 @@ The next variable is in the SwigNext inner class rather than i Marshalling between Java enums and the C/C++ enum integer value is handled via the swigToEnum and swigValue methods. All the constructors and methods in the Java enum are required just to handle C/C++ enums with initializers. These needn't be generated if the enum being wrapped does not have any initializers and the -Simpler Java enums for enums without initializers section describes how typemaps can be used to achieve this. +Simpler Java enums for enums without initializers section describes how typemaps can be used to achieve this.

    -

    21.4.5.3 Type unsafe enum classes

    +

    21.4.5.3 Type unsafe enum classes

    @@ -3284,7 +3284,7 @@ public final class Beverage { -

    21.5 Cross language polymorphism using directors

    +

    21.5 Cross language polymorphism using directors

    @@ -3306,7 +3306,7 @@ The upshot is that C++ classes can be extended in Java and from C++ these extens Neither C++ code nor Java code needs to know where a particular method is implemented: the combination of proxy classes, director classes, and C wrapper functions transparently takes care of all the cross-language method routing.

    -

    21.5.1 Enabling directors

    +

    21.5.1 Enabling directors

    @@ -3377,7 +3377,7 @@ public: -

    21.5.2 Director classes

    +

    21.5.2 Director classes

    @@ -3404,7 +3404,7 @@ If the correct implementation is in Java, the Java API is used to call the metho

    -

    21.5.3 Overhead and code bloat

    +

    21.5.3 Overhead and code bloat

    @@ -3422,7 +3422,7 @@ This situation can be optimized by selectively enabling director methods (using

    -

    21.5.4 Simple directors example

    +

    21.5.4 Simple directors example

    @@ -3487,7 +3487,7 @@ DirectorDerived::upcall_method() invoked. -

    21.5.5 Director threading issues

    +

    21.5.5 Director threading issues

    @@ -3507,7 +3507,7 @@ Macros can be defined on the commandline when compiling your C++ code, or altern -

    21.6 Accessing protected members

    +

    21.6 Accessing protected members

    @@ -3603,7 +3603,7 @@ class MyProtectedBase extends ProtectedBase -

    21.7 Common customization features

    +

    21.7 Common customization features

    @@ -3615,7 +3615,7 @@ be awkward. This section describes some common SWIG features that are used to improve the interface to existing C/C++ code.

    -

    21.7.1 C/C++ helper functions

    +

    21.7.1 C/C++ helper functions

    @@ -3681,7 +3681,7 @@ hard to implement. It is possible to improve on this using Java code, typemaps, customization features as covered in later sections, but sometimes helper functions are a quick and easy solution to difficult cases.

    -

    21.7.2 Class extension with %extend

    +

    21.7.2 Class extension with %extend

    @@ -3744,7 +3744,7 @@ Vector(2,3,4) in any way---the extensions only show up in the Java interface.

    -

    21.7.3 Exception handling with %exception and %javaexception

    +

    21.7.3 Exception handling with %exception and %javaexception

    @@ -3821,7 +3821,7 @@ The $action is a SWIG special variable and is replaced by the C/C++ f The return $null; handles all native method return types, namely those that have a void return and those that do not. This is useful for typemaps that will be used in native method returning all return types. See the section on -Java special variables for further explanation. +Java special variables for further explanation.

    @@ -3900,10 +3900,10 @@ It is however possible to write JNI calls which will compile under both C and C+

    The language-independent exception.i library file can also be used to raise exceptions. See the SWIG Library chapter. -The typemap example Handling C++ exception specifications as Java exceptions provides further exception handling capabilities. +The typemap example Handling C++ exception specifications as Java exceptions provides further exception handling capabilities.

    -

    21.7.4 Method access with %javamethodmodifiers

    +

    21.7.4 Method access with %javamethodmodifiers

    @@ -3929,7 +3929,7 @@ protected static void protect_me() { -

    21.8 Tips and techniques

    +

    21.8 Tips and techniques

    @@ -3939,7 +3939,7 @@ strings and arrays. This chapter discusses the common techniques for solving these problems.

    -

    21.8.1 Input and output parameters using primitive pointers and references

    +

    21.8.1 Input and output parameters using primitive pointers and references

    @@ -4113,7 +4113,7 @@ void foo(Bar *OUTPUT); will not have the intended effect since typemaps.i does not define an OUTPUT rule for Bar.

    -

    21.8.2 Simple pointers

    +

    21.8.2 Simple pointers

    @@ -4179,7 +4179,7 @@ System.out.println("3 + 4 = " + result); See the SWIG Library chapter for further details.

    -

    21.8.3 Wrapping C arrays with Java arrays

    +

    21.8.3 Wrapping C arrays with Java arrays

    @@ -4246,7 +4246,7 @@ Please be aware that the typemaps in this library are not efficient as all the e There is an alternative approach using the SWIG array library and this is covered in the next section.

    -

    21.8.4 Unbounded C Arrays

    +

    21.8.4 Unbounded C Arrays

    @@ -4391,7 +4391,7 @@ well suited for applications in which you need to create buffers, package binary data, etc.

    -

    21.8.5 Overriding new and delete to allocate from Java heap

    +

    21.8.5 Overriding new and delete to allocate from Java heap

    @@ -4508,7 +4508,7 @@ model and use these functions in place of malloc and free in your own code.

    -

    21.9 Java typemaps

    +

    21.9 Java typemaps

    @@ -4529,7 +4529,7 @@ Before proceeding, it should be stressed that typemaps are not a required part of using SWIG---the default wrapping behavior is enough in most cases. Typemaps are only used if you want to change some aspect of the generated code. -

    21.9.1 Default primitive type mappings

    +

    21.9.1 Default primitive type mappings

    @@ -4696,7 +4696,7 @@ So in summary, the C/C++ pointer to non-primitive types is cast into the 64 bit The Java type is either the proxy class or type wrapper class.

    -

    21.9.3 Sixty four bit JVMs

    +

    21.9.3 Sixty four bit JVMs

    @@ -4709,7 +4709,7 @@ Unfortunately it won't of course hold true for JNI code.

    -

    21.9.4 What is a typemap?

    +

    21.9.4 What is a typemap?

    @@ -4832,7 +4832,7 @@ int c = example.count('e',"Hello World"); -

    21.9.5 Typemaps for mapping C/C++ types to Java types

    +

    21.9.5 Typemaps for mapping C/C++ types to Java types

    @@ -4886,7 +4886,7 @@ The most important of these implement the mapping of C/C++ types to Java types: These are Java code typemaps which transform the type used in the Java intermediary JNI class (as specified in the "jtype" typemap) to the Java type used in the Java module class, proxy classes and type wrapper classes (as specified in the "jstype" typemap). This typemap provides the conversion for the parameters in the director methods when calling up from C++ to Java. - See Director typemaps. + See Director typemaps. @@ -4895,7 +4895,7 @@ The most important of these implement the mapping of C/C++ types to Java types: These are Java code typemaps which transform the type used in the Java module class, proxy classes and type wrapper classes (as specified in the "jstype" typemap) to the type used in the Java intermediary JNI class (as specified in the "jtype" typemap). This typemap provides the conversion for the return type in the director methods when returning from the C++ to Java upcall. - See Director typemaps. + See Director typemaps. @@ -4903,7 +4903,7 @@ The most important of these implement the mapping of C/C++ types to Java types: Conversion from C++ type to jni type for director methods. These are C++ typemaps which convert the parameters used in the C++ director method to the appropriate JNI intermediary type. The conversion is done in JNI code prior to calling the Java function from the JNI code. - See Director typemaps. + See Director typemaps. @@ -4911,7 +4911,7 @@ The most important of these implement the mapping of C/C++ types to Java types: Conversion from jni type to C++ type for director methods. These are C++ typemaps which convert the JNI return type used in the C++ director method to the appropriate C++ return type. The conversion is done in JNI code after calling the Java function from the JNI code. - See Director typemaps. + See Director typemaps. @@ -4989,12 +4989,12 @@ SWIGEXPORT jlong JNICALL Java_exampleJNI_FooBar(JNIEnv *jenv, jclass jcls,

    If you are using gcc as your C compiler, you might get a "dereferencing type-punned pointer will break strict-aliasing rules" warning about this. -Please see Compiling a dynamic module to avoid runtime problems with these strict aliasing rules. +Please see Compiling a dynamic module to avoid runtime problems with these strict aliasing rules.

    The default code generated by SWIG for the Java module comes from the typemaps in the "java.swg" library file which implements the -Default primitive type mappings and +Default primitive type mappings and Default typemaps for non-primitive types covered earlier. There are other type mapping typemaps in the Java library. These are listed below: @@ -5092,7 +5092,7 @@ These are listed below: -

    21.9.6 Java typemap attributes

    +

    21.9.6 Java typemap attributes

    @@ -5102,7 +5102,7 @@ There are a few additional typemap attributes that the Java module supports.

    The first of these is the 'throws' attribute. The throws attribute is optional and specified after the typemap name and contains one or more comma separated classes for adding to the throws clause for any methods that use that typemap. -It is analogous to the %javaexception feature's throws attribute. +It is analogous to the %javaexception feature's throws attribute.

    @@ -5114,7 +5114,7 @@ It is analogous to the %javaexception feature'

    The attribute is necessary for supporting Java checked exceptions and can be added to just about any typemap. The list of typemaps include all the C/C++ (JNI) typemaps in the "Typemaps" chapter and the -Java specific typemaps listed in the previous section, barring +Java specific typemaps listed in the previous section, barring the "jni", "jtype" and "jstype" typemaps as they could never contain code to throw an exception.

    @@ -5122,23 +5122,23 @@ the "jni", "jtype" and "jstype" typemaps as they could never contain code to thr The throws clause is generated for the proxy method as well as the JNI method in the JNI intermediary class. If a method uses more than one typemap and each of those typemaps have classes specified in the throws clause, the union of the exception classes is added to the throws clause ensuring there are no duplicate classes. -See the NaN exception example for further usage. +See the NaN exception example for further usage.

    -The "jtype" typemap has the optional 'nopgcpp' attribute which can be used to suppress the generation of the premature garbage collection prevention parameter. +The "jtype" typemap has the optional 'nopgcpp' attribute which can be used to suppress the generation of the premature garbage collection prevention parameter.

    -The "javain" typemap has the optional 'pre', 'post' and 'pgcppname' attributes. These are used for generating code before and after the JNI call in the proxy class or module class. The 'pre' attribute contains code that is generated before the JNI call and the 'post' attribute contains code generated after the JNI call. The 'pgcppname' attribute is used to change the premature garbage collection prevention parameter name passed to the JNI function. This is sometimes needed when the 'pre' typemap creates a temporary variable which is then passed to the JNI function. +The "javain" typemap has the optional 'pre', 'post' and 'pgcppname' attributes. These are used for generating code before and after the JNI call in the proxy class or module class. The 'pre' attribute contains code that is generated before the JNI call and the 'post' attribute contains code generated after the JNI call. The 'pgcppname' attribute is used to change the premature garbage collection prevention parameter name passed to the JNI function. This is sometimes needed when the 'pre' typemap creates a temporary variable which is then passed to the JNI function.

    - -Note that when the 'pre' or 'post' attributes are specified and the associated type is used in a constructor, a constructor helper function is generated. This is necessary as the Java proxy constructor wrapper makes a call to a support constructor using a this call. In Java the this call must be the first statement in the constructor body. The constructor body thus calls the helper function and the helper function instead makes the JNI call, ensuring the 'pre' code is called before the JNI call is made. There is a Date marshalling example showing 'pre', 'post' and 'pgcppname' attributes in action. + +Note that when the 'pre' or 'post' attributes are specified and the associated type is used in a constructor, a constructor helper function is generated. This is necessary as the Java proxy constructor wrapper makes a call to a support constructor using a this call. In Java the this call must be the first statement in the constructor body. The constructor body thus calls the helper function and the helper function instead makes the JNI call, ensuring the 'pre' code is called before the JNI call is made. There is a Date marshalling example showing 'pre', 'post' and 'pgcppname' attributes in action.

    -

    21.9.7 Java special variables

    +

    21.9.7 Java special variables

    @@ -5267,7 +5267,7 @@ can be wrapped with the Java equivalent, that is, static inner proxy classes.

    $jniinput, $javacall and $packagepath
    -These special variables are used in the directors typemaps. See Director specific typemaps for details. +These special variables are used in the directors typemaps. See Director specific typemaps for details.

    @@ -5278,10 +5278,10 @@ This special variable expands to the module name, as specified by %module $imclassname
    This special variable expands to the intermediary class name. Usually this is the same as '$moduleJNI', -unless the jniclassname attribute is specified in the %module directive. +unless the jniclassname attribute is specified in the %module directive.

    -

    21.9.8 Typemaps for both C and C++ compilation

    +

    21.9.8 Typemaps for both C and C++ compilation

    @@ -5318,7 +5318,7 @@ If you do not intend your code to be targeting both C and C++ then your typemaps

    -

    21.9.9 Java code typemaps

    +

    21.9.9 Java code typemaps

    @@ -5517,7 +5517,7 @@ For the typemap to be used in all type wrapper classes, all the different types Again this is the same that is in "java.swg", barring the method modifier for getCPtr.

    -

    21.9.10 Director specific typemaps

    +

    21.9.10 Director specific typemaps

    @@ -5543,7 +5543,7 @@ For example, integers are converted as follows:

    $input is the SWIG name of the JNI temporary variable passed to Java in the upcall. The descriptor="I" will put an I into the JNI field descriptor that identifies the Java method that will be called from C++. -For more about JNI field descriptors and their importance, refer to the JNI documentation mentioned earlier. +For more about JNI field descriptors and their importance, refer to the JNI documentation mentioned earlier. A typemap for C character strings is:

    @@ -5742,7 +5742,7 @@ The basic strategy here is to provide a default package typemap for the majority
    -

    21.10 Typemap Examples

    +

    21.10 Typemap Examples

    @@ -5752,11 +5752,11 @@ the SWIG library.

    -

    21.10.1 Simpler Java enums for enums without initializers

    +

    21.10.1 Simpler Java enums for enums without initializers

    -The default Proper Java enums approach to wrapping enums is somewhat verbose. +The default Proper Java enums approach to wrapping enums is somewhat verbose. This is to handle all possible C/C++ enums, in particular enums with initializers. The generated code can be simplified if the enum being wrapped does not have any initializers.

    @@ -5831,7 +5831,7 @@ This would be done by using the original versions of these typemaps in "enums.sw

    -

    21.10.2 Handling C++ exception specifications as Java exceptions

    +

    21.10.2 Handling C++ exception specifications as Java exceptions

    @@ -5899,7 +5899,7 @@ If, however, we wanted to throw a checked exception, say java.io.IOException

    -Note that this typemap uses the 'throws' typemap attribute to ensure a throws clause is generated. +Note that this typemap uses the 'throws' typemap attribute to ensure a throws clause is generated. The generated proxy method then specifies the checked exception by containing java.io.IOException in the throws clause:

    @@ -5956,7 +5956,7 @@ We could alternatively have used %rename to rename what() into

    -

    21.10.3 NaN Exception - exception handling for a particular type

    +

    21.10.3 NaN Exception - exception handling for a particular type

    @@ -6056,13 +6056,13 @@ public class example {

    -See the Date marshalling example for an example using further "javain" typemap attributes. +See the Date marshalling example for an example using further "javain" typemap attributes.

    If we decide that what we actually want is a checked exception instead of a runtime exception, we can change this easily enough. The proxy method that uses float as an input, must then add the exception class to the throws clause. -SWIG can handle this as it supports the 'throws' typemap attribute for specifying classes for the throws clause. +SWIG can handle this as it supports the 'throws' typemap attribute for specifying classes for the throws clause. Thus we can modify the pragma and the typemap for the throws clause:

    @@ -6111,7 +6111,7 @@ If we were a martyr to the JNI cause, we could replace the succinct code within If we had, we would have put it in the "in" typemap which, like all JNI and Java typemaps, also supports the 'throws' attribute.

    -

    21.10.4 Converting Java String arrays to char **

    +

    21.10.4 Converting Java String arrays to char **

    @@ -6255,7 +6255,7 @@ Lastly the "jni", "jtype" and "jstype" typemaps are also required to specify what Java types to use.

    -

    21.10.5 Expanding a Java object to multiple arguments

    +

    21.10.5 Expanding a Java object to multiple arguments

    @@ -6337,7 +6337,7 @@ example.foo(new String[]{"red", "green", "blue", "white"}); -

    21.10.6 Using typemaps to return arguments

    +

    21.10.6 Using typemaps to return arguments

    @@ -6455,7 +6455,7 @@ $ java runme 1 12.0 340.0 -

    21.10.7 Adding Java downcasts to polymorphic return types

    +

    21.10.7 Adding Java downcasts to polymorphic return types

    @@ -6661,7 +6661,7 @@ SWIG usually generates code which constructs the proxy classes using Java code a Note that the JNI code above uses a number of string lookups to call a constructor, whereas this would not occur using byte compiled Java code.

    -

    21.10.8 Adding an equals method to the Java classes

    +

    21.10.8 Adding an equals method to the Java classes

    @@ -6705,7 +6705,7 @@ System.out.println("foo1? " + foo1.equals(foo2)); -

    21.10.9 Void pointers and a common Java base class

    +

    21.10.9 Void pointers and a common Java base class

    @@ -6764,7 +6764,7 @@ This example contains some useful functionality which you may want in your code.

  • It also has a function which effectively implements a cast from the type of the proxy/type wrapper class to a void pointer. This is necessary for passing a proxy class or a type wrapper class to a function that takes a void pointer. -

    21.10.10 Struct pointer to pointer

    +

    21.10.10 Struct pointer to pointer

    @@ -6944,7 +6944,7 @@ The C functional interface has been completely morphed into an object-oriented i the Butler class would behave much like any pure Java class and feel more natural to Java users.

    -

    21.10.11 Memory management when returning references to member variables

    +

    21.10.11 Memory management when returning references to member variables

    @@ -7067,7 +7067,7 @@ public class Bike { Note the addReference call.

    -

    21.10.12 Memory management for objects passed to the C++ layer

    +

    21.10.12 Memory management for objects passed to the C++ layer

    @@ -7183,11 +7183,11 @@ The 'javacode' typemap simply adds in the specified code into the Java proxy cla -

    21.10.13 Date marshalling using the javain typemap and associated attributes

    +

    21.10.13 Date marshalling using the javain typemap and associated attributes

    -The NaN Exception example is a simple example of the "javain" typemap and its 'pre' attribute. +The NaN Exception example is a simple example of the "javain" typemap and its 'pre' attribute. This example demonstrates how a C++ date class, say CDate, can be mapped onto the standard Java date class, java.util.GregorianCalendar by using the 'pre', 'post' and 'pgcppname' attributes of the "javain" typemap. The idea is that the GregorianCalendar is used wherever the C++ API uses a CDate. @@ -7354,13 +7354,13 @@ A few things to note: more local variables with the same name would be generated.

  • The use of the "javain" typemap causes a constructor helper function (SwigConstructAction) to be generated. This allows Java code to be called before the JNI call and is required as the Java compiler won't compile code inserted before the 'this' call. -
  • The 'pgcppname' attribute is used to modify the object being passed as the premature garbage collection prevention parameter (the 2nd and 4th parameters in the JNI calls). +
  • The 'pgcppname' attribute is used to modify the object being passed as the premature garbage collection prevention parameter (the 2nd and 4th parameters in the JNI calls). -

    21.11 Living with Java Directors

    +

    21.11 Living with Java Directors

    @@ -7541,10 +7541,10 @@ public abstract class UserVisibleFoo extends Foo {

  • -

    21.12 Odds and ends

    +

    21.12 Odds and ends

    -

    21.12.1 JavaDoc comments

    +

    21.12.1 JavaDoc comments

    @@ -7600,7 +7600,7 @@ public class Barmy { -

    21.12.2 Functional interface without proxy classes

    +

    21.12.2 Functional interface without proxy classes

    @@ -7661,7 +7661,7 @@ All destructors have to be called manually for example the delete_Foo(foo) -

    21.12.3 Using your own JNI functions

    +

    21.12.3 Using your own JNI functions

    @@ -7711,7 +7711,7 @@ This directive is only really useful if you want to mix your own hand crafted JN

    -

    21.12.4 Performance concerns and hints

    +

    21.12.4 Performance concerns and hints

    @@ -7732,7 +7732,7 @@ However, you will have to be careful about memory management and make sure that This method normally calls the C++ destructor or free() for C code.

    -

    21.12.5 Debugging

    +

    21.12.5 Debugging

    @@ -7754,7 +7754,7 @@ The -verbose:jni and -verbose:gc are also useful options for monitoring code beh

    -

    21.13 Examples

    +

    21.13 Examples

    diff --git a/Doc/Manual/Modula3.html b/Doc/Manual/Modula3.html index 70d99c305..6ed36cf45 100644 --- a/Doc/Manual/Modula3.html +++ b/Doc/Manual/Modula3.html @@ -9,38 +9,38 @@

    @@ -57,7 +57,7 @@ especially typemaps.

    -

    24.1 Overview

    +

    24.1 Overview

    @@ -90,7 +90,7 @@ So the introduction got a bit longer than it should ... ;-)

    -

    24.1.1 Why not scripting ?

    +

    24.1.1 Why not scripting ?

    @@ -126,7 +126,7 @@ are not advantages of the language itself but can be provided by function libraries.

    -

    24.1.2 Why Modula-3 ?

    +

    24.1.2 Why Modula-3 ?

    @@ -166,7 +166,7 @@ it's statically typed, too.

    -

    24.1.3 Why C / C++ ?

    +

    24.1.3 Why C / C++ ?

    @@ -179,7 +179,7 @@ Even more fortunately even non-C libraries may provide C header files. This is where SWIG becomes helpful.

    -

    24.1.4 Why SWIG ?

    +

    24.1.4 Why SWIG ?

    @@ -252,10 +252,10 @@ integrate Modula-3 code into a C / C++ project.

    -

    24.2 Conception

    +

    24.2 Conception

    -

    24.2.1 Interfaces to C libraries

    +

    24.2.1 Interfaces to C libraries

    @@ -404,7 +404,7 @@ and the principal type must be renamed (%typemap).

    -

    24.2.2 Interfaces to C++ libraries

    +

    24.2.2 Interfaces to C++ libraries

    @@ -477,8 +477,8 @@ Is it possible to sub-class C++ classes with Modula-3 code? This issue is addressed by directors, a feature that was experimentally added to some Language modules like -Java and -Python. +Java and +Python.

  • How to manage storage with the garbage collector of Modula-3? @@ -505,10 +505,10 @@ There is no C++ library I wrote a SWIG interface for, so I'm not sure if this is possible or sensible, yet.

    -

    24.3 Preliminaries

    +

    24.3 Preliminaries

    -

    24.3.1 Compilers

    +

    24.3.1 Compilers

    @@ -522,7 +522,7 @@ For testing examples I use Critical Mass cm3.

    -

    24.3.2 Additional Commandline Options

    +

    24.3.2 Additional Commandline Options

    @@ -599,10 +599,10 @@ Instead generate templates for some basic typemaps. -

    24.4 Modula-3 typemaps

    +

    24.4 Modula-3 typemaps

    -

    24.4.1 Inputs and outputs

    +

    24.4.1 Inputs and outputs

    @@ -818,7 +818,7 @@ consist of the following parts: -

    24.4.2 Subranges, Enumerations, Sets

    +

    24.4.2 Subranges, Enumerations, Sets

    @@ -870,7 +870,7 @@ that I'd like to automate.

    -

    24.4.3 Objects

    +

    24.4.3 Objects

    @@ -883,7 +883,7 @@ is not really useful, yet.

    -

    24.4.4 Imports

    +

    24.4.4 Imports

    @@ -918,7 +918,7 @@ IMPORT M3toC; -

    24.4.5 Exceptions

    +

    24.4.5 Exceptions

    @@ -942,7 +942,7 @@ you should declare %typemap("m3wrapinconv:throws") blah * %{OSError.E%}.

    -

    24.4.6 Example

    +

    24.4.6 Example

    @@ -989,10 +989,10 @@ where almost everything is generated by a typemap: -

    24.5 More hints to the generator

    +

    24.5 More hints to the generator

    -

    24.5.1 Features

    +

    24.5.1 Features

    @@ -1029,7 +1029,7 @@ where almost everything is generated by a typemap:
    -

    24.5.2 Pragmas

    +

    24.5.2 Pragmas

    @@ -1052,7 +1052,7 @@ where almost everything is generated by a typemap:
    -

    24.6 Remarks

    +

    24.6 Remarks

      From 03634e6c9b78f68d7b55ede04364971d74cac0ad Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 6 Mar 2010 23:22:40 +0000 Subject: [PATCH 0776/1680] Add linkchecker target for checking html links git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11923 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Makefile | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/Doc/Manual/Makefile b/Doc/Manual/Makefile index 4c907791b..7db42322c 100644 --- a/Doc/Manual/Makefile +++ b/Doc/Manual/Makefile @@ -9,6 +9,7 @@ # validation. # # Additional html validation can be done using the validate target. +# Additional link checking can be done using the linkchecker target. # # Note the # and " are escaped @@ -28,9 +29,9 @@ CCache.html: ../../CCache/ccache.yo # it is just used as a primitive HTML checker. # CCache.html is generated by yodl2html and has a few insignificant problems, so we don't put it through tidy check: - tidy -errors --gnu-emacs yes -quiet index.html - tidy -errors --gnu-emacs yes -quiet Sections.html - all=`sed '/^#/d' chapters | grep -v CCache.html`; for a in $$all; do tidy -errors --gnu-emacs yes -quiet $$a; done; + tidy -errors --gnu-emacs yes -quiet index.html + tidy -errors --gnu-emacs yes -quiet Sections.html + all=`sed '/^#/d' chapters | grep -v CCache.html`; for a in $$all; do tidy -errors --gnu-emacs yes -quiet $$a; done; generate: swightml.book swigpdf.book htmldoc --batch swightml.book || true @@ -60,11 +61,15 @@ clean-baks: rm -f *.bak test: - grep "href=\".*\.html\"" index.html - grep "href=\".*\.html\"" Sections.html - all=`sed '/^#/d' chapters`; for a in $$all; do grep -l "href=\".*\.html\"" $$a; done; + grep "href=\".*\.html\"" index.html + grep "href=\".*\.html\"" Sections.html + all=`sed '/^#/d' chapters`; for a in $$all; do grep -l "href=\".*\.html\"" $$a; done; # Validating using the WDG offline validator - http://www.htmlhelp.com/tools/validator/offline/ validate: - all=`sed '/^#/d' chapters`; for a in $$all; do validate --emacs $$a; done; + all=`sed '/^#/d' chapters`; for a in $$all; do validate --emacs $$a; done; + +# Link checking using linkchecker (can take a while - 30 mins) +linkchecker: + linkchecker --anchors Contents.html From 673ce4551e54c62f9d4494e791ec52211b39a056 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 6 Mar 2010 23:23:43 +0000 Subject: [PATCH 0777/1680] Fix numerous broken links reported by linkchecker git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11924 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Allegrocl.html | 2 +- Doc/Manual/CSharp.html | 2 +- Doc/Manual/Chicken.html | 8 ++++---- Doc/Manual/Contents.html | 6 +++--- Doc/Manual/Customization.html | 2 +- Doc/Manual/Extending.html | 6 +++--- Doc/Manual/Guile.html | 2 +- Doc/Manual/Java.html | 8 ++++---- Doc/Manual/Lisp.html | 8 ++++---- Doc/Manual/Lua.html | 4 ++-- Doc/Manual/Modula3.html | 4 ++-- Doc/Manual/Mzscheme.html | 2 +- Doc/Manual/Php.html | 2 +- Doc/Manual/Preprocessor.html | 4 ++-- Doc/Manual/Python.html | 2 +- Doc/Manual/Ruby.html | 20 ++++++++++---------- Doc/Manual/SWIG.html | 4 ++-- Doc/Manual/Sections.html | 10 +++------- 18 files changed, 46 insertions(+), 50 deletions(-) diff --git a/Doc/Manual/Allegrocl.html b/Doc/Manual/Allegrocl.html index cf70f6c27..5cedee26b 100644 --- a/Doc/Manual/Allegrocl.html +++ b/Doc/Manual/Allegrocl.html @@ -8,7 +8,7 @@ -

      17 SWIG and Allegro Common Lisp

      +

      17 SWIG and Allegro Common Lisp

        diff --git a/Doc/Manual/CSharp.html b/Doc/Manual/CSharp.html index d489ebf09..fd2ef981f 100644 --- a/Doc/Manual/CSharp.html +++ b/Doc/Manual/CSharp.html @@ -54,7 +54,7 @@ The wrapper code implementation uses C# and the Platform Invoke (PInvoke) interf The PInvoke interface has been chosen over Microsoft's Managed C++ interface as it is portable to both Microsoft Windows and non-Microsoft platforms. PInvoke is part of the ECMA/ISO C# specification. It is also better suited for robust production environments due to the Managed C++ flaw called the -Mixed DLL Loading Problem. +Mixed DLL Loading Problem. SWIG C# works equally well on non-Microsoft operating systems such as Linux, Solaris and Apple Mac using Mono and Portable.NET.

        diff --git a/Doc/Manual/Chicken.html b/Doc/Manual/Chicken.html index 693e08e62..006b648d6 100644 --- a/Doc/Manual/Chicken.html +++ b/Doc/Manual/Chicken.html @@ -262,7 +262,7 @@ inside the %exception blocks. SWIG_exception will throw a list consisting of the code (as an integer) and the message. Both of these will throw an exception using (abort), which can be handled by (handle-exceptions). See - Chicken manual on Exceptions + the Chicken manual on Exceptions and SFRI-12. Since the exception values are thrown directly, if (condition-case) is used to catch an exception the exception will come through in the val () case.

        @@ -416,8 +416,8 @@ $ csc -sv modname.scm modname_wrap.c modname_impl.c -o modname.so

      This library can then be loaded by scheme code with the (require 'modname) function. -See -Loading-extension-libraries in the eval unit inside the CHICKEN manual for more information.

      +See the +Loading-extension-libraries in the eval unit inside the CHICKEN manual for more information.

      Another alternative is to run SWIG normally and create a scheme file that contains (declare (uses modname)) and then compile that file into the shared library as well. For example, inside the mod_load.scm file,

      @@ -535,7 +535,7 @@ all the modules.

      In situations where a C or C++ function will assume ownership of a pointer, and thus chicken should no longer garbage collect it, SWIG provides the DISOWN input typemap. - After applying this typemap (see the Typemaps chapter for more information on how to apply typemaps), + After applying this typemap (see the Typemaps chapter for more information on how to apply typemaps), any pointer that gets passed in will no longer be garbage collected. An object is disowned by passing the SWIG_POINTER_DISOWN flag to SWIG_ConvertPtr. Warning: Since the lifetime of the object is now controlled by the underlying code, the object might diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index b5fda3b8d..5bd3210bf 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -122,7 +122,7 @@

    • Running SWIG
    • Advanced Topics @@ -1588,7 +1588,7 @@
    • Entry point to code generation
    • Module I/O and wrapper skeleton
    • Low-level code generators -
    • Configuration files +
    • Configuration files
    • Runtime support
    • Standard library files
    • User examples diff --git a/Doc/Manual/Customization.html b/Doc/Manual/Customization.html index 48f1fd476..734067475 100644 --- a/Doc/Manual/Customization.html +++ b/Doc/Manual/Customization.html @@ -773,7 +773,7 @@ involving %feature:

      -The name matching rules outlined in the Ambiguity resolution and renaming +The name matching rules outlined in the Ambiguity resolution and renaming section applies to all %feature directives. In fact the the %rename directive is just a special form of %feature. The matching rules mean that features are very flexible and can be applied with diff --git a/Doc/Manual/Extending.html b/Doc/Manual/Extending.html index bdf5e8478..ff8751540 100644 --- a/Doc/Manual/Extending.html +++ b/Doc/Manual/Extending.html @@ -54,7 +54,7 @@

    • Entry point to code generation
    • Module I/O and wrapper skeleton
    • Low-level code generators -
    • Configuration files +
    • Configuration files
    • Runtime support
    • Standard library files
    • User examples @@ -3049,7 +3049,7 @@ but without the typemaps, there is still work to do.

      -

      35.10.8 Configuration files

      +

      35.10.8 Configuration files

      @@ -3246,7 +3246,7 @@ These can be found, for example for Python, in

      By default, all of the examples are built and run when the user types make check. To ensure that your examples are automatically run -during this process, see the section on configuration +during this process, see the section on configuration files.

      diff --git a/Doc/Manual/Guile.html b/Doc/Manual/Guile.html index c39abcb46..cc063c436 100644 --- a/Doc/Manual/Guile.html +++ b/Doc/Manual/Guile.html @@ -69,7 +69,7 @@ SCM interface is the default. The SCM and GH interface differ greatly in how th pointers and have completely different run-time code. See below for more info.

      The GH interface to guile is deprecated. Read more about why in the -Guile manual. +Guile manual. The idea of the GH interface was to provide a high level API that other languages and projects could adopt. This was a good idea, but didn't pan out well for general development. But for the specific, minimal uses that the SWIG typemaps put the GH interface to use is ideal for diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html index 902657220..4753fbce7 100644 --- a/Doc/Manual/Java.html +++ b/Doc/Manual/Java.html @@ -254,7 +254,7 @@ It is also possible to change the output directo

      -The module name, specified with %module, determines the name of various generated classes as discussed later. +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.

      @@ -3894,7 +3894,7 @@ public class FooClass {

      The examples above first use the C JNI calling syntax then the C++ JNI calling syntax. The C++ calling syntax will not compile as C and also vice versa. -It is however possible to write JNI calls which will compile under both C and C++ and is covered in the Typemaps for both C and C++ compilation section. +It is however possible to write JNI calls which will compile under both C and C++ and is covered in the Typemaps for both C and C++ compilation section.

      @@ -5126,11 +5126,11 @@ See the NaN exception example for furt

      -The "jtype" typemap has the optional 'nopgcpp' attribute which can be used to suppress the generation of the premature garbage collection prevention parameter. +The "jtype" typemap has the optional 'nopgcpp' attribute which can be used to suppress the generation of the premature garbage collection prevention parameter.

      -The "javain" typemap has the optional 'pre', 'post' and 'pgcppname' attributes. These are used for generating code before and after the JNI call in the proxy class or module class. The 'pre' attribute contains code that is generated before the JNI call and the 'post' attribute contains code generated after the JNI call. The 'pgcppname' attribute is used to change the premature garbage collection prevention parameter name passed to the JNI function. This is sometimes needed when the 'pre' typemap creates a temporary variable which is then passed to the JNI function. +The "javain" typemap has the optional 'pre', 'post' and 'pgcppname' attributes. These are used for generating code before and after the JNI call in the proxy class or module class. The 'pre' attribute contains code that is generated before the JNI call and the 'post' attribute contains code generated after the JNI call. The 'pgcppname' attribute is used to change the premature garbage collection prevention parameter name passed to the JNI function. This is sometimes needed when the 'pre' typemap creates a temporary variable which is then passed to the JNI function.

      diff --git a/Doc/Manual/Lisp.html b/Doc/Manual/Lisp.html index 0f1b45721..aa62250b9 100644 --- a/Doc/Manual/Lisp.html +++ b/Doc/Manual/Lisp.html @@ -6,7 +6,7 @@ -

      22 SWIG and Common Lisp

      +

      22 SWIG and Common Lisp

        @@ -47,7 +47,7 @@

        Allegro Common Lisp support in SWIG has been updated to include support for both C and C++. You can read about the interface - here + here

        22.2 Common Foreign Function Interface(CFFI)

        @@ -96,14 +96,14 @@ swig -cffi -help -generate-typedef -If this option is given then defctype will be used to generate +If this option is given then defctype will be used to generate
        shortcuts according to the typedefs in the input. -[no]cwrap -Turn on or turn off generation of an intermediate C file when +Turn on or turn off generation of an intermediate C file when
        creating a C interface. By default this is only done for C++ code. diff --git a/Doc/Manual/Lua.html b/Doc/Manual/Lua.html index 382e03fb6..53687d3de 100644 --- a/Doc/Manual/Lua.html +++ b/Doc/Manual/Lua.html @@ -6,7 +6,7 @@ -

        23 SWIG and Lua

        +

        23 SWIG and Lua

          @@ -1210,7 +1210,7 @@ extern void sort_double(double* arr, int len);

          There are basically two ways that SWIG can deal with this. The first way, uses the <carrays.i> library to create an array in C/C++ then this can be filled within Lua and passed into the function. It works, but its a bit tedious. -More details can be found in the carrays.i documention.

          +More details can be found in the carrays.i documention.

          The second and more intuitive way, would be to pass a Lua table directly into the function, and have SWIG automatically convert between Lua-table and C-array. Within the <typemaps.i> file there are typemaps ready written to perform this task. To use them is again a matter of using %appy in the correct manner.

          diff --git a/Doc/Manual/Modula3.html b/Doc/Manual/Modula3.html index 6ed36cf45..228c181c0 100644 --- a/Doc/Manual/Modula3.html +++ b/Doc/Manual/Modula3.html @@ -54,7 +54,7 @@ You should be familiar with the basics of SWIG, especially -typemaps. +typemaps.

          24.1 Overview

          @@ -1022,7 +1022,7 @@ where almost everything is generated by a typemap: This is necessary in the cases where it was defined by a non-trivial C expression. This feature is used by the - -generateconst option. + -generateconst option. In future it may be generalized to other kind of values such as strings. diff --git a/Doc/Manual/Mzscheme.html b/Doc/Manual/Mzscheme.html index 9413bb010..008e3aeb3 100644 --- a/Doc/Manual/Mzscheme.html +++ b/Doc/Manual/Mzscheme.html @@ -8,7 +8,7 @@ -

          25 SWIG and MzScheme

          +

          25 SWIG and MzScheme

            diff --git a/Doc/Manual/Php.html b/Doc/Manual/Php.html index b9dcb83c5..fbe31b9e3 100644 --- a/Doc/Manual/Php.html +++ b/Doc/Manual/Php.html @@ -413,7 +413,7 @@ Although PHP does not support overloading functions natively, swig will generate dispatch functions which will use %typecheck typemaps to allow overloading. This dispatch function's operation and precedence is described in Wrapping +href="SWIGPlus.html#SWIGPlus_overloaded_methods">Wrapping Overloaded Functions and Methods.

            diff --git a/Doc/Manual/Preprocessor.html b/Doc/Manual/Preprocessor.html index 2dd79dac5..d7917c41a 100644 --- a/Doc/Manual/Preprocessor.html +++ b/Doc/Manual/Preprocessor.html @@ -81,7 +81,7 @@ Such information generally includes type declarations (e.g., typedef) a C++ classes that might be used as base-classes for class declarations in the interface. The use of %import is also important when SWIG is used to generate extensions as a collection of related modules. This is an advanced topic and is described -in later in the Working with Modules chapter. +in later in the Working with Modules chapter.

            @@ -377,7 +377,7 @@ SWIG will strip the extra % and leave the preprocessor directive in the

            -Typemaps support a special attribute called noblock where the { ... } delimiters can be used, +Typemaps support a special attribute called noblock where the { ... } delimiters can be used, but the delimiters are not actually generated into the code. The effect is then similar to using "" or %{ %} delimiters but the code is run through the preprocessor. For example:

            diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html index b22a7e30e..e898fb359 100644 --- a/Doc/Manual/Python.html +++ b/Doc/Manual/Python.html @@ -2513,7 +2513,7 @@ in Python-2.2, an entirely new type of class system was introduced. This new-style class system offers many enhancements including static member functions, properties (managed attributes), and class methods. Details about all of these changes can be found on www.python.org and is not repeated here. +href="http://www.python.org">www.python.org and is not repeated here.

            diff --git a/Doc/Manual/Ruby.html b/Doc/Manual/Ruby.html index c10702559..8684c355f 100644 --- a/Doc/Manual/Ruby.html +++ b/Doc/Manual/Ruby.html @@ -142,7 +142,7 @@

        • Advanced Topics @@ -1317,7 +1317,7 @@ this code:

          If you want to set an array member, you will need to supply a -"memberin" typemap described in the section on typemaps. +"memberin" typemap described in the section on typemaps. As a special case, SWIG does generate code to set array members of type char (allowing you to store a Ruby string in the structure).

          @@ -1956,7 +1956,7 @@ example:

          More details about wrapping C++ operators into Ruby operators -is discussed in the section +is discussed in the section on operator overloading.

          @@ -2877,7 +2877,7 @@ method. For example:

          SWIG's Ruby module supports cross-language polymorphism (a.k.a. the "directors" feature) similar to that for SWIG's Python -module. Rather than duplicate the information presented in the Python chapter, this +module. Rather than duplicate the information presented in the Python chapter, this section just notes the differences that you need to be aware of when using this feature with Ruby.

          @@ -6089,7 +6089,7 @@ a function. For example:

          -

          See Object +

          See Object ownership and %newobject for further details.

          @@ -7099,8 +7099,8 @@ being created.
        • When you write a typemap, you usually have to work directly with Ruby objects. The following functions may prove to be useful. -(These functions plus many more can be found in Programming -Ruby, by David Thomas and Andrew Hunt.) 

          +(These functions plus many more can be found in Programming +Ruby book, by David Thomas and Andrew Hunt.) 

          In addition, we list equivalent functions that SWIG defines, which provide a language neutral conversion (these functions are defined for each swig language supported).  If you are trying to create a swig @@ -8510,7 +8510,7 @@ docstring and they are output together.

          32.9 Advanced Topics

          -

          32.9.1 Operator overloading

          +

          32.9.1 Operator overloading

          SWIG allows operator overloading with, by using the %extend @@ -9530,7 +9530,7 @@ parses the expression a != b as !(a == b).

          32.9.2 Creating Multi-Module Packages

          -

          The chapter on Working +

          The chapter on Working with Modules discusses the basics of creating multi-module extensions with SWIG, and in particular the considerations for sharing runtime type information among the different modules.

          @@ -10050,7 +10050,7 @@ above. For example:

          In this case, the default SWIG behavior for calling member functions is incorrect. The Ruby object should assume ownership of the returned object. This can be done by using the %newobject directive. -See +See Object ownership and %newobject for more information.

          diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html index 0479f30d7..9ad450425 100644 --- a/Doc/Manual/SWIG.html +++ b/Doc/Manual/SWIG.html @@ -13,7 +13,7 @@
        • Running SWIG
          • Input format -
          • SWIG Output +
          • SWIG Output
          • Comments
          • C Preprocessor
          • SWIG Directives @@ -193,7 +193,7 @@ semantics in SWIG is analogous to that of the declarations section used in input files to parser generation tools such as yacc or bison.

            -

            5.1.2 SWIG Output

            +

            5.1.2 SWIG Output

            diff --git a/Doc/Manual/Sections.html b/Doc/Manual/Sections.html index ab47ed8ee..e26e4d31d 100644 --- a/Doc/Manual/Sections.html +++ b/Doc/Manual/Sections.html @@ -41,13 +41,13 @@ to help!).

            Language Module Documentation

            - From 978dd1f48f8e8760dcb8189e45e952a8bd567dec Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 8 Mar 2010 07:35:06 +0000 Subject: [PATCH 0778/1680] Windows portability fixes git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11925 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/csharp/Makefile.in | 8 +++----- Source/Swig/misc.c | 6 +++++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Examples/test-suite/csharp/Makefile.in b/Examples/test-suite/csharp/Makefile.in index 0f44b3335..13a4d114f 100644 --- a/Examples/test-suite/csharp/Makefile.in +++ b/Examples/test-suite/csharp/Makefile.in @@ -69,14 +69,12 @@ run_testcase = \ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ $(MAKE) -f $*/$(top_builddir)/$(EXAMPLES)/Makefile \ CSHARPFLAGS='-nologo $(CSHARPFLAGSSPECIAL) -out:$*_runme.exe' \ - CSHARPSRCS='`$(CSHARPCYGPATH_W) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX)` \ - `find $* -name "*.cs"`' csharp_compile && \ + CSHARPSRCS='`$(CSHARPCYGPATH_W) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX)` `find $* -name "*.cs" -exec $(CSHARPCYGPATH_W) "{}" \+`' csharp_compile && \ env LD_LIBRARY_PATH="$*:$$LD_LIBRARY_PATH" PATH="$*:$$PATH" SHLIB_PATH="$*:$$SHLIB_PATH" $(RUNTOOL) $(INTERPRETER) $*_runme.exe; \ else \ - cd $* && \ - $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile \ + $(MAKE) -f $*/$(top_builddir)/$(EXAMPLES)/Makefile \ CSHARPFLAGS='-nologo $(CSHARPFLAGSSPECIAL) -t:module -out:$*.netmodule' \ - CSHARPSRCS='`find . -name "*.cs"`' csharp_compile && cd .. ; \ + CSHARPSRCS='`find $* -name "*.cs" -exec $(CSHARPCYGPATH_W) "{}" \+`' csharp_compile; \ fi # Clean: remove testcase directories diff --git a/Source/Swig/misc.c b/Source/Swig/misc.c index 7085f3b4a..9a2a33278 100644 --- a/Source/Swig/misc.c +++ b/Source/Swig/misc.c @@ -20,6 +20,10 @@ char cvsroot_misc_c[] = "$Id$"; #include #include +#ifdef _WIN32 +#include +#define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR) +#endif static char *fake_version = 0; @@ -170,7 +174,7 @@ String *Swig_new_subdirectory(String *basedirectory, String *subdirectory) { } } else { #ifdef _WIN32 - int result = mkdir(Char(dir)); + int result = _mkdir(Char(dir)); #else int result = mkdir(Char(dir), 0777); #endif From 83391b135d0b9b39ae4fea6c23e5794993e1f473 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 8 Mar 2010 20:46:21 +0000 Subject: [PATCH 0779/1680] .netmodule files are generated in the subdirectories again git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11926 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/csharp/Makefile.in | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Examples/test-suite/csharp/Makefile.in b/Examples/test-suite/csharp/Makefile.in index 13a4d114f..35ca41fb0 100644 --- a/Examples/test-suite/csharp/Makefile.in +++ b/Examples/test-suite/csharp/Makefile.in @@ -72,9 +72,10 @@ run_testcase = \ CSHARPSRCS='`$(CSHARPCYGPATH_W) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX)` `find $* -name "*.cs" -exec $(CSHARPCYGPATH_W) "{}" \+`' csharp_compile && \ env LD_LIBRARY_PATH="$*:$$LD_LIBRARY_PATH" PATH="$*:$$PATH" SHLIB_PATH="$*:$$SHLIB_PATH" $(RUNTOOL) $(INTERPRETER) $*_runme.exe; \ else \ + cd $* && \ $(MAKE) -f $*/$(top_builddir)/$(EXAMPLES)/Makefile \ CSHARPFLAGS='-nologo $(CSHARPFLAGSSPECIAL) -t:module -out:$*.netmodule' \ - CSHARPSRCS='`find $* -name "*.cs" -exec $(CSHARPCYGPATH_W) "{}" \+`' csharp_compile; \ + CSHARPSRCS='`find . -name "*.cs" -exec $(CSHARPCYGPATH_W) "{}" \+`' csharp_compile; \ fi # Clean: remove testcase directories From c1cce1bc98cc052f368ce5de1047061983a8bfdf Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 8 Mar 2010 20:48:11 +0000 Subject: [PATCH 0780/1680] The intermediary JNI class modifiers are now public by default. The proxy class pointer constructor and getCPtr() methods are also now public git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11927 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 10 ++++++++++ Doc/Manual/Java.html | 33 ++++++++++++++++++++------------- Examples/test-suite/nspace.i | 5 ----- Lib/java/java.swg | 4 ++-- 4 files changed, 32 insertions(+), 20 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 1e9704783..baf364a47 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,16 @@ Version 2.0.0 (in progress) ============================ +2010-03-06: wsfulton + [Java] The intermediary JNI class modifiers are now public by default meaning these + intermediary low level functions are now accessible by default from outside any package + used. The proxy class pointer constructor and getCPtr() methods are also now public. + These are needed in order for the nspace option to work without any other mods. + The previous default of protected access can be restored using: + + SWIG_JAVABODY_METHODS(protected, protected, SWIGTYPE) + %pragma(java) jniclassclassmodifiers = "class" + 2010-03-06: wsfulton [C#] Added the nspace feature for C#. Documentation for the nspace feature is now available. diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html index 4753fbce7..0984b2ecf 100644 --- a/Doc/Manual/Java.html +++ b/Doc/Manual/Java.html @@ -2253,17 +2253,17 @@ The jniclasscode pragma is quite useful for adding in a static block fo

            Pragmas will take either "" or %{ %} as delimiters. -For example, let's change the intermediary JNI class access to public. +For example, let's change the intermediary JNI class access to just the default package-private access.

            -%pragma(java) jniclassclassmodifiers="public class"
            +%pragma(java) jniclassclassmodifiers="class"
             

            -All the methods in the intermediary JNI class will then be callable outside of the package as the method modifiers are public by default. +All the methods in the intermediary JNI class will then not be be callable outside of the package as the method modifiers have been changed from public access to default access. This is useful if you want to prevent users calling these low level functions.

            21.4.2 The Java module class

            @@ -2368,7 +2368,7 @@ public class Foo { swigCPtr = cPtr; } - protected static long getCPtr(Foo obj) { + public static long getCPtr(Foo obj) { return (obj == null) ? 0 : obj.swigCPtr; } @@ -2619,7 +2619,7 @@ public class Base { swigCPtr = cPtr; } - protected static long getCPtr(Base obj) { + public static long getCPtr(Base obj) { return (obj == null) ? 0 : obj.swigCPtr; } @@ -2659,7 +2659,7 @@ public class Derived extends Base { swigCPtr = cPtr; } - protected static long getCPtr(Derived obj) { + public static long getCPtr(Derived obj) { return (obj == null) ? 0 : obj.swigCPtr; } @@ -2938,7 +2938,7 @@ public class Test { swigCPtr = cPtr; } - protected static long getCPtr(Test obj) { + public static long getCPtr(Test obj) { return (obj == null) ? 0 : obj.swigCPtr; } @@ -5459,9 +5459,9 @@ The "javaimports" typemap is ignored if the enum class is wrapped by an inner Ja

            The defaults can be overridden to tailor these classes. -Here is an example which will change the getCPtr method and constructor from the default protected access to public access. -This has a practical application if you are invoking SWIG more than once and generating the wrapped classes into different packages in each invocation. -If the classes in one package are using the classes in another package, then these methods need to be public. +Here is an example which will change the getCPtr method and constructor from the default public access to protected access. +If the classes in one package are not using the classes in another package, then these methods need not be public and removing access to these low level implementation details, is a good thing. +If you are invoking SWIG more than once and generating the wrapped classes into different packages in each invocation, then you cannot do this as you will then have different packages.

            @@ -5470,12 +5470,12 @@ If the classes in one package are using the classes in another package, then the private long swigCPtr; protected boolean swigCMemOwn; - public $javaclassname(long cPtr, boolean cMemoryOwn) { + protected $javaclassname(long cPtr, boolean cMemoryOwn) { swigCMemOwn = cMemoryOwn; swigCPtr = cPtr; } - public static long getCPtr($javaclassname obj) { + protected static long getCPtr($javaclassname obj) { return (obj == null) ? 0 : obj.swigCPtr; } %} @@ -5483,12 +5483,19 @@ If the classes in one package are using the classes in another package, then the

            -The typemap code is the same that is in "java.swg", barring the two method modifiers. +The typemap code is the same that is in "java.swg", barring the last two method modifiers. Note that SWIGTYPE will target all proxy classes, but not the type wrapper classes. Also the above typemap is only used for proxy classes that are potential base classes. To target proxy classes that are derived from a wrapped class as well, the "javabody_derived" typemap should also be overridden. +There is a macro in java.swg that implements this and the above can instead be implemented using:

            +
            +
            +SWIG_JAVABODY_METHODS(protected, protected, SWIGTYPE)
            +
            +
            +

            For the typemap to be used in all type wrapper classes, all the different types that type wrapper classes could be used for should be targeted:

            diff --git a/Examples/test-suite/nspace.i b/Examples/test-suite/nspace.i index eb63f342d..14be0aa20 100644 --- a/Examples/test-suite/nspace.i +++ b/Examples/test-suite/nspace.i @@ -1,11 +1,6 @@ // Test the nspace feature %module nspace -#if defined(SWIGJAVA) -SWIG_JAVABODY_METHODS(public, public, SWIGTYPE) -%pragma(java) jniclassclassmodifiers = "public class" -#endif - // nspace feature only supported by these languages #if defined(SWIGJAVA) || defined(SWIGCSHARP) diff --git a/Lib/java/java.swg b/Lib/java/java.swg index 6173502ca..f37cba77a 100644 --- a/Lib/java/java.swg +++ b/Lib/java/java.swg @@ -1085,7 +1085,7 @@ /* Set the default for SWIGTYPE: pointer constructor is protected, getCPtr is protected. Season to your own taste! */ -SWIG_JAVABODY_METHODS(protected, protected, SWIGTYPE) +SWIG_JAVABODY_METHODS(public, public, SWIGTYPE) // Typewrapper classes %typemap(javabody) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) %{ @@ -1195,7 +1195,7 @@ SWIG_PROXY_CONSTRUCTOR(true, true, SWIGTYPE) #define %nojavaexception %feature("except","0",throws="") #define %clearjavaexception %feature("except","",throws="") -%pragma(java) jniclassclassmodifiers="class" +%pragma(java) jniclassclassmodifiers="public class" %pragma(java) moduleclassmodifiers="public class" /* Some ANSI C typemaps */ From 9dd30264f6e3d37e551871c4adc9e28069e6fd27 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 8 Mar 2010 22:26:17 +0000 Subject: [PATCH 0781/1680] fix last commit git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11928 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/csharp/Makefile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/test-suite/csharp/Makefile.in b/Examples/test-suite/csharp/Makefile.in index 35ca41fb0..afb29dfbf 100644 --- a/Examples/test-suite/csharp/Makefile.in +++ b/Examples/test-suite/csharp/Makefile.in @@ -73,7 +73,7 @@ run_testcase = \ 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 \ + $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile \ CSHARPFLAGS='-nologo $(CSHARPFLAGSSPECIAL) -t:module -out:$*.netmodule' \ CSHARPSRCS='`find . -name "*.cs" -exec $(CSHARPCYGPATH_W) "{}" \+`' csharp_compile; \ fi From deafe98dc4d4fc1b0683f950cfffeb2ea519f45b Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 8 Mar 2010 23:02:53 +0000 Subject: [PATCH 0782/1680] Test %extend and nspace feature git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11929 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/common.mk | 1 + .../test-suite/csharp/nspace_extend_runme.cs | 39 +++++++++++++++ Examples/test-suite/java/Makefile.in | 1 + .../test-suite/java/nspace_extend_runme.java | 44 ++++++++++++++++ Examples/test-suite/nspace_extend.i | 50 +++++++++++++++++++ 5 files changed, 135 insertions(+) create mode 100644 Examples/test-suite/csharp/nspace_extend_runme.cs create mode 100644 Examples/test-suite/java/nspace_extend_runme.java create mode 100644 Examples/test-suite/nspace_extend.i diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 2b4ab0701..db162487f 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -243,6 +243,7 @@ CPP_TEST_CASES += \ namespace_union \ namespace_virtual_method \ nspace \ + nspace_extend \ naturalvar \ nested_class \ nested_comment \ diff --git a/Examples/test-suite/csharp/nspace_extend_runme.cs b/Examples/test-suite/csharp/nspace_extend_runme.cs new file mode 100644 index 000000000..addee7fe5 --- /dev/null +++ b/Examples/test-suite/csharp/nspace_extend_runme.cs @@ -0,0 +1,39 @@ +using System; + +public class runme +{ + static void Main() + { + { + // constructors and destructors + nspace_extendNamespace.Outer.Inner1.Color color1 = new nspace_extendNamespace.Outer.Inner1.Color(); + nspace_extendNamespace.Outer.Inner1.Color color = new nspace_extendNamespace.Outer.Inner1.Color(color1); + color1.Dispose(); + color1 = null; + + // class methods + color.colorInstanceMethod(20.0); + nspace_extendNamespace.Outer.Inner1.Color.colorStaticMethod(20.0); + nspace_extendNamespace.Outer.Inner1.Color created = nspace_extendNamespace.Outer.Inner1.Color.create(); + created.Dispose(); + } + { + // constructors and destructors + nspace_extendNamespace.Outer.Inner2.Color color2 = new nspace_extendNamespace.Outer.Inner2.Color(); + nspace_extendNamespace.Outer.Inner2.Color color = new nspace_extendNamespace.Outer.Inner2.Color(color2); + color2.Dispose(); + color2 = null; + + // class methods + color.colorInstanceMethod(20.0); + nspace_extendNamespace.Outer.Inner2.Color.colorStaticMethod(20.0); + nspace_extendNamespace.Outer.Inner2.Color created = nspace_extendNamespace.Outer.Inner2.Color.create(); + created.Dispose(); + + // Same class different namespaces + nspace_extendNamespace.Outer.Inner1.Color col1 = new nspace_extendNamespace.Outer.Inner1.Color(); + nspace_extendNamespace.Outer.Inner2.Color col2 = nspace_extendNamespace.Outer.Inner2.Color.create(); + col2.colors(col1, col1, col2, col2, col2); + } + } +} diff --git a/Examples/test-suite/java/Makefile.in b/Examples/test-suite/java/Makefile.in index 119b50868..3cb7c0c53 100644 --- a/Examples/test-suite/java/Makefile.in +++ b/Examples/test-suite/java/Makefile.in @@ -43,6 +43,7 @@ INTERFACEDIR = ../../ # Custom tests - tests with additional commandline options nspace.%: JAVA_PACKAGE = $*Package +nspace_extend.%: JAVA_PACKAGE = $*Package # Rules for the different types of tests %.cpptest: diff --git a/Examples/test-suite/java/nspace_extend_runme.java b/Examples/test-suite/java/nspace_extend_runme.java new file mode 100644 index 000000000..3e44673d1 --- /dev/null +++ b/Examples/test-suite/java/nspace_extend_runme.java @@ -0,0 +1,44 @@ +// This tests changes the package name from nspace to nspacePackage as javac can't seem to resolve classes and packages having the same name +public class nspace_extend_runme { + + static { + try { + System.loadLibrary("nspace_extend"); + } catch (UnsatisfiedLinkError e) { + System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); + System.exit(1); + } + } + + public static void main(String argv[]) { + { + // constructors and destructors + nspace_extendPackage.Outer.Inner1.Color color1 = new nspace_extendPackage.Outer.Inner1.Color(); + nspace_extendPackage.Outer.Inner1.Color color = new nspace_extendPackage.Outer.Inner1.Color(color1); + color1.delete(); + color1 = null; + + // class methods + color.colorInstanceMethod(20.0); + nspace_extendPackage.Outer.Inner1.Color.colorStaticMethod(20.0); + nspace_extendPackage.Outer.Inner1.Color created = nspace_extendPackage.Outer.Inner1.Color.create(); + } + { + // constructors and destructors + nspace_extendPackage.Outer.Inner2.Color color2 = new nspace_extendPackage.Outer.Inner2.Color(); + nspace_extendPackage.Outer.Inner2.Color color = new nspace_extendPackage.Outer.Inner2.Color(color2); + color2.delete(); + color2 = null; + + // class methods + color.colorInstanceMethod(20.0); + nspace_extendPackage.Outer.Inner2.Color.colorStaticMethod(20.0); + nspace_extendPackage.Outer.Inner2.Color created = nspace_extendPackage.Outer.Inner2.Color.create(); + + // Same class different namespaces + nspace_extendPackage.Outer.Inner1.Color col1 = new nspace_extendPackage.Outer.Inner1.Color(); + nspace_extendPackage.Outer.Inner2.Color col2 = nspace_extendPackage.Outer.Inner2.Color.create(); + col2.colors(col1, col1, col2, col2, col2); + } + } +} diff --git a/Examples/test-suite/nspace_extend.i b/Examples/test-suite/nspace_extend.i new file mode 100644 index 000000000..7f7ba01f8 --- /dev/null +++ b/Examples/test-suite/nspace_extend.i @@ -0,0 +1,50 @@ +// Test the nspace feature and %extend +%module nspace_extend + +// nspace feature only supported by these languages +#if defined(SWIGJAVA) || defined(SWIGCSHARP) + +%nspace; + +%extend Outer::Inner1::Color { + Color() { return new Outer::Inner1::Color(); } + virtual ~Color() { delete $self; } + static Color* create() { return new Outer::Inner1::Color(); } + Color(const Color& other) { return new Outer::Inner1::Color(other); } + + void colorInstanceMethod(double d) {} + static void colorStaticMethod(double d) {} +} + +%inline %{ + +namespace Outer { + namespace Inner1 { + struct Color { + }; + } + + namespace Inner2 { + struct Color { + }; + } +} +%} + +#endif + +%extend Outer::Inner2::Color { + Color() { return new Outer::Inner2::Color(); } + ~Color() { delete $self; } + static Color* create() { return new Outer::Inner2::Color(); } + Color(const Color& other) { return new Outer::Inner2::Color(other); } + + void colorInstanceMethod(double d) {} + static void colorStaticMethod(double d) {} + void colors(const Inner1::Color& col1a, + const Outer::Inner1::Color& col1b, + const Color &col2a, + const Inner2::Color& col2b, + const Outer::Inner2::Color& col2c) {} +} + From 96f98795116fbf5b176ea5f299f15d0e469c23f4 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 9 Mar 2010 21:15:34 +0000 Subject: [PATCH 0783/1680] Fixes for nspace and derived classes git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11930 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/CSharp.html | 1 + Doc/Manual/Java.html | 8 ++++++ Examples/test-suite/csharp/nspace_runme.cs | 6 ++++ Examples/test-suite/java/nspace_runme.java | 6 ++++ Examples/test-suite/nspace.i | 12 ++++++++ Lib/csharp/csharp.swg | 2 +- Lib/java/java.swg | 2 +- Source/Modules/csharp.cxx | 22 ++++++++++----- Source/Modules/java.cxx | 32 ++++++++++++---------- 9 files changed, 67 insertions(+), 24 deletions(-) diff --git a/Doc/Manual/CSharp.html b/Doc/Manual/CSharp.html index fd2ef981f..21b319e29 100644 --- a/Doc/Manual/CSharp.html +++ b/Doc/Manual/CSharp.html @@ -206,6 +206,7 @@ jniclassinterfaces -> imclassinterfaces $javaclassname -> $csclassname $&javaclassname -> $&csclassname $*javaclassname -> $*csclassname +$javaclazzname -> $csclazzname $javainput -> $csinput $jnicall -> $imcall
        diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html index 0984b2ecf..5b61955ab 100644 --- a/Doc/Manual/Java.html +++ b/Doc/Manual/Java.html @@ -5161,6 +5161,14 @@ If the type does not have an associated proxy class, it expands to the type wrap SWIGTYPE_p_unsigned_short is generated when wrapping unsigned short *.

        +

        +$javaclazzname
        +This special variable works like $javaclassname, but expands the fully qualified C++ class into the package name, +if used by the nspace feature, and the proxy class name, mangled for use as a function name. +For example, Namespace1::Namespace2::Klass is expanded into Namespace1_Namespace2_Klass_. +This special variable is usually used for making calls to a function in the intermediary JNI class, as they are mangled with this prefix. +

        +

        $null
        Used in input typemaps to return early from JNI functions that have either void or a non-void return type. Example: diff --git a/Examples/test-suite/csharp/nspace_runme.cs b/Examples/test-suite/csharp/nspace_runme.cs index 91baf6a0f..7ced06a04 100644 --- a/Examples/test-suite/csharp/nspace_runme.cs +++ b/Examples/test-suite/csharp/nspace_runme.cs @@ -56,5 +56,11 @@ public class runme ns.Dispose(); nspaceNamespace.NoNSpacePlease nons = new nspaceNamespace.NoNSpacePlease(); nons.Dispose(); + + // Derived class + nspaceNamespace.Outer.Inner3.Blue blue3 = new nspaceNamespace.Outer.Inner3.Blue(); + blue3.blueInstanceMethod(); + nspaceNamespace.Outer.Inner4.Blue blue4 = new nspaceNamespace.Outer.Inner4.Blue(); + blue4.blueInstanceMethod(); } } diff --git a/Examples/test-suite/java/nspace_runme.java b/Examples/test-suite/java/nspace_runme.java index ca83b7d04..a50bb9ae9 100644 --- a/Examples/test-suite/java/nspace_runme.java +++ b/Examples/test-suite/java/nspace_runme.java @@ -60,5 +60,11 @@ public class nspace_runme { // turn feature off / ignoring nspacePackage.Outer.nspace ns = new nspacePackage.Outer.nspace(); nspacePackage.NoNSpacePlease nons = new nspacePackage.NoNSpacePlease(); + + // Derived class + nspacePackage.Outer.Inner3.Blue blue3 = new nspacePackage.Outer.Inner3.Blue(); + blue3.blueInstanceMethod(); + nspacePackage.Outer.Inner4.Blue blue4 = new nspacePackage.Outer.Inner4.Blue(); + blue4.blueInstanceMethod(); } } diff --git a/Examples/test-suite/nspace.i b/Examples/test-suite/nspace.i index 14be0aa20..82f6e1101 100644 --- a/Examples/test-suite/nspace.i +++ b/Examples/test-suite/nspace.i @@ -73,6 +73,18 @@ namespace Outer { class NoNSpacePlease {}; } // Inner2 + // Derived class + namespace Inner3 { + struct Blue : Inner2::Color { + void blueInstanceMethod() {} + }; + } + namespace Inner4 { + struct Blue : Inner2::Color { + void blueInstanceMethod() {} + }; + } + class SomeClass { public: Inner1::Color::Channel GetInner1ColorChannel() { return Inner1::Color::Transmission; } diff --git a/Lib/csharp/csharp.swg b/Lib/csharp/csharp.swg index 204cf4b2f..1f58db48d 100644 --- a/Lib/csharp/csharp.swg +++ b/Lib/csharp/csharp.swg @@ -841,7 +841,7 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) { %typemap(csbody_derived) SWIGTYPE %{ private HandleRef swigCPtr; - internal $csclassname(IntPtr cPtr, bool cMemoryOwn) : base($imclassname.$csclassnameUpcast(cPtr), cMemoryOwn) { + internal $csclassname(IntPtr cPtr, bool cMemoryOwn) : base($imclassname.$csclazznameSWIGUpcast(cPtr), cMemoryOwn) { swigCPtr = new HandleRef(this, cPtr); } diff --git a/Lib/java/java.swg b/Lib/java/java.swg index f37cba77a..ad7c8074d 100644 --- a/Lib/java/java.swg +++ b/Lib/java/java.swg @@ -1072,7 +1072,7 @@ private long swigCPtr; PTRCTOR_VISIBILITY $javaclassname(long cPtr, boolean cMemoryOwn) { - super($imclassname.SWIG$javaclassnameUpcast(cPtr), cMemoryOwn); + super($imclassname.$javaclazznameSWIGUpcast(cPtr), cMemoryOwn); swigCPtr = cPtr; } diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index 0dbed4d1e..55de14285 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -1753,6 +1753,8 @@ public: Delete(attributes); Delete(destruct); + String *csclazzname = Swig_name_member(getNSpace(), proxy_class_name, ""); // mangled full proxy class name + // Emit extra user code Printv(proxy_class_def, typemapLookup(n, "cscode", typemap_lookup_type, WARN_NONE), // extra C# code "\n", NIL); @@ -1770,21 +1772,27 @@ public: Replaceall(proxy_class_def, "$dllimport", dllimport); Replaceall(proxy_class_code, "$dllimport", dllimport); + Replaceall(proxy_class_def, "$csclazzname", csclazzname); + Replaceall(proxy_class_code, "$csclazzname", csclazzname); + // Add code to do C++ casting to base class (only for classes in an inheritance hierarchy) if (derived) { - Printv(imclass_cppcasts_code, "\n [DllImport(\"", dllimport, "\", EntryPoint=\"CSharp_", proxy_class_name, "Upcast", "\")]\n", NIL); - Printf(imclass_cppcasts_code, " public static extern IntPtr $csclassnameUpcast(IntPtr objectRef);\n"); + String *upcast_method = Swig_name_member(getNSpace(), proxy_class_name, "SWIGUpcast"); + String *wname = Swig_name_wrapper(upcast_method); + + Printv(imclass_cppcasts_code, "\n [DllImport(\"", dllimport, "\", EntryPoint=\"", wname, "\")]\n", NIL); + Printf(imclass_cppcasts_code, " public static extern IntPtr %s(IntPtr jarg1);\n", upcast_method); Replaceall(imclass_cppcasts_code, "$csclassname", proxy_class_name); Printv(upcasts_code, - "SWIGEXPORT $cbaseclass * SWIGSTDCALL CSharp_$imclazznameUpcast", - "($cclass *objectRef) {\n", " return ($cbaseclass *)objectRef;\n" "}\n", "\n", NIL); + "SWIGEXPORT ", c_baseclass, " * SWIGSTDCALL ", wname, + "(", c_classname, " *jarg1) {\n", " return (", c_baseclass, " *)jarg1;\n" "}\n", "\n", NIL); - Replaceall(upcasts_code, "$cbaseclass", c_baseclass); - Replaceall(upcasts_code, "$imclazzname", proxy_class_name); - Replaceall(upcasts_code, "$cclass", c_classname); + Delete(wname); + Delete(upcast_method); } + Delete(csclazzname); Delete(baseclass); } diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index 50b80dc8b..7315bd9a5 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -1762,6 +1762,8 @@ public: Delete(attributes); Delete(destruct); + String *javaclazzname = Swig_name_member(getNSpace(), proxy_class_name, ""); // mangled full proxy class name + // Emit extra user code Printv(proxy_class_def, typemapLookup(n, "javacode", typemap_lookup_type, WARN_NONE), // extra Java code "\n", NIL); @@ -1776,29 +1778,29 @@ public: Replaceall(proxy_class_def, "$imclassname", full_imclass_name); Replaceall(proxy_class_code, "$imclassname", full_imclass_name); + Replaceall(proxy_class_def, "$javaclazzname", javaclazzname); + Replaceall(proxy_class_code, "$javaclazzname", javaclazzname); + // Add code to do C++ casting to base class (only for classes in an inheritance hierarchy) if (derived) { - Printv(imclass_cppcasts_code, " public final static native long SWIG$javaclassnameUpcast(long jarg1);\n", NIL); + String *upcast_method = Swig_name_member(getNSpace(), proxy_class_name, "SWIGUpcast"); + String *jniname = makeValidJniName(upcast_method); + String *wname = Swig_name_wrapper(jniname); - Replaceall(imclass_cppcasts_code, "$javaclassname", full_proxy_class_name); + Printf(imclass_cppcasts_code, " public final static native long %s(long jarg1);\n", upcast_method); Printv(upcasts_code, - "SWIGEXPORT jlong JNICALL Java_$jnipackage$imimclass_SWIG$imclazznameUpcast", - "(JNIEnv *jenv, jclass jcls, jlong jarg1) {\n", + "SWIGEXPORT jlong JNICALL ", wname, "(JNIEnv *jenv, jclass jcls, jlong jarg1) {\n", " jlong baseptr = 0;\n" - " (void)jenv;\n" " (void)jcls;\n" " *($cbaseclass **)&baseptr = *($cclass **)&jarg1;\n" " return baseptr;\n" "}\n", "\n", NIL); + " (void)jenv;\n" " (void)jcls;\n" " *(", c_baseclassname, " **)&baseptr = *(", c_classname, " **)&jarg1;\n" + " return baseptr;\n" + "}\n", "\n", NIL); - String *imimclass = makeValidJniName(imclass_name); - String *imclazzname = makeValidJniName(full_proxy_class_name); - Replaceall(upcasts_code, "$cbaseclass", c_baseclass); - Replaceall(upcasts_code, "$imclazzname", imclazzname); - Replaceall(upcasts_code, "$cclass", c_classname); - Replaceall(upcasts_code, "$jnipackage", jnipackage); - Replaceall(upcasts_code, "$imimclass", imimclass); - - Delete(imclazzname); - Delete(imimclass); + Delete(wname); + Delete(jniname); + Delete(upcast_method); } + Delete(javaclazzname); Delete(baseclass); } From bce282fa0cbe5f5e5c0a5e30f1376a8973320e1a Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 10 Mar 2010 07:29:16 +0000 Subject: [PATCH 0784/1680] Minor tweaks git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11931 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/java/java.swg | 2 +- Source/Modules/csharp.cxx | 20 ++++++++++++++------ Source/Modules/java.cxx | 18 ++++++++++++------ 3 files changed, 27 insertions(+), 13 deletions(-) diff --git a/Lib/java/java.swg b/Lib/java/java.swg index ad7c8074d..2dfbe59f2 100644 --- a/Lib/java/java.swg +++ b/Lib/java/java.swg @@ -1132,7 +1132,7 @@ SWIG_JAVABODY_METHODS(public, public, SWIGTYPE) */ %define SWIG_PROXY_CONSTRUCTOR(OWNERSHIP, WEAKREF, TYPENAME...) -%typemap(javaconstruct,directorconnect="\n $imclassname.$javaclassname_director_connect(this, swigCPtr, swigCMemOwn, WEAKREF);") TYPENAME { +%typemap(javaconstruct,directorconnect="\n $imclassname.$javaclazznamedirector_connect(this, swigCPtr, swigCMemOwn, WEAKREF);") TYPENAME { this($imcall, OWNERSHIP);$directorconnect } %enddef diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index 55de14285..8b8cbaa43 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -803,7 +803,7 @@ public: return SWIG_OK; } - Printv(imclass_class_code, "\n [DllImport(\"", dllimport, "\", EntryPoint=\"CSharp_", overloaded_name, "\")]\n", NIL); + Printv(imclass_class_code, "\n [DllImport(\"", dllimport, "\", EntryPoint=\"", wname, "\")]\n", NIL); if (im_outattributes) Printf(imclass_class_code, " %s\n", im_outattributes); @@ -1887,14 +1887,16 @@ public: downcasts, making the constructorHandler() a bad place (because ABCs don't get to have constructors emitted.) */ if (GetFlag(n, "feature:javadowncast")) { + String *downcast_method = Swig_name_member(getNSpace(), proxy_class_name, "SWIGDowncast"); + String *wname = Swig_name_wrapper(downcast_method); + String *norm_name = SwigType_namestr(Getattr(n, "name")); - Printf(imclass_class_code, " public final static native %s downcast%s(long cPtrBase, boolean cMemoryOwn);\n", proxy_class_name, proxy_class_name); + Printf(imclass_class_code, " public final static native %s %s(long cPtrBase, boolean cMemoryOwn);\n", proxy_class_name, downcast_method); Wrapper *dcast_wrap = NewWrapper(); - Printf(dcast_wrap->def, "SWIGEXPORT jobject SWIGSTDCALL CSharp_downcast%s(JNIEnv *jenv, jclass jcls, jlong jCPtrBase, jboolean cMemoryOwn) {", - proxy_class_name); + Printf(dcast_wrap->def, "SWIGEXPORT jobject SWIGSTDCALL %s(JNIEnv *jenv, jclass jcls, jlong jCPtrBase, jboolean cMemoryOwn) {", wname); Printf(dcast_wrap->code, " Swig::Director *director = (Swig::Director *) 0;\n"); Printf(dcast_wrap->code, " jobject jresult = (jobject) 0;\n"); Printf(dcast_wrap->code, " %s *obj = *((%s **)&jCPtrBase);\n", norm_name, norm_name); @@ -1905,6 +1907,10 @@ public: Wrapper_print(dcast_wrap, f_wrappers); DelWrapper(dcast_wrap); + + Delete(norm_name); + Delete(wname); + Delete(downcast_method); } emitDirectorExtraMethods(n); @@ -3307,14 +3313,15 @@ public: // Output the director connect method: String *norm_name = SwigType_namestr(Getattr(n, "name")); String *swig_director_connect = Swig_name_member(getNSpace(), proxy_class_name, "director_connect"); + String *wname = Swig_name_wrapper(swig_director_connect); String *sym_name = Getattr(n, "sym:name"); Wrapper *code_wrap; - Printv(imclass_class_code, "\n [DllImport(\"", dllimport, "\", EntryPoint=\"CSharp_", swig_director_connect, "\")]\n", NIL); + Printv(imclass_class_code, "\n [DllImport(\"", dllimport, "\", EntryPoint=\"", wname, "\")]\n", NIL); Printf(imclass_class_code, " public static extern void %s(HandleRef jarg1", swig_director_connect); code_wrap = NewWrapper(); - Printf(code_wrap->def, "SWIGEXPORT void SWIGSTDCALL CSharp_%s(void *objarg", swig_director_connect); + Printf(code_wrap->def, "SWIGEXPORT void SWIGSTDCALL %s(void *objarg", wname); Printf(code_wrap->code, " %s *obj = (%s *)objarg;\n", norm_name, norm_name); Printf(code_wrap->code, " SwigDirector_%s *director = dynamic_cast(obj);\n", sym_name, sym_name); @@ -3343,6 +3350,7 @@ public: Wrapper_print(code_wrap, f_wrappers); DelWrapper(code_wrap); + Delete(wname); Delete(swig_director_connect); } diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index 7315bd9a5..2bceae83f 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -1792,7 +1792,7 @@ public: Printv(upcasts_code, "SWIGEXPORT jlong JNICALL ", wname, "(JNIEnv *jenv, jclass jcls, jlong jarg1) {\n", " jlong baseptr = 0;\n" - " (void)jenv;\n" " (void)jcls;\n" " *(", c_baseclassname, " **)&baseptr = *(", c_classname, " **)&jarg1;\n" + " (void)jenv;\n" " (void)jcls;\n" " *(", c_baseclass, " **)&baseptr = *(", c_classname, " **)&jarg1;\n" " return baseptr;\n" "}\n", "\n", NIL); @@ -1901,16 +1901,17 @@ public: downcasts, making the constructorHandler() a bad place (because ABCs don't get to have constructors emitted.) */ if (GetFlag(n, "feature:javadowncast")) { - String *jni_imclass_name = makeValidJniName(imclass_name); - String *jni_class_name = makeValidJniName(proxy_class_name); + String *downcast_method = Swig_name_member(getNSpace(), proxy_class_name, "SWIGDowncast"); + String *jniname = makeValidJniName(downcast_method); + String *wname = Swig_name_wrapper(jniname); + String *norm_name = SwigType_namestr(Getattr(n, "name")); - Printf(imclass_class_code, " public final static native %s downcast%s(long cPtrBase, boolean cMemoryOwn);\n", proxy_class_name, proxy_class_name); + Printf(imclass_class_code, " public final static native %s %s(long cPtrBase, boolean cMemoryOwn);\n", proxy_class_name, downcast_method); Wrapper *dcast_wrap = NewWrapper(); - Printf(dcast_wrap->def, "SWIGEXPORT jobject JNICALL Java_%s%s_downcast%s(JNIEnv *jenv, jclass jcls, jlong jCPtrBase, jboolean cMemoryOwn) {", - jnipackage, jni_imclass_name, jni_class_name); + Printf(dcast_wrap->def, "SWIGEXPORT jobject JNICALL %s(JNIEnv *jenv, jclass jcls, jlong jCPtrBase, jboolean cMemoryOwn) {", wname); Printf(dcast_wrap->code, " Swig::Director *director = (Swig::Director *) 0;\n"); Printf(dcast_wrap->code, " jobject jresult = (jobject) 0;\n"); Printf(dcast_wrap->code, " %s *obj = *((%s **)&jCPtrBase);\n", norm_name, norm_name); @@ -1921,6 +1922,11 @@ public: Wrapper_print(dcast_wrap, f_wrappers); DelWrapper(dcast_wrap); + + Delete(norm_name); + Delete(wname); + Delete(jniname); + Delete(downcast_method); } emitDirectorExtraMethods(n); From ebe21075f9c08a8555d0aadc67acecda8701c3be Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 10 Mar 2010 07:30:22 +0000 Subject: [PATCH 0785/1680] update package builds with more generic version numbers git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11932 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Tools/mkdist.py | 6 +++--- Tools/mkrelease.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Tools/mkdist.py b/Tools/mkdist.py index 0e2eafa79..9e25d3827 100755 --- a/Tools/mkdist.py +++ b/Tools/mkdist.py @@ -1,7 +1,7 @@ #!/usr/bin/env python -# This script builds a swig-1.3 distribution. -# Usage : mkdist.py version, where version should be 1.3.x +# This script builds a swig-x.y.z distribution. +# Usage : mkdist.py version, where version should be x.y.z import sys import string @@ -16,7 +16,7 @@ try: version = sys.argv[1] dirname = "swig-" + version except: - print "Usage: mkdist.py version, where version should be 1.3.x" + print "Usage: mkdist.py version, where version should be x.y.z" sys.exit(1) # Check name matches normal unix conventions diff --git a/Tools/mkrelease.py b/Tools/mkrelease.py index b719c470e..4b5e7e2e1 100755 --- a/Tools/mkrelease.py +++ b/Tools/mkrelease.py @@ -18,7 +18,7 @@ try: username = sys.argv[2] except: print "Usage: python mkrelease.py version username" - print "where version should be 1.3.x and username is your SF username" + print "where version should be x.y.z and username is your SF username" sys.exit(1) print "Looking for rsync" From 8d227bce62f9514bf97409727729bb025a813e6e Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 10 Mar 2010 07:50:32 +0000 Subject: [PATCH 0786/1680] Slightly efficiency improvements for packages/namespaces/ git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11933 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/csharp.cxx | 53 ++++++++++++++++++++------------------- Source/Modules/java.cxx | 35 +++++++++++++------------- 2 files changed, 45 insertions(+), 43 deletions(-) diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index 8b8cbaa43..341937308 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -181,7 +181,7 @@ public: String *nspace = Getattr(n, "sym:nspace"); String *symname = Getattr(n, "sym:name"); if (nspace) { - if (Len(namespce) > 0) + if (namespce) proxyname = NewStringf("%s.%s.%s", namespce, nspace, symname); else proxyname = NewStringf("%s.%s", nspace, symname); @@ -239,6 +239,10 @@ public: if (argv[i + 1]) { namespce = NewString(""); Printf(namespce, argv[i + 1]); + if (Len(namespce) == 0) { + Delete(namespce); + namespce = 0; + } Swig_mark_arg(i); Swig_mark_arg(i + 1); i++; @@ -378,8 +382,6 @@ public: dmethods_table = NewHash(); n_dmethods = 0; n_directors = 0; - if (!namespce) - namespce = NewString(""); if (!dllimport) dllimport = Copy(module_class_name); @@ -439,7 +441,7 @@ public: // Start writing out the intermediary class file emitBanner(f_im); - addOpenNamespace(namespce, 0, f_im); + addOpenNamespace(0, f_im); if (imclass_imports) Printf(f_im, "%s\n", imclass_imports); @@ -463,7 +465,7 @@ public: // Finish off the class Printf(f_im, "}\n"); - addCloseNamespace(namespce, 0, f_im); + addCloseNamespace(0, f_im); Close(f_im); } @@ -483,7 +485,7 @@ public: // Start writing out the module class file emitBanner(f_module); - addOpenNamespace(namespce, 0, f_module); + addOpenNamespace(0, f_module); if (module_imports) Printf(f_module, "%s\n", module_imports); @@ -515,7 +517,7 @@ public: // Finish off the class Printf(f_module, "}\n"); - addCloseNamespace(namespce, 0, f_module); + addCloseNamespace(0, f_module); Close(f_module); } @@ -1134,7 +1136,7 @@ public: if (!nspace) { full_imclass_name = NewStringf("%s", imclass_name); } else { - if (Len(namespce) > 0) { + if (namespce) { full_imclass_name = NewStringf("%s.%s", namespce, imclass_name); } else { full_imclass_name = NewStringf("%s", imclass_name); @@ -1214,12 +1216,12 @@ public: // Start writing out the enum file emitBanner(f_enum); - addOpenNamespace(namespce, nspace, f_enum); + addOpenNamespace(nspace, f_enum); Printv(f_enum, typemapLookup(n, "csimports", typemap_lookup_type, WARN_NONE), // Import statements "\n", enum_code, "\n", NIL); - addCloseNamespace(namespce, nspace, f_enum); + addCloseNamespace(nspace, f_enum); Close(f_enum); Delete(output_directory); } @@ -1820,7 +1822,7 @@ public: SWIG_exit(EXIT_FAILURE); } } else { - if (Len(namespce) > 0) { + if (namespce) { full_proxy_class_name = NewStringf("%s.%s.%s", namespce, nspace, proxy_class_name); full_imclass_name = NewStringf("%s.%s", namespce, imclass_name); } else { @@ -1846,7 +1848,7 @@ public: // Start writing out the proxy class file emitBanner(f_proxy); - addOpenNamespace(namespce, nspace, f_proxy); + addOpenNamespace(nspace, f_proxy); Clear(proxy_class_def); Clear(proxy_class_code); @@ -1878,7 +1880,7 @@ public: Printv(f_proxy, proxy_class_constants_code, NIL); Printf(f_proxy, "}\n"); - addCloseNamespace(namespce, nspace, f_proxy); + addCloseNamespace(nspace, f_proxy); Close(f_proxy); f_proxy = NULL; @@ -2959,7 +2961,7 @@ public: // global enum or enum in a namespace String *nspace = Getattr(n, "sym:nspace"); if (nspace) { - if (Len(namespce) > 0) + if (namespce) enumname = NewStringf("%s.%s.%s", namespce, nspace, symname); else enumname = NewStringf("%s.%s", nspace, symname); @@ -3111,7 +3113,7 @@ public: // Start writing out the type wrapper class file emitBanner(f_swigtype); - addOpenNamespace(namespce, 0, f_swigtype); + addOpenNamespace(0, f_swigtype); // Pure C# baseclass and interfaces const String *pure_baseclass = typemapLookup(n, "csbase", type, WARN_NONE); @@ -3140,7 +3142,7 @@ public: Printv(f_swigtype, swigtype, NIL); - addCloseNamespace(namespce, 0, f_swigtype); + addCloseNamespace(0, f_swigtype); Close(f_swigtype); Delete(swigtype); @@ -3215,12 +3217,12 @@ public: * addOpenNamespace() * ----------------------------------------------------------------------------- */ - void addOpenNamespace(const String *namspace, const String *nspace, File *file) { - if (namspace) { - if (Len(namspace) > 0 || nspace) { + void addOpenNamespace(const String *nspace, File *file) { + if (namespce) { + if (namespce || nspace) { Printf(file, "namespace "); - if (Len(namspace) > 0) - Printv(file, namspace, nspace ? "." : "", NIL); + if (namespce) + Printv(file, namespce, nspace ? "." : "", NIL); if (nspace) Printv(file, nspace, NIL); Printf(file, " {\n"); @@ -3232,9 +3234,9 @@ public: * addCloseNamespace() * ----------------------------------------------------------------------------- */ - void addCloseNamespace(const String *namspace, const String *nspace, File *file) { - if (namspace) - if (Len(namspace) > 0 || nspace) + void addCloseNamespace(const String *nspace, File *file) { + if (namespce) + if (namespce || nspace) Printf(file, "\n}\n"); } @@ -3303,8 +3305,7 @@ public: /*---------------------------------------------------------------------- * emitDirectorExtraMethods() * - * This is where the director connect method is - * generated. + * This is where the director connect method is generated. *--------------------------------------------------------------------*/ void emitDirectorExtraMethods(Node *n) { if (!Swig_directorclass(n)) diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index 2bceae83f..65bb440f3 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -176,7 +176,7 @@ public: String *nspace = Getattr(n, "sym:nspace"); String *symname = Getattr(n, "sym:name"); if (nspace) { - if (Len(package) > 0) + if (package) proxyname = NewStringf("%s.%s.%s", package, nspace, symname); else proxyname = NewStringf("%s.%s", nspace, symname); @@ -234,6 +234,10 @@ public: if (argv[i + 1]) { package = NewString(""); Printf(package, argv[i + 1]); + if (Len(package) == 0) { + Delete(package); + package = 0; + } Swig_mark_arg(i); Swig_mark_arg(i + 1); i++; @@ -390,8 +394,6 @@ public: dmethods_table = NewHash(); n_dmethods = 0; n_directors = 0; - if (!package) - package = NewString(""); jnipackage = NewString(""); package_path = NewString(""); @@ -420,7 +422,7 @@ public: String *wrapper_name = NewString(""); - if (Len(package)) { + if (package) { String *jniname = makeValidJniName(package); Printv(jnipackage, jniname, NIL); Delete(jniname); @@ -467,7 +469,7 @@ public: // Start writing out the intermediary class file emitBanner(f_im); - if (Len(package) > 0) + if (package) Printf(f_im, "package %s;\n", package); if (imclass_imports) @@ -518,7 +520,7 @@ public: // Start writing out the module class file emitBanner(f_module); - if (Len(package) > 0) + if (package) Printf(f_module, "package %s;\n", package); if (module_imports) @@ -570,7 +572,7 @@ public: // Start writing out the Java constants interface file emitBanner(f_module); - if (Len(package) > 0) + if (package) Printf(f_module, "package %s;\n", package); if (module_imports) @@ -1195,7 +1197,7 @@ public: if (!nspace) { full_imclass_name = NewStringf("%s", imclass_name); } else { - if (Len(package) > 0) { + if (package) { full_imclass_name = NewStringf("%s.%s", package, imclass_name); } else { full_imclass_name = NewStringf("%s", imclass_name); @@ -1277,9 +1279,9 @@ public: // Start writing out the enum file emitBanner(f_enum); - if (Len(package) > 0 || nspace) { + if (package || nspace) { Printf(f_enum, "package "); - if (Len(package) > 0) + if (package) Printv(f_enum, package, nspace ? "." : "", NIL); if (nspace) Printv(f_enum, nspace, NIL); @@ -1828,7 +1830,7 @@ public: SWIG_exit(EXIT_FAILURE); } } else { - if (Len(package) > 0) { + if (package) { full_proxy_class_name = NewStringf("%s.%s.%s", package, nspace, proxy_class_name); full_imclass_name = NewStringf("%s.%s", package, imclass_name); } else { @@ -1856,9 +1858,9 @@ public: // Start writing out the proxy class file emitBanner(f_proxy); - if (Len(package) > 0 || nspace) { + if (package || nspace) { Printf(f_proxy, "package "); - if (Len(package) > 0) + if (package) Printv(f_proxy, package, nspace ? "." : "", NIL); if (nspace) Printv(f_proxy, nspace, NIL); @@ -2807,7 +2809,7 @@ public: // global enum or enum in a namespace String *nspace = Getattr(n, "sym:nspace"); if (nspace) { - if (Len(package) > 0) + if (package) enumname = NewStringf("%s.%s.%s", package, nspace, symname); else enumname = NewStringf("%s.%s", nspace, symname); @@ -2963,7 +2965,7 @@ public: // Start writing out the type wrapper class file emitBanner(f_swigtype); - if (Len(package) > 0) + if (package) Printf(f_swigtype, "package %s;\n", package); // Pure Java baseclass and interfaces @@ -3274,8 +3276,7 @@ public: /*---------------------------------------------------------------------- * emitDirectorExtraMethods() * - * This is where the $javaclassname_director_connect is - * generated. + * This is where the director connect method is generated. *--------------------------------------------------------------------*/ void emitDirectorExtraMethods(Node *n) { if (!Swig_directorclass(n)) From 48533467451c63fc25bde65e8bc1cdea3665c3f7 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 10 Mar 2010 08:07:39 +0000 Subject: [PATCH 0787/1680] remove duplicate special variable replacement git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11934 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/csharp.cxx | 32 +++++++++++++------------------- Source/Modules/java.cxx | 29 +++++++++++++---------------- 2 files changed, 26 insertions(+), 35 deletions(-) diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index 341937308..f3025603c 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -1755,28 +1755,10 @@ public: Delete(attributes); Delete(destruct); - String *csclazzname = Swig_name_member(getNSpace(), proxy_class_name, ""); // mangled full proxy class name - // Emit extra user 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 - Replaceall(proxy_class_code, "$csclassname", proxy_class_name); - Replaceall(proxy_class_def, "$csclassname", proxy_class_name); - - Replaceall(proxy_class_def, "$module", module_class_name); - Replaceall(proxy_class_code, "$module", module_class_name); - - Replaceall(proxy_class_def, "$imclassname", full_imclass_name); - Replaceall(proxy_class_code, "$imclassname", full_imclass_name); - - Replaceall(proxy_class_def, "$dllimport", dllimport); - Replaceall(proxy_class_code, "$dllimport", dllimport); - - Replaceall(proxy_class_def, "$csclazzname", csclazzname); - Replaceall(proxy_class_code, "$csclazzname", csclazzname); - // Add code to do C++ casting to base class (only for classes in an inheritance hierarchy) if (derived) { String *upcast_method = Swig_name_member(getNSpace(), proxy_class_name, "SWIGUpcast"); @@ -1794,7 +1776,6 @@ public: Delete(wname); Delete(upcast_method); } - Delete(csclazzname); Delete(baseclass); } @@ -1863,12 +1844,24 @@ public: emitProxyClassDefAndCPPCasts(n); + String *csclazzname = Swig_name_member(getNSpace(), proxy_class_name, ""); // mangled full proxy class name + + Replaceall(proxy_class_def, "$csclassname", proxy_class_name); + Replaceall(proxy_class_code, "$csclassname", proxy_class_name); + Replaceall(proxy_class_constants_code, "$csclassname", proxy_class_name); + + Replaceall(proxy_class_def, "$csclazzname", csclazzname); + Replaceall(proxy_class_code, "$csclazzname", csclazzname); + Replaceall(proxy_class_constants_code, "$csclazzname", csclazzname); + Replaceall(proxy_class_def, "$module", module_class_name); Replaceall(proxy_class_code, "$module", module_class_name); Replaceall(proxy_class_constants_code, "$module", module_class_name); + Replaceall(proxy_class_def, "$imclassname", full_imclass_name); Replaceall(proxy_class_code, "$imclassname", full_imclass_name); Replaceall(proxy_class_constants_code, "$imclassname", full_imclass_name); + Replaceall(proxy_class_def, "$dllimport", dllimport); Replaceall(proxy_class_code, "$dllimport", dllimport); Replaceall(proxy_class_constants_code, "$dllimport", dllimport); @@ -1917,6 +1910,7 @@ public: emitDirectorExtraMethods(n); + Delete(csclazzname); Delete(proxy_class_name); proxy_class_name = NULL; Delete(full_proxy_class_name); diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index 65bb440f3..ebba67106 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -1764,25 +1764,10 @@ public: Delete(attributes); Delete(destruct); - String *javaclazzname = Swig_name_member(getNSpace(), proxy_class_name, ""); // mangled full proxy class name - // Emit extra user 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 - Replaceall(proxy_class_code, "$javaclassname", proxy_class_name); - Replaceall(proxy_class_def, "$javaclassname", proxy_class_name); - - Replaceall(proxy_class_def, "$module", module_class_name); - Replaceall(proxy_class_code, "$module", module_class_name); - - Replaceall(proxy_class_def, "$imclassname", full_imclass_name); - Replaceall(proxy_class_code, "$imclassname", full_imclass_name); - - Replaceall(proxy_class_def, "$javaclazzname", javaclazzname); - Replaceall(proxy_class_code, "$javaclazzname", javaclazzname); - // Add code to do C++ casting to base class (only for classes in an inheritance hierarchy) if (derived) { String *upcast_method = Swig_name_member(getNSpace(), proxy_class_name, "SWIGUpcast"); @@ -1802,7 +1787,6 @@ public: Delete(jniname); Delete(upcast_method); } - Delete(javaclazzname); Delete(baseclass); } @@ -1882,12 +1866,24 @@ public: emitProxyClassDefAndCPPCasts(n); + String *javaclazzname = Swig_name_member(getNSpace(), proxy_class_name, ""); // mangled full proxy class name + + Replaceall(proxy_class_def, "$javaclassname", proxy_class_name); + Replaceall(proxy_class_code, "$javaclassname", proxy_class_name); + Replaceall(proxy_class_constants_code, "$javaclassname", proxy_class_name); + + Replaceall(proxy_class_def, "$javaclazzname", javaclazzname); + Replaceall(proxy_class_code, "$javaclazzname", javaclazzname); + Replaceall(proxy_class_constants_code, "$javaclazzname", javaclazzname); + Replaceall(proxy_class_def, "$module", module_class_name); Replaceall(proxy_class_code, "$module", module_class_name); Replaceall(proxy_class_constants_code, "$module", module_class_name); + Replaceall(proxy_class_def, "$imclassname", full_imclass_name); Replaceall(proxy_class_code, "$imclassname", full_imclass_name); Replaceall(proxy_class_constants_code, "$imclassname", full_imclass_name); + Printv(f_proxy, proxy_class_def, proxy_class_code, NIL); // Write out all the constants @@ -1933,6 +1929,7 @@ public: emitDirectorExtraMethods(n); + Delete(javaclazzname); Delete(proxy_class_name); proxy_class_name = NULL; Delete(full_proxy_class_name); From 541bc7d43539486f8d32497af904ad4916d382b9 Mon Sep 17 00:00:00 2001 From: Mikel Bancroft Date: Wed, 10 Mar 2010 19:38:24 +0000 Subject: [PATCH 0788/1680] [allegrocl] Use fully qualified symbol name for cl::identity git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11935 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 3 +++ Source/Modules/allegrocl.cxx | 7 +------ 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index baf364a47..7b18af4c7 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,9 @@ Version 2.0.0 (in progress) ============================ +2010-03-10: mutandiz (Mikel Bancroft) + [allegrocl] Use fully qualified symbol name of cl::identity in emit_defun(). + 2010-03-06: wsfulton [Java] The intermediary JNI class modifiers are now public by default meaning these intermediary low level functions are now accessible by default from outside any package diff --git a/Source/Modules/allegrocl.cxx b/Source/Modules/allegrocl.cxx index 3c6e86cc5..de4a7bfa9 100644 --- a/Source/Modules/allegrocl.cxx +++ b/Source/Modules/allegrocl.cxx @@ -1669,13 +1669,8 @@ int ALLEGROCL::top(Node *n) { Printf(f_clhead, "(in-package :%s)\n", module_name); - // Swig_print_tree(n); - Language::top(n); - // SwigType_emit_type_table(f_runtime,f_cxx_wrapper); - - // Swig_print_tree(n); #ifdef ALLEGROCL_TYPE_DEBUG dump_linked_types(stderr); #endif @@ -2538,7 +2533,7 @@ int ALLEGROCL::emit_defun(Node *n, File *fcl) { // NewStringf("(push (swig-ff-call%s) ACL_result)", wrap->locals))); String *ldestructor = Copy(lclass); if (ff_foreign_ptr) - Replaceall(ldestructor, ldestructor, "identity"); + Replaceall(ldestructor, ldestructor, "cl::identity"); else Replaceall(ldestructor, ":type :class", ":type :destructor"); Replaceall(wrap->code, "$ldestructor", ldestructor); From 7af8eb954b6f1dcbf4fe2dd6888e8d4f22b04906 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 10 Mar 2010 22:00:14 +0000 Subject: [PATCH 0789/1680] add some missing nspace support git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11936 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/csharp.cxx | 4 ++-- Source/Modules/java.cxx | 4 ++-- Source/Modules/modula3.cxx | 4 ++-- Source/Modules/ocaml.cxx | 4 ++-- Source/Modules/pike.cxx | 4 ++-- Source/Modules/ruby.cxx | 6 +++--- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index f3025603c..0ee47c708 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -411,8 +411,8 @@ public: Swig_name_register("wrapper", "CSharp_%f"); if (old_variable_names) { - Swig_name_register("set", "set_%v"); - Swig_name_register("get", "get_%v"); + Swig_name_register("set", "set_%n%v"); + Swig_name_register("get", "get_%n%v"); } Printf(f_wrappers, "\n#ifdef __cplusplus\n"); diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index ebba67106..b8a0dd9a5 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -437,8 +437,8 @@ public: Swig_name_register("wrapper", Char(wrapper_name)); if (old_variable_names) { - Swig_name_register("set", "set_%v"); - Swig_name_register("get", "get_%v"); + Swig_name_register("set", "set_%n%v"); + Swig_name_register("get", "get_%n%v"); } Delete(wrapper_name); diff --git a/Source/Modules/modula3.cxx b/Source/Modules/modula3.cxx index 252e92a7d..fb928a898 100644 --- a/Source/Modules/modula3.cxx +++ b/Source/Modules/modula3.cxx @@ -972,8 +972,8 @@ MODULA3(): Swig_name_register("wrapper", "Modula3_%f"); if (old_variable_names) { - Swig_name_register("set", "set_%v"); - Swig_name_register("get", "get_%v"); + Swig_name_register("set", "set_%n%v"); + Swig_name_register("get", "get_%n%v"); } Printf(f_wrappers, "\n#ifdef __cplusplus\n"); diff --git a/Source/Modules/ocaml.cxx b/Source/Modules/ocaml.cxx index 41c30c858..7aa7286e9 100644 --- a/Source/Modules/ocaml.cxx +++ b/Source/Modules/ocaml.cxx @@ -265,8 +265,8 @@ public: Swig_register_filebyname("class_ctors", f_class_ctors); if (old_variable_names) { - Swig_name_register("set", "%v__set__"); - Swig_name_register("get", "%v__get__"); + Swig_name_register("set", "%n%v__set__"); + Swig_name_register("get", "%n%v__get__"); } Swig_banner(f_begin); diff --git a/Source/Modules/pike.cxx b/Source/Modules/pike.cxx index 51758ae46..bd1edec62 100644 --- a/Source/Modules/pike.cxx +++ b/Source/Modules/pike.cxx @@ -159,8 +159,8 @@ public: Printf(f_header, "#define SWIG_name \"%s\"\n\n", module); /* Change naming scheme for constructors and destructors */ - Swig_name_register("construct", "%c_create"); - Swig_name_register("destroy", "%c_destroy"); + Swig_name_register("construct", "%n%c_create"); + Swig_name_register("destroy", "%n%c_destroy"); /* Current wrap type */ current = NO_CPP; diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx index 043df02f2..0ed175945 100644 --- a/Source/Modules/ruby.cxx +++ b/Source/Modules/ruby.cxx @@ -2578,7 +2578,7 @@ public: /* First wrap the allocate method */ current = CONSTRUCTOR_ALLOCATE; - Swig_name_register("construct", "%c_allocate"); + Swig_name_register("construct", "%n%c_allocate"); Language::constructorHandler(n); @@ -2613,7 +2613,7 @@ public: Delete(docs); current = CONSTRUCTOR_INITIALIZE; - Swig_name_register("construct", "new_%c"); + Swig_name_register("construct", "new_%n%c"); Language::constructorHandler(n); /* Restore original parameter list */ @@ -2635,7 +2635,7 @@ public: /* First wrap the allocate method */ current = CONSTRUCTOR_ALLOCATE; - Swig_name_register("construct", "%c_allocate"); + Swig_name_register("construct", "%n%n%c_allocate"); return Language::copyconstructorHandler(n); } From 7ed1528349066c1257fb59812e40c5be4a0033d5 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 13 Mar 2010 00:05:31 +0000 Subject: [PATCH 0790/1680] nspace fixes and adding in missing symbols in language symbol tables for Java and C# git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11937 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/csharp/nspace_runme.cs | 18 ++++-- Examples/test-suite/java/nspace_runme.java | 18 ++++-- Examples/test-suite/nspace.i | 37 +++++------- Source/Modules/csharp.cxx | 69 ++++++++++++++++++---- Source/Modules/java.cxx | 68 +++++++++++++++++---- Source/Modules/lang.cxx | 19 ++++-- 6 files changed, 174 insertions(+), 55 deletions(-) diff --git a/Examples/test-suite/csharp/nspace_runme.cs b/Examples/test-suite/csharp/nspace_runme.cs index 7ced06a04..9cf593857 100644 --- a/Examples/test-suite/csharp/nspace_runme.cs +++ b/Examples/test-suite/csharp/nspace_runme.cs @@ -22,16 +22,26 @@ public class runme if (channel != nspaceNamespace.Outer.Inner1.Color.Channel.Transmission) throw new ApplicationException("Transmission wrong"); - // static member variables - nspaceNamespace.Outer.Inner1.Color.staticMemberVariable = 789; - if (nspaceNamespace.Outer.Inner1.Color.staticMemberVariable != 789) - throw new ApplicationException("static member variable failed"); + // class anonymous enums + int val1 = nspaceNamespace.Outer.Inner1.Color.ColorEnumVal1; + int val2 = nspaceNamespace.Outer.Inner1.Color.ColorEnumVal2; + if (val1 != 0 || val2 != 0x22) + throw new ApplicationException("ColorEnumVal wrong"); // instance member variables color.instanceMemberVariable = 123; if (color.instanceMemberVariable != 123) throw new ApplicationException("instance member variable failed"); + // static member variables + nspaceNamespace.Outer.Inner1.Color.staticMemberVariable = 789; + if (nspaceNamespace.Outer.Inner1.Color.staticMemberVariable != 789) + throw new ApplicationException("static member variable failed"); + if (nspaceNamespace.Outer.Inner1.Color.staticConstMemberVariable != 222) + throw new ApplicationException("static const member variable failed"); + if (nspaceNamespace.Outer.Inner1.Color.staticConstEnumMemberVariable != nspaceNamespace.Outer.Inner1.Color.Channel.Transmission) + throw new ApplicationException("static const enum member variable failed"); + // check globals in a namespace don't get mangled with the nspaceNamespace option nspaceNamespace.nspace.namespaceFunction(color); nspaceNamespace.nspace.namespaceVar = 111; diff --git a/Examples/test-suite/java/nspace_runme.java b/Examples/test-suite/java/nspace_runme.java index a50bb9ae9..9800e79cd 100644 --- a/Examples/test-suite/java/nspace_runme.java +++ b/Examples/test-suite/java/nspace_runme.java @@ -28,16 +28,26 @@ public class nspace_runme { if (channel != nspacePackage.Outer.Inner1.Color.Channel.Transmission) throw new RuntimeException("Transmission wrong"); - // static member variables - nspacePackage.Outer.Inner1.Color.setStaticMemberVariable(789); - if (nspacePackage.Outer.Inner1.Color.getStaticMemberVariable() != 789) - throw new RuntimeException("static member variable failed"); + // class anonymous enums + int val1 = nspacePackage.Outer.Inner1.Color.ColorEnumVal1; + int val2 = nspacePackage.Outer.Inner1.Color.ColorEnumVal2; + if (val1 != 0 || val2 != 0x22) + throw new RuntimeException("ColorEnumVal wrong"); // instance member variables color.setInstanceMemberVariable(123); if (color.getInstanceMemberVariable() != 123) throw new RuntimeException("instance member variable failed"); + // static member variables + nspacePackage.Outer.Inner1.Color.setStaticMemberVariable(789); + if (nspacePackage.Outer.Inner1.Color.getStaticMemberVariable() != 789) + throw new RuntimeException("static member variable failed"); + if (nspacePackage.Outer.Inner1.Color.staticConstMemberVariable != 222) + throw new RuntimeException("static const member variable failed"); + if (nspacePackage.Outer.Inner1.Color.staticConstEnumMemberVariable != nspacePackage.Outer.Inner1.Color.Channel.Transmission) + throw new RuntimeException("static const enum member variable failed"); + // Same class different namespaces nspacePackage.Outer.Inner1.Color col1 = new nspacePackage.Outer.Inner1.Color(); nspacePackage.Outer.Inner2.Color col2 = nspacePackage.Outer.Inner2.Color.create(); diff --git a/Examples/test-suite/nspace.i b/Examples/test-suite/nspace.i index 82f6e1101..4e4e461c0 100644 --- a/Examples/test-suite/nspace.i +++ b/Examples/test-suite/nspace.i @@ -10,29 +10,27 @@ %copyctor; %ignore Outer::Inner2::Color::Color(); +#define CONSTANT100 100 + %inline %{ namespace Outer { class nspace { }; namespace Inner1 { - enum Channel { - Diffuse, - Specular = 0x10, - Transmission1 - }; + enum Channel { Diffuse, Specular = 0x10, Transmission1 }; + enum { ColorEnumVal1, ColorEnumVal2 = 0x11, ColorEnumVal3 }; struct Color { static Color* create() { return new Color(); } - enum Channel { - Diffuse, - Specular = 0x20, - Transmission - }; + enum Channel { Diffuse, Specular = 0x20, Transmission }; + enum { ColorEnumVal1, ColorEnumVal2 = 0x22, ColorEnumVal3 }; int instanceMemberVariable; static int staticMemberVariable; + static const int staticConstMemberVariable = 222; + static const Channel staticConstEnumMemberVariable = Transmission; void colorInstanceMethod(double d) {} static void colorStaticMethod(double d) {} }; // Color @@ -43,24 +41,19 @@ namespace Outer { } // Inner1 namespace Inner2 { - enum Channel { - Diffuse, - Specular /* = 0x30*/, - Transmission2 - }; + enum Channel { Diffuse, Specular = 0x30, Transmission2 }; struct Color { Color() : instanceMemberVariable(0) {} static Color* create() { return new Color(); } - enum Channel { - Diffuse, - Specular/* = 0x40*/, - Transmission - }; + enum Channel { Diffuse, Specular = 0x40, Transmission }; + enum { ColorEnumVal1, ColorEnumVal2 = 0x33, ColorEnumVal3 }; int instanceMemberVariable; static int staticMemberVariable; + static const int staticConstMemberVariable = 333; + static const Channel staticConstEnumMemberVariable = Transmission; void colorInstanceMethod(double d) {} static void colorStaticMethod(double d) {} void colors(const Inner1::Color& col1a, @@ -85,8 +78,8 @@ namespace Outer { }; } - class SomeClass { - public: + class SomeClass { + public: Inner1::Color::Channel GetInner1ColorChannel() { return Inner1::Color::Transmission; } Inner2::Color::Channel GetInner2ColorChannel() { return Inner2::Color::Transmission; } Inner1::Channel GetInner1Channel() { return Inner1::Transmission1; } diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index 0ee47c708..4fb5699b8 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -1128,9 +1128,9 @@ public: if (getCurrentClass() && (cplus_mode != PUBLIC)) return SWIG_NOWRAP; + String *nspace = Getattr(n, "sym:nspace"); // NSpace/getNSpace() only works during Language::enumDeclaration call if (proxy_flag && !is_wrapping_class()) { // Global enums / enums in a namespace - String *nspace = Getattr(n, "sym:nspace"); assert(!full_imclass_name); if (!nspace) { @@ -1153,6 +1153,17 @@ public: if ((enum_feature != SimpleEnum) && symname && typemap_lookup_type) { // Wrap (non-anonymous) C/C++ enum within a typesafe, typeunsafe or proper C# enum + String *scope = 0; + if (nspace || proxy_class_name) { + scope = NewString(""); + if (nspace) + Printf(scope, "%s", nspace); + if (proxy_class_name) + Printv(scope, nspace ? "." : "", proxy_class_name, NIL); + } + if (!addSymbol(symname, n, scope)) + return SWIG_ERROR; + // Pure C# baseclass and interfaces const String *pure_baseclass = typemapLookup(n, "csbase", typemap_lookup_type, WARN_NONE); const String *pure_interfaces = typemapLookup(n, "csinterfaces", typemap_lookup_type, WARN_NONE); @@ -1166,6 +1177,7 @@ public: Printv(enum_code, typemapLookup(n, "csclassmodifiers", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers (enum modifiers really) " ", symname, (*Char(pure_baseclass) || *Char(pure_interfaces)) ? " : " : "", pure_baseclass, ((*Char(pure_baseclass)) && *Char(pure_interfaces)) ? // Interfaces ", " : "", pure_interfaces, " {\n", NIL); + Delete(scope); } else { // Wrap C++ enum with integers - just indicate start of enum with a comment, no comment for anonymous enums of any sort if (symname && !Getattr(n, "unnamedinstance")) @@ -1201,7 +1213,6 @@ public: Printv(proxy_class_constants_code, " ", enum_code, "\n\n", NIL); } else { // Global enums are defined in their own file - String *nspace = Getattr(n, "sym:nspace"); String *output_directory = outputDirectory(nspace); String *filen = NewStringf("%s%s.cs", output_directory, symname); File *f_enum = NewFile(filen, "w", SWIG_output_files()); @@ -1260,6 +1271,7 @@ public: Node *parent = parentNode(n); int unnamedinstance = GetFlag(parent, "unnamedinstance"); String *parent_name = Getattr(parent, "name"); + String *nspace = getNSpace(); String *tmpValue; // Strange hack from parent method @@ -1272,6 +1284,29 @@ public: { EnumFeature enum_feature = decodeEnumFeature(parent); + + // Add to language symbol table + String *scope = 0; + if (unnamedinstance || !parent_name || enum_feature == SimpleEnum) { + if (proxy_class_name) { + scope = NewString(""); + if (nspace) + Printf(scope, "%s.", nspace); + Printf(scope, "%s", proxy_class_name); + } else { + scope = Copy(module_class_name); + } + } else { + scope = NewString(""); + if (nspace) + Printf(scope, "%s.", nspace); + if (proxy_class_name) + Printf(scope, "%s.", proxy_class_name); + Printf(scope, "%s",Getattr(parent, "sym:name")); + } + if (!addSymbol(name, n, scope)) + return SWIG_ERROR; + const String *csattributes = Getattr(n, "feature:cs:attributes"); if ((enum_feature == ProperEnum) && parent_name && !unnamedinstance) { @@ -1336,6 +1371,7 @@ public: Setattr(parent, "enumvalues", Copy(symname)); else Printv(enumvalues, ", ", symname, NIL); + Delete(scope); } Delete(tmpValue); @@ -1365,9 +1401,21 @@ public: 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; + if (!is_enum_item) { + String *scope = 0; + if (proxy_class_name) { + String *nspace = getNSpace(); + scope = NewString(""); + if (nspace) + Printf(scope, "%s.", nspace); + Printf(scope, "%s", proxy_class_name); + } else { + scope = Copy(module_class_name); + } + if (!addSymbol(itemname, n, scope)) + return SWIG_ERROR; + Delete(scope); + } // The %csconst feature determines how the constant value is obtained int const_feature_flag = GetFlag(n, "feature:cs:const"); @@ -1426,13 +1474,14 @@ public: if (classname_substituted_flag) { if (SwigType_isenum(t)) { // This handles wrapping of inline initialised const enum static member variables (not when wrapping enum items - ignored later on) - Printf(constants_code, "(%s)%s.%s();\n", return_type, imclass_name, Swig_name_get(getNSpace(), symname)); + Printf(constants_code, "(%s)%s.%s();\n", return_type, full_imclass_name, Swig_name_get(getNSpace(), symname)); } else { // This handles function pointers using the %constant directive - Printf(constants_code, "new %s(%s.%s(), false);\n", return_type, imclass_name, Swig_name_get(getNSpace(), symname)); + Printf(constants_code, "new %s(%s.%s(), false);\n", return_type, full_imclass_name, Swig_name_get(getNSpace(), symname)); } - } else - Printf(constants_code, "%s.%s();\n", imclass_name, Swig_name_get(getNSpace(), symname)); + } else { + Printf(constants_code, "%s.%s();\n", full_imclass_name ? full_imclass_name : imclass_name, Swig_name_get(getNSpace(), symname)); + } // Each constant and enum value is wrapped with a separate PInvoke function call SetFlag(n, "feature:immutable"); @@ -2924,7 +2973,7 @@ public: value = NewStringf("%s.%s()", full_imclass_name ? full_imclass_name : imclass_name, Swig_name_get(getNSpace(), symname)); } else { memberconstantHandler(n); - value = NewStringf("%s.%s()", full_imclass_name ? full_imclass_name : imclass_name, Swig_name_get(getNSpace(), Swig_name_member(getNSpace(), proxy_class_name, symname))); + value = NewStringf("%s.%s()", full_imclass_name ? full_imclass_name : imclass_name, Swig_name_get(getNSpace(), Swig_name_member(0, proxy_class_name, symname))); } } } diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index b8a0dd9a5..229e65379 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -1189,9 +1189,9 @@ public: if (getCurrentClass() && (cplus_mode != PUBLIC)) return SWIG_NOWRAP; + String *nspace = Getattr(n, "sym:nspace"); // NSpace/getNSpace() only works during Language::enumDeclaration call if (proxy_flag && !is_wrapping_class()) { // Global enums / enums in a namespace - String *nspace = Getattr(n, "sym:nspace"); assert(!full_imclass_name); if (!nspace) { @@ -1216,6 +1216,17 @@ public: if ((enum_feature != SimpleEnum) && symname && typemap_lookup_type) { // Wrap (non-anonymous) C/C++ enum within a typesafe, typeunsafe or proper Java enum + String *scope = 0; + if (nspace || proxy_class_name) { + scope = NewString(""); + if (nspace) + Printf(scope, "%s", nspace); + if (proxy_class_name) + Printv(scope, nspace ? "." : "", proxy_class_name, NIL); + } + if (!addSymbol(symname, n, scope)) + return SWIG_ERROR; + // Pure Java baseclass and interfaces const String *pure_baseclass = typemapLookup(n, "javabase", typemap_lookup_type, WARN_NONE); const String *pure_interfaces = typemapLookup(n, "javainterfaces", typemap_lookup_type, WARN_NONE); @@ -1229,6 +1240,7 @@ public: Replaceall(enum_code, "$static ", "static "); else Replaceall(enum_code, "$static ", ""); + Delete(scope); } else { // Wrap C++ enum with integers - just indicate start of enum with a comment, no comment for anonymous enums of any sort if (symname && !Getattr(n, "unnamedinstance")) @@ -1264,7 +1276,6 @@ public: Printv(proxy_class_constants_code, " ", enum_code, "\n\n", NIL); } else { // Global enums are defined in their own file - String *nspace = Getattr(n, "sym:nspace"); String *output_directory = outputDirectory(nspace); String *filen = NewStringf("%s%s.java", output_directory, symname); File *f_enum = NewFile(filen, "w", SWIG_output_files()); @@ -1330,6 +1341,7 @@ public: Node *parent = parentNode(n); int unnamedinstance = GetFlag(parent, "unnamedinstance"); String *parent_name = Getattr(parent, "name"); + String *nspace = getNSpace(); String *tmpValue; // Strange hack from parent method @@ -1343,6 +1355,28 @@ public: { EnumFeature enum_feature = decodeEnumFeature(parent); + // Add to language symbol table + String *scope = 0; + if (unnamedinstance || !parent_name || enum_feature == SimpleEnum) { + if (proxy_class_name) { + scope = NewString(""); + if (nspace) + Printf(scope, "%s.", nspace); + Printf(scope, "%s", proxy_class_name); + } else { + scope = Copy(constants_interface_name); + } + } else { + scope = NewString(""); + if (nspace) + Printf(scope, "%s.", nspace); + if (proxy_class_name) + Printf(scope, "%s.", proxy_class_name); + Printf(scope, "%s",Getattr(parent, "sym:name")); + } + if (!addSymbol(name, n, scope)) + return SWIG_ERROR; + if ((enum_feature == ProperEnum) && parent_name && !unnamedinstance) { // Wrap (non-anonymous) C/C++ enum with a proper Java enum // Emit the enum item. @@ -1389,6 +1423,7 @@ public: Setattr(parent, "enumvalues", Copy(symname)); else Printv(enumvalues, ", ", symname, NIL); + Delete(scope); } Delete(tmpValue); @@ -1418,9 +1453,21 @@ public: 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; + if (!is_enum_item) { + String *scope = 0; + if (proxy_class_name) { + String *nspace = getNSpace(); + scope = NewString(""); + if (nspace) + Printf(scope, "%s.", nspace); + Printf(scope, "%s", proxy_class_name); + } else { + scope = Copy(constants_interface_name); + } + if (!addSymbol(itemname, n, scope)) + return SWIG_ERROR; + Delete(scope); + } // The %javaconst feature determines how the constant value is obtained int const_feature_flag = GetFlag(n, "feature:java:const"); @@ -1472,13 +1519,14 @@ public: if (classname_substituted_flag) { if (SwigType_isenum(t)) { // This handles wrapping of inline initialised const enum static member variables (not when wrapping enum items - ignored later on) - Printf(constants_code, "%s.swigToEnum(%s.%s());\n", return_type, imclass_name, Swig_name_get(getNSpace(), symname)); + Printf(constants_code, "%s.swigToEnum(%s.%s());\n", return_type, full_imclass_name, Swig_name_get(getNSpace(), symname)); } else { // This handles function pointers using the %constant directive - Printf(constants_code, "new %s(%s.%s(), false);\n", return_type, imclass_name, Swig_name_get(getNSpace(), symname)); + Printf(constants_code, "new %s(%s.%s(), false);\n", return_type, full_imclass_name, Swig_name_get(getNSpace(), symname)); } - } else - Printf(constants_code, "%s.%s();\n", imclass_name, Swig_name_get(getNSpace(), symname)); + } else { + Printf(constants_code, "%s.%s();\n", full_imclass_name ? full_imclass_name : imclass_name, Swig_name_get(getNSpace(), symname)); + } // Each constant and enum value is wrapped with a separate JNI function call SetFlag(n, "feature:immutable"); @@ -2772,7 +2820,7 @@ public: value = NewStringf("%s.%s()", full_imclass_name ? full_imclass_name : imclass_name, Swig_name_get(getNSpace(), symname)); } else { memberconstantHandler(n); - value = NewStringf("%s.%s()", full_imclass_name ? full_imclass_name : imclass_name, Swig_name_get(getNSpace(), Swig_name_member(getNSpace(), proxy_class_name, symname))); + value = NewStringf("%s.%s()", full_imclass_name ? full_imclass_name : imclass_name, Swig_name_get(getNSpace(), Swig_name_member(0, proxy_class_name, symname))); } } } diff --git a/Source/Modules/lang.cxx b/Source/Modules/lang.cxx index 2ccefb619..778c8e5ba 100644 --- a/Source/Modules/lang.cxx +++ b/Source/Modules/lang.cxx @@ -1612,9 +1612,15 @@ int Language::externDeclaration(Node *n) { * ---------------------------------------------------------------------- */ int Language::enumDeclaration(Node *n) { + String *oldNSpace = NSpace; + NSpace = Getattr(n, "sym:nspace"); + if (!ImportMode) { emit_children(n); } + + NSpace = oldNSpace; + return SWIG_OK; } @@ -1677,7 +1683,7 @@ int Language::memberconstantHandler(Node *n) { String *symname = Getattr(n, "sym:name"); String *value = Getattr(n, "value"); - String *mrename = Swig_name_member(NSpace, ClassPrefix, symname); + String *mrename = Swig_name_member(0, ClassPrefix, symname); Setattr(n, "sym:name", mrename); String *new_name = 0; @@ -2316,7 +2322,6 @@ int Language::classDeclaration(Node *n) { String *name = Getattr(n, "name"); String *tdname = Getattr(n, "tdname"); String *symname = Getattr(n, "sym:name"); - String *symnspace = Getattr(n, "sym:nspace"); char *classname = tdname ? Char(tdname) : Char(name); char *iname = Char(symname); @@ -2345,7 +2350,6 @@ int Language::classDeclaration(Node *n) { ClassName = NewString(classname); ClassPrefix = NewString(iname); - NSpace = symnspace; if (strip) { ClassType = NewString(classname); } else { @@ -2357,6 +2361,8 @@ int Language::classDeclaration(Node *n) { InClass = 1; CurrentClass = n; + String *oldNSpace = NSpace; + NSpace = Getattr(n, "sym:nspace"); /* Call classHandler() here */ if (!ImportMode) { @@ -2406,7 +2412,7 @@ int Language::classDeclaration(Node *n) { Language::classHandler(n); } - NSpace = 0; + NSpace = oldNSpace; InClass = 0; CurrentClass = 0; Delete(ClassType); @@ -2944,7 +2950,10 @@ int Language::addSymbol(const String *s, const Node *n, const_String_or_char_ptr } 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); + if (scope) + Swig_error(input_file, line_number, "'%s' is multiply defined in the generated target language module in scope %s.\n", s, scope); + else + Swig_error(input_file, line_number, "'%s' is multiply defined in the generated target language module.\n", s); Swig_error(Getfile(c), Getline(c), "Previous declaration of '%s'\n", s); return 0; } From 780e71e509ca48cadc0b67dd3c862802d6e3676c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 13 Mar 2010 00:24:00 +0000 Subject: [PATCH 0791/1680] minor ruby cleanup git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11938 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/ruby.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx index 0ed175945..ce89f9c63 100644 --- a/Source/Modules/ruby.cxx +++ b/Source/Modules/ruby.cxx @@ -2621,7 +2621,7 @@ public: Swig_restore(n); /* Done */ - Swig_name_unregister((const_String_or_char_ptr ) "construct"); + Swig_name_unregister("construct"); current = NO_CPP; klass->constructor_defined = 1; return SWIG_OK; @@ -2635,7 +2635,7 @@ public: /* First wrap the allocate method */ current = CONSTRUCTOR_ALLOCATE; - Swig_name_register("construct", "%n%n%c_allocate"); + Swig_name_register("construct", "%n%c_allocate"); return Language::copyconstructorHandler(n); } From bbf225ef6390438d637096514c409cf51495f408 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 13 Mar 2010 09:54:07 +0000 Subject: [PATCH 0792/1680] Minor changes to error message for Java when -package is missing with nspace git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11943 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Java.html | 9 ++++++++- Source/Modules/java.cxx | 9 ++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html index 5b61955ab..857363840 100644 --- a/Doc/Manual/Java.html +++ b/Doc/Manual/Java.html @@ -1916,9 +1916,16 @@ Note that it only works for classes, structs, unions and enums declared within a When the nspace feature is used, the C++ namespaces are converted into Java packages of the same name. Proxy classes are thus declared within a package and this proxy makes numerous calls to the JNI intermediary class which is declared in the unnamed package by default. As Java does not support types declared in a named package accessing types declared in an unnamed package, the -package commandline option described earlier must be used to provide a parent package. -So if SWIG is run using the -package com.myco option, a wrapped class, MyWorld::Material::Color, can then be accessed as com.myco.MyWorld.Material.Color. +So if SWIG is run using the -package com.myco option, a wrapped class, MyWorld::Material::Color, can then be accessed as com.myco.MyWorld.Material.Color. If you don't specify a package, you will get the following error message:

        +
        +
        +example.i:16: Error: The nspace feature used on 'MyWorld::Material::Color' is not supported unless a package is specified
        +with -package - Java does not support types declared in a named package accessing types declared in an unnamed package.
        +
        +
        +

        21.3.14 C++ templates

        diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index 229e65379..924d11941 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -1200,8 +1200,8 @@ public: if (package) { full_imclass_name = NewStringf("%s.%s", package, imclass_name); } else { - full_imclass_name = NewStringf("%s", imclass_name); - Printf(stderr, "The nspace feature used on %s is not supported unless a package is specified with -package - Java does not support types declared in a named package accessing types declared in an unnamed package.\n", Getattr(n, "name")); + String *name = Getattr(n, "name") ? Getattr(n, "name") : NewString(""); + Swig_error(Getfile(n), Getline(n), "The nspace feature used on '%s' is not supported unless a package is specified with -package - Java does not support types declared in a named package accessing types declared in an unnamed package.\n", name); SWIG_exit(EXIT_FAILURE); } } @@ -1866,9 +1866,8 @@ public: full_proxy_class_name = NewStringf("%s.%s.%s", package, nspace, proxy_class_name); full_imclass_name = NewStringf("%s.%s", package, imclass_name); } else { - full_proxy_class_name = NewStringf("%s.%s", nspace, proxy_class_name); - full_imclass_name = NewStringf("%s", imclass_name); - Printf(stderr, "The nspace feature used on %s is not supported unless a package is specified with -package - Java does not support types declared in a named package accessing types declared in an unnamed package.\n", Getattr(n, "name")); + String *name = Getattr(n, "name") ? Getattr(n, "name") : NewString(""); + Swig_error(Getfile(n), Getline(n), "The nspace feature used on '%s' is not supported unless a package is specified with -package - Java does not support types declared in a named package accessing types declared in an unnamed package.\n", name); SWIG_exit(EXIT_FAILURE); } } From 4f88d641af21c5bcfb9477370f6693a6c9711139 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 13 Mar 2010 22:28:24 +0000 Subject: [PATCH 0793/1680] Better handling of file paths containing multiple path separators. Fix recent regression incorrectly detecting a directory on Windows when the output directory is not the current directory. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11944 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 3 +++ Source/Modules/main.cxx | 23 ++++++++++++----------- Source/Swig/misc.c | 36 +++++++++++++++++++++++++++++++----- 3 files changed, 46 insertions(+), 16 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 7b18af4c7..b680f87fc 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,9 @@ Version 2.0.0 (in progress) ============================ +2010-03-13: wsfulton + Improve handling of file names and directories containing double/multiple path separators. + 2010-03-10: mutandiz (Mikel Bancroft) [allegrocl] Use fully qualified symbol name of cl::identity in emit_defun(). diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx index 86f279a67..2ad1665f6 100644 --- a/Source/Modules/main.cxx +++ b/Source/Modules/main.cxx @@ -281,20 +281,21 @@ static unsigned int decode_numbers_list(String *numlist) { // ----------------------------------------------------------------------------- // Sets the output directory for language specific (proxy) files if not set and -// adds trailing file separator if necessary. +// corrects the directory name and adds trailing file separator if necessary. // ----------------------------------------------------------------------------- -static void set_outdir(const String *c_wrapper_file_dir) { +static void configure_outdir(const String *c_wrapper_file_dir) { + + // Use the C wrapper file's directory if the output directory has not been set by user + if (!outdir || Len(outdir) == 0) + outdir = NewString(c_wrapper_file_dir); + + Swig_filename_correct(outdir); // Add file delimiter if not present in output directory name - if (outdir && Len(outdir) != 0) { - const char *outd = Char(outdir); - if (strcmp(outd + strlen(outd) - strlen(SWIG_FILE_DELIMITER), SWIG_FILE_DELIMITER) != 0) - Printv(outdir, SWIG_FILE_DELIMITER, NIL); - } - // Use the C wrapper file's directory if the output directory has not been set by user - if (!outdir) - outdir = NewString(c_wrapper_file_dir); + const char *outd = Char(outdir); + if (strcmp(outd + strlen(outd) - strlen(SWIG_FILE_DELIMITER), SWIG_FILE_DELIMITER) != 0) + Printv(outdir, SWIG_FILE_DELIMITER, NIL); } /* This function sets the name of the configuration file */ @@ -1221,7 +1222,7 @@ int SWIG_main(int argc, char *argv[], Language *l) { } else { Setattr(top, "outfile_h", outfile_name_h); } - set_outdir(Swig_file_dirname(Getattr(top, "outfile"))); + configure_outdir(Swig_file_dirname(Getattr(top, "outfile"))); if (Swig_contract_mode_get()) { Swig_contracts(top); } diff --git a/Source/Swig/misc.c b/Source/Swig/misc.c index 9a2a33278..8c480cc7c 100644 --- a/Source/Swig/misc.c +++ b/Source/Swig/misc.c @@ -22,7 +22,7 @@ char cvsroot_misc_c[] = "$Id$"; #ifdef _WIN32 #include -#define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR) +#define S_ISDIR(mode) (((mode) & S_IFDIR) == S_IFDIR) #endif static char *fake_version = 0; @@ -142,6 +142,26 @@ String *Swig_strip_c_comments(const String *s) { return stripped; } +/* ----------------------------------------------------------------------------- + * is_directory() + * ----------------------------------------------------------------------------- */ +static int is_directory(String *directory) { + int last = Len(directory) - 1; + int statres; + struct stat st; + char *dir = Char(directory); + if (dir[last] == SWIG_FILE_DELIMITER[0]) { + /* remove trailing slash - can cause S_ISDIR to fail on Windows, at least */ + dir[last] = 0; + statres = stat(dir, &st); + dir[last] = SWIG_FILE_DELIMITER[0]; + } else { + statres = stat(dir, &st); + } + Printf(stdout, "is_directory %d %s\n", (statres == 0 && S_ISDIR(st.st_mode)), dir); + return (statres == 0 && S_ISDIR(st.st_mode)); +} + /* ----------------------------------------------------------------------------- * Swig_new_subdirectory() * @@ -154,7 +174,7 @@ String *Swig_new_subdirectory(String *basedirectory, String *subdirectory) { struct stat st; int current_directory = basedirectory ? (Len(basedirectory) == 0 ? 1 : 0) : 0; - if (current_directory || ((stat(Char(basedirectory), &st) == 0) && S_ISDIR(st.st_mode))) { + if (current_directory || is_directory(basedirectory)) { Iterator it; String *dir = basedirectory ? NewString(basedirectory) : NewString(""); List *subdirs = Split(subdirectory, SWIG_FILE_DELIMITER[0], INT_MAX); @@ -186,7 +206,7 @@ String *Swig_new_subdirectory(String *basedirectory, String *subdirectory) { } } } else { - error = NewStringf("Cannot create subdirectory %s under the base directory %s", subdirectory, basedirectory); + error = NewStringf("Cannot create subdirectory %s under the base directory %s. Either the base does not exist as a directory or it is not readable.", subdirectory, basedirectory); } return error; } @@ -194,7 +214,8 @@ String *Swig_new_subdirectory(String *basedirectory, String *subdirectory) { /* ----------------------------------------------------------------------------- * Swig_filename_correct() * - * Corrects filenames on non-unix systems + * Corrects filename paths by removing duplicate delimeters and on non-unix + * systems use the correct delimeter across the whole name. * ----------------------------------------------------------------------------- */ void Swig_filename_correct(String *filename) { @@ -207,6 +228,9 @@ void Swig_filename_correct(String *filename) { /* accept Windows path separator in addition to Unix path separator */ Replaceall(filename, "\\", SWIG_FILE_DELIMITER); #endif + /* remove all duplicate file name delimiters */ + while (Replaceall(filename, SWIG_FILE_DELIMITER SWIG_FILE_DELIMITER, SWIG_FILE_DELIMITER)) { + } } /* ----------------------------------------------------------------------------- @@ -218,7 +242,9 @@ 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 */ + /* remove all double '\' in case any already present */ + while (Replaceall(adjusted_filename, "\\\\", "\\")) { + } Replaceall(adjusted_filename, "\\", "\\\\"); #endif return adjusted_filename; From e81bfb86c00565ac0bd79917f9fcfcb41b718a9f Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 13 Mar 2010 23:08:02 +0000 Subject: [PATCH 0794/1680] Correct file and line number display for some error messages, these now also result in exiting with an error. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11945 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 3 +++ Source/Modules/csharp.cxx | 4 ++-- Source/Modules/java.cxx | 32 ++++++++++++++++---------------- Source/Modules/modula3.cxx | 2 +- Source/Modules/perl5.cxx | 4 ++-- Source/Modules/php.cxx | 6 +++--- 6 files changed, 27 insertions(+), 24 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index b680f87fc..883963f27 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,9 @@ Version 2.0.0 (in progress) ============================ +2010-03-13: wsfulton + [Java] Some very old deprecated pragma warnings are now errors. + 2010-03-13: wsfulton Improve handling of file names and directories containing double/multiple path separators. diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index 4fb5699b8..38679dfba 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -712,7 +712,7 @@ public: Swig_restore(n); native_function_flag = false; } else { - Printf(stderr, "%s : Line %d. No return type for %%native method %s.\n", input_file, line_number, Getattr(n, "wrap:name")); + Swig_error(input_file, line_number, "No return type for %%native method %s.\n", Getattr(n, "wrap:name")); } return SWIG_OK; @@ -1586,7 +1586,7 @@ public: Delete(module_interfaces); module_interfaces = Copy(strvalue); } else { - Printf(stderr, "%s : Line %d. Unrecognized pragma.\n", input_file, line_number); + Swig_error(input_file, line_number, "Unrecognized pragma.\n"); } Delete(strvalue); } diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index 924d11941..d2338bd0f 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -785,7 +785,7 @@ public: Swig_restore(n); native_function_flag = false; } else { - Printf(stderr, "%s : Line %d. No return type for %%native method %s.\n", input_file, line_number, Getattr(n, "wrap:name")); + Swig_error(input_file, line_number, "No return type for %%native method %s.\n", Getattr(n, "wrap:name")); } return SWIG_OK; @@ -1630,37 +1630,37 @@ public: Delete(module_interfaces); module_interfaces = Copy(strvalue); } else if (Strcmp(code, "moduleimport") == 0) { - Printf(stderr, "%s : Line %d. Ignored: Deprecated pragma. Please use the moduleimports pragma.\n", input_file, line_number); + Swig_error(input_file, line_number, "Deprecated pragma. Please use the moduleimports pragma.\n"); } else if (Strcmp(code, "moduleinterface") == 0) { - Printf(stderr, "%s : Line %d. Ignored: Deprecated pragma. Please use the moduleinterfaces pragma.\n", input_file, line_number); + Swig_error(input_file, line_number, "Deprecated pragma. Please use the moduleinterfaces pragma.\n"); } else if (Strcmp(code, "modulemethodmodifiers") == 0) { - Printf(stderr, "%s : Line %d. Ignored: Deprecated pragma. Please use %%javamethodmodifiers.\n", input_file, line_number); + Swig_error(input_file, line_number, "Deprecated pragma. Please use %%javamethodmodifiers.\n"); } else if (Strcmp(code, "allshadowimport") == 0) { - Printf(stderr, "%s : Line %d. Ignored: Deprecated pragma. Please use %%typemap(javaimports).\n", input_file, line_number); + Swig_error(input_file, line_number, "Deprecated pragma. Please use %%typemap(javaimports).\n"); } else if (Strcmp(code, "allshadowcode") == 0) { - Printf(stderr, "%s : Line %d. Ignored: Deprecated pragma. Please use %%typemap(javacode).\n", input_file, line_number); + Swig_error(input_file, line_number, "Deprecated pragma. Please use %%typemap(javacode).\n"); } else if (Strcmp(code, "allshadowbase") == 0) { - Printf(stderr, "%s : Line %d. Ignored: Deprecated pragma. Please use %%typemap(javabase).\n", input_file, line_number); + Swig_error(input_file, line_number, "Deprecated pragma. Please use %%typemap(javabase).\n"); } else if (Strcmp(code, "allshadowinterface") == 0) { - Printf(stderr, "%s : Line %d. Ignored: Deprecated pragma. Please use %%typemap(javainterfaces).\n", input_file, line_number); + Swig_error(input_file, line_number, "Deprecated pragma. Please use %%typemap(javainterfaces).\n"); } else if (Strcmp(code, "allshadowclassmodifiers") == 0) { - Printf(stderr, "%s : Line %d. Ignored: Deprecated pragma. Please use %%typemap(javaclassmodifiers).\n", input_file, line_number); + Swig_error(input_file, line_number, "Deprecated pragma. Please use %%typemap(javaclassmodifiers).\n"); } else if (proxy_flag) { if (Strcmp(code, "shadowcode") == 0) { - Printf(stderr, "%s : Line %d. Ignored: Deprecated pragma. Please use %%typemap(javacode).\n", input_file, line_number); + Swig_error(input_file, line_number, "Deprecated pragma. Please use %%typemap(javacode).\n"); } else if (Strcmp(code, "shadowimport") == 0) { - Printf(stderr, "%s : Line %d. Ignored: Deprecated pragma. Please use %%typemap(javaimports).\n", input_file, line_number); + Swig_error(input_file, line_number, "Deprecated pragma. Please use %%typemap(javaimports).\n"); } else if (Strcmp(code, "shadowbase") == 0) { - Printf(stderr, "%s : Line %d. Ignored: Deprecated pragma. Please use %%typemap(javabase).\n", input_file, line_number); + Swig_error(input_file, line_number, "Deprecated pragma. Please use %%typemap(javabase).\n"); } else if (Strcmp(code, "shadowinterface") == 0) { - Printf(stderr, "%s : Line %d. Ignored: Deprecated pragma. Please use %%typemap(javainterfaces).\n", input_file, line_number); + Swig_error(input_file, line_number, "Deprecated pragma. Please use %%typemap(javainterfaces).\n"); } else if (Strcmp(code, "shadowclassmodifiers") == 0) { - Printf(stderr, "%s : Line %d. Ignored: Deprecated pragma. Please use %%typemap(javaclassmodifiers).\n", input_file, line_number); + Swig_error(input_file, line_number, "Deprecated pragma. Please use %%typemap(javaclassmodifiers).\n"); } else { - Printf(stderr, "%s : Line %d. Unrecognized pragma.\n", input_file, line_number); + Swig_error(input_file, line_number, "Unrecognized pragma.\n"); } } else { - Printf(stderr, "%s : Line %d. Unrecognized pragma.\n", input_file, line_number); + Swig_error(input_file, line_number, "Unrecognized pragma.\n"); } Delete(strvalue); } diff --git a/Source/Modules/modula3.cxx b/Source/Modules/modula3.cxx index fb928a898..fc26dff85 100644 --- a/Source/Modules/modula3.cxx +++ b/Source/Modules/modula3.cxx @@ -1196,7 +1196,7 @@ MODULA3(): Swig_restore(n); native_function_flag = false; } else { - Printf(stderr, "%s : Line %d. No return type for %%native method %s.\n", input_file, line_number, Getattr(n, "wrap:name")); + Swig_error(input_file, line_number, "No return type for %%native method %s.\n", Getattr(n, "wrap:name")); } return SWIG_OK; diff --git a/Source/Modules/perl5.cxx b/Source/Modules/perl5.cxx index 4be759194..f6ea029fe 100644 --- a/Source/Modules/perl5.cxx +++ b/Source/Modules/perl5.cxx @@ -1631,7 +1631,7 @@ public: if (value) { FILE *f = Swig_include_open(value); if (!f) { - Printf(stderr, "%s : Line %d. Unable to locate file %s\n", input_file, line_number, value); + Swig_error(input_file, line_number, "Unable to locate file %s\n", value); } else { char buffer[4096]; while (fgets(buffer, 4095, f)) { @@ -1641,7 +1641,7 @@ public: fclose(f); } } else { - Printf(stderr, "%s : Line %d. Unrecognized pragma.\n", input_file, line_number); + Swig_error(input_file, line_number, "Unrecognized pragma.\n"); } } } diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index c44e7c6ce..09eb21dcd 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -1788,7 +1788,7 @@ done: Replaceall(tm, "$target", name); Printf(s_vinit, "%s\n", tm); } else { - Printf(stderr, "%s: Line %d, Unable to link with type %s\n", input_file, line_number, SwigType_str(t, 0)); + Swig_error(input_file, line_number, "Unable to link with type %s\n", SwigType_str(t, 0)); } /* Now generate PHP -> C sync blocks */ @@ -1798,7 +1798,7 @@ done: Replaceall(tm, "$symname", iname); Printf(f_c->code, "%s\n", tm); } else { - Printf(stderr,"%s: Line %d, Unable to link with type %s\n", input_file, line_number, SwigType_str(t, 0)); + Swig_error(input_file, line_number, "Unable to link with type %s\n", SwigType_str(t, 0)); } */ /* Now generate C -> PHP sync blocks */ @@ -1810,7 +1810,7 @@ done: Replaceall(tm, "$symname", iname); Printf(f_php->code, "%s\n", tm); } else { - Printf(stderr,"%s: Line %d, Unable to link with type %s\n", input_file, line_number, SwigType_str(t, 0)); + Swig_error(input_file, line_number, "Unable to link with type %s\n", SwigType_str(t, 0)); } } */ From c5b25bde5a5b12a51487b0b6c1451c11b8291456 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 13 Mar 2010 23:24:15 +0000 Subject: [PATCH 0795/1680] Fix incorrect current directory handling from last commit git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11946 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/main.cxx | 58 ++++++++++++++++++++++------------------- 1 file changed, 31 insertions(+), 27 deletions(-) diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx index 2ad1665f6..f0e941f22 100644 --- a/Source/Modules/main.cxx +++ b/Source/Modules/main.cxx @@ -197,11 +197,11 @@ enum { STAGE1=1, STAGE2=2, STAGE3=4, STAGE4=8, STAGEOVERFLOW=16 }; static List *libfiles = 0; static List *all_output_files = 0; -// ----------------------------------------------------------------------------- -// check_suffix() -// -// Checks the suffix of a file to see if we should emit extern declarations. -// ----------------------------------------------------------------------------- +/* ----------------------------------------------------------------------------- + * check_suffix() + * + * Checks the suffix of a file to see if we should emit extern declarations. + * ----------------------------------------------------------------------------- */ static int check_suffix(String *filename) { const char *name = Char(filename); @@ -216,10 +216,11 @@ static int check_suffix(String *filename) { return 0; } -// ----------------------------------------------------------------------------- -// install_opts(int argc, char *argv[]) -// Install all command line options as preprocessor symbols -// ----------------------------------------------------------------------------- +/* ----------------------------------------------------------------------------- + * install_opts() + * + * Install all command line options as preprocessor symbols + * ----------------------------------------------------------------------------- */ static void install_opts(int argc, char *argv[]) { int i; @@ -255,11 +256,12 @@ static void install_opts(int argc, char *argv[]) { } } -// ----------------------------------------------------------------------------- -// decode_numbers_list(String *numlist) -// Decode comma separated list into a binary number of the inputs or'd together -// eg list="1,4" will return (2^0 || 2^3) = 0x1001 -// ----------------------------------------------------------------------------- +/* ----------------------------------------------------------------------------- + * decode_numbers_list() + * + * Decode comma separated list into a binary number of the inputs or'd together + * eg list="1,4" will return (2^0 || 2^3) = 0x1001 + * ----------------------------------------------------------------------------- */ static unsigned int decode_numbers_list(String *numlist) { unsigned int decoded_number = 0; @@ -279,10 +281,10 @@ static unsigned int decode_numbers_list(String *numlist) { return decoded_number; } -// ----------------------------------------------------------------------------- -// Sets the output directory for language specific (proxy) files if not set and -// corrects the directory name and adds trailing file separator if necessary. -// ----------------------------------------------------------------------------- +/* ----------------------------------------------------------------------------- + * Sets the output directory for language specific (proxy) files if not set and + * corrects the directory name and adds trailing file separator if necessary. + * ----------------------------------------------------------------------------- */ static void configure_outdir(const String *c_wrapper_file_dir) { @@ -292,10 +294,12 @@ static void configure_outdir(const String *c_wrapper_file_dir) { Swig_filename_correct(outdir); - // Add file delimiter if not present in output directory name - const char *outd = Char(outdir); - if (strcmp(outd + strlen(outd) - strlen(SWIG_FILE_DELIMITER), SWIG_FILE_DELIMITER) != 0) - Printv(outdir, SWIG_FILE_DELIMITER, NIL); + // Add trailing file delimiter if not present in output directory name + if (Len(outdir) > 0) { + const char *outd = Char(outdir); + if (strcmp(outd + strlen(outd) - strlen(SWIG_FILE_DELIMITER), SWIG_FILE_DELIMITER) != 0) + Printv(outdir, SWIG_FILE_DELIMITER, NIL); + } } /* This function sets the name of the configuration file */ @@ -1291,11 +1295,11 @@ int SWIG_main(int argc, char *argv[], Language *l) { return Swig_error_count(); } -// -------------------------------------------------------------------------- -// SWIG_exit(int exit_code) -// -// Cleanup and either freeze or exit -// -------------------------------------------------------------------------- +/* ----------------------------------------------------------------------------- + * SWIG_exit() + * + * Cleanup and either freeze or exit + * ----------------------------------------------------------------------------- */ void SWIG_exit(int exit_code) { while (freeze) { From cd317b3f1c1f668b318b4cced2497370cf823889 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 13 Mar 2010 23:39:46 +0000 Subject: [PATCH 0796/1680] Java/C# constants fix after last nspace commit git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11947 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/csharp.cxx | 2 +- Source/Modules/java.cxx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index 38679dfba..8abc3307e 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -1477,7 +1477,7 @@ public: Printf(constants_code, "(%s)%s.%s();\n", return_type, full_imclass_name, Swig_name_get(getNSpace(), symname)); } else { // This handles function pointers using the %constant directive - Printf(constants_code, "new %s(%s.%s(), false);\n", return_type, full_imclass_name, Swig_name_get(getNSpace(), symname)); + Printf(constants_code, "new %s(%s.%s(), false);\n", return_type, full_imclass_name ? full_imclass_name : imclass_name, Swig_name_get(getNSpace(), symname)); } } else { Printf(constants_code, "%s.%s();\n", full_imclass_name ? full_imclass_name : imclass_name, Swig_name_get(getNSpace(), symname)); diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index d2338bd0f..5fecf8208 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -1522,7 +1522,7 @@ public: Printf(constants_code, "%s.swigToEnum(%s.%s());\n", return_type, full_imclass_name, Swig_name_get(getNSpace(), symname)); } else { // This handles function pointers using the %constant directive - Printf(constants_code, "new %s(%s.%s(), false);\n", return_type, full_imclass_name, Swig_name_get(getNSpace(), symname)); + Printf(constants_code, "new %s(%s.%s(), false);\n", return_type, full_imclass_name ? full_imclass_name : imclass_name, Swig_name_get(getNSpace(), symname)); } } else { Printf(constants_code, "%s.%s();\n", full_imclass_name ? full_imclass_name : imclass_name, Swig_name_get(getNSpace(), symname)); From 163d15e2e388fbdba3a3c76da7ad49dccfcead7c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 16 Mar 2010 22:20:41 +0000 Subject: [PATCH 0797/1680] remove debug printout git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11948 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Swig/misc.c | 1 - 1 file changed, 1 deletion(-) diff --git a/Source/Swig/misc.c b/Source/Swig/misc.c index 8c480cc7c..f845d1a03 100644 --- a/Source/Swig/misc.c +++ b/Source/Swig/misc.c @@ -158,7 +158,6 @@ static int is_directory(String *directory) { } else { statres = stat(dir, &st); } - Printf(stdout, "is_directory %d %s\n", (statres == 0 && S_ISDIR(st.st_mode)), dir); return (statres == 0 && S_ISDIR(st.st_mode)); } From 31485a7b3b1ab157c8b14f49d07123aedccb0cdd Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 17 Mar 2010 19:35:45 +0000 Subject: [PATCH 0798/1680] Fix nspace when no -namespace is used (for C#) git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11949 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/csharp.cxx | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index 8abc3307e..f70403326 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -3261,15 +3261,13 @@ public: * ----------------------------------------------------------------------------- */ void addOpenNamespace(const String *nspace, File *file) { - if (namespce) { - if (namespce || nspace) { - Printf(file, "namespace "); - if (namespce) - Printv(file, namespce, nspace ? "." : "", NIL); - if (nspace) - Printv(file, nspace, NIL); - Printf(file, " {\n"); - } + if (namespce || nspace) { + Printf(file, "namespace "); + if (namespce) + Printv(file, namespce, nspace ? "." : "", NIL); + if (nspace) + Printv(file, nspace, NIL); + Printf(file, " {\n"); } } @@ -3278,9 +3276,8 @@ public: * ----------------------------------------------------------------------------- */ void addCloseNamespace(const String *nspace, File *file) { - if (namespce) - if (namespce || nspace) - Printf(file, "\n}\n"); + if (namespce || nspace) + Printf(file, "\n}\n"); } /* ----------------------------------------------------------------------------- From ff0426355b613cb4b734f7dbfd12244a8488c0db Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 31 Mar 2010 06:15:49 +0000 Subject: [PATCH 0799/1680] Fix typo in rename message git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11955 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/ocaml/ocamlkw.swg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/ocaml/ocamlkw.swg b/Lib/ocaml/ocamlkw.swg index 9b9096e2b..92d822219 100644 --- a/Lib/ocaml/ocamlkw.swg +++ b/Lib/ocaml/ocamlkw.swg @@ -2,7 +2,7 @@ #define OCAML_OCAMLKW_SWG_ /* Warnings for Ocaml keywords */ -#define OCAMLKW(x) %namewarn("314: '" #x "' is a ocaml keyword and it will properly renamed") #x +#define OCAMLKW(x) %namewarn("314: '" #x "' is an ocaml keyword and it will be appropriately renamed") #x /* from From 15dfd9f0e7470d8a3f23f9155ce0b9eb8ac97859 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 31 Mar 2010 19:14:34 +0000 Subject: [PATCH 0800/1680] minor formatting change git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11956 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/python/pydocs.swg | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Lib/python/pydocs.swg b/Lib/python/pydocs.swg index 0091a30b9..862339da7 100644 --- a/Lib/python/pydocs.swg +++ b/Lib/python/pydocs.swg @@ -3,13 +3,13 @@ #ifdef SWIG_DOC_DOXYGEN_STYLE %typemap(doc) SWIGTYPE "@param $1_name $1_type value"; -%typemap(doc) SWIGTYPE* "@param $1_name $1_type value"; -%typemap(doc) const SWIGTYPE& "@param $1_name $1_type value"; +%typemap(doc) SWIGTYPE * "@param $1_name $1_type value"; +%typemap(doc) const SWIGTYPE & "@param $1_name $1_type value"; %typemap(doc) enum SWIGTYPE "@param $1_name enum $1_type value"; #else %typemap(doc) SWIGTYPE "$1_name: $1_type value"; -%typemap(doc) SWIGTYPE* "$1_name: $1_type value"; -%typemap(doc) const SWIGTYPE& "$1_name: $1_type value"; +%typemap(doc) SWIGTYPE * "$1_name: $1_type value"; +%typemap(doc) const SWIGTYPE & "$1_name: $1_type value"; %typemap(doc) enum SWIGTYPE "$1_name: enum $1_type value"; %typemap(doc) SWIGTYPE *INOUT "$1_name: $1_type input/ouput value"; From b1c594078628ca7b5e57aa63ea117e1cd281ec80 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 1 Apr 2010 18:12:48 +0000 Subject: [PATCH 0801/1680] test case fix for languages that don't support the nspace feature git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11957 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/nspace_extend.i | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Examples/test-suite/nspace_extend.i b/Examples/test-suite/nspace_extend.i index 7f7ba01f8..88f40bc69 100644 --- a/Examples/test-suite/nspace_extend.i +++ b/Examples/test-suite/nspace_extend.i @@ -31,8 +31,6 @@ namespace Outer { } %} -#endif - %extend Outer::Inner2::Color { Color() { return new Outer::Inner2::Color(); } ~Color() { delete $self; } @@ -48,3 +46,5 @@ namespace Outer { const Outer::Inner2::Color& col2c) {} } +#endif + From bdb136d611286df89ba94b04170259d75c51e9f8 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 1 Apr 2010 18:26:37 +0000 Subject: [PATCH 0802/1680] Change typemap matching rules for the default type (SWIGTYPE) to follow template partial specialization type deduction. Fixes some containers of const pointers. SWIGTYPE*& typemps removed and replaced with SWIGTYPE *const&. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11958 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 70 ++++++++ Examples/test-suite/constant_pointers.i | 4 +- Examples/test-suite/global_namespace.i | 8 +- Examples/test-suite/java_pgcpp.i | 14 +- Examples/test-suite/li_boost_intrusive_ptr.i | 4 +- Examples/test-suite/li_boost_shared_ptr.i | 4 +- Examples/test-suite/pointer_reference.i | 4 +- Lib/allegrocl/allegrocl.swg | 6 + Lib/cffi/cffi.swg | 5 + Lib/chicken/chicken.swg | 10 ++ Lib/csharp/boost_shared_ptr.i | 8 +- Lib/csharp/csharp.swg | 26 +-- Lib/guile/std_map.i | 2 +- Lib/guile/std_vector.i | 2 +- Lib/guile/typemaps.i | 6 + Lib/java/boost_intrusive_ptr.i | 16 +- Lib/java/boost_shared_ptr.i | 8 +- Lib/java/java.swg | 26 +-- Lib/lua/lua.swg | 2 +- Lib/lua/luatypemaps.swg | 11 +- Lib/modula3/modula3.swg | 7 + Lib/mzscheme/typemaps.i | 7 + Lib/ocaml/std_map.i | 2 +- Lib/ocaml/typemaps.i | 8 + Lib/octave/boost_shared_ptr.i | 16 +- Lib/perl5/perltypemaps.swg | 5 +- Lib/perl5/std_map.i | 2 +- Lib/php/php.swg | 21 ++- Lib/php/std_map.i | 2 +- Lib/pike/pike.swg | 6 + Lib/python/boost_shared_ptr.i | 16 +- Lib/python/pytypemaps.swg | 2 +- Lib/r/rtype.swg | 14 +- Lib/tcl/std_map.i | 2 +- Lib/tcl/tcltypemaps.swg | 3 +- Lib/typemaps/swigtype.swg | 22 ++- Source/Modules/lang.cxx | 34 ++-- Source/Swig/stype.c | 180 +++++++++++++++++++ Source/Swig/swig.h | 2 + Source/Swig/typemap.c | 6 +- Source/Swig/typeobj.c | 6 + 41 files changed, 477 insertions(+), 122 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 883963f27..0be45290b 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,76 @@ Version 2.0.0 (in progress) ============================ +2010-04-01: wsfulton + Numerous subtle typemap matching rule fixes when using the default type. The typemap + matching rules are to take a type and find the best default typemap (SWIGTYPE, SWIGTYPE* etc), + then look for the next best match by reducing the chosen default type. The type reduction + now follows C++ template partial specialization matching rules. + + Below are the set of changes made showing the default type reduction + along with the old reduced type and the new version of the reduced type: + + SWIGTYPE const &[ANY] + new: SWIGTYPE const &[] + old: SWIGTYPE (&)[ANY] + + SWIGTYPE *const [ANY] + new: SWIGTYPE const [ANY] + old: SWIGTYPE *[ANY] + + SWIGTYPE const *const [ANY] + new: SWIGTYPE *const [ANY] + old: SWIGTYPE const *[ANY] + + SWIGTYPE const *const & + new: SWIGTYPE *const & + old: SWIGTYPE const *& + + SWIGTYPE *const * + new: SWIGTYPE const * + old: SWIGTYPE ** + + SWIGTYPE *const & + new: SWIGTYPE const & + old: SWIGTYPE *& + + Additionally, a const SWIGTYPE lookup is used now for any constant type. Some examples, where + T is some reduced type, eg int, struct Foo: + + T const + new: SWIGTYPE const + old: SWIGTYPE + + T *const + new: SWIGTYPE *const + old: SWIGTYPE * + + T const[] + new: SWIGTYPE const[] + old: SWIGTYPE[] + + enum T const + new: enum SWIGTYPE const + old: enum SWIGTYPE + + T (*const )[] + new: SWIGTYPE (*const )[] + old: SWIGTYPE (*)[] + + Reminder: the typemap matching rules can now be seen for any types being wrapped by using + either the -debug-tmsearch or -debug-tmused options. + + In practice this leads to some subtle matching rule changes and the majority of users + won't notice any changes, except in the prime area of motivation for this change: Improve + STL containers of const pointers and passing const pointers by reference. This is fixed + because many of the STL containers use a type 'T const&' as parameters and when T is + a const pointer, for example, 'K const*', then the full type is 'K const*const&'. This + means that the 'SWIGTYPE *const&' typemaps now match when T is either a non-const or + const pointer. Furthermore, some target languages incorrectly had 'SWIGTYPE *&' typemaps + when these should have been 'SWIGTYPE *const&'. These have been corrected (Java, C#, Lua, PHP). + + *** POTENTIAL INCOMPATIBILITY *** + 2010-03-13: wsfulton [Java] Some very old deprecated pragma warnings are now errors. diff --git a/Examples/test-suite/constant_pointers.i b/Examples/test-suite/constant_pointers.i index c2344fb6a..277d3cc75 100644 --- a/Examples/test-suite/constant_pointers.i +++ b/Examples/test-suite/constant_pointers.i @@ -70,6 +70,8 @@ public: void ret6(int*& a) {} int*& ret7() {return GlobalIntPtr;} + void ret8(int*const& a) {} + int*const& ret9() {return GlobalIntPtr;} ReturnValuesTest() : int3(NULL) {} private: ReturnValuesTest& operator=(const ReturnValuesTest&); @@ -112,7 +114,7 @@ int* const globalRet2() {return &GlobalInt;} return b; } - B const*& cbar(B const*& b) { + B *const& cbar(B *const& b) { return b; } } diff --git a/Examples/test-suite/global_namespace.i b/Examples/test-suite/global_namespace.i index 31dbb9e59..7b575614f 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*const& pr) {} + static void methodB( Klass1 v, const Klass2 cv, const Klass3 *cp, Klass4 *p, const Klass5 &cr, Klass6 &r, Klass7*const& 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*const& pr) {} + static void methodB( Space::XYZ1 v, const Space::XYZ2 cv, const Space::XYZ3 *cp, Space::XYZ4 *p, const Space::XYZ5 &cr, Space::XYZ6 &r, Space::XYZ7*const& pr) {} }; %} diff --git a/Examples/test-suite/java_pgcpp.i b/Examples/test-suite/java_pgcpp.i index 6a50ffe72..6bfef9316 100644 --- a/Examples/test-suite/java_pgcpp.i +++ b/Examples/test-suite/java_pgcpp.i @@ -16,21 +16,21 @@ %typemap(jstype) Space::Classic ** " Classic " %typemap(javain) Space::Classic ** "Classic.getCPtr($javainput)" -// Default typemaps for pass by value, ref, pointer and pointer reference should use pgcpp +// Default typemaps for pass by value, ref, pointer and pointer const reference should use pgcpp %inline %{ namespace Space { struct Classic { Classic() {} - Classic(Classic c1, Classic& c2, Classic* c3, Classic*& c4, Classic** c5) {} - Classic(const Classic c1, const Classic& c2, const Classic* c3, const Classic*& c4, const Classic** c5, bool b) {} + Classic(Classic c1, Classic& c2, Classic* c3, Classic*const& c4, Classic** c5) {} + Classic(const Classic c1, const Classic& c2, const Classic* c3, const Classic*const& c4, const Classic** c5, bool b) {} - void method(Classic c1, Classic& c2, Classic* c3, Classic*& c4, Classic** c5) {} - void methodconst(const Classic c1, const Classic& c2, const Classic* c3, const Classic*& c4, const Classic** c5) {} + void method(Classic c1, Classic& c2, Classic* c3, Classic*const& c4, Classic** c5) {} + void methodconst(const Classic c1, const Classic& c2, const Classic* c3, const Classic*const& c4, const Classic** c5) {} }; - void function(Classic c1, Classic& c2, Classic* c3, Classic*& c4, Classic** c5) {} - void functionconst(const Classic c1, const Classic& c2, const Classic* c3, const Classic*& c4, const Classic** c5) {} + void function(Classic c1, Classic& c2, Classic* c3, Classic*const& c4, Classic** c5) {} + void functionconst(const Classic c1, const Classic& c2, const Classic* c3, const Classic*const& c4, const Classic** c5) {} } %} diff --git a/Examples/test-suite/li_boost_intrusive_ptr.i b/Examples/test-suite/li_boost_intrusive_ptr.i index 7c37e6843..47b64682a 100644 --- a/Examples/test-suite/li_boost_intrusive_ptr.i +++ b/Examples/test-suite/li_boost_intrusive_ptr.i @@ -295,7 +295,7 @@ Klass& reftest(Klass& k) { k.append(" reftest"); return k; } -Klass*& pointerreftest(Klass*& k) { +Klass *const& pointerreftest(Klass *const& k) { k->append(" pointerreftest"); return k; } @@ -334,7 +334,7 @@ std::string overload_rawbyptr(int i) { return "int"; } std::string overload_rawbyptr(Klass *k) { return "rawbyptr"; } std::string overload_rawbyptrref(int i) { return "int"; } -std::string overload_rawbyptrref(Klass *&k) { return "rawbyptrref"; } +std::string overload_rawbyptrref(Klass *const&k) { return "rawbyptrref"; } diff --git a/Examples/test-suite/li_boost_shared_ptr.i b/Examples/test-suite/li_boost_shared_ptr.i index f992a3c08..7a9468e4f 100644 --- a/Examples/test-suite/li_boost_shared_ptr.i +++ b/Examples/test-suite/li_boost_shared_ptr.i @@ -222,7 +222,7 @@ Klass& reftest(Klass& k) { k.append(" reftest"); return k; } -Klass*& pointerreftest(Klass*& k) { +Klass *const& pointerreftest(Klass *const& k) { k->append(" pointerreftest"); return k; } @@ -275,7 +275,7 @@ std::string overload_rawbyptr(int i) { return "int"; } std::string overload_rawbyptr(Klass *k) { return "rawbyptr"; } std::string overload_rawbyptrref(int i) { return "int"; } -std::string overload_rawbyptrref(Klass *&k) { return "rawbyptrref"; } +std::string overload_rawbyptrref(Klass *const&k) { return "rawbyptrref"; } diff --git a/Examples/test-suite/pointer_reference.i b/Examples/test-suite/pointer_reference.i index b7c605429..c57a32374 100644 --- a/Examples/test-suite/pointer_reference.i +++ b/Examples/test-suite/pointer_reference.i @@ -29,10 +29,10 @@ struct Struct { static Struct *pInstance; }; -void set(Struct *& s) { +void set(Struct *const& s) { Struct::instance = *s; } -Struct *& get() { +Struct *const& get() { return Struct::pInstance; } %} diff --git a/Lib/allegrocl/allegrocl.swg b/Lib/allegrocl/allegrocl.swg index 266303113..cc23a1f90 100644 --- a/Lib/allegrocl/allegrocl.swg +++ b/Lib/allegrocl/allegrocl.swg @@ -219,6 +219,12 @@ $body)" %typemap(lispclass) wchar_t* "cl:string"; ////////////////////////////////////////////////////////////// +/* Array reference typemaps */ +%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) } + +/* const pointers */ +%apply SWIGTYPE * { SWIGTYPE *const } + /* name conversion for overloaded operators. */ #ifdef __cplusplus %rename(__add__) *::operator+; diff --git a/Lib/cffi/cffi.swg b/Lib/cffi/cffi.swg index c832e00d2..6ac82f45e 100644 --- a/Lib/cffi/cffi.swg +++ b/Lib/cffi/cffi.swg @@ -130,6 +130,11 @@ %typemap(lispclass) double "cl:number"; %typemap(lispclass) char * "cl:string"; +/* Array reference typemaps */ +%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) } + +/* const pointers */ +%apply SWIGTYPE * { SWIGTYPE *const } %{ diff --git a/Lib/chicken/chicken.swg b/Lib/chicken/chicken.swg index 68f022570..112780499 100644 --- a/Lib/chicken/chicken.swg +++ b/Lib/chicken/chicken.swg @@ -679,6 +679,16 @@ $result = C_SCHEME_UNDEFINED; %apply unsigned long { size_t }; +/* ------------------------------------------------------------ + * Various + * ------------------------------------------------------------ */ + +/* Array reference typemaps */ +%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) } + +/* const pointers */ +%apply SWIGTYPE * { SWIGTYPE *const } + /* ------------------------------------------------------------ * Overloaded operator support * ------------------------------------------------------------ */ diff --git a/Lib/csharp/boost_shared_ptr.i b/Lib/csharp/boost_shared_ptr.i index 52ac510ce..86a62c33c 100644 --- a/Lib/csharp/boost_shared_ptr.i +++ b/Lib/csharp/boost_shared_ptr.i @@ -44,10 +44,10 @@ %{ $result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner); %} // plain pointer by reference -%typemap(in) CONST TYPE *& ($*1_ltype temp = 0) -%{ temp = (((SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)$input) ? ((SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)$input)->get() : 0); +%typemap(in) TYPE *CONST& ($*1_ltype temp = 0) +%{ temp = (TYPE *)(((SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)$input) ? ((SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)$input)->get() : 0); $1 = &temp; %} -%typemap(out, fragment="SWIG_null_deleter") CONST TYPE *& +%typemap(out, fragment="SWIG_null_deleter") TYPE *CONST& %{ $result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_$owner); %} // shared_ptr by value @@ -138,7 +138,7 @@ PROXYCLASS ret = (cPtr == IntPtr.Zero) ? null : new PROXYCLASS(cPtr, true);$excode return ret; } -%typemap(csout, excode=SWIGEXCODE) CONST TYPE *& { +%typemap(csout, excode=SWIGEXCODE) TYPE *CONST& { IntPtr cPtr = $imcall; PROXYCLASS ret = (cPtr == IntPtr.Zero) ? null : new PROXYCLASS(cPtr, true);$excode return ret; diff --git a/Lib/csharp/csharp.swg b/Lib/csharp/csharp.swg index 1f58db48d..57998b9db 100644 --- a/Lib/csharp/csharp.swg +++ b/Lib/csharp/csharp.swg @@ -522,6 +522,7 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) { SWIGTYPE, SWIGTYPE *, SWIGTYPE &, + SWIGTYPE *const&, SWIGTYPE [], SWIGTYPE (CLASS::*) "" @@ -782,24 +783,21 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) { } %} /* Pointer reference typemaps */ -%typemap(ctype) SWIGTYPE *& "void *" -%typemap(imtype, out="IntPtr") SWIGTYPE *& "HandleRef" -%typemap(cstype) SWIGTYPE *& "$*csclassname" -%typemap(csin) SWIGTYPE *& "$*csclassname.getCPtr($csinput)" -%typemap(csout, excode=SWIGEXCODE) SWIGTYPE *& { +%typemap(ctype) SWIGTYPE *const& "void *" +%typemap(imtype, out="IntPtr") SWIGTYPE *const& "HandleRef" +%typemap(cstype) SWIGTYPE *const& "$*csclassname" +%typemap(csin) SWIGTYPE *const& "$*csclassname.getCPtr($csinput)" +%typemap(csout, excode=SWIGEXCODE) SWIGTYPE *const& { IntPtr cPtr = $imcall; $*csclassname ret = (cPtr == IntPtr.Zero) ? null : new $*csclassname(cPtr, $owner);$excode return ret; } -%typemap(in) SWIGTYPE *& ($*1_ltype temp = 0) +%typemap(in) SWIGTYPE *const& ($*1_ltype temp = 0) %{ temp = ($*1_ltype)$input; - $1 = &temp; %} -%typemap(out) SWIGTYPE *& + $1 = ($1_ltype)&temp; %} +%typemap(out) SWIGTYPE *const& %{ $result = (void *)*$1; %} -/* Array reference typemaps */ -%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) } - /* Marshal C/C++ pointer to IntPtr */ %typemap(ctype) void *VOID_INT_PTR "void *" %typemap(imtype) void *VOID_INT_PTR "IntPtr" @@ -953,6 +951,12 @@ using System.Runtime.InteropServices; %apply unsigned long { size_t }; %apply const unsigned long & { const size_t & }; +/* Array reference typemaps */ +%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) } + +/* const pointers */ +%apply SWIGTYPE * { SWIGTYPE *const } + /* csharp keywords */ %include diff --git a/Lib/guile/std_map.i b/Lib/guile/std_map.i index 19c863096..600075ebe 100644 --- a/Lib/guile/std_map.i +++ b/Lib/guile/std_map.i @@ -224,7 +224,7 @@ namespace std { bool empty() const; void clear(); %extend { - T& __getitem__(const K& key) throw (std::out_of_range) { + const T& __getitem__(const K& key) throw (std::out_of_range) { std::map::iterator i = self->find(key); if (i != self->end()) return i->second; diff --git a/Lib/guile/std_vector.i b/Lib/guile/std_vector.i index 6801daee8..6a5e8ae36 100644 --- a/Lib/guile/std_vector.i +++ b/Lib/guile/std_vector.i @@ -208,7 +208,7 @@ namespace std { self->pop_back(); return x; } - T& ref(int i) throw (std::out_of_range) { + const T& ref(int i) throw (std::out_of_range) { int size = int(self->size()); if (i>=0 && i *smartarg = 0) %{ +%typemap(in) TYPE *CONST& ($*1_ltype temp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{ // plain pointer by reference - temp = ((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0); + temp = ($*1_ltype)((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0); $1 = &temp; %} -%typemap(out, fragment="SWIG_intrusive_deleter,SWIG_null_deleter") CONST TYPE *& %{ +%typemap(out, fragment="SWIG_intrusive_deleter,SWIG_null_deleter") TYPE *CONST& %{ // plain pointer by reference(out) #if ($owner) if (*$1) { @@ -246,7 +246,7 @@ long cPtr = $jnicall; return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true); } -%typemap(javaout) CONST TYPE *& { +%typemap(javaout) TYPE *CONST& { long cPtr = $jnicall; return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true); } @@ -353,10 +353,10 @@ %{ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner); %} // plain pointer by reference -%typemap(in) CONST TYPE *& ($*1_ltype temp = 0) -%{ temp = ((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0); +%typemap(in) TYPE *CONST& ($*1_ltype temp = 0) +%{ temp = ($*1_ltype)((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0); $1 = &temp; %} -%typemap(out, fragment="SWIG_null_deleter") CONST TYPE *& +%typemap(out, fragment="SWIG_null_deleter") TYPE *CONST& %{ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_$owner); %} %typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast ($&1_type smartarg) %{ @@ -396,7 +396,7 @@ long cPtr = $jnicall; return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true); } -%typemap(javaout) CONST TYPE *& { +%typemap(javaout) TYPE *CONST& { long cPtr = $jnicall; return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true); } diff --git a/Lib/java/boost_shared_ptr.i b/Lib/java/boost_shared_ptr.i index 38262f20c..1c74a2453 100644 --- a/Lib/java/boost_shared_ptr.i +++ b/Lib/java/boost_shared_ptr.i @@ -44,10 +44,10 @@ %{ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner); %} // plain pointer by reference -%typemap(in) CONST TYPE *& ($*1_ltype temp = 0) -%{ temp = ((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0); +%typemap(in) TYPE *CONST& ($*1_ltype temp = 0) +%{ temp = (TYPE *)((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0); $1 = &temp; %} -%typemap(out, fragment="SWIG_null_deleter") CONST TYPE *& +%typemap(out, fragment="SWIG_null_deleter") TYPE *CONST& %{ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_$owner); %} // shared_ptr by value @@ -132,7 +132,7 @@ long cPtr = $jnicall; return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true); } -%typemap(javaout) CONST TYPE *& { +%typemap(javaout) TYPE *CONST& { long cPtr = $jnicall; return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true); } diff --git a/Lib/java/java.swg b/Lib/java/java.swg index 2dfbe59f2..0fadf1604 100644 --- a/Lib/java/java.swg +++ b/Lib/java/java.swg @@ -897,6 +897,7 @@ SWIGTYPE, SWIGTYPE *, SWIGTYPE &, + SWIGTYPE *const&, SWIGTYPE [], SWIGTYPE (CLASS::*) "" @@ -1025,23 +1026,20 @@ } /* Pointer reference typemaps */ -%typemap(jni) SWIGTYPE *& "jlong" -%typemap(jtype) SWIGTYPE *& "long" -%typemap(jstype) SWIGTYPE *& "$*javaclassname" -%typemap(javain) SWIGTYPE *& "$*javaclassname.getCPtr($javainput)" -%typemap(javaout) SWIGTYPE *& { +%typemap(jni) SWIGTYPE *const& "jlong" +%typemap(jtype) SWIGTYPE *const& "long" +%typemap(jstype) SWIGTYPE *const& "$*javaclassname" +%typemap(javain) SWIGTYPE *const& "$*javaclassname.getCPtr($javainput)" +%typemap(javaout) SWIGTYPE *const& { long cPtr = $jnicall; return (cPtr == 0) ? null : new $*javaclassname(cPtr, $owner); } -%typemap(in) SWIGTYPE *& ($*1_ltype temp = 0) +%typemap(in) SWIGTYPE *const& ($*1_ltype temp = 0) %{ temp = *($1_ltype)&$input; - $1 = &temp; %} -%typemap(out) SWIGTYPE *& + $1 = ($1_ltype)&temp; %} +%typemap(out) SWIGTYPE *const& %{ *($1_ltype)&$result = *$1; %} -/* Array reference typemaps */ -%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) } - /* Typemaps used for the generation of proxy and type wrapper class code */ %typemap(javabase) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "" %typemap(javaclassmodifiers) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "public class" @@ -1203,6 +1201,12 @@ SWIG_PROXY_CONSTRUCTOR(true, true, SWIGTYPE) %apply unsigned long { size_t }; %apply const unsigned long & { const size_t & }; +/* Array reference typemaps */ +%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) } + +/* const pointers */ +%apply SWIGTYPE * { SWIGTYPE *const } + /* java keywords */ %include diff --git a/Lib/lua/lua.swg b/Lib/lua/lua.swg index c3f5cecc5..5218bf0a8 100644 --- a/Lib/lua/lua.swg +++ b/Lib/lua/lua.swg @@ -40,7 +40,7 @@ %typemap(consttab) long long, unsigned long long { SWIG_LUA_STRING, (char *) "$symname", 0, 0, (void *)"$value", 0} -%typemap(consttab) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] +%typemap(consttab) SWIGTYPE *, SWIGTYPE *const, SWIGTYPE &, SWIGTYPE [] { SWIG_LUA_POINTER, (char *)"$symname", 0, 0, (void *)$value, &$1_descriptor} // member function pointers diff --git a/Lib/lua/luatypemaps.swg b/Lib/lua/luatypemaps.swg index 401541267..58f42eea1 100644 --- a/Lib/lua/luatypemaps.swg +++ b/Lib/lua/luatypemaps.swg @@ -167,11 +167,11 @@ temp=($basetype)lua_tonumber(L,$input); $1=&temp;%} // Also needed for object ptrs by const ref // eg A* const& ref_pointer(A* const& a); // found in mixed_types.i -%typemap(in,checkfn="lua_isuserdata") SWIGTYPE *&($*ltype temp) +%typemap(in,checkfn="lua_isuserdata") SWIGTYPE *const&($*ltype temp) %{temp=($*ltype)SWIG_MustGetPtr(L,$input,$*descriptor,0,$argnum,"$symname"); -$1=&temp;%} +$1=($1_ltype)&temp;%} -%typemap(out) SWIGTYPE *& +%typemap(out) SWIGTYPE *const& %{SWIG_NewPointerObj(L,*$1,$*descriptor,$owner); SWIG_arg++; %} @@ -335,7 +335,7 @@ parmeters match which function // Also needed for object ptrs by const ref // eg const A* ref_pointer(A* const& a); // found in mixed_types.i -%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE* const & +%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *const& { void *ptr; if (lua_isuserdata(L,$input)==0 || SWIG_ConvertPtr(L,$input, (void **) &ptr, $*descriptor, 0)) { @@ -352,6 +352,9 @@ parmeters match which function // Array reference typemaps %apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) } +/* const pointers */ +%apply SWIGTYPE * { SWIGTYPE *const } + // size_t (which is just a unsigned long) %apply unsigned long { size_t }; %apply const unsigned long & { const size_t & }; diff --git a/Lib/modula3/modula3.swg b/Lib/modula3/modula3.swg index 599a12e5a..3affdd0de 100644 --- a/Lib/modula3/modula3.swg +++ b/Lib/modula3/modula3.swg @@ -745,3 +745,10 @@ FROM BlaBla IMPORT Bla; /* Some ANSI C typemaps */ %apply unsigned long { size_t }; + +/* Array reference typemaps */ +%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) } + +/* const pointers */ +%apply SWIGTYPE * { SWIGTYPE *const } + diff --git a/Lib/mzscheme/typemaps.i b/Lib/mzscheme/typemaps.i index b9f22440c..f12513df8 100644 --- a/Lib/mzscheme/typemaps.i +++ b/Lib/mzscheme/typemaps.i @@ -349,3 +349,10 @@ REF_MAP(double, SCHEME_REALP, scheme_real_to_double, } +/* Array reference typemaps */ +%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) } + +/* const pointers */ +%apply SWIGTYPE * { SWIGTYPE *const } + + diff --git a/Lib/ocaml/std_map.i b/Lib/ocaml/std_map.i index f202e74ed..d7bf1e0f7 100644 --- a/Lib/ocaml/std_map.i +++ b/Lib/ocaml/std_map.i @@ -29,7 +29,7 @@ namespace std { bool empty() const; void clear(); %extend { - T& get(const K& key) throw (std::out_of_range) { + const T& get(const K& key) throw (std::out_of_range) { std::map::iterator i = self->find(key); if (i != self->end()) return i->second; diff --git a/Lib/ocaml/typemaps.i b/Lib/ocaml/typemaps.i index 39544de94..e5458a3e2 100644 --- a/Lib/ocaml/typemaps.i +++ b/Lib/ocaml/typemaps.i @@ -314,3 +314,11 @@ SIMPLE_MAP(unsigned long long,caml_val_ulong,caml_long_val); %swig_enum_out(out) %swig_enum_out(varout) %swig_enum_out(directorin) + + +/* Array reference typemaps */ +%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) } + +/* const pointers */ +%apply SWIGTYPE * { SWIGTYPE *const } + diff --git a/Lib/octave/boost_shared_ptr.i b/Lib/octave/boost_shared_ptr.i index 2a3c1532f..d702108a6 100644 --- a/Lib/octave/boost_shared_ptr.i +++ b/Lib/octave/boost_shared_ptr.i @@ -143,7 +143,7 @@ // plain pointer by reference // Note: $disown not implemented as it will lead to a memory leak of the shared_ptr instance -%typemap(in) CONST TYPE *& (void *argp = 0, int res = 0, $*1_ltype temp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared) { +%typemap(in) TYPE *CONST& (void *argp = 0, int res = 0, $*1_ltype temp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared) { int newmem = 0; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { @@ -158,15 +158,15 @@ } $1 = &temp; } -%typemap(out, fragment="SWIG_null_deleter") CONST TYPE *& { +%typemap(out, fragment="SWIG_null_deleter") TYPE *CONST& { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_$owner); %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } -%typemap(varin) CONST TYPE *& %{ +%typemap(varin) TYPE *CONST& %{ #error "varin typemap not implemented" %} -%typemap(varout) CONST TYPE *& %{ +%typemap(varout) TYPE *CONST& %{ #error "varout typemap not implemented" %} @@ -283,10 +283,10 @@ // Note: SWIG_ConvertPtr with void ** parameter set to 0 instead of using SWIG_ConvertPtrAndOwn, so that the casting // function is not called thereby avoiding a possible smart pointer copy constructor call when casting up the inheritance chain. %typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1) - CONST TYPE, - CONST TYPE &, - CONST TYPE *, - CONST TYPE *&, + TYPE CONST, + TYPE CONST &, + TYPE CONST *, + TYPE *CONST&, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *, diff --git a/Lib/perl5/perltypemaps.swg b/Lib/perl5/perltypemaps.swg index a59f84689..540974476 100644 --- a/Lib/perl5/perltypemaps.swg +++ b/Lib/perl5/perltypemaps.swg @@ -75,7 +75,7 @@ %include /* ------------------------------------------------------------ - * Perl extra typemaps + * Perl extra typemaps / typemap overrides * ------------------------------------------------------------ */ %typemap(varout,type="$1_descriptor") SWIGTYPE *, SWIGTYPE [] @@ -90,3 +90,6 @@ %typemap(varout,type="$1_descriptor") SWIGTYPE (CLASS::*) { SWIG_MakePackedObj($result, (void *) &$1, sizeof($1_type), $1_descriptor); } + +%typemap(varout) SWIGTYPE *const = SWIGTYPE *; + diff --git a/Lib/perl5/std_map.i b/Lib/perl5/std_map.i index b19414597..ab0d3816d 100644 --- a/Lib/perl5/std_map.i +++ b/Lib/perl5/std_map.i @@ -30,7 +30,7 @@ namespace std { bool empty() const; void clear(); %extend { - T& get(const K& key) throw (std::out_of_range) { + const T& get(const K& key) throw (std::out_of_range) { std::map::iterator i = self->find(key); if (i != self->end()) return i->second; diff --git a/Lib/php/php.swg b/Lib/php/php.swg index feeb9c5df..ff4001d7e 100644 --- a/Lib/php/php.swg +++ b/Lib/php/php.swg @@ -115,12 +115,12 @@ } } -%typemap(in) SWIGTYPE *& ($*ltype temp) +%typemap(in) SWIGTYPE *const& ($*ltype temp) { if(SWIG_ConvertPtr(*$input, (void **) &temp, $*1_descriptor, 0) < 0) { SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $*1_descriptor"); } - $1 = &temp; + $1 = ($1_ltype)&temp; } %typemap(in) SWIGTYPE *DISOWN @@ -339,7 +339,7 @@ SWIG_SetPointerZval(return_value, (void *)$1, $1_descriptor, $owner); %} -%typemap(out) SWIGTYPE *& +%typemap(out) SWIGTYPE *const& %{ SWIG_SetPointerZval(return_value, (void *)*$1, $*1_descriptor, $owner); %} @@ -394,10 +394,6 @@ SWIG_SetPointerZval($input, SWIG_as_voidptr(&$1_name), $&1_descriptor, 2); } -/* Array reference typemaps */ -%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) } - - %typemap(out) void ""; %typemap(out) char [ANY] @@ -441,10 +437,11 @@ _v = (SWIG_ConvertPtr(*$input, (void **)&tmp, $&1_descriptor, 0) >= 0); } -%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, +%typecheck(SWIG_TYPECHECK_POINTER) + SWIGTYPE *, SWIGTYPE [], SWIGTYPE &, - SWIGTYPE *& + SWIGTYPE *const& { void *tmp; _v = (SWIG_ConvertPtr(*$input, (void**)&tmp, $1_descriptor, 0) >= 0); @@ -478,6 +475,12 @@ SWIG_PHP_Error(E_ERROR, (char *)$1); %} +/* Array reference typemaps */ +%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) } + +/* const pointers */ +%apply SWIGTYPE * { SWIGTYPE *const } + /* php keywords */ %include diff --git a/Lib/php/std_map.i b/Lib/php/std_map.i index cfb82f44c..b6b417da7 100644 --- a/Lib/php/std_map.i +++ b/Lib/php/std_map.i @@ -29,7 +29,7 @@ namespace std { unsigned int size() const; void clear(); %extend { - T& get(const K& key) throw (std::out_of_range) { + const T& get(const K& key) throw (std::out_of_range) { std::map::iterator i = self->find(key); if (i != self->end()) return i->second; diff --git a/Lib/pike/pike.swg b/Lib/pike/pike.swg index 2ba27671e..0cfec52b0 100644 --- a/Lib/pike/pike.swg +++ b/Lib/pike/pike.swg @@ -264,6 +264,12 @@ extern "C" { } } +/* Array reference typemaps */ +%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) } + +/* const pointers */ +%apply SWIGTYPE * { SWIGTYPE *const } + /* ------------------------------------------------------------ * Overloaded operator support * ------------------------------------------------------------ */ diff --git a/Lib/python/boost_shared_ptr.i b/Lib/python/boost_shared_ptr.i index d5dffcda9..59a3a9298 100644 --- a/Lib/python/boost_shared_ptr.i +++ b/Lib/python/boost_shared_ptr.i @@ -151,7 +151,7 @@ // plain pointer by reference // Note: $disown not implemented by default as it will lead to a memory leak of the shared_ptr instance -%typemap(in) CONST TYPE *& (void *argp = 0, int res = 0, $*1_ltype temp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared) { +%typemap(in) TYPE *CONST& (void *argp = 0, int res = 0, $*1_ltype temp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared) { int newmem = 0; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SHARED_PTR_DISOWN | %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { @@ -166,15 +166,15 @@ } $1 = &temp; } -%typemap(out, fragment="SWIG_null_deleter") CONST TYPE *& { +%typemap(out, fragment="SWIG_null_deleter") TYPE *CONST& { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_$owner); %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } -%typemap(varin) CONST TYPE *& %{ +%typemap(varin) TYPE *CONST& %{ #error "varin typemap not implemented" %} -%typemap(varout) CONST TYPE *& %{ +%typemap(varout) TYPE *CONST& %{ #error "varout typemap not implemented" %} @@ -291,10 +291,10 @@ // Note: SWIG_ConvertPtr with void ** parameter set to 0 instead of using SWIG_ConvertPtrAndOwn, so that the casting // function is not called thereby avoiding a possible smart pointer copy constructor call when casting up the inheritance chain. %typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1) - CONST TYPE, - CONST TYPE &, - CONST TYPE *, - CONST TYPE *&, + TYPE CONST, + TYPE CONST &, + TYPE CONST *, + TYPE *CONST&, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *, diff --git a/Lib/python/pytypemaps.swg b/Lib/python/pytypemaps.swg index e8df069ef..817ed1d90 100644 --- a/Lib/python/pytypemaps.swg +++ b/Lib/python/pytypemaps.swg @@ -61,7 +61,7 @@ /* ------------------------------------------------------------ - * Python extra typemaps + * Python extra typemaps / typemap overrides * ------------------------------------------------------------ */ /* Get the address of the 'python self' object */ diff --git a/Lib/r/rtype.swg b/Lib/r/rtype.swg index ee01d07d7..5103e43db 100644 --- a/Lib/r/rtype.swg +++ b/Lib/r/rtype.swg @@ -29,8 +29,10 @@ %typemap("rtype") bool, bool * "logical"; %typemap("rtype") enum SWIGTYPE "character"; %typemap("rtype") enum SWIGTYPE * "character"; +%typemap("rtype") enum SWIGTYPE *const "character"; %typemap("rtype") enum SWIGTYPE & "character"; %typemap("rtype") SWIGTYPE * "$R_class"; +%typemap("rtype") SWIGTYPE *const "$R_class"; %typemap("rtype") SWIGTYPE & "$R_class"; %typemap("rtype") SWIGTYPE "$&R_class"; @@ -65,13 +67,15 @@ %{ $input = enumToInteger($input, "$R_class"); %} %typemap(scoercein) enum SWIGTYPE * %{ $input = enumToInteger($input, "$R_class"); %} +%typemap(scoercein) enum SWIGTYPE *const + %{ $input = enumToInteger($input, "$R_class"); %} -%typemap(scoercein) SWIGTYPE, SWIGTYPE *, SWIGTYPE & +%typemap(scoercein) SWIGTYPE, SWIGTYPE *, SWIGTYPE *const, SWIGTYPE & %{ %} /* -%typemap(scoercein) SWIGTYPE * +%typemap(scoercein) SWIGTYPE *, SWIGTYPE *const %{ $input = coerceIfNotSubclass($input, "$R_class") %} %typemap(scoercein) SWIGTYPE & @@ -115,6 +119,9 @@ string &, std::string & %typemap(scoerceout) enum SWIGTYPE * %{ $result = enumToInteger($result, "$R_class"); %} +%typemap(scoerceout) enum SWIGTYPE *const + %{ $result = enumToInteger($result, "$R_class"); %} + %typemap(scoerceout) SWIGTYPE %{ class($result) <- "$&R_class"; %} @@ -125,6 +132,9 @@ string &, std::string & %typemap(scoerceout) SWIGTYPE * %{ class($result) <- "$R_class"; %} +%typemap(scoerceout) SWIGTYPE *const + %{ class($result) <- "$R_class"; %} + /* Override the SWIGTYPE * above. */ %typemap(scoerceout) char, char *, diff --git a/Lib/tcl/std_map.i b/Lib/tcl/std_map.i index 006a62efd..9d27e0f39 100644 --- a/Lib/tcl/std_map.i +++ b/Lib/tcl/std_map.i @@ -31,7 +31,7 @@ namespace std { bool empty() const; void clear(); %extend { - T& get(const K& key) throw (std::out_of_range) { + const T& get(const K& key) throw (std::out_of_range) { std::map::iterator i = self->find(key); if (i != self->end()) return i->second; diff --git a/Lib/tcl/tcltypemaps.swg b/Lib/tcl/tcltypemaps.swg index 7199e674c..d93c8869b 100644 --- a/Lib/tcl/tcltypemaps.swg +++ b/Lib/tcl/tcltypemaps.swg @@ -61,7 +61,7 @@ /* ------------------------------------------------------------ - * Tcl extra typemaps + * Tcl extra typemaps / typemap overrides * ------------------------------------------------------------ */ #if 1 @@ -84,6 +84,7 @@ %typemap(out) SWIGTYPE = SWIGTYPE INSTANCE; %typemap(out) SWIGTYPE * = SWIGTYPE *INSTANCE; +%typemap(out) SWIGTYPE *const = SWIGTYPE *; %typemap(out) SWIGTYPE & = SWIGTYPE &INSTANCE; %typemap(out) SWIGTYPE [] = SWIGTYPE INSTANCE[]; %typemap(varout) SWIGTYPE = SWIGTYPE INSTANCE; diff --git a/Lib/typemaps/swigtype.swg b/Lib/typemaps/swigtype.swg index 15f2f9b41..f57766962 100644 --- a/Lib/typemaps/swigtype.swg +++ b/Lib/typemaps/swigtype.swg @@ -21,15 +21,15 @@ %typemap(freearg) SWIGTYPE [] ""; -%typemap(in, noblock=1) SWIGTYPE* const& (void *argp = 0, int res = 0, $*ltype temp) { +%typemap(in, noblock=1) SWIGTYPE *const& (void *argp = 0, int res = 0, $*1_ltype temp) { res = SWIG_ConvertPtr($input, &argp, $*descriptor, $disown | %convertptr_flags); if (!SWIG_IsOK(res)) { %argument_fail(res, "$*ltype", $symname, $argnum); } temp = %reinterpret_cast(argp, $*ltype); - $1 = &temp; + $1 = %reinterpret_cast(&temp, $1_ltype); } -%typemap(freearg) SWIGTYPE* const& ""; +%typemap(freearg) SWIGTYPE *const& ""; /* Reference */ @@ -106,7 +106,7 @@ %set_output(SWIG_NewPointerObj(%as_voidptr($1), $descriptor, $owner | %newpointer_flags)); } -%typemap(out, noblock=1) SWIGTYPE* const& { +%typemap(out, noblock=1) SWIGTYPE *const& { %set_output(SWIG_NewPointerObj(%as_voidptr(*$1), $*descriptor, $owner | %newpointer_flags)); } @@ -299,6 +299,12 @@ $1 = SWIG_CheckState(res); } +%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1) SWIGTYPE *const& { + void *vptr = 0; + int res = SWIG_ConvertPtr($input, &vptr, $descriptor, 0); + $1 = SWIG_CheckState(res); +} + %typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1) SWIGTYPE & { void *vptr = 0; int res = SWIG_ConvertPtr($input, &vptr, $descriptor, 0); @@ -337,7 +343,7 @@ /* directorin */ -%typemap(directorin,noblock=1) SWIGTYPE*, SWIGTYPE* const& { +%typemap(directorin,noblock=1) SWIGTYPE *, SWIGTYPE *const& { $input = SWIG_NewPointerObj(%as_voidptr($1_name), $descriptor, %newpointer_flags); } @@ -345,7 +351,7 @@ $input = SWIG_NewPointerObj(%as_voidptr(&$1_name), $&descriptor, %newpointer_flags); } -%typemap(directorin,noblock=1) SWIGTYPE& { +%typemap(directorin,noblock=1) SWIGTYPE & { $input = SWIG_NewPointerObj(%as_voidptr(&$1_name), $descriptor, %newpointer_flags); } @@ -407,7 +413,7 @@ * --- Constants --- * ------------------------------------------------------------ */ -%typemap(constcode,noblock=1) SWIGTYPE *, SWIGTYPE &, SWIGTYPE []{ +%typemap(constcode,noblock=1) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] { %set_constant("$symname", SWIG_NewPointerObj(%as_voidptr($value),$descriptor,%newpointer_flags)); } @@ -547,6 +553,7 @@ } #endif +%apply SWIGTYPE * { SWIGTYPE *const } /* ------------------------------------------------------------ * --- Special typemaps --- @@ -602,3 +609,4 @@ %typemap(varout,noblock=1) SWIGTYPE INSTANCE { %set_varoutput(SWIG_NewInstanceObj(%as_voidptr(&$1), $&1_descriptor, %newinstance_flags)); } + diff --git a/Source/Modules/lang.cxx b/Source/Modules/lang.cxx index 778c8e5ba..2bfddc764 100644 --- a/Source/Modules/lang.cxx +++ b/Source/Modules/lang.cxx @@ -3014,8 +3014,6 @@ Node *Language::classLookup(SwigType *s) { Symtab *stab = 0; SwigType *ty1 = SwigType_typedef_resolve_all(s); SwigType *ty2 = SwigType_strip_qualifiers(ty1); - Delete(ty1); - ty1 = 0; String *base = SwigType_base(ty2); @@ -3052,11 +3050,18 @@ Node *Language::classLookup(SwigType *s) { if (n) { /* Found a match. Look at the prefix. We only allow the cases where where we want a proxy class for the particular type */ - if ((Len(prefix) == 0) || // simple type (pass by value) - (Strcmp(prefix, "p.") == 0) || // pointer - (Strcmp(prefix, "r.") == 0) || // reference - (Strcmp(prefix, "r.p.") == 0) || // pointer by reference - SwigType_prefix_is_simple_1D_array(prefix)) { // Simple 1D array (not arrays of pointers/references) + bool acceptable_prefix = + (Len(prefix) == 0) || // simple type (pass by value) + (Strcmp(prefix, "p.") == 0) || // pointer + (Strcmp(prefix, "r.") == 0) || // reference + SwigType_prefix_is_simple_1D_array(prefix); // Simple 1D array (not arrays of pointers/references) + // Also accept pointer by const reference, not non-const pointer reference + if (!acceptable_prefix && (Strcmp(prefix, "r.p.") == 0)) { + Delete(prefix); + prefix = SwigType_prefix(ty1); + acceptable_prefix = (Strncmp(prefix, "r.q(const", 9) == 0); + } + if (acceptable_prefix) { SwigType *cs = Copy(s); Setattr(classtypes, cs, n); Delete(cs); @@ -3064,9 +3069,10 @@ Node *Language::classLookup(SwigType *s) { n = 0; } } - Delete(ty2); - Delete(base); Delete(prefix); + Delete(base); + Delete(ty2); + Delete(ty1); } if (n && (GetFlag(n, "feature:ignore") || Getattr(n, "feature:onlychildren"))) { n = 0; @@ -3092,10 +3098,6 @@ Node *Language::enumLookup(SwigType *s) { SwigType *lt = SwigType_ltype(s); SwigType *ty1 = SwigType_typedef_resolve_all(lt); SwigType *ty2 = SwigType_strip_qualifiers(ty1); - Delete(lt); - Delete(ty1); - lt = 0; - ty1 = 0; String *base = SwigType_base(ty2); @@ -3134,9 +3136,11 @@ Node *Language::enumLookup(SwigType *s) { n = 0; } } - Delete(ty2); - Delete(base); Delete(prefix); + Delete(base); + Delete(ty2); + Delete(ty1); + Delete(lt); } if (n && (GetFlag(n, "feature:ignore"))) { n = 0; diff --git a/Source/Swig/stype.c b/Source/Swig/stype.c index fd6a06ca0..079fa07fe 100644 --- a/Source/Swig/stype.c +++ b/Source/Swig/stype.c @@ -492,6 +492,186 @@ SwigType *SwigType_default(SwigType *t) { return def; } +/* ----------------------------------------------------------------------------- + * SwigType_default_create() + * + * Create the default type for this datatype. This takes a type and strips it + * down to a generic form first by resolving all typedefs. + * + * Rules: + * Pointers: p.SWIGTYPE + * References: r.SWIGTYPE + * Arrays no dimension: a().SWIGTYPE + * Arrays with dimension: a(ANY).SWIGTYPE + * Member pointer: m(CLASS).SWIGTYPE + * Function pointer: f(ANY).SWIGTYPE + * Enums: enum SWIGTYPE + * Types: SWIGTYPE + * + * Examples (also see SwigType_default_reduce): + * + * int [2][4] + * a(2).a(4).int + * a(ANY).a(ANY).SWIGTYPE + * + * struct A {}; + * typedef A *Aptr; + * Aptr const & + * r.q(const).Aptr + * r.q(const).p.SWIGTYPE + * + * enum E {e1, e2}; + * enum E const & + * r.q(const).enum E + * r.q(const).enum SWIGTYPE + * ----------------------------------------------------------------------------- */ + +SwigType *SwigType_default_create(SwigType *ty) { + SwigType *r = 0; + List *l; + Iterator it; + int numitems; + + if (!SwigType_isvarargs(ty)) { + SwigType *t = SwigType_typedef_resolve_all(ty); + r = NewStringEmpty(); + l = SwigType_split(t); + numitems = Len(l); + + if (numitems >= 1) { + String *last_subtype = Getitem(l, numitems-1); + if (SwigType_isenum(last_subtype)) + Setitem(l, numitems-1, NewString("enum SWIGTYPE")); + else + Setitem(l, numitems-1, NewString("SWIGTYPE")); + } + + for (it = First(l); it.item; it = Next(it)) { + String *subtype = it.item; + if (SwigType_isarray(subtype)) { + if (Equal(subtype, "a().")) + Append(r, NewString("a().")); + else + Append(r, NewString("a(ANY).")); + } else if (SwigType_isfunction(subtype)) { + Append(r, NewString("f(ANY).SWIGTYPE")); + break; + } else if (SwigType_ismemberpointer(subtype)) { + Append(r, NewString("m(CLASS).SWIGTYPE")); + break; + } else { + Append(r, subtype); + } + } + + Delete(l); + Delete(t); + } + + return r; +} + +/* ----------------------------------------------------------------------------- + * SwigType_default_reduce() + * + * This function implements type reduction used in the typemap matching rules + * and is very close to the type reduction used in partial template specialization. + * SWIGTYPE is used as the generic type. The basic idea is to repeatedly call + * this function to reduce the type until it is reduced to nothing. + * + * The type t must have already been converted to the default type via a call to + * SwigType_default_create() before calling this function. + * + * Example reductions (matching the examples described in SwigType_default_create): + * + * a(ANY).a(ANY).SWIGTYPE + * a(ANY).a().SWIGTYPE + * a(ANY).p.SWIGTYPE + * a(ANY).SWIGTYPE + * a().SWIGTYPE + * p.SWIGTYPE + * SWIGTYPE + * + * r.q(const).p.SWIGTYPE + * r.q(const).SWIGTYPE + * r.SWIGTYPE + * SWIGTYPE + * + * r.q(const).enum SWIGTYPE + * r.enum SWIGTYPE + * r.SWIGTYPE + * SWIGTYPE + * ----------------------------------------------------------------------------- */ + +SwigType *SwigType_default_reduce(SwigType *t) { + SwigType *r = NewStringEmpty(); + List *l; + Iterator it; + int numitems; + + l = SwigType_split(t); + + numitems = Len(l); + if (numitems >= 1) { + String *last_subtype = Getitem(l, numitems-1); + int is_enum = SwigType_isenum(last_subtype); + + if (numitems >=2 ) { + String *subtype = Getitem(l, numitems-2); /* last but one */ + if (SwigType_isarray(subtype)) { + if (is_enum) { + /* enum reduction, enum SWIGTYPE => SWIGTYPE */ + Setitem(l, numitems-1, NewString("SWIGTYPE")); + } else { + /* array reduction, a(ANY). => a(). => p. */ + String *reduced_subtype = 0; + if (Strcmp(subtype, "a().") == 0) { + reduced_subtype = NewString("p."); + } else if (Strcmp(subtype, "a(ANY).") == 0) { + reduced_subtype = NewString("a()."); + } else { + assert(0); + } + Setitem(l, numitems-2, reduced_subtype); + } + } else if (SwigType_ismemberpointer(subtype)) { + /* member pointer reduction, m(CLASS). => p. */ + Setitem(l, numitems-2, NewString("p.")); + } else if (is_enum && !SwigType_isqualifier(subtype)) { + /* enum reduction, enum SWIGTYPE => SWIGTYPE */ + Setitem(l, numitems-1, NewString("SWIGTYPE")); + } else { + /* simple type reduction, eg, r.p.p. => r.p. */ + /* also function pointers eg, p.f(ANY). => p. */ + Delitem(l, numitems-2); + } + } else { + if (is_enum) { + /* enum reduction, enum SWIGTYPE => SWIGTYPE */ + Setitem(l, numitems-1, NewString("SWIGTYPE")); + } else { + /* delete the only item, we are done with reduction */ + Delitem(l, 0); + } + } + } else { + assert(0); + } + + for (it = First(l); it.item; it = Next(it)) { + Append(r, it.item); + } + + if (Len(r) == 0) { + Delete(r); + r = 0; + } + + Delete(l); + return r; +} + + /* ----------------------------------------------------------------------------- * SwigType_namestr() * diff --git a/Source/Swig/swig.h b/Source/Swig/swig.h index b3cb0f158..6228b2f43 100644 --- a/Source/Swig/swig.h +++ b/Source/Swig/swig.h @@ -172,6 +172,8 @@ extern "C" { extern void SwigType_array_setdim(SwigType *t, int n, const_String_or_char_ptr rep); extern SwigType *SwigType_array_type(SwigType *t); extern String *SwigType_default(SwigType *t); + extern SwigType *SwigType_default_create(SwigType *ty); + extern SwigType *SwigType_default_reduce(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); diff --git a/Source/Swig/typemap.c b/Source/Swig/typemap.c index aaf156d8e..cc32780c5 100644 --- a/Source/Swig/typemap.c +++ b/Source/Swig/typemap.c @@ -674,7 +674,7 @@ static Hash *typemap_search_helper(int debug_display, Hash *tm, const String *tm 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 */ + result = Getattr(tm, tm_method); /* See if there is simply a type without name match */ if (result && Getattr(result, "code")) goto ret_result; if (result) @@ -779,7 +779,7 @@ 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 (SWIGTYPE) mapping */ - primitive = SwigType_default(type); + primitive = SwigType_default_create(type); while (primitive) { tm = get_typemap(ts, primitive); result = typemap_search_helper(debug_display, tm, tm_method, primitive, cqualifiedname, cname, &backup); @@ -787,7 +787,7 @@ static Hash *typemap_search(const_String_or_char_ptr tmap_method, SwigType *type goto ret_result; { - SwigType *nprim = SwigType_default(primitive); + SwigType *nprim = SwigType_default_reduce(primitive); Delete(primitive); primitive = nprim; } diff --git a/Source/Swig/typeobj.c b/Source/Swig/typeobj.c index 9ccdfbf7b..a2e23e52d 100644 --- a/Source/Swig/typeobj.c +++ b/Source/Swig/typeobj.c @@ -50,6 +50,9 @@ char cvsroot_typeobj_c[] = "$Id$"; * 'q(str).' = Qualifier (such as const or volatile) (const, volatile) * 'm(qual).' = Pointer to member (qual::*) * + * The complete type representation for varargs is: + * 'v(...)' + * * The encoding follows the order that you might describe a type in words. * For example "p.a(200).int" is "A pointer to array of int's" and * "p.q(const).char" is "a pointer to a const char". @@ -177,6 +180,9 @@ SwigType *SwigType_del_element(SwigType *t) { * SwigType_pop() * * Pop one type element off the type. + * Example: t in: q(const).p.Integer + * t out: p.Integer + * result: q(const). * ----------------------------------------------------------------------------- */ SwigType *SwigType_pop(SwigType *t) { From 2a1a4309677e4574810e158335fdc868f2bc2db6 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 1 Apr 2010 18:29:36 +0000 Subject: [PATCH 0803/1680] Remove some R debugging output git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11959 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/r.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Modules/r.cxx b/Source/Modules/r.cxx index ad83d608a..5ae2397b2 100644 --- a/Source/Modules/r.cxx +++ b/Source/Modules/r.cxx @@ -556,10 +556,10 @@ String * R::createFunctionPointerHandler(SwigType *t, Node *n, int *numArgs) { ParmList *parms = SwigType_function_parms(SwigType_del_pointer(Copy(t)), n); - // if (debugMode) { + if (debugMode) { Printf(stderr, "Type: %s\n", t); Printf(stderr, "Return type: %s\n", SwigType_base(t)); - //} + } bool isVoidType = Strcmp(rettype, "void") == 0; if (debugMode) From b6c4ea90b64c9968b53000a2276824b476872a23 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 1 Apr 2010 18:33:27 +0000 Subject: [PATCH 0804/1680] remove old default SWIGTYPE reduction code git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11960 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Swig/stype.c | 218 -------------------------------------------- Source/Swig/swig.h | 2 +- 2 files changed, 1 insertion(+), 219 deletions(-) diff --git a/Source/Swig/stype.c b/Source/Swig/stype.c index 079fa07fe..7594a6ad6 100644 --- a/Source/Swig/stype.c +++ b/Source/Swig/stype.c @@ -274,224 +274,6 @@ int SwigType_issimple(SwigType *t) { return 1; } -/* ----------------------------------------------------------------------------- - * SwigType_default() - * - * Create the default string for this datatype. This takes a type and strips it - * down to its most primitive form--resolving all typedefs and removing operators. - * - * Rules: - * Pointers: p.SWIGTYPE - * References: r.SWIGTYPE - * Arrays: a().SWIGTYPE - * Types: SWIGTYPE - * MemberPointer: m(CLASS).SWIGTYPE - * Enums: enum SWIGTYPE - * - * Note: if this function is applied to a primitive type, it returns NULL. This - * allows recursive application for special types like arrays. - * ----------------------------------------------------------------------------- */ - -#ifdef SWIG_DEFAULT_CACHE -static Hash *default_cache = 0; -#endif - -#define SWIG_NEW_TYPE_DEFAULT -/* The new default type resolution method: - -1.- It preserves the original mixed types, then it goes 'backward' - first deleting the qualifier, then the inner types - - typedef A *Aptr; - const Aptr&; - r.q(const).Aptr -> r.q(const).p.SWIGTYPE - r.q(const).p.SWIGTYPE -> r.p.SWIGTYPE - r.p.SWIGTYPE -> r.SWIGTYPE - r.SWIGTYPE -> SWIGTYPE - - - enum Hello {}; - const Hello& hi; - r.q(const).Hello -> r.q(const).enum SWIGTYPE - r.q(const).enum SWIGTYPE -> r.enum SWIGTYPE - r.enum SWIGTYPE -> r.SWIGTYPE - r.SWIGTYPE -> SWIGTYPE - - int a[2][4]; - a(2).a(4).int -> a(ANY).a(ANY).SWIGTYPE - a(ANY).a(ANY).SWIGTYPE -> a(ANY).a().SWIGTYPE - a(ANY).a().SWIGTYPE -> a(ANY).p.SWIGTYPE - a(ANY).p.SWIGTYPE -> a(ANY).SWIGTYPE - a(ANY).SWIGTYPE -> a().SWIGTYPE - a().SWIGTYPE -> p.SWIGTYPE - p.SWIGTYPE -> SWIGTYPE -*/ - -static -void SwigType_add_default(String *def, SwigType *nr) { - if (Strcmp(nr, "SWIGTYPE") == 0) { - Append(def, "SWIGTYPE"); - } else { - String *q = SwigType_isqualifier(nr) ? SwigType_pop(nr) : 0; - if (q && strstr(Char(nr), "SWIGTYPE")) { - Append(def, nr); - } else { - String *nd = SwigType_default(nr); - if (nd) { - String *bdef = nd; - if (q) { - bdef = NewStringf("%s%s", q, nd); - if ((Strcmp(nr, bdef) == 0)) { - Delete(bdef); - bdef = nd; - } else { - Delete(nd); - } - } - Append(def, bdef); - Delete(bdef); - } else { - Append(def, nr); - } - } - Delete(q); - } -} - - -SwigType *SwigType_default(SwigType *t) { - String *r1, *def; - String *r = 0; - char *cr; - -#ifdef SWIG_DEFAULT_CACHE - if (!default_cache) - default_cache = NewHash(); - - r = Getattr(default_cache, t); - if (r) { - return Copy(r); - } -#endif - - if (SwigType_isvarargs(t)) { - return 0; - } - - r = t; - while ((r1 = SwigType_typedef_resolve(r))) { - if (r != t) - Delete(r); - r = r1; - } - if (SwigType_isqualifier(r)) { - String *q; - if (r == t) - r = Copy(t); - q = SwigType_pop(r); - if (strstr(Char(r), "SWIGTYPE")) { - Delete(q); - def = r; - return def; - } - Delete(q); - } - cr = Char(r); - if (strcmp(cr, "p.SWIGTYPE") == 0) { - def = NewString("SWIGTYPE"); - } else if (SwigType_ispointer(r)) { -#ifdef SWIG_NEW_TYPE_DEFAULT - SwigType *nr = Copy(r); - SwigType_del_pointer(nr); - def = SwigType_isfunction(nr) ? NewStringEmpty() : NewString("p."); - SwigType_add_default(def, nr); - Delete(nr); -#else - def = NewString("p.SWIGTYPE"); -#endif - } else if (strcmp(cr, "r.SWIGTYPE") == 0) { - def = NewString("SWIGTYPE"); - } else if (SwigType_isreference(r)) { -#ifdef SWIG_NEW_TYPE_DEFAULT - SwigType *nr = Copy(r); - SwigType_del_reference(nr); - def = NewString("r."); - SwigType_add_default(def, nr); - Delete(nr); -#else - def = NewString("r.SWIGTYPE"); -#endif - } else if (SwigType_isarray(r)) { - if (strcmp(cr, "a().SWIGTYPE") == 0) { - def = NewString("p.SWIGTYPE"); - } else if (strcmp(cr, "a(ANY).SWIGTYPE") == 0) { - def = NewString("a().SWIGTYPE"); - } else { - int i, empty = 0; - int ndim = SwigType_array_ndim(r); - SwigType *nr = Copy(r); - for (i = 0; i < ndim; i++) { - String *dim = SwigType_array_getdim(r, i); - if (!Len(dim)) { - char *c = Char(nr); - empty = strstr(c, "a(ANY).") != c; - } - Delete(dim); - } - if (empty) { - def = NewString("a()."); - } else { - def = NewString("a(ANY)."); - } -#ifdef SWIG_NEW_TYPE_DEFAULT - SwigType_del_array(nr); - SwigType_add_default(def, nr); -#else - Append(def, "SWIGTYPE"); -#endif - Delete(nr); - } - } else if (SwigType_ismemberpointer(r)) { - if (strcmp(cr, "m(CLASS).SWIGTYPE") == 0) { - def = NewString("p.SWIGTYPE"); - } else { - def = NewString("m(CLASS).SWIGTYPE"); - } - } else if (SwigType_isenum(r)) { - if (strcmp(cr, "enum SWIGTYPE") == 0) { - def = NewString("SWIGTYPE"); - } else { - def = NewString("enum SWIGTYPE"); - } - } else if (SwigType_isfunction(r)) { - if (strcmp(cr, "f(ANY).SWIGTYPE") == 0) { - def = NewString("p.SWIGTYPE"); - } else { - def = NewString("p.f(ANY).SWIGTYPE"); - } - } else { - def = NewString("SWIGTYPE"); - } - if (r != t) - Delete(r); - if (Equal(def, t)) { - Delete(def); - def = 0; - } -#ifdef SWIG_DEFAULT_CACHE - /* The cache produces strange results, see enum_template.i case */ - if (def) { - String *cdef = Copy(def); - Setattr(default_cache, t, cdef); - Delete(cdef); - } -#endif - - /* Printf(stderr,"type : def %s : %s\n", t, def); */ - - return def; -} - /* ----------------------------------------------------------------------------- * SwigType_default_create() * diff --git a/Source/Swig/swig.h b/Source/Swig/swig.h index 6228b2f43..cf94acfa8 100644 --- a/Source/Swig/swig.h +++ b/Source/Swig/swig.h @@ -37,7 +37,7 @@ extern "C" { /* Global macros */ #define NSPACE_SEPARATOR "." /* Namespace separator for the nspace feature - this should be changed to a target language configurable variable */ -#define NSPACE_TODO 0 /* temporary TODO hack */ +#define NSPACE_TODO 0 /* Languages that still need to implement and test the nspace feature use this */ /* Short names for common data types */ From 482c06c28c44ab0e234a78e9850fd3835e96e3ac Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 1 Apr 2010 23:30:26 +0000 Subject: [PATCH 0805/1680] Remove unnecessary vector of constant pointer specialization since the improved default typemap matching rules were introduced git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11961 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/li_std_vector.i | 8 ------ Lib/csharp/std_vector.i | 40 +++++++++++++---------------- 2 files changed, 18 insertions(+), 30 deletions(-) diff --git a/Examples/test-suite/li_std_vector.i b/Examples/test-suite/li_std_vector.i index 74b3f6e6f..a58f97ff1 100644 --- a/Examples/test-suite/li_std_vector.i +++ b/Examples/test-suite/li_std_vector.i @@ -74,12 +74,6 @@ const std::vector & vecstructptr(const std::vector & vec) { const std::vector & vecstructconstptr(const std::vector & vec) { return vec; } %} -#if defined(SWIGCSHARP) -// Also test const and non-const pointers, but not strictly necessary since std::vector was enhanced in swig-1.3.40 -%template(StructurePtrVector) std::vector; -%template(StructureConstPtrVector) std::vector; -#endif - #if !defined(SWIGR) %template(IntPtrVector) std::vector; %template(IntConstPtrVector) std::vector; @@ -88,7 +82,6 @@ const std::vector & vecstructconstptr(const std::vector; %template(StructConstPtrVector) std::vector; -#if !defined(SWIGTCL) %inline { struct MyClass {}; typedef MyClass *MyClassPtr; @@ -106,7 +99,6 @@ const std::vector & vecstructconstptr(const std::vector; diff --git a/Lib/csharp/std_vector.i b/Lib/csharp/std_vector.i index 57abe614d..7fca7d2fd 100644 --- a/Lib/csharp/std_vector.i +++ b/Lib/csharp/std_vector.i @@ -25,7 +25,7 @@ %include // MACRO for use within the std::vector class body -%define SWIG_STD_VECTOR_MINIMUM_INTERNAL(CSINTERFACE, CONST_REFERENCE_TYPE, CTYPE...) +%define SWIG_STD_VECTOR_MINIMUM_INTERNAL(CSINTERFACE, CONST_REFERENCE, 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() { @@ -208,16 +208,16 @@ public: typedef size_t size_type; typedef CTYPE value_type; - typedef CONST_REFERENCE_TYPE const_reference; + typedef CONST_REFERENCE const_reference; %rename(Clear) clear; void clear(); %rename(Add) push_back; - void push_back(const value_type& x); + void push_back(CTYPE const& x); size_type size() const; size_type capacity() const; void reserve(size_type n); %newobject GetRange(int index, int count); - %newobject Repeat(const value_type& value, int count); + %newobject Repeat(CTYPE const& value, int count); vector(); vector(const vector &other); %extend { @@ -243,7 +243,7 @@ else throw std::out_of_range("index"); } - void setitem(int index, const value_type& val) throw (std::out_of_range) { + void setitem(int index, CTYPE const& val) throw (std::out_of_range) { if (index>=0 && index<(int)$self->size()) (*$self)[index] = val; else @@ -263,7 +263,7 @@ throw std::invalid_argument("invalid range"); return new std::vector($self->begin()+index, $self->begin()+index+count); } - void Insert(int index, const value_type& x) throw (std::out_of_range) { + void Insert(int index, CTYPE const& x) throw (std::out_of_range) { if (index>=0 && index<(int)$self->size()+1) $self->insert($self->begin()+index, x); else @@ -291,7 +291,7 @@ throw std::invalid_argument("invalid range"); $self->erase($self->begin()+index, $self->begin()+index+count); } - static std::vector *Repeat(const value_type& value, int count) throw (std::out_of_range) { + static std::vector *Repeat(CTYPE const& value, int count) throw (std::out_of_range) { if (count < 0) throw std::out_of_range("count"); return new std::vector(count, value); @@ -320,31 +320,31 @@ %enddef %define SWIG_STD_VECTOR_MINIMUM(CTYPE...) -SWIG_STD_VECTOR_MINIMUM_INTERNAL(IEnumerable, const value_type&, CTYPE) +SWIG_STD_VECTOR_MINIMUM_INTERNAL(IEnumerable, CTYPE const&, CTYPE) %enddef // Extra methods added to the collection class if operator== is defined for the class being wrapped // The class will then implement IList<>, which adds extra functionality %define SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(CTYPE...) %extend { - bool Contains(const value_type& value) { + bool Contains(CTYPE const& value) { return std::find($self->begin(), $self->end(), value) != $self->end(); } - int IndexOf(const value_type& value) { + int IndexOf(CTYPE const& value) { int index = -1; std::vector::iterator it = std::find($self->begin(), $self->end(), value); if (it != $self->end()) index = (int)(it - $self->begin()); return index; } - int LastIndexOf(const value_type& value) { + int LastIndexOf(CTYPE const& value) { int index = -1; std::vector::reverse_iterator rit = std::find($self->rbegin(), $self->rend(), value); if (rit != $self->rend()) index = (int)($self->rend() - 1 - rit); return index; } - bool Remove(const value_type& value) { + bool Remove(CTYPE const& value) { std::vector::iterator it = std::find($self->begin(), $self->end(), value); if (it != $self->end()) { $self->erase(it); @@ -359,7 +359,7 @@ SWIG_STD_VECTOR_MINIMUM_INTERNAL(IEnumerable, const value_type&, CTYPE) %define SWIG_STD_VECTOR_ENHANCED(CTYPE...) namespace std { template<> class vector { - SWIG_STD_VECTOR_MINIMUM_INTERNAL(IList, const value_type&, CTYPE) + SWIG_STD_VECTOR_MINIMUM_INTERNAL(IList, CTYPE const&, CTYPE) SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(CTYPE) }; } @@ -394,16 +394,12 @@ namespace std { template class vector { SWIG_STD_VECTOR_MINIMUM(T) }; - // specializations for pointers - template class vector { - SWIG_STD_VECTOR_MINIMUM_INTERNAL(IList, const value_type&, T*) - SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(T*) + // specialization for pointers + template class vector { + SWIG_STD_VECTOR_MINIMUM_INTERNAL(IList, T *const&, T *) + SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(T *) }; - template class vector { - 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 + // bool is specialized in the C++ standard - const_reference in particular template<> class vector { SWIG_STD_VECTOR_MINIMUM_INTERNAL(IList, bool, bool) SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(bool) From 662084aa06d5b3818532b87709e0b5be383a3df1 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 2 Apr 2010 19:48:20 +0000 Subject: [PATCH 0806/1680] Lua - Fix char pointers, wchar_t pointers and char arrays so that nil can be passed as a valid value git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11963 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 +++ Examples/test-suite/char_strings.i | 6 +++++ .../test-suite/lua/char_strings_runme.lua | 12 +++++++++ Lib/lua/luatypemaps.swg | 25 +++++++++++++------ Lib/lua/wchar.i | 4 +-- 5 files changed, 41 insertions(+), 10 deletions(-) create mode 100644 Examples/test-suite/lua/char_strings_runme.lua diff --git a/CHANGES.current b/CHANGES.current index 0be45290b..a58cd68d3 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,10 @@ Version 2.0.0 (in progress) ============================ +2010-04-02: wsfulton + [Lua] Fix char pointers, wchar_t pointers and char arrays so that nil can be passed as a + valid value. Bug reported by Gedalia Pasternak. + 2010-04-01: wsfulton Numerous subtle typemap matching rule fixes when using the default type. The typemap matching rules are to take a type and find the best default typemap (SWIGTYPE, SWIGTYPE* etc), diff --git a/Examples/test-suite/char_strings.i b/Examples/test-suite/char_strings.i index 2561108c6..26f3f22a5 100644 --- a/Examples/test-suite/char_strings.i +++ b/Examples/test-suite/char_strings.i @@ -109,6 +109,12 @@ bool SetConstCharArrayStaticString(const char str[], unsigned int number) { char *CharPingPong(char *str) { return str; } +char *CharArrayPingPong(char abcstr[]) { + return abcstr; +} +char *CharArrayDimsPingPong(char abcstr[16]) { + return abcstr; +} // variables char *global_char = NULL; diff --git a/Examples/test-suite/lua/char_strings_runme.lua b/Examples/test-suite/lua/char_strings_runme.lua new file mode 100644 index 000000000..64ae6ec1c --- /dev/null +++ b/Examples/test-suite/lua/char_strings_runme.lua @@ -0,0 +1,12 @@ +require("import") -- the import fn +import("char_strings") -- import code + +assert (char_strings.CharPingPong("hi there") == "hi there") +assert (char_strings.CharPingPong(nil) == nil) + +assert (char_strings.CharArrayPingPong("hi there") == "hi there") +assert (char_strings.CharArrayPingPong(nil) == nil) + +assert (char_strings.CharArrayDimsPingPong("hi there") == "hi there") +assert (char_strings.CharArrayDimsPingPong(nil) == nil) + diff --git a/Lib/lua/luatypemaps.swg b/Lib/lua/luatypemaps.swg index 58f42eea1..ae65cbfea 100644 --- a/Lib/lua/luatypemaps.swg +++ b/Lib/lua/luatypemaps.swg @@ -90,10 +90,19 @@ temp=($basetype)lua_tonumber(L,$input); $1=&temp;%} %{ lua_pushboolean(L,(int)((*$1)!=0)); SWIG_arg++;%} // strings (char* and char[]) -%typemap(in,checkfn="lua_isstring") const char*, char* +%fragment("SWIG_lua_isnilstring", "header") { + int SWIG_lua_isnilstring(lua_State *L, int idx) { + int ret = lua_isstring(L, idx); + if (!ret) + ret = lua_isnil(L, idx); + return ret; + } +} + +%typemap(in,checkfn="SWIG_lua_isnilstring",fragment="SWIG_lua_isnilstring") const char*, char* %{$1 = ($ltype)lua_tostring(L, $input);%} -%typemap(in,checkfn="lua_isstring") const char[ANY], char[ANY] +%typemap(in,checkfn="SWIG_lua_isnilstring",fragment="SWIG_lua_isnilstring") const char[ANY], char[ANY] %{$1 = ($ltype)lua_tostring(L, $input);%} %typemap(out) const char*, char* @@ -105,14 +114,14 @@ temp=($basetype)lua_tonumber(L,$input); $1=&temp;%} // char's // currently treating chars as small strings, not as numbers // (however signed & unsigned char's are numbers...) -%typemap(in,checkfn="lua_isstring") char +%typemap(in,checkfn="SWIG_lua_isnilstring",fragment="SWIG_lua_isnilstring") char %{$1 = (lua_tostring(L, $input))[0];%} %typemap(out) char %{ lua_pushfstring(L,"%c",$1); SWIG_arg++;%} // by const ref -%typemap(in,checkfn="lua_isstring") const char& (char temp) +%typemap(in,checkfn="SWIG_lua_isnilstring",fragment="SWIG_lua_isnilstring") const char& (char temp) %{temp = (lua_tostring(L, $input))[0]; $1=&temp;%} %typemap(out) const char& @@ -288,12 +297,12 @@ parmeters match which function } // special check for a char (string of length 1) -%typecheck(SWIG_TYPECHECK_CHAR) char, const char& { - $1 = lua_isstring(L,$input) && (lua_strlen(L,$input)==1); +%typecheck(SWIG_TYPECHECK_CHAR,fragment="SWIG_lua_isnilstring") char, const char& { + $1 = SWIG_lua_isnilstring(L,$input) && (lua_strlen(L,$input)==1); } -%typecheck(SWIG_TYPECHECK_STRING) char *, char[] { - $1 = lua_isstring(L,$input); +%typecheck(SWIG_TYPECHECK_STRING,fragment="SWIG_lua_isnilstring") char *, char[] { + $1 = SWIG_lua_isnilstring(L,$input); } %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE [] { diff --git a/Lib/lua/wchar.i b/Lib/lua/wchar.i index 5021c1604..02b5428be 100644 --- a/Lib/lua/wchar.i +++ b/Lib/lua/wchar.i @@ -28,13 +28,13 @@ wchar_t* str2wstr(const char* str, int len) } %} -%typemap( in, checkfn="lua_isstring" ) wchar_t* +%typemap(in, checkfn="SWIG_lua_isnilstring", fragment="SWIG_lua_isnilstring") wchar_t* %{ $1 = str2wstr(lua_tostring( L, $input ),lua_strlen( L, $input )); if ($1==0) {lua_pushfstring(L,"Error in converting to wchar (arg %d)",$input);goto fail;} %} -%typemap( freearg ) wchar_t* +%typemap(freearg) wchar_t* %{ free($1); %} From fb99ef318c769fdc95ee67f7452d0e21c2d36649 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 3 Apr 2010 00:20:42 +0000 Subject: [PATCH 0807/1680] fixes for make distclean git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11964 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CCache/Makefile.in | 4 ++-- Examples/Makefile.in | 5 +++++ Makefile.in | 12 ++++++++++-- Source/Makefile.am | 3 +++ 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/CCache/Makefile.in b/CCache/Makefile.in index ef20f48a0..543970f9e 100644 --- a/CCache/Makefile.in +++ b/CCache/Makefile.in @@ -63,10 +63,10 @@ test: test.sh check: test distclean: clean distclean-docs - /bin/rm -f Makefile config.h config.sub config.log build-stamp config.status config.h.in ccache_swig_config.h + /bin/rm -f Makefile config.h config.sub config.log build-stamp config.status ccache_swig_config.h maintainer-clean: distclean - /bin/rm -f configure + /bin/rm -f configure config.h.in # FIXME: To fix this, test.sh needs to be able to take ccache from the # installed prefix, not from the source dir. diff --git a/Examples/Makefile.in b/Examples/Makefile.in index 3516d6f28..7f11884ee 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -84,6 +84,11 @@ CXXSHARED= @CXXSHARED@ OBJS = $(SRCS:.c=.@OBJEXT@) $(CXXSRCS:.cxx=.@OBJEXT@) +distclean: + rm -f Makefile + rm -f guile/Makefile + rm -f xml/Makefile + ################################################################## ##### Tcl/Tk ###### ################################################################## diff --git a/Makefile.in b/Makefile.in index 6effe59b9..1401ea9fc 100644 --- a/Makefile.in +++ b/Makefile.in @@ -336,9 +336,9 @@ maintainer-clean: clean-libfiles # DISTCLEAN ##################################################################### -DISTCLEAN-DEAD = config.status config.log config.cache swig.spec Makefile mkmf.log libtool +DISTCLEAN-DEAD = config.status config.log config.cache swig.spec Makefile mkmf.log libtool preinst-swig Lib/ocaml/swigp4.ml -distclean: clean-docs distclean-objects clean-examples distclean-test-suite distclean-dead distclean-ccache +distclean: clean-docs distclean-objects distclean-test-suite distclean-examples distclean-dead distclean-ccache distclean-objects: distclean-source @@ -351,6 +351,11 @@ distclean-test-suite: @echo distcleaning Examples/test-suite @$(MAKE) -k -s check-test-suite ACTION=distclean NOSKIP=1 +distclean-examples: + @echo distcleaning Examples + @$(MAKE) -k -s clean-examples + @cd Examples && $(MAKE) -k -s distclean + distclean-ccache: test -z "$(ENABLE_CCACHE)" || (cd $(CCACHE) && $(MAKE) -s distclean) @@ -360,6 +365,9 @@ distclean-docs-ccache: distclean-dead: rm -f $(DISTCLEAN-DEAD) +distclean-: + rm -f Lib/ocaml/swigp4.ml + ##################################################################### # Update the Lib/swigwarn.swg file # Note: Generated into the source tree rather than build tree diff --git a/Source/Makefile.am b/Source/Makefile.am index bc3222b25..3f710302a 100644 --- a/Source/Makefile.am +++ b/Source/Makefile.am @@ -104,6 +104,9 @@ clean-local: rm -f $(top_builddir)/swig@EXEEXT@ rm -f core @EXTRA_CLEAN@ +distclean: + rm -f $(top_builddir)/Source/Include/swigconfig.h + rm -f $(top_builddir)/Source/Include/stamp-h1 # Beautify the code. # Note that this works well on C code, but does some odd joining of lines for C++ code. From 96fbbc50ccd8fc9f62de335f843cda85eec2aec6 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 3 Apr 2010 00:30:16 +0000 Subject: [PATCH 0808/1680] make maintainer-clean fixes git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11965 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CCache/Makefile.in | 4 ++-- Doc/Manual/Makefile | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CCache/Makefile.in b/CCache/Makefile.in index 543970f9e..fdb316f1f 100644 --- a/CCache/Makefile.in +++ b/CCache/Makefile.in @@ -52,7 +52,7 @@ uninstall: $(PACKAGE_NAME)$(EXEEXT) $(PACKAGE_NAME).1 clean: /bin/rm -f $(OBJS) *~ $(PACKAGE_NAME)$(EXEEXT) -distclean-docs: +maintainer-clean: rm -f $(PACKAGE_NAME).1 web/ccache-man.html check : test @@ -62,7 +62,7 @@ test: test.sh check: test -distclean: clean distclean-docs +distclean: clean /bin/rm -f Makefile config.h config.sub config.log build-stamp config.status ccache_swig_config.h maintainer-clean: distclean diff --git a/Doc/Manual/Makefile b/Doc/Manual/Makefile index 7db42322c..69d361f07 100644 --- a/Doc/Manual/Makefile +++ b/Doc/Manual/Makefile @@ -50,7 +50,7 @@ swightml.book: echo "Sections.html" >> swightml.book cat chapters >> swightml.book -clean: clean-baks +maintainer-clean: clean-baks rm -f swightml.book rm -f swigpdf.book rm -f CCache.html From b53e52602aeaf3aedd94d79f16a69ec58c72c66e Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 3 Apr 2010 01:14:52 +0000 Subject: [PATCH 0809/1680] make maintainer-clean and make distclean fixes git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11966 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CCache/Makefile.in | 5 ++--- Makefile.in | 38 ++++++++++++++++++-------------------- 2 files changed, 20 insertions(+), 23 deletions(-) diff --git a/CCache/Makefile.in b/CCache/Makefile.in index fdb316f1f..b96d42a60 100644 --- a/CCache/Makefile.in +++ b/CCache/Makefile.in @@ -52,9 +52,6 @@ uninstall: $(PACKAGE_NAME)$(EXEEXT) $(PACKAGE_NAME).1 clean: /bin/rm -f $(OBJS) *~ $(PACKAGE_NAME)$(EXEEXT) -maintainer-clean: - rm -f $(PACKAGE_NAME).1 web/ccache-man.html - check : test test: test.sh @@ -67,6 +64,8 @@ distclean: clean maintainer-clean: distclean /bin/rm -f configure config.h.in + /bin/rm -f $(PACKAGE_NAME).1 web/ccache-man.html + # FIXME: To fix this, test.sh needs to be able to take ccache from the # installed prefix, not from the source dir. diff --git a/Makefile.in b/Makefile.in index 1401ea9fc..7b74870b6 100644 --- a/Makefile.in +++ b/Makefile.in @@ -302,9 +302,6 @@ clean-source: @cd $(SOURCE) && $(MAKE) -s clean @rm -f $(TARGET) -clean-libfiles: - @rm -f $(srcdir)/Lib/swigwarn.swg - clean-examples: @$(MAKE) -k -s check-examples ACTION=clean @@ -320,27 +317,15 @@ clean-%-test-suite: clean-ccache: test -z "$(ENABLE_CCACHE)" || (cd $(CCACHE) && $(MAKE) -s clean) -clean-docs: clean-docs-main clean-docs-ccache - -clean-docs-main: - @echo cleaning Docs - @test -d $(DOCS) || exit 0; cd $(DOCS) && $(MAKE) clean - -clean-docs-ccache: - @# 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 - ##################################################################### -# DISTCLEAN +# DISTCLEAN - clean what configure built ##################################################################### DISTCLEAN-DEAD = config.status config.log config.cache swig.spec Makefile mkmf.log libtool preinst-swig Lib/ocaml/swigp4.ml -distclean: clean-docs distclean-objects distclean-test-suite distclean-examples distclean-dead distclean-ccache +distclean-helper: distclean-test-suite distclean-examples distclean-dead distclean-ccache -distclean-objects: distclean-source +distclean: distclean-source distclean-helper distclean-source: @echo distcleaning Source @@ -365,8 +350,21 @@ distclean-docs-ccache: distclean-dead: rm -f $(DISTCLEAN-DEAD) -distclean-: - rm -f Lib/ocaml/swigp4.ml +##################################################################### +# MAINTAINER CLEAN - clean what the maintainer builds and ships in +# the distributed tarball - should not delete anything needed to run +# ./configure && make +##################################################################### + +maintainer-clean: + @echo maintainer-cleaning source + @cd $(SOURCE) && $(MAKE) -k -s maintainer-clean + @echo maintainer-cleaning docs + @cd $(DOCS) && $(MAKE) -k -s maintainer-clean + @echo maintainer-cleaning Lib files + @rm -f $(srcdir)/Lib/swigwarn.swg + @echo distcleaning + @$(MAKE) -k -s distclean-helper ##################################################################### # Update the Lib/swigwarn.swg file From d090cadb4c86da2af96cfb7bc3c96c7ee037258f Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 3 Apr 2010 10:11:01 +0000 Subject: [PATCH 0810/1680] more distclean fixes git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11967 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CCache/Makefile.in | 1 + Makefile.in | 1 + Source/Makefile.am | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CCache/Makefile.in b/CCache/Makefile.in index b96d42a60..fd7ee7eb0 100644 --- a/CCache/Makefile.in +++ b/CCache/Makefile.in @@ -61,6 +61,7 @@ check: test distclean: clean /bin/rm -f Makefile config.h config.sub config.log build-stamp config.status ccache_swig_config.h + /bin/rm -rf autom4te.cache maintainer-clean: distclean /bin/rm -f configure config.h.in diff --git a/Makefile.in b/Makefile.in index 7b74870b6..228b9201d 100644 --- a/Makefile.in +++ b/Makefile.in @@ -349,6 +349,7 @@ distclean-docs-ccache: distclean-dead: rm -f $(DISTCLEAN-DEAD) + rm -rf autom4te.cache ##################################################################### # MAINTAINER CLEAN - clean what the maintainer builds and ships in diff --git a/Source/Makefile.am b/Source/Makefile.am index 3f710302a..26f37b2fe 100644 --- a/Source/Makefile.am +++ b/Source/Makefile.am @@ -104,7 +104,7 @@ clean-local: rm -f $(top_builddir)/swig@EXEEXT@ rm -f core @EXTRA_CLEAN@ -distclean: +distclean-local: rm -f $(top_builddir)/Source/Include/swigconfig.h rm -f $(top_builddir)/Source/Include/stamp-h1 From 3289c7d897144ad99f05ef8d196212adbc0919c2 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 3 Apr 2010 10:34:34 +0000 Subject: [PATCH 0811/1680] more distclean and maintainer-clean fixes git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11968 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CCache/Makefile.in | 1 - Makefile.in | 7 +++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/CCache/Makefile.in b/CCache/Makefile.in index fd7ee7eb0..e1014d230 100644 --- a/CCache/Makefile.in +++ b/CCache/Makefile.in @@ -64,7 +64,6 @@ distclean: clean /bin/rm -rf autom4te.cache maintainer-clean: distclean - /bin/rm -f configure config.h.in /bin/rm -f $(PACKAGE_NAME).1 web/ccache-man.html diff --git a/Makefile.in b/Makefile.in index 228b9201d..48ebafc65 100644 --- a/Makefile.in +++ b/Makefile.in @@ -342,10 +342,7 @@ distclean-examples: @cd Examples && $(MAKE) -k -s distclean distclean-ccache: - test -z "$(ENABLE_CCACHE)" || (cd $(CCACHE) && $(MAKE) -s distclean) - -distclean-docs-ccache: - @test -z "$(ENABLE_CCACHE)" || (cd $(CCACHE) && $(MAKE) distclean-docs) + @test -z "$(ENABLE_CCACHE)" || (cd $(CCACHE) && $(MAKE) -s distclean) distclean-dead: rm -f $(DISTCLEAN-DEAD) @@ -360,6 +357,8 @@ distclean-dead: maintainer-clean: @echo maintainer-cleaning source @cd $(SOURCE) && $(MAKE) -k -s maintainer-clean + @echo maintainer-cleaning CCache + @test -z "$(ENABLE_CCACHE)" || (cd $(CCACHE) && $(MAKE) -s maintainer-clean) @echo maintainer-cleaning docs @cd $(DOCS) && $(MAKE) -k -s maintainer-clean @echo maintainer-cleaning Lib files From 07621c122a1d176ee9178b9adc9c977eadb8ef41 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 3 Apr 2010 11:36:54 +0000 Subject: [PATCH 0812/1680] more maintainer-clean fixes git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11969 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Makefile.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile.in b/Makefile.in index 48ebafc65..923c34321 100644 --- a/Makefile.in +++ b/Makefile.in @@ -323,9 +323,9 @@ clean-ccache: DISTCLEAN-DEAD = config.status config.log config.cache swig.spec Makefile mkmf.log libtool preinst-swig Lib/ocaml/swigp4.ml -distclean-helper: distclean-test-suite distclean-examples distclean-dead distclean-ccache +distclean-helper: distclean-test-suite distclean-examples distclean-dead -distclean: distclean-source distclean-helper +distclean: distclean-source distclean-ccache distclean-helper distclean-source: @echo distcleaning Source From 0080d1e031e7dc9e41b6e187aa35b80fa7ec8d4e Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 3 Apr 2010 12:04:28 +0000 Subject: [PATCH 0813/1680] display to user ccache-swig install files git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11970 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CCache/Makefile.in | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CCache/Makefile.in b/CCache/Makefile.in index e1014d230..d8f9042fe 100644 --- a/CCache/Makefile.in +++ b/CCache/Makefile.in @@ -40,8 +40,11 @@ web/ccache-man.html: ccache.yo yodl2html -o web/ccache-man.html ccache.yo install: $(PACKAGE_NAME)$(EXEEXT) $(PACKAGE_NAME).1 + @echo "Installing $(PACKAGE_NAME)" + @echo "Installing $(DESTDIR)${bindir}/`echo $(PACKAGE_NAME) | sed '$(transform)'`$(EXEEXT)" ${INSTALLCMD} -d $(DESTDIR)${bindir} ${INSTALLCMD} -m 755 $(PACKAGE_NAME)$(EXEEXT) $(DESTDIR)${bindir}/`echo $(PACKAGE_NAME) | sed '$(transform)'`$(EXEEXT) + @echo "Installing $(DESTDIR)${mandir}/man1/`echo $(PACKAGE_NAME) | sed '$(transform)'`.1" ${INSTALLCMD} -d $(DESTDIR)${mandir}/man1 ${INSTALLCMD} -m 644 ${srcdir}/$(PACKAGE_NAME).1 $(DESTDIR)${mandir}/man1/`echo $(PACKAGE_NAME) | sed '$(transform)'`.1 From 5b3b15ae15e6d404341ebc51606f1404fbbff81b Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 3 Apr 2010 12:05:16 +0000 Subject: [PATCH 0814/1680] Minor robustness tweaks to building distribution git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11971 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Tools/mkdist.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Tools/mkdist.py b/Tools/mkdist.py index 9e25d3827..bd7872fb0 100755 --- a/Tools/mkdist.py +++ b/Tools/mkdist.py @@ -46,17 +46,18 @@ os.system("rm -Rf "+dirname+"/debian") == 0 or failed() # Go build the system print "Building system" -os.system("cd "+dirname+"; ./autogen.sh") == 0 or failed() -os.system("cd "+dirname+"/Tools/WAD; autoconf") == 0 or failed() -os.system("cd "+dirname+"/Source/CParse; bison -y -d parser.y; mv y.tab.c parser.c; mv y.tab.h parser.h") == 0 or failed() -os.system("cd "+dirname+"; make -f Makefile.in libfiles srcdir=./") == 0 or failed() +os.system("cd "+dirname+" && ./autogen.sh") == 0 or failed() +os.system("cd "+dirname+"/Tools/WAD && autoconf") == 0 or failed() +os.system("cd "+dirname+"/Source/CParse && bison -y -d parser.y && mv y.tab.c parser.c && mv y.tab.h parser.h") == 0 or failed() +os.system("cd "+dirname+" && make -f Makefile.in libfiles srcdir=./") == 0 or failed() # Remove autoconf files os.system("find "+dirname+" -name autom4te.cache -exec rm -rf {} \\;") # Build documentation -print "Building documentation" +print "Building html documentation" os.system("cd "+dirname+"/Doc/Manual && make all clean-baks") == 0 or failed() +print "Building man pages" os.system("cd "+dirname+"/CCache && yodl2man -o ccache-swig.1 ccache.yo") == 0 or failed() # Build the tar-ball From e75d8d44639e442f75cda8e1bbc0ed3ba0cfbe55 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 3 Apr 2010 12:15:10 +0000 Subject: [PATCH 0815/1680] quieter ccache-swig install git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11972 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Makefile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.in b/Makefile.in index 923c34321..9f6c23499 100644 --- a/Makefile.in +++ b/Makefile.in @@ -436,7 +436,7 @@ install-lib: done install-ccache: - test -z "$(ENABLE_CCACHE)" || (cd $(CCACHE) && $(MAKE) install) + @test -z "$(ENABLE_CCACHE)" || (cd $(CCACHE) && $(MAKE) -s install) ##################################################################### From 5494c4295bbd3782d64abd6f838ae7efdc05bb79 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 3 Apr 2010 12:22:23 +0000 Subject: [PATCH 0816/1680] Show success at end of distribution build git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11973 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Tools/mkdist.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Tools/mkdist.py b/Tools/mkdist.py index bd7872fb0..6972eb829 100755 --- a/Tools/mkdist.py +++ b/Tools/mkdist.py @@ -64,3 +64,5 @@ os.system("cd "+dirname+"/CCache && yodl2man -o ccache-swig.1 ccache.yo") == 0 o os.system("tar -cf "+dirname+".tar "+dirname) == 0 or failed() os.system("gzip "+dirname+".tar") == 0 or failed() +print "Finished building "+dirname+".tar.gz" + From 7a1551e0c45843a2c02961932fde7cd04deed48c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 3 Apr 2010 12:44:17 +0000 Subject: [PATCH 0817/1680] fix make clean git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11974 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Makefile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.in b/Makefile.in index 9f6c23499..0beb7cbdd 100644 --- a/Makefile.in +++ b/Makefile.in @@ -293,7 +293,7 @@ broken-%-test-suite: # CLEAN ##################################################################### -clean: clean-objects clean-libfiles clean-examples clean-test-suite clean-docs +clean: clean-objects clean-examples clean-test-suite clean-objects: clean-source clean-ccache From ab62df21e800c183df96d706524ecbe94c323ed4 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 3 Apr 2010 12:47:50 +0000 Subject: [PATCH 0818/1680] add fix distclean and maintainer-clean targets to CHANGES file git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11975 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index a58cd68d3..f85338ed1 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,9 @@ Version 2.0.0 (in progress) ============================ +2010-04-03: wsfulton + Fix Makefile targets: distclean and maintainer-clean + 2010-04-02: wsfulton [Lua] Fix char pointers, wchar_t pointers and char arrays so that nil can be passed as a valid value. Bug reported by Gedalia Pasternak. From 964382336ee3058ab1544709367f22ae2483899c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 4 Apr 2010 20:37:20 +0000 Subject: [PATCH 0819/1680] remove std::map specializations - not needed since the typemap matching rules were changed to follow type deducation used in template specialization git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11978 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/csharp/std_map.i | 6 +- Lib/java/std_map.i | 122 ++++------------------------------------- Lib/ocaml/std_map.i | 121 ++++------------------------------------ Lib/perl5/std_map.i | 122 ++++------------------------------------- Lib/php/std_map.i | 128 ++++--------------------------------------- Lib/tcl/std_map.i | 122 ++++------------------------------------- 6 files changed, 53 insertions(+), 568 deletions(-) diff --git a/Lib/csharp/std_map.i b/Lib/csharp/std_map.i index 24efbe26f..2db6ddf5b 100644 --- a/Lib/csharp/std_map.i +++ b/Lib/csharp/std_map.i @@ -296,14 +296,14 @@ namespace std { // 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 +#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 +#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 +#warning "specialize_std_map_on_both ignored - macro is deprecated and no longer necessary" %enddef diff --git a/Lib/java/std_map.i b/Lib/java/std_map.i index a7020532c..e7812f38a 100644 --- a/Lib/java/std_map.i +++ b/Lib/java/std_map.i @@ -58,119 +58,17 @@ namespace std { } }; +// 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 - // specializations for built-ins +%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_key(K,CHECK,CONVERT_FROM,CONVERT_TO) - - template class map { - // add typemaps here - public: - map(); - map(const map &); - - unsigned int size() const; - bool empty() const; - void clear(); - %extend { - T& get(K key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); - if (i != self->end()) - return i->second; - else - throw std::out_of_range("key not found"); - } - void set(K key, const T& x) { - (*self)[key] = x; - } - void del(K key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); - if (i != self->end()) - self->erase(i); - else - throw std::out_of_range("key not found"); - } - bool has_key(K key) { - std::map::iterator i = self->find(key); - return i != self->end(); - } - } - }; - %enddef - - %define specialize_std_map_on_value(T,CHECK,CONVERT_FROM,CONVERT_TO) - template class map { - // add typemaps here - public: - map(); - map(const map &); - - unsigned int size() const; - bool empty() const; - void clear(); - %extend { - T get(const K& key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); - if (i != self->end()) - return i->second; - else - throw std::out_of_range("key not found"); - } - void set(const K& key, T x) { - (*self)[key] = x; - } - void del(const K& key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); - if (i != self->end()) - self->erase(i); - else - throw std::out_of_range("key not found"); - } - bool has_key(const K& key) { - std::map::iterator i = self->find(key); - return i != self->end(); - } - } - }; - %enddef - - %define specialize_std_map_on_both(K,CHECK_K,CONVERT_K_FROM,CONVERT_K_TO, - T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO) - template<> class map { - // add typemaps here - public: - map(); - map(const map &); - - unsigned int size() const; - bool empty() const; - void clear(); - %extend { - T get(K key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); - if (i != self->end()) - return i->second; - else - throw std::out_of_range("key not found"); - } - void set(K key, T x) { - (*self)[key] = x; - } - void del(K key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); - if (i != self->end()) - self->erase(i); - else - throw std::out_of_range("key not found"); - } - bool has_key(K key) { - std::map::iterator i = self->find(key); - return i != self->end(); - } - } - }; - %enddef - - // add specializations here +%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 } diff --git a/Lib/ocaml/std_map.i b/Lib/ocaml/std_map.i index d7bf1e0f7..924120f24 100644 --- a/Lib/ocaml/std_map.i +++ b/Lib/ocaml/std_map.i @@ -53,118 +53,17 @@ namespace std { } }; +// 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 - // specializations for built-ins +%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_key(K,CHECK,CONVERT_FROM,CONVERT_TO) +%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 - template class map { - // add typemaps here - public: - map(); - map(const map &); - - unsigned int size() const; - bool empty() const; - void clear(); - %extend { - T& get(K key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); - if (i != self->end()) - return i->second; - else - throw std::out_of_range("key not found"); - } - void set(K key, const T& x) { - (*self)[key] = x; - } - void del(K key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); - if (i != self->end()) - self->erase(i); - else - throw std::out_of_range("key not found"); - } - bool has_key(K key) { - std::map::iterator i = self->find(key); - return i != self->end(); - } - } - }; - %enddef - - %define specialize_std_map_on_value(T,CHECK,CONVERT_FROM,CONVERT_TO) - template class map { - // add typemaps here - public: - map(); - map(const map &); - - unsigned int size() const; - bool empty() const; - void clear(); - %extend { - T get(const K& key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); - if (i != self->end()) - return i->second; - else - throw std::out_of_range("key not found"); - } - void set(const K& key, T x) { - (*self)[key] = x; - } - void del(const K& key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); - if (i != self->end()) - self->erase(i); - else - throw std::out_of_range("key not found"); - } - bool has_key(const K& key) { - std::map::iterator i = self->find(key); - return i != self->end(); - } - } - }; - %enddef - - %define specialize_std_map_on_both(K,CHECK_K,CONVERT_K_FROM,CONVERT_K_TO, - T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO) - template<> class map { - // add typemaps here - public: - map(); - map(const map &); - - unsigned int size() const; - bool empty() const; - void clear(); - %extend { - T get(K key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); - if (i != self->end()) - return i->second; - else - throw std::out_of_range("key not found"); - } - void set(K key, T x) { - (*self)[key] = x; - } - void del(K key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); - if (i != self->end()) - self->erase(i); - else - throw std::out_of_range("key not found"); - } - bool has_key(K key) { - std::map::iterator i = self->find(key); - return i != self->end(); - } - } - }; - %enddef - - // add specializations here } diff --git a/Lib/perl5/std_map.i b/Lib/perl5/std_map.i index ab0d3816d..898c84484 100644 --- a/Lib/perl5/std_map.i +++ b/Lib/perl5/std_map.i @@ -54,119 +54,17 @@ namespace std { } }; +// 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 - // specializations for built-ins +%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_key(K,CHECK,CONVERT_FROM,CONVERT_TO) - - template class map { - // add typemaps here - public: - map(); - map(const map &); - - unsigned int size() const; - bool empty() const; - void clear(); - %extend { - T& get(K key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); - if (i != self->end()) - return i->second; - else - throw std::out_of_range("key not found"); - } - void set(K key, const T& x) { - (*self)[key] = x; - } - void del(K key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); - if (i != self->end()) - self->erase(i); - else - throw std::out_of_range("key not found"); - } - bool has_key(K key) { - std::map::iterator i = self->find(key); - return i != self->end(); - } - } - }; - %enddef - - %define specialize_std_map_on_value(T,CHECK,CONVERT_FROM,CONVERT_TO) - template class map { - // add typemaps here - public: - map(); - map(const map &); - - unsigned int size() const; - bool empty() const; - void clear(); - %extend { - T get(const K& key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); - if (i != self->end()) - return i->second; - else - throw std::out_of_range("key not found"); - } - void set(const K& key, T x) { - (*self)[key] = x; - } - void del(const K& key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); - if (i != self->end()) - self->erase(i); - else - throw std::out_of_range("key not found"); - } - bool has_key(const K& key) { - std::map::iterator i = self->find(key); - return i != self->end(); - } - } - }; - %enddef - - %define specialize_std_map_on_both(K,CHECK_K,CONVERT_K_FROM,CONVERT_K_TO, - T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO) - template<> class map { - // add typemaps here - public: - map(); - map(const map &); - - unsigned int size() const; - bool empty() const; - void clear(); - %extend { - T get(K key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); - if (i != self->end()) - return i->second; - else - throw std::out_of_range("key not found"); - } - void set(K key, T x) { - (*self)[key] = x; - } - void del(K key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); - if (i != self->end()) - self->erase(i); - else - throw std::out_of_range("key not found"); - } - bool has_key(K key) { - std::map::iterator i = self->find(key); - return i != self->end(); - } - } - }; - %enddef - - // add specializations here +%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 } diff --git a/Lib/php/std_map.i b/Lib/php/std_map.i index b6b417da7..ff74b7b0b 100644 --- a/Lib/php/std_map.i +++ b/Lib/php/std_map.i @@ -56,125 +56,17 @@ namespace std { } }; +// 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 - // specializations for built-ins +%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_key(K,CHECK,CONVERT_FROM,CONVERT_TO) - - template class map { - // add typemaps here - public: - map(); - map(const map &); - - unsigned int size() const; - void clear(); - %extend { - T& get(K key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); - if (i != self->end()) - return i->second; - else - throw std::out_of_range("key not found"); - } - void set(K key, const T& x) { - (*self)[key] = x; - } - void del(K key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); - if (i != self->end()) - self->erase(i); - else - throw std::out_of_range("key not found"); - } - bool has_key(K key) { - std::map::iterator i = self->find(key); - return i != self->end(); - } - bool is_empty() const { - return self->empty(); - } - } - }; - %enddef - - %define specialize_std_map_on_value(T,CHECK,CONVERT_FROM,CONVERT_TO) - template class map { - // add typemaps here - public: - map(); - map(const map &); - - unsigned int size() const; - void clear(); - %extend { - T get(const K& key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); - if (i != self->end()) - return i->second; - else - throw std::out_of_range("key not found"); - } - void set(const K& key, T x) { - (*self)[key] = x; - } - void del(const K& key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); - if (i != self->end()) - self->erase(i); - else - throw std::out_of_range("key not found"); - } - bool has_key(const K& key) { - std::map::iterator i = self->find(key); - return i != self->end(); - } - bool is_empty() const { - return self->empty(); - } - } - }; - %enddef - - %define specialize_std_map_on_both(K,CHECK_K,CONVERT_K_FROM,CONVERT_K_TO, - T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO) - template<> class map { - // add typemaps here - public: - map(); - map(const map &); - - unsigned int size() const; - void clear(); - %extend { - T get(K key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); - if (i != self->end()) - return i->second; - else - throw std::out_of_range("key not found"); - } - void set(K key, T x) { - (*self)[key] = x; - } - void del(K key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); - if (i != self->end()) - self->erase(i); - else - throw std::out_of_range("key not found"); - } - bool has_key(K key) { - std::map::iterator i = self->find(key); - return i != self->end(); - } - bool is_empty() const { - return self->empty(); - } - } - }; - %enddef - - // add specializations here +%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 } diff --git a/Lib/tcl/std_map.i b/Lib/tcl/std_map.i index 9d27e0f39..e36cc96f2 100644 --- a/Lib/tcl/std_map.i +++ b/Lib/tcl/std_map.i @@ -55,119 +55,17 @@ namespace std { } }; +// 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 - // specializations for built-ins +%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_key(K,CHECK,CONVERT_FROM,CONVERT_TO) - - template class map { - // add typemaps here - public: - map(); - map(const map &); - - unsigned int size() const; - bool empty() const; - void clear(); - %extend { - T& get(K key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); - if (i != self->end()) - return i->second; - else - throw std::out_of_range("key not found"); - } - void set(K key, const T& x) { - (*self)[key] = x; - } - void del(K key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); - if (i != self->end()) - self->erase(i); - else - throw std::out_of_range("key not found"); - } - bool has_key(K key) { - std::map::iterator i = self->find(key); - return i != self->end(); - } - } - }; - %enddef - - %define specialize_std_map_on_value(T,CHECK,CONVERT_FROM,CONVERT_TO) - template class map { - // add typemaps here - public: - map(); - map(const map &); - - unsigned int size() const; - bool empty() const; - void clear(); - %extend { - T get(const K& key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); - if (i != self->end()) - return i->second; - else - throw std::out_of_range("key not found"); - } - void set(const K& key, T x) { - (*self)[key] = x; - } - void del(const K& key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); - if (i != self->end()) - self->erase(i); - else - throw std::out_of_range("key not found"); - } - bool has_key(const K& key) { - std::map::iterator i = self->find(key); - return i != self->end(); - } - } - }; - %enddef - - %define specialize_std_map_on_both(K,CHECK_K,CONVERT_K_FROM,CONVERT_K_TO, - T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO) - template<> class map { - // add typemaps here - public: - map(); - map(const map &); - - unsigned int size() const; - bool empty() const; - void clear(); - %extend { - T get(K key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); - if (i != self->end()) - return i->second; - else - throw std::out_of_range("key not found"); - } - void set(K key, T x) { - (*self)[key] = x; - } - void del(K key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); - if (i != self->end()) - self->erase(i); - else - throw std::out_of_range("key not found"); - } - bool has_key(K key) { - std::map::iterator i = self->find(key); - return i != self->end(); - } - } - }; - %enddef - - // add specializations here +%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 85ac524d37c88493dda55df827ad4d50791c0e3a Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 4 Apr 2010 22:27:10 +0000 Subject: [PATCH 0820/1680] formatting change of const _TP * -> _TP const* merely to aid difference debugging with vector of non-const pointers std::vector specialization git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11979 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/std/std_vector.i | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Lib/std/std_vector.i b/Lib/std/std_vector.i index b0bb714d4..147f7449d 100644 --- a/Lib/std/std_vector.i +++ b/Lib/std/std_vector.i @@ -138,11 +138,11 @@ namespace std { // const pointer specialization // *** template - class vector { + class vector<_Tp const *, _Alloc > { public: typedef size_t size_type; typedef ptrdiff_t difference_type; - typedef const _Tp * value_type; + typedef _Tp const * value_type; typedef value_type* pointer; typedef const value_type* const_pointer; typedef value_type reference; @@ -151,32 +151,32 @@ namespace std { %traits_swigtype(_Tp); - %fragment(SWIG_Traits_frag(std::vector), "header", + %fragment(SWIG_Traits_frag(std::vector<_Tp const*, _Alloc >), "header", fragment=SWIG_Traits_frag(_Tp), fragment="StdVectorTraits") { namespace swig { - template <> struct traits > { + template <> struct traits > { typedef value_category category; static const char* type_name() { - return "std::vector"; + return "std::vector<" #_Tp " const*," #_Alloc " >"; } }; } } - %typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector); + %typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector<_Tp const*, _Alloc >); #ifdef %swig_vector_methods_val // Add swig/language extra methods - %swig_vector_methods_val(std::vector); + %swig_vector_methods_val(std::vector<_Tp const*, _Alloc >); #endif %std_vector_methods_val(vector); }; - // *** // *** // bool specialization + // *** template class vector { From a743d54665ccb154be5c999c38474393d724e046 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 8 Apr 2010 06:46:18 +0000 Subject: [PATCH 0821/1680] Fix segfault when using Python's -threads options and exceptions are thrown git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11980 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++ Examples/test-suite/common.mk | 1 + .../python/threads_exception_runme.py | 36 +++++++++++++ Examples/test-suite/threads_exception.i | 54 +++++++++++++++++++ Source/Modules/emit.cxx | 34 +++++++----- Source/Modules/python.cxx | 19 ++++--- 6 files changed, 127 insertions(+), 21 deletions(-) create mode 100755 Examples/test-suite/python/threads_exception_runme.py create mode 100755 Examples/test-suite/threads_exception.i diff --git a/CHANGES.current b/CHANGES.current index f85338ed1..ab92524ca 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,10 @@ Version 2.0.0 (in progress) ============================ +2010-04-03: wsfulton + [Python] Fix exceptions being thrown with the -threads option based on patch from Arto Vuori. + Fixes bug #2818499. + 2010-04-03: wsfulton Fix Makefile targets: distclean and maintainer-clean diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index db162487f..a902166b5 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -375,6 +375,7 @@ CPP_TEST_CASES += \ template_virtual \ template_whitespace \ threads \ + threads_exception \ throw_exception \ typedef_array_member \ typedef_class \ diff --git a/Examples/test-suite/python/threads_exception_runme.py b/Examples/test-suite/python/threads_exception_runme.py new file mode 100755 index 000000000..9fbc6a9b2 --- /dev/null +++ b/Examples/test-suite/python/threads_exception_runme.py @@ -0,0 +1,36 @@ +import threads_exception + +t = threads_exception.Test() +try: + t.unknown() +except RuntimeError,e: + pass + +try: + t.simple() +except RuntimeError,e: + if e.args[0] != 37: + raise RuntimeError + +try: + t.message() +except RuntimeError,e: + if e.args[0] != "I died.": + raise RuntimeError + +try: + t.hosed() +except threads_exception.Exc,e: + if e.code != 42: + raise RuntimeError + if e.msg != "Hosed": + raise RuntimeError + +for i in range(1,4): + try: + t.multi(i) + except RuntimeError,e: + pass + except threads_exception.Exc,e: + pass + diff --git a/Examples/test-suite/threads_exception.i b/Examples/test-suite/threads_exception.i new file mode 100755 index 000000000..9f275bd6a --- /dev/null +++ b/Examples/test-suite/threads_exception.i @@ -0,0 +1,54 @@ +// Throw a lot of exceptions + +// The Python runtime tests were previously failing with the -threads option on Windows due to SWIG_PYTHON_THREAD_BEGIN_ALLOW not being within the try block. + +%module(threads="1") threads_exception + +%{ +struct A {}; +%} + +%inline %{ +#include + +#if defined(_MSC_VER) + #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) +#endif + +class Exc { +public: + Exc(int c, const char *m) { + code = c; + strncpy(msg,m,255); + } + int code; + char msg[256]; +}; + +class Test { +public: + int simple() throw(int) { + throw(37); + return 1; + } + int message() throw(const char *) { + throw("I died."); + return 1; + } + int hosed() throw(Exc) { + throw(Exc(42,"Hosed")); + return 1; + } + int unknown() throw(A*) { + static A a; + throw &a; + return 1; + } + int multi(int x) throw(int, const char *, Exc) { + if (x == 1) throw(37); + if (x == 2) throw("Bleah!"); + if (x == 3) throw(Exc(42,"No-go-diggy-die")); + return 1; + } +}; +%} diff --git a/Source/Modules/emit.cxx b/Source/Modules/emit.cxx index ed75e4d74..0c6c6515f 100644 --- a/Source/Modules/emit.cxx +++ b/Source/Modules/emit.cxx @@ -462,32 +462,40 @@ String *emit_action(Node *n) { Printf(eaction, "try {\n"); } + String *preaction = Getattr(n, "wrap:preaction"); + if (preaction) + Printv(eaction, preaction, NIL); + Printv(eaction, action, NIL); + String *postaction = Getattr(n, "wrap:postaction"); + if (postaction) + Printv(eaction, postaction, NIL); + if (catchlist) { int unknown_catch = 0; Printf(eaction, "}\n"); for (Parm *ep = catchlist; ep; ep = nextSibling(ep)) { String *em = Swig_typemap_lookup("throws", ep, "_e", 0); if (em) { - SwigType *et = Getattr(ep, "type"); - SwigType *etr = SwigType_typedef_resolve_all(et); - if (SwigType_isreference(etr) || SwigType_ispointer(etr) || SwigType_isarray(etr)) { - Printf(eaction, "catch(%s) {", SwigType_str(et, "_e")); - } else if (SwigType_isvarargs(etr)) { - Printf(eaction, "catch(...) {"); - } else { - Printf(eaction, "catch(%s) {", SwigType_str(et, "&_e")); - } - Printv(eaction, em, "\n", NIL); - Printf(eaction, "}\n"); + SwigType *et = Getattr(ep, "type"); + SwigType *etr = SwigType_typedef_resolve_all(et); + if (SwigType_isreference(etr) || SwigType_ispointer(etr) || SwigType_isarray(etr)) { + Printf(eaction, "catch(%s) {", SwigType_str(et, "_e")); + } else if (SwigType_isvarargs(etr)) { + Printf(eaction, "catch(...) {"); + } else { + Printf(eaction, "catch(%s) {", SwigType_str(et, "&_e")); + } + Printv(eaction, em, "\n", NIL); + Printf(eaction, "}\n"); } else { Swig_warning(WARN_TYPEMAP_THROW, Getfile(n), Getline(n), "No 'throws' typemap defined for exception type '%s'\n", SwigType_str(Getattr(ep, "type"), 0)); - unknown_catch = 1; + unknown_catch = 1; } } if (unknown_catch) { - Printf(eaction, "catch(...) { throw; }\n"); + Printf(eaction, "catch(...) { throw; }\n"); } } diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 3215d29aa..3639efe86 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -211,6 +211,7 @@ public: virtual void thread_begin_allow(Node *n, String *f) { if (!GetFlag(n, "feature:nothreadallow")) { String *bb = Getattr(n, "feature:threadbeginallow"); + Append(f, "{\n"); if (bb) { Append(f, bb); } else { @@ -222,11 +223,13 @@ public: virtual void thread_end_allow(Node *n, String *f) { if (!GetFlag(n, "feature:nothreadallow")) { String *eb = Getattr(n, "feature:threadendallow"); + Append(f, "\n"); if (eb) { Append(f, eb); } else { - Append(f, "SWIG_PYTHON_THREAD_END_ALLOW;\n"); + Append(f, "SWIG_PYTHON_THREAD_END_ALLOW;"); } + Append(f, "\n}"); } } @@ -2200,8 +2203,13 @@ public: Append(f->code, "try {\n"); } else { if (allow_thread) { - Append(f->code, "{\n"); - thread_begin_allow(n, f->code); + String *preaction = NewString(""); + thread_begin_allow(n, preaction); + Setattr(n,"wrap:preaction", preaction); + + String *postaction = NewString(""); + thread_end_allow(n, postaction); + Setattr(n,"wrap:postaction", postaction); } } @@ -2214,11 +2222,6 @@ public: Append(actioncode, "} catch (Swig::DirectorException&) {\n"); Append(actioncode, " SWIG_fail;\n"); Append(actioncode, "}\n"); - } else { - if (allow_thread) { - thread_end_allow(n, actioncode); - Append(actioncode, "}\n"); - } } /* This part below still needs cleanup */ From edd0a06409f019d6528a346b947ae3b21748e37b Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 8 Apr 2010 20:22:03 +0000 Subject: [PATCH 0822/1680] fix 0 sized array compile error in test git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11981 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/constant_expr.i | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Examples/test-suite/constant_expr.i b/Examples/test-suite/constant_expr.i index 47db2d026..8e5c8aee6 100644 --- a/Examples/test-suite/constant_expr.i +++ b/Examples/test-suite/constant_expr.i @@ -5,7 +5,7 @@ /* % didn't work in SWIG 1.3.40 and earlier. */ const int X = 123%7; -#define FOO 12 % 6 -double d_array[12 % 6]; +#define FOO 12 % 9 +double d_array[12 % 9]; %} From 01c4ab6baf71cf7a7c73bec1497136fe5d55315d Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 9 Apr 2010 21:40:23 +0000 Subject: [PATCH 0823/1680] Fix some terminology used in C++ template partial specialization and new typemap matching rules git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11982 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++-- Source/CParse/templ.c | 4 ++-- Source/Swig/stype.c | 38 ++++++++++++++++++++------------------ Source/Swig/swig.h | 2 +- Source/Swig/typemap.c | 2 +- 5 files changed, 26 insertions(+), 24 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index ab92524ca..ca74f192f 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -15,10 +15,10 @@ Version 2.0.0 (in progress) 2010-04-01: wsfulton Numerous subtle typemap matching rule fixes when using the default type. The typemap matching rules are to take a type and find the best default typemap (SWIGTYPE, SWIGTYPE* etc), - then look for the next best match by reducing the chosen default type. The type reduction + then look for the next best match by reducing the chosen default type. The type deduction now follows C++ template partial specialization matching rules. - Below are the set of changes made showing the default type reduction + Below are the set of changes made showing the default type deduction along with the old reduced type and the new version of the reduced type: SWIGTYPE const &[ANY] diff --git a/Source/CParse/templ.c b/Source/CParse/templ.c index 8d77cb0ee..503f725cb 100644 --- a/Source/CParse/templ.c +++ b/Source/CParse/templ.c @@ -432,7 +432,7 @@ typedef enum { ExactNoMatch = -2, PartiallySpecializedNoMatch = -1, PartiallySpe * 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'. + * template parameter type. Typedef reduce 'partial_parm_type' to see if it matches 'type'. * * type - template parameter type to match against * partial_parm_type - partially specialized template type - a possible match @@ -664,7 +664,7 @@ static Node *template_locate(String *name, Parm *tparms, Symtab *tscope) { 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 + * Exact matches rank the highest and deduced parameters are ranked by how specialized they are, eg looking for * a match to const int *, the following rank (highest to lowest): * const int * (exact match) * const T * diff --git a/Source/Swig/stype.c b/Source/Swig/stype.c index 7594a6ad6..533b8195f 100644 --- a/Source/Swig/stype.c +++ b/Source/Swig/stype.c @@ -290,7 +290,7 @@ int SwigType_issimple(SwigType *t) { * Enums: enum SWIGTYPE * Types: SWIGTYPE * - * Examples (also see SwigType_default_reduce): + * Examples (also see SwigType_default_deduce): * * int [2][4] * a(2).a(4).int @@ -354,17 +354,19 @@ SwigType *SwigType_default_create(SwigType *ty) { } /* ----------------------------------------------------------------------------- - * SwigType_default_reduce() + * SwigType_default_deduce() * - * This function implements type reduction used in the typemap matching rules - * and is very close to the type reduction used in partial template specialization. + * This function implements type deduction used in the typemap matching rules + * and is very close to the type deduction used in partial template specialization + * matching in that the most specialized type is always chosen. * SWIGTYPE is used as the generic type. The basic idea is to repeatedly call - * this function to reduce the type until it is reduced to nothing. + * this function to find a deduced type unless until nothing matches. * * The type t must have already been converted to the default type via a call to * SwigType_default_create() before calling this function. * - * Example reductions (matching the examples described in SwigType_default_create): + * Example deductions (matching the examples described in SwigType_default_create), + * where the the most specialized matches are highest in the list: * * a(ANY).a(ANY).SWIGTYPE * a(ANY).a().SWIGTYPE @@ -385,7 +387,7 @@ SwigType *SwigType_default_create(SwigType *ty) { * SWIGTYPE * ----------------------------------------------------------------------------- */ -SwigType *SwigType_default_reduce(SwigType *t) { +SwigType *SwigType_default_deduce(SwigType *t) { SwigType *r = NewStringEmpty(); List *l; Iterator it; @@ -402,37 +404,37 @@ SwigType *SwigType_default_reduce(SwigType *t) { String *subtype = Getitem(l, numitems-2); /* last but one */ if (SwigType_isarray(subtype)) { if (is_enum) { - /* enum reduction, enum SWIGTYPE => SWIGTYPE */ + /* enum deduction, enum SWIGTYPE => SWIGTYPE */ Setitem(l, numitems-1, NewString("SWIGTYPE")); } else { - /* array reduction, a(ANY). => a(). => p. */ - String *reduced_subtype = 0; + /* array deduction, a(ANY). => a(). => p. */ + String *deduced_subtype = 0; if (Strcmp(subtype, "a().") == 0) { - reduced_subtype = NewString("p."); + deduced_subtype = NewString("p."); } else if (Strcmp(subtype, "a(ANY).") == 0) { - reduced_subtype = NewString("a()."); + deduced_subtype = NewString("a()."); } else { assert(0); } - Setitem(l, numitems-2, reduced_subtype); + Setitem(l, numitems-2, deduced_subtype); } } else if (SwigType_ismemberpointer(subtype)) { - /* member pointer reduction, m(CLASS). => p. */ + /* member pointer deduction, m(CLASS). => p. */ Setitem(l, numitems-2, NewString("p.")); } else if (is_enum && !SwigType_isqualifier(subtype)) { - /* enum reduction, enum SWIGTYPE => SWIGTYPE */ + /* enum deduction, enum SWIGTYPE => SWIGTYPE */ Setitem(l, numitems-1, NewString("SWIGTYPE")); } else { - /* simple type reduction, eg, r.p.p. => r.p. */ + /* simple type deduction, eg, r.p.p. => r.p. */ /* also function pointers eg, p.f(ANY). => p. */ Delitem(l, numitems-2); } } else { if (is_enum) { - /* enum reduction, enum SWIGTYPE => SWIGTYPE */ + /* enum deduction, enum SWIGTYPE => SWIGTYPE */ Setitem(l, numitems-1, NewString("SWIGTYPE")); } else { - /* delete the only item, we are done with reduction */ + /* delete the only item, we are done with deduction */ Delitem(l, 0); } } diff --git a/Source/Swig/swig.h b/Source/Swig/swig.h index cf94acfa8..2b2c7f4cf 100644 --- a/Source/Swig/swig.h +++ b/Source/Swig/swig.h @@ -173,7 +173,7 @@ extern "C" { extern SwigType *SwigType_array_type(SwigType *t); extern String *SwigType_default(SwigType *t); extern SwigType *SwigType_default_create(SwigType *ty); - extern SwigType *SwigType_default_reduce(SwigType *t); + extern SwigType *SwigType_default_deduce(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); diff --git a/Source/Swig/typemap.c b/Source/Swig/typemap.c index cc32780c5..37f8c3d82 100644 --- a/Source/Swig/typemap.c +++ b/Source/Swig/typemap.c @@ -787,7 +787,7 @@ static Hash *typemap_search(const_String_or_char_ptr tmap_method, SwigType *type goto ret_result; { - SwigType *nprim = SwigType_default_reduce(primitive); + SwigType *nprim = SwigType_default_deduce(primitive); Delete(primitive); primitive = nprim; } From 00b1468091f3e14d7775f9b96f5b973a182ee2ba Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 9 Apr 2010 21:41:09 +0000 Subject: [PATCH 0824/1680] Update typemaps chapter and document new default typemap matching rules git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11983 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Typemaps.html | 208 +++++++++++++++++++++------------------ 1 file changed, 111 insertions(+), 97 deletions(-) diff --git a/Doc/Manual/Typemaps.html b/Doc/Manual/Typemaps.html index dee2bcf7f..066d9d79e 100644 --- a/Doc/Manual/Typemaps.html +++ b/Doc/Manual/Typemaps.html @@ -580,14 +580,14 @@ suppose you had a declaration like this,
        -Foo *make_Foo();
        +Foo *make_Foo(int n);
         

        -and you wanted to tell SWIG that make_Foo() returned a newly +and you wanted to tell SWIG that make_Foo(int n) returned a newly allocated object (for the purposes of providing better memory -management). Clearly, this property of make_Foo() is +management). Clearly, this property of make_Foo(int n) is not a property that would be associated with the datatype Foo * by itself. Therefore, a completely different SWIG customization mechanism (%feature) is used for this purpose. Consult the std::string and Foo::string).

        It should be noted that for scoping to work, SWIG has to know that string is a typename defined -within a particular namespace. In this example, this is done using the class declaration class string. +within a particular namespace. In this example, this is done using the forward class declaration class string.

        10.3 Pattern matching rules

        @@ -1085,16 +1085,16 @@ shows how some of the basic rules are applied: ... typemap 5 } -void A(int *x); // int *x rule (typemap 1) -void B(int *y); // int * rule (typemap 2) -void C(const int *x); // int *x rule (typemap 1) -void D(const int *z); // int * rule (typemap 3) -void E(int x[4]); // int [4] rule (typemap 4) -void F(int x[1000]); // int [ANY] rule (typemap 5) +void A(int *x); // int *x rule (typemap 1) +void B(int *y); // int * rule (typemap 2) +void C(const int *x); // int *x rule (typemap 1) +void D(const int *z); // const int *z rule (typemap 3) +void E(int x[4]); // int [4] rule (typemap 4) +void F(int x[1000]); // int [ANY] rule (typemap 5)
      -

      10.3.2 Typedef reductions

      +

      10.3.2 Typedef reductions matching

      @@ -1269,58 +1269,77 @@ void go(Struct aStruct); -

      10.3.3 Default typemaps

      +

      10.3.3 Default typemap matching rules

      +

      +If the basic pattern matching rules result in no match being made, even after typedef reductions, +the default typemap matching rules are used to look for a suitable typemap match. +These rules match a generic typemap based on the reserved SWIGTYPE base type. +For example pointers will use SWIGTYPE * and references will use SWIGTYPE &. +More precisely, the rules are based on the C++ template partial specialization matching rules used +by C++ compilers when looking for an appropriate partial template specialization. +This means that a match is chosen from the most specialized set of generic typemap types available. For example, +when looking for a match to int const *, the rules will prefer to match SWIGTYPE const * +if available before matching SWIGTYPE *, before matching SWIGTYPE. +

      +

      Most SWIG language modules use typemaps to define the default behavior of the C primitive types. This -is entirely straightforward. For example, a set of typemaps are written like this: +is entirely straightforward. For example, a set of typemaps for primitives marshalled by value or +const reference are written like this:

      -%typemap(in) int   "convert an int";
      -%typemap(in) short "convert a short";
      -%typemap(in) float "convert a float";
      +%typemap(in) int           "... convert to int ...";
      +%typemap(in) short         "... convert to short ...";
      +%typemap(in) float         "... convert to float ...";
      +...
      +%typemap(in) const int &   "... convert ...";
      +%typemap(in) const short & "... convert ...";
      +%typemap(in) const float & "... convert ...";
       ...
       

      Since typemap matching follows all typedef declarations, any sort of type that is -mapped to a primitive type through typedef will be picked up by one of these primitive typemaps. +mapped to a primitive type by value or const reference through typedef will be picked +up by one of these primitive typemaps. +Most language modules also define typemaps for char pointers and char arrays to handle strings, +so these non-default types will also be used in preference as the basic typemap matching rules +provide a better match than the default typemap matching rules.

      -The default behavior for pointers, arrays, references, and other kinds of types are handled by -specifying rules for variations of the reserved SWIGTYPE type. For example: +Below is a list of the typical default types supplied by language modules, showing what the "in" typemap would look like:

      -%typemap(in) SWIGTYPE *            { ... default pointer handling ...         }
      -%typemap(in) SWIGTYPE &            { ... default reference handling ...       }
      -%typemap(in) SWIGTYPE []           { ... default array handling ...           }
      -%typemap(in) enum SWIGTYPE         { ... default handling for enum values ... }
      -%typemap(in) SWIGTYPE (CLASS::*)   { ... default pointer member handling ...  } 
      +%typemap(in) SWIGTYPE &            { ... default reference handling ...                       };
      +%typemap(in) SWIGTYPE *            { ... default pointer handling ...                         };
      +%typemap(in) SWIGTYPE *const       { ... default pointer const handling ...                   };
      +%typemap(in) SWIGTYPE *const&      { ... default pointer const reference handling ...         };
      +%typemap(in) SWIGTYPE[ANY]         { ... 1D fixed size arrays handlling ...                   };
      +%typemap(in) SWIGTYPE []           { ... unknown sized array handling ...                     };
      +%typemap(in) enum SWIGTYPE         { ... default handling for enum values ...                 };
      +%typemap(in) const enum SWIGTYPE & { ... default handling for const enum reference values ... };
      +%typemap(in) SWIGTYPE (CLASS::*)   { ... default pointer member handling ...                  };
      +%typemap(in) SWIGTYPE              { ... simple default handling ...                          };
       

      -These rules match any kind of pointer, reference, or array--even when -multiple levels of indirection or multiple array dimensions are used. -Therefore, if you wanted to change SWIG's default handling for all -types of pointers, you would simply redefine the rule for SWIGTYPE -*. -

      - -

      -Finally, the following typemap rule is used to match against simple types that don't match any other rules: +If you wanted to change SWIG's default handling for +simple pointers, you would simply redefine the rule for SWIGTYPE *. +Note, the simple default typemap rule is used to match against simple types that don't match any other rules:

      -%typemap(in) SWIGTYPE   { ... handle an unknown type ... }
      +%typemap(in) SWIGTYPE              { ... simple default handling ...                          } 
       
      @@ -1339,7 +1358,7 @@ double dot_product(Vector a, Vector b);

      The Vector type will usually just get matched against SWIGTYPE. The default implementation of SWIGTYPE is -to convert the value into pointers (as described in chapter 3). +to convert the value into pointers (as described in this earlier section).

      @@ -1351,34 +1370,7 @@ objects into strings instead of converting them to pointers.

      -The best way to explore the default typemaps is to look at the ones -already defined for a particular language module. Typemaps -definitions are usually found in the SWIG library in a file such as -python.swg, tcl8.swg, etc. -

      - -

      10.3.4 Mixed default typemaps

      - - -

      -The default typemaps described above can be mixed with const and with each other. -For example the SWIGTYPE * typemap is for default pointer handling, but if a const SWIGTYPE * typemap -is defined it will be used instead for constant pointers. Some further examples follow: -

      - -
      -
      -%typemap(in) enum SWIGTYPE &        { ... enum references ...                       }
      -%typemap(in) const enum SWIGTYPE &  { ... const enum references ...                 }
      -%typemap(in) SWIGTYPE *&            { ... pointers passed by reference ...          }
      -%typemap(in) SWIGTYPE * const &     { ... constant pointers passed by reference ... }
      -%typemap(in) SWIGTYPE[ANY][ANY]     { ... 2D arrays ...                             }
      -
      -
      - -

      -Note that the the typedef reduction described earlier is also used with these mixed default typemaps. -For example, say the following typemaps are defined and SWIG is looking for the best match for the enum shown below: +Let's consider an example where the following typemaps are defined and SWIG is looking for the best match for the enum shown below:

      @@ -1397,12 +1389,22 @@ const Hello &hi;

      The typemap at the top of the list will be chosen, not because it is defined first, but because it is the closest match for the type being wrapped. If any of the typemaps in the above list were not defined, then the next one on the list would have precedence. -In other words the typemap chosen is the closest explicit match.

      -Compatibility note: The mixed default typemaps were introduced in SWIG-1.3.23, but were not used much in this version. -Expect to see them being used more and more within the various libraries in later versions of SWIG. +The best way to explore the default typemaps is to look at the ones +already defined for a particular language module. Typemap +definitions are usually found in the SWIG library in a file such as +java.swg, csharp.swg etc. +However, for many of the target languages the typemaps are hidden behind complicated macros, +so the best way to view the default typemaps, or any typemaps for that matter, +is to look at the preprocessed output by running swig -E on any interface file. +Finally the best way to view the typemap matching rules in action is via the debugging typemap pattern matching options covered later on. +

      + +

      +Compatibility note: The default typemap matching rules were modified in SWIG-2.0.0 from a slightly +simpler scheme to match the current C++ template partial specialization matching rules.

      @@ -1501,9 +1503,17 @@ example.h:3: Searching for a suitable 'in' typemap for: Row4 rows[10]

      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. +As the example shows, the successful match displays the used typemap source including typemap method, type and optional name in one of these simplified formats:

      + +

        +
      • Using: %typemap(method) type name +
      • Using: %typemap(method) type name = type2 name2 +
      • Using: %apply type2 name2 { type name } +
      + +

      This information might meet your debugging needs, however, you might want to analyze further. -If you next invoke SWIG with the -E option to display the preprocessed output, and search for this particular typemap, +If you next invoke SWIG with the -E option to display the preprocessed output, and search for the particular typemap used, you'll find the full typemap contents (example shown below for Python):

      @@ -1543,7 +1553,7 @@ SWIGINTERN PyObject *_wrap_foo(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {

      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: +For example, the output for the code in the earlier multi-arguments section is as follows:

      @@ -1560,7 +1570,7 @@ 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 displays the type, and name if present, the typemap method in brackets and then the actual typemap used. +The output displays the type, and name if present, the typemap method in brackets and then the actual typemap used in the same simplified format output by the -debug-tmsearch option. Below is the output for the example code at the start of this section on debugging.

      @@ -1711,12 +1721,16 @@ Occasionally, typemap code will be specified using a few alternative forms. For %typemap(in) int %{ $1 = PyInt_AsLong($input); %} +%typemap(in, noblock=1) int { +$1 = PyInt_AsLong($input); +}

      -These two forms are mainly used for cosmetics--the specified code is not enclosed inside +These three forms are mainly used for cosmetics--the specified code is not enclosed inside a block scope when it is emitted. This sometimes results in a less complicated looking wrapper function. +Note that only the third of the three typemaps have the typemap code passed through the SWIG preprocessor.

      10.4.2 Declaring new local variables

      @@ -1845,7 +1859,7 @@ wrap_foo() {

      Some typemaps do not recognize local variables (or they may simply not -apply). At this time, only typemaps that apply to argument conversion support this. +apply). At this time, only typemaps that apply to argument conversion support this (input typemaps such as the "in" typemap).

      @@ -2262,7 +2276,7 @@ When numinputs is set to 0, the argument is effectively ignored and can The argument is still required when making the C/C++ call and the above typemap shows the value used is instead obtained from a locally declared variable called temp. Usually numinputs is not specified, whereupon the default value is 1, that is, there is a one to one mapping of the number of arguments when used from the target language to the C/C++ call. -Multi-argument typemaps provide a similar concept where the number of arguments mapped from the target language to C/C++ can be changed for more tha multiple adjacent C/C++ arguments. +Multi-argument typemaps provide a similar concept where the number of arguments mapped from the target language to C/C++ can be changed for multiple adjacent C/C++ arguments.

      @@ -2293,7 +2307,7 @@ the input argument is the correct type.

      If you define new "in" typemaps and your program uses overloaded methods, you should also define a collection of -"typecheck" typemaps. More details about this follow in a later section on "Typemaps and Overloading." +"typecheck" typemaps. More details about this follow in the Typemaps and overloading section.

      10.5.3 "out" typemap

      @@ -2441,7 +2455,7 @@ return values are often appended to return value of the function.

      -See the typemaps.i library for examples. +See the typemaps.i library file for examples.

      10.5.8 "freearg" typemap

      @@ -2766,9 +2780,8 @@ You may even get a warning message like this:

      -swig -python  example.i
      -Generating wrappers for Python
      -example.i:10.  Warning. Array member value will be read-only.
      +$ swig -python  example.i
      +example.i:10: Warning 462: Unable to set variable of type float [4].
       

      @@ -2865,7 +2878,7 @@ useless and has since been eliminated. To return structure members, simply use One particularly interesting application of typemaps is the implementation of argument constraints. This can be done with the "check" typemap. When used, this allows you to provide code for -checking the values of function arguments. For example :

      +checking the values of function arguments. For example:

       %module math
      @@ -2888,7 +2901,7 @@ your program terminated with an error message.

      This kind of checking can be particularly useful when working with -pointers. For example :

      +pointers. For example:

       %typemap(check) Vector * {
      @@ -2906,10 +2919,6 @@ a NULL pointer. As a result, SWIG can often prevent a potential
       segmentation faults or other run-time problems by raising an exception
       rather than blindly passing values to the underlying C/C++ program.

      -

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

      -

      10.7 Typemaps for multiple target languages

      @@ -2986,7 +2995,7 @@ struct XX {

      -The "out" typemap shown is the default typemap for C# when returning by objects by value. +The "out" typemap shown is the default typemap for C# when returning objects by value. When making a call to XX::create() from C#, the output is as follows:

      @@ -3108,7 +3117,7 @@ try {

      -It should be clear that the above code cannot be used as the argument to the copy constructor call, ie for the $1 substitution. +It should be clear that the above code cannot be used as the argument to the copy constructor call, that is, for the $1 substitution.

      @@ -3159,14 +3168,14 @@ list of strings like this:

      To do this, you not only need to map a list of strings to char *argv[], but the value of int argc is implicitly determined by the length of the list. Using only simple -typemaps, this type of conversion is possible, but extremely painful. Therefore, SWIG1.3 -introduces the notion of multi-argument typemaps. +typemaps, this type of conversion is possible, but extremely painful. +Multi-argument typemaps help in this situation.

      A multi-argument typemap is a conversion rule that specifies how to -convert a single object in the target language to set of -consecutive function arguments in C/C++. For example, the following multi-argument +convert a single object in the target language to a set of +consecutive function arguments in C/C++. For example, the following multi-argument maps perform the conversion described for the above example:

      @@ -3390,7 +3399,9 @@ this, you could write a multi-argument typemap like this: This kind of technique can be used to hook into scripting-language matrix packages such as Numeric Python. However, it should also be stressed that some care is in order. For example, when crossing languages you may need to worry about issues such as row-major vs. column-major -ordering (and perform conversions if needed). +ordering (and perform conversions if needed). Note that multi-argument typemaps cannot deal +with non-consecutive C/C++ arguments; a workaround such as a helper function re-ordering +the arguments to make them consecutive will need to be written.

      10.10 The run-time type checker

      @@ -3693,7 +3704,7 @@ interface file.

      Further details about the run-time type checking can be found in the documentation for individual language modules. Reading the source code may also help. The file -Lib/swigrun.swg in the SWIG library contains all of the source code for +Lib/swigrun.swg in the SWIG library contains all of the source of the generated code for type-checking. This code is also included in every generated wrapped file so you probably just look at the output of SWIG to get a better sense for how types are managed. @@ -3703,7 +3714,9 @@ managed.

      -In many target languages, SWIG fully supports C++ overloaded methods and functions. For example, +This section does not apply to the statically typed languages like Java and C#, where overloading +of the types is handled much like C++ by generating overloaded methods in the target language. +In many of the other target languages, SWIG still fully supports C++ overloaded methods and functions. For example, if you have a collection of functions like this:

      @@ -4215,7 +4228,7 @@ sure that the typemaps sharing information have exactly the same types and names

      -All the rules discussed for Typemaps apply to C++ as well as C. +All the rules discussed for typemaps apply to C++ as well as C. However in addition C++ passes an extra parameter into every non-static class method -- the this pointer. Occasionally it can be useful to apply a typemap to this pointer (for example to check @@ -4235,7 +4248,8 @@ For example, if wrapping for Java generation:

       %typemap(check) SWIGTYPE *self %{
       if (!$1) {
      -  SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "swigCPtr null");
      +  SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException,
      +    "invalid native object; delete() likely already called");
         return $null;
       }
       %}
      @@ -4260,14 +4274,14 @@ The generated code will look something like:
             "invalid native object; delete() likely already called");
           return ;
         }
      -  (arg1)->wrappedFunction(...);
      +  (arg1)->wrappedFunction(...);
       

      Note that if you have a parameter named self then it will also match the typemap. One work around is to create an interface file that wraps -the method, but give the argument a name other than self. +the method, but gives the argument a name other than self.

      10.16 Where to go for more information?

      From 9dd763d4d3edf7946d9ccb7c09db8dbecbc9c0a7 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 9 Apr 2010 22:02:09 +0000 Subject: [PATCH 0825/1680] Fix #2887254 and #2946032 - SWIG_Lua_typename using wrong stack index. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11984 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 3 +++ Lib/lua/luarun.swg | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index ca74f192f..d2f5f0372 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,9 @@ Version 2.0.0 (in progress) ============================ +2010-04-09: wsfulton + [Lua] Fix #2887254 and #2946032 - SWIG_Lua_typename using wrong stack index. + 2010-04-03: wsfulton [Python] Fix exceptions being thrown with the -threads option based on patch from Arto Vuori. Fixes bug #2818499. diff --git a/Lib/lua/luarun.swg b/Lib/lua/luarun.swg index b4e979531..89b762637 100644 --- a/Lib/lua/luarun.swg +++ b/Lib/lua/luarun.swg @@ -661,7 +661,7 @@ SWIGRUNTIME const char *SWIG_Lua_typename(lua_State *L, int tp) swig_lua_userdata* usr; if (lua_isuserdata(L,tp)) { - usr=(swig_lua_userdata*)lua_touserdata(L,1); /* get data */ + usr=(swig_lua_userdata*)lua_touserdata(L,tp); /* get data */ if (usr && usr->type && usr->type->str) return usr->type->str; return "userdata (unknown type)"; From 5a626898dfcee189183451284755422627b67aff Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 9 Apr 2010 22:22:06 +0000 Subject: [PATCH 0826/1680] Apply patch #2952374 - fix Python directors and the -nortti option. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11985 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 3 +++ Source/Modules/lang.cxx | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index d2f5f0372..c05a530c5 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,9 @@ Version 2.0.0 (in progress) ============================ +2010-04-09: wsfulton + [Python] Apply patch #2952374 - fix directors and the -nortti option. + 2010-04-09: wsfulton [Lua] Fix #2887254 and #2946032 - SWIG_Lua_typename using wrong stack index. diff --git a/Source/Modules/lang.cxx b/Source/Modules/lang.cxx index 2bfddc764..fb3d58ce4 100644 --- a/Source/Modules/lang.cxx +++ b/Source/Modules/lang.cxx @@ -1924,7 +1924,7 @@ int Language::classDirectorDisown(Node *n) { 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); + Printv(action, "{\n", "Swig::Director *director = SWIG_DIRECTOR_CAST(arg1);\n", "if (director) director->swig_disown();\n", "}\n", NULL); Setfile(disown, Getfile(n)); Setline(disown, Getline(n)); Setattr(disown, "wrap:action", action); From 242689aed533bd50acff56dcf9253697d4f32c91 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 9 Apr 2010 23:04:59 +0000 Subject: [PATCH 0827/1680] Apply Ubuntu patch to fix Mzscheme std::map wrappers git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11986 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++++ Lib/mzscheme/std_map.i | 16 ++++++++-------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index c05a530c5..296416c6b 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,10 @@ Version 2.0.0 (in progress) ============================ +2010-04-09: wsfulton + [Mzscheme] Apply Ubuntu patch to fix std::map wrappers: + https://bugs.launchpad.net/ubuntu/+source/swig1.3/+bug/203876 + 2010-04-09: wsfulton [Python] Apply patch #2952374 - fix directors and the -nortti option. diff --git a/Lib/mzscheme/std_map.i b/Lib/mzscheme/std_map.i index b2c894509..ffd76d213 100644 --- a/Lib/mzscheme/std_map.i +++ b/Lib/mzscheme/std_map.i @@ -247,8 +247,8 @@ namespace std { } Scheme_Object* keys() { Scheme_Object* result = scheme_null; - for (std::map::reverse_iterator i=$1.rbegin(); - i!=$1.rend(); ++i) { + for (std::map::reverse_iterator i=self->rbegin(); + i!=self->rend(); ++i) { K* key = new K(i->first); Scheme_Object* k = SWIG_NewPointerObj(key,$descriptor(K *), 1); result = scheme_make_pair(k,result); @@ -467,8 +467,8 @@ namespace std { } Scheme_Object* keys() { Scheme_Object* result = scheme_null; - for (std::map::reverse_iterator i=$1.rbegin(); - i!=$1.rend(); ++i) { + for (std::map::reverse_iterator i=self->rbegin(); + i!=self->rend(); ++i) { Scheme_Object* k = CONVERT_TO(i->first); result = scheme_make_pair(k,result); } @@ -679,8 +679,8 @@ namespace std { } Scheme_Object* keys() { Scheme_Object* result = scheme_null; - for (std::map::reverse_iterator i=$1.rbegin(); - i!=$1.rend(); ++i) { + for (std::map::reverse_iterator i=self->rbegin(); + i!=self->rend(); ++i) { K* key = new K(i->first); Scheme_Object* k = SWIG_NewPointerObj(key,$descriptor(K *), 1); result = scheme_make_pair(k,result); @@ -891,8 +891,8 @@ namespace std { } Scheme_Object* keys() { Scheme_Object* result = scheme_null; - for (std::map::reverse_iterator i=$1.rbegin(); - i!=$1.rend(); ++i) { + for (std::map::reverse_iterator i=self->rbegin(); + i!=self->rend(); ++i) { Scheme_Object* k = CONVERT_K_TO(i->first); result = scheme_make_pair(k,result); } From 894f89fe9735a3850b552f100f069c72bfeb7e57 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 9 Apr 2010 23:27:40 +0000 Subject: [PATCH 0828/1680] Apply Ubuntu patch to fix Ruby and std::vector wrappers with -minherit. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11987 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++++ Examples/test-suite/minherit.i | 5 +++++ Source/Modules/ruby.cxx | 6 +++++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index 296416c6b..76afade79 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,10 @@ Version 2.0.0 (in progress) ============================ +2010-04-09: wsfulton + [Ruby] Apply Ubuntu patch to fix Ruby and std::vector wrappers with -minherit. + https://bugs.launchpad.net/ubuntu/+source/swig1.3/+bug/522874 + 2010-04-09: wsfulton [Mzscheme] Apply Ubuntu patch to fix std::map wrappers: https://bugs.launchpad.net/ubuntu/+source/swig1.3/+bug/203876 diff --git a/Examples/test-suite/minherit.i b/Examples/test-suite/minherit.i index 24092b6c6..fed8b029c 100644 --- a/Examples/test-suite/minherit.i +++ b/Examples/test-suite/minherit.i @@ -75,3 +75,8 @@ int wget(SpamPtr f) { #endif + +// Was causing runtime error in Ruby +%include +%template(IntVector) std::vector; + diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx index ce89f9c63..8fc41813f 100644 --- a/Source/Modules/ruby.cxx +++ b/Source/Modules/ruby.cxx @@ -1248,7 +1248,11 @@ public: Iterator alias = First(aliases); while (alias.item) { if (Len(alias.item) > 0) { - Printv(klass->init, tab4, "rb_define_alias(", klass->vname, ", \"", alias.item, "\", \"", iname, "\");\n", NIL); + if (multipleInheritance) { + Printv(klass->init, tab4, "rb_define_alias(", klass->mImpl, ", \"", alias.item, "\", \"", iname, "\");\n", NIL); + } else { + Printv(klass->init, tab4, "rb_define_alias(", klass->vname, ", \"", alias.item, "\", \"", iname, "\");\n", NIL); + } } alias = Next(alias); } From fc3873befc38ed224161326eb268a8de1914b4de Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 9 Apr 2010 23:47:55 +0000 Subject: [PATCH 0829/1680] Update Ruby and std::vector wrappers with -minherit bug info git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11988 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index 76afade79..6db583a33 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -2,7 +2,8 @@ Version 2.0.0 (in progress) ============================ 2010-04-09: wsfulton - [Ruby] Apply Ubuntu patch to fix Ruby and std::vector wrappers with -minherit. + [Ruby] Fix #2048064 and #2408020. + Apply Ubuntu patch to fix Ruby and std::vector wrappers with -minherit. https://bugs.launchpad.net/ubuntu/+source/swig1.3/+bug/522874 2010-04-09: wsfulton From f9caea4b295aa6ac57c264e546008bd9c0b86f7a Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 10 Apr 2010 00:04:28 +0000 Subject: [PATCH 0830/1680] Add SWIG_DIRECTOR_CAST recently added to languages needing it git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11989 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/ocaml/director.swg | 2 ++ Lib/octave/octrun.swg | 2 ++ Lib/python/director.swg | 8 ++++---- Lib/ruby/director.swg | 2 ++ 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Lib/ocaml/director.swg b/Lib/ocaml/director.swg index a21f62102..77b2fd3c0 100644 --- a/Lib/ocaml/director.swg +++ b/Lib/ocaml/director.swg @@ -10,6 +10,8 @@ #include +# define SWIG_DIRECTOR_CAST(ARG) dynamic_cast(ARG) + namespace Swig { /* base class for director exceptions */ class DirectorException { diff --git a/Lib/octave/octrun.swg b/Lib/octave/octrun.swg index be2dc9653..8013dcb6e 100644 --- a/Lib/octave/octrun.swg +++ b/Lib/octave/octrun.swg @@ -106,6 +106,8 @@ SWIGRUNTIME void SWIG_Octave_SetModule(void *clientdata, swig_module_info *point typedef octave_value_list(*octave_func) (const octave_value_list &, int); class octave_swig_type; +# define SWIG_DIRECTOR_CAST(ARG) dynamic_cast(ARG) + namespace Swig { class Director; diff --git a/Lib/python/director.swg b/Lib/python/director.swg index a57df7315..8514365a9 100644 --- a/Lib/python/director.swg +++ b/Lib/python/director.swg @@ -85,13 +85,13 @@ namespace Swig { } # endif /* SWIG_DIRECTOR_RTDIR */ -# define SWIG_DIRECTOR_CAST(Arg) Swig::get_rtdir(static_cast(Arg)) -# define SWIG_DIRECTOR_RGTR(Arg1, Arg2) Swig::set_rtdir(static_cast(Arg1), Arg2) +# define SWIG_DIRECTOR_CAST(ARG) Swig::get_rtdir(static_cast(ARG)) +# define SWIG_DIRECTOR_RGTR(ARG1, ARG2) Swig::set_rtdir(static_cast(ARG1), ARG2) #else -# define SWIG_DIRECTOR_CAST(Arg) dynamic_cast(Arg) -# define SWIG_DIRECTOR_RGTR(Arg1, Arg2) +# define SWIG_DIRECTOR_CAST(ARG) dynamic_cast(ARG) +# define SWIG_DIRECTOR_RGTR(ARG1, ARG2) #endif /* SWIG_DIRECTOR_NORTTI */ diff --git a/Lib/ruby/director.swg b/Lib/ruby/director.swg index de6289cc5..cdc4baea1 100644 --- a/Lib/ruby/director.swg +++ b/Lib/ruby/director.swg @@ -21,6 +21,8 @@ #include #include +# define SWIG_DIRECTOR_CAST(ARG) dynamic_cast(ARG) + namespace Swig { /* memory handler */ struct GCItem From bdea09ed83828592b08b1151e0f14517cccd8b68 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 14 Apr 2010 22:22:16 +0000 Subject: [PATCH 0831/1680] Make typemap fragments official - move the documentation in fragments.swg into Typemaps.html git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11992 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 3 + Doc/Manual/Contents.html | 13 +- Doc/Manual/Typemaps.html | 435 +++++++++++++++++++++++++++++-------- Lib/typemaps/fragments.swg | 241 +------------------- 4 files changed, 363 insertions(+), 329 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 6db583a33..387ad224b 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,9 @@ Version 2.0.0 (in progress) ============================ +2010-04-14: wsfulton + Typemap fragments are now official and documented in Typemaps.html. + 2010-04-09: wsfulton [Ruby] Fix #2048064 and #2408020. Apply Ubuntu patch to fix Ruby and std::vector wrappers with -minherit. diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index 5bd3210bf..a99fd1885 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -349,9 +349,8 @@
    • Pattern matching rules @@ -390,14 +389,18 @@
    • Typemaps for multiple target languages
    • Optimal code generation when returning by value
    • Multi-argument typemaps -
    • The run-time type checker +
    • Typemap fragments + +
    • The run-time type checker
    • Typemaps and overloading
    • More about %apply and %clear -
    • Reducing wrapper code size
    • Passing data between typemaps
    • C++ "this" pointer
    • Where to go for more information? diff --git a/Doc/Manual/Typemaps.html b/Doc/Manual/Typemaps.html index 066d9d79e..71c2c43ec 100644 --- a/Doc/Manual/Typemaps.html +++ b/Doc/Manual/Typemaps.html @@ -31,9 +31,8 @@
    • Pattern matching rules @@ -72,14 +71,18 @@
    • Typemaps for multiple target languages
    • Optimal code generation when returning by value
    • Multi-argument typemaps -
    • The run-time type checker +
    • Typemap fragments + +
    • The run-time type checker
    • Typemaps and overloading
    • More about %apply and %clear -
    • Reducing wrapper code size
    • Passing data between typemaps
    • C++ "this" pointer
    • Where to go for more information? @@ -1408,7 +1411,7 @@ simpler scheme to match the current C++ template partial specialization matching

      -

      10.3.5 Multi-arguments typemaps

      +

      10.3.4 Multi-arguments typemaps

      @@ -1438,7 +1441,7 @@ but all subsequent arguments must match exactly.

      -

      10.3.6 Debugging typemap pattern matching

      +

      10.3.5 Debugging typemap pattern matching

      @@ -3404,7 +3407,335 @@ with non-consecutive C/C++ arguments; a workaround such as a helper function re- the arguments to make them consecutive will need to be written.

      -

      10.10 The run-time type checker

      +

      10.10 Typemap fragments

      + + +

      +The primary purpose of fragments is to reduce code bloat that repeated use of typemap code can lead to. +Fragments are snippets of code that can be thought of as code dependencies of a typemap. +If a fragment is used by more than one typemap, then the snippet of code within the fragment is only generated once. +Code bloat is typically reduced by moving typemap code into a support function +and then placing the support function into a fragment. +

      + +

      +For example, if you have a very long typemap +

      + +
      +
      +%typemap(in) MyClass * {
      +  MyClass *value = 0;
      +
      +  ... many lines of marshalling code  ...
      +
      +  $result = value;
      +}
      +
      +
      + +

      +the same marshalling code is often repeated in several typemaps, such as "in", "varin", "directorout", etc. +SWIG copies the code for each argument that requires the typemap code, easily leading to code bloat +in the generated code. +To eliminate this, define a fragment that includes the common marshalling code: +

      + +
      +
      +%fragment("AsMyClass", "header") {
      +  MyClass *AsMyClass(PyObject *obj) {
      +    MyClass *value = 0;
      +
      +    ... many lines of marshalling code  ...
      +
      +    return value;
      +  }
      +}
      +
      +%typemap(in, fragment="AsMyClass") MyClass * {
      +  $result = AsMyClass($input);
      +}
      +
      +%typemap(varin, fragment="AsMyClass") MyClass * {
      +  $result = AsMyClass($input);
      +}
      +
      +
      + +

      +When the "in" or "varin" typemaps for MyClass are required, the +contents of the fragment called "AsMyClass" is added to the "header" section within the generated code, and then the +typemap code is emitted. Hence, the method AsMyClass will be +generated into the wrapper code before any typemap code that calls it. +

      + +

      +To define a fragment you need a fragment name, a section name for generating the fragment code into, and the code itself. +See Code insertion blocks for a full list of section names. +Usually the section name used is "header". Both string and curly braces can be used: +

      + +
      +
      +%fragment("my_name", "header") { ... }
      +%fragment("my_name", "header") " ... "
      +
      +
      + +

      +The following are some rules and guidelines for using fragments: +

      + +
        +
      1. +

        +A fragment is added to the wrapping code only once. When using the MyClass * typemaps above and wrapping the method: +

        + +
        +
        +void foo(MyClass *a, MyClass *b);
        +
        +
        + +

        +the generated code will look something like: +

        + +
        +
        +MyClass *AsMyClass(PyObject *obj) {
        +  ...
        +}
        +
        +void _wrap_foo(...) {
        +  ....
        +  arg1 = AsMyClass(obj1);
        +  arg2 = AsMyClass(obj2);
        +  ...
        +  foo(arg1, arg2);
        +}
        +
        +
        + +

        +even as there is duplicated typemap code to process both a and +b, the AsMyClass method will be defined only once. +

        + +
      2. +

        +A fragment should only be defined once. If there is more than +one definition, the first definition is the one used. +All other definitions are silently ignored. For example, if you have +

        + + +
        +
        +%fragment("AsMyClass", "header") { ...definition 1... }
        +....
        +%fragment("AsMyClass", "header") { ...definition 2... }
        +
        +
        + +

        +only the first definition is used. In this way +you can override the default fragments in a SWIG library by defining your fragment before the library %include. +Note that this behavior is the opposite to typemaps, where the last typemap defined/applied prevails. +Fragments follow the first-in-first-out convention since they are intended to be global, +while typemaps are intended to be locally specialized. +

        + +
      3. +

        +Fragment names cannot contain commas. +

        + + +
      4. +

        +A fragment can use one or more additional fragments, for example: +

        + +
        +
        +%fragment("<limits.h>", "header")  {
        +  #include <limits.h>
        +}
        +
        +
        +%fragment("AsMyClass", "header", fragment="<limits.h>") {
        +  MyClass *AsMyClass(PyObject *obj) {
        +    MyClass *value = 0;
        +
        +    ... some marshalling code  ...
        +
        +    if  (ival < CHAR_MIN /*defined in <limits.h>*/) {
        +       ...
        +    } else {
        +       ...
        +    }
        +    ...
        +    return value;
        +  }
        +}
        +
        +
        + +

        +in this case, when the "AsMyClass" fragment is emitted, it also +triggers the inclusion of the "<limits.h>" fragment. +

        + +
      5. +

        +A fragment can have dependencies on a number of other fragments, for example: +

        + +
        +
        +%fragment("bigfragment", "header", fragment="frag1", fragment="frag2", fragment="frag3") "";
        +
        +
        + +

        +When the "bigfragment" is used, the three dependent fragments "frag1", +"frag2" and "frag3" are also pulled in. Note that as "bigframent" is +empty (the empty string - ""), it does not add any code itself, but merely triggers the +inclusion of the other fragments. +

        + +
      6. +

        +A typemap can also use more than one fragment, but since the +syntax is different, you need to specify the dependent fragments in a comma separated +list. Consider: +

        + +
        +
        +%typemap(in, fragment="frag1,frag2,frag3") {...}
        +
        +
        + +

        +which is equivalent to: +

        + +
        +
        +%typemap(in, fragment="bigfragment") {...}
        +
        +
        + +

        +when used with the "bigfragment" defined above. +

        + +
      7. +

        +Finally, you can force the inclusion of a fragment at any point in the generated code as follows: +

        + +
        +
        +%fragment("bigfragment");
        +
        +
        + +

        +which is very useful inside a template class, for example. +

        +
      + +

      +Most readers will probably want to skip the next two sub-sections on advanced +fragment usage unless a desire to really get to grips +with some powerful but tricky macro and fragment usage that is used in parts of the SWIG typemap library. +

      + +

      10.10.1 Fragment type specialization

      + + +

      +Fragments can be type specialized. The syntax is as follows: +

      + +
      +
      +%fragment("name", "header") { ...a type independent fragment... }
      +%fragment("name"{type}, "header") { ...a type dependent fragment...  }
      +
      +
      + +

      +where type is a C/C++ type. Like typemaps, fragments can also be used inside templates, for example: +

      + +
      +
      +template <class T>
      +struct A {
      +  %fragment("incode"{A<T>}, "header") {
      +    ... 'incode' specialized fragment ...
      +  }
      +
      +  %typemap(in, fragment="incode"{A<T>}) {
      +     ... here we use the 'type specialized' fragment "incode"{A<T>} ...
      +  }
      +};
      +
      +
      + +

      10.10.2 Fragments and automatic typemap specialization

      + + +

      +Since fragments can be type specialized, they can be elegantly used +to specialize typemaps. For example, if you have something like: +

      + +
      +
      +%fragment("incode"{float}, "header") {
      +  float in_method_float(PyObject *obj) {
      +    ...
      +  }
      +}
      +
      +%fragment("incode"{long}, "header") {
      +  float in_method_long(PyObject *obj) {
      +    ...
      +  }
      +}
      +
      +// %my_typemaps macro definition
      +%define %my_typemaps(Type) 
      +%typemap(in, fragment="incode"{Type}) Type {
      +  value = in_method_##Type(obj);
      +}
      +%enddef
      +
      +%my_typemaps(float);
      +%my_typemaps(long);
      +
      +
      + +

      +then the proper "incode"{float} or "incode"{long} fragment will be used, +and the in_method_float and in_method_long methods will be called whenever +the float or long types are used as input parameters. +

      + +

      +This feature is used a lot in the typemaps shipped in the SWIG library for some scripting languages. +The interested (or very brave) reader can take a look at the fragments.swg file shipped with SWIG to see this in action. +

      + + +

      10.11 The run-time type checker

      @@ -3430,7 +3761,7 @@ language modules.

    • Modules can be unloaded from the type system.
    -

    10.10.1 Implementation

    +

    10.11.1 Implementation

    @@ -3616,7 +3947,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.11.2 Usage

    This section covers how to use these functions from typemaps. To learn how to @@ -3710,7 +4041,7 @@ probably just look at the output of SWIG to get a better sense for how types are managed.

    -

    10.11 Typemaps and overloading

    +

    10.12 Typemaps and overloading

    @@ -4021,7 +4352,7 @@ Subsequent "in" typemaps would then perform more extensive type-checking.

  • -

    10.12 More about %apply and %clear

    +

    10.13 More about %apply and %clear

    @@ -4106,86 +4437,6 @@ example: -

    10.13 Reducing wrapper code size

    - - -

    -Since the code supplied to a typemap is inlined directly into wrapper functions, typemaps can result -in a tremendous amount of code bloat. For example, consider this typemap for an array: -

    - -
    -
    -%typemap(in) float [ANY] {
    -  int i;
    -  if (!PySequence_Check($input)) {
    -    PyErr_SetString(PyExc_ValueError,"Expected a sequence");
    -    return NULL;
    -  }
    -  if (PySequence_Length($input) != $1_dim0) {
    -    PyErr_SetString(PyExc_ValueError,"Size mismatch. Expected $1_dim0 elements");
    -    return NULL;
    -  }
    -  $1 = (float) malloc($1_dim0*sizeof(float));
    -  for (i = 0; i < $1_dim0; i++) {
    -    PyObject *o = PySequence_GetItem($input,i);
    -    if (PyNumber_Check(o)) {
    -      $1[i] = (float) PyFloat_AsDouble(o);
    -    } else {
    -      PyErr_SetString(PyExc_ValueError,"Sequence elements must be numbers");      
    -      free(result);
    -      return NULL;
    -    }
    -  }
    -}
    -
    -
    - -

    -If you had a large interface with hundreds of functions all accepting -array parameters, this typemap would be replicated -repeatedly--generating a huge amount of code. A better approach might -be to consolidate some of the typemap into a function. For example: -

    - -
    -
    -%{
    -/* Define a helper function */
    -static float *
    -convert_float_array(PyObject *input, int size) {
    -  int i;
    -  float *result;
    -  if (!PySequence_Check(input)) {
    -    PyErr_SetString(PyExc_ValueError,"Expected a sequence");
    -    return NULL;
    -  }
    -  if (PySequence_Length(input) != size) {
    -    PyErr_SetString(PyExc_ValueError,"Size mismatch. ");
    -    return NULL;
    -  }
    -  result = (float) malloc(size*sizeof(float));
    -  for (i = 0; i < size; i++) {
    -    PyObject *o = PySequence_GetItem(input,i);
    -    if (PyNumber_Check(o)) {
    -      result[i] = (float) PyFloat_AsDouble(o);
    -    } else {
    -      PyErr_SetString(PyExc_ValueError,"Sequence elements must be numbers");
    -      free(result);       
    -      return NULL;
    -    }
    -  }
    -  return result;
    -}
    -%}
    -
    -%typemap(in) float [ANY] {
    -    $1 = convert_float_array($input, $1_dim0);
    -    if (!$1) return NULL;
    -}
    -%}
    -
    -

    10.14 Passing data between typemaps

    diff --git a/Lib/typemaps/fragments.swg b/Lib/typemaps/fragments.swg index ef6a346cc..099bb4729 100644 --- a/Lib/typemaps/fragments.swg +++ b/Lib/typemaps/fragments.swg @@ -1,238 +1,15 @@ /* - Fragments: - ========== + Fragments + ========= + See the "Typemap fragments" section in the documentation for understanding + fragments. Below is some info on how fragments and automatic type + specialization is used. - Second to typemaps, fragments are one the most powerful and - dangerous swig features. So, if you are starting to read about them, - make sure you read all of this document. + Macros that make the automatic generation of typemaps easier are provided. - Basics: - ======= + Consider the following code: - Fragments provide a way to include or generate code into "on-demand" - as the typemaps could require. - - For example, if you have a very long typemap - - %typemap(in) MyClass * { - MyClass *value = 0; - - - .... - value = somewhere_converted_from_input_object_here($input); - ... - - - $result = value; - } - - very soon you will discover yourself copying the same long - conversion code in several typemaps, such as varin, directorout, - etc. Also, you will discover that swig copes verbatim the same very - long conversion code for every argument that requires it, making the - code very large too. - - To eliminate this automatic or manual code copying, we define a - fragment that includes the common conversion code: - - %fragment("AsMyClass","header") { - MyClass *AsMyClass(PyObject *obj) { - MyClass *value = 0; - - .... - value = somewhere_converted_from_input_object_here(obj); - ... - - - return value; - } - } - - %typemap(in,fragment="AsMyClass") MyClass * { - $result = AsMyClass($input); - } - - %typemap(varin,fragment="AsMyClass") MyClass * { - $result = AsMyClass($input); - } - - When the 'in' or 'varin' typemaps for MyClass are invoked, the - fragment "AsMyClass" is added to the "header" section, and then the - typemap code is emitted. Hence, the method AsMyClass will be - included in the wrapping code and it will be available at the time - the typemap is applied. - - To define a fragment then you need a name, a section where it goes, - and the code. Usually the section refers to the "header" part, and - both string and braces forms are accepted, ie: - - %fragment("my_name","header") { ... } - %fragment("my_name","header") "..."; - - To ensure all the fragment/typemap engine works as expected, there - are some rules that fragments follow: - - 1.- A fragment is added to the wrapping code only once, ie, for the - method: - - int foo(MyClass *a, MyClass *b); - - the wrapped code will look as much as: - - MyClass *AsMyClass(PyObject *obj) { - ..... - } - - int _wrap_foo(...) { - .... - arg1 = AsMyClass(obj1); - arg2 = AsMyClass(obj2); - ... - result = foo(arg1, arg2); - } - - - even when there will be duplicated typemap to process 'a' and - 'b', the 'AsMyClass' method will be defined only once. - - - 2.- A fragment can only defined once, and the first definition - is the only one taking in account. All other definitions of the - same fragments are silently ignored. For example, you can have - - - %fragment("AsMyClass","header") { } - .... - %fragment("AsMyClass","header") { } - - and then only the first definition is considered. In this way - you can change the 'system' fragments by including yours first. - - Note that this behavior is opposite to the typemaps, where the - last typemap applied or defined prevails. Fragment follows the - first-in-first-out convention since they are intended to be - "global", while typemaps intend to be "locally" specialized. - - 3.- Fragments names can not contain commas. - - - A fragment can include one or more additional fragments, for example: - - %fragment("", "header") { - #include - } - - - %fragment("AsMyClass", "header", fragment="") { - MyClass *AsMyClass(PyObject *obj) { - MyClass *value = 0; - int ival = somewhere_converted_from_input_object_here(obj) - ... - if (ival < CHAR_MIN) { - value = something_from_ival(ival); - } else { - ... - } - ... - return value; - } - } - - in this case, when the "AsMyClass" fragment is emitted, it also - trigger the inclusion of the "" fragment. - - You can add as many fragments as you want, for example - - %fragment("bigfragment","header", fragment="frag1", fragment="frag2", fragment="frag3") ""; - - here, when the "bigfragment" is included, the three fragments "frag1", - "frag2" and "frag3" are included. Note that as "bigframent" is defined - empty, "", it does not add any code by itself, buy only trigger the - inclusion of the other fragments. - - In a typemap you can also include more than one fragment, but since the - syntax is different, you need to specify them in a 'comma separated' - list, for example, considering the previous example: - - %typemap(in,fragment="frag1,frag2,frag3") {...} - - is equivalent to - - %typemap(in,fragment="bigfragment") {...} - - - Finally, you can force the inclusion of a fragment at any moment as follow: - - %fragment("bigfragment"); - - which is very useful inside a template class, for example. - - - Fragment type specialization - ============================ - - Fragments can be "type specialized". The syntax is as follows - - %fragment("name","header") { a type independent fragment } - %fragment("name" {Type}, "header") { a type dependent fragment } - - and they can also, as typemaps, be used inside templates, for exampe: - - template - struct A { - %fragment("incode"{A},"header") { - 'incode' specialized fragment - } - - %typemap(in,fragment="incode"{A}) { - here we use the 'type specialized' - fragment "incode"{A} - } - }; - - which could seems a not much interesting feature, but is - fundamental for automatic typemap and template specialization. - - - Fragments and automatic typemap specialization: - =============================================== - - Since fragments can be type specialized, they can be elegantly used - to specialized typemaps . - - For example, if you have something like: - - %fragment("incode"{float}, "header") { - float in_method_float(PyObject *obj) { - ... - } - } - - %fragment("incode"{long}, "header") { - float in_method_long(PyObject *obj) { - ... - } - } - - %define %my_typemaps(Type) - %typemaps(in,fragment="incode"{Type}) { - value = in_method_##Type(obj); - } - %enddef - - %my_typemaps(float); - %my_typemaps(long); - - then the proper "incode"{float,double} fragment will be included, - and the proper in_method_{float,double} will be called. - - Since this is a recurrent fragment use, we provide a couple of - macros that make the automatic generation of typemaps easier: - - - Consider for example the following code: - - %fragment(SWIG_From_frag(bool),"header") { + %fragment(SWIG_From_frag(bool), "header") { static PyObject* SWIG_From_dec(bool)(bool value) { @@ -242,7 +19,7 @@ } } - %typemap(out,fragment=SWIG_From_frag(bool)) bool { + %typemap(out, fragment=SWIG_From_frag(bool)) bool { $result = SWIG_From(bool)($1)); } From 2535297efbc72e857ac0865a4bd3e0e4ca331ca2 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 23 Apr 2010 06:44:47 +0000 Subject: [PATCH 0832/1680] minor formatting change git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11995 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/allegrocl/allegrocl.swg | 6 +++--- Lib/chicken/std_string.i | 5 ++--- Lib/guile/std_string.i | 7 +++---- Lib/lua/lua.swg | 2 +- Lib/lua/luatypemaps.swg | 10 +++++----- Lib/lua/wchar.i | 8 ++++---- Lib/python/argcargv.i | 2 +- Lib/r/r.swg | 6 +++--- 8 files changed, 22 insertions(+), 24 deletions(-) diff --git a/Lib/allegrocl/allegrocl.swg b/Lib/allegrocl/allegrocl.swg index cc23a1f90..87e030ce4 100644 --- a/Lib/allegrocl/allegrocl.swg +++ b/Lib/allegrocl/allegrocl.swg @@ -203,20 +203,20 @@ SWIG_TYPECHECK_STRING_ARRAY 1140 %typemap(in) wchar_t "$1 = $input;"; %typemap(lin,numinputs=1) wchar_t "(cl::let (($out (cl:char-code $in)))\n $body)"; -%typemap(lin,numinputs=1) wchar_t* "(excl:with-native-string ($out $in +%typemap(lin,numinputs=1) wchar_t * "(excl:with-native-string ($out $in :external-format #+little-endian :fat-le #-little-endian :fat)\n $body)" %typemap(out) wchar_t "$result = $1;"; %typemap(lout) wchar_t "(cl::setq ACL_ffresult (cl::code-char $body))"; -%typemap(lout) wchar_t* "(cl::setq ACL_ffresult (excl:native-to-string $body +%typemap(lout) wchar_t * "(cl::setq ACL_ffresult (excl:native-to-string $body :external-format #+little-endian :fat-le #-little-endian :fat))"; %typemap(ffitype) wchar_t ":unsigned-short"; %typemap(lisptype) wchar_t ""; %typemap(ctype) wchar_t "wchar_t"; %typemap(lispclass) wchar_t "cl:character"; -%typemap(lispclass) wchar_t* "cl:string"; +%typemap(lispclass) wchar_t * "cl:string"; ////////////////////////////////////////////////////////////// /* Array reference typemaps */ diff --git a/Lib/chicken/std_string.i b/Lib/chicken/std_string.i index ce24cba32..9907a58bc 100644 --- a/Lib/chicken/std_string.i +++ b/Lib/chicken/std_string.i @@ -30,7 +30,7 @@ namespace std { %typemap(typecheck) string = char *; %typemap(typecheck) const string & = char *; - %typemap(in) string (char* tempptr) { + %typemap(in) string (char * tempptr) { if ($input == C_SCHEME_FALSE) { $1.resize(0); } else { @@ -44,8 +44,7 @@ namespace std { } } - %typemap(in) const string& (std::string temp, - char* tempptr) { + %typemap(in) const string& (std::string temp, char *tempptr) { if ($input == C_SCHEME_FALSE) { temp.resize(0); diff --git a/Lib/guile/std_string.i b/Lib/guile/std_string.i index c10806e98..65ab6efbf 100644 --- a/Lib/guile/std_string.i +++ b/Lib/guile/std_string.i @@ -26,7 +26,7 @@ namespace std { %typemap(typecheck) string = char *; %typemap(typecheck) const string & = char *; - %typemap(in) string (char* tempptr) { + %typemap(in) string (char * tempptr) { if (gh_string_p($input)) { tempptr = SWIG_scm2str($input); $1.assign(tempptr); @@ -36,8 +36,7 @@ namespace std { } } - %typemap(in) const string & (std::string temp, - char* tempptr) { + %typemap(in) const string & (std::string temp, char *tempptr) { if (gh_string_p($input)) { tempptr = SWIG_scm2str($input); temp.assign(tempptr); @@ -48,7 +47,7 @@ namespace std { } } - %typemap(in) string * (char* tempptr) { + %typemap(in) string * (char *tempptr) { if (gh_string_p($input)) { tempptr = SWIG_scm2str($input); $1 = new std::string(tempptr); diff --git a/Lib/lua/lua.swg b/Lib/lua/lua.swg index 5218bf0a8..a15f14148 100644 --- a/Lib/lua/lua.swg +++ b/Lib/lua/lua.swg @@ -176,7 +176,7 @@ use %include instead %{lua_pushnumber(L,(lua_Number)(int)$1);SWIG_fail; %} // strings are just sent as errors -%typemap(throws) char*, const char* +%typemap(throws) char *, const char * %{lua_pushstring(L,$1);SWIG_fail;%} // char is changed to a string diff --git a/Lib/lua/luatypemaps.swg b/Lib/lua/luatypemaps.swg index ae65cbfea..aff116192 100644 --- a/Lib/lua/luatypemaps.swg +++ b/Lib/lua/luatypemaps.swg @@ -89,7 +89,7 @@ temp=($basetype)lua_tonumber(L,$input); $1=&temp;%} %typemap(out) const bool& %{ lua_pushboolean(L,(int)((*$1)!=0)); SWIG_arg++;%} -// strings (char* and char[]) +// strings (char * and char[]) %fragment("SWIG_lua_isnilstring", "header") { int SWIG_lua_isnilstring(lua_State *L, int idx) { int ret = lua_isstring(L, idx); @@ -99,17 +99,17 @@ temp=($basetype)lua_tonumber(L,$input); $1=&temp;%} } } -%typemap(in,checkfn="SWIG_lua_isnilstring",fragment="SWIG_lua_isnilstring") const char*, char* +%typemap(in,checkfn="SWIG_lua_isnilstring",fragment="SWIG_lua_isnilstring") const char *, char * %{$1 = ($ltype)lua_tostring(L, $input);%} %typemap(in,checkfn="SWIG_lua_isnilstring",fragment="SWIG_lua_isnilstring") const char[ANY], char[ANY] %{$1 = ($ltype)lua_tostring(L, $input);%} -%typemap(out) const char*, char* -%{ lua_pushstring(L,(const char*)$1); SWIG_arg++;%} +%typemap(out) const char *, char * +%{ lua_pushstring(L,(const char *)$1); SWIG_arg++;%} %typemap(out) const char[ANY], char[ANY] -%{ lua_pushstring(L,(const char*)$1); SWIG_arg++;%} +%{ lua_pushstring(L,(const char *)$1); SWIG_arg++;%} // char's // currently treating chars as small strings, not as numbers diff --git a/Lib/lua/wchar.i b/Lib/lua/wchar.i index 02b5428be..92f7ed0e2 100644 --- a/Lib/lua/wchar.i +++ b/Lib/lua/wchar.i @@ -12,11 +12,11 @@ %{ #include -wchar_t* str2wstr(const char* str, int len) +wchar_t* str2wstr(const char *str, int len) { wchar_t* p; if (str==0 || len<1) return 0; - p=(wchar*)malloc((len+1)*sizeof(wchar_t)); + p=(wchar *)malloc((len+1)*sizeof(wchar_t)); if (p==0) return 0; if (mbstowcs(p, str, len)==-1) { @@ -28,13 +28,13 @@ wchar_t* str2wstr(const char* str, int len) } %} -%typemap(in, checkfn="SWIG_lua_isnilstring", fragment="SWIG_lua_isnilstring") wchar_t* +%typemap(in, checkfn="SWIG_lua_isnilstring", fragment="SWIG_lua_isnilstring") wchar_t * %{ $1 = str2wstr(lua_tostring( L, $input ),lua_strlen( L, $input )); if ($1==0) {lua_pushfstring(L,"Error in converting to wchar (arg %d)",$input);goto fail;} %} -%typemap(freearg) wchar_t* +%typemap(freearg) wchar_t * %{ free($1); %} diff --git a/Lib/python/argcargv.i b/Lib/python/argcargv.i index d5d008ae5..717fe7334 100644 --- a/Lib/python/argcargv.i +++ b/Lib/python/argcargv.i @@ -60,7 +60,7 @@ SWIG_AsArgcArgv(PyObject *input, } /* - This typemap works with either a char**, a python list or a python + This typemap works with either a char **, a python list or a python tuple */ diff --git a/Lib/r/r.swg b/Lib/r/r.swg index b70d80581..121797e33 100644 --- a/Lib/r/r.swg +++ b/Lib/r/r.swg @@ -144,11 +144,11 @@ SWIG_InitializeModule(0); $1 = %reinterpret_cast(INTEGER($input), $1_ltype); } -%typemap(in,noblock=1,fragment="SWIG_strdup") char* { +%typemap(in,noblock=1,fragment="SWIG_strdup") char * { $1 = %reinterpret_cast(SWIG_strdup(CHAR(STRING_ELT($input, 0))), $1_ltype); } -%typemap(freearg,noblock=1) char* { +%typemap(freearg,noblock=1) char * { free($1); } @@ -189,7 +189,7 @@ else strcpy($1, ""); %} -%typemap(out,noblock=1) char* +%typemap(out,noblock=1) char * { $result = $1 ? Rf_mkString(%reinterpret_cast($1,char *)) : R_NilValue; } %typemap(in,noblock=1) char { From ff8f6b5c66a2bba42f5f7c134ea8128ddb46dc3c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 23 Apr 2010 18:16:31 +0000 Subject: [PATCH 0833/1680] minor formatting changes git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11996 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/typemaps/cstrings.swg | 3 +-- Lib/typemaps/strings.swg | 15 ++++++--------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/Lib/typemaps/cstrings.swg b/Lib/typemaps/cstrings.swg index c60ef6496..7fe6a3f8f 100644 --- a/Lib/typemaps/cstrings.swg +++ b/Lib/typemaps/cstrings.swg @@ -147,8 +147,7 @@ */ %define Name ## _mutable(TYPEMAP,EXP...) -%typemap(in,noblock=1,fragment=#SWIG_AsCharPtrAndSize) TYPEMAP - (int res, Char* t = 0, size_t n = 0, int alloc = 0, size_t expansion = 0) { +%typemap(in,noblock=1,fragment=#SWIG_AsCharPtrAndSize) TYPEMAP (int res, Char *t = 0, size_t n = 0, int alloc = 0, size_t expansion = 0) { #if #EXP != "" expansion += EXP; #endif diff --git a/Lib/typemaps/strings.swg b/Lib/typemaps/strings.swg index 04fa28f5d..7c5f59ae2 100644 --- a/Lib/typemaps/strings.swg +++ b/Lib/typemaps/strings.swg @@ -54,7 +54,7 @@ /* out */ -%typemap(out,noblock=1,fragment=#SWIG_FromCharPtr) Char *, const Char* { +%typemap(out,noblock=1,fragment=#SWIG_FromCharPtr) Char *, const Char * { %set_output(SWIG_FromCharPtr((const Char *)$1)); } @@ -98,7 +98,7 @@ /* varout */ -%typemap(varout,noblock=1,fragment=#SWIG_FromCharPtr) Char*, const Char* { +%typemap(varout,noblock=1,fragment=#SWIG_FromCharPtr) Char *, const Char * { %set_varoutput(SWIG_FromCharPtr($1)); } @@ -165,8 +165,7 @@ /* directorout */ -%typemap(directorout,noblock=1,fragment=#SWIG_AsCharPtr,warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) - Char * (int res, Char* buf = 0, int alloc = SWIG_NEWOBJ) { +%typemap(directorout,noblock=1,fragment=#SWIG_AsCharPtr,warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) Char * (int res, Char *buf = 0, int alloc = SWIG_NEWOBJ) { res = SWIG_AsCharPtr($input, &buf, &alloc); if (!SWIG_IsOK(res)) { %dirout_fail(res, "$type"); @@ -184,9 +183,7 @@ } -%typemap(directorout,noblock=1,fragment=#SWIG_AsCharPtr,warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) - Char * const& (int res, Char* buf = 0, int alloc = SWIG_NEWOBJ), - Char const* const& (int res, Char* buf = 0, int alloc = SWIG_NEWOBJ) { +%typemap(directorout,noblock=1,fragment=#SWIG_AsCharPtr,warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) Char *const& (int res, Char *buf = 0, int alloc = SWIG_NEWOBJ), Char const*const& (int res, Char *buf = 0, int alloc = SWIG_NEWOBJ) { res = SWIG_AsCharPtr($input, &buf, &alloc); if (!SWIG_IsOK(res)) { %dirout_fail(res, "$type"); @@ -226,8 +223,8 @@ * Unknown size const Character array Char[ANY] handling * ------------------------------------------------------------ */ -%apply Char* { Char [] }; -%apply const Char* { const Char [] }; +%apply Char * { Char [] }; +%apply const Char * { const Char [] }; %typemap(varin,noblock=1,warning="462:Unable to set variable of type Char []") Char [] { From 2450c4b108da7d3cd231ccd14b478c48c3b0f391 Mon Sep 17 00:00:00 2001 From: Haoyu Bai Date: Sun, 25 Apr 2010 14:07:14 +0000 Subject: [PATCH 0834/1680] fix regression of Python constructor renaming introduced by py3k work git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11997 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 3 +++ Examples/test-suite/common.mk | 1 + Examples/test-suite/constructor_rename.i | 12 ++++++++++++ .../test-suite/python/constructor_rename_runme.py | 3 +++ Source/Modules/python.cxx | 5 +++-- 5 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 Examples/test-suite/constructor_rename.i create mode 100644 Examples/test-suite/python/constructor_rename_runme.py diff --git a/CHANGES.current b/CHANGES.current index 387ad224b..0a707a918 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,9 @@ Version 2.0.0 (in progress) ============================ +2010-04-25: bhy + [Python] Fix #2985655 - broken constructor renaming. + 2010-04-14: wsfulton Typemap fragments are now official and documented in Typemaps.html. diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index a902166b5..308ff9f1e 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -131,6 +131,7 @@ CPP_TEST_CASES += \ constructor_exception \ constructor_explicit \ constructor_ignore \ + constructor_rename \ constructor_value \ contract \ conversion \ diff --git a/Examples/test-suite/constructor_rename.i b/Examples/test-suite/constructor_rename.i new file mode 100644 index 000000000..401b07d65 --- /dev/null +++ b/Examples/test-suite/constructor_rename.i @@ -0,0 +1,12 @@ +%module constructor_rename + +%{ +struct Foo { + Foo() {} +}; +%} + +struct Foo { + %rename(RenamedConstructor) Foo(); + Foo() {} +}; diff --git a/Examples/test-suite/python/constructor_rename_runme.py b/Examples/test-suite/python/constructor_rename_runme.py new file mode 100644 index 000000000..cf3f88b81 --- /dev/null +++ b/Examples/test-suite/python/constructor_rename_runme.py @@ -0,0 +1,3 @@ +from constructor_rename import * + +x = RenamedConstructor() diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 3639efe86..93679084c 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -3257,6 +3257,7 @@ public: String *classname = Swig_class_name(parent); String *rclassname = Swig_class_name(getCurrentClass()); assert(rclassname); + String *parms = make_pyParmList(n, true, false, allow_kwargs); /* Pass 'self' only if using director */ @@ -3300,8 +3301,8 @@ public: Printv(f_shadow_stubs, pycode, "\n", NIL); Delete(pycode); } else { - String *parms = make_pyParmList(n, true, false, allow_kwargs); - String *callParms = make_pyParmList(n, true, true, allow_kwargs); + String *parms = make_pyParmList(n, false, false, allow_kwargs); + String *callParms = make_pyParmList(n, false, true, allow_kwargs); Printv(f_shadow_stubs, "\ndef ", symname, "(", parms, ")", returnTypeAnnotation(n), ":\n", NIL); if (have_docstring(n)) From 89a8bd2abf0bc92a1102813aa7bc0b4f920766f5 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 29 Apr 2010 19:46:14 +0000 Subject: [PATCH 0835/1680] Remove confusion about ignoring header include guards git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11998 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/SWIG.html | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html index 9ad450425..e4a2a8c42 100644 --- a/Doc/Manual/SWIG.html +++ b/Doc/Manual/SWIG.html @@ -1672,7 +1672,7 @@ directive as shown :

    // interface.i %rename(my_print) print; -extern void print(char *); +extern void print(const char *); %rename(foo) a_really_long_and_annoying_name; extern int a_really_long_and_annoying_name; @@ -1725,9 +1725,10 @@ to ignore declarations that match a given identifier. For example:
     %ignore print;         // Ignore all declarations named print
    -%ignore _HAVE_FOO_H;   // Ignore an include guard constant
    +%ignore MYMACRO;       // Ignore a macro
     ...
    -%include "foo.h"       // Grab a header file
    +#define MYMACRO 123
    +void print(const char *);
     ...
     
    @@ -1752,7 +1753,7 @@ For example:
    -%name(output) extern void print(char *);
    +%name(output) extern void print(const char *);
     
    From eef90444774d02fa0d3a10dc9713df4f8fc933c1 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 1 May 2010 10:01:26 +0000 Subject: [PATCH 0836/1680] More string tests: char const*const git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12005 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/char_strings.i | 14 +++++++++++++- Examples/test-suite/csharp/char_strings_runme.cs | 10 ++++++++++ Examples/test-suite/java/char_strings_runme.java | 10 ++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/Examples/test-suite/char_strings.i b/Examples/test-suite/char_strings.i index 26f3f22a5..cc59815b2 100644 --- a/Examples/test-suite/char_strings.i +++ b/Examples/test-suite/char_strings.i @@ -21,7 +21,7 @@ below. static char *global_str = NULL; const int UINT_DIGITS = 10; // max unsigned int is 4294967295 -bool check(const char *str, unsigned int number) { +bool check(const char *const str, unsigned int number) { static char expected[256]; sprintf(expected, "%s%d", OTHERLAND_MSG, number); bool matches = (strcmp(str, expected) == 0); @@ -105,6 +105,18 @@ bool SetConstCharArrayStaticString(const char str[], unsigned int number) { return check(static_str, number); } +bool SetCharConstStaticString(char *const str, unsigned int number) { + static char static_str[] = CPLUSPLUS_MSG; + strcpy(static_str, str); + return check(static_str, number); +} + +bool SetConstCharConstStaticString(const char *const str, unsigned int number) { + static char static_str[] = CPLUSPLUS_MSG; + strcpy(static_str, str); + return check(static_str, number); +} + // get set function char *CharPingPong(char *str) { return str; diff --git a/Examples/test-suite/csharp/char_strings_runme.cs b/Examples/test-suite/csharp/char_strings_runme.cs index 59bcc64df..414d32b7a 100644 --- a/Examples/test-suite/csharp/char_strings_runme.cs +++ b/Examples/test-suite/csharp/char_strings_runme.cs @@ -76,6 +76,16 @@ public class char_strings_runme { throw new Exception("Test char set 6 failed, iteration " + i); } + for (i=0; i Date: Sat, 1 May 2010 10:02:23 +0000 Subject: [PATCH 0837/1680] Remove incorrect documentation about %ref and %unref git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12006 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Python.html | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html index e898fb359..aa50630be 100644 --- a/Doc/Manual/Python.html +++ b/Doc/Manual/Python.html @@ -2124,8 +2124,8 @@ Object 'RCObj', which implements the ref/unref idiom.

    To tell SWIG that 'RCObj' and all its derived classes are reference -counted objects, you use the "ref" and "unref" features, or -%ref and %unref directives (since 1.3.28). For example: +counted objects, you use the "ref" and "unref" features. +For example:

    @@ -2143,25 +2143,6 @@ counted objects, you use the "ref" and "unref" features, or -or, using the directive form: - - -
    -
    -%module example
    -...
    -
    -%ref   RCObj "$this->ref();"
    -%unref RCObj "$this->unref();"
    -
    -%include "rcobj.h"
    -%include "A.h"
    -...
    -
    -
    - - -

    where the code passed to the "ref" and "unref" features will be executed as needed whenever a new object is passed to python, or when From efd200ffe2bc9b3f620e73c2b6cda51b1960a38a Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 2 May 2010 21:35:02 +0000 Subject: [PATCH 0838/1680] Typemap matching rules enhancement for non-default typemaps. Previously all qualifiers were stripped in one step, now they are stripped one at a time starting with the left most qualifier. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12007 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 10 +- Doc/Manual/Contents.html | 1 + Doc/Manual/Typemaps.html | 181 +++++++++++++++++- Examples/test-suite/common.mk | 1 + .../python/typemap_qualifier_strip_runme.py | 54 ++++++ Examples/test-suite/typemap_qualifier_strip.i | 76 ++++++++ Source/Swig/stype.c | 4 +- Source/Swig/swig.h | 1 + Source/Swig/typemap.c | 49 +++-- Source/Swig/typeobj.c | 59 ++++++ 10 files changed, 398 insertions(+), 38 deletions(-) create mode 100644 Examples/test-suite/python/typemap_qualifier_strip_runme.py create mode 100644 Examples/test-suite/typemap_qualifier_strip.i diff --git a/CHANGES.current b/CHANGES.current index 0a707a918..287a97e8f 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,14 @@ Version 2.0.0 (in progress) ============================ +2010-05-01: wsfulton + Typemap matching enhancement for non-default typemaps. Previously all + qualifiers were stripped in one step, now they are stripped one at a time + starting with the left most qualifier. For example, int const*const + is first stripped to int *const then int *. + + *** POTENTIAL INCOMPATIBILITY *** + 2010-04-25: bhy [Python] Fix #2985655 - broken constructor renaming. @@ -37,7 +45,7 @@ Version 2.0.0 (in progress) Numerous subtle typemap matching rule fixes when using the default type. The typemap matching rules are to take a type and find the best default typemap (SWIGTYPE, SWIGTYPE* etc), then look for the next best match by reducing the chosen default type. The type deduction - now follows C++ template partial specialization matching rules. + now follows C++ class template partial specialization matching rules. Below are the set of changes made showing the default type deduction along with the old reduced type and the new version of the reduced type: diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index a99fd1885..242b86429 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -351,6 +351,7 @@

  • Basic matching rules
  • Typedef reductions matching
  • Default typemap matching rules +
  • Matching comparison with C++ templates
  • Multi-arguments typemaps
  • Debugging typemap pattern matching diff --git a/Doc/Manual/Typemaps.html b/Doc/Manual/Typemaps.html index 71c2c43ec..76cc770b2 100644 --- a/Doc/Manual/Typemaps.html +++ b/Doc/Manual/Typemaps.html @@ -33,6 +33,7 @@
  • Basic matching rules
  • Typedef reductions matching
  • Default typemap matching rules +
  • Matching comparison with C++ templates
  • Multi-arguments typemaps
  • Debugging typemap pattern matching @@ -1026,8 +1027,10 @@ is used.

    -If TYPE includes qualifiers (const, volatile, etc.), they are stripped to form a new stripped type +If TYPE includes qualifiers (const, volatile, etc.), each qualifier is stripped one at a time to form a new stripped type and the matching rules above are repeated on the stripped type. +The left-most qualifier is stripped first, resulting in the right-most (or top-level) qualifier being stripped last. +For example int const*const is first stripped to int *const then int *.

    @@ -1056,8 +1059,8 @@ To find a typemap for the argument const char *s, SWIG will search for

     const char *s           Exact type and name match
     const char *            Exact type match
    -char *s                 Type and name match (stripped qualifiers)
    -char *                  Type match (stripped qualifiers)
    +char *s                 Type and name match (qualifier stripped)
    +char *                  Type match (qualifier stripped)
     
    @@ -1097,6 +1100,11 @@ void F(int x[1000]); // int [ANY] rule (typemap 5) +

    +Compatibility note: SWIG-2.0.0 introduced stripping the qualifiers one step at a time. Prior versions +stripped all qualifiers in one step. +

    +

    10.3.2 Typedef reductions matching

    @@ -1280,7 +1288,7 @@ If the basic pattern matching rules result in no match being made, even after ty the default typemap matching rules are used to look for a suitable typemap match. These rules match a generic typemap based on the reserved SWIGTYPE base type. For example pointers will use SWIGTYPE * and references will use SWIGTYPE &. -More precisely, the rules are based on the C++ template partial specialization matching rules used +More precisely, the rules are based on the C++ class template partial specialization matching rules used by C++ compilers when looking for an appropriate partial template specialization. This means that a match is chosen from the most specialized set of generic typemap types available. For example, when looking for a match to int const *, the rules will prefer to match SWIGTYPE const * @@ -1407,11 +1415,10 @@ Finally the best way to view the typemap matching rules in action is via the Compatibility note: The default typemap matching rules were modified in SWIG-2.0.0 from a slightly -simpler scheme to match the current C++ template partial specialization matching rules. +simpler scheme to match the current C++ class template partial specialization matching rules.

    - -

    10.3.4 Multi-arguments typemaps

    +

    10.3.5 Multi-arguments typemaps

    @@ -1441,7 +1448,165 @@ but all subsequent arguments must match exactly.

    -

    10.3.5 Debugging typemap pattern matching

    +

    10.3.4 Matching rules compared to C++ templates

    + +

    +For those intimately familiar with C++ templates, a comparison of the typemap matching rules and template type deduction is interesting. +The two areas considered are firstly the default typemaps and their similarities to partial template specialization and secondly, non-default typemaps and their similarities to full template specialization. +

    + +

    +For default (SWIGTYPE) typemaps the rules are inspired by C++ class template +partial specialization. For example, given partial specialization for T const& : +

    + +
    +
    +template <typename T> struct X             { void a(); };
    +template <typename T> struct X< T const& > { void b(); };
    +
    +
    + +

    +The full (unspecialized) template is matched with most types, such as: +

    + +
    +
    +X< int & >            x1;  x1.a();
    +
    +
    + +

    +and the following all match the T const& partial specialization: +

    + +
    +
    +X< int *const& >      x2;  x2.b();
    +X< int const*const& > x3;  x3.b();
    +X< int const& >       x4;  x4.b();
    +
    +
    + +

    +Now, given just these two default typemaps, where T is analogous to SWIGTYPE: +

    + +
    +
    +%typemap(...) SWIGTYPE        { ... }
    +%typemap(...) SWIGTYPE const& { ... }
    +
    +
    + +

    +The generic default typemap SWIGTYPE is used with most types, such as +

    + +
    +
    +int &
    +
    +
    + +

    +and the following all match the SWIGTYPE const& typemap, just like the partial template matching: +

    + +
    +
    +int *const&
    +int const*const&
    +int const&
    +
    +
    + +

    +Note that the template and typemap matching rules are not identical for all default typemaps though, for example, with arrays. +

    + +

    +For non-default typemaps, one might expect SWIG to follow the fully specialized template rules. +This is nearly the case, but not quite. +Consider a very similar example to the earlier partially specialized template but this time there is a fully specialized template: +

    + +
    +
    +template <typename T> struct Y       { void a(); };
    +template <> struct Y< int const & >  { void b(); };
    +
    +
    + +

    +Only the one type matches the specialized template exactly: +

    + +
    +
    +Y< int & >             y1;  y1.a();
    +Y< int *const& >       y2;  y2.a();
    +Y< int const *const& > y3;  y3.a();
    +Y< int const& >        y4;  y4.b(); // fully specialized match
    +
    +
    + +

    +Given typemaps with the same types used for the template declared above, where T is again analogous to SWIGTYPE: +

    + +
    +
    +%typemap(...) SWIGTYPE        { ... }
    +%typemap(...) int const&      { ... }
    +
    +
    + +

    +The comparison between non-default typemaps and fully specialized single parameter templates turns out to be the same, as just the one type will match the non-default typemap: +

    + +
    +
    +int &
    +int *const&
    +int const*const&
    +int const&        // matches non-default typemap int const&
    +
    +
    + +

    +However, if a non-const type is used instead: +

    + +
    +
    +%typemap(...) SWIGTYPE        { ... }
    +%typemap(...) int &           { ... }
    +
    +
    + +

    +then there is a clear difference to template matching as both the const and non-const types match the typemap: +

    + +
    +
    +int &             // matches non-default typemap int &
    +int *const&
    +int const*const&
    +int const&        // matches non-default typemap int &
    +
    +
    + +

    +There are other subtle differences such as typedef handling, but at least it should be clear that the typemap matching rules +are similar to those for specialized template handling. +

    + + +

    10.3.6 Debugging typemap pattern matching

    diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 308ff9f1e..64dea58b7 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -393,6 +393,7 @@ CPP_TEST_CASES += \ typemap_numinputs \ typemap_template \ typemap_out_optimal \ + typemap_qualifier_strip \ typemap_variables \ typemap_various \ typename \ diff --git a/Examples/test-suite/python/typemap_qualifier_strip_runme.py b/Examples/test-suite/python/typemap_qualifier_strip_runme.py new file mode 100644 index 000000000..5e466cf69 --- /dev/null +++ b/Examples/test-suite/python/typemap_qualifier_strip_runme.py @@ -0,0 +1,54 @@ +import typemap_qualifier_strip + +val = typemap_qualifier_strip.create_int(111) +if typemap_qualifier_strip.testA1(val) != 1234: + raise RuntimeError + +if typemap_qualifier_strip.testA2(val) != 1234: + raise RuntimeError + +if typemap_qualifier_strip.testA3(val) != 1234: + raise RuntimeError + +if typemap_qualifier_strip.testA4(val) != 1234: + raise RuntimeError + + +if typemap_qualifier_strip.testB1(val) != 111: + raise RuntimeError + +if typemap_qualifier_strip.testB2(val) != 111: + raise RuntimeError + +if typemap_qualifier_strip.testB3(val) != 111: + raise RuntimeError + +if typemap_qualifier_strip.testB4(val) != 111: + raise RuntimeError + + +if typemap_qualifier_strip.testC1(val) != 5678: + raise RuntimeError + +if typemap_qualifier_strip.testC2(val) != 111: + raise RuntimeError + +if typemap_qualifier_strip.testC3(val) != 5678: + raise RuntimeError + +if typemap_qualifier_strip.testC4(val) != 111: + raise RuntimeError + + +if typemap_qualifier_strip.testD1(val) != 111: + raise RuntimeError + +if typemap_qualifier_strip.testD2(val) != 3456: + raise RuntimeError + +if typemap_qualifier_strip.testD3(val) != 111: + raise RuntimeError + +if typemap_qualifier_strip.testD4(val) != 111: + raise RuntimeError + diff --git a/Examples/test-suite/typemap_qualifier_strip.i b/Examples/test-suite/typemap_qualifier_strip.i new file mode 100644 index 000000000..d91a7b109 --- /dev/null +++ b/Examples/test-suite/typemap_qualifier_strip.i @@ -0,0 +1,76 @@ +%module typemap_qualifier_strip + +%typemap(in) int *ptr { + int temp = 1234; + $1 = &temp; +} + +%typemap(in) int *const ptrConst { + int temp = 5678; + $1 = &temp; +} + +%typemap(in) int const* constPtr { + int temp = 3456; + $1 = &temp; +} + +%inline %{ +int *create_int(int newval) { + static int val = 0; + val = newval; + return &val; +} +int testA1(int const*const ptr) { + return *ptr; +} +int testA2(int const* ptr) { + return *ptr; +} +int testA3(int *const ptr) { + return *ptr; +} +int testA4(int * ptr) { + return *ptr; +} + +int testB1(int const*const p) { + return *p; +} +int testB2(int const* p) { + return *p; +} +int testB3(int *const p) { + return *p; +} +int testB4(int * p) { + return *p; +} + +int testC1(int const*const ptrConst) { + return *ptrConst; +} +int testC2(int const* ptrConst) { + return *ptrConst; +} +int testC3(int *const ptrConst) { + return *ptrConst; +} +int testC4(int * ptrConst) { + return *ptrConst; +} + +int testD1(int const*const constPtr) { + return *constPtr; +} +int testD2(int const* constPtr) { + return *constPtr; +} +int testD3(int *const constPtr) { + return *constPtr; +} +int testD4(int * constPtr) { + return *constPtr; +} +%} + diff --git a/Source/Swig/stype.c b/Source/Swig/stype.c index 533b8195f..c984d639b 100644 --- a/Source/Swig/stype.c +++ b/Source/Swig/stype.c @@ -357,8 +357,8 @@ SwigType *SwigType_default_create(SwigType *ty) { * SwigType_default_deduce() * * This function implements type deduction used in the typemap matching rules - * and is very close to the type deduction used in partial template specialization - * matching in that the most specialized type is always chosen. + * and is very close to the type deduction used in partial template class + * specialization matching in that the most specialized type is always chosen. * SWIGTYPE is used as the generic type. The basic idea is to repeatedly call * this function to find a deduced type unless until nothing matches. * diff --git a/Source/Swig/swig.h b/Source/Swig/swig.h index 2b2c7f4cf..f90a5ffb1 100644 --- a/Source/Swig/swig.h +++ b/Source/Swig/swig.h @@ -159,6 +159,7 @@ extern "C" { extern int SwigType_isenum(SwigType *t); extern int SwigType_check_decl(SwigType *t, const_String_or_char_ptr decl); extern SwigType *SwigType_strip_qualifiers(SwigType *t); + extern SwigType *SwigType_strip_single_qualifier(SwigType *t); extern SwigType *SwigType_functionpointer_decompose(SwigType *t); extern String *SwigType_base(const SwigType *t); extern String *SwigType_namestr(const SwigType *t); diff --git a/Source/Swig/typemap.c b/Source/Swig/typemap.c index 37f8c3d82..cbe881577 100644 --- a/Source/Swig/typemap.c +++ b/Source/Swig/typemap.c @@ -698,11 +698,11 @@ static Hash *typemap_search(const_String_or_char_ptr tmap_method, SwigType *type Hash *backup = 0; SwigType *primitive = 0; SwigType *ctype = 0; + SwigType *ctype_unstripped = 0; int ts; int isarray; const String *cname = 0; const String *cqualifiedname = 0; - SwigType *unstripped = 0; String *tm_method = typemap_method_name(tmap_method); int debug_display = (in_typemap_search_multi == 0) && typemap_search_debug; @@ -718,7 +718,8 @@ static Hash *typemap_search(const_String_or_char_ptr tmap_method, SwigType *type Delete(typestr); } while (ts >= 0) { - ctype = type; + ctype = Copy(type); + ctype_unstripped = Copy(ctype); while (ctype) { /* Try to get an exact type-match */ tm = get_typemap(ts, ctype); @@ -751,29 +752,25 @@ static Hash *typemap_search(const_String_or_char_ptr tmap_method, SwigType *type goto ret_result; } - /* No match so far. If the type is unstripped, we'll strip its - qualifiers and check. Otherwise, we'll try to resolve a typedef */ - - if (!unstripped) { - unstripped = ctype; - ctype = SwigType_strip_qualifiers(ctype); - if (!Equal(ctype, unstripped)) - continue; /* Types are different */ - Delete(ctype); - ctype = unstripped; - unstripped = 0; - } + /* No match so far - try with a qualifier stripped (strip one qualifier at a time until none remain) + * The order of stripping in SwigType_strip_single_qualifier is used to provide some sort of consistency + * with the default (SWIGTYPE) typemap matching rules for the first qualifier to be stripped. */ { - String *octype; - if (unstripped) { - Delete(ctype); - ctype = unstripped; - unstripped = 0; + SwigType *oldctype = ctype; + ctype = SwigType_strip_single_qualifier(oldctype); + if (!Equal(ctype, oldctype)) { + Delete(oldctype); + continue; } - octype = ctype; - ctype = SwigType_typedef_resolve(ctype); - if (octype != type) - Delete(octype); + Delete(oldctype); + } + + /* Once all qualifiers are stripped try resolve a typedef */ + { + SwigType *oldctype = ctype; + ctype = SwigType_typedef_resolve(ctype_unstripped); + Delete(oldctype); + ctype_unstripped = Copy(ctype); } } @@ -802,12 +799,10 @@ static Hash *typemap_search(const_String_or_char_ptr tmap_method, SwigType *type ret_result: Delete(primitive); - if ((unstripped) && (unstripped != type)) - Delete(unstripped); if (matchtype) *matchtype = Copy(ctype); - if (type != ctype) - Delete(ctype); + Delete(ctype); + Delete(ctype_unstripped); return result; } diff --git a/Source/Swig/typeobj.c b/Source/Swig/typeobj.c index a2e23e52d..074bbf904 100644 --- a/Source/Swig/typeobj.c +++ b/Source/Swig/typeobj.c @@ -1125,3 +1125,62 @@ SwigType *SwigType_strip_qualifiers(SwigType *t) { } return r; } + +/* ----------------------------------------------------------------------------- + * SwigType_strip_single_qualifier() + * + * If the type contains a qualifier, strip one qualifier and return a new type. + * The left most qualifier is stripped first (when viewed as C source code) but + * this is the equivalent to the right most qualifier using SwigType notation. + * Example: + * r.q(const).p.q(const).int => r.q(const).p.int + * r.q(const).p.int => r.p.int + * r.p.int => r.p.int + * ----------------------------------------------------------------------------- */ + +SwigType *SwigType_strip_single_qualifier(SwigType *t) { + static Hash *memoize_stripped = 0; + SwigType *r = 0; + List *l; + int numitems; + + if (!memoize_stripped) + memoize_stripped = NewHash(); + r = Getattr(memoize_stripped, t); + if (r) + return Copy(r); + + l = SwigType_split(t); + + numitems = Len(l); + if (numitems >= 2) { + int item; + /* iterate backwards from last but one item */ + for (item = numitems - 2; item >= 0; --item) { + String *subtype = Getitem(l, item); + if (SwigType_isqualifier(subtype)) { + Iterator it; + Delitem(l, item); + r = NewStringEmpty(); + for (it = First(l); it.item; it = Next(it)) { + Append(r, it.item); + } + break; + } + } + } + if (!r) + r = Copy(t); + + Delete(l); + { + String *key, *value; + key = Copy(t); + value = Copy(r); + Setattr(memoize_stripped, key, value); + Delete(key); + Delete(value); + } + return r; +} + From 03bd7005bbbb6190280877b61a1f209b2c67bb22 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 3 May 2010 22:58:27 +0000 Subject: [PATCH 0839/1680] Fix typemap delete regression introduced in rev 11838 git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12008 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/common.mk | 1 + .../test-suite/python/typemap_delete_runme.py | 5 +++++ Examples/test-suite/typemap_delete.i | 16 ++++++++++++++++ Source/Swig/typemap.c | 8 ++++---- 4 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 Examples/test-suite/python/typemap_delete_runme.py create mode 100644 Examples/test-suite/typemap_delete.i diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 64dea58b7..831b1b78f 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -387,6 +387,7 @@ CPP_TEST_CASES += \ typedef_scope \ typedef_sizet \ typedef_struct \ + typemap_delete \ typemap_global_scope \ typemap_namespace \ typemap_ns_using \ diff --git a/Examples/test-suite/python/typemap_delete_runme.py b/Examples/test-suite/python/typemap_delete_runme.py new file mode 100644 index 000000000..582a2167c --- /dev/null +++ b/Examples/test-suite/python/typemap_delete_runme.py @@ -0,0 +1,5 @@ +import typemap_delete + +r = typemap_delete.Rect(123) +if r.val != 123: + raise RuntimeError diff --git a/Examples/test-suite/typemap_delete.i b/Examples/test-suite/typemap_delete.i new file mode 100644 index 000000000..eb6abe73c --- /dev/null +++ b/Examples/test-suite/typemap_delete.i @@ -0,0 +1,16 @@ +%module typemap_delete + +%typemap(in) Rect* (Rect temp) { + $1 = 0; + will_not_compile +} + +%typemap(in) Rect*; + +%inline %{ +struct Rect +{ + int val; + Rect(int v) : val(v) {} +}; +%} diff --git a/Source/Swig/typemap.c b/Source/Swig/typemap.c index cbe881577..2bf806e66 100644 --- a/Source/Swig/typemap.c +++ b/Source/Swig/typemap.c @@ -724,7 +724,7 @@ static Hash *typemap_search(const_String_or_char_ptr tmap_method, SwigType *type /* Try to get an exact type-match */ tm = get_typemap(ts, ctype); result = typemap_search_helper(debug_display, tm, tm_method, ctype, cqualifiedname, cname, &backup); - if (result) + if (result && Getattr(result, "code")) goto ret_result; { @@ -734,7 +734,7 @@ static Hash *typemap_search(const_String_or_char_ptr tmap_method, SwigType *type 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) + if (result && Getattr(result, "code")) goto ret_result; } } @@ -748,7 +748,7 @@ static Hash *typemap_search(const_String_or_char_ptr tmap_method, SwigType *type tm = get_typemap(ts, noarrays); result = typemap_search_helper(debug_display, tm, tm_method, noarrays, cqualifiedname, cname, &backup); Delete(noarrays); - if (result) + if (result && Getattr(result, "code")) goto ret_result; } @@ -780,7 +780,7 @@ static Hash *typemap_search(const_String_or_char_ptr tmap_method, SwigType *type while (primitive) { tm = get_typemap(ts, primitive); result = typemap_search_helper(debug_display, tm, tm_method, primitive, cqualifiedname, cname, &backup); - if (result) + if (result && Getattr(result, "code")) goto ret_result; { From f76fcb4eb4490cb244a31f17697f05b2f7f30676 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 5 May 2010 05:01:22 +0000 Subject: [PATCH 0840/1680] Memory leak fix handling const std::string & inputs, reported by Will Nolan. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12009 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 3 +++ Lib/r/rfragments.swg | 6 ++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 287a97e8f..7c57b7040 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,9 @@ Version 2.0.0 (in progress) ============================ +2010-05-05: wsfulton + [R] Memory leak fix handling const std::string & inputs, reported by Will Nolan. + 2010-05-01: wsfulton Typemap matching enhancement for non-default typemaps. Previously all qualifiers were stripped in one step, now they are stripped one at a time diff --git a/Lib/r/rfragments.swg b/Lib/r/rfragments.swg index f6191dfeb..7c8da2a5f 100644 --- a/Lib/r/rfragments.swg +++ b/Lib/r/rfragments.swg @@ -122,7 +122,7 @@ SWIGINTERN int SWIG_AsCharPtrAndSize(SEXP obj, char** cptr, size_t* psize, int *alloc) { if (cptr && Rf_isString(obj)) { - const char *cstr = CHAR(STRING_ELT(obj, 0)); + char *cstr = %const_cast(CHAR(STRING_ELT(obj, 0)), char *); int len = strlen(cstr); if (alloc) { @@ -130,9 +130,7 @@ SWIG_AsCharPtrAndSize(SEXP obj, char** cptr, size_t* psize, int *alloc) *cptr = %new_copy_array(cstr, len + 1, char); *alloc = SWIG_NEWOBJ; } else { - *cptr = %reinterpret_cast(malloc(len + 1), char *); - *cptr = strcpy(*cptr, cstr); - *alloc = SWIG_OLDOBJ; + *cptr = cstr; } } else { *cptr = %reinterpret_cast(malloc(len + 1), char *); From 5ff1e34ee66707e84f71926f403b23c60d43c68a Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 7 May 2010 18:13:15 +0000 Subject: [PATCH 0841/1680] fix my perl keyword warning git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12012 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/enums.i | 4 ++-- Examples/test-suite/octave/enums_runme.m | 2 +- Examples/test-suite/python/enums_runme.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Examples/test-suite/enums.i b/Examples/test-suite/enums.i index 40be28e94..5632b5e97 100644 --- a/Examples/test-suite/enums.i +++ b/Examples/test-suite/enums.i @@ -90,8 +90,8 @@ enum Exclamation { enum ContainYourself { slap = 10, - my, + mine, thigh -} Slap = slap, My = my, Thigh = thigh, *pThigh = &Thigh, arrayContainYourself[3] = {slap, my, thigh}; +} Slap = slap, Mine = mine, Thigh = thigh, *pThigh = &Thigh, arrayContainYourself[3] = {slap, mine, thigh}; %} diff --git a/Examples/test-suite/octave/enums_runme.m b/Examples/test-suite/octave/enums_runme.m index 789f7c9e4..b654d9d04 100644 --- a/Examples/test-suite/octave/enums_runme.m +++ b/Examples/test-suite/octave/enums_runme.m @@ -13,7 +13,7 @@ if (enums.cvar.Slap != 10) error endif -if (enums.cvar.My != 11) +if (enums.cvar.Mine != 11) error endif diff --git a/Examples/test-suite/python/enums_runme.py b/Examples/test-suite/python/enums_runme.py index e8dbe6942..8d491baf4 100644 --- a/Examples/test-suite/python/enums_runme.py +++ b/Examples/test-suite/python/enums_runme.py @@ -11,7 +11,7 @@ if _enums.cvar.enumInstance != 2: if _enums.cvar.Slap != 10: raise RuntimeError -if _enums.cvar.My != 11: +if _enums.cvar.Mine != 11: raise RuntimeError if _enums.cvar.Thigh != 12: From 68308583b7d9e86a215e06c18eb09fa942f45ec0 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 7 May 2010 19:10:41 +0000 Subject: [PATCH 0842/1680] Apply patch #2955146 from Sergey Satskiy to fix expressions containing divide by operator in constructor initialization lists. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12013 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++++ Examples/test-suite/common.mk | 1 + Examples/test-suite/expressions.i | 10 ++++++++++ Source/Swig/scanner.c | 4 ++++ 4 files changed, 19 insertions(+) create mode 100644 Examples/test-suite/expressions.i diff --git a/CHANGES.current b/CHANGES.current index 7c57b7040..a9d580153 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,10 @@ Version 2.0.0 (in progress) ============================ +2010-05-07: wsfulton + Apply patch #2955146 from Sergey Satskiy to fix expressions containing divide by + operator in constructor initialization lists. + 2010-05-05: wsfulton [R] Memory leak fix handling const std::string & inputs, reported by Will Nolan. diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 831b1b78f..1701dd8ba 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -193,6 +193,7 @@ CPP_TEST_CASES += \ extern_c \ extern_namespace \ extern_throws \ + expressions \ features \ fragments \ friends \ diff --git a/Examples/test-suite/expressions.i b/Examples/test-suite/expressions.i new file mode 100644 index 000000000..7b907ec3b --- /dev/null +++ b/Examples/test-suite/expressions.i @@ -0,0 +1,10 @@ +%module expressions + +%inline %{ +struct A +{ + A() : k( 20/(5-1) ) {} + A(int i) : k( 20/(5-1)*i /* comment */ ) {} + int k; +}; +%} diff --git a/Source/Swig/scanner.c b/Source/Swig/scanner.c index db7f0a06e..7f6e3e149 100644 --- a/Source/Swig/scanner.c +++ b/Source/Swig/scanner.c @@ -1182,6 +1182,10 @@ int Scanner_skip_balanced(Scanner * s, int startchar, int endchar) { state = 11; else if (c == '*') state = 12; + else if (c == startchar) { + state = 0; + num_levels++;; + } else state = 0; break; From 3d5d3a5bdbe2f7bda9a77dead6d729d83a618b8c Mon Sep 17 00:00:00 2001 From: Joseph Wang Date: Sun, 9 May 2010 15:39:31 +0000 Subject: [PATCH 0843/1680] change call for R to use mkCharLen where it exists (R versions >= 2.7.0). This is necessary because later versions of R (>= 2.8.0) depreciate creation of strings through vectors because this does not allow R to use character caches git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12014 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/r/rfragments.swg | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Lib/r/rfragments.swg b/Lib/r/rfragments.swg index 7c8da2a5f..8a0d85580 100644 --- a/Lib/r/rfragments.swg +++ b/Lib/r/rfragments.swg @@ -162,9 +162,20 @@ SWIG_FromCharPtrAndSize(const char* carray, size_t size) { SEXP t, c; if (!carray) return R_NilValue; +/* See R internals document 1.10. + MkCharLen was introduced in 2.7.0. Use that instead of hand + creating vector. + + Starting in 2.8.0 creating strings via vectors was deprecated in + order to allow for use of CHARSXP caches. */ + Rf_protect(t = Rf_allocVector(STRSXP, 1)); +#if R_VERSION >= R_Version(2,7,0) + c = Rf_mkCharLen(carray, size); +#else c = Rf_allocVector(CHARSXP, size); strncpy((char *)CHAR(c), carray, size); +#endif SET_STRING_ELT(t, 0, c); Rf_unprotect(1); return t; From 948748f8e8d9a15d400f5f4c39b3ed148b5b7709 Mon Sep 17 00:00:00 2001 From: Joseph Wang Date: Sun, 9 May 2010 15:41:24 +0000 Subject: [PATCH 0844/1680] update with r mkcharexp change git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12015 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index a9d580153..8ad55f8a7 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,10 @@ Version 2.0.0 (in progress) ============================ +2010-05-09: drjoe + Fix bug reported by Wil Nolan change creation of string so + that R 2.7.0+ can use char hashes + 2010-05-07: wsfulton Apply patch #2955146 from Sergey Satskiy to fix expressions containing divide by operator in constructor initialization lists. From 02b31416f6a7ea62a5959b391f17d78ada1590b1 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 10 May 2010 17:58:06 +0000 Subject: [PATCH 0845/1680] Some octave SWIG test-suite warning fixes git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12017 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/operator_overload.i | 2 ++ Lib/octave/std_basic_string.i | 2 ++ 2 files changed, 4 insertions(+) diff --git a/Examples/test-suite/operator_overload.i b/Examples/test-suite/operator_overload.i index b62bf5179..80facff76 100644 --- a/Examples/test-suite/operator_overload.i +++ b/Examples/test-suite/operator_overload.i @@ -45,6 +45,8 @@ see bottom for a set of possible tests %rename(MinusMinusPostfix) operator--(int); #endif +%rename(IndexInto) *::operator[](unsigned idx); // some languages have a %rename *::operator[] already in place, which seems to takes precedence over the above %rename operator[]. + #ifdef SWIGCSHARP %csmethodmodifiers operator++() "protected"; %csmethodmodifiers operator++(int) "private"; diff --git a/Lib/octave/std_basic_string.i b/Lib/octave/std_basic_string.i index 9fc0b0730..19712e8d0 100644 --- a/Lib/octave/std_basic_string.i +++ b/Lib/octave/std_basic_string.i @@ -32,6 +32,8 @@ SWIGINTERNINLINE octave_value } } +%ignore std::basic_string::operator +=; + %include %typemaps_asptrfromn(%checkcode(STRING), std::basic_string); From 64641c97504d71db5c3f5c29a3ccaa6539bab75a Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 10 May 2010 18:21:34 +0000 Subject: [PATCH 0846/1680] Fix compile errors in Octave std::map wrappers. Remove li_std_map_runme.oct which looks like Python code git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12018 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/octave/li_std_map_runme.m | 61 ------------------- Lib/octave/std_map.i | 8 +-- 2 files changed, 4 insertions(+), 65 deletions(-) delete mode 100644 Examples/test-suite/octave/li_std_map_runme.m diff --git a/Examples/test-suite/octave/li_std_map_runme.m b/Examples/test-suite/octave/li_std_map_runme.m deleted file mode 100644 index f37c78012..000000000 --- a/Examples/test-suite/octave/li_std_map_runme.m +++ /dev/null @@ -1,61 +0,0 @@ -li_std_map - -a1 = li_std_map.A(3); -a2 = li_std_map.A(7); - - -p0 = li_std_map.pairii(1,2); -p1 = li_std_map.pairA(1,a1.this); -m = {}; -m{1} = a1; -m{2} = a2; - -pp1 = li_std_map.p_identa(p1); -mm = li_std_map.m_identa(m); - - - -m = li_std_map.mapA(); -m{1} = a1; -m{2} = a2; - - -pm ={}; -for k in m, - pm{k} = m{k}; -endfor - -for k in m, - if (swig_this(pm{k}) != swig_this(m{k})) - error - endif -endfor - - - -m = {}; -m{1} = [1,2]; -m["foo"] = "hello"; - -pm = li_std_map.pymap(); - -for k in m, - pm{k} = m{k}; -endfor - -for k in pm, - if (pm{k} != m{k}) - error - endif -endfor - -mii = li_std_map.IntIntMap(); - -mii{1} = 1; -mii{1} = 2; - -if (mii[1] != 2) - error -endif - - diff --git a/Lib/octave/std_map.i b/Lib/octave/std_map.i index 20003df58..6c476ce53 100644 --- a/Lib/octave/std_map.i +++ b/Lib/octave/std_map.i @@ -92,10 +92,10 @@ }; template - struct OctMapIterator_T : SwigPyIteratorClosed_T + struct OctMapIterator_T : OctSwigIteratorClosed_T { OctMapIterator_T(OutIterator curr, OutIterator first, OutIterator last, octave_value seq) - : SwigPyIteratorClosed_T(curr, first, last, seq) + : OctSwigIteratorClosed_T(curr, first, last, seq) { } }; @@ -112,7 +112,7 @@ }; template - inline SwigPyIterator* + inline OctSwigIterator* make_output_key_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, octave_value seq = octave_value()) { return new OctMapKeyIterator_T(current, begin, end, seq); @@ -130,7 +130,7 @@ template - inline SwigPyIterator* + inline OctSwigIterator* make_output_value_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, octave_value seq = 0) { return new OctMapValueIterator_T(current, begin, end, seq); From e854baabec278d2235f4cef3cee69ae113ab0c64 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 11 May 2010 22:48:56 +0000 Subject: [PATCH 0847/1680] Change Octave to run C tests in SWIG C mode, not C++ mode git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12021 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/Makefile.in | 2 +- Examples/test-suite/octave/Makefile.in | 3 ++- Examples/test-suite/octave/octave_empty.c | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 Examples/test-suite/octave/octave_empty.c diff --git a/Examples/Makefile.in b/Examples/Makefile.in index 7f11884ee..cb8b7f4d4 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -346,7 +346,7 @@ OCTAVE_SO = @OCTAVE_SO@ octave: $(SRCS) $(SWIG) -octave $(SWIGOPT) $(INTERFACEPATH) $(CXX) -g -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(INCLUDES) -I$(OCTAVE_INCLUDE) - $(CC) -g -c $(CCSHARED) $(CFLAGS) $(SRCS) $(INCLUDES) + $(CC) -g -c $(CCSHARED) $(CFLAGS) $(SRCS) $(CSRCS) $(INCLUDES) $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(OCTAVE_DLNK) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(OCTAVE_SO) # ----------------------------------------------------------------- diff --git a/Examples/test-suite/octave/Makefile.in b/Examples/test-suite/octave/Makefile.in index a9a7649ec..0dbb6a1e5 100644 --- a/Examples/test-suite/octave/Makefile.in +++ b/Examples/test-suite/octave/Makefile.in @@ -32,6 +32,7 @@ include $(srcdir)/../common.mk # Overridden variables here LIBS = -L. +CSRCS = octave_empty.c # Custom tests - tests with additional commandline options # none! @@ -44,7 +45,7 @@ LIBS = -L. %.ctest: $(setup) - +$(swig_and_compile_cpp) + +$(swig_and_compile_c) $(run_testcase) %.multicpptest: diff --git a/Examples/test-suite/octave/octave_empty.c b/Examples/test-suite/octave/octave_empty.c new file mode 100644 index 000000000..9bb690bbd --- /dev/null +++ b/Examples/test-suite/octave/octave_empty.c @@ -0,0 +1 @@ +/* empty C file for the Octave test-suite C tests is needed - build system workaround as the generated files for Octave are C++ files */ From 3cf41050b56fcf5f3bea0d4368825e93e2111604 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 11 May 2010 22:53:33 +0000 Subject: [PATCH 0848/1680] Fix Octave C enums wrapping when the generated code is C++ compiled git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12022 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Octave.html | 20 ++++++++++++++------ Source/Modules/octave.cxx | 3 ++- Source/Modules/typepass.cxx | 6 +++++- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/Doc/Manual/Octave.html b/Doc/Manual/Octave.html index 7409d78f1..63663a474 100644 --- a/Doc/Manual/Octave.html +++ b/Doc/Manual/Octave.html @@ -58,17 +58,18 @@ Also, there are a dozen or so examples in the Examples/octave directory, and hun

    -The current SWIG implemention is based on Octave 2.9.12. Support for other versions (in particular the recent 3.0) has not been tested, nor has support for any OS other than Linux. +The SWIG implemention was first based on Octave 2.9.12, so this is the minimum version required. Testing has only been done on Linux.

    27.2 Running SWIG

    -Let's start with a very simple SWIG interface file: +Let's start with a very simple SWIG interface file, example.i:

    -
    %module example
    +
    +%module example
     %{
     #include "example.h"
     %}
    @@ -76,13 +77,20 @@ int gcd(int x, int y);
     extern double Foo; 

    -To build an Octave module, run SWIG using the -octave option. The -c++ option is required (for now) as Octave itself is written in C++ and thus the wrapper code must also be. +To build an Octave module when wrapping C code, run SWIG using the -octave option:

    +
    $ swig -octave example.i 
    + +

    +The -c++ option is also required when wrapping C++ code: +

    + +
    $ swig -octave -c++ example.i 

    -This creates a C/C++ source file example_wrap.cxx. The generated C++ source file contains the low-level wrappers that need to be compiled and linked with the rest of your C/C++ application (in this case, the gcd implementation) to create an extension module. +This creates a C++ source file example_wrap.cxx. A C++ file is generated even when wrapping C code as Octave is itself written in C++ and requires wrapper code to be in the same language. The generated C++ source file contains the low-level wrappers that need to be compiled and linked with the rest of your C/C++ application (in this case, the gcd implementation) to create an extension module.

    @@ -811,7 +819,7 @@ In the case where one wishes for the C++ side to own an object that was created

    -This is some skeleton support for various STL containers. +Various STL library files are provided for wrapping STL containers.

    27.3.17 Matrix typemaps

    diff --git a/Source/Modules/octave.cxx b/Source/Modules/octave.cxx index 16adddcce..db9592ad6 100644 --- a/Source/Modules/octave.cxx +++ b/Source/Modules/octave.cxx @@ -760,6 +760,7 @@ public: SwigType *type = Getattr(n, "type"); String *rawval = Getattr(n, "rawval"); String *value = rawval ? rawval : Getattr(n, "value"); + String *cppvalue = Getattr(n, "cppvalue"); String *tm; if (!addSymbol(iname, n)) @@ -775,7 +776,7 @@ public: if ((tm = Swig_typemap_lookup("constcode", n, name, 0))) { Replaceall(tm, "$source", value); Replaceall(tm, "$target", name); - Replaceall(tm, "$value", value); + Replaceall(tm, "$value", cppvalue ? cppvalue : value); Replaceall(tm, "$nsname", iname); Printf(f_init, "%s\n", tm); } else { diff --git a/Source/Modules/typepass.cxx b/Source/Modules/typepass.cxx index a975e350c..e63b58a10 100644 --- a/Source/Modules/typepass.cxx +++ b/Source/Modules/typepass.cxx @@ -807,11 +807,15 @@ class TypePass:private Dispatcher { value = name; if (Strcmp(value, name) == 0) { String *new_value; - if (((nsname) || (inclass)) && cparse_cplusplus) { + if ((nsname || inclass) && cparse_cplusplus) { new_value = NewStringf("%s::%s", SwigType_namestr(Swig_symbol_qualified(n)), value); } else { new_value = NewString(value); } + if ((nsname || inclass) && !cparse_cplusplus) { + String *cppvalue = NewStringf("%s::%s", SwigType_namestr(Swig_symbol_qualified(n)), value); + Setattr(n, "cppvalue", cppvalue); /* for target languages that always generate C++ code even when wrapping C code */ + } Setattr(n, "value", new_value); Delete(new_value); } From 70c557e8e3bb09f221f2624b2146f812c45c1bf5 Mon Sep 17 00:00:00 2001 From: Joseph Wang Date: Wed, 12 May 2010 04:12:42 +0000 Subject: [PATCH 0849/1680] add R garbage collection and newfree git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12023 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++++ Source/Modules/r.cxx | 24 ++++++++++++++++++++---- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 8ad55f8a7..5e1544160 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,10 @@ Version 2.0.0 (in progress) ============================ +2010-05-12: drjoe + [R] Add two more changes from Wil Nolan. Get garbage + collection to work. Implement newfree + 2010-05-09: drjoe Fix bug reported by Wil Nolan change creation of string so that R 2.7.0+ can use char hashes diff --git a/Source/Modules/r.cxx b/Source/Modules/r.cxx index 5ae2397b2..e4b246c4e 100644 --- a/Source/Modules/r.cxx +++ b/Source/Modules/r.cxx @@ -1673,7 +1673,7 @@ int R::functionWrapper(Node *n) { } p = nextSibling(p); } - + String *unresolved_return_type = Copy(type); if (expandTypedef(type) && @@ -1731,7 +1731,7 @@ int R::functionWrapper(Node *n) { Wrapper *f = NewWrapper(); Wrapper *sfun = NewWrapper(); - + int isVoidReturnType = (Strcmp(type, "void") == 0); // Need to use the unresolved return type since // typedef resolution removes the const which causes a @@ -2036,7 +2036,13 @@ int R::functionWrapper(Node *n) { Printv(f->code, cleanup, NIL); Delete(cleanup); - + /* Look to see if there is any newfree cleanup code */ + if (GetFlag(n, "feature:new")) { + if ((tm = Swig_typemap_lookup("newfree", n, "result", 0))) { + Replaceall(tm, "$source", "result"); /* deprecated */ + Printf(f->code, "%s\n", tm); + } + } Printv(f->code, UnProtectWrapupCode, NIL); @@ -2053,7 +2059,17 @@ int R::functionWrapper(Node *n) { 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\n", tm); + if (constructor) + { + String *finalizer = NewString(iname); + Replace(finalizer, "new_", "", DOH_REPLACE_FIRST); + Printf(sfun->code, "reg.finalizer(ans, delete_%s)\n", finalizer); + } + Printf(sfun->code, "ans\n"); + } + if (destructor) Printv(f->code, "R_ClearExternalPtr(self);\n", NIL); From 108f826a76c7a1b1dbd63c66c6c0b5238d81933a Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Wed, 12 May 2010 23:56:38 +0000 Subject: [PATCH 0850/1680] Fix typo in example in comment. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12024 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Swig/typesys.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Swig/typesys.c b/Source/Swig/typesys.c index 8d35c9746..f8cec14c9 100644 --- a/Source/Swig/typesys.c +++ b/Source/Swig/typesys.c @@ -79,7 +79,7 @@ char cvsroot_typesys_c[] = "$Id$"; * * class Bar : public Foo { * void blah(Integer x); - * } + * }; * * The argument type of Bar::blah will be set to Foo::Integer. * From 6a9a167e8e619d04b260c1c7152ca77e9e980fd1 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Fri, 14 May 2010 04:10:19 +0000 Subject: [PATCH 0851/1680] Fix typo in comment. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12025 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Swig/typesys.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Swig/typesys.c b/Source/Swig/typesys.c index f8cec14c9..2436e005c 100644 --- a/Source/Swig/typesys.c +++ b/Source/Swig/typesys.c @@ -1773,7 +1773,7 @@ void SwigType_inherit_equiv(File *out) { continue; } - /* This type has subclasses. We now need to walk through these subtypes and generate pointer converion functions */ + /* This type has subclasses. We now need to walk through these subtypes and generate pointer conversion functions */ rh = Getattr(r_resolved, rk.key); rlist = NewList(); From 1f4abe162d952e35e663eaf52c5ea2ee583e150b Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 14 May 2010 06:14:18 +0000 Subject: [PATCH 0852/1680] clarification on SWIG_VERSION coding git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12026 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Preprocessor.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/Manual/Preprocessor.html b/Doc/Manual/Preprocessor.html index d7917c41a..8d41efccf 100644 --- a/Doc/Manual/Preprocessor.html +++ b/Doc/Manual/Preprocessor.html @@ -102,7 +102,7 @@ by SWIG when it is parsing the interface:
     SWIG                            Always defined when SWIG is processing a file
     SWIGIMPORTED                    Defined when SWIG is importing a file with %import
    -SWIG_VERSION                    Hexadecimal number containing SWIG version,
    +SWIG_VERSION                    Hexadecimal (binary-coded decimal) number containing SWIG version,
                                     such as 0x010311 (corresponding to SWIG-1.3.11).
     
     SWIGALLEGROCL                   Defined when using Allegro CL
    
    From 227f2e2e0aa07b750ae976c3dda35fb442769a8a Mon Sep 17 00:00:00 2001
    From: Olly Betts 
    Date: Fri, 14 May 2010 08:22:28 +0000
    Subject: [PATCH 0853/1680] [PHP] Fix wrapping of global variables which was
     producing uncompilable code in some cases.
    
    git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12027 626c5289-ae23-0410-ae9c-e8d60b6d4f22
    ---
     CHANGES.current        | 4 ++++
     Source/Modules/php.cxx | 2 --
     2 files changed, 4 insertions(+), 2 deletions(-)
    
    diff --git a/CHANGES.current b/CHANGES.current
    index 5e1544160..28b80ad54 100644
    --- a/CHANGES.current
    +++ b/CHANGES.current
    @@ -1,6 +1,10 @@
     Version 2.0.0 (in progress)
     ============================
     
    +2010-05-14: olly
    +	    [PHP] Fix wrapping of global variables which was producing
    +	    uncompilable code in some cases.
    +
     2010-05-12: drjoe
     	    [R] Add two more changes from Wil Nolan.  Get garbage
     	    collection to work.  Implement newfree
    diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx
    index 09eb21dcd..700358ee4 100644
    --- a/Source/Modules/php.cxx
    +++ b/Source/Modules/php.cxx
    @@ -1779,8 +1779,6 @@ done:
         if (!addSymbol(iname, n))
           return SWIG_ERROR;
     
    -    SwigType_remember(t);
    -
         /* First link C variables to PHP */
     
         tm = Swig_typemap_lookup("varinit", n, name, 0);
    
    From 8a169eb0cb80b85d656f728b6659c6937dca9148 Mon Sep 17 00:00:00 2001
    From: William S Fulton 
    Date: Fri, 14 May 2010 18:46:20 +0000
    Subject: [PATCH 0854/1680] Fix wrapping of C++ enum boolean values
    
    git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12028 626c5289-ae23-0410-ae9c-e8d60b6d4f22
    ---
     CHANGES.current                |  4 ++++
     Examples/test-suite/cpp_enum.i | 13 ++++++++++++-
     Source/CParse/parser.y         |  6 +++---
     Source/Modules/csharp.cxx      |  7 +++++++
     4 files changed, 26 insertions(+), 4 deletions(-)
    
    diff --git a/CHANGES.current b/CHANGES.current
    index 28b80ad54..2cc874bb1 100644
    --- a/CHANGES.current
    +++ b/CHANGES.current
    @@ -1,6 +1,10 @@
     Version 2.0.0 (in progress)
     ============================
     
    +2010-05-14: wsfulton
    +            Fix wrapping of C++ enum boolean values reported by Torsten Landschoff:
    +              typedef enum { PLAY = true, STOP = false } play_state;
    +
     2010-05-14: olly
     	    [PHP] Fix wrapping of global variables which was producing
     	    uncompilable code in some cases.
    diff --git a/Examples/test-suite/cpp_enum.i b/Examples/test-suite/cpp_enum.i
    index e6eef6d0c..cb212615a 100644
    --- a/Examples/test-suite/cpp_enum.i
    +++ b/Examples/test-suite/cpp_enum.i
    @@ -24,7 +24,6 @@ struct StructWithEnums {
         enum SOME_ENUM& enum_test8() { return some_enum; };
     };
     
    -
      struct Foo
      {   
        enum {Hi, Hello } hola;
    @@ -41,3 +40,15 @@ extern "C"
     }
     
     %}
    +
    +// Using true and false in enums is legal in C++. Quoting the standard:
    +// [dcl.enum]
    +//     ... The constant-expression shall be of integral or enumeration type.
    +// [basic.fundamental]
    +//     ... Types bool, char, wchar_t, and the signed and unsigned integer
    +//     types are collectively called integral types.
    +// So this shouldn't lead to a warning, at least in C++ mode.
    +%inline %{
    +typedef enum { PLAY = true, STOP = false } play_state;
    +%}
    +
    diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y
    index 1990a66c6..6e41fa565 100644
    --- a/Source/CParse/parser.y
    +++ b/Source/CParse/parser.y
    @@ -5601,7 +5601,7 @@ edecl          :  ID {
     		     Setattr($$,"type",type);
     		     Delete(type);
     		   } else {
    -		     SwigType *type = NewSwigType(T_INT);
    +		     SwigType *type = NewSwigType($3.type == T_BOOL ? T_BOOL : T_INT);
     		     Setattr($$,"value",$1);
     		     Setattr($$,"type",type);
     		     Delete(type);
    @@ -5617,8 +5617,8 @@ etype            : expr {
     		       ($$.type != T_LONG) && ($$.type != T_ULONG) &&
     		       ($$.type != T_SHORT) && ($$.type != T_USHORT) &&
     		       ($$.type != T_SCHAR) && ($$.type != T_UCHAR) &&
    -		       ($$.type != T_CHAR)) {
    -		     Swig_error(cparse_file,cparse_line,"Type error. Expecting an int\n");
    +		       ($$.type != T_CHAR) && ($$.type != T_BOOL)) {
    +		     Swig_error(cparse_file,cparse_line,"Type error. Expecting an integral type\n");
     		   }
     		   if ($$.type == T_CHAR) $$.type = T_INT;
                     }
    diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx
    index f70403326..3dd51aabf 100644
    --- a/Source/Modules/csharp.cxx
    +++ b/Source/Modules/csharp.cxx
    @@ -1282,6 +1282,13 @@ public:
         // Note that this is used in enumValue() amongst other places
         Setattr(n, "value", tmpValue);
     
    +    // Deal with enum values that are bools
    +    if (SwigType_type(Getattr(n, "type")) == T_BOOL) {
    +      String *boolValue = NewStringf("%s ? 1 : 0", Getattr(n, "enumvalue"));
    +      Setattr(n, "enumvalue", boolValue);
    +      Delete(boolValue);
    +    }
    +
         {
           EnumFeature enum_feature = decodeEnumFeature(parent);
     
    
    From 76bbd7373d469149b8cfa091c32cf35d34861da3 Mon Sep 17 00:00:00 2001
    From: William S Fulton 
    Date: Fri, 14 May 2010 19:03:01 +0000
    Subject: [PATCH 0855/1680] Fix wrapping of C++ enum boolean values when using
     %javaconst(1)
    
    git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12029 626c5289-ae23-0410-ae9c-e8d60b6d4f22
    ---
     Examples/test-suite/java_enums.i | 6 ++++++
     Source/Modules/java.cxx          | 7 +++++++
     2 files changed, 13 insertions(+)
    
    diff --git a/Examples/test-suite/java_enums.i b/Examples/test-suite/java_enums.i
    index 4d2fe92c8..855913d06 100644
    --- a/Examples/test-suite/java_enums.i
    +++ b/Examples/test-suite/java_enums.i
    @@ -58,3 +58,9 @@ static const int FOUR = 4;
     %inline %{
     enum Numero { Quattro = FOUR };
     %}
    +
    +// Test boolean enums
    +%inline %{
    +typedef enum { PLAY = true, STOP = false } play_state;
    +%}
    +
    diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx
    index 5fecf8208..234af4c8e 100644
    --- a/Source/Modules/java.cxx
    +++ b/Source/Modules/java.cxx
    @@ -1352,6 +1352,13 @@ public:
         // Note that this is used in enumValue() amongst other places
         Setattr(n, "value", tmpValue);
     
    +    // Deal with enum values that are bools
    +    if (SwigType_type(Getattr(n, "type")) == T_BOOL) {
    +      String *boolValue = NewStringf("%s ? 1 : 0", Getattr(n, "enumvalue"));
    +      Setattr(n, "enumvalue", boolValue);
    +      Delete(boolValue);
    +    }
    +
         {
           EnumFeature enum_feature = decodeEnumFeature(parent);
     
    
    From d324633cfa25dfdcb66290c4bba2315adc07da5e Mon Sep 17 00:00:00 2001
    From: William S Fulton 
    Date: Fri, 14 May 2010 19:47:39 +0000
    Subject: [PATCH 0856/1680] Fix php limited precision test fix when dealing
     with large long long numbers
    
    git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12030 626c5289-ae23-0410-ae9c-e8d60b6d4f22
    ---
     Examples/test-suite/php/primitive_ref_runme.php | 15 ++++++++++++---
     1 file changed, 12 insertions(+), 3 deletions(-)
    
    diff --git a/Examples/test-suite/php/primitive_ref_runme.php b/Examples/test-suite/php/primitive_ref_runme.php
    index ab23fb1cc..263a28074 100644
    --- a/Examples/test-suite/php/primitive_ref_runme.php
    +++ b/Examples/test-suite/php/primitive_ref_runme.php
    @@ -3,6 +3,16 @@
     require "tests.php";
     require "primitive_ref.php";
     
    +# A large long long number is too big, so PHP makes treats it as a double, but SWIG opts to return it as a string.
    +# The conversion to double can lose precision so this isn't an exact comparison.
    +function long_long_equal($a,$b,$message) {
    +  if (! ($a===$b))
    +    if (! ((double)$a===$b))
    +      return check::fail($message . ": '$a'!=='$b'");
    +  return TRUE;
    +}
    +
    +
     check::equal(ref_over(3), 3, "ref_over failed");
     
     check::equal(ref_int(3), 3, "ref_int failed");
    @@ -17,9 +27,8 @@ 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");
    -# 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");
    +long_long_equal(ref_longlong(0x123456789ABCDEF0), 0x123456789ABCDEF0, "ref_longlong failed");
    +long_long_equal(ref_ulonglong(0xF23456789ABCDEF0), 0xF23456789ABCDEF0, "ref_ulonglong failed");
     
     check::done();
     ?>
    
    From 9df4479a08811b4e201fbfab972bb69dd41717f2 Mon Sep 17 00:00:00 2001
    From: William S Fulton 
    Date: Tue, 18 May 2010 21:18:43 +0000
    Subject: [PATCH 0857/1680] Fix member pointers on 64 bit platforms for Java
    
    git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12031 626c5289-ae23-0410-ae9c-e8d60b6d4f22
    ---
     CHANGES.current   |   3 ++
     Lib/java/java.swg | 101 +++++++++++++++++++++++++++++++++++++++++-----
     2 files changed, 95 insertions(+), 9 deletions(-)
    
    diff --git a/CHANGES.current b/CHANGES.current
    index 2cc874bb1..15883747d 100644
    --- a/CHANGES.current
    +++ b/CHANGES.current
    @@ -1,6 +1,9 @@
     Version 2.0.0 (in progress)
     ============================
     
    +2010-05-18: wsfulton
    +            [Java] Fix member pointers on 64 bit platforms.
    +
     2010-05-14: wsfulton
                 Fix wrapping of C++ enum boolean values reported by Torsten Landschoff:
                   typedef enum { PLAY = true, STOP = false } play_state;
    diff --git a/Lib/java/java.swg b/Lib/java/java.swg
    index 0fadf1604..44e1337bc 100644
    --- a/Lib/java/java.swg
    +++ b/Lib/java/java.swg
    @@ -11,6 +11,49 @@
      * The jtype typemap contains the Java type used in the JNI intermediary class. 
      * The jstype typemap contains the Java type used in the Java proxy classes, type wrapper classes and module class. */
     
    +/* Fragments */
    +%fragment("SWIG_PackData", "header") {
    +/* Pack binary data into a string */
    +SWIGINTERN char * SWIG_PackData(char *c, void *ptr, size_t sz) {
    +  static const char hex[17] = "0123456789abcdef";
    +  register const unsigned char *u = (unsigned char *) ptr;
    +  register const unsigned char *eu =  u + sz;
    +  for (; u != eu; ++u) {
    +    register unsigned char uu = *u;
    +    *(c++) = hex[(uu & 0xf0) >> 4];
    +    *(c++) = hex[uu & 0xf];
    +  }
    +  return c;
    +}
    +}
    +
    +%fragment("SWIG_UnPackData", "header") {
    +/* Unpack binary data from a string */
    +SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
    +  register unsigned char *u = (unsigned char *) ptr;
    +  register const unsigned char *eu = u + sz;
    +  for (; u != eu; ++u) {
    +    register char d = *(c++);
    +    register unsigned char uu;
    +    if ((d >= '0') && (d <= '9'))
    +      uu = ((d - '0') << 4);
    +    else if ((d >= 'a') && (d <= 'f'))
    +      uu = ((d - ('a'-10)) << 4);
    +    else 
    +      return (char *) 0;
    +    d = *(c++);
    +    if ((d >= '0') && (d <= '9'))
    +      uu |= (d - '0');
    +    else if ((d >= 'a') && (d <= 'f'))
    +      uu |= (d - ('a'-10));
    +    else 
    +      return (char *) 0;
    +    *u = uu;
    +  }
    +  return c;
    +}
    +}
    +
     /* Primitive types */
     %typemap(jni) bool,               const bool &               "jboolean"
     %typemap(jni) char,               const char &               "jchar"
    @@ -143,8 +186,8 @@
     %typemap(jstype) SWIGTYPE & "$javaclassname"
     
     /* pointer to a class member */
    -%typemap(jni) SWIGTYPE (CLASS::*) "jlong"
    -%typemap(jtype) SWIGTYPE (CLASS::*) "long"
    +%typemap(jni) SWIGTYPE (CLASS::*) "jstring"
    +%typemap(jtype) SWIGTYPE (CLASS::*) "String"
     %typemap(jstype) SWIGTYPE (CLASS::*) "$javaclassname"
     
     /* The following are the in, out, freearg, argout typemaps. These are the JNI code generating typemaps for converting from Java to C and visa versa. */
    @@ -592,20 +635,39 @@
     %typemap(javadirectorout) SWIGTYPE "$&javaclassname.getCPtr($javacall)"
     
     /* Generic pointers and references */
    -%typemap(in) SWIGTYPE *, SWIGTYPE (CLASS::*) %{ $1 = *($&1_ltype)&$input; %}
    +%typemap(in) SWIGTYPE * %{ $1 = *($&1_ltype)&$input; %}
    +%typemap(in, fragment="SWIG_UnPackData") SWIGTYPE (CLASS::*) { 
    +  const char *temp = 0;
    +  if ($input) {
    +    temp = JCALL2(GetStringUTFChars, jenv, $input, 0);
    +    if (!temp) return $null;
    +  }
    +  SWIG_UnpackData(temp, (void *)&$1, sizeof($1));
    +}
     %typemap(in) SWIGTYPE & %{ $1 = *($&1_ltype)&$input;
       if (!$1) {
         SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "$1_type reference is null");
         return $null;
       } %}
    -%typemap(out) SWIGTYPE *, SWIGTYPE (CLASS::*)
    +%typemap(out) SWIGTYPE *
     %{ *($&1_ltype)&$result = $1; %} 
    +%typemap(out, fragment="SWIG_PackData", noblock=1) SWIGTYPE (CLASS::*) {
    +  char buf[128];
    +  char *data = SWIG_PackData(buf, (void *)&$1, sizeof($1));
    +  *data = '\0';
    +  $result = JCALL1(NewStringUTF, jenv, buf);
    +}
     %typemap(out) SWIGTYPE &
     %{ *($&1_ltype)&$result = $1; %} 
     
    -%typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE *, SWIGTYPE (CLASS::*)
    +%typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE *
     %{ $result = *($&1_ltype)&$input; %}
    -%typemap(directorin,descriptor="L$packagepath/$javaclassname;") SWIGTYPE *, SWIGTYPE (CLASS::*)
    +%typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE (CLASS::*)
    +%{ $result = *($&1_ltype)&$input; %}
    +
    +%typemap(directorin,descriptor="L$packagepath/$javaclassname;") SWIGTYPE *
    +%{ *(($&1_ltype)&$input) = ($1_ltype) $1; %}
    +%typemap(directorin,descriptor="L$packagepath/$javaclassname;") SWIGTYPE (CLASS::*)
     %{ *(($&1_ltype)&$input) = ($1_ltype) $1; %}
     
     %typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE &
    @@ -967,7 +1029,8 @@
                      jobjectArray
         "$javainput"
     %typemap(javain) SWIGTYPE "$&javaclassname.getCPtr($javainput)"
    -%typemap(javain) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "$javaclassname.getCPtr($javainput)"
    +%typemap(javain) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] "$javaclassname.getCPtr($javainput)"
    +%typemap(javain) SWIGTYPE (CLASS::*) "$javaclassname.getCMemberPtr($javainput)"
     
     /* The javaout typemap is used for converting function return types from the return type
      * used in the JNI class to the type returned by the proxy, module or type wrapper class. */
    @@ -1020,10 +1083,14 @@
     %typemap(javaout) SWIGTYPE & {
         return new $javaclassname($jnicall, $owner);
       }
    -%typemap(javaout) SWIGTYPE *, SWIGTYPE [], SWIGTYPE (CLASS::*) {
    +%typemap(javaout) SWIGTYPE *, SWIGTYPE [] {
         long cPtr = $jnicall;
         return (cPtr == 0) ? null : new $javaclassname(cPtr, $owner);
       }
    +%typemap(javaout) SWIGTYPE (CLASS::*) {
    +    String cMemberPtr = $jnicall;
    +    return (cMemberPtr == null) ? null : new $javaclassname(cMemberPtr, $owner);
    +  }
     
     /* Pointer reference typemaps */
     %typemap(jni) SWIGTYPE *const& "jlong"
    @@ -1086,7 +1153,7 @@
     SWIG_JAVABODY_METHODS(public, public, SWIGTYPE)
     
     // Typewrapper classes
    -%typemap(javabody) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) %{
    +%typemap(javabody) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] %{
       private long swigCPtr;
     
       protected $javaclassname(long cPtr, boolean futureUse) {
    @@ -1102,6 +1169,22 @@ SWIG_JAVABODY_METHODS(public, public, SWIGTYPE)
       }
     %}
     
    +%typemap(javabody) SWIGTYPE (CLASS::*) %{
    +  private String swigCMemberPtr;
    +
    +  protected $javaclassname(String cMemberPtr, boolean futureUse) {
    +    swigCMemberPtr = cMemberPtr;
    +  }
    +
    +  protected $javaclassname() {
    +    swigCMemberPtr = null;
    +  }
    +
    +  protected static String getCMemberPtr($javaclassname obj) {
    +    return obj.swigCMemberPtr;
    +  }
    +%}
    +
     %typemap(javafinalize) SWIGTYPE %{
       protected void finalize() {
         delete();
    
    From e51209335836dcfdc9946a8fc23034ce798602f7 Mon Sep 17 00:00:00 2001
    From: Olly Betts 
    Date: Fri, 21 May 2010 07:07:15 +0000
    Subject: [PATCH 0858/1680] [PHP] Stop generating a bogus line of code in
     certain constructors. This was mostly harmless, but caused a PHP notice to be
     issued, if enabled (SF#2985684).
    
    git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12033 626c5289-ae23-0410-ae9c-e8d60b6d4f22
    ---
     CHANGES.current        |  5 +++++
     Source/Modules/php.cxx | 14 ++++++++------
     2 files changed, 13 insertions(+), 6 deletions(-)
    
    diff --git a/CHANGES.current b/CHANGES.current
    index 15883747d..68732468c 100644
    --- a/CHANGES.current
    +++ b/CHANGES.current
    @@ -1,6 +1,11 @@
     Version 2.0.0 (in progress)
     ============================
     
    +2010-05-21: olly
    +	    [PHP] Stop generating a bogus line of code in certain constructors.
    +	    This was mostly harmless, but caused a PHP notice to be issued, if
    +	    enabled (SF#2985684).
    +
     2010-05-18: wsfulton
                 [Java] Fix member pointers on 64 bit platforms.
     
    diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx
    index 700358ee4..c6f01c3e3 100644
    --- a/Source/Modules/php.cxx
    +++ b/Source/Modules/php.cxx
    @@ -1495,7 +1495,7 @@ public:
     	      Printf(prepare, "case %d: ", ++last_handled_i);
     	    }
     	    if (Cmp(d, "void") != 0) {
    -		if ((!directorsEnabled() || !Swig_directorclass(n)) && !newobject) {
    +	      if ((!directorsEnabled() || !Swig_directorclass(n)) && !newobject) {
     		Append(prepare, "$r=");
     	      } else {
     		Printf(prepare, "$this->%s=", SWIG_PTR);
    @@ -1631,11 +1631,13 @@ public:
     	Printf(output, "%s", prepare);
           if (constructor) {
     	if (!directorsEnabled() || !Swig_directorclass(n)) {
    -	  if (strcmp(methodname, "__construct") == 0) {
    -	    Printf(output, "\t\t$this->%s=%s;\n", SWIG_PTR, invoke);
    -	  } else {
    -	    String *classname = Swig_class_name(current_class);
    -	    Printf(output, "\t\treturn new %s(%s);\n", classname, invoke);
    +	  if (!Len(prepare)) {
    +	    if (strcmp(methodname, "__construct") == 0) {
    +	      Printf(output, "\t\t$this->%s=%s;\n", SWIG_PTR, invoke);
    +	    } else {
    +	      String *classname = Swig_class_name(current_class);
    +	      Printf(output, "\t\treturn new %s(%s);\n", classname, invoke);
    +	    }
     	  }
     	} else {
     	  Node *parent = Swig_methodclass(n);
    
    From bf1d3f0714f14bc91cc74b87d404f393bc48272a Mon Sep 17 00:00:00 2001
    From: Olly Betts 
    Date: Fri, 21 May 2010 07:10:12 +0000
    Subject: [PATCH 0859/1680] Remove superfluous semicolons.
    
    git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12034 626c5289-ae23-0410-ae9c-e8d60b6d4f22
    ---
     Source/Modules/chicken.cxx  | 2 +-
     Source/Modules/csharp.cxx   | 2 +-
     Source/Modules/guile.cxx    | 2 +-
     Source/Modules/java.cxx     | 2 +-
     Source/Modules/mzscheme.cxx | 2 +-
     Source/Modules/ocaml.cxx    | 2 +-
     Source/Modules/octave.cxx   | 4 ++--
     Source/Preprocessor/cpp.c   | 2 +-
     Source/Swig/scanner.c       | 2 +-
     9 files changed, 10 insertions(+), 10 deletions(-)
    
    diff --git a/Source/Modules/chicken.cxx b/Source/Modules/chicken.cxx
    index 9cac92dcb..07deb261a 100644
    --- a/Source/Modules/chicken.cxx
    +++ b/Source/Modules/chicken.cxx
    @@ -677,7 +677,7 @@ int CHICKEN::variableWrapper(Node *n) {
       String *wname = NewString("");
       String *mangle = NewString("");
       String *tm;
    -  String *tm2 = NewString("");;
    +  String *tm2 = NewString("");
       String *argnum = NewString("0");
       String *arg = NewString("argv[0]");
       Wrapper *f;
    diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx
    index 3dd51aabf..bedaae7f2 100644
    --- a/Source/Modules/csharp.cxx
    +++ b/Source/Modules/csharp.cxx
    @@ -3886,7 +3886,7 @@ public:
     
       int classDirectorConstructor(Node *n) {
         Node *parent = parentNode(n);
    -    String *decl = Getattr(n, "decl");;
    +    String *decl = Getattr(n, "decl");
         String *supername = Swig_class_name(parent);
         String *classname = directorClassName(parent);
         String *sub = NewString("");
    diff --git a/Source/Modules/guile.cxx b/Source/Modules/guile.cxx
    index 9e0f43daf..029978ede 100644
    --- a/Source/Modules/guile.cxx
    +++ b/Source/Modules/guile.cxx
    @@ -657,7 +657,7 @@ public:
         Parm *p;
         String *proc_name = 0;
         char source[256];
    -    Wrapper *f = NewWrapper();;
    +    Wrapper *f = NewWrapper();
         String *cleanup = NewString("");
         String *outarg = NewString("");
         String *signature = NewString("");
    diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx
    index 234af4c8e..ee68af948 100644
    --- a/Source/Modules/java.cxx
    +++ b/Source/Modules/java.cxx
    @@ -4066,7 +4066,7 @@ public:
     
       int classDirectorConstructor(Node *n) {
         Node *parent = parentNode(n);
    -    String *decl = Getattr(n, "decl");;
    +    String *decl = Getattr(n, "decl");
         String *supername = Swig_class_name(parent);
         String *classname = directorClassName(parent);
         String *sub = NewString("");
    diff --git a/Source/Modules/mzscheme.cxx b/Source/Modules/mzscheme.cxx
    index 5eb0a58c9..0bc3c8a68 100644
    --- a/Source/Modules/mzscheme.cxx
    +++ b/Source/Modules/mzscheme.cxx
    @@ -514,7 +514,7 @@ public:
     
         String *proc_name = NewString("");
         String *tm;
    -    String *tm2 = NewString("");;
    +    String *tm2 = NewString("");
         String *argnum = NewString("0");
         String *arg = NewString("argv[0]");
         Wrapper *f;
    diff --git a/Source/Modules/ocaml.cxx b/Source/Modules/ocaml.cxx
    index 7aa7286e9..4c266a7ab 100644
    --- a/Source/Modules/ocaml.cxx
    +++ b/Source/Modules/ocaml.cxx
    @@ -778,7 +778,7 @@ public:
     
         String *proc_name = NewString("");
         String *tm;
    -    String *tm2 = NewString("");;
    +    String *tm2 = NewString("");
         String *argnum = NewString("0");
         String *arg = NewString("SWIG_Field(args,0)");
         Wrapper *f;
    diff --git a/Source/Modules/octave.cxx b/Source/Modules/octave.cxx
    index db9592ad6..6c89794ec 100644
    --- a/Source/Modules/octave.cxx
    +++ b/Source/Modules/octave.cxx
    @@ -973,12 +973,12 @@ public:
           Delete(self);
         }
     
    -    return Language::constructorHandler(n);;
    +    return Language::constructorHandler(n);
       }
     
       virtual int destructorHandler(Node *n) {
         have_destructor = 1;
    -    return Language::destructorHandler(n);;
    +    return Language::destructorHandler(n);
       }
     
       virtual int staticmemberfunctionHandler(Node *n) {
    diff --git a/Source/Preprocessor/cpp.c b/Source/Preprocessor/cpp.c
    index feaa82ff8..5dd320994 100644
    --- a/Source/Preprocessor/cpp.c
    +++ b/Source/Preprocessor/cpp.c
    @@ -191,7 +191,7 @@ void Preprocessor_init(void) {
       Preprocessor_expr_init();	/* Initialize the expression evaluator */
       included_files = NewHash();
     
    -  id_scan = NewScanner();;
    +  id_scan = NewScanner();
     
     }
     
    diff --git a/Source/Swig/scanner.c b/Source/Swig/scanner.c
    index 7f6e3e149..9b5b35f96 100644
    --- a/Source/Swig/scanner.c
    +++ b/Source/Swig/scanner.c
    @@ -1184,7 +1184,7 @@ int Scanner_skip_balanced(Scanner * s, int startchar, int endchar) {
     	state = 12;
           else if (c == startchar) {
     	state = 0;
    -	num_levels++;;
    +	num_levels++;
           }
           else
     	state = 0;
    
    From 1fe29bae873b2c389a5bcdbfbc54dae9e7851d1b Mon Sep 17 00:00:00 2001
    From: Olly Betts 
    Date: Fri, 21 May 2010 07:37:40 +0000
    Subject: [PATCH 0860/1680] Remove superfluous semicolons
    
    git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12035 626c5289-ae23-0410-ae9c-e8d60b6d4f22
    ---
     Lib/lua/typemaps.i | 4 ++--
     1 file changed, 2 insertions(+), 2 deletions(-)
    
    diff --git a/Lib/lua/typemaps.i b/Lib/lua/typemaps.i
    index 084726e58..c96814613 100644
    --- a/Lib/lua/typemaps.i
    +++ b/Lib/lua/typemaps.i
    @@ -199,10 +199,10 @@ There probably is some compiler that its not true for, so the code is left here
     %{
     #ifdef __cplusplus	/* generic alloc/dealloc fns*/
     #define SWIG_ALLOC_ARRAY(TYPE,LEN) 	new TYPE[LEN]
    -#define SWIG_FREE_ARRAY(PTR)		delete[] PTR;
    +#define SWIG_FREE_ARRAY(PTR)		delete[] PTR
     #else
     #define SWIG_ALLOC_ARRAY(TYPE,LEN) 	(TYPE *)malloc(LEN*sizeof(TYPE))
    -#define SWIG_FREE_ARRAY(PTR)		free(PTR);
    +#define SWIG_FREE_ARRAY(PTR)		free(PTR)
     #endif
     /* counting the size of arrays:*/
     SWIGINTERN int SWIG_itable_size(lua_State* L, int index)
    
    From 12cfc251e423a526811b84ccb0f11fd7684cbc56 Mon Sep 17 00:00:00 2001
    From: William S Fulton 
    Date: Sat, 22 May 2010 22:49:47 +0000
    Subject: [PATCH 0861/1680] Fix #2408232. Improve shared_ptr and intrusive_ptr
     wrappers for classes in an inheritance hierarchy. No special treatment is
     needed for derived classes, the SWIG_SHARED_PTR_DERIVED macro is deprecated.
    
    git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12036 626c5289-ae23-0410-ae9c-e8d60b6d4f22
    ---
     CHANGES.current                              |  6 +++
     Examples/test-suite/li_boost_intrusive_ptr.i |  9 ++--
     Examples/test-suite/li_boost_shared_ptr.i    | 17 ++-----
     Lib/csharp/boost_shared_ptr.i                |  5 +-
     Lib/intrusive_ptr.i                          | 38 +-------------
     Lib/java/boost_intrusive_ptr.i               |  4 +-
     Lib/java/boost_shared_ptr.i                  |  6 +--
     Lib/octave/boost_shared_ptr.i                |  3 --
     Lib/python/boost_shared_ptr.i                |  3 --
     Lib/shared_ptr.i                             | 18 +------
     Source/Modules/csharp.cxx                    | 36 ++++++++++++--
     Source/Modules/java.cxx                      | 52 ++++++++++++++++----
     Source/Modules/typepass.cxx                  | 31 ++++++++++++
     13 files changed, 124 insertions(+), 104 deletions(-)
    
    diff --git a/CHANGES.current b/CHANGES.current
    index 68732468c..9e70c291e 100644
    --- a/CHANGES.current
    +++ b/CHANGES.current
    @@ -1,6 +1,12 @@
     Version 2.0.0 (in progress)
     ============================
     
    +2010-05-22: wsfulton
    +            Fix #2408232. Improve shared_ptr and intrusive_ptr wrappers for classes in an
    +            inheritance hierarchy. No special treatment is needed for derived classes, the
    +            SWIG_SHARED_PTR_DERIVED macro is deprecated and SWIG_SHARED_PTR should be used
    +            instead.
    +
     2010-05-21: olly
     	    [PHP] Stop generating a bogus line of code in certain constructors.
     	    This was mostly harmless, but caused a PHP notice to be issued, if
    diff --git a/Examples/test-suite/li_boost_intrusive_ptr.i b/Examples/test-suite/li_boost_intrusive_ptr.i
    index 47b64682a..23d78bcdc 100644
    --- a/Examples/test-suite/li_boost_intrusive_ptr.i
    +++ b/Examples/test-suite/li_boost_intrusive_ptr.i
    @@ -46,8 +46,8 @@
     %include 
     SWIG_INTRUSIVE_PTR(Klass, Space::Klass)
     SWIG_INTRUSIVE_PTR_NO_WRAP(KlassWithoutRefCount, Space::KlassWithoutRefCount)
    -SWIG_INTRUSIVE_PTR_DERIVED(KlassDerived, Space::KlassWithoutRefCount, Space::KlassDerived)
    -SWIG_INTRUSIVE_PTR_DERIVED(KlassDerivedDerived, Space::KlassDerived, Space::KlassDerivedDerived)
    +SWIG_INTRUSIVE_PTR(KlassDerived, Space::KlassDerived)
    +SWIG_INTRUSIVE_PTR(KlassDerivedDerived, Space::KlassDerivedDerived)
     
     //For the use_count shared_ptr functions
     %typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::Klass > & ($*1_ltype tempnull) %{ 
    @@ -390,9 +390,7 @@ Space::Klass & GlobalReference = GlobalValue;
     
     // Note: %template after the intrusive_ptr typemaps
     SWIG_INTRUSIVE_PTR(BaseIntDouble, Base)
    -// Note: cannot use Base in the macro below because of the comma in the type, 
    -// so we use a typedef instead. Alternatively use %arg(Base). %arg is defined in swigmacros.swg.
    -SWIG_INTRUSIVE_PTR_DERIVED(PairIntDouble, BaseIntDouble_t, Pair)
    +SWIG_INTRUSIVE_PTR(PairIntDouble, Pair)
     
     #endif
     
    @@ -409,7 +407,6 @@ template  struct Base {
       void release(void) const { if (--count == 0) delete this; }
       int use_count(void) const { return count; }
     };
    -typedef Base BaseIntDouble_t;
     %}
     
     %template(BaseIntDouble) Base;
    diff --git a/Examples/test-suite/li_boost_shared_ptr.i b/Examples/test-suite/li_boost_shared_ptr.i
    index 7a9468e4f..886a8d9c8 100644
    --- a/Examples/test-suite/li_boost_shared_ptr.i
    +++ b/Examples/test-suite/li_boost_shared_ptr.i
    @@ -42,15 +42,9 @@
     
     %include 
     SWIG_SHARED_PTR(Klass, Space::Klass)
    -SWIG_SHARED_PTR_DERIVED(KlassDerived, Space::Klass, Space::KlassDerived)
    -SWIG_SHARED_PTR_DERIVED(Klass2ndDerived, Space::Klass, Space::Klass2ndDerived)
    -SWIG_SHARED_PTR_DERIVED(Klass3rdDerived, Space::Klass2ndDerived, Space::Klass3rdDerived)
    -
    -// TEMP for python
    -%types(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< Space::Klass3rdDerived > = SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< Space::Klass >) {
    -  *newmemory = SWIG_CAST_NEW_MEMORY;
    -  return (void *) new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< Space::Klass >(*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< Space::Klass3rdDerived > *)$from);
    -}
    +SWIG_SHARED_PTR(KlassDerived, Space::KlassDerived)
    +SWIG_SHARED_PTR(Klass2ndDerived, Space::Klass2ndDerived)
    +SWIG_SHARED_PTR(Klass3rdDerived, Space::Klass3rdDerived)
     
     #endif
     
    @@ -324,9 +318,7 @@ Space::Klass & GlobalReference = GlobalValue;
     
     // Note: %template after the shared_ptr typemaps
     SWIG_SHARED_PTR(BaseIntDouble, Base)
    -// Note: cannot use Base in the macro below because of the comma in the type, 
    -// so we use a typedef instead. Alternatively use %arg(Base). %arg is defined in swigmacros.swg.
    -SWIG_SHARED_PTR_DERIVED(PairIntDouble, BaseIntDouble_t, Pair)
    +SWIG_SHARED_PTR(PairIntDouble, Pair)
     
     #endif
     
    @@ -339,7 +331,6 @@ template  struct Base {
       Base(T1 t1, T2 t2) : baseVal1(t1*2), baseVal2(t2*2) {}
       virtual std::string getValue() const { return "Base<>"; };
     };
    -typedef Base BaseIntDouble_t;
     %}
     
     %template(BaseIntDouble) Base;
    diff --git a/Lib/csharp/boost_shared_ptr.i b/Lib/csharp/boost_shared_ptr.i
    index 86a62c33c..8463c2b81 100644
    --- a/Lib/csharp/boost_shared_ptr.i
    +++ b/Lib/csharp/boost_shared_ptr.i
    @@ -190,7 +190,7 @@
       private HandleRef swigCPtr;
       private bool swigCMemOwnDerived;
     
    -  internal $csclassname(IntPtr cPtr, bool cMemoryOwn) : base($imclassname.$csclassname_SWIGSharedPtrUpcast(cPtr), true) {
    +  internal $csclassname(IntPtr cPtr, bool cMemoryOwn) : base($imclassname.$csclassname_SWIGSmartPtrUpcast(cPtr), true) {
         swigCMemOwnDerived = cMemoryOwn;
         swigCPtr = new HandleRef(this, cPtr);
       }
    @@ -227,9 +227,6 @@
         }
       }
     
    -%typemap(imtype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast "IntPtr"
    -%typemap(csin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast "PROXYCLASS.getCPtr($csinput).Handle"
    -
     
     %template() SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >;
     %enddef
    diff --git a/Lib/intrusive_ptr.i b/Lib/intrusive_ptr.i
    index 43e78f986..a7c922fea 100644
    --- a/Lib/intrusive_ptr.i
    +++ b/Lib/intrusive_ptr.i
    @@ -45,51 +45,17 @@ struct SWIG_null_deleter {
     }
     
     // Main user macro for defining intrusive_ptr typemaps for both const and non-const pointer types
    -// For plain classes, do not use for derived classes
     %define SWIG_INTRUSIVE_PTR(PROXYCLASS, TYPE...)
    +%feature("smartptr", noblock=1) TYPE { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > }
     SWIG_INTRUSIVE_PTR_TYPEMAPS(PROXYCLASS, , TYPE)
     SWIG_INTRUSIVE_PTR_TYPEMAPS(PROXYCLASS, const, TYPE)
     %enddef
     
    -// Main user macro for defining intrusive_ptr typemaps for both const and non-const pointer types
    -// For derived classes
    -%define SWIG_INTRUSIVE_PTR_DERIVED(PROXYCLASS, BASECLASSTYPE, TYPE...)
    -SWIG_INTRUSIVE_PTR_TYPEMAPS(PROXYCLASS, , TYPE)
    -SWIG_INTRUSIVE_PTR_TYPEMAPS(PROXYCLASS, const, TYPE)
    -%types(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > = SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< BASECLASSTYPE >) %{
    -  *newmemory = SWIG_CAST_NEW_MEMORY;
    -  return (void *) new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< BASECLASSTYPE >(*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *)$from);
    -  %}
    -%extend TYPE {
    -  static SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< BASECLASSTYPE > SWIGSharedPtrUpcast(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > swigSharedPtrUpcast) {
    -    return swigSharedPtrUpcast;
    -  }
    -}
    -%enddef
    -
     // Extra user macro for including classes in intrusive_ptr typemaps for both const and non-const pointer types
     // This caters for classes which cannot be wrapped by intrusive_ptrs but are still part of the class hierarchy
    -// For plain classes, do not use for derived classes
     %define SWIG_INTRUSIVE_PTR_NO_WRAP(PROXYCLASS, TYPE...)
    +%feature("smartptr", noblock=1) TYPE { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > }
     SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP(PROXYCLASS, , TYPE)
     SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP(PROXYCLASS, const, TYPE)
     %enddef
     
    -// Extra user macro for including classes in intrusive_ptr typemaps for both const and non-const pointer types
    -// This caters for classes which cannot be wrapped by intrusive_ptrs but are still part of the class hierarchy
    -// For derived classes
    -%define SWIG_INTRUSIVE_PTR_DERIVED_NO_WRAP(PROXYCLASS, BASECLASSTYPE, TYPE...)
    -SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP(PROXYCLASS, , TYPE)
    -SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP(PROXYCLASS, const, TYPE)
    -%types(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > = SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< BASECLASSTYPE >) %{
    -  *newmemory = SWIG_CAST_NEW_MEMORY;
    -  return (void *) new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< BASECLASSTYPE >(*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *)$from);
    -%}
    -%extend TYPE {
    -  static SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< BASECLASSTYPE > SWIGSharedPtrUpcast(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > swigSharedPtrUpcast) {
    -    return swigSharedPtrUpcast;
    -  }
    -}
    -%enddef
    -
    -
    diff --git a/Lib/java/boost_intrusive_ptr.i b/Lib/java/boost_intrusive_ptr.i
    index f7b7da32f..28446908f 100644
    --- a/Lib/java/boost_intrusive_ptr.i
    +++ b/Lib/java/boost_intrusive_ptr.i
    @@ -272,7 +272,7 @@
       private boolean swigCMemOwnDerived;
     
       protected $javaclassname(long cPtr, boolean cMemoryOwn) {
    -    super($imclassname.$javaclassname_SWIGSharedPtrUpcast(cPtr), true);
    +    super($imclassname.$javaclassname_SWIGSmartPtrUpcast(cPtr), true);
         swigCMemOwnDerived = cMemoryOwn;
         swigCPtr = cPtr;
       }
    @@ -422,7 +422,7 @@
       private boolean swigCMemOwnDerived;
     
       protected $javaclassname(long cPtr, boolean cMemoryOwn) {
    -    super($imclassname.$javaclassname_SWIGSharedPtrUpcast(cPtr), true);
    +    super($imclassname.$javaclassname_SWIGSmartPtrUpcast(cPtr), true);
         swigCMemOwnDerived = cMemoryOwn;
         swigCPtr = cPtr;
       }
    diff --git a/Lib/java/boost_shared_ptr.i b/Lib/java/boost_shared_ptr.i
    index 1c74a2453..5b89cafb7 100644
    --- a/Lib/java/boost_shared_ptr.i
    +++ b/Lib/java/boost_shared_ptr.i
    @@ -158,7 +158,7 @@
       private boolean swigCMemOwnDerived;
     
       protected $javaclassname(long cPtr, boolean cMemoryOwn) {
    -    super($imclassname.$javaclassname_SWIGSharedPtrUpcast(cPtr), true);
    +    super($imclassname.$javaclassname_SWIGSmartPtrUpcast(cPtr), true);
         swigCMemOwnDerived = cMemoryOwn;
         swigCPtr = cPtr;
       }
    @@ -189,10 +189,6 @@
         super.delete();
       }
     
    -// CONST version needed ???? also for C#
    -%typemap(jtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > swigSharedPtrUpcast "long"
    -%typemap(jtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast "long"
    -
     
     %template() SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >;
     %enddef
    diff --git a/Lib/octave/boost_shared_ptr.i b/Lib/octave/boost_shared_ptr.i
    index d702108a6..e475b2308 100644
    --- a/Lib/octave/boost_shared_ptr.i
    +++ b/Lib/octave/boost_shared_ptr.i
    @@ -12,9 +12,6 @@
     //"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
    diff --git a/Lib/python/boost_shared_ptr.i b/Lib/python/boost_shared_ptr.i
    index 59a3a9298..a3006e36a 100644
    --- a/Lib/python/boost_shared_ptr.i
    +++ b/Lib/python/boost_shared_ptr.i
    @@ -18,9 +18,6 @@
     //"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
    diff --git a/Lib/shared_ptr.i b/Lib/shared_ptr.i
    index ffff2b40b..877330721 100644
    --- a/Lib/shared_ptr.i
    +++ b/Lib/shared_ptr.i
    @@ -41,25 +41,9 @@ struct SWIG_null_deleter {
     
     
     // Main user macro for defining shared_ptr typemaps for both const and non-const pointer types
    -// For plain classes, do not use for derived classes
     %define SWIG_SHARED_PTR(PROXYCLASS, TYPE...)
    +%feature("smartptr", noblock=1) TYPE { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > }
     SWIG_SHARED_PTR_TYPEMAPS(PROXYCLASS, , TYPE)
     SWIG_SHARED_PTR_TYPEMAPS(PROXYCLASS, const, TYPE)
     %enddef
     
    -// Main user macro for defining shared_ptr typemaps for both const and non-const pointer types
    -// For derived classes
    -%define SWIG_SHARED_PTR_DERIVED(PROXYCLASS, BASECLASSTYPE, TYPE...)
    -SWIG_SHARED_PTR_TYPEMAPS(PROXYCLASS, , TYPE)
    -SWIG_SHARED_PTR_TYPEMAPS(PROXYCLASS, const, TYPE)
    -%types(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > = SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< BASECLASSTYPE >) %{
    -  *newmemory = SWIG_CAST_NEW_MEMORY;
    -  return (void *) new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< BASECLASSTYPE >(*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *)$from);
    -%}
    -%extend TYPE {
    -  static SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< BASECLASSTYPE > SWIGSharedPtrUpcast(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > swigSharedPtrUpcast) {
    -    return swigSharedPtrUpcast;
    -  }
    -}
    -%enddef
    -
    diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx
    index bedaae7f2..ba8f34b47 100644
    --- a/Source/Modules/csharp.cxx
    +++ b/Source/Modules/csharp.cxx
    @@ -1817,7 +1817,8 @@ public:
     
         // Add code to do C++ casting to base class (only for classes in an inheritance hierarchy)
         if (derived) {
    -      String *upcast_method = Swig_name_member(getNSpace(), proxy_class_name, "SWIGUpcast");
    +      String *smartptr = Getattr(n, "feature:smartptr");
    +      String *upcast_method = Swig_name_member(getNSpace(), proxy_class_name, smartptr != 0 ? "SWIGSmartPtrUpcast" : "SWIGUpcast");
           String *wname = Swig_name_wrapper(upcast_method);
     
           Printv(imclass_cppcasts_code, "\n  [DllImport(\"", dllimport, "\", EntryPoint=\"", wname, "\")]\n", NIL);
    @@ -1825,10 +1826,35 @@ public:
     
           Replaceall(imclass_cppcasts_code, "$csclassname", proxy_class_name);
     
    -      Printv(upcasts_code,
    -	     "SWIGEXPORT ", c_baseclass, " * SWIGSTDCALL ", wname,
    -	     "(", c_classname, " *jarg1) {\n", "    return (", c_baseclass, " *)jarg1;\n" "}\n", "\n", NIL);
    -
    +      if (smartptr) {
    +	SwigType *spt = Swig_cparse_type(smartptr);
    +	if (spt) {
    +	  SwigType *smart = SwigType_typedef_resolve_all(spt);
    +	  Delete(spt);
    +	  SwigType *bsmart = Copy(smart);
    +	  SwigType *rclassname = SwigType_typedef_resolve_all(c_classname);
    +	  SwigType *rbaseclass = SwigType_typedef_resolve_all(c_baseclass);
    +	  Replaceall(bsmart, rclassname, rbaseclass);
    +	  Delete(rclassname);
    +	  Delete(rbaseclass);
    +	  String *smartnamestr = SwigType_namestr(smart);
    +	  String *bsmartnamestr = SwigType_namestr(bsmart);
    +	  Printv(upcasts_code,
    +		 "SWIGEXPORT ", bsmartnamestr, " * SWIGSTDCALL ", wname, "(", smartnamestr, " *jarg1) {\n",
    +		 "    return jarg1 ? new ", bsmartnamestr, "(*jarg1) : 0;\n"
    +		 "}\n", "\n", NIL);
    +	  Delete(bsmartnamestr);
    +	  Delete(smartnamestr);
    +	  Delete(bsmart);
    +	} else {
    +	  Swig_error(Getfile(n), Getline(n), "Invalid type (%s) in 'smartptr' feature for class %s.\n", smartptr, c_classname);
    +	}
    +      } else {
    +	Printv(upcasts_code,
    +	       "SWIGEXPORT ", c_baseclass, " * SWIGSTDCALL ", wname, "(", c_classname, " *jarg1) {\n",
    +	       "    return (", c_baseclass, " *)jarg1;\n"
    +	       "}\n", "\n", NIL);
    +      }
           Delete(wname);
           Delete(upcast_method);
         }
    diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx
    index ee68af948..8c4770a9e 100644
    --- a/Source/Modules/java.cxx
    +++ b/Source/Modules/java.cxx
    @@ -1825,19 +1825,51 @@ public:
     
         // Add code to do C++ casting to base class (only for classes in an inheritance hierarchy)
         if (derived) {
    -      String *upcast_method = Swig_name_member(getNSpace(), proxy_class_name, "SWIGUpcast");
    +      String *smartptr = Getattr(n, "feature:smartptr");
    +      String *upcast_method = Swig_name_member(getNSpace(), proxy_class_name, smartptr != 0 ? "SWIGSmartPtrUpcast" : "SWIGUpcast");
           String *jniname = makeValidJniName(upcast_method);
           String *wname = Swig_name_wrapper(jniname);
    -
           Printf(imclass_cppcasts_code, "  public final static native long %s(long jarg1);\n", upcast_method);
    -
    -      Printv(upcasts_code,
    -	     "SWIGEXPORT jlong JNICALL ", wname, "(JNIEnv *jenv, jclass jcls, jlong jarg1) {\n",
    -	     "    jlong baseptr = 0;\n"
    -	     "    (void)jenv;\n" "    (void)jcls;\n" "    *(", c_baseclass, " **)&baseptr = *(", c_classname, " **)&jarg1;\n"
    -	     "    return baseptr;\n"
    -	     "}\n", "\n", NIL);
    -
    +      if (smartptr) {
    +	SwigType *spt = Swig_cparse_type(smartptr);
    +	if (spt) {
    +	  SwigType *smart = SwigType_typedef_resolve_all(spt);
    +	  Delete(spt);
    +	  SwigType *bsmart = Copy(smart);
    +	  SwigType *rclassname = SwigType_typedef_resolve_all(c_classname);
    +	  SwigType *rbaseclass = SwigType_typedef_resolve_all(c_baseclass);
    +	  Replaceall(bsmart, rclassname, rbaseclass);
    +	  Delete(rclassname);
    +	  Delete(rbaseclass);
    +	  String *smartnamestr = SwigType_namestr(smart);
    +	  String *bsmartnamestr = SwigType_namestr(bsmart);
    +	  Printv(upcasts_code,
    +		 "SWIGEXPORT jlong JNICALL ", wname, "(JNIEnv *jenv, jclass jcls, jlong jarg1) {\n",
    +		 "    jlong baseptr = 0;\n"
    +		 "    ", smartnamestr, " *argp1;\n"
    +		 "    ", bsmartnamestr, " result;\n"
    +		 "    (void)jenv;\n"
    +		 "    (void)jcls;\n"
    +		 "    argp1 = *(", smartnamestr, " **)&jarg1;\n"
    +		 "    *(", bsmartnamestr, " **)&baseptr = argp1 ? new ", bsmartnamestr, "(*argp1) : 0;\n"
    +		 "    return baseptr;\n"
    +		 "}\n", "\n", NIL);
    +	  Delete(bsmartnamestr);
    +	  Delete(smartnamestr);
    +	  Delete(bsmart);
    +	} else {
    +	  Swig_error(Getfile(n), Getline(n), "Invalid type (%s) in 'smartptr' feature for class %s.\n", smartptr, c_classname);
    +	}
    +      } else {
    +	Printv(upcasts_code,
    +	       "SWIGEXPORT jlong JNICALL ", wname, "(JNIEnv *jenv, jclass jcls, jlong jarg1) {\n",
    +	       "    jlong baseptr = 0;\n"
    +	       "    (void)jenv;\n"
    +	       "    (void)jcls;\n"
    +	       "    *(", c_baseclass, " **)&baseptr = *(", c_classname, " **)&jarg1;\n"
    +	       "    return baseptr;\n"
    +	       "}\n", "\n", NIL);
    +      }
           Delete(wname);
           Delete(jniname);
           Delete(upcast_method);
    diff --git a/Source/Modules/typepass.cxx b/Source/Modules/typepass.cxx
    index e63b58a10..57a7663eb 100644
    --- a/Source/Modules/typepass.cxx
    +++ b/Source/Modules/typepass.cxx
    @@ -231,6 +231,37 @@ class TypePass:private Dispatcher {
           Node *bclass = n;		/* Getattr(n,"class"); */
           Hash *scopes = Getattr(bclass, "typescope");
           SwigType_inherit(clsname, bname, cast, 0);
    +      String *smartptr = Getattr(first, "feature:smartptr");
    +      if (smartptr) {
    +	SwigType *smart = 0;
    +	SwigType *spt = Swig_cparse_type(smartptr);
    +	if (spt) {
    +	  smart = SwigType_typedef_resolve_all(spt);
    +	  Delete(spt);
    +	  /* Record a (fake) inheritance relationship between smart pointer
    +	     and smart pointer to base class, so that smart pointer upcasts
    +	     are automatically generated. */
    +          SwigType *bsmart = Copy(smart);
    +          SwigType *rclsname = SwigType_typedef_resolve_all(clsname);
    +          SwigType *rbname = SwigType_typedef_resolve_all(bname);
    +	  Replaceall(bsmart, rclsname, rbname);
    +          Delete(rclsname);
    +          Delete(rbname);
    +	  String *smartnamestr = SwigType_namestr(smart);
    +	  String *bsmartnamestr = SwigType_namestr(bsmart);
    +	  /* construct casting code */
    +	  String *convcode = NewStringf("\n    *newmemory = SWIG_CAST_NEW_MEMORY;\n    return (void *) new %s(*(%s *)$from);\n", bsmartnamestr, smartnamestr);
    +	  Delete(bsmartnamestr);
    +	  Delete(smartnamestr);
    +	  /* setup inheritance relationship between smart pointer templates */
    +	  SwigType_inherit(smart, bsmart, 0, convcode);
    +	  Delete(convcode);
    +	  Delete(bsmart);
    +	  Delete(smart);
    +	} else {
    +	  Swig_error(Getfile(first), Getline(first), "Invalid type (%s) in 'smartptr' feature for class %s.\n", smartptr, clsname);
    +	}
    +      }
           if (!importmode) {
     	String *btype = Copy(bname);
     	SwigType_add_pointer(btype);
    
    From 3dfac02269f5390ef44b98e5977b47d2eff883e8 Mon Sep 17 00:00:00 2001
    From: William S Fulton 
    Date: Sat, 22 May 2010 23:57:19 +0000
    Subject: [PATCH 0862/1680] shared_ptr improvements so the proxy class does not
     need to be specified - SWIG_SHARED_PTR macro deprecated and replaced by
     %shared_ptr
    
    git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12037 626c5289-ae23-0410-ae9c-e8d60b6d4f22
    ---
     CHANGES.current                               | 17 ++++++--
     Examples/test-suite/li_boost_intrusive_ptr.i  | 12 +++---
     Examples/test-suite/li_boost_shared_ptr.i     | 12 +++---
     .../test-suite/li_boost_shared_ptr_bits.i     |  2 +-
     Lib/csharp/boost_shared_ptr.i                 | 27 ++++++-------
     Lib/intrusive_ptr.i                           | 37 +++++++++++++----
     Lib/java/boost_intrusive_ptr.i                | 40 +++++++++----------
     Lib/java/boost_shared_ptr.i                   | 22 +++++-----
     Lib/octave/boost_shared_ptr.i                 |  2 +-
     Lib/python/boost_shared_ptr.i                 |  2 +-
     Lib/shared_ptr.i                              | 19 +++++++--
     11 files changed, 117 insertions(+), 75 deletions(-)
    
    diff --git a/CHANGES.current b/CHANGES.current
    index 9e70c291e..53ac43291 100644
    --- a/CHANGES.current
    +++ b/CHANGES.current
    @@ -1,11 +1,20 @@
     Version 2.0.0 (in progress)
     ============================
     
    -2010-05-22: wsfulton
    +2010-05-23: wsfulton
                 Fix #2408232. Improve shared_ptr and intrusive_ptr wrappers for classes in an
    -            inheritance hierarchy. No special treatment is needed for derived classes, the
    -            SWIG_SHARED_PTR_DERIVED macro is deprecated and SWIG_SHARED_PTR should be used
    -            instead.
    +            inheritance hierarchy. No special treatment is needed for derived classes.
    +            The proxy class also no longer needs to be specified, it is automatically
    +            deduced. The following macros are deprecated:
    +              SWIG_SHARED_PTR(PROXYCLASS, TYPE)
    +              SWIG_SHARED_PTR_DERIVED(PROXYCLASS, BASECLASSTYPE, TYPE)
    +            and have been replaced by
    +              %shared_ptr(TYPE)
    +            Similarly for intrusive_ptr wrappers, the following macro is deprecated:
    +              SWIG_INTRUSIVE_PTR(PROXYCLASS, TYPE)
    +              SWIG_INTRUSIVE_PTR_DERIVED(PROXYCLASS, BASECLASSTYPE, TYPE)
    +            and have been replaced by
    +              %intrusive_ptr(TYPE)
     
     2010-05-21: olly
     	    [PHP] Stop generating a bogus line of code in certain constructors.
    diff --git a/Examples/test-suite/li_boost_intrusive_ptr.i b/Examples/test-suite/li_boost_intrusive_ptr.i
    index 23d78bcdc..a84af4d45 100644
    --- a/Examples/test-suite/li_boost_intrusive_ptr.i
    +++ b/Examples/test-suite/li_boost_intrusive_ptr.i
    @@ -44,10 +44,10 @@
     #if defined(INTRUSIVE_PTR_WRAPPERS_IMPLEMENTED)
     
     %include 
    -SWIG_INTRUSIVE_PTR(Klass, Space::Klass)
    -SWIG_INTRUSIVE_PTR_NO_WRAP(KlassWithoutRefCount, Space::KlassWithoutRefCount)
    -SWIG_INTRUSIVE_PTR(KlassDerived, Space::KlassDerived)
    -SWIG_INTRUSIVE_PTR(KlassDerivedDerived, Space::KlassDerivedDerived)
    +%intrusive_ptr(Space::Klass)
    +%intrusive_ptr_no_wrap(Space::KlassWithoutRefCount)
    +%intrusive_ptr(Space::KlassDerived)
    +%intrusive_ptr(Space::KlassDerivedDerived)
     
     //For the use_count shared_ptr functions
     %typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::Klass > & ($*1_ltype tempnull) %{ 
    @@ -389,8 +389,8 @@ Space::Klass & GlobalReference = GlobalValue;
     #if defined(INTRUSIVE_PTR_WRAPPERS_IMPLEMENTED)
     
     // Note: %template after the intrusive_ptr typemaps
    -SWIG_INTRUSIVE_PTR(BaseIntDouble, Base)
    -SWIG_INTRUSIVE_PTR(PairIntDouble, Pair)
    +%intrusive_ptr(Base)
    +%intrusive_ptr(Pair)
     
     #endif
     
    diff --git a/Examples/test-suite/li_boost_shared_ptr.i b/Examples/test-suite/li_boost_shared_ptr.i
    index 886a8d9c8..f92df23a9 100644
    --- a/Examples/test-suite/li_boost_shared_ptr.i
    +++ b/Examples/test-suite/li_boost_shared_ptr.i
    @@ -41,10 +41,10 @@
     #if defined(SHARED_PTR_WRAPPERS_IMPLEMENTED)
     
     %include 
    -SWIG_SHARED_PTR(Klass, Space::Klass)
    -SWIG_SHARED_PTR(KlassDerived, Space::KlassDerived)
    -SWIG_SHARED_PTR(Klass2ndDerived, Space::Klass2ndDerived)
    -SWIG_SHARED_PTR(Klass3rdDerived, Space::Klass3rdDerived)
    +%shared_ptr(Space::Klass)
    +%shared_ptr(Space::KlassDerived)
    +%shared_ptr(Space::Klass2ndDerived)
    +%shared_ptr(Space::Klass3rdDerived)
     
     #endif
     
    @@ -317,8 +317,8 @@ Space::Klass & GlobalReference = GlobalValue;
     #if defined(SHARED_PTR_WRAPPERS_IMPLEMENTED)
     
     // Note: %template after the shared_ptr typemaps
    -SWIG_SHARED_PTR(BaseIntDouble, Base)
    -SWIG_SHARED_PTR(PairIntDouble, Pair)
    +%shared_ptr(Base)
    +%shared_ptr(Pair)
     
     #endif
     
    diff --git a/Examples/test-suite/li_boost_shared_ptr_bits.i b/Examples/test-suite/li_boost_shared_ptr_bits.i
    index 85ce1d6ab..4e144093e 100644
    --- a/Examples/test-suite/li_boost_shared_ptr_bits.i
    +++ b/Examples/test-suite/li_boost_shared_ptr_bits.i
    @@ -7,7 +7,7 @@
     #if defined(SHARED_PTR_WRAPPERS_IMPLEMENTED)
     
     %include 
    -SWIG_SHARED_PTR(NonDynamic, NonDynamic)
    +%shared_ptr(NonDynamic)
     
     #endif
     
    diff --git a/Lib/csharp/boost_shared_ptr.i b/Lib/csharp/boost_shared_ptr.i
    index 8463c2b81..f574f61d8 100644
    --- a/Lib/csharp/boost_shared_ptr.i
    +++ b/Lib/csharp/boost_shared_ptr.i
    @@ -1,7 +1,7 @@
     %include 
     
     // Language specific macro implementing all the customisations for handling the smart pointer
    -%define SWIG_SHARED_PTR_TYPEMAPS(PROXYCLASS, CONST, TYPE...)
    +%define SWIG_SHARED_PTR_TYPEMAPS(CONST, TYPE...)
     
     // %naturalvar is as documented for member variables
     %naturalvar TYPE;
    @@ -96,51 +96,51 @@
     %typemap (cstype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, 
                       SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &,
                       SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *,
    -                  SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& "PROXYCLASS"
    +                  SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& "$typemap(cstype, TYPE)"
     
     %typemap(csin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, 
                    SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &,
                    SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *,
    -               SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& "PROXYCLASS.getCPtr($csinput)"
    +               SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& "$typemap(cstype, TYPE).getCPtr($csinput)"
     
     %typemap(csout, excode=SWIGEXCODE) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > {
         IntPtr cPtr = $imcall;
    -    PROXYCLASS ret = (cPtr == IntPtr.Zero) ? null : new PROXYCLASS(cPtr, true);$excode
    +    $typemap(cstype, TYPE) ret = (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
         return ret;
       }
     %typemap(csout, excode=SWIGEXCODE) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & {
         IntPtr cPtr = $imcall;
    -    PROXYCLASS ret = (cPtr == IntPtr.Zero) ? null : new PROXYCLASS(cPtr, true);$excode
    +    $typemap(cstype, TYPE) ret = (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
         return ret;
       }
     %typemap(csout, excode=SWIGEXCODE) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * {
         IntPtr cPtr = $imcall;
    -    PROXYCLASS ret = (cPtr == IntPtr.Zero) ? null : new PROXYCLASS(cPtr, true);$excode
    +    $typemap(cstype, TYPE) ret = (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
         return ret;
       }
     %typemap(csout, excode=SWIGEXCODE) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& {
         IntPtr cPtr = $imcall;
    -    PROXYCLASS ret = (cPtr == IntPtr.Zero) ? null : new PROXYCLASS(cPtr, true);$excode
    +    $typemap(cstype, TYPE) ret = (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
         return ret;
       }
     
     
     %typemap(csout, excode=SWIGEXCODE) CONST TYPE {
    -    PROXYCLASS ret = new PROXYCLASS($imcall, true);$excode
    +    $typemap(cstype, TYPE) ret = new $typemap(cstype, TYPE)($imcall, true);$excode
         return ret;
       }
     %typemap(csout, excode=SWIGEXCODE) CONST TYPE & {
    -    PROXYCLASS ret = new PROXYCLASS($imcall, true);$excode
    +    $typemap(cstype, TYPE) ret = new $typemap(cstype, TYPE)($imcall, true);$excode
         return ret;
       }
     %typemap(csout, excode=SWIGEXCODE) CONST TYPE * {
         IntPtr cPtr = $imcall;
    -    PROXYCLASS ret = (cPtr == IntPtr.Zero) ? null : new PROXYCLASS(cPtr, true);$excode
    +    $typemap(cstype, TYPE) ret = (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
         return ret;
       }
     %typemap(csout, excode=SWIGEXCODE) TYPE *CONST& {
         IntPtr cPtr = $imcall;
    -    PROXYCLASS ret = (cPtr == IntPtr.Zero) ? null : new PROXYCLASS(cPtr, true);$excode
    +    $typemap(cstype, TYPE) ret = (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
         return ret;
       }
     
    @@ -159,13 +159,13 @@
     %typemap(csvarout, excode=SWIGEXCODE2) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & %{
         get {
           IntPtr cPtr = $imcall;
    -      PROXYCLASS ret = (cPtr == IntPtr.Zero) ? null : new PROXYCLASS(cPtr, true);$excode
    +      $typemap(cstype, TYPE) ret = (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
           return ret;
         } %}
     %typemap(csvarout, excode=SWIGEXCODE2) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * %{
         get {
           IntPtr cPtr = $imcall;
    -      PROXYCLASS ret = (cPtr == IntPtr.Zero) ? null : new PROXYCLASS(cPtr, true);$excode
    +      $typemap(cstype, TYPE) ret = (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
           return ret;
         } %}
     
    @@ -227,7 +227,6 @@
         }
       }
     
    -
     %template() SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >;
     %enddef
     
    diff --git a/Lib/intrusive_ptr.i b/Lib/intrusive_ptr.i
    index a7c922fea..eed750c79 100644
    --- a/Lib/intrusive_ptr.i
    +++ b/Lib/intrusive_ptr.i
    @@ -44,18 +44,39 @@ struct SWIG_null_deleter {
     %#define SWIG_NO_NULL_DELETER_1
     }
     
    +// Workaround empty first macro argument bug
    +#define SWIGEMPTYHACK
     // Main user macro for defining intrusive_ptr typemaps for both const and non-const pointer types
    +%define %intrusive_ptr(TYPE...)
    +%feature("smartptr", noblock=1) TYPE { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > }
    +SWIG_INTRUSIVE_PTR_TYPEMAPS(SWIGEMPTYHACK, TYPE)
    +SWIG_INTRUSIVE_PTR_TYPEMAPS(const, TYPE)
    +%enddef
    +
    +%define %intrusive_ptr_no_wrap(TYPE...)
    +%feature("smartptr", noblock=1) TYPE { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > }
    +SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP(SWIGEMPTYHACK, TYPE)
    +SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP(const, TYPE)
    +%enddef
    +
    +// Legacy macros
     %define SWIG_INTRUSIVE_PTR(PROXYCLASS, TYPE...)
    -%feature("smartptr", noblock=1) TYPE { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > }
    -SWIG_INTRUSIVE_PTR_TYPEMAPS(PROXYCLASS, , TYPE)
    -SWIG_INTRUSIVE_PTR_TYPEMAPS(PROXYCLASS, const, TYPE)
    +#warning "SWIG_INTRUSIVE_PTR(PROXYCLASS, TYPE) is deprecated. Please use %intrusive_ptr(TYPE) instead."
    +%intrusive_ptr(TYPE)
    +%enddef
    +
    +%define SWIG_INTRUSIVE_PTR_DERIVED(PROXYCLASS, BASECLASSTYPE, TYPE...)
    +#warning "SWIG_INTRUSIVE_PTR_DERIVED(PROXYCLASS, BASECLASSTYPE, TYPE) is deprecated. Please use %intrusive_ptr(TYPE) instead."
    +%intrusive_ptr(TYPE)
     %enddef
     
    -// Extra user macro for including classes in intrusive_ptr typemaps for both const and non-const pointer types
    -// This caters for classes which cannot be wrapped by intrusive_ptrs but are still part of the class hierarchy
     %define SWIG_INTRUSIVE_PTR_NO_WRAP(PROXYCLASS, TYPE...)
    -%feature("smartptr", noblock=1) TYPE { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > }
    -SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP(PROXYCLASS, , TYPE)
    -SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP(PROXYCLASS, const, TYPE)
    +#warning "SWIG_INTRUSIVE_PTR_NO_WRAP(PROXYCLASS, TYPE) is deprecated. Please use %intrusive_ptr_no_wrap(TYPE) instead."
    +%intrusive_ptr_no_wrap(TYPE)
    +%enddef
    +
    +%define SWIG_INTRUSIVE_PTR_DERIVED_NO_WRAP(PROXYCLASS, BASECLASSTYPE, TYPE...)
    +#warning "SWIG_INTRUSIVE_PTR_DERIVED_NO_WRAP(PROXYCLASS, BASECLASSTYPE, TYPE) is deprecated. Please use %intrusive_ptr_no_wrap(TYPE) instead."
    +%intrusive_ptr_no_wrap(TYPE)
     %enddef
     
    diff --git a/Lib/java/boost_intrusive_ptr.i b/Lib/java/boost_intrusive_ptr.i
    index 28446908f..52cf42b44 100644
    --- a/Lib/java/boost_intrusive_ptr.i
    +++ b/Lib/java/boost_intrusive_ptr.i
    @@ -1,7 +1,7 @@
     %include 
     
     // Language specific macro implementing all the customisations for handling the smart pointer
    -%define SWIG_INTRUSIVE_PTR_TYPEMAPS(PROXYCLASS, CONST, TYPE...)
    +%define SWIG_INTRUSIVE_PTR_TYPEMAPS(CONST, TYPE...)
     
     // %naturalvar is as documented for member variables
     %naturalvar TYPE;
    @@ -207,48 +207,48 @@
                       SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >,
                       SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > &,
                       SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *,
    -                  SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& "PROXYCLASS"
    +                  SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& "$typemap(jstype, TYPE)"
     %typemap(javain) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >,
                      SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >,
                      SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > &,
                      SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *,
    -                 SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& "PROXYCLASS.getCPtr($javainput)"
    +                 SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& "$typemap(jstype, TYPE).getCPtr($javainput)"
     
     %typemap(javaout) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > {
         long cPtr = $jnicall;
    -    return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true);
    +    return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true);
       }
     %typemap(javaout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > {
         long cPtr = $jnicall;
    -    return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true);
    +    return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true);
       }
     %typemap(javaout) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > & {
         long cPtr = $jnicall;
    -    return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true);
    +    return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true);
       }
     %typemap(javaout) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * {
         long cPtr = $jnicall;
    -    return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true);
    +    return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true);
       }
     %typemap(javaout) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& {
         long cPtr = $jnicall;
    -    return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true);
    +    return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true);
       }
     
     
     %typemap(javaout) CONST TYPE {
    -    return new PROXYCLASS($jnicall, true);
    +    return new $typemap(jstype, TYPE)($jnicall, true);
       }
     %typemap(javaout) CONST TYPE & {
    -    return new PROXYCLASS($jnicall, true);
    +    return new $typemap(jstype, TYPE)($jnicall, true);
       }
     %typemap(javaout) CONST TYPE * {
         long cPtr = $jnicall;
    -    return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true);
    +    return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true);
       }
     %typemap(javaout) TYPE *CONST& {
         long cPtr = $jnicall;
    -    return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true);
    +    return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true);
       }
     
     // Base proxy classes
    @@ -314,7 +314,7 @@
     
     %include 
     
    -%define SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP(PROXYCLASS, CONST, TYPE...)
    +%define SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP(CONST, TYPE...)
     
     %naturalvar TYPE;
     %naturalvar SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >;
    @@ -379,26 +379,26 @@
     
     %typemap (jni)    SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > "jlong"
     %typemap (jtype)  SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > "long"
    -%typemap (jstype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > "PROXYCLASS"
    -%typemap (javain) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > "PROXYCLASS.getCPtr($javainput)"
    +%typemap (jstype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > "$typemap(jstype, TYPE)"
    +%typemap (javain) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > "$typemap(jstype, TYPE).getCPtr($javainput)"
     %typemap(javaout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > {
         long cPtr = $jnicall;
    -    return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true);
    +    return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true);
       }
     
     %typemap(javaout) CONST TYPE {
    -    return new PROXYCLASS($jnicall, true);
    +    return new $typemap(jstype, TYPE)($jnicall, true);
       }
     %typemap(javaout) CONST TYPE & {
    -    return new PROXYCLASS($jnicall, true);
    +    return new $typemap(jstype, TYPE)($jnicall, true);
       }
     %typemap(javaout) CONST TYPE * {
         long cPtr = $jnicall;
    -    return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true);
    +    return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true);
       }
     %typemap(javaout) TYPE *CONST& {
         long cPtr = $jnicall;
    -    return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true);
    +    return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true);
       }
     
     // Base proxy classes
    diff --git a/Lib/java/boost_shared_ptr.i b/Lib/java/boost_shared_ptr.i
    index 5b89cafb7..06d839e2e 100644
    --- a/Lib/java/boost_shared_ptr.i
    +++ b/Lib/java/boost_shared_ptr.i
    @@ -1,7 +1,7 @@
     %include 
     
     // Language specific macro implementing all the customisations for handling the smart pointer
    -%define SWIG_SHARED_PTR_TYPEMAPS(PROXYCLASS, CONST, TYPE...)
    +%define SWIG_SHARED_PTR_TYPEMAPS(CONST, TYPE...)
     
     // %naturalvar is as documented for member variables
     %naturalvar TYPE;
    @@ -97,44 +97,44 @@
     %typemap (jstype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, 
                       SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &,
                       SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *,
    -                  SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& "PROXYCLASS"
    +                  SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& "$typemap(jstype, TYPE)"
     
     %typemap(javain) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, 
                      SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &,
                      SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *,
    -                 SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& "PROXYCLASS.getCPtr($javainput)"
    +                 SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& "$typemap(jstype, TYPE).getCPtr($javainput)"
     
     %typemap(javaout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > {
         long cPtr = $jnicall;
    -    return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true);
    +    return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true);
       }
     %typemap(javaout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & {
         long cPtr = $jnicall;
    -    return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true);
    +    return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true);
       }
     %typemap(javaout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * {
         long cPtr = $jnicall;
    -    return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true);
    +    return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true);
       }
     %typemap(javaout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& {
         long cPtr = $jnicall;
    -    return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true);
    +    return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true);
       }
     
     
     %typemap(javaout) CONST TYPE {
    -    return new PROXYCLASS($jnicall, true);
    +    return new $typemap(jstype, TYPE)($jnicall, true);
       }
     %typemap(javaout) CONST TYPE & {
    -    return new PROXYCLASS($jnicall, true);
    +    return new $typemap(jstype, TYPE)($jnicall, true);
       }
     %typemap(javaout) CONST TYPE * {
         long cPtr = $jnicall;
    -    return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true);
    +    return (cPtr == 0) ? null : new $typemap(jstype, TYPE)/*ha*/(cPtr, true);
       }
     %typemap(javaout) TYPE *CONST& {
         long cPtr = $jnicall;
    -    return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true);
    +    return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true);
       }
     
     // Base proxy classes
    diff --git a/Lib/octave/boost_shared_ptr.i b/Lib/octave/boost_shared_ptr.i
    index e475b2308..93b1a896f 100644
    --- a/Lib/octave/boost_shared_ptr.i
    +++ b/Lib/octave/boost_shared_ptr.i
    @@ -1,7 +1,7 @@
     %include 
     
     // Language specific macro implementing all the customisations for handling the smart pointer
    -%define SWIG_SHARED_PTR_TYPEMAPS(PROXYCLASS, CONST, TYPE...)
    +%define SWIG_SHARED_PTR_TYPEMAPS(CONST, TYPE...)
     
     // %naturalvar is as documented for member variables
     %naturalvar TYPE;
    diff --git a/Lib/python/boost_shared_ptr.i b/Lib/python/boost_shared_ptr.i
    index a3006e36a..e8c536026 100644
    --- a/Lib/python/boost_shared_ptr.i
    +++ b/Lib/python/boost_shared_ptr.i
    @@ -7,7 +7,7 @@
     #endif
     
     // Language specific macro implementing all the customisations for handling the smart pointer
    -%define SWIG_SHARED_PTR_TYPEMAPS(PROXYCLASS, CONST, TYPE...)
    +%define SWIG_SHARED_PTR_TYPEMAPS(CONST, TYPE...)
     
     // %naturalvar is as documented for member variables
     %naturalvar TYPE;
    diff --git a/Lib/shared_ptr.i b/Lib/shared_ptr.i
    index 877330721..77e868de2 100644
    --- a/Lib/shared_ptr.i
    +++ b/Lib/shared_ptr.i
    @@ -40,10 +40,23 @@ struct SWIG_null_deleter {
     }
     
     
    +// Workaround empty first macro argument bug
    +#define SWIGEMPTYHACK
     // Main user macro for defining shared_ptr typemaps for both const and non-const pointer types
    -%define SWIG_SHARED_PTR(PROXYCLASS, TYPE...)
    +%define %shared_ptr(TYPE...)
     %feature("smartptr", noblock=1) TYPE { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > }
    -SWIG_SHARED_PTR_TYPEMAPS(PROXYCLASS, , TYPE)
    -SWIG_SHARED_PTR_TYPEMAPS(PROXYCLASS, const, TYPE)
    +SWIG_SHARED_PTR_TYPEMAPS(SWIGEMPTYHACK, TYPE)
    +SWIG_SHARED_PTR_TYPEMAPS(const, TYPE)
    +%enddef
    +
    +// Legacy macros
    +%define SWIG_SHARED_PTR(PROXYCLASS, TYPE...)
    +#warning "SWIG_SHARED_PTR(PROXYCLASS, TYPE) is deprecated. Please use %shared_ptr(TYPE) instead."
    +%shared_ptr(TYPE)
    +%enddef
    +
    +%define SWIG_SHARED_PTR_DERIVED(PROXYCLASS, BASECLASSTYPE, TYPE...)
    +#warning "SWIG_SHARED_PTR_DERIVED(PROXYCLASS, BASECLASSTYPE, TYPE) is deprecated. Please use %shared_ptr(TYPE) instead."
    +%shared_ptr(TYPE)
     %enddef
     
    
    From 9c53d41e0fb61671896b44baefe980ac3017d566 Mon Sep 17 00:00:00 2001
    From: William S Fulton 
    Date: Sun, 23 May 2010 00:29:58 +0000
    Subject: [PATCH 0863/1680] nspace fixes for smart pointers
    
    git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12038 626c5289-ae23-0410-ae9c-e8d60b6d4f22
    ---
     Lib/csharp/boost_shared_ptr.i  |  2 +-
     Lib/java/boost_intrusive_ptr.i | 12 ++++++------
     Lib/java/boost_shared_ptr.i    |  8 ++++----
     3 files changed, 11 insertions(+), 11 deletions(-)
    
    diff --git a/Lib/csharp/boost_shared_ptr.i b/Lib/csharp/boost_shared_ptr.i
    index f574f61d8..54c2a6e87 100644
    --- a/Lib/csharp/boost_shared_ptr.i
    +++ b/Lib/csharp/boost_shared_ptr.i
    @@ -190,7 +190,7 @@
       private HandleRef swigCPtr;
       private bool swigCMemOwnDerived;
     
    -  internal $csclassname(IntPtr cPtr, bool cMemoryOwn) : base($imclassname.$csclassname_SWIGSmartPtrUpcast(cPtr), true) {
    +  internal $csclassname(IntPtr cPtr, bool cMemoryOwn) : base($imclassname.$csclazznameSWIGSmartPtrUpcast(cPtr), true) {
         swigCMemOwnDerived = cMemoryOwn;
         swigCPtr = new HandleRef(this, cPtr);
       }
    diff --git a/Lib/java/boost_intrusive_ptr.i b/Lib/java/boost_intrusive_ptr.i
    index 52cf42b44..8e7a57426 100644
    --- a/Lib/java/boost_intrusive_ptr.i
    +++ b/Lib/java/boost_intrusive_ptr.i
    @@ -256,7 +256,7 @@
       private long swigCPtr;
       private boolean swigCMemOwnBase;
     
    -  protected $javaclassname(long cPtr, boolean cMemoryOwn) {
    +  public $javaclassname(long cPtr, boolean cMemoryOwn) {
         swigCMemOwnBase = cMemoryOwn;
         swigCPtr = cPtr;
       }
    @@ -271,8 +271,8 @@
       private long swigCPtr;
       private boolean swigCMemOwnDerived;
     
    -  protected $javaclassname(long cPtr, boolean cMemoryOwn) {
    -    super($imclassname.$javaclassname_SWIGSmartPtrUpcast(cPtr), true);
    +  public $javaclassname(long cPtr, boolean cMemoryOwn) {
    +    super($imclassname.$javaclazznameSWIGSmartPtrUpcast(cPtr), true);
         swigCMemOwnDerived = cMemoryOwn;
         swigCPtr = cPtr;
       }
    @@ -406,7 +406,7 @@
       private long swigCPtr;
       private boolean swigCMemOwnBase;
     
    -  protected $javaclassname(long cPtr, boolean cMemoryOwn) {
    +  public $javaclassname(long cPtr, boolean cMemoryOwn) {
         swigCMemOwnBase = cMemoryOwn;
         swigCPtr = cPtr;
       }
    @@ -421,8 +421,8 @@
       private long swigCPtr;
       private boolean swigCMemOwnDerived;
     
    -  protected $javaclassname(long cPtr, boolean cMemoryOwn) {
    -    super($imclassname.$javaclassname_SWIGSmartPtrUpcast(cPtr), true);
    +  public $javaclassname(long cPtr, boolean cMemoryOwn) {
    +    super($imclassname.$javaclazznameSWIGSmartPtrUpcast(cPtr), true);
         swigCMemOwnDerived = cMemoryOwn;
         swigCPtr = cPtr;
       }
    diff --git a/Lib/java/boost_shared_ptr.i b/Lib/java/boost_shared_ptr.i
    index 06d839e2e..dd7344ea6 100644
    --- a/Lib/java/boost_shared_ptr.i
    +++ b/Lib/java/boost_shared_ptr.i
    @@ -130,7 +130,7 @@
       }
     %typemap(javaout) CONST TYPE * {
         long cPtr = $jnicall;
    -    return (cPtr == 0) ? null : new $typemap(jstype, TYPE)/*ha*/(cPtr, true);
    +    return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true);
       }
     %typemap(javaout) TYPE *CONST& {
         long cPtr = $jnicall;
    @@ -142,7 +142,7 @@
       private long swigCPtr;
       private boolean swigCMemOwnBase;
     
    -  protected $javaclassname(long cPtr, boolean cMemoryOwn) {
    +  public $javaclassname(long cPtr, boolean cMemoryOwn) {
         swigCMemOwnBase = cMemoryOwn;
         swigCPtr = cPtr;
       }
    @@ -157,8 +157,8 @@
       private long swigCPtr;
       private boolean swigCMemOwnDerived;
     
    -  protected $javaclassname(long cPtr, boolean cMemoryOwn) {
    -    super($imclassname.$javaclassname_SWIGSmartPtrUpcast(cPtr), true);
    +  public $javaclassname(long cPtr, boolean cMemoryOwn) {
    +    super($imclassname.$javaclazznameSWIGSmartPtrUpcast(cPtr), true);
         swigCMemOwnDerived = cMemoryOwn;
         swigCPtr = cPtr;
       }
    
    From 51bbc83fdd2cff376b5814c24f94e1e0b40bc17a Mon Sep 17 00:00:00 2001
    From: Olly Betts 
    Date: Sun, 23 May 2010 03:32:20 +0000
    Subject: [PATCH 0864/1680] Fix typo
    
    git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12039 626c5289-ae23-0410-ae9c-e8d60b6d4f22
    ---
     Doc/Manual/Modules.html | 2 +-
     1 file changed, 1 insertion(+), 1 deletion(-)
    
    diff --git a/Doc/Manual/Modules.html b/Doc/Manual/Modules.html
    index 094d4fd5d..5ce448ce6 100644
    --- a/Doc/Manual/Modules.html
    +++ b/Doc/Manual/Modules.html
    @@ -29,7 +29,7 @@
     

    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 +Exactly what this means and what the name is used for depends on the target language, for example the name can define a target language namespace or merely be a useful name for naming files or helper classes. Essentially, a module comprises target language wrappers for a chosen collection of global variables/functions, structs/classes and other C/C++ types. From 3f47ff6988c5e48617f5b4b43a50582a56c72919 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Sun, 23 May 2010 03:43:31 +0000 Subject: [PATCH 0865/1680] Fix more doubled word typos git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12040 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Allegrocl.html | 2 +- Doc/Manual/CSharp.html | 2 +- Doc/Manual/Customization.html | 2 +- Doc/Manual/Introduction.html | 2 +- Doc/Manual/Java.html | 8 ++++---- Doc/Manual/Lua.html | 4 ++-- Doc/Manual/Octave.html | 2 +- Doc/Manual/Pike.html | 2 +- Doc/Manual/Python.html | 4 ++-- Doc/Manual/Ruby.html | 4 ++-- Doc/Manual/SWIG.html | 2 +- Doc/Manual/Windows.html | 2 +- 12 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Doc/Manual/Allegrocl.html b/Doc/Manual/Allegrocl.html index 5cedee26b..5d00c4cd0 100644 --- a/Doc/Manual/Allegrocl.html +++ b/Doc/Manual/Allegrocl.html @@ -1777,7 +1777,7 @@ return-val wrapper-name(parm0, parm1, ..., parmN)

    - These three typemaps are specifically employed by the the + These three typemaps are specifically employed by the Allegro CL interface generator. SWIG also implements a number of other typemaps that can be used for generating code in the C/C++ wrappers. You can read about diff --git a/Doc/Manual/CSharp.html b/Doc/Manual/CSharp.html index 21b319e29..ea8b66e65 100644 --- a/Doc/Manual/CSharp.html +++ b/Doc/Manual/CSharp.html @@ -511,7 +511,7 @@ In the P/Invoke default marshalling scheme, one needs to designate whether the i array parameter as input, output, or both. When the function is invoked, the CLR allocates a separate chunk of memory as big as the given managed array, which is automatically released at the end of the function call. If the array parameter is marked as being input, the content of the managed array is copied into this buffer when the call is made. Correspondingly, if the array parameter is marked as being output, the contents of the reserved buffer are copied -back into the managed array after the call returns. A pointer to to this buffer +back into the managed array after the call returns. A pointer to this buffer is passed to the native function.

    diff --git a/Doc/Manual/Customization.html b/Doc/Manual/Customization.html index 734067475..b43075991 100644 --- a/Doc/Manual/Customization.html +++ b/Doc/Manual/Customization.html @@ -775,7 +775,7 @@ involving %feature:

    The name matching rules outlined in the Ambiguity resolution and renaming section applies to all %feature directives. -In fact the the %rename directive is just a special form of %feature. +In fact the %rename directive is just a special form of %feature. The matching rules mean that features are very flexible and can be applied with pinpoint accuracy to specific declarations if needed. Additionally, if no declaration name is given, a global feature is said to be defined. diff --git a/Doc/Manual/Introduction.html b/Doc/Manual/Introduction.html index df8d03fdf..4b954040b 100644 --- a/Doc/Manual/Introduction.html +++ b/Doc/Manual/Introduction.html @@ -365,7 +365,7 @@ possible to support different types of interfaces depending on the application.

    SWIG is a command line tool and as such can be incorporated into any build system that supports invoking external tools/compilers. -SWIG is most commonly invoked from within a Makefile, but is also known to be invoked from from popular IDEs such as +SWIG is most commonly invoked from within a Makefile, but is also known to be invoked from popular IDEs such as Microsoft Visual Studio.

    diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html index 857363840..366736eb7 100644 --- a/Doc/Manual/Java.html +++ b/Doc/Manual/Java.html @@ -1094,7 +1094,7 @@ C++ enums defined within a C++ class are generated into a static final inner Jav

    -Typesafe enums have their advantages over using plain integers in that they they can be used in a typesafe manner. +Typesafe enums have their advantages over using plain integers in that they can be used in a typesafe manner. However, there are limitations. For example, they cannot be used in switch statements and serialization is an issue. Please look at the following references for further information: @@ -2270,7 +2270,7 @@ For example, let's change the intermediary JNI class access to just the default

    -All the methods in the intermediary JNI class will then not be be callable outside of the package as the method modifiers have been changed from public access to default access. This is useful if you want to prevent users calling these low level functions. +All the methods in the intermediary JNI class will then not be callable outside of the package as the method modifiers have been changed from public access to default access. This is useful if you want to prevent users calling these low level functions.

    21.4.2 The Java module class

    @@ -2758,7 +2758,7 @@ You can encourage the garbage collector to call the finalizers, for example, add }

    Although this usually works, the documentation doesn't guarantee that runFinalization() will actually call the finalizers. -As the the shutdown hook is guaranteed you could also make a JNI call to clean up any resources that are being tracked by the C/C++ code.

    +As the shutdown hook is guaranteed you could also make a JNI call to clean up any resources that are being tracked by the C/C++ code.

  • @@ -4521,7 +4521,7 @@ code.

    This section describes how you can modify SWIG's default wrapping behavior for various C/C++ datatypes using the %typemap directive. -You are advised to be familiar with the the material in the "Typemaps" chapter. +You are advised to be familiar with the material in the "Typemaps" chapter. While not absolutely essential knowledge, this section assumes some familiarity with the Java Native Interface (JNI). JNI documentation can be consulted either online at Sun's Java web site or from a good JNI book. The following two books are recommended:

    diff --git a/Doc/Manual/Lua.html b/Doc/Manual/Lua.html index 53687d3de..a1544d21e 100644 --- a/Doc/Manual/Lua.html +++ b/Doc/Manual/Lua.html @@ -334,7 +334,7 @@ extern double Foo; %mutable;

    -SWIG will allow the the reading of Foo but when a set attempt is made, an error function will be called. +SWIG will allow the reading of Foo but when a set attempt is made, an error function will be called.

     > print(e.Foo) -- reading works ok
    @@ -1099,7 +1099,7 @@ userdata: 0003D880
     

    -Note: is is also possible (though tedious) to have a function throw several different kinds of exceptions. To process this +Note: it is also possible (though tedious) to have a function throw several different kinds of exceptions. To process this will require a pcall, followed by a set of if statements checking the type of the error.

    diff --git a/Doc/Manual/Octave.html b/Doc/Manual/Octave.html index 63663a474..de28a1427 100644 --- a/Doc/Manual/Octave.html +++ b/Doc/Manual/Octave.html @@ -239,7 +239,7 @@ extern double Foo;

    - SWIG will allow the the reading of Foo but when a set attempt is made, an error function will be called. + SWIG will allow the reading of Foo but when a set attempt is made, an error function will be called.

    octave:1> example
    diff --git a/Doc/Manual/Pike.html b/Doc/Manual/Pike.html
    index a47d07865..ad8976a14 100644
    --- a/Doc/Manual/Pike.html
    +++ b/Doc/Manual/Pike.html
    @@ -172,7 +172,7 @@ exactly as you'd expect it to:
     
     
     

    -Global variables are currently wrapped as a pair of of functions, one to get +Global variables are currently wrapped as a pair of functions, one to get the current value of the variable and another to set it. For example, the declaration

    diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html index aa50630be..8f876316e 100644 --- a/Doc/Manual/Python.html +++ b/Doc/Manual/Python.html @@ -1282,7 +1282,7 @@ something like this:

    This object is actually a Python instance that has been wrapped around a pointer to the low-level C structure. This instance doesn't actually do anything--it just serves as a proxy. -The pointer to the C object can be found in the the .this +The pointer to the C object can be found in the .this attribute. For example:

    @@ -3101,7 +3101,7 @@ customization features.

    Sometimes you may want to replace or modify the wrapper function that SWIG creates in the proxy .py file. The Python module -in SWIG provides some features that enable you do do this. First, to +in SWIG provides some features that enable you to do this. First, to entirely replace a proxy function you can use %feature("shadow"). For example:

    diff --git a/Doc/Manual/Ruby.html b/Doc/Manual/Ruby.html index 8684c355f..8b43962c5 100644 --- a/Doc/Manual/Ruby.html +++ b/Doc/Manual/Ruby.html @@ -10204,7 +10204,7 @@ the same underlying C++ object. This can cause problems. For example:
    -

    After the the garbage collector runs, as a result of our call +

    After the garbage collector runs, as a result of our call to GC.start, callingtiger2.get_name() causes a segmentation fault. The problem is that when tiger1 is garbage collected, it frees the underlying C++ object. Thus, when tiger2 @@ -10649,7 +10649,7 @@ initialization a normal Ruby interpreter will call the ruby_init() function which in turn will call a function called Init_stack or similar.  This function will store a pointer to the location where -the stack points at at that point in time.

    +the stack points at that point in time.

    diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html index e4a2a8c42..b4f332b14 100644 --- a/Doc/Manual/SWIG.html +++ b/Doc/Manual/SWIG.html @@ -92,7 +92,7 @@ chapters.

    -To run SWIG, use the swig command with options options and a filename like this: +To run SWIG, use the swig command with options and a filename like this:

    diff --git a/Doc/Manual/Windows.html b/Doc/Manual/Windows.html
    index 5d16a8b9f..e295fe307 100644
    --- a/Doc/Manual/Windows.html
    +++ b/Doc/Manual/Windows.html
    @@ -272,7 +272,7 @@ Execute the steps in the order shown and don't use spaces in path names. In fact
       
    • Answer y to the "do you wish to continue with the post install?"
    • Answer y to the "do you have MinGW installed?"
    • -
    • Type in the the folder in which you installed MinGW (C:/MinGW is default)
    • +
    • Type in the folder in which you installed MinGW (C:/MinGW is default)
  • From b89a0b24a96520a9ddef44a01b8e295a07383570 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Sun, 23 May 2010 03:56:15 +0000 Subject: [PATCH 0866/1680] More typo fixes git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12041 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Devel/cmdopt.html | 2 +- Doc/Devel/scanner.html | 9 ++------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/Doc/Devel/cmdopt.html b/Doc/Devel/cmdopt.html index c5f207c03..5e90d2aba 100644 --- a/Doc/Devel/cmdopt.html +++ b/Doc/Devel/cmdopt.html @@ -36,7 +36,7 @@ functions to mark whether or not a particular command line option was used. Thi

    Argument Marking

    -As command line options are are processed by language modules, the following functions are used +As command line options are processed by language modules, the following functions are used to mark the arguments as used:

    diff --git a/Doc/Devel/scanner.html b/Doc/Devel/scanner.html index 272216475..65ef1d8e9 100644 --- a/Doc/Devel/scanner.html +++ b/Doc/Devel/scanner.html @@ -77,7 +77,7 @@ string prior to using this function. Pushes a token into the scanner. This exact token will be returned by the next call to Scanner_token(). tokvalue is the integer token value to return and val is the token text to return. This function is only used to handle very special parsing cases. For instance, if you need the scanner to -return a ficticious token into order to enter a special parsing case. +return a fictitious token into order to enter a special parsing case.

    @@ -238,7 +238,7 @@ SWIG_TOKEN_PERIOD . SWIG_TOKEN_AT @ SWIG_TOKEN_DOLLAR $ SWIG_TOKEN_ENDLINE Literal newline -SWIG_TOKEN_ID identifer +SWIG_TOKEN_ID identifier SWIG_TOKEN_FLOAT Floating point with F suffix (e.g., 3.1415F) SWIG_TOKEN_DOUBLE Floating point (e.g., 3.1415 ) SWIG_TOKEN_INT Integer (e.g., 314) @@ -281,8 +281,3 @@ using these functions to write a yacc-compatible lexer. - - - - - From 17a6b5424a491a57ea8b6ae329668f087761356b Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Sun, 23 May 2010 04:08:44 +0000 Subject: [PATCH 0867/1680] Update to reflect current directory structure. Drop unwritten sections on differences from 1.1 (if nobody has yet written it, it seems unlikely anyone will), and plans for 2.0 (since we're about to release it). git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12042 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Devel/internals.html | 87 ++++++++++++---------------------------- 1 file changed, 26 insertions(+), 61 deletions(-) diff --git a/Doc/Devel/internals.html b/Doc/Devel/internals.html index 5f774c095..6ac3947f7 100644 --- a/Doc/Devel/internals.html +++ b/Doc/Devel/internals.html @@ -42,11 +42,9 @@ David M. Beazley

  • 3. Types and Typemaps
  • 4. Parsing -
  • 5. Difference Between SWIG 1.1 and SWIG 1.3 -
  • 6. Plans for SWIG 2.0 -
  • 7. C/C++ Wrapper Support Functions -
  • 8. Symbol Naming Guidelines for Generated C/C++ Code -
  • 9. Debugging SWIG +
  • 5. C/C++ Wrapper Support Functions +
  • 6. Symbol Naming Guidelines for Generated C/C++ Code +
  • 7. Debugging SWIG @@ -96,55 +94,35 @@ info. Source -SWIG source code is in this subdir tree. Directories marked w/ "(*)" -are used in building the swig executable. +The C and C++ source code for the swig executable is in this +subdir tree. - + + containers. - - - - - + - - + + - - - - + language has a .cxx and a .h file). - - + + - - - - - - - - - - + @@ -153,7 +131,7 @@ are used in building the swig executable. - + @@ -172,14 +150,14 @@ to look for code:
      -
    • Modules1.1/swigmain.cxx:main() is the program entry +
    • Modules/swigmain.cxx:main() is the program entry point. It parses the language-specifying command-line option (for example, -java), creating a new language-specific wrapping object (each language is a C++ class derived from base class Language). This object and the command-line is passed to SWIG_main(), whose return value is the program exit value. -
    • SWIG1.1/main.cxx:SWIG_main() is the "real" main. It +
    • Modules/main.cxx:SWIG_main() is the "real" main. It initializes the preprocessor and typemap machinery, defines some preprocessor symbols, locates the SWIG library, processes common command-line options, and then calls the language-specific command-line @@ -202,7 +180,7 @@ included -freeze, go into an infinite loop; otherwise return the error count.
    • The language-specific parse() (and all other -language-specific code) lives in Modules1.1/foo.{h,cxx} for +language-specific code) lives in Modules/foo.{h,cxx} for language Foo. Typically, FOO::parse() calls FOO::headers() and then the global function yyparse(), which uses the callbacks registered by SWIG_main() above. @@ -552,8 +530,7 @@ list item: listval5 The representation and manipulation of types is currently in the process of being reorganized and (hopefully) simplified. The following list describes the current set of functions that are used to -manipulate datatypes. These functions are different than in -SWIG1.1 and may change names in the final SWIG1.3 release. +manipulate datatypes.
      • SwigType_str(SwigType *t, char *name).
        @@ -709,19 +686,7 @@ repeated calls without making any copies. [TODO] -

        5. Difference Between SWIG 1.1 and SWIG 1.3

        -
        - -[TODO] - - -

        6. Plans for SWIG 2.0

        -
        - -[TODO] - - -

        7. The C/C++ Wrapping Layer

        +

        5. The C/C++ Wrapping Layer

        Added: Dave Beazley (July 22, 2000) @@ -1000,8 +965,8 @@ for specifying local variable declarations and argument conversions. - -

        8. Symbol Naming Guidelines for Generated C/C++ Code

        +
        +

        6. Symbol Naming Guidelines for Generated C/C++ Code

        The C++ standard (ISO/IEC 14882:1998(E)) states:
        @@ -1047,8 +1012,8 @@ For code compiled as C or C++ that attempts to mangle a wrapped symbol: In the past SWIG has generated many symbols which flout the standard especially double underscores. In fact they may not all be rooted out yet, so please fix them when you see them. - -

        9. Debugging SWIG

        +
        +

        7. Debugging SWIG

        Warning. Debugging SWIG is for the very patient.

        @@ -1099,7 +1064,7 @@ Please also read the Debugging Functions section in SWIG Par


        -Copyright (C) 1999-2004 SWIG Development Team. +Copyright (C) 1999-2010 SWIG Development Team. From a363a0361bb2965310c327194b1e02ab7af1ff4b Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Sun, 23 May 2010 04:58:40 +0000 Subject: [PATCH 0868/1680] Clean up the Modula-3 docs a bit. Refocus the introduction on matters that people reading it will actually want to know. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12043 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Modula3.html | 193 ++++++++-------------------------------- 1 file changed, 35 insertions(+), 158 deletions(-) diff --git a/Doc/Manual/Modula3.html b/Doc/Manual/Modula3.html index 228c181c0..ef15132b7 100644 --- a/Doc/Manual/Modula3.html +++ b/Doc/Manual/Modula3.html @@ -11,10 +11,7 @@
        • Overview
        • Conception
            @@ -49,7 +46,7 @@

            This chapter describes SWIG's support of -Modula-3. +Modula-3. You should be familiar with the basics of SWIG, @@ -59,14 +56,18 @@ especially

            24.1 Overview

            +

            +Modula-3 is a compiled language in the tradition of Niklaus Wirth's Modula 2, +which is in turn a successor to Pascal. +

            -The Modula-3 support is very basic and highly experimental! +SWIG's Modula-3 support is currently very basic and highly experimental! Many features are still not designed satisfyingly and I need more discussion about the odds and ends. Don't rely on any feature, incompatible changes are likely in the future! -The Modula-3 generator was already useful for interfacing -to the libraries +However, the Modula-3 generator was already useful for interfacing +to the libraries:

              @@ -78,130 +79,33 @@ PLPlot
            1. FFTW - . +
            +

            24.1.3 Motivation

            -I took some more time to explain -why I think it's right what I'm doing. -So the introduction got a bit longer than it should ... ;-) -

            - - -

            24.1.1 Why not scripting ?

            - - -

            -SWIG started as wrapper from the fast compiled languages C and C++ -to high level scripting languages like Python. -Although scripting languages are designed -to make programming life easier -by hiding machine internals from the programmer -there are several aspects of today's scripting languages -that are unfavourable in my opinion. +Although it is possible to write Modula-3 code that performs as well as C/C++ +most existing libraries are not written in Modula-3 but in C or C++, and +even libraries in other languages may provide C header files.

            -Besides C, C++, Cluster (a Modula derivate for Amiga computers) -I evaluated several scripting like languages in the past: -Different dialects of BASIC, -Perl, ARexx (a variant of Rexx for Amiga computers), -shell scripts. -I found them too inconsistent, -too weak in distinguishing types, -too weak in encapsulating pieces of code. -Eventually I have started several projects in Python -because of the fine syntax. -But when projects became larger -I lost the track. -I got convinced that one can not have -maintainable code in a language -that is not statically typed. -In fact the main advantages of scripting languages -e.g. matching regular expressions, -complex built-in datatypes like lists, dictionaries, -are not advantages of the language itself -but can be provided by function libraries. -

            - -

            24.1.2 Why Modula-3 ?

            - - -

            -Modula-3 is a compiler language -in the tradition of Niklaus Wirth's Modula 2, -which is in turn a successor of the popular Pascal. -I have chosen Modula-3 -because of its -logical syntax, -strong modularization, -the type system which is very detailed -for machine types compared to other languages. -Of course it supports all of the modern games -like exceptions, objects, garbage collection, threads. -While C++ programmers must -control three languages, -namely the preprocessor, C and ++, -Modula-3 is made in one go -and the language definition is really compact. +Fortunately Modula-3 can call C functions, but you have to write Modula-3 +interfaces to them, and to make things comfortable you will also need +wrappers that convert between high-level features of Modula-3 (garbage +collecting, exceptions) and the explicit tracking of allocated memory and +exception codes used by C APIs.

            -On the one hand Modula-3 can be safe -(but probably less efficient) in normal modules -while providing much static and dynamic safety. -On the other hand you can write efficient -but less safe code in the style of C -within UNSAFE modules. +SWIG converts C headers to Modula-3 interfaces for you, and using typemaps +you can pass TEXTs or open arrays, and convert error return codes +into exceptions.

            -Unfortunately Modula's safety and strength -requires more writing than scripting languages do. -Today if I want to safe characters -I prefer Haskell (similar to OCAML) - -it's statically typed, too. -

            - - -

            24.1.3 Why C / C++ ?

            - - -

            -Although it is no problem to write Modula-3 programs -that performs as fast as C -most libraries are not written in Modula-3 but in C. -Fortunately the binary interface of most function libraries -can be addressed by Modula-3. -Even more fortunately even non-C libraries may provide C header files. -This is where SWIG becomes helpful. -

            - -

            24.1.4 Why SWIG ?

            - - -

            -The C headers and the possibility to interface to C libraries -still leaves the work for you -to write Modula-3 interfaces to them. -To make things comfortable you will also need -wrappers that convert between high-level features of Modula-3 -(garbage collecting, exceptions) -and the low level of the C libraries. -

            - -

            -SWIG converts C headers to Modula-3 interfaces for you. -You could call the C functions without loss -of efficiency but it won't be joy -because you could not pass TEXTs -or open arrays and -you would have to process error return codes -rather then exceptions. -But using some typemaps SWIG will also generate -wrappers that bring the whole Modula-3 comfort to you. If the library API is ill designed writing appropriate typemaps can be still time-consuming. E.g. C programmers are very creative to work-around @@ -211,47 +115,20 @@ otherwise you lose static safety and consistency.

            - -But you have still a problem: -C library interfaces are often ill. -They lack for certain information -because C compilers wouldn't care about. -You should integrate detailed type information -by adding typedefs and consts -and you should persuade the C library programmer -to add this information to his interface. -Only this way other language users can benefit from your work -and only this way you can easily update your interfaces -when a new library version is released. - -You will realise that writing good SWIG interfaces -is very costly and it will only amortise -when considering evolving libraries. -

            - - -

            -Without SWIG you would probably never consider -to call C++ libraries from Modula-3. -But with SWIG this is worth a consideration. -SWIG can write C wrappers to C++ functions and object methods -that may throw exceptions. -In fact it breaks down C++ libraries to C interfaces -which can be in turn called from Modula-3. -To make it complete you can hide the C interface -with Modula-3 classes and exceptions. +Without SWIG you would probably never consider trying to call C++ libraries +from Modula-3, but with SWIG this is becomes feasible. +SWIG can generate C wrappers to C++ functions and object methods +that may throw exceptions, and then wrap these C wrappers for Module-3. +To make it complete you can then hide the C interface with Modula-3 classes and +exceptions.

            -Although SWIG does the best it can do -it can only serve as a one-way strategy. -That means you can use C++ libraries -with Modula-3 (even with call back functions), -but it's certainly not possible to smoothly -integrate Modula-3 code into a C / C++ project. +SWIG allows you to call C and C++ libraries from Modula-3 (even with call back +functions), but it doesn't allow you to easily integrate a Module-3 module into +a C/C++ project.

            -

            24.2 Conception

            @@ -259,7 +136,7 @@ integrate Modula-3 code into a C / C++ project.

            -Modula-3 has an integrated support for calling C functions. +Modula-3 has integrated support for calling C functions. This is also extensively used by the standard Modula-3 libraries to call OS functions. The Modula-3 part of SWIG and the corresponding SWIG library @@ -417,7 +294,7 @@ with a C interface.

            Here's a scheme of how the function calls to Modula-3 wrappers -a redirected to C library functions: +are redirected to C library functions:

    DOH (*)
    DOH C library providing memory allocation, file access and generic - containers. Result: libdoh.a
    Experiment[TODO]
    Include (*)
    Include Configuration .h files
    LParseParser (lex / yacc) files and support [why not (*)?!]
    CParseParser (lex / yacc) files and support
    Modules[TODO]
    Modules1.1 (*) Language-specific callbacks that does actual code generation (each - language has a .cxx and a .h file). Result: libmodules11.a
    Preprocessor (*)SWIG-specialized C/C++ preprocessor. Result: libcpp.a
    PreprocessorSWIG-specialized C/C++ preprocessor.
    SWIG1.1 (*)Parts of SWIG that are not language-specific, including option - processing and the type-mapping system. Result: libswig11.a. - Note: This directory is currently being phased out.
    SWIG1.3[TODO] [funny, nothing here is presently used for swig-1.3]. - This directory might turn into a compatibility interface between - SWIG1.3 and the SWIG1.1 modules.
    Swig (*)This directory contains the new ANSI C core of the system +
    SwigThis directory contains the ANSI C core of the system and contains generic functions related to types, file handling, scanning, and so forth.
    ToolsLibtool support and the mkdist.py script.The mkdist.py script and other tools.
    Win
    @@ -1058,8 +935,8 @@ where almost everything is generated by a typemap:
    • The Modula-3 part of SWIG doesn't try to generate nicely formatted code. -Use m3pp to postprocess the Modula files, -it does a very good job here. +If you need to read the generated code, use m3pp to postprocess the +Modula files.
    From a4febe779909fe257f14fa54967db1629286a2c8 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 23 May 2010 22:24:36 +0000 Subject: [PATCH 0869/1680] Fix #2957375 (C#) - SWIGStringHelper and SWIGExceptionHelper not always being initialized before use in .NET 4 as the intermediary class was not marked as beforefieldinit. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12044 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 16 ++++++++++++++++ Lib/csharp/csharphead.swg | 8 ++++++++ 2 files changed, 24 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 53ac43291..9839e13bc 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,22 @@ Version 2.0.0 (in progress) ============================ +2010-05-23: wsfulton + [C#] Fix #2957375 - SWIGStringHelper and SWIGExceptionHelper not always being + initialized before use in .NET 4 as the classes were not marked beforefieldinit. + A static constructor has been added to the intermediary class like this: + + %pragma(csharp) imclasscode=%{ + static $imclassname() { + } + %} + + If you had added your own custom static constructor to the intermediary class in + the same way as above, you will have to modify your approach to use static variable + initialization or define SWIG_CSHARP_NO_IMCLASS_STATIC_CONSTRUCTOR - See csharphead.swg. + + *** POTENTIAL INCOMPATIBILITY *** + 2010-05-23: wsfulton Fix #2408232. Improve shared_ptr and intrusive_ptr wrappers for classes in an inheritance hierarchy. No special treatment is needed for derived classes. diff --git a/Lib/csharp/csharphead.swg b/Lib/csharp/csharphead.swg index 9b144d6a5..a1c56a4b3 100644 --- a/Lib/csharp/csharphead.swg +++ b/Lib/csharp/csharphead.swg @@ -319,6 +319,14 @@ SWIGEXPORT void SWIGSTDCALL SWIGRegisterStringCallback_$module(SWIG_CSharpString %} #endif // SWIG_CSHARP_NO_STRING_HELPER +#if !defined(SWIG_CSHARP_NO_IMCLASS_STATIC_CONSTRUCTOR) +// Ensure the class is not marked beforefieldinit +%pragma(csharp) imclasscode=%{ + static $imclassname() { + } +%} +#endif + %insert(runtime) %{ /* Contract support */ From 1be936380fe678fe81f951acc88d9ca7842a9ec0 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 24 May 2010 06:02:11 +0000 Subject: [PATCH 0870/1680] S_ISDIR is defined for mingw gcc but not visual c++ git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12045 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Swig/misc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Source/Swig/misc.c b/Source/Swig/misc.c index f845d1a03..2ba7827a1 100644 --- a/Source/Swig/misc.c +++ b/Source/Swig/misc.c @@ -22,8 +22,10 @@ char cvsroot_misc_c[] = "$Id$"; #ifdef _WIN32 #include +#ifndef S_ISDIR #define S_ISDIR(mode) (((mode) & S_IFDIR) == S_IFDIR) #endif +#endif static char *fake_version = 0; From dc33d167bf35975062eacbff21149c81cdb0e15b Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Tue, 25 May 2010 06:08:08 +0000 Subject: [PATCH 0871/1680] Fix to work with PHP5 wrappers git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12046 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/php/proxy/runme.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Examples/php/proxy/runme.php b/Examples/php/proxy/runme.php index dea80e358..e70ab229f 100644 --- a/Examples/php/proxy/runme.php +++ b/Examples/php/proxy/runme.php @@ -9,10 +9,10 @@ include("example.php"); # ----- Object creation ----- print "Creating some objects:\n"; -$c = CircleFactory(10); -print " Created circle $c with area ". $c->area() ."\n"; +$c = example::CircleFactory(10); +print " Created circle \$c with area ". $c->area() ."\n"; $s = new Square(10); -print " Created square $s\n"; +print " Created square \$s\n"; # ----- Access a static member ----- @@ -37,7 +37,7 @@ print " Square = (" . $s->x . "," . $s->y . ")\n"; print "\nHere are some properties of the shapes:\n"; foreach (array($c,$s) as $o) { - print " ".get_class($o)." $o\n"; + print " ".get_class($o)." \$o\n"; print " x = " . $o->x . "\n"; print " y = " . $o->y . "\n"; print " area = " . $o->area() . "\n"; From 744bfd6118be34caef135e9d4770b39207f246b7 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Tue, 25 May 2010 06:24:03 +0000 Subject: [PATCH 0872/1680] Fix to work with PHP5 wrappers. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12047 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/php/disown/runme.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Examples/php/disown/runme.php b/Examples/php/disown/runme.php index 73d50786b..d90b03a9d 100644 --- a/Examples/php/disown/runme.php +++ b/Examples/php/disown/runme.php @@ -10,9 +10,9 @@ require("example.php"); print "Creating some objects:\n"; $c = new Circle(10); -print " Created circle $c\n"; +print " Created circle \$c\n"; $s = new Square(10); -print " Created square $s\n"; +print " Created square \$s\n"; # ----- Create the ShapeContainer ---- From ae8ac072da2b9824abd297dad9d3b7c87dca07f0 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Tue, 25 May 2010 06:25:28 +0000 Subject: [PATCH 0873/1680] Fix to work with PHP5 wrappers git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12048 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/php/overloading/runme.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Examples/php/overloading/runme.php b/Examples/php/overloading/runme.php index 5aa69048d..01044445f 100644 --- a/Examples/php/overloading/runme.php +++ b/Examples/php/overloading/runme.php @@ -10,9 +10,9 @@ include("example.php"); print "Creating some objects:\n"; $c = new Circle(10); -print " Created circle $c\n"; +print " Created circle \$c\n"; $s = new Square(10); -print " Created square $s\n"; +print " Created square \$s\n"; # ----- Access a static member ----- @@ -37,7 +37,7 @@ print " Square = (" . $s->x . "," . $s->y . ")\n"; print "\nHere are some properties of the shapes:\n"; foreach (array(1, 2.1, "quick brown fox", $c, $s) as $o) { - print " ".get_class($o)." $o\n"; + print " ".get_class($o)." \$o\n"; print " overloaded = " . overloaded($o) . "\n"; } From 314d4f17de0b2ae6807ae588b4e42de8ca22779c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 25 May 2010 06:43:21 +0000 Subject: [PATCH 0874/1680] Fix running R examples and update docs about R CMD SHLIB git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12049 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/R.html | 34 +++++++++++++++++++++++++++------- Examples/Makefile.in | 4 ++-- Examples/r/class/Makefile | 5 +---- Examples/r/simple/Makefile | 7 +++---- 4 files changed, 33 insertions(+), 17 deletions(-) diff --git a/Doc/Manual/R.html b/Doc/Manual/R.html index 0ed43fc52..e8cee6448 100644 --- a/Doc/Manual/R.html +++ b/Doc/Manual/R.html @@ -56,28 +56,48 @@ example.c is the name of the file with the functions in them
     swig -r example.i
    -PKG_LIBS="example.c" R CMD SHLIB example_wrap.c
    +R CMD SHLIB example_wrap.c example.c
     

    -The corresponding comments for C++ mode are +The corresponding options for C++ mode are

     swig -c++ -r -o example_wrap.cpp example.i
    -PKG_LIBS="example.cxx" R CMD SHLIB example_wrap.cpp
    +R CMD SHLIB example_wrap.cpp example.cpp
     

    -Note that R is sensitive to the name of the file and to the file -extension in C and C++ mode. The name of the wrapper file must be the -name of the library. Also in C++ mode, the file extension must be .cpp -rather than .cxx for the R compile command to recognize it. +Note that R is sensitive to the names of the files. +The name of the wrapper file must be the +name of the library unless you use the -o option to R when building the library, for example:

    +
    +
    +swig -c++ -r -o example_wrap.cpp example.i
    +R CMD SHLIB -o example.so example_wrap.cpp example.cpp
    +
    +
    + +

    +R is also sensitive to the name of the file +extension in C and C++ mode. In C++ mode, the file extension must be .cpp +rather than .cxx for the R compile command to recognize it. If your C++ code is +in a file using something other than a .cpp extension, then it may still work using PKG_LIBS: +

    + +
    +
    +swig -c++ -r -o example_wrap.cpp example.i
    +PKG_LIBS="example.cxx" R CMD SHLIB -o example example_wrap.cpp
    +
    +
    +

    The commands produces two files. A dynamic shared object file called example.so, or example.dll, and an R wrapper file called example.R. To load these diff --git a/Examples/Makefile.in b/Examples/Makefile.in index cb8b7f4d4..9dee0347f 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -1129,11 +1129,11 @@ RRSRC = $(INTERFACE:.i=.R) r: $(SRCS) $(SWIG) -r $(SWIGOPT) $(INTERFACEPATH) - +( PKG_LIBS="$(SRCS)" PKG_CPPFLAGS="$(INCLUDES)" $(COMPILETOOL) $(R) CMD SHLIB -fPIC -o $(LIBPREFIX)$(TARGET)$(SO) $(ISRCS) ) + +( PKG_CPPFLAGS="$(INCLUDES)" $(COMPILETOOL) $(R) CMD SHLIB -o $(LIBPREFIX)$(TARGET)$(SO) $(ISRCS) $(SRCS) ) r_cpp: $(CXXSRCS) $(SWIG) -c++ -r $(SWIGOPT) -o $(RCXXSRCS) $(INTERFACEPATH) - +( PKG_LIBS="$(CXXSRCS)" PKG_CPPFLAGS="$(INCLUDES)" $(COMPILETOOL) $(R) CMD SHLIB -fPIC -o $(LIBPREFIX)$(TARGET)$(SO) $(RCXXSRCS) ) + +( PKG_CPPFLAGS="$(INCLUDES)" $(COMPILETOOL) $(R) CMD SHLIB -o $(LIBPREFIX)$(TARGET)$(SO) $(RCXXSRCS) $(SRCS) $(CXXSRCS)) r_clean: rm -f *_wrap* *~ .~* diff --git a/Examples/r/class/Makefile b/Examples/r/class/Makefile index 6bed3ce53..0cd8ed3d3 100644 --- a/Examples/r/class/Makefile +++ b/Examples/r/class/Makefile @@ -3,16 +3,13 @@ SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i -LIBS = -lm -ARGS = SRCS='$(SRCS)' SWIG='$(SWIG)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' all:: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' r_cpp clean:: - $(MAKE) -f $(TOP)/Makefile $(ARGS) r_clean + $(MAKE) -f $(TOP)/Makefile INTERFACE='$(INTERFACE)' r_clean check: all R CMD BATCH runme.R diff --git a/Examples/r/simple/Makefile b/Examples/r/simple/Makefile index e01d35925..5ef29565a 100644 --- a/Examples/r/simple/Makefile +++ b/Examples/r/simple/Makefile @@ -3,14 +3,13 @@ SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i -ARGS = SRCS='$(SRCS)' SWIG='$(SWIG)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' all:: - $(MAKE) -f $(TOP)/Makefile $(ARGS) r + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' r clean:: - $(MAKE) -f $(TOP)/Makefile $(ARGS) r_clean + $(MAKE) -f $(TOP)/Makefile INTERFACE='$(INTERFACE)' r_clean check: all R CMD BATCH runme.R From 9f55943801a5451e7b9367bb3aa76c9913ab8103 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 25 May 2010 18:13:32 +0000 Subject: [PATCH 0875/1680] Fix RUNTOOL in the test-suite for php and add an example for using RUNTOOL to invoke a debugger git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12050 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Extending.html | 8 ++++++++ Examples/test-suite/common.mk | 7 +++++-- Examples/test-suite/php/Makefile.in | 4 ++-- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/Doc/Manual/Extending.html b/Doc/Manual/Extending.html index ff8751540..bb50d3878 100644 --- a/Doc/Manual/Extending.html +++ b/Doc/Manual/Extending.html @@ -3469,6 +3469,14 @@ SWIG can be analyzed for bad memory accesses using: make ret_by_value.ctest SWIGTOOL="valgrind --tool=memcheck --trace-children=yes" +

    +A debugger can also be invoked easily on an individual test, for example gdb: +

    + +
    +make ret_by_value.ctest RUNTOOL="gdb --args"
    +
    +

    35.10.13 Documentation

    diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 1701dd8ba..97708be47 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -29,14 +29,17 @@ # # Note that the RUNTOOL, COMPILETOOL and SWIGTOOL variables can be used # 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: +# compiler (eg javac), and on SWIG respectively. For example, valgrind +# can be used for memory checking of the runtime tests using: # make RUNTOOL="valgrind --leak-check=full" # and valgrind can be used when invoking SWIG using: # make SWIGTOOL="valgrind --tool=memcheck --trace-children=yes" # Note: trace-children needed because of preinst-swig shell wrapper # to the swig executable. # +# An individual test run can be debugged easily: +# make director_string.cpptest RUNTOOL="gdb --args" +# # The variables below can be overridden after including this makefile ####################################################################### diff --git a/Examples/test-suite/php/Makefile.in b/Examples/test-suite/php/Makefile.in index 963051258..bf227da63 100644 --- a/Examples/test-suite/php/Makefile.in +++ b/Examples/test-suite/php/Makefile.in @@ -48,9 +48,9 @@ missingtests: missingcpptests missingctests # 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; \ + $(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; \ + $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile PHPSCRIPT=$(srcdir)/$(SCRIPTPREFIX)$*.php RUNTOOL="$(RUNTOOL)" php_run; \ fi # Clean: remove the generated .php file From 465373d92d211e64c83c5e4cf405a4974d547452 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 25 May 2010 18:35:21 +0000 Subject: [PATCH 0876/1680] Fix R keyword warning git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12051 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/director_enum.i | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Examples/test-suite/director_enum.i b/Examples/test-suite/director_enum.i index c7932d1dc..e57734e74 100644 --- a/Examples/test-suite/director_enum.i +++ b/Examples/test-suite/director_enum.i @@ -48,7 +48,7 @@ namespace EnumDirector { %inline %{ namespace EnumDirector { -enum FType{ SA = -1, NA=0, EA=1}; +enum FType{ SA = -1, NA_=0, EA=1}; struct A{ A(const double a, const double b, const FType c) @@ -71,7 +71,7 @@ struct B : public A{ %inline %{ namespace EnumDirector { struct A2{ - A2(const FType c = NA) {} + A2(const FType c = NA_) {} virtual ~A2() {} From 08cdb5a7eeae460f52859ea0186ec309454b8e2e Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Tue, 25 May 2010 21:46:23 +0000 Subject: [PATCH 0877/1680] Set string contents when we allocate it for a small efficiency gain. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12052 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/php/std_string.i | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Lib/php/std_string.i b/Lib/php/std_string.i index 656765194..f6b036bd8 100644 --- a/Lib/php/std_string.i +++ b/Lib/php/std_string.i @@ -71,8 +71,7 @@ namespace std { %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)); + temp = new std::string(Z_STRVAL_PP($input), Z_STRLEN_PP($input)); swig_acquire_ownership(temp); $result = temp; %} From 9207a2fe37be54d53c03871e6ee7dc2dd4649440 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Tue, 25 May 2010 23:38:44 +0000 Subject: [PATCH 0878/1680] [PHP] Add missing directorin typemap for const std::string &. Fixes SF#3006404 reported by t-Legiaw. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12053 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++++ Lib/php/std_string.i | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 9839e13bc..68b92fbbd 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,10 @@ Version 2.0.0 (in progress) ============================ +2010-05-25: olly + [PHP] Add missing directorin typemap for const std::string &. + Fixes SF#3006404 reported by t-Legiaw. + 2010-05-23: wsfulton [C#] Fix #2957375 - SWIGStringHelper and SWIGExceptionHelper not always being initialized before use in .NET 4 as the classes were not marked beforefieldinit. diff --git a/Lib/php/std_string.i b/Lib/php/std_string.i index f6b036bd8..6eb8ac22a 100644 --- a/Lib/php/std_string.i +++ b/Lib/php/std_string.i @@ -53,6 +53,10 @@ namespace std { ZVAL_STRINGL($result, const_cast($1->data()), $1->size(), 1); %} + %typemap(directorin) const string & %{ + ZVAL_STRINGL($input, const_cast($1_name.data()), $1_name.size(), 1); + %} + %typemap(throws) string %{ SWIG_PHP_Error(E_ERROR, (char *)$1.c_str()); %} From ed98187e3bd3f2e23e1cce128bace99d36ba5c3a Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Wed, 26 May 2010 00:19:08 +0000 Subject: [PATCH 0879/1680] Tidy up typemaps, combining variants with the same code. Use const_cast to remove const-ness from const char * for stupid PHP API in %throws typemap. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12054 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/php/std_string.i | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/Lib/php/std_string.i b/Lib/php/std_string.i index 6eb8ac22a..de4e15c4e 100644 --- a/Lib/php/std_string.i +++ b/Lib/php/std_string.i @@ -23,8 +23,8 @@ namespace std { class string; - %typemap(typecheck,precedence=SWIG_TYPECHECK_STRING) string %{ - $1 = ( Z_TYPE_PP($input) == IS_STRING ) ? 1 : 0; + %typemap(typecheck,precedence=SWIG_TYPECHECK_STRING) string, const string& %{ + $1 = ( Z_TYPE_PP($input) == IS_STRING ) ? 1 : 0; %} %typemap(in) string %{ @@ -37,15 +37,11 @@ namespace std { $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; - %} - %typemap(out) string %{ ZVAL_STRINGL($result, const_cast($1.data()), $1.size(), 1); %} - %typemap(directorin) string %{ + %typemap(directorin) string, const string& %{ ZVAL_STRINGL($input, const_cast($1_name.data()), $1_name.size(), 1); %} @@ -53,16 +49,8 @@ namespace std { ZVAL_STRINGL($result, const_cast($1->data()), $1->size(), 1); %} - %typemap(directorin) const string & %{ - ZVAL_STRINGL($input, const_cast($1_name.data()), $1_name.size(), 1); - %} - - %typemap(throws) string %{ - SWIG_PHP_Error(E_ERROR, (char *)$1.c_str()); - %} - - %typemap(throws) const string& %{ - SWIG_PHP_Error(E_ERROR, (char *)$1.c_str()); + %typemap(throws) string, const string& %{ + SWIG_PHP_Error(E_ERROR, const_cast($1.c_str())); %} /* These next two handle a function which takes a non-const reference to From 1392a6e497b8cc15b73585620b9f465d905d7a02 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Wed, 26 May 2010 07:32:20 +0000 Subject: [PATCH 0880/1680] [PHP] When using %throws or %catches, SWIG-generated PHP5 wrappers now throw PHP Exception objects instead of giving a PHP error of type E_ERROR. This change shouldn't cause incompatibility issues, since you can't set an error handler for E_ERROR, so previously PHP would just exit which also happens for unhandled exceptions. The benefit is you can now catch them if you want to. Fixes SF#2545578 and SF#2955522. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12055 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 12 ++++++ Examples/test-suite/php/Makefile.in | 9 ++++ .../test-suite/php/exception_order_runme.php | 39 +++++++++++++++++ .../php/threads_exception_runme.php | 43 +++++++++++++++++++ Lib/php/php.swg | 11 ++--- Lib/php/phprun.swg | 1 + Lib/php/std_string.i | 3 +- 7 files changed, 112 insertions(+), 6 deletions(-) create mode 100644 Examples/test-suite/php/exception_order_runme.php create mode 100755 Examples/test-suite/php/threads_exception_runme.php diff --git a/CHANGES.current b/CHANGES.current index 68b92fbbd..b294f9664 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,18 @@ Version 2.0.0 (in progress) ============================ +2010-05-26: olly + [PHP] When using %throws or %catches, SWIG-generated PHP5 wrappers + now throw PHP Exception objects instead of giving a PHP error of + type E_ERROR. + + This change shouldn't cause incompatibility issues, since you can't + set an error handler for E_ERROR, so previously PHP would just exit + which also happens for unhandled exceptions. The benefit is you can + now catch them if you want to. + + Fixes SF#2545578 and SF#2955522. + 2010-05-25: olly [PHP] Add missing directorin typemap for const std::string &. Fixes SF#3006404 reported by t-Legiaw. diff --git a/Examples/test-suite/php/Makefile.in b/Examples/test-suite/php/Makefile.in index bf227da63..5340751e7 100644 --- a/Examples/test-suite/php/Makefile.in +++ b/Examples/test-suite/php/Makefile.in @@ -44,6 +44,15 @@ missingtests: missingcpptests missingctests +$(swig_and_compile_multi_cpp) +$(run_testcase) +# Smart target +%.test: + @echo ' $(C_TEST_CASES) '|grep -F -v ' $* ' >/dev/null ||\ + $(MAKE) $*.ctest + @echo ' $(CPP_TEST_CASES) '|grep -F -v ' $* ' >/dev/null ||\ + $(MAKE) $*.cpptest + @echo ' $(MULTICPP_TEST_CASES) '|grep -F -v ' $* ' >/dev/null ||\ + $(MAKE) $*.multicpptest + # Runs the testcase. Tries to run testcase_runme.php, and if that's not # found, runs testcase.php, except for multicpptests. run_testcase = \ diff --git a/Examples/test-suite/php/exception_order_runme.php b/Examples/test-suite/php/exception_order_runme.php new file mode 100644 index 000000000..a83598170 --- /dev/null +++ b/Examples/test-suite/php/exception_order_runme.php @@ -0,0 +1,39 @@ +foo(); +} catch (Exception $e) { + check::equal($e->getMessage(), 'C++ E1 exception thrown', ''); +} + +try { + $a->bar(); +} catch (Exception $e) { + check::equal($e->getMessage(), 'C++ E2 exception thrown', ''); +} + +try { + $a->foobar(); +} catch (Exception $e) { + check::equal($e->getMessage(), 'postcatch unknown', ''); +} + +try { + $a->barfoo(1); +} catch (Exception $e) { + check::equal($e->getMessage(), 'C++ E1 exception thrown', ''); +} + +try { + $a->barfoo(2); +} catch (Exception $e) { + check::equal($e->getMessage(), 'C++ E2 * exception thrown', ''); +} +?> diff --git a/Examples/test-suite/php/threads_exception_runme.php b/Examples/test-suite/php/threads_exception_runme.php new file mode 100755 index 000000000..31148a1e1 --- /dev/null +++ b/Examples/test-suite/php/threads_exception_runme.php @@ -0,0 +1,43 @@ +unknown(); +} catch (Exception $e) { + check::equal($e->getMessage(), 'C++ A * exception thrown', ''); +} + +try { + $t->simple(); +} catch (Exception $e) { + check::equal($e->getCode(), 37, ''); +} + +try { + $t->message(); +} catch (Exception $e) { + check::equal($e->getMessage(), 'I died.', ''); +} + +try { + $t->hosed(); +} catch (Exception $e) { + check::equal($e->getMessage(), 'C++ Exc exception thrown', ''); +} + +foreach (Array(1,2,3,4) as $i) { + try { + $t->multi($i); + } catch (Exception $e) { + } +} diff --git a/Lib/php/php.swg b/Lib/php/php.swg index ff4001d7e..2471a0992 100644 --- a/Lib/php/php.swg +++ b/Lib/php/php.swg @@ -461,18 +461,19 @@ unsigned int, unsigned long, unsigned short { - char error_msg[256]; - sprintf(error_msg, "C++ $1_type exception thrown, value: %d", $1); - SWIG_PHP_Error(E_ERROR, error_msg); + zend_throw_exception(NULL, const_cast("C++ $1_type exception thrown"), $1 TSRMLS_CC); + return; } %typemap(throws) SWIGTYPE, SWIGTYPE &, SWIGTYPE *, SWIGTYPE [], SWIGTYPE [ANY] %{ (void)$1; - SWIG_PHP_Error(E_ERROR, "C++ $1_type exception thrown"); + zend_throw_exception(NULL, const_cast("C++ $1_type exception thrown"), 0 TSRMLS_CC); + return; %} %typemap(throws) char * %{ - SWIG_PHP_Error(E_ERROR, (char *)$1); + zend_throw_exception(NULL, const_cast($1), 0 TSRMLS_CC); + return; %} /* Array reference typemaps */ diff --git a/Lib/php/phprun.swg b/Lib/php/phprun.swg index a48a30b20..e76f7033a 100644 --- a/Lib/php/phprun.swg +++ b/Lib/php/phprun.swg @@ -9,6 +9,7 @@ extern "C" { #endif #include "zend.h" #include "zend_API.h" +#include "zend_exceptions.h" #include "php.h" #include "ext/standard/php_string.h" diff --git a/Lib/php/std_string.i b/Lib/php/std_string.i index de4e15c4e..5b82fde53 100644 --- a/Lib/php/std_string.i +++ b/Lib/php/std_string.i @@ -50,7 +50,8 @@ namespace std { %} %typemap(throws) string, const string& %{ - SWIG_PHP_Error(E_ERROR, const_cast($1.c_str())); + zend_throw_exception(NULL, const_cast($1.c_str()), 0 TSRMLS_CC); + return; %} /* These next two handle a function which takes a non-const reference to From 71dddaa2de7298d002a37538e84f5be00cca080c Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Wed, 26 May 2010 08:21:03 +0000 Subject: [PATCH 0881/1680] Fix %attribute2ref not to produce a syntax error if the last argument (AccessorMethod) is omitted. Patch from David Piepgras in SF#2235756. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12056 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 5 +++++ Lib/typemaps/attribute.swg | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index b294f9664..a1e7ed6e2 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,11 @@ Version 2.0.0 (in progress) ============================ +2010-05-26: olly + Fix %attribute2ref not to produce a syntax error if the last + argument (AccessorMethod) is omitted. Patch from David Piepgras + in SF#2235756. + 2010-05-26: olly [PHP] When using %throws or %catches, SWIG-generated PHP5 wrappers now throw PHP Exception objects instead of giving a PHP error of diff --git a/Lib/typemaps/attribute.swg b/Lib/typemaps/attribute.swg index 4dcf15e2d..214133edc 100644 --- a/Lib/typemaps/attribute.swg +++ b/Lib/typemaps/attribute.swg @@ -221,7 +221,7 @@ #if #AccessorMethod != "" %attribute_custom(Class, AttributeType, AttributeName, AccessorMethod, AccessorMethod, &self_->AccessorMethod(), self_->AccessorMethod() = *val_) #else - %attribute_custom(Class, AttributeType, AccessorMethod, AccessorMethod, AccessorMethod, &self_->AccessorMethod(), self_->AccessorMethod() = *val_) + %attribute_custom(Class, AttributeType, AccessorName, AccessorName, AccessorName, &self_->AccessorName(), self_->AccessorName() = *val_) #endif %enddef From 7b2c6b477abff9a81da8b10549ed9a758ad7a2ef Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 26 May 2010 19:01:12 +0000 Subject: [PATCH 0882/1680] Fix segfault attempting illegal javaclassname and csclassname special variable substitution git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12058 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/csharp_typemaps.i | 9 +++++++++ Examples/test-suite/java_typemaps_typewrapper.i | 7 +++++++ Source/Modules/csharp.cxx | 6 ++++-- Source/Modules/java.cxx | 6 ++++-- 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/Examples/test-suite/csharp_typemaps.i b/Examples/test-suite/csharp_typemaps.i index dcef278f6..b940f25a3 100644 --- a/Examples/test-suite/csharp_typemaps.i +++ b/Examples/test-suite/csharp_typemaps.i @@ -101,3 +101,12 @@ Number times12(const Number* num) { %inline %{ int myInt = 0; %} + + +// Illegal special variable crash +%typemap(cstype) WasCrashing "$csclassname /*cstype $*csclassname*/" // $*csclassname was causing crash +%inline %{ +struct WasCrashing {}; +void hoop(WasCrashing was) {} +%} + diff --git a/Examples/test-suite/java_typemaps_typewrapper.i b/Examples/test-suite/java_typemaps_typewrapper.i index 8c772ae81..a99ca7b65 100644 --- a/Examples/test-suite/java_typemaps_typewrapper.i +++ b/Examples/test-suite/java_typemaps_typewrapper.i @@ -63,3 +63,10 @@ class Farewell {}; Greeting* solong(Farewell* f) { return NULL; } %} +// Illegal special variable crash +%typemap(jstype) WasCrashing "$javaclassname /*jstype $*javaclassname*/" // $*javaclassname was causing crash +%inline %{ +struct WasCrashing {}; +void hoop(WasCrashing was) {} +%} + diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index ba8f34b47..e1c8d5415 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -3085,8 +3085,10 @@ public: if (Strstr(tm, "$*csclassname")) { SwigType *classnametype = Copy(strippedtype); Delete(SwigType_pop(classnametype)); - substituteClassnameSpecialVariable(classnametype, tm, "$*csclassname"); - substitution_performed = true; + if (Len(classnametype) > 0) { + substituteClassnameSpecialVariable(classnametype, tm, "$*csclassname"); + substitution_performed = true; + } Delete(classnametype); } if (Strstr(tm, "$&csclassname")) { diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index 8c4770a9e..11cfe8184 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -2943,8 +2943,10 @@ public: if (Strstr(tm, "$*javaclassname")) { SwigType *classnametype = Copy(strippedtype); Delete(SwigType_pop(classnametype)); - substituteClassnameSpecialVariable(classnametype, tm, "$*javaclassname", jnidescriptor); - substitution_performed = true; + if (Len(classnametype) > 0) { + substituteClassnameSpecialVariable(classnametype, tm, "$*javaclassname", jnidescriptor); + substitution_performed = true; + } Delete(classnametype); } if (Strstr(tm, "$&javaclassname")) { From e2ce97f397c7d59d2d99ee3907dd5db930a9287e Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 26 May 2010 23:22:49 +0000 Subject: [PATCH 0883/1680] Add the ability for special variable macros to call other special variable macros. Also added additional diagnostics when using -debug-tmsearch. Add tests for std::vector of shared_ptr. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12059 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 27 +++++++++++++++++++ .../csharp/li_boost_shared_ptr_bits_runme.cs | 17 ++++++++++++ .../java/li_boost_shared_ptr_bits_runme.java | 24 +++++++++++++++++ .../test-suite/li_boost_shared_ptr_bits.i | 25 +++++++++++++++++ .../python/li_boost_shared_ptr_bits_runme.py | 11 ++++++++ Source/Swig/typemap.c | 17 ++++++++---- 6 files changed, 116 insertions(+), 5 deletions(-) create mode 100644 Examples/test-suite/csharp/li_boost_shared_ptr_bits_runme.cs create mode 100644 Examples/test-suite/java/li_boost_shared_ptr_bits_runme.java diff --git a/CHANGES.current b/CHANGES.current index a1e7ed6e2..c52179d45 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,33 @@ Version 2.0.0 (in progress) ============================ +2010-05-27: wsfulton + Add the ability for $typemap special variable macros to call other $typemap + special variable macros, for example: + + %typemap(cstype) CC "CC" + %typemap(cstype) BB "$typemap(cstype, CC)" + %typemap(cstype) AA "$typemap(cstype, BB)" + void hah(AA aa); + + This also fixes C# std::vector containers of shared_ptr and %shared_ptr. + + Also added diagnostics for $typemap with -debug-tmsearch, for example, the + above displays additional diagnostic lines starting "Containing: ": + + example.i:34: Searching for a suitable 'cstype' typemap for: AA aa + Looking for: AA aa + Looking for: AA + Using: %typemap(cstype) AA + Containing: $typemap(cstype, BB) + example.i:31: Searching for a suitable 'cstype' typemap for: BB + Looking for: BB + Using: %typemap(cstype) BB + Containing: $typemap(cstype, CC) + example.i:29: Searching for a suitable 'cstype' typemap for: CC + Looking for: CC + Using: %typemap(cstype) CC + 2010-05-26: olly Fix %attribute2ref not to produce a syntax error if the last argument (AccessorMethod) is omitted. Patch from David Piepgras diff --git a/Examples/test-suite/csharp/li_boost_shared_ptr_bits_runme.cs b/Examples/test-suite/csharp/li_boost_shared_ptr_bits_runme.cs new file mode 100644 index 000000000..2b8c84e1b --- /dev/null +++ b/Examples/test-suite/csharp/li_boost_shared_ptr_bits_runme.cs @@ -0,0 +1,17 @@ +using System; +using li_boost_shared_ptr_bitsNamespace; + +public class runme +{ + static void Main() + { + VectorIntHolder v = new VectorIntHolder(); + v.Add(new IntHolder(11)); + v.Add(new IntHolder(22)); + v.Add(new IntHolder(33)); + + int sum = li_boost_shared_ptr_bits.sum(v); + if (sum != 66) + throw new ApplicationException("sum is wrong"); + } +} diff --git a/Examples/test-suite/java/li_boost_shared_ptr_bits_runme.java b/Examples/test-suite/java/li_boost_shared_ptr_bits_runme.java new file mode 100644 index 000000000..ffa0c5e64 --- /dev/null +++ b/Examples/test-suite/java/li_boost_shared_ptr_bits_runme.java @@ -0,0 +1,24 @@ +import li_boost_shared_ptr_bits.*; + +public class li_boost_shared_ptr_bits_runme { + static { + try { + System.loadLibrary("li_boost_shared_ptr_bits"); + } catch (UnsatisfiedLinkError e) { + System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); + System.exit(1); + } + } + + public static void main(String argv[]) + { + VectorIntHolder v = new VectorIntHolder(); + v.add(new IntHolder(11)); + v.add(new IntHolder(22)); + v.add(new IntHolder(33)); + + int sum = li_boost_shared_ptr_bits.sum(v); + if (sum != 66) + throw new RuntimeException("sum is wrong"); + } +} diff --git a/Examples/test-suite/li_boost_shared_ptr_bits.i b/Examples/test-suite/li_boost_shared_ptr_bits.i index 4e144093e..b43e1b137 100644 --- a/Examples/test-suite/li_boost_shared_ptr_bits.i +++ b/Examples/test-suite/li_boost_shared_ptr_bits.i @@ -23,3 +23,28 @@ struct NonDynamic { boost::shared_ptr boing(boost::shared_ptr b) { return b; } %} +// vector of shared_ptr +%include "std_vector.i" + +#if defined(SHARED_PTR_WRAPPERS_IMPLEMENTED) + +%shared_ptr(IntHolder); + +#endif + +%inline %{ +#include "boost/shared_ptr.hpp" +struct IntHolder { + int val; + IntHolder(int a) : val(a) {} +}; +int sum(std::vector< boost::shared_ptr > v) { + int sum = 0; + for (size_t i=0; ival; + return sum; +} +%} + +%template(VectorIntHolder) std::vector< boost::shared_ptr >; + diff --git a/Examples/test-suite/python/li_boost_shared_ptr_bits_runme.py b/Examples/test-suite/python/li_boost_shared_ptr_bits_runme.py index c6bd2f97a..9e5668e57 100644 --- a/Examples/test-suite/python/li_boost_shared_ptr_bits_runme.py +++ b/Examples/test-suite/python/li_boost_shared_ptr_bits_runme.py @@ -18,3 +18,14 @@ check(nd) b = boing(nd) check(b) +################################ + +v = VectorIntHolder() +v.push_back(IntHolder(11)) +v.push_back(IntHolder(22)) +v.push_back(IntHolder(33)) + +sum = sum(v) +if sum != 66: + raise "sum is wrong" + diff --git a/Source/Swig/typemap.c b/Source/Swig/typemap.c index 2bf806e66..607ab6d10 100644 --- a/Source/Swig/typemap.c +++ b/Source/Swig/typemap.c @@ -1940,10 +1940,16 @@ static void replace_embedded_typemap(String *s, ParmList *parm_sublist, Wrapper #ifdef SWIG_DEBUG Printf(stdout, "Swig_typemap_attach_parms: embedded\n"); #endif - if (!already_substituting) { - already_substituting = 1; + if (already_substituting < 10) { + already_substituting++; + if ((in_typemap_search_multi == 0) && typemap_search_debug) { + String *dtypemap = NewString(dollar_typemap); + Replaceall(dtypemap, "$TYPEMAP", "$typemap"); + Printf(stdout, " Containing: %s\n", dtypemap); + Delete(dtypemap); + } Swig_typemap_attach_parms(tmap_method, to_match_parms, f); - already_substituting = 0; + already_substituting--; /* Look for the typemap code */ attr = NewStringf("tmap:%s", tmap_method); @@ -1974,10 +1980,11 @@ static void replace_embedded_typemap(String *s, ParmList *parm_sublist, Wrapper } Delete(attr); } else { - /* simple recursive call check, but prevents using an embedded typemap that contains another embedded typemap */ + /* Simple recursive call check to prevent infinite recursion - this strategy only allows a limited + * number of calls by a embedded typemaps to other embedded typemaps though */ String *dtypemap = NewString(dollar_typemap); Replaceall(dtypemap, "$TYPEMAP", "$typemap"); - Swig_error(Getfile(s), Getline(s), "Recursive $typemap calls not supported - %s\n", dtypemap); + Swig_error(Getfile(s), Getline(s), "Likely recursive $typemap calls containing %s. Use -debug-tmsearch to debug.\n", dtypemap); Delete(dtypemap); } syntax_error = 0; From 00d07a77c153650b75766ade8058e3ae01e484c0 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Thu, 27 May 2010 07:14:20 +0000 Subject: [PATCH 0884/1680] Fix a couple of typos git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12060 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index 509484e2f..cad14004b 100644 --- a/CHANGES +++ b/CHANGES @@ -956,7 +956,7 @@ Version 1.3.35 (7 April 2008) 03/17/2008: olly Fix memory leak in SWIG's parser (based on patch from Russell - Bryant in SF#1914023).` + Bryant in SF#1914023). 03/12/2008: wsfulton Fix bug #1878285 - unnecessary cast for C struct creation wrappers. @@ -8256,7 +8256,7 @@ Version 1.3.22 (September 4, 2004) When needed, use %inlcude std_string.i // 'char' strings - %inlcude std_wstring.i // 'wchar_t; strings + %inlcude std_wstring.i // 'wchar_t' strings 04/10/2004: mmatus (Marcelo Matus) From 5dfa9c048da9e45e42c8b61164e4c950caccaf80 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 27 May 2010 20:12:58 +0000 Subject: [PATCH 0885/1680] some warning fixes on solaris git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12061 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/global_scope_types.i | 2 +- Examples/test-suite/typemap_global_scope.i | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Examples/test-suite/global_scope_types.i b/Examples/test-suite/global_scope_types.i index 4c73dfa72..05aa43b77 100644 --- a/Examples/test-suite/global_scope_types.i +++ b/Examples/test-suite/global_scope_types.i @@ -39,6 +39,6 @@ namespace Spac { } -void funcptrtest( void (*)(::Dingaling) ) {} +extern "C" void funcptrtest( void (*)(::Dingaling) ) {} %} diff --git a/Examples/test-suite/typemap_global_scope.i b/Examples/test-suite/typemap_global_scope.i index 92170363f..421ed9dd0 100644 --- a/Examples/test-suite/typemap_global_scope.i +++ b/Examples/test-suite/typemap_global_scope.i @@ -12,7 +12,7 @@ // Structs ///////////////////////////////////////////////////////////////////// -%typemap(in) Test1, ::Test2, Space::Test3, ::Space::Test4 "/*in typemap for $type*/" +%typemap(in) Test1, ::Test2, Space::Test3, ::Space::Test4 "$1 = $type(); /*in typemap for $type*/" %typemap(in) const Test1 &, const ::Test2 &, const Space::Test3 &, const ::Space::Test4 & "/*in typemap for $type*/" %inline %{ struct Test1 {}; @@ -55,7 +55,7 @@ namespace Space { struct XX {}; %} -%typemap(in) TemplateTest1< ::XX >, ::TemplateTest2< ::XX >, Space::TemplateTest3< ::XX >, ::Space::TemplateTest4< ::XX > "/* in typemap for $type */" +%typemap(in) TemplateTest1< ::XX >, ::TemplateTest2< ::XX >, Space::TemplateTest3< ::XX >, ::Space::TemplateTest4< ::XX > "$1 = $type(); /* in typemap for $type */" %typemap(in) const TemplateTest1< XX > &, const ::TemplateTest2< XX > &, const Space::TemplateTest3< XX > &, const ::Space::TemplateTest4< XX > & "/* in typemap for $type */" %inline %{ template struct TemplateTest1 { T m_t; }; @@ -99,7 +99,7 @@ namespace Space { // Enums ///////////////////////////////////////////////////////////////////// -%typemap(in) Enum1, ::Enum2, Space::Enum3, ::Space::Enum4 "/*in typemap for $type*/" +%typemap(in) Enum1, ::Enum2, Space::Enum3, ::Space::Enum4 "$1 = $1_type(); /*in typemap for $type*/" %typemap(in) const Enum1 &, const ::Enum2 &, const Space::Enum3 &, const ::Space::Enum4 & "/*in typemap for $type*/" %inline %{ enum Enum1 { enum_1 }; From bb41eeb343e956da1a0e76480a6f259ac5525b34 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 27 May 2010 20:55:24 +0000 Subject: [PATCH 0886/1680] Fix potential name clashes with symbols in the Director class git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12062 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/php/director.swg | 12 ++++++------ Lib/python/director.swg | 20 ++++++++++---------- Lib/ruby/director.swg | 16 ++++++++-------- Source/Modules/php.cxx | 2 +- Source/Modules/python.cxx | 12 ++++++------ 5 files changed, 31 insertions(+), 31 deletions(-) diff --git a/Lib/php/director.swg b/Lib/php/director.swg index 5c1d8d08f..163cd7fb6 100644 --- a/Lib/php/director.swg +++ b/Lib/php/director.swg @@ -100,19 +100,19 @@ namespace Swig { class Director { protected: zval *swig_self; - typedef std::map ownership_map; - mutable ownership_map owner; + typedef std::map swig_ownership_map; + mutable swig_ownership_map swig_owner; public: Director(zval* self) : swig_self(self) { } ~Director() { - for (ownership_map::iterator i = owner.begin(); i != owner.end(); i++) { - owner.erase(i); + for (swig_ownership_map::iterator i = swig_owner.begin(); i != swig_owner.end(); i++) { + swig_owner.erase(i); } } - bool is_overriden_method(char *cname, char *lc_fname) { + bool swig_is_overridden_method(char *cname, char *lc_fname) { zval classname; zend_class_entry **ce; zend_function *mptr; @@ -133,7 +133,7 @@ namespace Swig { void swig_acquire_ownership(Type *vptr) const { if (vptr) { - owner[vptr] = new GCItem_T(vptr); + swig_owner[vptr] = new GCItem_T(vptr); } } }; diff --git a/Lib/python/director.swg b/Lib/python/director.swg index 8514365a9..fcd174711 100644 --- a/Lib/python/director.swg +++ b/Lib/python/director.swg @@ -404,17 +404,17 @@ namespace Swig { } /* methods to implement pseudo protected director members */ - virtual bool swig_get_inner(const char* /* name */) const { + virtual bool swig_get_inner(const char* /* protected_method_name */) const { return true; } - virtual void swig_set_inner(const char* /* name */, bool /* val */) const { + virtual void swig_set_inner(const char* /* protected_method_name */, bool /* val */) const { } /* ownership management */ private: - typedef std::map ownership_map; - mutable ownership_map owner; + typedef std::map swig_ownership_map; + mutable swig_ownership_map swig_owner; #ifdef __THREAD__ static PyThread_type_lock swig_mutex_own; #endif @@ -425,7 +425,7 @@ namespace Swig { { if (vptr) { SWIG_GUARD(swig_mutex_own); - owner[vptr] = new GCArray_T(vptr); + swig_owner[vptr] = new GCArray_T(vptr); } } @@ -434,7 +434,7 @@ namespace Swig { { if (vptr) { SWIG_GUARD(swig_mutex_own); - owner[vptr] = new GCItem_T(vptr); + swig_owner[vptr] = new GCItem_T(vptr); } } @@ -442,7 +442,7 @@ namespace Swig { { if (vptr && own) { SWIG_GUARD(swig_mutex_own); - owner[vptr] = new GCItem_Object(own); + swig_owner[vptr] = new GCItem_Object(own); } } @@ -451,10 +451,10 @@ namespace Swig { int own = 0; if (vptr) { SWIG_GUARD(swig_mutex_own); - ownership_map::iterator iter = owner.find(vptr); - if (iter != owner.end()) { + swig_ownership_map::iterator iter = swig_owner.find(vptr); + if (iter != swig_owner.end()) { own = iter->second->get_own(); - owner.erase(iter); + swig_owner.erase(iter); } } return own; diff --git a/Lib/ruby/director.swg b/Lib/ruby/director.swg index cdc4baea1..9807b11bb 100644 --- a/Lib/ruby/director.swg +++ b/Lib/ruby/director.swg @@ -327,8 +327,8 @@ namespace Swig { /* ownership management */ private: - typedef std::map ownership_map; - mutable ownership_map owner; + typedef std::map swig_ownership_map; + mutable swig_ownership_map swig_owner; #ifdef __PTHREAD__ static pthread_mutex_t swig_mutex_own; #endif @@ -339,7 +339,7 @@ namespace Swig { { if (vptr) { SWIG_GUARD(swig_mutex_own); - owner[vptr] = new GCArray_T(vptr); + swig_owner[vptr] = new GCArray_T(vptr); } } @@ -348,7 +348,7 @@ namespace Swig { { if (vptr) { SWIG_GUARD(swig_mutex_own); - owner[vptr] = new GCItem_T(vptr); + swig_owner[vptr] = new GCItem_T(vptr); } } @@ -356,7 +356,7 @@ namespace Swig { { if (vptr && own) { SWIG_GUARD(swig_mutex_own); - owner[vptr] = new GCItem_Object(own); + swig_owner[vptr] = new GCItem_Object(own); } } @@ -365,10 +365,10 @@ namespace Swig { ruby_owntype own = 0; if (vptr) { SWIG_GUARD(swig_mutex_own); - ownership_map::iterator iter = owner.find(vptr); - if (iter != owner.end()) { + swig_ownership_map::iterator iter = swig_owner.find(vptr); + if (iter != swig_owner.end()) { own = iter->second->get_own(); - owner.erase(iter); + swig_owner.erase(iter); } } return own; diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index c6f01c3e3..bd751f767 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -799,7 +799,7 @@ public: 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", + Printf(f->code, "upcall = !director->swig_is_overridden_method((char *)\"%s\", (char *)\"%s\");\n", Swig_class_name(Swig_methodclass(n)), name); } diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 93679084c..42a6b234f 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -2721,15 +2721,15 @@ public: Printf(f_directors_h, "\n\n"); Printf(f_directors_h, "/* Internal Director utilities */\n"); Printf(f_directors_h, "public:\n"); - Printf(f_directors_h, " bool swig_get_inner(const char* name) const {\n"); - Printf(f_directors_h, " std::map::const_iterator iv = inner.find(name);\n"); - Printf(f_directors_h, " return (iv != inner.end() ? iv->second : false);\n"); + Printf(f_directors_h, " bool swig_get_inner(const char* protected_method_name) const {\n"); + Printf(f_directors_h, " std::map::const_iterator iv = swig_inner.find(protected_method_name);\n"); + Printf(f_directors_h, " return (iv != swig_inner.end() ? iv->second : false);\n"); Printf(f_directors_h, " }\n\n"); - Printf(f_directors_h, " void swig_set_inner(const char* name, bool val) const\n"); - Printf(f_directors_h, " { inner[name] = val;}\n\n"); + Printf(f_directors_h, " void swig_set_inner(const char* protected_method_name, bool val) const\n"); + Printf(f_directors_h, " { swig_inner[protected_method_name] = val;}\n\n"); Printf(f_directors_h, "private:\n"); - Printf(f_directors_h, " mutable std::map inner;\n"); + Printf(f_directors_h, " mutable std::map swig_inner;\n"); } if (director_method_index) { From 5bcfc81c12f6cc081da5519fed9664735ab77405 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 27 May 2010 20:59:29 +0000 Subject: [PATCH 0887/1680] Fix potential name clashes with symbols in the Director class git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12063 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/octave/octrun.swg | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Lib/octave/octrun.swg b/Lib/octave/octrun.swg index 8013dcb6e..5b90d91b3 100644 --- a/Lib/octave/octrun.swg +++ b/Lib/octave/octrun.swg @@ -1132,24 +1132,24 @@ namespace Swig { namespace Swig { class Director { octave_swig_type *self; - bool disowned; + bool swig_disowned; Director(const Director &x); Director &operator=(const Director &rhs); public: - Director(void *vptr):self(0), disowned(false) { + Director(void *vptr):self(0), swig_disowned(false) { set_rtdir(vptr, this); } ~Director() { swig_director_destroyed(self, this); - if (disowned) + if (swig_disowned) self->decref(); } void swig_set_self(octave_swig_type *new_self) { - assert(!disowned); + assert(!swig_disowned); self = new_self; } @@ -1158,9 +1158,9 @@ namespace Swig { } void swig_disown() { - if (disowned) + if (swig_disowned) return; - disowned = true; + swig_disowned = true; self->incref(); } }; From 45f20c73635e64ebcb8cb776075234aebcb3bdc1 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 28 May 2010 22:24:11 +0000 Subject: [PATCH 0888/1680] Fix constants wrapper warnings for visual c++ git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12064 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/csharp.cxx | 2 +- Source/Modules/java.cxx | 2 +- Source/Modules/modula3.cxx | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index e1c8d5415..8ffd9768a 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -941,7 +941,7 @@ public: // below based on Swig_VargetToFunction() SwigType *ty = Swig_wrapped_var_type(Getattr(n, "type"), use_naturalvar_mode(n)); - Setattr(n, "wrap:action", NewStringf("result = (%s) %s;", SwigType_lstr(ty, 0), Getattr(n, "value"))); + Setattr(n, "wrap:action", NewStringf("result = (%s)(%s);", SwigType_lstr(ty, 0), Getattr(n, "value"))); } Swig_director_emit_dynamic_cast(n, f); diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index 11cfe8184..4a6abd569 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -1024,7 +1024,7 @@ public: // below based on Swig_VargetToFunction() SwigType *ty = Swig_wrapped_var_type(Getattr(n, "type"), use_naturalvar_mode(n)); - Setattr(n, "wrap:action", NewStringf("result = (%s) %s;", SwigType_lstr(ty, 0), Getattr(n, "value"))); + Setattr(n, "wrap:action", NewStringf("result = (%s)(%s);", SwigType_lstr(ty, 0), Getattr(n, "value"))); } // Now write code to make the function call diff --git a/Source/Modules/modula3.cxx b/Source/Modules/modula3.cxx index fc26dff85..602b43d4f 100644 --- a/Source/Modules/modula3.cxx +++ b/Source/Modules/modula3.cxx @@ -1422,7 +1422,7 @@ MODULA3(): // below based on Swig_VargetToFunction() SwigType *ty = Swig_wrapped_var_type(Getattr(n, "type"), use_naturalvar_mode(n)); - Setattr(n, "wrap:action", NewStringf("result = (%s) %s;", SwigType_lstr(ty, 0), Getattr(n, "value"))); + Setattr(n, "wrap:action", NewStringf("result = (%s)(%s);", SwigType_lstr(ty, 0), Getattr(n, "value"))); } Setattr(n, "wrap:name", wname); From 859cfff732b9deefaad6b4d7e14ad6abd7820056 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 28 May 2010 22:46:50 +0000 Subject: [PATCH 0889/1680] chapter numbering update git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12065 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Contents.html | 7 ++----- Doc/Manual/Modula3.html | 4 +++- Doc/Manual/Typemaps.html | 7 ++++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index 242b86429..549f6da3d 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -351,8 +351,8 @@
  • Basic matching rules
  • Typedef reductions matching
  • Default typemap matching rules -
  • Matching comparison with C++ templates
  • Multi-arguments typemaps +
  • Matching rules compared to C++ templates
  • Debugging typemap pattern matching
  • Code generation rules @@ -963,10 +963,7 @@
    • Overview
    • Conception
    • Code generation rules @@ -1418,7 +1418,7 @@ Finally the best way to view the typemap matching rules in action is via the -

      10.3.5 Multi-arguments typemaps

      +

      10.3.4 Multi-arguments typemaps

      @@ -1448,7 +1448,8 @@ but all subsequent arguments must match exactly.

      -

      10.3.4 Matching rules compared to C++ templates

      +

      10.3.5 Matching rules compared to C++ templates

      +

      For those intimately familiar with C++ templates, a comparison of the typemap matching rules and template type deduction is interesting. From 6eb118801ef75995e531a9fd6158c93149e88c03 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 28 May 2010 23:42:53 +0000 Subject: [PATCH 0890/1680] Update autoconf links git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12066 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Introduction.html | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Doc/Manual/Introduction.html b/Doc/Manual/Introduction.html index 4b954040b..3bac9484e 100644 --- a/Doc/Manual/Introduction.html +++ b/Doc/Manual/Introduction.html @@ -37,7 +37,7 @@

      SWIG is a software development tool that simplifies the task of interfacing different languages to C and C++ programs. In a -nutshell, SWIG is a compiler that takes C declarations and creates +nutshell, SWIG is a compiler that takes C/C++ declarations and creates the wrappers needed to access those declarations from other languages including including Perl, Python, Tcl, Ruby, Guile, and Java. SWIG normally requires no modifications to existing code and can often be used to @@ -68,7 +68,8 @@ a dedicated IDL compiler). Although this style of development isn't appropriate for every project, it is particularly well suited to software development in the small; especially the research and development work that is commonly found -in scientific and engineering projects. +in scientific and engineering projects. However, nowadays SWIG is known to be used in many +large open source and commercial projects.

      2.2 Why use SWIG?

      @@ -375,10 +376,10 @@ If you are using the GNU Autotools Automake/ Libtool) to configure SWIG use in your project, the SWIG Autoconf macros can be used. -The primary macro is ac_pkg_swig, see -http://www.gnu.org/software/ac-archive/htmldoc/ac_pkg_swig.html. -The ac_python_devel macro is also helpful for generating Python extensions. See the -Autoconf Macro Archive +The primary macro is ax_pkg_swig, see +http://www.gnu.org/software/autoconf-archive/ax_pkg_swig.html#ax_pkg_swig. +The ax_python_devel macro is also helpful for generating Python extensions. See the +Autoconf Archive for further information on this and other Autoconf macros.

      From 8e496434d195d61ae3ee608e8a3dd8ff4abfc696 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 28 May 2010 23:53:49 +0000 Subject: [PATCH 0891/1680] Update docs for first 2.0 release git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12067 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Guile.html | 2 - Doc/Manual/Preface.html | 81 +++++++++++++--------------------------- Doc/Manual/Sections.html | 21 +---------- Doc/Manual/Windows.html | 4 +- 4 files changed, 29 insertions(+), 79 deletions(-) diff --git a/Doc/Manual/Guile.html b/Doc/Manual/Guile.html index cc063c436..8f3c5f85c 100644 --- a/Doc/Manual/Guile.html +++ b/Doc/Manual/Guile.html @@ -767,8 +767,6 @@ guile-modules. For example,

      (use-modules ((Test) #:renamer (symbol-prefix-proc 'goops:))) -

      TODO: Renaming class name prefixes?

      -

      20.10.2 Linking

      diff --git a/Doc/Manual/Preface.html b/Doc/Manual/Preface.html index 630657a9a..ae2e1b7d9 100644 --- a/Doc/Manual/Preface.html +++ b/Doc/Manual/Preface.html @@ -49,31 +49,19 @@ has since evolved into a general purpose tool that is used in a wide variety of applications--in fact almost anything where C/C++ programming is involved. -

      1.2 Special Introduction for Version 1.3

      - - -

      -Since SWIG was released in 1996, its user base and applicability has -continued to grow. Although its rate of development has varied, an -active development effort has continued to make improvements to the -system. Today, nearly a dozen developers are working to create -SWIG-2.0---a system that aims to provide wrapping support for nearly -all of the ANSI C++ standard and approximately ten target languages -including Guile, Java, Mzscheme, Ocaml, Perl, Pike, PHP, Python, Ruby, -and Tcl. -

      -

      1.3 SWIG Versions

      -For several years, the most stable version of SWIG has been release -1.1p5. Starting with version 1.3, a new version numbering scheme has -been adopted. Odd version numbers (1.3, 1.5, etc.) represent -development versions of SWIG. Even version numbers (1.4, 1.6, etc.) -represent stable releases. Currently, developers are working to -create a stable SWIG-2.0 release. Don't let the development status -of SWIG-1.3 scare you---it is much more stable (and capable) than SWIG-1.1p5. +In the late 1990's, the most stable version of SWIG was release +1.1p5. Versions 1.3.x were officially development versions and these were released +over a period of 10 years starting from the year 2000. The final version in the 1.3.x +series was 1.3.40, but in truth the 1.3.x series had been stable for many years. +An official stable version was released along with the decision to make SWIG +license changes and this gave rise to version 2.0.0 in 2010. The license was clarified +so that the code that SWIG generated could be distributed +under license terms of the user's choice/requirements and at the same time the SWIG +source was placed under the GNU General Public License version 3.

      1.4 SWIG resources

      @@ -106,7 +94,7 @@ SWIG along with information about beta releases and future work.

      -SVN access to the latest version of SWIG is also available. More information +Subversion access to the latest version of SWIG is also available. More information about this can be obtained at:

      @@ -132,7 +120,7 @@ writing a normal C program.

      -Recent SWIG releases have become significantly more capable in +Over time SWIG releases have become significantly more capable in their C++ handling--especially support for advanced features like namespaces, overloaded operators, and templates. Whenever possible, this manual tries to cover the technicalities of this interface. @@ -149,8 +137,7 @@ provide an overview of its capabilities. The remaining chapters are devoted to specific SWIG language modules and are self contained. Thus, if you are using SWIG to build Python interfaces, you can probably skip to that chapter and find almost everything you need -to know. Caveat: we are currently working on a documentation rewrite and many -of the older language module chapters are still somewhat out of date. +to know.

      1.7 How to avoid reading the manual

      @@ -165,24 +152,19 @@ The SWIG distribution also comes with a large directory of examples that illustrate different topics.

      -

      1.8 Backwards Compatibility

      +

      1.8 Backwards compatibility

      -If you are a previous user of SWIG, don't expect recent versions of -SWIG to provide backwards compatibility. In fact, backwards -compatibility issues may arise even between successive 1.3.x releases. -Although these incompatibilities are regrettable, SWIG-1.3 is an active -development project. The primary goal of this effort is to make SWIG +If you are a previous user of SWIG, don't expect +SWIG to provide complete backwards compatibility. +Although the developers strive to the utmost to keep backwards compatibility, +this isn't always possible as the +primary goal over time is to make SWIG better---a process that would simply be impossible if the developers are constantly bogged down with backwards compatibility issues. -

      - -

      -On a positive note, a few incompatibilities are a small price to pay -for the large number of new features that have been -added---namespaces, templates, smart pointers, overloaded methods, -operators, and more. +Potential incompatibilities are clearly marked in the detailed release notes +(CHANGES files).

      @@ -211,26 +193,15 @@ wrapper file. The SWIG preprocessor has defined SWIG_VERSION since SWIG-1.3.11.

      SWIG is an unfunded project that would not be possible without the -contributions of many people. Most recent SWIG development has been -supported by Matthias Köppe, William Fulton, Lyle Johnson, -Richard Palmer, Thien-Thi Nguyen, Jason Stewart, Loic Dachary, Masaki -Fukushima, Luigi Ballabio, Sam Liddicott, Art Yerkes, Marcelo Matus, -Harco de Hilster, John Lenz, and Surendra Singhi. +contributions of many people working in their spare time. +If you have benefitted from using SWIG, please consider +Donating to SWIG to keep development going. +There have been a large varied number of people +who have made contributions at all levels over time. Contributors +are mentioned either in the COPYRIGHT file or CHANGES files shipped with SWIG or in submitted bugs.

      -Historically, the following people contributed to early versions of SWIG. -Peter Lomdahl, Brad Holian, Shujia Zhou, Niels Jensen, and Tim Germann -at Los Alamos National Laboratory were the first users. Patrick -Tullmann at the University of Utah suggested the idea of automatic -documentation generation. John Schmidt and Kurtis Bleeker at the -University of Utah tested out the early versions. Chris Johnson -supported SWIG's developed at the University of Utah. John Buckman, -Larry Virden, and Tom Schwaller provided valuable input on the first -releases and improving the portability of SWIG. David Fletcher and -Gary Holt have provided a great deal of input on improving SWIG's -Perl5 implementation. Kevin Butler contributed the first Windows NT -port.

      1.10 Bug reports

      diff --git a/Doc/Manual/Sections.html b/Doc/Manual/Sections.html index e26e4d31d..2d795595c 100644 --- a/Doc/Manual/Sections.html +++ b/Doc/Manual/Sections.html @@ -4,20 +4,12 @@ SWIG-1.3 Documentation -

      SWIG-1.3 Development Documentation

      +

      SWIG-2.0 Documentation

      Last update : SWIG-2.0.0 (in progress)

      Sections

      -

      -The SWIG documentation is being updated to reflect new SWIG -features and enhancements. However, this update process is not quite -finished--there is a lot of old SWIG-1.1 documentation and it is taking -some time to update all of it. Please pardon our dust (or volunteer -to help!). -

      -

      SWIG Core Documentation

      -

      Documentation that has not yet been updated

      - -

      -This documentation has not been completely updated from SWIG-1.1, but most of the topics -still apply to the current release. Make sure you read the -SWIG Basics chapter before reading -any of these chapters. Also, SWIG-1.3.10 features extensive changes to the -implementation of typemaps. Make sure you read the Typemaps -chapter above if you are using this feature. -

      - diff --git a/Doc/Manual/Windows.html b/Doc/Manual/Windows.html index e295fe307..da8a5d6bf 100644 --- a/Doc/Manual/Windows.html +++ b/Doc/Manual/Windows.html @@ -67,7 +67,7 @@ SWIG does not come with the usual Windows type installation program, however it

      -The swigwin distribution contains the SWIG Windows executable, swig.exe, which will run on 32 bit versions of Windows, ie Windows 95/98/ME/NT/2000/XP. +The swigwin distribution contains the SWIG Windows executable, swig.exe, which will run on 32 bit versions of Windows, ie Windows 95 and later. If you want to build your own swig.exe have a look at Building swig.exe on Windows.

      @@ -78,7 +78,7 @@ If you want to build your own swig.exe have a look at diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html index 366736eb7..c5778c432 100644 --- a/Doc/Manual/Java.html +++ b/Doc/Manual/Java.html @@ -1098,6 +1098,7 @@ Typesafe enums have their advantages over using plain integers in that they can However, there are limitations. For example, they cannot be used in switch statements and serialization is an issue. Please look at the following references for further information: + http://java.sun.com/developer/Books/shiftintojava/page1.html#replaceenums Replace Enums with Classes in Effective Java Programming on the Sun website, Create enumerated constants in Java JavaWorld article, Java Tip 133: More on typesafe enums and @@ -2360,7 +2361,7 @@ See The intermediary JNI class pragmas secti

      A Java proxy class is generated for each structure, union or C++ class that is wrapped. -Proxy classes have also been called peer classes. +Proxy classes have also been called peer classes. The default proxy class for our previous example looks like this:

      diff --git a/Doc/Manual/Modules.html b/Doc/Manual/Modules.html index 5ce448ce6..69cc58c30 100644 --- a/Doc/Manual/Modules.html +++ b/Doc/Manual/Modules.html @@ -244,7 +244,7 @@ is empty. Only modules compiled with the same pair will share type information.

      15.4 External access to the runtime

      -

      As described in The run-time type checker, +

      As described in The run-time type checker, the functions SWIG_TypeQuery, SWIG_NewPointerObj, and others sometimes need to be called. Calling these functions from a typemap is supported, since the typemap code is embedded into the _wrap.c file, which has those declarations available. If you need diff --git a/Doc/Manual/Preface.html b/Doc/Manual/Preface.html index ae2e1b7d9..2680328dd 100644 --- a/Doc/Manual/Preface.html +++ b/Doc/Manual/Preface.html @@ -11,13 +11,12 @@

      @@ -49,7 +48,7 @@ has since evolved into a general purpose tool that is used in a wide variety of applications--in fact almost anything where C/C++ programming is involved. -

      1.3 SWIG Versions

      +

      1.2 SWIG Versions

      @@ -64,7 +63,7 @@ under license terms of the user's choice/requirements and at the same time the S source was placed under the GNU General Public License version 3.

      -

      1.4 SWIG resources

      +

      1.3 SWIG resources

      @@ -103,7 +102,7 @@ about this can be obtained at:

      -

      1.5 Prerequisites

      +

      1.4 Prerequisites

      @@ -128,7 +127,7 @@ However, this isn't meant to be a tutorial on C++ programming. For many of the gory details, you will almost certainly want to consult a good C++ reference. If you don't program in C++, you may just want to skip those parts of the manual. -

      1.6 Organization of this manual

      +

      1.5 Organization of this manual

      @@ -140,7 +139,7 @@ can probably skip to that chapter and find almost everything you need to know.

      -

      1.7 How to avoid reading the manual

      +

      1.6 How to avoid reading the manual

      @@ -152,7 +151,7 @@ The SWIG distribution also comes with a large directory of examples that illustrate different topics.

      -

      1.8 Backwards compatibility

      +

      1.7 Backwards compatibility

      @@ -188,7 +187,7 @@ Note: The version symbol is not defined in the generated SWIG wrapper file. The SWIG preprocessor has defined SWIG_VERSION since SWIG-1.3.11.

      -

      1.9 Credits

      +

      1.8 Credits

      @@ -203,7 +202,7 @@ are mentioned either in the COPYRIGHT file or CHANGES files shipped with SWIG or

      -

      1.10 Bug reports

      +

      1.9 Bug reports

      From 27056fbd9f7e246aea3a6f85dcd0304679f5210e Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 29 May 2010 21:24:08 +0000 Subject: [PATCH 0893/1680] Tidy up for first 2.0 release. Move release notes summary into new file RELEASENOTES git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12069 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- ANNOUNCE | 13 +- COPYRIGHT | 13 ++ FUTURE | 335 ----------------------------------------------- Misc/fileheader | 10 -- NEW | 267 ------------------------------------- README | 342 ++++-------------------------------------------- RELEASENOTES | 223 +++++++++++++++++++++++++++++++ swig.spec.in | 2 +- 8 files changed, 268 insertions(+), 937 deletions(-) delete mode 100644 FUTURE delete mode 100644 Misc/fileheader delete mode 100644 NEW create mode 100644 RELEASENOTES diff --git a/ANNOUNCE b/ANNOUNCE index 2595f7a55..1327eb124 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -2,13 +2,10 @@ http://www.swig.org - -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. +We're pleased to announce SWIG-2.0.0, the latest SWIG release. What is SWIG? -------------- +============= SWIG is a software development tool that reads C/C++ header files and generates the wrapper code needed to make C and C++ code accessible @@ -20,8 +17,8 @@ SWIG include generation of scripting language extension modules, rapid prototyping, testing, and user interface development for large C/C++ systems. -Availability: -------------- +Availability +============ The release is available for download on Sourceforge at http://prdownloads.sourceforge.net/swig/swig-2.0.0.tar.gz @@ -30,7 +27,7 @@ A Windows version is also available at http://prdownloads.sourceforge.net/swig/swigwin-2.0.0.zip -Please report problems with this release to the swig-dev mailing list, +Please report problems with this release to the swig-devel mailing list, details at http://www.swig.org/mail.html. --- The SWIG Developers diff --git a/COPYRIGHT b/COPYRIGHT index 0e660ba3a..5296b3b48 100644 --- a/COPYRIGHT +++ b/COPYRIGHT @@ -61,3 +61,16 @@ Past contributors include: Kovuk, Oleg Tolmatcev, Tal Shalif, Lluis Padro, Chris Seatory, Igor Bely, Robin Dunn (See CHANGES and CHANGES.current for a more complete list). +Historically, the following people contributed to early versions of SWIG. +Peter Lomdahl, Brad Holian, Shujia Zhou, Niels Jensen, and Tim Germann +at Los Alamos National Laboratory were the first users. Patrick +Tullmann at the University of Utah suggested the idea of automatic +documentation generation. John Schmidt and Kurtis Bleeker at the +University of Utah tested out the early versions. Chris Johnson +supported SWIG's developed at the University of Utah. John Buckman, +Larry Virden, and Tom Schwaller provided valuable input on the first +releases and improving the portability of SWIG. David Fletcher and +Gary Holt have provided a great deal of input on improving SWIG's +Perl5 implementation. Kevin Butler contributed the first Windows NT +port. + diff --git a/FUTURE b/FUTURE deleted file mode 100644 index 997de9b4c..000000000 --- a/FUTURE +++ /dev/null @@ -1,335 +0,0 @@ -SWIG-1.3.12, SWIG 2.0, and Beyond -================================= - -With the release of SWIG-1.3.12, I thought I'd take a few moments of -everyone's time to talk about the past, the present, and the future of -SWIG development. I'm really quite excited about the current release -because I think it represents a huge turning point in SWIG's -development. Furthermore, it is only the beginning of bigger and -better things to come. However, we definitely need your help. - -To put a little perspective on the discussion, I'd start with a few -development statistics. In the last 12 months, there have been over -300 entries added to the CHANGES log and over 4000 CVS commits. -Although that may not sound like a lot compared to a huge software -project, it is significant in the context of SWIG. As a point of -comparison, there has been more SWIG development this year than in any -other year of the project and more than in the previous three years -combined. This even includes the first few years of development in -which there was also a lot of activity. Furthermore, many of the -recent changes have been extremely non-trivial (e.g., templates, -namespaces, type system, operators, etc.). As a result, SWIG is more -capable than I ever imagined possible. - -Regrettably, I must admit that I've been a little negligent in -discussing the roadmap for where I thought this flurry of SWIG -development was actually headed. In part, this is because I've been -buried in work. However, the real reason is that I didn't really know -where we were going---except that in a time far far far away in the -future, we might arrive at some kind of "stable" release with a -version number other than "1.3.x". Needless to say, that's not a very -compelling story. - -That said, I've spent a lot of time thinking about SWIG and trying to -wrap my brain around it. Specifically, just what is (or should be) -the primary focus of this project and what are we really trying to do? -That's what the rest of this message is about. - -SWIG Prehistory ---------------- -The first version of SWIG was written in 1995. The original system -was developed to help with some software wrapping problems I -encountered while writing molecular dynamics software at Los -Alamos. Later that year, I became interested in extending the wrapper -generator to support other scripting languages so it was rewritten in -C++ and modified with multiple backends (Tcl, Perl, and Guile). This -led to a first public release in February, 1996. Feedback from this -release led to a series of enhancements and the release of SWIG 1.0 in -September 1996. Throughout this process, my intent was to create a -tool that I would want to use---I never viewed the project as an -CS experiment in programming languages or software engineering. - -SWIG 1.1 --------- -SWIG-1.1 (June, 1997) represented a series of enhancements that were -added in response to feedback at conferences and from users. Shadow -classes, exception handling, typemaps, and a number of more useful -features were added. However, the overall structure of the system was -relatively unchanged from the initial version. Following the release -of 1.1, a series of minor patch releases were made. This resulted in -the release of SWIG-1.1p5 in February, 1998. Unfortunately, this -release would remain the last "stable" release for quite a long -time---in fact, it is still listed as the last "stable" release on the -SWIG web page! - -SWIG Hell ---------- -Even during the development of SWIG-1.1, it was clear that the whole -design of the system was deeply flawed. The implementation was a mess -and the C/C++ support was full of holes and nasty corner cases. -Furthermore, there was no unifying principle that tied all of the -different SWIG directives together. Not only that, fixing these -problems appeared to be nothing short of impossible---requiring a -total ground-up rewrite at best. The only redeeming quality was that -the system basically worked "well enough," it was extensively -documented, and its flaws mostly known. People could use it and there -were work-arounds for most common problems. - -To deal with the design problem, there were at least four attempts to -completely rewrite SWIG, some of which were attempted in parallel with -the work on SWIG-1.1. Unfortunately, none of these were ever -completed. The primary problem was a strong "second system" effect and -a desire to make SWIG do everything that one might conceivably want to -do with a wrapper generator (somehow). Clearly, this was a recipe for -disaster. In fact, all such attempts to rewrite SWIG were eventually -abandoned several years ago. In hindsight, I think the real problem -was that these rewrite efforts focused far too much attention on -implementation technique rather than principles. In short, the -failure of these efforts was due to a lack of clarity in understanding -how SWIG ought to work (regardless of how it was actually -implemented). - -SWIG Restart (1.3a1-1.3a5) --------------------------- -Having languished for several years, the SWIG1.1p5 release had a -growing pile of maintenance issues. It didn't work for newer versions -of certain language modules and a lot of minor bug reports and feature -requests had been building up. With a lot of help from Loic Dachary and -Thien-Thi Nguyen, we put together the 1.3a1 release (February, -2000). This was mostly a bug fix release to 1.1p5 except that the -preprocessor module from SWIG1.2 was added and a lot of minor -enhancements were added. - -For the next six months, a massive effort was made to rewrite all of -SWIG's internal data structures (strings, lists, hashes, etc.). This -work was all going on underneath the covers while we tried to keep -SWIG in an operational state. The primary focus of this work was -really one of cleanup. Having given up on a total rewrite, perhaps -we could settle with making the implementation incrementally better -than before. In addition this, Matthias Koppe jumped on board to -reimplement the Guile module and to make other improvements to the system. - -An important aspect of these releases was that many parts of the -system not directly related to wrapper code generation were removed. -This included the documentation system and Objective-C support. These -were not removed because they weren't useful. Instead, the -documentation system was removed because it accounted for nearly half -of the special SWIG directives, yet had no direct bearing on what SWIG -actually did. Obective-C support was removed because it was tangled -with C++ support in a way that was very difficult to understand and -maintain. The removal of these features was seen as a way to vastly -simplify cleanup--and to buy some time where we could rethink their -role in a future release. - -SWIG Redux (1.3.6-1.3.11) -------------------------- -This work, started in February 2001, is the beginning of the current -SWIG implementation. With the help of William Fulton, Matthias Koppe, -Lyle Johnson, Luigi Ballabio, Jason Stewart, Richard Palmer, Sam -Liddicot, and others, this work can best be described as the wholesale -destruction of everything remaining from SWIG-1.1. The language -module API, type system, the parser, numerous SWIG directives, and -SWIG library files---all destroyed or rewritten. Not only that, we -started introducing significant incompatibilities with -SWIG-1.1---mostly in an effort to correct past wrongs and get -ourselves out of the tangled mess of earlier versions. A huge number -of long-standing bugs and difficult feature requests have also been -resolved. - -The general goal of this development could best be described as an -attempt to reduce SWIG to an easily described set of general "ideas" -about how it should operate. Special SWIG directives have been -eliminated or combined with others. Different parts of the system have -been better integrated. Features not directly related to wrapper code -generation have been removed and the system has become more -focused. Changes in internal data structures and APIs have allowed -SWIG to capture more information from interface files and to resolve -hard corner cases. More often than not, these are things that you -never notice unless you are an old user and you suddenly realize that -a problem you had several years back has disappeared. - -Along with the destruction of old code, this work has quietly -introduced a new core--the most significant features of which are a -new C++ type system and multi-pass compilation. More importantly, -this work has really tried to provide a more principled foundation for -future SWIG development. However, just what is this "more principled -foundation?" - -Convergence (1.3.12) --------------------- -With the upcoming 1.3.12 release, SWIG is about to take a big leap -forward. Almost all of this is due to one realization---that almost -every hard problem in past SWIG releases has been directly related to -errors and limitations in its type system. Types are the key to -understanding the structure of C and C++ code. They are at the heart -of understanding advanced language features like namespaces, nested -classes, and templates. They are directly related to the data -marshalling that occurs in wrappers. Not only that, they interact -with nearly every SWIG directive. A proper type system *is* the -necessary foundation for moving SWIG forward. - -To be honest, I don't think that the emphasis on types is entirely -obvious. In fact, a great deal of work in past SWIG rewrites has -focused on the problem of C++ parsing. For instance, modifying the -parser to handle more advanced C++ code or representing parse trees as -XML. Furthermore, if one looks at the SWIG mailing list, you can find -a *lot* of messages related to issues of C++ parsing whereas almost no -one ever talks about types (well, other than typemaps). Even other -wrapper generation tools seems to spend a lot of time dealing with the -parsing issue. Although parsing is clearly important, I don't think it -has ever been the real problem in SWIG. This is because even though a -parser can tell you what's in a header file, it doesn't tell you -anything about how the different pieces of the system behave or how -they might interact. To do that, you need to do a lot more than just -parsing--and that's really the whole point. - -Although earlier 1.3 releases have made big improvements to the type -system, SWIG-1.3.12 is the first release that really tries to tackle -the type-system issue in a major way. We have patched nearly all -remaining holes in the type system and we have added full support for -C++ namespaces. Not only that, we have completely reimplemented C++ -template support in a way that supports templates, member templates, -and template specialization. Luigi and I are currently using this to -work on proper SWIG library support for parts of the C++ standard -library and the Standard Template Library (STL). Although some crusty -C programmers (present company excepted), might balk at such apparent -insanity, this work has impacted all parts of SWIG at all levels. -Even a variety of subtle errors in C support have been fixed by this -work. - -In addition to the type system work, SWIG-1.3.12 contains continued -reduction in the implementation. Directives have been removed, -refined, renamed, or consolidated. We're still narrowing the focus of -the system and working towards some kind of convergence. "Convergence -to what?!?", you ask. - -So, what is SWIG? ------------------ -In a nutshell, SWIG is a C/C++ declaration compiler that generates -wrapper code (okay, so you knew that much). However, to really -understand what SWIG is doing and where SWIG-1.3.x is headed, it is -useful to know that the whole system is essentially being built around -three extensions to the C++ type system: - - - Typemaps. Typemaps are rules that define the process by which - data is converted between languages. They are fully integrated - with the C++ type system and they are applied using a type-based - pattern matching mechanism. All data conversion SWIG is - defined by typemaps and is fully reconfigurable. - - - Declaration annotation. There are special directives that modify - the wrapping behavior of individual declarations. Declarations - can be selectively identified and decorated with arbitrary - attributes that affect wrapper generation. Like typemaps, - declaration matching is fully integrated with the C++ type system. - Almost all SWIG customization directives are a form of declaration - annotation. - - - Class extension. The ability to extend classes and structures - with new methods/attributes when building wrappers. Classes - are part of the type system so class extension is naturally - integrated with the C++ type system as well (big surprise). - -And that's it--this is the end-game of SWIG-1.3.x development. When -stabilized and documented it will become SWIG-2.0. - -The Bigger Picture ------------------- -I really want to emphasize that all of this work is part of a much -bigger picture. SWIG is used by a surprising number of people in -industry, government, and academia. It's used to build systems used -by millions of people every day. It has even shown up in video games -and other unlikely settings. Although SWIG doesn't have the same -visibility as many large software projects, over 12000 people have -downloaded SWIG-1.3.11 in the last 4 months. Clearly someone is using -it for something! Because of this, I think it is important for us to -work on moving SWIG towards a more solid foundation. Doing so will -give the system more credibility and long term viability---and it will -be a lot more fun to use! - -It's also worth noting that there are some rather interesting CS -connections at work here. Extensions to the type system and typemaps -have some interesting relations to work in programming languages. The -SWIG declaration annotation system and class extension feature seem -oddly similar to work in the emerging area of Aspect Oriented -Programming (AOP). There are undoubtedly connections to other areas -of software engineering and architecture. - -The key point is that SWIG isn't going to connect to anything if -no-one can quite describe what it is or how it works. - -SWIG-2.0 and the Future ------------------------ -SWIG-1.3.12 still represents work in progress. There are bugs, the -documentation is still incomplete, and there are parts of the -implementation that are rather ugly. We are also still working out a -few very hard problems like nested classes, callback functions, and -overloading. A few old features are still missing (Objective-C, -documentation). However, I believe the end of the 1.3.x series is -near and achievable. - -Over the summer, a few more 1.3.x releases may appear but the current -plan is to aim for a SWIG-2.0 release in September. This release is -really moving towards the design principles described above and will -be a very major enhancement over SWIG-1.1. - -As for the future, a number of interesting ideas are on the table. I -want to add support for contracts/assertions in order to solve some -reliability issues that arise when retrofitting legacy codes with a -scripting interface. Support for an extension language has been -promoted by David Fletcher and was suggested by someone else on the -mailing list rather recently. I have a graduate student working on -SWIG support for the Microsoft CLR and .NET languages. Other work -might include support for alternative parsers, dynamically loadable -language modules, and so forth. However, none of this is really going -to materialize if we can't get the 2.0 release stablized. In fact, I -see SWIG-2.0 as a necessary step for moving forward with these ideas. - -We need your help! Yes, you. ----------------------------- -Nobody gets paid to work on SWIG. The developers are volunteers who -work in their spare time. Furthermore, SWIG is not supported by -investors, a large corporation, or research grants. I work on it -because it's fun, challenging, and useful. I presume that other -developers do the same. However, we only have limited resources and -we need your help. - -- If you like SWIG and find it useful, we need you to try new versions. - We want you to torture test the releases and to break them. We need - bug reports. No bug is too obscure or unimportant---we *will* fix it - if we can. We also need feedback about things that are annoying or - compatibility features that might help in going from 1.1 to 2.0. - -- We need help with documentation, examples, testing, libraries, and all - sorts of other aspects of the release. Even if you have never - written a SWIG language module or dived into its implementation, - there are many ways that you can help. Consider writing a case study - about how you wrapped a big library. Contribute tests that break the - implementation in horrible ways. Help with the web page or FAQ. - -- Most of the SWIG-1.3.x work has focused on the SWIG core. However, as - the 2.0 release nears, we will be working on a variety of enhancements - to the language modules. If there are things you would like to see - in any of the language modules, you need to let us know. - -- There are SWIG language modules that have not made it into the - distribution. Examples that I know about include ITCL, Swig-Eiffel, - and Swig-Lua. We would gladly make these part of the standard SWIG - distribution. However, we also need help to do it. Porting from - SWIG-1.1 is no easy task, but we're more than willing to help. It's - not as bad as one might imagine. - -- We are always looking for developers. Subscribe to - the swig-dev mailing list, details at http://www.swig.org/mail.html, - or send me email to get involved. - -Acknowledgements ----------------- -I'd just like to thank everyone who has submitted feedback, bugs, made -contributions, and put up with my occasional thrashing over the years. -I welcome any comments about this document and how we can make SWIG even -better. - -Dave Beazley (beazley@cs.uchicago.edu) -June 2, 2002 - diff --git a/Misc/fileheader b/Misc/fileheader deleted file mode 100644 index dcdbdeb75..000000000 --- a/Misc/fileheader +++ /dev/null @@ -1,10 +0,0 @@ -/* ----------------------------------------------------------------------------- - * file.c - * - * This file does a bunch of stuff. - * - * 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. - * ----------------------------------------------------------------------------- */ diff --git a/NEW b/NEW deleted file mode 100644 index b329eb89a..000000000 --- a/NEW +++ /dev/null @@ -1,267 +0,0 @@ -New Features and Important Changes, v1.3 - -Author(s) : David Beazley - -March 21, 2003 - -1. Introduction ---------------- -This document briefly explains some of the most important changes made -since the release of SWIG1.1. The goal is to provide information for -people who want to upgrade an older SWIG interface to the new version. - -Most changes pertain to the internal implementation of SWIG and the -organization of the core, parser, and language modules. As a SWIG -user, almost all of these changes are hidden from view except for a -few important cases where changes to the core have dramatically -altered SWIG's old behavior. - -2. Types and typemaps ---------------------- -2.1 Variables of the form 'const type *' are no longer wrapped as - constants, but as C global variables. The earlier SWIG behavior - was incorrect due to Dave's misinterpretation of 'const' in the C - language specification. - - If you have written an interface that expects to create - constants using 'const type *' you will need to rewrite those - specifications using a new %constant directive like this: - - %constant(type *) name = value; - -2.2 SWIG generally has better support for pointers, 'const', - arrays, and pointers to functions. - -2.3 Typemaps are now applied to a more precisely defined set - of datatypes. For example, consider the following - typemap: - - %typemap(in) foo * { - ... get a foo ... - } - - In SWIG1.1, this typemap would get applied to 'foo *', - 'foo &', 'foo []', 'foo[][]', and so forth. - - In SWIG1.3, this typemap *only* gets applied to 'foo *' and - 'const foo *'. It does *NOT* get mapped to the other - variants listed above. - -2.4 Bug fix. SWIG now correctly handles typemaps of the form - - %typemap(in) Object { - ... get an object ... - } - -2.5 The memberout typemap is no longer available and is withdrawn. - The old implementation was essentially useless because of the - way in which code was generated. - -2.6 The memberin typemap is now inserted inline in the generated - wrapper code. This provides access to scripting-specific - variables in the wrapper function. - -2.7 SWIG-1.3.10 features a total rewrite of the typemap system. - Typemaps now use a different variable naming scheme. Typemaps - for arguments look like this: - - %typemap(in) sometype { - $1 = convert value ($input); - } - - The variable $1 replaces $target and the variable $input replaces - $source. - - For output values, typemaps look like this: - - %typemap(out) sometype { - $result = create result ($1); - } - - The variable $1 replaces $source and the variable $result replaces - $target. - - See Doc/Manual/Typemaps.html for a full description of the new - typemap system. - -2.8 Multi-argument typemaps are now supported. This solves a common - problem that occurs with functions like this - - void foo(char *buffer, int len); - - where you would like to make the two arguments operate as a single - object in the target language. - -2.9 Types such as 'const int &', 'const double &', are passed as - values instead of pointers. - -2.10 C++ namespaces are now supported. - -3. Type checking ----------------- - -SWIG no longer uses the functions SWIG_GetPtr() and SWIG_MakePtr() to -parse datatypes in wrapper code. This is because the type of a -pointer is no longer associated with a string, but with a special -"swig_type_info *" object. If you are not using typemaps, this change -should cause no noticable effects. However, if you have written -typemaps to handle pointers, here are the essential details: - -3.1 Type name mangling is different in SWIG1.3. For a type of - "int **", SWIG1.1 used to produce a name of the form - "_int_pp". SWIG1.3 on the other hand, produces a name - of the form "_p_p_int". There are a number of reasons for - changing the format, but I'd rather not go into it here. You'll - just have to learn to live with it :-). - -3.2 Types are described by a special "swig_type_info *" object. Everywhere - a string was used before, an object of this type will be used. - The "swig_type_info *" for a given type can always be obtained - using macros involving the mangled typename in 3.1. For example, - the type object of of 'int **' is 'SWIGTYPE_p_p_int'. - -3.3 Instead of SWIG_GetPtr, a function of the following form is used: - - int SWIG_ConvertPtr(ScriptObj *o, void **ptr, swig_type_info *ty, int flags); - - Note: the function name may differ in certain implementations (read - the source). For example: - - int SWIG_ConvertPtr(ScriptObj *o, void **ptr, SWIGTYPE_p_p_int,0); - - Passing a value of '0' for the type will accept any pointer. This - works kind of like 'void *'. The flags argument is reserved for - future expansion. - -3.4. To create a pointer object, one uses a function similar to - - ScriptObj *SWIG_NewPointer(void *ptr, swig_type_info *ty, int flags); - - It works in a similar manner: - - p = SWIG_NewPointer(ptr, SWIGTYPE_p_p_int, 0); - - You will have to read the source to get the exact function name - used. The flags argument is implementation specific and reserved - for future expansion. - -3.5. If, for whatever reason, you need to obtain the 'swig_type_info *' - outside the context of a wrapper file, you can use the - SWIG_TypeQuery() function. For example: - - swig_type_info *ty = SWIG_TypeQuery("int **"); - - this function returns an appropriate type_info structure or NULL - if no such type is registered. - -3.6 SWIG does not generate swig_type_info structures for types that are - not actually used in an interface file. As a result, the type - checking tables for SWIG1.3 tend to be much smaller than for SWIG1.1. - -*** Note: The old string-based type checking scheme is not going to -return to SWIG so do not ask for backwards compatibility. The new -scheme is substantially faster, it is less error-prone, it requires no -dynamic memory allocation, it works better with the runtime libraries, -and it is simpler to implement than the old string based approach. - -4. Deprecated Features (incomplete list) ----------------------------------------- - -4.1 Documentation system. The old documentation system has been removed - entirely. I expect it to return someday, but it will have a much - different form (probably influenced by XML). - -4.2 The %val and %out directives. These directives used to attach - properties to function parameters such as - - void foo(%val int *ptr); - - The same effect can now be achieved with typemaps: - - void foo(int *INPUT); - - -4.3 Extensions to the %module and %init directive are no longer - supported. For example: - - %module example, foo, bar - - This used to perform a special kind of multi-module - initialization for static linking. If you really - need to do this, you will have to manually insert - code into the module initialization function. - -4.4 %ifdef, %ifndef, %endif, %if, %elif, %else directives are - withdrawn. SWIG now has a real preprocessor. - -4.5 %checkout directive removed. - -4.6 %except and %new are deprecated. - -4.7 %readonly and %readwrite are deprecated. Use %immutable instead. - -4.8 The %addmethods directive has been renamed to %extend. - -5. Language specific changes ----------------------------- - -5.1 Python shadow classes are much more efficient and pass the shadow objects - directly to the C wrappers. - -5.2 Tcl code generation is substantially improved--especially for C++. - -5.3 Tcl module can now link to global variables of any type. - -5.4 Perl shadow classes improved and optimized somewhat. - -5.5 The Guile module represents pointers as smobs. (They used to be - mangled into strings.) Memory leaks and type conversion bugs have been - fixed. The Guile module system, including dynamic loading, and - exceptions are supported. A typemap-driven procedure-documentation - system has been added (requires Guile 1.4). Procedures-with-setters - can be generated. - -5.6 The Python module now automatically creates shadow class objects from the - C wrappers. This fixes a bunch of hard problems related to typemaps, - exception handling, and more. - -6. New Features ---------------- - -6.1 Java module added - -6.2 Ruby module added - -6.3 Mzscheme module added. - -6.4 Integrated preprocessor. You can now use C macros in SWIG interface files. - -6.5 PHP module added. - -6.6 %rename directive is greatly enhanced to deal with overloaded functions. - -6.7 Support for simple templates - -6.8 Support for overloaded operators. - -6.9 %feature directive. - -6.10 Ocaml module added. - -6.11 XML module added. - -6.12 CHICKEN module added. - -6.13 C# module added. - - - - - - - - - - - - diff --git a/README b/README index 8cdc34887..19036dc02 100644 --- a/README +++ b/README @@ -12,318 +12,36 @@ code) in order to make the corresponding C/C++ libraries available to the listed languages, or to extend C/C++ programs with a scripting language. -This distribution represents the latest development release of SWIG. - Up-to-date SWIG related information can be found at http://www.swig.org A SWIG FAQ and other hints can be found on the SWIG Wiki: - http://www.dabeaz.com/cgi-bin/wiki.pl + http://www.dabeaz.com/cgi-bin/wiki.pl - -!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!!!!!!! IMPORTANT !!!!!!! -!!!!!!! !!!!!!! -!!!!!!! Previous SWIG-1.1 users should read the documentation !!!!!!! -!!!!!!! file Doc/Manual/SWIG.html before trying to use SWIG-1.3!!!!!!! -!!!!!!! on existing SWIG interfaces. This is the most current !!!!!!! -!!!!!!! documentation that describes new 1.3 features and !!!!!!! -!!!!!!! incompatibilities. !!!!!!! -!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -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. -- Improved C# std::vector wrappers. -- Bug fixes: mainly Python, but also Perl, MzScheme, CFFI, Allegrocl - and Ruby - -SWIG-1.3.38 summary: -- Output directory regression fix and other minor bug fixes - -SWIG-1.3.37 summary: -- Python 3 support added -- SWIG now ships with a version of ccache that can be used with SWIG. - This enables the files generated by SWIG to be cached so that repeated - use of SWIG on unchanged input files speeds up builds quite considerably. -- PHP 4 support removed and PHP support improved in general -- Improved C# array support -- Numerous Allegro CL improvements -- Bug fixes/enhancements for Python, PHP, Java, C#, Chicken, Allegro CL, - CFFI, Ruby, Tcl, Perl, R, Lua. -- Other minor generic bug fixes and enhancements - -SWIG-1.3.36 summary: -- Enhancement to directors to wrap all protected members -- Optimisation feature for objects returned by value -- A few bugs fixes in the PHP, Java, Ruby, R, C#, Python, Lua and - Perl modules -- Other minor generic bug fixes - -SWIG-1.3.35 summary: -- Octave language module added -- Bug fixes in Python, Lua, Java, C#, Perl modules -- A few other generic bugs and runtime assertions fixed - -SWIG-1.3.34 summary: -- shared_ptr support for Python -- Support for latest R - version 2.6 -- Various minor improvements/bug fixes for R, Lua, Python, Java, C# -- A few other generic bug fixes, mainly for templates and using statements - -SWIG-1.3.33 summary: -- Fix regression for Perl where C++ wrappers would not compile -- Fix regression parsing macros - -SWIG-1.3.32 summary: -- shared_ptr support for Java and C# -- Enhanced STL support for Ruby -- Windows support for R -- Fixed long-standing memory leak in PHP Module -- Numerous fixes and minor enhancements for Allegrocl, C#, cffi, Chicken, Guile, - Java, Lua, Ocaml, Perl, PHP, Python, Ruby, Tcl. -- Improved warning support - -SWIG-1.3.31 summary: -- Python modern classes regression fix - -SWIG-1.3.30 summary: -- Python-2.5 support -- New language module: R -- Director support added for C# -- Numerous director fixes and improvements -- Improved mingw/msys support -- Better constants support in Guile and chicken modules -- Support for generating PHP5 class wrappers -- Important Java premature garbage collection fix -- Minor improvements/fixes in cffi, php, allegrocl, perl, chicken, lua, ruby, - ocaml, python, java, c# and guile language modules -- Many many other bug fixes - -SWIG-1.3.29 summary: -- Numerous important bug fixes -- Few minor new features -- Some performance improvements in generated code for Python - -SWIG-1.3.28 summary: -- More powerful renaming (%rename) capability. -- More user friendly warning handling. -- Add finer control for default constructors and destructors. We discourage - the use of the 'nodefault' option, which disables both constructors and - destructors, leading to possible memory leaks. Use instead 'nodefaultctor' - and/or 'nodefaultdtor'. -- Automatic copy constructor wrapper generation via the 'copyctor' option/feature. -- Better handling of Windows extensions and types. -- Better runtime error reporting. -- Add the %catches directive to catch and dispatch exceptions. -- Add the %naturalvar directive for more 'natural' variable wrapping. -- Better default handling of std::string variables using the %naturalvar directive. -- Add the %allowexcept and %exceptionvar directives to handle exceptions when - accessing a variable. -- Add the %delobject directive to mark methods that act like destructors. -- Add the -fastdispatch option to enable smaller and faster overload dispatch - mechanism. -- Template support for %rename, %feature and %typemap improved. -- Add/doc more debug options, such as -dump_module, -debug_typemaps, etc. -- Unified typemap library (UTL) potentially providing core typemaps for all - scripting languages based on the recently evolving Python typemaps. -- New language module: Common Lisp with CFFI. -- Python, Ruby, Perl and Tcl use the new UTL, many old reported and hidden - errors with typemaps are now fixed. -- Initial Java support for languages using the UTL via GCJ, you can now use - Java libraries in your favorite script language using gcj + swig. -- Tcl support for std::wstring. -- PHP4 module update, many error fixes and actively maintained again. -- Allegrocl support for C++, also enhanced C support. -- Ruby support for bang methods. -- Ruby support for user classes as native exceptions. -- Perl improved dispatching in overloaded functions via the new cast and rank - mechanism. -- Perl improved backward compatibility, 5.004 and later tested and working. -- Python improved backward compatibility, 1.5.2 and later tested and working. -- Python can use the same cast/rank mechanism via the -castmode option. -- Python implicit conversion mechanism similar to C++, via the %implicitconv - directive (replaces and improves the implicit.i library). -- Python threading support added. -- Python STL support improved, iterators are supported and STL containers can - use now the native PyObject type. -- Python many performance options and improvements, try the -O option to test - all of them. Python runtime benchmarks show up to 20 times better performance - compared to 1.3.27 and older versions. -- Python support for 'multi-inheritance' on the python side. -- Python simplified proxy classes, now swig doesn't need to generate the - additional 'ClassPtr' classes. -- Python extended support for smart pointers. -- Python better support for static member variables. -- Python backward compatibility improved, many projects that used to work - only with swig-1.3.21 to swig-1.3.24 are working again with swig-1.3.28 -- Python test-suite is now 'valgrinded' before release, and swig also - reports memory leaks due to missing destructors. -- Minor bug fixes and improvements to the Lua, Ruby, Java, C#, Python, Guile, - Chicken, Tcl and Perl modules. - -SWIG-1.3.27 summary: -- Fix bug in anonymous typedef structures which was leading to strange behaviour - -SWIG-1.3.26 summary: -- New language modules: Lua, CLISP and Common Lisp with UFFI. -- Big overhaul to the PHP module. -- Change to the way 'extern' is handled. -- Minor bug fixes specific to C#, Java, Modula3, Ocaml, Allegro CL, - XML, Lisp s-expressions, Tcl, Ruby and Python modules. -- Other minor improvements and bug fixes. - -SWIG-1.3.25 summary: -- Improved runtime type system. Speed of module loading improved in - modules with lots of types. SWIG_RUNTIME_VERSION has been increased - from 1 to 2, but the API is exactly the same; only internal changes - were made. -- The languages that use the runtime type system now support external - access to the runtime type system. -- Various improvements with typemaps and template handling. -- Fewer warnings in generated code. -- Improved colour documentation. -- Many C# module improvements (exception handling, prevention of early - garbage collection, C# attributes support added, more flexible type - marshalling/asymmetric types.) -- Minor improvements and bug fixes specific to the C#, Java, TCL, Guile, - Chicken, MzScheme, Perl, Php, Python, Ruby and Ocaml modules). -- Various other bug fixes and memory leak fixes. - -SWIG-1.3.24 summary: -- Improved enum handling -- More runtime library options -- More bugs fixes for templates and template default arguments, directors - and other areas. -- Better smart pointer support, including data members, static members - and %extend. - -SWIG-1.3.23 summary: -- Improved support for callbacks -- Python docstring support and better error handling -- C++ default argument support for Java and C# added. -- Improved c++ default argument support for the scripting languages plus - option to use original (compact) default arguments. -- %feature and %ignore/%rename bug fixes and mods - they might need default - arguments specified to maintain compatible behaviour when using the new - default arguments wrapping. -- Runtime library changes: Runtime code can now exist in more than one module - and so need not be compiled into just one module -- Further improved support for templates and namespaces -- Overloaded templated function support added -- More powerful default typemaps (mixed default typemaps) -- Some important %extend and director code bug fixes -- Guile now defaults to using SCM API. The old interface can be obtained by - the -gh option. -- Various minor improvements and bug fixes for C#, Chicken, Guile, Java, - MzScheme, Perl, Python and Ruby -- Improved dependencies generation for constructing Makefiles. - -SWIG-1.3.22 summary: -- Improved exception handling and translation of C errors or C++ - exceptions into target language exceptions. -- Improved enum support, mapping to built-in Java 1.5 enums and C# - enums or the typesafe enum pattern for these two languages. -- Python - much better STL suppport and support for std::wstring, - wchar_t and FILE *. -- Initial support for Modula3 and Allegro CL. -- 64 bit TCL support. -- Java and C#'s proxy classes are now nearly 100% generated from - typemaps and/or features for finer control on the generated code. -- SWIG runtime library support deprecation. -- Improved documentation. SWIG now additionally provides documentation - in the form of a single HTML page as well as a pdf document. -- Enhanced C++ friend declaration support. -- Better support for reference counted classes. -- Various %fragment improvements. -- RPM fixes. -- Various minor improvements and bug fixes for C#, Chicken, Guile, Java, - MzScheme, Perl, Php, Python, Ruby and XML. - - -The SWIG-1.3.x development releases offer a huge number of improvements -over older SWIG-1.1 releases. These improvements include: - - - Support for C++ overloaded functions and methods. - - Support for C++ smart pointers. - - Support for C++ namespaces - - Support for C++ overloaded operators. - - Support for C++ templates including member templates. - - Support for C++ template specialization and partial specialization. - - Support for C++ friend declarations. - - Parsing support for almost all C/C++ datatypes. - - Automatic translation of C++ exception specifiers. - - Contract support. - - A full C preprocessor with macro expansion. Includes C99 variadic macros. - - Java, Ruby, MzScheme, PHP4, OCAML, Pike, CHICKEN, XML and C# modules - added. Guile module improved. - - Director support - upcalls for C++ virtual functions into the target - language proxy class. - - Better code generation. SWIG is better able to make optimizations - in order to generate less code. - - Testing framework part of the distribution ("make -k check" support). - - A lot of minor bug fixes and cleanup. - - Better Windows support. - -If you used SWIG-1.1, a number of old features are missing from SWIG-1.3. - - - The SWIG-1.1 documentation system is gone and hasn't been - replaced yet. This is on the long-term to-do list. - - - The Tcl7.x and Perl4 modules are deprecated and no longer - included. - - - A wide variety of old SWIG command-line options and - obscure features are gone. - - - A lot of old %pragma directives and obscure undocumented - customization features have been eliminated. The same - functionality is now available through other means. - - - Objective C support doesn't work right now. No ETA as to - when it will return. - -Although we are making some attempt to preserve backwards -compatibility with interfaces written for SWIG-1.1, SWIG-1.3 -incorporates a number of very substantial modifications to type -handling, typemaps, and wrapper code generation. Therefore, if you -are making extensive use of advanced SWIG features, interfaces written -for SWIG-1.1 may not work. We apologize for the inconvenience, but -these changes are needed in order to fix a number of annoying -"features" in SWIG-1.1. Hopefully the list of new features will -provide enough incentive for you to upgrade (and that the -modifications to your interfaces will only be minor). - -In addition, SWIG-1.3 makes no attempt to be compatible with SWIG-1.1 at -the C++ API level so language modules written for SWIG-1.1 will most -definitely not work with this release. - -See the documentation for details of the SWIG_VERSION preprocessor -symbol if you have backward compatibility issues and need to use more -than one version of SWIG. - -The files NEW and CHANGES describe in some detail all of the important -changes that have been made to the system. Experienced users would be -well advised to read this. +License +======= +Please see the LICENSE file for details of the SWIG license. Release Notes ============= Please see the CHANGES.current file for a detailed list of bug fixes and new features for the current release. The CHANGES file contains bug fixes -and new features for older versions. A summary of the changes is included -in this README file. +and new features for older versions. A summary of changes in each release +can be found in the RELEASENOTES file. + +Backwards Compatibility +======================= +The developers strive their best to preserve backwards compatibility +between releases, but this is not always possible as the overriding +aim is to provide the best wrapping experience. Where backwards +compatibility is known to be broken, it is clearly marked as an +incompatibility in the CHANGES and CHANGES.current files. + +See the documentation for details of the SWIG_VERSION preprocessor +symbol if you have backward compatibility issues and need to use more +than one version of SWIG. Windows Installation ==================== @@ -380,8 +98,9 @@ examples which build the runtime library. Notes: (1) If you checked the code out via SVN, you will have to run ./autogen.sh - before typing 'configure'. In addition, a full build of SWIG requires - the use of bison. + before typing 'configure'. In addition, a full build of SWIG requires + the a number of packages to be installed. Full instructions at + http://www.swig.org/svn.html Macintosh OS X Installation ============================ @@ -389,15 +108,13 @@ SWIG is known to work on various flavors of OS X. Follow the Unix installation instructions above. However, as of this writing, there is still great deal of inconsistency with how shared libaries are handled by various scripting languages on OS X. We've tried to resolve these differences to the extent of our knowledge. -This release was most recently checked with the Panther release of OS X on a -Macintosh G5 system. Your mileage may vary. Users of OS X should be aware that Darwin handles shared libraries and linking in a radically different way than most Unix systems. In order to test SWIG and run the examples, SWIG configures itself to use flat namespaces and to allow undefined -symbols (-flat_namespace -undefined suppress). This mostly closely follows the Unix +symbols (-flat_namespace -undefined suppress). This mostly closely follows the Unix model and makes it more likely that the SWIG examples will work with whatever -installation of software you might have. However, this is generally not the recommended +installation of software you might have. However, this is generally not the recommended technique for building larger extension modules. Instead, you should utilize Darwin's two-level namespaces. Some details about this can be found here @@ -435,7 +152,7 @@ tests may fail on older C++ compilers (for instance if your compiler does not support member templates). These errors are harmless if you don't intend to use these features in your own programs. -Note: The test-suite currently contains around 250 tests. If you +Note: The test-suite currently contains over 500 tests. If you have many different target languages installed and a slow machine, it might take more than an hour to run the test-suite. @@ -490,16 +207,11 @@ Documentation The Doc/Manual directory contains the most recent set of updated documentation for this release. The documentation is available in three different formats, each of which contains identical content. -These format are, pdf (SWIGDocumentation.pdf), single +These format are, pdf (Doc/Manual/SWIGDocumentation.pdf), single page html (Doc/Manual/SWIGDocumentation.html) or multiple page html (other files in Doc/Manual). Please select your chosen format and copy/install to wherever takes your fancy. -This is a development release and the documentation is largely, but -not entirely up to date. We are working on it, but there -was a lot of old documentation and it is taking some time to -update and complete. Please be patient or volunteer to help. - There is some technical developer documentation available in the Doc/Devel subdirectory. This is not necessarily up-to-date, but it has some information on SWIG internals. @@ -511,11 +223,9 @@ have access to a limited variety of hardware (Linux, Solaris, OS-X, and Windows). All contributions help. If you would like to join the SWIG development team or contribute a -language module to the distribution, please contact the swig-dev +language module to the distribution, please contact the swig-devel mailing list, details at http://www.swig.org/mail.html. -- The SWIG Maintainers - - diff --git a/RELEASENOTES b/RELEASENOTES new file mode 100644 index 000000000..da833574c --- /dev/null +++ b/RELEASENOTES @@ -0,0 +1,223 @@ +Release Notes +============= + +A summary of recent releases is described below. A more detailed description +is available in the CHANGES.current and CHANGES files. + +SWIG-1.3.40 summary: +- SWIG now supports directors for PHP. +- PHP support improved in general. +- Octave 3.2 support added. +- Various bug fixes/enhancements for Allegrocl, C#, Java, Octave, Perl, + Python, Ruby and Tcl. +- Other generic fixes and minor new features. + +SWIG-1.3.39 summary: +- Some new small feature enhancements. +- Improved C# std::vector wrappers. +- Bug fixes: mainly Python, but also Perl, MzScheme, CFFI, Allegrocl + and Ruby + +SWIG-1.3.38 summary: +- Output directory regression fix and other minor bug fixes + +SWIG-1.3.37 summary: +- Python 3 support added +- SWIG now ships with a version of ccache that can be used with SWIG. + This enables the files generated by SWIG to be cached so that repeated + use of SWIG on unchanged input files speeds up builds quite considerably. +- PHP 4 support removed and PHP support improved in general +- Improved C# array support +- Numerous Allegro CL improvements +- Bug fixes/enhancements for Python, PHP, Java, C#, Chicken, Allegro CL, + CFFI, Ruby, Tcl, Perl, R, Lua. +- Other minor generic bug fixes and enhancements + +SWIG-1.3.36 summary: +- Enhancement to directors to wrap all protected members +- Optimisation feature for objects returned by value +- A few bugs fixes in the PHP, Java, Ruby, R, C#, Python, Lua and + Perl modules +- Other minor generic bug fixes + +SWIG-1.3.35 summary: +- Octave language module added +- Bug fixes in Python, Lua, Java, C#, Perl modules +- A few other generic bugs and runtime assertions fixed + +SWIG-1.3.34 summary: +- shared_ptr support for Python +- Support for latest R - version 2.6 +- Various minor improvements/bug fixes for R, Lua, Python, Java, C# +- A few other generic bug fixes, mainly for templates and using statements + +SWIG-1.3.33 summary: +- Fix regression for Perl where C++ wrappers would not compile +- Fix regression parsing macros + +SWIG-1.3.32 summary: +- shared_ptr support for Java and C# +- Enhanced STL support for Ruby +- Windows support for R +- Fixed long-standing memory leak in PHP Module +- Numerous fixes and minor enhancements for Allegrocl, C#, cffi, Chicken, Guile, + Java, Lua, Ocaml, Perl, PHP, Python, Ruby, Tcl. +- Improved warning support + +SWIG-1.3.31 summary: +- Python modern classes regression fix + +SWIG-1.3.30 summary: +- Python-2.5 support +- New language module: R +- Director support added for C# +- Numerous director fixes and improvements +- Improved mingw/msys support +- Better constants support in Guile and chicken modules +- Support for generating PHP5 class wrappers +- Important Java premature garbage collection fix +- Minor improvements/fixes in cffi, php, allegrocl, perl, chicken, lua, ruby, + ocaml, python, java, c# and guile language modules +- Many many other bug fixes + +SWIG-1.3.29 summary: +- Numerous important bug fixes +- Few minor new features +- Some performance improvements in generated code for Python + +SWIG-1.3.28 summary: +- More powerful renaming (%rename) capability. +- More user friendly warning handling. +- Add finer control for default constructors and destructors. We discourage + the use of the 'nodefault' option, which disables both constructors and + destructors, leading to possible memory leaks. Use instead 'nodefaultctor' + and/or 'nodefaultdtor'. +- Automatic copy constructor wrapper generation via the 'copyctor' option/feature. +- Better handling of Windows extensions and types. +- Better runtime error reporting. +- Add the %catches directive to catch and dispatch exceptions. +- Add the %naturalvar directive for more 'natural' variable wrapping. +- Better default handling of std::string variables using the %naturalvar directive. +- Add the %allowexcept and %exceptionvar directives to handle exceptions when + accessing a variable. +- Add the %delobject directive to mark methods that act like destructors. +- Add the -fastdispatch option to enable smaller and faster overload dispatch + mechanism. +- Template support for %rename, %feature and %typemap improved. +- Add/doc more debug options, such as -dump_module, -debug_typemaps, etc. +- Unified typemap library (UTL) potentially providing core typemaps for all + scripting languages based on the recently evolving Python typemaps. +- New language module: Common Lisp with CFFI. +- Python, Ruby, Perl and Tcl use the new UTL, many old reported and hidden + errors with typemaps are now fixed. +- Initial Java support for languages using the UTL via GCJ, you can now use + Java libraries in your favorite script language using gcj + swig. +- Tcl support for std::wstring. +- PHP4 module update, many error fixes and actively maintained again. +- Allegrocl support for C++, also enhanced C support. +- Ruby support for bang methods. +- Ruby support for user classes as native exceptions. +- Perl improved dispatching in overloaded functions via the new cast and rank + mechanism. +- Perl improved backward compatibility, 5.004 and later tested and working. +- Python improved backward compatibility, 1.5.2 and later tested and working. +- Python can use the same cast/rank mechanism via the -castmode option. +- Python implicit conversion mechanism similar to C++, via the %implicitconv + directive (replaces and improves the implicit.i library). +- Python threading support added. +- Python STL support improved, iterators are supported and STL containers can + use now the native PyObject type. +- Python many performance options and improvements, try the -O option to test + all of them. Python runtime benchmarks show up to 20 times better performance + compared to 1.3.27 and older versions. +- Python support for 'multi-inheritance' on the python side. +- Python simplified proxy classes, now swig doesn't need to generate the + additional 'ClassPtr' classes. +- Python extended support for smart pointers. +- Python better support for static member variables. +- Python backward compatibility improved, many projects that used to work + only with swig-1.3.21 to swig-1.3.24 are working again with swig-1.3.28 +- Python test-suite is now 'valgrinded' before release, and swig also + reports memory leaks due to missing destructors. +- Minor bug fixes and improvements to the Lua, Ruby, Java, C#, Python, Guile, + Chicken, Tcl and Perl modules. + +SWIG-1.3.27 summary: +- Fix bug in anonymous typedef structures which was leading to strange behaviour + +SWIG-1.3.26 summary: +- New language modules: Lua, CLISP and Common Lisp with UFFI. +- Big overhaul to the PHP module. +- Change to the way 'extern' is handled. +- Minor bug fixes specific to C#, Java, Modula3, Ocaml, Allegro CL, + XML, Lisp s-expressions, Tcl, Ruby and Python modules. +- Other minor improvements and bug fixes. + +SWIG-1.3.25 summary: +- Improved runtime type system. Speed of module loading improved in + modules with lots of types. SWIG_RUNTIME_VERSION has been increased + from 1 to 2, but the API is exactly the same; only internal changes + were made. +- The languages that use the runtime type system now support external + access to the runtime type system. +- Various improvements with typemaps and template handling. +- Fewer warnings in generated code. +- Improved colour documentation. +- Many C# module improvements (exception handling, prevention of early + garbage collection, C# attributes support added, more flexible type + marshalling/asymmetric types.) +- Minor improvements and bug fixes specific to the C#, Java, TCL, Guile, + Chicken, MzScheme, Perl, Php, Python, Ruby and Ocaml modules). +- Various other bug fixes and memory leak fixes. + +SWIG-1.3.24 summary: +- Improved enum handling +- More runtime library options +- More bugs fixes for templates and template default arguments, directors + and other areas. +- Better smart pointer support, including data members, static members + and %extend. + +SWIG-1.3.23 summary: +- Improved support for callbacks +- Python docstring support and better error handling +- C++ default argument support for Java and C# added. +- Improved c++ default argument support for the scripting languages plus + option to use original (compact) default arguments. +- %feature and %ignore/%rename bug fixes and mods - they might need default + arguments specified to maintain compatible behaviour when using the new + default arguments wrapping. +- Runtime library changes: Runtime code can now exist in more than one module + and so need not be compiled into just one module +- Further improved support for templates and namespaces +- Overloaded templated function support added +- More powerful default typemaps (mixed default typemaps) +- Some important %extend and director code bug fixes +- Guile now defaults to using SCM API. The old interface can be obtained by + the -gh option. +- Various minor improvements and bug fixes for C#, Chicken, Guile, Java, + MzScheme, Perl, Python and Ruby +- Improved dependencies generation for constructing Makefiles. + +SWIG-1.3.22 summary: +- Improved exception handling and translation of C errors or C++ + exceptions into target language exceptions. +- Improved enum support, mapping to built-in Java 1.5 enums and C# + enums or the typesafe enum pattern for these two languages. +- Python - much better STL suppport and support for std::wstring, + wchar_t and FILE *. +- Initial support for Modula3 and Allegro CL. +- 64 bit TCL support. +- Java and C#'s proxy classes are now nearly 100% generated from + typemaps and/or features for finer control on the generated code. +- SWIG runtime library support deprecation. +- Improved documentation. SWIG now additionally provides documentation + in the form of a single HTML page as well as a pdf document. +- Enhanced C++ friend declaration support. +- Better support for reference counted classes. +- Various %fragment improvements. +- RPM fixes. +- Various minor improvements and bug fixes for C#, Chicken, Guile, Java, + MzScheme, Perl, Php, Python, Ruby and XML. + + diff --git a/swig.spec.in b/swig.spec.in index 14d95d22f..0f64235fb 100644 --- a/swig.spec.in +++ b/swig.spec.in @@ -50,7 +50,7 @@ rm -rf ${RPM_BUILD_ROOT} %files %defattr(-,root,root) -%doc ANNOUNCE CHANGES FUTURE INSTALL LICENSE NEW README TODO +%doc ANNOUNCE CHANGES INSTALL LICENSE LICENSE-GPL LICENSE-UNIVERSITIES README RELEASENOTES %doc Doc/* %{_bindir}/* %{prefix}/share/* From 5aaf531b5ad3220044506a0273f18c35515de3ec Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 29 May 2010 21:35:39 +0000 Subject: [PATCH 0894/1680] Remove WAD and swig.spec.1 - not used or maintained git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12070 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Tools/WAD/CHANGES | 25 - Tools/WAD/COPYING | 504 ------------------ Tools/WAD/HACK | 78 --- Tools/WAD/Include/wad.h | 269 ---------- Tools/WAD/Makefile.in | 46 -- Tools/WAD/Misc/fileheader | 28 - Tools/WAD/Papers/README | 5 - Tools/WAD/Prebuilt/linux/Makefile.in | 11 - Tools/WAD/Prebuilt/solaris/Makefile.in | 11 - Tools/WAD/Python/Makefile.in | 54 -- Tools/WAD/Python/python.c | 221 -------- Tools/WAD/Python/type.c | 277 ---------- Tools/WAD/Python/wadpyinit.cxx | 45 -- Tools/WAD/README | 376 -------------- Tools/WAD/Tcl/Makefile.in | 54 -- Tools/WAD/Tcl/wadtcl.c | 122 ----- Tools/WAD/Tcl/wadtclinit.cxx | 38 -- Tools/WAD/Test/Makefile.in | 44 -- Tools/WAD/Test/README | 5 - Tools/WAD/Test/death.py | 65 --- Tools/WAD/Test/death.tcl | 65 --- Tools/WAD/Test/debug.c | 119 ----- Tools/WAD/Test/debug.i | 9 - Tools/WAD/Test/debug.py | 35 -- Tools/WAD/Test/debug.tcl | 25 - Tools/WAD/Test/foo.py | 31 -- Tools/WAD/Test/wadpm.py | 49 -- Tools/WAD/Test/wpm.py | 280 ---------- Tools/WAD/Wad/Makefile.in | 73 --- Tools/WAD/Wad/debug.c | 98 ---- Tools/WAD/Wad/default.c | 311 ----------- Tools/WAD/Wad/demangle.c | 36 -- Tools/WAD/Wad/elf.c | 428 ---------------- Tools/WAD/Wad/init.c | 113 ---- Tools/WAD/Wad/io.c | 107 ---- Tools/WAD/Wad/libwadpl.pm | 8 - Tools/WAD/Wad/main.cxx | 14 - Tools/WAD/Wad/makehandler.py | 20 - Tools/WAD/Wad/memory.c | 174 ------- Tools/WAD/Wad/object.c | 303 ----------- Tools/WAD/Wad/return.c | 69 --- Tools/WAD/Wad/segment.c | 227 -------- Tools/WAD/Wad/signal.c | 520 ------------------- Tools/WAD/Wad/stab.c | 682 ------------------------- Tools/WAD/Wad/stack.c | 309 ----------- Tools/WAD/Wad/string.c | 131 ----- Tools/WAD/Wad/vars.c | 271 ---------- Tools/WAD/Wad/wadhandler.pl | 36 -- Tools/WAD/Wad/wadpl.cxx | 176 ------- Tools/WAD/configure.in | 365 ------------- Tools/swig.spec.1 | 42 -- 51 files changed, 7404 deletions(-) delete mode 100644 Tools/WAD/CHANGES delete mode 100644 Tools/WAD/COPYING delete mode 100644 Tools/WAD/HACK delete mode 100644 Tools/WAD/Include/wad.h delete mode 100644 Tools/WAD/Makefile.in delete mode 100644 Tools/WAD/Misc/fileheader delete mode 100644 Tools/WAD/Papers/README delete mode 100644 Tools/WAD/Prebuilt/linux/Makefile.in delete mode 100644 Tools/WAD/Prebuilt/solaris/Makefile.in delete mode 100644 Tools/WAD/Python/Makefile.in delete mode 100644 Tools/WAD/Python/python.c delete mode 100644 Tools/WAD/Python/type.c delete mode 100644 Tools/WAD/Python/wadpyinit.cxx delete mode 100644 Tools/WAD/README delete mode 100644 Tools/WAD/Tcl/Makefile.in delete mode 100644 Tools/WAD/Tcl/wadtcl.c delete mode 100644 Tools/WAD/Tcl/wadtclinit.cxx delete mode 100644 Tools/WAD/Test/Makefile.in delete mode 100644 Tools/WAD/Test/README delete mode 100644 Tools/WAD/Test/death.py delete mode 100644 Tools/WAD/Test/death.tcl delete mode 100644 Tools/WAD/Test/debug.c delete mode 100644 Tools/WAD/Test/debug.i delete mode 100644 Tools/WAD/Test/debug.py delete mode 100644 Tools/WAD/Test/debug.tcl delete mode 100644 Tools/WAD/Test/foo.py delete mode 100644 Tools/WAD/Test/wadpm.py delete mode 100644 Tools/WAD/Test/wpm.py delete mode 100644 Tools/WAD/Wad/Makefile.in delete mode 100644 Tools/WAD/Wad/debug.c delete mode 100644 Tools/WAD/Wad/default.c delete mode 100644 Tools/WAD/Wad/demangle.c delete mode 100644 Tools/WAD/Wad/elf.c delete mode 100644 Tools/WAD/Wad/init.c delete mode 100644 Tools/WAD/Wad/io.c delete mode 100644 Tools/WAD/Wad/libwadpl.pm delete mode 100644 Tools/WAD/Wad/main.cxx delete mode 100755 Tools/WAD/Wad/makehandler.py delete mode 100644 Tools/WAD/Wad/memory.c delete mode 100644 Tools/WAD/Wad/object.c delete mode 100644 Tools/WAD/Wad/return.c delete mode 100644 Tools/WAD/Wad/segment.c delete mode 100644 Tools/WAD/Wad/signal.c delete mode 100644 Tools/WAD/Wad/stab.c delete mode 100644 Tools/WAD/Wad/stack.c delete mode 100644 Tools/WAD/Wad/string.c delete mode 100644 Tools/WAD/Wad/vars.c delete mode 100644 Tools/WAD/Wad/wadhandler.pl delete mode 100644 Tools/WAD/Wad/wadpl.cxx delete mode 100644 Tools/WAD/configure.in delete mode 100644 Tools/swig.spec.1 diff --git a/Tools/WAD/CHANGES b/Tools/WAD/CHANGES deleted file mode 100644 index 186d15e7b..000000000 --- a/Tools/WAD/CHANGES +++ /dev/null @@ -1,25 +0,0 @@ -WAD 0.3 - June 2, 2002 - - - Added to the SWIG distribution. - -WAD 0.2 - June 24, 2001 - - - Minor changes. Added the wadtrace file - - - Put everything under the LGPL. - -WAD 0.1 - March 23, 2001 - - - Extensive changes to WAD core. WAD now builds an exception - object that can be queried and manipulated after a fault - occurs. - - - Better collection of debugging information. WAD is now - able to determine basic datatypes and other information - from stabs data. - - - Better reliability overall. - -WAD 0.0 - January, 2001 - -beazley - Initial "release". Not much of a release really. diff --git a/Tools/WAD/COPYING b/Tools/WAD/COPYING deleted file mode 100644 index b1e3f5a26..000000000 --- a/Tools/WAD/COPYING +++ /dev/null @@ -1,504 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 2.1, February 1999 - - Copyright (C) 1991, 1999 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - -[This is the first released version of the Lesser GPL. It also counts - as the successor of the GNU Library Public License, version 2, hence - the version number 2.1.] - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -Licenses are intended to guarantee your freedom to share and change -free software--to make sure the software is free for all its users. - - This license, the Lesser General Public License, applies to some -specially designated software packages--typically libraries--of the -Free Software Foundation and other authors who decide to use it. You -can use it too, but we suggest you first think carefully about whether -this license or the ordinary General Public License is the better -strategy to use in any particular case, based on the explanations below. - - When we speak of free software, we are referring to freedom of use, -not price. Our General Public Licenses are designed to make sure that -you have the freedom to distribute copies of free software (and charge -for this service if you wish); that you receive source code or can get -it if you want it; that you can change the software and use pieces of -it in new free programs; and that you are informed that you can do -these things. - - To protect your rights, we need to make restrictions that forbid -distributors to deny you these rights or to ask you to surrender these -rights. These restrictions translate to certain responsibilities for -you if you distribute copies of the library or if you modify it. - - For example, if you distribute copies of the library, whether gratis -or for a fee, you must give the recipients all the rights that we gave -you. You must make sure that they, too, receive or can get the source -code. If you link other code with the library, you must provide -complete object files to the recipients, so that they can relink them -with the library after making changes to the library and recompiling -it. And you must show them these terms so they know their rights. - - We protect your rights with a two-step method: (1) we copyright the -library, and (2) we offer you this license, which gives you legal -permission to copy, distribute and/or modify the library. - - To protect each distributor, we want to make it very clear that -there is no warranty for the free library. Also, if the library is -modified by someone else and passed on, the recipients should know -that what they have is not the original version, so that the original -author's reputation will not be affected by problems that might be -introduced by others. - - Finally, software patents pose a constant threat to the existence of -any free program. We wish to make sure that a company cannot -effectively restrict the users of a free program by obtaining a -restrictive license from a patent holder. Therefore, we insist that -any patent license obtained for a version of the library must be -consistent with the full freedom of use specified in this license. - - Most GNU software, including some libraries, is covered by the -ordinary GNU General Public License. This license, the GNU Lesser -General Public License, applies to certain designated libraries, and -is quite different from the ordinary General Public License. We use -this license for certain libraries in order to permit linking those -libraries into non-free programs. - - When a program is linked with a library, whether statically or using -a shared library, the combination of the two is legally speaking a -combined work, a derivative of the original library. The ordinary -General Public License therefore permits such linking only if the -entire combination fits its criteria of freedom. The Lesser General -Public License permits more lax criteria for linking other code with -the library. - - We call this license the "Lesser" General Public License because it -does Less to protect the user's freedom than the ordinary General -Public License. It also provides other free software developers Less -of an advantage over competing non-free programs. These disadvantages -are the reason we use the ordinary General Public License for many -libraries. However, the Lesser license provides advantages in certain -special circumstances. - - For example, on rare occasions, there may be a special need to -encourage the widest possible use of a certain library, so that it becomes -a de-facto standard. To achieve this, non-free programs must be -allowed to use the library. A more frequent case is that a free -library does the same job as widely used non-free libraries. In this -case, there is little to gain by limiting the free library to free -software only, so we use the Lesser General Public License. - - In other cases, permission to use a particular library in non-free -programs enables a greater number of people to use a large body of -free software. For example, permission to use the GNU C Library in -non-free programs enables many more people to use the whole GNU -operating system, as well as its variant, the GNU/Linux operating -system. - - Although the Lesser General Public License is Less protective of the -users' freedom, it does ensure that the user of a program that is -linked with the Library has the freedom and the wherewithal to run -that program using a modified version of the Library. - - The precise terms and conditions for copying, distribution and -modification follow. Pay close attention to the difference between a -"work based on the library" and a "work that uses the library". The -former contains code derived from the library, whereas the latter must -be combined with the library in order to run. - - GNU LESSER GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License Agreement applies to any software library or other -program which contains a notice placed by the copyright holder or -other authorized party saying it may be distributed under the terms of -this Lesser General Public License (also called "this License"). -Each licensee is addressed as "you". - - A "library" means a collection of software functions and/or data -prepared so as to be conveniently linked with application programs -(which use some of those functions and data) to form executables. - - The "Library", below, refers to any such software library or work -which has been distributed under these terms. A "work based on the -Library" means either the Library or any derivative work under -copyright law: that is to say, a work containing the Library or a -portion of it, either verbatim or with modifications and/or translated -straightforwardly into another language. (Hereinafter, translation is -included without limitation in the term "modification".) - - "Source code" for a work means the preferred form of the work for -making modifications to it. For a library, complete source code means -all the source code for all modules it contains, plus any associated -interface definition files, plus the scripts used to control compilation -and installation of the library. - - Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running a program using the Library is not restricted, and output from -such a program is covered only if its contents constitute a work based -on the Library (independent of the use of the Library in a tool for -writing it). Whether that is true depends on what the Library does -and what the program that uses the Library does. - - 1. You may copy and distribute verbatim copies of the Library's -complete source code as you receive it, in any medium, provided that -you conspicuously and appropriately publish on each copy an -appropriate copyright notice and disclaimer of warranty; keep intact -all the notices that refer to this License and to the absence of any -warranty; and distribute a copy of this License along with the -Library. - - You may charge a fee for the physical act of transferring a copy, -and you may at your option offer warranty protection in exchange for a -fee. - - 2. You may modify your copy or copies of the Library or any portion -of it, thus forming a work based on the Library, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices - stating that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no - charge to all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or a - table of data to be supplied by an application program that uses - the facility, other than as an argument passed when the facility - is invoked, then you must make a good faith effort to ensure that, - in the event an application does not supply such function or - table, the facility still operates, and performs whatever part of - its purpose remains meaningful. - - (For example, a function in a library to compute square roots has - a purpose that is entirely well-defined independent of the - application. Therefore, Subsection 2d requires that any - application-supplied function or table used by this function must - be optional: if the application does not supply it, the square - root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Library, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Library, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote -it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Library. - -In addition, mere aggregation of another work not based on the Library -with the Library (or with a work based on the Library) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may opt to apply the terms of the ordinary GNU General Public -License instead of this License to a given copy of the Library. To do -this, you must alter all the notices that refer to this License, so -that they refer to the ordinary GNU General Public License, version 2, -instead of to this License. (If a newer version than version 2 of the -ordinary GNU General Public License has appeared, then you can specify -that version instead if you wish.) Do not make any other change in -these notices. - - Once this change is made in a given copy, it is irreversible for -that copy, so the ordinary GNU General Public License applies to all -subsequent copies and derivative works made from that copy. - - This option is useful when you wish to copy part of the code of -the Library into a program that is not a library. - - 4. You may copy and distribute the Library (or a portion or -derivative of it, under Section 2) in object code or executable form -under the terms of Sections 1 and 2 above provided that you accompany -it with the complete corresponding machine-readable source code, which -must be distributed under the terms of Sections 1 and 2 above on a -medium customarily used for software interchange. - - If distribution of object code is made by offering access to copy -from a designated place, then offering equivalent access to copy the -source code from the same place satisfies the requirement to -distribute the source code, even though third parties are not -compelled to copy the source along with the object code. - - 5. A program that contains no derivative of any portion of the -Library, but is designed to work with the Library by being compiled or -linked with it, is called a "work that uses the Library". Such a -work, in isolation, is not a derivative work of the Library, and -therefore falls outside the scope of this License. - - However, linking a "work that uses the Library" with the Library -creates an executable that is a derivative of the Library (because it -contains portions of the Library), rather than a "work that uses the -library". The executable is therefore covered by this License. -Section 6 states terms for distribution of such executables. - - When a "work that uses the Library" uses material from a header file -that is part of the Library, the object code for the work may be a -derivative work of the Library even though the source code is not. -Whether this is true is especially significant if the work can be -linked without the Library, or if the work is itself a library. The -threshold for this to be true is not precisely defined by law. - - If such an object file uses only numerical parameters, data -structure layouts and accessors, and small macros and small inline -functions (ten lines or less in length), then the use of the object -file is unrestricted, regardless of whether it is legally a derivative -work. (Executables containing this object code plus portions of the -Library will still fall under Section 6.) - - Otherwise, if the work is a derivative of the Library, you may -distribute the object code for the work under the terms of Section 6. -Any executables containing that work also fall under Section 6, -whether or not they are linked directly with the Library itself. - - 6. As an exception to the Sections above, you may also combine or -link a "work that uses the Library" with the Library to produce a -work containing portions of the Library, and distribute that work -under terms of your choice, provided that the terms permit -modification of the work for the customer's own use and reverse -engineering for debugging such modifications. - - You must give prominent notice with each copy of the work that the -Library is used in it and that the Library and its use are covered by -this License. You must supply a copy of this License. If the work -during execution displays copyright notices, you must include the -copyright notice for the Library among them, as well as a reference -directing the user to the copy of this License. Also, you must do one -of these things: - - a) Accompany the work with the complete corresponding - machine-readable source code for the Library including whatever - changes were used in the work (which must be distributed under - Sections 1 and 2 above); and, if the work is an executable linked - with the Library, with the complete machine-readable "work that - uses the Library", as object code and/or source code, so that the - user can modify the Library and then relink to produce a modified - executable containing the modified Library. (It is understood - that the user who changes the contents of definitions files in the - Library will not necessarily be able to recompile the application - to use the modified definitions.) - - b) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (1) uses at run time a - copy of the library already present on the user's computer system, - rather than copying library functions into the executable, and (2) - will operate properly with a modified version of the library, if - the user installs one, as long as the modified version is - interface-compatible with the version that the work was made with. - - c) Accompany the work with a written offer, valid for at - least three years, to give the same user the materials - specified in Subsection 6a, above, for a charge no more - than the cost of performing this distribution. - - d) If distribution of the work is made by offering access to copy - from a designated place, offer equivalent access to copy the above - specified materials from the same place. - - e) Verify that the user has already received a copy of these - materials or that you have already sent this user a copy. - - For an executable, the required form of the "work that uses the -Library" must include any data and utility programs needed for -reproducing the executable from it. However, as a special exception, -the materials to be distributed need not include anything that is -normally distributed (in either source or binary form) with the major -components (compiler, kernel, and so on) of the operating system on -which the executable runs, unless that component itself accompanies -the executable. - - It may happen that this requirement contradicts the license -restrictions of other proprietary libraries that do not normally -accompany the operating system. Such a contradiction means you cannot -use both them and the Library together in an executable that you -distribute. - - 7. You may place library facilities that are a work based on the -Library side-by-side in a single library together with other library -facilities not covered by this License, and distribute such a combined -library, provided that the separate distribution of the work based on -the Library and of the other library facilities is otherwise -permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work - based on the Library, uncombined with any other library - facilities. This must be distributed under the terms of the - Sections above. - - b) Give prominent notice with the combined library of the fact - that part of it is a work based on the Library, and explaining - where to find the accompanying uncombined form of the same work. - - 8. You may not copy, modify, sublicense, link with, or distribute -the Library except as expressly provided under this License. Any -attempt otherwise to copy, modify, sublicense, link with, or -distribute the Library is void, and will automatically terminate your -rights under this License. However, parties who have received copies, -or rights, from you under this License will not have their licenses -terminated so long as such parties remain in full compliance. - - 9. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Library or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Library (or any work based on the -Library), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Library or works based on it. - - 10. Each time you redistribute the Library (or any work based on the -Library), the recipient automatically receives a license from the -original licensor to copy, distribute, link with or modify the Library -subject to these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties with -this License. - - 11. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Library at all. For example, if a patent -license would not permit royalty-free redistribution of the Library by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Library. - -If any portion of this section is held invalid or unenforceable under any -particular circumstance, the balance of the section is intended to apply, -and the section as a whole is intended to apply in other circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 12. If the distribution and/or use of the Library is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Library under this License may add -an explicit geographical distribution limitation excluding those countries, -so that distribution is permitted only in or among countries not thus -excluded. In such case, this License incorporates the limitation as if -written in the body of this License. - - 13. The Free Software Foundation may publish revised and/or new -versions of the Lesser 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 Library -specifies a version number of this License which applies to it and -"any later version", you have the option of following the terms and -conditions either of that version or of any later version published by -the Free Software Foundation. If the Library does not specify a -license version number, you may choose any version ever published by -the Free Software Foundation. - - 14. If you wish to incorporate parts of the Library into other free -programs whose distribution conditions are incompatible with these, -write to the author to ask for permission. For software which is -copyrighted by the Free Software Foundation, write to the Free -Software Foundation; we sometimes make exceptions for this. Our -decision will be guided by the two goals of preserving the free status -of all derivatives of our free software and of promoting the sharing -and reuse of software generally. - - NO WARRANTY - - 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO -WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. -EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR -OTHER PARTIES PROVIDE THE LIBRARY "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 -LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN -WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY -AND/OR REDISTRIBUTE THE LIBRARY 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 -LIBRARY (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 LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Libraries - - If you develop a new library, and you want it to be of the greatest -possible use to the public, we recommend making it free software that -everyone can redistribute and change. You can do so by permitting -redistribution under these terms (or, alternatively, under the terms of the -ordinary General Public License). - - To apply these terms, attach the following notices to the library. It is -safest to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least the -"copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -Also add information on how to contact you by electronic and paper mail. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the library, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the - library `Frob' (a library for tweaking knobs) written by James Random Hacker. - - , 1 April 1990 - Ty Coon, President of Vice - -That's all there is to it! - - diff --git a/Tools/WAD/HACK b/Tools/WAD/HACK deleted file mode 100644 index dfece608d..000000000 --- a/Tools/WAD/HACK +++ /dev/null @@ -1,78 +0,0 @@ -The WAD Developers Guide - -David Beazley (beazley@cs.uchicago.edu) - -$Id$ - -1. Introduction - -This short document is intended for anyone who feels inclined to work -on WAD and make improvements. It is by no means complete. However, -it contains random commentary on the current implementation. - -2. A brief word on the execution environment - -Because WAD is embedded in the same application it is intended to -debug, it must take an extremely conservative approach to its own -execution environment. Specifically, it can not rely upon the correct -operation of C library--especially with respect to memory management -and other basic operations. Because of this, the implementation of -WAD makes every effort to be as self-contained as possible--thus -minimizing its exposure to corrupted libraries in the faulting -application. Closely related to this, WAD does not rely on any -third-party libraries (e.g., libbfd) since it is almost impossible to -fully verify the way in which such libraries might use other programming -libraries. - -With that said, you might keep the following rules in mind: - - rule 1: Trust nothing--it might be broken. - rule 2: When in doubt, see rule 1. - -(Of course, we can probably get away with assuming that the OS isn't -hosed). - -3. Memory management - -There are two problems here: first, the dynamic memory -allocator may be corrupted or broken (e.g., as might occur when -you double-free memory or free memory not allocated by malloc). -Second, the WAD signal handler prefers to execute own on its own -signal handling stack. This stack is of limited size so it is not -a reliable place to put large amounts of data. - -Small buffers and scratch areas are managed through the use of static -variables allocated in the WAD data-segment. - -For dynamic memory management, WAD provides its own memory allocator -in the function wad_malloc(). This function allocates memory by using -mmap() to grab anonymous memory regions (mapped to /dev/zero). This -memory is currently allocated in chunks of 64Kbytes as needed. - -To simplify the implementation and prevent potential memory problems -in WAD itself, WAD never releases the memory that it allocates. There -is no wad_free() operation nor is there any way to release all of the -memory previously allocated. - -Although memory is never released, WAD tries to intern commonly used -strings. An internal string hash is built as WAD runs and in most -cases, each string is mapped to a single instance of the string in -this hash table. The function wad_string_lookup(char *s) is used to -return a pointer to the string s in the hash table. If no entry -exists, it is created and a pointer is returned. - -4. I/O - -It is probably a bad idea to use buffered I/O with WAD. This may -result in implicit calls to malloc() and related functions. - - - - - - - - - - - diff --git a/Tools/WAD/Include/wad.h b/Tools/WAD/Include/wad.h deleted file mode 100644 index 9a5007394..000000000 --- a/Tools/WAD/Include/wad.h +++ /dev/null @@ -1,269 +0,0 @@ -/* ----------------------------------------------------------------------------- - * wad.h - * - * WAD header file (obviously) - * - * Author(s) : David Beazley (beazley@cs.uchicago.edu) - * - * Copyright (C) 2001. University of Chicago. All rights reserved. - * - * $Id$ - * ----------------------------------------------------------------------------- */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef WAD_SOLARIS -#include - -#endif - -#ifdef __cplusplus -extern "C" { -#endif - - /* Core datatypes */ - - typedef int int32; - typedef unsigned uint32; - typedef short int16; - typedef unsigned short uint16; - typedef signed char int8; - typedef unsigned char uint8; - - -#ifndef MAX_PATH -#define MAX_PATH 1024 -#endif - -#define WAD_SRC_WINDOW 2 - -/* --- Low level memory management functions --- */ - -extern int wad_memory_init(); -extern void *wad_malloc(int nbytes); -extern char *wad_strdup(const char *c); -extern void wad_memory_debug(); -extern void wad_memcpy(void *t, const void *s, unsigned len); - - /* --- Low level string handling --- */ - -extern char *wad_string_lookup(char *s); -extern void wad_string_debug(); -extern char *wad_strcpy(char *t, const char *s); -extern char *wad_strcat(char *t, const char *s); -extern int wad_strlen(const char *s); - -/* --- I/O, Debugging --- */ - -extern void wad_printf(const char *fmt, ...); -extern char *wad_format_hex(unsigned long u, int leading); -extern char *wad_format_unsigned(unsigned long u, int width); -extern char *wad_format_signed(long s, int width); - -/* --- Memory segments --- */ -typedef struct WadSegment { - char *base; /* Base address for symbol lookup */ - char *vaddr; /* Virtual address start */ - unsigned long size; /* Size of the segment (bytes) */ - unsigned long offset; /* Offset into mapped object */ - char *mapname; /* Filename mapped to this region */ - char *mappath; /* Full path to mapname */ - struct WadSegment *next; /* Next segment */ -} WadSegment; - -extern int wad_segment_read(); -extern WadSegment *wad_segment_find(void *vaddr); -extern int wad_segment_valid(void *vaddr); - -/* --- Object files --- */ -typedef struct WadObjectFile { - void *ptr; /* Pointer to data */ - int len; /* Length of data */ - int type; /* Type of the object file */ - char *path; /* Path name of this object */ - struct WadObjectFile *next; -} WadObjectFile; - -extern void wad_object_reset(); -extern WadObjectFile *wad_object_load(const char *path); -extern int wad_file_check(void *); - -#define SYM_LOCAL 1 -#define SYM_GLOBAL 2 - -/* Signal handling */ -extern void wad_init(); -extern void wad_signalhandler(int, siginfo_t *, void *); -extern void wad_signal_init(); -extern void wad_signal_clear(); -extern void wad_set_return(const char *name, long value); -extern void wad_set_return_value(long value); -extern void wad_set_return_func(void (*f)(void)); - -typedef struct WadLocal { - char *name; /* Name of the local */ - void *ptr; /* Pointer to the actual data (if known) */ - int size; /* Size of the data (if known) */ - int type; /* Data type */ - - /* Debugging information */ - - int loc; /* Location: register or stack */ - int stack; /* location on the stack */ - int reg; /* Register number */ - int line; /* Line number where defined */ - struct WadLocal *next; -} WadLocal; - -#define PARM_REGISTER 1 -#define PARM_STACK 2 - -/* Type codes for local variables */ - -#define WAD_TYPE_UNKNOWN 0 -#define WAD_TYPE_INT32 1 -#define WAD_TYPE_INT16 2 -#define WAD_TYPE_INT8 3 -#define WAD_TYPE_INT64 4 -#define WAD_TYPE_UINT32 5 -#define WAD_TYPE_UINT16 6 -#define WAD_TYPE_UINT8 7 -#define WAD_TYPE_UINT64 8 -#define WAD_TYPE_FLOAT 9 -#define WAD_TYPE_DOUBLE 10 -#define WAD_TYPE_POINTER 11 -#define WAD_TYPE_CHAR 12 - -extern long wad_local_as_long(WadLocal *loc); -extern double wad_local_as_double(WadLocal *loc); - -/* Data structure containing information about each stack frame */ - -typedef struct WadFrame { - long frameno; /* Frame number */ - struct WadFrame *next; /* Next frame up the stack */ - struct WadFrame *prev; /* Previous frame down the stack */ - - /* Stack context information */ - long pc; /* Real PC */ - long sp; /* Real SP */ - long fp; /* Real FP */ - char *stack; /* Pointer to where a copy of the stack frame is stored */ - int stack_size; /* Stack frame size (fp-sp) */ - - /* Loading information. Contains information from /proc as well as a pointer to - the executable or shared library in which the PC is located */ - - WadSegment *segment; /* Memory segment corresponding to PC */ - WadObjectFile *object; /* Object file corresponding to PC */ - - /* Symbol table information for PC */ - - char *sym_name; /* Symbol name */ - int sym_nlen; /* Symbol name length */ - char *sym_file; /* Source file (if any) */ - unsigned long sym_base; /* Symbol base address */ - unsigned long sym_size; /* Symbol size */ - int sym_type; /* Symbol type */ - int sym_bind; /* Symbol binding */ - - /* Location information */ - char *loc_objfile; /* Object filename */ - char *loc_srcfile; /* Source filename */ - int loc_line; /* Source line */ - - /* Debugging information */ - int debug_check; /* Checked debugging information */ - int debug_nargs; /* Number of arguments */ - WadLocal *debug_args; /* Arguments */ - WadLocal *debug_lastarg; /* Last argument */ - int debug_nlocals; /* Number of locals */ - WadLocal *debug_locals; /* Local variables */ - WadLocal *debug_lastlocal; /* Last local */ - - /* Output strings */ - char *debug_str; /* Debugging string */ - char *debug_srcstr; /* Source string */ - - int last; /* Last frame flag */ -} WadFrame; - -extern WadFrame *wad_stack_trace(unsigned long, unsigned long, unsigned long); -extern void wad_stack_debug(WadFrame *f); - -extern char *wad_strip_dir(char *); -extern void wad_default_callback(int signo, WadFrame *frame, char *ret); -extern void wad_dump_trace(int fd, int signo, WadFrame *frame, char *ret); - -extern void wad_set_callback(void (*h)(int, WadFrame *, char *)); -extern char *wad_load_source(char *, int line); -extern void wad_release_source(); -extern void wad_release_trace(); -extern long wad_steal_arg(WadFrame *f, char *symbol, int argno, int *error); -extern long wad_steal_outarg(WadFrame *f, char *symbol, int argno, int *error); - -extern char *wad_arg_string(WadFrame *f); - -typedef struct { - char name[128]; - long value; -} WadReturnFunc; - -extern void wad_set_returns(WadReturnFunc *rf); -extern WadReturnFunc *wad_check_return(const char *name); - -extern int wad_search_stab(void *stab, int size, char *stabstr, WadFrame *f); - -extern void wad_find_object(WadFrame *f); -extern void wad_find_symbol(WadFrame *f); -extern void wad_find_debug(WadFrame *f); -extern void wad_build_vars(WadFrame *f); -extern char *wad_format_var(WadLocal *l); - -extern void wad_debug_make_strings(WadFrame *f); - -/* --- Debugging Interface --- */ - -#define DEBUG_SEGMENT 0x1 -#define DEBUG_SYMBOL 0x2 -#define DEBUG_STABS 0x4 -#define DEBUG_OBJECT 0x8 -#define DEBUG_FILE 0x10 -#define DEBUG_HOLD 0x20 -#define DEBUG_RETURN 0x40 -#define DEBUG_SYMBOL_SEARCH 0x80 -#define DEBUG_INIT 0x100 -#define DEBUG_NOSTACK 0x200 -#define DEBUG_ONESHOT 0x400 -#define DEBUG_STACK 0x800 -#define DEBUG_UNWIND 0x1000 -#define DEBUG_SIGNAL 0x2000 -#define DEBUG_STRING 0x4000 -#define DEBUG_MEMORY 0x8000 - -extern int wad_debug_mode; -extern int wad_heap_overflow; - -#ifdef WAD_LINUX -#define WAD_LITTLE_ENDIAN -#endif -#ifdef WAD_SOLARIS -#define WAD_BIG_ENDIAN -#endif - -#ifdef __cplusplus -} -#endif - - - - diff --git a/Tools/WAD/Makefile.in b/Tools/WAD/Makefile.in deleted file mode 100644 index d76f1179c..000000000 --- a/Tools/WAD/Makefile.in +++ /dev/null @@ -1,46 +0,0 @@ -# Generated automatically from Makefile.in by configure. - -SHELL = /bin/sh -prefix = @prefix@ -execprefix= @exec_prefix@ -LIB = $(execprefix)/lib - -# Location of your Python installation -PYINCLUDE = @PYINCLUDE@ - -# Location of your Tcl installation -TCLINCLUDE = @TCLINCLUDE@ - -# Location of your Perl installation -PERLINCLUDE = @PERL5EXT@ - -all: wad @MAKEPYTHON@ @MAKETCL@ #@MAKEPERL@ - -wad: - @cd Wad; $(MAKE) wad - -python: - @cd Python; $(MAKE) SINCLUDE='$(PYINCLUDE)' python - -tcl: - @cd Tcl; $(MAKE) SINCLUDE='$(TCLINCLUDE)' tcl - -perl: - @cd Wad; $(MAKE) SINCLUDE='$(PERLINCLUDE)' perl - -install: - cp libwad*.so $(LIB) - chmod a+rx $(LIB)/libwad*.so - -semi: - @cd Wad; $(MAKE) semi - @cd Python; $(MAKE) semi - @cd Tcl; $(MAKE) semi - -clean: - @cd Wad; $(MAKE) clean - @cd Python; $(MAKE) clean - @cd Tcl; $(MAKE) clean - @cd Test; $(MAKE) clean - rm *.so - diff --git a/Tools/WAD/Misc/fileheader b/Tools/WAD/Misc/fileheader deleted file mode 100644 index 7b82e9e05..000000000 --- a/Tools/WAD/Misc/fileheader +++ /dev/null @@ -1,28 +0,0 @@ -/* ----------------------------------------------------------------------------- - * segment.c - * - * This file provides access to the virtual memory map of a process - * including the location of the executable, data segments, shared - * libraries, and memory mapped regions. This information is - * obtained through /proc. - * - * Author(s) : David Beazley (beazley@cs.uchicago.edu) - * - * Copyright (C) 2000. The University of Chicago. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * See the file COPYING for a complete copy of the LGPL. - * ----------------------------------------------------------------------------- */ diff --git a/Tools/WAD/Papers/README b/Tools/WAD/Papers/README deleted file mode 100644 index 8eb7b81d1..000000000 --- a/Tools/WAD/Papers/README +++ /dev/null @@ -1,5 +0,0 @@ -Papers about WAD can be obtained at: - - http://systems.cs.uchicago.edu/wad - - diff --git a/Tools/WAD/Prebuilt/linux/Makefile.in b/Tools/WAD/Prebuilt/linux/Makefile.in deleted file mode 100644 index 074e65452..000000000 --- a/Tools/WAD/Prebuilt/linux/Makefile.in +++ /dev/null @@ -1,11 +0,0 @@ -# Generated automatically from Makefile.in by configure. - -SHELL = /bin/sh -prefix = @prefix@ -execprefix= @exec_prefix@ -LIB = $(execprefix)/lib - -install: - cp libwad*.so $(LIB) - chmod a+rx $(LIB)/libwad*.so - diff --git a/Tools/WAD/Prebuilt/solaris/Makefile.in b/Tools/WAD/Prebuilt/solaris/Makefile.in deleted file mode 100644 index 074e65452..000000000 --- a/Tools/WAD/Prebuilt/solaris/Makefile.in +++ /dev/null @@ -1,11 +0,0 @@ -# Generated automatically from Makefile.in by configure. - -SHELL = /bin/sh -prefix = @prefix@ -execprefix= @exec_prefix@ -LIB = $(execprefix)/lib - -install: - cp libwad*.so $(LIB) - chmod a+rx $(LIB)/libwad*.so - diff --git a/Tools/WAD/Python/Makefile.in b/Tools/WAD/Python/Makefile.in deleted file mode 100644 index 2859039af..000000000 --- a/Tools/WAD/Python/Makefile.in +++ /dev/null @@ -1,54 +0,0 @@ -####################################################################### -# WAD Makefile -# -# David Beazley -# January 1, 2001 -####################################################################### - -# These are the files that make up the WAD core -SRCS = type.c python.c -OBJS = type.o python.o -INCLUDE = -I../Include -I. $(SINCLUDE) -WADOPT = @WADOPT@ - -# Location of your Python installation -PYINCLUDE = @PYINCLUDE@ -PYSRCS = wadpyinit.cxx -PYOBJS = wadpyinit.o - -# C Compiler -CC = @CC@ -CFLAGS = #@CCSHARED@ - -# C++ Compiler -CXX = @CXX@ -CXXFLAGS = #@CXXSHARED@ - -# Linking options -CLINK = -CXXLINK = @CXXLINK@ - -# Rules for creation of a .o file from .cxx -.SUFFIXES: .cxx -.cxx.o: - $(CXX) $(CXXFLAGS) $(WADOPT) $(INCLUDE) -c -o $*.o $< - -.c.o: - $(CC) $(CFLAGS) $(PYINCLUDE) $(WADOPT) $(INCLUDE) -c -o $*.o $< - -python: $(OBJS) $(PYOBJS) - $(CXXLINK) $(OBJS) $(PYOBJS) -o libwadpy.so -L.. -lwadcore - cp libwadpy.so .. - -wc:: - wc $(SRCS) - -semi:: - @egrep ";" $(SRCS) $(PYSRCS) | wc - -clean:: - rm -f *.o *.so *~ - - - - diff --git a/Tools/WAD/Python/python.c b/Tools/WAD/Python/python.c deleted file mode 100644 index 9f4686587..000000000 --- a/Tools/WAD/Python/python.c +++ /dev/null @@ -1,221 +0,0 @@ -/* ----------------------------------------------------------------------------- - * python.c - * - * Dynamically loadable python module for wad. - * - * Author(s) : David Beazley (beazley@cs.uchicago.edu) - * - * Copyright (C) 2000. The University of Chicago. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * See the file COPYING for a complete copy of the LGPL. - * ----------------------------------------------------------------------------- */ - -#include "Python.h" -#include "wad.h" - -static char cvs[] = "$Id$"; - -/* These are the python exception objects we will add - SegFault, BusError, AbortError */ - -static PyObject *segfault_exc = 0; -static PyObject *buserror_exc = 0; -static PyObject *abort_exc = 0; -static PyObject *illegal_exc = 0; - -extern PyObject *new_wadobject(WadFrame *f,int); - -/* Function return points and values */ - -static WadReturnFunc retpts[] = { - {"call_builtin", 0}, - {"_PyImport_LoadDynamicModule", 0}, - {"PyEval_EvalCode", 0}, - {"PyObject_GetAttrString", 0}, - {"PyObject_SetAttrString", -1}, - {"PyObject_Repr", 0}, - {"PyObject_Print", -1}, - {"PyObject_CallFunction", 0}, - {"PyObject_CallMethod", 0}, - {"PyObject_CallObject", 0}, - {"PyObject_Cmp", -1}, - {"PyObject_Compare", -1}, - {"PyObject_DelAttrString",-1}, - {"PyObject_DelItem",-1}, - {"PyObject_GetItem",0}, - {"PyObject_SetItem",-1}, - {"PyObject_HasAttrString",-1}, - {"PyObject_Hash",-1}, - {"PyObject_Length",-1}, - {"PyObject_Str",0}, - {"PyObject_Type", 0}, - - {"PyNumber_Absolute", 0}, - {"PyNumber_Add",0}, - {"PyNumber_And",0}, - {"PyNumber_Coerce",0}, - {"PyNumber_Divide",0}, - {"PyNumber_Divmod",0}, - {"PyNumber_Float",0}, - {"PyNumber_Int",0}, - {"PyNumber_Invert",0}, - {"PyNumber_Long",0}, - {"PyNumber_Lshift",0}, - {"PyNumber_Multiply", 0}, - {"PyNumber_Negative", 0}, - {"PyNumber_Or",0}, - {"PyNumber_Positive", 0}, - {"PyNumber_Power",0}, - {"PyNumber_Remainder",0}, - {"PyNumber_Rshift",0}, - {"PyNumber_Subtract",0}, - {"PyNumber_Xor",0}, - - {"PySequence_Concat",0}, - {"PySequence_Count",-1}, - {"PySequence_Delitem",-1}, - {"PySequence_DelSlice",-1}, - {"PySequence_Getitem",0}, - {"PySequence_GetSlice",0}, - {"PySequence_In",-1}, - {"PySequence_Index",-1}, - {"PySequence_Repeat",0}, - {"PySequence_SetItem",-1}, - {"PySequence_SetSlice",-1}, - {"PySequence_Tuple",0}, - - {"PyMapping_Clear",-1}, - {"PyMapping_DelItem",-1}, - {"PyMapping_DelItemString",-1}, - {"PyMapping_GetItemString",0}, - {"PyMapping_HasKey",-1}, - {"PyMapping_HasKeyString",-1}, - {"PyMapping_Items",0}, - {"PyMapping_Keys",0}, - {"PyMapping_Length", -1}, - {"PyMapping_SetItemString", -1}, - {"PyMapping_Values", 0}, - {"",0}}; - -/* Handler function */ -static void handler(int signo, WadFrame *frame, char *ret) { - static char message[65536]; - static char temp[1024]; - int len = 0; - PyObject *type; - char *name; - WadFrame *f; - WadFrame *fline = 0; - char *srcstr = 0; - - /* printf("python handler.\n"); */ - if (!ret) { - wad_default_callback(signo, frame, ret); - return; - } - - strcpy(message,"[ C stack trace ]\n\n"); - switch(signo) { - case SIGSEGV: - type = segfault_exc; - break; - case SIGBUS: - type = buserror_exc; - break; - case SIGABRT: - type = abort_exc; - break; - case SIGFPE: - type = PyExc_FloatingPointError; - break; - case SIGILL: - type = illegal_exc; - break; - default: - type = PyExc_RuntimeError; - break; - } - -#ifdef OLD - f = frame; - /* Find the last exception frame */ - while (!f->last) { - f= f->next; - } - /* Now work backwards */ - f = f->prev; - while (f) { - strcat(message, f->debug_str); - if (f->debug_srcstr) srcstr = f->debug_srcstr; - f = f->prev; - } - if (srcstr) { - strcat(message,"\n"); - strcat(message, srcstr); - strcat(message,"\n"); - } -#endif - - if (wad_heap_overflow) { - write(2, "WAD: Heap overflow detected.\n", 30); - wad_default_callback(signo, frame, ret); - } - - /* Note: if the heap is blown, there is a very good chance that this - function will not succeed and we'll dump core. However, the check - above should dump a stack trace to stderr just in case we don't make it - back. */ - -#ifdef OLD - PyErr_SetString(type, message); -#endif - PyErr_SetObject(type, new_wadobject(frame,0)); - -} - -void pywadinit() { - PyObject *d, *m; - m = PyImport_ImportModule((char *)"__builtin__"); - d = PyModule_GetDict(m); - printf("WAD Enabled\n"); - - segfault_exc = PyErr_NewException((char *)"exceptions.SegFault", NULL, NULL); - PyDict_SetItemString(d,(char *)"SegFault",segfault_exc); - - buserror_exc = PyErr_NewException((char *)"exceptions.BusError", NULL, NULL); - PyDict_SetItemString(d,(char *)"BusError",buserror_exc); - - abort_exc = PyErr_NewException((char*)"exceptions.AbortError", NULL, NULL); - PyDict_SetItemString(d,(char *)"AbortError",abort_exc); - - illegal_exc = PyErr_NewException((char *)"exceptions.IllegalInstruction", NULL, NULL); - PyDict_SetItemString(d,(char *)"IllegalInstruction",illegal_exc); - - wad_init(); - wad_set_callback(handler); - wad_set_returns(retpts); -} - -static PyMethodDef wadmethods[] = { - {0,0}, -}; - -void initlibwadpy() { - Py_InitModule((char *)"libwadpy",wadmethods); -} - - diff --git a/Tools/WAD/Python/type.c b/Tools/WAD/Python/type.c deleted file mode 100644 index 7d8248e0b..000000000 --- a/Tools/WAD/Python/type.c +++ /dev/null @@ -1,277 +0,0 @@ -/* ----------------------------------------------------------------------------- - * type.c - * - * This file defines a new python type that contains information from - * the WAD stack trace. - * - * Author(s) : David Beazley (beazley@cs.uchicago.edu) - * - * Copyright (C) 2000. The University of Chicago. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * See the file COPYING for a complete copy of the LGPL. - * ----------------------------------------------------------------------------- */ - - -#include "wad.h" -#include "Python.h" - -static char cvs[] = "$Id$"; - -typedef struct { - PyObject_HEAD - WadFrame *frame; /* Wad Stack frame object */ - int count; /* Number of frames */ -} wadobject; - -staticforward PyTypeObject WadObjectType; - - -PyObject * -new_wadobject(WadFrame *f, int count) { - wadobject *self; - self = PyObject_NEW(wadobject, &WadObjectType); - if (self == NULL) return NULL; - - self->frame = f; - if (count > 0) { - self->count = count; - } else { - self->count = 0; - while (f) { - self->count++; - f = f->next; - } - } - return (PyObject *) self; -} - -/* release a wad object */ -static void -wadobject_dealloc(wadobject *self) { - PyObject_Del(self); -} - -static char message[65536]; -static PyObject * -wadobject_repr(wadobject *self) { - char *srcstr = 0; - WadFrame *fp = 0; - int n; - WadFrame *f = self->frame; - - message[0] = 0; - /* Find the last exception frame */ - n = self->count; - while (f && n) { - fp = f; - f= f->next; - n--; - } - - if (fp) { - /* Now work backwards */ - f = fp; - while (f) { - strcat(message, f->debug_str); - if (f->debug_srcstr) srcstr = f->debug_srcstr; - if (f == self->frame) break; - f = f->prev; - } - if (srcstr) { - strcat(message,"\n"); - strcat(message, srcstr); - strcat(message,"\n"); - } - } - return PyString_FromString(message); -} - -static PyObject * -wadobject_str(wadobject *self) { - char *srcstr = 0; - int n; - - WadFrame *f = self->frame; - n = self->count; - strcpy(message,"[ C stack trace ]\n\n"); - /* Find the last exception frame */ - while (!f->last && n) { - f= f->next; - n--; - } - /* Now work backwards */ - if (n <= 0) { - f = f->prev; - } - while (f) { - strcat(message, f->debug_str); - if (f->debug_srcstr) srcstr = f->debug_srcstr; - if (self->frame == f) break; - f = f->prev; - } - if (srcstr) { - strcat(message,"\n"); - strcat(message, srcstr); - strcat(message,"\n"); - } - return PyString_FromString(message); -} - -static int -wadobject_len(wadobject *self) { - int n = 0; - WadFrame *f = self->frame; - while (f) { - n++; - f = f->next; - } - return n; -} - -static PyObject * -wadobject_getitem(wadobject *self, int n) { - int i; - WadFrame *f; - if (n < 0) { - n = self->count + n; - } - if ((n < 0) || (n >= self->count)) { - PyErr_SetString(PyExc_IndexError,"Stack frame out of range"); - return NULL; - } - f = self->frame; - for (i = 0; i next; - } - return new_wadobject(f,1); -} - -static PyObject * -wadobject_getslice(wadobject *self, int start, int end) { - int i; - WadFrame *f; - - f = self->frame; - for (i = 0; i < start; i++) { - f = f->next; - } - return new_wadobject(f,(end-start)); -} - -static PyObject * -wadobject_getattr(wadobject *self, char *name) { - if (strcmp(name,"__NAME__") == 0) { - return Py_BuildValue("z", self->frame->sym_name); - } else if (strcmp(name,"__EXE__") == 0) { - return Py_BuildValue("z", self->frame->object->path); - } else if (strcmp(name,"__FILE__") == 0) { - return Py_BuildValue("z", self->frame->loc_srcfile); - } else if (strcmp(name,"__OBJECT__") == 0) { - return Py_BuildValue("z", self->frame->loc_objfile); - } else if (strcmp(name,"__LINE__") == 0) { - return Py_BuildValue("i", self->frame->loc_line); - } else if (strcmp(name,"__SOURCE__") == 0) { - return Py_BuildValue("z",self->frame->debug_srcstr); - } else if (strcmp(name,"__PC__") == 0) { - return PyLong_FromUnsignedLong(self->frame->pc); - } else if (strcmp(name,"__SP__") == 0) { - return PyLong_FromUnsignedLong(self->frame->sp); - } else if (strcmp(name,"__FP__") == 0) { - return PyLong_FromUnsignedLong(self->frame->fp); - } else if (strcmp(name,"__STACK__") == 0) { - return PyString_FromStringAndSize(self->frame->stack, self->frame->stack_size); - } else if (strcmp(name,"__NARGS__") == 0) { - return PyInt_FromLong(self->frame->debug_nargs); - } else if (strcmp(name,"__LAST__") == 0) { - return PyInt_FromLong(self->frame->last); - } else if (strcmp(name,"__WHERE__") == 0) { - return Py_BuildValue("z",self->frame->debug_str); - } else if (strcmp(name,"__WAD__") == 0) { - return PyInt_FromLong(1); - } - - - /* Put a check for local variables */ - { - int i; - for (i = 0; i < 2; i++) { - WadLocal *loc; - if (i == 0) loc = self->frame->debug_locals; - else loc = self->frame->debug_args; - while (loc) { - if (strcmp(name,loc->name) == 0) { - switch(loc->type) { - case WAD_TYPE_INT32: - case WAD_TYPE_INT16: - case WAD_TYPE_INT8: - return PyLong_FromLong(wad_local_as_long(loc)); - break; - case WAD_TYPE_UINT8: - case WAD_TYPE_UINT16: - case WAD_TYPE_UINT32: - return PyLong_FromUnsignedLong((unsigned long) wad_local_as_long(loc)); - break; - case WAD_TYPE_CHAR: - return Py_BuildValue("c", (char) (PyLong_FromLong(wad_local_as_long(loc)))); - break; - case WAD_TYPE_FLOAT: - case WAD_TYPE_DOUBLE: - return PyFloat_FromDouble(wad_local_as_double(loc)); - break; - default: - return PyLong_FromUnsignedLong((unsigned long) wad_local_as_long(loc)); - } - } - loc = loc->next; - } - } - } - - PyErr_SetString(PyExc_NameError,"Unknown attribute."); - return NULL; -} -static PySequenceMethods wadobject_as_sequence = { - (inquiry) wadobject_len, - 0, - 0, - (intargfunc) wadobject_getitem, /* get item */ - (intintargfunc) wadobject_getslice, /* get slice */ - 0, - 0 -}; - -static PyTypeObject WadObjectType = { - PyObject_HEAD_INIT(&PyType_Type) - 0, - "WadObject", - sizeof(wadobject), - 0, - (destructor) wadobject_dealloc, - 0, /* printfunc */ - (getattrfunc) wadobject_getattr, - (setattrfunc) 0, - (cmpfunc) 0, - (reprfunc) wadobject_repr, - - 0, /* number */ - &wadobject_as_sequence, /* sequence */ - 0, /* mapping */ - 0, /* hash */ - 0, /* call */ - (reprfunc) wadobject_str, /* str */ -}; - diff --git a/Tools/WAD/Python/wadpyinit.cxx b/Tools/WAD/Python/wadpyinit.cxx deleted file mode 100644 index b97009402..000000000 --- a/Tools/WAD/Python/wadpyinit.cxx +++ /dev/null @@ -1,45 +0,0 @@ -/* ----------------------------------------------------------------------------- - * wadpyinit.cxx - * - * C++ automatic initializer for Python module. - * - * Author(s) : David Beazley (beazley@cs.uchicago.edu) - * - * Copyright (C) 2000. The University of Chicago. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * See the file COPYING for a complete copy of the LGPL. - * ----------------------------------------------------------------------------- */ - -#include "wad.h" - -static char cvs[] = "$Id$"; - -extern "C" void pywadinit(); - -/* This hack is used to auto-initialize wad regardless of whether we are - used as an imported module or as a link-library for another module */ - -class wadinitializer { -public: - wadinitializer() { - pywadinit(); - } -}; - -static wadinitializer wi; - - diff --git a/Tools/WAD/README b/Tools/WAD/README deleted file mode 100644 index c777c4efb..000000000 --- a/Tools/WAD/README +++ /dev/null @@ -1,376 +0,0 @@ -WAD (Wrapped Application Debugger) - -Author(s): - David M. Beazley (beazley@cs.uchicago.edu) - -Copyright (C) 2001 -University of Chicago - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This library 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 -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -See the file COPYING for a complete copy of the LGPL. - -$Id$ - -!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!!!!!!!! DISCLAIMER !!!!!!!! -!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -THIS IS EXPERIMENTAL UNMAINTAINED RESEARCH SOFTWARE THAT REPRESENTS -WORK IN PROGRESS. IT IS NOT PORTABLE, IT HAS NOT BEEN EXHAUSTIVELY -TESTED, AND IT MIGHT NOT WORK AT ALL. PLEASE KEEP AWAY FROM SMALL -CHILDREN, PETS, NUCLEAR REACTORS, AIR-TRAFFIC CONTROL, AND VOTING -MACHINES. - -0. Supported Platforms - -This software is currently only known to work with 32-bit applications -on Sun Sparc Solaris 2.8 and recent i386-Linux systems. In addition, -there are numerous issues concerning the interaction of this software -with signal handling, thread libraries, and compilers. Please read -this entire document before proceeding. - -1. Introduction - -WAD is an embedded error-recovery mechanism that attempts to convert -fatal errors such as SIGSEGV, SIGBUS, and SIGFPE into sensible error -messages and exceptions. It is primarily designed to support -scripting language extension programming although it can also be used -with stand-alone C programs. - -The primary goal of this system is to explore an alternative approach -to mixed scripting-compiled debugging. It requires no modifications -or recompilation of existing software. Therefore, it should be -relatively easy to try out. Feedback is welcome. Contributions and -modifications are even more welcome. - -2. Compilation and Installation - -WAD is not particularly portable and at this time, only two platforms -are supported: Sun Sparc Solaris and i386-Linux. - -Installation is as follows: - - ./configure - make - make install - -The build process creates the following shared libraries: - - libwad.so - Standalone WAD. Can be linked with C/C++ - programs. - - libwadpy.so - Python WAD. Can be linked to Python extension - modules or imported on its own as 'import libwadpy' - - libwadtcl.so - Tcl WAD. Can be linked to Tcl extension - modules or loaded as 'load libwadtcl.so'. - - libwadpl.so - Perl WAD. Can be linked to Perl extension - modules or loaded as 'libwadpl'. - -To install the libraries, simply type 'make install'. This copies the libraries -to /usr/local/lib (unless you modify the makefile). - -Notes: - - - The Sun version of WAD has only been tested when compiled with the - Sun Workshop C/C++ compilers. However WAD works with other programs - that have been compiled with gcc. If gcc is installed on your - machine, you may want to set the following environment variables - before running configure: - - setenv CC cc - setenv CXX CC - ./configure - - - You may need to modify the Makefile to point to the installed locations - of various scripting language libraries if you have installed - them in non-traditional locations. - - - The Linux version has only been tested with 2.2-12 and 2.2-14 kernels - and the RedHat 6.x distribution. Your mileage may vary. There - may be some compatibility issues related to glibc and other parts - of the system as well. - -3. Using WAD - -WAD has no functional API nor does it have any command line options so -it's pretty easy to describe---simply link the appropriate WAD library with -your C code. For example: - - % cc blah.c -lwad - -Once linked, fatal errors will now produce stack traces. For example: - -% ./a.out seg -starting. -Segmentation fault. -#2 0x400571eb in __libc_start_main() in 'libc-start.c', line 90 -#1 0x08048b39 in main(argc=0x2,argv=0xbffffce4) in 'debug.c', line 62 -#0 0x080489b3 in seg_crash(n=0x0) in 'debug.c', line 9 - -/r0/beazley/Projects/WAD/Wad/debug.c, line 9 - - int *a = 0; - if (n > 0) seg_crash(n-1); - => *a = 3; - return 1; - } - -For scripting languages, WAD works in a similar manner--simply link -your scripting language extension module with the appropriate WAD library -(wadpy, wadtcl, wadpl). For example: - - % ld -G $(OBJS) -lwadpy -o pymodule.so - -When the scripting module is loaded into the interpreter, WAD should -automatically initialize. - -4. Debugging Modes - -Due to WAD's experimental nature, a number of debugging modes can be set -through the use of environment variables. These variables control WAD's -runtime behavior and cause the system to dump debugging information for -various stages of error recovery. A lot of this data is pretty ugly and -probably only of interest to you if you are trying to debug WAD itself. - -WAD_DEBUG_SEGMENT - Displays information about the virtual memory - map and mapping of addresses to segments. - -WAD_DEBUG_SYMBOL - Symbol table mapping. - -WAD_DEBUG_OBJECT - Loading/Unloading of object files. - -WAD_DEBUG_FILE - Loading/Unloading of raw files. - -WAD_DEBUG_HOLD - Freezes WAD before it returns from the signal handler. - Useful if you need to attach a debugger to WAD itself. - -WAD_DEBUG_STABS - Display stabs data. - -WAD_DEBUG_RETURN - Display information about WAD return points. - -WAD_DEBUG_SYMBOL_SEARCH - Display all symbols in the symbol table that are - searched. - -WAD_DEBUG_UNWIND - Display information about stack unwinding. - -WAD_DEBUG_SIGNAL - Display information about signal handling. - -WAD_DEBUG_INIT - Print initialization information. - -WAD_NOSTACK - Do NOT use an alternative signal handling stack. - This may be necessary on certain Linux systems when - threads are being used. - -WAD_ONESHOT - Disable WAD signal handler after first signal has - been received. - -WAD_DEBUG_MEMORY - Print information about WAD memory use. - -WAD_DEBUG_STRINGS - Print information about WAD string manager. - -5. Platform Specific Issues - -General: - - - WAD does not gracefully recover from errors that corrupt the call - stack (i.e., buffer overlow). - - - Errors that destroy the process heap may or may not be recoverable - depending on what has been destroyed. - - - WAD does not currently support 64 bit applications on any platform. - - - If executables have been stripped, their symbol tables might not - have enough information to recover from errors. Therefore, if you - are using Python, Tcl, or Perl from a binary distribution, you - may want to rebuild non-stripped versions of these packages yourself. - - - WAD only works with programs that utilize the ELF32 linking format - and stabs debugging data. Newer formats such as DWARF2 are not - supported at this time. - - - WAD does not correctly report argument values for structures or - floating point numbers yet. - - - Overly aggressive compiler optimization may lead to very strange - WAD output. - -Solaris: - - - WAD is extremely slow at collecting debugging information - from large applications. - -Linux: - - - The interaction of threads and signals are particularly problematic - on this platform and may cause WAD not to work at all. Here are - some specific thread-based issues that may arise: - - 1. WAD causes the program to crash immediately upon startup. - This appears to be caused by a bug in in the implementation - of sigaction() and the initialization of signals. This - only occurs if WAD is directly linked to an executable - using threads. It does not occur when WAD is dynamically - loaded into a threaded application. - - 2. Programs may lock up when an error occurs. This is sometimes - caused by an apparently broken implementation of sigaltstack(). - One solution to this is to set the following environment - variable: - - setenv WAD_NOSTACK - - in which case the WAD signal handler will use the same - stack as the thread/process that generates the error. - - 3. WAD just crashes altogether and doesn't seem to do anything. - It appears that some versions of Linux threads do *not* - pass CPU context information correctly to signal handlers - defined in threaded programs. There is no known fix to - this at this time. Upgrade your system. - - - WAD does not work if it is compiled as PIC code. The WAD libraries - should be compiled *without* the -fpic option. - - - WAD has to rely upon a heuristic register recovery scheme when it - returns to scripting language interpreters. It seems to - work, but it relies upon a very specific compiler code generation - convention for saving registers in function prologues. It also - relies upon the register save conventions described in the Linux - Assembly HOWTO. - - - If you are using WAD with pre-installed binaries for Python, Tcl, - and other scripting languages, it may not work correctly due to - stripped symbol tables. Most Linux installs such as Redhat strip - symbol tables from executables. This makes it difficult for WAD - to determine context correctly (although it may still work since - the dynamic loading symbol table is still available in most cases). - -6. Language specific issues - -If WAD is linked with a normal C/C++ program, errors simply produce a stack trace -that is printed on standard error. - -Python: - -WAD tries to raise a Python exception and return. At this time, the exception -merely contains a traceback string. However, in future versions, it may be -possible to access a complete exception object. - -Tcl: - -WAD returns a Tcl and places the stack trace into the Tcl variable $errorInfo. -The wish shell uses this to dump error information. - -Perl: - -Perl doesn't seem to have a very well-defined exception handling -mechanism. Standard functions tend to just exit. The WAD handler -produces a C stack trace and produces a Perl stack trace using some -code derived from the sigtrap module. - -Note: 3/23/01 - Perl support is currently broken. - -7. Testing and Examples - -The Test directory contains some very simple code for testing WAD. In the -most simple form, compile the stand-along test program 'debug' as follows: - -% cd Test -% make - -Now, running it: - -% debug -WAD debug program. - -Usage: debug type - seg - Fail with an uninitialized pointer. - bus - Fail with a bus error. - abort - Fail with an assertion error. - math - Fail with a math error. - heap - Blow the process heap. - overflow - Buffer overflow on the stack. - -% debug seg -WAD debug program. -Segmentation fault. -#2 0x400581eb in __libc_start_main() in 'libc-start.c', line 90 -#1 0x08048b61 in main(argc=0x2,argv=0xbffffc54) in 'debug.c', line 85 -#0 0x080489d0 in seg_crash() in 'debug.c', line 15 - -/r0/beazley/Projects/WAD/Test/debug.c, line 15 - - int seg_crash() { - int *a = 0; - => *a = 3; - return 1; - } - -Additional targets 'make python', 'make tcl', and 'make perl' are also available. -The scripts debug.py, debug.tcl, debug.pl can be used to test these extensions. - -8. Documentation - -No official documentation exists at this time. However, details -of WAD's design and implementation can be found in papers presented -at the Ninth International Python Conference and the 2000 USENIX -Technical Conference. Both papers can be obtained at: - - http://systems.cs.uchicago.edu/wad - - -9. To-Do - -If you find WAD to be interesting or useful, there are a variety of -ways to contribute. Here is the short to-do list: - - - Better register management. Try to implement in a more portable - way. Add some support code for recovering local variables - that happen to be stored in registers. - - - Add heuristic for recovering functions called through an - -fomit-frame-pointer compiler optimization scheme. This - can probably be determined by looking at the function preamble - machine code. Then one can back-trace to the calling function - and look at it's preamble. - - - Continued clean up and modularization of the core. Many of the - internal APIs could be greatly improved. - - - Support for ELF64 linking format. - - - Support for DWARF2 debugging data. - - - Improved support for stack-overflow and heap-corruption. Although WAD - probably won't be able to recover, it still might be able to produce some - informative diagnostics. - - - Removal of printf() and other high-level library calls which may not - operate with a corrupted heap. - - - Better integration with scripting languages. - - - Support for new platforms. - - - Support for new scripting languages. - -Please contact me if you are interested in working on any of these projects. - -Dave Beazley (beazley@cs.uchicago.edu) -June 24, 2001 diff --git a/Tools/WAD/Tcl/Makefile.in b/Tools/WAD/Tcl/Makefile.in deleted file mode 100644 index b734a8c5f..000000000 --- a/Tools/WAD/Tcl/Makefile.in +++ /dev/null @@ -1,54 +0,0 @@ -####################################################################### -# WAD Makefile -# -# David Beazley -# January 1, 2001 -####################################################################### - -# These are the files that make up the WAD core -SRCS = wadtcl.c -OBJS = wadtcl.o -INCLUDE = -I../Include -I. $(SINCLUDE) -WADOPT = @WADOPT@ - -# Location of your Tcl installation -TCLINCLUDE = @TCLINCLUDE@ -TCLSRCS = wadtclinit.cxx -TCLOBJS = wadtclinit.o - -# C Compiler -CC = @CC@ -CFLAGS = #@CCSHARED@ - -# C++ Compiler -CXX = @CXX@ -CXXFLAGS = #@CXXSHARED@ - -# Linking options -CLINK = -CXXLINK = @CXXLINK@ - -# Rules for creation of a .o file from .cxx -.SUFFIXES: .cxx -.cxx.o: - $(CXX) $(CXXFLAGS) $(WADOPT) $(INCLUDE) -c -o $*.o $< - -.c.o: - $(CC) $(CFLAGS) $(TCLINCLUDE) $(WADOPT) $(INCLUDE) -c -o $*.o $< - -tcl: $(OBJS) $(TCLOBJS) - $(CXXLINK) $(OBJS) $(TCLOBJS) -o libwadtcl.so -L.. -lwadcore - cp libwadtcl.so .. - -wc:: - wc $(SRCS) - -semi:: - @egrep ";" $(SRCS) $(TCLSRCS) | wc - -clean:: - rm -f *.o *.so *~ - - - - diff --git a/Tools/WAD/Tcl/wadtcl.c b/Tools/WAD/Tcl/wadtcl.c deleted file mode 100644 index df68f7473..000000000 --- a/Tools/WAD/Tcl/wadtcl.c +++ /dev/null @@ -1,122 +0,0 @@ -/* ----------------------------------------------------------------------------- - * wadtcl.c - * - * Dynamically loadable Tcl module for wad. - * - * Author(s) : David Beazley (beazley@cs.uchicago.edu) - * - * Copyright (C) 2000. The University of Chicago. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * See the file COPYING for a complete copy of the LGPL. - * ----------------------------------------------------------------------------- */ - -#include -#include "wad.h" -#include - -static char cvs[] = "$Id$"; - -/* Handler function */ -static void handler(int signo, WadFrame *frame, char *ret) { - static char message[65536]; - static char temp[1024]; - int len = 0; - char *name; - WadFrame *f; - WadFrame *fline = 0; - char *srcstr= 0; - Tcl_Interp *interp; - int err; - char *type; - - if (!ret) { - wad_default_callback(signo, frame, ret); - return; - } - - strcpy(message,"[ C stack trace ]\n\n"); - switch(signo) { - case SIGSEGV: - type = (char*)"Segmentation fault."; - break; - case SIGBUS: - type = (char*)"Bus error."; - break; - case SIGABRT: - type = (char*)"Abort."; - break; - case SIGFPE: - type = (char*)"Floating point exception."; - break; - default: - type = (char*)"Unknown."; - break; - } - - f = frame; - /* Find the last exception frame */ - while (!f->last) { - f= f->next; - } - /* Now work backwards */ - f = f->prev; - while (f) { - strcat(message, f->debug_str); - if (f->debug_srcstr) srcstr = f->debug_srcstr; - f = f->prev; - } - if (srcstr) { - strcat(message,"\n"); - strcat(message, srcstr); - strcat(message,"\n"); - } - - if (wad_heap_overflow) { - write(2, "WAD: Heap overflow detected.\n", 30); - wad_default_callback(signo, frame, ret); - } - - /* Note: if the heap is blown, there is a very good chance that this - function will not succeed and we'll dump core. However, the check - above should dump a stack trace to stderr just in case we don't make it - back. */ - - /* Try to get the Tcl interpreter through magic */ - if (ret) { - interp = (Tcl_Interp *) wad_steal_outarg(frame,ret,1,&err); - if (err == 0) { - Tcl_SetResult(interp,type,TCL_STATIC); - Tcl_AddErrorInfo(interp,message); - } - } -} - -void tclwadinit() { - printf("WAD Enabled\n"); - wad_init(); - wad_set_callback(handler); - wad_set_return("TclExecuteByteCode", TCL_ERROR); - wad_set_return("EvalObjv", TCL_ERROR); -} - -int Wad_Init(Tcl_Interp *interp) { - return TCL_OK; -} - -int Wadtcl_Init(Tcl_Interp *interp) { - return TCL_OK; -} diff --git a/Tools/WAD/Tcl/wadtclinit.cxx b/Tools/WAD/Tcl/wadtclinit.cxx deleted file mode 100644 index 30c288cea..000000000 --- a/Tools/WAD/Tcl/wadtclinit.cxx +++ /dev/null @@ -1,38 +0,0 @@ -/* ----------------------------------------------------------------------------- - * wadtclinit.cxx - * - * C++ initializer for Tcl wad. - * - * Copyright (C) 2000. The University of Chicago. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * See the file COPYING for a complete copy of the LGPL. - * ----------------------------------------------------------------------------- */ -static char cvs[] = "$Id$"; - -extern "C" void tclwadinit(); - -/* This hack is used to auto-initialize wad regardless of whether we are - used as an imported module or as a link-library for another module */ - -class wadinitializer { -public: - wadinitializer() { - tclwadinit(); - } -}; - -static wadinitializer wi; diff --git a/Tools/WAD/Test/Makefile.in b/Tools/WAD/Test/Makefile.in deleted file mode 100644 index c6e808275..000000000 --- a/Tools/WAD/Test/Makefile.in +++ /dev/null @@ -1,44 +0,0 @@ -####################################################################### -# WAD Test makefile -# -# Build some WAD test programs. -####################################################################### - -CC= @CC@ -CCSHARED = @CCSHARED@ -LDSHARED = @LDSHARED@ -RPATH = @RPATH@ - -PYINCLUDE = @PYINCLUDE@ -TCLINCLUDE = @TCLINCLUDE@ -PERLINCLUDE = @PERL5EXT@ -INCLUDE = -I../Include -WADLIB = .. -WADLINK = -L$(WADLIB) $(RPATH)$(WADLIB) - -test: - $(CC) -g -DNEED_MAIN debug.c $(INCLUDE) $(WADLINK) -lwad -o debug - -python: pydebug.c - $(CC) $(CCSHARED) -c -g debug.c pydebug.c $(PYINCLUDE) - $(LDSHARED) debug.o pydebug.o $(WADLINK) -lwadpy -o debugmodule.so - -tcl: tcldebug.c - $(CC) $(CCSHARED) -c -g debug.c tcldebug.c $(TCLINCLUDE) - $(LDSHARED) debug.o tcldebug.o $(WADLINK) -lwadtcl -o debug.so - -perl: pldebug.c - $(CC) $(CCSHARED) -c -Dbool=char -g debug.c pldebug.c $(PERLINCLUDE) - $(LDSHARED) debug.o pldebug.o $(WADLINK) -lwadpl -o debug.so - -pydebug.c: - swig -python -o pydebug.c debug.i - -tcldebug.c: - swig -tcl -o tcldebug.c debug.i - -pldebug.c: - swig -perl5 -o pldebug.c debug.i - -clean: - rm -f *.so *.o debug *_wrap* diff --git a/Tools/WAD/Test/README b/Tools/WAD/Test/README deleted file mode 100644 index 6a04a7e8a..000000000 --- a/Tools/WAD/Test/README +++ /dev/null @@ -1,5 +0,0 @@ -Simple test programs for WAD. This is currently incomplete. - -Note: To completely rebuild the Python, Perl, and Tcl tests, -you need to have SWIG installed (www.swig.org). - diff --git a/Tools/WAD/Test/death.py b/Tools/WAD/Test/death.py deleted file mode 100644 index ba1de20a3..000000000 --- a/Tools/WAD/Test/death.py +++ /dev/null @@ -1,65 +0,0 @@ -import debug -from Tkinter import * - -def death_by_segmentation(): - debug.seg_crash() - -def death_by_bus(): - debug.bus_crash() - -def death_by_abort(): - debug.abort_crash(-1) - -def death_by_math(): - debug.math_crash(37,0) - -def death_by_buffer(): - debug.overflow_crash() - -def death(f): - ty = f.tvar.get() - if ty == 1: - death_by_segmentation() - elif ty == 2: - death_by_abort() - elif ty == 3: - death_by_math() - elif ty == 4: - death_by_bus() - elif ty == 5: - death_by_buffer() - -class death_options(Frame): - def __init__(self): - Frame.__init__(self) - tvar = IntVar() - Radiobutton(self,text="Segmentation fault", variable=tvar, value=1).pack(anchor=W) - Radiobutton(self,text="Failed assertion", variable=tvar, value=2).pack(anchor=W) - Radiobutton(self,text="Math error", variable=tvar, value=3).pack(anchor=W) - Radiobutton(self,text="Bus error", variable=tvar, value=4).pack(anchor=W) - Radiobutton(self,text="Stack overflow", variable=tvar, value=5).pack(anchor=W) - Button(self,text="Die", command=lambda x=self: death(x)).pack(expand=1, fill=BOTH) - self.tvar = tvar - tvar.set(1) - -def death_wizard(): - root = Tk() - l = Label(text="How would you like to die today?") - l.pack() - death_options().pack() - root.title("Death Wizard") -death_wizard() - -#root.mainloop() - - - - - - - - - - - - diff --git a/Tools/WAD/Test/death.tcl b/Tools/WAD/Test/death.tcl deleted file mode 100644 index e52fa9ec2..000000000 --- a/Tools/WAD/Test/death.tcl +++ /dev/null @@ -1,65 +0,0 @@ -load ./debug[info sharedlibextension] - -proc death_by_segmentation { } { - seg_crash -} - -proc death_by_bus { } { - bus_crash -} - -proc death_by_abort { } { - abort_crash -1 -} - -proc death_by_math { } { - math_crash 37 0 -} - -proc death_by_buffer { } { - overflow_crash -} - -set method 1 -proc death {} { - global method - if { $method == 1 } { - death_by_segmentation - } - if { $method == 2 } { - death_by_abort - } - if { $method == 3 } { - death_by_math - } - if { $method == 4 } { - death_by_bus - } - if { $method == 5 } { - death_by_buffer - } -} - -label .l -text "How would you like to die today?" -pack .l - -radiobutton .r1 -text "Segmentation fault" -variable method -value 1 -pack .r1 -anchor w - -radiobutton .r2 -text "Failed assertion" -variable method -value 2 -pack .r2 -anchor w - -radiobutton .r3 -text "Math error" -variable method -value 3 -pack .r3 -anchor w - -radiobutton .r4 -text "Bus error" -variable method -value 4 -pack .r4 -anchor w - -radiobutton .r5 -text "Stack overflow" -variable method -value 5 -pack .r5 -anchor w - -button .b -text "Die" -command death -pack .b -fill both -expand 1 - -wm title . "Death Wizard" - diff --git a/Tools/WAD/Test/debug.c b/Tools/WAD/Test/debug.c deleted file mode 100644 index b95b539f0..000000000 --- a/Tools/WAD/Test/debug.c +++ /dev/null @@ -1,119 +0,0 @@ -/* ----------------------------------------------------------------------------- - * debug.c - * - * This file contains a variety of different programming errors to test with - * WAD. - * ----------------------------------------------------------------------------- */ - -#include -#include -#include - -typedef double Real; -typedef Real Float; - -char buffer[256]; - -/* A simple segmentation fault on an uninitialized pointer */ -int seg_crash() { - int *a = 0; - *a = 3; - return 1; -} - -/* Blow the process heap */ - -int blowheap_crash() { - int i; - int *a = (int *) malloc(sizeof(int)); - - for (i = 0;; i++) { - a[i] = i; - } -} - -/* Buffer overflow crash on the stack */ -int overflow_crash() { - int a[512]; - int i; - - for (i = 0; i < 1024; i++) { - a[i] = i; - } -} - -/* A simple bus error. */ -int bus_crash() { - double *a = (double *) (buffer+1); - *a = 3.4; - return 1; -} - -/* An assertion */ -int abort_crash(int n) { - assert(n > 0); - return 1; -} - -/* A math error (maybe) */ -int math_crash(int x, int y) { - return x/y; -} - -void type_crash(int a, short b, char c, unsigned long d, float f, double g) { - int la; - short lb; - char lc; - long ld; - float lf; - double lg; - long ll; - - la = a; - lb = b; - lc = c; - ld = ld; - lf = lf; - lg = lg; - assert(0); -} - -#ifdef NEED_MAIN - -static const char *usage="\n\ -Usage: debug type\n\ - seg - Fail with an uninitialized pointer.\n\ - bus - Fail with a bus error.\n\ - abort - Fail with an assertion error.\n\ - math - Fail with a math error.\n\ - heap - Blow the process heap.\n\ - overflow - Buffer overflow on the stack.\n\ -"; - -int main(int argc, char **argv) { - int n; - - printf("WAD debug program.\n"); - - if (argc < 2) { - printf("%s\n", usage); - exit(0); - } - if (strcmp(argv[1],"abort") == 0) { - abort_crash(-4); - } else if (strcmp(argv[1],"seg") ==0) { - seg_crash(); - } else if (strcmp(argv[1],"bus") == 0) { - bus_crash(); - } else if (strcmp(argv[1],"math") == 0) { - math_crash(3,0); - } else if (strcmp(argv[1],"heap") == 0) { - blowheap_crash(); - } else if (strcmp(argv[1],"overflow") == 0) { - overflow_crash(); - } else if (strcmp(argv[1],"type") == 0) { - type_crash(0,2,'x',420000,3.14159,2.1828); - } -} - -#endif diff --git a/Tools/WAD/Test/debug.i b/Tools/WAD/Test/debug.i deleted file mode 100644 index 1823161fc..000000000 --- a/Tools/WAD/Test/debug.i +++ /dev/null @@ -1,9 +0,0 @@ -%module debug - -extern int seg_crash(); -extern int bus_crash(); -extern int blowheap_crash(); -extern int overflow_crash(); -extern int abort_crash(int); -extern int math_crash(int x, int y); -extern void type_crash(int, short, char, unsigned long, float, double); diff --git a/Tools/WAD/Test/debug.py b/Tools/WAD/Test/debug.py deleted file mode 100644 index 07d9453a8..000000000 --- a/Tools/WAD/Test/debug.py +++ /dev/null @@ -1,35 +0,0 @@ -# WAD debugging module for python - -import debug -import sys - -try: - name = sys.argv[1] -except: - print """ -usage: debug.py test - - seg - Segmentation fault due to uninitialized pointer. - bus - Bus error. - abort - Failed assertion. - math - Math error. - heap - Blown heap. - overflow - Buffer overflow. -""" - sys.exit(1) - -if name == "seg": - debug.seg_crash() -elif name == "bus": - debug.bus_crash() -elif name == "abort": - debug.abort_crash(-2) -elif name == "math": - debug.math_crash(3,0) -elif name == "heap": - debug.blowheap_crash() -elif name == "overflow": - debug.overflow_crash() -elif name == "type": - debug.type_crash(37,42, 'x', 420000, 3.14159, 2.1828) - diff --git a/Tools/WAD/Test/debug.tcl b/Tools/WAD/Test/debug.tcl deleted file mode 100644 index ab5cd16aa..000000000 --- a/Tools/WAD/Test/debug.tcl +++ /dev/null @@ -1,25 +0,0 @@ -# WAD debugging module for Tcl. This should be executed with wish - -load ./debug[info sharedlibextension] - -message .t -text "This program tests various program faults. Note: Not all of these errors can be gracefully handled." - -button .b1 -text "Segmentation fault" -command "seg_crash" -button .b2 -text "Bus error (not on Linux)" -command "bus_crash" -button .b3 -text "Abort" -command "abort_crash -1" -button .b4 -text "Math" -command "math_crash 3 0" -button .b5 -text "Blow Heap" -command "blowheap_crash" -button .b6 -text "Buffer overflow" -command "overflow_crash" -button .q -text "Quit" -command "exit" - -pack .t -fill x - -pack .b1 -fill x -pack .b2 -fill x -pack .b3 -fill x -pack .b4 -fill x -pack .b5 -fill x -pack .b6 -fill x -pack .q -fill x - - diff --git a/Tools/WAD/Test/foo.py b/Tools/WAD/Test/foo.py deleted file mode 100644 index dee2e7d57..000000000 --- a/Tools/WAD/Test/foo.py +++ /dev/null @@ -1,31 +0,0 @@ -import debug - -def foo(): - debug.abort_crash(-1) - -def bar(): - foo() - -def spam(): - bar() - -from Tkinter import * - -root = Tk() - -button = Button(text="Press me", command=spam) -button.pack() - -#root.mainloop() - - - - - - - - - - - - diff --git a/Tools/WAD/Test/wadpm.py b/Tools/WAD/Test/wadpm.py deleted file mode 100644 index 8a633129e..000000000 --- a/Tools/WAD/Test/wadpm.py +++ /dev/null @@ -1,49 +0,0 @@ -# ----------------------------------------------------------------------------- -# Wad port-mortem debugger -# -# David Beazley -# ----------------------------------------------------------------------------- - -import sys - -_last_exc = None -_last_level = 0 - -print "WAD port-mortem" - -class where_impl: - def __repr__(self): - global _last_exc, _last_level - if sys.last_value: - if sys.last_value[0] != _last_exc: - _last_exc = sys.last_value[0] - _last_level = 0 - else: - raise RuntimeError,"No pending error." - print repr(_last_exc) - return "" - -where = where_impl() - -class up_impl: - def __repr__(self): - global _last_exc, _last_level - if not _last_exc: - return "" - _last_level += 1 - print repr(_last_exc[_last_level]) - return "" - -up = up_impl() - -class down_impl: - def __repr__(self): - global _last_exc, _last_level - if not _last_exc: - return "" - _last_level -= 1 - print repr(_last_exc[_last_level]) - return "" - -down = down_impl() - diff --git a/Tools/WAD/Test/wpm.py b/Tools/WAD/Test/wpm.py deleted file mode 100644 index f849e3167..000000000 --- a/Tools/WAD/Test/wpm.py +++ /dev/null @@ -1,280 +0,0 @@ -# ----------------------------------------------------------------------------- -# WAD Post-mortem debugger -# -# This program can be used to walk up and down the call stack of a mixed -# Python-C program. The following commands are supported: -# -# w - A stack traceback -# u - Go up the call stack -# d - Go down the call stack -# e - Edit a file -# c - Clear the debugger. -# -# David Beazley -# Copyright (C) 2001 -# University of Chicago -# All Rights Reserved -# ----------------------------------------------------------------------------- - -import sys -import os -import traceback -import types -import linecache - - -print "**************************************************" -print "* WAD Debugger *" -print "**************************************************" - -# Save a local copy of the last exception and value objects from sys - -_last_type = sys.last_type -_last_value = sys.last_value -_last_traceback = sys.last_traceback -_last_level = 0 - -_cstack = None # Stack of C-only code -_pystack = None # Stack of Python only code -_combined_stack = None # Combined C-python stack - -_allmode = 0 # Show entire C stack - -# Generalized object for holding stack frames - -class wad_frame: - def __init__(self,frame, n = 0): - if isinstance(frame,types.TupleType): - # A Python traceback object - self.__FILE__ = frame[0] - self.__LINE__ = frame[1] - self.__NAME__ = frame[2] - self.__ARGSTR__ = frame[3] - self.__FRAMENO__ = n - # Make the debugging string - self.__DEBUGSTR__ = "#%-3d [ Python ] in %s in %s, line %d" % (self.__FRAMENO__, self.__ARGSTR__, self.__FILE__, self.__LINE__) - - # Try to get source data - self.__SOURCE__ = "%s, Line %d\n\n" % (self.__FILE__, self.__LINE__) - for i in range(self.__LINE__-2,self.__LINE__+3): - l = linecache.getline(self.__FILE__,i) - if not l: l = '\n' - if (i == self.__LINE__): - self.__SOURCE__ += " => " - else: - self.__SOURCE__ += " " - self.__SOURCE__ += l - self.__frame__ = None - - elif hasattr(frame,"__WAD__"): - # A WAD traceback object - self.__FILE__ = frame.__FILE__ - self.__LINE__ = frame.__LINE__ - self.__NAME__ = frame.__NAME__ - self.__DEBUGSTR__ = frame.__WHERE__ - self.__SOURCE__ = frame.__SOURCE__ - self.__frame__ = frame - - def __str__(self): - return self.__DEBUGSTR__.strip() - - def __getattr__(self,name): - if self.__frame__: - return getattr(self.__frame__,name) - raise AttributeError - - def output(self): - print self - if self.__SOURCE__: - print "\n%s" % (self.__SOURCE__) - - -def wad_build_info(): - global _last_type,_last_value, _last_traceback, _cstack, _combined_stack,_pystack - - _last_type = None - _last_value = None - _last_traceback = None - _cstack = None - _combined_stack = [] - - # Check to see if any exception is defined - if not sys.last_type: - print "No exception has occurred." - return - - # Save a copy of previous exception - _last_type = sys.last_type - _last_value = sys.last_value - _last_traceback = sys.last_traceback - _last_level = 0 - - start_frame = 0 - # Test to see what kind of object it is - if issubclass(_last_type,StandardError): - # Python exception - print "Python exception" - elif hasattr(_last_value[0],"__WAD__"): - # A wad exception frame object - w = sys.last_value[0] - i = 0 - _cstack = [] - while not w[i].__LAST__: - start_frame += 1 - wf = wad_frame(w[i]) - _cstack.append(wf) - i = i + 1 - -# wf = wad_frame(w[i]) -# _cstack.append(wf) -# start_frame += 1 - - # Build the rest of the c stack - _combined_stack = _cstack[:] - while i < len(w): - wf = wad_frame(w[i]) - _cstack.append(wf) - i = i + 1 - - else: - print "Unknown error" - - # Build the Python call stack - _pystack = [] - t = sys.last_traceback - tp = None - while hasattr(t,"tb_frame"): - tp = t - t = t.tb_next - - fr = traceback.extract_stack(tp.tb_frame) - for i in range(len(fr),0,-1): - f = wad_frame(fr[i-1], start_frame) - start_frame += 1 - _pystack.append(f) - _combined_stack.extend(_pystack) - - -wad_build_info() - -class where_impl: - def __init__(self): - self.all = 0; - self.cstack = 0 - - def __repr__(self): - global _combined_stack, _cstack, _last_level - if (self.cstack): - stack = _cstack - else: - stack = _combined_stack - - if not stack: - print "No current exception." - return "" - - last_source = None - for i in range(len(stack),0,-1): - f = stack[i-1] - print f - if (f.__SOURCE__): - last_source = f.__SOURCE__ - _last_level = i-1 - if last_source: print "\n%s" % last_source - return "" - - def __getitem__(self,n): - global _last_level, _cstack, _combined_stack - if (self.cstack): - stack = _cstack - else: - stack = _combined_stack - _last_level = n - stack[_last_level].output() - return None - - def __len__(self): - return len(frame) - - -where = where_impl() -w = where - -class up_impl: - def __repr__(self): - global _last_level, _combined_stack, _cstack - if where.cstack: - stack = _cstack - else: - stack = _combined_stack - - if not stack: - return "" - _last_level += 1 - stack[_last_level].output() - return "" - -up = up_impl() -u = up - -class down_impl: - def __repr__(self): - global _last_level, _combined_stack, _cstack - if where.cstack: - stack = _cstack - else: - stack = _combined_stack - - if not stack: - return "" - _last_level -= 1 - stack[_last_level].output() - return "" - -down = down_impl() -d = down - -class clear_impl: - def __repr__(self): - global _last_exc, _last_level, frame - _last_exc = None - frame = None - -clear = clear_impl() -c = clear - -class edit_impl: - def __repr__(self): - global _last_level, _combined_stack, _cstack - if where.cstack: - stack = _cstack - else: - stack = _combined_stack - - if not stack: - return "" - f = stack[_last_level] - e = os.getenv("EDITOR","vi") - if f.__FILE__: - os.system("%s +%d %s" % (e,f.__LINE__,f.__FILE__)) - return "" - -edit = edit_impl() -e = edit - -class var_impl: - def __getattr__(self,name): - if (w.cstack): - stack = _cstack - else: - stack = _combined_stack - - return getattr(stack[_last_level],name) - - -v = var_impl() - - -repr(w) - - diff --git a/Tools/WAD/Wad/Makefile.in b/Tools/WAD/Wad/Makefile.in deleted file mode 100644 index b933dfa23..000000000 --- a/Tools/WAD/Wad/Makefile.in +++ /dev/null @@ -1,73 +0,0 @@ -####################################################################### -# WAD Makefile -# -# David Beazley -# January 1, 2001 -####################################################################### - -# These are the files that make up the WAD core -WADSRCS = string.c vars.c io.c memory.c return.c default.c stack.c stab.c elf.c object.c init.c segment.c signal.c -WADOBJS = string.o vars.o io.o memory.o return.o default.o stack.o stab.o elf.o object.o signal.o segment.o init.o -INCLUDE = -I../Include -I. $(SINCLUDE) -WADOPT = @WADOPT@ - - -# Location of your Perl installation -PERLINCLUDE = @PERL5EXT@ -PERLSRCS = wadpl.cxx -PERLOBJS = wadpl.o - -# C Compiler -CC = @CC@ -CFLAGS = #@CCSHARED@ - -# C++ Compiler -CXX = @CXX@ -CXXFLAGS = #@CXXSHARED@ - -# Linking options -CLINK = -CXXLINK = @CXXLINK@ - -# AR -AR = @AR@ - -# Rules for creation of a .o file from .cxx -.SUFFIXES: .cxx -.cxx.o: - $(CXX) $(CXXFLAGS) $(WADOPT) $(INCLUDE) -c -o $*.o $< - -.c.o: - $(CC) $(CFLAGS) $(WADOPT) $(INCLUDE) -c -o $*.o $< - -wad: $(WADOBJS) main.o - $(CXXLINK) $(WADOBJS) main.o -o libwad.so - $(AR) cr libwadcore.a $(WADOBJS) - cp libwad.so .. - cp libwadcore.a .. - -perl: wad_perl_handler.c $(WADOBJS) $(PERLOBJS) - $(CXXLINK) $(WADOBJS) $(PERLOBJS) -o libwadpl.so - cp libwadpl.so .. - -wad_perl_handler.c: - python makehandler.py - -debug:: - cc -g debug.c $(INCLUDE) -L. -R. -lwad - -plus:: - CC -g debug.cxx $(INCLUDE) -L. -R. -lwad - -wc:: - wc $(SRCS) - -semi:: - @egrep ";" $(WADSRCS) plat/*.c | wc - -clean:: - rm -f *.o *.so *~ - - - - diff --git a/Tools/WAD/Wad/debug.c b/Tools/WAD/Wad/debug.c deleted file mode 100644 index fcdb87a60..000000000 --- a/Tools/WAD/Wad/debug.c +++ /dev/null @@ -1,98 +0,0 @@ -#include -#include -#include "wad.h" -#include - -typedef struct Foo { - double a; - double b; - float c; -} Foo; - -static int type_crash(int n, short m, char c, double x, float y, Foo f, void *ptr) { - int *a = 0; - *a = 3; - return 1; -} -static int seg_crash(int n, double x, - float y) { - int *a = 0; - if (n > 0) seg_crash(n-1,x,y); - *a = 3; - return 1; -} - -int bus_crash(int n) { - int b; - int *a = &b; - a = (int *) ((int) a | 0x1); - if (n > 0) bus_crash(n-1); - *a = 3; - printf("well, well, well.\n"); - return 1; -} - -int abort_crash(int n) { - assert(n > 0); - abort_crash(n-1); - return 1; -} - -double double_crash(double a, double b) { - double *c; - *c = a+b; - return *c; -} - -int math_crash(int x, int y) { - return x/y; -} - -int call_func(int n, int (*f)(int)) { - - int ret; - ret = (*f)(n); - if (ret <= 0) { - printf("An error occurred!\n"); - } - return 0; -} - -static int multi(char a, short b, int c, double d) { - a = 'x'; - b = 15236; - c = 12345678; - d = 3.14159; - return c; -} - -static int test(int x, int (*f)(int)) { - return (*f)(-x); -} - -int main(int argc, char **argv) { - int n; - int (*f)(int); - Foo foo = { 3.14, 28.18, 1.0 }; - - printf("starting.\n"); - - if (strcmp(argv[1],"abort") == 0) { - abort_crash(0); - } else if (strcmp(argv[1],"seg") ==0) { - seg_crash(0,1,2); - } else if (strcmp(argv[1],"bus") == 0) { - bus_crash(0); - } else if (strcmp(argv[1],"ret") == 0) { - call_func(4,abort_crash); - } else if (strcmp(argv[1],"test") == 0) { - test(-1000,abort_crash); - } else if (strcmp(argv[1],"double") == 0) { - double_crash(3.14159,2.1828); - } else if (strcmp(argv[1],"math") == 0) { - math_crash(3,0); - } else if (strcmp(argv[1],"type") == 0) { - type_crash(34,42,17, 3.14159, 2.1828, foo, &foo); - } - multi(3,5,10,3.14); -} diff --git a/Tools/WAD/Wad/default.c b/Tools/WAD/Wad/default.c deleted file mode 100644 index fc72a9e08..000000000 --- a/Tools/WAD/Wad/default.c +++ /dev/null @@ -1,311 +0,0 @@ -/* ----------------------------------------------------------------------------- - * default.c - * - * Default signal handler. Just prints a stack trace and returns. - * - * Author(s) : David Beazley (beazley@cs.uchicago.edu) - * - * Copyright (C) 2000. The University of Chicago. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * See the file COPYING for a complete copy of the LGPL. - * ----------------------------------------------------------------------------- */ - -#include "wad.h" - -static char cvs[] = "$Id$"; - -#include - - -/* This function tries to produce some kind of sensible argument - string for a stack frame. If no debugging information is available, - we'll just dump the %i0-%i5 registers in hex. If debugging information - is available, we'll try to do something a little more sensible */ - -char *wad_arg_string(WadFrame *frame) { - static char str[1024]; - WadLocal *wp; - long *stack; - long *nextstack; - long *prevstack; - int i; - WadFrame *nf; - WadFrame *pf; - - nf = frame->next; - if (nf) - nextstack = (long *) nf->stack; - else - nextstack = 0; - - pf = frame->prev; - if (pf) - prevstack = (long *) pf->stack; - else - prevstack = 0; - - str[0] = 0; - stack = (long *) frame->stack; - - -#ifdef WAD_LINUX - if (!nf) { - return ""; - } -#endif - - if ((frame->debug_nargs < 0) || (0)){ - /* No argument information is available. If we are on SPARC, we'll dump - the %in registers since these usually hold input parameters. On - Linux, we do nothing */ - -#ifdef WAD_SOLARIS - for (i = 0; i < 6; i++) { - wad_strcat(str,"0x"); - wad_strcat(str,wad_format_hex((unsigned long) stack[8+i],0)); - if (i < 5) - wad_strcat(str,","); - } -#endif - } else { - /* We were able to get some argument information out the debugging table */ - wp = frame->debug_args; - for (i = 0; i < frame->debug_nargs; i++, wp = wp->next) { - wad_strcat(str,wp->name); - wad_strcat(str,"="); - wad_strcat(str,wad_format_var(wp)); - if (i < (frame->debug_nargs-1)) wad_strcat(str,","); - } - } - return str; - -} - -char *wad_strip_dir(char *name) { - char *c; - /* printf("strip: '%s'\n", name); */ - c = name + strlen(name); - while (c != name) { - if (*c == '/') { - c++; - return c; - } - c--; - } - return name; -} - - - -static char *src_file = 0; -static int src_len = 0; -static char src_path[1024] = ""; - -/* Opens up a source file and tries to locate a specific line number */ - -char *wad_load_source(char *path, int line) { - int fd; - char *c; - char *start; - int n; - - if (strcmp(src_path,path)) { - if (src_file) { - munmap(src_file, src_len); - src_file = 0; - src_len = 0; - } - fd = open(path, O_RDONLY); - if (fd < 0) return 0; - src_len = lseek(fd, 0, SEEK_END); - lseek(fd,0,SEEK_SET); - src_file = (char *)mmap(NULL,src_len, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0); - if (src_file == MAP_FAILED) { - close(fd); - return 0; - } - close(fd); - wad_strcpy(src_path,path); - } - n = 0; - start = src_file; - c = src_file; - while (n < src_len) { - if (*c == '\n') { - line--; - if (line == 0) { - return start; - } - start = c+1; - } - c++; - n++; - } - return 0; -} - -void wad_release_source() { - if (src_file) { - munmap(src_file,src_len); - src_file = 0; - src_len = 0; - src_path[0] = 0; - } -} - -/* ----------------------------------------------------------------------------- - * wad_debug_src_code(WadFrame *f) - * - * Get source code for a frame - * ----------------------------------------------------------------------------- */ - -char *wad_debug_src_string(WadFrame *f, int window) { - static char temp[16384]; - - if (f->loc_srcfile && strlen(f->loc_srcfile) && (f->loc_line > 0)) { - char *line, *c; - int i; - int first, last; - first = f->loc_line - window; - last = f->loc_line + window; - if (first < 1) first = 1; - line = wad_load_source(f->loc_srcfile,first); - if (line) { - wad_strcpy(temp,f->loc_srcfile); - wad_strcat(temp,", line "); - wad_strcat(temp,wad_format_signed(f->loc_line,-1)); - wad_strcat(temp,"\n\n"); - for (i = first; i <= last; i++) { - if (i == f->loc_line) wad_strcat(temp," => "); - else wad_strcat(temp," "); - c = strchr(line,'\n'); - if (c) { - *c = 0; - wad_strcat(temp,line); - wad_strcat(temp,"\n"); - *c = '\n'; - } else { - wad_strcat(temp,line); - wad_strcat(temp,"\n"); - break; - } - line = c+1; - } - f->debug_srcstr = wad_strdup(temp); - return f->debug_srcstr; - } - } - f->debug_srcstr = 0; - return 0; -} - -/* ----------------------------------------------------------------------------- - * wad_debug_make_strings(WadFrame *f) - * - * This function walks the stack trace and tries to generate a debugging string - * ----------------------------------------------------------------------------- */ - -void -wad_debug_make_strings(WadFrame *f) { - static char msg[16384]; - while (f) { - wad_strcpy(msg,"#"); - wad_strcat(msg,wad_format_signed(f->frameno,3)); - wad_strcat(msg," 0x"); - wad_strcat(msg,wad_format_hex(f->pc,1)); - wad_strcat(msg," in "); - wad_strcat(msg, f->sym_name ? f->sym_name : "?"); - wad_strcat(msg,"("); - wad_strcat(msg,wad_arg_string(f)); - wad_strcat(msg,")"); - if (f->loc_srcfile && strlen(f->loc_srcfile)) { - wad_strcat(msg," in '"); - wad_strcat(msg, wad_strip_dir(f->loc_srcfile)); - wad_strcat(msg,"'"); - if (f->loc_line > 0) { - wad_strcat(msg,", line "); - wad_strcat(msg,wad_format_signed(f->loc_line,-1)); - /* Try to locate the source file */ - wad_debug_src_string(f, WAD_SRC_WINDOW); - } - } else { - if (f->loc_objfile && strlen(f->loc_objfile)) { - wad_strcat(msg," from '"); - wad_strcat(msg, wad_strip_dir(f->loc_objfile)); - wad_strcat(msg,"'"); - } - } - wad_strcat(msg,"\n"); - f->debug_str = wad_strdup(msg); - f = f->next; - } -} - -/* Dump trace to a file */ -void wad_dump_trace(int fd, int signo, WadFrame *f, char *ret) { - static char buffer[128]; - char *srcstr = 0; - - switch(signo) { - case SIGSEGV: - write(fd,"WAD: Segmentation fault.\n", 25); - break; - case SIGBUS: - write(fd,"WAD: Bus error.\n",17); - break; - case SIGABRT: - write(fd,"WAD: Abort.\n",12); - break; - case SIGFPE: - write(fd,"WAD: Floating point exception.\n", 31); - break; - case SIGILL: - write(fd,"WAD: Illegal instruction.\n", 26); - break; - default: - sprintf(buffer,"WAD: Signal %d\n", signo); - write(fd,buffer,strlen(buffer)); - break; - } - /* Find the last exception frame */ - - while (f && !(f->last)) { - f = f->next; - } - - while (f) { - write(fd,f->debug_str,strlen(f->debug_str)); - if (f->debug_srcstr) { - srcstr = f->debug_srcstr; - } - f = f->prev; - } - if (srcstr) { - write(fd,"\n",1); - write(fd,srcstr,strlen(srcstr)); - write(fd,"\n",1); - } -} - -/* ----------------------------------------------------------------------------- - * Default callback - * ----------------------------------------------------------------------------- */ - -void wad_default_callback(int signo, WadFrame *f, char *ret) { - wad_dump_trace(2,signo,f,ret); -} - diff --git a/Tools/WAD/Wad/demangle.c b/Tools/WAD/Wad/demangle.c deleted file mode 100644 index 6b8b541a2..000000000 --- a/Tools/WAD/Wad/demangle.c +++ /dev/null @@ -1,36 +0,0 @@ -/* ----------------------------------------------------------------------------- - * demangle.c - * - * This file performs C++ partial name demangling to the extent that it - * seems reasonable. - * - * Author(s) : David Beazley (beazley@cs.uchicago.edu) - * - * Copyright (C) 2000. The University of Chicago. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * See the file COPYING for a complete copy of the LGPL. - * ----------------------------------------------------------------------------- */ - -#include "wad.h" - -static char cvs[] = "$Id$"; - -char *wad_cplus_demangle(WadSymbol *ws) { - static char buffer[4096]; - strcpy(buffer,ws->name); - return buffer; -} diff --git a/Tools/WAD/Wad/elf.c b/Tools/WAD/Wad/elf.c deleted file mode 100644 index 5a2947b02..000000000 --- a/Tools/WAD/Wad/elf.c +++ /dev/null @@ -1,428 +0,0 @@ -/* ----------------------------------------------------------------------------- - * elf.c - * - * ELF file management. This file contains functions for accessing ELF - * file data from a raw memory mapped ELF file (as performed by the - * functions in object.c). - * - * Author(s) : David Beazley (beazley@cs.uchicago.edu) - * - * Copyright (C) 2000. The University of Chicago. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * See the file COPYING for a complete copy of the LGPL. - * ----------------------------------------------------------------------------- */ - -#include "wad.h" - -static char cvs[] = "$Id$"; - -#ifdef WAD_SOLARIS -#include -#endif -#ifdef WAD_LINUX -#include -#endif - -/* --- What's needed here (high level interface) : - - Mapping of addresses to symbols - - Mapping of symbols to file+line -*/ - - -/* ----------------------------------------------------------------------------- - * wad_elf_check() - * - * Checks to see if an object file is an ELF file. Returns 1 on success and - * changes the type flag of wo to indicate the type of ELF file. - * ----------------------------------------------------------------------------- */ - -int -wad_elf_check(WadObjectFile *wo) { - if (strncmp((char *)wo->ptr,ELFMAG, SELFMAG) != 0) - return 0; - - /* Probably need to put some kind of 32/64 bit check here */ - return 1; -} - -/* ----------------------------------------------------------------------------- - * wad_elf_phdrcnt() - * - * Return number of entries in the ELF program header section - * ----------------------------------------------------------------------------- */ - -int -wad_elf_phdrcnt(WadObjectFile *wo) { - Elf32_Ehdr *eh; - - eh = (Elf32_Ehdr *) wo->ptr; - return eh->e_phnum; -} - -/* ----------------------------------------------------------------------------- - * wad_elf_phdrpos() - * - * Return the location of the ELF program header. - * ----------------------------------------------------------------------------- */ - -void * -wad_elf_phdrpos(WadObjectFile *wo) { - Elf32_Ehdr *eh; - char *c; - eh = (Elf32_Ehdr *) wo->ptr; - c = (char *) wo->ptr; - return (void *) (c+eh->e_phoff); -} - -/* ----------------------------------------------------------------------------- - * wad_elf_shdrcnt() - * - * Return number of entries in the ELF section header - * ----------------------------------------------------------------------------- */ - -int -wad_elf_shdrcnt(WadObjectFile *wo) { - Elf32_Ehdr *eh; - - eh = (Elf32_Ehdr *) wo->ptr; - return eh->e_shnum; -} - - -/* ----------------------------------------------------------------------------- - * wad_elf_shdrpos() - * - * Return the location of the section headers - * ----------------------------------------------------------------------------- */ - -void * -wad_elf_shdrpos(WadObjectFile *wo) { - Elf32_Ehdr *eh; - char *c; - eh = (Elf32_Ehdr *) wo->ptr; - c = (char *) wo->ptr; - return (void *) (c+eh->e_shoff); -} - -/* ----------------------------------------------------------------------------- - * wad_elf_section_header() - * - * Get a specific section number - * ----------------------------------------------------------------------------- */ - -void *wad_elf_section_header(WadObjectFile *wo, int sn) { - Elf32_Ehdr *eh; - char *r; - - eh = (Elf32_Ehdr *) wo->ptr; - if ((sn < 0) || (sn >= eh->e_shnum)) return 0; - - r = (char *) wad_elf_shdrpos(wo) + (sn*eh->e_shentsize); - return (void *) r; -} - -/* ----------------------------------------------------------------------------- - * wad_elf_section_data() - * - * Get section data - * ----------------------------------------------------------------------------- */ - -void *wad_elf_section_data(WadObjectFile *wo, int sn) { - Elf32_Shdr *sh; - char *r; - - sh = (Elf32_Shdr *) wad_elf_section_header(wo,sn); - if (!sh) return 0; - - r = ((char *) wo->ptr) + sh->sh_offset; - return r; -} - -/* ----------------------------------------------------------------------------- - * wad_elf_section_size() - * Return section size - * ----------------------------------------------------------------------------- */ - -int wad_elf_section_size(WadObjectFile *wo, int sn) { - Elf32_Shdr *sh; - - sh = (Elf32_Shdr *) wad_elf_section_header(wo,sn); - if (!sh) return -1; - return sh->sh_size; -} - -/* ----------------------------------------------------------------------------- - * wad_elf_section_name() - * - * Returns the name of an ELF section - * ----------------------------------------------------------------------------- */ - -char *wad_elf_section_name(WadObjectFile *wo, int sn) { - Elf32_Ehdr *eh; - Elf32_Shdr *sh; - char *sectionstr; - - eh = (Elf32_Ehdr *) wo->ptr; - - /* Get the string table */ - sectionstr = (char *) wad_elf_section_data(wo,eh->e_shstrndx); - if (!sectionstr) { - return 0; - } - - /* Get the section header for the section */ - sh = (Elf32_Shdr *) wad_elf_section_header(wo,sn); - if (!sh) return 0; - return sectionstr + sh->sh_name; -} - -/* ----------------------------------------------------------------------------- - * wad_elf_section_byname() - * - * Get section data given a section name - * ----------------------------------------------------------------------------- */ - -int -wad_elf_section_byname(WadObjectFile *wo, char *name) { - int i; - char *sn; - int n; - - n = wad_elf_shdrcnt(wo); - for (i = 0; i pc; - base = (unsigned long) f->segment->base; - - nsymtab = wad_elf_section_byname(f->object,secname); - if (nsymtab < 0) return 0; - nstrtab = wad_elf_section_byname(f->object,strname); - if (nstrtab < 0) return 0; - - symtab_size = wad_elf_section_size(f->object,nsymtab); - sym = (Elf32_Sym *) wad_elf_section_data(f->object,nsymtab); - str = (char *) wad_elf_section_data(f->object,nstrtab); - - nsym = (symtab_size/sizeof(Elf32_Sym)); - for (i = 0; i < nsym; i++) { - name = str + sym[i].st_name; - /* Look for filename in case the symbol maps to a local symbol */ - if (ELF32_ST_TYPE(sym[i].st_info) == STT_FILE) { - localfile = name; - } - if (wad_debug_mode & DEBUG_SYMBOL_SEARCH) { - wad_printf("%x(%x): %s %x + %x, %x, %x\n", base, vaddr, name, sym[i].st_value, sym[i].st_size, sym[i].st_info, sym[i].st_shndx); - } - if (((base + sym[i].st_value) <= vaddr) && (vaddr <= (base+sym[i].st_value + sym[i].st_size))) { -#ifdef WAD_LINUX - /* If the section index is 0, the symbol is undefined */ - if (sym[i].st_shndx == 0) continue; -#endif - f->sym_name = name; - f->sym_nlen = strlen(name); - f->sym_base = base + sym[i].st_value; - f->sym_size = sym[i].st_size; - if (ELF32_ST_BIND(sym[i].st_info) == STB_LOCAL) { - f->sym_file = localfile; - f->sym_bind = SYM_LOCAL; - } else { - f->sym_bind = SYM_GLOBAL; - } - return 1; - } - } - return 0; -} - -void -wad_elf_find_symbol(WadFrame *f) { - /* We simply try a few possible sections */ - if (elf_search_section_sym(f,".symtab",".strtab")) return; - if (elf_search_section_sym(f,".dynsym",".dynstr")) return; - - /* Hmmm. No match found. Oh well */ - return; -} - -/* ----------------------------------------------------------------------------- - * wad_elf_debug_info() - * - * Gather debugging information about a function (if possible) - * ----------------------------------------------------------------------------- */ - -int -wad_elf_debug_info(WadFrame *f) { - int nstab, nstabstr, nstabindex, nstabindexstr, nstabexcl, nstabexclstr; - int ret; - void *stab; - char *stabstr; - int stabsize; - - nstab = wad_elf_section_byname(f->object,".stab"); - nstabstr = wad_elf_section_byname(f->object,".stabstr"); - nstabindex = wad_elf_section_byname(f->object,".stab.index"); - nstabindexstr = wad_elf_section_byname(f->object,".stab.indexstr"); - nstabexcl = wad_elf_section_byname(f->object,".stab.excl"); - nstabexclstr = wad_elf_section_byname(f->object,".stab.exclstr"); - -#ifdef DEBUG_DEBUG - wad_printf("nstab = %d\n", nstab); - wad_printf("nstabstr = %d\n", nstabstr); - wad_printf("nstabindex = %d\n", nstabindex); - wad_printf("nstabindexstr = %d\n", nstabindexstr); - wad_printf("nstabexcl = %d\n", nstabexcl); - wad_printf("nstabexclstr = %d\n", nstabexclstr); -#endif - - /* Now start searching stabs */ - - /* Look in the .stab section */ - if (nstab > 0) { - stab = wad_elf_section_data(f->object,nstab); - stabsize = wad_elf_section_size(f->object,nstab); - stabstr = (char *) wad_elf_section_data(f->object,nstabstr); - - - if (wad_search_stab(stab,stabsize,stabstr, f)) return 1; - } - - /* Look in the .stab.excl section. A solaris oddity? */ - - if (nstabexcl > 0) { - stab = wad_elf_section_data(f->object,nstabexcl); - stabsize = wad_elf_section_size(f->object, nstabexcl); - stabstr = (char *) wad_elf_section_data(f->object, nstabexclstr); - - if (wad_search_stab(stab,stabsize,stabstr, f)) return 1; - } - - /* Look in the .stab.index section. A Solaris oddity? */ - if (nstabindex > 0) { - - stab = wad_elf_section_data(f->object,nstabindex); - stabsize = wad_elf_section_size(f->object, nstabindex); - stabstr = (char *) wad_elf_section_data(f->object, nstabindexstr); - - if (wad_search_stab(stab,stabsize,stabstr, f)) { - /* Hmmm. Might be in a different file */ - WadObjectFile *wo1, *wold; - char objfile[MAX_PATH]; - /* printf("DEBUG %s\n", f->sym_name); */ - wad_strcpy(objfile, f->loc_objfile); - wo1 = wad_object_load(objfile); - if (wo1) { - wold = f->object; - f->object = wo1; - wad_find_debug(f); - f->object = wold; - return ret; - } else { - /* wad_printf("couldn't load %s\n", objfile); */ - } - /* if (!ret) return wad_search_stab(stab,stabsize,stabstr,f);*/ - return ret; - } - } - return 0; -} - -/* ----------------------------------------------------------------------------- - * wad_elf_debug() - * - * Print some debugging information about an object - * ----------------------------------------------------------------------------- */ - -void -wad_elf_debug(WadObjectFile *wo) { - int i; - wad_printf("ELF Debug : obj = %x (%s)\n", wo, wo->path); - wad_printf(" phdrcnt = %d\n", wad_elf_phdrcnt(wo)); - wad_printf(" phdrpos = %x\n", wad_elf_phdrpos(wo)); - wad_printf(" shdrcnt = %d\n", wad_elf_shdrcnt(wo)); - wad_printf(" shdrpos = %x\n", wad_elf_shdrpos(wo)); - for (i = 0; i < wad_elf_shdrcnt(wo); i++) { - wad_printf(" section '%s': data = 0x%x, size = %d\n", - wad_elf_section_name(wo,i), - wad_elf_section_data(wo,i), - wad_elf_section_size(wo,i)); - } -} - -/* general purpose functions exposed to the outside world */ - -/* ----------------------------------------------------------------------------- - * wad_find_symbol() - * ----------------------------------------------------------------------------- */ - -void -wad_find_symbol(WadFrame *f) { - if (wad_debug_mode & DEBUG_SYMBOL) { - wad_printf("wad: Searching for 0x%08x --> ", f->pc); - } - if (f->object) - wad_elf_find_symbol(f); - if (wad_debug_mode & DEBUG_SYMBOL) { - if (f->sym_name) { - wad_printf("%s", f->sym_name); - if (f->sym_file) - wad_printf(" in '%s'\n", f->sym_file); - else - wad_printf("\n"); - } else { - wad_printf("?\n"); - } - } -} - -void -wad_find_debug(WadFrame *f) { - /* if (f->debug_check) return; */ - if (f->object) { - wad_elf_debug_info(f); - } - /* f->debug_check = 1; */ -} - - - diff --git a/Tools/WAD/Wad/init.c b/Tools/WAD/Wad/init.c deleted file mode 100644 index fb44b8d1c..000000000 --- a/Tools/WAD/Wad/init.c +++ /dev/null @@ -1,113 +0,0 @@ -/* ----------------------------------------------------------------------------- - * init.c - * - * Initialize the wad system. This sets up a signal handler for catching - * SIGSEGV, SIGBUS, and SIGABRT. - * - * Author(s) : David Beazley (beazley@cs.uchicago.edu) - * - * Copyright (C) 2000. The University of Chicago. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * See the file COPYING for a complete copy of the LGPL. - * ----------------------------------------------------------------------------- */ - -#include "wad.h" - -static char cvs[] = "$Id$"; - -/* Debugging flag */ -int wad_debug_mode = 0; - -/* Initialize wad */ -void wad_init() { - static int init = 0; - - wad_memory_init(); - if (getenv("WAD_DEBUG_SEGMENT")) { - wad_debug_mode |= DEBUG_SEGMENT; - } - if (getenv("WAD_DEBUG_SYMBOL")) { - wad_debug_mode |= DEBUG_SYMBOL; - } - - if (getenv("WAD_DEBUG_OBJECT")) { - wad_debug_mode |= DEBUG_OBJECT; - } - - if (getenv("WAD_DEBUG_FILE")) { - wad_debug_mode |= DEBUG_FILE; - } - - if (getenv("WAD_DEBUG_HOLD")) { - wad_debug_mode |= DEBUG_HOLD; - } - - if (getenv("WAD_DEBUG_STABS")) { - wad_debug_mode |= DEBUG_STABS; - } - - if (getenv("WAD_DEBUG_RETURN")) { - wad_debug_mode |= DEBUG_RETURN; - } - - if (getenv("WAD_DEBUG_SYMBOL_SEARCH")) { - wad_debug_mode |= DEBUG_SYMBOL_SEARCH; - } - - if (getenv("WAD_DEBUG_INIT")) { - wad_debug_mode |= DEBUG_INIT; - } - - if (getenv("WAD_DEBUG_STACK")) { - wad_debug_mode |= DEBUG_STACK; - } - - if (getenv("WAD_DEBUG_UNWIND")) { - wad_debug_mode |= DEBUG_UNWIND; - } - - if (getenv("WAD_DEBUG_SIGNAL")) { - wad_debug_mode |= DEBUG_SIGNAL; - } - - if (getenv("WAD_NOSTACK")) { - wad_debug_mode |= DEBUG_NOSTACK; - } - - if (getenv("WAD_ONESHOT")) { - wad_debug_mode |= DEBUG_ONESHOT; - } - - if (getenv("WAD_DEBUG_STRING")) { - wad_debug_mode |= DEBUG_STRING; - } - - if (getenv("WAD_DEBUG_MEMORY")) { - wad_debug_mode |= DEBUG_MEMORY; - } - - if (wad_debug_mode & DEBUG_INIT) { - wad_printf("WAD: initializing\n"); - } - - - if (!init) { - wad_signal_init(); - wad_object_reset(); - } - init = 1; -} diff --git a/Tools/WAD/Wad/io.c b/Tools/WAD/Wad/io.c deleted file mode 100644 index afbb3093a..000000000 --- a/Tools/WAD/Wad/io.c +++ /dev/null @@ -1,107 +0,0 @@ -/* ----------------------------------------------------------------------------- - * io.c - * - * This file provides some I/O routines so that WAD can produce - * debugging output without using buffered I/O. - * - * Author(s) : David Beazley (beazley@cs.uchicago.edu) - * - * Copyright (C) 2000. The University of Chicago. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * See the file COPYING for a complete copy of the LGPL. - * ----------------------------------------------------------------------------- */ - -#include "wad.h" -#include - -static char cvs[] = "$Id$"; - -/* Utility functions used to generate strings that are guaranteed not to - rely upon malloc() and related functions */ - -char *wad_format_hex(unsigned long u, int leading) { - static char result[64]; - int i; - char *c; - c = &result[63]; - *c = 0; - for (i = 0; i < (sizeof(unsigned long)*2); i++) { - int d; - d = (int) (u & 0xf); - c--; - if (d < 10) { - *c = '0' + d; - } else { - *c = 'a' + (d-10); - } - if (!u && !leading) break; - u = u >> 4; - } - return c; -} - -char *wad_format_unsigned(unsigned long u, int width) { - static char result[128]; - static char digits[] = "0123456789"; - char *c, *w; - int count = 0; - int i; - c = &result[64]; - while (u) { - int digit = u % 10; - *(--c) = digits[digit]; - count++; - u = u / 10; - } - if (!count) { - *(--c) = '0'; - count++; - } - w = &result[64]; - for (i = count; i < width; i++) { - *(w++) = ' '; - } - *w = 0; - return c; -} - -char *wad_format_signed(signed long s, int width) { - static char result[128]; - unsigned long u; - char *c = result; - if (s < 0) { - *(c++) = '-'; - width--; - u = (unsigned long) (-s); - if (u == 0) { - u = (unsigned long) s; - } - } else { - u = (unsigned long) s; - } - *c = 0; - wad_strcat(result, wad_format_unsigned(u,width)); - return result; -} - - -void wad_printf(const char *fmt, ...) { - va_list ap; - va_start(ap, fmt); - vfprintf(stderr,fmt,ap); - va_end(ap); -} diff --git a/Tools/WAD/Wad/libwadpl.pm b/Tools/WAD/Wad/libwadpl.pm deleted file mode 100644 index 21a01db46..000000000 --- a/Tools/WAD/Wad/libwadpl.pm +++ /dev/null @@ -1,8 +0,0 @@ -package libwadpl; -require Exporter; -require DynaLoader; -@ISA = qw(Exporter DynaLoader); -package libwadpl; -bootstrap libwadpl; -@EXPORT = qw( ); -1; diff --git a/Tools/WAD/Wad/main.cxx b/Tools/WAD/Wad/main.cxx deleted file mode 100644 index 1cf5ce958..000000000 --- a/Tools/WAD/Wad/main.cxx +++ /dev/null @@ -1,14 +0,0 @@ -extern "C" { -#include "wad.h" -} - -/* This is a sick hack to force initialization upon loading */ - -class StartDebug { -public: - StartDebug() { - wad_init(); - } -}; - -static StartDebug s; diff --git a/Tools/WAD/Wad/makehandler.py b/Tools/WAD/Wad/makehandler.py deleted file mode 100755 index c4e23a654..000000000 --- a/Tools/WAD/Wad/makehandler.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/local/bin/python -import string -f = open("wadhandler.pl") -data = f.read() -f.close() - -data = string.replace(data,"\\", "\\\\") -data = string.replace(data,"\"", "\\\"") -data = string.replace(data,"\n", "\\n\\\n") - -f = open("wad_perl_handler.c","w") - -f.write("static char wad_perl_handler[] = \"") -f.write(data) -f.write("\";\n"); -f.close() - - - - diff --git a/Tools/WAD/Wad/memory.c b/Tools/WAD/Wad/memory.c deleted file mode 100644 index 0260cb89e..000000000 --- a/Tools/WAD/Wad/memory.c +++ /dev/null @@ -1,174 +0,0 @@ -/* ----------------------------------------------------------------------------- - * memory.c - * - * This file provides simple mmap() based memory management for WAD. Since - * the process heap-allocator might be corrupted when WAD is invoked, we - * have to do all of our own memory management. However, since WAD mostly - * just collects data, we only provide the function wad_malloc(). To - * release all allocated memory, the wad_release_memory() function should - * be used. - * - * Author(s) : David Beazley (beazley@cs.uchicago.edu) - * - * Copyright (C) 2000. The University of Chicago. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * See the file COPYING for a complete copy of the LGPL. - * ----------------------------------------------------------------------------- */ - -#include "wad.h" - -static char cvs[] = "$Id$"; - -typedef struct _WadMemory { - int npages; /* Number of pages */ - int last; /* Last offset in page */ - struct _WadMemory *next; /* Pointer to next allocation */ -} WadMemory; - -static WadMemory *current = 0; /* Current memory block */ -static int pagesize = 0; /* System page size */ -static int devzero = 0; -static int npalloc = 8; /* Number of pages per alloc */ - -/* ----------------------------------------------------------------------------- - * wad_memory_init() - * - * Initialize the WAD allocator. - * ----------------------------------------------------------------------------- */ - -int wad_memory_init() { - pagesize = getpagesize(); - devzero = open("/dev/zero", O_RDWR); - if (devzero < 0) { - wad_printf("WAD: couldn't open /dev/zero.\n"); - return -1; - } - return 0; -} - -/* ----------------------------------------------------------------------------- - * wad_page_alloc() - * - * Allocate pages using mmap - * ----------------------------------------------------------------------------- */ - -void *wad_page_alloc(int npages) { - void *m; - m = mmap(NULL, npages*pagesize, PROT_READ | PROT_WRITE, MAP_PRIVATE, devzero, 0); - if (((long) m) == -1) return 0; - /* printf("page_alloc: %x - %x\n", m, ((char *) m) + npages*pagesize); */ - return m; -} - -/* ----------------------------------------------------------------------------- - * wad_malloc() - * - * Allocate memory using mmap(). If the allocation is smaller than half a page, - * We'll look at current to see if there is enough space. If so, we'll just - * use that memory. Otherwise, we'll allocate a new page. If the allocation - * request is larger than a page, we'll round up to the nearest page size and - * do a special allocation. - * ----------------------------------------------------------------------------- */ - -void *wad_malloc(int nbytes) { - void *ptr; - WadMemory *wm; - char *c; - int npages; - /* wad_printf("wad_malloc: %d\n", nbytes); */ - if (nbytes >= ((npalloc*pagesize) >> 2)) { - /* Large allocation. */ - npages = ((nbytes + sizeof(WadMemory))/pagesize) + 1; - ptr = wad_page_alloc(npages); - if (!ptr) return 0; - wm = (WadMemory *)ptr; - wm->npages = npages; - wm->last = sizeof(WadMemory) + 8; - wm->next = current; - current = wm; - c = (char *) current + (current->last); - current->last += ((nbytes & ~0x7) + 8); - return c; - } - /* Small allocation. See if there are any regions big enough */ - wm = current; - while (wm) { - if (((wm->npages*pagesize) - wm->last) > nbytes) { - /* Yep. Found a region */ - break; - } - wm = wm->next; - } - if (!wm) { - /* wad_printf("wad_malloc: new page\n", nbytes);*/ - wm = (WadMemory *) wad_page_alloc(npalloc); - if (!wm) return 0; - wm->npages = npalloc; - wm->last = sizeof(WadMemory) + 8; - wm->next = current; - current = wm; - } - c = ((char *) wm) + (wm->last); - wm->last += ((nbytes & ~0x7) + 8); - return c; -} - -/* ----------------------------------------------------------------------------- - * wad_strdup() - * - * Duplicate a string - * ----------------------------------------------------------------------------- */ - -char *wad_strdup(const char *c) { - char *t; - if (!c) c = ""; - t = (char *) wad_malloc(strlen(c)+1); - wad_strcpy(t,c); - return t; -} - -/* ----------------------------------------------------------------------------- - * wad_memcpy() - * ----------------------------------------------------------------------------- */ - -void wad_memcpy(void *t, const void *s, unsigned len) { - char *tc, *sc; - int i; - tc = (char *) t; - sc = (char *) s; - for (i = 0; i < len; i++, tc++, sc++) - *tc = *sc; -} - -/* ----------------------------------------------------------------------------- - * wad_memory_debug() - * ----------------------------------------------------------------------------- */ - -void wad_memory_debug() { - int total_alloc = 0; - int inuse = 0; - WadMemory *m; - if (wad_debug_mode & DEBUG_MEMORY) { - m = current; - while (m) { - total_alloc += (m->npages)*pagesize; - inuse += m->last; - m = m->next; - } - wad_printf("WAD: memory allocated %d bytes (%d bytes used).\n", total_alloc, inuse); - } -} diff --git a/Tools/WAD/Wad/object.c b/Tools/WAD/Wad/object.c deleted file mode 100644 index f13d6b320..000000000 --- a/Tools/WAD/Wad/object.c +++ /dev/null @@ -1,303 +0,0 @@ -/* ----------------------------------------------------------------------------- - * object.c - * - * This file provides access to raw object files, executables, and - * library files. Memory management is handled through mmap() to - * avoid the use of heap/stack space. - * - * All of the files and objects created by this module persist - * until the process exits. Since WAD may be invoked multiple times - * over the course of program execution, it makes little sense to keep - * loading and unloading files---subsequent invocations of the handler - * can simply used previously loaded copies. Caveat: things probably - * won't work right if a program is doing lots of low-level manipulation - * of the dynamic loader. - * - * Author(s) : David Beazley (beazley@cs.uchicago.edu) - * - * Copyright (C) 2000. The University of Chicago. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * See the file COPYING for a complete copy of the LGPL. - * ----------------------------------------------------------------------------- */ - -#include "wad.h" - -static char cvs[] = "$Id$"; - -#include - -typedef struct WadFile { - void *addr; /* Base address of the file */ - int size; /* Size in bytes */ - char *path; /* Path name */ - struct WadFile *next; /* Next file */ -} WadFile; - -static WadFile *wad_files = 0; /* Linked list of loaded files */ - -/* private function to manage the loading of raw files into memory */ -static WadFile * -load_file(const char *path) { - int fd; - WadFile *wf = wad_files; - - if (wad_debug_mode & DEBUG_FILE) { - wad_printf("wad: Loading file '%s' ... ", path); - } - while (wf) { - if (strcmp(wf->path,path) == 0) { - if (wad_debug_mode & DEBUG_FILE) wad_printf("cached.\n"); - return wf; - } - wf = wf->next; - } - fd = open(path, O_RDONLY); - if (fd < 0) { - if (wad_debug_mode & DEBUG_FILE) wad_printf("not found!\n"); - return 0; /* Doesn't exist. Oh well */ - } - if (wad_debug_mode & DEBUG_FILE) wad_printf("loaded.\n"); - wf = (WadFile *) wad_malloc(sizeof(WadFile)); - wf->path = wad_strdup(path); - - /* Get file length */ - wf->size = lseek(fd,0,SEEK_END); - lseek(fd,0,SEEK_SET); - - /* Try to mmap the file */ - wf->addr = mmap(NULL,wf->size, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE, fd, 0); - close(fd); - if (wf->addr == MAP_FAILED) { - if (wad_debug_mode & DEBUG_FILE) wad_printf("wad: Couldn't mmap '%s'\n", path); - return 0; - } - wf->next = wad_files; - wad_files = wf; - return wf; -} - -static WadObjectFile *wad_objects = 0; /* Linked list of object files */ - -/* ----------------------------------------------------------------------------- - * wad_object_cleanup() - * - * Reset the object file loader. This unmaps the files themselves, but - * memory will leak for object files pointers themselves. - * ----------------------------------------------------------------------------- */ - -void -wad_object_reset() { - WadFile *f = wad_files; - if (wad_debug_mode & DEBUG_OBJECT) { - wad_printf("wad: Releasing all files.\n"); - } - /* Unmap all of the loaded files */ - while (f) { - if (f->addr) { - munmap(f->addr, f->size); - } - f = f->next; - } - /* Reset the linked lists */ - wad_files = 0; - wad_objects = 0; -} - -/* ----------------------------------------------------------------------------- - * wad_object_load() - * - * Load an object file into memory using mmap. Returns 0 if the object does - * not exist or if we're out of memory. - * ----------------------------------------------------------------------------- */ - -WadObjectFile * -wad_object_load(const char *path) { - WadObjectFile *wo; - WadFile *wf; - WadObjectFile *wad_arobject_load(const char *path, const char *name); - - if (wad_debug_mode & DEBUG_OBJECT) { - wad_printf("wad: Loading object '%s'", path); - } - for (wo = wad_objects; wo; wo=wo->next) { - if (strcmp(wo->path,path) == 0) { - if (wad_debug_mode & DEBUG_OBJECT) { - wad_printf(" (cached)\n"); - } - return wo; - } - } - if (wad_debug_mode & DEBUG_OBJECT) { - wad_printf("\n"); - } - /* Didn't find it. Now we need to go load some files */ - - /* If this is an archive reference like /path/libfoo.a(blah.o), we need to - split up the name a little bit */ - { - char realfile[MAX_PATH]; - char *objfile; - char *c; - c = strchr(path,'('); - if (c) { - wad_strcpy(realfile,path); - c = strchr(realfile,'('); - *c = 0; - objfile = c+1; - c = strchr(objfile,')'); - *c = 0; - - /* Okay, I'm going to attempt to map this as a library file */ - wo = wad_arobject_load(realfile,objfile); - if (wo) { - /* Reset the path */ - wo->path = wad_strdup(path); - wo->next = wad_objects; - wad_objects = wo; - return wo; - } - } - } - wf = load_file(path); - if (!wf) return 0; - - wo = (WadObjectFile *) wad_malloc(sizeof(WadObjectFile)); - wo->path = wad_strdup(path); - wo->ptr = wf->addr; - wo->len = wf->size; - wo->next = wad_objects; - wad_objects = wo; - return wo; -} - -/* ----------------------------------------------------------------------------- - * wad_arobject_load() - * - * Load an object file stored in an archive file created with an archive. The - * pathname should be the path of the .a file and robjname should be the name - * of the object file stored in the object file. - * ----------------------------------------------------------------------------- */ - -WadObjectFile * -wad_arobject_load(const char *arpath, const char *robjname) { - WadObjectFile *wo; - WadFile *wf; - int arlen; - char *arptr; - struct ar_hdr *ah; - int offset; - int msize; - char *strtab = 0; - int sobjname; - char objname[MAX_PATH]; - - wad_strcpy(objname,robjname); - wad_strcat(objname,"/"); - sobjname = strlen(objname); - - wf = load_file(arpath); - if (!wf) return 0; /* Doesn't exit */ - - arptr = (char *) wf->addr; - arlen = wf->size; - - /* Now take a look at the archive */ - if (strncmp(arptr,ARMAG,SARMAG) == 0) { - /* printf("Got an archive\n"); */ - } else { - return 0; - } - - /* Search the archive for the request member */ - strtab = 0; - offset = SARMAG; - while (offset < arlen) { - char mname[MAX_PATH]; - ah = (struct ar_hdr *) (arptr + offset); - if (strncmp(ah->ar_name,"// ", 3) == 0) { - strtab = arptr + offset + sizeof(struct ar_hdr); - } - msize = atoi(ah->ar_size); - - offset += sizeof(struct ar_hdr); - /* Try to figure out the filename */ - if ((ah->ar_name[0] == '/') && (isdigit(ah->ar_name[1]))) { - int soff; - char *e; - /* Must be in the string offset table */ - soff = atoi(ah->ar_name+1); - if (!strtab) { - /* No offset table */ - return 0; - } - e = strchr(strtab+soff,'\n'); - if (e) { - strncpy(mname, strtab+soff, (e - (strtab+soff))); - mname[e-(strtab+soff)] = 0; - } else { - mname[0] = 0; - } - } else { - /* Name must be in the name field */ - strncpy(mname,ah->ar_name,16); - mname[16] = 0; - } - /* Compare the names */ - if (strncmp(mname,objname,sobjname) == 0) { - /* Found the archive */ - wo = (WadObjectFile *) wad_malloc(sizeof(WadObjectFile)); - wo->ptr = (void *) (arptr + offset); - wo->len = msize; - wo->path = 0; - return wo; - } - offset += msize; - } - return 0; -} - -/* ----------------------------------------------------------------------------- - * wad_find_object(WadFrame *f) - * - * Given a stack frame. Try to locate the object file - * ----------------------------------------------------------------------------- */ - -void wad_find_object(WadFrame *f) { - if (f->segment) { - f->object = wad_object_load(f->segment->mappath); - } -} - -/* ----------------------------------------------------------------------------- - * wad_file_check(void *addr) - * - * Given an address, this function checks to see if it corresponds to a file - * we already mapped. - * ----------------------------------------------------------------------------- */ - -int -wad_file_check(void *addr) { - WadFile *f = wad_files; - while (f) { - if ((((char *) f->addr) <= ((char *) addr)) && - (((char *) addr) < (((char *) f->addr) + f->size))) { - return 1; - } - f = f->next; - } - return 0; -} diff --git a/Tools/WAD/Wad/return.c b/Tools/WAD/Wad/return.c deleted file mode 100644 index 909cba314..000000000 --- a/Tools/WAD/Wad/return.c +++ /dev/null @@ -1,69 +0,0 @@ -/* ----------------------------------------------------------------------------- - * return.c - * - * This file manages the set of return-points for the WAD signal handler. - * - * Author(s) : David Beazley (beazley@cs.uchicago.edu) - * - * Copyright (C) 2000. The University of Chicago. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * See the file COPYING for a complete copy of the LGPL. - * ----------------------------------------------------------------------------- */ - -#include "wad.h" - -static char cvs[] = "$Id$"; - -/* Maximum number of return points */ -#define WAD_NUMBER_RETURN 128 - -static WadReturnFunc return_points[WAD_NUMBER_RETURN]; -static int num_return = 0; - -void wad_set_return(const char *name, long value) { - WadReturnFunc *rp; - rp = &return_points[num_return]; - wad_strcpy(rp->name,name); - rp->value = value; - num_return++; - if (wad_debug_mode & DEBUG_RETURN) { - printf("wad: Setting return ('%s', %d)\n", name,value); - } -} - -void wad_set_returns(WadReturnFunc *rf) { - int i = 0; - while (strlen(rf[i].name)) { - wad_set_return(rf[i].name, rf[i].value); - i++; - } -} - -WadReturnFunc *wad_check_return(const char *name) { - int i; - if (!name) return 0; - for (i = 0; i < num_return; i++) { - if (strcmp(name,return_points[i].name) == 0) { - if (wad_debug_mode & DEBUG_RETURN) { - printf("wad: Found return ('%s', %d)\n", return_points[i].name, return_points[i].value); - } - return &return_points[i]; - } - } - return 0; -} - diff --git a/Tools/WAD/Wad/segment.c b/Tools/WAD/Wad/segment.c deleted file mode 100644 index ec4cf134f..000000000 --- a/Tools/WAD/Wad/segment.c +++ /dev/null @@ -1,227 +0,0 @@ -/* ----------------------------------------------------------------------------- - * segment.c - * - * This file provides access to the virtual memory map of a process - * including the location of the executable, data segments, shared - * libraries, and memory mapped regions. - * - * The primary purpose of this module is to collect this information - * and store it in a form that hides platform specific details (the - * WadSegment structure). - * - * Author(s) : David Beazley (beazley@cs.uchicago.edu) - * - * Copyright (C) 2000. The University of Chicago. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * See the file COPYING for a complete copy of the LGPL. - * ----------------------------------------------------------------------------- */ - -#include "wad.h" - -static char cvs[] = "$Id$"; - -/* Include the proper code for reading the segment map */ - -#ifdef WAD_SOLARIS - -/* This code is used to read the process virtual memory map on Solaris machines */ - -static int -segment_open() { - int f; - f = open("/proc/self/map", O_RDONLY); - return f; -} - -static int -segment_read(int fs, WadSegment *s) { - int dz; - int n; - prmap_t pmap; - - n = read(fs, &pmap, sizeof(prmap_t)); - if (n <= 0) return 0; - s->mapname = wad_strdup(pmap.pr_mapname); - s->mappath = (char *) wad_malloc(20+strlen(pmap.pr_mapname)); - wad_strcpy(s->mappath,"/proc/self/object/"); - strcat(s->mappath,pmap.pr_mapname); - s->vaddr = (char *) pmap.pr_vaddr; - - /* This is a solaris oddity. a.out section starts 1 page up, but - symbols are relative to a base of 0 */ - - if (strcmp(s->mapname,"a.out") == 0) s->base = 0; - else s->base = s->vaddr; - - s->size = pmap.pr_size; - s->offset = pmap.pr_offset; - return 1; -} - -#endif /* WAD_SOLARIS */ - -#ifdef WAD_LINUX -static char linux_firstsegment[1024]; -static int linux_first = 1; - -static int -segment_open() { - FILE *f; - f = fopen("/proc/self/maps", "r"); - linux_first =1; - return (int) f; -} - -static int -segment_read(int fd, WadSegment *s) -{ - char pbuffer[1024]; - char *c; - int len; - FILE *fs = (FILE *) fd; - c = fgets(pbuffer,1024,fs); - if (!c) return 0; - - pbuffer[strlen(pbuffer)-1] = 0; /* Chop off endline */ - - /* Break up the field into records */ - /* 0-8 : Starting address - 9-17 : Ending Address - 18 : r - 19 : w - 20 : x - 21 : p - 23-31 : Offset - 49- : Filename */ - - len = strlen(pbuffer); - pbuffer[8] = 0; - pbuffer[17] = 0; - pbuffer[31] = 0; - if (len >= 49) { - s->mapname = wad_strdup(pbuffer+49); - s->mappath = s->mapname; - } else { - s->mapname = ""; - s->mappath = s->mapname; - } - if (linux_first) { - wad_strcpy(linux_firstsegment, s->mappath); - linux_first = 0; - } - s->vaddr = (char *) strtoul(pbuffer,NULL,16); - s->size = strtoul(pbuffer+9,NULL,16) - (long) (s->vaddr); - s->offset = strtoul(pbuffer+23,NULL,16); - if (strcmp(linux_firstsegment, s->mappath) == 0) { - s->base = 0; - } else { - s->base = s->vaddr; - } - s++; - return 1; -} - -#endif /* WAD_LINUX */ - -static WadSegment *segments = 0; /* Linked list of segments */ - -/* ----------------------------------------------------------------------------- - * wad_segment_read() - * - * Read all of the memory segments into a linked list. Any previous segment - * map is simply lost. The only way to reclaim this memory is to call - * wad_release_memory(). - * ----------------------------------------------------------------------------- */ - -int -wad_segment_read() { - int fs; - int n; - WadSegment *s, *lasts; - - segments = 0; - lasts = 0; - fs = segment_open(); - - while (1) { - s = (WadSegment *) wad_malloc(sizeof(WadSegment)); - skip: - n = segment_read(fs,s); - if (n <= 0) break; - if (wad_file_check(s->vaddr)) goto skip; /* Skip files we already loaded */ - s->next = 0; - if (!lasts) { - segments = s; - lasts = s; - } else { - lasts->next = s; - lasts = s; - } - if (wad_debug_mode & DEBUG_SEGMENT) { - wad_printf("wad_segment: read : %08x-%08x, base=%x in %s\n", s->vaddr, ((char *) s->vaddr) + s->size, s->base, s->mappath); - } - } - close(fs); - return 0; -} - -/* ----------------------------------------------------------------------------- - * wad_segment_find() - * - * Try to find the virtual memory segment corresponding to a virtual address. - * If a segment is mapped to a file, this function actually returns the *first* - * segment that is mapped. This is because symbol relocations are always - * performed relative to the beginning of the file (so we need the base address) - * ----------------------------------------------------------------------------- */ - -WadSegment * -wad_segment_find(void *vaddr) { - WadSegment *ls; - WadSegment *s; - char *addr = (char *)vaddr; - - s = segments; - ls = segments; - while (s) { - if (strcmp(s->mapname,ls->mapname) || (!strlen(ls->mapname))) { - ls = s; /* First segment for a given name */ - } - if ((addr >= s->vaddr) && (addr < (s->vaddr + s->size))) { - if (wad_debug_mode & DEBUG_SEGMENT) { - wad_printf("wad_segment: %08x --> %08x-%08x in %s\n", vaddr, s->vaddr, ((char *) s->vaddr) + s->size, s->mappath); - } - return ls; - } - s = s->next; - } - return 0; -} - -/* ----------------------------------------------------------------------------- - * wad_segment_valid() - * - * Checks to see if a memory address is valid or not based on data in the - * segment map - * ----------------------------------------------------------------------------- */ - -int wad_segment_valid(void *vaddr) { - return wad_segment_find(vaddr) ? 1 : 0; -} - - - - diff --git a/Tools/WAD/Wad/signal.c b/Tools/WAD/Wad/signal.c deleted file mode 100644 index 36f89c3c7..000000000 --- a/Tools/WAD/Wad/signal.c +++ /dev/null @@ -1,520 +0,0 @@ -/* ----------------------------------------------------------------------------- - * signal.c - * - * WAD signal handler. - * - * Author(s) : David Beazley (beazley@cs.uchicago.edu) - * - * Copyright (C) 2000. The University of Chicago. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * See the file COPYING for a complete copy of the LGPL. - * ----------------------------------------------------------------------------- */ - -#include "wad.h" - -static char cvs[] = "$Id$"; - -extern void wad_stab_debug(); - -/* For some odd reason, certain linux distributions do not seem to define the - register constants in a way that is easily accessible to us. This is a hack */ - -#ifdef WAD_LINUX -#ifndef ESP -#define ESP 7 -#endif -#ifndef EBP -#define EBP 6 -#endif -#ifndef EIP -#define EIP 14 -#endif -#ifndef ESI -#define ESI 5 -#endif -#ifndef EDI -#define EDI 4 -#endif -#ifndef EBX -#define EBX 8 -#endif - -#endif - -/* Signal handling stack */ -#define STACK_SIZE 4*SIGSTKSZ -char wad_sig_stack[STACK_SIZE]; - -/* This variable is set if the signal handler thinks that the - heap has overflowed */ - -int wad_heap_overflow = 0; - -static void (*sig_callback)(int signo, WadFrame *data, char *ret) = 0; - -void wad_set_callback(void (*s)(int,WadFrame *,char *ret)) { - sig_callback = s; -} - -/* This bit of nastiness is used to make a non-local return from the - signal handler to a configurable location on the call stack. In a nutshell, - this works by repeatedly calling "restore" to roll back the - register windows and stack pointer. Then we fake a return value and - return to the caller as if the function had actually completed - normally. */ - -int wad_nlr_levels = 0; -static volatile int *volatile nlr_p = &wad_nlr_levels; -long wad_nlr_value = 0; -void (*wad_nlr_func)(void) = 0; - -/* Set the return value from another module */ -void wad_set_return_value(long value) { - wad_nlr_value = value; -} - -/* Set the return function */ -void wad_set_return_func(void(*f)(void)) { - wad_nlr_func = f; -} - -#ifdef WAD_SOLARIS -static void nonlocalret() { - long a; - - a = wad_nlr_value; - /* We never call this procedure as a function. This code - causes an immediate return if someone does this */ - - asm("jmp %i7 + 8"); - asm("restore"); - - /* This is the real entry point */ - /* asm(".globl _returnsignal");*/ - asm(".type _returnsignal,2"); - asm("_returnsignal:"); - - while (*nlr_p > 0) { - (*nlr_p)--; - asm("restore"); - } - - asm("sethi %hi(wad_nlr_value), %o0"); - asm("or %o0, %lo(wad_nlr_value), %o0"); - asm("ld [%o0], %i0"); - - /* If there is a non-local return function. We're going to go ahead - and transfer control to it */ - - if (wad_nlr_func) - (*wad_nlr_func)(); - - asm("jmp %i7 + 8"); - asm("restore"); - asm(".size _returnsignal,(.-_returnsignal)"); -} -#endif - -#ifdef WAD_LINUX - -/* Saved values of the machine registers */ - -long wad_saved_esi = 0; -long wad_saved_edi = 0; -long wad_saved_ebx = 0; - -static void nonlocalret() { - asm("_returnsignal:"); - while (*nlr_p > 0) { - (*nlr_p)--; - asm("leave"); - } - - if (wad_nlr_func) - (*wad_nlr_func)(); - - /* Restore the registers */ - asm("movl wad_saved_esi, %esi"); - asm("movl wad_saved_edi, %edi"); - asm("movl wad_saved_ebx, %ebx"); - asm("movl wad_nlr_value, %eax"); - asm("leave"); - asm("ret"); -} - -/* This function uses a heuristic to restore the callee-save registers on i386. - According to the Linux Assembly HOWTO, the %esi, %edi, %ebx, and %ebp registers - are callee-saved. All others are caller saved. To restore the callee-save - registers, we use the fact that the C compiler saves the callee-save registers - (if any) at the beginning of function execution. Therefore, we can scan the - instructions at the start of each function in the stack trace to try and find - where they are. - - The following heuristic is used: - - 1. Each function starts with a preamble like this which saves the %ebp - register: - - 55 89 e5 ---> push %ebp - mov %esp, %ebp - - 2. Next, space is allocated for local variables, using one of two schemes: - - 83 ec xx ---> Less than 256 bytes of local storage - ^^^ - length - - 81 ec xx xx xx xx --> More than 256 bytes of local storage - ^^^^^^^^^^^ - length - - 3. After this, a collection of 1-byte stack push op codes might appear - - 56 = pushl %esi - 57 = pushl %edi - 53 = pushl %ebx - - - Based on the size of local variable storage and the order in which - the %esi, %edi, and %ebx registers are pushed on the stack, we can - determine where in memory the registers are saved and restore them to - their proper values. -*/ - -void wad_restore_i386_registers(WadFrame *f, int nlevels) { - WadFrame *lastf = f; - int localsize = 0; - unsigned char *pc; - unsigned long *saved; - int i, j; - int pci; - for (i = 0; i <= nlevels; i++, f=f->next) { - - /* This gets the starting instruction for the stack frame */ - pc = (unsigned char *) f->sym_base; - /* printf("pc = %x, base = %x, %s\n", f->pc, f->sym_base, SYMBOL(f)); */ - if (!pc) continue; - - /* Look for the standard prologue 0x55 0x89 0xe5 */ - if ((pc[0] == 0x55) && (pc[1] == 0x89) && (pc[2] == 0xe5)) { - /* Determine the size */ - pci = 3; - if ((pc[3] == 0x83) && (pc[4] == 0xec)) { - /* printf("8-bit size\n");*/ - localsize = (int) pc[5]; - pci = 6; - } - if ((pc[3] == 0x81) && (pc[4] == 0xec)) { - /* printf("32-bit size\n"); */ - localsize = (int) *((long *) (pc+5)); - pci = 10; - } - saved = (long *) (f->fp - localsize - sizeof(long)); - /* printf("saved = %x, fp = %x\n", saved, f->fp); - printf("localsize = %d\n", localsize); - */ - for (j = 0; j < 3; j++, saved--, pci++) { - if (pc[pci] == 0x57) { - wad_saved_edi = *saved; - /* printf("restored edi = %x\n", wad_saved_edi); */ - } - else if (pc[pci] == 0x56) { - wad_saved_esi = *saved; - /* printf("restored esi = %x\n", wad_saved_esi); */ - } - else if (pc[pci] == 0x53) { - wad_saved_ebx = *saved; - /* printf("restored ebx = %x\n", wad_saved_ebx); */ - } - else break; - } - } - } -} - -#endif - -void wad_signalhandler(int sig, siginfo_t *si, void *vcontext) { - greg_t *pc; - greg_t *npc; - greg_t *sp; - greg_t *fp; -#ifdef WAD_LINUX - greg_t *esi; - greg_t *edi; - greg_t *ebx; -#endif - - unsigned long addr; - ucontext_t *context; - unsigned long p_sp; /* process stack pointer */ - unsigned long p_pc; /* Process program counter */ - unsigned long p_fp; /* Process frame pointer */ - int nlevels = 0; - int found = 0; - void _returnsignal(); - WadFrame *frame, *origframe; - char *framedata; - char *retname = 0; - unsigned long current_brk; - - /* Reset all of the signals while running WAD */ - wad_signal_clear(); - - wad_nlr_func = 0; - - context = (ucontext_t *) vcontext; - - wad_printf("WAD: Collecting debugging information...\n"); - - /* Read the segments */ - if (wad_segment_read() < 0) { - wad_printf("WAD: Unable to read segment map\n"); - return; - } - - if (wad_debug_mode & DEBUG_SIGNAL) { - wad_printf("WAD: siginfo = %x, context = %x\n", si, vcontext); - } - - current_brk = (long) sbrk(0); - - /* Get some information about the current context */ - -#ifdef WAD_SOLARIS - pc = &((context->uc_mcontext).gregs[REG_PC]); - npc = &((context->uc_mcontext).gregs[REG_nPC]); - sp = &((context->uc_mcontext).gregs[REG_SP]); -#endif - -#ifdef WAD_LINUX - sp = &((context->uc_mcontext).gregs[ESP]); /* Top of stack */ - fp = &((context->uc_mcontext).gregs[EBP]); /* Stack base - frame pointer */ - pc = &((context->uc_mcontext).gregs[EIP]); /* Current instruction */ - esi = &((context->uc_mcontext).gregs[ESI]); - edi = &((context->uc_mcontext).gregs[EDI]); - ebx = &((context->uc_mcontext).gregs[EBX]); - - wad_saved_esi = (unsigned long) (*esi); - wad_saved_edi = (unsigned long) (*edi); - wad_saved_ebx = (unsigned long) (*ebx); - - /* printf("esi = %x, edi = %x, ebx = %x\n", wad_saved_esi, wad_saved_edi, wad_saved_ebx); */ - - /* printf("&sp = %x, &pc = %x\n", sp, pc); */ -#endif - - /* Get some information out of the signal handler stack */ - addr = (unsigned long) si->si_addr; - - /* See if this might be a stack overflow */ - - p_pc = (unsigned long) (*pc); - p_sp = (unsigned long) (*sp); -#ifdef WAD_LINUX - p_fp = (unsigned long) (*fp); -#endif -#ifdef WAD_SOLARIS - p_fp = (unsigned long) *(((long *) p_sp) + 14); -#endif - - if (wad_debug_mode & DEBUG_SIGNAL) { - wad_printf("fault at address %x, pc = %x, sp = %x, fp = %x\n", addr, p_pc, p_sp, p_fp); - } - frame = wad_stack_trace(p_pc, p_sp, p_fp); - - if (!frame) { - /* We're really hosed. Not possible to generate a stack trace */ - wad_printf("WAD: Unable to generate stack trace.\n"); - wad_printf("WAD: Maybe the call stack has been corrupted by buffer overflow.\n"); - wad_signal_clear(); - return; - } - - { - WadFrame *f = frame; - while (f) { - wad_find_object(f); - wad_find_symbol(f); - f = f->next; - } - f = frame; - while (f) { - wad_find_debug(f); - wad_build_vars(f); - f = f->next; - } - } - wad_heap_overflow = 0; - if (sig == SIGSEGV) { - if (addr >= current_brk) wad_heap_overflow = 1; - } - - wad_stack_debug(frame); - - /* Generate debugging strings */ - wad_debug_make_strings(frame); - - wad_stab_debug(); - - /* Walk the exception frames and try to find a return point */ - origframe = frame; - while (frame) { - WadReturnFunc *wr = wad_check_return(frame->sym_name); - if (wr) { - found = 1; - wad_nlr_value = wr->value; - retname = wr->name; - } - if (found) { - frame->last = 1; /* Cut off top of the stack trace */ - break; - } - frame = frame->next; - nlevels++; - } - - - if (found) { - wad_nlr_levels = nlevels - 1; -#ifdef WAD_LINUX - wad_restore_i386_registers(origframe, wad_nlr_levels); -#endif - } else { - wad_nlr_levels = -1; - } - - wad_string_debug(); - wad_memory_debug(); - - /* Before we do anything with callbacks, we are going - to attempt to dump a wad-core */ - - { - int fd; - static int already = 0; - fd = open("wadtrace",O_WRONLY | O_CREAT | (already*O_APPEND) | ((already==0)*O_TRUNC),0666); - if (fd > 0) { - wad_dump_trace(fd,sig,origframe,retname); - close(fd); - already=1; - } - } - - if (sig_callback) { - (*sig_callback)(sig,origframe,retname); - } else { - /* No signal handler defined. Go invoke the default */ - - wad_default_callback(sig, origframe,retname); - } - - if (wad_debug_mode & DEBUG_HOLD) while(1); - - /* If we found a function to which we should return, we jump to - an alternative piece of code that unwinds the stack and - initiates a non-local return. */ - - if (wad_nlr_levels >= 0) { - *(pc) = (greg_t) _returnsignal; -#ifdef WAD_SOLARIS - *(npc) = *(pc) + 4; -#endif - if (!(wad_debug_mode & DEBUG_ONESHOT)) { - wad_signal_init(); - } - return; - } - exit(1); -} - - -/* ----------------------------------------------------------------------------- - * wad_signal_init() - * - * Resets the signal handler. - * ----------------------------------------------------------------------------- */ - -void wad_signal_init() { - struct sigaction newvec; - static stack_t sigstk; - static int initstack = 0; - - if (wad_debug_mode & DEBUG_INIT) { - wad_printf("WAD: Initializing signal handler.\n"); - } - /* This is buggy in Linux and threads. disabled by default */ - -#ifndef WAD_LINUX - - if (!initstack) { - /* Set up an alternative stack */ - - sigstk.ss_sp = (char *) wad_sig_stack; - sigstk.ss_size = STACK_SIZE; - sigstk.ss_flags = 0; - if (!(wad_debug_mode & DEBUG_NOSTACK)) { - if (sigaltstack(&sigstk, (stack_t*)0) < 0) { - perror("sigaltstack"); - } - } - initstack=1; - } -#endif - - sigemptyset(&newvec.sa_mask); - sigaddset(&newvec.sa_mask, SIGSEGV); - sigaddset(&newvec.sa_mask, SIGBUS); - sigaddset(&newvec.sa_mask, SIGABRT); - sigaddset(&newvec.sa_mask, SIGILL); - sigaddset(&newvec.sa_mask, SIGFPE); - newvec.sa_flags = SA_SIGINFO; - - if (wad_debug_mode & DEBUG_ONESHOT) { - newvec.sa_flags |= SA_RESETHAND; - } -#ifndef WAD_LINUX - if (!(wad_debug_mode & DEBUG_NOSTACK)) { - newvec.sa_flags |= SA_ONSTACK; - } -#endif - newvec.sa_sigaction = ((void (*)(int,siginfo_t *, void *)) wad_signalhandler); - if (sigaction(SIGSEGV, &newvec, NULL) < 0) goto werror; - if (sigaction(SIGBUS, &newvec, NULL) < 0) goto werror; - if (sigaction(SIGABRT, &newvec, NULL) < 0) goto werror; - if (sigaction(SIGFPE, &newvec, NULL) < 0) goto werror; - if (sigaction(SIGILL, &newvec, NULL) < 0) goto werror; - - return; - werror: - wad_printf("WAD: Couldn't install signal handler!\n"); -} - -/* ----------------------------------------------------------------------------- - * clear signals - * ----------------------------------------------------------------------------- */ - -void wad_signal_clear() { - signal(SIGSEGV, SIG_DFL); - signal(SIGBUS, SIG_DFL); - signal(SIGILL, SIG_DFL); - signal(SIGFPE, SIG_DFL); - signal(SIGABRT, SIG_DFL); -} - - - diff --git a/Tools/WAD/Wad/stab.c b/Tools/WAD/Wad/stab.c deleted file mode 100644 index 29626ae99..000000000 --- a/Tools/WAD/Wad/stab.c +++ /dev/null @@ -1,682 +0,0 @@ -/* ----------------------------------------------------------------------------- - * stab.c - * - * This file reads stabs data and looks for various properties of a - * given symbol. - * - * Author(s) : David Beazley (beazley@cs.uchicago.edu) - * - * Copyright (C) 2000. The University of Chicago. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * See the file COPYING for a complete copy of the LGPL. - * ----------------------------------------------------------------------------- */ - -#include "wad.h" - -static char cvs[] = "$Id$"; - -/* stabs data structure. This appears to be somewhat universal. */ -typedef struct Stab { - unsigned n_strx; /* index into file string table */ - unsigned char n_type; /* type flag (N_TEXT,..) */ - char n_other; /* used by N_SLINE stab */ - unsigned short n_desc; /* see stabs documentation */ - unsigned n_value; /* value of symbol (or sdb offset) */ -} Stab; - -/* stabs data types used by this module */ - -#define N_UNDF 0x0 /* undefined */ -#define N_FUN 0x24 /* function */ -#define N_OBJ 0x38 /* object file path */ -#define N_RSYM 0x40 /* Register symbol */ -#define N_SLINE 0x44 /* Source line */ -#define N_SO 0x64 /* Source file name */ -#define N_LSYM 0x80 /* Local symbol */ -#define N_PSYM 0xa0 /* Parameter */ -#define N_LBRAC 0xc0 /* Left brace */ -#define N_RBRAC 0xe0 /* Right brace */ - -/* ----------------------------------------------------------------------------- - * stabs type handler - * - * Type names are defined as N_LSYM types. We need to keep a hash table of - * logical type names and stabs type names. - * - * We also need to keep a hash table of stabs types. - * ----------------------------------------------------------------------------- */ - -typedef struct stabtype { - char *name; - char *value; - struct stabtype *next; - int visit; -} stabtype; - -#define HASH_SIZE 113 - -static int stab_type_init = 0; -static stabtype *lnames[HASH_SIZE]; /* Hash of local names */ -static stabtype *deadnames[HASH_SIZE]; /* Hash of dead names */ - -/* Initialize the hash table */ - -static void init_hash() { - int i; - stabtype *s, *sp = 0; - - for (i = 0; i < HASH_SIZE; i++) { - if (stab_type_init) { - /* Add stabs to dead list */ - s = lnames[i]; - sp = 0; - while (s) { - sp = s; - s = s->next; - } - if (sp) { - sp->next = deadnames[i]; - deadnames[i] = lnames[i]; - } - } - lnames[i] = 0; - } - stab_type_init = 1; -} - -static int thash(char *name) { - unsigned int h = 0; - int i; - for (i = 0; i < 8 && (*name); i++, name++) { - h = ((h << 7) + *name); - } - return (h % HASH_SIZE); -} - -/* Add a symbol to the hash */ - -static void type_add(char *name, char *value) { - int h; - stabtype *s; - char sc =0; - char *v; - char *vr; - char *split; - - if (!stab_type_init) { - init_hash(); - stab_type_init = 1; - } - - /* Split the "value" up into a type name and a value */ - - split = strchr(value,'='); - if (value[0] != '(') split = 0; - if (split) { - sc = *split; - v = value; - *split = 0; - vr = split+1; - } else { - v = value; - sc = 0; - vr = 0; - } - - h = thash(name); - s = lnames[h]; - while (s) { - if (strcmp(s->name,name) == 0) { - if (strcmp(s->value,v)) { - s->value = wad_string_lookup(v); - } - goto add_more; - } - s = s->next; - } - s = deadnames[h]; - if (!s) { - s = (stabtype *) wad_malloc(sizeof(stabtype)); - } else { - deadnames[h] = s->next; - } - s->name = wad_string_lookup(name); - s->value = wad_string_lookup(v); - s->next = lnames[h]; - s->visit = 0; - lnames[h] = s; - - /* Now take a look at the value. If it is contains other types, we might be able to define more stuff */ - add_more: - if (vr) { - /* There is a mapping to another type */ - type_add(v,vr); - } -} - -static -char *type_resolve(char *name) { - int h; - stabtype *s; - h = thash(name); - s = lnames[h]; - while(s) { - if (strcmp(s->name,name) == 0) { - if (!s->visit) { - char *c; - /* The visit flag is set so that we don't get in infinite loops */ - s->visit = 1; - c = type_resolve(s->value); - s->visit = 0; - return c; - } else { - return name; - } - } - s = s->next; - } - return name; -} - -/* This function tries to resolve base stabs types into a machine equivalent */ -static -int type_typecode(char *name) { - char *range; - - if (name[0] == '*') { - return WAD_TYPE_POINTER; - } - - range = strchr(name,';'); - if (!range) return WAD_TYPE_UNKNOWN; - range++; - - if (name[0] == 'r') { - /* GNU-style range specifiers */ - if ( - (strcmp(range,"0000000000000;0037777777777;") == 0) - ) { - return WAD_TYPE_UINT32; - } - if ( - (strcmp(range,"0020000000000;0017777777777;") == 0) - ) { - return WAD_TYPE_INT32; - } - if ( - (strcmp(range,"-32768;32767;") == 0) - ) { - return WAD_TYPE_INT16; - } - if ( - (strcmp(range,"0;65535;") == 0) - ) { - return WAD_TYPE_UINT16; - } - if ( - (strcmp(range,"0;127;") == 0) - ) { - return WAD_TYPE_CHAR; - } - if ( - (strcmp(range,"-128;127;") == 0) - ) { - return WAD_TYPE_INT8; - } - if ( - (strcmp(range,"0;255;") == 0) - ) { - return WAD_TYPE_UINT8; - } - if ( - (strcmp(range,"4;0;") == 0) - ) { - return WAD_TYPE_FLOAT; - } - if ( - (strcmp(range,"8;0;") == 0) - ) { - return WAD_TYPE_DOUBLE; - } - } - /* Traditional built-in types */ - if (strcmp(name,"bs4;0;32;") == 0) { - return WAD_TYPE_INT32; - } - if (strcmp(name,"bs2;0;16;") == 0) { - return WAD_TYPE_INT16; - } - if (strcmp(name,"bs1;0;8;") == 0) { - return WAD_TYPE_INT8; - } - if (strcmp(name,"bsc1;0;8;") == 0) { - return WAD_TYPE_CHAR; - } - if (strcmp(name,"bu4;0;32;") == 0) { - return WAD_TYPE_UINT32; - } - if (strcmp(name,"bu2;0;16;") == 0) { - return WAD_TYPE_UINT16; - } - if (strcmp(name,"bu1;0;8;") == 0) { - return WAD_TYPE_UINT8; - } - if (strcmp(name,"R1;4;") == 0) { - return WAD_TYPE_FLOAT; - } - if (strcmp(name,"R2;8;") == 0) { - return WAD_TYPE_DOUBLE; - } - return WAD_TYPE_UNKNOWN; -} - -static void types_print() { - stabtype *s; - int i; - for (i = 0; i < HASH_SIZE; i++) { - s = lnames[i]; - while (s) { - wad_printf("%20s %s\n", s->name, s->value); - s = s->next; - } - } -} - -void wad_stab_debug() { - /* types_print();*/ -} - -/* ----------------------------------------------------------------------------- - * match_stab_symbol() - * - * Match a stabs symbol name against a stab string. The stab string may contain - * extra information delimited by a colon which is not used in the comparsion. - * Returns 1 on match, 0 on mismatch. - * ----------------------------------------------------------------------------- */ - -static int -match_stab_symbol(char *symbol, char *stabtext, int slen) { - if (strcmp(symbol,stabtext) == 0) { - return 1; - } - if ((strncmp(symbol, stabtext, slen) == 0) && (*(stabtext+slen) == ':')) return 1; - return 0; -} - -static char * -stab_string_parm(char *str) { - return strchr(str,':'); -} - -/* ----------------------------------------------------------------------------- - * stab_symbol(Stab *s, char *stabstr) - * - * Process stab symbol specifier N_LSYM - * ----------------------------------------------------------------------------- */ - -static void -stab_symbol(Stab *s, char *stabstr) { - char *str; - char *pstr; - char name[1024]; - char value[65536]; - - str = stabstr+s->n_strx; - pstr = stab_string_parm(str); - if (!pstr) return; - - strncpy(name,str, pstr-str); - name[(int)(pstr-str)] = 0; - if ((pstr[1] == 't') || (pstr[1] == 'p') || (pstr[1] == 'r')) { - /* A stabs type definition */ - /* printf("stab lsym: other=%d, desc=%d, value=%d, str='%s'\n", s->n_other,s->n_desc,s->n_value, - stabstr+s->n_strx); */ - /* wad_printf("name = '%s', pstr='%s'\n", name, pstr+2); */ - wad_strcpy(value,pstr+2); - type_add(name,value); - } -} - - -/* ----------------------------------------------------------------------------- - * scan_function() - * - * Collect stabs data for a function definition. - * ----------------------------------------------------------------------------- */ - -static int -scan_function(Stab *s, char *stabstr, int ns, WadFrame *f) { - int i; - unsigned long offset; - int get_parms = 1; - int nbrace = 0; - - offset = f->pc - f->sym_base; - if (wad_debug_mode & DEBUG_STABS) { - wad_printf("---[ %s ] --------------\n", f->sym_name); - } - - for (i = 0; i < ns; i++,s++) { - if (wad_debug_mode & DEBUG_STABS) { - wad_printf(" %10d %10x %10d %10d %10d: '%s'\n", s->n_strx, s->n_type, s->n_other, s->n_desc, s->n_value, - stabstr+s->n_strx); - - } - - if ((s->n_type == N_UNDF) || (s->n_type == N_SO) || /* (s->n_type == N_FUN) || */ - (s->n_type == N_OBJ)) return i; - - if ((s->n_type == N_FUN) && !(strlen(stabstr+s->n_strx))) return 1; - - if (s->n_type == N_LBRAC) { - nbrace++; - get_parms = 0; - } - if (s->n_type == N_RBRAC) { - nbrace--; - if (nbrace <= 0) return i; - } - /* Local variable declaration */ - - if (s->n_type == N_LSYM) { - /* This might be a local variable definition */ - /* wad_printf("local: n_value = %d, offset = %d\n", s->n_value, offset);*/ - if (s->n_desc <= f->loc_line) - { - /* Okay. We can pay attention to it */ - char *pname; - char *c; - int len; - WadLocal *arg, *a; - pname = stabstr+s->n_strx; - c = strchr(pname,':'); - if (*(c+1) != '(') continue; - if (c) { - len = (c-pname); - } else { - len = strlen(pname); - } - /* printf("local\n"); */ - stab_symbol(s,stabstr); - a = f->debug_locals; - while (a) { - if ((strncmp(a->name,pname,len) == 0) && (strlen(a->name) == len)) { - /* We already saw this argument. Given a choice between a register and a stack - argument. We will choose the stack version */ - a->loc = PARM_STACK; - a->stack = s->n_value; - break; - } - a = a->next; - } - if (a) continue; /* We got an argument match. Just skip to the next stab */ - arg = (WadLocal *) wad_malloc(sizeof(WadLocal)); - { - char t = pname[len]; - pname[len] = 0; - arg->name = wad_string_lookup(pname); - pname[len] = t; - } - arg->loc = PARM_STACK; - arg->line = s->n_desc; - arg->stack = s->n_value; - arg->type = 0; - arg->next = 0; - { - char tname[128]; - char *t = tname; - - c+=1; - while ((*c) && (*c != '=')) { - *t++ = *c++; - } - *t = 0; - t = type_resolve(tname); - arg->type = type_typecode(t); - if (wad_debug_mode & DEBUG_STABS) { - wad_printf("type_resolve '%s' -> '%s' (%d)\n", tname, t, arg->type); - } - } - if (f->debug_locals) { - f->debug_lastlocal->next = arg; - f->debug_lastlocal = arg; - } else { - f->debug_locals = arg; - f->debug_lastlocal = arg; - f->debug_nlocals= 0; - } - f->debug_nlocals++; - } - } - - if (s->n_type == N_SLINE) { - get_parms = 0; - if (s->n_value <= offset) { - f->loc_line = s->n_desc; - } - } else if (((s->n_type == N_PSYM) || (s->n_type == N_RSYM)) && get_parms) { - /* Parameter counting */ - char *pname; - char *c; - int len; - WadLocal *arg; - pname = stabstr+s->n_strx; - c = strchr(pname,':'); - if (c) { - len = (c-pname); - } else { - len = strlen(pname); - } - /* Get type information */ - - stab_symbol(s,stabstr); - - /* Check if the argument was already used */ - /* In this case, the first stab simply identifies an argument. The second - one identifies its location for the debugger */ - - { - /* Need to do some fix up for linux here */ - WadLocal *a = f->debug_args; - while (a) { - if ((strncmp(a->name,pname,len) == 0) && (strlen(a->name) == len)) { - /* We already saw this argument. Given a choice between a register and a stack - argument. We will choose the stack version */ - - if (a->loc == PARM_STACK) { - break; - } - /* Go ahead and use the new argument */ - if (s->n_type == N_RSYM) { - a->loc = PARM_REGISTER; - a->reg = s->n_value; - } else { - a->loc = PARM_STACK; - a->stack = s->n_value; - } - break; - } - a = a->next; - } - if (a) continue; /* We got an argument match. Just skip to the next stab */ - } - - arg = (WadLocal *) wad_malloc(sizeof(WadLocal)); - { - char t = pname[len]; - pname[len] = 0; - arg->name = wad_string_lookup(pname); - pname[len] = t; - } - if (s->n_type == N_RSYM) { - arg->loc = PARM_REGISTER; - arg->reg = s->n_value; - arg->stack = 0; - } else { - arg->loc = PARM_STACK; - arg->line = s->n_desc; - arg->stack = s->n_value; - } - arg->type = 0; - arg->next = 0; - { - char tname[128]; - char *t = tname; - - c+=2; - while ((*c) && (*c != '=')) { - *t++ = *c++; - } - *t = 0; - t = type_resolve(tname); - arg->type = type_typecode(t); - if (wad_debug_mode & DEBUG_STABS) { - wad_printf("type_resolve '%s' -> '%s' (%d)\n", tname, t, arg->type); - } - } - if (f->debug_args) { - f->debug_lastarg->next = arg; - f->debug_lastarg = arg; - } else { - f->debug_args = arg; - f->debug_lastarg = arg; - f->debug_nargs= 0; - } - f->debug_nargs++; - } - } - return i; -} - -/* Given a stabs data segment (obtained somehow), this function tries to - collect as much information as it can about a given symbol. - - s points to the stab data. stabstr points to the stab string section, - ns is the size of the stab section, symbol is the item of interest, - and offset is the offset in the object file of the symbol - - Note: this function may recurse upon itself if there are multiple - stabs sections. - - Note: If a symbol corresponds to a local symbol, it's entirely possible - that the only stabs data we will find is a file specifier. In this case, - */ - -int -wad_search_stab(void *sp, int size, char *stabstr, WadFrame *f) { - Stab *s; - int ns; - int i; - int found = 0; - - char *file, *lastfile = 0; - - char srcfile[MAX_PATH]; - char objfile[MAX_PATH]; - - /* It appears to be necessary to clear the types table on each new stabs section */ - - init_hash(); - - if (!f->sym_name) return 0; - - s = (Stab *) sp; /* Stabs data */ - ns = size/sizeof(Stab); /* number of stabs */ - - srcfile[0] = 0; - objfile[0] = 0; - - for (i = 0; i < ns; i++, s++) { - if (wad_debug_mode & DEBUG_STABS) { - /* wad_printf(" %10d %10x %10d %10d %10d: '%s'\n", s->n_strx, s->n_type, s->n_other, s->n_desc, s->n_value, - stabstr+s->n_strx); */ - - } - if (s->n_type == N_LSYM) { - stab_symbol(s,stabstr); - continue; - } - if ((s->n_type == N_UNDF)) { /* && (s->n_desc >= 0)) { */ - /* New stabs section. We need to be a little careful here. Do a recursive - search of the subsection. */ - - if (wad_search_stab(s+1,s->n_desc*sizeof(Stab), stabstr, f)) { - return 1; - } - - /* On solaris, each stabs section seems to increment the stab string pointer. On Linux, - the linker seems to do a certain amount of optimization that results in a single - string table. */ - -#ifdef WAD_SOLARIS - stabstr += s->n_value; /* Update the string table location*/ -#endif - i += s->n_desc; - s += s->n_desc; - objfile[0] = 0; - srcfile[0] = 0; - continue; - } else if (s->n_type == N_SO) { - /* Source file specification */ - /* Look for directory */ - file = stabstr+s->n_strx; - if (strlen(file) && (file[strlen(file)-1] == '/')) { - wad_strcpy(srcfile,file); - } else { - wad_strcat(srcfile,file); - } - objfile[0] = 0; - /* If we have a file match, we might be looking for a local symbol. If so, - we'll go ahead and set the srcfile field of the frame */ - - /* We're going to check for a file match. Maybe we're looking for a local symbol */ - if (f->sym_file && strcmp(f->sym_file,file) == 0) { - found = 1; - } - lastfile = file; - } else if (s->n_type == N_OBJ) { - /* Object file specifier */ - if (objfile[0]) { - wad_strcat(objfile,"/"); - } - wad_strcat(objfile,stabstr+s->n_strx); - } else if (s->n_type == N_FUN) { - if (match_stab_symbol(f->sym_name, stabstr+s->n_strx, f->sym_nlen)) { - if (!f->sym_file || (strcmp(f->sym_file,lastfile) == 0)) { - int n; - /* Go find debugging information for the function */ - n = scan_function(s+1, stabstr, ns -i - 1, f); - f->loc_srcfile = wad_string_lookup(srcfile); - f->loc_objfile = wad_string_lookup(objfile); - return 1; - } - } - } - } - /* If found, but no other debugging information was filled in, go ahead and copy the - source and objfile information */ - - if ((found) && (!f->debug_check)) { - f->loc_srcfile = wad_string_lookup(srcfile); - f->loc_objfile = wad_string_lookup(objfile); - } - return found; -} - - - - diff --git a/Tools/WAD/Wad/stack.c b/Tools/WAD/Wad/stack.c deleted file mode 100644 index 68a55a77f..000000000 --- a/Tools/WAD/Wad/stack.c +++ /dev/null @@ -1,309 +0,0 @@ -/* ----------------------------------------------------------------------------- - * stack.c - * - * This file unwinds the C call stack and creates a list of stack frames. - * - * Author(s) : David Beazley (beazley@cs.uchicago.edu) - * - * Copyright (C) 2000. The University of Chicago. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * See the file COPYING for a complete copy of the LGPL. - * ----------------------------------------------------------------------------- */ - -#include "wad.h" - -static char cvs[] = "$Id$"; - -/* ----------------------------------------------------------------------------- - * new_frame() - * - * Create a new stack frame object and initialize all of the fields. - * ----------------------------------------------------------------------------- */ - -static WadFrame * -new_frame() { - WadFrame *f; - f = (WadFrame *) wad_malloc(sizeof(WadFrame)); - f->frameno = 0; - f->segment = 0; - f->object = 0; - f->pc = 0; - f->sp = 0; - f->sp = 0; - f->stack = 0; - f->stack_size = 0; - - f->sym_name = 0; - f->sym_nlen = 0; - f->sym_file = 0; - f->sym_base = 0; - f->sym_size = 0; - f->sym_type = 0; - f->sym_bind = 0; - - f->loc_objfile = 0; - f->loc_srcfile = 0; - f->loc_line = 0; - - f->debug_check = 0; - f->debug_nargs = -1; - f->debug_args = 0; - f->debug_lastarg = 0; - f->debug_nlocals = 0; - f->debug_locals = 0; - f->debug_lastlocal = 0; - f->debug_str = 0; - f->debug_srcstr = 0; - - f->last = 0; - f->next = 0; - f->prev = 0; - return f; -} - -/* ----------------------------------------------------------------------------- - * stack_unwind() - * - * This function performs a single level of stack unwinding given the stack pointer - * frame pointer and program counter. Validations are made to make sure the stack - * and frame pointers are in valid memory. Updates the values of the sp, pc, and fp - * in-place. Returns a stack frame object on success, 0 if memory is invalid - * or the end of the stack has been reached. - * ----------------------------------------------------------------------------- */ - -static WadFrame * -stack_unwind(unsigned long *pc, unsigned long *sp, unsigned long *fp) { - WadSegment *sp_seg, *fp_seg; - WadFrame *f; - unsigned long fake_fp; - - if (wad_debug_mode & DEBUG_UNWIND) { - wad_printf("::: stack unwind : pc = %x, sp = %x, fp = %x\n", *pc, *sp, *fp); - } - - /* Verify that the sp and fp are in mapped memory */ - sp_seg = wad_segment_find((void *) *sp); - fp_seg = wad_segment_find((void *) *fp); - - /* Make sure the stack pointer is in memory */ - if (!sp_seg) { - return 0; - } - - if (!fp_seg) { - /* Hmmm. If no frame pointer, we must be off the top of the call stack */ - fake_fp = (unsigned long) (sp_seg->vaddr + sp_seg->size); - fp_seg = sp_seg; - } else { - fake_fp = *fp; - } - if (sp_seg != fp_seg) { - /* Whoa. Stack pointer and frame pointer are in different memory segments. */ - wad_printf("WAD: Warning. Stack pointer and frame pointer are in different regions.\n"); - return 0; - } - - /* Check to see if the PC is valid */ - if (!wad_segment_valid((void *) *pc)) { - return 0; - } - - f = new_frame(); - f->pc = *pc; - f->sp = *sp; - f->fp = fake_fp; - f->segment = wad_segment_find((void *) *pc); - f->stack_size = fake_fp - *sp; - /* Make a copy of the call stack */ - f->stack = (char *) wad_malloc(f->stack_size); - wad_memcpy(f->stack,(void *) *sp, f->stack_size); - - /* Update the sp, fp, and pc */ - -#ifdef WAD_SOLARIS - *pc = *((unsigned long *) *sp+15); /* %i7 - Return address */ - *sp = *((unsigned long *) *sp+14); /* %i6 - frame pointer */ - if (wad_segment_valid((void *) *sp)) { - *fp = *((unsigned long *) *sp+14); - } else { - *fp = 0; - } -#endif - -#ifdef WAD_LINUX - if (wad_segment_valid((void *) ((unsigned long *) *fp+1))) { - *pc = *((unsigned long *) *fp+1); - *sp = *fp; - } else { - *sp = 0; - } - if (wad_segment_valid((void *) ((unsigned long *) *fp))) { - *fp = *((unsigned long *) *fp); - } else { - *fp = 0; - } -#endif - return f; -} - -/* ----------------------------------------------------------------------------- - * wad_stack_trace() - * - * Create a stack trace of the process. Returns a linked list of stack frames - * with a limited about debugging information and other details. - * ----------------------------------------------------------------------------- */ - -WadFrame * -wad_stack_trace(unsigned long pc, unsigned long sp, unsigned long fp) { - WadFrame *firstframe=0, *lastframe=0, *frame=0; - unsigned long p_pc; - unsigned long p_sp; - unsigned long p_fp; - int n = 0; - - /* Try to do a stack traceback */ - - p_pc = pc; - p_sp = sp; - p_fp = fp; - - while ((frame = stack_unwind(&p_pc, &p_sp, &p_fp))) { - /* Got a frame successfully */ - frame->frameno = n; - if (lastframe) { - lastframe->next = frame; - frame->prev = lastframe; - lastframe = frame; - } else { - firstframe = frame; - lastframe = frame; - } - n++; - } - if (lastframe) - lastframe->last = 1; - return firstframe; -} - -/* ----------------------------------------------------------------------------- - * wad_stack_debug() - * - * Make a dump of a stack trace - * ----------------------------------------------------------------------------- */ - -void wad_stack_debug(WadFrame *frame) { - if (wad_debug_mode & DEBUG_STACK) { - /* Walk the exception frames and try to find a return point */ - while (frame) { - /* Print out detailed stack trace information */ - wad_printf("::: Stack frame - 0x%08x :::\n", frame); - wad_printf(" pc = %x\n", frame->pc); - wad_printf(" sp = %x\n", frame->sp); - wad_printf(" fp = %x\n", frame->fp); - wad_printf(" stack = %x\n", frame->stack); - wad_printf(" size = %x\n", frame->stack_size); - wad_printf(" segment = %x (%s)\n", frame->segment, frame->segment ? frame->segment->mappath : "?"); - wad_printf(" object = %x (%s)\n", frame->object, frame->object ? frame->object->path : "?"); - - if (frame->sym_name) { - wad_printf(" sym_name = %s\n", frame->sym_name); - wad_printf(" sym_base = %x\n", frame->sym_base); - wad_printf(" sym_size = %x\n", frame->sym_size); - wad_printf(" sym_bind = %x\n", frame->sym_bind); - wad_printf(" sym_file = %s\n", frame->sym_file ? frame->sym_file : ""); - } - - if (frame->loc_srcfile) { - wad_printf(" loc_srcfile = %s\n", frame->loc_srcfile); - } - - if (frame->loc_objfile) { - wad_printf(" loc_objfile = %s\n", frame->loc_objfile); - } - wad_printf(" loc_line = %d\n", frame->loc_line); - - - wad_printf(" debug_nargs = %d\n", frame->debug_nargs); - if (frame->debug_args) { - int i = 0; - WadLocal *p = frame->debug_args; - wad_printf(" debug_args = [ \n"); - while (p) { - wad_printf(" arg[%d] : name = '%s', loc = %d, type = %d, stack = %d, reg = %d, line=%d, ptr=%x(%d)\n", i, p->name, p->loc, p->type, p->stack,p->reg,p->line,p->ptr,p->size); - p = p->next; - } - } - wad_printf(" ]\n"); - - wad_printf(" debug_nlocal = %d\n", frame->debug_nlocals); - if (frame->debug_locals) { - int i = 0; - WadLocal *p = frame->debug_locals; - wad_printf(" debug_locals = [ \n"); - while (p) { - wad_printf(" loc[%d] : name = '%s', loc = %d, type = %d, stack = %d, reg = %d, line=%d, ptr=%x(%d)\n", i, p->name, p->loc, p->type, p->stack,p->reg,p->line,p->ptr,p->size); - p = p->next; - } - } - wad_printf(" ]\n"); - - frame = frame->next; - } - } -} - - -/* ----------------------------------------------------------------------------- - * wad_steal_outarg() - * - * Steal an output argument - * ----------------------------------------------------------------------------- */ - -long -wad_steal_outarg(WadFrame *f, char *symbol, int argno, int *error) { - long *regs; - WadFrame *lastf = 0; - - *error = 0; - /* Start searching */ - while (f) { - if (f->sym_name && (strcmp(f->sym_name,symbol) == 0)) { - /* Got a match */ - if (lastf) { -#ifdef WAD_SOLARIS - regs = (long *) lastf->stack; - return regs[8+argno]; -#endif -#ifdef WAD_LINUX - regs = (long *) f->stack; - return regs[argno+2]; -#endif - } - } - lastf = f; - f = f->next; - } - *error = -1; - return 0; -} - - - - - - - diff --git a/Tools/WAD/Wad/string.c b/Tools/WAD/Wad/string.c deleted file mode 100644 index 1a15878ee..000000000 --- a/Tools/WAD/Wad/string.c +++ /dev/null @@ -1,131 +0,0 @@ -/* ----------------------------------------------------------------------------- - * string.c - * - * This file provides support for string storage in WAD. Since strings are - * used frequently in WAD, this file implements string interning and - * some lookup functions that can be used to return a previously stored - * string rather than making a new copy. - * - * Author(s) : David Beazley (beazley@cs.uchicago.edu) - * - * Copyright (C) 2000. The University of Chicago. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * See the file COPYING for a complete copy of the LGPL. - * ----------------------------------------------------------------------------- */ - -#include "wad.h" - -static char cvs[] = "$Id$"; - -/* Hash table containing stab strings and such */ -typedef struct stringtype { - char *str; - struct stringtype *next; -} stringtype; - -#define STRING_HASH_SIZE 1013 - -static stringtype *strings[STRING_HASH_SIZE]; -static int strings_init = 0; - -static int shash(char *name) { - unsigned int h = 0; - char *c; - int i; - c = name; - for (i = 0; (i < 16) && (*c); i++, c++) { - h = ((h^~i) << 6) + *c; - } - return h % STRING_HASH_SIZE; -} - -char * -wad_string_lookup(char *s) { - int h; - int i; - stringtype *st; - - if (!strings_init) { - for (i = 0; i < STRING_HASH_SIZE; i++) { - strings[i] = 0; - } - strings_init = 1; - } - - h = shash(s); - st = strings[h]; - while (st) { - if (strcmp(st->str,s) == 0) return st->str; - st = st->next; - } - - /* Not found. Add the string to the hash table */ - st = (stringtype *) wad_malloc(sizeof(stringtype)); - st->str = wad_strdup(s); - st->next = strings[h]; - strings[h] = st; - return st->str; -} - -void wad_string_debug() { - if (wad_debug_mode & DEBUG_STRING) { - int maxdepth = 0; - int total = 0; - int stringlen = 0; - int i; - - for (i = 0; i < STRING_HASH_SIZE; i++) { - stringtype *s; - int c = 0; - s = strings[i]; - while (s) { - c++; - stringlen += strlen(s->str); - s = s->next; - } - /* wad_printf("WAD: stringhash[%d] = %d\n", i, c);*/ - if (c > maxdepth) maxdepth = c; - total += c; - } - wad_printf("WAD: nstrings = %d (%d bytes)\n", total, stringlen + total*sizeof(stringtype)); - wad_printf("WAD: maxdepth = %d\n", maxdepth); - } -} - -/* Our own string copy */ -char *wad_strcpy(char *t, const char *s) { - if (s) - for (; *s; s++, t++) *t = *s; - *t = 0; - return t; -} - -char * -wad_strcat(char *t, const char *s) { - while (*t) t++; - return wad_strcpy(t,s); -} - -int -wad_strlen(const char *s) { - int count = 0; - while (*(s++)) count++; - return count; -} - - - diff --git a/Tools/WAD/Wad/vars.c b/Tools/WAD/Wad/vars.c deleted file mode 100644 index b22f71758..000000000 --- a/Tools/WAD/Wad/vars.c +++ /dev/null @@ -1,271 +0,0 @@ -/* ----------------------------------------------------------------------------- - * vars.c - * - * This file examines the stack trace and tries to make some sense out of - * collected debugging information. This includes locating the data on - * the stack and/or registers. - * - * This feature is detached from the debugging info collector to make - * it independent of debugging formats. - * - * Author(s) : David Beazley (beazley@cs.uchicago.edu) - * - * Copyright (C) 2000. The University of Chicago. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * See the file COPYING for a complete copy of the LGPL. - * ----------------------------------------------------------------------------- */ - -#include "wad.h" - -static char cvs[] = "$Id$"; - -/* ----------------------------------------------------------------------------- - * wad_build_vars() - * - * Build variable information for a single stack frame - * ----------------------------------------------------------------------------- */ - -void wad_build_vars(WadFrame *f) { - char *stack = 0; - char *nstack = 0; - char *pstack = 0; - WadLocal *loc; - int n; - - stack = (char *) f->stack; - if (f->next) { - nstack = (char *) f->next->stack; - } - if (f->prev) { - pstack = (char *) f->prev->stack; - } - - for (n = 0; n < 2; n++) { - if (n == 0) loc = f->debug_args; - else loc = f->debug_locals; - - while (loc) { - loc->ptr = 0; - if (loc->loc == PARM_STACK) { - if ((loc->stack >= 0) && (nstack)) { - loc->ptr = (void *) (nstack + loc->stack); - } else if (loc->stack < 0) { - loc->ptr = (void *) (stack + f->stack_size + loc->stack); - } - loc->size = sizeof(long); - } - if (loc->loc == PARM_REGISTER) { - /* Parameter is located in a register */ -#ifdef WAD_SOLARIS - if ((loc->reg >= 24) && (loc->reg < 32)) { - /* Value is located in the %in registers. */ - loc->ptr = (void *) (stack + (loc->reg - 16)*sizeof(int)); - loc->size = sizeof(int); - } else if ((loc->reg >= 8) && (loc->reg < 16)) { - - /* Value is located in the %on registers */ - if (nstack) { - loc->ptr = (void *) (stack + (loc->reg)*sizeof(int)); - loc->size = sizeof(int); - } - } else if ((loc->reg >= 16) && (loc->reg < 24)) { - /* Value has been placed in the %ln registers */ - loc->ptr = (void *) (stack + (loc->reg - 16)*sizeof(int)); - loc->size = sizeof(int); - } -#endif - } - loc = loc->next; - } - } -} - -/* This function creates a formatted integer given a pointer, size, and sign flag */ -static -char *wad_format_int(char *ptr, int nbytes, int sgn) { - static char fmt[128]; - unsigned char *s; - int incr; - unsigned long value = 0; - int i; - -#ifdef WAD_LITTLE_ENDIAN - s = (unsigned char *) (ptr + nbytes - 1); - incr = -1; -#else - s = (unsigned char *) (ptr); - incr = +1; -#endif - for (i = 0; i < nbytes; i++, s += incr) { - value = (value << 8) + *s; - } - if (sgn) { - return wad_format_signed((long) value,-1); - } else { - return wad_format_unsigned((unsigned long) value, -1); - } - return fmt; -} - -/* Try to make a formatted version of a local */ -char *wad_format_var(WadLocal *l) { - static char hexdigits[] = "0123456789abcdef"; - static char buffer[1024]; - double dval; - float fval; - - buffer[0] = 0; - - switch(l->type) { - case WAD_TYPE_INT32: - wad_strcpy(buffer,wad_format_int(l->ptr,4,1)); - break; - case WAD_TYPE_UINT32: - wad_strcpy(buffer,wad_format_int(l->ptr,4,0)); - break; - case WAD_TYPE_INT16: - wad_strcpy(buffer,wad_format_int(l->ptr,2,1)); - break; - case WAD_TYPE_UINT16: - wad_strcpy(buffer,wad_format_int(l->ptr,2,0)); - break; - case WAD_TYPE_INT8: - wad_strcpy(buffer,wad_format_int(l->ptr,1,1)); - break; - case WAD_TYPE_UINT8: - wad_strcpy(buffer,wad_format_int(l->ptr,1,0)); - break; - case WAD_TYPE_CHAR: - buffer[0] = '\''; - buffer[1] = *((char *) l->ptr); - buffer[2] = '\''; - buffer[3] = 0; - break; - case WAD_TYPE_FLOAT: - wad_memcpy(&fval,l->ptr,sizeof(float)); - sprintf(buffer,"%g",fval); - break; - case WAD_TYPE_DOUBLE: - wad_memcpy(&dval,l->ptr,sizeof(double)); - sprintf(buffer,"%g",dval); - break; - case WAD_TYPE_UNKNOWN: - case WAD_TYPE_POINTER: - default: - /* Hmmm. Unknown data type. We'll just treat it as a word */ - if (l->ptr) { - int incr,i; - int b; - int leading = 1; - char *c; - char *ptr; - -#ifdef WAD_LITTLE_ENDIAN - ptr = ((char *) l->ptr) + 3; - incr = -1; -#else - ptr = (char *) l->ptr; - incr =1 ; -#endif - wad_strcat(buffer,"0x"); - c = buffer+2; - for (i = 0; i < sizeof(void *); i++) { - b = (int) *ptr; - if (!leading || (b)) { - if (!leading || (b & 0xf0)) - *(c++) = hexdigits[(b & 0xf0) >> 4]; - *(c++) = hexdigits[(b & 0xf)]; - leading = 0; - } - ptr += incr; - } - if (leading) - *(c++) = '0'; - - *c = 0; - } - } - return buffer; -} - -/* Convert a wad local variable to a long */ -long wad_local_as_long(WadLocal *loc) { - long value = 0; - int32 i32; - int16 i16; - int8 i8; - uint32 u32; - uint16 u16; - uint8 u8; - - switch(loc->type) { - case WAD_TYPE_INT32: - wad_memcpy(&i32,loc->ptr,4); - value = (long) i32; - break; - case WAD_TYPE_UINT32: - wad_memcpy(&u32,loc->ptr,4); - value = (long) u32; - break; - case WAD_TYPE_INT16: - wad_memcpy(&i16,loc->ptr,2); - value = (long) i16; - break; - case WAD_TYPE_UINT16: - wad_memcpy(&u16,loc->ptr,2); - value = (long) u16; - break; - case WAD_TYPE_INT8: - case WAD_TYPE_CHAR: - wad_memcpy(&i8, loc->ptr,1); - value = (long) i8; - break; - case WAD_TYPE_UINT8: - wad_memcpy(&u8, loc->ptr,1); - value = (long) u8; - break; - default: - wad_memcpy(&u32,loc->ptr,4); - value = (long) u32; - } - return value; -} - -/* Convert a wad local variable to a long */ -double wad_local_as_double(WadLocal *loc) { - double value = 0; - float fval; - - switch(loc->type) { - case WAD_TYPE_DOUBLE: - wad_memcpy(&value,loc->ptr,8); - break; - case WAD_TYPE_FLOAT: - wad_memcpy(&fval,loc->ptr,4); - value = (double) fval; - break; - default: - value = 0; - } - return value; -} - - - - - - diff --git a/Tools/WAD/Wad/wadhandler.pl b/Tools/WAD/Wad/wadhandler.pl deleted file mode 100644 index e29240b69..000000000 --- a/Tools/WAD/Wad/wadhandler.pl +++ /dev/null @@ -1,36 +0,0 @@ -package libwadpl; -sub wad_handler_traceback { - package DB; - my $es = ""; - ($pack,$file,$line) = caller(1); - - for ($i = 2; ($p,$f,$l,$s,$h,$w,$e,$r) = caller($i); $i++) { - @a = (); - for $arg (@args) { - $_ = "$arg"; - s/([\'\\])/\\$1/g; - s/([^\0]*)/'$1'/ - unless /^(?: -?[\d.]+ | \*[\w:]* )$/x; - s/([\200-\377])/sprintf("M-%c",ord($1)&0177)/eg; - s/([\0-\37\177])/sprintf("^%c",ord($1)^64)/eg; - push(@a, $_); - } - $w = $w ? '@ = ' : '$ = '; - $a = $h ? '(' . join(', ', @a) . ')' : ''; - $e =~ s/\n\s*\;\s*\Z// if $e; - $e =~ s/[\\\']/\\$1/g if $e; - if ($r) { - $s = "require '$e'"; - } elsif (defined $r) { - $s = "eval '$e'"; - } elsif ($s eq '(eval)') { - $s = "eval {...}"; - } - $f = "file `$f'" unless $f eq '-e'; - $mess = "$w$s$a called from $f line $l\n"; - $es = $mess . $es; - - } - $es = "Signal at $file line $line\n" . $es; - return $es; -} diff --git a/Tools/WAD/Wad/wadpl.cxx b/Tools/WAD/Wad/wadpl.cxx deleted file mode 100644 index 25ca5bb74..000000000 --- a/Tools/WAD/Wad/wadpl.cxx +++ /dev/null @@ -1,176 +0,0 @@ -/* ----------------------------------------------------------------------------- - * wadpl.cxx - * - * Dynamically loadable module for Perl. - * - * Author(s) : David Beazley (beazley@cs.uchicago.edu) - * - * Copyright (C) 2000. The University of Chicago - * See the file LICENSE for information on usage and redistribution. - * ----------------------------------------------------------------------------- */ - -#ifdef __cplusplus -extern "C" { -#endif -#include "EXTERN.h" -#include "perl.h" -#include "XSUB.h" - -#include "wad.h" -#ifdef __cplusplus -} -#endif - -#include - -#include "wad_perl_handler.c" - -/* Error message returned to perl */ - -static char message[65536]; -static int global_signo = 0; - -static void returnfunc(void) { - SV *s; - s = perl_eval_pv((char*)"libwadpl::wad_handler_traceback(0)", 0); - croak("%s\n%s",SvPV(s,PL_na),message); - return; -} - -/* Handler function */ -static void handler(int signo, WadFrame *frame, char *ret) { - - static char temp[1024]; - int len = 0; - char *name; - char *fd; - WadFrame *f; - WadFrame *fline = 0; - int err; - char *type; - - if (!ret) { - wad_default_callback(signo, frame, ret); - return; - } - - - switch(signo) { - case SIGSEGV: - type = (char*)"Segmentation fault."; - break; - case SIGBUS: - type = (char*)"Bus error."; - break; - case SIGABRT: - type = (char*)"Abort."; - break; - case SIGFPE: - type = (char*)"Math."; - default: - break; - } - strcpy(message,type); - strcat(message,"\n[ C stack trace ]\n\n"); - fd = (char *) frame; - f = (WadFrame *) fd; - - /* Find the last exception frame */ - while (!f->last) { - fd = fd + f->size; - f = (WadFrame *) fd; - } - /* Now work backwards */ - fd = fd - f->lastsize; - f = (WadFrame *) fd; - while (1) { - sprintf(temp,"#%-3d 0x%08x in ", f->frameno, f->pc); - strcat(message,temp); - strcat(message,*(fd + f->sym_off) ? fd+f->sym_off : "?"); - strcat(message,"()"); - if (strlen(SRCFILE(f))) { - strcat(message," in '"); - strcat(message, wad_strip_dir(SRCFILE(f))); - strcat(message,"'"); - if (f->line_number > 0) { - sprintf(temp,", line %d", f->line_number); - strcat(message,temp); - fline = f; - } - } else { - if (strlen(fd+f->obj_off)) { - strcat(message," from '"); - strcat(message, wad_strip_dir(OBJFILE(f))); - strcat(message,"'"); - } - } - strcat(message,"\n"); - if (!f->lastsize) break; - fd = fd - f->lastsize; - f = (WadFrame *) fd; - } - if (fline) { - int first; - int last; - char *line, *c; - int i; - first = fline->line_number - 2; - last = fline->line_number + 2; - if (first < 1) first = 1; - - line = wad_load_source(SRCFILE(fline),first); - if (line) { - strcat(message,"\n"); - strcat(message, SRCFILE(fline)); - sprintf(temp,", line %d\n\n", fline->line_number); - strcat(message, temp); - for (i = first; i <= last; i++) { - if (i == fline->line_number) strcat(message," => "); - else strcat(message," "); - c = strchr(line,'\n'); - if (c) { - *c = 0; - strcat(message,line); - strcat(message,"\n"); - *c = '\n'; - } else { - strcat(message,line); - strcat(message,"\n"); - break; - } - line = c+1; - } - wad_release_source(); - strcat(message,"\n"); - } - } - wad_set_return_func(returnfunc); - wad_release_trace(); -} - -static void perlwadinit() { - printf("WAD Enabled\n"); - wad_init(); - wad_set_callback(handler); - wad_set_return("Perl_pp_entersub", 0); - perl_eval_pv(wad_perl_handler, 0); -} - -/* This hack is used to auto-initialize wad regardless of whether we are - used as an imported module or as a link-library for another module */ - -class wadinitializer { -public: - wadinitializer() { - perlwadinit(); - } -}; - -static wadinitializer wi; - -extern "C" -XS(boot_libwadpl) { - dXSARGS; - ST(0) = &PL_sv_yes; - XSRETURN(1); -} diff --git a/Tools/WAD/configure.in b/Tools/WAD/configure.in deleted file mode 100644 index 1a8dcdbed..000000000 --- a/Tools/WAD/configure.in +++ /dev/null @@ -1,365 +0,0 @@ -dnl Process this file with autoconf to produce a configure script. - -dnl NOTES: -dnl * As of 1.34, we no longer use and test for "nope" to indicate -dnl an empty variable. Instead, we use `VAR=' (set the variable -dnl to nothing) and `test -z "$VAR"' or `test -n "$VAR"' as the -dnl case may be. --ttn, 2000/08/04 12:11:26 - -AC_INIT -AC_CONFIG_SRCDIR([Include/wad.h]) -AC_PREREQ(2.53) - -# Set name for machine-dependent library files -AC_SUBST(MACHDEP) -AC_MSG_CHECKING(MACHDEP) -if test -z "$MACHDEP" -then - if test -f /usr/lib/NextStep/software_version; then - set X `hostinfo | grep 'NeXT Mach.*:' | \ - sed -e 's/://' -e 's/\./_/'` && \ - ac_sys_system=next && ac_sys_release=$4 - MACHDEP="$ac_sys_system$ac_sys_release$ac_sys_cpu" - else - ac_sys_system=`uname -s` - if test "$ac_sys_system" = "AIX" ; then - ac_sys_release=`uname -v` - else - ac_sys_release=`uname -r` - fi - ac_md_system=`echo $ac_sys_system | - tr -d '[/ ]' | tr '[[A-Z]]' '[[a-z]]'` - ac_md_release=`echo $ac_sys_release | - tr -d '[/ ]' | sed 's/\..*//'` - MACHDEP="$ac_md_system$ac_md_release" - fi - case MACHDEP in - '') MACHDEP=unknown;; - esac -fi -AC_MSG_RESULT($MACHDEP) - -AC_PROG_CC -AC_PROG_CXX -AC_PROG_RANLIB - -dnl Checks for programs. - -AC_SUBST(AR) -AC_CHECK_PROGS(AR, ar aal, ar) - -dnl Checks for header files. -AC_HEADER_STDC -dnl Checks for library functions. - -# Set info about shared libraries. -AC_SUBST(SO) -AC_SUBST(LDSHARED) -AC_SUBST(CCSHARED) - -# SO is the extension of shared libraries `(including the dot!) -# -- usually .so, .sl on HP-UX -AC_MSG_CHECKING(SO) -if test -z "$SO" -then - case $ac_sys_system in - hp*|HP*) SO=.sl;; - *) SO=.so;; - esac -fi -AC_MSG_RESULT($SO) - -# WAD Options -AC_SUBST(WADOPT) -AC_MSG_CHECKING(WADOPT) -if test -z "$WADOPT" -then - case $ac_sys_system/$ac_sys_release in - SunOS/5*) WADOPT="-DWAD_SOLARIS";; - Linux*) WADOPT="-DWAD_LINUX";; - *) WADOPT="-DWAD_UNKWOWN";; - esac -fi -AC_MSG_RESULT($WADOPT) - - -# LDSHARED is the ld *command* used to create shared library -# -- "ld" on SunOS 4.x.x, "ld -G" on SunOS 5.x, "ld -shared" on IRIX 5 -# (Shared libraries in this instance are shared modules to be loaded into -# Python, as opposed to building Python itself as a shared library.) -AC_MSG_CHECKING(LDSHARED) -if test -z "$LDSHARED" -then - case $ac_sys_system/$ac_sys_release in - AIX*) LDSHARED="\$(srcdir)/ld_so_aix \$(CC)";; - IRIX/5*) LDSHARED="ld -shared";; - IRIX*/6*) LDSHARED="ld ${SGI_ABI} -shared -all";; - SunOS/4*) LDSHARED="ld";; - SunOS/5*) LDSHARED="ld -G";; - hp*|HP*) LDSHARED="ld -b";; - OSF*) LDSHARED="ld -shared -expect_unresolved \"*\"";; - DYNIX/ptx*) LDSHARED="ld -G";; - next/*) - if test "$ns_dyld" - then LDSHARED='$(CC) $(LDFLAGS) -bundle -prebind' - else LDSHARED='$(CC) $(CFLAGS) -nostdlib -r'; - fi - if test "$with_next_framework" ; then - LDSHARED="$LDSHARED \$(LDLIBRARY)" - fi ;; - Linux*) LDSHARED="gcc -shared";; - dgux*) LDSHARED="ld -G";; - FreeBSD*/3*) LDSHARED="gcc -shared";; - FreeBSD*|OpenBSD*) LDSHARED="ld -Bshareable";; - NetBSD*) - if [[ "`$CC -dM -E - ], , TCLINCLUDE="") -if test -z "$TCLINCLUDE"; then - dirs="$prefix/include /usr/local/include /usr/include /opt/local/include /home/sci/local/include" - for i in $dirs ; do - if test -r $i/tcl.h; then - AC_MSG_RESULT($i) - TCLINCLUDE="-I$i" - MAKETCL="tcl" - break - fi - done -fi -if test -z "$TCLINCLUDE"; then - TCLINCLUDE="" - MAKETCL="" - AC_MSG_RESULT(not found) -fi -else - AC_MSG_RESULT($TCLINCLUDE) -fi - -AC_SUBST(TCLINCLUDE) -AC_SUBST(MAKETCL) - -#---------------------------------------------------------------- -# Look for Python -#---------------------------------------------------------------- - -PYINCLUDE= -MAKEPYTHON= -PYLIB= -PYPACKAGE= - -AC_ARG_WITH(py,[ --with-py=path Set location of Python],[ - PYPACKAGE="$withval"], [PYPACKAGE=]) -AC_ARG_WITH(pyincl,[ --with-pyincl=path Set location of Python include directory],[ - PYINCLUDE="$withval"], [PYINCLUDE=]) -AC_ARG_WITH(pylib,[ --with-pylib=path Set location of Python library directory],[ - PYLIB="$withval"], [PYLIB=]) - -if test -z "$PYINCLUDE"; then - if test -n "$PYPACKAGE"; then - PYINCLUDE="$PYPACKAGE/include" - fi -fi - -if test -z "$PYLIB"; then - if test -n "$PYPACKAGE"; then - PYLIB="$PYPACKAGE/lib" - fi -fi - - -AC_MSG_CHECKING(for Python header files) - -dirs="$PYINCLUDE $PYINCLUDE/python2.0 $PYINCLUDE/python1.6 $PYINCLUDE/python1.5 $prefix/include/python2.0 $prefix/include/python1.6 $prefix/include/python1.5 /usr/local/include/python2.0 /usr/local/include/python1.6 /usr/local/include/python1.5 /usr/include/python1.5" -for i in $dirs ; do - if test -r $i/Python.h; then - AC_MSG_RESULT($i) - PYINCLUDE="-I$i" - MAKEPYTHON="python" - break - fi -done -if test -z "$PYINCLUDE"; then - PYINCLUDE="" - MAKEPYTHON="" - AC_MSG_RESULT(not found) -fi - -AC_SUBST(PYINCLUDE) -AC_SUBST(PYLINK) -AC_SUBST(MAKEPYTHON) - -#---------------------------------------------------------------- -# Look for Perl5 -#---------------------------------------------------------------- - -PERLBIN= -MAKEPERL= - -AC_ARG_WITH(perl5,[ --with-perl5=path Set location of Perl5 executable],[ PERLBIN="$withval"], [PERLBIN=]) - -# First figure out what the name of Perl5 is - -if test -z "$PERLBIN"; then -AC_CHECK_PROGS(PERL, perl5.004 perl5.003 perl5.002 perl5.001 perl5 perl) -else -PERL="$PERLBIN" -fi -AC_MSG_CHECKING(for Perl5 header files) -if test -n "$PERL"; then - PERL5DIR=`($PERL -e 'use Config; print $Config{archlib};') 2>/dev/null` - if test "$PERL5DIR" != ""; then - dirs="$PERL5DIR $PERL5DIR/CORE" - PERL5EXT=none - for i in $dirs; do - if test -r $i/perl.h; then - AC_MSG_RESULT($i) - PERL5EXT="-I$i" - MAKEPERL="perl" - break; - fi - done - if test "$PERL5EXT" = none; then - PERL5EXT="" - MAKEPERL="" - AC_MSG_RESULT(could not locate perl.h...using $PERL5EXT) - fi - else - AC_MSG_RESULT(unable to determine perl5 configuration) - PERL5EXT="" - MAKEPERL="" - fi - else - AC_MSG_RESULT(could not figure out how to run perl5) - PERL5EXT="" - MAKEPERL="" - fi - -AC_SUBST(PERL5EXT) -AC_SUBST(MAKEPERL) - -dnl We use the following in `AC_CONFIG_FILES' and "make distclean". -configure_substituted_files=`echo \ - Wad/Makefile \ - Python/Makefile \ - Tcl/Makefile \ - Test/Makefile \ - Prebuilt/linux/Makefile \ - Prebuilt/solaris/Makefile \ - Makefile \ -` -AC_SUBST(configure_substituted_files) - -AC_CONFIG_FILES([$configure_substituted_files]) -AC_OUTPUT - -dnl configure.in ends here - diff --git a/Tools/swig.spec.1 b/Tools/swig.spec.1 deleted file mode 100644 index 7af0440cd..000000000 --- a/Tools/swig.spec.1 +++ /dev/null @@ -1,42 +0,0 @@ -%define version 1.3.7 -%define release 1 - -# Preamble -Summary: Simplified Wrapper and Interface Generator -Name: swig -Version: %{version} -Release: %{release} -Copyright: BSD -URL: http://www.swig.org -Group: System Environment/Daemons -Source0: http://download.sourceforge.net/swig/swig-%{version}.tar.gz -Packager: Dustin Mitchell -BuildRoot: /var/tmp/rpm/swig-root -Prefix: /usr - -%description -SWIG is an interface compiler that connects programs written in C, -C++, and Objective-C with scripting languages including Perl, Python, -and Tcl/Tk. It works by taking the declarations commonly found in -C/C++ header files and using them to generate the glue code (wrappers) -that scripting languages need to access the underlying C/C++ code - -# PREP -%prep -%setup -n SWIG-%{version} - -# BUILD -%build -./configure --prefix=%prefix -make - -# INSTALL -%install -rm -rf ${RPM_BUILD_ROOT} -install -d -m 755 ${RPM_BUILD_ROOT} -make prefix=${RPM_BUILD_ROOT}%prefix install - -# FILES -%files -%prefix/lib/* -%prefix/bin/swig From 78224af80b3225858cfd8aa2ca49d3e6f76759b9 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 29 May 2010 23:44:05 +0000 Subject: [PATCH 0895/1680] Add 2.0.0 release notes summary git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12071 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- RELEASENOTES | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/RELEASENOTES b/RELEASENOTES index da833574c..86daf285f 100644 --- a/RELEASENOTES +++ b/RELEASENOTES @@ -1,8 +1,28 @@ Release Notes ============= -A summary of recent releases is described below. A more detailed description -is available in the CHANGES.current and CHANGES files. +A detailed description of changes are available in the CHANGES.current +and CHANGES files. The summaries below contain just a brief overview of +the changes made in each release. + +SWIG-2.0.0 summary: +- Much better nested class/struct support. +- Much improved template partial specialization and explicit + specialization handling. +- Namespace support improved with the 'nspace' feature where namespaces + can be automatically translated into Java packages or C# namespaces. +- Improved typemap and symbol table debugging. +- Numerous subtle typemap matching rule changes when using the default + (SWIGTYPE) type. These now work much like C++ class template partial + specialization matching. +- Other small enhancements for typemaps. Typemap fragments are also now + official and documented. +- Warning and error display refinements. +- Wrapping of shared_ptr is improved and documented now. +- Numerous C++ unary scope operator (::) fixes. +- Better support for boolean expressions. +- Various bug fixes and improvements in the Allegrocl, C#, Java, Lua, + Octave, PHP, Python, R, Ruby and XML modules. SWIG-1.3.40 summary: - SWIG now supports directors for PHP. From 4144eaa214ad5cebcde10a968da1551fb02c3869 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Tue, 1 Jun 2010 06:24:48 +0000 Subject: [PATCH 0896/1680] Remove PHP4 hangover. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12072 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/php/reference/runme-proxy.php4 | 79 ------------------------- 1 file changed, 79 deletions(-) delete mode 100644 Examples/php/reference/runme-proxy.php4 diff --git a/Examples/php/reference/runme-proxy.php4 b/Examples/php/reference/runme-proxy.php4 deleted file mode 100644 index 9d216f78b..000000000 --- a/Examples/php/reference/runme-proxy.php4 +++ /dev/null @@ -1,79 +0,0 @@ -print() . "\n"; -print " Created b: $b " . $b->print() . "\n"; - -# ----- Call an overloaded operator ----- - -# This calls the wrapper we placed around -# -# operator+(const Vector &a, const Vector &) -# -# It returns a new allocated object. - -print "Adding a+b\n"; -$c = addv($a,$b); -print " a+b =". $c->print()."\n"; - -# Note: Unless we free the result, a memory leak will occur -$c = 0; - -# ----- Create a vector array ----- - -# Note: Using the high-level interface here -print "Creating an array of vectors\n"; -$va = new VectorArray(10); - -print " va: $va size=".$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; - -# Get some values from the array - -print "Getting some array values\n"; -for ($i = 0; $i < 5; $i++) { -print "do $i\n"; - $v = $va->get($i); - print " va($i) = ". $v->print(). "\n"; -} - -# Watch under resource meter to check on this -#print "Making sure we don't leak memory.\n"; -#for ($i = 0; $i < 1000000; $i++) { -# $c = VectorArray_get($va,$i % 10); -#} - -# ----- Clean up ----- -print "Cleaning up\n"; -# wants fixing FIXME -#delete_VectorArray($va); -#delete_Vector($a); -#delete_Vector($b); - -?> From 09c9bf881ddb6bfba2659137a068e72b96398720 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Tue, 1 Jun 2010 06:29:16 +0000 Subject: [PATCH 0897/1680] Remove PHP4 hangover git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12073 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/php/variables/runme.php4.old | 80 --------------------------- 1 file changed, 80 deletions(-) delete mode 100644 Examples/php/variables/runme.php4.old diff --git a/Examples/php/variables/runme.php4.old b/Examples/php/variables/runme.php4.old deleted file mode 100644 index 9a6bfb386..000000000 --- a/Examples/php/variables/runme.php4.old +++ /dev/null @@ -1,80 +0,0 @@ - - From 507ae344529fea9cd904484efce71b27529414c1 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Tue, 1 Jun 2010 15:14:29 +0000 Subject: [PATCH 0898/1680] Fix typos in __disown__() example git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12074 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Python.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html index 8f876316e..1cef3683a 100644 --- a/Doc/Manual/Python.html +++ b/Doc/Manual/Python.html @@ -2782,12 +2782,12 @@ public:

       >>> c = FooContainer()
      ->>> a = Foo().__disown()__
      +>>> a = Foo().__disown__()
       >>> c.addFoo(a)
       >>> b = Foo()
      ->>> b = b.__disown()__
      +>>> b = b.__disown__()
       >>> c.addFoo(b)
      ->>> c.addFoo(Foo().__disown()__)
      +>>> c.addFoo(Foo().__disown__())
       
      From 515ec7311ff7933bb1db587c52a999be3cb0ba99 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 1 Jun 2010 19:00:19 +0000 Subject: [PATCH 0899/1680] remove run test which doesn't do anything git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12075 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- .../octave/li_boost_shared_ptr_runme.m | 478 ------------------ 1 file changed, 478 deletions(-) delete mode 100644 Examples/test-suite/octave/li_boost_shared_ptr_runme.m diff --git a/Examples/test-suite/octave/li_boost_shared_ptr_runme.m b/Examples/test-suite/octave/li_boost_shared_ptr_runme.m deleted file mode 100644 index ca09316bc..000000000 --- a/Examples/test-suite/octave/li_boost_shared_ptr_runme.m +++ /dev/null @@ -1,478 +0,0 @@ -li_boost_shared_ptr - -debug = false; - -function main() - if (debug) - printf("Started\n") - endif - - li_boost_shared_ptr.cvar.debug_shared = debug; - - # Change loop count to run for a long time to monitor memory - loopCount = 1; #5000 - for i=0:loopCount, - self.runtest(); - endfor - - if (li_boost_shared_ptr.Klass.getTotal_count() != 0) - error("Klass.total_count=", li_boost_shared_ptr.Klass.getTotal_count()) - endif - - wrapper_count = li_boost_shared_ptr.shared_ptr_wrapper_count(); - if (wrapper_count != li_boost_shared_ptr.NOT_COUNTING) - if (wrapper_count != 0) - error("shared_ptr wrapper count not zero: %i", wrapper_count) - endif - endif - - if (debug) - error("Finished") - endif -endfunction - -function runtest() - # simple shared_ptr usage - created in C++ - k = li_boost_shared_ptr.Klass("me oh my"); - val = k.getValue(); - self.verifyValue("me oh my", val); - self.verifyCount(1, k); - - # simple shared_ptr usage - not created in C++ - k = li_boost_shared_ptr.factorycreate(); - val = k.getValue(); - self.verifyValue("factorycreate", val); - self.verifyCount(1, k); - - # pass by shared_ptr - k = li_boost_shared_ptr.Klass("me oh my"); - kret = li_boost_shared_ptr.smartpointertest(k); - val = kret.getValue(); - self.verifyValue("me oh my smartpointertest", val); - self.verifyCount(2, k); - self.verifyCount(2, kret); - - # pass by shared_ptr pointer - k = li_boost_shared_ptr.Klass("me oh my"); - kret = li_boost_shared_ptr.smartpointerpointertest(k); - val = kret.getValue(); - self.verifyValue("me oh my smartpointerpointertest", val); - self.verifyCount(2, k); - self.verifyCount(2, kret); - - # pass by shared_ptr reference - k = li_boost_shared_ptr.Klass("me oh my"); - kret = li_boost_shared_ptr.smartpointerreftest(k); - val = kret.getValue(); - self.verifyValue("me oh my smartpointerreftest", val); - self.verifyCount(2, k); - self.verifyCount(2, kret); - - # pass by shared_ptr pointer reference - k = li_boost_shared_ptr.Klass("me oh my"); - kret = li_boost_shared_ptr.smartpointerpointerreftest(k); - val = kret.getValue(); - self.verifyValue("me oh my smartpointerpointerreftest", val); - self.verifyCount(2, k); - self.verifyCount(2, kret); - - # const pass by shared_ptr - k = li_boost_shared_ptr.Klass("me oh my"); - kret = li_boost_shared_ptr.constsmartpointertest(k); - val = kret.getValue(); - self.verifyValue("me oh my", val); - self.verifyCount(2, k); - self.verifyCount(2, kret); - - # const pass by shared_ptr pointer - k = li_boost_shared_ptr.Klass("me oh my"); - kret = li_boost_shared_ptr.constsmartpointerpointertest(k); - val = kret.getValue(); - self.verifyValue("me oh my", val); - self.verifyCount(2, k); - self.verifyCount(2, kret); - - # const pass by shared_ptr reference - k = li_boost_shared_ptr.Klass("me oh my"); - kret = li_boost_shared_ptr.constsmartpointerreftest(k); - val = kret.getValue(); - self.verifyValue("me oh my", val); - self.verifyCount(2, k); - self.verifyCount(2, kret); - - # pass by value - k = li_boost_shared_ptr.Klass("me oh my"); - kret = li_boost_shared_ptr.valuetest(k); - val = kret.getValue(); - self.verifyValue("me oh my valuetest", val); - self.verifyCount(1, k); - self.verifyCount(1, kret); - - # pass by pointer - k = li_boost_shared_ptr.Klass("me oh my"); - kret = li_boost_shared_ptr.pointertest(k); - val = kret.getValue(); - self.verifyValue("me oh my pointertest", val); - self.verifyCount(1, k); - self.verifyCount(1, kret); - - # pass by reference - k = li_boost_shared_ptr.Klass("me oh my"); - kret = li_boost_shared_ptr.reftest(k); - val = kret.getValue(); - self.verifyValue("me oh my reftest", val); - self.verifyCount(1, k); - self.verifyCount(1, kret); - - # pass by pointer reference - k = li_boost_shared_ptr.Klass("me oh my"); - kret = li_boost_shared_ptr.pointerreftest(k); - val = kret.getValue(); - self.verifyValue("me oh my pointerreftest", val); - self.verifyCount(1, k); - self.verifyCount(1, kret); - - # null tests - k = None; - - if (li_boost_shared_ptr.smartpointertest(k) != None) - error("return was not null") - endif - - if (li_boost_shared_ptr.smartpointerpointertest(k) != None) - error("return was not null") - endif - - if (li_boost_shared_ptr.smartpointerreftest(k) != None) - error("return was not null") - endif - - if (li_boost_shared_ptr.smartpointerpointerreftest(k) != None) - error("return was not null") - endif - - if (li_boost_shared_ptr.nullsmartpointerpointertest(None) != "null pointer") - error("not null smartpointer pointer") - endif - - try - li_boost_shared_ptr.valuetest(k) - error("Failed to catch null pointer") - catch - end_try_catch - - if (li_boost_shared_ptr.pointertest(k) != None) - error("return was not null") - endif - - try - li_boost_shared_ptr.reftest(k) - error("Failed to catch null pointer") - catch - end_try_catch - - # $owner - k = li_boost_shared_ptr.pointerownertest(); - val = k.getValue(); - self.verifyValue("pointerownertest", val); - self.verifyCount(1, k); - k = li_boost_shared_ptr.smartpointerpointerownertest(); - val = k.getValue(); - self.verifyValue("smartpointerpointerownertest", val); - self.verifyCount(1, k); - - # //////////////////////////////// Derived class //////////////////////////////////////// - # derived pass by shared_ptr - k = li_boost_shared_ptr.KlassDerived("me oh my"); - kret = li_boost_shared_ptr.derivedsmartptrtest(k); - val = kret.getValue(); - self.verifyValue("me oh my derivedsmartptrtest-Derived", val); - self.verifyCount(2, k); - self.verifyCount(2, kret); - - # derived pass by shared_ptr pointer - k = li_boost_shared_ptr.KlassDerived("me oh my"); - kret = li_boost_shared_ptr.derivedsmartptrpointertest(k); - val = kret.getValue(); - self.verifyValue("me oh my derivedsmartptrpointertest-Derived", val); - self.verifyCount(2, k); - self.verifyCount(2, kret); - - # derived pass by shared_ptr ref - k = li_boost_shared_ptr.KlassDerived("me oh my"); - kret = li_boost_shared_ptr.derivedsmartptrreftest(k); - val = kret.getValue(); - self.verifyValue("me oh my derivedsmartptrreftest-Derived", val); - self.verifyCount(2, k); - self.verifyCount(2, kret); - - # derived pass by shared_ptr pointer ref - k = li_boost_shared_ptr.KlassDerived("me oh my"); - kret = li_boost_shared_ptr.derivedsmartptrpointerreftest(k); - val = kret.getValue(); - self.verifyValue("me oh my derivedsmartptrpointerreftest-Derived", val); - self.verifyCount(2, k); - self.verifyCount(2, kret); - - # derived pass by pointer - k = li_boost_shared_ptr.KlassDerived("me oh my"); - kret = li_boost_shared_ptr.derivedpointertest(k); - val = kret.getValue(); - self.verifyValue("me oh my derivedpointertest-Derived", val); - self.verifyCount(1, k); - self.verifyCount(1, kret); - - # derived pass by ref - k = li_boost_shared_ptr.KlassDerived("me oh my"); - kret = li_boost_shared_ptr.derivedreftest(k); - val = kret.getValue(); - self.verifyValue("me oh my derivedreftest-Derived", val); - self.verifyCount(1, k); - self.verifyCount(1, kret); - - # //////////////////////////////// Derived and base class mixed //////////////////////////////////////// - # pass by shared_ptr (mixed) - k = li_boost_shared_ptr.KlassDerived("me oh my"); - kret = li_boost_shared_ptr.smartpointertest(k); - val = kret.getValue(); - self.verifyValue("me oh my smartpointertest-Derived", val); - self.verifyCount(2, k); - self.verifyCount(2, kret); - - # pass by shared_ptr pointer (mixed) - k = li_boost_shared_ptr.KlassDerived("me oh my"); - kret = li_boost_shared_ptr.smartpointerpointertest(k); - val = kret.getValue(); - self.verifyValue("me oh my smartpointerpointertest-Derived", val); - self.verifyCount(2, k); - self.verifyCount(2, kret); - - # pass by shared_ptr reference (mixed) - k = li_boost_shared_ptr.KlassDerived("me oh my"); - kret = li_boost_shared_ptr.smartpointerreftest(k); - val = kret.getValue(); - self.verifyValue("me oh my smartpointerreftest-Derived", val); - self.verifyCount(2, k); - self.verifyCount(2, kret); - - # pass by shared_ptr pointer reference (mixed) - k = li_boost_shared_ptr.KlassDerived("me oh my"); - kret = li_boost_shared_ptr.smartpointerpointerreftest(k); - val = kret.getValue(); - self.verifyValue("me oh my smartpointerpointerreftest-Derived", val); - self.verifyCount(2, k); - self.verifyCount(2, kret); - - # pass by value (mixed) - k = li_boost_shared_ptr.KlassDerived("me oh my"); - kret = li_boost_shared_ptr.valuetest(k); - val = kret.getValue(); - self.verifyValue("me oh my valuetest", val); # note slicing - self.verifyCount(1, k); - self.verifyCount(1, kret); - - # pass by pointer (mixed) - k = li_boost_shared_ptr.KlassDerived("me oh my"); - kret = li_boost_shared_ptr.pointertest(k); - val = kret.getValue(); - self.verifyValue("me oh my pointertest-Derived", val); - self.verifyCount(1, k); - self.verifyCount(1, kret); - - # pass by ref (mixed) - k = li_boost_shared_ptr.KlassDerived("me oh my"); - kret = li_boost_shared_ptr.reftest(k); - val = kret.getValue(); - self.verifyValue("me oh my reftest-Derived", val); - self.verifyCount(1, k); - self.verifyCount(1, kret); - - # //////////////////////////////// Overloading tests //////////////////////////////////////// - # Base class - k = li_boost_shared_ptr.Klass("me oh my"); - self.verifyValue(li_boost_shared_ptr.overload_rawbyval(k), "rawbyval"); - self.verifyValue(li_boost_shared_ptr.overload_rawbyref(k), "rawbyref"); - self.verifyValue(li_boost_shared_ptr.overload_rawbyptr(k), "rawbyptr"); - self.verifyValue(li_boost_shared_ptr.overload_rawbyptrref(k), "rawbyptrref"); - - self.verifyValue(li_boost_shared_ptr.overload_smartbyval(k), "smartbyval"); - self.verifyValue(li_boost_shared_ptr.overload_smartbyref(k), "smartbyref"); - self.verifyValue(li_boost_shared_ptr.overload_smartbyptr(k), "smartbyptr"); - self.verifyValue(li_boost_shared_ptr.overload_smartbyptrref(k), "smartbyptrref"); - - # Derived class - k = li_boost_shared_ptr.KlassDerived("me oh my"); - self.verifyValue(li_boost_shared_ptr.overload_rawbyval(k), "rawbyval"); - self.verifyValue(li_boost_shared_ptr.overload_rawbyref(k), "rawbyref"); - self.verifyValue(li_boost_shared_ptr.overload_rawbyptr(k), "rawbyptr"); - self.verifyValue(li_boost_shared_ptr.overload_rawbyptrref(k), "rawbyptrref"); - - self.verifyValue(li_boost_shared_ptr.overload_smartbyval(k), "smartbyval"); - self.verifyValue(li_boost_shared_ptr.overload_smartbyref(k), "smartbyref"); - self.verifyValue(li_boost_shared_ptr.overload_smartbyptr(k), "smartbyptr"); - self.verifyValue(li_boost_shared_ptr.overload_smartbyptrref(k), "smartbyptrref"); - - # //////////////////////////////// Member variables //////////////////////////////////////// - # smart pointer by value - m = li_boost_shared_ptr.MemberVariables(); - k = li_boost_shared_ptr.Klass("smart member value"); - m.SmartMemberValue = k; - val = k.getValue(); - self.verifyValue("smart member value", val); - self.verifyCount(2, k); - - kmember = m.SmartMemberValue; - val = kmember.getValue(); - self.verifyValue("smart member value", val); - self.verifyCount(3, kmember); - self.verifyCount(3, k); - - clear m; - self.verifyCount(2, kmember); - self.verifyCount(2, k); - - # smart pointer by pointer - m = li_boost_shared_ptr.MemberVariables(); - k = li_boost_shared_ptr.Klass("smart member pointer"); - m.SmartMemberPointer = k; - val = k.getValue(); - self.verifyValue("smart member pointer", val); - self.verifyCount(1, k); - - kmember = m.SmartMemberPointer; - val = kmember.getValue(); - self.verifyValue("smart member pointer", val); - self.verifyCount(2, kmember); - self.verifyCount(2, k); - - clear m; - self.verifyCount(2, kmember); - self.verifyCount(2, k); - - # smart pointer by reference - m = li_boost_shared_ptr.MemberVariables(); - k = li_boost_shared_ptr.Klass("smart member reference"); - m.SmartMemberReference = k; - val = k.getValue(); - self.verifyValue("smart member reference", val); - self.verifyCount(2, k); - - kmember = m.SmartMemberReference; - val = kmember.getValue(); - self.verifyValue("smart member reference", val); - self.verifyCount(3, kmember); - self.verifyCount(3, k); - - # The C++ reference refers to SmartMemberValue... - kmemberVal = m.SmartMemberValue; - val = kmember.getValue(); - self.verifyValue("smart member reference", val); - self.verifyCount(4, kmemberVal); - self.verifyCount(4, kmember); - self.verifyCount(4, k); - - clear m; - self.verifyCount(3, kmemberVal); - self.verifyCount(3, kmember); - self.verifyCount(3, k); - - # plain by value - m = li_boost_shared_ptr.MemberVariables(); - k = li_boost_shared_ptr.Klass("plain member value"); - m.MemberValue = k; - val = k.getValue(); - self.verifyValue("plain member value", val); - self.verifyCount(1, k); - - kmember = m.MemberValue; - val = kmember.getValue(); - self.verifyValue("plain member value", val); - self.verifyCount(1, kmember); - self.verifyCount(1, k); - - clear m; - self.verifyCount(1, kmember); - self.verifyCount(1, k); - - # plain by pointer - m = li_boost_shared_ptr.MemberVariables(); - k = li_boost_shared_ptr.Klass("plain member pointer"); - m.MemberPointer = k; - val = k.getValue(); - self.verifyValue("plain member pointer", val); - self.verifyCount(1, k); - - kmember = m.MemberPointer; - val = kmember.getValue(); - self.verifyValue("plain member pointer", val); - self.verifyCount(1, kmember); - self.verifyCount(1, k); - - clear m; - self.verifyCount(1, kmember); - self.verifyCount(1, k); - - # plain by reference - m = li_boost_shared_ptr.MemberVariables(); - k = li_boost_shared_ptr.Klass("plain member reference"); - m.MemberReference = k; - val = k.getValue(); - self.verifyValue("plain member reference", val); - self.verifyCount(1, k); - - kmember = m.MemberReference; - val = kmember.getValue(); - self.verifyValue("plain member reference", val); - self.verifyCount(1, kmember); - self.verifyCount(1, k); - - clear m; - self.verifyCount(1, kmember); - self.verifyCount(1, k); - - # null member variables - m = li_boost_shared_ptr.MemberVariables(); - - # shared_ptr by value - k = m.SmartMemberValue; - if (k != None) - error("expected null") - endif - m.SmartMemberValue = None; - k = m.SmartMemberValue; - if (k != None) - error("expected null") - endif - self.verifyCount(0, k); - - # plain by value - try - m.MemberValue = None; - error("Failed to catch null pointer"); - catch - end_try_catch - - # templates - pid = li_boost_shared_ptr.PairIntDouble(10, 20.2) - if (pid.baseVal1 != 20 || pid.baseVal2 != 40.4) - error("Base values wrong") - endif - if (pid.val1 != 10 || pid.val2 != 20.2) - error("Derived Values wrong") - endif -endfunction - -function verifyValue(expected,got) - if (expected != got) - error("verify value failed. Expected: %i, Got %i\n",expected,got) - endif -endfunction - -function verifyCount(expected,k) - got = li_boost_shared_ptr.use_count(k); - if (expected != got) - error("verify value failed. Expected: %i, Got %i\n",expected,got) - endif -endfunction - - From 84985fa2056f3f9f2719a69c6fcf616c232b4519 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 1 Jun 2010 19:00:54 +0000 Subject: [PATCH 0900/1680] remove WAD from distribution git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12076 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Tools/mkdist.py | 1 - 1 file changed, 1 deletion(-) diff --git a/Tools/mkdist.py b/Tools/mkdist.py index 6972eb829..f2a04542c 100755 --- a/Tools/mkdist.py +++ b/Tools/mkdist.py @@ -47,7 +47,6 @@ os.system("rm -Rf "+dirname+"/debian") == 0 or failed() print "Building system" os.system("cd "+dirname+" && ./autogen.sh") == 0 or failed() -os.system("cd "+dirname+"/Tools/WAD && autoconf") == 0 or failed() os.system("cd "+dirname+"/Source/CParse && bison -y -d parser.y && mv y.tab.c parser.c && mv y.tab.h parser.h") == 0 or failed() os.system("cd "+dirname+" && make -f Makefile.in libfiles srcdir=./") == 0 or failed() From 36c2e97a1c4d761fdc89fa374830edea33db95b4 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 1 Jun 2010 19:03:55 +0000 Subject: [PATCH 0901/1680] Add std_shared_ptr.i and document shared_ptr library git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12077 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 10 +++ Doc/Manual/Library.html | 138 ++++++++++++++++++++++++++++++++---- Doc/Manual/SWIGPlus.html | 4 +- Lib/csharp/std_shared_ptr.i | 2 + Lib/java/std_shared_ptr.i | 2 + Lib/python/std_shared_ptr.i | 2 + Lib/shared_ptr.i | 2 + 7 files changed, 143 insertions(+), 17 deletions(-) create mode 100644 Lib/csharp/std_shared_ptr.i create mode 100644 Lib/java/std_shared_ptr.i create mode 100644 Lib/python/std_shared_ptr.i diff --git a/CHANGES.current b/CHANGES.current index c52179d45..a2987e392 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,16 @@ Version 2.0.0 (in progress) ============================ +2010-06-01: wsfulton + Add in std_shared_ptr.i for wrapping std::shared_ptr. Requires the %shared_ptr + macro like in the boost_shared_ptr.i library. std::tr1::shared_ptr can also be + wrapped if the following macro is defined: + + #define SWIG_SHARED_PTR_SUBNAMESPACE tr1 + %include + + shared_ptr is also documented in Library.html now. + 2010-05-27: wsfulton Add the ability for $typemap special variable macros to call other $typemap special variable macros, for example: diff --git a/Doc/Manual/Library.html b/Doc/Manual/Library.html index c003151ac..8ea8a7a31 100644 --- a/Doc/Manual/Library.html +++ b/Doc/Manual/Library.html @@ -27,8 +27,8 @@
  • STL/C++ Library
  • Utility Libraries @@ -1383,6 +1383,7 @@ The following table shows which C++ classes are supported and the equivalent SWI
  • +
    std::set set std_set.i
    std::string string std_string.i
    std::vector vector std_vector.i
    std::shared_ptr shared_ptr std_shared_ptr.i
    @@ -1392,7 +1393,7 @@ Please look for the library files in the appropriate language library directory.

    -

    8.4.1 std_string.i

    +

    std::string

    @@ -1476,16 +1477,11 @@ void foo(string s, const String &t); // std_string typemaps still applie -

    -Note: The std_string library is incompatible with Perl on some platforms. -We're looking into it. -

    - -

    8.4.2 std_vector.i

    +

    std::vector

    -The std_vector.i library provides support for the C++ vector class in the STL. +The std_vector.i library provides support for the C++ std::vector class in the STL. Using this library involves the use of the %template directive. All you need to do is to instantiate different versions of vector for the types that you want to use. For example:

    @@ -1660,11 +1656,6 @@ if you want to make their head explode. details and the public API exposed to the interpreter vary.

    -

    -Note: std_vector.i was written by Luigi "The Amazing" Ballabio. -

    - -

    8.4.3 STL exceptions

    @@ -1715,6 +1706,123 @@ The %exception directive can be used by placing the following code befo Any thrown STL exceptions will then be gracefully handled instead of causing a crash.

    +

    shared_ptr smart pointer

    + +

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

    + +
    +
    +#define SWIG_SHARED_PTR_SUBNAMESPACE tr1
    +%include <std_shared_ptr.i>
    +
    +
    + +

    +You can only use one of these variants of shared_ptr in your interface file at a time. +and all three variants must be used in conjunction with the %shared_ptr(T) macro, +where T is the underlying pointer type equating to usage shared_ptr<T>. +The type T must be non-primitive. +A simple example demonstrates usage: +

    + +
    +
    +%module example
    +%include <boost_shared_ptr.i>
    +%shared_ptr(IntValue)
    +
    +%inline %{
    +#include <boost/shared_ptr.hpp>
    +
    +struct IntValue {
    +  int value;
    +  IntValue(int v) : value(v) {}
    +};
    +
    +static int extractValue(const IntValue &t) {
    +  return t.value;
    +}
    +
    +static int extractValueSmart(boost::shared_ptr<IntValue> t) {
    +  return t->value;
    +}
    +%}
    +
    +
    + +

    +Note that the %shared_ptr(IntValue) declaration occurs after the inclusion of the boost_shared_ptr.i +library which provides the macro and, very importantly, before any usage or declaration of the type, IntValue. +The %shared_ptr macro provides, a few things for handling this smart pointer, but mostly a number of +typemaps. These typemaps override the default typemaps so that the underlying proxy class is stored and passed around +as a pointer to a shared_ptr instead of a plain pointer to the underlying type. +This approach means that any instantiation of the type can be passed to methods taking the type by value, reference, pointer +or as a smart pointer. +The interested reader might want to look at the generated code, however, usage is simple and no different +handling is required from the target language. +For example, a simple use case of the above code from Java would be: +

    + +
    +
    +IntValue iv = new IntValue(1234);
    +int val1 = example.extractValue(iv);
    +int val2 = example.extractValueSmart(iv);
    +System.out.println(val1 + " " + val2);
    +
    +
    + +

    +This shared_ptr library works quite differently to SWIG's normal, but somewhat limited, +smart pointer handling. +The shared_ptr library does not generate extra wrappers, just for smart pointer handling, in addition to the proxy class. +The normal proxy class including inheritance relationships is generated as usual. +The only real change introduced by the %shared_ptr macro is that the proxy class stores a pointer to the shared_ptr instance instead of a raw pointer to the instance. +A proxy class derived from a base which is being wrapped with shared_ptr can and must be wrapped as a shared_ptr too. +In other words all classes in an inheritance hierarchy must all be used with the %shared_ptr macro. +For example the following code can be used with the base class shown earlier: +

    + +
    +
    +%shared_ptr(DerivedIntValue)
    +%inline %{
    +struct DerivedIntValue : IntValue {
    +  DerivedIntValue(int value) : IntValue(value) {}
    +  ...
    +};
    +%}
    +
    +
    + +

    +Note that if the %shared_ptr macro is omitted for any class in the inheritance hierarchy, it will +result in a C++ compiler error. +For example if the above %shared_ptr(DerivedIntValue) is omitted, the following is typical of the compiler error that will result: +

    + +
    +
    +example_wrap.cxx: In function ‘void Java_exampleJNI_delete_1DerivedIntValue(JNIEnv*, _jclass*, jlong)’:
    +example_wrap.cxx:3169: error: ‘smartarg1’ was not declared in this scope
    +
    +
    + +

    +A shared_ptr of the derived class can now be passed to a method where the base is expected in the target language, just as it can in C++: +

    + +
    +
    +DerivedIntValue div = new DerivedIntValue(5678);
    +int val3 = example.extractValue(div);
    +int val4 = example.extractValueSmart(div);
    +
    +

    8.5 Utility Libraries

    diff --git a/Doc/Manual/SWIGPlus.html b/Doc/Manual/SWIGPlus.html index 47ed38186..f9bfc8ec6 100644 --- a/Doc/Manual/SWIGPlus.html +++ b/Doc/Manual/SWIGPlus.html @@ -56,7 +56,7 @@
  • Exception specifications
  • Exception handling with %catches
  • Pointers to Members -
  • Smart pointers and operator->() +
  • Smart pointers and operator->()
  • Using declarations and inheritance
  • Nested classes
  • A brief rant about const-correctness @@ -4408,7 +4408,7 @@ when checking types. However, no such support is currently provided for member pointers.

    -

    6.24 Smart pointers and operator->()

    +

    6.24 Smart pointers and operator->()

    diff --git a/Lib/csharp/std_shared_ptr.i b/Lib/csharp/std_shared_ptr.i new file mode 100644 index 000000000..df873679c --- /dev/null +++ b/Lib/csharp/std_shared_ptr.i @@ -0,0 +1,2 @@ +#define SWIG_SHARED_PTR_NAMESPACE std +%include diff --git a/Lib/java/std_shared_ptr.i b/Lib/java/std_shared_ptr.i new file mode 100644 index 000000000..df873679c --- /dev/null +++ b/Lib/java/std_shared_ptr.i @@ -0,0 +1,2 @@ +#define SWIG_SHARED_PTR_NAMESPACE std +%include diff --git a/Lib/python/std_shared_ptr.i b/Lib/python/std_shared_ptr.i new file mode 100644 index 000000000..df873679c --- /dev/null +++ b/Lib/python/std_shared_ptr.i @@ -0,0 +1,2 @@ +#define SWIG_SHARED_PTR_NAMESPACE std +%include diff --git a/Lib/shared_ptr.i b/Lib/shared_ptr.i index 77e868de2..450493db4 100644 --- a/Lib/shared_ptr.i +++ b/Lib/shared_ptr.i @@ -1,3 +1,5 @@ +// This is a helper file for shared_ptr and should not be included directly. + // The main implementation detail in using this smart pointer of a type is to customise the code generated // to use a pointer to the smart pointer of the type, rather than the usual pointer to the underlying type. // So for some type T, shared_ptr * is used rather than T *. From 978080846c130e011f0b4e172a164235ae55997a Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 1 Jun 2010 19:19:17 +0000 Subject: [PATCH 0902/1680] html fixes and chapter renumbering git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12078 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Contents.html | 7 ++++--- Doc/Manual/Library.html | 12 +++++++----- Doc/Manual/Preface.html | 2 -- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index 9d353636a..8612ef237 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -236,7 +236,7 @@

  • Exception specifications
  • Exception handling with %catches
  • Pointers to Members -
  • Smart pointers and operator->() +
  • Smart pointers and operator->()
  • Using declarations and inheritance
  • Nested classes
  • A brief rant about const-correctness @@ -287,9 +287,10 @@
  • STL/C++ Library
  • Utility Libraries
  • Utility Libraries
      @@ -1393,7 +1394,7 @@ Please look for the library files in the appropriate language library directory.

      -

      std::string

      +

      8.4.1 std::string

      @@ -1477,7 +1478,7 @@ void foo(string s, const String &t); // std_string typemaps still applie -

      std::vector

      +

      8.4.2 std::vector

      @@ -1706,7 +1707,8 @@ The %exception directive can be used by placing the following code befo Any thrown STL exceptions will then be gracefully handled instead of causing a crash.

      -

      shared_ptr smart pointer

      +

      8.4.4 shared_ptr smart pointer

      +

      Some target languages have support for handling the widely used boost::shared_ptr smart pointer. @@ -1807,8 +1809,8 @@ For example if the above %shared_ptr(DerivedIntValue) is omitted, the f

      -example_wrap.cxx: In function ‘void Java_exampleJNI_delete_1DerivedIntValue(JNIEnv*, _jclass*, jlong)’:
      -example_wrap.cxx:3169: error: ‘smartarg1’ was not declared in this scope
      +example_wrap.cxx: In function 'void Java_exampleJNI_delete_1DerivedIntValue(JNIEnv*, _jclass*, jlong)':
      +example_wrap.cxx:3169: error: 'smartarg1' was not declared in this scope
       
      diff --git a/Doc/Manual/Preface.html b/Doc/Manual/Preface.html index 2680328dd..2d0aa093e 100644 --- a/Doc/Manual/Preface.html +++ b/Doc/Manual/Preface.html @@ -200,8 +200,6 @@ who have made contributions at all levels over time. Contributors are mentioned either in the COPYRIGHT file or CHANGES files shipped with SWIG or in submitted bugs.

      -

      -

      1.9 Bug reports

      From cccd7d605c84608708d21ca4654c1f5b2516b6f0 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 1 Jun 2010 20:03:26 +0000 Subject: [PATCH 0903/1680] Refer each of the changes/release notes files to each other git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12079 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES | 3 ++- CHANGES.current | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index cad14004b..721a49269 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,7 @@ SWIG (Simplified Wrapper and Interface Generator) -See CHANGES.current for current version. +See CHANGES.current for changes in the current version. +See RELEASENOTES for a summary of changes in each release. Version 1.3.40 (18 August 2009) =============================== diff --git a/CHANGES.current b/CHANGES.current index a2987e392..19f477d5b 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,9 @@ Version 2.0.0 (in progress) ============================ +See CHANGES for changes in older releases. +See RELEASENOTES for a summary of changes in each release. + 2010-06-01: wsfulton Add in std_shared_ptr.i for wrapping std::shared_ptr. Requires the %shared_ptr macro like in the boost_shared_ptr.i library. std::tr1::shared_ptr can also be From b802e37ad215542c291b8c06b2f18a23cad46f0b Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 1 Jun 2010 22:43:34 +0000 Subject: [PATCH 0904/1680] Add license changes to release notes git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12080 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++++ RELEASENOTES | 1 + 2 files changed, 5 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 19f477d5b..d0ff785eb 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -399,6 +399,10 @@ See RELEASENOTES for a summary of changes in each release. and line number related to the type. This is effectively a condensed form of the -debug-tmsearch option. Documented in Typemaps.html. +2009-12-27: wsfulton + License code changes: SWIG Source is GPL-v3 and library code license is now clearer + and is provided under a very permissive license. See http://www.swig.org/legal.html. + 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/RELEASENOTES b/RELEASENOTES index 86daf285f..74e043ae7 100644 --- a/RELEASENOTES +++ b/RELEASENOTES @@ -6,6 +6,7 @@ and CHANGES files. The summaries below contain just a brief overview of the changes made in each release. SWIG-2.0.0 summary: +- License changes, see LICENSE file and http://www.swig.org/legal.html. - Much better nested class/struct support. - Much improved template partial specialization and explicit specialization handling. From d25121a0ed3f2b3104bd50a991e917099dd12380 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 1 Jun 2010 23:10:22 +0000 Subject: [PATCH 0905/1680] Fix SWIG_STD_VECTOR_ENHANCED macro used in C# std::vector to work with commas git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12081 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 6 ++++ .../csharp/li_std_combinations_runme.cs | 31 +++++++++++++++++++ Examples/test-suite/li_std_combinations.i | 8 +++++ Lib/csharp/csharp.swg | 3 ++ Lib/csharp/std_vector.i | 8 ++--- 5 files changed, 50 insertions(+), 6 deletions(-) create mode 100644 Examples/test-suite/csharp/li_std_combinations_runme.cs diff --git a/CHANGES.current b/CHANGES.current index d0ff785eb..f24856b49 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -4,6 +4,12 @@ Version 2.0.0 (in progress) See CHANGES for changes in older releases. See RELEASENOTES for a summary of changes in each release. +2010-06-02: wsfulton + [C#] Fix SWIG_STD_VECTOR_ENHANCED macro used in std::vector to work with + types containing commas, for example: + + SWIG_STD_VECTOR_ENHANCED(std::pair< double, std::string >) + 2010-06-01: wsfulton Add in std_shared_ptr.i for wrapping std::shared_ptr. Requires the %shared_ptr macro like in the boost_shared_ptr.i library. std::tr1::shared_ptr can also be diff --git a/Examples/test-suite/csharp/li_std_combinations_runme.cs b/Examples/test-suite/csharp/li_std_combinations_runme.cs new file mode 100644 index 000000000..ced9d17a3 --- /dev/null +++ b/Examples/test-suite/csharp/li_std_combinations_runme.cs @@ -0,0 +1,31 @@ +using System; +using li_std_combinationsNamespace; + +public class li_std_combinations_runme { + public static void Main() { + VectorPairIntString vpis = new VectorPairIntString(); + vpis.Add(new PairIntString(123, "one hundred and twenty three")); + + VectorString vs = new VectorString(); + vs.Add("hi"); + PairIntVectorString pivs = new PairIntVectorString(456, vs); + if (pivs.second[0] != "hi") + throw new ApplicationException("PairIntVectorString"); + + VectorVectorString vvs = new VectorVectorString(); + vvs.Add(vs); + + PairIntPairIntString pipis = new PairIntPairIntString(12, new PairIntString(3, "4")); + if (pipis.first != 12) + throw new ApplicationException("PairIntPairIntString"); + + PairDoubleString pds = new PairDoubleString(12.34, "okay"); + VectorPairDoubleString vpds = new VectorPairDoubleString(); + vpds.Add(pds); + + // Check SWIG_STD_VECTOR_ENHANCED macro - it provides the Contains method + if (!vpds.Contains(pds)) + throw new ApplicationException("VectorPairDoubleString"); + } +} + diff --git a/Examples/test-suite/li_std_combinations.i b/Examples/test-suite/li_std_combinations.i index d760fa44e..9acc8f23d 100644 --- a/Examples/test-suite/li_std_combinations.i +++ b/Examples/test-suite/li_std_combinations.i @@ -13,3 +13,11 @@ %template(VectorVectorString) std::vector< std::vector >; %template(PairIntPairIntString) std::pair< int, std::pair >; + +#if defined(SWIGCSHARP) +// Checks macro containing a type with a comma +SWIG_STD_VECTOR_ENHANCED(std::pair< double, std::string >) +#endif +%template(PairDoubleString) std::pair< double, std::string >; +%template(VectorPairDoubleString) std::vector< std::pair >; + diff --git a/Lib/csharp/csharp.swg b/Lib/csharp/csharp.swg index 57998b9db..d16584565 100644 --- a/Lib/csharp/csharp.swg +++ b/Lib/csharp/csharp.swg @@ -963,6 +963,9 @@ using System.Runtime.InteropServices; // Default enum handling %include +// For vararg handling in macros, from swigmacros.swg +#define %arg(X...) X + /* // Alternative char * typemaps. %pragma(csharp) imclasscode=%{ diff --git a/Lib/csharp/std_vector.i b/Lib/csharp/std_vector.i index 7fca7d2fd..f270b7f59 100644 --- a/Lib/csharp/std_vector.i +++ b/Lib/csharp/std_vector.i @@ -319,10 +319,6 @@ } %enddef -%define SWIG_STD_VECTOR_MINIMUM(CTYPE...) -SWIG_STD_VECTOR_MINIMUM_INTERNAL(IEnumerable, CTYPE const&, CTYPE) -%enddef - // Extra methods added to the collection class if operator== is defined for the class being wrapped // The class will then implement IList<>, which adds extra functionality %define SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(CTYPE...) @@ -359,7 +355,7 @@ SWIG_STD_VECTOR_MINIMUM_INTERNAL(IEnumerable, CTYPE const&, CTYPE) %define SWIG_STD_VECTOR_ENHANCED(CTYPE...) namespace std { template<> class vector { - SWIG_STD_VECTOR_MINIMUM_INTERNAL(IList, CTYPE const&, CTYPE) + SWIG_STD_VECTOR_MINIMUM_INTERNAL(IList, %arg(CTYPE const&), %arg(CTYPE)) SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(CTYPE) }; } @@ -392,7 +388,7 @@ namespace std { // primary (unspecialized) class template for std::vector // does not require operator== to be defined template class vector { - SWIG_STD_VECTOR_MINIMUM(T) + SWIG_STD_VECTOR_MINIMUM_INTERNAL(IEnumerable, T const&, T) }; // specialization for pointers template class vector { From 570b9154e4f629f055ce41bd5bc3a20c233f4732 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 1 Jun 2010 23:14:42 +0000 Subject: [PATCH 0906/1680] Correct license change date git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12082 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index f24856b49..cde7a5e53 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -294,6 +294,10 @@ See RELEASENOTES for a summary of changes in each release. [Python] Remove -dirvtable from the optimizations included by -O as it this option currently leads to memory leaks as reported by Johan Blake. +2010-02-27: wsfulton + License code changes: SWIG Source is GPL-v3 and library code license is now clearer + and is provided under a very permissive license. See http://www.swig.org/legal.html. + 2010-02-13: wsfulton [Ruby] A few fixes for compiling under ruby-1.9.x including patch from 'Nibble'. @@ -405,10 +409,6 @@ See RELEASENOTES for a summary of changes in each release. and line number related to the type. This is effectively a condensed form of the -debug-tmsearch option. Documented in Typemaps.html. -2009-12-27: wsfulton - License code changes: SWIG Source is GPL-v3 and library code license is now clearer - and is provided under a very permissive license. See http://www.swig.org/legal.html. - 2009-12-23: wsfulton Fix for %javaexception and directors so that all the appropriate throws clauses are generated. Problem reported by Peter Greenwood. From cc9b81128180d03e7ba8122a68c93e634f84579b Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 1 Jun 2010 23:36:08 +0000 Subject: [PATCH 0907/1680] Add spaces to avoid unintended <: digraph in SWIG_STD_VECTOR_ENHANCED git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12083 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/csharp/std_vector.i | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/Lib/csharp/std_vector.i b/Lib/csharp/std_vector.i index f270b7f59..5a21ad399 100644 --- a/Lib/csharp/std_vector.i +++ b/Lib/csharp/std_vector.i @@ -26,8 +26,8 @@ // MACRO for use within the std::vector class body %define SWIG_STD_VECTOR_MINIMUM_INTERNAL(CSINTERFACE, CONST_REFERENCE, 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 %{ +%typemap(csinterfaces) std::vector< CTYPE > "IDisposable, System.Collections.IEnumerable\n#if !SWIG_DOTNET_1\n , System.Collections.Generic.CSINTERFACE<$typemap(cstype, CTYPE)>\n#endif\n"; +%typemap(cscode) std::vector< CTYPE > %{ public $csclassname(System.Collections.ICollection c) : this() { if (c == null) throw new ArgumentNullException("c"); @@ -222,9 +222,9 @@ vector(const vector &other); %extend { vector(int capacity) throw (std::out_of_range) { - std::vector* pv = 0; + std::vector< CTYPE >* pv = 0; if (capacity >= 0) { - pv = new std::vector(); + pv = new std::vector< CTYPE >(); pv->reserve(capacity); } else { throw std::out_of_range("capacity"); @@ -250,18 +250,18 @@ throw std::out_of_range("index"); } // Takes a deep copy of the elements unlike ArrayList.AddRange - void AddRange(const std::vector& values) { + void AddRange(const std::vector< CTYPE >& values) { $self->insert($self->end(), values.begin(), values.end()); } // Takes a deep copy of the elements unlike ArrayList.GetRange - std::vector *GetRange(int index, int count) throw (std::out_of_range, std::invalid_argument) { + std::vector< CTYPE > *GetRange(int index, int count) throw (std::out_of_range, std::invalid_argument) { if (index < 0) throw std::out_of_range("index"); if (count < 0) throw std::out_of_range("count"); if (index >= (int)$self->size()+1 || index+count > (int)$self->size()) throw std::invalid_argument("invalid range"); - return new std::vector($self->begin()+index, $self->begin()+index+count); + return new std::vector< CTYPE >($self->begin()+index, $self->begin()+index+count); } void Insert(int index, CTYPE const& x) throw (std::out_of_range) { if (index>=0 && index<(int)$self->size()+1) @@ -270,7 +270,7 @@ throw std::out_of_range("index"); } // Takes a deep copy of the elements unlike ArrayList.InsertRange - void InsertRange(int index, const std::vector& values) throw (std::out_of_range) { + void InsertRange(int index, const std::vector< CTYPE >& values) throw (std::out_of_range) { if (index>=0 && index<(int)$self->size()+1) $self->insert($self->begin()+index, values.begin(), values.end()); else @@ -291,10 +291,10 @@ throw std::invalid_argument("invalid range"); $self->erase($self->begin()+index, $self->begin()+index+count); } - static std::vector *Repeat(CTYPE const& value, int count) throw (std::out_of_range) { + static std::vector< CTYPE > *Repeat(CTYPE const& value, int count) throw (std::out_of_range) { if (count < 0) throw std::out_of_range("count"); - return new std::vector(count, value); + return new std::vector< CTYPE >(count, value); } void Reverse() { std::reverse($self->begin(), $self->end()); @@ -309,7 +309,7 @@ std::reverse($self->begin()+index, $self->begin()+index+count); } // Takes a deep copy of the elements unlike ArrayList.SetRange - void SetRange(int index, const std::vector& values) throw (std::out_of_range) { + void SetRange(int index, const std::vector< CTYPE >& values) throw (std::out_of_range) { if (index < 0) throw std::out_of_range("index"); if (index+values.size() > $self->size()) @@ -328,20 +328,20 @@ } int IndexOf(CTYPE const& value) { int index = -1; - std::vector::iterator it = std::find($self->begin(), $self->end(), value); + std::vector< CTYPE >::iterator it = std::find($self->begin(), $self->end(), value); if (it != $self->end()) index = (int)(it - $self->begin()); return index; } int LastIndexOf(CTYPE const& value) { int index = -1; - std::vector::reverse_iterator rit = std::find($self->rbegin(), $self->rend(), value); + std::vector< CTYPE >::reverse_iterator rit = std::find($self->rbegin(), $self->rend(), value); if (rit != $self->rend()) index = (int)($self->rend() - 1 - rit); return index; } bool Remove(CTYPE const& value) { - std::vector::iterator it = std::find($self->begin(), $self->end(), value); + std::vector< CTYPE >::iterator it = std::find($self->begin(), $self->end(), value); if (it != $self->end()) { $self->erase(it); return true; @@ -354,7 +354,7 @@ // Macros for std::vector class specializations/enhancements %define SWIG_STD_VECTOR_ENHANCED(CTYPE...) namespace std { - template<> class vector { + template<> class vector< CTYPE > { SWIG_STD_VECTOR_MINIMUM_INTERNAL(IList, %arg(CTYPE const&), %arg(CTYPE)) SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(CTYPE) }; From 490f3a838bd15a8513fdc43a6ff5008facb61998 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 2 Jun 2010 20:00:20 +0000 Subject: [PATCH 0908/1680] mv contributors from website to COPYRIGHT file git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12084 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- COPYRIGHT | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/COPYRIGHT b/COPYRIGHT index 5296b3b48..40d09a1d6 100644 --- a/COPYRIGHT +++ b/COPYRIGHT @@ -58,8 +58,16 @@ Past SWIG developers and 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 and CHANGES.current for a more complete list). + Kovuk, Oleg Tolmatcev, Tal Shalif, Lluis Padro, Chris Seatory, Igor Bely, Robin Dunn, + Edward Zimmermann, David Ascher, Dominique Dumont, Pier Giorgio Esposito, Hasan Baran Kovuk, + Klaus Wiederänders + (See CHANGES and CHANGES.current and the bug tracker for a more complete list). + +Past students: + Songyan Feng (Chicago). + Xinghua Shi (Chicago). + Jing Cao (Chicago). + Aquinas Hobor (Chicago). Historically, the following people contributed to early versions of SWIG. Peter Lomdahl, Brad Holian, Shujia Zhou, Niels Jensen, and Tim Germann @@ -74,3 +82,18 @@ Gary Holt have provided a great deal of input on improving SWIG's Perl5 implementation. Kevin Butler contributed the first Windows NT port. +Early bug reports and patches: +Adam Hupp, Arthur Smyles, Brad Clements, Brett Williams, Buck Hodges, +Burkhard Kloss, Chia-Liang Kao, Craig Files, Dennis Marsa, Dieter Baron, +Drake Diedrich, Fleur Diana Dragan, Gary Pennington, Geoffrey Hort, Gerald Williams, +Greg Anderson, Greg Kochanski, Greg Troxel, Henry Rowley, Irina Kotlova, +Israel Taller, James Bailey, Jim Fulton, Joel Reed, Jon Travis, +Junio Hamano, Justin Heyes-Jones, Karl Forner, Keith Davidson, +Krzysztof Kozminski, Larry Virden, Luke J Crook, Magnus Ljung, Marc Zonzon, +Mark Howson, Micahel Scharf, Michel Sanner, Mike Romberg, Mike Simons, +Mike Weiblen, Paul Brannan, Ram Bhamidipaty, Reinhard Fobbe, Rich Wales, +Richard Salz, Roy Lecates, Rudy Albachten, Scott Drummonds +Scott Michel, Shaun Lowry, Steve Galser, Tarn Weisner Burton, +Thomas Weidner, Tony Seward, Uwe Steinmann, Vadim Chugunov, Wyss Clemens, +Zhong Ren. + From 289cfef4b4766ff266f3b1bdda8ca3a952e5a047 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 2 Jun 2010 20:04:06 +0000 Subject: [PATCH 0909/1680] 2.0.0 release date added git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12085 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- ANNOUNCE | 2 +- CHANGES.current | 4 ++-- Doc/Manual/Sections.html | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ANNOUNCE b/ANNOUNCE index 1327eb124..d9a401553 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -1,4 +1,4 @@ -*** ANNOUNCE: SWIG 2.0.0 (in progress) *** +*** ANNOUNCE: SWIG 2.0.0 (2 June 2010) *** http://www.swig.org diff --git a/CHANGES.current b/CHANGES.current index cde7a5e53..fe0eaf958 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,5 +1,5 @@ -Version 2.0.0 (in progress) -============================ +Version 2.0.0 (2 June 2010) +=========================== See CHANGES for changes in older releases. See RELEASENOTES for a summary of changes in each release. diff --git a/Doc/Manual/Sections.html b/Doc/Manual/Sections.html index 2d795595c..5e36106b5 100644 --- a/Doc/Manual/Sections.html +++ b/Doc/Manual/Sections.html @@ -6,7 +6,7 @@

      SWIG-2.0 Documentation

      -Last update : SWIG-2.0.0 (in progress) +Last update : SWIG-2.0.0 (2 June 2010)

      Sections

      From 2ef2219fe5a027ac04c802b0f8f1c1193979d5cd Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 2 Jun 2010 20:29:48 +0000 Subject: [PATCH 0910/1680] add release date to README file git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12087 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README b/README index 19036dc02..d9288cdae 100644 --- a/README +++ b/README @@ -1,6 +1,6 @@ SWIG (Simplified Wrapper and Interface Generator) -Version: 2.0.0 (in progress) +Version: 2.0.0 (2 June 2010) Tagline: SWIG is a compiler that integrates C and C++ with languages including Perl, Python, Tcl, Ruby, PHP, Java, Ocaml, Lua, From 2b325a6347fa47d619c907c92f2912fc06604dc8 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 2 Jun 2010 20:45:16 +0000 Subject: [PATCH 0911/1680] minor tweaks for release notes uploaded to SF git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12088 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES | 4 ++-- CHANGES.current | 4 ++-- Tools/mkrelease.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CHANGES b/CHANGES index 721a49269..83888c235 100644 --- a/CHANGES +++ b/CHANGES @@ -1,7 +1,7 @@ SWIG (Simplified Wrapper and Interface Generator) -See CHANGES.current for changes in the current version. -See RELEASENOTES for a summary of changes in each release. +See CHANGES.current file for changes in the current version. +See RELEASENOTES file for a summary of changes in each release. Version 1.3.40 (18 August 2009) =============================== diff --git a/CHANGES.current b/CHANGES.current index fe0eaf958..d463d1657 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,8 +1,8 @@ Version 2.0.0 (2 June 2010) =========================== -See CHANGES for changes in older releases. -See RELEASENOTES for a summary of changes in each release. +See CHANGES file for changes in older releases. +See RELEASENOTES file for a summary of changes in each release. 2010-06-02: wsfulton [C#] Fix SWIG_STD_VECTOR_ENHANCED macro used in std::vector to work with diff --git a/Tools/mkrelease.py b/Tools/mkrelease.py index 4b5e7e2e1..7d4c6599e 100755 --- a/Tools/mkrelease.py +++ b/Tools/mkrelease.py @@ -37,7 +37,7 @@ swigwin_dir_sf = username + ",swig@frs.sourceforge.net:/home/frs/project/s/sw/sw 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("cat swig-" + version + "/README " + "swig-" + version + "/CHANGES.current " + "swig-" + version + "/RELEASENOTES " + "> " + 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("") From 88c4336ec2b4638eca32b570b1876a2f9bd7693b Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 2 Jun 2010 21:15:38 +0000 Subject: [PATCH 0912/1680] mention tagging is being done in mkrelease.py git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12090 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Tools/mkrelease.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Tools/mkrelease.py b/Tools/mkrelease.py index 7d4c6599e..fc404d43f 100755 --- a/Tools/mkrelease.py +++ b/Tools/mkrelease.py @@ -42,6 +42,7 @@ os.system("cat swig-" + version + "/README " + "swig-" + version + "/CHANGES.cur 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("") +print "Tagging release" 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" From 2ebbdfc47d653535dd636967f5cabbd521903cd2 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 2 Jun 2010 22:38:41 +0000 Subject: [PATCH 0913/1680] 1.3 => 2.0 for documentation headings git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12094 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Sections.html | 2 +- Doc/Manual/Typemaps.html | 3 ++- Doc/Manual/index.html | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Doc/Manual/Sections.html b/Doc/Manual/Sections.html index 5e36106b5..e957318e8 100644 --- a/Doc/Manual/Sections.html +++ b/Doc/Manual/Sections.html @@ -1,7 +1,7 @@ -SWIG-1.3 Documentation +SWIG-2.0 Documentation

      SWIG-2.0 Documentation

      diff --git a/Doc/Manual/Typemaps.html b/Doc/Manual/Typemaps.html index 5b97c9bae..cacfd5f2f 100644 --- a/Doc/Manual/Typemaps.html +++ b/Doc/Manual/Typemaps.html @@ -1672,7 +1672,8 @@ example.h:3: Searching for a suitable 'in' typemap for: Row4 rows[10]

      showing that the best default match supplied by SWIG is the SWIGTYPE [] typemap. -As the example shows, the successful match displays the used typemap source including typemap method, type and optional name in one of these simplified formats:

      +As the example shows, the successful match displays the used typemap source including typemap method, type and optional name in one of these simplified formats: +

      • Using: %typemap(method) type name diff --git a/Doc/Manual/index.html b/Doc/Manual/index.html index 8560a9199..30c69578f 100644 --- a/Doc/Manual/index.html +++ b/Doc/Manual/index.html @@ -1,10 +1,10 @@ -SWIG-1.3 Documentation +SWIG-2.0 Documentation -

        SWIG-1.3 Development Documentation

        +

        SWIG-2.0 Documentation

        The SWIG documentation is available in one of the following formats.
          From 293426b02a05c3a58ce02c74dc4018fe88b6c9f6 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 3 Jun 2010 06:34:15 +0000 Subject: [PATCH 0914/1680] Bump version to 2.0.1 git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12096 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- ANNOUNCE | 8 +- CHANGES | 666 +++++++++++++++++++++++++++++++++++++- CHANGES.current | 667 +-------------------------------------- Doc/Manual/Sections.html | 2 +- README | 2 +- RELEASENOTES | 8 +- configure.in | 2 +- 7 files changed, 681 insertions(+), 674 deletions(-) diff --git a/ANNOUNCE b/ANNOUNCE index d9a401553..ad3e8f8d6 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -1,8 +1,8 @@ -*** ANNOUNCE: SWIG 2.0.0 (2 June 2010) *** +*** ANNOUNCE: SWIG 2.0.1 (in progress) *** http://www.swig.org -We're pleased to announce SWIG-2.0.0, the latest SWIG release. +We're pleased to announce SWIG-2.0.1, the latest SWIG release. What is SWIG? ============= @@ -21,11 +21,11 @@ Availability ============ The release is available for download on Sourceforge at - http://prdownloads.sourceforge.net/swig/swig-2.0.0.tar.gz + http://prdownloads.sourceforge.net/swig/swig-2.0.1.tar.gz A Windows version is also available at - http://prdownloads.sourceforge.net/swig/swigwin-2.0.0.zip + http://prdownloads.sourceforge.net/swig/swigwin-2.0.1.zip Please report problems with this release to the swig-devel mailing list, details at http://www.swig.org/mail.html. diff --git a/CHANGES b/CHANGES index 83888c235..bd65df32b 100644 --- a/CHANGES +++ b/CHANGES @@ -1,8 +1,672 @@ SWIG (Simplified Wrapper and Interface Generator) -See CHANGES.current file for changes in the current version. +See the CHANGES.current file for changes in the current version. +See the RELEASENOTES file for a summary of changes in each release. + +Version 2.0.0 (2 June 2010) +=========================== + +See CHANGES file for changes in older releases. See RELEASENOTES file for a summary of changes in each release. +2010-06-02: wsfulton + [C#] Fix SWIG_STD_VECTOR_ENHANCED macro used in std::vector to work with + types containing commas, for example: + + SWIG_STD_VECTOR_ENHANCED(std::pair< double, std::string >) + +2010-06-01: wsfulton + Add in std_shared_ptr.i for wrapping std::shared_ptr. Requires the %shared_ptr + macro like in the boost_shared_ptr.i library. std::tr1::shared_ptr can also be + wrapped if the following macro is defined: + + #define SWIG_SHARED_PTR_SUBNAMESPACE tr1 + %include + + shared_ptr is also documented in Library.html now. + +2010-05-27: wsfulton + Add the ability for $typemap special variable macros to call other $typemap + special variable macros, for example: + + %typemap(cstype) CC "CC" + %typemap(cstype) BB "$typemap(cstype, CC)" + %typemap(cstype) AA "$typemap(cstype, BB)" + void hah(AA aa); + + This also fixes C# std::vector containers of shared_ptr and %shared_ptr. + + Also added diagnostics for $typemap with -debug-tmsearch, for example, the + above displays additional diagnostic lines starting "Containing: ": + + example.i:34: Searching for a suitable 'cstype' typemap for: AA aa + Looking for: AA aa + Looking for: AA + Using: %typemap(cstype) AA + Containing: $typemap(cstype, BB) + example.i:31: Searching for a suitable 'cstype' typemap for: BB + Looking for: BB + Using: %typemap(cstype) BB + Containing: $typemap(cstype, CC) + example.i:29: Searching for a suitable 'cstype' typemap for: CC + Looking for: CC + Using: %typemap(cstype) CC + +2010-05-26: olly + Fix %attribute2ref not to produce a syntax error if the last + argument (AccessorMethod) is omitted. Patch from David Piepgras + in SF#2235756. + +2010-05-26: olly + [PHP] When using %throws or %catches, SWIG-generated PHP5 wrappers + now throw PHP Exception objects instead of giving a PHP error of + type E_ERROR. + + This change shouldn't cause incompatibility issues, since you can't + set an error handler for E_ERROR, so previously PHP would just exit + which also happens for unhandled exceptions. The benefit is you can + now catch them if you want to. + + Fixes SF#2545578 and SF#2955522. + +2010-05-25: olly + [PHP] Add missing directorin typemap for const std::string &. + Fixes SF#3006404 reported by t-Legiaw. + +2010-05-23: wsfulton + [C#] Fix #2957375 - SWIGStringHelper and SWIGExceptionHelper not always being + initialized before use in .NET 4 as the classes were not marked beforefieldinit. + A static constructor has been added to the intermediary class like this: + + %pragma(csharp) imclasscode=%{ + static $imclassname() { + } + %} + + If you had added your own custom static constructor to the intermediary class in + the same way as above, you will have to modify your approach to use static variable + initialization or define SWIG_CSHARP_NO_IMCLASS_STATIC_CONSTRUCTOR - See csharphead.swg. + + *** POTENTIAL INCOMPATIBILITY *** + +2010-05-23: wsfulton + Fix #2408232. Improve shared_ptr and intrusive_ptr wrappers for classes in an + inheritance hierarchy. No special treatment is needed for derived classes. + The proxy class also no longer needs to be specified, it is automatically + deduced. The following macros are deprecated: + SWIG_SHARED_PTR(PROXYCLASS, TYPE) + SWIG_SHARED_PTR_DERIVED(PROXYCLASS, BASECLASSTYPE, TYPE) + and have been replaced by + %shared_ptr(TYPE) + Similarly for intrusive_ptr wrappers, the following macro is deprecated: + SWIG_INTRUSIVE_PTR(PROXYCLASS, TYPE) + SWIG_INTRUSIVE_PTR_DERIVED(PROXYCLASS, BASECLASSTYPE, TYPE) + and have been replaced by + %intrusive_ptr(TYPE) + +2010-05-21: olly + [PHP] Stop generating a bogus line of code in certain constructors. + This was mostly harmless, but caused a PHP notice to be issued, if + enabled (SF#2985684). + +2010-05-18: wsfulton + [Java] Fix member pointers on 64 bit platforms. + +2010-05-14: wsfulton + Fix wrapping of C++ enum boolean values reported by Torsten Landschoff: + typedef enum { PLAY = true, STOP = false } play_state; + +2010-05-14: olly + [PHP] Fix wrapping of global variables which was producing + uncompilable code in some cases. + +2010-05-12: drjoe + [R] Add two more changes from Wil Nolan. Get garbage + collection to work. Implement newfree + +2010-05-09: drjoe + Fix bug reported by Wil Nolan change creation of string so + that R 2.7.0+ can use char hashes + +2010-05-07: wsfulton + Apply patch #2955146 from Sergey Satskiy to fix expressions containing divide by + operator in constructor initialization lists. + +2010-05-05: wsfulton + [R] Memory leak fix handling const std::string & inputs, reported by Will Nolan. + +2010-05-01: wsfulton + Typemap matching enhancement for non-default typemaps. Previously all + qualifiers were stripped in one step, now they are stripped one at a time + starting with the left most qualifier. For example, int const*const + is first stripped to int *const then int *. + + *** POTENTIAL INCOMPATIBILITY *** + +2010-04-25: bhy + [Python] Fix #2985655 - broken constructor renaming. + +2010-04-14: wsfulton + Typemap fragments are now official and documented in Typemaps.html. + +2010-04-09: wsfulton + [Ruby] Fix #2048064 and #2408020. + Apply Ubuntu patch to fix Ruby and std::vector wrappers with -minherit. + https://bugs.launchpad.net/ubuntu/+source/swig1.3/+bug/522874 + +2010-04-09: wsfulton + [Mzscheme] Apply Ubuntu patch to fix std::map wrappers: + https://bugs.launchpad.net/ubuntu/+source/swig1.3/+bug/203876 + +2010-04-09: wsfulton + [Python] Apply patch #2952374 - fix directors and the -nortti option. + +2010-04-09: wsfulton + [Lua] Fix #2887254 and #2946032 - SWIG_Lua_typename using wrong stack index. + +2010-04-03: wsfulton + [Python] Fix exceptions being thrown with the -threads option based on patch from Arto Vuori. + Fixes bug #2818499. + +2010-04-03: wsfulton + Fix Makefile targets: distclean and maintainer-clean + +2010-04-02: wsfulton + [Lua] Fix char pointers, wchar_t pointers and char arrays so that nil can be passed as a + valid value. Bug reported by Gedalia Pasternak. + +2010-04-01: wsfulton + Numerous subtle typemap matching rule fixes when using the default type. The typemap + matching rules are to take a type and find the best default typemap (SWIGTYPE, SWIGTYPE* etc), + then look for the next best match by reducing the chosen default type. The type deduction + now follows C++ class template partial specialization matching rules. + + Below are the set of changes made showing the default type deduction + along with the old reduced type and the new version of the reduced type: + + SWIGTYPE const &[ANY] + new: SWIGTYPE const &[] + old: SWIGTYPE (&)[ANY] + + SWIGTYPE *const [ANY] + new: SWIGTYPE const [ANY] + old: SWIGTYPE *[ANY] + + SWIGTYPE const *const [ANY] + new: SWIGTYPE *const [ANY] + old: SWIGTYPE const *[ANY] + + SWIGTYPE const *const & + new: SWIGTYPE *const & + old: SWIGTYPE const *& + + SWIGTYPE *const * + new: SWIGTYPE const * + old: SWIGTYPE ** + + SWIGTYPE *const & + new: SWIGTYPE const & + old: SWIGTYPE *& + + Additionally, a const SWIGTYPE lookup is used now for any constant type. Some examples, where + T is some reduced type, eg int, struct Foo: + + T const + new: SWIGTYPE const + old: SWIGTYPE + + T *const + new: SWIGTYPE *const + old: SWIGTYPE * + + T const[] + new: SWIGTYPE const[] + old: SWIGTYPE[] + + enum T const + new: enum SWIGTYPE const + old: enum SWIGTYPE + + T (*const )[] + new: SWIGTYPE (*const )[] + old: SWIGTYPE (*)[] + + Reminder: the typemap matching rules can now be seen for any types being wrapped by using + either the -debug-tmsearch or -debug-tmused options. + + In practice this leads to some subtle matching rule changes and the majority of users + won't notice any changes, except in the prime area of motivation for this change: Improve + STL containers of const pointers and passing const pointers by reference. This is fixed + because many of the STL containers use a type 'T const&' as parameters and when T is + a const pointer, for example, 'K const*', then the full type is 'K const*const&'. This + means that the 'SWIGTYPE *const&' typemaps now match when T is either a non-const or + const pointer. Furthermore, some target languages incorrectly had 'SWIGTYPE *&' typemaps + when these should have been 'SWIGTYPE *const&'. These have been corrected (Java, C#, Lua, PHP). + + *** POTENTIAL INCOMPATIBILITY *** + +2010-03-13: wsfulton + [Java] Some very old deprecated pragma warnings are now errors. + +2010-03-13: wsfulton + Improve handling of file names and directories containing double/multiple path separators. + +2010-03-10: mutandiz (Mikel Bancroft) + [allegrocl] Use fully qualified symbol name of cl::identity in emit_defun(). + +2010-03-06: wsfulton + [Java] The intermediary JNI class modifiers are now public by default meaning these + intermediary low level functions are now accessible by default from outside any package + used. The proxy class pointer constructor and getCPtr() methods are also now public. + These are needed in order for the nspace option to work without any other mods. + The previous default of protected access can be restored using: + + SWIG_JAVABODY_METHODS(protected, protected, SWIGTYPE) + %pragma(java) jniclassclassmodifiers = "class" + +2010-03-06: wsfulton + [C#] Added the nspace feature for C#. Documentation for the nspace feature is now available. + +2010-03-04: wsfulton + Added the nspace feature. This adds some improved namespace support. Currently only Java + is supported for target languages, where C++ namespaces are automatically translated into + Java packages. The feature only applies to classes,struct,unions and enums declared within + a namespace. Methods and variables declared in namespaces still effectively have their + namespaces flattened. Example usage: + + %feature(nspace) Outer::Inner1::Color; + %feature(nspace) Outer::Inner2::Color; + + namespace Outer { + namespace Inner1 { + struct Color { + ... + }; + } + namespace Inner2 { + struct Color { + ... + }; + } + } + + For Java, the -package option is also required when using the nspace feature. Say + we use -package com.myco, the two classes can then be accessed as follows from Java: + + com.myco.Outer.Inner1.Color and com.myco.Outer.Inner2.Color. + +2010-02-27: wsfulton + [Python] Remove -dirvtable from the optimizations included by -O as it this option + currently leads to memory leaks as reported by Johan Blake. + +2010-02-27: wsfulton + License code changes: SWIG Source is GPL-v3 and library code license is now clearer + and is provided under a very permissive license. See http://www.swig.org/legal.html. + +2010-02-13: wsfulton + [Ruby] A few fixes for compiling under ruby-1.9.x including patch from 'Nibble'. + +2010-02-13: wsfulton + [Ruby] Apply patch from Patrick Bennett to fix RARRAY_LEN and RARRAY_PTR usage for Ruby 1.9.x + used in various STL wrappers. + +2010-02-13: wsfulton + [C#, Java] Fix incorrect multiply defined symbol name error when an enum item + and class name have the same name, as reported by Nathan Krieger. Example: + + class Vector {}; + namespace Text { + enum Preference { Vector }; + } + + This also fixes other incorrect corner case target language symbol name clashes. + +2010-02-11: wsfulton + Add the -debug-lsymbols option for displaying the target language layer symbols. + +2010-02-09: wsfulton + Fix -MM and -MMD options on Windows. They were not omitting files in the SWIG library as + they should be. + +2010-02-08: wsfulton + Fix #1807329 - When Makefile dependencies are being generated using the -M family of options + on Windows, the file paths have been corrected to use single backslashes rather than double + backslashes as path separators. + +2010-02-06: wsfulton + Fix #2918902 - language specific files not being generated in correct directory on + Windows when using forward slashes for -o, for example: + swig -python -c++ -o subdirectory/theinterface_wrap.cpp subdirectory/theinterface.i + +2010-02-05: wsfulton + Fix #2894405 - assertion when using -xmlout. + +2010-01-28: wsfulton + Fix typemap matching bug when a templated type has a typemap both specialized and not + specialized. For example: + + template struct XX { ... }; + %typemap(in) const XX & "..." + %typemap(in) const XX< int > & "..." + + resulted in the 2nd typemap being applied for all T in XX< T >. + +2010-01-22: wsfulton + Fix #2933129 - typemaps not being found when the unary scope operator (::) is used to denote + global scope, the typemap is now used in situations like this: + + struct X {}; + %typemap(in) const X & "..." + void m(const ::X &); + + and this: + + struct X {}; + %typemap(in) const ::X & "..." + void m(const X &); + +2010-01-20: wsfulton + Fix some unary scope operator (::) denoting global scope problems in the types generated + into the C++ layer. Previously the unary scope operator was dropped in the generated code + if the type had any sort of qualifier, for example when using pointers, references, like + ::foo*, ::foo&, bar< ::foo* >. + +2010-01-13: olly + [PHP] Add datetime to the list of PHP predefined classes (patch + from David Fletcher in SF#2931042). + +2010-01-11: wsfulton + Slight change to warning, error and diagnostic reporting. The warning number is no + longer shown within brackets. This is to help default parsing of warning messages by + other tools, vim on Unix in particular. + + Example original display using -Fstandard: + example.i:20: Warning(401): Nothing known about base class 'B'. Ignored. + New display: + example.i:20: Warning 401: Nothing known about base class 'B'. Ignored. + + Also subtle fix to -Fmicrosoft format adding in missing space. Example original display: + example.i(20): Warning(401): Nothing known about base class 'Base'. Ignored. + New display: + example.i(20) : Warning 401: Nothing known about base class 'Base'. Ignored. + +2010-01-10: wsfulton + Fix a few inconsistencies in reporting of file/line numberings including modifying + the overload warnings 509, 512, 516, 474, 475 to now be two line warnings. + +2010-01-10: wsfulton + Modify -debug-tags output to use standard file name/line reporting so that editors + can easily navigate to the appropriate lines. + Was typically: + . top . include . include (/usr/share/swig/temp/trunk/Lib/swig.swg:312) + . top . include . include . include (/usr/share/swig/temp/trunk/Lib/swigwarnings.swg:39) + now: + /usr/share/swig/temp/trunk/Lib/swig.swg:312: . top . include . include + /usr/share/swig/temp/trunk/Lib/swigwarnings.swg:39: . top . include . include . include + +2010-01-03: wsfulton + Fix missing file/line numbers for typemap warnings and in output from the + -debug-tmsearch/-debug-tmused options. + +2010-01-03: wsfulton + Add typemaps used debugging option (-debug-tmused). When used each line displays + the typemap used for each type for which code is being generated including the file + and line number related to the type. This is effectively a condensed form of the + -debug-tmsearch option. Documented in Typemaps.html. + +2009-12-23: wsfulton + Fix for %javaexception and directors so that all the appropriate throws clauses + are generated. Problem reported by Peter Greenwood. + +2009-12-20: wsfulton + Add -debug-tmsearch option for debugging the typemap pattern matching rules. + Documented in Typemaps.html. + +2009-12-12: wsfulton + [Octave] Remove the -api option and use the new OCTAVE_API_VERSION_NUMBER + macro provided in the octave headers for determining the api version instead. + +2009-12-04: olly + [Ruby] Improve support for Ruby 1.9 under GCC. Addresses part of + SF#2859614. + +2009-12-04: olly + Fix handling of modulo operator (%) in constant expressions + (SF#2818562). + +2009-12-04: olly + [PHP] "empty" is a reserved word in PHP, so rename empty() method + on STL classes to "is_empty()" (previously this was automatically + renamed to "c_empty()"). + *** POTENTIAL INCOMPATIBILITY *** + +2009-12-03: olly + [PHP] Add typemaps for long long and unsigned long long, and for + pointer to method. + +2009-12-02: olly + [PHP] Fix warning and rename of reserved class name to be case + insensitive. + +2009-12-01: wsfulton + Revert support for %extend and memberin typemaps added in swig-1.3.39. The + memberin typemaps are ignored again for member variables within a %extend block. + Documentation inconsistency reported by Torsten Landschoff. + +2009-11-29: wsfulton + [Java, C#] Fix generated quoting when using %javaconst(1)/%csconst(1) for + static const char member variables. + + %javaconst(1) A; + %csconst(1) A; + struct X { + static const char A = 'A'; + }; + +2009-11-26: wsfulton + [Java, C#] Fix %javaconst(1)/%csconst(1) for static const member variables to + use the actual constant value if it is specified, rather than the C++ code to + access the member. + + %javaconst(1) EN; + %csconst(1) EN; + struct X { + static const int EN = 2; + }; + +2009-11-23: wsfulton + C++ nested typedef classes can now be handled too, for example: + struct Outer { + typedef Foo { } FooTypedef1, FooTypedef2; + }; + +2009-11-18: wsfulton + The wrappers for C nested structs are now generated in the same order as declared + in the parsed code. + +2009-11-18: wsfulton + Fix #491476 - multiple declarations of nested structs, for example: + struct Outer { + struct { + int val; + } inner1, inner2, *inner3, inner4[1]; + } outer; + +2009-11-17: wsfulton + Fix parsing of enum declaration and initialization, for example: + + enum ABC { + a, + b, + c + } A = a, *pC = &C, array[3] = {a, b, c}; + +2009-11-17: wsfulton + Fix parsing of struct declaration and initialization, for example: + + struct S { + int x; + } instance = { 10 }; + +2009-11-15: wsfulton + Fix #1960977 - Syntax error parsing derived nested class declaration and member + variable instance. + +2009-11-14: wsfulton + Fix #2310483 - function pointer typedef within extern "C" block. + +2009-11-13: wsfulton + Fix usage of nested template classes within templated classes so that compileable code + is generated. + +2009-11-13: olly + [php] Fix place where class prefix (as specified with -prefix) + wasn't being used. Patch from gverbruggen in SF#2892647. + +2009-11-12: wsfulton + Fix usage of nested template classes so that compileable code is generated - the nested + template class is now treated like a normal nested classes, that is, as an opaque type + unless the nestedworkaround feature is used. + +2009-11-12: wsfulton + Replace SWIGWARN_PARSE_NESTED_CLASS with SWIGWARN_PARSE_NAMED_NESTED_CLASS and + SWIGWARN_PARSE_UNNAMED_NESTED_CLASS for named and unnamed nested classes respectively. + + Named nested class ignored warnings can now be suppressed by name using %warnfilter, eg: + + %warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer::Inner; + + but clearly unnamed nested classes cannot and the global suppression is still required, eg: + + #pragma SWIG nowarn=SWIGWARN_PARSE_UNNAMED_NESTED_CLASS + +2009-11-11: wsfulton + Added the nestedworkaround feature as a way to use the full functionality of a nested class + (C++ mode only). It removes the nested class from SWIG's type information so it is as if SWIG + had never parsed the nested class. The documented nested class workarounds using a global + fake class stopped working when SWIG treated the nested class as an opaque pointer, and + this feature reverts this behaviour. The documentation has been updated with details of how + to use and implement it, see the "Nested classes" section in SWIGPlus.html. + +2009-11-11: wsfulton + There were a number of C++ cases where nested classes/structs/unions were being handled + as if C code was being parsed which would oftentimes lead to uncompileable code as an + attempt was made to wrap the nested structs like it is documented for C code. Now all + nested structs/classes/unions are ignored in C++ mode, as was always documented. However, + there is an improvement as usage of nested structs/classes/unions is now always treated + as an opaque type by default, resulting in generated code that should always compile. + + *** POTENTIAL INCOMPATIBILITY *** + +2009-11-09: drjoe + Fix R for -fcompact and add std_map.i + +2009-11-08: wsfulton + Fix inconsistency for nested structs/unions/classes. Uncompileable code was being + generated when inner struct and union declarations were used as types within the + inner struct. The inner struct/union is now treated as a forward declaration making the + behaviour the same as an inner class. (C++ code), eg: + + struct Outer { + struct InnerStruct { int x; }; + InnerStruct* getInnerStruct(); + }; + +2009-11-08: wsfulton + Ignored nested class/struct warnings now display the name of the ignored class/struct. + +2009-11-07: wsfulton + Bug #1514681 - Fix nested template classes within a namespace generated uncompileable + code and introduced strange side effects to other wrapper code especially code + after the nested template class. Note that nested template classes are still ignored. + +2009-11-07: wsfulton + Add new debug options: + -debug-symtabs - Display symbol tables information + -debug-symbols - Display target language symbols in the symbol tables + -debug-csymbols - Display C symbols in the symbol tables + +2009-11-03: wsfulton + Fix some usage of unary scope operator (::) denoting global scope, for example: + + namespace AA { /* ... */ } + using namespace ::AA; + + and bug #1816802 - SwigValueWrapper should be used: + + struct CC { + CC(int); // no default constructor + }; + ::CC x(); + + and in template parameter specializations: + + struct S {}; + template struct X { void a() {}; }; + template <> struct X { void b() {}; }; + %template(MyTConcrete) X< ::S >; + + plus probably some other corner case usage of ::. + +2009-11-02: olly + [Python] Fix potential memory leak in initialisation code for the + generated module. + +2009-10-23: wsfulton + Fix seg fault when using a named nested template instantiation using %template(name) + within a class. A warning that these are not supported is now issued plus processing + continues as if no name was given. + +2009-10-20: wsfulton + [Python] Fix std::vector. This would previously compile, but not run correctly. + +2009-10-20: wsfulton + Fixed previously fairly poor template partial specialization and explicit + specialization support. Numerous bugs in this area have been fixed including: + + - Template argument deduction implemented for template type arguments, eg this now + works: + template class X {}; + template class X {}; + %template(X1) X; // Chooses T * specialization + + and more complex cases with multiple parameters and a mix of template argument + deduction and explicitly specialised parameters, eg: + template struct TwoParm { void a() {} }; + template struct TwoParm { void e() {} }; + %template(E) TwoParm; + + Note that the primary template must now be in scope, like in C++, when + an explicit or partial specialization is instantiated with %template. + + *** POTENTIAL INCOMPATIBILITY *** + +2009-09-14: wsfulton + [C#] Add %csattributes for adding C# attributes to enum values, see docs for example. + +2009-09-11: wsfulton + Fix memmove regression in cdata.i as reported by Adriaan Renting. + +2009-09-07: wsfulton + Fix constant expressions containing <= or >=. + +2009-09-02: wsfulton + The following operators in constant expressions now result in type bool for C++ + wrappers and remain as type int for C wrappers, as per each standard: + + && || == != < > <= >= (Actually the last 4 are still broken). For example: + + #define A 10 + #define B 10 + #define A_EQ_B A == B // now wrapped as type bool for C++ + #define A_AND_B A && B // now wrapped as type bool for C++ + +2009-09-02: wsfulton + Fix #2845746. true and false are now recognised keywords (only when wrapping C++). + Constants such as the following are now wrapped (as type bool): + #define FOO true + #define BAR FOO && false + Version 1.3.40 (18 August 2009) =============================== diff --git a/CHANGES.current b/CHANGES.current index d463d1657..9982286c2 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,664 +1,7 @@ -Version 2.0.0 (2 June 2010) +This file contains the changes for the current release. +See the CHANGES file for changes in older releases. +See the RELEASENOTES file for a summary of changes in each release. + +Version 2.0.1 (in progress) =========================== -See CHANGES file for changes in older releases. -See RELEASENOTES file for a summary of changes in each release. - -2010-06-02: wsfulton - [C#] Fix SWIG_STD_VECTOR_ENHANCED macro used in std::vector to work with - types containing commas, for example: - - SWIG_STD_VECTOR_ENHANCED(std::pair< double, std::string >) - -2010-06-01: wsfulton - Add in std_shared_ptr.i for wrapping std::shared_ptr. Requires the %shared_ptr - macro like in the boost_shared_ptr.i library. std::tr1::shared_ptr can also be - wrapped if the following macro is defined: - - #define SWIG_SHARED_PTR_SUBNAMESPACE tr1 - %include - - shared_ptr is also documented in Library.html now. - -2010-05-27: wsfulton - Add the ability for $typemap special variable macros to call other $typemap - special variable macros, for example: - - %typemap(cstype) CC "CC" - %typemap(cstype) BB "$typemap(cstype, CC)" - %typemap(cstype) AA "$typemap(cstype, BB)" - void hah(AA aa); - - This also fixes C# std::vector containers of shared_ptr and %shared_ptr. - - Also added diagnostics for $typemap with -debug-tmsearch, for example, the - above displays additional diagnostic lines starting "Containing: ": - - example.i:34: Searching for a suitable 'cstype' typemap for: AA aa - Looking for: AA aa - Looking for: AA - Using: %typemap(cstype) AA - Containing: $typemap(cstype, BB) - example.i:31: Searching for a suitable 'cstype' typemap for: BB - Looking for: BB - Using: %typemap(cstype) BB - Containing: $typemap(cstype, CC) - example.i:29: Searching for a suitable 'cstype' typemap for: CC - Looking for: CC - Using: %typemap(cstype) CC - -2010-05-26: olly - Fix %attribute2ref not to produce a syntax error if the last - argument (AccessorMethod) is omitted. Patch from David Piepgras - in SF#2235756. - -2010-05-26: olly - [PHP] When using %throws or %catches, SWIG-generated PHP5 wrappers - now throw PHP Exception objects instead of giving a PHP error of - type E_ERROR. - - This change shouldn't cause incompatibility issues, since you can't - set an error handler for E_ERROR, so previously PHP would just exit - which also happens for unhandled exceptions. The benefit is you can - now catch them if you want to. - - Fixes SF#2545578 and SF#2955522. - -2010-05-25: olly - [PHP] Add missing directorin typemap for const std::string &. - Fixes SF#3006404 reported by t-Legiaw. - -2010-05-23: wsfulton - [C#] Fix #2957375 - SWIGStringHelper and SWIGExceptionHelper not always being - initialized before use in .NET 4 as the classes were not marked beforefieldinit. - A static constructor has been added to the intermediary class like this: - - %pragma(csharp) imclasscode=%{ - static $imclassname() { - } - %} - - If you had added your own custom static constructor to the intermediary class in - the same way as above, you will have to modify your approach to use static variable - initialization or define SWIG_CSHARP_NO_IMCLASS_STATIC_CONSTRUCTOR - See csharphead.swg. - - *** POTENTIAL INCOMPATIBILITY *** - -2010-05-23: wsfulton - Fix #2408232. Improve shared_ptr and intrusive_ptr wrappers for classes in an - inheritance hierarchy. No special treatment is needed for derived classes. - The proxy class also no longer needs to be specified, it is automatically - deduced. The following macros are deprecated: - SWIG_SHARED_PTR(PROXYCLASS, TYPE) - SWIG_SHARED_PTR_DERIVED(PROXYCLASS, BASECLASSTYPE, TYPE) - and have been replaced by - %shared_ptr(TYPE) - Similarly for intrusive_ptr wrappers, the following macro is deprecated: - SWIG_INTRUSIVE_PTR(PROXYCLASS, TYPE) - SWIG_INTRUSIVE_PTR_DERIVED(PROXYCLASS, BASECLASSTYPE, TYPE) - and have been replaced by - %intrusive_ptr(TYPE) - -2010-05-21: olly - [PHP] Stop generating a bogus line of code in certain constructors. - This was mostly harmless, but caused a PHP notice to be issued, if - enabled (SF#2985684). - -2010-05-18: wsfulton - [Java] Fix member pointers on 64 bit platforms. - -2010-05-14: wsfulton - Fix wrapping of C++ enum boolean values reported by Torsten Landschoff: - typedef enum { PLAY = true, STOP = false } play_state; - -2010-05-14: olly - [PHP] Fix wrapping of global variables which was producing - uncompilable code in some cases. - -2010-05-12: drjoe - [R] Add two more changes from Wil Nolan. Get garbage - collection to work. Implement newfree - -2010-05-09: drjoe - Fix bug reported by Wil Nolan change creation of string so - that R 2.7.0+ can use char hashes - -2010-05-07: wsfulton - Apply patch #2955146 from Sergey Satskiy to fix expressions containing divide by - operator in constructor initialization lists. - -2010-05-05: wsfulton - [R] Memory leak fix handling const std::string & inputs, reported by Will Nolan. - -2010-05-01: wsfulton - Typemap matching enhancement for non-default typemaps. Previously all - qualifiers were stripped in one step, now they are stripped one at a time - starting with the left most qualifier. For example, int const*const - is first stripped to int *const then int *. - - *** POTENTIAL INCOMPATIBILITY *** - -2010-04-25: bhy - [Python] Fix #2985655 - broken constructor renaming. - -2010-04-14: wsfulton - Typemap fragments are now official and documented in Typemaps.html. - -2010-04-09: wsfulton - [Ruby] Fix #2048064 and #2408020. - Apply Ubuntu patch to fix Ruby and std::vector wrappers with -minherit. - https://bugs.launchpad.net/ubuntu/+source/swig1.3/+bug/522874 - -2010-04-09: wsfulton - [Mzscheme] Apply Ubuntu patch to fix std::map wrappers: - https://bugs.launchpad.net/ubuntu/+source/swig1.3/+bug/203876 - -2010-04-09: wsfulton - [Python] Apply patch #2952374 - fix directors and the -nortti option. - -2010-04-09: wsfulton - [Lua] Fix #2887254 and #2946032 - SWIG_Lua_typename using wrong stack index. - -2010-04-03: wsfulton - [Python] Fix exceptions being thrown with the -threads option based on patch from Arto Vuori. - Fixes bug #2818499. - -2010-04-03: wsfulton - Fix Makefile targets: distclean and maintainer-clean - -2010-04-02: wsfulton - [Lua] Fix char pointers, wchar_t pointers and char arrays so that nil can be passed as a - valid value. Bug reported by Gedalia Pasternak. - -2010-04-01: wsfulton - Numerous subtle typemap matching rule fixes when using the default type. The typemap - matching rules are to take a type and find the best default typemap (SWIGTYPE, SWIGTYPE* etc), - then look for the next best match by reducing the chosen default type. The type deduction - now follows C++ class template partial specialization matching rules. - - Below are the set of changes made showing the default type deduction - along with the old reduced type and the new version of the reduced type: - - SWIGTYPE const &[ANY] - new: SWIGTYPE const &[] - old: SWIGTYPE (&)[ANY] - - SWIGTYPE *const [ANY] - new: SWIGTYPE const [ANY] - old: SWIGTYPE *[ANY] - - SWIGTYPE const *const [ANY] - new: SWIGTYPE *const [ANY] - old: SWIGTYPE const *[ANY] - - SWIGTYPE const *const & - new: SWIGTYPE *const & - old: SWIGTYPE const *& - - SWIGTYPE *const * - new: SWIGTYPE const * - old: SWIGTYPE ** - - SWIGTYPE *const & - new: SWIGTYPE const & - old: SWIGTYPE *& - - Additionally, a const SWIGTYPE lookup is used now for any constant type. Some examples, where - T is some reduced type, eg int, struct Foo: - - T const - new: SWIGTYPE const - old: SWIGTYPE - - T *const - new: SWIGTYPE *const - old: SWIGTYPE * - - T const[] - new: SWIGTYPE const[] - old: SWIGTYPE[] - - enum T const - new: enum SWIGTYPE const - old: enum SWIGTYPE - - T (*const )[] - new: SWIGTYPE (*const )[] - old: SWIGTYPE (*)[] - - Reminder: the typemap matching rules can now be seen for any types being wrapped by using - either the -debug-tmsearch or -debug-tmused options. - - In practice this leads to some subtle matching rule changes and the majority of users - won't notice any changes, except in the prime area of motivation for this change: Improve - STL containers of const pointers and passing const pointers by reference. This is fixed - because many of the STL containers use a type 'T const&' as parameters and when T is - a const pointer, for example, 'K const*', then the full type is 'K const*const&'. This - means that the 'SWIGTYPE *const&' typemaps now match when T is either a non-const or - const pointer. Furthermore, some target languages incorrectly had 'SWIGTYPE *&' typemaps - when these should have been 'SWIGTYPE *const&'. These have been corrected (Java, C#, Lua, PHP). - - *** POTENTIAL INCOMPATIBILITY *** - -2010-03-13: wsfulton - [Java] Some very old deprecated pragma warnings are now errors. - -2010-03-13: wsfulton - Improve handling of file names and directories containing double/multiple path separators. - -2010-03-10: mutandiz (Mikel Bancroft) - [allegrocl] Use fully qualified symbol name of cl::identity in emit_defun(). - -2010-03-06: wsfulton - [Java] The intermediary JNI class modifiers are now public by default meaning these - intermediary low level functions are now accessible by default from outside any package - used. The proxy class pointer constructor and getCPtr() methods are also now public. - These are needed in order for the nspace option to work without any other mods. - The previous default of protected access can be restored using: - - SWIG_JAVABODY_METHODS(protected, protected, SWIGTYPE) - %pragma(java) jniclassclassmodifiers = "class" - -2010-03-06: wsfulton - [C#] Added the nspace feature for C#. Documentation for the nspace feature is now available. - -2010-03-04: wsfulton - Added the nspace feature. This adds some improved namespace support. Currently only Java - is supported for target languages, where C++ namespaces are automatically translated into - Java packages. The feature only applies to classes,struct,unions and enums declared within - a namespace. Methods and variables declared in namespaces still effectively have their - namespaces flattened. Example usage: - - %feature(nspace) Outer::Inner1::Color; - %feature(nspace) Outer::Inner2::Color; - - namespace Outer { - namespace Inner1 { - struct Color { - ... - }; - } - namespace Inner2 { - struct Color { - ... - }; - } - } - - For Java, the -package option is also required when using the nspace feature. Say - we use -package com.myco, the two classes can then be accessed as follows from Java: - - com.myco.Outer.Inner1.Color and com.myco.Outer.Inner2.Color. - -2010-02-27: wsfulton - [Python] Remove -dirvtable from the optimizations included by -O as it this option - currently leads to memory leaks as reported by Johan Blake. - -2010-02-27: wsfulton - License code changes: SWIG Source is GPL-v3 and library code license is now clearer - and is provided under a very permissive license. See http://www.swig.org/legal.html. - -2010-02-13: wsfulton - [Ruby] A few fixes for compiling under ruby-1.9.x including patch from 'Nibble'. - -2010-02-13: wsfulton - [Ruby] Apply patch from Patrick Bennett to fix RARRAY_LEN and RARRAY_PTR usage for Ruby 1.9.x - used in various STL wrappers. - -2010-02-13: wsfulton - [C#, Java] Fix incorrect multiply defined symbol name error when an enum item - and class name have the same name, as reported by Nathan Krieger. Example: - - class Vector {}; - namespace Text { - enum Preference { Vector }; - } - - This also fixes other incorrect corner case target language symbol name clashes. - -2010-02-11: wsfulton - Add the -debug-lsymbols option for displaying the target language layer symbols. - -2010-02-09: wsfulton - Fix -MM and -MMD options on Windows. They were not omitting files in the SWIG library as - they should be. - -2010-02-08: wsfulton - Fix #1807329 - When Makefile dependencies are being generated using the -M family of options - on Windows, the file paths have been corrected to use single backslashes rather than double - backslashes as path separators. - -2010-02-06: wsfulton - Fix #2918902 - language specific files not being generated in correct directory on - Windows when using forward slashes for -o, for example: - swig -python -c++ -o subdirectory/theinterface_wrap.cpp subdirectory/theinterface.i - -2010-02-05: wsfulton - Fix #2894405 - assertion when using -xmlout. - -2010-01-28: wsfulton - Fix typemap matching bug when a templated type has a typemap both specialized and not - specialized. For example: - - template struct XX { ... }; - %typemap(in) const XX & "..." - %typemap(in) const XX< int > & "..." - - resulted in the 2nd typemap being applied for all T in XX< T >. - -2010-01-22: wsfulton - Fix #2933129 - typemaps not being found when the unary scope operator (::) is used to denote - global scope, the typemap is now used in situations like this: - - struct X {}; - %typemap(in) const X & "..." - void m(const ::X &); - - and this: - - struct X {}; - %typemap(in) const ::X & "..." - void m(const X &); - -2010-01-20: wsfulton - Fix some unary scope operator (::) denoting global scope problems in the types generated - into the C++ layer. Previously the unary scope operator was dropped in the generated code - if the type had any sort of qualifier, for example when using pointers, references, like - ::foo*, ::foo&, bar< ::foo* >. - -2010-01-13: olly - [PHP] Add datetime to the list of PHP predefined classes (patch - from David Fletcher in SF#2931042). - -2010-01-11: wsfulton - Slight change to warning, error and diagnostic reporting. The warning number is no - longer shown within brackets. This is to help default parsing of warning messages by - other tools, vim on Unix in particular. - - Example original display using -Fstandard: - example.i:20: Warning(401): Nothing known about base class 'B'. Ignored. - New display: - example.i:20: Warning 401: Nothing known about base class 'B'. Ignored. - - Also subtle fix to -Fmicrosoft format adding in missing space. Example original display: - example.i(20): Warning(401): Nothing known about base class 'Base'. Ignored. - New display: - example.i(20) : Warning 401: Nothing known about base class 'Base'. Ignored. - -2010-01-10: wsfulton - Fix a few inconsistencies in reporting of file/line numberings including modifying - the overload warnings 509, 512, 516, 474, 475 to now be two line warnings. - -2010-01-10: wsfulton - Modify -debug-tags output to use standard file name/line reporting so that editors - can easily navigate to the appropriate lines. - Was typically: - . top . include . include (/usr/share/swig/temp/trunk/Lib/swig.swg:312) - . top . include . include . include (/usr/share/swig/temp/trunk/Lib/swigwarnings.swg:39) - now: - /usr/share/swig/temp/trunk/Lib/swig.swg:312: . top . include . include - /usr/share/swig/temp/trunk/Lib/swigwarnings.swg:39: . top . include . include . include - -2010-01-03: wsfulton - Fix missing file/line numbers for typemap warnings and in output from the - -debug-tmsearch/-debug-tmused options. - -2010-01-03: wsfulton - Add typemaps used debugging option (-debug-tmused). When used each line displays - the typemap used for each type for which code is being generated including the file - and line number related to the type. This is effectively a condensed form of the - -debug-tmsearch option. Documented in Typemaps.html. - -2009-12-23: wsfulton - Fix for %javaexception and directors so that all the appropriate throws clauses - are generated. Problem reported by Peter Greenwood. - -2009-12-20: wsfulton - Add -debug-tmsearch option for debugging the typemap pattern matching rules. - Documented in Typemaps.html. - -2009-12-12: wsfulton - [Octave] Remove the -api option and use the new OCTAVE_API_VERSION_NUMBER - macro provided in the octave headers for determining the api version instead. - -2009-12-04: olly - [Ruby] Improve support for Ruby 1.9 under GCC. Addresses part of - SF#2859614. - -2009-12-04: olly - Fix handling of modulo operator (%) in constant expressions - (SF#2818562). - -2009-12-04: olly - [PHP] "empty" is a reserved word in PHP, so rename empty() method - on STL classes to "is_empty()" (previously this was automatically - renamed to "c_empty()"). - *** POTENTIAL INCOMPATIBILITY *** - -2009-12-03: olly - [PHP] Add typemaps for long long and unsigned long long, and for - pointer to method. - -2009-12-02: olly - [PHP] Fix warning and rename of reserved class name to be case - insensitive. - -2009-12-01: wsfulton - Revert support for %extend and memberin typemaps added in swig-1.3.39. The - memberin typemaps are ignored again for member variables within a %extend block. - Documentation inconsistency reported by Torsten Landschoff. - -2009-11-29: wsfulton - [Java, C#] Fix generated quoting when using %javaconst(1)/%csconst(1) for - static const char member variables. - - %javaconst(1) A; - %csconst(1) A; - struct X { - static const char A = 'A'; - }; - -2009-11-26: wsfulton - [Java, C#] Fix %javaconst(1)/%csconst(1) for static const member variables to - use the actual constant value if it is specified, rather than the C++ code to - access the member. - - %javaconst(1) EN; - %csconst(1) EN; - struct X { - static const int EN = 2; - }; - -2009-11-23: wsfulton - C++ nested typedef classes can now be handled too, for example: - struct Outer { - typedef Foo { } FooTypedef1, FooTypedef2; - }; - -2009-11-18: wsfulton - The wrappers for C nested structs are now generated in the same order as declared - in the parsed code. - -2009-11-18: wsfulton - Fix #491476 - multiple declarations of nested structs, for example: - struct Outer { - struct { - int val; - } inner1, inner2, *inner3, inner4[1]; - } outer; - -2009-11-17: wsfulton - Fix parsing of enum declaration and initialization, for example: - - enum ABC { - a, - b, - c - } A = a, *pC = &C, array[3] = {a, b, c}; - -2009-11-17: wsfulton - Fix parsing of struct declaration and initialization, for example: - - struct S { - int x; - } instance = { 10 }; - -2009-11-15: wsfulton - Fix #1960977 - Syntax error parsing derived nested class declaration and member - variable instance. - -2009-11-14: wsfulton - Fix #2310483 - function pointer typedef within extern "C" block. - -2009-11-13: wsfulton - Fix usage of nested template classes within templated classes so that compileable code - is generated. - -2009-11-13: olly - [php] Fix place where class prefix (as specified with -prefix) - wasn't being used. Patch from gverbruggen in SF#2892647. - -2009-11-12: wsfulton - Fix usage of nested template classes so that compileable code is generated - the nested - template class is now treated like a normal nested classes, that is, as an opaque type - unless the nestedworkaround feature is used. - -2009-11-12: wsfulton - Replace SWIGWARN_PARSE_NESTED_CLASS with SWIGWARN_PARSE_NAMED_NESTED_CLASS and - SWIGWARN_PARSE_UNNAMED_NESTED_CLASS for named and unnamed nested classes respectively. - - Named nested class ignored warnings can now be suppressed by name using %warnfilter, eg: - - %warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer::Inner; - - but clearly unnamed nested classes cannot and the global suppression is still required, eg: - - #pragma SWIG nowarn=SWIGWARN_PARSE_UNNAMED_NESTED_CLASS - -2009-11-11: wsfulton - Added the nestedworkaround feature as a way to use the full functionality of a nested class - (C++ mode only). It removes the nested class from SWIG's type information so it is as if SWIG - had never parsed the nested class. The documented nested class workarounds using a global - fake class stopped working when SWIG treated the nested class as an opaque pointer, and - this feature reverts this behaviour. The documentation has been updated with details of how - to use and implement it, see the "Nested classes" section in SWIGPlus.html. - -2009-11-11: wsfulton - There were a number of C++ cases where nested classes/structs/unions were being handled - as if C code was being parsed which would oftentimes lead to uncompileable code as an - attempt was made to wrap the nested structs like it is documented for C code. Now all - nested structs/classes/unions are ignored in C++ mode, as was always documented. However, - there is an improvement as usage of nested structs/classes/unions is now always treated - as an opaque type by default, resulting in generated code that should always compile. - - *** POTENTIAL INCOMPATIBILITY *** - -2009-11-09: drjoe - Fix R for -fcompact and add std_map.i - -2009-11-08: wsfulton - Fix inconsistency for nested structs/unions/classes. Uncompileable code was being - generated when inner struct and union declarations were used as types within the - inner struct. The inner struct/union is now treated as a forward declaration making the - behaviour the same as an inner class. (C++ code), eg: - - struct Outer { - struct InnerStruct { int x; }; - InnerStruct* getInnerStruct(); - }; - -2009-11-08: wsfulton - Ignored nested class/struct warnings now display the name of the ignored class/struct. - -2009-11-07: wsfulton - Bug #1514681 - Fix nested template classes within a namespace generated uncompileable - code and introduced strange side effects to other wrapper code especially code - after the nested template class. Note that nested template classes are still ignored. - -2009-11-07: wsfulton - Add new debug options: - -debug-symtabs - Display symbol tables information - -debug-symbols - Display target language symbols in the symbol tables - -debug-csymbols - Display C symbols in the symbol tables - -2009-11-03: wsfulton - Fix some usage of unary scope operator (::) denoting global scope, for example: - - namespace AA { /* ... */ } - using namespace ::AA; - - and bug #1816802 - SwigValueWrapper should be used: - - struct CC { - CC(int); // no default constructor - }; - ::CC x(); - - and in template parameter specializations: - - struct S {}; - template struct X { void a() {}; }; - template <> struct X { void b() {}; }; - %template(MyTConcrete) X< ::S >; - - plus probably some other corner case usage of ::. - -2009-11-02: olly - [Python] Fix potential memory leak in initialisation code for the - generated module. - -2009-10-23: wsfulton - Fix seg fault when using a named nested template instantiation using %template(name) - within a class. A warning that these are not supported is now issued plus processing - continues as if no name was given. - -2009-10-20: wsfulton - [Python] Fix std::vector. This would previously compile, but not run correctly. - -2009-10-20: wsfulton - Fixed previously fairly poor template partial specialization and explicit - specialization support. Numerous bugs in this area have been fixed including: - - - Template argument deduction implemented for template type arguments, eg this now - works: - template class X {}; - template class X {}; - %template(X1) X; // Chooses T * specialization - - and more complex cases with multiple parameters and a mix of template argument - deduction and explicitly specialised parameters, eg: - template struct TwoParm { void a() {} }; - template struct TwoParm { void e() {} }; - %template(E) TwoParm; - - Note that the primary template must now be in scope, like in C++, when - an explicit or partial specialization is instantiated with %template. - - *** POTENTIAL INCOMPATIBILITY *** - -2009-09-14: wsfulton - [C#] Add %csattributes for adding C# attributes to enum values, see docs for example. - -2009-09-11: wsfulton - Fix memmove regression in cdata.i as reported by Adriaan Renting. - -2009-09-07: wsfulton - Fix constant expressions containing <= or >=. - -2009-09-02: wsfulton - The following operators in constant expressions now result in type bool for C++ - wrappers and remain as type int for C wrappers, as per each standard: - - && || == != < > <= >= (Actually the last 4 are still broken). For example: - - #define A 10 - #define B 10 - #define A_EQ_B A == B // now wrapped as type bool for C++ - #define A_AND_B A && B // now wrapped as type bool for C++ - -2009-09-02: wsfulton - Fix #2845746. true and false are now recognised keywords (only when wrapping C++). - Constants such as the following are now wrapped (as type bool): - #define FOO true - #define BAR FOO && false - diff --git a/Doc/Manual/Sections.html b/Doc/Manual/Sections.html index e957318e8..e514f726d 100644 --- a/Doc/Manual/Sections.html +++ b/Doc/Manual/Sections.html @@ -6,7 +6,7 @@

          SWIG-2.0 Documentation

          -Last update : SWIG-2.0.0 (2 June 2010) +Last update : SWIG-2.0.1 (in progress)

          Sections

          diff --git a/README b/README index d9288cdae..3c6ee27a0 100644 --- a/README +++ b/README @@ -1,6 +1,6 @@ SWIG (Simplified Wrapper and Interface Generator) -Version: 2.0.0 (2 June 2010) +Version: 2.0.1 (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/RELEASENOTES b/RELEASENOTES index 74e043ae7..5f41df04f 100644 --- a/RELEASENOTES +++ b/RELEASENOTES @@ -1,10 +1,10 @@ +This file contains a brief overview of the changes made in each release. +A detailed description of changes are available in the CHANGES.current +and CHANGES files. + Release Notes ============= -A detailed description of changes are available in the CHANGES.current -and CHANGES files. The summaries below contain just a brief overview of -the changes made in each release. - SWIG-2.0.0 summary: - License changes, see LICENSE file and http://www.swig.org/legal.html. - Much better nested class/struct support. diff --git a/configure.in b/configure.in index 49076ec8c..fe95fa7c0 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],[2.0.0],[http://www.swig.org]) +AC_INIT([swig],[2.0.1],[http://www.swig.org]) AC_PREREQ(2.58) AC_CONFIG_SRCDIR([Source/Swig/swig.h]) AC_CONFIG_AUX_DIR([Tools/config]) From d30054b5f63a75d2688518b82b90b10507a62259 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 3 Jun 2010 17:41:36 +0000 Subject: [PATCH 0915/1680] Remove duplicate intro git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12097 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES | 3 --- 1 file changed, 3 deletions(-) diff --git a/CHANGES b/CHANGES index bd65df32b..f243ff7c6 100644 --- a/CHANGES +++ b/CHANGES @@ -6,9 +6,6 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.0 (2 June 2010) =========================== -See CHANGES file for changes in older releases. -See RELEASENOTES file for a summary of changes in each release. - 2010-06-02: wsfulton [C#] Fix SWIG_STD_VECTOR_ENHANCED macro used in std::vector to work with types containing commas, for example: From 257ce20f30b2535fff7b52f18df5595be6b4ec9b Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 3 Jun 2010 17:44:42 +0000 Subject: [PATCH 0916/1680] Fix uncompileable code when %rename results in two enum items with the same name git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12098 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 3 +++ Examples/test-suite/common.mk | 1 + Examples/test-suite/enum_rename.i | 12 ++++++++++++ Source/Modules/typepass.cxx | 2 +- 4 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 Examples/test-suite/enum_rename.i diff --git a/CHANGES.current b/CHANGES.current index 9982286c2..331e9d8dd 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,3 +5,6 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.1 (in progress) =========================== +2010-06-03: wsfulton + Fix uncompileable code when %rename results in two enum items + with the same name. Reported by Vadim Zeitlin. diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 97708be47..5033f1957 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -180,6 +180,7 @@ CPP_TEST_CASES += \ disown \ dynamic_cast \ empty \ + enum_rename \ enum_scope_template \ enum_template \ enum_thorough \ diff --git a/Examples/test-suite/enum_rename.i b/Examples/test-suite/enum_rename.i new file mode 100644 index 000000000..455826f8b --- /dev/null +++ b/Examples/test-suite/enum_rename.i @@ -0,0 +1,12 @@ +%module enum_rename + +%warnfilter(SWIGWARN_PARSE_REDEFINED) S_May; + +// %rename with rxspencer can do the equivalent of these two renames, which was resulting in uncompileable code +%rename(May) M_May; +%rename(May) S_May; + +%inline %{ + enum Month { M_Jan, M_May, M_Dec }; + enum Severity { S_May, S_Can, S_Must }; +%} diff --git a/Source/Modules/typepass.cxx b/Source/Modules/typepass.cxx index 57a7663eb..e0e06d54e 100644 --- a/Source/Modules/typepass.cxx +++ b/Source/Modules/typepass.cxx @@ -796,7 +796,7 @@ class TypePass:private Dispatcher { bool reset; String *enumvalue = Getattr(c, "enumvalue"); - if (GetFlag(c, "feature:ignore")) { + if (GetFlag(c, "feature:ignore") || !Getattr(c, "sym:name")) { reset = enumvalue ? true : false; previous_ignored = true; } else { From 9622d908ae0e9cbfcad7eb3bb4b8c894fd2e311c Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Fri, 4 Jun 2010 05:14:14 +0000 Subject: [PATCH 0917/1680] Fix typo reported in SF#3011286 by Ben Ceschi. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12100 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Php.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/Manual/Php.html b/Doc/Manual/Php.html index fbe31b9e3..e9190a837 100644 --- a/Doc/Manual/Php.html +++ b/Doc/Manual/Php.html @@ -857,7 +857,7 @@ either %init or %minit.

          To insert code into the PHP_MSHUTDOWN_FUNCTION, one can use -either %init or %minit. +either %shutdown or %mshutdown.

          
          From 229ce6196d92e2023ae786ff0243c508399a379d Mon Sep 17 00:00:00 2001
          From: William S Fulton 
          Date: Mon, 7 Jun 2010 18:56:59 +0000
          Subject: [PATCH 0918/1680] remove reference to old version of Perl
          
          git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12103 626c5289-ae23-0410-ae9c-e8d60b6d4f22
          ---
           Examples/perl5/index.html | 5 ++---
           1 file changed, 2 insertions(+), 3 deletions(-)
          
          diff --git a/Examples/perl5/index.html b/Examples/perl5/index.html
          index 5648c587d..db46023c4 100644
          --- a/Examples/perl5/index.html
          +++ b/Examples/perl5/index.html
          @@ -68,9 +68,8 @@ Please see the Windows page in the m
           
           

          Due to wide variations in the Perl C API and differences between versions such as the ActivePerl release for Windows, -the code generated by SWIG is extremely messy. We have made every attempt to maintain compatibility with -many Perl releases going as far back as 5.003 and as recent as 5.6. However, your mileage may vary. -If you experience a problem, please let us know by +the code generated by SWIG is extremely messy. +If the code doesn't compile or work with your version of Perl, please let us know by contacting us on the mailing lists. Better yet, send us a patch. From 9f99c73221753aa5c2c425ca58d8e42f91556a41 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 8 Jun 2010 05:37:49 +0000 Subject: [PATCH 0919/1680] minor clarification in Php docs git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12104 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Php.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/Manual/Php.html b/Doc/Manual/Php.html index e9190a837..f3bf720d9 100644 --- a/Doc/Manual/Php.html +++ b/Doc/Manual/Php.html @@ -868,8 +868,8 @@ either %shutdown or %mshutdown.

          -The %rinit and %rshutdown statements insert code -into the request init and shutdown code respectively. +The %rinit and %rshutdown statements are very similar but insert code +into the request init (PHP_RINIT_FUNCTION) and request shutdown (PHP_RSHUTDOWN_FUNCTION) code respectively.

          29.3 Cross language polymorphism

          From 09f14197ac1df83e9b428d84782238abec0500bd Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 8 Jun 2010 06:02:56 +0000 Subject: [PATCH 0920/1680] Add section on Aspect Oriented Programming after discussion on swig-devel git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12105 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Contents.html | 1 + Doc/Manual/Typemaps.html | 23 +++++++++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index 8612ef237..27337ea7a 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -336,6 +336,7 @@
        • Reusing typemaps
        • What can be done with typemaps?
        • What can't be done with typemaps? +
        • Similarities to Aspect Oriented Programming
        • The rest of this chapter
      • Typemap specifications diff --git a/Doc/Manual/Typemaps.html b/Doc/Manual/Typemaps.html index cacfd5f2f..1568c082e 100644 --- a/Doc/Manual/Typemaps.html +++ b/Doc/Manual/Typemaps.html @@ -18,6 +18,7 @@
      • Reusing typemaps
      • What can be done with typemaps?
      • What can't be done with typemaps? +
      • Similarities to Aspect Oriented Programming
      • The rest of this chapter
    • Typemap specifications @@ -115,7 +116,7 @@ chapter with only a vague idea of what SWIG already does by default.

      One of the most important problems in wrapper code generation is the -conversion of datatypes between programming languages. Specifically, +conversion or marshalling of datatypes between programming languages. Specifically, for every C/C++ declaration, SWIG must somehow generate wrapper code that allows values to be passed back and forth between languages. Since every programming language represents data differently, this is @@ -637,7 +638,25 @@ void wrap_foo(char *s, int x) { -

      10.1.7 The rest of this chapter

      +

      10.1.7 Similarities to Aspect Oriented Programming

      + + +

      +SWIG has parallels to Aspect Oriented Software Development (AOP). +The AOP terminology with respect to SWIG typemaps can be viewed as follows: +

      +
        +
      • Cross-cutting concerns: The cross-cutting concerns are the modularization of the functionality that the typemaps implement, which is primarily marshalling of types from/to the target language and C/C++. +
      • Advice: The typemap body contains code which is executed whenever the marshalling is required. +
      • Pointcut: The pointcuts are the positions in the wrapper code that the typemap code is generated into. +
      • Aspect: Aspects are the combination of the pointcut and the advice, hence each typemap is an aspect. +
      +

      +SWIG can also be viewed as has having a second set of aspects based around %feature. +Features such as %exception are also cross-cutting concerns as they encapsulate code that can be used to add logging or exception handling to any function. +

      + +

      10.1.8 The rest of this chapter

      From 5af2978f77cad0eec048ba1ea09b07e8ad7abbfa Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Thu, 10 Jun 2010 01:13:31 +0000 Subject: [PATCH 0921/1680] Add support for the Go programming language. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12108 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Go.html | 463 ++ Doc/Manual/SWIG.html | 1 + Doc/Manual/Sections.html | 1 + Doc/Manual/chapters | 1 + Examples/Makefile.in | 71 + Examples/go/callback/Makefile | 18 + Examples/go/callback/example.cxx | 4 + Examples/go/callback/example.go | 188 + Examples/go/callback/example.h | 23 + Examples/go/callback/example.i | 13 + Examples/go/callback/index.html | 81 + Examples/go/callback/runme.go | 41 + Examples/go/check.list | 13 + Examples/go/class/Makefile | 16 + Examples/go/class/example.cxx | 28 + Examples/go/class/example.go | 284 + Examples/go/class/example.h | 39 + Examples/go/class/example.i | 10 + Examples/go/class/index.html | 203 + Examples/go/class/runme.go | 63 + Examples/go/constants/Makefile | 16 + Examples/go/constants/example.go | 44 + Examples/go/constants/example.i | 25 + Examples/go/constants/index.html | 55 + Examples/go/constants/runme.go | 18 + Examples/go/enum/Makefile | 18 + Examples/go/enum/example.cxx | 37 + Examples/go/enum/example.go | 93 + Examples/go/enum/example.h | 13 + Examples/go/enum/example.i | 11 + Examples/go/enum/index.html | 42 + Examples/go/enum/runme.go | 32 + Examples/go/extend/Makefile | 18 + Examples/go/extend/example.cxx | 4 + Examples/go/extend/example.go | 397 ++ Examples/go/extend/example.h | 56 + Examples/go/extend/example.i | 15 + Examples/go/extend/index.html | 27 + Examples/go/extend/runme.go | 77 + Examples/go/funcptr/Makefile | 18 + Examples/go/funcptr/example.c | 19 + Examples/go/funcptr/example.go | 54 + Examples/go/funcptr/example.h | 9 + Examples/go/funcptr/example.i | 16 + Examples/go/funcptr/index.html | 89 + Examples/go/funcptr/runme.go | 25 + Examples/go/index.html | 89 + Examples/go/multimap/Makefile | 18 + Examples/go/multimap/example.c | 53 + Examples/go/multimap/example.go | 55 + Examples/go/multimap/example.i | 110 + Examples/go/multimap/runme.go | 26 + Examples/go/pointer/Makefile | 18 + Examples/go/pointer/example.c | 16 + Examples/go/pointer/example.go | 68 + Examples/go/pointer/example.i | 30 + Examples/go/pointer/index.html | 143 + Examples/go/pointer/runme.go | 47 + Examples/go/reference/Makefile | 18 + Examples/go/reference/example.cxx | 46 + Examples/go/reference/example.go | 126 + Examples/go/reference/example.h | 26 + Examples/go/reference/example.i | 42 + Examples/go/reference/index.html | 143 + Examples/go/reference/runme.go | 71 + Examples/go/simple/Makefile | 15 + Examples/go/simple/example.c | 18 + Examples/go/simple/example.go | 48 + Examples/go/simple/example.i | 7 + Examples/go/simple/index.html | 126 + Examples/go/simple/runme.go | 25 + Examples/go/template/Makefile | 18 + Examples/go/template/example.go | 150 + Examples/go/template/example.h | 32 + Examples/go/template/example.i | 17 + Examples/go/template/index.html | 113 + Examples/go/template/runme.go | 43 + Examples/go/variables/Makefile | 18 + Examples/go/variables/example.c | 91 + Examples/go/variables/example.go | 198 + Examples/go/variables/example.h | 6 + Examples/go/variables/example.i | 49 + Examples/go/variables/index.html | 87 + Examples/go/variables/runme.go | 67 + Examples/test-suite/dynamic_cast.i | 14 +- Examples/test-suite/go/Makefile.in | 110 + .../test-suite/go/abstract_access_runme.go | 10 + .../test-suite/go/abstract_typedef2_runme.go | 7 + .../test-suite/go/abstract_typedef_runme.go | 11 + .../test-suite/go/abstract_virtual_runme.go | 8 + Examples/test-suite/go/array_member_runme.go | 26 + Examples/test-suite/go/arrays_global_runme.go | 22 + Examples/test-suite/go/class_ignore_runme.go | 10 + .../test-suite/go/class_scope_weird_runme.go | 11 + .../test-suite/go/compactdefaultargs_runme.go | 29 + Examples/test-suite/go/constover_runme.go | 50 + .../test-suite/go/constructor_copy_runme.go | 34 + Examples/test-suite/go/contract_runme.go | 208 + Examples/test-suite/go/cpp_enum_runme.go | 27 + Examples/test-suite/go/cpp_namespace_runme.go | 57 + Examples/test-suite/go/cpp_static_runme.go | 13 + Examples/test-suite/go/default_args_runme.go | 26 + .../go/default_constructor_runme.go | 35 + .../test-suite/go/director_abstract_runme.go | 62 + .../test-suite/go/director_basic_runme.go | 115 + .../test-suite/go/director_classic_runme.go | 135 + .../test-suite/go/director_default_runme.go | 11 + .../test-suite/go/director_detect_runme.go | 46 + Examples/test-suite/go/director_enum_runme.go | 17 + .../test-suite/go/director_exception_runme.go | 95 + .../test-suite/go/director_extend_runme.go | 18 + .../test-suite/go/director_finalizer_runme.go | 37 + Examples/test-suite/go/director_frob_runme.go | 12 + .../test-suite/go/director_nested_runme.go | 79 + .../test-suite/go/director_profile_runme.go | 49 + .../test-suite/go/director_protected_runme.go | 48 + .../test-suite/go/director_string_runme.go | 39 + .../test-suite/go/director_thread_runme.go | 28 + .../test-suite/go/director_unroll_runme.go | 21 + Examples/test-suite/go/disown_runme.go | 10 + Examples/test-suite/go/dynamic_cast_runme.go | 16 + Examples/test-suite/go/empty_runme.go | 6 + Examples/test-suite/go/enum_template_runme.go | 11 + Examples/test-suite/go/enums_runme.go | 25 + .../test-suite/go/exception_order_runme.go | 58 + .../test-suite/go/extend_placement_runme.go | 47 + .../test-suite/go/extend_template_ns_runme.go | 14 + .../test-suite/go/extend_template_runme.go | 14 + .../test-suite/go/extend_variable_runme.go | 9 + Examples/test-suite/go/extern_c_runme.go | 7 + Examples/test-suite/go/friends_runme.go | 50 + Examples/test-suite/go/fvirtual_runme.go | 13 + Examples/test-suite/go/global_ns_arg_runme.go | 8 + Examples/test-suite/go/grouping_runme.go | 19 + .../test-suite/go/import_nomodule_runme.go | 12 + Examples/test-suite/go/imports_runme.go | 17 + Examples/test-suite/go/inctest_runme.go | 18 + .../test-suite/go/inherit_missing_runme.go | 26 + Examples/test-suite/go/input_runme.go | 14 + .../test-suite/go/keyword_rename_runme.go | 8 + Examples/test-suite/go/li_attribute_runme.go | 90 + Examples/test-suite/go/li_carrays_runme.go | 14 + Examples/test-suite/go/li_cdata_runme.go | 13 + Examples/test-suite/go/li_cmalloc_runme.go | 25 + Examples/test-suite/go/li_cpointer_runme.go | 14 + Examples/test-suite/go/li_std_map_runme.go | 30 + .../test-suite/go/member_pointer_runme.go | 49 + .../test-suite/go/memberin_extend_c_runme.go | 11 + Examples/test-suite/go/minherit_runme.go | 82 + Examples/test-suite/go/mod_runme.go | 10 + Examples/test-suite/go/multi_import_runme.go | 29 + .../test-suite/go/namespace_class_runme.go | 19 + .../test-suite/go/namespace_typemap_runme.go | 116 + .../go/namespace_virtual_method_runme.go | 7 + Examples/test-suite/go/naturalvar_runme.go | 17 + .../test-suite/go/nested_workaround_runme.go | 19 + .../go/overload_complicated_runme.go | 62 + Examples/test-suite/go/overload_copy_runme.go | 8 + .../test-suite/go/overload_extend_runme.go | 22 + .../test-suite/go/overload_extendc_runme.go | 33 + .../test-suite/go/overload_rename_runme.go | 10 + .../test-suite/go/overload_simple_runme.go | 125 + .../test-suite/go/overload_subtype_runme.go | 16 + .../go/overload_template_fast_runme.go | 187 + .../test-suite/go/overload_template_runme.go | 188 + Examples/test-suite/go/preproc_runme.go | 21 + Examples/test-suite/go/primitive_ref_runme.go | 57 + Examples/test-suite/go/profiletest_runme.go | 38 + Examples/test-suite/go/refcount_runme.go | 32 + .../go/reference_global_vars_runme.go | 98 + Examples/test-suite/go/rename_scope_runme.go | 18 + .../go/rename_strip_encoder_runme.go | 9 + Examples/test-suite/go/ret_by_value_runme.go | 14 + .../test-suite/go/return_const_value_runme.go | 15 + .../go/smart_pointer_extend_runme.go | 40 + .../go/smart_pointer_member_runme.go | 30 + .../go/smart_pointer_multi_runme.go | 20 + .../go/smart_pointer_multi_typedef_runme.go | 20 + .../go/smart_pointer_overload_runme.go | 28 + .../go/smart_pointer_rename_runme.go | 20 + .../go/smart_pointer_simple_runme.go | 19 + .../smart_pointer_templatevariables_runme.go | 22 + .../go/smart_pointer_typedef_runme.go | 19 + Examples/test-suite/go/sneaky1_runme.go | 10 + .../go/special_variable_macros_runme.go | 25 + .../go/static_const_member_2_runme.go | 18 + .../go/struct_initialization_runme.go | 29 + Examples/test-suite/go/struct_rename_runme.go | 7 + Examples/test-suite/go/struct_value_runme.go | 17 + .../go/template_default_arg_runme.go | 107 + .../test-suite/go/template_extend1_runme.go | 16 + .../test-suite/go/template_extend2_runme.go | 16 + .../test-suite/go/template_inherit_runme.go | 72 + Examples/test-suite/go/template_ns4_runme.go | 10 + Examples/test-suite/go/template_ns_runme.go | 26 + .../test-suite/go/template_opaque_runme.go | 9 + .../test-suite/go/template_ref_type_runme.go | 9 + .../test-suite/go/template_rename_runme.go | 16 + .../test-suite/go/template_static_runme.go | 7 + .../go/template_tbase_template_runme.go | 10 + .../go/template_type_namespace_runme.go | 8 + .../go/template_typedef_cplx3_runme.go | 29 + .../go/template_typedef_cplx4_runme.go | 29 + .../go/template_typedef_import_runme.go | 30 + .../test-suite/go/threads_exception_runme.go | 66 + Examples/test-suite/go/typedef_class_runme.go | 11 + .../test-suite/go/typedef_inherit_runme.go | 31 + Examples/test-suite/go/typedef_scope_runme.go | 16 + .../test-suite/go/typemap_namespace_runme.go | 13 + .../test-suite/go/typemap_ns_using_runme.go | 9 + .../go/typemap_out_optimal_runme.go | 8 + Examples/test-suite/go/typename_runme.go | 13 + Examples/test-suite/go/unions_runme.go | 51 + Examples/test-suite/go/using1_runme.go | 9 + Examples/test-suite/go/using2_runme.go | 9 + .../test-suite/go/using_composition_runme.go | 44 + Examples/test-suite/go/using_extend_runme.go | 30 + Examples/test-suite/go/using_inherit_runme.go | 59 + Examples/test-suite/go/using_private_runme.go | 20 + .../test-suite/go/using_protected_runme.go | 12 + Examples/test-suite/go/varargs_runme.go | 26 + .../test-suite/go/virtual_derivation_runme.go | 12 + Examples/test-suite/go/virtual_poly_runme.go | 43 + Examples/test-suite/go/voidtest_runme.go | 26 + Examples/test-suite/go/wrapmacro_runme.go | 11 + Examples/test-suite/keyword_rename.i | 4 + Examples/test-suite/minherit.i | 2 +- Examples/test-suite/name_warnings.i | 2 + Examples/test-suite/namespace_typemap.i | 26 + Examples/test-suite/null_pointer.i | 2 + Examples/test-suite/overload_simple.i | 2 + Examples/test-suite/return_const_value.i | 9 +- Examples/test-suite/rname.i | 5 + Examples/test-suite/typemap_namespace.i | 5 +- Examples/test-suite/typemap_subst.i | 4 +- Examples/test-suite/union_parameter.i | 2 + Lib/go/cdata.i | 135 + Lib/go/exception.i | 7 + Lib/go/go.swg | 514 ++ Lib/go/gokw.swg | 31 + Lib/go/goruntime.swg | 208 + Lib/go/std_common.i | 4 + Lib/go/std_deque.i | 1 + Lib/go/std_except.i | 29 + Lib/go/std_map.i | 64 + Lib/go/std_pair.i | 34 + Lib/go/std_string.i | 55 + Lib/go/std_vector.i | 78 + Lib/go/stl.i | 9 + Lib/go/typemaps.i | 335 ++ Makefile.in | 17 +- Source/Makefile.am | 1 + Source/Modules/allegrocl.cxx | 2 + Source/Modules/go.cxx | 4824 +++++++++++++++++ Source/Modules/overload.cxx | 2 +- Source/Modules/r.cxx | 2 + Source/Modules/swigmain.cxx | 2 + Source/Modules/swigmod.h | 1 + configure.in | 36 + 259 files changed, 16159 insertions(+), 14 deletions(-) create mode 100644 Doc/Manual/Go.html create mode 100644 Examples/go/callback/Makefile create mode 100644 Examples/go/callback/example.cxx create mode 100644 Examples/go/callback/example.go create mode 100644 Examples/go/callback/example.h create mode 100644 Examples/go/callback/example.i create mode 100644 Examples/go/callback/index.html create mode 100644 Examples/go/callback/runme.go create mode 100644 Examples/go/check.list create mode 100644 Examples/go/class/Makefile create mode 100644 Examples/go/class/example.cxx create mode 100644 Examples/go/class/example.go create mode 100644 Examples/go/class/example.h create mode 100644 Examples/go/class/example.i create mode 100644 Examples/go/class/index.html create mode 100644 Examples/go/class/runme.go create mode 100644 Examples/go/constants/Makefile create mode 100644 Examples/go/constants/example.go create mode 100644 Examples/go/constants/example.i create mode 100644 Examples/go/constants/index.html create mode 100644 Examples/go/constants/runme.go create mode 100644 Examples/go/enum/Makefile create mode 100644 Examples/go/enum/example.cxx create mode 100644 Examples/go/enum/example.go create mode 100644 Examples/go/enum/example.h create mode 100644 Examples/go/enum/example.i create mode 100644 Examples/go/enum/index.html create mode 100644 Examples/go/enum/runme.go create mode 100644 Examples/go/extend/Makefile create mode 100644 Examples/go/extend/example.cxx create mode 100644 Examples/go/extend/example.go create mode 100644 Examples/go/extend/example.h create mode 100644 Examples/go/extend/example.i create mode 100644 Examples/go/extend/index.html create mode 100644 Examples/go/extend/runme.go create mode 100644 Examples/go/funcptr/Makefile create mode 100644 Examples/go/funcptr/example.c create mode 100644 Examples/go/funcptr/example.go create mode 100644 Examples/go/funcptr/example.h create mode 100644 Examples/go/funcptr/example.i create mode 100644 Examples/go/funcptr/index.html create mode 100644 Examples/go/funcptr/runme.go create mode 100644 Examples/go/index.html create mode 100644 Examples/go/multimap/Makefile create mode 100644 Examples/go/multimap/example.c create mode 100644 Examples/go/multimap/example.go create mode 100644 Examples/go/multimap/example.i create mode 100644 Examples/go/multimap/runme.go create mode 100644 Examples/go/pointer/Makefile create mode 100644 Examples/go/pointer/example.c create mode 100644 Examples/go/pointer/example.go create mode 100644 Examples/go/pointer/example.i create mode 100644 Examples/go/pointer/index.html create mode 100644 Examples/go/pointer/runme.go create mode 100644 Examples/go/reference/Makefile create mode 100644 Examples/go/reference/example.cxx create mode 100644 Examples/go/reference/example.go create mode 100644 Examples/go/reference/example.h create mode 100644 Examples/go/reference/example.i create mode 100644 Examples/go/reference/index.html create mode 100644 Examples/go/reference/runme.go create mode 100644 Examples/go/simple/Makefile create mode 100644 Examples/go/simple/example.c create mode 100644 Examples/go/simple/example.go create mode 100644 Examples/go/simple/example.i create mode 100644 Examples/go/simple/index.html create mode 100644 Examples/go/simple/runme.go create mode 100644 Examples/go/template/Makefile create mode 100644 Examples/go/template/example.go create mode 100644 Examples/go/template/example.h create mode 100644 Examples/go/template/example.i create mode 100644 Examples/go/template/index.html create mode 100644 Examples/go/template/runme.go create mode 100644 Examples/go/variables/Makefile create mode 100644 Examples/go/variables/example.c create mode 100644 Examples/go/variables/example.go create mode 100644 Examples/go/variables/example.h create mode 100644 Examples/go/variables/example.i create mode 100644 Examples/go/variables/index.html create mode 100644 Examples/go/variables/runme.go create mode 100644 Examples/test-suite/go/Makefile.in create mode 100644 Examples/test-suite/go/abstract_access_runme.go create mode 100644 Examples/test-suite/go/abstract_typedef2_runme.go create mode 100644 Examples/test-suite/go/abstract_typedef_runme.go create mode 100644 Examples/test-suite/go/abstract_virtual_runme.go create mode 100644 Examples/test-suite/go/array_member_runme.go create mode 100644 Examples/test-suite/go/arrays_global_runme.go create mode 100644 Examples/test-suite/go/class_ignore_runme.go create mode 100644 Examples/test-suite/go/class_scope_weird_runme.go create mode 100644 Examples/test-suite/go/compactdefaultargs_runme.go create mode 100644 Examples/test-suite/go/constover_runme.go create mode 100644 Examples/test-suite/go/constructor_copy_runme.go create mode 100644 Examples/test-suite/go/contract_runme.go create mode 100644 Examples/test-suite/go/cpp_enum_runme.go create mode 100644 Examples/test-suite/go/cpp_namespace_runme.go create mode 100644 Examples/test-suite/go/cpp_static_runme.go create mode 100644 Examples/test-suite/go/default_args_runme.go create mode 100644 Examples/test-suite/go/default_constructor_runme.go create mode 100644 Examples/test-suite/go/director_abstract_runme.go create mode 100644 Examples/test-suite/go/director_basic_runme.go create mode 100644 Examples/test-suite/go/director_classic_runme.go create mode 100644 Examples/test-suite/go/director_default_runme.go create mode 100644 Examples/test-suite/go/director_detect_runme.go create mode 100644 Examples/test-suite/go/director_enum_runme.go create mode 100644 Examples/test-suite/go/director_exception_runme.go create mode 100644 Examples/test-suite/go/director_extend_runme.go create mode 100644 Examples/test-suite/go/director_finalizer_runme.go create mode 100644 Examples/test-suite/go/director_frob_runme.go create mode 100644 Examples/test-suite/go/director_nested_runme.go create mode 100644 Examples/test-suite/go/director_profile_runme.go create mode 100644 Examples/test-suite/go/director_protected_runme.go create mode 100644 Examples/test-suite/go/director_string_runme.go create mode 100644 Examples/test-suite/go/director_thread_runme.go create mode 100644 Examples/test-suite/go/director_unroll_runme.go create mode 100644 Examples/test-suite/go/disown_runme.go create mode 100644 Examples/test-suite/go/dynamic_cast_runme.go create mode 100644 Examples/test-suite/go/empty_runme.go create mode 100644 Examples/test-suite/go/enum_template_runme.go create mode 100644 Examples/test-suite/go/enums_runme.go create mode 100644 Examples/test-suite/go/exception_order_runme.go create mode 100644 Examples/test-suite/go/extend_placement_runme.go create mode 100644 Examples/test-suite/go/extend_template_ns_runme.go create mode 100644 Examples/test-suite/go/extend_template_runme.go create mode 100644 Examples/test-suite/go/extend_variable_runme.go create mode 100644 Examples/test-suite/go/extern_c_runme.go create mode 100644 Examples/test-suite/go/friends_runme.go create mode 100644 Examples/test-suite/go/fvirtual_runme.go create mode 100644 Examples/test-suite/go/global_ns_arg_runme.go create mode 100644 Examples/test-suite/go/grouping_runme.go create mode 100644 Examples/test-suite/go/import_nomodule_runme.go create mode 100644 Examples/test-suite/go/imports_runme.go create mode 100644 Examples/test-suite/go/inctest_runme.go create mode 100644 Examples/test-suite/go/inherit_missing_runme.go create mode 100644 Examples/test-suite/go/input_runme.go create mode 100644 Examples/test-suite/go/keyword_rename_runme.go create mode 100644 Examples/test-suite/go/li_attribute_runme.go create mode 100644 Examples/test-suite/go/li_carrays_runme.go create mode 100644 Examples/test-suite/go/li_cdata_runme.go create mode 100644 Examples/test-suite/go/li_cmalloc_runme.go create mode 100644 Examples/test-suite/go/li_cpointer_runme.go create mode 100644 Examples/test-suite/go/li_std_map_runme.go create mode 100644 Examples/test-suite/go/member_pointer_runme.go create mode 100644 Examples/test-suite/go/memberin_extend_c_runme.go create mode 100644 Examples/test-suite/go/minherit_runme.go create mode 100644 Examples/test-suite/go/mod_runme.go create mode 100644 Examples/test-suite/go/multi_import_runme.go create mode 100644 Examples/test-suite/go/namespace_class_runme.go create mode 100644 Examples/test-suite/go/namespace_typemap_runme.go create mode 100644 Examples/test-suite/go/namespace_virtual_method_runme.go create mode 100644 Examples/test-suite/go/naturalvar_runme.go create mode 100644 Examples/test-suite/go/nested_workaround_runme.go create mode 100644 Examples/test-suite/go/overload_complicated_runme.go create mode 100644 Examples/test-suite/go/overload_copy_runme.go create mode 100644 Examples/test-suite/go/overload_extend_runme.go create mode 100644 Examples/test-suite/go/overload_extendc_runme.go create mode 100644 Examples/test-suite/go/overload_rename_runme.go create mode 100644 Examples/test-suite/go/overload_simple_runme.go create mode 100644 Examples/test-suite/go/overload_subtype_runme.go create mode 100644 Examples/test-suite/go/overload_template_fast_runme.go create mode 100644 Examples/test-suite/go/overload_template_runme.go create mode 100644 Examples/test-suite/go/preproc_runme.go create mode 100644 Examples/test-suite/go/primitive_ref_runme.go create mode 100644 Examples/test-suite/go/profiletest_runme.go create mode 100644 Examples/test-suite/go/refcount_runme.go create mode 100644 Examples/test-suite/go/reference_global_vars_runme.go create mode 100644 Examples/test-suite/go/rename_scope_runme.go create mode 100644 Examples/test-suite/go/rename_strip_encoder_runme.go create mode 100644 Examples/test-suite/go/ret_by_value_runme.go create mode 100644 Examples/test-suite/go/return_const_value_runme.go create mode 100644 Examples/test-suite/go/smart_pointer_extend_runme.go create mode 100644 Examples/test-suite/go/smart_pointer_member_runme.go create mode 100644 Examples/test-suite/go/smart_pointer_multi_runme.go create mode 100644 Examples/test-suite/go/smart_pointer_multi_typedef_runme.go create mode 100644 Examples/test-suite/go/smart_pointer_overload_runme.go create mode 100644 Examples/test-suite/go/smart_pointer_rename_runme.go create mode 100644 Examples/test-suite/go/smart_pointer_simple_runme.go create mode 100644 Examples/test-suite/go/smart_pointer_templatevariables_runme.go create mode 100644 Examples/test-suite/go/smart_pointer_typedef_runme.go create mode 100644 Examples/test-suite/go/sneaky1_runme.go create mode 100644 Examples/test-suite/go/special_variable_macros_runme.go create mode 100644 Examples/test-suite/go/static_const_member_2_runme.go create mode 100644 Examples/test-suite/go/struct_initialization_runme.go create mode 100644 Examples/test-suite/go/struct_rename_runme.go create mode 100644 Examples/test-suite/go/struct_value_runme.go create mode 100644 Examples/test-suite/go/template_default_arg_runme.go create mode 100644 Examples/test-suite/go/template_extend1_runme.go create mode 100644 Examples/test-suite/go/template_extend2_runme.go create mode 100644 Examples/test-suite/go/template_inherit_runme.go create mode 100644 Examples/test-suite/go/template_ns4_runme.go create mode 100644 Examples/test-suite/go/template_ns_runme.go create mode 100644 Examples/test-suite/go/template_opaque_runme.go create mode 100644 Examples/test-suite/go/template_ref_type_runme.go create mode 100644 Examples/test-suite/go/template_rename_runme.go create mode 100644 Examples/test-suite/go/template_static_runme.go create mode 100644 Examples/test-suite/go/template_tbase_template_runme.go create mode 100644 Examples/test-suite/go/template_type_namespace_runme.go create mode 100644 Examples/test-suite/go/template_typedef_cplx3_runme.go create mode 100644 Examples/test-suite/go/template_typedef_cplx4_runme.go create mode 100644 Examples/test-suite/go/template_typedef_import_runme.go create mode 100644 Examples/test-suite/go/threads_exception_runme.go create mode 100644 Examples/test-suite/go/typedef_class_runme.go create mode 100644 Examples/test-suite/go/typedef_inherit_runme.go create mode 100644 Examples/test-suite/go/typedef_scope_runme.go create mode 100644 Examples/test-suite/go/typemap_namespace_runme.go create mode 100644 Examples/test-suite/go/typemap_ns_using_runme.go create mode 100644 Examples/test-suite/go/typemap_out_optimal_runme.go create mode 100644 Examples/test-suite/go/typename_runme.go create mode 100644 Examples/test-suite/go/unions_runme.go create mode 100644 Examples/test-suite/go/using1_runme.go create mode 100644 Examples/test-suite/go/using2_runme.go create mode 100644 Examples/test-suite/go/using_composition_runme.go create mode 100644 Examples/test-suite/go/using_extend_runme.go create mode 100644 Examples/test-suite/go/using_inherit_runme.go create mode 100644 Examples/test-suite/go/using_private_runme.go create mode 100644 Examples/test-suite/go/using_protected_runme.go create mode 100644 Examples/test-suite/go/varargs_runme.go create mode 100644 Examples/test-suite/go/virtual_derivation_runme.go create mode 100644 Examples/test-suite/go/virtual_poly_runme.go create mode 100644 Examples/test-suite/go/voidtest_runme.go create mode 100644 Examples/test-suite/go/wrapmacro_runme.go create mode 100644 Lib/go/cdata.i create mode 100644 Lib/go/exception.i create mode 100644 Lib/go/go.swg create mode 100644 Lib/go/gokw.swg create mode 100644 Lib/go/goruntime.swg create mode 100644 Lib/go/std_common.i create mode 100644 Lib/go/std_deque.i create mode 100644 Lib/go/std_except.i create mode 100644 Lib/go/std_map.i create mode 100644 Lib/go/std_pair.i create mode 100644 Lib/go/std_string.i create mode 100644 Lib/go/std_vector.i create mode 100644 Lib/go/stl.i create mode 100644 Lib/go/typemaps.i create mode 100644 Source/Modules/go.cxx diff --git a/Doc/Manual/Go.html b/Doc/Manual/Go.html new file mode 100644 index 000000000..7d2ce9db8 --- /dev/null +++ b/Doc/Manual/Go.html @@ -0,0 +1,463 @@ + + + +SWIG and Go + + + +

      20 SWIG and Go

      + + + + + + +

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

      + +

      20.1 Overview

      + + +

      +Go is a compiled language, not a scripting language. However, it does +not support direct calling of functions written in C/C++. The cgo +program may be used to generate wrappers to call C code from Go, but +there is no convenient way to call C++ code. SWIG fills this gap. +

      + +

      +There are (at least) two different Go compilers. One is the gc +compiler, normally invoked under the names 6g, 8g, or 5g. The other +is the gccgo compiler, which is a frontend to the gcc compiler suite. +The interface to C/C++ code is completely different for the two Go +compilers. SWIG supports both, selected by a command line option. +

      + +

      +Because Go is a type-safe compiled language, SWIG's runtime type +checking and runtime library are not used with Go. This should be +borne in mind when reading the rest of the SWIG documentation. +

      + +

      20.2 Running SWIG with Go

      + + +

      +To generate Go code, use the -go option with SWIG. By +default SWIG will generate code for the gc compilers. To generate +code for gccgo, you should use the -gccgo option. +

      + +

      20.2.1 Additional Commandline Options

      + + +

      +These are the command line options for SWIG's GO module. They can +also be seen by using: +

      + +
      +swig -go -help
      +
      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      Go specific options
      -gccgoGenerate code for gccgo. The default is to generate code for + 6g/8g/6g.
      -package <name>Set the name of the Go package to <name>. The default + package name is the SWIG module name.
      -go-prefix <prefix>When generating code for gccgo, set the prefix to use. This + corresponds to the -fgo-prefix option to gccgo.
      -long-type-size <s>Set the size for the C/C++ type long. This controls + whether long is converted to the Go type int32 + or int64. The <s> argument should be 32 or 64.
      -rename <old>=<new>Rename <old%gt; to <new> when processing the C/C++ code + and also the SWIG input file. This is a convenient way to rename + names in the C/C++ code which are the same expect for the first + letter, to avoid conflicts when applying the Go renaming rules + described below.
      + +

      20.2.2 Go Output Files

      + + +

      When generating Go code, SWIG will generate the following + files:

      + +
        +
      • +MODULE.go will contain the Go functions that your Go code will call. +These functions will be wrappers for the C++ functions defined by your +module. This file should, of course, be compiled with the Go +compiler. +
      • +MODULE_wrap.c or MODULE_wrap.cxx will contain C/C++ functions will be +invoked by the Go wrapper code. This file should be compiled with the +usual C or C++ compiler and linked into a shared library. +
      • +MODULE_wrap.h will be generated if you use the directors feature. It +provides a definition of the generated C++ director classes. It is +generally not necessary to use this file, but in some special cases it +may be helpful to include it in your code, compiled with the usual C +or C++ compiler. +
      • +If using the gc compiler, MODULE_gc.c will contain C code which should +be compiled with the C compiler which part of the gc compiler: 6c, 8c, +or 5c. It should then be combined with the compiled MODULE.go using +gopack. This file will not be generated when using gccgo. +
      + +

      +A typical command sequence would look like this: +

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

      20.3 A tour of basic C/C++ wrapping

      + + +

      +By default, SWIG attempts to build a natural Go interface to your +C/C++ code. However, the languages are somewhat different, so some +modifications have to occur. This section briefly covers the +essential aspects of this wrapping. +

      + +

      20.3.1 Go Package Name

      + + +

      +All Go source code lives in a package. The name of this package will +default to the name of the module from SWIG's %module +directive. You may override this by using SWIG's -package +command line option. +

      + +

      20.3.2 Go Names

      + + +

      +In Go, a function is only visible outside the current package if the +first letter of the name is uppercase. This is quite different from +C/C++. Because of this, C/C++ names are modified when generating the +Go interface: the first letter is forced to be uppercase if it is not +already. This affects the names of functions, methods, variables, +constants, enums, and classes. +

      + +

      +C/C++ variables are wrapped with setter and getter functions in Go. +First the first letter of the variable name will be forced to +uppercase, and then Get or Set will be prepended. +For example, if the C/C++ variable is called var, then SWIG +will define the functions GetVar and SetVar. If a +variable is declared as const, or if +SWIG's +%immutable directive is used for the variable, then only +the getter will be defined. +

      + +

      +C++ classes will be discussed further below. Here we'll note that the +first letter of the class name will be forced to uppercase to give the +name of a type in Go. A constructor will be named New +followed by that name, and the destructor will be +named Delete followed by that name. +

      + +

      20.3.3 Go Constants

      + + +

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

      20.3.4 Go Enumerations

      + + +

      +C/C++ enumeration types will cause SWIG to define an integer type with +the name of the enumeration (with first letter forced to uppercase as +usual). The values of the enumeration will become variables in Go; +code should avoid modifying those variables. +

      + +

      20.3.5 Go Classes

      + + +

      +Go has interfaces, methods and inheritance, but it does not have +classes in the same sense as C++. This sections describes how SWIG +represents C++ classes represented in Go. +

      + +

      +For a C++ class ClassName, SWIG will define two types in Go: +an underlying type, which will just hold a pointer to the C++ type, +and an interface type. The interface type will be +named ClassName. SWIG will define a +function NewClassName which will take any constructor +arguments and return a value of the interface +type ClassName. SWIG will also define a +destructor DeleteClassName. +

      + +

      +SWIG will represent any methods of the C++ class as methods on the +underlying type, and also as methods of the interface type. Thus C++ +methods may be invoked directly using the +usual val.MethodName syntax. Public members of the C++ class +will be given getter and setter functions defined as methods of the +class. +

      + +

      +SWIG will represent static methods of C++ classes as ordinary Go +functions. SWIG will use names like ClassName_MethodName. +SWIG will give static members getter and setter functions with names +like GetClassName_VarName. +

      + +

      +Given a value of the interface type, Go code can retrieve the pointer +to the C++ type by calling the Swigcptr method. This will +return a value of type SwigcptrClassName, which is just a +name for uintptr. A Go type conversion can be used to +convert this value to a different C++ type, but note that this +conversion will not be type checked and is essentially equivalent +to reinterpret_cast. This should only be used for very +special cases, such as where C++ would use a dynamic_cast. +

      + +

      20.3.5.1 Go Class Inheritance

      + + +

      +C++ class inheritance is automatically represented in Go due to its +use of interfaces. The interface for a child class will be a superset +of the interface of its parent class. Thus a value of the child class +type in Go may be passed to a function which expects the parent class. +Doing the reverse will require an explicit type assertion, which will +be checked dynamically. +

      + +

      20.3.6 Go Templates

      + + +

      +In order to use C++ templates in Go, you must tell SWIG to create +wrappers for a particular template instantation. To do this, use +the %template directive. + +

      20.3.7 Go Director Classes

      + + +

      +SWIG's director feature permits a Go type to act as the subclass of a +C++ class with virtual methods. This is complicated by the fact that +C++ and Go define inheritance differently. In Go, structs can inherit +methods via anonymous field embedding. However, when a method is +called for an embedded struct, if that method calls any other methods, +they are called for the embedded struct, not for the original type. +Therefore, SWIG must use Go interfaces to represent C++ inheritance. +

      + +

      +In order to use the director feature in Go, you must define a type in +your Go code. You must then add methods for the type. Define a +method in Go for each C++ virtual function that you want to override. +You must then create a value of your new type, and pass a pointer to +it to the function NewDirectorClassName, +where ClassName is the name of the C++ class. That will +return a value of type ClassName. +

      + +

      +For example: +

      + +
      +
      +type GoClass struct { }
      +func (p *GoClass) VirtualFunction() { }
      +func MakeClass() ClassName {
      +	return NewDirectorClassName(&GoClass{})
      +}
      +
      +
      + +

      +Any call in C++ code to the virtual function will wind up calling the +method defined in Go. The Go code may of course call other methods on +itself, and those methods may be defined either in Go or in C++. +

      + +

      20.3.8 Default Go primitive type mappings

      + + +

      +The following table lists the default type mapping from C/C++ to Go. +This table will tell you which Go type to expect for a function which +uses a given C/C++ type. +

      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      C/C++ typeGo type
      boolbool
      charbyte
      signed charint8
      unsigned charbyte
      shortint16
      unsigned shortuint16
      intint
      unsigned intuint
      longint32 or int64, depending on -long-type-size
      unsigned longuint32 or uint64, depending on -long-type-size
      long longint64
      unsigned long longuint64
      floatfloat32
      doublefloat64
      char *
      char []
      string
      + +

      +Note that SWIG wraps the C char type as a character. Pointers +and arrays of this type are wrapped as strings. The signed +char type can be used if you want to treat char as a +signed number rather than a character. Also note that all const +references to primitive types are treated as if they are passed by +value. +

      + +

      +These type mappings are defined by the "go" typemap. You may change +that typemap, or add new values, to control how C/C++ types are mapped +into Go types. +

      + + + diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html index b4f332b14..d523bee77 100644 --- a/Doc/Manual/SWIG.html +++ b/Doc/Manual/SWIG.html @@ -113,6 +113,7 @@ can be obtained by typing swig -help or swig -clisp Generate CLISP wrappers -cffi Generate CFFI wrappers -csharp Generate C# wrappers +-go Generate Go wrappers -guile Generate Guile wrappers -java Generate Java wrappers -lua Generate Lua wrappers diff --git a/Doc/Manual/Sections.html b/Doc/Manual/Sections.html index e514f726d..8693adc07 100644 --- a/Doc/Manual/Sections.html +++ b/Doc/Manual/Sections.html @@ -36,6 +36,7 @@ Last update : SWIG-2.0.1 (in progress)
    • Allegro CL support
    • C# support
    • Chicken support
    • +
    • Go support
    • Guile support
    • Java support
    • Lua support
    • diff --git a/Doc/Manual/chapters b/Doc/Manual/chapters index bf180f1b4..cd399996b 100644 --- a/Doc/Manual/chapters +++ b/Doc/Manual/chapters @@ -17,6 +17,7 @@ CCache.html Allegrocl.html CSharp.html Chicken.html +Go.html Guile.html Java.html Lisp.html diff --git a/Examples/Makefile.in b/Examples/Makefile.in index 9dee0347f..5960d79fb 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -1141,3 +1141,74 @@ r_clean: rm -f *.@OBJEXT@ *@SO@ NAMESPACE rm -f $(RRSRC) runme.Rout .RData +################################################################## +##### Go ###### +################################################################## + +GO = @GO@ +GOGCC = @GOGCC@ + +GOSWIGARG = `if $(GOGCC) ; then echo -gccgo; fi` +GOCOMPILEARG = `if $(GOGCC) ; then echo -c -g; fi` + +GOSRCS = $(INTERFACE:.i=.go) +GOCSRCS = $(INTERFACE:.i=_gc.c) + +GOC = $(GO:g=c) +GOLD = $(GO:g=l) + +GOPACKAGE = $(INTERFACE:.i=.a) + +GOOBJEXT = $(GO:g=) +GOGCOBJS = $(GOSRCS:.go=.$(GOOBJEXT)) +GOGCCOBJS = $(GOSRCS:.go=.@OBJEXT@) + +# ---------------------------------------------------------------- +# Build a Go dynamically loadable module (C) +# ---------------------------------------------------------------- + +go: $(SRCS) + $(SWIG) -go $(GOSWIGARG) $(SWIGOPT) $(INTERFACEPATH) + $(CC) -g -c $(CCSHARED) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) + $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO) + $(GO) -I . $(GOCOMPILEARG) $(GOSRCS) + if ! $(GOGCC) ; then \ + $(GOC) -I $${GOROOT}/pkg/$${GOOS}_$${GOARCH} $(GOCSRCS) && \ + gopack grc $(GOPACKAGE) $(GOGCOBJS) $(GOCSRCS:.c=.$(GOOBJEXT)); \ + fi + +# ---------------------------------------------------------------- +# Build a Go dynamically loadable module (C++) +# ---------------------------------------------------------------- + +go_cpp: $(SRCS) + $(SWIG) -go -c++ $(GOSWIGARG) $(SWIGOPT) $(INTERFACEPATH) + $(CXX) -g -c $(CCSHARED) $(CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) + $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO) + $(GO) -I . $(GOCOMPILEARG) $(GOSRCS) + if ! $(GOGCC) ; then \ + $(GOC) -I $${GOROOT}/pkg/$${GOOS}_$${GOARCH} $(GOCSRCS) && \ + gopack grc $(GOPACKAGE) $(GOGCOBJS) $(GOCSRCS:.c=.$(GOOBJEXT)); \ + else true; fi + +# ----------------------------------------------------------------- +# Running a Go example +# ----------------------------------------------------------------- + +go_run: runme.go + $(GO) $(GOCOMPILEARG) runme.go + if $(GOGCC) ; then \ + $(GO) -o runme runme.@OBJEXT@ $(GOGCCOBJS) $(LIBPREFIX)$(TARGET)$(SO); \ + else \ + $(GOLD) -r $${GOROOT}/pkg/$${GOOS}_$${GOARCH}:. -o runme runme.$(GOOBJEXT); \ + fi + env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH ./runme + +# ----------------------------------------------------------------- +# Cleaning the Go examples +# ----------------------------------------------------------------- + +go_clean: + rm -f *_wrap* *_gc* .~* runme + rm -f core @EXTRA_CLEAN@ + rm -f *.@OBJEXT@ *.[568] *.a *@SO@ diff --git a/Examples/go/callback/Makefile b/Examples/go/callback/Makefile new file mode 100644 index 000000000..9dc8b8851 --- /dev/null +++ b/Examples/go/callback/Makefile @@ -0,0 +1,18 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +CXXSRCS = example.cxx +TARGET = example +INTERFACE = example.i +SWIGOPT = + +all:: go + +go:: + $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_cpp + +clean:: + $(MAKE) -f $(TOP)/Makefile go_clean + +check: all + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run diff --git a/Examples/go/callback/example.cxx b/Examples/go/callback/example.cxx new file mode 100644 index 000000000..450d75608 --- /dev/null +++ b/Examples/go/callback/example.cxx @@ -0,0 +1,4 @@ +/* File : example.cxx */ + +#include "example.h" + diff --git a/Examples/go/callback/example.go b/Examples/go/callback/example.go new file mode 100644 index 000000000..5c0cfb051 --- /dev/null +++ b/Examples/go/callback/example.go @@ -0,0 +1,188 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 2.0.1 + * + * This file is not intended to be easily readable and contains a number of + * coding conventions designed to improve portability and efficiency. Do not make + * changes to this file unless you know what you are doing--modify the SWIG + * interface file instead. + * ----------------------------------------------------------------------------- */ + +package example + + +type _swig_fnptr *byte +type _swig_memberptr *byte + + +func _swig_allocatememory(int) *byte +func _swig_internal_allocate(len int) *byte { + return _swig_allocatememory(len) +} + +func _swig_allocatestring(*byte, int) string +func _swig_internal_makegostring(p *byte, l int) string { + return _swig_allocatestring(p, l) +} + +func _swig_internal_gopanic(p *byte, l int) { + panic(_swig_allocatestring(p, l)) +} + +type _swig_DirectorCallback struct { + SwigcptrCallback + v interface{} +} + +func (p *_swig_DirectorCallback) Swigcptr() uintptr { + return p.SwigcptrCallback.Swigcptr() +} + +func (p *_swig_DirectorCallback) SwigIsCallback() { +} + +func (p *_swig_DirectorCallback) DirectorInterface() interface{} { + return p.v +} + +func _swig_NewDirectorCallbackCallback(*_swig_DirectorCallback) SwigcptrCallback + +func NewDirectorCallback(v interface{}) Callback { + p := &_swig_DirectorCallback{0, v} + p.SwigcptrCallback = _swig_NewDirectorCallbackCallback(p) + return p +} + +func _swig_wrap_DeleteDirectorCallback(uintptr) + +func DeleteDirectorCallback(arg1 Callback) { + _swig_wrap_DeleteDirectorCallback(arg1.Swigcptr()) +} + +func Swiggo_DeleteDirector_Callback(p *_swig_DirectorCallback) { + p.SwigcptrCallback = 0 +} + +type _swig_DirectorInterfaceCallbackRun interface { + Run() +} + +func _swig_wrap__swig_DirectorCallback_upcall_Run(SwigcptrCallback) +func (swig_p *_swig_DirectorCallback) Run() { + if swig_g, swig_ok := swig_p.v.(_swig_DirectorInterfaceCallbackRun); swig_ok { + swig_g.Run() + return + } + _swig_wrap__swig_DirectorCallback_upcall_Run(swig_p.SwigcptrCallback) +} + +func DirectorCallbackRun(p Callback) { + _swig_wrap__swig_DirectorCallback_upcall_Run(p.(*_swig_DirectorCallback).SwigcptrCallback) +} + +func Swig_DirectorCallback_callback_run(p *_swig_DirectorCallback) { + p.Run() +} + +type SwigcptrCallback uintptr + +func (p SwigcptrCallback) Swigcptr() uintptr { + return (uintptr)(p) +} + +func (p SwigcptrCallback) SwigIsCallback() { +} + +func (p SwigcptrCallback) DirectorInterface() interface{} { + return nil +} + +func _swig_wrap_delete_Callback(uintptr) + +func DeleteCallback(arg1 Callback) { + _swig_wrap_delete_Callback(arg1.Swigcptr()) +} + +func _swig_wrap_Callback_run(SwigcptrCallback) + +func (arg1 SwigcptrCallback) Run() { + _swig_wrap_Callback_run(arg1) +} + +func _swig_wrap_new_Callback() SwigcptrCallback + +func NewCallback() Callback { + return _swig_wrap_new_Callback() +} + +type Callback interface { + Swigcptr() uintptr + SwigIsCallback() + DirectorInterface() interface{} + Run() +} + +type SwigcptrCaller uintptr + +func (p SwigcptrCaller) Swigcptr() uintptr { + return (uintptr)(p) +} + +func (p SwigcptrCaller) SwigIsCaller() { +} + +func _swig_wrap_new_Caller() SwigcptrCaller + +func NewCaller() Caller { + return _swig_wrap_new_Caller() +} + +func _swig_wrap_delete_Caller(uintptr) + +func DeleteCaller(arg1 Caller) { + _swig_wrap_delete_Caller(arg1.Swigcptr()) +} + +func _swig_wrap_Caller_delCallback(SwigcptrCaller) + +func (arg1 SwigcptrCaller) DelCallback() { + _swig_wrap_Caller_delCallback(arg1) +} + +func _swig_wrap_Caller_setCallback(SwigcptrCaller, uintptr) + +func (arg1 SwigcptrCaller) SetCallback(arg2 Callback) { + _swig_wrap_Caller_setCallback(arg1, arg2.Swigcptr()) +} + +func _swig_wrap_Caller_call(SwigcptrCaller) + +func (arg1 SwigcptrCaller) Call() { + _swig_wrap_Caller_call(arg1) +} + +type Caller interface { + Swigcptr() uintptr + SwigIsCaller() + DelCallback() + SetCallback(arg2 Callback) + Call() +} + + +type SwigcptrSwigDirector_Callback uintptr +type SwigDirector_Callback interface { + Swigcptr() uintptr; +} +func (p SwigcptrSwigDirector_Callback) Swigcptr() uintptr { + return uintptr(p) +} + +type SwigcptrVoid uintptr +type Void interface { + Swigcptr() uintptr; +} +func (p SwigcptrVoid) Swigcptr() uintptr { + return uintptr(p) +} + diff --git a/Examples/go/callback/example.h b/Examples/go/callback/example.h new file mode 100644 index 000000000..1a0e8c432 --- /dev/null +++ b/Examples/go/callback/example.h @@ -0,0 +1,23 @@ +/* File : example.h */ + +#include +#include + +class Callback { +public: + virtual ~Callback() { std::cout << "Callback::~Callback()" << std:: endl; } + virtual void run() { std::cout << "Callback::run()" << std::endl; } +}; + + +class Caller { +private: + Callback *_callback; +public: + Caller(): _callback(0) {} + ~Caller() { delCallback(); } + void delCallback() { delete _callback; _callback = 0; } + void setCallback(Callback *cb) { delCallback(); _callback = cb; } + void call() { if (_callback) _callback->run(); } +}; + diff --git a/Examples/go/callback/example.i b/Examples/go/callback/example.i new file mode 100644 index 000000000..90beda01a --- /dev/null +++ b/Examples/go/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/go/callback/index.html b/Examples/go/callback/index.html new file mode 100644 index 000000000..b053cf547 --- /dev/null +++ b/Examples/go/callback/index.html @@ -0,0 +1,81 @@ + + +SWIG:Examples:go:callback + + + + + +SWIG/Examples/go/callback/ +
      + +

      Implementing C++ callbacks in Go

      + +

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

      + +

      +Because Go and C++ use inheritance differently, you must call a +different function to create a class which uses callbacks. Instead of +calling the usual constructor function whose name is New +followed by the capitalized name of the class, you call a function +named NewDirector followed by the capitalized name of the +class. +

      + +

      +The first argument to the NewDirector function is an instance +of a type. The NewDirector function will return an interface +value as usual. However, when calling any method on the returned +value, the program will first check whether the value passed +to NewDirector implements that method. If it does, the +method will be called in Go. This is true whether the method is +called from Go code or C++ code. +

      + +

      +Note that the Go code will be called with just the Go value, not the +C++ value. If the Go code needs to call a C++ method on itself, you +need to get a copy of the C++ object. This is typically done as +follows: + +

      +
      +type Child struct { abi Parent }
      +func (p *Child) ChildMethod() {
      +	p.abi.ParentMethod()
      +}
      +func f() {
      +	p := &Child{nil}
      +	d := NewDirectorParent(p)
      +	p.abi = d
      +	...
      +}
      +
      +
      + +In other words, we first create the Go value. We pass that to +the NewDirector function to create the C++ value; this C++ +value will be created with an association to the Go value. We then +store the C++ value in the Go value, giving us the reverse +association. That permits us to call parent methods from the child. + +

      + +

      +To delete a director object, use the function DeleteDirector +followed by the capitalized name of the class. +

      + +

      +

      + +
      + + diff --git a/Examples/go/callback/runme.go b/Examples/go/callback/runme.go new file mode 100644 index 000000000..ffa4b3874 --- /dev/null +++ b/Examples/go/callback/runme.go @@ -0,0 +1,41 @@ +package main + +import ( + "fmt" + . "./example" +) + +func main() { + fmt.Println("Adding and calling a normal C++ callback") + fmt.Println("----------------------------------------") + + caller := NewCaller() + callback := NewCallback() + + caller.SetCallback(callback) + caller.Call() + caller.DelCallback() + + callback = NewDirectorCallback(new(GoCallback)) + + fmt.Println() + fmt.Println("Adding and calling a Go callback") + fmt.Println("------------------------------------") + + caller.SetCallback(callback) + caller.Call() + caller.DelCallback() + + // Test that a double delete does not occur as the object has + // already been deleted from the C++ layer. + DeleteDirectorCallback(callback) + + fmt.Println() + fmt.Println("Go exit") +} + +type GoCallback struct{} + +func (p *GoCallback) Run() { + fmt.Println("GoCallback.Run") +} diff --git a/Examples/go/check.list b/Examples/go/check.list new file mode 100644 index 000000000..5399b8979 --- /dev/null +++ b/Examples/go/check.list @@ -0,0 +1,13 @@ +# see top-level Makefile.in +callback +class +constants +enum +extend +funcptr +multimap +pointer +reference +simple +template +variables diff --git a/Examples/go/class/Makefile b/Examples/go/class/Makefile new file mode 100644 index 000000000..53d31d1a4 --- /dev/null +++ b/Examples/go/class/Makefile @@ -0,0 +1,16 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +CXXSRCS = example.cxx +TARGET = example +INTERFACE = example.i +LIBS = -lm + +all:: + $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_cpp + +clean:: + $(MAKE) -f $(TOP)/Makefile go_clean + +check: all + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run diff --git a/Examples/go/class/example.cxx b/Examples/go/class/example.cxx new file mode 100644 index 000000000..1e8e203dd --- /dev/null +++ b/Examples/go/class/example.cxx @@ -0,0 +1,28 @@ +/* File : example.c */ + +#include "example.h" +#define M_PI 3.14159265358979323846 + +/* Move the shape to a new location */ +void Shape::move(double dx, double dy) { + x += dx; + y += dy; +} + +int Shape::nshapes = 0; + +double Circle::area(void) { + return M_PI*radius*radius; +} + +double Circle::perimeter(void) { + return 2*M_PI*radius; +} + +double Square::area(void) { + return width*width; +} + +double Square::perimeter(void) { + return 4*width; +} diff --git a/Examples/go/class/example.go b/Examples/go/class/example.go new file mode 100644 index 000000000..ec8113ad4 --- /dev/null +++ b/Examples/go/class/example.go @@ -0,0 +1,284 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 2.0.1 + * + * This file is not intended to be easily readable and contains a number of + * coding conventions designed to improve portability and efficiency. Do not make + * changes to this file unless you know what you are doing--modify the SWIG + * interface file instead. + * ----------------------------------------------------------------------------- */ + +package example + + +type _swig_fnptr *byte +type _swig_memberptr *byte + + +func _swig_allocatememory(int) *byte +func _swig_internal_allocate(len int) *byte { + return _swig_allocatememory(len) +} + +func _swig_allocatestring(*byte, int) string +func _swig_internal_makegostring(p *byte, l int) string { + return _swig_allocatestring(p, l) +} + +func _swig_internal_gopanic(p *byte, l int) { + panic(_swig_allocatestring(p, l)) +} + +type SwigcptrShape uintptr + +func (p SwigcptrShape) Swigcptr() uintptr { + return (uintptr)(p) +} + +func (p SwigcptrShape) SwigIsShape() { +} + +func _swig_wrap_delete_Shape(uintptr) + +func DeleteShape(arg1 Shape) { + _swig_wrap_delete_Shape(arg1.Swigcptr()) +} + +func _swig_wrap_Shape_x_set(SwigcptrShape, float64) + +func (arg1 SwigcptrShape) SetX(arg2 float64) { + _swig_wrap_Shape_x_set(arg1, arg2) +} + +func _swig_wrap_Shape_x_get(SwigcptrShape) float64 + +func (arg1 SwigcptrShape) GetX() float64 { + return _swig_wrap_Shape_x_get(arg1) +} + +func _swig_wrap_Shape_y_set(SwigcptrShape, float64) + +func (arg1 SwigcptrShape) SetY(arg2 float64) { + _swig_wrap_Shape_y_set(arg1, arg2) +} + +func _swig_wrap_Shape_y_get(SwigcptrShape) float64 + +func (arg1 SwigcptrShape) GetY() float64 { + return _swig_wrap_Shape_y_get(arg1) +} + +func _swig_wrap_Shape_move(SwigcptrShape, float64, float64) + +func (arg1 SwigcptrShape) Move(arg2 float64, arg3 float64) { + _swig_wrap_Shape_move(arg1, arg2, arg3) +} + +func _swig_wrap_Shape_area(SwigcptrShape) float64 + +func (arg1 SwigcptrShape) Area() float64 { + return _swig_wrap_Shape_area(arg1) +} + +func _swig_wrap_Shape_perimeter(SwigcptrShape) float64 + +func (arg1 SwigcptrShape) Perimeter() float64 { + return _swig_wrap_Shape_perimeter(arg1) +} + +func _swig_wrap_Shape_nshapes_set(int) + +func SetShapeNshapes(arg1 int) { + _swig_wrap_Shape_nshapes_set(arg1) +} + +func GetShapeNshapes() int +type Shape interface { + Swigcptr() uintptr + SwigIsShape() + SetX(arg2 float64) + GetX() float64 + SetY(arg2 float64) + GetY() float64 + Move(arg2 float64, arg3 float64) + Area() float64 + Perimeter() float64 +} + +type SwigcptrCircle uintptr + +func (p SwigcptrCircle) Swigcptr() uintptr { + return (uintptr)(p) +} + +func (p SwigcptrCircle) SwigIsCircle() { +} + +func _swig_wrap_new_Circle(float64) SwigcptrCircle + +func NewCircle(arg1 float64) Circle { + return _swig_wrap_new_Circle(arg1) +} + +func _swig_wrap_Circle_area(SwigcptrCircle) float64 + +func (arg1 SwigcptrCircle) Area() float64 { + return _swig_wrap_Circle_area(arg1) +} + +func _swig_wrap_Circle_perimeter(SwigcptrCircle) float64 + +func (arg1 SwigcptrCircle) Perimeter() float64 { + return _swig_wrap_Circle_perimeter(arg1) +} + +func _swig_wrap_delete_Circle(uintptr) + +func DeleteCircle(arg1 Circle) { + _swig_wrap_delete_Circle(arg1.Swigcptr()) +} + +func _swig_wrap_SetCircle_X(SwigcptrCircle, float64) + +func (_swig_base SwigcptrCircle) SetX(arg1 float64) { + _swig_wrap_SetCircle_X(_swig_base, arg1) +} + +func _swig_wrap_GetCircle_X(SwigcptrCircle) float64 + +func (_swig_base SwigcptrCircle) GetX() float64 { + return _swig_wrap_GetCircle_X(_swig_base) +} + +func _swig_wrap_SetCircle_Y(SwigcptrCircle, float64) + +func (_swig_base SwigcptrCircle) SetY(arg1 float64) { + _swig_wrap_SetCircle_Y(_swig_base, arg1) +} + +func _swig_wrap_GetCircle_Y(SwigcptrCircle) float64 + +func (_swig_base SwigcptrCircle) GetY() float64 { + return _swig_wrap_GetCircle_Y(_swig_base) +} + +func _swig_wrap_Circle_move(SwigcptrCircle, float64, float64) + +func (_swig_base SwigcptrCircle) Move(arg1 float64, arg2 float64) { + _swig_wrap_Circle_move(_swig_base, arg1, arg2) +} + +func (p SwigcptrCircle) SwigIsShape() { +} + +func (p SwigcptrCircle) SwigGetShape() Shape { + return SwigcptrShape(p.Swigcptr()) +} + +type Circle interface { + Swigcptr() uintptr + SwigIsCircle() + Area() float64 + Perimeter() float64 + SetX(arg1 float64) + GetX() float64 + SetY(arg1 float64) + GetY() float64 + Move(arg1 float64, arg2 float64) + SwigIsShape() + SwigGetShape() Shape +} + +type SwigcptrSquare uintptr + +func (p SwigcptrSquare) Swigcptr() uintptr { + return (uintptr)(p) +} + +func (p SwigcptrSquare) SwigIsSquare() { +} + +func _swig_wrap_new_Square(float64) SwigcptrSquare + +func NewSquare(arg1 float64) Square { + return _swig_wrap_new_Square(arg1) +} + +func _swig_wrap_Square_area(SwigcptrSquare) float64 + +func (arg1 SwigcptrSquare) Area() float64 { + return _swig_wrap_Square_area(arg1) +} + +func _swig_wrap_Square_perimeter(SwigcptrSquare) float64 + +func (arg1 SwigcptrSquare) Perimeter() float64 { + return _swig_wrap_Square_perimeter(arg1) +} + +func _swig_wrap_delete_Square(uintptr) + +func DeleteSquare(arg1 Square) { + _swig_wrap_delete_Square(arg1.Swigcptr()) +} + +func _swig_wrap_SetSquare_X(SwigcptrSquare, float64) + +func (_swig_base SwigcptrSquare) SetX(arg1 float64) { + _swig_wrap_SetSquare_X(_swig_base, arg1) +} + +func _swig_wrap_GetSquare_X(SwigcptrSquare) float64 + +func (_swig_base SwigcptrSquare) GetX() float64 { + return _swig_wrap_GetSquare_X(_swig_base) +} + +func _swig_wrap_SetSquare_Y(SwigcptrSquare, float64) + +func (_swig_base SwigcptrSquare) SetY(arg1 float64) { + _swig_wrap_SetSquare_Y(_swig_base, arg1) +} + +func _swig_wrap_GetSquare_Y(SwigcptrSquare) float64 + +func (_swig_base SwigcptrSquare) GetY() float64 { + return _swig_wrap_GetSquare_Y(_swig_base) +} + +func _swig_wrap_Square_move(SwigcptrSquare, float64, float64) + +func (_swig_base SwigcptrSquare) Move(arg1 float64, arg2 float64) { + _swig_wrap_Square_move(_swig_base, arg1, arg2) +} + +func (p SwigcptrSquare) SwigIsShape() { +} + +func (p SwigcptrSquare) SwigGetShape() Shape { + return SwigcptrShape(p.Swigcptr()) +} + +type Square interface { + Swigcptr() uintptr + SwigIsSquare() + Area() float64 + Perimeter() float64 + SetX(arg1 float64) + GetX() float64 + SetY(arg1 float64) + GetY() float64 + Move(arg1 float64, arg2 float64) + SwigIsShape() + SwigGetShape() Shape +} + + +type SwigcptrVoid uintptr +type Void interface { + Swigcptr() uintptr; +} +func (p SwigcptrVoid) Swigcptr() uintptr { + return uintptr(p) +} + diff --git a/Examples/go/class/example.h b/Examples/go/class/example.h new file mode 100644 index 000000000..46d901361 --- /dev/null +++ b/Examples/go/class/example.h @@ -0,0 +1,39 @@ +/* File : example.h */ + +class Shape { +public: + Shape() { + nshapes++; + } + virtual ~Shape() { + nshapes--; + }; + double x, y; + void move(double dx, double dy); + virtual double area(void) = 0; + virtual double perimeter(void) = 0; + static int nshapes; +}; + +class Circle : public Shape { +private: + double radius; +public: + Circle(double r) : radius(r) { }; + virtual double area(void); + virtual double perimeter(void); +}; + +class Square : public Shape { +private: + double width; +public: + Square(double w) : width(w) { }; + virtual double area(void); + virtual double perimeter(void); +}; + + + + + diff --git a/Examples/go/class/example.i b/Examples/go/class/example.i new file mode 100644 index 000000000..75700b305 --- /dev/null +++ b/Examples/go/class/example.i @@ -0,0 +1,10 @@ +/* File : example.i */ +%module example + +%{ +#include "example.h" +%} + +/* Let's just grab the original header file here */ +%include "example.h" + diff --git a/Examples/go/class/index.html b/Examples/go/class/index.html new file mode 100644 index 000000000..b39119d12 --- /dev/null +++ b/Examples/go/class/index.html @@ -0,0 +1,203 @@ + + +SWIG:Examples:go:class + + + + + +SWIG/Examples/go/class/ +
      + +

      Wrapping a simple C++ class

      + +

      +This example illustrates the most primitive form of C++ class wrapping +performed by SWIG. In this case, C++ classes are simply transformed +into a collection of C-style functions that provide access to class +members. + +

      The C++ Code

      + +Suppose you have some C++ classes described by the following (and +admittedly lame) header file: + +
      +
      +/* File : example.h */
      +
      +class Shape {
      +public:
      +  Shape() {
      +    nshapes++;
      +  }
      +  virtual ~Shape() {
      +    nshapes--;
      +  };
      +  double  x, y;   
      +  void    move(double dx, double dy);
      +  virtual double area() = 0;
      +  virtual double perimeter() = 0;
      +  static  int nshapes;
      +};
      +
      +class Circle : public Shape {
      +private:
      +  double radius;
      +public:
      +  Circle(double r) : radius(r) { };
      +  virtual double area();
      +  virtual double perimeter();
      +};
      +
      +class Square : public Shape {
      +private:
      +  double width;
      +public:
      +  Square(double w) : width(w) { };
      +  virtual double area();
      +  virtual double perimeter();
      +};
      +
      +
      + +

      The SWIG interface

      + +A simple SWIG interface for this can be built by simply grabbing the +header file like this: + +
      +
      +/* File : example.i */
      +%module example
      +
      +%{
      +#include "example.h"
      +%}
      +
      +/* Let's just grab the original header file here */
      +%include "example.h"
      +
      +
      + +Note: when creating a C++ extension, you must run SWIG with +the -c++ option like this: +
      +
      +% swig -c++ -go example.i
      +
      +
      + +

      A sample Go script

      + +See example.go for a program that calls the +C++ functions from Go. + +

      Key points

      + +
        +
      • To create a new object, you call a constructor like this: + +
        +
        +c := example.NewCircle(10.0)
        +
        +
        + +The name of the constructor is New followed by the name of +the class, capitalized. + +

        +

      • +The constructor returns a value of interface type. The methods of the +interface will be the methods of the C++ class, plus member accessor +functions. + +

        +

      • To access member data, a pair of accessor methods are used. For +example: + +
        +
        +c.SetX(15)          # Set member data
        +x := c.GetX()       # Get member data.
        +
        +
        + +These are methods on the type returned by the constructor. The getter +is named Get followed by the name of the member, +capitalized. The setter is similar but uses Set. + +

        +

      • To invoke a member function, you simply do this + +
        +
        +fmt.Println("The area is", example.c.Area())
        +
        +
        + +
      • To invoke a destructor, simply do this + +
        +
        +example.DeleteShape(c)     # Deletes a shape
        +
        +
        + +The name of the destructor is Delete followed by the name of +the class, capitalized. (Note: destructors are currently not +inherited. This might change later). + +

        +

      • Static member variables are wrapped much like C global variables. +For example: + +
        +
        +n := GetShapeNshapes()     # Get a static data member
        +SetShapeNshapes(13)        # Set a static data member
        +
        +
        + +The name is Get or Set, followed by the name of the +class, capitalized, followed by the name of the member, capitalized. + +
      + +

      General Comments

      + +
        +
      • This low-level interface is not the only way to handle C++ code. +Director classes provide a much higher-level interface. + +

        +

      • Because C++ and Go implement inheritance quite differently, you +can not simply upcast an object in Go code when using multiple +inheritance. When using only single inheritance, you can simply pass +a class to a function expecting a parent class. When using multiple +inheritance, you have to call an automatically generated getter +function named Get followed by the capitalized name of the +immediate parent. This will return the same object converted to the + parent class. + +

        +

      • +Overloaded methods should normally work. However, when calling an +overloaded method you must explicitly convert constants to the +expected type when it is not int or float. In +particular, a floating point constant will default to +type float, but C++ functions typically expect the C++ +type double which is equivalent to the Go +type float64 So calling an overloaded method with a floating +point constant typically requires an explicit conversion +to float64. + +

        +

      • Namespaces are not supported in any very coherent way. + +
      + +
      + + diff --git a/Examples/go/class/runme.go b/Examples/go/class/runme.go new file mode 100644 index 000000000..ff64bb4be --- /dev/null +++ b/Examples/go/class/runme.go @@ -0,0 +1,63 @@ +// This example illustrates how C++ classes can be used from Go using SWIG. + +package main + +import ( + "fmt" + . "./example" +) + +func main() { + // ----- Object creation ----- + + fmt.Println("Creating some objects:") + c := NewCircle(10) + fmt.Println(" Created circle", c) + s := NewSquare(10) + fmt.Println(" Created square", s) + + // ----- Access a static member ----- + + fmt.Println("\nA total of", GetShapeNshapes(), "shapes were created") + + // ----- Member data access ----- + + // Notice how we can do this using functions specific to + // the 'Circle' class. + c.SetX(20) + c.SetY(30) + + // Now use the same functions in the base class + var shape Shape = s + shape.SetX(-10) + shape.SetY(5) + + fmt.Println("\nHere is their current position:") + fmt.Println(" Circle = (", c.GetX(), " ", c.GetY(), ")") + fmt.Println(" Square = (", s.GetX(), " ", s.GetY(), ")") + + // ----- Call some methods ----- + + fmt.Println("\nHere are some properties of the shapes:") + shapes := []Shape{c, s} + for i := 0; i < len(shapes); i++ { + fmt.Println(" ", shapes[i]) + fmt.Println(" area = ", shapes[i].Area()) + fmt.Println(" perimeter = ", shapes[i].Perimeter()) + } + + // Notice how the area() and perimeter() functions really + // invoke the appropriate virtual method on each object. + + // ----- Delete everything ----- + + fmt.Println("\nGuess I'll clean up now") + + // Note: this invokes the virtual destructor + // You could leave this to the garbage collector + DeleteCircle(c) + DeleteSquare(s) + + fmt.Println(GetShapeNshapes(), " shapes remain") + fmt.Println("Goodbye") +} diff --git a/Examples/go/constants/Makefile b/Examples/go/constants/Makefile new file mode 100644 index 000000000..71d4d73a4 --- /dev/null +++ b/Examples/go/constants/Makefile @@ -0,0 +1,16 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +CXXSRCS = +TARGET = example +INTERFACE = example.i +SWIGOPT = + +all:: + $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go + +clean:: + $(MAKE) -f $(TOP)/Makefile go_clean + +check: all + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run diff --git a/Examples/go/constants/example.go b/Examples/go/constants/example.go new file mode 100644 index 000000000..0e5e66418 --- /dev/null +++ b/Examples/go/constants/example.go @@ -0,0 +1,44 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 2.0.1 + * + * This file is not intended to be easily readable and contains a number of + * coding conventions designed to improve portability and efficiency. Do not make + * changes to this file unless you know what you are doing--modify the SWIG + * interface file instead. + * ----------------------------------------------------------------------------- */ + +package example + + +type _swig_fnptr *byte +type _swig_memberptr *byte + + +func _swig_allocatememory(int) *byte +func _swig_internal_allocate(len int) *byte { + return _swig_allocatememory(len) +} + +func _swig_allocatestring(*byte, int) string +func _swig_internal_makegostring(p *byte, l int) string { + return _swig_allocatestring(p, l) +} + +func _swig_internal_gopanic(p *byte, l int) { + panic(_swig_allocatestring(p, l)) +} + +const ICONST int = 42 +const FCONST float64 = 2.1828 +const CCONST byte = 'x' +func _swig_getCCONST2() byte +var CCONST2 byte = _swig_getCCONST2() +const SCONST string = "Hello World" +func _swig_getSCONST2() string +var SCONST2 string = _swig_getSCONST2() +func _swig_getEXPR() float64 +var EXPR float64 = _swig_getEXPR() +const Iconst int = 37 +const Fconst float64 = 3.14 + diff --git a/Examples/go/constants/example.i b/Examples/go/constants/example.i new file mode 100644 index 000000000..daca042df --- /dev/null +++ b/Examples/go/constants/example.i @@ -0,0 +1,25 @@ +/* File : example.i */ +%module example + +/* A few preprocessor macros */ + +#define ICONST 42 +#define FCONST 2.1828 +#define CCONST 'x' +#define CCONST2 '\n' +#define SCONST "Hello World" +#define SCONST2 "\"Hello World\"" + +/* This should work just fine */ +#define EXPR ICONST + 3*(FCONST) + +/* This shouldn't do anything */ +#define EXTERN extern + +/* Neither should this (BAR isn't defined) */ +#define FOO (ICONST + BAR) + +/* The following directives also produce constants */ + +%constant int iconst = 37; +%constant double fconst = 3.14; diff --git a/Examples/go/constants/index.html b/Examples/go/constants/index.html new file mode 100644 index 000000000..b1397ab2d --- /dev/null +++ b/Examples/go/constants/index.html @@ -0,0 +1,55 @@ + + +SWIG:Examples:go:constants + + + + +SWIG/Examples/go/constants/ +
      + +

      Wrapping C Constants

      + +

      +When SWIG encounters C preprocessor macros and C declarations that +look like constants, it creates a Go constant with an identical value. +Click here to see a SWIG interface with some +constant declarations in it. + + +

      Accessing Constants from Go

      +Click here for +the section on constants in the SWIG and Go documentation. +

      + +Click here to see a Go program that prints out +the values of the constants contained in the above file.

      +

      Key points

      +
        +
      • All names are capitalized to make them visible. +
      • The values of preprocessor macros are converted into Go constants. +
      • C string literals such as "Hello World" are converted into Go strings. +
      • Macros that are not fully defined are simply ignored. For example: +
        +
        +#define EXTERN extern
        +
        +
        +is ignored because SWIG has no idea what type of variable this would be. + +

        +

      • Expressions are allowed provided that all of their components are +defined. Otherwise, the constant is ignored. + +
      • Certain C declarations involving 'const' are also turned into Go +constants. +
      • The constants that appear in a SWIG interface file do not have to +appear in any sort of matching C source file since the creation of a +constant does not require linkage to a stored value (i.e., a value +held in a C global variable or memory location). +
      + +
      + + + diff --git a/Examples/go/constants/runme.go b/Examples/go/constants/runme.go new file mode 100644 index 000000000..78a047e20 --- /dev/null +++ b/Examples/go/constants/runme.go @@ -0,0 +1,18 @@ +package main + +import ( + "fmt" + "./example" +) + +func main() { + fmt.Println("ICONST = ", example.ICONST, " (should be 42)") + fmt.Println("FCONST = ", example.FCONST, " (should be 2.1828)") + fmt.Printf("CCONST = %c (should be 'x')\n", example.CCONST) + fmt.Printf("CCONST2 = %c(this should be on a new line)\n", example.CCONST2) + fmt.Println("SCONST = ", example.SCONST, " (should be 'Hello World')") + fmt.Println("SCONST2 = ", example.SCONST2, " (should be '\"Hello World\"')") + fmt.Println("EXPR = ", example.EXPR, " (should be 48.5484)") + fmt.Println("iconst = ", example.Iconst, " (should be 37)") + fmt.Println("fconst = ", example.Fconst, " (should be 3.14)") +} diff --git a/Examples/go/enum/Makefile b/Examples/go/enum/Makefile new file mode 100644 index 000000000..9dc8b8851 --- /dev/null +++ b/Examples/go/enum/Makefile @@ -0,0 +1,18 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +CXXSRCS = example.cxx +TARGET = example +INTERFACE = example.i +SWIGOPT = + +all:: go + +go:: + $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_cpp + +clean:: + $(MAKE) -f $(TOP)/Makefile go_clean + +check: all + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run diff --git a/Examples/go/enum/example.cxx b/Examples/go/enum/example.cxx new file mode 100644 index 000000000..df7bb6328 --- /dev/null +++ b/Examples/go/enum/example.cxx @@ -0,0 +1,37 @@ +/* File : example.cxx */ + +#include "example.h" +#include + +void Foo::enum_test(speed s) { + if (s == IMPULSE) { + printf("IMPULSE speed\n"); + } else if (s == WARP) { + printf("WARP speed\n"); + } else if (s == LUDICROUS) { + printf("LUDICROUS speed\n"); + } else { + printf("Unknown speed\n"); + } +} + +void enum_test(color c, Foo::speed s) { + if (c == RED) { + printf("color = RED, "); + } else if (c == BLUE) { + printf("color = BLUE, "); + } else if (c == GREEN) { + printf("color = GREEN, "); + } else { + printf("color = Unknown color!, "); + } + if (s == Foo::IMPULSE) { + printf("speed = IMPULSE speed\n"); + } else if (s == Foo::WARP) { + printf("speed = WARP speed\n"); + } else if (s == Foo::LUDICROUS) { + printf("speed = LUDICROUS speed\n"); + } else { + printf("speed = Unknown speed!\n"); + } +} diff --git a/Examples/go/enum/example.go b/Examples/go/enum/example.go new file mode 100644 index 000000000..4653ab57a --- /dev/null +++ b/Examples/go/enum/example.go @@ -0,0 +1,93 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 2.0.1 + * + * This file is not intended to be easily readable and contains a number of + * coding conventions designed to improve portability and efficiency. Do not make + * changes to this file unless you know what you are doing--modify the SWIG + * interface file instead. + * ----------------------------------------------------------------------------- */ + +package example + + +type _swig_fnptr *byte +type _swig_memberptr *byte + + +func _swig_allocatememory(int) *byte +func _swig_internal_allocate(len int) *byte { + return _swig_allocatememory(len) +} + +func _swig_allocatestring(*byte, int) string +func _swig_internal_makegostring(p *byte, l int) string { + return _swig_allocatestring(p, l) +} + +func _swig_internal_gopanic(p *byte, l int) { + panic(_swig_allocatestring(p, l)) +} + +type Color int +func _swig_getRED() Color +var RED Color = _swig_getRED() +func _swig_getBLUE() Color +var BLUE Color = _swig_getBLUE() +func _swig_getGREEN() Color +var GREEN Color = _swig_getGREEN() +type SwigcptrFoo uintptr + +func (p SwigcptrFoo) Swigcptr() uintptr { + return (uintptr)(p) +} + +func (p SwigcptrFoo) SwigIsFoo() { +} + +func _swig_wrap_new_Foo() SwigcptrFoo + +func NewFoo() Foo { + return _swig_wrap_new_Foo() +} + +type FooSpeed int +func _swig_getFoo_IMPULSE_Foo() FooSpeed +var FooIMPULSE FooSpeed = _swig_getFoo_IMPULSE_Foo() +func _swig_getFoo_WARP_Foo() FooSpeed +var FooWARP FooSpeed = _swig_getFoo_WARP_Foo() +func _swig_getFoo_LUDICROUS_Foo() FooSpeed +var FooLUDICROUS FooSpeed = _swig_getFoo_LUDICROUS_Foo() +func _swig_wrap_Foo_enum_test(SwigcptrFoo, FooSpeed) + +func (arg1 SwigcptrFoo) Enum_test(arg2 FooSpeed) { + _swig_wrap_Foo_enum_test(arg1, arg2) +} + +func _swig_wrap_delete_Foo(uintptr) + +func DeleteFoo(arg1 Foo) { + _swig_wrap_delete_Foo(arg1.Swigcptr()) +} + +type Foo interface { + Swigcptr() uintptr + SwigIsFoo() + Enum_test(arg2 FooSpeed) +} + +func _swig_wrap_enum_test(Color, FooSpeed) + +func Enum_test(arg1 Color, arg2 FooSpeed) { + _swig_wrap_enum_test(arg1, arg2) +} + + +type SwigcptrVoid uintptr +type Void interface { + Swigcptr() uintptr; +} +func (p SwigcptrVoid) Swigcptr() uintptr { + return uintptr(p) +} + diff --git a/Examples/go/enum/example.h b/Examples/go/enum/example.h new file mode 100644 index 000000000..9119cd9fc --- /dev/null +++ b/Examples/go/enum/example.h @@ -0,0 +1,13 @@ +/* File : example.h */ + +enum color { RED, BLUE, GREEN }; + +class Foo { + public: + Foo() { } + enum speed { IMPULSE=10, WARP=20, LUDICROUS=30 }; + void enum_test(speed s); +}; + +void enum_test(color c, Foo::speed s); + diff --git a/Examples/go/enum/example.i b/Examples/go/enum/example.i new file mode 100644 index 000000000..23ee8a822 --- /dev/null +++ b/Examples/go/enum/example.i @@ -0,0 +1,11 @@ +/* File : example.i */ +%module example + +%{ +#include "example.h" +%} + +/* Let's just grab the original header file here */ + +%include "example.h" + diff --git a/Examples/go/enum/index.html b/Examples/go/enum/index.html new file mode 100644 index 000000000..868efe6ad --- /dev/null +++ b/Examples/go/enum/index.html @@ -0,0 +1,42 @@ + + +SWIG:Examples:go:enum + + + + + +SWIG/Examples/go/enum/ +
      + +

      Wrapping enumerations

      + +

      +This example tests SWIG's ability to wrap enumerations. +

        +
      • +Enum values are expressed as constants or variables in GO. +
      • +If the enum is named, then that name, capitalized, as defined as a new +type name for int. All the enum values will be defined to +have that type. +
      • +If the enum is declared at global level, then the name in Go is simply +the enum value, capitalized. +
      • +If the enum is declared within a C++ class or struct, then the name in +Go is the capitalized name of the class or struct followed by the +capitalized name of the enum value. +
      • +
      + +

      +

      + +
      + + diff --git a/Examples/go/enum/runme.go b/Examples/go/enum/runme.go new file mode 100644 index 000000000..419df5f93 --- /dev/null +++ b/Examples/go/enum/runme.go @@ -0,0 +1,32 @@ +package main + +import ( + "fmt" + . "./example" +) + +func main() { + // Print out the value of some enums + fmt.Println("*** color ***") + fmt.Println(" RED = ", RED) + fmt.Println(" BLUE = ", BLUE) + fmt.Println(" GREEN = ", GREEN) + + fmt.Println("\n*** Foo::speed ***") + fmt.Println(" Foo::IMPULSE = ", FooIMPULSE) + fmt.Println(" Foo::WARP = ", FooWARP) + fmt.Println(" Foo::LUDICROUS = ", FooLUDICROUS) + + fmt.Println("\nTesting use of enums with functions\n") + + Enum_test(RED, FooIMPULSE) + Enum_test(BLUE, FooWARP) + Enum_test(GREEN, FooLUDICROUS) + + fmt.Println("\nTesting use of enum with class method") + f := NewFoo() + + f.Enum_test(FooIMPULSE) + f.Enum_test(FooWARP) + f.Enum_test(FooLUDICROUS) +} diff --git a/Examples/go/extend/Makefile b/Examples/go/extend/Makefile new file mode 100644 index 000000000..9dc8b8851 --- /dev/null +++ b/Examples/go/extend/Makefile @@ -0,0 +1,18 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +CXXSRCS = example.cxx +TARGET = example +INTERFACE = example.i +SWIGOPT = + +all:: go + +go:: + $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_cpp + +clean:: + $(MAKE) -f $(TOP)/Makefile go_clean + +check: all + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run diff --git a/Examples/go/extend/example.cxx b/Examples/go/extend/example.cxx new file mode 100644 index 000000000..450d75608 --- /dev/null +++ b/Examples/go/extend/example.cxx @@ -0,0 +1,4 @@ +/* File : example.cxx */ + +#include "example.h" + diff --git a/Examples/go/extend/example.go b/Examples/go/extend/example.go new file mode 100644 index 000000000..08f21e6ab --- /dev/null +++ b/Examples/go/extend/example.go @@ -0,0 +1,397 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 2.0.1 + * + * This file is not intended to be easily readable and contains a number of + * coding conventions designed to improve portability and efficiency. Do not make + * changes to this file unless you know what you are doing--modify the SWIG + * interface file instead. + * ----------------------------------------------------------------------------- */ + +package example + + +type _swig_fnptr *byte +type _swig_memberptr *byte + + +func _swig_allocatememory(int) *byte +func _swig_internal_allocate(len int) *byte { + return _swig_allocatememory(len) +} + +func _swig_allocatestring(*byte, int) string +func _swig_internal_makegostring(p *byte, l int) string { + return _swig_allocatestring(p, l) +} + +func _swig_internal_gopanic(p *byte, l int) { + panic(_swig_allocatestring(p, l)) +} + +type _swig_DirectorEmployee struct { + SwigcptrEmployee + v interface{} +} + +func (p *_swig_DirectorEmployee) Swigcptr() uintptr { + return p.SwigcptrEmployee.Swigcptr() +} + +func (p *_swig_DirectorEmployee) SwigIsEmployee() { +} + +func (p *_swig_DirectorEmployee) DirectorInterface() interface{} { + return p.v +} + +func _swig_NewDirectorEmployeeEmployee(*_swig_DirectorEmployee, string) SwigcptrEmployee + +func NewDirectorEmployee(v interface{}, arg1 string) Employee { + p := &_swig_DirectorEmployee{0, v} + p.SwigcptrEmployee = _swig_NewDirectorEmployeeEmployee(p, arg1) + return p +} + +type _swig_DirectorInterfaceEmployeeGetTitle interface { + GetTitle() string +} + +func _swig_wrap__swig_DirectorEmployee_upcall_GetTitle(SwigcptrEmployee) string +func (swig_p *_swig_DirectorEmployee) GetTitle() string { + if swig_g, swig_ok := swig_p.v.(_swig_DirectorInterfaceEmployeeGetTitle); swig_ok { + return swig_g.GetTitle() + } + return _swig_wrap__swig_DirectorEmployee_upcall_GetTitle(swig_p.SwigcptrEmployee) +} + +func DirectorEmployeeGetTitle(p Employee) string { + return _swig_wrap__swig_DirectorEmployee_upcall_GetTitle(p.(*_swig_DirectorEmployee).SwigcptrEmployee) +} + +func Swig_DirectorEmployee_callback_getTitle(p *_swig_DirectorEmployee) (swig_result string) { + return p.GetTitle() +} + +type _swig_DirectorInterfaceEmployeeGetName interface { + GetName() string +} + +func _swig_wrap__swig_DirectorEmployee_upcall_GetName(SwigcptrEmployee) string +func (swig_p *_swig_DirectorEmployee) GetName() string { + if swig_g, swig_ok := swig_p.v.(_swig_DirectorInterfaceEmployeeGetName); swig_ok { + return swig_g.GetName() + } + return _swig_wrap__swig_DirectorEmployee_upcall_GetName(swig_p.SwigcptrEmployee) +} + +func DirectorEmployeeGetName(p Employee) string { + return _swig_wrap__swig_DirectorEmployee_upcall_GetName(p.(*_swig_DirectorEmployee).SwigcptrEmployee) +} + +func Swig_DirectorEmployee_callback_getName(p *_swig_DirectorEmployee) (swig_result string) { + return p.GetName() +} + +type _swig_DirectorInterfaceEmployeeGetPosition interface { + GetPosition() string +} + +func _swig_wrap__swig_DirectorEmployee_upcall_GetPosition(SwigcptrEmployee) string +func (swig_p *_swig_DirectorEmployee) GetPosition() string { + if swig_g, swig_ok := swig_p.v.(_swig_DirectorInterfaceEmployeeGetPosition); swig_ok { + return swig_g.GetPosition() + } + return _swig_wrap__swig_DirectorEmployee_upcall_GetPosition(swig_p.SwigcptrEmployee) +} + +func DirectorEmployeeGetPosition(p Employee) string { + return _swig_wrap__swig_DirectorEmployee_upcall_GetPosition(p.(*_swig_DirectorEmployee).SwigcptrEmployee) +} + +func Swig_DirectorEmployee_callback_getPosition(p *_swig_DirectorEmployee) (swig_result string) { + return p.GetPosition() +} + +func _swig_wrap_DeleteDirectorEmployee(uintptr) + +func DeleteDirectorEmployee(arg1 Employee) { + _swig_wrap_DeleteDirectorEmployee(arg1.Swigcptr()) +} + +func Swiggo_DeleteDirector_Employee(p *_swig_DirectorEmployee) { + p.SwigcptrEmployee = 0 +} + +type SwigcptrEmployee uintptr + +func (p SwigcptrEmployee) Swigcptr() uintptr { + return (uintptr)(p) +} + +func (p SwigcptrEmployee) SwigIsEmployee() { +} + +func (p SwigcptrEmployee) DirectorInterface() interface{} { + return nil +} + +func _swig_wrap_new_Employee(string) SwigcptrEmployee + +func NewEmployee(arg1 string) Employee { + return _swig_wrap_new_Employee(arg1) +} + +func _swig_wrap_Employee_getTitle(SwigcptrEmployee) string + +func (arg1 SwigcptrEmployee) GetTitle() string { + return _swig_wrap_Employee_getTitle(arg1) +} + +func _swig_wrap_Employee_getName(SwigcptrEmployee) string + +func (arg1 SwigcptrEmployee) GetName() string { + return _swig_wrap_Employee_getName(arg1) +} + +func _swig_wrap_Employee_getPosition(SwigcptrEmployee) string + +func (arg1 SwigcptrEmployee) GetPosition() string { + return _swig_wrap_Employee_getPosition(arg1) +} + +func _swig_wrap_delete_Employee(uintptr) + +func DeleteEmployee(arg1 Employee) { + _swig_wrap_delete_Employee(arg1.Swigcptr()) +} + +type Employee interface { + Swigcptr() uintptr + SwigIsEmployee() + DirectorInterface() interface{} + GetTitle() string + GetName() string + GetPosition() string +} + +type _swig_DirectorManager struct { + SwigcptrManager + v interface{} +} + +func (p *_swig_DirectorManager) Swigcptr() uintptr { + return p.SwigcptrManager.Swigcptr() +} + +func (p *_swig_DirectorManager) SwigIsManager() { +} + +func (p *_swig_DirectorManager) DirectorInterface() interface{} { + return p.v +} + +func _swig_NewDirectorManagerManager(*_swig_DirectorManager, string) SwigcptrManager + +func NewDirectorManager(v interface{}, arg1 string) Manager { + p := &_swig_DirectorManager{0, v} + p.SwigcptrManager = _swig_NewDirectorManagerManager(p, arg1) + return p +} + +type _swig_DirectorInterfaceManagerGetTitle interface { + GetTitle() string +} + +func _swig_wrap__swig_DirectorManager_upcall_GetTitle(SwigcptrManager) string +func (swig_p *_swig_DirectorManager) GetTitle() string { + if swig_g, swig_ok := swig_p.v.(_swig_DirectorInterfaceManagerGetTitle); swig_ok { + return swig_g.GetTitle() + } + return _swig_wrap__swig_DirectorManager_upcall_GetTitle(swig_p.SwigcptrManager) +} + +func DirectorManagerGetTitle(p Manager) string { + return _swig_wrap__swig_DirectorManager_upcall_GetTitle(p.(*_swig_DirectorManager).SwigcptrManager) +} + +func Swig_DirectorManager_callback_getTitle(p *_swig_DirectorManager) (swig_result string) { + return p.GetTitle() +} + +type _swig_DirectorInterfaceManagerGetName interface { + GetName() string +} + +func _swig_wrap__swig_DirectorManager_upcall_GetName(SwigcptrManager) string +func (swig_p *_swig_DirectorManager) GetName() string { + if swig_g, swig_ok := swig_p.v.(_swig_DirectorInterfaceManagerGetName); swig_ok { + return swig_g.GetName() + } + return _swig_wrap__swig_DirectorManager_upcall_GetName(swig_p.SwigcptrManager) +} + +func DirectorManagerGetName(p Manager) string { + return _swig_wrap__swig_DirectorManager_upcall_GetName(p.(*_swig_DirectorManager).SwigcptrManager) +} + +func Swig_DirectorManager_callback_getName(p *_swig_DirectorManager) (swig_result string) { + return p.GetName() +} + +type _swig_DirectorInterfaceManagerGetPosition interface { + GetPosition() string +} + +func _swig_wrap__swig_DirectorManager_upcall_GetPosition(SwigcptrManager) string +func (swig_p *_swig_DirectorManager) GetPosition() string { + if swig_g, swig_ok := swig_p.v.(_swig_DirectorInterfaceManagerGetPosition); swig_ok { + return swig_g.GetPosition() + } + return _swig_wrap__swig_DirectorManager_upcall_GetPosition(swig_p.SwigcptrManager) +} + +func DirectorManagerGetPosition(p Manager) string { + return _swig_wrap__swig_DirectorManager_upcall_GetPosition(p.(*_swig_DirectorManager).SwigcptrManager) +} + +func Swig_DirectorManager_callback_getPosition(p *_swig_DirectorManager) (swig_result string) { + return p.GetPosition() +} + +func _swig_wrap_DeleteDirectorManager(uintptr) + +func DeleteDirectorManager(arg1 Manager) { + _swig_wrap_DeleteDirectorManager(arg1.Swigcptr()) +} + +func Swiggo_DeleteDirector_Manager(p *_swig_DirectorManager) { + p.SwigcptrManager = 0 +} + +type SwigcptrManager uintptr + +func (p SwigcptrManager) Swigcptr() uintptr { + return (uintptr)(p) +} + +func (p SwigcptrManager) SwigIsManager() { +} + +func (p SwigcptrManager) DirectorInterface() interface{} { + return nil +} + +func _swig_wrap_new_Manager(string) SwigcptrManager + +func NewManager(arg1 string) Manager { + return _swig_wrap_new_Manager(arg1) +} + +func _swig_wrap_Manager_getPosition(SwigcptrManager) string + +func (arg1 SwigcptrManager) GetPosition() string { + return _swig_wrap_Manager_getPosition(arg1) +} + +func _swig_wrap_delete_Manager(uintptr) + +func DeleteManager(arg1 Manager) { + _swig_wrap_delete_Manager(arg1.Swigcptr()) +} + +func _swig_wrap_Manager_getTitle(SwigcptrManager) string + +func (_swig_base SwigcptrManager) GetTitle() string { + return _swig_wrap_Manager_getTitle(_swig_base) +} + +func _swig_wrap_Manager_getName(SwigcptrManager) string + +func (_swig_base SwigcptrManager) GetName() string { + return _swig_wrap_Manager_getName(_swig_base) +} + +func (p SwigcptrManager) SwigIsEmployee() { +} + +func (p SwigcptrManager) SwigGetEmployee() Employee { + return SwigcptrEmployee(p.Swigcptr()) +} + +type Manager interface { + Swigcptr() uintptr + SwigIsManager() + DirectorInterface() interface{} + GetPosition() string + GetTitle() string + GetName() string + SwigIsEmployee() + SwigGetEmployee() Employee +} + +type SwigcptrEmployeeList uintptr + +func (p SwigcptrEmployeeList) Swigcptr() uintptr { + return (uintptr)(p) +} + +func (p SwigcptrEmployeeList) SwigIsEmployeeList() { +} + +func _swig_wrap_new_EmployeeList() SwigcptrEmployeeList + +func NewEmployeeList() EmployeeList { + return _swig_wrap_new_EmployeeList() +} + +func _swig_wrap_EmployeeList_addEmployee(SwigcptrEmployeeList, uintptr) + +func (arg1 SwigcptrEmployeeList) AddEmployee(arg2 Employee) { + _swig_wrap_EmployeeList_addEmployee(arg1, arg2.Swigcptr()) +} + +func _swig_wrap_EmployeeList_get_item(SwigcptrEmployeeList, int) SwigcptrEmployee + +func (arg1 SwigcptrEmployeeList) Get_item(arg2 int) Employee { + return _swig_wrap_EmployeeList_get_item(arg1, arg2) +} + +func _swig_wrap_delete_EmployeeList(uintptr) + +func DeleteEmployeeList(arg1 EmployeeList) { + _swig_wrap_delete_EmployeeList(arg1.Swigcptr()) +} + +type EmployeeList interface { + Swigcptr() uintptr + SwigIsEmployeeList() + AddEmployee(arg2 Employee) + Get_item(arg2 int) Employee +} + + +type SwigcptrSwigDirector_Manager uintptr +type SwigDirector_Manager interface { + Swigcptr() uintptr; +} +func (p SwigcptrSwigDirector_Manager) Swigcptr() uintptr { + return uintptr(p) +} + +type SwigcptrSwigDirector_Employee uintptr +type SwigDirector_Employee interface { + Swigcptr() uintptr; +} +func (p SwigcptrSwigDirector_Employee) Swigcptr() uintptr { + return uintptr(p) +} + +type SwigcptrVoid uintptr +type Void interface { + Swigcptr() uintptr; +} +func (p SwigcptrVoid) Swigcptr() uintptr { + return uintptr(p) +} + diff --git a/Examples/go/extend/example.h b/Examples/go/extend/example.h new file mode 100644 index 000000000..b27ab9711 --- /dev/null +++ b/Examples/go/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/go/extend/example.i b/Examples/go/extend/example.i new file mode 100644 index 000000000..c8ec32e09 --- /dev/null +++ b/Examples/go/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/go/extend/index.html b/Examples/go/extend/index.html new file mode 100644 index 000000000..471fa9cdc --- /dev/null +++ b/Examples/go/extend/index.html @@ -0,0 +1,27 @@ + + +SWIG:Examples:go:extend + + + + + +SWIG/Examples/go/extend/ +
      + +

      Extending a simple C++ class in Go

      + +

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

      +

      + +
      + + diff --git a/Examples/go/extend/runme.go b/Examples/go/extend/runme.go new file mode 100644 index 000000000..796c5ce68 --- /dev/null +++ b/Examples/go/extend/runme.go @@ -0,0 +1,77 @@ +// This file illustrates the cross language polymorphism using directors. + +package main + +import ( + "fmt" + . "./example" +) + +type CEO struct{} + +func (p *CEO) GetPosition() string { + return "CEO" +} + +func main() { + // Create an instance of CEO, a class derived from the Go + // proxy of the underlying C++ class. The calls to getName() + // and getPosition() are standard, the call to getTitle() uses + // the director wrappers to call CEO.getPosition(). + + e := NewDirectorManager(new(CEO), "Alice") + fmt.Println(e.GetName(), " is a ", e.GetPosition()) + fmt.Println("Just call her \"", e.GetTitle(), "\"") + fmt.Println("----------------------") + + + // Create a new EmployeeList instance. This class does not + // have a C++ director wrapper, but can be used freely with + // other classes that do. + + list := NewEmployeeList() + + // EmployeeList owns its items, so we must surrender ownership + // of objects we add. + // e.DisownMemory() + list.AddEmployee(e) + fmt.Println("----------------------") + + // Now we access the first four items in list (three are C++ + // objects that EmployeeList's constructor adds, the last is + // our CEO). The virtual methods of all these instances are + // treated the same. For items 0, 1, and 2, all methods + // resolve in C++. For item 3, our CEO, GetTitle calls + // GetPosition which resolves in Go. The call to GetPosition + // is slightly different, however, because of the overidden + // GetPosition() call, since now the object reference has been + // "laundered" by passing through EmployeeList as an + // Employee*. Previously, Go resolved the call immediately in + // CEO, but now Go thinks the object is an instance of class + // Employee. So the call passes through the Employee proxy + // class and on to the C wrappers and C++ director, eventually + // ending up back at the Java CEO implementation of + // getPosition(). The call to GetTitle() for item 3 runs the + // C++ Employee::getTitle() method, which in turn calls + // GetPosition(). This virtual method call passes down + // through the C++ director class to the Java implementation + // in CEO. All this routing takes place transparently. + + fmt.Println("(position, title) for items 0-3:") + + fmt.Println(" ", list.Get_item(0).GetPosition(), ", \"", list.Get_item(0).GetTitle(), "\"") + fmt.Println(" ", list.Get_item(1).GetPosition(), ", \"", list.Get_item(1).GetTitle(), "\"") + fmt.Println(" ", list.Get_item(2).GetPosition(), ", \"", list.Get_item(2).GetTitle(), "\"") + fmt.Println(" ", list.Get_item(3).GetPosition(), ", \"", list.Get_item(3).GetTitle(), "\"") + fmt.Println("----------------------") + + // Time to delete the EmployeeList, which will delete all the + // Employee* items it contains. The last item is our CEO, + // which gets destroyed as well. + DeleteEmployeeList(list) + fmt.Println("----------------------") + + // All done. + + fmt.Println("Go exit") +} diff --git a/Examples/go/funcptr/Makefile b/Examples/go/funcptr/Makefile new file mode 100644 index 000000000..b0aa9c970 --- /dev/null +++ b/Examples/go/funcptr/Makefile @@ -0,0 +1,18 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +SRCS = example.c +TARGET = example +INTERFACE = example.i +SWIGOPT = + +all:: go + +go:: + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go + +clean:: + $(MAKE) -f $(TOP)/Makefile go_clean + +check: all + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run diff --git a/Examples/go/funcptr/example.c b/Examples/go/funcptr/example.c new file mode 100644 index 000000000..5c4a3dabf --- /dev/null +++ b/Examples/go/funcptr/example.c @@ -0,0 +1,19 @@ +/* File : example.c */ + +int do_op(int a, int b, int (*op)(int,int)) { + return (*op)(a,b); +} + +int add(int a, int b) { + return a+b; +} + +int sub(int a, int b) { + return a-b; +} + +int mul(int a, int b) { + return a*b; +} + +int (*funcvar)(int,int) = add; diff --git a/Examples/go/funcptr/example.go b/Examples/go/funcptr/example.go new file mode 100644 index 000000000..b059bae8d --- /dev/null +++ b/Examples/go/funcptr/example.go @@ -0,0 +1,54 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 2.0.1 + * + * This file is not intended to be easily readable and contains a number of + * coding conventions designed to improve portability and efficiency. Do not make + * changes to this file unless you know what you are doing--modify the SWIG + * interface file instead. + * ----------------------------------------------------------------------------- */ + +package example + + +type _swig_fnptr *byte +type _swig_memberptr *byte + + +func _swig_allocatememory(int) *byte +func _swig_internal_allocate(len int) *byte { + return _swig_allocatememory(len) +} + +func _swig_allocatestring(*byte, int) string +func _swig_internal_makegostring(p *byte, l int) string { + return _swig_allocatestring(p, l) +} + +func _swig_internal_gopanic(p *byte, l int) { + panic(_swig_allocatestring(p, l)) +} + +func Do_op(int, int, _swig_fnptr) int +func _swig_getADD() _swig_fnptr +var ADD _swig_fnptr = _swig_getADD() +func _swig_getSUB() _swig_fnptr +var SUB _swig_fnptr = _swig_getSUB() +func _swig_getMUL() _swig_fnptr +var MUL _swig_fnptr = _swig_getMUL() +func _swig_wrap_funcvar_set(_swig_fnptr) + +func SetFuncvar(arg1 _swig_fnptr) { + _swig_wrap_funcvar_set(arg1) +} + +func GetFuncvar() _swig_fnptr + +type SwigcptrVoid uintptr +type Void interface { + Swigcptr() uintptr; +} +func (p SwigcptrVoid) Swigcptr() uintptr { + return uintptr(p) +} + diff --git a/Examples/go/funcptr/example.h b/Examples/go/funcptr/example.h new file mode 100644 index 000000000..9936e24fc --- /dev/null +++ b/Examples/go/funcptr/example.h @@ -0,0 +1,9 @@ +/* file: example.h */ + +extern int do_op(int,int, int (*op)(int,int)); +extern int add(int,int); +extern int sub(int,int); +extern int mul(int,int); + +extern int (*funcvar)(int,int); + diff --git a/Examples/go/funcptr/example.i b/Examples/go/funcptr/example.i new file mode 100644 index 000000000..8b3bef678 --- /dev/null +++ b/Examples/go/funcptr/example.i @@ -0,0 +1,16 @@ +/* File : example.i */ +%module example +%{ +#include "example.h" +%} + +/* Wrap a function taking a pointer to a function */ +extern int do_op(int a, int b, int (*op)(int, int)); + +/* Now install a bunch of "ops" as constants */ +%constant int (*ADD)(int,int) = add; +%constant int (*SUB)(int,int) = sub; +%constant int (*MUL)(int,int) = mul; + +extern int (*funcvar)(int,int); + diff --git a/Examples/go/funcptr/index.html b/Examples/go/funcptr/index.html new file mode 100644 index 000000000..4212260a9 --- /dev/null +++ b/Examples/go/funcptr/index.html @@ -0,0 +1,89 @@ + + +SWIG:Examples:go:funcptr + + + + + +SWIG/Examples/go/funcptr/ +
      + +

      Pointers to Functions

      + +

      +Okay, just what in the heck does SWIG do with a declaration like this? + +

      +
      +int do_op(int a, int b, int (*op)(int, int));
      +
      +
      + +Well, it creates a wrapper as usual. Of course, that does raise some +questions about the third argument (the pointer to a function). + +

      +In this case, SWIG will wrap the function pointer as it does for all +other pointers. However, in order to actually call this function from +a Go program, you will need to pass some kind of C function pointer +object. In C, this is easy, you just supply a function name as an +argument like this: + +

      +
      +/* Some callback function */
      +int add(int a, int b) {
      +   return a+b;
      +} 
      +...
      +int r = do_op(x,y,add);
      +
      +
      + +To make this work with SWIG, you will need to do a little extra work. +Specifically, you need to create some function pointer objects using +the %constant directive like this: + +
      +
      +%constant(int (*)(int,int)) ADD = add;
      +
      +
      + +Now, in a Go program, you would do this: + +
      +
      +int r = do_op(x,y, example.ADD)
      +
      +
      +where example is the module name. + +

      An Example

      + +Here are some files that illustrate this with a simple example: + + + +

      Notes

      + +
        +
      • The value of a function pointer must correspond to a function +written in C or C++. It is not possible to pass an arbitrary Go +function in as a substitute for a C function pointer. + +
      + +
      + + + + + + diff --git a/Examples/go/funcptr/runme.go b/Examples/go/funcptr/runme.go new file mode 100644 index 000000000..73ecbb805 --- /dev/null +++ b/Examples/go/funcptr/runme.go @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + . "./example" +) + +func main() { + a := 37 + b := 42 + + // Now call our C function with a bunch of callbacks + + fmt.Println("Trying some C callback functions") + fmt.Println(" a = ", a) + fmt.Println(" b = ", b) + fmt.Println(" ADD(a,b) = ", Do_op(a, b, ADD)) + fmt.Println(" SUB(a,b) = ", Do_op(a, b, SUB)) + fmt.Println(" MUL(a,b) = ", Do_op(a, b, MUL)) + + fmt.Println("Here is what the C callback function classes are called in Go") + fmt.Println(" ADD = ", ADD) + fmt.Println(" SUB = ", SUB) + fmt.Println(" MUL = ", MUL) +} diff --git a/Examples/go/index.html b/Examples/go/index.html new file mode 100644 index 000000000..21dda21b5 --- /dev/null +++ b/Examples/go/index.html @@ -0,0 +1,89 @@ + + +SWIG:Examples:Go + + + +

      SWIG Go Examples

      + +

      +The following examples illustrate the use of SWIG with Go. + +

        +
      • simple. A minimal example showing how SWIG can +be used to wrap a C function, a global variable, and a constant. +
      • constants. This shows how preprocessor macros and +certain C declarations are turned into constants. +
      • variables. An example showing how to access C global variables from Go. +
      • enum. Wrapping enumerations. +
      • class. Wrapping a simple C++ class. +
      • reference. C++ references. +
      • pointer. Simple pointer handling. +
      • funcptr. Pointers to functions. +
      • template. C++ templates. +
      • callback. C++ callbacks using directors. +
      • extend. Polymorphism using directors. +
      + +

      Compilation Issues

      + +
        +
      • To create a Go extension, SWIG is run with the following options: + +
        +
        +% swig -go interface.i
        +
        +
        + +
      • On Unix the compilation of examples is done using the +file Example/Makefile. This makefile performs a manual +module compilation which is platform specific. When using +the 6g or 8g compiler, the steps look like this +(GNU/Linux): + +
        +
        +% swig -go interface.i
        +% gcc -fpic -c interface_wrap.c
        +% gcc -shared interface_wrap.o $(OBJS) -o interfacemodule.so 
        +% 6g interface.go
        +% 6c interface_gc.c
        +% gopack grc interface.a interface.6 interface_gc.6
        +% 6l program.6
        +
        +
        + +
      • When using the gccgo compiler, the steps look like this: + +
        +
        +% swig -go interface.i
        +% gcc -c interface_wrap.c
        +% gccgo -c interface.go
        +% gccgo program.o interface.o interface_wrap.o
        +
        +
        + +

        Compatibility

        + +The examples have been extensively tested on the following platforms: + +
          +
        • GNU/Linux +
        + +All of the examples were last tested with the following configuration +(10 May 2010): + +
          +
        • Ubuntu Hardy +
        • gcc-4.2.4 +
        + +Your mileage may vary. If you experience a problem, please let us know by +contacting us on the mailing lists. + + diff --git a/Examples/go/multimap/Makefile b/Examples/go/multimap/Makefile new file mode 100644 index 000000000..b0aa9c970 --- /dev/null +++ b/Examples/go/multimap/Makefile @@ -0,0 +1,18 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +SRCS = example.c +TARGET = example +INTERFACE = example.i +SWIGOPT = + +all:: go + +go:: + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go + +clean:: + $(MAKE) -f $(TOP)/Makefile go_clean + +check: all + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run diff --git a/Examples/go/multimap/example.c b/Examples/go/multimap/example.c new file mode 100644 index 000000000..b8360fa8a --- /dev/null +++ b/Examples/go/multimap/example.c @@ -0,0 +1,53 @@ +/* File : example.c */ +#include +#include +#include + +/* Compute the greatest common divisor of positive integers */ +int gcd(int x, int y) { + int g; + g = y; + while (x > 0) { + g = x; + x = y % x; + y = g; + } + return g; +} + +int gcdmain(int argc, char *argv[]) { + int x,y; + if (argc != 3) { + printf("usage: gcd x y\n"); + return -1; + } + x = atoi(argv[1]); + y = atoi(argv[2]); + printf("gcd(%d,%d) = %d\n", x,y,gcd(x,y)); + return 0; +} + +int count(char *bytes, int len, char c) { + int i; + int count = 0; + for (i = 0; i < len; i++) { + if (bytes[i] == c) count++; + } + return count; +} + +void capitalize(char *str, int len) { + int i; + for (i = 0; i < len; i++) { + str[i] = (char)toupper(str[i]); + } +} + +void circle(double x, double y) { + double a = x*x + y*y; + if (a > 1.0) { + printf("Bad points %g, %g\n", x,y); + } else { + printf("Good points %g, %g\n", x,y); + } +} diff --git a/Examples/go/multimap/example.go b/Examples/go/multimap/example.go new file mode 100644 index 000000000..59ed9eaad --- /dev/null +++ b/Examples/go/multimap/example.go @@ -0,0 +1,55 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 2.0.1 + * + * This file is not intended to be easily readable and contains a number of + * coding conventions designed to improve portability and efficiency. Do not make + * changes to this file unless you know what you are doing--modify the SWIG + * interface file instead. + * ----------------------------------------------------------------------------- */ + +package example + + +type _swig_fnptr *byte +type _swig_memberptr *byte + + +func _swig_allocatememory(int) *byte +func _swig_internal_allocate(len int) *byte { + return _swig_allocatememory(len) +} + +func _swig_allocatestring(*byte, int) string +func _swig_internal_makegostring(p *byte, l int) string { + return _swig_allocatestring(p, l) +} + +func _swig_internal_gopanic(p *byte, l int) { + panic(_swig_allocatestring(p, l)) +} + +func Gcd(int, int) int +func Gcdmain([]string) int +func Count(string, byte) int +func _swig_wrap_capitalize([]string) + +func Capitalize(arg1 []string) { + _swig_wrap_capitalize(arg1) +} + +func _swig_wrap_circle(float64, float64) + +func Circle(arg1 float64, arg2 float64) { + _swig_wrap_circle(arg1, arg2) +} + + +type SwigcptrVoid uintptr +type Void interface { + Swigcptr() uintptr; +} +func (p SwigcptrVoid) Swigcptr() uintptr { + return uintptr(p) +} + diff --git a/Examples/go/multimap/example.i b/Examples/go/multimap/example.i new file mode 100644 index 000000000..04d6eea20 --- /dev/null +++ b/Examples/go/multimap/example.i @@ -0,0 +1,110 @@ +/* File : example.i */ +%module example + +%{ +extern int gcd(int x, int y); +extern int gcdmain(int argc, char *argv[]); +extern int count(char *bytes, int len, char c); +extern void capitalize (char *str, int len); +extern void circle (double cx, double cy); +extern int squareCubed (int n, int *OUTPUT); +%} + +extern int gcd(int x, int y); + +%typemap(go) (int argc, char *argv[]) "[]string" + +%typemap(in) (int argc, char *argv[]) +%{ + { + int i; + _gostring_* a; + + $1 = $input.len; + a = (_gostring_*) $input.array; + $2 = (char **) malloc (($1 + 1) * sizeof (char *)); + for (i = 0; i < $1; i++) { + _gostring_ *ps = &a[i]; + $2[i] = (char *) ps->p; + } + $2[i] = NULL; + } +%} + +%typemap(argout) (int argc, char *argv[]) "" /* override char *[] default */ + +%typemap(freearg) (int argc, char *argv[]) +%{ + free($2); +%} + +extern int gcdmain(int argc, char *argv[]); + +%typemap(go) (char *bytes, int len) "string" + +%typemap(in) (char *bytes, int len) +%{ + $1 = $input.p; + $2 = $input.n; +%} + +extern int count(char *bytes, int len, char c); + +/* This example shows how to wrap a function that mutates a c string. A one + * element Go string slice is used so that the string can be returned + * modified. + */ + +%typemap(go) (char *str, int len) "[]string" + +%typemap(in) (char *str, int len) +%{ + { + _gostring_ *a; + char *p; + int n; + + a = (_gostring_*) $input.array; + p = a[0].p; + n = a[0].n; + $1 = malloc(n + 1); + $2 = n; + memcpy($1, p, n); + } +%} + +/* Return the mutated string as a modified element in the array. */ +%typemap(argout) (char *str, int len) +%{ + { + _gostring_ *a; + + a = (_gostring_*) $input.array; + a[0] = _swig_makegostring($1, $2); + } +%} + +%typemap(freearg) (char *str, int len) +%{ + free($1); +%} + +extern void capitalize(char *str, int len); + +/* A multi-valued constraint. Force two arguments to lie + inside the unit circle */ + +%typemap(check) (double cx, double cy) +%{ + { + double a = $1*$1 + $2*$2; + if (a > 1.0) { + _swig_gopanic("$1_name and $2_name must be in unit circle"); + return; + } + } +%} + +extern void circle(double cx, double cy); + + diff --git a/Examples/go/multimap/runme.go b/Examples/go/multimap/runme.go new file mode 100644 index 000000000..94c29127c --- /dev/null +++ b/Examples/go/multimap/runme.go @@ -0,0 +1,26 @@ +package main + +import ( + "fmt" + . "./example" +) + +func main() { + // Call our gcd() function + x := 42 + y := 105 + g := Gcd(x, y) + fmt.Println("The gcd of ", x, " and ", y, " is ", g) + + // Call the gcdmain() function + args := []string{"gcdmain", "42", "105"} + Gcdmain(args) + + // Call the count function + fmt.Println(Count("Hello World", 'l')) + + // Call the capitalize function + capitalizeMe := []string{"hello world"} + Capitalize(capitalizeMe) + fmt.Println(capitalizeMe[0]) +} diff --git a/Examples/go/pointer/Makefile b/Examples/go/pointer/Makefile new file mode 100644 index 000000000..b0aa9c970 --- /dev/null +++ b/Examples/go/pointer/Makefile @@ -0,0 +1,18 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +SRCS = example.c +TARGET = example +INTERFACE = example.i +SWIGOPT = + +all:: go + +go:: + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go + +clean:: + $(MAKE) -f $(TOP)/Makefile go_clean + +check: all + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run diff --git a/Examples/go/pointer/example.c b/Examples/go/pointer/example.c new file mode 100644 index 000000000..b877d9a5b --- /dev/null +++ b/Examples/go/pointer/example.c @@ -0,0 +1,16 @@ +/* File : example.c */ + +void add(int *x, int *y, int *result) { + *result = *x + *y; +} + +void sub(int *x, int *y, int *result) { + *result = *x - *y; +} + +int divide(int n, int d, int *r) { + int q; + q = n/d; + *r = n - q*d; + return q; +} diff --git a/Examples/go/pointer/example.go b/Examples/go/pointer/example.go new file mode 100644 index 000000000..567c41c32 --- /dev/null +++ b/Examples/go/pointer/example.go @@ -0,0 +1,68 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 2.0.1 + * + * This file is not intended to be easily readable and contains a number of + * coding conventions designed to improve portability and efficiency. Do not make + * changes to this file unless you know what you are doing--modify the SWIG + * interface file instead. + * ----------------------------------------------------------------------------- */ + +package example + + +type _swig_fnptr *byte +type _swig_memberptr *byte + + +func _swig_allocatememory(int) *byte +func _swig_internal_allocate(len int) *byte { + return _swig_allocatememory(len) +} + +func _swig_allocatestring(*byte, int) string +func _swig_internal_makegostring(p *byte, l int) string { + return _swig_allocatestring(p, l) +} + +func _swig_internal_gopanic(p *byte, l int) { + panic(_swig_allocatestring(p, l)) +} + +func _swig_wrap_add(*int, *int, *int) + +func Add(arg1 *int, arg2 *int, arg3 *int) { + _swig_wrap_add(arg1, arg2, arg3) +} + +func New_intp() *int +func Copy_intp(int) *int +func _swig_wrap_delete_intp(*int) + +func Delete_intp(arg1 *int) { + _swig_wrap_delete_intp(arg1) +} + +func _swig_wrap_intp_assign(*int, int) + +func Intp_assign(arg1 *int, arg2 int) { + _swig_wrap_intp_assign(arg1, arg2) +} + +func Intp_value(*int) int +func _swig_wrap_sub(int, int, []int) + +func Sub(arg1 int, arg2 int, arg3 []int) { + _swig_wrap_sub(arg1, arg2, arg3) +} + +func Divide(int, int, []int) int + +type SwigcptrVoid uintptr +type Void interface { + Swigcptr() uintptr; +} +func (p SwigcptrVoid) Swigcptr() uintptr { + return uintptr(p) +} + diff --git a/Examples/go/pointer/example.i b/Examples/go/pointer/example.i new file mode 100644 index 000000000..a8ac79499 --- /dev/null +++ b/Examples/go/pointer/example.i @@ -0,0 +1,30 @@ +/* File : example.i */ +%module example + +%{ +extern void add(int *, int *, int *); +extern void sub(int *, int *, int *); +extern int divide(int, int, int *); +%} + +/* This example illustrates a couple of different techniques + for manipulating C pointers */ + +/* First we'll use the pointer library */ +extern void add(int *x, int *y, int *result); +%include cpointer.i +%pointer_functions(int, intp); + +/* Next we'll use some typemaps */ + +%include typemaps.i +extern void sub(int *INPUT, int *INPUT, int *OUTPUT); + +/* Next we'll use typemaps and the %apply directive */ + +%apply int *OUTPUT { int *r }; +extern int divide(int n, int d, int *r); + + + + diff --git a/Examples/go/pointer/index.html b/Examples/go/pointer/index.html new file mode 100644 index 000000000..cfa8a3acc --- /dev/null +++ b/Examples/go/pointer/index.html @@ -0,0 +1,143 @@ + + +SWIG:Examples:go:pointer + + + + +SWIG/Examples/go/pointer/ +
        + +

        Simple Pointer Handling

        + +

        +This example illustrates a couple of techniques for handling simple +pointers in SWIG. The prototypical example is a C function that +operates on pointers such as this: + +

        +
        +void add(int *x, int *y, int *r) { 
        +    *r = *x + *y;
        +}
        +
        +
        + +By default, SWIG wraps this function exactly as specified and creates +an interface that expects pointer objects for arguments. This only +works when there is a precise correspondence between the C type and +some Go type. +

        + +

        Other approaches

        + +

        +

      • The SWIG pointer library provides a different, safer, way to + handle pointers. For example, in the interface file you would do + this: + +
        +
        +%include cpointer.i
        +%pointer_functions(int, intp);
        +
        +
        + +and from Go you would use pointers like this: + +
        +
        +a := example.New_intp()
        +b := example.New_intp()
        +c := example.New_intp()
        +Intp_Assign(a, 37)
        +Intp_Assign(b, 42)
        +
        +fmt.Println("     a =", a)
        +fmt.Println("     b =", b)
        +fmt.Println("     c =", c)
        +
        +// Call the add() function with some pointers
        +example.Add(a,b,c)
        +
        +// Now get the result
        +res := example.Intp_value(c)
        +fmt.Println("     37 + 42 =", res)
        +
        +// Clean up the pointers
        +example.Delete_intp(a)
        +example.Delete_intp(b)
        +example.Delete_intp(c)
        +
        +
        + +

        +

      • Use the SWIG typemap library. This library allows you to +completely change the way arguments are processed by SWIG. For +example: + +
        +
        +%include "typemaps.i"
        +void add(int *INPUT, int *INPUT, int *OUTPUT);
        +
        +
        + +And in a Go program: + +
        +
        +r := []int{0}
        +example.Sub(37,42,r)
        +fmt.Println("Result =", r[0])
        +
        +
        +Needless to say, this is substantially easier although a bit unusual. + +

        +

      • A final alternative is to use the typemaps library in combination +with the %apply directive. This allows you to change the names of parameters +that behave as input or output parameters. For example: + +
        +
        +%include "typemaps.i"
        +%apply int *INPUT {int *x, int *y};
        +%apply int *OUTPUT {int *r};
        +
        +void add(int *x, int *y, int *r);
        +void sub(int *x, int *y, int *r);
        +void mul(int *x, int *y, int *r);
        +... etc ...
        +
        +
        + +
      + +

      Example

      + +The following example illustrates the use of these features for pointer +extraction. + + + +

      Notes

      + +
        +
      • Since pointers are used for so many different things (arrays, output values, +etc...) the complexity of pointer handling can be as complicated as you want to +make it. + +

        +

      • More documentation on the typemaps.i and cpointer.i library files can be +found in the SWIG user manual. The files also contain documentation. + +
      + +
      + + diff --git a/Examples/go/pointer/runme.go b/Examples/go/pointer/runme.go new file mode 100644 index 000000000..9cbcda489 --- /dev/null +++ b/Examples/go/pointer/runme.go @@ -0,0 +1,47 @@ +package main + +import ( + "fmt" + . "./example" +) + +func main() { + // First create some objects using the pointer library. + fmt.Println("Testing the pointer library") + a := New_intp() + b := New_intp() + c := New_intp() + Intp_assign(a, 37) + Intp_assign(b, 42) + + fmt.Println(" a =", a) + fmt.Println(" b =", b) + fmt.Println(" c =", c) + + // Call the add() function with some pointers + Add(a, b, c) + + // Now get the result + res := Intp_value(c) + fmt.Println(" 37 + 42 =", res) + + // Clean up the pointers + Delete_intp(a) + Delete_intp(b) + Delete_intp(c) + + // Now try the typemap library + // Now it is no longer necessary to manufacture pointers. + // Instead we use a single element array which in Java is modifiable. + + fmt.Println("Trying the typemap library") + r := []int{0} + Sub(37, 42, r) + fmt.Println(" 37 - 42 = ", r[0]) + + // Now try the version with return value + + fmt.Println("Testing return value") + q := Divide(42, 37, r) + fmt.Println(" 42/37 = ", q, " remainder ", r[0]) +} diff --git a/Examples/go/reference/Makefile b/Examples/go/reference/Makefile new file mode 100644 index 000000000..9dc8b8851 --- /dev/null +++ b/Examples/go/reference/Makefile @@ -0,0 +1,18 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +CXXSRCS = example.cxx +TARGET = example +INTERFACE = example.i +SWIGOPT = + +all:: go + +go:: + $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_cpp + +clean:: + $(MAKE) -f $(TOP)/Makefile go_clean + +check: all + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run diff --git a/Examples/go/reference/example.cxx b/Examples/go/reference/example.cxx new file mode 100644 index 000000000..8a513bf49 --- /dev/null +++ b/Examples/go/reference/example.cxx @@ -0,0 +1,46 @@ +/* File : example.cxx */ + +/* Deal with Microsoft's attempt at deprecating C standard runtime functions */ +#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) +# define _CRT_SECURE_NO_DEPRECATE +#endif + +#include "example.h" +#include +#include + +Vector operator+(const Vector &a, const Vector &b) { + Vector r; + r.x = a.x + b.x; + r.y = a.y + b.y; + r.z = a.z + b.z; + return r; +} + +char *Vector::print() { + static char temp[512]; + sprintf(temp,"Vector %p (%g,%g,%g)", this, x,y,z); + return temp; +} + +VectorArray::VectorArray(int size) { + items = new Vector[size]; + maxsize = size; +} + +VectorArray::~VectorArray() { + delete [] items; +} + +Vector &VectorArray::operator[](int index) { + if ((index < 0) || (index >= maxsize)) { + printf("Panic! Array index out of bounds.\n"); + exit(1); + } + return items[index]; +} + +int VectorArray::size() { + return maxsize; +} + diff --git a/Examples/go/reference/example.go b/Examples/go/reference/example.go new file mode 100644 index 000000000..fb98f8a18 --- /dev/null +++ b/Examples/go/reference/example.go @@ -0,0 +1,126 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 2.0.1 + * + * This file is not intended to be easily readable and contains a number of + * coding conventions designed to improve portability and efficiency. Do not make + * changes to this file unless you know what you are doing--modify the SWIG + * interface file instead. + * ----------------------------------------------------------------------------- */ + +package example + + +type _swig_fnptr *byte +type _swig_memberptr *byte + + +func _swig_allocatememory(int) *byte +func _swig_internal_allocate(len int) *byte { + return _swig_allocatememory(len) +} + +func _swig_allocatestring(*byte, int) string +func _swig_internal_makegostring(p *byte, l int) string { + return _swig_allocatestring(p, l) +} + +func _swig_internal_gopanic(p *byte, l int) { + panic(_swig_allocatestring(p, l)) +} + +type SwigcptrVector uintptr + +func (p SwigcptrVector) Swigcptr() uintptr { + return (uintptr)(p) +} + +func (p SwigcptrVector) SwigIsVector() { +} + +func _swig_wrap_new_Vector(float64, float64, float64) SwigcptrVector + +func NewVector(arg1 float64, arg2 float64, arg3 float64) Vector { + return _swig_wrap_new_Vector(arg1, arg2, arg3) +} + +func _swig_wrap_delete_Vector(uintptr) + +func DeleteVector(arg1 Vector) { + _swig_wrap_delete_Vector(arg1.Swigcptr()) +} + +func _swig_wrap_Vector_print(SwigcptrVector) string + +func (arg1 SwigcptrVector) Print() string { + return _swig_wrap_Vector_print(arg1) +} + +type Vector interface { + Swigcptr() uintptr + SwigIsVector() + Print() string +} + +func _swig_wrap_addv(uintptr, uintptr) SwigcptrVector + +func Addv(arg1 Vector, arg2 Vector) Vector { + return _swig_wrap_addv(arg1.Swigcptr(), arg2.Swigcptr()) +} + +type SwigcptrVectorArray uintptr + +func (p SwigcptrVectorArray) Swigcptr() uintptr { + return (uintptr)(p) +} + +func (p SwigcptrVectorArray) SwigIsVectorArray() { +} + +func _swig_wrap_new_VectorArray(int) SwigcptrVectorArray + +func NewVectorArray(arg1 int) VectorArray { + return _swig_wrap_new_VectorArray(arg1) +} + +func _swig_wrap_delete_VectorArray(uintptr) + +func DeleteVectorArray(arg1 VectorArray) { + _swig_wrap_delete_VectorArray(arg1.Swigcptr()) +} + +func _swig_wrap_VectorArray_size(SwigcptrVectorArray) int + +func (arg1 SwigcptrVectorArray) Size() int { + return _swig_wrap_VectorArray_size(arg1) +} + +func _swig_wrap_VectorArray_get(SwigcptrVectorArray, int) SwigcptrVector + +func (arg1 SwigcptrVectorArray) Get(arg2 int) Vector { + return _swig_wrap_VectorArray_get(arg1, arg2) +} + +func _swig_wrap_VectorArray_set(SwigcptrVectorArray, int, uintptr) + +func (arg1 SwigcptrVectorArray) Set(arg2 int, arg3 Vector) { + _swig_wrap_VectorArray_set(arg1, arg2, arg3.Swigcptr()) +} + +type VectorArray interface { + Swigcptr() uintptr + SwigIsVectorArray() + Size() int + Get(arg2 int) Vector + Set(arg2 int, arg3 Vector) +} + + +type SwigcptrVoid uintptr +type Void interface { + Swigcptr() uintptr; +} +func (p SwigcptrVoid) Swigcptr() uintptr { + return uintptr(p) +} + diff --git a/Examples/go/reference/example.h b/Examples/go/reference/example.h new file mode 100644 index 000000000..4915adb1b --- /dev/null +++ b/Examples/go/reference/example.h @@ -0,0 +1,26 @@ +/* File : example.h */ + +class Vector { +private: + double x,y,z; +public: + Vector() : x(0), y(0), z(0) { }; + Vector(double x, double y, double z) : x(x), y(y), z(z) { }; + friend Vector operator+(const Vector &a, const Vector &b); + char *print(); +}; + +class VectorArray { +private: + Vector *items; + int maxsize; +public: + VectorArray(int maxsize); + ~VectorArray(); + Vector &operator[](int); + int size(); +}; + + + + diff --git a/Examples/go/reference/example.i b/Examples/go/reference/example.i new file mode 100644 index 000000000..1cf19c82c --- /dev/null +++ b/Examples/go/reference/example.i @@ -0,0 +1,42 @@ +/* File : example.i */ + +/* This file has a few "typical" uses of C++ references. */ + +%module example + +%{ +#include "example.h" +%} + +class Vector { +public: + Vector(double x, double y, double z); + ~Vector(); + char *print(); +}; + +/* This helper function calls an overloaded operator */ +%inline %{ +Vector addv(Vector &a, Vector &b) { + return a+b; +} +%} + +/* Wrapper around an array of vectors class */ + +class VectorArray { +public: + VectorArray(int maxsize); + ~VectorArray(); + int size(); + + /* This wrapper provides an alternative to the [] operator */ + %extend { + Vector &get(int index) { + return (*$self)[index]; + } + void set(int index, Vector &a) { + (*$self)[index] = a; + } + } +}; diff --git a/Examples/go/reference/index.html b/Examples/go/reference/index.html new file mode 100644 index 000000000..5e8589349 --- /dev/null +++ b/Examples/go/reference/index.html @@ -0,0 +1,143 @@ + + +SWIG:Examples:go:reference + + + + + +SWIG/Examples/go/reference/ +
      + +

      C++ Reference Handling

      + +

      +This example tests SWIG's handling of C++ references. A reference in +C++ is much like a pointer. Go represents C++ classes as pointers +which are stored in interface values. Therefore, a reference to a +class in C++ simply becomes an object of the class type in Go. For +types which are not classes, a reference in C++ is represented as a +pointer in Go. + +

      Some examples

      + +References are most commonly used as function parameters. For +example, you might have a function like this: + +
      +
      +Vector addv(const Vector &a, const Vector &b) {
      +   Vector result;
      +   result.x = a.x + b.x;
      +   result.y = a.y + b.y;
      +   result.z = a.z + b.z;
      +   return result;
      +}
      +
      +
      + +In these cases, SWIG transforms everything into a pointer and creates +a wrapper that looks like this in C++. + +
      +
      +Vector wrap_addv(Vector *a, Vector *b);
      +
      +
      + +or like this in Go: + +
      +
      +func Addv(arg1 Vector, arg2 Vector) Vector
      +
      +
      + +Occasionally, a reference is used as a return value of a function +when the return result is to be used as an lvalue in an expression. +The prototypical example is an operator like this: + +
      +
      +Vector &operator[](int index);
      +
      +
      + +or a method: + +
      +
      +Vector &get(int index);
      +
      +
      + +For functions returning references, a wrapper like this is created: + +
      +
      +Vector *wrap_Object_get(Object *self, int index) {
      +    Vector &result = self->get(index);
      +    return &result;
      +}
      +
      +
      + +The following header file contains some class +definitions with some operators and use of references. + +

      SWIG Interface

      + +SWIG does NOT support overloaded operators so it can not directly +build an interface to the classes in the above file. However, a +number of workarounds can be made. For example, an overloaded +operator can be stuck behind a function call such as the addv +function above. Array access can be handled with a pair of set/get +functions like this: + +
      +
      +class VectorArray {
      +public:
      + ...
      +   %addmethods {
      +    Vector &get(int index) {
      +      return (*self)[index];
      +    }
      +    void set(int index, Vector &a) {
      +      (*self)[index] = a;
      +    }
      +   }
      +   ...
      +}
      +
      +
      + +Click here to see a SWIG interface file with +these additions. + +

      Sample Go program

      + +Click here to see a Go program that manipulates +some C++ references. + +

      Notes:

      + +
        +
      • C++ references primarily provide notational convenience for C++ +source code. However, Go only supports the 'x.a' notation so it +doesn't much matter. + +

        +

      • When a program returns a reference, a pointer is returned. Unlike +return by value, memory is not allocated to hold the return result. + +

        +

      • SWIG has particular trouble handling various combinations of +references and pointers. This is side effect of an old parsing scheme +and type representation that will be replaced in future versions. + +
      + +
      + + diff --git a/Examples/go/reference/runme.go b/Examples/go/reference/runme.go new file mode 100644 index 000000000..3683d6144 --- /dev/null +++ b/Examples/go/reference/runme.go @@ -0,0 +1,71 @@ +// This example illustrates the manipulation of C++ references in Java. + +package main + +import ( + "fmt" + . "./example" +) + +func main() { + fmt.Println("Creating some objects:") + a := NewVector(3, 4, 5) + b := NewVector(10, 11, 12) + + fmt.Println(" Created ", a.Print()) + fmt.Println(" Created ", b.Print()) + + // ----- Call an overloaded operator ----- + + // This calls the wrapper we placed around + // + // operator+(const Vector &a, const Vector &) + // + // It returns a new allocated object. + + fmt.Println("Adding a+b") + c := Addv(a, b) + fmt.Println(" a+b = " + c.Print()) + + // Because addv returns a reference, Addv will return a + // pointer allocated using Go's memory allocator. That means + // that it will be freed by Go's garbage collector, and we can + // not use DeleteVector to release it. + + c = nil + + // ----- Create a vector array ----- + + fmt.Println("Creating an array of vectors") + va := NewVectorArray(10) + fmt.Println(" va = ", va) + + // ----- Set some values in the array ----- + + // These operators copy the value of Vector a and Vector b to + // the vector array + va.Set(0, a) + va.Set(1, b) + + va.Set(2, Addv(a, b)) + + // Get some values from the array + + fmt.Println("Getting some array values") + for i := 0; i < 5; i++ { + fmt.Println(" va(", i, ") = ", va.Get(i).Print()) + } + + // Watch under resource meter to check on this + fmt.Println("Making sure we don't leak memory.") + for i := 0; i < 1000000; i++ { + c = va.Get(i % 10) + } + + // ----- Clean up ----- This could be omitted. The garbage + // collector would then clean up for us. + fmt.Println("Cleaning up") + DeleteVectorArray(va) + DeleteVector(a) + DeleteVector(b) +} diff --git a/Examples/go/simple/Makefile b/Examples/go/simple/Makefile new file mode 100644 index 000000000..e67fa8bb6 --- /dev/null +++ b/Examples/go/simple/Makefile @@ -0,0 +1,15 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +SRCS = example.c +TARGET = example +INTERFACE = example.i + +all:: + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go + +clean:: + $(MAKE) -f $(TOP)/Makefile go_clean + +check: all + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run diff --git a/Examples/go/simple/example.c b/Examples/go/simple/example.c new file mode 100644 index 000000000..1c2af789c --- /dev/null +++ b/Examples/go/simple/example.c @@ -0,0 +1,18 @@ +/* File : example.c */ + +/* A global variable */ +double Foo = 3.0; + +/* Compute the greatest common divisor of positive integers */ +int gcd(int x, int y) { + int g; + g = y; + while (x > 0) { + g = x; + x = y % x; + y = g; + } + return g; +} + + diff --git a/Examples/go/simple/example.go b/Examples/go/simple/example.go new file mode 100644 index 000000000..df0e70564 --- /dev/null +++ b/Examples/go/simple/example.go @@ -0,0 +1,48 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 2.0.1 + * + * This file is not intended to be easily readable and contains a number of + * coding conventions designed to improve portability and efficiency. Do not make + * changes to this file unless you know what you are doing--modify the SWIG + * interface file instead. + * ----------------------------------------------------------------------------- */ + +package example + + +type _swig_fnptr *byte +type _swig_memberptr *byte + + +func _swig_allocatememory(int) *byte +func _swig_internal_allocate(len int) *byte { + return _swig_allocatememory(len) +} + +func _swig_allocatestring(*byte, int) string +func _swig_internal_makegostring(p *byte, l int) string { + return _swig_allocatestring(p, l) +} + +func _swig_internal_gopanic(p *byte, l int) { + panic(_swig_allocatestring(p, l)) +} + +func Gcd(int, int) int +func _swig_wrap_Foo_set(float64) + +func SetFoo(arg1 float64) { + _swig_wrap_Foo_set(arg1) +} + +func GetFoo() float64 + +type SwigcptrVoid uintptr +type Void interface { + Swigcptr() uintptr; +} +func (p SwigcptrVoid) Swigcptr() uintptr { + return uintptr(p) +} + diff --git a/Examples/go/simple/example.i b/Examples/go/simple/example.i new file mode 100644 index 000000000..24093b9bf --- /dev/null +++ b/Examples/go/simple/example.i @@ -0,0 +1,7 @@ +/* File : example.i */ +%module example + +%inline %{ +extern int gcd(int x, int y); +extern double Foo; +%} diff --git a/Examples/go/simple/index.html b/Examples/go/simple/index.html new file mode 100644 index 000000000..82372ef37 --- /dev/null +++ b/Examples/go/simple/index.html @@ -0,0 +1,126 @@ + + +SWIG:Examples:go:simple + + + + + +SWIG/Examples/go/simple/ +
      + +

      Simple Go Example

      + +

      +This example illustrates how you can hook Go to a very simple C program containing +a function and a global variable. + +

      The C Code

      + +Suppose you have the following C code: + +
      +
      +/* File : example.c */
      +
      +/* A global variable */
      +double Foo = 3.0;
      +
      +/* Compute the greatest common divisor of positive integers */
      +int gcd(int x, int y) {
      +  int g;
      +  g = y;
      +  while (x > 0) {
      +    g = x;
      +    x = y % x;
      +    y = g;
      +  }
      +  return g;
      +}
      +
      +
      + +

      The SWIG interface

      + +Here is a simple SWIG interface file: + +
      +
      +/* File: example.i */
      +%module example
      +
      +extern int gcd(int x, int y);
      +extern double Foo;
      +
      +
      + +

      Compilation

      + +These are the instructions if you are using 6g/8g +rather than gccgo. + +
        +
      1. Run swig -go example.i. This + will create the three + files example.go, example_gc.c, + and example_wrap.c. +
      2. Compile example.go + using 6g or 8g; e.g., 6g example.go. +
      3. Compile example_gc.c + using 6c or 8c; e.g., 6c example_gc.c. +
      4. Put the two object files together into an archive + named example.a; e.g., gopack grc example.a example.6 + example_gc.6. +
      5. Compile the example_wrap.c + file using your standard C compiler with the -fpic option; + e.g., gcc -c -O -fpic example_wrap.c. +
      6. Put the gcc compiled object file into a shared library; + e.g., gcc -shared -o example.so example_wrap.o. +
      7. Compile the program which demonstrates how to use the library; + e.g., 6g runme.go. +
      8. Link the program; e.g., 6l -o runme runme.6. +
      9. Now you should have a program runme. +
      + +

      Using the extension

      + +The Go program which demonstrates calling the C functions from Go +is runme.go. + +

      Key points

      + +
        +
      • Use the import statement to load your extension module from Go. For example: +
        +
        +import "example"
        +
        +
        + +
      • C functions work just like Go functions. However, the function + names are automatically capitalized in order to make the names + visible from other Go packages. For example: +
        +
        +g := example.Gcd(42,105)
        +
        +
        + +(If there are name conflicts, you can use the %rename +directive in the .i file or the -rename option to Go to +rename one or the other symbol). + +
      • C global variables are accessed using getter and setter + functions. The getter function is named Get followed by + the capitalized name of the C variable. The Setter function + uses Set instead of Get. +
        +
        +a = example.GetFoo()
        +
        +
        +
      + +
      + + diff --git a/Examples/go/simple/runme.go b/Examples/go/simple/runme.go new file mode 100644 index 000000000..c829ad21a --- /dev/null +++ b/Examples/go/simple/runme.go @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "./example" +) + +func main() { + // Call our gcd() function + x := 42 + y := 105 + g := example.Gcd(x, y) + fmt.Println("The gcd of", x, "and", y, "is", g) + + // Manipulate the Foo global variable + + // Output its current value + fmt.Println("Foo =", example.GetFoo()) + + // Change its value + example.SetFoo(3.1415926) + + // See if the change took effect + fmt.Println("Foo =", example.GetFoo()) +} diff --git a/Examples/go/template/Makefile b/Examples/go/template/Makefile new file mode 100644 index 000000000..b9278b53e --- /dev/null +++ b/Examples/go/template/Makefile @@ -0,0 +1,18 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +CXXSRCS = +TARGET = example +INTERFACE = example.i +SWIGOPT = + +all:: go + +go:: + $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_cpp + +clean:: + $(MAKE) -f $(TOP)/Makefile go_clean + +check: all + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run diff --git a/Examples/go/template/example.go b/Examples/go/template/example.go new file mode 100644 index 000000000..671b5c2ba --- /dev/null +++ b/Examples/go/template/example.go @@ -0,0 +1,150 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 2.0.1 + * + * This file is not intended to be easily readable and contains a number of + * coding conventions designed to improve portability and efficiency. Do not make + * changes to this file unless you know what you are doing--modify the SWIG + * interface file instead. + * ----------------------------------------------------------------------------- */ + +package example + + +type _swig_fnptr *byte +type _swig_memberptr *byte + + +func _swig_allocatememory(int) *byte +func _swig_internal_allocate(len int) *byte { + return _swig_allocatememory(len) +} + +func _swig_allocatestring(*byte, int) string +func _swig_internal_makegostring(p *byte, l int) string { + return _swig_allocatestring(p, l) +} + +func _swig_internal_gopanic(p *byte, l int) { + panic(_swig_allocatestring(p, l)) +} + +func Maxint(int, int) int +func Maxdouble(float64, float64) float64 +type SwigcptrVecint uintptr + +func (p SwigcptrVecint) Swigcptr() uintptr { + return (uintptr)(p) +} + +func (p SwigcptrVecint) SwigIsVecint() { +} + +func _swig_wrap_new_vecint(int) SwigcptrVecint + +func NewVecint(arg1 int) Vecint { + return _swig_wrap_new_vecint(arg1) +} + +func _swig_wrap_vecint_get(SwigcptrVecint, int) *int + +func (arg1 SwigcptrVecint) Get(arg2 int) *int { + return _swig_wrap_vecint_get(arg1, arg2) +} + +func _swig_wrap_vecint_set(SwigcptrVecint, int, *int) + +func (arg1 SwigcptrVecint) Set(arg2 int, arg3 *int) { + _swig_wrap_vecint_set(arg1, arg2, arg3) +} + +func _swig_wrap_vecint_getitem(SwigcptrVecint, int) int + +func (arg1 SwigcptrVecint) Getitem(arg2 int) int { + return _swig_wrap_vecint_getitem(arg1, arg2) +} + +func _swig_wrap_vecint_setitem(SwigcptrVecint, int, int) + +func (arg1 SwigcptrVecint) Setitem(arg2 int, arg3 int) { + _swig_wrap_vecint_setitem(arg1, arg2, arg3) +} + +func _swig_wrap_delete_vecint(uintptr) + +func DeleteVecint(arg1 Vecint) { + _swig_wrap_delete_vecint(arg1.Swigcptr()) +} + +type Vecint interface { + Swigcptr() uintptr + SwigIsVecint() + Get(arg2 int) *int + Set(arg2 int, arg3 *int) + Getitem(arg2 int) int + Setitem(arg2 int, arg3 int) +} + +type SwigcptrVecdouble uintptr + +func (p SwigcptrVecdouble) Swigcptr() uintptr { + return (uintptr)(p) +} + +func (p SwigcptrVecdouble) SwigIsVecdouble() { +} + +func _swig_wrap_new_vecdouble(int) SwigcptrVecdouble + +func NewVecdouble(arg1 int) Vecdouble { + return _swig_wrap_new_vecdouble(arg1) +} + +func _swig_wrap_vecdouble_get(SwigcptrVecdouble, int) *float64 + +func (arg1 SwigcptrVecdouble) Get(arg2 int) *float64 { + return _swig_wrap_vecdouble_get(arg1, arg2) +} + +func _swig_wrap_vecdouble_set(SwigcptrVecdouble, int, *float64) + +func (arg1 SwigcptrVecdouble) Set(arg2 int, arg3 *float64) { + _swig_wrap_vecdouble_set(arg1, arg2, arg3) +} + +func _swig_wrap_vecdouble_getitem(SwigcptrVecdouble, int) float64 + +func (arg1 SwigcptrVecdouble) Getitem(arg2 int) float64 { + return _swig_wrap_vecdouble_getitem(arg1, arg2) +} + +func _swig_wrap_vecdouble_setitem(SwigcptrVecdouble, int, float64) + +func (arg1 SwigcptrVecdouble) Setitem(arg2 int, arg3 float64) { + _swig_wrap_vecdouble_setitem(arg1, arg2, arg3) +} + +func _swig_wrap_delete_vecdouble(uintptr) + +func DeleteVecdouble(arg1 Vecdouble) { + _swig_wrap_delete_vecdouble(arg1.Swigcptr()) +} + +type Vecdouble interface { + Swigcptr() uintptr + SwigIsVecdouble() + Get(arg2 int) *float64 + Set(arg2 int, arg3 *float64) + Getitem(arg2 int) float64 + Setitem(arg2 int, arg3 float64) +} + + +type SwigcptrVoid uintptr +type Void interface { + Swigcptr() uintptr; +} +func (p SwigcptrVoid) Swigcptr() uintptr { + return uintptr(p) +} + diff --git a/Examples/go/template/example.h b/Examples/go/template/example.h new file mode 100644 index 000000000..7401df650 --- /dev/null +++ b/Examples/go/template/example.h @@ -0,0 +1,32 @@ +/* File : example.h */ + +// Some template definitions + +template T max(T a, T b) { return a>b ? a : b; } + +template class vector { + T *v; + int sz; + public: + vector(int _sz) { + v = new T[_sz]; + sz = _sz; + } + T &get(int index) { + return v[index]; + } + void set(int index, T &val) { + v[index] = val; + } +#ifdef SWIG + %extend { + T getitem(int index) { + return $self->get(index); + } + void setitem(int index, T val) { + $self->set(index,val); + } + } +#endif +}; + diff --git a/Examples/go/template/example.i b/Examples/go/template/example.i new file mode 100644 index 000000000..8f94c4da1 --- /dev/null +++ b/Examples/go/template/example.i @@ -0,0 +1,17 @@ +/* File : example.i */ +%module example + +%{ +#include "example.h" +%} + +/* Let's just grab the original header file here */ +%include "example.h" + +/* Now instantiate some specific template declarations */ + +%template(maxint) max; +%template(maxdouble) max; +%template(vecint) vector; +%template(vecdouble) vector; + diff --git a/Examples/go/template/index.html b/Examples/go/template/index.html new file mode 100644 index 000000000..a14e3b29a --- /dev/null +++ b/Examples/go/template/index.html @@ -0,0 +1,113 @@ + + +SWIG:Examples:go:template + + + + + +SWIG/Examples/go/template/ +
      + +

      C++ template support

      + +

      +This example illustrates how C++ templates can be used from Go using +SWIG. + +

      The C++ Code

      + +Lets take a templated function and a templated class as follows: + +
      +
      +/* File : example.h */
      +
      +// Some template definitions
      +
      +template T max(T a, T b) { return  a>b ? a : b; }
      +
      +template class vector {
      +  T *v;
      +  int sz;
      + public:
      +  vector(int _sz) {
      +    v = new T[_sz];
      +    sz = _sz;
      +  }
      +  T &get(int index) {
      +    return v[index];
      +  }
      +  void set(int index, T &val) {
      +    v[index] = val;
      +  }
      +#ifdef SWIG
      +  %addmethods {
      +    T getitem(int index) {
      +      return self->get(index);
      +    }
      +    void setitem(int index, T val) {
      +      self->set(index,val);
      +    }
      +  }
      +#endif
      +};
      +
      +
      +The %addmethods is used for a neater interface from Go as the +functions get and set use C++ references to +primitive types. These are tricky to use from Go as they end up as +pointers, which only work when the C++ and Go types correspond +precisely. + +

      The SWIG interface

      + +A simple SWIG interface for this can be built by simply grabbing the +header file like this: + +
      +
      +/* File : example.i */
      +%module example
      +
      +%{
      +#include "example.h"
      +%}
      +
      +/* Let's just grab the original header file here */
      +%include "example.h"
      +
      +/* Now instantiate some specific template declarations */
      +
      +%template(maxint) max;
      +%template(maxdouble) max;
      +%template(vecint) vector;
      +%template(vecdouble) vector;
      +
      +
      + +Note that SWIG parses the templated function max and +templated class vector and so knows about them. However to +generate code for use from Go, SWIG has to be told which class/type to +use as the template parameter. The SWIG directive %template is used +for this. + +

      A sample Go program

      + +Click here to see a Go program that calls the +C++ functions from Go. + +

      Notes

      Use templated classes just like you would any other +SWIG generated Go class. Use the classnames specified by the %template +directive. + +
      +
      +vecdouble dv = new vecdouble(1000);
      +dv.setitem(i, 12.34));
      +
      +
      + +
      + + diff --git a/Examples/go/template/runme.go b/Examples/go/template/runme.go new file mode 100644 index 000000000..8b3d4000e --- /dev/null +++ b/Examples/go/template/runme.go @@ -0,0 +1,43 @@ +// This example illustrates how C++ templates can be used from Go. + +package main + +import ( + "fmt" + . "./example" +) + +func main() { + + // Call some templated functions + fmt.Println(Maxint(3, 7)) + fmt.Println(Maxdouble(3.14, 2.18)) + + // Create some class + iv := NewVecint(100) + dv := NewVecdouble(1000) + + for i := 0; i < 100; i++ { + iv.Setitem(i, 2*i) + } + + for i := 0; i < 1000; i++ { + dv.Setitem(i, 1.0/float64(i+1)) + } + + { + sum := 0 + for i := 0; i < 100; i++ { + sum = sum + iv.Getitem(i) + } + fmt.Println(sum) + } + + { + sum := float64(0.0) + for i := 0; i < 1000; i++ { + sum = sum + dv.Getitem(i) + } + fmt.Println(sum) + } +} diff --git a/Examples/go/variables/Makefile b/Examples/go/variables/Makefile new file mode 100644 index 000000000..b0aa9c970 --- /dev/null +++ b/Examples/go/variables/Makefile @@ -0,0 +1,18 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +SRCS = example.c +TARGET = example +INTERFACE = example.i +SWIGOPT = + +all:: go + +go:: + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go + +clean:: + $(MAKE) -f $(TOP)/Makefile go_clean + +check: all + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run diff --git a/Examples/go/variables/example.c b/Examples/go/variables/example.c new file mode 100644 index 000000000..aa4ffe9b3 --- /dev/null +++ b/Examples/go/variables/example.c @@ -0,0 +1,91 @@ +/* File : example.c */ + +/* I'm a file containing some C global variables */ + +/* Deal with Microsoft's attempt at deprecating C standard runtime functions */ +#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) +# define _CRT_SECURE_NO_DEPRECATE +#endif + +#include +#include +#include "example.h" + +int ivar = 0; +short svar = 0; +long lvar = 0; +unsigned int uivar = 0; +unsigned short usvar = 0; +unsigned long ulvar = 0; +signed char scvar = 0; +unsigned char ucvar = 0; +char cvar = 0; +float fvar = 0; +double dvar = 0; +char *strvar = 0; +const char cstrvar[] = "Goodbye"; +int *iptrvar = 0; +char name[256] = "Dave"; +char path[256] = "/home/beazley"; + + +/* Global variables involving a structure */ +Point *ptptr = 0; +Point pt = { 10, 20 }; + +/* A variable that we will make read-only in the interface */ +int status = 1; + +/* A debugging function to print out their values */ + +void print_vars() { + printf("ivar = %d\n", ivar); + printf("svar = %d\n", svar); + printf("lvar = %ld\n", lvar); + printf("uivar = %u\n", uivar); + printf("usvar = %u\n", usvar); + printf("ulvar = %lu\n", ulvar); + printf("scvar = %d\n", scvar); + printf("ucvar = %u\n", ucvar); + printf("fvar = %g\n", fvar); + printf("dvar = %g\n", dvar); + printf("cvar = %c\n", cvar); + printf("strvar = %s\n", strvar ? strvar : "(null)"); + printf("cstrvar = %s\n", cstrvar ? cstrvar : "(null)"); + printf("iptrvar = %p\n", iptrvar); + printf("name = %s\n", name); + printf("ptptr = %p (%d, %d)\n", ptptr, ptptr ? ptptr->x : 0, ptptr ? ptptr->y : 0); + printf("pt = (%d, %d)\n", pt.x, pt.y); + printf("status = %d\n", status); +} + +/* A function to create an integer (to test iptrvar) */ + +int *new_int(int value) { + int *ip = (int *) malloc(sizeof(int)); + *ip = value; + return ip; +} + +/* A function to create a point */ + +Point *new_Point(int x, int y) { + Point *p = (Point *) malloc(sizeof(Point)); + p->x = x; + p->y = y; + return p; +} + +char * Point_print(Point *p) { + static char buffer[256]; + if (p) { + sprintf(buffer,"(%d,%d)", p->x,p->y); + } else { + sprintf(buffer,"null"); + } + return buffer; +} + +void pt_print() { + printf("(%d, %d)\n", pt.x, pt.y); +} diff --git a/Examples/go/variables/example.go b/Examples/go/variables/example.go new file mode 100644 index 000000000..f4f299b73 --- /dev/null +++ b/Examples/go/variables/example.go @@ -0,0 +1,198 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 2.0.1 + * + * This file is not intended to be easily readable and contains a number of + * coding conventions designed to improve portability and efficiency. Do not make + * changes to this file unless you know what you are doing--modify the SWIG + * interface file instead. + * ----------------------------------------------------------------------------- */ + +package example + + +type _swig_fnptr *byte +type _swig_memberptr *byte + + +func _swig_allocatememory(int) *byte +func _swig_internal_allocate(len int) *byte { + return _swig_allocatememory(len) +} + +func _swig_allocatestring(*byte, int) string +func _swig_internal_makegostring(p *byte, l int) string { + return _swig_allocatestring(p, l) +} + +func _swig_internal_gopanic(p *byte, l int) { + panic(_swig_allocatestring(p, l)) +} + +func _swig_wrap_ivar_set(int) + +func SetIvar(arg1 int) { + _swig_wrap_ivar_set(arg1) +} + +func GetIvar() int +func _swig_wrap_svar_set(int16) + +func SetSvar(arg1 int16) { + _swig_wrap_svar_set(arg1) +} + +func GetSvar() int16 +func _swig_wrap_lvar_set(int32) + +func SetLvar(arg1 int32) { + _swig_wrap_lvar_set(arg1) +} + +func GetLvar() int32 +func _swig_wrap_uivar_set(uint) + +func SetUivar(arg1 uint) { + _swig_wrap_uivar_set(arg1) +} + +func GetUivar() uint +func _swig_wrap_usvar_set(uint16) + +func SetUsvar(arg1 uint16) { + _swig_wrap_usvar_set(arg1) +} + +func GetUsvar() uint16 +func _swig_wrap_ulvar_set(uint32) + +func SetUlvar(arg1 uint32) { + _swig_wrap_ulvar_set(arg1) +} + +func GetUlvar() uint32 +func _swig_wrap_scvar_set(int8) + +func SetScvar(arg1 int8) { + _swig_wrap_scvar_set(arg1) +} + +func GetScvar() int8 +func _swig_wrap_ucvar_set(byte) + +func SetUcvar(arg1 byte) { + _swig_wrap_ucvar_set(arg1) +} + +func GetUcvar() byte +func _swig_wrap_cvar_set(byte) + +func SetCvar(arg1 byte) { + _swig_wrap_cvar_set(arg1) +} + +func GetCvar() byte +func _swig_wrap_fvar_set(float32) + +func SetFvar(arg1 float32) { + _swig_wrap_fvar_set(arg1) +} + +func GetFvar() float32 +func _swig_wrap_dvar_set(float64) + +func SetDvar(arg1 float64) { + _swig_wrap_dvar_set(arg1) +} + +func GetDvar() float64 +func _swig_wrap_strvar_set(string) + +func SetStrvar(arg1 string) { + _swig_wrap_strvar_set(arg1) +} + +func GetStrvar() string +func GetCstrvar() string +func _swig_wrap_iptrvar_set(*int) + +func SetIptrvar(arg1 *int) { + _swig_wrap_iptrvar_set(arg1) +} + +func GetIptrvar() *int +func _swig_wrap_name_set(string) + +func SetName(arg1 string) { + _swig_wrap_name_set(arg1) +} + +func GetName() string +func _swig_wrap_ptptr_set(uintptr) + +func SetPtptr(arg1 Point) { + _swig_wrap_ptptr_set(arg1.Swigcptr()) +} + +func _swig_wrap_ptptr_get() SwigcptrPoint + +func GetPtptr() Point { + return _swig_wrap_ptptr_get() +} + +func _swig_wrap_pt_set(uintptr) + +func SetPt(arg1 Point) { + _swig_wrap_pt_set(arg1.Swigcptr()) +} + +func _swig_wrap_pt_get() SwigcptrPoint + +func GetPt() Point { + return _swig_wrap_pt_get() +} + +func GetStatus() int +func GetPath() string +func _swig_wrap_print_vars() + +func Print_vars() { + _swig_wrap_print_vars() +} + +func New_int(int) *int +func _swig_wrap_new_Point(int, int) SwigcptrPoint + +func New_Point(arg1 int, arg2 int) Point { + return _swig_wrap_new_Point(arg1, arg2) +} + +func _swig_wrap_Point_print(uintptr) string + +func Point_print(arg1 Point) string { + return _swig_wrap_Point_print(arg1.Swigcptr()) +} + +func _swig_wrap_pt_print() + +func Pt_print() { + _swig_wrap_pt_print() +} + + +type SwigcptrPoint uintptr +type Point interface { + Swigcptr() uintptr; +} +func (p SwigcptrPoint) Swigcptr() uintptr { + return uintptr(p) +} + +type SwigcptrVoid uintptr +type Void interface { + Swigcptr() uintptr; +} +func (p SwigcptrVoid) Swigcptr() uintptr { + return uintptr(p) +} + diff --git a/Examples/go/variables/example.h b/Examples/go/variables/example.h new file mode 100644 index 000000000..0f7e89594 --- /dev/null +++ b/Examples/go/variables/example.h @@ -0,0 +1,6 @@ +/* File: example.h */ + +typedef struct { + int x,y; +} Point; + diff --git a/Examples/go/variables/example.i b/Examples/go/variables/example.i new file mode 100644 index 000000000..591b871ed --- /dev/null +++ b/Examples/go/variables/example.i @@ -0,0 +1,49 @@ +/* File : example.i */ +%module example +%{ +#include "example.h" +%} + +/* Some global variable declarations */ +%inline %{ +extern int ivar; +extern short svar; +extern long lvar; +extern unsigned int uivar; +extern unsigned short usvar; +extern unsigned long ulvar; +extern signed char scvar; +extern unsigned char ucvar; +extern char cvar; +extern float fvar; +extern double dvar; +extern char *strvar; +extern const char cstrvar[]; +extern int *iptrvar; +extern char name[256]; + +extern Point *ptptr; +extern Point pt; +%} + + +/* Some read-only variables */ + +%immutable; + +%inline %{ +extern int status; +extern char path[256]; +%} + +%mutable; + +/* Some helper functions to make it easier to test */ +%inline %{ +extern void print_vars(); +extern int *new_int(int value); +extern Point *new_Point(int x, int y); +extern char *Point_print(Point *p); +extern void pt_print(); +%} + diff --git a/Examples/go/variables/index.html b/Examples/go/variables/index.html new file mode 100644 index 000000000..5a11194df --- /dev/null +++ b/Examples/go/variables/index.html @@ -0,0 +1,87 @@ + + +SWIG:Examples:go:variables + + + + +SWIG/Examples/go/variables/ +
      + +

      Wrapping C Global Variables

      + +

      +When a C global variable appears in an interface file, SWIG provides +getter and setter functions for the variable. The getter function is +named Get followed by the capitalized name of the variable. +The setter variable starts with Set instead. The getter +function takes no parameters and returns the value of the variable. +The setter function takes a single parameter with the same type as the +variable, and returns nothing. + +

      Click here to see a SWIG interface with +some variable declarations in it. + +

      Manipulating Variables from Go

      + +For example, if the package is called example, the global +variable + +
      +
      +double foo;
      +
      +
      + +will be accessed from Go as +
      +
      +example.GetFoo();
      +example.SetFoo(12.3);
      +
      +
      + +Click here to see the example program that +updates and prints out the values of the variables using this +technique. + +

      Key points

      + +
        +
      • The name of the variable is capitalized. +
      • When a global variable has the type "char *", SWIG +manages it as a character string. +
      • signed char and unsigned char are handled as +small 8-bit integers. +
      • String array variables such as 'char name[256]' are +managed as Go strings, but when setting the value, the result is +truncated to the maximum length of the array. Furthermore, the string +is assumed to be null-terminated. +
      • When structures and classes are used as global variables, they are +mapped into pointers. Getting the "value" returns a pointer to the +global variable. Setting the value of a structure results in a memory +copy from a pointer to the global. +
      + +

      Creating read-only variables

      + +The %immutable and %mutable directives can be used +to specify a collection of read-only variables. A read only variable +will have a getter function but no setter function. For example: + +
      +
      +%immutable;
      +int    status;
      +double blah;
      +...
      +%mutable;
      +
      +
      + +The %immutable directive remains in effect until it is +explicitly disabled using the %mutable directive. + + + +
      diff --git a/Examples/go/variables/runme.go b/Examples/go/variables/runme.go new file mode 100644 index 000000000..26cad4b3c --- /dev/null +++ b/Examples/go/variables/runme.go @@ -0,0 +1,67 @@ +// This example illustrates global variable access from Go. + +package main + +import ( + "fmt" + "./example" +) + +func main() { + // Try to set the values of some global variables + + example.SetIvar(42) + example.SetSvar(-31000) + example.SetLvar(65537) + example.SetUivar(123456) + example.SetUsvar(61000) + example.SetUlvar(654321) + example.SetScvar(-13) + example.SetUcvar(251) + example.SetCvar('S') + example.SetFvar(3.14159) + example.SetDvar(2.1828) + example.SetStrvar("Hello World") + example.SetIptrvar(example.New_int(37)) + example.SetPtptr(example.New_Point(37, 42)) + example.SetName("Bill") + + // Now print out the values of the variables + + fmt.Println("Variables (values printed from Go)") + + fmt.Println("ivar =", example.GetIvar()) + fmt.Println("svar =", example.GetSvar()) + fmt.Println("lvar =", example.GetLvar()) + fmt.Println("uivar =", example.GetUivar()) + fmt.Println("usvar =", example.GetUsvar()) + fmt.Println("ulvar =", example.GetUlvar()) + fmt.Println("scvar =", example.GetScvar()) + fmt.Println("ucvar =", example.GetUcvar()) + fmt.Println("fvar =", example.GetFvar()) + fmt.Println("dvar =", example.GetDvar()) + fmt.Printf("cvar = %c\n", example.GetCvar()) + fmt.Println("strvar =", example.GetStrvar()) + fmt.Println("cstrvar =", example.GetCstrvar()) + fmt.Println("iptrvar =", example.GetIptrvar()) + fmt.Println("name =", example.GetName()) + fmt.Println("ptptr =", example.GetPtptr(), example.Point_print(example.GetPtptr())) + fmt.Println("pt =", example.GetPt(), example.Point_print(example.GetPt())) + + fmt.Println("\nVariables (values printed from C)") + + example.Print_vars() + + // This line would not compile: since status is marked with + // %immutable, there is no SetStatus function. + // fmt.Println("\nNow I'm going to try and modify some read only variables") + // example.SetStatus(0) + + fmt.Println("\nI'm going to try and update a structure variable.\n") + + example.SetPt(example.GetPtptr()) + + fmt.Println("The new value is") + example.Pt_print() + fmt.Println("You should see the value", example.Point_print(example.GetPtptr())) +} diff --git a/Examples/test-suite/dynamic_cast.i b/Examples/test-suite/dynamic_cast.i index 5d4fbb0b6..ccbaa5b47 100644 --- a/Examples/test-suite/dynamic_cast.i +++ b/Examples/test-suite/dynamic_cast.i @@ -1,7 +1,7 @@ /* File : example.i */ %module dynamic_cast -#if !defined(SWIGJAVA) && !defined(SWIGCSHARP) +#if !defined(SWIGJAVA) && !defined(SWIGCSHARP) && !defined(SWIGGO) %apply SWIGTYPE *DYNAMIC { Foo * }; #endif @@ -17,7 +17,7 @@ public: }; %} -#if defined(SWIGJAVA) || defined(SWIGCSHARP) +#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGGO) %typemap(out) Foo *blah { Bar *downcast = dynamic_cast($1); *(Bar **)&$result = downcast; @@ -37,6 +37,14 @@ public: } #endif +#if defined(SWIGGO) +%insert(go_runtime) %{ +func FooToBar(f Foo) Bar { + return SwigcptrBar(f.Swigcptr()) +} +%} +#endif + %inline %{ class Bar : public Foo { @@ -54,7 +62,7 @@ char *do_test(Bar *b) { } %} -#if !defined(SWIGJAVA) && !defined(SWIGCSHARP) +#if !defined(SWIGJAVA) && !defined(SWIGCSHARP) && !defined(SWIGGO) // A general purpose function for dynamic casting of a Foo * %{ static swig_type_info * diff --git a/Examples/test-suite/go/Makefile.in b/Examples/test-suite/go/Makefile.in new file mode 100644 index 000000000..d666c81bf --- /dev/null +++ b/Examples/test-suite/go/Makefile.in @@ -0,0 +1,110 @@ +####################################################################### +# Makefile for Go test-suite +####################################################################### + +LANGUAGE = go +GO = 6g +GOGCC = false +SCRIPTSUFFIX = _runme.go + +GOCOMPILEARG = `if $(GOGCC) ; then echo -c -g; fi` +GOC = $(GO:g=c) +GOLD = $(GO:g=l) + +GOOBJEXT = $(GO:g=) + +SO = @SO@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +top_builddir = @top_builddir@ + +include $(srcdir)/../common.mk + +# Custom tests - tests with additional commandline options +constant_pointers.cpptest: SWIGOPT += -rename foo=foofn +director_enum.cpptest: SWIGOPT += -rename Hello=Helloe +director_finalizer.cpptest: SWIGOPT += -rename deleteFoo=deleteFooFn +enum_thorough.cpptest: SWIGOPT += -rename One=Onee -rename Two=Twoe +mixed_types.cpptest: SWIGOPT += -rename Hello=Helloe +overload_simple.cpptest: SWIGOPT += -rename foo=foofn +smart_pointer_extend.cpptest: SWIGOPT += -rename CPtrFoo=CPtrFoos +smart_pointer_member.cpptest: SWIGOPT += -rename Foo=Foos +special_variable_macros.cpptest: SWIGOPT += -rename Name=Names +template_partial_specialization.cpptest: SWIGOPT += -rename b=bfn +template_partial_specialization_typedef.cpptest: SWIGOPT += -rename b=bfn +template_specialization_enum.cpptest: SWIGOPT += -rename Hello=Helloe +preproc.ctest: SWIGOPT += -rename a5=a5c -rename a6=a6c +mod.multicpptest: SWIGOPT += -rename GetC=GetCFn + +.SUFFIXES: .cpptest .ctest .multicpptest + +# Rules for the different types of tests +%.cpptest: + $(setup) + +$(swig_and_compile_cpp) + $(run_testcase) + +%.ctest: + $(setup) + +$(swig_and_compile_c) + $(run_testcase) + +%.multicpptest: + $(setup) + +$(swig_and_compile_multi_cpp) + $(run_multi_testcase) + +multi_import.multicpptest: + $(setup) + for f in multi_import_b multi_import_a; do \ + $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile CXXSRCS="$(CXXSRCS)" \ + SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" LIBS='$(LIBS)' \ + INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT)" NOLINK=true \ + TARGET="$(TARGETPREFIX)$${f}$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$$f.i" \ + $(LANGUAGE)$(VARIANT)_cpp; \ + done + $(run_multi_testcase) + +# Runs the testcase. +run_testcase = \ + if test -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); then \ + $(GO) -I . $(GOCOMPILEARG) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \ + if $(GOGCC) ; then \ + $(GO) -o $*_runme $(SCRIPTPREFIX)$*_runme.@OBJEXT@ $*.@OBJEXT@ $*$(SO); \ + else \ + $(GOLD) -L . -r $${GOROOT}/pkg/$${GOOS}_$${GOARCH}:. -o $*_runme $(SCRIPTPREFIX)$*_runme.$(GOOBJEXT); \ + fi && \ + env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH ./$*_runme; \ + fi + +run_multi_testcase = \ + if test -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); then \ + $(GO) -I . $(GOCOMPILEARG) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \ + if $(GOGCC) ; then \ + files=`cat $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list`; \ + $(GO) -o $*_runme $(SCRIPTPREFIX)$*_runme.@OBJEXT@ `for f in $$files; do echo $$f.@OBJEXT@ $$f$(SO); done`; \ + else \ + $(GOLD) -L . -r $${GOROOT}/pkg/$${GOOS}_$${GOARCH}:. -o $*_runme $(SCRIPTPREFIX)$*_runme.$(GOOBJEXT); \ + fi && \ + env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH ./$*_runme; \ + fi + +%.clean: + @rm -f $*.go $*_gc.c $*_wrap.* $*_runme + +clean: + $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile go_clean + rm -f mod_a.go mod_b.go imports_a.go imports_b.go + rm -f clientdata_prop_a.go clientdata_prop_b.go + rm -f multi_import_a.go multi_import_b.go + rm -f packageoption_a.go packageoption_b.go packageoption_c.go + +cvsignore: + @echo '*_gc.c *_wrap.* *.so *.dll *.exp *.lib' + @echo Makefile + @echo mod_a.go mod_b.go imports_a.go imports_b.go + @echo clientdata_prop_a.go clientdata_prop_b.go + @echo multi_import_a.go multi_import_b.go + @echo packageoption_a.go packageoption_b.go packageoption_c.go + @for i in ${CPP_TEST_CASES} ${C_TEST_CASES}; do echo $$i.go; done diff --git a/Examples/test-suite/go/abstract_access_runme.go b/Examples/test-suite/go/abstract_access_runme.go new file mode 100644 index 000000000..a2cfeda92 --- /dev/null +++ b/Examples/test-suite/go/abstract_access_runme.go @@ -0,0 +1,10 @@ +package main + +import "./abstract_access" + +func main() { + d := abstract_access.NewD() + if d.Do_x() != 1 { + panic(d.Do_x()) + } +} diff --git a/Examples/test-suite/go/abstract_typedef2_runme.go b/Examples/test-suite/go/abstract_typedef2_runme.go new file mode 100644 index 000000000..ef760e45d --- /dev/null +++ b/Examples/test-suite/go/abstract_typedef2_runme.go @@ -0,0 +1,7 @@ +package main + +import "./abstract_typedef2" + +func main() { + abstract_typedef2.NewA_UF() +} diff --git a/Examples/test-suite/go/abstract_typedef_runme.go b/Examples/test-suite/go/abstract_typedef_runme.go new file mode 100644 index 000000000..99ff94ded --- /dev/null +++ b/Examples/test-suite/go/abstract_typedef_runme.go @@ -0,0 +1,11 @@ +package main + +import "./abstract_typedef" + +func main() { + e := abstract_typedef.NewEngine() + a := abstract_typedef.NewA() + if !a.Write(e) { + panic("failed") + } +} diff --git a/Examples/test-suite/go/abstract_virtual_runme.go b/Examples/test-suite/go/abstract_virtual_runme.go new file mode 100644 index 000000000..b87cf9b5c --- /dev/null +++ b/Examples/test-suite/go/abstract_virtual_runme.go @@ -0,0 +1,8 @@ +package main + +import "./abstract_virtual" + +func main() { + abstract_virtual.NewD() + abstract_virtual.NewE() +} diff --git a/Examples/test-suite/go/array_member_runme.go b/Examples/test-suite/go/array_member_runme.go new file mode 100644 index 000000000..d8a8fac2b --- /dev/null +++ b/Examples/test-suite/go/array_member_runme.go @@ -0,0 +1,26 @@ +package main + +import . "./array_member" + +func main() { + f := NewFoo() + f.SetData(GetGlobal_data()) + + for i := 0; i < 8; i++ { + if Get_value(f.GetData(), i) != Get_value(GetGlobal_data(), i) { + panic("Bad array assignment") + } + } + + for i := 0; i < 8; i++ { + Set_value(f.GetData(), i, -i) + } + + SetGlobal_data(f.GetData()) + + for i := 0; i < 8; i++ { + if Get_value(f.GetData(), i) != Get_value(GetGlobal_data(), i) { + panic("Bad array assignment") + } + } +} diff --git a/Examples/test-suite/go/arrays_global_runme.go b/Examples/test-suite/go/arrays_global_runme.go new file mode 100644 index 000000000..0ff40090c --- /dev/null +++ b/Examples/test-suite/go/arrays_global_runme.go @@ -0,0 +1,22 @@ +package main + +import . "./arrays_global" + +func main() { + SetArray_i(GetArray_const_i()) + + GetBeginString_FIX44a() + GetBeginString_FIX44b() + GetBeginString_FIX44c() + GetBeginString_FIX44d() + GetBeginString_FIX44d() + SetBeginString_FIX44b("12\00045") + GetBeginString_FIX44b() + GetBeginString_FIX44d() + GetBeginString_FIX44e() + GetBeginString_FIX44f() + + Test_a("hello", "hi", "chello", "chi") + + Test_b("1234567", "hi") +} diff --git a/Examples/test-suite/go/class_ignore_runme.go b/Examples/test-suite/go/class_ignore_runme.go new file mode 100644 index 000000000..82e52eff5 --- /dev/null +++ b/Examples/test-suite/go/class_ignore_runme.go @@ -0,0 +1,10 @@ +package main + +import "./class_ignore" + +func main() { + a := class_ignore.NewBar() + if class_ignore.Do_blah(a) != "Bar::blah" { + panic(class_ignore.Do_blah(a)) + } +} diff --git a/Examples/test-suite/go/class_scope_weird_runme.go b/Examples/test-suite/go/class_scope_weird_runme.go new file mode 100644 index 000000000..332586f31 --- /dev/null +++ b/Examples/test-suite/go/class_scope_weird_runme.go @@ -0,0 +1,11 @@ +package main + +import "./class_scope_weird" + +func main() { + f := class_scope_weird.NewFoo() + class_scope_weird.NewFoo(3) + if f.Bar(3) != 3 { + panic(f.Bar(3)) + } +} diff --git a/Examples/test-suite/go/compactdefaultargs_runme.go b/Examples/test-suite/go/compactdefaultargs_runme.go new file mode 100644 index 000000000..8818dce07 --- /dev/null +++ b/Examples/test-suite/go/compactdefaultargs_runme.go @@ -0,0 +1,29 @@ +package main + +import . "./compactdefaultargs" + +func main() { + defaults1 := NewDefaults1(1000) + defaults1 = NewDefaults1() + + if defaults1.Ret(float64(10.0)) != 10.0 { + println(1, defaults1.Ret(float64(10.0))) + panic(defaults1.Ret(float64(10.0))) + } + + if defaults1.Ret() != -1.0 { + println(2, defaults1.Ret()) + panic(defaults1.Ret()) + } + + defaults2 := NewDefaults2(1000) + defaults2 = NewDefaults2() + + if defaults2.Ret(float64(10.0)) != 10.0 { + panic(defaults2.Ret(float64(10.0))) + } + + if defaults2.Ret() != -1.0 { + panic(defaults2.Ret()) + } +} diff --git a/Examples/test-suite/go/constover_runme.go b/Examples/test-suite/go/constover_runme.go new file mode 100644 index 000000000..e649140a6 --- /dev/null +++ b/Examples/test-suite/go/constover_runme.go @@ -0,0 +1,50 @@ +package main + +import ( + "fmt" + "os" + "./constover" +) + +func main() { + error := 0 + + p := constover.Test("test") + if p != "test" { + fmt.Println("test failed!") + error = 1 + } + + p = constover.Test_pconst("test") + if p != "test_pconst" { + fmt.Println("test_pconst failed!") + error = 1 + } + + f := constover.NewFoo() + p = f.Test("test") + if p != "test" { + fmt.Println("member-test failed!") + error = 1 + } + + p = f.Test_pconst("test") + if p != "test_pconst" { + fmt.Println("member-test_pconst failed!") + error = 1 + } + + p = f.Test_constm("test") + if p != "test_constmethod" { + fmt.Println("member-test_constm failed!") + error = 1 + } + + p = f.Test_pconstm("test") + if p != "test_pconstmethod" { + fmt.Println("member-test_pconstm failed!") + error = 1 + } + + os.Exit(error) +} diff --git a/Examples/test-suite/go/constructor_copy_runme.go b/Examples/test-suite/go/constructor_copy_runme.go new file mode 100644 index 000000000..d9b77a9db --- /dev/null +++ b/Examples/test-suite/go/constructor_copy_runme.go @@ -0,0 +1,34 @@ +package main + +import . "./constructor_copy" + +func main() { + f1 := NewFoo1(3) + f11 := NewFoo1(f1) + + if f1.GetX() != f11.GetX() { + panic("f1/f11 x mismatch") + } + + bi := NewBari(5) + bc := NewBari(bi) + + if bi.GetX() != bc.GetX() { + panic("bi/bc x mismatch") + } + + bd := NewBard(5) + good := false + func() { + defer func() { + if recover() != nil { + good = true + } + }() + NewBard(bd) + }() + + if !good { + panic("bd !good") + } +} diff --git a/Examples/test-suite/go/contract_runme.go b/Examples/test-suite/go/contract_runme.go new file mode 100644 index 000000000..d86110be2 --- /dev/null +++ b/Examples/test-suite/go/contract_runme.go @@ -0,0 +1,208 @@ +package main + +import "./contract" + +func main() { + contract.Test_preassert(1, 2) + contract.Test_postassert(3) + func() { + defer func() { + if recover() == nil { + panic("Failed! Postassertions are broken") + } + }() + contract.Test_postassert(-3) + }() + + contract.Test_prepost(2, 3) + contract.Test_prepost(5, -4) + func() { + defer func() { + if recover() == nil { + panic("Failed! Preassertions are broken") + } + }() + contract.Test_prepost(-3, 4) + }() + + func() { + defer func() { + if recover() == nil { + panic("Failed! Postassertions are broken") + } + }() + contract.Test_prepost(4, -10) + }() + + f := contract.NewFoo() + f.Test_preassert(4, 5) + func() { + defer func() { + if recover() == nil { + panic("Failed! Method preassertion.") + } + }() + f.Test_preassert(-2, 3) + }() + + f.Test_postassert(4) + func() { + defer func() { + if recover() == nil { + panic("Failed! Method postassertion") + } + }() + f.Test_postassert(-4) + }() + + f.Test_prepost(3, 4) + f.Test_prepost(4, -3) + func() { + defer func() { + if recover() == nil { + panic("Failed! Method preassertion.") + } + }() + f.Test_prepost(-4, 2) + }() + + func() { + defer func() { + if recover() == nil { + panic("Failed! Method postassertion.") + } + }() + f.Test_prepost(4, -10) + }() + + contract.FooStest_prepost(4, 0) + func() { + defer func() { + if recover() == nil { + panic("Failed! Static method preassertion") + } + }() + contract.FooStest_prepost(-4, 2) + }() + + func() { + defer func() { + if recover() == nil { + panic("Failed! Static method posteassertion") + } + }() + contract.FooStest_prepost(4, -10) + }() + + b := contract.NewBar() + func() { + defer func() { + if recover() == nil { + panic("Failed! Inherited preassertion.") + } + }() + b.Test_prepost(2, -4) + }() + + d := contract.NewD() + func() { + defer func() { + if recover() == nil { + panic("Failed! Inherited preassertion (D).") + } + }() + d.Foo(-1, 1, 1, 1, 1) + }() + + func() { + defer func() { + if recover() == nil { + panic("Failed! Inherited preassertion (D).") + } + }() + d.Foo(1, -1, 1, 1, 1) + }() + + func() { + defer func() { + if recover() == nil { + panic("Failed! Inherited preassertion (D).") + } + }() + d.Foo(1, 1, -1, 1, 1) + }() + + func() { + defer func() { + if recover() == nil { + panic("Failed! Inherited preassertion (D).") + } + }() + d.Foo(1, 1, 1, -1, 1) + }() + + func() { + defer func() { + if recover() == nil { + panic("Failed! Inherited preassertion (D).") + } + }() + d.Foo(1, 1, 1, 1, -1) + }() + + func() { + defer func() { + if recover() == nil { + panic("Failed! Inherited preassertion (D).") + } + }() + d.Bar(-1, 1, 1, 1, 1) + }() + + func() { + defer func() { + if recover() == nil { + panic("Failed! Inherited preassertion (D).") + } + }() + d.Bar(1, -1, 1, 1, 1) + }() + + func() { + defer func() { + if recover() == nil { + panic("Failed! Inherited preassertion (D).") + } + }() + d.Bar(1, 1, -1, 1, 1) + }() + + func() { + defer func() { + if recover() == nil { + panic("Failed! Inherited preassertion (D).") + } + }() + d.Bar(1, 1, 1, -1, 1) + }() + + func() { + defer func() { + if recover() == nil { + panic("Failed! Inherited preassertion (D).") + } + }() + d.Bar(1, 1, 1, 1, -1) + }() + + //Namespace + my := contract.NewMyClass(1) + func() { + defer func() { + if recover() == nil { + panic("Failed! constructor preassertion") + } + }() + my = contract.NewMyClass(0) + }() +} diff --git a/Examples/test-suite/go/cpp_enum_runme.go b/Examples/test-suite/go/cpp_enum_runme.go new file mode 100644 index 000000000..7d7db953d --- /dev/null +++ b/Examples/test-suite/go/cpp_enum_runme.go @@ -0,0 +1,27 @@ +package main + +import "./cpp_enum" + +func main() { + f := cpp_enum.NewFoo() + + if f.GetHola() != cpp_enum.FooHello { + panic(f.GetHola()) + } + + f.SetHola(cpp_enum.FooHi) + if f.GetHola() != cpp_enum.FooHi { + panic(f.GetHola()) + } + + f.SetHola(cpp_enum.FooHello) + + if f.GetHola() != cpp_enum.FooHello { + panic(f.GetHola()) + } + + cpp_enum.SetHi(cpp_enum.Hello) + if cpp_enum.GetHi() != cpp_enum.Hello { + panic(cpp_enum.Hi) + } +} diff --git a/Examples/test-suite/go/cpp_namespace_runme.go b/Examples/test-suite/go/cpp_namespace_runme.go new file mode 100644 index 000000000..8482b043f --- /dev/null +++ b/Examples/test-suite/go/cpp_namespace_runme.go @@ -0,0 +1,57 @@ +// Note: This example assumes that namespaces are flattened +package main + +import "./cpp_namespace" + +func main() { + n := cpp_namespace.Fact(4) + if n != 24 { + panic("Bad return value!") + } + + if cpp_namespace.GetFoo() != 42 { + panic("Bad variable value!") + } + + t := cpp_namespace.NewTest() + if t.Method() != "Test::method" { + panic("Bad method return value!") + } + + if cpp_namespace.Do_method(t) != "Test::method" { + panic("Bad return value!") + } + + if cpp_namespace.Do_method2(t) != "Test::method" { + panic("Bad return value!") + } + + cpp_namespace.Weird("hello", 4) + + cpp_namespace.DeleteTest(t) + + t2 := cpp_namespace.NewTest2() + t3 := cpp_namespace.NewTest3() + t4 := cpp_namespace.NewTest4() + t5 := cpp_namespace.NewTest5() + + if cpp_namespace.Foo3(42) != 42 { + panic("Bad return value!") + } + + if cpp_namespace.Do_method3(t2, 40) != "Test2::method" { + panic("Bad return value!") + } + + if cpp_namespace.Do_method3(t3, 40) != "Test3::method" { + panic("Bad return value!") + } + + if cpp_namespace.Do_method3(t4, 40) != "Test4::method" { + panic("Bad return value!") + } + + if cpp_namespace.Do_method3(t5, 40) != "Test5::method" { + panic("Bad return value!") + } +} diff --git a/Examples/test-suite/go/cpp_static_runme.go b/Examples/test-suite/go/cpp_static_runme.go new file mode 100644 index 000000000..ead433466 --- /dev/null +++ b/Examples/test-suite/go/cpp_static_runme.go @@ -0,0 +1,13 @@ +package main + +import . "./cpp_static" + +func main() { + StaticFunctionTestStatic_func() + StaticFunctionTestStatic_func_2(1) + StaticFunctionTestStatic_func_3(1, 2) + SetStaticMemberTestStatic_int(10) + if GetStaticMemberTestStatic_int() != 10 { + panic(GetStaticMemberTestStatic_int()) + } +} diff --git a/Examples/test-suite/go/default_args_runme.go b/Examples/test-suite/go/default_args_runme.go new file mode 100644 index 000000000..38243ac44 --- /dev/null +++ b/Examples/test-suite/go/default_args_runme.go @@ -0,0 +1,26 @@ +package main + +import "./default_args" + +func main() { + if default_args.StaticsStaticmethod() != 60 { + panic(0) + } + + if default_args.Cfunc1(1) != 2 { + panic(0) + } + + if default_args.Cfunc2(1) != 3 { + panic(0) + } + + if default_args.Cfunc3(1) != 4 { + panic(0) + } + + f := default_args.NewFoo() + + f.Newname() + f.Newname(1) +} diff --git a/Examples/test-suite/go/default_constructor_runme.go b/Examples/test-suite/go/default_constructor_runme.go new file mode 100644 index 000000000..e5e325475 --- /dev/null +++ b/Examples/test-suite/go/default_constructor_runme.go @@ -0,0 +1,35 @@ +package main + +import dc "./default_constructor" + +func main() { + a := dc.NewA() + dc.DeleteA(a) + + aa := dc.NewAA() + dc.DeleteAA(aa) + + cc := dc.NewCC() + dc.DeleteCC(cc) + + e := dc.NewE() + dc.DeleteE(e) + + ee := dc.NewEE() + dc.DeleteEE(ee) + + f := dc.NewF() + f.Destroy() + + ff := dc.NewFFF() + ff.Destroy() + + g := dc.NewG() + + dc.GDestroy(g) + + gg := dc.NewGG() + dc.DeleteGG(gg) + + dc.NewHH(1, 1) +} diff --git a/Examples/test-suite/go/director_abstract_runme.go b/Examples/test-suite/go/director_abstract_runme.go new file mode 100644 index 000000000..37279383a --- /dev/null +++ b/Examples/test-suite/go/director_abstract_runme.go @@ -0,0 +1,62 @@ +package main + +import "./director_abstract" + +type MyFoo struct{} + +func (p *MyFoo) Ping() string { + return "MyFoo::ping()" +} + +func f1() { + a := director_abstract.NewDirectorFoo(&MyFoo{}) + + if a.Ping() != "MyFoo::ping()" { + panic(a.Ping()) + } + + if a.Pong() != "Foo::pong();MyFoo::ping()" { + panic(a.Pong()) + } +} + +type MyExample1 struct{} + +func (p *MyExample1) Color(r, g, b byte) int { + return int(r) +} + +type MyExample2 struct{} + +func (p *MyExample2) Color(r, g, b byte) int { + return int(g) +} + +type MyExample3 struct{} + +func (p *MyExample3) Color(r, g, b byte) int { + return int(b) +} + +func f2() { + me1 := director_abstract.NewDirectorExample1(&MyExample1{}) + if director_abstract.Example1Get_color(me1, 1, 2, 3) != 1 { + println(director_abstract.Example1Get_color(me1, 1, 2, 3)) + panic(0) + } + + me2 := director_abstract.NewDirectorExample2(&MyExample2{}, 1, 2) + if director_abstract.Example2Get_color(me2, 1, 2, 3) != 2 { + panic(0) + } + + me3 := director_abstract.NewDirectorExample3_i(&MyExample3{}) + if director_abstract.Example3_iGet_color(me3, 1, 2, 3) != 3 { + panic(0) + } +} + +func main() { + f1() + f2() +} diff --git a/Examples/test-suite/go/director_basic_runme.go b/Examples/test-suite/go/director_basic_runme.go new file mode 100644 index 000000000..1995452ce --- /dev/null +++ b/Examples/test-suite/go/director_basic_runme.go @@ -0,0 +1,115 @@ +package main + +import "./director_basic" + +type GoFoo struct{} + +func (p *GoFoo) Ping() string { + return "GoFoo::ping()" +} + +func f1() { + a := director_basic.NewDirectorFoo(&GoFoo{}) + + if a.Ping() != "GoFoo::ping()" { + panic(a.Ping()) + } + + if a.Pong() != "Foo::pong();GoFoo::ping()" { + panic(a.Pong()) + } + + b := director_basic.NewFoo() + + if b.Ping() != "Foo::ping()" { + panic(b.Ping()) + } + + if b.Pong() != "Foo::pong();Foo::ping()" { + panic(b.Pong()) + } + + a1 := director_basic.NewA1(1) + + if a1.Rg(2) != 2 { + panic(0) + } +} + +type GoClass struct { + cmethod int +} + +func (p *GoClass) Method(uintptr) { + p.cmethod = 7 +} +func (p *GoClass) Vmethod(b director_basic.Bar) director_basic.Bar { + b.SetX(b.GetX() + 31) + return b +} + +var bc director_basic.Bar + +func f2() { + b := director_basic.NewBar(3) + d := director_basic.NewMyClass() + pc := &GoClass{0} + c := director_basic.NewDirectorMyClass(pc) + + cc := director_basic.MyClassGet_self(c) + dd := director_basic.MyClassGet_self(d) + + bc = cc.Cmethod(b) + bd := dd.Cmethod(b) + + cc.Method(b.Swigcptr()) + if pc.cmethod != 7 { + panic(pc.cmethod) + } + + if bc.GetX() != 34 { + panic(bc.GetX()) + } + + if bd.GetX() != 16 { + panic(bd.GetX()) + } +} + +type GoMulti struct { + GoClass +} + +func (p *GoMulti) Vmethod(b director_basic.Bar) director_basic.Bar { + b.SetX(b.GetX() + 31) + return b +} +func (p *GoMulti) Ping() string { + return "GoFoo::ping()" +} + +func f3() { + for i := 0; i < 100; i++ { + p := &GoMulti{GoClass{0}} + gomult := director_basic.NewDirectorFoo(p) + gomult.Pong() + director_basic.DeleteDirectorFoo(gomult) + } + + p := &GoMulti{GoClass{0}} + gomult := director_basic.NewDirectorMyClass(p) + fgomult := director_basic.NewDirectorFoo(gomult) + + p1 := director_basic.FooGet_self(fgomult.(director_basic.Foo)) + p2 := director_basic.MyClassGet_self(gomult.(director_basic.MyClass)) + + p1.Ping() + p2.Vmethod(bc) +} + + +func main() { + f1() + f2() + f3() +} diff --git a/Examples/test-suite/go/director_classic_runme.go b/Examples/test-suite/go/director_classic_runme.go new file mode 100644 index 000000000..45e89eac5 --- /dev/null +++ b/Examples/test-suite/go/director_classic_runme.go @@ -0,0 +1,135 @@ +package main + +import "fmt" +import . "./director_classic" + +type TargetLangPerson struct{} // From Person +func (p *TargetLangPerson) Id() string { + return "TargetLangPerson" +} + +type TargetLangChild struct{} // Form Child +func (p *TargetLangChild) Id() string { + return "TargetLangChild" +} + +type TargetLangGrandChild struct{} // From Grandchild +func (p *TargetLangGrandChild) Id() string { + return "TargetLangGrandChild" +} + +// Semis - don't override id() in target language + +type TargetLangSemiPerson struct{} // From Person + +type TargetLangSemiChild struct{} // From Child + +type TargetLangSemiGrandChild struct{} // From GrandChild + +// Orphans - don't override id() in C++ + +type TargetLangOrphanPerson struct{} // From OrphanPerson +func (p *TargetLangOrphanPerson) Id() string { + return "TargetLangOrphanPerson" +} + +type TargetLangOrphanChild struct{} // From OrphanChild +func (p *TargetLangOrphanChild) Id() string { + return "TargetLangOrphanChild" +} + +func check(person Person, expected string) { + debug := false + + // Normal target language polymorphic call + ret := person.Id() + if debug { + fmt.Println(ret) + } + if ret != expected { + panic("Failed. Received: " + ret + " Expected: " + expected) + } + + // Polymorphic call from C++ + caller := NewCaller() + caller.SetCallback(person) + ret = caller.Call() + if debug { + fmt.Println(ret) + } + if ret != expected { + panic("Failed. Received: " + ret + " Expected: " + expected) + } + + // Polymorphic call of object created in target language and + // passed to C++ and back again + baseclass := caller.BaseClass() + ret = baseclass.Id() + if debug { + fmt.Println(ret) + } + if ret != expected { + panic("Failed. Received: " + ret + " Expected: " + expected) + } + + caller.ResetCallback() + if debug { + fmt.Println("----------------------------------------") + } +} + +func main() { + person := NewPerson() + check(person, "Person") + DeletePerson(person) + + person = NewChild() + check(person, "Child") + DeletePerson(person) + + person = NewGrandChild() + check(person, "GrandChild") + DeletePerson(person) + + person = NewDirectorPerson(&TargetLangPerson{}) + check(person, "TargetLangPerson") + DeleteDirectorPerson(person) + + person = NewDirectorChild(&TargetLangChild{}) + check(person, "TargetLangChild") + DeleteDirectorChild(person.(Child)) + + person = NewDirectorGrandChild(&TargetLangGrandChild{}) + check(person, "TargetLangGrandChild") + DeleteDirectorGrandChild(person.(GrandChild)) + + // Semis - don't override id() in target language + person = NewDirectorPerson(&TargetLangSemiPerson{}) + check(person, "Person") + DeleteDirectorPerson(person) + + person = NewDirectorChild(&TargetLangSemiChild{}) + check(person, "Child") + DeleteDirectorChild(person.(Child)) + + person = NewDirectorGrandChild(&TargetLangSemiGrandChild{}) + check(person, "GrandChild") + DeleteDirectorGrandChild(person.(GrandChild)) + + // Orphans - don't override id() in C++ + person = NewOrphanPerson() + check(person, "Person") + DeleteOrphanPerson(person.(OrphanPerson)) + + person = NewOrphanChild() + check(person, "Child") + DeleteOrphanChild(person.(OrphanChild)) + + person = NewDirectorOrphanPerson(&TargetLangOrphanPerson{}) + check(person, "TargetLangOrphanPerson") + DeleteDirectorOrphanPerson(person.(OrphanPerson)) + + person = NewDirectorOrphanChild(&TargetLangOrphanChild{}) + check(person, "TargetLangOrphanChild") + DeleteDirectorOrphanChild(person.(OrphanChild)) +} diff --git a/Examples/test-suite/go/director_default_runme.go b/Examples/test-suite/go/director_default_runme.go new file mode 100644 index 000000000..2f963b239 --- /dev/null +++ b/Examples/test-suite/go/director_default_runme.go @@ -0,0 +1,11 @@ +package main + +import . "./director_default" + +func main() { + NewFoo() + NewFoo(1) + + NewBar() + NewBar(1) +} diff --git a/Examples/test-suite/go/director_detect_runme.go b/Examples/test-suite/go/director_detect_runme.go new file mode 100644 index 000000000..9f1ad94a9 --- /dev/null +++ b/Examples/test-suite/go/director_detect_runme.go @@ -0,0 +1,46 @@ +package main + +import "./director_detect" + +type MyBar struct { + val int +} // From director_detect.Bar + +func NewMyBar() director_detect.Bar { + return director_detect.NewDirectorBar(&MyBar{2}) +} + +func (p *MyBar) Get_value() int { + p.val++ + return p.val +} + +func (p *MyBar) Get_class() director_detect.A { + p.val++ + return director_detect.NewA() +} + +func (p *MyBar) Just_do_it() { + p.val++ +} + +func (p *MyBar) Clone() director_detect.Bar { + return director_detect.NewDirectorBar(&MyBar{p.val}) +} + +func main() { + b := NewMyBar() + + f := b.Baseclass() + + v := f.Get_value() + _ = f.Get_class() + f.Just_do_it() + + c := b.DirectorInterface().(*MyBar).Clone() + vc := c.Get_value() + + if (v != 3) || (b.DirectorInterface().(*MyBar).val != 5) || (vc != 6) { + panic("Bad virtual detection") + } +} diff --git a/Examples/test-suite/go/director_enum_runme.go b/Examples/test-suite/go/director_enum_runme.go new file mode 100644 index 000000000..e0dad900b --- /dev/null +++ b/Examples/test-suite/go/director_enum_runme.go @@ -0,0 +1,17 @@ +package main + +import "./director_enum" + +type MyFoo struct{} // From director_enum.Foo +func (p *MyFoo) Say_hi(val director_enum.EnumDirectorHelloe) director_enum.EnumDirectorHelloe { + return val +} + +func main() { + b := director_enum.NewFoo() + a := director_enum.NewDirectorFoo(&MyFoo{}) + + if a.Say_hi(director_enum.Hello) != b.Say_hello(director_enum.Hi) { + panic(0) + } +} diff --git a/Examples/test-suite/go/director_exception_runme.go b/Examples/test-suite/go/director_exception_runme.go new file mode 100644 index 000000000..29df3e40b --- /dev/null +++ b/Examples/test-suite/go/director_exception_runme.go @@ -0,0 +1,95 @@ +package main + +import . "./director_exception" + +type Exception struct { + msg string +} + +func NewException(a, b string) *Exception { + return &Exception{a + b} +} + +type MyFoo struct{} // From Foo +func (p *MyFoo) Ping() string { + panic("MyFoo::ping() EXCEPTION") +} + +type MyFoo2 struct{} // From Foo +func (p *MyFoo2) Ping() bool { + return true // should return a string +} + +type MyFoo3 struct{} // From Foo +func (p *MyFoo3) Ping() string { + panic(NewException("foo", "bar")) +} + +func main() { + // Check that the NotImplementedError raised by MyFoo.ping() + // is returned by MyFoo.pong(). + ok := false + a := NewDirectorFoo(&MyFoo{}) + b := Launder(a) + func() { + defer func() { + e := recover() + if e.(string) == "MyFoo::ping() EXCEPTION" { + ok = true + } else { + panic("Unexpected error message: " + e.(string)) + } + }() + b.Pong() + }() + if !ok { + panic(0) + } + + // Check that if the method has the wrong return type it is + // not called. + ok = false + a = NewDirectorFoo(&MyFoo2{}) + b = Launder(a) + e := b.Pong() + if e != "Foo::pong();"+"Foo::ping()" { + panic(e) + } + + // Check that the director can return an exception which + // requires two arguments to the constructor, without mangling + // it. + ok = false + a = NewDirectorFoo(&MyFoo3{}) + b = Launder(a) + func() { + defer func() { + e := recover() + if e.(*Exception).msg == "foobar" { + ok = true + } else { + panic("Unexpected error message: " + e.(string)) + } + }() + b.Pong() + }() + if !ok { + panic(0) + } + + func() { + defer func() { + e := recover() + _ = e.(Exception2) + }() + panic(NewException2()) + }() + + func() { + defer func() { + e := recover() + _ = e.(Exception1) + }() + panic(NewException1()) + }() +} diff --git a/Examples/test-suite/go/director_extend_runme.go b/Examples/test-suite/go/director_extend_runme.go new file mode 100644 index 000000000..70e2ab41b --- /dev/null +++ b/Examples/test-suite/go/director_extend_runme.go @@ -0,0 +1,18 @@ +// Test case from bug #1506850 "When threading is enabled, the +// interpreter will infinitely wait on a mutex the second time this +// type of extended method is called. Attached is an example program +// that waits on the mutex to be unlocked." + +package main + +import . "./director_extend" + +func main() { + m := NewSpObject() + if m.Dummy() != 666 { + panic("1st call") + } + if m.Dummy() != 666 { + panic("2nd call") + } +} diff --git a/Examples/test-suite/go/director_finalizer_runme.go b/Examples/test-suite/go/director_finalizer_runme.go new file mode 100644 index 000000000..96fcf860e --- /dev/null +++ b/Examples/test-suite/go/director_finalizer_runme.go @@ -0,0 +1,37 @@ +package main + +import . "./director_finalizer" + +type MyFoo struct{} // From Foo +func DeleteMyFoo(p Foo) { + p.OrStatus(2) + DeleteFoo(p) +} + +func main() { + ResetStatus() + + a := NewDirectorFoo(&MyFoo{}) + DeleteMyFoo(a) + + if GetStatus() != 3 { + panic(0) + } + + ResetStatus() + + a = NewDirectorFoo(&MyFoo{}) + Launder(a) + + if GetStatus() != 0 { + panic(0) + } + + DeleteMyFoo(a) + + if GetStatus() != 3 { + panic(0) + } + + ResetStatus() +} diff --git a/Examples/test-suite/go/director_frob_runme.go b/Examples/test-suite/go/director_frob_runme.go new file mode 100644 index 000000000..a6afedf69 --- /dev/null +++ b/Examples/test-suite/go/director_frob_runme.go @@ -0,0 +1,12 @@ +package main + +import . "./director_frob" + +func main() { + foo := NewBravo() + s := foo.Abs_method() + + if s != "Bravo::abs_method()" { + panic(s) + } +} diff --git a/Examples/test-suite/go/director_nested_runme.go b/Examples/test-suite/go/director_nested_runme.go new file mode 100644 index 000000000..2d3bc77e1 --- /dev/null +++ b/Examples/test-suite/go/director_nested_runme.go @@ -0,0 +1,79 @@ +package main + +import . "./director_nested" + +type A struct{} // From FooBar_int +func (p *A) Do_step() string { + return "A::do_step;" +} +func (p *A) Get_value() string { + return "A::get_value" +} + +func f1() { + a := NewDirectorFooBar_int(&A{}) + if a.Step() != "Bar::step;Foo::advance;Bar::do_advance;A::do_step;" { + panic("Bad A virtual resolution") + } +} + +type B struct{} // From FooBar_int +func (p *B) Do_advance() string { + return "B::do_advance;" + p.Do_step() +} +func (p *B) Do_step() string { + return "B::do_step;" +} +func (p *B) Get_value() int { + return 1 +} + +func f2() { + b := NewDirectorFooBar_int(&B{}) + + if b.Step() != "Bar::step;Foo::advance;B::do_advance;B::do_step;" { + panic("Bad B virtual resolution") + } +} + +type C struct { + fbi FooBar_int +} // From FooBar_int + +func (p *C) Do_advance() string { + return "C::do_advance;" + DirectorFooBar_intDo_advance(p.fbi) +} + +func (p *C) Do_step() string { + return "C::do_step;" +} + +func (p *C) Get_value() int { + return 2 +} + +func (p *C) Get_name() string { + return DirectorFooBar_intGet_name(p.fbi) + " hello" +} + +func f3() { + m := &C{nil} + cc := NewDirectorFooBar_int(m) + m.fbi = cc + c := FooBar_intGet_self(cc) + c.Advance() + + if c.Get_name() != "FooBar::get_name hello" { + panic(0) + } + + if c.Name() != "FooBar::get_name hello" { + panic(0) + } +} + +func main() { + f1() + f2() + f3() +} diff --git a/Examples/test-suite/go/director_profile_runme.go b/Examples/test-suite/go/director_profile_runme.go new file mode 100644 index 000000000..87edcbe26 --- /dev/null +++ b/Examples/test-suite/go/director_profile_runme.go @@ -0,0 +1,49 @@ +package main + +import "fmt" +import "./director_profile" + +type MyB struct{} // From director_profile.B +func (p *MyB) Vfi(a int) int { + return a + 3 +} + +func main() { + _ = director_profile.NewA() + myb := director_profile.NewDirectorB(&MyB{}) + b := director_profile.BGet_self(myb) + + fi := func(a int) int { + return b.Fi(a) + } + + i := 50000 + a := 1 + for i != 0 { + a = fi(a) // 1 + a = fi(a) // 2 + a = fi(a) // 3 + a = fi(a) // 4 + a = fi(a) // 5 + a = fi(a) // 6 + a = fi(a) // 7 + a = fi(a) // 8 + a = fi(a) // 9 + a = fi(a) // 10 + a = fi(a) // 1 + a = fi(a) // 2 + a = fi(a) // 3 + a = fi(a) // 4 + a = fi(a) // 5 + a = fi(a) // 6 + a = fi(a) // 7 + a = fi(a) // 8 + a = fi(a) // 9 + a = fi(a) // 20 + i -= 1 + } + + if false { + fmt.Println(a) + } +} diff --git a/Examples/test-suite/go/director_protected_runme.go b/Examples/test-suite/go/director_protected_runme.go new file mode 100644 index 000000000..3ffc1fbfa --- /dev/null +++ b/Examples/test-suite/go/director_protected_runme.go @@ -0,0 +1,48 @@ +package main + +import . "./director_protected" + +type FooBar struct{} // From Bar +func (p *FooBar) Ping() string { + return "FooBar::ping();" +} + +type FooBar2 struct{} // From Bar +func (p *FooBar2) Ping() string { + return "FooBar2::ping();" +} +func (p *FooBar2) Pang() string { + return "FooBar2::pang();" +} + +func main() { + b := NewBar() + f := b.Create() + fb := NewDirectorBar(&FooBar{}) + fb2 := NewDirectorBar(&FooBar2{}) + + s := fb.Used() + if s != "Foo::pang();Bar::pong();Foo::pong();FooBar::ping();" { + panic(0) + } + + s = fb2.Used() + if s != "FooBar2::pang();Bar::pong();Foo::pong();FooBar2::ping();" { + panic(0) + } + + s = b.Pong() + if s != "Bar::pong();Foo::pong();Bar::ping();" { + panic(0) + } + + s = f.Pong() + if s != "Bar::pong();Foo::pong();Bar::ping();" { + panic(0) + } + + s = fb.Pong() + if s != "Bar::pong();Foo::pong();FooBar::ping();" { + panic(0) + } +} diff --git a/Examples/test-suite/go/director_string_runme.go b/Examples/test-suite/go/director_string_runme.go new file mode 100644 index 000000000..c5201ab96 --- /dev/null +++ b/Examples/test-suite/go/director_string_runme.go @@ -0,0 +1,39 @@ +package main + +import . "./director_string" + +type B struct { // From A + abi A + smem string +} + +func NewB(s string) A { + p := &B{nil, ""} + ret := NewDirectorA(p, s) + p.abi = ret + return ret +} + +func (p *B) Get_first() string { + return DirectorAGet_first(p.abi) + " world!" +} + +func (p *B) Process_text(s string) { + DirectorAProcess_text(p.abi, s) + p.smem = "hello" +} + +func main() { + b := NewB("hello") + + b.Get(0) + if b.Get_first() != "hello world!" { + panic(b.Get_first()) + } + + b.Call_process_func() + + if b.DirectorInterface().(*B).smem != "hello" { + panic(b.DirectorInterface().(*B).smem) + } +} diff --git a/Examples/test-suite/go/director_thread_runme.go b/Examples/test-suite/go/director_thread_runme.go new file mode 100644 index 000000000..ddfacedbe --- /dev/null +++ b/Examples/test-suite/go/director_thread_runme.go @@ -0,0 +1,28 @@ +package main + +import . "./director_thread" + +type Derived struct { + abi Foo +} // From Foo +func (p *Derived) Do_foo() { + p.abi.SetVal(p.abi.GetVal() - 1) +} + +func main() { + + // FIXME: This test fails until we fix callbacks from a + // different thread. + return + + p := &Derived{nil} + d := NewDirectorFoo(p) + p.abi = d + d.Run() + + if d.GetVal() >= 0 { + panic(d.GetVal()) + } + + d.Stop() +} diff --git a/Examples/test-suite/go/director_unroll_runme.go b/Examples/test-suite/go/director_unroll_runme.go new file mode 100644 index 000000000..6d2894a72 --- /dev/null +++ b/Examples/test-suite/go/director_unroll_runme.go @@ -0,0 +1,21 @@ +package main + +import "./director_unroll" + +type MyFoo struct{} // From director_unroll.Foo +func (p *MyFoo) Ping() string { + return "MyFoo::ping()" +} + +func main() { + a := director_unroll.NewDirectorFoo(&MyFoo{}) + + b := director_unroll.NewBar() + + b.Set(a) + c := b.Get() + + if c.Ping() != "MyFoo::ping()" { + panic(c.Ping()) + } +} diff --git a/Examples/test-suite/go/disown_runme.go b/Examples/test-suite/go/disown_runme.go new file mode 100644 index 000000000..3e853de59 --- /dev/null +++ b/Examples/test-suite/go/disown_runme.go @@ -0,0 +1,10 @@ +package main + +import . "./disown" + +func main() { + a := NewA() + + b := NewB() + b.Acquire(a) +} diff --git a/Examples/test-suite/go/dynamic_cast_runme.go b/Examples/test-suite/go/dynamic_cast_runme.go new file mode 100644 index 000000000..476734805 --- /dev/null +++ b/Examples/test-suite/go/dynamic_cast_runme.go @@ -0,0 +1,16 @@ +package main + +import "./dynamic_cast" + +func main() { + f := dynamic_cast.NewFoo() + b := dynamic_cast.NewBar() + + _ = f.Blah() + y := b.Blah() + + a := dynamic_cast.Do_test(dynamic_cast.FooToBar(y)) + if a != "Bar::test" { + panic("Failed!!") + } +} diff --git a/Examples/test-suite/go/empty_runme.go b/Examples/test-suite/go/empty_runme.go new file mode 100644 index 000000000..f74285cb0 --- /dev/null +++ b/Examples/test-suite/go/empty_runme.go @@ -0,0 +1,6 @@ +package main + +import _ "./empty" + +func main() { +} diff --git a/Examples/test-suite/go/enum_template_runme.go b/Examples/test-suite/go/enum_template_runme.go new file mode 100644 index 000000000..269fe7d5b --- /dev/null +++ b/Examples/test-suite/go/enum_template_runme.go @@ -0,0 +1,11 @@ +package main + +import "./enum_template" + +func main() { + if enum_template.MakeETest() != 1 { + panic(0) + } + + enum_template.TakeETest(0) +} diff --git a/Examples/test-suite/go/enums_runme.go b/Examples/test-suite/go/enums_runme.go new file mode 100644 index 000000000..ab193f74b --- /dev/null +++ b/Examples/test-suite/go/enums_runme.go @@ -0,0 +1,25 @@ +package main + +import "./enums" + +func main() { + enums.Bar2(1) + enums.Bar3(1) + enums.Bar1(1) + + if enums.GetEnumInstance() != 2 { + panic(0) + } + + if enums.GetSlap() != 10 { + panic(0) + } + + if enums.GetMine() != 11 { + panic(0) + } + + if enums.GetThigh() != 12 { + panic(0) + } +} diff --git a/Examples/test-suite/go/exception_order_runme.go b/Examples/test-suite/go/exception_order_runme.go new file mode 100644 index 000000000..626a826f8 --- /dev/null +++ b/Examples/test-suite/go/exception_order_runme.go @@ -0,0 +1,58 @@ +package main + +import "strings" +import . "./exception_order" + +func main() { + a := NewA() + + func() { + defer func() { + e := recover() + if strings.Index(e.(string), "E1") == -1 { + panic(e.(string)) + } + }() + a.Foo() + }() + + func() { + defer func() { + e := recover() + if strings.Index(e.(string), "E2") == -1 { + panic(e.(string)) + } + }() + a.Bar() + }() + + func() { + defer func() { + e := recover() + if e.(string) != "postcatch unknown" { + panic("bad exception order") + } + }() + a.Foobar() + }() + + func() { + defer func() { + e := recover() + if strings.Index(e.(string), "E1") == -1 { + panic(e.(string)) + } + }() + a.Barfoo(1) + }() + + func() { + defer func() { + e := recover() + if strings.Index(e.(string), "E2") == -1 { + panic(e.(string)) + } + }() + a.Barfoo(2) + }() +} diff --git a/Examples/test-suite/go/extend_placement_runme.go b/Examples/test-suite/go/extend_placement_runme.go new file mode 100644 index 000000000..f74831c7d --- /dev/null +++ b/Examples/test-suite/go/extend_placement_runme.go @@ -0,0 +1,47 @@ +package main + +import "./extend_placement" + +func main() { + foo := extend_placement.NewFoo() + foo = extend_placement.NewFoo(1) + foo = extend_placement.NewFoo(1, 1) + foo.Spam() + foo.Spam("hello") + foo.Spam(1) + foo.Spam(1, 1) + foo.Spam(1, 1, 1) + foo.Spam(extend_placement.NewFoo()) + foo.Spam(extend_placement.NewFoo(), float64(1.0)) + + bar := extend_placement.NewBar() + bar = extend_placement.NewBar(1) + bar.Spam() + bar.Spam("hello") + bar.Spam(1) + bar.Spam(1, 1) + bar.Spam(1, 1, 1) + bar.Spam(extend_placement.NewBar()) + bar.Spam(extend_placement.NewBar(), float64(1.0)) + + footi := extend_placement.NewFooTi() + footi = extend_placement.NewFooTi(1) + footi = extend_placement.NewFooTi(1, 1) + footi.Spam() + footi.Spam("hello") + footi.Spam(1) + footi.Spam(1, 1) + footi.Spam(1, 1, 1) + footi.Spam(extend_placement.NewFoo()) + footi.Spam(extend_placement.NewFoo(), float64(1.0)) + + barti := extend_placement.NewBarTi() + barti = extend_placement.NewBarTi(1) + barti.Spam() + barti.Spam("hello") + barti.Spam(1) + barti.Spam(1, 1) + barti.Spam(1, 1, 1) + barti.Spam(extend_placement.NewBar()) + barti.Spam(extend_placement.NewBar(), float64(1.0)) +} diff --git a/Examples/test-suite/go/extend_template_ns_runme.go b/Examples/test-suite/go/extend_template_ns_runme.go new file mode 100644 index 000000000..164a31b26 --- /dev/null +++ b/Examples/test-suite/go/extend_template_ns_runme.go @@ -0,0 +1,14 @@ +package main + +import . "./extend_template_ns" + +func main() { + f := NewFoo_One() + if f.Test1(37) != 37 { + panic(0) + } + + if f.Test2(42) != 42 { + panic(0) + } +} diff --git a/Examples/test-suite/go/extend_template_runme.go b/Examples/test-suite/go/extend_template_runme.go new file mode 100644 index 000000000..5adb4b3c2 --- /dev/null +++ b/Examples/test-suite/go/extend_template_runme.go @@ -0,0 +1,14 @@ +package main + +import "./extend_template" + +func main() { + f := extend_template.NewFoo_0() + if f.Test1(37) != 37 { + panic(0) + } + + if f.Test2(42) != 42 { + panic(0) + } +} diff --git a/Examples/test-suite/go/extend_variable_runme.go b/Examples/test-suite/go/extend_variable_runme.go new file mode 100644 index 000000000..c6428c467 --- /dev/null +++ b/Examples/test-suite/go/extend_variable_runme.go @@ -0,0 +1,9 @@ +package main + +import . "./extend_variable" + +func main() { + if FooBar != 42 { + panic(0) + } +} diff --git a/Examples/test-suite/go/extern_c_runme.go b/Examples/test-suite/go/extern_c_runme.go new file mode 100644 index 000000000..0fb5b21cc --- /dev/null +++ b/Examples/test-suite/go/extern_c_runme.go @@ -0,0 +1,7 @@ +package main + +import "./extern_c" + +func main() { + extern_c.RealFunction(2) +} diff --git a/Examples/test-suite/go/friends_runme.go b/Examples/test-suite/go/friends_runme.go new file mode 100644 index 000000000..80177bae8 --- /dev/null +++ b/Examples/test-suite/go/friends_runme.go @@ -0,0 +1,50 @@ +package main + +import "./friends" + +func main() { + a := friends.NewA(2) + + if friends.Get_val1(a).(int) != 2 { + panic(0) + } + if friends.Get_val2(a) != 4 { + panic(0) + } + if friends.Get_val3(a) != 6 { + panic(0) + } + + // nice overload working fine + if friends.Get_val1(1, 2, 3).(int) != 1 { + panic(0) + } + + b := friends.NewB(3) + + // David's case + if friends.Mix(a, b) != 5 { + panic(0) + } + + di := friends.NewD_d(2) + dd := friends.NewD_d(3.3) + + // incredible template overloading working just fine + if friends.Get_val1(di).(float64) != 2 { + panic(0) + } + if friends.Get_val1(dd).(float64) != 3.3 { + panic(0) + } + + friends.Set(di, float64(4.0)) + friends.Set(dd, float64(1.3)) + + if friends.Get_val1(di).(float64) != 4 { + panic(0) + } + if friends.Get_val1(dd).(float64) != 1.3 { + panic(0) + } +} diff --git a/Examples/test-suite/go/fvirtual_runme.go b/Examples/test-suite/go/fvirtual_runme.go new file mode 100644 index 000000000..8810d5cbb --- /dev/null +++ b/Examples/test-suite/go/fvirtual_runme.go @@ -0,0 +1,13 @@ +package main + +import . "./fvirtual" + +func main() { + sw := NewNodeSwitch() + n := NewNode() + i := sw.AddChild(n) + + if i != 2 { + panic("addChild") + } +} diff --git a/Examples/test-suite/go/global_ns_arg_runme.go b/Examples/test-suite/go/global_ns_arg_runme.go new file mode 100644 index 000000000..f4c8a7ed5 --- /dev/null +++ b/Examples/test-suite/go/global_ns_arg_runme.go @@ -0,0 +1,8 @@ +package main + +import . "./global_ns_arg" + +func main() { + Foo(1) + Bar() +} diff --git a/Examples/test-suite/go/grouping_runme.go b/Examples/test-suite/go/grouping_runme.go new file mode 100644 index 000000000..c63d6fb12 --- /dev/null +++ b/Examples/test-suite/go/grouping_runme.go @@ -0,0 +1,19 @@ +package main + +import "./grouping" + +func main() { + x := grouping.Test1(42) + if x != 42 { + panic(0) + } + + grouping.Test2(42) + + x = grouping.Do_unary(37, grouping.NEGATE) + if x != -37 { + panic(0) + } + + grouping.SetTest3(42) +} diff --git a/Examples/test-suite/go/import_nomodule_runme.go b/Examples/test-suite/go/import_nomodule_runme.go new file mode 100644 index 000000000..a6bbd7de5 --- /dev/null +++ b/Examples/test-suite/go/import_nomodule_runme.go @@ -0,0 +1,12 @@ +package main + +import . "./import_nomodule" + +func main() { + f := Create_Foo() + Test1(f, 42) + Delete_Foo(f) + + b := NewBar() + Test1(b, 37) +} diff --git a/Examples/test-suite/go/imports_runme.go b/Examples/test-suite/go/imports_runme.go new file mode 100644 index 000000000..896036cbf --- /dev/null +++ b/Examples/test-suite/go/imports_runme.go @@ -0,0 +1,17 @@ +// This is the import runtime testcase. + +package main + +import "imports_b" +import "imports_a" + +func main() { + x := imports_b.NewB() + x.Hello() + + _ = imports_a.NewA() + + c := imports_b.NewC() + _ = c.Get_a(c) + _ = c.Get_a_type(c) +} diff --git a/Examples/test-suite/go/inctest_runme.go b/Examples/test-suite/go/inctest_runme.go new file mode 100644 index 000000000..f8a2c116c --- /dev/null +++ b/Examples/test-suite/go/inctest_runme.go @@ -0,0 +1,18 @@ +package main + +import "./inctest" + +func main() { + inctest.NewA() + inctest.NewB() + + // Check the import in subdirectory worked + if inctest.Importtest1(5) != 15 { + panic("import test 1 failed") + } + + a := []byte("black") + if inctest.Importtest2(string(a)) != "white" { + panic("import test 2 failed") + } +} diff --git a/Examples/test-suite/go/inherit_missing_runme.go b/Examples/test-suite/go/inherit_missing_runme.go new file mode 100644 index 000000000..ba9a2a516 --- /dev/null +++ b/Examples/test-suite/go/inherit_missing_runme.go @@ -0,0 +1,26 @@ +package main + +import "./inherit_missing" + +func main() { + a := inherit_missing.New_Foo() + b := inherit_missing.NewBar() + c := inherit_missing.NewSpam() + + x := inherit_missing.Do_blah(a) + if x != "Foo::blah" { + panic(x) + } + + x = inherit_missing.Do_blah(b) + if x != "Bar::blah" { + panic(x) + } + + x = inherit_missing.Do_blah(c) + if x != "Spam::blah" { + panic(x) + } + + inherit_missing.Delete_Foo(a) +} diff --git a/Examples/test-suite/go/input_runme.go b/Examples/test-suite/go/input_runme.go new file mode 100644 index 000000000..207bdaa28 --- /dev/null +++ b/Examples/test-suite/go/input_runme.go @@ -0,0 +1,14 @@ +package main + +import . "./input" + +func main() { + f := NewFoo() + if f.Foo(2) != 4 { + panic(0) + } + + if Sfoo("Hello") != "Hello world" { + panic(0) + } +} diff --git a/Examples/test-suite/go/keyword_rename_runme.go b/Examples/test-suite/go/keyword_rename_runme.go new file mode 100644 index 000000000..e36bc5968 --- /dev/null +++ b/Examples/test-suite/go/keyword_rename_runme.go @@ -0,0 +1,8 @@ +package main + +import "./keyword_rename" + +func main() { + keyword_rename.Xgo(1) + keyword_rename.Xchan(1) +} diff --git a/Examples/test-suite/go/li_attribute_runme.go b/Examples/test-suite/go/li_attribute_runme.go new file mode 100644 index 000000000..5d2c3d0c3 --- /dev/null +++ b/Examples/test-suite/go/li_attribute_runme.go @@ -0,0 +1,90 @@ +package main + +import "./li_attribute" + +func main() { + aa := li_attribute.NewA(1, 2, 3) + + if aa.GetA() != 1 { + panic(0) + } + aa.SetA(3) + if aa.GetA() != 3 { + panic(aa.GetA()) + } + + if aa.GetB() != 2 { + panic(aa.GetB()) + } + aa.SetB(5) + if aa.GetB() != 5 { + panic(0) + } + + if aa.GetD() != aa.GetB() { + panic(0) + } + + if aa.GetC() != 3 { + panic(0) + } + + pi := li_attribute.NewParam_i(7) + if pi.GetValue() != 7 { + panic(0) + } + pi.SetValue(3) + if pi.GetValue() != 3 { + panic(0) + } + + b := li_attribute.NewB(aa) + + if b.GetA().GetC() != 3 { + panic(0) + } + + // class/struct attribute with get/set methods using + // return/pass by reference + myFoo := li_attribute.NewMyFoo() + myFoo.SetX(8) + myClass := li_attribute.NewMyClass() + myClass.SetFoo(myFoo) + if myClass.GetFoo().GetX() != 8 { + panic(0) + } + + // class/struct attribute with get/set methods using + // return/pass by value + myClassVal := li_attribute.NewMyClassVal() + if myClassVal.GetReadWriteFoo().GetX() != -1 { + panic(0) + } + if myClassVal.GetReadOnlyFoo().GetX() != -1 { + panic(0) + } + myClassVal.SetReadWriteFoo(myFoo) + if myClassVal.GetReadWriteFoo().GetX() != 8 { + panic(0) + } + if myClassVal.GetReadOnlyFoo().GetX() != 8 { + panic(0) + } + + // string attribute with get/set methods using return/pass by + // value + myStringyClass := li_attribute.NewMyStringyClass("initial string") + if myStringyClass.GetReadWriteString() != "initial string" { + panic(0) + } + if myStringyClass.GetReadOnlyString() != "initial string" { + panic(0) + } + myStringyClass.SetReadWriteString("changed string") + if myStringyClass.GetReadWriteString() != "changed string" { + panic(0) + } + if myStringyClass.GetReadOnlyString() != "changed string" { + panic(0) + } +} diff --git a/Examples/test-suite/go/li_carrays_runme.go b/Examples/test-suite/go/li_carrays_runme.go new file mode 100644 index 000000000..0cbe92cd8 --- /dev/null +++ b/Examples/test-suite/go/li_carrays_runme.go @@ -0,0 +1,14 @@ +package main + +import . "./li_carrays" + +func main() { + d := NewDoubleArray(10) + + d.Setitem(0, 7) + d.Setitem(5, d.Getitem(0)+3) + + if d.Getitem(5)+d.Getitem(0) != 17 { + panic(0) + } +} diff --git a/Examples/test-suite/go/li_cdata_runme.go b/Examples/test-suite/go/li_cdata_runme.go new file mode 100644 index 000000000..f71a3a2c3 --- /dev/null +++ b/Examples/test-suite/go/li_cdata_runme.go @@ -0,0 +1,13 @@ +package main + +import . "./li_cdata" + +func main() { + s := "ABC abc" + m := Malloc(256) + Memmove(m, s, len(s)) + ss := Cdata(m, 7) + if string(ss) != "ABC abc" { + panic("failed") + } +} diff --git a/Examples/test-suite/go/li_cmalloc_runme.go b/Examples/test-suite/go/li_cmalloc_runme.go new file mode 100644 index 000000000..45f47b45f --- /dev/null +++ b/Examples/test-suite/go/li_cmalloc_runme.go @@ -0,0 +1,25 @@ +package main + +import . "./li_cmalloc" + +func main() { + p := Malloc_int() + Free_int(p) + + ok := false + func() { + defer func() { + if recover() != nil { + ok = true + } + }() + p = Calloc_int(-1) + if p == nil { + ok = true + } + Free_int(p) + }() + if !ok { + panic(0) + } +} diff --git a/Examples/test-suite/go/li_cpointer_runme.go b/Examples/test-suite/go/li_cpointer_runme.go new file mode 100644 index 000000000..57493b122 --- /dev/null +++ b/Examples/test-suite/go/li_cpointer_runme.go @@ -0,0 +1,14 @@ +package main + +import . "./li_cpointer" + +func main() { + p := New_intp() + Intp_assign(p, 3) + + if Intp_value(p) != 3 { + panic(0) + } + + Delete_intp(p) +} diff --git a/Examples/test-suite/go/li_std_map_runme.go b/Examples/test-suite/go/li_std_map_runme.go new file mode 100644 index 000000000..66e74dd60 --- /dev/null +++ b/Examples/test-suite/go/li_std_map_runme.go @@ -0,0 +1,30 @@ +package main + +import "./li_std_map" + +func main() { + a1 := li_std_map.NewA(3) + a2 := li_std_map.NewA(7) + + _ = li_std_map.NewPairii(1, 2) + p1 := li_std_map.NewPairA(1, a1) + m := li_std_map.NewMapA() + m.Set(1, a1) + m.Set(2, a2) + + _ = li_std_map.P_identa(p1) + _ = li_std_map.M_identa(m) + + m = li_std_map.NewMapA() + m.Set(1, a1) + m.Set(2, a2) + + mii := li_std_map.NewIntIntMap() + + mii.Set(1, 1) + mii.Set(1, 2) + + if mii.Get(1) != 2 { + panic(0) + } +} diff --git a/Examples/test-suite/go/member_pointer_runme.go b/Examples/test-suite/go/member_pointer_runme.go new file mode 100644 index 000000000..9a55bc4b9 --- /dev/null +++ b/Examples/test-suite/go/member_pointer_runme.go @@ -0,0 +1,49 @@ +// Example using pointers to member functions + +package main + +import "fmt" +import . "./member_pointer" + +func check(what string, expected float64, actual float64) { + if expected != actual { + panic(fmt.Sprintf("Failed: %s Expected: %f Actual; %f", what, expected, actual)) + } +} + +func main() { + // Get the pointers + + area_pt := Areapt() + perim_pt := Perimeterpt() + + // Create some objects + + s := NewSquare(10) + + // Do some calculations + + check("Square area ", 100.0, Do_op(s, area_pt)) + check("Square perim", 40.0, Do_op(s, perim_pt)) + + _ = GetAreavar() + _ = GetPerimetervar() + + // Try the variables + check("Square area ", 100.0, Do_op(s, GetAreavar())) + check("Square perim", 40.0, Do_op(s, GetPerimetervar())) + + // Modify one of the variables + SetAreavar(perim_pt) + + check("Square perimeter", 40.0, Do_op(s, GetAreavar())) + + // Try the constants + + _ = AREAPT + _ = PERIMPT + _ = NULLPT + + check("Square area ", 100.0, Do_op(s, AREAPT)) + check("Square perim", 40.0, Do_op(s, PERIMPT)) +} diff --git a/Examples/test-suite/go/memberin_extend_c_runme.go b/Examples/test-suite/go/memberin_extend_c_runme.go new file mode 100644 index 000000000..ec8b11e60 --- /dev/null +++ b/Examples/test-suite/go/memberin_extend_c_runme.go @@ -0,0 +1,11 @@ +package main + +import "./memberin_extend_c" + +func main() { + t := memberin_extend_c.NewPerson() + t.SetName("Fred Bloggs") + if t.GetName() != "FRED BLOGGS" { + panic("name wrong") + } +} diff --git a/Examples/test-suite/go/minherit_runme.go b/Examples/test-suite/go/minherit_runme.go new file mode 100644 index 000000000..c69fe92c1 --- /dev/null +++ b/Examples/test-suite/go/minherit_runme.go @@ -0,0 +1,82 @@ +package main + +import "fmt" +import "./minherit" + +func main() { + a := minherit.NewFoo() + b := minherit.NewBar() + c := minherit.NewFooBar() + d := minherit.NewSpam() + + if a.Xget() != 1 { + panic("1 Bad attribute value") + } + + if b.Yget() != 2 { + panic("2 Bad attribute value") + } + + if c.Xget() != 1 || c.Yget() != 2 || c.Zget() != 3 { + panic("3 Bad attribute value") + } + + if d.Xget() != 1 || d.Yget() != 2 || d.Zget() != 3 || d.Wget() != 4 { + panic("4 Bad attribute value") + } + + if minherit.Xget(a) != 1 { + panic(fmt.Sprintf("5 Bad attribute value %d", minherit.Xget(a))) + } + + if minherit.Yget(b) != 2 { + panic(fmt.Sprintf("6 Bad attribute value %d", minherit.Yget(b))) + } + + if minherit.Xget(c) != 1 || minherit.Yget(c.SwigGetBar()) != 2 || minherit.Zget(c) != 3 { + panic(fmt.Sprintf("7 Bad attribute value %d %d %d", minherit.Xget(c), minherit.Yget(c.SwigGetBar()), minherit.Zget(c))) + } + + if minherit.Xget(d) != 1 || minherit.Yget(d.SwigGetBar()) != 2 || minherit.Zget(d) != 3 || minherit.Wget(d) != 4 { + panic(fmt.Sprintf("8 Bad attribute value %d %d %d %d", minherit.Xget(d), minherit.Yget(d.SwigGetBar()), minherit.Zget(d), minherit.Wget(d))) + } + + // Cleanse all of the pointers and see what happens + + aa := minherit.ToFooPtr(a) + bb := minherit.ToBarPtr(b) + cc := minherit.ToFooBarPtr(c) + dd := minherit.ToSpamPtr(d) + + if aa.Xget() != 1 { + panic("9 Bad attribute value") + } + + if bb.Yget() != 2 { + panic("10 Bad attribute value") + } + + if cc.Xget() != 1 || cc.Yget() != 2 || cc.Zget() != 3 { + panic("11 Bad attribute value") + } + + if dd.Xget() != 1 || dd.Yget() != 2 || dd.Zget() != 3 || dd.Wget() != 4 { + panic("12 Bad attribute value") + } + + if minherit.Xget(aa) != 1 { + panic(fmt.Sprintf("13 Bad attribute value %d", minherit.Xget(aa))) + } + + if minherit.Yget(bb) != 2 { + panic(fmt.Sprintf("14 Bad attribute value %d", minherit.Yget(bb))) + } + + if minherit.Xget(cc) != 1 || minherit.Yget(cc.SwigGetBar()) != 2 || minherit.Zget(cc) != 3 { + panic(fmt.Sprintf("15 Bad attribute value %d %d %d", minherit.Xget(cc), minherit.Yget(cc.SwigGetBar()), minherit.Zget(cc))) + } + + if minherit.Xget(dd) != 1 || minherit.Yget(dd.SwigGetBar()) != 2 || minherit.Zget(dd) != 3 || minherit.Wget(dd) != 4 { + panic(fmt.Sprintf("16 Bad attribute value %d %d %d %d", minherit.Xget(dd), minherit.Yget(dd.SwigGetBar()), minherit.Zget(dd), minherit.Wget(dd))) + } +} diff --git a/Examples/test-suite/go/mod_runme.go b/Examples/test-suite/go/mod_runme.go new file mode 100644 index 000000000..581c83918 --- /dev/null +++ b/Examples/test-suite/go/mod_runme.go @@ -0,0 +1,10 @@ +package main + +import "mod_a" +import "mod_b" + +func main() { + c := mod_b.NewC() + d := mod_b.NewD() + d.DoSomething(mod_a.SwigcptrA(c.Swigcptr())) +} diff --git a/Examples/test-suite/go/multi_import_runme.go b/Examples/test-suite/go/multi_import_runme.go new file mode 100644 index 000000000..973af1e7b --- /dev/null +++ b/Examples/test-suite/go/multi_import_runme.go @@ -0,0 +1,29 @@ +package main + +import "multi_import_a" +import "multi_import_b" + +func main() { + x := multi_import_b.NewXXX() + if x.Testx() != 0 { + panic(0) + } + + y := multi_import_b.NewYYY() + if y.Testx() != 0 { + panic(0) + } + if y.Testy() != 1 { + panic(0) + } + + z := multi_import_a.NewZZZ() + if z.Testx() != 0 { + println("z.Testx", z.Testx(), z.Testz()) + panic(0) + } + if z.Testz() != 2 { + println("z.Testz", z.Testz()) + panic(0) + } +} diff --git a/Examples/test-suite/go/namespace_class_runme.go b/Examples/test-suite/go/namespace_class_runme.go new file mode 100644 index 000000000..2ed5567f7 --- /dev/null +++ b/Examples/test-suite/go/namespace_class_runme.go @@ -0,0 +1,19 @@ +package main + +import . "./namespace_class" + +func main() { + EulerT3DToFrame(1, 1, 1) + + _ = NewBooT_i() + _ = NewBooT_H() + + f1 := NewFooT_i() + f1.Quack(1) + + f2 := NewFooT_d() + f2.Moo(1) + + f3 := NewFooT_H() + f3.Foo(Hi) +} diff --git a/Examples/test-suite/go/namespace_typemap_runme.go b/Examples/test-suite/go/namespace_typemap_runme.go new file mode 100644 index 000000000..95311a37a --- /dev/null +++ b/Examples/test-suite/go/namespace_typemap_runme.go @@ -0,0 +1,116 @@ +package main + +import . "./namespace_typemap" + +func main() { + if Stest1("hello") != "hello" { + panic(0) + } + + if Stest2("hello") != "hello" { + panic(0) + } + + if Stest3("hello") != "hello" { + panic(0) + } + + if Stest4("hello") != "hello" { + panic(0) + } + + if Stest5("hello") != "hello" { + panic(0) + } + + if Stest6("hello") != "hello" { + panic(0) + } + + if Stest7("hello") != "hello" { + panic(0) + } + + if Stest8("hello") != "hello" { + panic(0) + } + + if Stest9("hello") != "hello" { + panic(0) + } + + if Stest10("hello") != "hello" { + panic(0) + } + + if Stest11("hello") != "hello" { + panic(0) + } + + if Stest12("hello") != "hello" { + panic(0) + } + + c := cmplx(float64(2), float64(3)) + r := real(c) + + if Ctest1(c) != r { + println(Ctest1(c)) + panic(Ctest1(c)) + } + + if Ctest2(c) != r { + panic(0) + } + + if Ctest3(c) != r { + panic(0) + } + + if Ctest4(c) != r { + panic(0) + } + + if Ctest5(c) != r { + panic(0) + } + + if Ctest6(c) != r { + panic(0) + } + + if Ctest7(c) != r { + panic(0) + } + + if Ctest8(c) != r { + panic(0) + } + + if Ctest9(c) != r { + panic(0) + } + + if Ctest10(c) != r { + panic(0) + } + + if Ctest11(c) != r { + panic(0) + } + + if Ctest12(c) != r { + panic(0) + } + + ok := false + func() { + defer func() { + ok = recover() != nil + }() + Ttest1(-14) + }() + if !ok { + panic(0) + } +} diff --git a/Examples/test-suite/go/namespace_virtual_method_runme.go b/Examples/test-suite/go/namespace_virtual_method_runme.go new file mode 100644 index 000000000..3f8e774c6 --- /dev/null +++ b/Examples/test-suite/go/namespace_virtual_method_runme.go @@ -0,0 +1,7 @@ +package main + +import "./namespace_virtual_method" + +func main() { + _ = namespace_virtual_method.NewSpam() +} diff --git a/Examples/test-suite/go/naturalvar_runme.go b/Examples/test-suite/go/naturalvar_runme.go new file mode 100644 index 000000000..e3723e6ab --- /dev/null +++ b/Examples/test-suite/go/naturalvar_runme.go @@ -0,0 +1,17 @@ +package main + +import . "./naturalvar" + +func main() { + f := NewFoo() + b := NewBar() + + b.SetF(f) + + SetS("hello") + b.SetS("hello") + + if b.GetS() != GetS() { + panic(0) + } +} diff --git a/Examples/test-suite/go/nested_workaround_runme.go b/Examples/test-suite/go/nested_workaround_runme.go new file mode 100644 index 000000000..5737aaaf7 --- /dev/null +++ b/Examples/test-suite/go/nested_workaround_runme.go @@ -0,0 +1,19 @@ +package main + +import . "./nested_workaround" + +func main() { + inner := NewInner(5) + outer := NewOuter() + newInner := outer.DoubleInnerValue(inner) + if newInner.GetValue() != 10 { + panic(0) + } + + outer = NewOuter() + inner = outer.CreateInner(3) + newInner = outer.DoubleInnerValue(inner) + if outer.GetInnerValue(newInner) != 6 { + panic(0) + } +} diff --git a/Examples/test-suite/go/overload_complicated_runme.go b/Examples/test-suite/go/overload_complicated_runme.go new file mode 100644 index 000000000..e3911c218 --- /dev/null +++ b/Examples/test-suite/go/overload_complicated_runme.go @@ -0,0 +1,62 @@ +package main + +import . "./overload_complicated" + +func main() { + var pInt *int + + // Check the correct constructors are available + p := NewPop(pInt) + + p = NewPop(pInt, false) + + // Check overloaded in const only and pointers/references + // which target languages cannot disambiguate + if p.Hip(false) != 701 { + panic("Test 1 failed") + } + + if p.Hip(pInt) != 702 { + panic("Test 2 failed") + } + + // Reverse the order for the above + if p.Hop(pInt) != 805 { + panic("Test 3 failed") + } + + if p.Hop(false) != 801 { + panic("Test 4 failed") + } + + // Few more variations and order shuffled + if p.Pop(false) != 901 { + panic("Test 5 failed") + } + + if p.Pop(pInt) != 902 { + panic("Test 6 failed") + } + + if p.Pop() != 905 { + panic("Test 7 failed") + } + + // Overload on const only + if p.Bop(pInt) != 1001 { + panic("Test 8 failed") + } + + if p.Bip(pInt) != 2001 { + panic("Test 9 failed") + } + + // Globals + if Muzak(false) != 3001 { + panic("Test 10 failed") + } + + if Muzak(pInt) != 3002 { + panic("Test 11 failed") + } +} diff --git a/Examples/test-suite/go/overload_copy_runme.go b/Examples/test-suite/go/overload_copy_runme.go new file mode 100644 index 000000000..d35ff70b1 --- /dev/null +++ b/Examples/test-suite/go/overload_copy_runme.go @@ -0,0 +1,8 @@ +package main + +import . "./overload_copy" + +func main() { + f := NewFoo() + _ = NewFoo(f) +} diff --git a/Examples/test-suite/go/overload_extend_runme.go b/Examples/test-suite/go/overload_extend_runme.go new file mode 100644 index 000000000..228dfe89c --- /dev/null +++ b/Examples/test-suite/go/overload_extend_runme.go @@ -0,0 +1,22 @@ +package main + +import "./overload_extend" + +func main() { + f := overload_extend.NewFoo() + if f.Test().(int) != 0 { + panic(0) + } + if f.Test(3).(int) != 1 { + panic(0) + } + if f.Test("hello").(int) != 2 { + panic(0) + } + if f.Test(float64(3), float64(2)).(float64) != 5 { + panic(0) + } + if f.Test(float64(3.0)).(float64) != 1003 { + panic(0) + } +} diff --git a/Examples/test-suite/go/overload_extendc_runme.go b/Examples/test-suite/go/overload_extendc_runme.go new file mode 100644 index 000000000..aec8935f5 --- /dev/null +++ b/Examples/test-suite/go/overload_extendc_runme.go @@ -0,0 +1,33 @@ +package main + +import "./overload_extendc" + +func main() { + f := overload_extendc.NewFoo() + if f.Test(3) != 1 { + panic(0) + } + if f.Test("hello") != 2 { + panic(0) + } + if f.Test(float64(3.5), float64(2.5)) != 3 { + panic(0) + } + if f.Test("hello", 20) != 1020 { + panic(0) + } + if f.Test("hello", 20, 100) != 120 { + panic(0) + } + + // C default args + if f.Test(f) != 30 { + panic(0) + } + if f.Test(f, 100) != 120 { + panic(0) + } + if f.Test(f, 100, 200) != 300 { + panic(0) + } +} diff --git a/Examples/test-suite/go/overload_rename_runme.go b/Examples/test-suite/go/overload_rename_runme.go new file mode 100644 index 000000000..dca5843c3 --- /dev/null +++ b/Examples/test-suite/go/overload_rename_runme.go @@ -0,0 +1,10 @@ +package main + +import "./overload_rename" + +func main() { + _ = overload_rename.NewFoo(float32(1)) + _ = overload_rename.NewFoo(float32(1), float32(1)) + _ = overload_rename.NewFoo_int(float32(1), 1) + _ = overload_rename.NewFoo_int(float32(1), 1, float32(1)) +} diff --git a/Examples/test-suite/go/overload_simple_runme.go b/Examples/test-suite/go/overload_simple_runme.go new file mode 100644 index 000000000..58fe46dab --- /dev/null +++ b/Examples/test-suite/go/overload_simple_runme.go @@ -0,0 +1,125 @@ +package main + +import . "./overload_simple" + +func main() { + if Foofn(3) != "foo:int" { + panic("foo(int)") + } + + if Foofn(float64(3.0)) != "foo:double" { + panic("foo(double)") + } + + if Foofn("hello") != "foo:char *" { + panic("foo(char *)") + } + + f := NewFoo() + b := NewBar() + + if Foofn(f) != "foo:Foo *" { + panic("foo(Foo *)") + } + + if Foofn(b) != "foo:Bar *" { + panic("foo(Bar *)") + } + + v := Malloc_void(32) + + if Foofn(v) != "foo:void *" { + panic("foo(void *)") + } + s := NewSpam() + + if s.Foofn(3) != "foo:int" { + panic("Spam::foo(int)") + } + + if s.Foofn(float64(3.0)) != "foo:double" { + panic("Spam::foo(double)") + } + + if s.Foofn("hello") != "foo:char *" { + panic("Spam::foo(char *)") + } + + if s.Foofn(f) != "foo:Foo *" { + panic("Spam::foo(Foo *)") + } + + if s.Foofn(b) != "foo:Bar *" { + panic("Spam::foo(Bar *)") + } + + if s.Foofn(v) != "foo:void *" { + panic("Spam::foo(void *)") + } + + if SpamBar(3) != "bar:int" { + panic("Spam::bar(int)") + } + + if SpamBar(float64(3.0)) != "bar:double" { + panic("Spam::bar(double)") + } + + if SpamBar("hello") != "bar:char *" { + panic("Spam::bar(char *)") + } + + if SpamBar(f) != "bar:Foo *" { + panic("Spam::bar(Foo *)") + } + + if SpamBar(b) != "bar:Bar *" { + panic("Spam::bar(Bar *)") + } + + if SpamBar(v) != "bar:void *" { + panic("Spam::bar(void *)") + } + + // Test constructors + + s = NewSpam() + if s.GetXtype() != "none" { + panic("Spam()") + } + + s = NewSpam(3) + if s.GetXtype() != "int" { + panic("Spam(int)") + } + + s = NewSpam(float64(3.4)) + if s.GetXtype() != "double" { + panic("Spam(double)") + } + + s = NewSpam("hello") + if s.GetXtype() != "char *" { + panic("Spam(char *)") + } + + s = NewSpam(f) + if s.GetXtype() != "Foo *" { + panic("Spam(Foo *)") + } + + s = NewSpam(b) + if s.GetXtype() != "Bar *" { + panic("Spam(Bar *)") + } + + s = NewSpam(v) + if s.GetXtype() != "void *" { + panic("Spam(void *)") + } + + Free_void(v) + + a := NewClassA() + _ = a.Method1(1) +} diff --git a/Examples/test-suite/go/overload_subtype_runme.go b/Examples/test-suite/go/overload_subtype_runme.go new file mode 100644 index 000000000..dc56d1ca7 --- /dev/null +++ b/Examples/test-suite/go/overload_subtype_runme.go @@ -0,0 +1,16 @@ +package main + +import . "./overload_subtype" + +func main() { + f := NewFoo() + b := NewBar() + + if Spam(f) != 1 { + panic("foo") + } + + if Spam(b) != 2 { + panic("bar") + } +} diff --git a/Examples/test-suite/go/overload_template_fast_runme.go b/Examples/test-suite/go/overload_template_fast_runme.go new file mode 100644 index 000000000..8fc7c364c --- /dev/null +++ b/Examples/test-suite/go/overload_template_fast_runme.go @@ -0,0 +1,187 @@ +package main + +import . "./overload_template_fast" + +func main() { + _ = Foo() + + _ = Maximum(3, 4) + _ = Maximum(float64(3.4), float64(5.2)) + + // mix 1 + if Mix1("hi") != 101 { + panic("mix1(const char*)") + } + + if Mix1(float64(1.0), float64(1.0)) != 102 { + panic("mix1(double, const double &)") + } + + if Mix1(float64(1.0)) != 103 { + panic("mix1(double)") + } + + // mix 2 + if Mix2("hi") != 101 { + panic("mix2(const char*)") + } + + if Mix2(float64(1.0), float64(1.0)) != 102 { + panic("mix2(double, const double &)") + } + + if Mix2(float64(1.0)) != 103 { + panic("mix2(double)") + } + + // mix 3 + if Mix3("hi") != 101 { + panic("mix3(const char*)") + } + + if Mix3(float64(1.0), float64(1.0)) != 102 { + panic("mix3(double, const double &)") + } + + if Mix3(float64(1.0)) != 103 { + panic("mix3(double)") + } + + // Combination 1 + if Overtparams1(100) != 10 { + panic("overtparams1(int)") + } + + if Overtparams1(float64(100.0), 100) != 20 { + panic("overtparams1(double, int)") + } + + // Combination 2 + if Overtparams2(float64(100.0), 100) != 40 { + panic("overtparams2(double, int)") + } + + // Combination 3 + if Overloaded() != 60 { + panic("overloaded()") + } + + if Overloaded(float64(100.0), 100) != 70 { + panic("overloaded(double, int)") + } + + // Combination 4 + if Overloadedagain("hello") != 80 { + panic("overloadedagain(const char *)") + } + + if Overloadedagain() != 90 { + panic("overloadedagain(double)") + } + + // specializations + if Specialization(10) != 202 { + panic("specialization(int)") + } + + if Specialization(float64(10.0)) != 203 { + panic("specialization(double)") + } + + if Specialization(10, 10) != 204 { + panic("specialization(int, int)") + } + + if Specialization(float64(10.0), float64(10.0)) != 205 { + panic("specialization(double, double)") + } + + if Specialization("hi", "hi") != 201 { + panic("specialization(const char *, const char *)") + } + + // simple specialization + Xyz() + Xyz_int() + Xyz_double() + + // a bit of everything + if Overload("hi") != 0 { + panic("overload()") + } + + if Overload(1) != 10 { + panic("overload(int t)") + } + + if Overload(1, 1) != 20 { + panic("overload(int t, const int &)") + } + + if Overload(1, "hello") != 30 { + panic("overload(int t, const char *)") + } + + k := NewKlass() + if Overload(k) != 10 { + panic("overload(Klass t)") + } + + if Overload(k, k) != 20 { + panic("overload(Klass t, const Klass &)") + } + + if Overload(k, "hello") != 30 { + panic("overload(Klass t, const char *)") + } + + if Overload(float64(10.0), "hi") != 40 { + panic("overload(double t, const char *)") + } + + if Overload() != 50 { + panic("overload(const char *)") + } + + + // everything put in a namespace + if Nsoverload("hi") != 1000 { + panic("nsoverload()") + } + + if Nsoverload(1) != 1010 { + panic("nsoverload(int t)") + } + + if Nsoverload(1, 1) != 1020 { + panic("nsoverload(int t, const int &)") + } + + if Nsoverload(1, "hello") != 1030 { + panic("nsoverload(int t, const char *)") + } + + if Nsoverload(k) != 1010 { + panic("nsoverload(Klass t)") + } + + if Nsoverload(k, k) != 1020 { + panic("nsoverload(Klass t, const Klass &)") + } + + if Nsoverload(k, "hello") != 1030 { + panic("nsoverload(Klass t, const char *)") + } + + if Nsoverload(float64(10.0), "hi") != 1040 { + panic("nsoverload(double t, const char *)") + } + + if Nsoverload() != 1050 { + panic("nsoverload(const char *)") + } + + AFoo(1) + b := NewB() + b.Foo(1) +} diff --git a/Examples/test-suite/go/overload_template_runme.go b/Examples/test-suite/go/overload_template_runme.go new file mode 100644 index 000000000..124402f37 --- /dev/null +++ b/Examples/test-suite/go/overload_template_runme.go @@ -0,0 +1,188 @@ +package main + +import . "./overload_template" + +func main() { + _ = Foo() + + _ = Maximum(3, 4) + _ = Maximum(float64(3.4), float64(5.2)) + + // mix 1 + if Mix1("hi") != 101 { + panic("mix1(const char*)") + } + + if Mix1(float64(1.0), float64(1.0)) != 102 { + panic("mix1(double, const double &)") + } + + if Mix1(float64(1.0)) != 103 { + panic("mix1(double)") + } + + // mix 2 + if Mix2("hi") != 101 { + panic("mix2(const char*)") + } + + if Mix2(float64(1.0), float64(1.0)) != 102 { + panic("mix2(double, const double &)") + } + + if Mix2(float64(1.0)) != 103 { + panic("mix2(double)") + } + + // mix 3 + if Mix3("hi") != 101 { + panic("mix3(const char*)") + } + + if Mix3(float64(1.0), float64(1.0)) != 102 { + panic("mix3(double, const double &)") + } + + if Mix3(float64(1.0)) != 103 { + panic("mix3(double)") + } + + // Combination 1 + if Overtparams1(100) != 10 { + panic("overtparams1(int)") + } + + if Overtparams1(float64(100.0), 100) != 20 { + panic("overtparams1(double, int)") + } + + // Combination 2 + if Overtparams2(float64(100.0), 100) != 40 { + panic("overtparams2(double, int)") + } + + // Combination 3 + if Overloaded() != 60 { + panic("overloaded()") + } + + if Overloaded(float64(100.0), 100) != 70 { + panic("overloaded(double, int)") + } + + // Combination 4 + if Overloadedagain("hello") != 80 { + panic("overloadedagain(const char *)") + } + + if Overloadedagain() != 90 { + panic("overloadedagain(double)") + } + + // specializations + if Specialization(10) != 202 { + panic("specialization(int)") + } + + if Specialization(float64(10.0)) != 203 { + panic("specialization(double)") + } + + if Specialization(10, 10) != 204 { + panic("specialization(int, int)") + } + + if Specialization(float64(10.0), float64(10.0)) != 205 { + panic("specialization(double, double)") + } + + if Specialization("hi", "hi") != 201 { + panic("specialization(const char *, const char *)") + } + + + // simple specialization + Xyz() + Xyz_int() + Xyz_double() + + // a bit of everything + if Overload("hi") != 0 { + panic("overload()") + } + + if Overload(1) != 10 { + panic("overload(int t)") + } + + if Overload(1, 1) != 20 { + panic("overload(int t, const int &)") + } + + if Overload(1, "hello") != 30 { + panic("overload(int t, const char *)") + } + + k := NewKlass() + if Overload(k) != 10 { + panic("overload(Klass t)") + } + + if Overload(k, k) != 20 { + panic("overload(Klass t, const Klass &)") + } + + if Overload(k, "hello") != 30 { + panic("overload(Klass t, const char *)") + } + + if Overload(float64(10.0), "hi") != 40 { + panic("overload(double t, const char *)") + } + + if Overload() != 50 { + panic("overload(const char *)") + } + + + // everything put in a namespace + if Nsoverload("hi") != 1000 { + panic("nsoverload()") + } + + if Nsoverload(1) != 1010 { + panic("nsoverload(int t)") + } + + if Nsoverload(1, 1) != 1020 { + panic("nsoverload(int t, const int &)") + } + + if Nsoverload(1, "hello") != 1030 { + panic("nsoverload(int t, const char *)") + } + + if Nsoverload(k) != 1010 { + panic("nsoverload(Klass t)") + } + + if Nsoverload(k, k) != 1020 { + panic("nsoverload(Klass t, const Klass &)") + } + + if Nsoverload(k, "hello") != 1030 { + panic("nsoverload(Klass t, const char *)") + } + + if Nsoverload(float64(10.0), "hi") != 1040 { + panic("nsoverload(double t, const char *)") + } + + if Nsoverload() != 1050 { + panic("nsoverload(const char *)") + } + + AFoo(1) + b := NewB() + b.Foo(1) +} diff --git a/Examples/test-suite/go/preproc_runme.go b/Examples/test-suite/go/preproc_runme.go new file mode 100644 index 000000000..a15062241 --- /dev/null +++ b/Examples/test-suite/go/preproc_runme.go @@ -0,0 +1,21 @@ +package main + +import "./preproc" + +func main() { + if preproc.GetEndif() != 1 { + panic(0) + } + + if preproc.GetDefine() != 1 { + panic(0) + } + + if preproc.GetDefined() != 1 { + panic(0) + } + + if 2*preproc.One != preproc.Two { + panic(0) + } +} diff --git a/Examples/test-suite/go/primitive_ref_runme.go b/Examples/test-suite/go/primitive_ref_runme.go new file mode 100644 index 000000000..973806955 --- /dev/null +++ b/Examples/test-suite/go/primitive_ref_runme.go @@ -0,0 +1,57 @@ +package main + +import . "./primitive_ref" + +func main() { + if Ref_int(3) != 3 { + panic(0) + } + + if Ref_uint(3) != 3 { + panic(0) + } + + if Ref_short(3) != 3 { + panic(0) + } + + if Ref_ushort(3) != 3 { + panic(0) + } + + if Ref_long(3) != 3 { + panic(0) + } + + if Ref_ulong(3) != 3 { + panic(0) + } + + if Ref_schar(3) != 3 { + panic(0) + } + + if Ref_uchar(3) != 3 { + panic(0) + } + + if Ref_float(3.5) != 3.5 { + panic(0) + } + + if Ref_double(3.5) != 3.5 { + panic(0) + } + + if Ref_bool(true) != true { + panic(0) + } + + if Ref_char('x') != 'x' { + panic(0) + } + + if Ref_over(0) != 0 { + panic(0) + } +} diff --git a/Examples/test-suite/go/profiletest_runme.go b/Examples/test-suite/go/profiletest_runme.go new file mode 100644 index 000000000..30b6cee69 --- /dev/null +++ b/Examples/test-suite/go/profiletest_runme.go @@ -0,0 +1,38 @@ +package main + +import "fmt" +import "./profiletest" + +func main() { + a := profiletest.NewA() + if false { + fmt.Println(a) + } + + b := profiletest.NewB() + fn := func(a profiletest.A) profiletest.A { return b.Fn(a) } + i := 50000 + for i != 0 { + a = fn(a) //1 + a = fn(a) //2 + a = fn(a) //3 + a = fn(a) //4 + a = fn(a) //5 + a = fn(a) //6 + a = fn(a) //7 + a = fn(a) //8 + a = fn(a) //9 + a = fn(a) //10 + a = fn(a) //1 + a = fn(a) //2 + a = fn(a) //3 + a = fn(a) //4 + a = fn(a) //5 + a = fn(a) //6 + a = fn(a) //7 + a = fn(a) //8 + a = fn(a) //9 + a = fn(a) //20 + i -= 1 + } +} diff --git a/Examples/test-suite/go/refcount_runme.go b/Examples/test-suite/go/refcount_runme.go new file mode 100644 index 000000000..fdb271cc6 --- /dev/null +++ b/Examples/test-suite/go/refcount_runme.go @@ -0,0 +1,32 @@ +package main + +import . "./refcount" + +// very innocent example + +func main() { + a := NewA3() + _ = NewB(a) + b2 := BCreate(a) + + if a.Ref_count() != 3 { + panic("This program will crash... now") + } + + rca := b2.Get_rca() + // _ = BCreate(rca) + _ = rca + + if a.Ref_count() != 4 { + panic("This program will crash... now") + } + + /* Requires smart pointer support. + v := NewVector_A(2) + v.Set(0, a) + v.Set(1, a) + + _ = v.Get(0) + DeleteVector_A(v) + */ +} diff --git a/Examples/test-suite/go/reference_global_vars_runme.go b/Examples/test-suite/go/reference_global_vars_runme.go new file mode 100644 index 000000000..b8cbb304a --- /dev/null +++ b/Examples/test-suite/go/reference_global_vars_runme.go @@ -0,0 +1,98 @@ +package main + +import . "./reference_global_vars" + +func main() { + // const class reference variable + if GetconstTC().GetNum() != 33 { + panic(0) + } + + // primitive reference variables + SetVar_bool(Createref_bool(false)) + if Value_bool(GetVar_bool()) != false { + println(1, GetVar_bool(), Value_bool(GetVar_bool())) + panic(0) + } + + SetVar_bool(Createref_bool(true)) + if Value_bool(GetVar_bool()) != true { + println(2, GetVar_bool(), Value_bool(GetVar_bool())) + panic(0) + } + + SetVar_char(Createref_char('w')) + if Value_char(GetVar_char()) != 'w' { + println(3, GetVar_char(), Value_char(GetVar_char())) + panic(0) + } + + SetVar_unsigned_char(Createref_unsigned_char(10)) + if Value_unsigned_char(GetVar_unsigned_char()) != 10 { + println(4, GetVar_unsigned_char(), Value_unsigned_char(GetVar_unsigned_char())) + panic(0) + } + + SetVar_signed_char(Createref_signed_char(10)) + if Value_signed_char(GetVar_signed_char()) != 10 { + panic(0) + } + + SetVar_short(Createref_short(10)) + if Value_short(GetVar_short()) != 10 { + panic(0) + } + + SetVar_unsigned_short(Createref_unsigned_short(10)) + if Value_unsigned_short(GetVar_unsigned_short()) != 10 { + panic(0) + } + + SetVar_int(Createref_int(10)) + if Value_int(GetVar_int()) != 10 { + panic(0) + } + + SetVar_unsigned_int(Createref_unsigned_int(10)) + if Value_unsigned_int(GetVar_unsigned_int()) != 10 { + panic(0) + } + + SetVar_long(Createref_long(10)) + if Value_long(GetVar_long()) != 10 { + panic(0) + } + + SetVar_unsigned_long(Createref_unsigned_long(10)) + if Value_unsigned_long(GetVar_unsigned_long()) != 10 { + panic(0) + } + + SetVar_long_long(Createref_long_long(0x6FFFFFFFFFFFFFF8)) + if Value_long_long(GetVar_long_long()) != 0x6FFFFFFFFFFFFFF8 { + panic(0) + } + + //ull = abs(0xFFFFFFF2FFFFFFF0) + ull := uint64(55834574864) + SetVar_unsigned_long_long(Createref_unsigned_long_long(ull)) + if Value_unsigned_long_long(GetVar_unsigned_long_long()) != ull { + panic(0) + } + + SetVar_float(Createref_float(10.5)) + if Value_float(GetVar_float()) != 10.5 { + panic(0) + } + + SetVar_double(Createref_double(10.5)) + if Value_double(GetVar_double()) != 10.5 { + panic(0) + } + + // class reference variable + SetVar_TestClass(Createref_TestClass(NewTestClass(20))) + if Value_TestClass(GetVar_TestClass()).GetNum() != 20 { + panic(0) + } +} diff --git a/Examples/test-suite/go/rename_scope_runme.go b/Examples/test-suite/go/rename_scope_runme.go new file mode 100644 index 000000000..995f8c64d --- /dev/null +++ b/Examples/test-suite/go/rename_scope_runme.go @@ -0,0 +1,18 @@ +package main + +import . "./rename_scope" + +func main() { + a := NewNatural_UP() + b := NewNatural_BP() + + if a.Rtest() != 1 { + panic(0) + } + + if b.Rtest() != 1 { + panic(0) + } + + _ = Equals +} diff --git a/Examples/test-suite/go/rename_strip_encoder_runme.go b/Examples/test-suite/go/rename_strip_encoder_runme.go new file mode 100644 index 000000000..1d0bcb660 --- /dev/null +++ b/Examples/test-suite/go/rename_strip_encoder_runme.go @@ -0,0 +1,9 @@ +package main + +import . "./rename_strip_encoder" + +func main() { + _ = NewSomeWidget() + a := NewAnotherWidget() + a.DoSomething() +} diff --git a/Examples/test-suite/go/ret_by_value_runme.go b/Examples/test-suite/go/ret_by_value_runme.go new file mode 100644 index 000000000..44743d2b7 --- /dev/null +++ b/Examples/test-suite/go/ret_by_value_runme.go @@ -0,0 +1,14 @@ +package main + +import "./ret_by_value" + +func main() { + a := ret_by_value.Get_test() + if a.GetMyInt() != 100 { + panic(0) + } + + if a.GetMyShort() != 200 { + panic(0) + } +} diff --git a/Examples/test-suite/go/return_const_value_runme.go b/Examples/test-suite/go/return_const_value_runme.go new file mode 100644 index 000000000..790921b74 --- /dev/null +++ b/Examples/test-suite/go/return_const_value_runme.go @@ -0,0 +1,15 @@ +package main + +import "./return_const_value" + +func main() { + p := return_const_value.Foo_ptrGetPtr() + if p.GetVal() != 17 { + panic("Runtime test1 failed") + } + + p = return_const_value.Foo_ptrGetConstPtr() + if p.GetVal() != 17 { + panic("Runtime test2 failed") + } +} diff --git a/Examples/test-suite/go/smart_pointer_extend_runme.go b/Examples/test-suite/go/smart_pointer_extend_runme.go new file mode 100644 index 000000000..ee5ce0538 --- /dev/null +++ b/Examples/test-suite/go/smart_pointer_extend_runme.go @@ -0,0 +1,40 @@ +package main + +import . "./smart_pointer_extend" + +func main() { + f := NewFoo() + b := NewBar(f) + + if b.Extension() != f.Extension() { + panic(0) + } + + b2 := NewCBase() + d := NewCDerived() + p := NewCPtr() + + if b2.Bar() != p.Bar() { + panic(0) + } + + if d.Foo() != p.Foo() { + panic(0) + } + + if CBaseHello() != p.Hello() { + panic(0) + } + + d2 := NewDFoo() + + dp := NewDPtrFoo(d2) + + if DFooSExt(1) != dp.SExt(1) { + panic(0) + } + + if d2.Ext(1) != dp.Ext(1) { + panic(0) + } +} diff --git a/Examples/test-suite/go/smart_pointer_member_runme.go b/Examples/test-suite/go/smart_pointer_member_runme.go new file mode 100644 index 000000000..d0da83cef --- /dev/null +++ b/Examples/test-suite/go/smart_pointer_member_runme.go @@ -0,0 +1,30 @@ +package main + +import "fmt" +import . "./smart_pointer_member" + +func main() { + f := NewFoos() + f.SetY(1) + + if f.GetY() != 1 { + panic(0) + } + + b := NewBar(f) + b.SetY(2) + + if f.GetY() != 2 { + fmt.Println(f.GetY()) + fmt.Println(b.GetY()) + panic(0) + } + + if b.GetX() != f.GetX() { + panic(0) + } + + if b.GetZ() != GetFoosZ() { + panic(0) + } +} diff --git a/Examples/test-suite/go/smart_pointer_multi_runme.go b/Examples/test-suite/go/smart_pointer_multi_runme.go new file mode 100644 index 000000000..d1a5f92f4 --- /dev/null +++ b/Examples/test-suite/go/smart_pointer_multi_runme.go @@ -0,0 +1,20 @@ +package main + +import . "./smart_pointer_multi" + +func main() { + f := NewFoo() + b := NewBar(f) + s := NewSpam(b) + g := NewGrok(b) + + s.SetX(3) + if s.Getx() != 3 { + panic(0) + } + + g.SetX(4) + if g.Getx() != 4 { + panic(0) + } +} diff --git a/Examples/test-suite/go/smart_pointer_multi_typedef_runme.go b/Examples/test-suite/go/smart_pointer_multi_typedef_runme.go new file mode 100644 index 000000000..f71740bbb --- /dev/null +++ b/Examples/test-suite/go/smart_pointer_multi_typedef_runme.go @@ -0,0 +1,20 @@ +package main + +import . "./smart_pointer_multi_typedef" + +func main() { + f := NewFoo() + b := NewBar(f) + s := NewSpam(b) + g := NewGrok(b) + + s.SetX(3) + if s.Getx() != 3 { + panic(0) + } + + g.SetX(4) + if g.Getx() != 4 { + panic(0) + } +} diff --git a/Examples/test-suite/go/smart_pointer_overload_runme.go b/Examples/test-suite/go/smart_pointer_overload_runme.go new file mode 100644 index 000000000..0a06aa080 --- /dev/null +++ b/Examples/test-suite/go/smart_pointer_overload_runme.go @@ -0,0 +1,28 @@ +package main + +import . "./smart_pointer_overload" + +func main() { + f := NewFoo() + b := NewBar(f) + + if f.Test(3) != 1 { + panic(0) + } + if f.Test(float64(3.5)) != 2 { + panic(0) + } + if f.Test("hello") != 3 { + panic(0) + } + + if b.Test(3) != 1 { + panic(0) + } + if b.Test(float64(3.5)) != 2 { + panic(0) + } + if b.Test("hello") != 3 { + panic(0) + } +} diff --git a/Examples/test-suite/go/smart_pointer_rename_runme.go b/Examples/test-suite/go/smart_pointer_rename_runme.go new file mode 100644 index 000000000..678c305c8 --- /dev/null +++ b/Examples/test-suite/go/smart_pointer_rename_runme.go @@ -0,0 +1,20 @@ +package main + +import . "./smart_pointer_rename" + +func main() { + f := NewFoo() + b := NewBar(f) + + if b.Test() != 3 { + panic(0) + } + + if b.Ftest1(1) != 1 { + panic(0) + } + + if b.Ftest2(2, 3) != 2 { + panic(0) + } +} diff --git a/Examples/test-suite/go/smart_pointer_simple_runme.go b/Examples/test-suite/go/smart_pointer_simple_runme.go new file mode 100644 index 000000000..328654225 --- /dev/null +++ b/Examples/test-suite/go/smart_pointer_simple_runme.go @@ -0,0 +1,19 @@ +package main + +import . "./smart_pointer_simple" + +func main() { + f := NewFoo() + b := NewBar(f) + + b.SetX(3) + if b.Getx() != 3 { + panic(0) + } + + fp := b.X__deref__() + fp.SetX(4) + if fp.Getx() != 4 { + panic(0) + } +} diff --git a/Examples/test-suite/go/smart_pointer_templatevariables_runme.go b/Examples/test-suite/go/smart_pointer_templatevariables_runme.go new file mode 100644 index 000000000..bf58ba52c --- /dev/null +++ b/Examples/test-suite/go/smart_pointer_templatevariables_runme.go @@ -0,0 +1,22 @@ +package main + +import . "./smart_pointer_templatevariables" + +func main() { + d := NewDiffImContainerPtr_D(Create(1234, 5678)) + + if d.GetId() != 1234 { + panic(0) + } + //if (d.xyz != 5678): + // panic(0) + + d.SetId(4321) + //d.xyz = 8765 + + if d.GetId() != 4321 { + panic(0) + } + //if (d.xyz != 8765): + // panic(0) +} diff --git a/Examples/test-suite/go/smart_pointer_typedef_runme.go b/Examples/test-suite/go/smart_pointer_typedef_runme.go new file mode 100644 index 000000000..a67a0ccda --- /dev/null +++ b/Examples/test-suite/go/smart_pointer_typedef_runme.go @@ -0,0 +1,19 @@ +package main + +import . "./smart_pointer_typedef" + +func main() { + f := NewFoo() + b := NewBar(f) + + b.SetX(3) + if b.Getx() != 3 { + panic(0) + } + + fp := b.X__deref__() + fp.SetX(4) + if fp.Getx() != 4 { + panic(0) + } +} diff --git a/Examples/test-suite/go/sneaky1_runme.go b/Examples/test-suite/go/sneaky1_runme.go new file mode 100644 index 000000000..ee38ae21b --- /dev/null +++ b/Examples/test-suite/go/sneaky1_runme.go @@ -0,0 +1,10 @@ +package main + +import "./sneaky1" + +func main() { + _ = sneaky1.Add(3, 4) + _ = sneaky1.Subtract(3, 4) + _ = sneaky1.Mul(3, 4) + _ = sneaky1.Divide(3, 4) +} diff --git a/Examples/test-suite/go/special_variable_macros_runme.go b/Examples/test-suite/go/special_variable_macros_runme.go new file mode 100644 index 000000000..366575551 --- /dev/null +++ b/Examples/test-suite/go/special_variable_macros_runme.go @@ -0,0 +1,25 @@ +package main + +import "./special_variable_macros" + +func main() { + name := special_variable_macros.NewNames() + if special_variable_macros.TestFred(name) != "none" { + panic("test failed") + } + if special_variable_macros.TestJack(name) != "$specialname" { + panic("test failed") + } + if special_variable_macros.TestJill(name) != "jilly" { + panic("test failed") + } + if special_variable_macros.TestMary(name) != "SWIGTYPE_p_NameWrap" { + panic("test failed") + } + if special_variable_macros.TestJim(name) != "multiname num" { + panic("test failed") + } + if special_variable_macros.TestJohn(special_variable_macros.NewPairIntBool(10, false)) != 123 { + panic("test failed") + } +} diff --git a/Examples/test-suite/go/static_const_member_2_runme.go b/Examples/test-suite/go/static_const_member_2_runme.go new file mode 100644 index 000000000..0d345c3d6 --- /dev/null +++ b/Examples/test-suite/go/static_const_member_2_runme.go @@ -0,0 +1,18 @@ +package main + +import . "./static_const_member_2" + +func main() { + _ = NewTest_int() + + _ = CavityPackFlagsForward_field + _ = Test_intCurrent_profile + _ = Test_intRightIndex + _ = CavityPackFlagsBackward_field + _ = Test_intLeftIndex + // _ = GetTest_int_Cavity_flags() + + if GetFooBAZ().GetVal() != 2*GetFooBAR().GetVal() { + panic(0) + } +} diff --git a/Examples/test-suite/go/struct_initialization_runme.go b/Examples/test-suite/go/struct_initialization_runme.go new file mode 100644 index 000000000..58ac25010 --- /dev/null +++ b/Examples/test-suite/go/struct_initialization_runme.go @@ -0,0 +1,29 @@ +package main + +import . "./struct_initialization" + +func main() { + if GetInstanceC1().GetX() != 10 { + panic(0) + } + + if GetInstanceD1().GetX() != 10 { + panic(0) + } + + if GetInstanceD2().GetX() != 20 { + panic(0) + } + + if GetInstanceD3().GetX() != 30 { + panic(0) + } + + if GetInstanceE1().GetX() != 1 { + panic(0) + } + + if GetInstanceF1().GetX() != 1 { + panic(0) + } +} diff --git a/Examples/test-suite/go/struct_rename_runme.go b/Examples/test-suite/go/struct_rename_runme.go new file mode 100644 index 000000000..845dac5be --- /dev/null +++ b/Examples/test-suite/go/struct_rename_runme.go @@ -0,0 +1,7 @@ +package main + +import "./struct_rename" + +func main() { + _ = struct_rename.NewBar() +} diff --git a/Examples/test-suite/go/struct_value_runme.go b/Examples/test-suite/go/struct_value_runme.go new file mode 100644 index 000000000..d0b60bd23 --- /dev/null +++ b/Examples/test-suite/go/struct_value_runme.go @@ -0,0 +1,17 @@ +package main + +import "./struct_value" + +func main() { + b := struct_value.NewBar() + + b.GetA().SetX(3) + if b.GetA().GetX() != 3 { + panic(0) + } + + b.GetB().SetX(3) + if b.GetB().GetX() != 3 { + panic(0) + } +} diff --git a/Examples/test-suite/go/template_default_arg_runme.go b/Examples/test-suite/go/template_default_arg_runme.go new file mode 100644 index 000000000..5be7f6d56 --- /dev/null +++ b/Examples/test-suite/go/template_default_arg_runme.go @@ -0,0 +1,107 @@ +package main + +import "./template_default_arg" + +func main() { + helloInt := template_default_arg.NewHello_int() + helloInt.Foo(template_default_arg.Hello_intHi) + + x := template_default_arg.NewX_int() + if x.Meth(float64(20.0), 200).(int) != 200 { + panic("X_int test 1 failed") + } + if x.Meth(20).(int) != 20 { + panic("X_int test 2 failed") + } + if x.Meth().(int) != 0 { + panic("X_int test 3 failed") + } + + y := template_default_arg.NewY_unsigned() + if y.Meth(float64(20.0), uint(200)).(uint) != 200 { + panic("Y_unsigned test 1 failed") + } + if y.Meth(uint(20)).(uint) != 20 { + panic("Y_unsigned test 2 failed") + } + if y.Meth().(uint) != 0 { + panic("Y_unsigned test 3 failed") + } + + _ = template_default_arg.NewX_longlong() + _ = template_default_arg.NewX_longlong(float64(20.0)) + _ = template_default_arg.NewX_longlong(float64(20.0), int64(200)) + + _ = template_default_arg.NewX_int() + _ = template_default_arg.NewX_int(float64(20.0)) + _ = template_default_arg.NewX_int(float64(20.0), 200) + + _ = template_default_arg.NewX_hello_unsigned() + _ = template_default_arg.NewX_hello_unsigned(float64(20.0)) + _ = template_default_arg.NewX_hello_unsigned(float64(20.0), template_default_arg.NewHello_int()) + + yy := template_default_arg.NewY_hello_unsigned() + yy.Meth(float64(20.0), template_default_arg.NewHello_int()) + yy.Meth(template_default_arg.NewHello_int()) + yy.Meth() + + fz := template_default_arg.NewFoo_Z_8() + xz := template_default_arg.NewX_Foo_Z_8() + _ = xz.Meth(fz) + + + // Templated functions + + // plain function: int ott(Foo) + if template_default_arg.Ott(template_default_arg.NewFoo_int()) != 30 { + panic("ott test 1 failed") + } + + // %template(ott) ott + if template_default_arg.Ott() != 10 { + panic("ott test 2 failed") + } + if template_default_arg.Ott(1) != 10 { + panic("ott test 3 failed") + } + if template_default_arg.Ott(1, 1) != 10 { + panic("ott test 4 failed") + } + + if template_default_arg.Ott("hi") != 20 { + panic("ott test 5 failed") + } + if template_default_arg.Ott("hi", 1) != 20 { + panic("ott test 6 failed") + } + if template_default_arg.Ott("hi", 1, 1) != 20 { + panic("ott test 7 failed") + } + + // %template(ott) ott + if template_default_arg.Ottstring(template_default_arg.NewHello_int(), "hi") != 40 { + panic("ott test 8 failed") + } + + if template_default_arg.Ottstring(template_default_arg.NewHello_int()) != 40 { + panic("ott test 9 failed") + } + + // %template(ott) ott + if template_default_arg.Ottint(template_default_arg.NewHello_int(), 1) != 50 { + panic("ott test 10 failed") + } + + if template_default_arg.Ottint(template_default_arg.NewHello_int()) != 50 { + panic("ott test 11 failed") + } + + // %template(ott) ott + if template_default_arg.Ott(template_default_arg.NewHello_int(), float64(1.0)) != 60 { + panic("ott test 12 failed") + } + + if template_default_arg.Ott(template_default_arg.NewHello_int()) != 60 { + panic("ott test 13 failed") + } +} diff --git a/Examples/test-suite/go/template_extend1_runme.go b/Examples/test-suite/go/template_extend1_runme.go new file mode 100644 index 000000000..5d6d376f5 --- /dev/null +++ b/Examples/test-suite/go/template_extend1_runme.go @@ -0,0 +1,16 @@ +package main + +import "./template_extend1" + +func main() { + a := template_extend1.NewLBaz() + b := template_extend1.NewDBaz() + + if a.Foo() != "lBaz::foo" { + panic(0) + } + + if b.Foo() != "dBaz::foo" { + panic(0) + } +} diff --git a/Examples/test-suite/go/template_extend2_runme.go b/Examples/test-suite/go/template_extend2_runme.go new file mode 100644 index 000000000..312410e27 --- /dev/null +++ b/Examples/test-suite/go/template_extend2_runme.go @@ -0,0 +1,16 @@ +package main + +import "./template_extend2" + +func main() { + a := template_extend2.NewLBaz() + b := template_extend2.NewDBaz() + + if a.Foo() != "lBaz::foo" { + panic(0) + } + + if b.Foo() != "dBaz::foo" { + panic(0) + } +} diff --git a/Examples/test-suite/go/template_inherit_runme.go b/Examples/test-suite/go/template_inherit_runme.go new file mode 100644 index 000000000..c0aca77c4 --- /dev/null +++ b/Examples/test-suite/go/template_inherit_runme.go @@ -0,0 +1,72 @@ +package main + +import . "./template_inherit" + +func main() { + a := NewFooInt() + b := NewFooDouble() + c := NewBarInt() + d := NewBarDouble() + e := NewFooUInt() + f := NewBarUInt() + + if a.Blah() != "Foo" { + panic(0) + } + + if b.Blah() != "Foo" { + panic(0) + } + + if e.Blah() != "Foo" { + panic(0) + } + + if c.Blah() != "Bar" { + panic(0) + } + + if d.Blah() != "Bar" { + panic(0) + } + + if f.Blah() != "Bar" { + panic(0) + } + + if c.Foomethod() != "foomethod" { + panic(0) + } + + if d.Foomethod() != "foomethod" { + panic(0) + } + + if f.Foomethod() != "foomethod" { + panic(0) + } + + if Invoke_blah_int(a) != "Foo" { + panic(0) + } + + if Invoke_blah_int(c) != "Bar" { + panic(0) + } + + if Invoke_blah_double(b) != "Foo" { + panic(0) + } + + if Invoke_blah_double(d) != "Bar" { + panic(0) + } + + if Invoke_blah_uint(e) != "Foo" { + panic(0) + } + + if Invoke_blah_uint(f) != "Bar" { + panic(0) + } +} diff --git a/Examples/test-suite/go/template_ns4_runme.go b/Examples/test-suite/go/template_ns4_runme.go new file mode 100644 index 000000000..4caf8f587 --- /dev/null +++ b/Examples/test-suite/go/template_ns4_runme.go @@ -0,0 +1,10 @@ +package main + +import . "./template_ns4" + +func main() { + d := Make_Class_DD() + if d.Test() != "test" { + panic(0) + } +} diff --git a/Examples/test-suite/go/template_ns_runme.go b/Examples/test-suite/go/template_ns_runme.go new file mode 100644 index 000000000..5d463f814 --- /dev/null +++ b/Examples/test-suite/go/template_ns_runme.go @@ -0,0 +1,26 @@ +package main + +import . "./template_ns" + +func main() { + p1 := NewPairii(2, 3) + p2 := NewPairii(p1) + + if p2.GetFirst() != 2 { + panic(0) + } + if p2.GetSecond() != 3 { + panic(0) + } + + p3 := NewPairdd(float64(3.5), float64(2.5)) + p4 := NewPairdd(p3) + + if p4.GetFirst() != 3.5 { + panic(0) + } + + if p4.GetSecond() != 2.5 { + panic(0) + } +} diff --git a/Examples/test-suite/go/template_opaque_runme.go b/Examples/test-suite/go/template_opaque_runme.go new file mode 100644 index 000000000..c22b71946 --- /dev/null +++ b/Examples/test-suite/go/template_opaque_runme.go @@ -0,0 +1,9 @@ +package main + +import "./template_opaque" + +func main() { + v := template_opaque.NewOpaqueVectorType(10) + + template_opaque.FillVector(v) +} diff --git a/Examples/test-suite/go/template_ref_type_runme.go b/Examples/test-suite/go/template_ref_type_runme.go new file mode 100644 index 000000000..e4bf626fb --- /dev/null +++ b/Examples/test-suite/go/template_ref_type_runme.go @@ -0,0 +1,9 @@ +package main + +import "./template_ref_type" + +func main() { + xr := template_ref_type.NewXC() + y := template_ref_type.NewY() + y.Find(xr) +} diff --git a/Examples/test-suite/go/template_rename_runme.go b/Examples/test-suite/go/template_rename_runme.go new file mode 100644 index 000000000..757ac7355 --- /dev/null +++ b/Examples/test-suite/go/template_rename_runme.go @@ -0,0 +1,16 @@ +package main + +import "./template_rename" + +func main() { + i := template_rename.NewIFoo() + d := template_rename.NewDFoo() + + _ = i.Blah_test(4) + _ = i.Spam_test(5) + _ = i.Groki_test(6) + + _ = d.Blah_test(7) + _ = d.Spam(8) + _ = d.Grok_test(9) +} diff --git a/Examples/test-suite/go/template_static_runme.go b/Examples/test-suite/go/template_static_runme.go new file mode 100644 index 000000000..7fa50760a --- /dev/null +++ b/Examples/test-suite/go/template_static_runme.go @@ -0,0 +1,7 @@ +package main + +import . "./template_static" + +func main() { + FooBar_double(1) +} diff --git a/Examples/test-suite/go/template_tbase_template_runme.go b/Examples/test-suite/go/template_tbase_template_runme.go new file mode 100644 index 000000000..9a52e2fac --- /dev/null +++ b/Examples/test-suite/go/template_tbase_template_runme.go @@ -0,0 +1,10 @@ +package main + +import . "./template_tbase_template" + +func main() { + a := Make_Class_dd() + if a.Test() != "test" { + panic(0) + } +} diff --git a/Examples/test-suite/go/template_type_namespace_runme.go b/Examples/test-suite/go/template_type_namespace_runme.go new file mode 100644 index 000000000..a3712ff59 --- /dev/null +++ b/Examples/test-suite/go/template_type_namespace_runme.go @@ -0,0 +1,8 @@ +package main + +import . "./template_type_namespace" + +func main() { + if Foo().Get(0) == "" { + } +} diff --git a/Examples/test-suite/go/template_typedef_cplx3_runme.go b/Examples/test-suite/go/template_typedef_cplx3_runme.go new file mode 100644 index 000000000..f827d7a1e --- /dev/null +++ b/Examples/test-suite/go/template_typedef_cplx3_runme.go @@ -0,0 +1,29 @@ +package main + +import . "./template_typedef_cplx3" + +func main() { + // this is OK + + + s := NewSin() + s.Get_base_value() + s.Get_value() + s.Get_arith_value() + My_func_r(s) + Make_Multiplies_double_double_double_double(s, s) + + z := NewCSin() + z.Get_base_value() + z.Get_value() + z.Get_arith_value() + My_func_c(z) + Make_Multiplies_complex_complex_complex_complex(z, z) + + // Here we fail + d := Make_Identity_double() + My_func_r(d) + + c := Make_Identity_complex() + My_func_c(c) +} diff --git a/Examples/test-suite/go/template_typedef_cplx4_runme.go b/Examples/test-suite/go/template_typedef_cplx4_runme.go new file mode 100644 index 000000000..9021cf135 --- /dev/null +++ b/Examples/test-suite/go/template_typedef_cplx4_runme.go @@ -0,0 +1,29 @@ +package main + +import . "./template_typedef_cplx4" + +func main() { + // this is OK + + + s := NewSin() + s.Get_base_value() + s.Get_value() + s.Get_arith_value() + My_func_r(s) + Make_Multiplies_double_double_double_double(s, s) + + z := NewCSin() + z.Get_base_value() + z.Get_value() + z.Get_arith_value() + My_func_c(z) + Make_Multiplies_complex_complex_complex_complex(z, z) + + // Here we fail + d := Make_Identity_double() + My_func_r(d) + + c := Make_Identity_complex() + My_func_c(c) +} diff --git a/Examples/test-suite/go/template_typedef_import_runme.go b/Examples/test-suite/go/template_typedef_import_runme.go new file mode 100644 index 000000000..8528b9a93 --- /dev/null +++ b/Examples/test-suite/go/template_typedef_import_runme.go @@ -0,0 +1,30 @@ +package main + +import "template_typedef_cplx2" +import "template_typedef_import" + +func main() { + // this is OK + + + s := template_typedef_import.NewSin() + s.Get_base_value() + s.Get_value() + s.Get_arith_value() + template_typedef_import.My_func_r(s) + template_typedef_cplx2.Make_Multiplies_double_double_double_double(s, s) + + z := template_typedef_import.NewCSin() + z.Get_base_value() + z.Get_value() + z.Get_arith_value() + template_typedef_import.My_func_c(z) + template_typedef_cplx2.Make_Multiplies_complex_complex_complex_complex(z, z) + + // Here we fail + d := template_typedef_cplx2.Make_Identity_double() + template_typedef_import.My_func_r(d) + + c := template_typedef_cplx2.Make_Identity_complex() + template_typedef_import.My_func_c(c) +} diff --git a/Examples/test-suite/go/threads_exception_runme.go b/Examples/test-suite/go/threads_exception_runme.go new file mode 100644 index 000000000..742a827bd --- /dev/null +++ b/Examples/test-suite/go/threads_exception_runme.go @@ -0,0 +1,66 @@ +package main + +import "strings" +import "./threads_exception" + +func main() { + t := threads_exception.NewTest() + + error := true + func() { + defer func() { + error = recover() == nil + }() + t.Unknown() + }() + if error { + panic(0) + } + + error = true + func() { + defer func() { + error = strings.Index(recover().(string), "int exception") == -1 + }() + t.Simple() + }() + if error { + panic(0) + } + + error = true + func() { + defer func() { + error = recover().(string) != "I died." + }() + t.Message() + }() + if error { + panic(0) + } + + error = true + func() { + defer func() { + e := recover().(string) + error = strings.Index(e, "Exc exception") == -1 + }() + t.Hosed() + }() + if error { + panic(0) + } + + for i := 1; i < 4; i++ { + error = true + func() { + defer func() { + error = recover() == nil + }() + t.Multi(i) + }() + if error { + panic(0) + } + } +} diff --git a/Examples/test-suite/go/typedef_class_runme.go b/Examples/test-suite/go/typedef_class_runme.go new file mode 100644 index 000000000..ec25162de --- /dev/null +++ b/Examples/test-suite/go/typedef_class_runme.go @@ -0,0 +1,11 @@ +package main + +import "./typedef_class" + +func main() { + a := typedef_class.NewRealA() + a.SetA(3) + + b := typedef_class.NewB() + b.TestA(a) +} diff --git a/Examples/test-suite/go/typedef_inherit_runme.go b/Examples/test-suite/go/typedef_inherit_runme.go new file mode 100644 index 000000000..49097999c --- /dev/null +++ b/Examples/test-suite/go/typedef_inherit_runme.go @@ -0,0 +1,31 @@ +package main + +import "./typedef_inherit" + +func main() { + a := typedef_inherit.NewFoo() + b := typedef_inherit.NewBar() + + x := typedef_inherit.Do_blah(a) + if x != "Foo::blah" { + panic(x) + } + + x = typedef_inherit.Do_blah(b) + if x != "Bar::blah" { + panic(x) + } + + c := typedef_inherit.NewSpam() + d := typedef_inherit.NewGrok() + + x = typedef_inherit.Do_blah2(c) + if x != "Spam::blah" { + panic(x) + } + + x = typedef_inherit.Do_blah2(d) + if x != "Grok::blah" { + panic(x) + } +} diff --git a/Examples/test-suite/go/typedef_scope_runme.go b/Examples/test-suite/go/typedef_scope_runme.go new file mode 100644 index 000000000..1c4314427 --- /dev/null +++ b/Examples/test-suite/go/typedef_scope_runme.go @@ -0,0 +1,16 @@ +package main + +import "./typedef_scope" + +func main() { + b := typedef_scope.NewBar() + x := b.Test1(42, "hello") + if x != 42 { + panic("Failed!!") + } + + xb := b.Test2(42, "hello") + if xb != "hello" { + panic("Failed!!") + } +} diff --git a/Examples/test-suite/go/typemap_namespace_runme.go b/Examples/test-suite/go/typemap_namespace_runme.go new file mode 100644 index 000000000..45184fd1e --- /dev/null +++ b/Examples/test-suite/go/typemap_namespace_runme.go @@ -0,0 +1,13 @@ +package main + +import . "./typemap_namespace" + +func main() { + if Test1("hello") != "hello" { + panic(0) + } + + if Test2("hello") != "hello" { + panic(0) + } +} diff --git a/Examples/test-suite/go/typemap_ns_using_runme.go b/Examples/test-suite/go/typemap_ns_using_runme.go new file mode 100644 index 000000000..877e44b3a --- /dev/null +++ b/Examples/test-suite/go/typemap_ns_using_runme.go @@ -0,0 +1,9 @@ +package main + +import "./typemap_ns_using" + +func main() { + if typemap_ns_using.Spam(37) != 37 { + panic(0) + } +} diff --git a/Examples/test-suite/go/typemap_out_optimal_runme.go b/Examples/test-suite/go/typemap_out_optimal_runme.go new file mode 100644 index 000000000..7cbd0ad9b --- /dev/null +++ b/Examples/test-suite/go/typemap_out_optimal_runme.go @@ -0,0 +1,8 @@ +package main + +import . "./typemap_out_optimal" + +func main() { + SetXXDebug(false) + _ = XXCreate() +} diff --git a/Examples/test-suite/go/typename_runme.go b/Examples/test-suite/go/typename_runme.go new file mode 100644 index 000000000..0bc15f11a --- /dev/null +++ b/Examples/test-suite/go/typename_runme.go @@ -0,0 +1,13 @@ +package main + +import "./typename" + +func main() { + f := typename.NewFoo() + b := typename.NewBar() + + var x float64 = typename.TwoFoo(f) + var y int = typename.TwoBar(b) + _ = x + _ = y +} diff --git a/Examples/test-suite/go/unions_runme.go b/Examples/test-suite/go/unions_runme.go new file mode 100644 index 000000000..ba9c27b17 --- /dev/null +++ b/Examples/test-suite/go/unions_runme.go @@ -0,0 +1,51 @@ +// This is the union runtime testcase. It ensures that values within a +// union embedded within a struct can be set and read correctly. + +package main + +import "./unions" + +func main() { + // Create new instances of SmallStruct and BigStruct for later use + small := unions.NewSmallStruct() + small.SetJill(200) + + big := unions.NewBigStruct() + big.SetSmallstruct(small) + big.SetJack(300) + + // Use SmallStruct then BigStruct to setup EmbeddedUnionTest. + // Ensure values in EmbeddedUnionTest are set correctly for each. + eut := unions.NewEmbeddedUnionTest() + + // First check the SmallStruct in EmbeddedUnionTest + eut.SetNumber(1) + eut.GetUni().SetSmall(small) + Jill1 := eut.GetUni().GetSmall().GetJill() + if Jill1 != 200 { + panic("Runtime test1 failed") + } + + Num1 := eut.GetNumber() + if Num1 != 1 { + panic("Runtime test2 failed") + } + + // Secondly check the BigStruct in EmbeddedUnionTest + eut.SetNumber(2) + eut.GetUni().SetBig(big) + Jack1 := eut.GetUni().GetBig().GetJack() + if Jack1 != 300 { + panic("Runtime test3 failed") + } + + Jill2 := eut.GetUni().GetBig().GetSmallstruct().GetJill() + if Jill2 != 200 { + panic("Runtime test4 failed") + } + + Num2 := eut.GetNumber() + if Num2 != 2 { + panic("Runtime test5 failed") + } +} diff --git a/Examples/test-suite/go/using1_runme.go b/Examples/test-suite/go/using1_runme.go new file mode 100644 index 000000000..8cc571288 --- /dev/null +++ b/Examples/test-suite/go/using1_runme.go @@ -0,0 +1,9 @@ +package main + +import "./using1" + +func main() { + if using1.Spam(37) != 37 { + panic(0) + } +} diff --git a/Examples/test-suite/go/using2_runme.go b/Examples/test-suite/go/using2_runme.go new file mode 100644 index 000000000..f679b0c40 --- /dev/null +++ b/Examples/test-suite/go/using2_runme.go @@ -0,0 +1,9 @@ +package main + +import "./using2" + +func main() { + if using2.Spam(37) != 37 { + panic(0) + } +} diff --git a/Examples/test-suite/go/using_composition_runme.go b/Examples/test-suite/go/using_composition_runme.go new file mode 100644 index 000000000..1602e9627 --- /dev/null +++ b/Examples/test-suite/go/using_composition_runme.go @@ -0,0 +1,44 @@ +package main + +import . "./using_composition" + +func main() { + f := NewFooBar() + if f.Blah(3).(int) != 3 { + panic("FooBar::blah(int)") + } + + if f.Blah(float64(3.5)).(float64) != 3.5 { + panic("FooBar::blah(double)") + } + + if f.Blah("hello").(string) != "hello" { + panic("FooBar::blah(char *)") + } + + f2 := NewFooBar2() + if f2.Blah(3).(int) != 3 { + panic("FooBar2::blah(int)") + } + + if f2.Blah(float64(3.5)).(float64) != 3.5 { + panic("FooBar2::blah(double)") + } + + if f2.Blah("hello").(string) != "hello" { + panic("FooBar2::blah(char *)") + } + + f3 := NewFooBar3() + if f3.Blah(3).(int) != 3 { + panic("FooBar3::blah(int)") + } + + if f3.Blah(float64(3.5)).(float64) != 3.5 { + panic("FooBar3::blah(double)") + } + + if f3.Blah("hello").(string) != "hello" { + panic("FooBar3::blah(char *)") + } +} diff --git a/Examples/test-suite/go/using_extend_runme.go b/Examples/test-suite/go/using_extend_runme.go new file mode 100644 index 000000000..144fac47d --- /dev/null +++ b/Examples/test-suite/go/using_extend_runme.go @@ -0,0 +1,30 @@ +package main + +import . "./using_extend" + +func main() { + f := NewFooBar() + if f.Blah(3).(int) != 3 { + panic("blah(int)") + } + + if f.Blah(float64(3.5)).(float64) != 3.5 { + panic("blah(double)") + } + + if f.Blah("hello").(string) != "hello" { + panic("blah(char *)") + } + + if f.Blah(3, 4).(int) != 7 { + panic("blah(int,int)") + } + + if f.Blah(float64(3.5), float64(7.5)).(float64) != (3.5 + 7.5) { + panic("blah(double,double)") + } + + if f.Duh(3) != 3 { + panic("duh(int)") + } +} diff --git a/Examples/test-suite/go/using_inherit_runme.go b/Examples/test-suite/go/using_inherit_runme.go new file mode 100644 index 000000000..669ed4d5f --- /dev/null +++ b/Examples/test-suite/go/using_inherit_runme.go @@ -0,0 +1,59 @@ +package main + +import . "./using_inherit" + +func main() { + b := NewBar() + if b.Test(3).(int) != 3 { + panic("Bar::test(int)") + } + + if b.Test(float64(3.5)).(float64) != 3.5 { + panic("Bar::test(double)") + } + + b2 := NewBar2() + if b2.Test(3).(int) != 6 { + panic("Bar2::test(int)") + } + + if b2.Test(float64(3.5)).(float64) != 7.0 { + panic("Bar2::test(double)") + } + + b3 := NewBar3() + if b3.Test(3).(int) != 6 { + panic("Bar3::test(int)") + } + + if b3.Test(float64(3.5)).(float64) != 7.0 { + panic("Bar3::test(double)") + } + + b4 := NewBar4() + if b4.Test(3).(int) != 6 { + panic("Bar4::test(int)") + } + + if b4.Test(float64(3.5)).(float64) != 7.0 { + panic("Bar4::test(double)") + } + + bf1 := NewFred1() + if bf1.Test(3).(int) != 3 { + panic("Fred1::test(int)") + } + + if bf1.Test(float64(3.5)).(float64) != 7.0 { + panic("Fred1::test(double)") + } + + bf2 := NewFred2() + if bf2.Test(3).(int) != 3 { + panic("Fred2::test(int)") + } + + if bf2.Test(float64(3.5)).(float64) != 7.0 { + panic("Fred2::test(double)") + } +} diff --git a/Examples/test-suite/go/using_private_runme.go b/Examples/test-suite/go/using_private_runme.go new file mode 100644 index 000000000..d683ef856 --- /dev/null +++ b/Examples/test-suite/go/using_private_runme.go @@ -0,0 +1,20 @@ +package main + +import . "./using_private" + +func main() { + f := NewFooBar() + f.SetX(3) + + if f.Blah(4) != 4 { + panic("blah(int)") + } + + if f.Defaulted() != -1 { + panic("defaulted()") + } + + if f.Defaulted(222) != 222 { + panic("defaulted(222)") + } +} diff --git a/Examples/test-suite/go/using_protected_runme.go b/Examples/test-suite/go/using_protected_runme.go new file mode 100644 index 000000000..65edb5001 --- /dev/null +++ b/Examples/test-suite/go/using_protected_runme.go @@ -0,0 +1,12 @@ +package main + +import . "./using_protected" + +func main() { + f := NewFooBar() + f.SetX(3) + + if f.Blah(4) != 4 { + panic("blah(int)") + } +} diff --git a/Examples/test-suite/go/varargs_runme.go b/Examples/test-suite/go/varargs_runme.go new file mode 100644 index 000000000..4009c3ed3 --- /dev/null +++ b/Examples/test-suite/go/varargs_runme.go @@ -0,0 +1,26 @@ +package main + +import "./varargs" + +func main() { + if varargs.Test("Hello") != "Hello" { + panic("Failed") + } + + f := varargs.NewFoo("Greetings") + if f.GetStr() != "Greetings" { + panic("Failed") + } + + if f.Test("Hello") != "Hello" { + panic("Failed") + } + + if varargs.Test_def("Hello", 1) != "Hello" { + panic("Failed") + } + + if varargs.Test_def("Hello") != "Hello" { + panic("Failed") + } +} diff --git a/Examples/test-suite/go/virtual_derivation_runme.go b/Examples/test-suite/go/virtual_derivation_runme.go new file mode 100644 index 000000000..48a7033a2 --- /dev/null +++ b/Examples/test-suite/go/virtual_derivation_runme.go @@ -0,0 +1,12 @@ +package main + +import . "./virtual_derivation" + +// very innocent example + +func main() { + b := NewB(3) + if b.Get_a() != b.Get_b() { + panic("something is really wrong") + } +} diff --git a/Examples/test-suite/go/virtual_poly_runme.go b/Examples/test-suite/go/virtual_poly_runme.go new file mode 100644 index 000000000..7048ba8cf --- /dev/null +++ b/Examples/test-suite/go/virtual_poly_runme.go @@ -0,0 +1,43 @@ +package main + +import "./virtual_poly" + +func main() { + d := virtual_poly.NewNDouble(3.5) + i := virtual_poly.NewNInt(2) + + // the copy methods return the right polymorphic types + dc := d.Copy() + ic := i.Copy() + + if d.Get() != dc.Get() { + panic(0) + } + + if i.Get() != ic.Get() { + panic(0) + } + + virtual_poly.Incr(ic) + + if (i.Get() + 1) != ic.Get() { + panic(0) + } + + dr := d.Ref_this() + if d.Get() != dr.Get() { + panic(0) + } + + + // 'narrowing' also works + ddc := virtual_poly.NDoubleNarrow(d.Nnumber()) + if d.Get() != ddc.Get() { + panic(0) + } + + dic := virtual_poly.NIntNarrow(i.Nnumber()) + if i.Get() != dic.Get() { + panic(0) + } +} diff --git a/Examples/test-suite/go/voidtest_runme.go b/Examples/test-suite/go/voidtest_runme.go new file mode 100644 index 000000000..0a685f081 --- /dev/null +++ b/Examples/test-suite/go/voidtest_runme.go @@ -0,0 +1,26 @@ +package main + +import "./voidtest" + +func main() { + voidtest.Globalfunc() + f := voidtest.NewFoo() + f.Memberfunc() + + voidtest.FooStaticmemberfunc() + + v1 := voidtest.Vfunc1(f.Swigcptr()) + v2 := voidtest.Vfunc2(f) + if v1 != v2 { + panic(0) + } + + v3 := voidtest.Vfunc3(v1) + + v4 := voidtest.Vfunc1(f.Swigcptr()) + if v4 != v1 { + panic(0) + } + + v3.Memberfunc() +} diff --git a/Examples/test-suite/go/wrapmacro_runme.go b/Examples/test-suite/go/wrapmacro_runme.go new file mode 100644 index 000000000..4d3791be8 --- /dev/null +++ b/Examples/test-suite/go/wrapmacro_runme.go @@ -0,0 +1,11 @@ +package main + +import "./wrapmacro" + +func main() { + a := 2 + b := -1 + wrapmacro.Maximum(a, b) + wrapmacro.Maximum(a/7.0, -b*256) + wrapmacro.GUINT16_SWAP_LE_BE_CONSTANT(1) +} diff --git a/Examples/test-suite/keyword_rename.i b/Examples/test-suite/keyword_rename.i index da9328868..6a6082ff9 100644 --- a/Examples/test-suite/keyword_rename.i +++ b/Examples/test-suite/keyword_rename.i @@ -27,6 +27,10 @@ KW(synchronized, final) KW(string, out) struct sealed {int i;}; +/* Go Keywords */ +KW(go, defer) +KW(chan, fallthrough) + %} diff --git a/Examples/test-suite/minherit.i b/Examples/test-suite/minherit.i index fed8b029c..82d1f3cce 100644 --- a/Examples/test-suite/minherit.i +++ b/Examples/test-suite/minherit.i @@ -6,7 +6,7 @@ %module(ruby_minherit="1") minherit -#if defined(SWIGPYTHON) || defined(SWIGRUBY) || defined(SWIGOCAML) || defined(SWIGOCTAVE) || defined(SWIGPERL) +#if defined(SWIGPYTHON) || defined(SWIGRUBY) || defined(SWIGOCAML) || defined(SWIGOCTAVE) || defined(SWIGPERL) || defined(SWIGGO) %inline %{ diff --git a/Examples/test-suite/name_warnings.i b/Examples/test-suite/name_warnings.i index 4032f20e1..3455c03bf 100644 --- a/Examples/test-suite/name_warnings.i +++ b/Examples/test-suite/name_warnings.i @@ -40,7 +40,9 @@ namespace std #endif virtual ~A() {} +#ifndef SWIGGO // func is a keyword in Go. virtual int func() = 0; +#endif private: typedef complex False; }; diff --git a/Examples/test-suite/namespace_typemap.i b/Examples/test-suite/namespace_typemap.i index 984b93a6f..4952aa7ad 100644 --- a/Examples/test-suite/namespace_typemap.i +++ b/Examples/test-suite/namespace_typemap.i @@ -70,6 +70,15 @@ namespace test { delete $1; } #endif +#ifdef SWIGGO +%typemap(go) test::test_complex * "complex128" +%typemap(in) test::test_complex * { + $1 = new test_complex(__real__ $input, __imag__ $input); +} +%typemap(freearg) test::test_complex * { + delete $1; +} +#endif namespace test { class string_class; @@ -97,6 +106,15 @@ namespace test { delete $1; } #endif +#ifdef SWIGGO + %typemap(go) string_class * "string" + %typemap(in) string_class * { + $1 = new string_class($input.p); + } + %typemap(freearg) string_class * { + delete $1; + } +#endif } %inline %{ @@ -240,6 +258,14 @@ namespace Split { } } #endif +#ifdef SWIGGO + %typemap(in) PosInteger { + $1 = $input; + if ($1 < 0) { + _swig_gopanic("domain error"); + } + } +#endif } %inline %{ diff --git a/Examples/test-suite/null_pointer.i b/Examples/test-suite/null_pointer.i index 59d554c2b..0bd7a9b92 100644 --- a/Examples/test-suite/null_pointer.i +++ b/Examples/test-suite/null_pointer.i @@ -1,5 +1,7 @@ %module null_pointer +%warnfilter(SWIGWARN_PARSE_KEYWORD) func; // 'func' is a Go keyword, renamed as 'Xfunc' + %inline { struct A {}; diff --git a/Examples/test-suite/overload_simple.i b/Examples/test-suite/overload_simple.i index be7602083..b08777854 100644 --- a/Examples/test-suite/overload_simple.i +++ b/Examples/test-suite/overload_simple.i @@ -14,6 +14,8 @@ %warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) fid; #endif +%warnfilter(SWIGWARN_PARSE_KEYWORD) type; // 'type' is a Go keyword, renamed as 'Xtype' + #ifndef SWIG_NO_OVERLOAD %immutable Spam::type; diff --git a/Examples/test-suite/return_const_value.i b/Examples/test-suite/return_const_value.i index 1d688d175..473878521 100644 --- a/Examples/test-suite/return_const_value.i +++ b/Examples/test-suite/return_const_value.i @@ -4,6 +4,8 @@ It was reported in bug 899332 by Jermey Brown (jhbrown94) */ %module return_const_value +%ignore Foo_ptr::operator=(const Foo_ptr&); + %inline %{ class Foo { @@ -35,7 +37,12 @@ public: { f._own = 0; } - + + Foo_ptr& operator=(const Foo_ptr& f) { + _ptr = f._ptr; + _own = f._own; + f._own = 0; + } ~Foo_ptr() { if(_own) delete _ptr; diff --git a/Examples/test-suite/rname.i b/Examples/test-suite/rname.i index dde71f203..31b99833d 100644 --- a/Examples/test-suite/rname.i +++ b/Examples/test-suite/rname.i @@ -22,7 +22,12 @@ %rename (newname) Base::oldname(double d) const; /* Rename derived class method only */ +#ifndef SWIGGO %rename (func) Derived::fn(Base baseValue, Base* basePtr, Base& baseRef); +#else +/* func is a keyword in Go. */ +%rename (Xfunc) Derived::fn(Base baseValue, Base* basePtr, Base& baseRef); +#endif %inline %{ class Bar { diff --git a/Examples/test-suite/typemap_namespace.i b/Examples/test-suite/typemap_namespace.i index b3fa1a733..6bf53e989 100644 --- a/Examples/test-suite/typemap_namespace.i +++ b/Examples/test-suite/typemap_namespace.i @@ -25,9 +25,12 @@ namespace Foo { %typemap(jstype) Str1 * = char *; %typemap(javain) Str1 * = char *; %typemap(javaout) Str1 * = char *; +#endif +#ifdef SWIGGO + %typemap(go) Str1 * = char *; #endif %typemap(in) Str1 * = char *; -#if !(defined(SWIGCSHARP) || defined(SWIGLUA) || defined(SWIGPHP) || defined(SWIGMZSCHEME) || defined(SWIGOCAML)) +#if !(defined(SWIGCSHARP) || defined(SWIGLUA) || defined(SWIGPHP) || defined(SWIGMZSCHEME) || defined(SWIGOCAML) || defined(SWIGGO)) %typemap(freearg) Str1 * = char *; #endif %typemap(typecheck) Str1 * = char *; diff --git a/Examples/test-suite/typemap_subst.i b/Examples/test-suite/typemap_subst.i index d5a8416db..1b1f8a3f4 100644 --- a/Examples/test-suite/typemap_subst.i +++ b/Examples/test-suite/typemap_subst.i @@ -61,8 +61,8 @@ $1 = ($ltype) temp; } -/* Java and C# modules don't use SWIG's runtime type system */ -#if !defined(SWIGJAVA) && !defined(SWIGCSHARP) +/* Java, C# and Go modules don't use SWIG's runtime type system */ +#if !defined(SWIGJAVA) && !defined(SWIGCSHARP) && !defined(SWIGGO) %inline %{ void foo(const struct xyzzy **TEST) {} %} diff --git a/Examples/test-suite/union_parameter.i b/Examples/test-suite/union_parameter.i index bb010d3fa..ed7bcacf8 100644 --- a/Examples/test-suite/union_parameter.i +++ b/Examples/test-suite/union_parameter.i @@ -1,5 +1,7 @@ %module union_parameter +%warnfilter(SWIGWARN_PARSE_KEYWORD) type; // 'type' is a Go keyword, renamed as 'Xtype' + %inline %{ typedef unsigned char Uint8; diff --git a/Lib/go/cdata.i b/Lib/go/cdata.i new file mode 100644 index 000000000..c3307945a --- /dev/null +++ b/Lib/go/cdata.i @@ -0,0 +1,135 @@ +/* ----------------------------------------------------------------------------- + * cdata.i + * + * SWIG library file containing macros for manipulating raw C data as strings. + * ----------------------------------------------------------------------------- */ + +%{ +typedef struct SWIGCDATA { + char *data; + int len; +} SWIGCDATA; +%} + +%typemap(go) SWIGCDATA %{ []byte %} +%typemap(out) SWIGCDATA (swigcdata argp) { + argp = _swig_makegobyteslice($1.data, $1.len); + $result.data = (char*)argp.data; + $result.len = (int)argp.len; +} + +/* The makegobyteslice function. */ + +%insert(runtime) %{ +typedef struct { + char *data; + int len; +} swigcdata; + +%} + +#ifndef SWIGGO_GCCGO +%insert(runtime) %{ +extern +#ifdef __cplusplus +"C" +#endif +void _swig_gc_makegobyteslice(void *, int); +static swigcdata _swig_makegobyteslice(const char *data, int len) { + struct { + const char *data; + int len; + swigcdata ret; + } a; + a.data = data; + a.len = len; + crosscall2(_swig_gc_makegobyteslice, &a, (int) sizeof a); + return a.ret; +} +%} + +%insert(gc_header) %{ +typedef struct { + byte *data; + int32 len; +} swigcdata; +extern void ·_swig_internal_makegobyteslice(void); +#pragma dynexport _swig_gc_makegobyteslice _swig_gc_makegobyteslice +void _swig_gc_makegobyteslice(void *a, int32 n) { + cgocallback(·_swig_internal_makegobyteslice, a, n); +} +void ·_swig_allocategobyteslice(byte *data, int32 len, swigcdata ret) { + ret.data = mal(len); + mcpy(ret.data, data, len); + ret.len = len; + FLUSH(&ret); +} +%} + +%insert(go_header) %{ +type swigcdata struct { data *byte; len int } +func _swig_allocategobyteslice(*byte, int) swigcdata +func _swig_internal_makegobyteslice(data *byte, len int) swigcdata { + return _swig_allocategobyteslice(data, len) +} +%} + +#else + +%insert(runtime) %{ +static swigcdata _swig_makegobyteslice(const char *data, int len) { + swigcdata ret; + ret.data = (char*)__go_alloc(len); + memcpy(ret.data, data, len); + ret.len = (int)len; + return ret; +} + +%} + +#endif + +/* ----------------------------------------------------------------------------- + * %cdata(TYPE [, NAME]) + * + * Convert raw C data to a binary string. + * ----------------------------------------------------------------------------- */ + +%define %cdata(TYPE,NAME...) + +%insert("header") { +#if #NAME == "" +static SWIGCDATA cdata_##TYPE(TYPE *ptr, int nelements) { +#else +static SWIGCDATA cdata_##NAME(TYPE *ptr, int nelements) { +#endif + SWIGCDATA d; + d.data = (char *) ptr; +#if #TYPE != "void" + d.len = nelements*sizeof(TYPE); +#else + d.len = nelements; +#endif + return d; +} +} + +%typemap(default) int nelements "$1 = 1;" + +#if #NAME == "" +SWIGCDATA cdata_##TYPE(TYPE *ptr, int nelements); +#else +SWIGCDATA cdata_##NAME(TYPE *ptr, int nelements); +#endif +%enddef + +%typemap(default) int nelements; + +%rename(cdata) ::cdata_void(void *ptr, int nelements); + +%cdata(void); + +/* Memory move function. Due to multi-argument typemaps this appears + to be wrapped as + void memmove(void *data, const char *s); */ +void memmove(void *data, char *indata, int inlen); diff --git a/Lib/go/exception.i b/Lib/go/exception.i new file mode 100644 index 000000000..5abd306a4 --- /dev/null +++ b/Lib/go/exception.i @@ -0,0 +1,7 @@ +%typemap(throws,noblock=1) (...) { + SWIG_exception(SWIG_RuntimeError,"unknown exception"); +} + +%insert("runtime") %{ +#define SWIG_exception(code, msg) _swig_gopanic(msg) +%} diff --git a/Lib/go/go.swg b/Lib/go/go.swg new file mode 100644 index 000000000..b1b8860df --- /dev/null +++ b/Lib/go/go.swg @@ -0,0 +1,514 @@ +/* ------------------------------------------------------------ + * go.swg + * + * Go configuration module. + * ------------------------------------------------------------ */ + +/* Basic types */ + +%typemap(go) bool, const bool & "bool" +%typemap(go) char, const char & "byte" +%typemap(go) signed char, const signed char & "int8" +%typemap(go) unsigned char, const unsigned char & "byte" +%typemap(go) short, const short & "int16" +%typemap(go) unsigned short, const unsigned short & "uint16" +%typemap(go) int, const int & "int" +%typemap(go) unsigned int, const unsigned int & "uint" +#if SWIGGO_LONG_TYPE_SIZE == 32 +%typemap(go) long, const long & "int32" +%typemap(go) unsigned long, const unsigned long & "uint32" +#elif SWIGGO_LONG_TYPE_SIZE == 64 +%typemap(go) long, const long & "int64" +%typemap(go) unsigned long, const unsigned long & "uint64" +#else +#error "SWIGGO_LONG_TYPE_SIZE not 32 or 64" +#endif +%typemap(go) long long, const long long & "int64" +%typemap(go) unsigned long long, const unsigned long long & "uint64" +%typemap(go) float, const float & "float32" +%typemap(go) double, const double & "float64" + +%typemap(in) bool, + char, + signed char, + unsigned char, + short, + unsigned short, + int, + unsigned int, + long, + unsigned long, + long long, + unsigned long long, + float, + double +%{ $1 = ($1_ltype)$input; %} + +%typemap(in) const bool &, + const char &, + const signed char &, + const unsigned char &, + const short &, + const unsigned short &, + const int &, + const unsigned int &, + const long &, + const unsigned long &, + const long long &, + const unsigned long long &, + const float &, + const double & +%{ $1 = ($1_ltype)&$input; %} + +%typemap(out) bool, + char, + signed char, + unsigned char, + short, + unsigned short, + int, + unsigned int, + long, + unsigned long, + long long, + unsigned long long, + float, + double +%{ $result = $1; %} + +%typemap(out) const bool &, + const char &, + const signed char &, + const unsigned char &, + const short &, + const unsigned short &, + const int &, + const unsigned int &, + const long &, + const unsigned long &, + const long long &, + const unsigned long long &, + const float &, + const double & +%{ $result = ($*1_ltype)*$1; %} + +%typemap(out) void "" + +%typemap(directorin) bool, + char, + signed char, + unsigned char, + short, + unsigned short, + int, + unsigned int, + long, + unsigned long, + long long, + unsigned long long, + float, + double +%{ $input = ($1_ltype)$1_name; %} + +%typemap(directorin) const bool &, + const char &, + const signed char &, + const unsigned char &, + const short &, + const unsigned short &, + const int &, + const unsigned int &, + const long &, + const unsigned long &, + const long long &, + const unsigned long long &, + const float &, + const double & +%{ $input = ($*1_ltype)$1_name; %} + +%typemap(directorout) bool, + char, + signed char, + unsigned char, + short, + unsigned short, + int, + unsigned int, + long, + unsigned long, + long long, + unsigned long long, + float, + double +%{ $result = ($1_ltype)$input; %} + +%typemap(directorout) const bool &, + const char &, + const signed char &, + const unsigned char &, + const short &, + const unsigned short &, + const int &, + const unsigned int &, + const long &, + const unsigned long &, + const long long &, + const unsigned long long &, + const float &, + const double & +%{ + $result = ($1_ltype)_swig_allocate(sizeof($*1_ltype)); + *$result = *($1_ltype)$input; +%} + +/* The size_t type. */ + +#if SWIGGO_LONG_TYPE_SIZE == 32 +%typemap(go) size_t, const size_t & %{int%} +#else +%typemap(go) size_t, const size_t & %{int64%} +#endif + +%typemap(in) size_t +%{ $1 = (size_t)$input; %} + +%typemap(in) const size_t & +%{ $1 = ($1_ltype)&$input; %} + +%typemap(out) size_t +%{ $result = $1; %} + +%typemap(out) const size_t & +%{ $result = ($*1_ltype)*$1; %} + +%typemap(directorin) size_t +%{ $input = (size_t)$1_name; %} + +%typemap(directorin) const size_t & +%{ $input = ($*1_ltype)$1_name; %} + +%typemap(directorout) size_t +%{ $result = ($1_ltype)$input; %} + +%typemap(directorout) const size_t & +%{ + $result = ($1_ltype)_swig_allocate(sizeof($*1_ltype)); + *$result = *($1_ltype)$input; +%} + +/* Member pointers. */ + +%typemap(go) SWIGTYPE (CLASS::*) +%{$gotypename%} + +%typemap(in) SWIGTYPE (CLASS::*) +%{ $1 = *($&1_ltype)$input; %} + +%typemap(out) SWIGTYPE (CLASS::*) +%{ + $result = _swig_allocate(sizeof($1_ltype)); + *($&1_ltype)$result = $1; +%} + +%typemap(directorin) SWIGTYPE (CLASS::*) +%{ $input = *($&1_ltype)$1_name; %} + +%typemap(directorout) SWIGTYPE (CLASS::*) +%{ + $result = _swig_allocate(sizeof($1_ltype)); + *($&1_ltype)$result = $input; +%} + +/* Pointers. */ + +/* We can't translate pointers using a typemap, so that is handled in + the C++ code. */ +%typemap(go) SWIGTYPE * +%{$gotypename%} + +%typemap(in) SWIGTYPE * +%{ $1 = *($&1_ltype)&$input; %} + +%typemap(out) SWIGTYPE * +%{ *($&1_ltype)&$result = $1; %} + +%typemap(directorin) SWIGTYPE * +%{ $input = ($1_ltype)$1_name; %} + +%typemap(directorout) SWIGTYPE * +%{ $result = ($1_ltype)$input; %} + +%apply SWIGTYPE * { SWIGTYPE *const } + +/* Pointer references. */ + +%typemap(go) SWIGTYPE *const& +%{$gotypename%} + +%typemap(in) SWIGTYPE *const& ($*1_ltype temp = 0) +%{ + temp = *($1_ltype)&$input; + $1 = ($1_ltype)&temp; +%} + +%typemap(out) SWIGTYPE *const& +%{ *($1_ltype)&$result = *$1; %} + +/* Function pointers are translated by the code in go.cxx into + _swig_fnptr. Member pointers are translated to _swig_memberptr. */ + +%insert(go_header) %{ +type _swig_fnptr *byte +type _swig_memberptr *byte +%} + +/* References. */ + +/* Converting a C++ reference to Go has to be handled in the C++ + code. */ +%typemap(go) SWIGTYPE & +%{$gotypename%} + +%typemap(in) SWIGTYPE & +%{ $1 = *($&1_ltype)&$input; %} + +%typemap(out) SWIGTYPE & +%{ *($&1_ltype)&$result = $1; %} + +%typemap(directorin) SWIGTYPE & +%{ $input = ($1_ltype)&$1_name; %} + +%typemap(directorout) SWIGTYPE & +%{ *($&1_ltype)&$result = $input; %} + +/* C arrays turn into Go pointers. If we know the length we can use a + slice. */ + +%typemap(go) SWIGTYPE [] +%{$gotypename%} + +%typemap(in) SWIGTYPE [] +%{ $1 = *($&1_ltype)&$input; %} + +%typemap(out) SWIGTYPE [] +%{ *($&1_ltype)&$result = $1; %} + +%typemap(directorin) SWIGTYPE [] +%{ $input = *($1_ltype)&$1_name; %} + +%typemap(directorout) SWIGTYPE [] +%{ *($&1_ltype)&$result = $input; %} + +/* Strings. */ + +%typemap(go) + char *, char *&, char[ANY], char[], + signed char *, signed char *&, signed char[ANY], signed char[], + unsigned char *, unsigned char *&, unsigned char[ANY], unsigned char[] +"string" + +/* Needed to avoid confusion with the way the go module handles + references. */ +%typemap(go) char&, unsigned char& "*byte" +%typemap(go) signed char& "*int8" + +%typemap(in) + char *, char[ANY], char[], + signed char *, signed char[ANY], signed char[], + unsigned char *, unsigned char[ANY], unsigned char[] +%{ $1 = ($1_ltype)$input.p; %} + +%typemap(in) char *&, signed char *&, unsigned char *& +%{ $1 = ($1_ltype)$input.p; %} + +%typemap(out) + char *, char *&, char[ANY], char[], + signed char *, signed char *&, signed char[ANY], signed char[], + unsigned char *, unsigned char *&, unsigned char[ANY], unsigned char[] +%{ $result = _swig_makegostring((char*)$1, $1 ? strlen((char*)$1) : 0); %} + +%typemap(directorin) + char *, char *&, char[ANY], char[], + signed char *, signed char *&, signed char[ANY], signed char[], + unsigned char *, unsigned char *&, unsigned char[ANY], unsigned char[] +%{ + $input = _swig_makegostring((char*)$1_name, $1_name ? strlen((char*)$1_name) : 0); +%} + +%typemap(directorout) + char *, char *&, char[ANY], char[], + signed char *, signed char *&, signed char[ANY], signed char[], + unsigned char *, unsigned char *&, unsigned char[ANY], unsigned char[] +%{ $result = ($1_ltype)$input.p; %} + +/* Enums. We can't do the right thing for enums in typemap(go) so we + deliberately don't define them. The right thing would be to + capitalize the name. This is instead done in go.cxx. */ + +%typemap(go) enum SWIGTYPE +%{$gotypename%} + +%typemap(in) enum SWIGTYPE +%{ $1 = ($1_ltype)$input; %} + +%typemap(out) enum SWIGTYPE +%{ $result = $1; %} + +%typemap(directorin) enum SWIGTYPE +%{ $input = ($1_ltype)$1_name; %} + +%typemap(directorout) enum SWIGTYPE +%{ $result = ($1_ltype)$input; %} + +/* Arbitrary type. This is a type passed by value in the C/C++ code. + We convert it to a pointer for the Go code. Note that all basic + types are explicitly handled above. */ + +%typemap(go) SWIGTYPE +%{$gotypename%} + +%typemap(in) SWIGTYPE ($&1_type argp) +%{ + argp = ($&1_ltype)$input; + if (argp == NULL) { + _swig_gopanic("Attempt to dereference null $1_type"); + } + $1 = ($1_ltype)*argp; +%} + +%typemap(out) SWIGTYPE +#ifdef __cplusplus +%{ *($&1_ltype*)&$result = new $1_ltype($1); %} +#else +{ + $&1_ltype $1ptr = ($&1_ltype)malloc(sizeof($1_ltype)); + memmove($1ptr, &$1, sizeof($1_type)); + *($&1_ltype*)&$result = $1ptr; +} +#endif + +%typemap(directorin) SWIGTYPE +%{ $input = ($&1_ltype)&$1_name; %} + +%typemap(directorout) SWIGTYPE +%{ $result = *($&1_ltype)$input; %} + +/* Exception handling */ + +%typemap(throws) char * +%{ _swig_gopanic($1); %} + +%typemap(throws) SWIGTYPE, SWIGTYPE &, SWIGTYPE *, SWIGTYPE [], SWIGTYPE [ANY] +%{ + (void)$1; + _swig_gopanic("C++ $1_type exception thrown"); +%} + +/* Typecheck typemaps. The purpose of these is merely to issue a + warning for overloaded C++ functions * that cannot be overloaded in + Go as more than one C++ type maps to a single Go type. */ + +%typecheck(SWIG_TYPECHECK_BOOL) /* Go bool */ + bool, + const bool & + "" + +%typecheck(SWIG_TYPECHECK_CHAR) /* Go byte */ + char, + const char &, + unsigned char, + const unsigned char & + "" + +%typecheck(SWIG_TYPECHECK_INT8) /* Go int8 */ + signed char, + const signed char & + "" + +%typecheck(SWIG_TYPECHECK_INT16) /* Go int16 */ + short, + const short & + "" + +%typecheck(SWIG_TYPECHECK_INT16) /* Go uint16 */ + unsigned short, + const unsigned short & + "" + +%typecheck(SWIG_TYPECHECK_INT32) /* Go int */ + int, + const int & + "" + +%typecheck(SWIG_TYPECHECK_INT32) /* Go uint */ + unsigned int, + const unsigned int & + "" + +#if SWIGGO_LONG_TYPE_SIZE == 32 +%typecheck(SWIG_TYPECHECK_INT32) /* Go int32 */ + long, + const long & + "" + +%typecheck(SWIG_TYPECHECK_INT32) /* Go uint32 */ + unsigned long, + const unsigned long & + "" +#endif + +%typecheck(SWIG_TYPECHECK_INT64) /* Go int64 */ +#if SWIGGO_LONG_TYPE_SIZE == 64 + long, + const long &, +#endif + long long, + const long long & + "" + +%typecheck(SWIG_TYPECHECK_INT64) /* Go uint64 */ +#if SWIGGO_LONG_TYPE_SIZE == 64 + unsigned long, + const unsigned long &, +#endif + unsigned long long, + const unsigned long long & + "" + +%typecheck(SWIG_TYPECHECK_FLOAT) /* Go float32 */ + float, + const float & + "" + +%typecheck(SWIG_TYPECHECK_DOUBLE) /* Go float64 */ + double, + const double & + "" + +%typecheck(SWIG_TYPECHECK_STRING) /* Go string */ + char *, + char *&, + char[ANY], + char [], + signed char *, + signed char *&, + signed char[ANY], + signed char [], + unsigned char *, + unsigned char *&, + unsigned char[ANY], + unsigned char [] + "" + +%typecheck(SWIG_TYPECHECK_POINTER) + SWIGTYPE, + SWIGTYPE *, + SWIGTYPE &, + SWIGTYPE *const&, + SWIGTYPE [], + SWIGTYPE (CLASS::*) + "" +/* Go keywords. */ +%include + +%include diff --git a/Lib/go/gokw.swg b/Lib/go/gokw.swg new file mode 100644 index 000000000..e7506d053 --- /dev/null +++ b/Lib/go/gokw.swg @@ -0,0 +1,31 @@ +/* Rename keywords. */ + +#define GOKW(x) %keywordwarn("'" `x` "' is a Go keyword, renaming to 'X"`x`"'",rename="X%s") `x` + +GOKW(break); +GOKW(case); +GOKW(chan); +GOKW(const); +GOKW(continue); +GOKW(default); +GOKW(defer); +GOKW(else); +GOKW(fallthrough); +GOKW(for); +GOKW(func); +GOKW(go); +GOKW(goto); +GOKW(if); +GOKW(import); +GOKW(interface); +GOKW(map); +GOKW(package); +GOKW(range); +GOKW(return); +GOKW(select); +GOKW(struct); +GOKW(switch); +GOKW(type); +GOKW(var); + +#undef GOKW diff --git a/Lib/go/goruntime.swg b/Lib/go/goruntime.swg new file mode 100644 index 000000000..5a51fd4b6 --- /dev/null +++ b/Lib/go/goruntime.swg @@ -0,0 +1,208 @@ +/* ------------------------------------------------------------ + * goruntime.swg + * + * Go runtime code for the various generated files. + * ------------------------------------------------------------ */ + +%insert(runtime) %{ +#include +#include +#include + +typedef struct { char *p; int n; } _gostring_; +typedef struct { void* array; unsigned int len; unsigned int cap; } _goslice_; + +%} + +#ifndef SWIGGO_GCCGO +/* Boilerplate for C/C++ code when using 6g/8g. This code is compiled + with gcc. */ +%insert(runtime) %{ + +#define __goswig_size_assert_eq(x, y, name) typedef char name[(x-y)*(x-y)*-2+1]; +#define __goswig_size_assert(t, n) __goswig_size_assert_eq(sizeof(t), n, _goswig_sizeof_##t##_is_not_##n) + +__goswig_size_assert(char, 1) +__goswig_size_assert(short, 2) +__goswig_size_assert(int, 4) +typedef long long __goswig_long_long; +__goswig_size_assert(__goswig_long_long, 8) +__goswig_size_assert(float, 4) +__goswig_size_assert(double, 8) + +extern +#ifdef __cplusplus +"C" +#endif +void crosscall2(void (*fn)(void *, int), void *, int); + +extern +#ifdef __cplusplus +"C" +#endif +void _swig_gc_allocate(void *, int); +static void *_swig_allocate(int len) { + struct { + int len; + void *ret; + } a; + a.len = len; + crosscall2(_swig_gc_allocate, &a, (int) sizeof a); + return a.ret; +} + +extern +#ifdef __cplusplus +"C" +#endif +void _swig_gc_makegostring(void *, int); +static _gostring_ _swig_makegostring(const char *p, size_t l) { + struct { + const char *p; + int l; + _gostring_ ret; + } a; + a.p = p; + a.l = l; + crosscall2(_swig_gc_makegostring, &a, (int) sizeof a); + return a.ret; +} + +extern +#ifdef __cplusplus +"C" +#endif +void _swig_gc_gopanic(void *, int); +static void _swig_gopanic(const char *p) { + struct { + const char *p; + int l; + } a; + a.p = p; + a.l = strlen(p); + crosscall2(_swig_gc_gopanic, &a, (int) sizeof a); +} + +%} + +/* Boilerplate for C code when using 6g/8g. This code is compiled + with 6c/8c. */ +%insert(gc_header) %{ +#include "runtime.h" +#include "cgocall.h" + +#pragma dynimport initcgo initcgo "libcgo.so" +#pragma dynimport libcgo_thread_start libcgo_thread_start "libcgo.so" +#pragma dynimport libcgo_set_scheduler libcgo_set_scheduler "libcgo.so" + +#ifdef _64BIT +#define SWIG_PARM_SIZE 8 +#else +#define SWIG_PARM_SIZE 4 +#endif +%} + +/* 6g/8g C boilerplate that is only needed once in a program. This + only gets added to the file if nothing is imported. */ +%insert(gc_once) %{ + +extern void ·_swig_internal_allocate(void); +#pragma dynexport _swig_gc_allocate _swig_gc_allocate +void _swig_gc_allocate(void *a, int32 n) { + cgocallback(·_swig_internal_allocate, a, n); +} + +void ·_swig_allocatememory(int32 len, byte *ret) { + ret = mal(len); + FLUSH(&ret); +} + +extern void ·_swig_internal_makegostring(void); +#pragma dynexport _swig_gc_makegostring _swig_gc_makegostring +void _swig_gc_makegostring(void *a, int32 n) { + cgocallback(·_swig_internal_makegostring, a, n); +} + +void ·_swig_allocatestring(byte *p, int32 l, String ret) { + ret.str = mal(l+1); + mcpy(ret.str, p, l); + ret.len = l; + FLUSH(&ret); +} + +extern void ·_swig_internal_gopanic(void); +#pragma dynexport _swig_gc_gopanic _swig_gc_gopanic +void _swig_gc_gopanic(void *a, int32 n) { + cgocallback(·_swig_internal_gopanic, a, n); +} + +%} + +/* Go code that is only needed once in a program. This is only added + to the file if nothing is imported. */ +%insert(go_once) %{ +func _swig_allocatememory(int) *byte +func _swig_internal_allocate(len int) *byte { + return _swig_allocatememory(len) +} + +func _swig_allocatestring(*byte, int) string +func _swig_internal_makegostring(p *byte, l int) string { + return _swig_allocatestring(p, l) +} + +func _swig_internal_gopanic(p *byte, l int) { + panic(_swig_allocatestring(p, l)) +} +%} + +#else + +/* Boilerplate for C/C++ code when using gccgo. */ +%insert(runtime) %{ +#define SWIGGO_GCCGO + +extern +#ifdef __cplusplus +"C" +#endif +void *__go_alloc (size_t); + +static void *_swig_allocate(int len) { + return __go_alloc(len); +} + +static _gostring_ _swig_makegostring(const char *p, size_t l) { + _gostring_ ret; + ret.p = (char*)__go_alloc(l); + memcpy(ret.p, p, l); + ret.n = l; + return ret; +} + +extern +#ifdef __cplusplus +"C" +#endif +void __go_panic_msg(const char *); +#define _swig_gopanic __go_panic_msg + +%} + +#endif + +%insert(runtime) %{ +#define SWIG_contract_assert(expr, msg) \ + if (!(expr)) { _swig_gopanic(msg); } else +%} + +#ifdef __cplusplus +/* We don't need a Swig::Director class, but the Swig testsuite + expects one. */ +%insert(runtime) %{ +namespace Swig { + typedef int Director; +} +%} + +#endif diff --git a/Lib/go/std_common.i b/Lib/go/std_common.i new file mode 100644 index 000000000..c010facac --- /dev/null +++ b/Lib/go/std_common.i @@ -0,0 +1,4 @@ +%include + +%apply size_t { std::size_t }; +%apply const size_t& { const std::size_t& }; diff --git a/Lib/go/std_deque.i b/Lib/go/std_deque.i new file mode 100644 index 000000000..cb98f6c2f --- /dev/null +++ b/Lib/go/std_deque.i @@ -0,0 +1 @@ +%include diff --git a/Lib/go/std_except.i b/Lib/go/std_except.i new file mode 100644 index 000000000..789a335f7 --- /dev/null +++ b/Lib/go/std_except.i @@ -0,0 +1,29 @@ +/* ----------------------------------------------------------------------------- + * std_except.i + * + * Typemaps used by the STL wrappers that throw exceptions. + * These typemaps are used when methods are declared with an STL exception specification, such as + * size_t at() const throw (std::out_of_range); + * ----------------------------------------------------------------------------- */ + +%{ +#include +%} + +namespace std +{ + %ignore exception; + struct exception {}; +} + +%typemap(throws) std::bad_exception %{_swig_gopanic($1.what());%} +%typemap(throws) std::domain_error %{_swig_gopanic($1.what());%} +%typemap(throws) std::exception %{_swig_gopanic($1.what());%} +%typemap(throws) std::invalid_argument %{_swig_gopanic($1.what());%} +%typemap(throws) std::length_error %{_swig_gopanic($1.what());%} +%typemap(throws) std::logic_error %{_swig_gopanic($1.what());%} +%typemap(throws) std::out_of_range %{_swig_gopanic($1.what());%} +%typemap(throws) std::overflow_error %{_swig_gopanic($1.what());%} +%typemap(throws) std::range_error %{_swig_gopanic($1.what());%} +%typemap(throws) std::runtime_error %{_swig_gopanic($1.what());%} +%typemap(throws) std::underflow_error %{_swig_gopanic($1.what());%} diff --git a/Lib/go/std_map.i b/Lib/go/std_map.i new file mode 100644 index 000000000..e37a9e676 --- /dev/null +++ b/Lib/go/std_map.i @@ -0,0 +1,64 @@ +/* ----------------------------------------------------------------------------- + * std_map.i + * + * SWIG typemaps for std::map + * ----------------------------------------------------------------------------- */ + +%include + +// ------------------------------------------------------------------------ +// std::map +// ------------------------------------------------------------------------ + +// "map" is a keyword in Go. +#define map cmap + +%{ +#define map cmap +#include +#include +#include +%} + +// exported class + +namespace std { + + template class map { + // add typemaps here + public: + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef K key_type; + typedef T mapped_type; + map(); + map(const map &); + + unsigned int size() const; + bool empty() const; + void clear(); + %extend { + const T& get(const K& key) throw (std::out_of_range) { + std::map::iterator i = self->find(key); + if (i != self->end()) + return i->second; + else + throw std::out_of_range("key not found"); + } + void set(const K& key, const T& x) { + (*self)[key] = x; + } + void del(const K& key) throw (std::out_of_range) { + std::map::iterator i = self->find(key); + if (i != self->end()) + self->erase(i); + else + throw std::out_of_range("key not found"); + } + bool has_key(const K& key) { + std::map::iterator i = self->find(key); + return i != self->end(); + } + } + }; +} diff --git a/Lib/go/std_pair.i b/Lib/go/std_pair.i new file mode 100644 index 000000000..fe45ee676 --- /dev/null +++ b/Lib/go/std_pair.i @@ -0,0 +1,34 @@ +/* ----------------------------------------------------------------------------- + * std_pair.i + * + * SWIG typemaps for std::pair + * ----------------------------------------------------------------------------- */ + +%include +%include + +// ------------------------------------------------------------------------ +// std::pair +// ------------------------------------------------------------------------ + +%{ +#include +%} + +namespace std { + + template struct pair { + + pair(); + pair(T first, U second); + pair(const pair& p); + + template pair(const pair &p); + + T first; + U second; + }; + + // add specializations here + +} diff --git a/Lib/go/std_string.i b/Lib/go/std_string.i new file mode 100644 index 000000000..3c94cbe10 --- /dev/null +++ b/Lib/go/std_string.i @@ -0,0 +1,55 @@ +/* ----------------------------------------------------------------------------- + * std_string.i + * + * Typemaps for std::string and const std::string& + * These are mapped to a Go string and are passed around by value. + * + * To use non-const std::string references use the following %apply. Note + * that they are passed by value. + * %apply const std::string & {std::string &}; + * ----------------------------------------------------------------------------- */ + +%{ +#include +%} + +namespace std { + +%naturalvar string; + +class string; + +%typemap(go) string, const string & "string" + +%typemap(in) string +%{ $1.assign($input.p, $input.n); %} + +%typemap(directorout) string +%{ $result.assign($input.p, $input.n); %} + +%typemap(out) string +%{ $result = _swig_makegostring($1.data(), $1.length()); %} + +%typemap(directorin) string +%{ $input = _swig_makegostring($1_name.data(), $1_name.length()); %} + +%typemap(in) const string & +%{ + std::string $1_str($input.p, $input.n); + $1 = &$1_str; +%} + +%typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const string & +%{ + static std::string $1_str; + $1_str.assign($input.p, $input.n); + $result = &$1_str; +%} + +%typemap(out) const string & +%{ $result = _swig_makegostring((*$1).data(), (*$1).length()); %} + +%typemap(directorin) const string & +%{ $input = _swig_makegostring($1_name.data(), $1_name.length()); %} + +} diff --git a/Lib/go/std_vector.i b/Lib/go/std_vector.i new file mode 100644 index 000000000..f4ce8431c --- /dev/null +++ b/Lib/go/std_vector.i @@ -0,0 +1,78 @@ +/* ----------------------------------------------------------------------------- + * std_vector.i + * ----------------------------------------------------------------------------- */ + +%{ +#include +#include +%} + +namespace std { + + template class vector { + public: + typedef size_t size_type; + typedef T value_type; + typedef const value_type& const_reference; + vector(); + vector(size_type n); + size_type size() const; + size_type capacity() const; + void reserve(size_type n); + %rename(isEmpty) empty; + bool empty() const; + void clear(); + %rename(add) push_back; + void push_back(const value_type& x); + %extend { + const_reference get(int i) throw (std::out_of_range) { + int size = int(self->size()); + if (i>=0 && isize()); + if (i>=0 && i class vector { + public: + typedef size_t size_type; + typedef bool value_type; + typedef bool const_reference; + vector(); + vector(size_type n); + size_type size() const; + size_type capacity() const; + void reserve(size_type n); + %rename(isEmpty) empty; + bool empty() const; + void clear(); + %rename(add) push_back; + void push_back(const value_type& x); + %extend { + const_reference get(int i) throw (std::out_of_range) { + int size = int(self->size()); + if (i>=0 && isize()); + if (i>=0 && i +%include +%include +%include +%include diff --git a/Lib/go/typemaps.i b/Lib/go/typemaps.i new file mode 100644 index 000000000..17da80c23 --- /dev/null +++ b/Lib/go/typemaps.i @@ -0,0 +1,335 @@ +/* ----------------------------------------------------------------------------- + * typemaps.i + * + * Pointer and reference handling typemap library + * + * These mappings provide support for input/output arguments and common + * uses for C/C++ pointers and C++ references. + * ----------------------------------------------------------------------------- */ + +/* +INPUT typemaps +-------------- + +These typemaps remap a C pointer or C++ reference to be an "INPUT" value which is +passed by value instead of reference. + +The following typemaps can be applied to turn a pointer or reference into a simple +input value. That is, instead of passing a pointer or reference to an object, +you would use a real value instead. + + bool *INPUT, bool &INPUT + signed char *INPUT, signed char &INPUT + unsigned char *INPUT, unsigned char &INPUT + short *INPUT, short &INPUT + unsigned short *INPUT, unsigned short &INPUT + int *INPUT, int &INPUT + unsigned int *INPUT, unsigned int &INPUT + long *INPUT, long &INPUT + unsigned long *INPUT, unsigned long &INPUT + long long *INPUT, long long &INPUT + unsigned long long *INPUT, unsigned long long &INPUT + float *INPUT, float &INPUT + double *INPUT, double &INPUT + +To use these, suppose you had a C function like this : + + double fadd(double *a, double *b) { + return *a+*b; + } + +You could wrap it with SWIG as follows : + + %include + double fadd(double *INPUT, double *INPUT); + +or you can use the %apply directive : + + %include + %apply double *INPUT { double *a, double *b }; + double fadd(double *a, double *b); + +In Go you could then use it like this: + answer := modulename.Fadd(10.0, 20.0) + +There are no char *INPUT typemaps, however you can apply the signed +char * typemaps instead: + %include + %apply signed char *INPUT {char *input}; + void f(char *input); +*/ + +%define INPUT_TYPEMAP(TYPE, GOTYPE) +%typemap(go) TYPE *INPUT, TYPE &INPUT "GOTYPE" + +%typemap(in) TYPE *INPUT +%{ $1 = ($1_ltype)&$input; %} + +%typemap(in) TYPE &INPUT +%{ $1 = ($1_ltype)$input; %} + +%typemap(freearg) TYPE *INPUT, TYPE &INPUT "" + +%typemap(directorout) TYPE *INPUT +%{ $result = ($1_ltype)&$input; %} + +%typemap(directorout) TYPE &INPUT +%{ $result = ($1_ltype)$input; %} + +%typemap(directorin) TYPE &INPUT +%{ $1 = ($input_ltype)&$input; %} + +// %typemap(typecheck) TYPE *INPUT = TYPE; +// %typemap(typecheck) TYPE &INPUT = TYPE; +%enddef + +INPUT_TYPEMAP(bool, bool); +INPUT_TYPEMAP(signed char, int8); +INPUT_TYPEMAP(char, byte); +INPUT_TYPEMAP(unsigned char, byte); +INPUT_TYPEMAP(short, int16); +INPUT_TYPEMAP(unsigned short, uint16); +INPUT_TYPEMAP(int, int); +INPUT_TYPEMAP(unsigned int, uint); +INPUT_TYPEMAP(long, int64); +INPUT_TYPEMAP(unsigned long, uint64); +INPUT_TYPEMAP(long long, int64); +INPUT_TYPEMAP(unsigned long long, uint64); +INPUT_TYPEMAP(float, float); +INPUT_TYPEMAP(double, float64); + +#undef INPUT_TYPEMAP + +// OUTPUT typemaps. These typemaps are used for parameters that +// are output only. An array replaces the c pointer or reference parameter. +// The output value is returned in this array passed in. + +/* +OUTPUT typemaps +--------------- + +The following typemaps can be applied to turn a pointer or reference +into an "output" value. When calling a function, no input value would +be given for a parameter, but an output value would be returned. This +works by a Go slice being passed as a parameter where a c pointer or +reference is required. As with any Go function, the array is passed +by reference so that any modifications to the array will be picked up +in the calling function. Note that the array passed in MUST have at +least one element, but as the c function does not require any input, +the value can be set to anything. + + bool *OUTPUT, bool &OUTPUT + signed char *OUTPUT, signed char &OUTPUT + unsigned char *OUTPUT, unsigned char &OUTPUT + short *OUTPUT, short &OUTPUT + unsigned short *OUTPUT, unsigned short &OUTPUT + int *OUTPUT, int &OUTPUT + unsigned int *OUTPUT, unsigned int &OUTPUT + long *OUTPUT, long &OUTPUT + unsigned long *OUTPUT, unsigned long &OUTPUT + long long *OUTPUT, long long &OUTPUT + unsigned long long *OUTPUT, unsigned long long &OUTPUT + float *OUTPUT, float &OUTPUT + double *OUTPUT, double &OUTPUT + +For example, suppose you were trying to wrap the modf() function in the +C math library which splits x into integral and fractional parts (and +returns the integer part in one of its parameters): + + double modf(double x, double *ip); + +You could wrap it with SWIG as follows : + + %include + double modf(double x, double *OUTPUT); + +or you can use the %apply directive : + + %include + %apply double *OUTPUT { double *ip }; + double modf(double x, double *ip); + +The Go output of the function would be the function return value and the +value in the single element array. In Go you would use it like this: + + ptr := []float64{0.0} + fraction := modulename.Modf(5.0,ptr) + +There are no char *OUTPUT typemaps, however you can apply the signed +char * typemaps instead: + %include + %apply signed char *OUTPUT {char *output}; + void f(char *output); +*/ + +%define OUTPUT_TYPEMAP(TYPE, GOTYPE) +%typemap(go) TYPE *OUTPUT, TYPE &OUTPUT %{[]GOTYPE%} + +%typemap(in) TYPE *OUTPUT($*1_ltype temp) +{ + if ($input.len == 0) { + _swig_gopanic("array must contain at least 1 element"); + } + $1 = &temp; +} + +%typemap(in) TYPE &OUTPUT($*1_ltype temp) +{ + if ($input->len == 0) { + _swig_gopanic("array must contain at least 1 element"); + } + $1 = &temp; +} + +%typemap(freearg) TYPE *OUTPUT, TYPE &OUTPUT "" + +%typemap(argout) TYPE *OUTPUT +{ + TYPE* a = (TYPE *) $input.array; + a[0] = temp$argnum; +} + +%typemap(argout) TYPE &OUTPUT +{ + TYPE* a = (TYPE *) $input->array; + a[0] = temp$argnum; +} + +%typemap(directorout,warning="Need to provide TYPE *OUTPUT directorout typemap") TYPE *OUTPUT, TYPE &OUTPUT { +} + +%typemap(directorin) TYPE &OUTPUT +%{ *(($&1_ltype) $input = &$1; %} + +%typemap(directorin,warning="Need to provide TYPE *OUTPUT directorin typemap, TYPE array length is unknown") TYPE *OUTPUT +{ +} + +%enddef + +OUTPUT_TYPEMAP(bool, bool); +OUTPUT_TYPEMAP(signed char, int8); +OUTPUT_TYPEMAP(char, byte); +OUTPUT_TYPEMAP(unsigned char, byte); +OUTPUT_TYPEMAP(short, int16); +OUTPUT_TYPEMAP(unsigned short, uint16); +OUTPUT_TYPEMAP(int, int); +OUTPUT_TYPEMAP(unsigned int, uint); +OUTPUT_TYPEMAP(long, int64); +OUTPUT_TYPEMAP(unsigned long, uint64); +OUTPUT_TYPEMAP(long long, int64); +OUTPUT_TYPEMAP(unsigned long long, uint64); +OUTPUT_TYPEMAP(float, float); +OUTPUT_TYPEMAP(double, float64); + +#undef OUTPUT_TYPEMAP + +/* +INOUT typemaps +-------------- + +Mappings for a parameter that is both an input and an output parameter + +The following typemaps can be applied to make a function parameter both +an input and output value. This combines the behavior of both the +"INPUT" and "OUTPUT" typemaps described earlier. Output values are +returned as an element in a Go slice. + + bool *INOUT, bool &INOUT + signed char *INOUT, signed char &INOUT + unsigned char *INOUT, unsigned char &INOUT + short *INOUT, short &INOUT + unsigned short *INOUT, unsigned short &INOUT + int *INOUT, int &INOUT + unsigned int *INOUT, unsigned int &INOUT + long *INOUT, long &INOUT + unsigned long *INOUT, unsigned long &INOUT + long long *INOUT, long long &INOUT + unsigned long long *INOUT, unsigned long long &INOUT + float *INOUT, float &INOUT + double *INOUT, double &INOUT + +For example, suppose you were trying to wrap the following function : + + void neg(double *x) { + *x = -(*x); + } + +You could wrap it with SWIG as follows : + + %include + void neg(double *INOUT); + +or you can use the %apply directive : + + %include + %apply double *INOUT { double *x }; + void neg(double *x); + +This works similarly to C in that the mapping directly modifies the +input value - the input must be an array with a minimum of one element. +The element in the array is the input and the output is the element in +the array. + + x := []float64{5.0} + Neg(x); + +The implementation of the OUTPUT and INOUT typemaps is different to +other languages in that other languages will return the output value +as part of the function return value. This difference is due to Go +being a typed language. + +There are no char *INOUT typemaps, however you can apply the signed +char * typemaps instead: + %include + %apply signed char *INOUT {char *inout}; + void f(char *inout); +*/ + +%define INOUT_TYPEMAP(TYPE, GOTYPE) +%typemap(go) TYPE *INOUT, TYPE &INOUT %{[]GOTYPE%} + +%typemap(in) TYPE *INOUT { + if ($input.len == 0) { + _swig_gopanic("array must contain at least 1 element"); + } + $1 = ($1_ltype) $input.array; +} + +%typemap(in) TYPE &INOUT { + if ($input->len == 0) { + _swig_gopanic("array must contain at least 1 element"); + } + $1 = ($1_ltype) $input->array; +} + +%typemap(freearg) TYPE *INOUT, TYPE &INOUT "" + +%typemap(directorout,warning="Need to provide TYPE *INOUT directorout typemap") TYPE *INOUT, TYPE &INOUT { +} + +%typemap(directorin) TYPE &INOUT +%{ *(($&1_ltype)&$input) = &$1; %} + +%typemap(directorin,warning="Need to provide TYPE *INOUT directorin typemap, TYPE array length is unknown") TYPE *INOUT, TYPE &INOUT +{ +} + +%enddef + +INOUT_TYPEMAP(bool, bool); +INOUT_TYPEMAP(signed char, int8); +INOUT_TYPEMAP(char, byte); +INOUT_TYPEMAP(unsigned char, byte); +INOUT_TYPEMAP(short, int16); +INOUT_TYPEMAP(unsigned short, uint16); +INOUT_TYPEMAP(int, int); +INOUT_TYPEMAP(unsigned int, uint); +INOUT_TYPEMAP(long, int64); +INOUT_TYPEMAP(unsigned long, uint64); +INOUT_TYPEMAP(long long, int64); +INOUT_TYPEMAP(unsigned long long, uint64); +INOUT_TYPEMAP(float, float); +INOUT_TYPEMAP(double, float64); + +#undef INOUT_TYPEMAP diff --git a/Makefile.in b/Makefile.in index 0beb7cbdd..180ad3451 100644 --- a/Makefile.in +++ b/Makefile.in @@ -75,6 +75,7 @@ skip-clisp = test -n "@SKIP_CLISP@" skip-cffi = test -n "@SKIP_CFFI@" skip-uffi = test -n "@SKIP_UFFI@" skip-r = test -n "@SKIP_R@" +skip-go = test -n "@SKIP_GO@" # Additional dependencies for some tests skip-gcj = test -n "@SKIP_GCJ@" @@ -110,6 +111,7 @@ check-aliveness: @$(skip-modula3) || ./$(TARGET) -modula3 -help @$(skip-lua) || ./$(TARGET) -lua -help @$(skip-r) || ./$(TARGET) -r -help + @$(skip-go) || ./$(TARGET) -go -help check-ccache: test -z "$(ENABLE_CCACHE)" || (cd $(CCACHE) && $(MAKE) check) @@ -135,7 +137,8 @@ check-examples: \ check-clisp-examples \ check-uffi-examples \ check-cffi-examples \ - check-r-examples + check-r-examples \ + check-go-examples tcl_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/tcl/check.list) perl5_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/perl5/check.list) @@ -157,6 +160,7 @@ clisp_examples := uffi_examples := cffi_examples := r_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/r/check.list) +go_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/go/check.list) # all examples check-%-examples : @@ -206,7 +210,8 @@ check-test-suite: \ check-uffi-test-suite \ check-cffi-test-suite \ check-chicken-test-suite \ - check-r-test-suite + check-r-test-suite \ + check-go-test-suite check-%-test-suite: @if test -z "$(skip-$*)"; then \ @@ -257,7 +262,8 @@ all-test-suite: \ all-uffi-test-suite \ all-cffi-test-suite \ all-chicken-test-suite \ - all-r-test-suite + all-r-test-suite \ + all-go-test-suite all-%-test-suite: @$(MAKE) -k -s check-$*-test-suite ACTION=all @@ -284,7 +290,8 @@ broken-test-suite: \ broken-uffi-test-suite \ broken-cffi-test-suite \ broken-chicken-test-suite \ - broken-r-test-suite + broken-r-test-suite \ + broken-go-test-suite broken-%-test-suite: @$(MAKE) -k -s check-$*-test-suite ACTION=broken @@ -401,7 +408,7 @@ install-main: @$(INSTALL_PROGRAM) $(TARGET) $(DESTDIR)$(BIN_DIR)/`echo $(TARGET_NOEXE) | sed '$(transform)'`@EXEEXT@ lib-languages = gcj typemaps tcl perl5 python guile java mzscheme ruby php ocaml octave \ - pike chicken csharp modula3 allegrocl clisp lua cffi uffi r + pike chicken csharp modula3 allegrocl clisp lua cffi uffi r go lib-modules = std diff --git a/Source/Makefile.am b/Source/Makefile.am index 26f37b2fe..4677002e6 100644 --- a/Source/Makefile.am +++ b/Source/Makefile.am @@ -44,6 +44,7 @@ eswig_SOURCES = CParse/cscanner.c \ Modules/csharp.cxx \ Modules/directors.cxx \ Modules/emit.cxx \ + Modules/go.cxx \ Modules/guile.cxx \ Modules/java.cxx \ Modules/lang.cxx \ diff --git a/Source/Modules/allegrocl.cxx b/Source/Modules/allegrocl.cxx index de4a7bfa9..93ca6d8f3 100644 --- a/Source/Modules/allegrocl.cxx +++ b/Source/Modules/allegrocl.cxx @@ -1709,6 +1709,8 @@ int ALLEGROCL::top(Node *n) { We don't need a dispatch function in the C++ wrapper code; we want it over on the lisp side. */ +#define Swig_overload_rank Allegrocl_swig_overload_rank + #define MAX_OVERLOAD 256 /* Overload "argc" and "argv" */ diff --git a/Source/Modules/go.cxx b/Source/Modules/go.cxx new file mode 100644 index 000000000..91a0f457b --- /dev/null +++ b/Source/Modules/go.cxx @@ -0,0 +1,4824 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * go.cxx + * + * Go language module for SWIG. + * ----------------------------------------------------------------------------- */ + +char cvsroot_go_cxx[] = "$Id"; + +#include "swigmod.h" +#include "cparse.h" +#include +#include + +class GO:public Language { + static const char * const usage; + + // Go package name. + String *package; + // Flag for generating gccgo output. + bool gccgo_flag; + // Prefix to use with gccgo. + String *go_prefix; + // Name of shared library to import. + String *soname; + // Size in bits of the C type "long". + int long_type_size; + // Rename directives. + String *renames; + + /* Output files */ + File *f_c_begin; + File *f_go_begin; + File *f_gc_begin; + + /* Output fragments */ + File *f_c_runtime; + File *f_c_header; + File *f_c_wrappers; + File *f_c_init; + File *f_c_directors; + File *f_c_directors_h; + File *f_go_runtime; + File *f_go_header; + File *f_go_wrappers; + File *f_go_once; + File *f_gc_runtime; + File *f_gc_header; + File *f_gc_wrappers; + File *f_gc_once; + + // True if we imported a module. + bool saw_import; + // If not NULL, name of import package being processed. + String *imported_package; + // Build interface methods while handling a class. This is only + // non-NULL when we are handling methods. + String *interfaces; + // The class node while handling a class. This is only non-NULL + // when we are handling methods. + Node *class_node; + // The class name while handling a class. This is only non-NULL + // when we are handling methods. This is the name of the class as + // SWIG sees it. + String *class_name; + // The receiver name while handling a class. This is only non-NULL + // when we are handling methods. This is the name of the class + // as run through goCPointerType. + String *class_receiver; + // A hash table of method names that we have seen when processing a + // class. This lets us detect base class methods that we don't want + // to use. + Hash *class_methods; + // True when we are generating the wrapper functions for a variable. + bool making_variable_wrappers; + // True when working with a static member function. + bool is_static_member_function; + // A hash table of types that we have seen but which may not have + // been defined. The index is a SwigType. + Hash *undefined_types; + // A hash table of classes which were defined. The index is a Go + // type name. + Hash *defined_types; + +public: + GO():package(NULL), + gccgo_flag(false), + go_prefix(NULL), + soname(NULL), + long_type_size(32), + renames(NULL), + f_c_begin(NULL), + f_go_begin(NULL), + f_gc_begin(NULL), + f_c_runtime(NULL), + f_c_header(NULL), + f_c_wrappers(NULL), + f_c_init(NULL), + f_c_directors(NULL), + f_c_directors_h(NULL), + f_go_runtime(NULL), + f_go_header(NULL), + f_go_wrappers(NULL), + f_go_once(NULL), + f_gc_runtime(NULL), + f_gc_header(NULL), + f_gc_wrappers(NULL), + f_gc_once(NULL), + saw_import(false), + imported_package(NULL), + interfaces(NULL), + class_receiver(NULL), + class_methods(NULL), + making_variable_wrappers(false), + is_static_member_function(false), + undefined_types(NULL), + defined_types(NULL) + { + director_multiple_inheritance = 1; + director_language = 1; + director_prot_ctor_code = NewString("_swig_gopanic(\"accessing abstract class or protected constructor\");"); + } + +private: + /* ------------------------------------------------------------ + * main() + * ------------------------------------------------------------ */ + virtual void main(int argc, char *argv[]) { + + SWIG_library_directory("go"); + + // Process command line options. + for (int i = 1; i < argc; i++) { + if (argv[i]) { + if (strcmp(argv[i], "-package") == 0) { + if (argv[i + 1] != NULL) { + package = NewString(argv[i + 1]); + Swig_mark_arg(i); + Swig_mark_arg(i + 1); + i++; + } else { + Swig_arg_error(); + } + } else if (strcmp(argv[i], "-gccgo") == 0) { + Swig_mark_arg(i); + gccgo_flag = true; + } else if (strcmp(argv[i], "-go-prefix") == 0) { + if (argv[i + 1] != NULL) { + go_prefix = NewString(argv[i + 1]); + Swig_mark_arg(i); + Swig_mark_arg(i + 1); + i++; + } else { + Swig_arg_error(); + } + } else if (strcmp(argv[i], "-soname") == 0) { + if (argv[i + 1] != NULL) { + soname = NewString(argv[i + 1]); + Swig_mark_arg(i); + Swig_mark_arg(i + 1); + i++; + } else { + Swig_arg_error(); + } + } else if (strcmp(argv[i], "-longsize") == 0) { + if (argv[i + 1] != NULL) { + long_type_size = atoi(argv[i + 1]); + if (long_type_size != 32 && long_type_size != 64) { + Printf(stderr, "-longsize not 32 or 64\n"); + Swig_arg_error(); + } + Swig_mark_arg(i); + Swig_mark_arg(i + 1); + ++i; + } else { + Swig_arg_error(); + } + } else if (strcmp(argv[i], "-rename") == 0) { + if (argv[i + 1] != NULL) { + String *d = NewString(argv[i + 1]); + Replace(d, "=", " ", DOH_REPLACE_FIRST); + Preprocessor_define(d, 0); + if (renames == NULL) { + renames = NewString(""); + } + Printv(renames, "#define ", d, "\n", NULL); + Delete(d); + Swig_mark_arg(i); + Swig_mark_arg(i + 1); + ++i; + // Prevent SWIG from trying to define this for the + // preprocessor, which breaks if there are multiple + // -rename options. + argv[i] = NULL; + } else { + Swig_arg_error(); + } + } else if (strcmp(argv[i], "-help") == 0) { + Printf(stdout, "%s\n", usage); + } + } + } + + if (gccgo_flag && go_prefix == NULL) { + go_prefix = NewString("go"); + } + + // Add preprocessor symbol to parser. + Preprocessor_define("SWIGGO 1", 0); + + if (gccgo_flag) { + Preprocessor_define("SWIGGO_GCCGO 1", 0); + } + + if (long_type_size == 32) { + Preprocessor_define("SWIGGO_LONG_TYPE_SIZE 32", 0); + } else { + Preprocessor_define("SWIGGO_LONG_TYPE_SIZE 64", 0); + } + + // Add typemap definitions. + SWIG_typemap_lang("go"); + SWIG_config_file("go.swg"); + + allow_overloading(); + } + + /* --------------------------------------------------------------------- + * top() + * + * For 6g/8g, we are going to create the following files: + * + * 1) A .c or .cxx file compiled with gcc. This file will contain + * function wrappers. Each wrapper will take a pointer to a + * struct holding the arguments, unpack them, and call the real + * function. + * + * 2) A .go file which defines the Go form of all types, and which + * defines Go function wrappers. Each wrapper will call the C + * function wrapper in the second file. + * + * 3) A .c file compiled with 6c/8c. This file will define + * Go-callable C function wrappers. Each wrapper will use + * cgocall to call the function wrappers in the first file. + * + * When generating code for gccgo, we don't need the third file, and + * the function wrappers in the first file have a different form. + * + * --------------------------------------------------------------------- */ + + virtual int top(Node *n) { + Node *optionsnode = Getattr(Getattr(n, "module"), "options"); + if (optionsnode != NULL) { + if (Getattr(optionsnode, "directors")) { + allow_directors(); + } + if (Getattr(optionsnode, "dirprot")) { + allow_dirprot(); + } + allow_allprotected(GetFlag(optionsnode, "allprotected")); + } + + String *module = Getattr(n, "name"); + if (package == NULL) { + package = Copy(module); + } + if (soname == NULL) { + soname = Copy(package); + Append(soname, ".so"); + } + + // Get filenames. + + String *c_filename = Getattr(n, "outfile"); + String *c_filename_h = Getattr(n, "outfile_h"); + + String *go_filename = NewString(""); + Printf(go_filename, "%s%s.go", SWIG_output_directory(), module); + + String *gc_filename = NULL; + if (!gccgo_flag) { + gc_filename = NewString(""); + Printf(gc_filename, "%s%s_gc.c", SWIG_output_directory(), module); + } + + // Open files. + + f_c_begin = NewFile(c_filename, "w", SWIG_output_files()); + if (!f_c_begin) { + FileErrorDisplay(c_filename); + SWIG_exit(EXIT_FAILURE); + } + + if (directorsEnabled()) { + if (!c_filename_h) { + Printf(stderr, "Unable to determine outfile_h\n"); + SWIG_exit(EXIT_FAILURE); + } + f_c_directors_h = NewFile(c_filename_h, "w", SWIG_output_files()); + if (!f_c_directors_h) { + FileErrorDisplay(c_filename_h); + SWIG_exit(EXIT_FAILURE); + } + } + + f_go_begin = NewFile(go_filename, "w", SWIG_output_files()); + if (!f_go_begin) { + FileErrorDisplay(go_filename); + SWIG_exit(EXIT_FAILURE); + } + + if (!gccgo_flag) { + f_gc_begin = NewFile(gc_filename, "w", SWIG_output_files()); + if (!f_gc_begin) { + FileErrorDisplay(gc_filename); + SWIG_exit(EXIT_FAILURE); + } + } + + f_c_runtime = NewString(""); + f_c_header = NewString(""); + f_c_wrappers = NewString(""); + f_c_init = NewString(""); + f_c_directors = NewString(""); + f_go_runtime = NewString(""); + f_go_header = NewString(""); + f_go_wrappers = NewString(""); + f_go_once = NewString(""); + if (!gccgo_flag) { + f_gc_runtime = NewString(""); + f_gc_header = NewString(""); + f_gc_wrappers = NewString(""); + f_gc_once = NewString(""); + } + + Swig_register_filebyname("begin", f_c_begin); + Swig_register_filebyname("runtime", f_c_runtime); + Swig_register_filebyname("header", f_c_header); + Swig_register_filebyname("wrapper", f_c_wrappers); + Swig_register_filebyname("init", f_c_init); + Swig_register_filebyname("director", f_c_directors); + Swig_register_filebyname("director_h", f_c_directors_h); + Swig_register_filebyname("go_begin", f_go_begin); + Swig_register_filebyname("go_runtime", f_go_runtime); + Swig_register_filebyname("go_header", f_go_header); + Swig_register_filebyname("go_wrapper", f_go_wrappers); + Swig_register_filebyname("go_once", f_go_once); + if (!gccgo_flag) { + Swig_register_filebyname("gc_begin", f_gc_begin); + Swig_register_filebyname("gc_runtime", f_gc_runtime); + Swig_register_filebyname("gc_header", f_gc_header); + Swig_register_filebyname("gc_wrapper", f_gc_wrappers); + Swig_register_filebyname("gc_once", f_gc_once); + } + + Swig_banner(f_c_begin); + if (!gccgo_flag) { + Printf(f_c_begin, "\n/* This file should be compiled with gcc. */\n"); + } + if (renames != NULL) { + Printf(f_c_begin, "%s\n", renames); + } + + if (directorsEnabled()) { + Printf(f_c_runtime, "#define SWIG_DIRECTORS\n"); + + Swig_banner(f_c_directors_h); + Printf(f_c_directors_h, + "\n/* This file should be compiled with gcc. */\n"); + Printf(f_c_directors_h, "#ifndef SWIG_%s_WRAP_H_\n", module); + Printf(f_c_directors_h, "#define SWIG_%s_WRAP_H_\n\n", module); + + Printf(f_c_directors, "\n// C++ director class methods.\n"); + Printf(f_c_directors, "#include \"%s\"\n\n", + Swig_file_filename(c_filename_h)); + } + + Swig_banner(f_go_begin); + + if (!gccgo_flag) { + Swig_banner(f_gc_begin); + Printf(f_gc_begin, "\n/* This file should be compiled with 6c/8c. */\n"); + } + + // Output module initialization code. + + Printf(f_go_begin, "\npackage %s\n\n", package); + + // Set up the hash table for types not defined by SWIG. + + undefined_types = NewHash(); + defined_types = NewHash(); + + // Emit code. + + Language::top(n); + + // Write out definitions for the types not defined by SWIG. + + Printv(f_go_wrappers, "\n", NULL); + for (Iterator p = First(undefined_types); p.key != NULL; p = Next(p)) { + String *ty = goType(NULL, p.key); + if (Getattr(defined_types, ty) == NULL) { + String *cp = goCPointerType(p.key, false); + if (Getattr(defined_types, cp) == NULL) { + Printv(f_go_wrappers, "type ", cp, " uintptr\n", NULL); + Printv(f_go_wrappers, "type ", ty, " interface {\n", NULL); + Printv(f_go_wrappers, "\tSwigcptr() uintptr;\n", NULL); + Printv(f_go_wrappers, "}\n", NULL); + Printv(f_go_wrappers, "func (p ", cp, ") Swigcptr() uintptr {\n", + NULL); + Printv(f_go_wrappers, "\treturn uintptr(p)\n", NULL); + Printv(f_go_wrappers, "}\n\n", NULL); + } + Delete(cp); + } + Delete(ty); + } + Delete(undefined_types); + Delete(defined_types); + + /* Write and cleanup */ + + Dump(f_c_header, f_c_runtime); + + if (directorsEnabled()) { + Printf(f_c_directors_h, "#endif\n"); + Close(f_c_directors_h); + Delete(f_c_directors_h); + f_c_directors_h = NULL; + + Dump(f_c_directors, f_c_runtime); + Close(f_c_directors); + Delete(f_c_directors); + f_c_directors = NULL; + } + + Dump(f_c_runtime, f_c_begin); + Dump(f_c_wrappers, f_c_begin); + Dump(f_c_init, f_c_begin); + Dump(f_go_header, f_go_begin); + if (!saw_import) { + Dump(f_go_once, f_go_begin); + } + Dump(f_go_runtime, f_go_begin); + Dump(f_go_wrappers, f_go_begin); + if (!gccgo_flag) { + Dump(f_gc_header, f_gc_begin); + if (!saw_import) { + Dump(f_gc_once, f_gc_begin); + } + Dump(f_gc_runtime, f_gc_begin); + Dump(f_gc_wrappers, f_gc_begin); + } + + Delete(f_c_runtime); + Delete(f_c_header); + Delete(f_c_wrappers); + Delete(f_c_init); + Delete(f_go_runtime); + Delete(f_go_header); + Delete(f_go_wrappers); + if (!gccgo_flag) { + Delete(f_gc_runtime); + Delete(f_gc_header); + Delete(f_gc_wrappers); + } + + Close(f_c_begin); + Delete(f_c_begin); + Close(f_go_begin); + Delete(f_go_begin); + if (!gccgo_flag) { + Close(f_gc_begin); + Delete(f_gc_begin); + } + + return SWIG_OK; + } + + /* ------------------------------------------------------------ + * importDirective() + * + * Handle a SWIG import statement by generating a Go import + * statement. + * ------------------------------------------------------------ */ + + virtual int importDirective(Node *n) { + String *hold_import = imported_package; + String *modname = Getattr(n, "module"); + if (modname != NULL) { + Printv(f_go_begin, "import \"", modname, "\"\n", NULL); + imported_package = modname; + saw_import = true; + } + int r = Language::importDirective(n); + imported_package = hold_import; + return r; + } + + /* ---------------------------------------------------------------------- + * functionWrapper() + * + * Implement a function. + * ---------------------------------------------------------------------- */ + + virtual int functionWrapper(Node *n) { + if (GetFlag(n, "feature:ignore")) { + return SWIG_OK; + } + + // We don't need explicit calls. + if (GetFlag(n, "explicitcall")) { + return SWIG_OK; + } + + String *name = Getattr(n, "sym:name"); + String *nodetype = Getattr(n, "nodeType"); + bool is_static = is_static_member_function || isStatic(n); + bool is_friend = isFriend(n); + bool is_ctor_dtor = false; + + SwigType *result = Getattr(n, "type"); + + // For some reason SWIG changs the "type" value during the call to + // functionWrapper. We need to remember the type for possible + // overload processing. + Setattr(n, "go:type", Copy(result)); + + String *go_name; + + String *r1 = NULL; + if (making_variable_wrappers) { + // Change the name of the variable setter and getter functions + // to be more Go like. + + bool is_set = Strcmp(Char(name) + Len(name) - 4, "_set") == 0; + assert(is_set || Strcmp(Char(name) + Len(name) - 4, "_get") == 0); + + // Start with Set or Get. + go_name = NewString(is_set ? "Set" : "Get"); + + // If this is a static variable, put in the class name, + // capitalized. + if (is_static && class_name != NULL) { + String *ccn = exportedName(class_name); + Append(go_name, ccn); + Delete(ccn); + } + + // Add the rest of the name, capitalized, dropping the _set or + // _get. + String *c1 = removeClassname(name); + String *c2 = exportedName(c1); + char *p = Char(c2); + int len = Len(p); + for (int i = 0; i < len - 4; ++i) { + Putc(p[i], go_name); + } + Delete(c2); + Delete(c1); + } else if (Cmp(nodetype, "constructor") == 0) { + is_ctor_dtor = true; + + // Change the name of a constructor to be more Go like. Change + // new_ to New, and capitalize the class name. + assert(Strncmp(name, "new_", 4) == 0); + String *c1 = NewString(Char(name) + 4); + String *c2 = exportedName(c1); + go_name = NewString("New"); + Append(go_name, c2); + Delete(c2); + Delete(c1); + + if (Swig_methodclass(n) != NULL + && Swig_directorclass(n) + && Strcmp(Char(Getattr(n, "wrap:action")), + director_prot_ctor_code) != 0) { + // The core SWIG code skips the first parameter when + // generating the $nondirector_new string. Recreate the + // action in this case. But don't it if we are using the + // special code for an abstract class. + String *call = Swig_cppconstructor_call(getClassType(), + Getattr(n, "parms")); + SwigType *type = Copy(getClassType()); + SwigType_add_pointer(type); + String *cres = Swig_cresult(type, "result", call); + Setattr(n, "wrap:action", cres); + } + } else if (Cmp(nodetype, "destructor") == 0) { + // No need to emit protected destructors. + if (!is_public(n)) { + return SWIG_OK; + } + + is_ctor_dtor = true; + + // Change the name of a destructor to be more Go like. Change + // delete_ to Delete and capitalize the class name. + assert(Strncmp(name, "delete_", 7) == 0); + String *c1 = NewString(Char(name) + 7); + String *c2 = exportedName(c1); + go_name = NewString("Delete"); + Append(go_name, c2); + Delete(c2); + Delete(c1); + + result = NewString("void"); + r1 = result; + } else { + if (!is_public(n)) { + return SWIG_OK; + } + + go_name = buildGoName(name, is_static, is_friend); + } + + String *overname = NULL; + if (Getattr(n, "sym:overloaded")) { + overname = Getattr(n, "sym:overname"); + } else if (class_name == NULL || is_static) { + if (!addSymbol(go_name, n)) { + return SWIG_ERROR; + } + } else { + String *c = Copy(class_name); + Putc('+', c); + Append(c, go_name); + if (!addSymbol(c, n)) { + return SWIG_ERROR; + } + Delete(c); + } + + String *wname = Swig_name_wrapper(name); + if (overname != NULL) { + Append(wname, overname); + } + Setattr(n, "wrap:name", wname); + + ParmList *parms = Getattr(n, "parms"); + Setattr(n, "wrap:parms", parms); + + int r = makeWrappers(n, name, go_name, overname, wname, NULL, parms, + result, is_static); + if (r != SWIG_OK) { + return r; + } + + if (Getattr(n, "sym:overloaded") && Getattr(n, "sym:nextSibling") == NULL) { + String *receiver = class_receiver; + if (is_static || is_ctor_dtor) { + receiver = NULL; + } + r = makeDispatchFunction(n, go_name, receiver, is_static, NULL, false); + if (r != SWIG_OK) { + return r; + } + } + + Delete(wname); + Delete(go_name); + if (r1 != NULL) { + Delete(r1); + } + + return SWIG_OK; + } + + /* ---------------------------------------------------------------------- + * staticmemberfunctionHandler + * + * For some reason the language code removes the "storage" attribute + * for a static function before calling functionWrapper, which means + * that we have no way of knowing whether a function is static or + * not. That makes no sense in the Go context. Here we note that a + * function is static. + * ---------------------------------------------------------------------- */ + + int staticmemberfunctionHandler(Node *n) { + assert(!is_static_member_function); + is_static_member_function = true; + int r = Language::staticmemberfunctionHandler(n); + is_static_member_function = false; + return r; + } + + /* ---------------------------------------------------------------------- + * makeWrappers() + * + * Write out the various function wrappers. + * N: The function we are emitting. + * NAME: The function name. + * GO_NAME: The name of the function in Go. + * OVERNAME: The overload string for overloaded function. + * WNAME: The SWIG wrapped name--the name of the C function. + * BASE: A list of the names of base classes, in the case where this + * is is a vritual method not defined in the current class. + * PARMS: The parameters. + * RESULT: The result type. + * IS_STATIC: Whether this is a static method or member. + * ---------------------------------------------------------------------- */ + + int makeWrappers(Node *n, String *name, String *go_name, String *overname, + String *wname, List *base, ParmList *parms, + SwigType *result, bool is_static) { + + assert(result != NULL); + + bool needs_wrapper; + int r = goFunctionWrapper(n, name, go_name, overname, wname, base, parms, + result, is_static, &needs_wrapper); + if (r != SWIG_OK) { + return r; + } + + if (!gccgo_flag) { + r = gcFunctionWrapper(n, name, go_name, overname, wname, parms, result, + is_static, needs_wrapper); + if (r != SWIG_OK) { + return r; + } + r = gccFunctionWrapper(n, base, wname, parms, result); + if (r != SWIG_OK) { + return r; + } + } else { + r = gccgoFunctionWrapper(n, base, wname, parms, result); + if (r != SWIG_OK) { + return r; + } + } + + if (class_methods != NULL) { + Setattr(class_methods, Getattr(n, "name"), NewString("")); + } + + return SWIG_OK; + } + + /* ---------------------------------------------------------------------- + * goFunctionWrapper() + * + * Write out a function wrapper in Go. When not implementing a + * method, the actual code is all in C; here we just declare the C + * function. When implementing a method, we have to call the C + * function, because it will have a different name. If base is not + * NULL, then we are being called to forward a virtual method to a + * base class. + * ---------------------------------------------------------------------- */ + + int goFunctionWrapper(Node *n, String *name, String *go_name, + String *overname, String *wname, List *base, + ParmList *parms, SwigType *result, bool is_static, + bool *p_needs_wrapper) { + Wrapper *dummy = NewWrapper(); + emit_attach_parmmaps(parms, dummy); + Swig_typemap_attach_parms("default", parms, dummy); + Swig_typemap_attach_parms("go", parms, dummy); + int parm_count = emit_num_arguments(parms); + int required_count = emit_num_required(parms); + + String *receiver = class_receiver; + if (receiver != NULL && is_static) { + receiver = NULL; + } + + String *nodetype = Getattr(n, "nodeType"); + bool is_constructor = Cmp(nodetype, "constructor") == 0; + bool is_destructor = Cmp(nodetype, "destructor") == 0; + if (is_constructor || is_destructor) { + assert(class_receiver != NULL); + assert(base == NULL); + receiver = NULL; + } + + bool add_to_interface = (interfaces != NULL + && !is_constructor + && !is_destructor + && !is_static + && overname == NULL + && is_public(n)); + + bool needs_wrapper = (gccgo_flag + || receiver != NULL + || is_constructor + || is_destructor + || parm_count > required_count); + + // See whether any of the function parameters are represented by + // interface values When calling the C++ code, we need to convert + // back to a uintptr. + if (!needs_wrapper) { + Parm *p = parms; + for (int i = 0; i < parm_count; ++i) { + p = getParm(p); + String *ty = Getattr(p, "type"); + if (goTypeIsInterface(p, ty)) { + needs_wrapper = true; + break; + } + p = nextParm(p); + } + } + if (goTypeIsInterface(NULL, result)) { + needs_wrapper = true; + } + + *p_needs_wrapper = needs_wrapper; + + // If this is a method, first declare the C function we will call. + // If we do not need a wrapper, then we will only be writing a + // declaration. + String *wrapper_name = NULL; + if (needs_wrapper) { + wrapper_name = buildGoWrapperName(name, overname); + + Printv(f_go_wrappers, "func ", wrapper_name, "(", NULL); + if (parm_count > required_count) { + Printv(f_go_wrappers, "int", NULL); + } + Parm *p = getParm(parms); + Swig_cparm_name(p, 0); + int i = 0; + if (is_destructor) { + if (parm_count > required_count) { + Printv(f_go_wrappers, ", ", NULL); + } + Printv(f_go_wrappers, "uintptr", NULL); + ++i; + p = nextParm(p); + } else if (receiver != NULL && (base != NULL || !is_constructor)) { + if (parm_count > required_count) { + Printv(f_go_wrappers, ", ", NULL); + } + Printv(f_go_wrappers, receiver, NULL); + if (base == NULL) { + ++i; + p = nextParm(p); + } + } + for (; i < parm_count; ++i) { + p = getParm(p); + // Give the parameter a name we will use below. + Swig_cparm_name(p, i); + if (i > 0 + || (base != NULL && receiver != NULL) + || parm_count > required_count) { + Printv(f_go_wrappers, ", ", NULL); + } + String *tm = goWrapperType(p, Getattr(p, "type"), false); + Printv(f_go_wrappers, tm, NULL); + Delete(tm); + p = nextParm(p); + } + Printv(f_go_wrappers, ")", NULL); + if (is_constructor) { + Printv(f_go_wrappers, " ", class_receiver, NULL); + } else { + if (SwigType_type(result) != T_VOID) { + String *tm = goWrapperType(n, result, true); + Printv(f_go_wrappers, " ", tm, NULL); + Delete(tm); + } + } + + if (gccgo_flag) { + Printv(f_go_wrappers, " __asm__ (\"", go_prefix, "_", wname, "\")", + NULL); + } + + Printv(f_go_wrappers, "\n\n", NULL); + } + + // Start defining the Go function. + + Printv(f_go_wrappers, "func ", NULL); + + Parm *p = parms; + int pi = 0; + + // Add the receiver if this is a method. + if (receiver != NULL) { + Printv(f_go_wrappers, "(", NULL); + if (base != NULL && receiver != NULL) { + Printv(f_go_wrappers, "_swig_base", NULL); + } else { + Printv(f_go_wrappers, Getattr(p, "lname"), NULL); + p = nextParm(p); + ++pi; + } + Printv(f_go_wrappers, " ", receiver, ") ", NULL); + } + + Printv(f_go_wrappers, go_name, NULL); + if (overname != NULL) { + Printv(f_go_wrappers, overname, NULL); + } + Printv(f_go_wrappers, "(", NULL); + + // If we are doing methods, add this function to the interface. + if (add_to_interface) { + Printv(interfaces, "\t", go_name, "(", NULL); + } + + // Write out the parameters to both the function definition and + // the interface. + + String *parm_print = NewString(""); + + for (; pi < parm_count; ++pi) { + p = getParm(p); + if (pi == 0 && is_destructor) { + String *cl = exportedName(class_name); + Printv(parm_print, Getattr(p, "lname"), " ", cl, NULL); + Delete(cl); + } else { + if (pi > (receiver != NULL && base == NULL ? 1 : 0)) { + Printv(parm_print, ", ", NULL); + } + if (pi >= required_count) { + Printv(parm_print, "_swig_args ...interface{}", NULL); + break; + } + if (needs_wrapper) { + Printv(parm_print, Getattr(p, "lname"), " ", NULL); + } + String *tm = goType(p, Getattr(p, "type")); + Printv(parm_print, tm, NULL); + Delete(tm); + } + p = nextParm(p); + } + + Printv(parm_print, ")", NULL); + + // Write out the result type. + if (is_constructor) { + String *cl = exportedName(class_name); + Printv(parm_print, " ", cl, NULL); + Delete(cl); + } else { + if (SwigType_type(result) != T_VOID) { + String *tm = goType(n, result); + Printv(parm_print, " ", tm, NULL); + Delete(tm); + } + } + + Printv(f_go_wrappers, parm_print, NULL); + if (add_to_interface) { + Printv(interfaces, parm_print, "\n", NULL); + } + + // If this is a wrapper, we need to actually call the C function. + if (needs_wrapper) { + Printv(f_go_wrappers, " {\n", NULL); + + if (parm_count > required_count) { + Parm *p = parms; + int i; + for (i = 0; i < required_count; ++i) { + p = getParm(p); + p = nextParm(p); + } + for (; i < parm_count; ++i) { + p = getParm(p); + String *tm = goType(p, Getattr(p, "type")); + Printv(f_go_wrappers, "\tvar ", Getattr(p, "lname"), " ", tm, "\n", + NULL); + Printf(f_go_wrappers, "\tif len(_swig_args) > %d {\n", + i - required_count); + Printf(f_go_wrappers, "\t\t%s = _swig_args[%d].(%s)\n", + Getattr(p, "lname"), i - required_count, tm); + Printv(f_go_wrappers, "\t}\n", NULL); + Delete(tm); + p = nextParm(p); + } + } + + Printv(f_go_wrappers, "\t", NULL); + if (SwigType_type(result) != T_VOID) { + Printv(f_go_wrappers, "return ", NULL); + } + + Printv(f_go_wrappers, wrapper_name, "(", NULL); + + if (parm_count > required_count) { + Printv(f_go_wrappers, "len(_swig_args)", NULL); + } + + if (base != NULL && receiver != NULL) { + if (parm_count > required_count) { + Printv(f_go_wrappers, ", ", NULL); + } + Printv(f_go_wrappers, "_swig_base", NULL); + } + + Parm *p = parms; + for (int i = 0; i < parm_count; ++i) { + p = getParm(p); + if (i > 0 + || (base != NULL && receiver != NULL) + || parm_count > required_count) { + Printv(f_go_wrappers, ", ", NULL); + } + Printv(f_go_wrappers, Getattr(p, "lname"), NULL); + + // If this is a destructor, then the C function expects the + // C++ value, and we have the interface. We need to get the + // C++ value. The same is true for a type represented as an + // interface. + if ((i == 0 && is_destructor) + || ((i > 0 || receiver == NULL || base != NULL || is_constructor) + && goTypeIsInterface(p, Getattr(p, "type")))) { + Printv(f_go_wrappers, ".Swigcptr()", NULL); + } + + p = nextParm(p); + } + Printv(f_go_wrappers, ")\n", NULL); + Printv(f_go_wrappers, "}\n", NULL); + } else { + if (gccgo_flag) { + Printv(f_go_wrappers, " __asm__ (\"", go_prefix, "_", + wname, "\")\n", NULL); + } + } + + Printv(f_go_wrappers, "\n", NULL); + + Delete(wrapper_name); + DelWrapper(dummy); + + return SWIG_OK; + } + + /* ---------------------------------------------------------------------- + * gcFunctionWrapper() + * + * This is used for 6g/8g, not for gccgo. Write out the function + * wrapper which will be compiled with 6c/8c. + * ---------------------------------------------------------------------- */ + + int gcFunctionWrapper(Node *n, String *name, String *go_name, + String *overname, String *wname, ParmList *parms, + SwigType *result, bool is_static, bool needs_wrapper) { + Wrapper *f = NewWrapper(); + + Printv(f->def, "#pragma dynimport ", wname, " ", wname, " \"", + soname, "\"\n", NULL); + Printv(f->def, "void (*", wname, ")(void*);\n", NULL); + Printv(f->def, "\n", NULL); + Printv(f->def, "void\n", NULL); + + Wrapper *dummy = NewWrapper(); + emit_attach_parmmaps(parms, dummy); + Swig_typemap_attach_parms("default", parms, dummy); + Swig_typemap_attach_parms("gosize", parms, dummy); + int parm_count = emit_num_arguments(parms); + int required_count = emit_num_required(parms); + + String *parm_size = NewString(""); + + if (parm_count > required_count) { + Append(parm_size, "SWIG_PARM_SIZE"); + } + + if (class_receiver != NULL && !is_static) { + if (Len(parm_size) > 0) { + Append(parm_size, " + "); + } + Append(parm_size, "SWIG_PARM_SIZE"); + } + + Parm *p = parms; + for (int i = 0; i < parm_count; ++i) { + p = getParm(p); + addGcTypeSize(p, Getattr(p, "type"), parm_size); + p = nextParm(p); + } + + if (SwigType_type(result) != T_VOID) { + addGcTypeSize(n, result, parm_size); + } + + if (Len(parm_size) == 0) { + Append(parm_size, "1"); + } + + String *fn_name; + if (!needs_wrapper) { + fn_name = Copy(go_name); + if (overname != NULL) { + Append(fn_name, overname); + } + } else { + fn_name = buildGoWrapperName(name, overname); + } + + // \xc2\xb7 is UTF-8 for U+00B7 which is Unicode 'Middle Dot' + Printv(f->def, "\xc2\xb7", fn_name, + "(struct { uint8 x[", parm_size, "];} p)", NULL); + + Delete(fn_name); + Delete(parm_size); + + Printv(f->code, "{\n", NULL); + Printv(f->code, "\tcgocall(", wname, ", &p);\n", NULL); + Printv(f->code, "}\n", NULL); + Printv(f->code, "\n", NULL); + + Wrapper_print(f, f_gc_wrappers); + + DelWrapper(f); + DelWrapper(dummy); + + return SWIG_OK; + } + + /* ---------------------------------------------------------------------- + * getGcTypeSize() + * + * Return the size to use when passing a type from 6g/8g to 6c/8c. + * ---------------------------------------------------------------------- */ + + String *addGcTypeSize(Node *n, SwigType *type, String *orig) { + if (Len(orig) > 0) { + Append(orig, " + "); + } + + String *go = goType(n, type); + if (Cmp(go, "string") == 0) { + // A string has a pointer and a length. + Append(orig, "(2 * SWIG_PARM_SIZE)"); + } else if (Strncmp(go, "[]", 2) == 0) { + // A slice has a pointer, a length, and a capacity. The + // length and capacity are always 4 bytes. + Append(orig, "(SWIG_PARM_SIZE + 8)"); + } else if (Strcmp(go, "float") == 0 || Strcmp(go, "float64") == 0) { + Append(orig, "8"); + } else if (Strcmp(go, "complex") == 0 || Strcmp(go, "complex64") == 0) { + Append(orig, "8"); + } else if (Strcmp(go, "complex128") == 0) { + Append(orig, "16"); + } else { + Append(orig, "SWIG_PARM_SIZE"); + } + + return orig; + } + + /* ---------------------------------------------------------------------- + * gccFunctionWrapper() + * + * This is used for 6g/8g, not for gccgo. Write out the function + * wrapper which will be compiled with gcc. If the base parameter + * is not NULL, this is calls the base class method rather than + * executing the SWIG wrapper code. + * ---------------------------------------------------------------------- */ + + int gccFunctionWrapper(Node *n, List *base, String *wname, ParmList *parms, + SwigType *result) { + Wrapper *f = NewWrapper(); + + Swig_save("gccFunctionWrapper", n, "parms", NULL); + + Parm *base_parm = NULL; + if (base != NULL && !isStatic(n)) { + SwigType *base_type = Copy(Getattr(class_node, "classtype")); + SwigType_add_pointer(base_type); + base_parm = NewParm(base_type, NewString("arg1"), n); + set_nextSibling(base_parm, parms); + parms = base_parm; + } + + emit_parameter_variables(parms, f); + emit_attach_parmmaps(parms, f); + int parm_count = emit_num_arguments(parms); + int required_count = emit_num_required(parms); + + emit_return_variable(n, result, f); + + // Start the function definition. + + Printv(f->def, + "#ifdef __cplusplus\n", + "extern \"C\"\n", + "#endif\n", + NULL); + + Printv(f->def, "void\n", wname, "(void *swig_v)\n", "{\n", NULL); + + // The single function parameter is a pointer to the real argument + // values. Define the structure that it points to. + + Printv(f->code, "\tstruct swigargs {\n", NULL); + + if (parm_count > required_count) { + Printv(f->code, "\t\tint _swig_optargc;\n", NULL); + } + + Parm *p = parms; + for (int i = 0; i < parm_count; ++i) { + p = getParm(p); + String *ln = Getattr(p, "lname"); + SwigType *pt = Getattr(p, "type"); + String *ct = gcCTypeForGoValue(p, pt, ln); + Printv(f->code, "\t\t\t", ct, ";\n", NULL); + Delete(ct); + p = nextParm(p); + } + if (SwigType_type(result) != T_VOID) { + Printv(f->code, "\t\tint : 0;\n", NULL); + String *ln = NewString("result"); + String *ct = gcCTypeForGoValue(n, result, ln); + Delete(ln); + Printv(f->code, "\t\t", ct, ";\n", NULL); + Delete(ct); + } + Printv(f->code, "\t} *swig_a = (struct swigargs *) swig_v;\n", NULL); + + Printv(f->code, "\n", NULL); + + // Copy the input arguments out of the structure into the + // parameter variables. + + p = parms; + for (int i = 0; i < parm_count; ++i) { + p = getParm(p); + + String *tm = Getattr(p, "tmap:in"); + if (tm == NULL) { + Swig_warning(WARN_TYPEMAP_IN_UNDEF, input_file, line_number, + "Unable to use type %s as a function argument\n", + SwigType_str(Getattr(p, "type"), 0)); + } else { + String *ln = Getattr(p, "lname"); + String *input = NewString(""); + Printv(input, "swig_a->", ln, NULL); + Replaceall(tm, "$input", input); + Setattr(p, "emit:input", input); + if (i < required_count) { + Printv(f->code, "\t", tm, "\n", NULL); + } else { + Printf(f->code, "\tif (swig_a->_swig_optargc > %d) {\n", + i - required_count); + Printv(f->code, "\t\t", tm, "\n", NULL); + Printv(f->code, "\t}\n", NULL); + } + } + p = nextParm(p); + } + + Printv(f->code, "\n", NULL); + + // Do the real work of the function. + + checkConstraints(parms, f); + + emitGoAction(n, base, parms, result, f); + + argout(parms, f); + + cleanupFunction(n, f, parms); + + Printv(f->code, "}\n", NULL); + + Wrapper_print(f, f_c_wrappers); + + Swig_restore(n); + + DelWrapper(f); + if (base_parm != NULL) { + Delete(base_parm); + } + + return SWIG_OK; + } + + /* ---------------------------------------------------------------------- + * gccgoFunctionWrapper() + * + * This is used for gccgo, not 6g/8g. Write out the function + * wrapper which will be compiled with gcc. If the base parameter + * is not NULL, this is calls the base class method rather than + * executing the SWIG wrapper code. + * ---------------------------------------------------------------------- */ + + int gccgoFunctionWrapper(Node *n, List *base, String *wname, ParmList *parms, + SwigType *result) { + Wrapper *f = NewWrapper(); + + Swig_save("gccgoFunctionWrapper", n, "parms", NULL); + + Parm *base_parm = NULL; + if (base != NULL && !isStatic(n)) { + SwigType *base_type = Copy(Getattr(class_node, "classtype")); + SwigType_add_pointer(base_type); + base_parm = NewParm(base_type, NewString("arg1"), n); + set_nextSibling(base_parm, parms); + parms = base_parm; + } + + emit_parameter_variables(parms, f); + emit_attach_parmmaps(parms, f); + int parm_count = emit_num_arguments(parms); + int required_count = emit_num_required(parms); + + emit_return_variable(n, result, f); + + // Start the function definition. + + Printv(f->def, + "#ifdef __cplusplus\n", + "extern \"C\"\n", + "#endif\n", + NULL); + + String *fnname = NewString(""); + Printv(fnname, go_prefix, "_", wname, "(", NULL); + + if (parm_count > required_count) { + Printv(fnname, "int _swig_optargc", NULL); + } + + Parm *p = parms; + for (int i = 0; i < parm_count; ++i) { + p = getParm(p); + SwigType *pt = Getattr(p, "type"); + String *pn = NewString("g"); + Append(pn, Getattr(p, "lname")); + String *ct = gccgoCTypeForGoValue(p, pt, pn); + if (i > 0 || parm_count > required_count) { + Printv(fnname, ", ", NULL); + } + Printv(fnname, ct, NULL); + Delete(ct); + Delete(pn); + p = nextParm(p); + } + + Printv(fnname, ")", NULL); + + if (SwigType_type(result) == T_VOID) { + Printv(f->def, "void ", fnname, NULL); + } else { + String *ct = gccgoCTypeForGoValue(n, result, fnname); + Printv(f->def, ct, NULL); + Delete(ct); + } + + Printv(f->def, " {\n", NULL); + + Delete(fnname); + + if (SwigType_type(result) != T_VOID) { + String *ln = NewString("go_result"); + String *ct = gccgoCTypeForGoValue(n, result, ln); + Wrapper_add_local(f, "go_result", ct); + Delete(ct); + Delete(ln); + } + + // Copy the parameters into the variables which hold their values, + // applying appropriate transformations. + + p = parms; + for (int i = 0; i < parm_count; ++i) { + p = getParm(p); + + String *tm = Getattr(p, "tmap:in"); + if (tm == NULL) { + Swig_warning(WARN_TYPEMAP_IN_UNDEF, input_file, line_number, + "Unable to use type %s as a function argument\n", + SwigType_str(Getattr(p, "type"), 0)); + } else { + String *ln = Getattr(p, "lname"); + String *pn = NewString("g"); + Append(pn, ln); + Replaceall(tm, "$input", pn); + Setattr(p, "emit:input", pn); + if (i < required_count) { + Printv(f->code, " ", tm, "\n", NULL); + } else { + Printf(f->code, " if (_swig_optargc > %d) {\n", i - required_count); + Printv(f->code, " ", tm, "\n", NULL); + Printv(f->code, " }\n", NULL); + } + } + + p = nextParm(p); + } + + Printv(f->code, "\n", NULL); + + // Do the real work of the function. + + checkConstraints(parms, f); + + emitGoAction(n, base, parms, result, f); + + argout(parms, f); + + cleanupFunction(n, f, parms); + + if (SwigType_type(result) != T_VOID) { + Printv(f->code, " return go_result;\n", NULL); + } + + Printv(f->code, "}\n", NULL); + + Wrapper_print(f, f_c_wrappers); + + Swig_restore(n); + + DelWrapper(f); + if (base_parm != NULL) { + Delete(base_parm); + } + + return SWIG_OK; + } + + /* ----------------------------------------------------------------------- + * checkConstraints() + * + * Check parameter constraints if any. This is used for the C/C++ + * function. This assumes that each parameter has an "emit:input" + * property with the name to use to refer to that parameter. + * ----------------------------------------------------------------------- */ + + void checkConstraints(ParmList *parms, Wrapper *f) { + Parm *p = parms; + while (p != NULL) { + String *tm = Getattr(p, "tmap:check"); + if (tm == NULL) { + p = nextSibling(p); + } else { + Replaceall(tm, "$input", Getattr(p, "emit:input")); + Printv(f->code, tm, "\n\n", NULL); + p = Getattr(p, "tmap:check:next"); + } + } + } + + /* ----------------------------------------------------------------------- + * getGoAction() + * + * Get the action of the function. This is used for C/C++ function. + * ----------------------------------------------------------------------- */ + + void emitGoAction(Node *n, List *base, ParmList *parms, SwigType *result, + Wrapper *f) { + String *actioncode; + if (base == NULL || isStatic(n)) { + Swig_director_emit_dynamic_cast(n, f); + actioncode = emit_action(n); + } else { + // Call the base class method. + actioncode = NewString(""); + + String *current = NewString(""); + if (!gccgo_flag) { + Printv(current, "swig_a->", NULL); + } + Printv(current, Getattr(parms, "lname"), NULL); + + String *last = NULL; + int vc = 0; + for (Iterator bi = First(base); bi.item != NULL; bi = Next(bi)) { + Printf(actioncode, " %s *swig_b%d = (%s *)%s;\n", bi.item, vc, + bi.item, current); + Delete(current); + current = NewString(""); + Printf(current, "swig_b%d", vc); + ++vc; + last = bi.item; + } + + String *code = Copy(Getattr(n, "wrap:action")); + Replaceall(code, Getattr(parms, "lname"), current); + Printv(actioncode, code, "\n", NULL); + } + + Swig_save("emitGoAction", n, "type", "tmap:out", NULL); + + Setattr(n, "type", result); + + String *tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode); + if (tm == NULL) { + Swig_warning(WARN_TYPEMAP_OUT_UNDEF, input_file, line_number, + "Unable to use return type %s\n", + SwigType_str(result, 0)); + } else { + if (!gccgo_flag) { + Replaceall(tm, "$result", "swig_a->result"); + } else { + Replaceall(tm, "$result", "go_result"); + } + if (GetFlag(n, "feature:new")) { + Replaceall(tm, "$owner", "1"); + } else { + Replaceall(tm, "$owner", "0"); + } + Printv(f->code, tm, "\n", NULL); + Delete(tm); + } + + Swig_restore(n); + } + + /* ----------------------------------------------------------------------- + * argout() + * + * Handle argument output code if any. This is used for the C/C++ + * function. This assumes that each parameter has an "emit:input" + * property with the name to use to refer to that parameter. + * ----------------------------------------------------------------------- */ + + void argout(ParmList *parms, Wrapper *f) { + Parm *p = parms; + while (p != NULL) { + String *tm = Getattr(p, "tmap:argout"); + if (tm == NULL) { + p = nextSibling(p); + } else { + Replaceall(tm, "$result", "result"); + Replaceall(tm, "$input", Getattr(p, "emit:input")); + Printv(f->code, tm, "\n", NULL); + p = Getattr(p, "tmap:argout:next"); + } + } + } + + /* ----------------------------------------------------------------------- + * freearg() + * + * Handle argument cleanup code if any. This is used for the C/C++ + * function. This assumes that each parameter has an "emit:input" + * property with the name to use to refer to that parameter. + * ----------------------------------------------------------------------- */ + + String *freearg(ParmList *parms) { + String *ret = NewString(""); + Parm *p = parms; + while (p != NULL) { + String *tm = Getattr(p, "tmap:freearg"); + if (tm == NULL) { + p = nextSibling(p); + } else { + Replaceall(tm, "$input", Getattr(p, "emit:input")); + Printv(ret, tm, "\n", NULL); + p = Getattr(p, "tmap:freearg:next"); + } + } + return ret; + } + + /* ----------------------------------------------------------------------- + * cleanupFunction() + * + * Final function cleanup code. + * ----------------------------------------------------------------------- */ + + void cleanupFunction(Node *n, Wrapper *f, ParmList *parms) { + String *cleanup = freearg(parms); + Printv(f->code, cleanup, NULL); + + if (GetFlag(n, "feature:new")) { + String *tm = Swig_typemap_lookup("newfree", n, "result", 0); + if (tm != NULL) { + Replaceall(tm, "$source", "result"); + Printv(f->code, tm, "\n", NULL); + Delete(tm); + } + } + + Replaceall(f->code, "$cleanup", cleanup); + Delete(cleanup); + + Replaceall(f->code, "$symname", Getattr(n, "sym:name")); + } + + /* ----------------------------------------------------------------------- + * variableHandler() + * + * This exists just to set the making_variable_wrappers flag. + * ----------------------------------------------------------------------- */ + + virtual int variableHandler(Node *n) { + assert(!making_variable_wrappers); + making_variable_wrappers = true; + int r = Language::variableHandler(n); + making_variable_wrappers = false; + return r; + } + + /* ----------------------------------------------------------------------- + * constantWrapper() + * + * Product a const declaration. + * ------------------------------------------------------------------------ */ + + virtual int constantWrapper(Node *n) { + SwigType *type = Getattr(n, "type"); + + if (!SwigType_issimple(type) && SwigType_type(type) != T_STRING) { + return goComplexConstant(n, type); + } + + if (Getattr(n, "storage") != NULL + && Strcmp(Getattr(n, "storage"), "static") == 0) { + return goComplexConstant(n, type); + } + + String *go_name = buildGoName(Getattr(n, "sym:name"), false, false); + + if (!addSymbol(go_name, n)) { + Delete(go_name); + return SWIG_ERROR; + } + + String *tm = goType(n, type); + String *value = Getattr(n, "value"); + + String *copy = NULL; + if (SwigType_type(type) == T_BOOL) { + if (Cmp(value, "true") != 0 && Cmp(value, "false") != 0) { + return goComplexConstant(n, type); + } + } else if (SwigType_type(type) == T_STRING + || SwigType_type(type) == T_CHAR) { + // Backslash sequences are somewhat different in Go and C/C++. + if (Strchr(value, '\\') != NULL) { + return goComplexConstant(n, type); + } + } else { + // Accept a 0x prefix, and strip combinations of u and l + // suffixes. Otherwise accept digits, decimal point, and + // exponentiation. Treat anything else as too complicated to + // handle as a Go constant. + char *p = Char(value); + int len = strlen(p); + bool need_copy = false; + while (len > 0) { + char c = p[len - 1]; + if (c != 'l' && c != 'L' && c != 'u' && c != 'U') { + break; + } + --len; + need_copy = true; + } + bool is_hex = false; + int i = 0; + if (p[0] == '0' && (p[1] == 'x' || p[1] == 'X')) { + i = 2; + is_hex = true; + } + for (; i < len; ++i) { + switch (p[i]) { + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + break; + case 'a': case 'b': case 'c': case 'd': case 'f': + case 'A': case 'B': case 'C': case 'D': case 'F': + if (!is_hex) { + return goComplexConstant(n, type); + } + break; + case '.': case 'e': case 'E': case '+': case '-': + break; + default: + return goComplexConstant(n, type); + } + } + if (need_copy) { + copy = Copy(value); + Replaceall(copy, p + len, ""); + value = copy; + } + } + + Printv(f_go_wrappers, "const ", go_name, " ", tm, " = ", NULL); + if (SwigType_type(type) == T_STRING) { + Printv(f_go_wrappers, "\"", value, "\"", NULL); + } else if (SwigType_type(type) == T_CHAR) { + Printv(f_go_wrappers, "'", value, "'", NULL); + } else { + Printv(f_go_wrappers, value, NULL); + } + + Printv(f_go_wrappers, "\n", NULL); + + Delete(tm); + Delete(go_name); + if (copy != NULL) { + Delete(copy); + } + + return SWIG_OK; + } + + /* ---------------------------------------------------------------------- + * enumDeclaration() + * + * A C++ enum type turns into a Named go int type. + * ---------------------------------------------------------------------- */ + + virtual int enumDeclaration(Node *n) { + String *name = goEnumName(n); + if (Strcmp(name, "int") != 0) { + if (!ImportMode || imported_package == NULL) { + Printv(f_go_wrappers, "type ", name, " int\n", NULL); + } else { + String *nw = NewString(""); + Printv(nw, imported_package, ".", name, NULL); + Setattr(n, "go:enumname", nw); + } + } + Delete(name); + + return Language::enumDeclaration(n); + } + + /* ----------------------------------------------------------------------- + * enumvalueDeclaration() + * + * Declare a single value of an enum type. We fetch the value by + * calling a C/C++ function. + * ------------------------------------------------------------------------ */ + + virtual int enumvalueDeclaration(Node *n) { + if (!is_public(n)) { + return SWIG_OK; + } + if (Getattr(parentNode(n), "unnamed") != NULL) { + Setattr(n, "type", NewString("int")); + } else { + Setattr(n, "type", Getattr(parentNode(n), "enumtype")); + } + return goComplexConstant(n, Getattr(n, "type")); + } + + /* ----------------------------------------------------------------------- + * goComplexConstant() + * + * Handle a const declaration for something which is not a Go constant. + * ------------------------------------------------------------------------ */ + + int goComplexConstant(Node *n, SwigType *type) { + String *get = NewString(""); + Printv(get, "result = ", NULL); + + char quote; + if (Getattr(n, "wrappedasconstant") != NULL) { + quote = '\0'; + } else if (SwigType_type(type) == T_CHAR) { + quote = '\''; + } else if (SwigType_type(type) == T_STRING) { + quote = '"'; + } else { + quote = '\0'; + } + + if (quote != '\0') { + Printf(get, "%c", quote); + } + + Printv(get, Getattr(n, "value"), NULL); + + if (quote != '\0') { + Printf(get, "%c", quote); + } + + Printv(get, ";\n", NULL); + Setattr(n, "wrap:action", get); + + String* symname = Getattr(n, "sym:name"); + if (symname == NULL) { + symname = Getattr(n, "name"); + } + + String *sname = Copy(symname); + if (class_name != NULL) { + Append(sname, "_"); + Append(sname, class_name); + } + + String *go_name = NewString("_swig_get"); + if (class_name != NULL) { + Append(go_name, class_name); + Append(go_name, "_"); + } + Append(go_name, sname); + + String *wname = Swig_name_wrapper(sname); + Setattr(n, "wrap:name", wname); + + int r = makeWrappers(n, sname, go_name, NULL, wname, NULL, NULL, type, + true); + + if (r != SWIG_OK) { + return r; + } + + String *varname = buildGoName(symname, true, false); + String *t = goType(n, type); + Printv(f_go_wrappers, "var ", varname, " ", t, " = ", go_name, "()\n", + NULL); + + Delete(varname); + Delete(t); + Delete(go_name); + Delete(sname); + + return SWIG_OK; + } + + /* ------------------------------------------------------------ + * classHandler() + * + * For a C++ class, in Go we generate both a struct and an + * interface. The interface will declare all the class public + * methods. We will define all the methods on the struct, so that + * the struct meets the interface. We then expect users of the + * class to use the interface. + * ------------------------------------------------------------ */ + + virtual int classHandler(Node *n) { + class_node = n; + + List *baselist = Getattr(n, "bases"); + bool has_base_classes = baselist != NULL && Len(baselist) > 0; + + String *name = Getattr(n, "sym:name"); + + String *go_name = exportedName(name); + + String *go_type_name = goCPointerType(Getattr(n, "classtypeobj"), true); + + class_name = name; + class_receiver = go_type_name; + class_methods = NewHash(); + + int isdir = GetFlag(n, "feature:director"); + int isnodir = GetFlag(n, "feature:nodirector"); + bool is_director = isdir && !isnodir; + + Printv(f_go_wrappers, "type ", go_type_name, " uintptr\n\n", NULL); + + // A method to return the pointer to the C++ class. This is used + // by generated code to convert between the interface and the C++ + // value. + Printv(f_go_wrappers, "func (p ", go_type_name, ") Swigcptr() uintptr {\n", + NULL); + Printv(f_go_wrappers, "\treturn (uintptr)(p)\n", NULL); + Printv(f_go_wrappers, "}\n\n", NULL); + + // A method used as a marker for the class, to avoid invalid + // interface conversions when using multiple inheritance. + Printv(f_go_wrappers, "func (p ", go_type_name, ") SwigIs", go_name, + "() {\n", NULL); + Printv(f_go_wrappers, "}\n\n", NULL); + + if (is_director) { + // Return the interface passed to the NewDirector function. + Printv(f_go_wrappers, "func (p ", go_type_name, + ") DirectorInterface() interface{} {\n", NULL); + Printv(f_go_wrappers, "\treturn nil\n", NULL); + Printv(f_go_wrappers, "}\n\n", NULL); + } + + // We have seen a definition for this type. + Setattr(defined_types, go_name, go_name); + Setattr(defined_types, go_type_name, go_type_name); + + interfaces = NewString(""); + + int r = Language::classHandler(n); + if (r != SWIG_OK) { + return r; + } + + if (has_base_classes) { + // For each method defined in a base class but not defined in + // this class, we need to define the method in this class. We + // can't use anonymous field inheritance because it works + // differently in Go and in C++. + + Hash *local = NewHash(); + for (Node *ni = Getattr(n, "firstChild"); + ni != NULL; + ni = nextSibling(ni)) { + + if (!is_public(ni)) { + continue; + } + + String *type = Getattr(ni, "nodeType"); + if (Cmp(type, "constructor") == 0 || Cmp(type, "destructor") == 0) { + continue; + } + + String *cname = Getattr(ni, "sym:name"); + if (cname == NULL) { + cname = Getattr(ni, "name"); + } + if (cname != NULL) { + Setattr(local, cname, NewString("")); + } + } + + for (Iterator b = First(baselist); b.item != NULL; b = Next(b)) { + List *bases = NewList(); + Append(bases, Getattr(b.item, "classtype")); + int r = addBase(n, b.item, bases, local); + if (r != SWIG_OK) { + return r; + } + Delete(bases); + } + + Delete(local); + + Hash *parents = NewHash(); + addFirstBaseInterface(n, parents, baselist); + int r = addExtraBaseInterfaces(n, parents, baselist); + Delete(parents); + if (r != SWIG_OK) { + return r; + } + } + + Printv(f_go_wrappers, "type ", go_name, " interface {\n", NULL); + Printv(f_go_wrappers, "\tSwigcptr() uintptr\n", NULL); + Printv(f_go_wrappers, "\tSwigIs", go_name, "()\n", NULL); + + if (is_director) { + Printv(f_go_wrappers, "\tDirectorInterface() interface{}\n", NULL); + } + + Append(f_go_wrappers, interfaces); + Printf(f_go_wrappers, "}\n\n", NULL); + Delete(interfaces); + + interfaces = NULL; + class_name = NULL; + class_receiver = NULL; + class_node = NULL; + Delete(class_methods); + class_methods = NULL; + + Delete(go_type_name); + + return SWIG_OK; + } + + /* ------------------------------------------------------------ + * addBase() + * + * Implement methods and members defined in a parent class for a + * child class. + * ------------------------------------------------------------ */ + + int addBase(Node *n, Node *base, List *bases, Hash *local) { + if (GetFlag(base, "feature:ignore")) { + return SWIG_OK; + } + + for (Node *ni = Getattr(base, "firstChild"); + ni != NULL; + ni = nextSibling(ni)) { + + if (GetFlag(ni, "feature:ignore")) { + continue; + } + + if (!is_public(ni)) { + continue; + } + + String *type = Getattr(ni, "nodeType"); + if (Strcmp(type, "constructor") == 0 + || Strcmp(type, "destructor") == 0 + || Strcmp(type, "enum") == 0 + || Strcmp(type, "using") == 0) { + continue; + } + String *storage = Getattr(ni, "storage"); + if (Strcmp(storage, "typedef") == 0 || Strcmp(storage, "friend") == 0) { + continue; + } + + String *mname = Getattr(ni, "sym:name"); + if (mname == NULL) { + continue; + } + + String *lname = Getattr(ni, "name"); + if (Getattr(class_methods, lname) != NULL) { + continue; + } + if (Getattr(local, lname) != NULL) { + continue; + } + Setattr(local, lname, NewString("")); + + String *ty = NewString(Getattr(ni, "type")); + SwigType_push(ty, Getattr(ni, "decl")); + String *fullty = SwigType_typedef_resolve_all(ty); + bool is_function = SwigType_isfunction(fullty); + Delete(ty); + Delete(fullty); + + if (is_function) { + int r = goBaseMethod(n, bases, ni); + if (r != SWIG_OK) { + return r; + } + + if (Getattr(ni, "sym:overloaded") != NULL) { + for (Node *on = Getattr(ni, "sym:nextSibling"); + on != NULL; + on = Getattr(on, "sym:nextSibling")) { + r = goBaseMethod(n, bases, on); + if (r != SWIG_OK) { + return r; + } + } + + String *receiver = class_receiver; + bool is_static = isStatic(ni); + if (is_static) { + receiver = NULL; + } + String *go_name = buildGoName(Getattr(ni, "sym:name"), is_static, + false); + r = makeDispatchFunction(ni, go_name, receiver, is_static, NULL, + false); + Delete(go_name); + if (r != SWIG_OK) { + return r; + } + } + } else { + int r = goBaseVariable(n, bases, ni); + if (r != SWIG_OK) { + return r; + } + } + } + + List *baselist = Getattr(base, "bases"); + if (baselist != NULL && Len(baselist) > 0) { + for (Iterator b = First(baselist); b.item != NULL; b = Next(b)) { + List *nb = Copy(bases); + Append(nb, Getattr(b.item, "classtype")); + int r = addBase(n, b.item, nb, local); + Delete(nb); + if (r != SWIG_OK) { + return r; + } + } + } + + return SWIG_OK; + } + + /* ------------------------------------------------------------ + * goBaseMethod() + * + * Implement a method defined in a parent class for a child class. + * ------------------------------------------------------------ */ + + int goBaseMethod(Node *method_class, List *bases, Node *method) { + String *symname = Getattr(method, "sym:name"); + if (!validIdentifier(symname)) { + return SWIG_OK; + } + + String *name = NewString(""); + Printv(name, Getattr(method_class, "sym:name"), "_", symname, NULL); + + bool is_static = isStatic(method); + + String *go_name = buildGoName(name, is_static, false); + + String *overname = NULL; + if (Getattr(method, "sym:overloaded")) { + overname = Getattr(method, "sym:overname"); + } + String *wname = Swig_name_wrapper(name); + if (overname != NULL) { + Append(wname, overname); + } + + String *result = NewString(Getattr(method, "type")); + SwigType_push(result, Getattr(method, "decl")); + if (SwigType_isqualifier(result)) { + Delete(SwigType_pop(result)); + } + Delete(SwigType_pop_function(result)); + + // If the base method is imported, wrap:action may not be set. + Swig_save("goBaseMethod", method, "wrap:action", "parms", NULL); + if (Getattr(method, "wrap:action") == NULL) { + if (!is_static) { + Swig_MethodToFunction(method, getNSpace(), getClassType(), + (Getattr(method, "template") != NULL + ? SmartPointer + : Extend | SmartPointer), + NULL, false); + // Remove any self parameter that was just added. + ParmList *parms = Getattr(method, "parms"); + if (parms != NULL && Getattr(parms, "self") != NULL) { + parms = CopyParmList(nextSibling(parms)); + Setattr(method, "parms", parms); + } + } else { + String *call = Swig_cfunction_call(Getattr(method, "name"), + Getattr(method, "parms")); + Setattr(method, "wrap:action", Swig_cresult(Getattr(method, "type"), + "result", call)); + } + } + + int r = makeWrappers(method, name, go_name, overname, wname, bases, + Getattr(method, "parms"), result, is_static); + + Swig_restore(method); + + Delete(result); + Delete(go_name); + Delete(name); + + return r; + } + + /* ------------------------------------------------------------ + * goBaseVariable() + * + * Add accessors for a member variable defined in a parent class for + * a child class. + * ------------------------------------------------------------ */ + + int goBaseVariable(Node *var_class, List *bases, Node *var) { + if (isStatic(var)) { + return SWIG_OK; + } + + String *var_name = buildGoName(Getattr(var, "sym:name"), false, false); + + Swig_save("goBaseVariable", var, "type", "wrap:action", NULL); + + // For a pointer type we apparently have to wrap in the decl. + SwigType *var_type = NewString(Getattr(var, "type")); + SwigType_push(var_type, Getattr(var, "decl")); + Setattr(var, "type", var_type); + + SwigType *vt = Copy(var_type); + if (SwigType_isclass(vt)) { + SwigType_add_pointer(vt); + } + + int flags = Extend | SmartPointer | use_naturalvar_mode(var); + if (is_non_virtual_protected_access(var)) { + flags |= CWRAP_ALL_PROTECTED_ACCESS; + } + + String *mname = Swig_name_member(getNSpace(), + Getattr(var_class, "sym:name"), + var_name); + + if (is_assignable(var)) { + for (Iterator ki = First(var); ki.key != NULL; ki = Next(ki)) { + if (Strncmp(ki.key, "tmap:", 5) == 0) { + Delattr(var, ki.key); + } + } + Swig_save("goBaseVariableSet", var, "name", "sym:name", "type", NULL); + + String *mname_set = NewString("Set"); + Append(mname_set, mname); + + String *go_name = NewString("Set"); + Append(go_name, var_name); + + Swig_MembersetToFunction(var, class_name, flags); + + String *wname = Swig_name_wrapper(mname_set); + ParmList *parms = NewParm(vt, var_name, var); + String *result = NewString("void"); + int r = makeWrappers(var, mname_set, go_name, NULL, wname, bases, parms, + result, false); + if (r != SWIG_OK) { + return r; + } + Delete(wname); + Delete(parms); + Delete(result); + Delete(go_name); + Delete(mname_set); + + Swig_restore(var); + for (Iterator ki = First(var); ki.key != NULL; ki = Next(ki)) { + if (Strncmp(ki.key, "tmap:", 5) == 0) { + Delattr(var, ki.key); + } + } + } + + Swig_MembergetToFunction(var, class_name, flags); + + String *mname_get = NewString("Get"); + Append(mname_get, mname); + + String *go_name = NewString("Get"); + Append(go_name, var_name); + + String *wname = Swig_name_wrapper(mname_get); + + int r = makeWrappers(var, mname_get, go_name, NULL, wname, bases, NULL, + vt, false); + if (r != SWIG_OK) { + return r; + } + + Delete(wname); + Delete(mname_get); + Delete(go_name); + Delete(mname); + Delete(var_name); + Delete(var_type); + Delete(vt); + + Swig_restore(var); + + return SWIG_OK; + } + + /* ------------------------------------------------------------ + * addFirstBaseInterface() + * + * When a C++ class uses multiple inheritance, we can use the C++ + * pointer for the first base class but not for any subsequent base + * classes. However, the Go interface will match the interface for + * all the base classes. To avoid accidentally treating a class as + * a pointer to a base class other than the first one, we use an + * isClassname method. This function adds those methods as + * required. + * + * For convenience when using multiple inheritance, we also add + * functions to retrieve the base class pointers. + * ------------------------------------------------------------ */ + + void addFirstBaseInterface(Node *n, Hash *parents, List *bases) { + if (bases == NULL || Len(bases) == 0) { + return; + } + Iterator b = First(bases); + if (!GetFlag(b.item, "feature:ignore")) { + String *go_name = buildGoName(Getattr(n, "sym:name"), false, false); + String *go_type_name = goCPointerType(Getattr(n, "classtypeobj"), true); + String *go_base_name = exportedName(Getattr(b.item, "sym:name")); + String *go_base_type = goType(n, Getattr(b.item, "classtypeobj")); + String *go_base_type_name = goCPointerType(Getattr(b.item, + "classtypeobj"), + true); + + Printv(f_go_wrappers, "func (p ", go_type_name, ") SwigIs", go_base_name, + "() {\n", NULL); + Printv(f_go_wrappers, "}\n\n", NULL); + + Printv(interfaces, "\tSwigIs", go_base_name, "()\n", NULL); + + Printv(f_go_wrappers, "func (p ", go_type_name, ") SwigGet", go_base_name, + "() ", go_base_type, " {\n", NULL); + Printv(f_go_wrappers, "\treturn ", go_base_type_name, + "(p.Swigcptr())\n", NULL); + Printv(f_go_wrappers, "}\n\n", NULL); + + Printv(interfaces, "\tSwigGet", go_base_name, "() ", go_base_type, "\n", + NULL); + + Setattr(parents, go_base_name, NewString("")); + + Delete(go_name); + Delete(go_type_name); + Delete(go_base_type); + Delete(go_base_type_name); + } + + addFirstBaseInterface(n, parents, Getattr(b.item, "bases")); + } + + /* ------------------------------------------------------------ + * addExtraBaseInterfaces() + * + * Add functions to retrieve the base class pointers for all base + * classes other than the first. + * ------------------------------------------------------------ */ + + int addExtraBaseInterfaces(Node *n, Hash *parents, List *bases) { + Iterator b = First(bases); + + Node *fb = b.item; + + for (b = Next(b); b.item != NULL; b = Next(b)) { + if (GetFlag(b.item, "feature:ignore")) { + continue; + } + + String *go_base_name = exportedName(Getattr(b.item, "sym:name")); + + Swig_save("addExtraBaseInterface", n, "wrap:action", "wrap:name", + "wrap:parms", NULL); + + SwigType *type = Copy(Getattr(n, "classtypeobj")); + SwigType_add_pointer(type); + Parm *parm = NewParm(type, "self", n); + Setattr(n, "wrap:parms", parm); + + String *pn = Swig_cparm_name(parm, 0); + String *action = NewString(""); + Printv(action, "result = (", Getattr(b.item, "classtype"), "*)", pn, + ";", NULL); + Delete(pn); + + Setattr(n, "wrap:action", action); + + String *name = Copy(class_name); + Append(name, "_SwigGet"); + Append(name, go_base_name); + + String *go_name = NewString("SwigGet"); + String *c1 = exportedName(go_base_name); + Append(go_name, c1); + Delete(c1); + + String *wname = Swig_name_wrapper(name); + Setattr(n, "wrap:name", wname); + + SwigType *result = Copy(Getattr(b.item, "classtypeobj")); + SwigType_add_pointer(result); + + int r = makeWrappers(n, name, go_name, NULL, wname, NULL, parm, result, + false); + if (r != SWIG_OK) { + return r; + } + + Swig_restore(n); + + Setattr(parents, go_base_name, NewString("")); + + Delete(go_name); + Delete(type); + Delete(parm); + Delete(action); + Delete(result); + + String *ns = NewString(""); + addParentExtraBaseInterfaces(n, parents, b.item, false, ns); + Delete(ns); + } + + if (!GetFlag(fb, "feature:ignore")) { + String *ns = NewString(""); + addParentExtraBaseInterfaces(n, parents, fb, true, ns); + Delete(ns); + } + + return SWIG_OK; + } + + /* ------------------------------------------------------------ + * addParentExtraBaseInterfaces() + * + * Add functions to retrieve the base class pointers for all base + * classes of parents other than the first base class at each level. + * ------------------------------------------------------------ */ + + void addParentExtraBaseInterfaces(Node *n, Hash *parents, Node *base, + bool is_base_first, String *sofar) { + List *baselist = Getattr(base, "bases"); + if (baselist == NULL || Len(baselist) == 0) { + return; + } + + String *go_this_base_name = exportedName(Getattr(base, "sym:name")); + + String *sf = NewString(""); + Printv(sf, sofar, ".SwigGet", go_this_base_name, "()", NULL); + + Iterator b = First(baselist); + + if (is_base_first) { + if (!GetFlag(b.item, "feature:ignore")) { + addParentExtraBaseInterfaces(n, parents, b.item, true, sf); + } + + b = Next(b); + if (b.item == NULL) { + return; + } + } + + String *go_name = buildGoName(Getattr(n, "sym:name"), false, false); + String *go_type_name = goCPointerType(Getattr(n, "classtypeobj"), true); + + for (; b.item != NULL; b = Next(b)) { + if (GetFlag(b.item, "feature:ignore")) { + continue; + } + + String *go_base_name = exportedName(Getattr(b.item, "sym:name")); + + if (Getattr(parents, go_base_name) == NULL) { + Printv(f_go_wrappers, "func (p ", go_type_name, ") SwigGet", + go_base_name, "() ", go_base_name, " {\n", NULL); + Printv(f_go_wrappers, "\treturn p", sf, ".SwigGet", go_base_name, + "()\n", NULL); + Printv(f_go_wrappers, "}\n\n", NULL); + + Printv(interfaces, "\tSwigGet", go_base_name, "() ", go_base_name, "\n", + NULL); + + addParentExtraBaseInterfaces(n, parents, b.item, false, sf); + + Setattr(parents, go_base_name, NewString("")); + } + } + + Delete(go_name); + Delete(go_type_name); + Delete(go_this_base_name); + Delete(sf); + } + + /* ------------------------------------------------------------ + * classDirectorInit + * + * Add support for a director class. + * + * Virtual inheritance is different in Go and C++. We implement + * director classes by defining a new function in Go, + * NewDirectorClassname, which takes a empty interface value and + * creates an instance of a new child class. The new child class + * refers all methods back to Go. The Go code checks whether the + * value passed to NewDirectorClassname implements that method; if + * it does, it calls it, otherwise it calls back into C++. + * ------------------------------------------------------------ */ + + int classDirectorInit(Node *n) { + // Because we use a different function to handle inheritance in + // Go, ordinary creations of the object should not create a + // director object. + Delete(director_ctor_code); + director_ctor_code = NewString("$nondirector_new"); + + class_node = n; + + String *name = Getattr(n, "sym:name"); + + assert(class_name == NULL); + class_name = name; + + String *go_name = exportedName(name); + + String *go_type_name = goCPointerType(Getattr(n, "classtypeobj"), true); + + assert(class_receiver == NULL); + class_receiver = go_type_name; + + String *director_struct_name = NewString("_swig_Director"); + Append(director_struct_name, go_name); + + String* cxx_director_name = NewString("SwigDirector_"); + Append(cxx_director_name, name); + + // The Go type of the director class. + Printv(f_go_wrappers, "type ", director_struct_name, " struct {\n", NULL); + Printv(f_go_wrappers, "\t", go_type_name, "\n", NULL); + Printv(f_go_wrappers, "\tv interface{}\n", NULL); + Printv(f_go_wrappers, "}\n\n", NULL); + + Printv(f_go_wrappers, "func (p *", director_struct_name, + ") Swigcptr() uintptr {\n", NULL); + Printv(f_go_wrappers, "\treturn p.", go_type_name, ".Swigcptr()\n", NULL); + Printv(f_go_wrappers, "}\n\n", NULL); + + Printv(f_go_wrappers, "func (p *", director_struct_name, ") SwigIs", + go_name, "() {\n", NULL); + Printv(f_go_wrappers, "}\n\n", NULL); + + Printv(f_go_wrappers, "func (p *", director_struct_name, + ") DirectorInterface() interface{} {\n", NULL); + Printv(f_go_wrappers, "\treturn p.v\n", NULL); + Printv(f_go_wrappers, "}\n\n", NULL); + + // Start defining the director class. + Printv(f_c_directors_h, "class ", cxx_director_name, " : public ", + Getattr(n, "classtype"), "\n", NULL); + Printv(f_c_directors_h, "{\n", NULL); + Printv(f_c_directors_h, " public:\n", NULL); + + Delete(director_struct_name); + Delete(cxx_director_name); + + class_methods = NewHash(); + + return SWIG_OK; + } + + /* ------------------------------------------------------------ + * classDirectorConstructor + * + * Emit a constructor for a director class. + * ------------------------------------------------------------ */ + + int classDirectorConstructor(Node *n) { + bool is_ignored = GetFlag(n, "feature:ignore"); + + String *name = Getattr(n, "sym:name"); + if (name == NULL) { + assert(is_ignored); + name = Getattr(n, "name"); + } + + String *overname = NULL; + if (Getattr(n, "sym:overloaded")) { + overname = Getattr(n, "sym:overname"); + } + + String *go_name = exportedName(name); + + ParmList *parms = Getattr(n, "parms"); + Setattr(n, "wrap:parms", parms); + + String *cn = exportedName(Getattr(parentNode(n), "sym:name")); + + String *go_type_name = goCPointerType(Getattr(parentNode(n), + "classtypeobj"), + true); + + String *director_struct_name = NewString("_swig_Director"); + Append(director_struct_name, cn); + + String *fn_name = NewString("_swig_NewDirector"); + Append(fn_name, cn); + Append(fn_name, go_name); + + if (overname == NULL && !is_ignored) { + if (!addSymbol(fn_name, n)) { + return SWIG_ERROR; + } + } + + String *wname = Swig_name_wrapper(fn_name); + + if (overname != NULL) { + Append(wname, overname); + } + Setattr(n, "wrap:name", wname); + + bool is_static = isStatic(n); + + Wrapper *dummy = NewWrapper(); + emit_attach_parmmaps(parms, dummy); + DelWrapper(dummy); + + Swig_typemap_attach_parms("go", parms, NULL); + int parm_count = emit_num_arguments(parms); + + String *func_name = NewString("NewDirector"); + Append(func_name, go_name); + + String *func_with_over_name = Copy(func_name); + if (overname != NULL) { + Append(func_with_over_name, overname); + } + + SwigType *first_type = NewString("void"); + SwigType_add_pointer(first_type); + Parm *first_parm = NewParm(first_type, "swig_p", n); + set_nextSibling(first_parm, parms); + Setattr(first_parm, "lname", "p"); + + Parm *p = parms; + for (int i = 0; i < parm_count; ++i) { + p = getParm(p); + Swig_cparm_name(p, i); + p = nextParm(p); + } + + if (!is_ignored) { + // Declare the C++ wrapper. + Printv(f_go_wrappers, "func ", fn_name, NULL); + if (overname != NULL) { + Printv(f_go_wrappers, overname, NULL); + } + Printv(f_go_wrappers, "(*", director_struct_name, NULL); + + p = parms; + for (int i = 0; i < parm_count; ++i) { + p = getParm(p); + String *tm = goType(p, Getattr(p, "type")); + Printv(f_go_wrappers, ", ", tm, NULL); + Delete(tm); + p = nextParm(p); + } + + Printv(f_go_wrappers, ") ", go_type_name, NULL); + + if (gccgo_flag) { + Printv(f_go_wrappers, " __asm__(\"", go_prefix, "_", wname, "\")", + NULL); + } + + Printv(f_go_wrappers, "\n\n", NULL); + + Printv(f_go_wrappers, "func ", func_with_over_name, "(v interface{}", + NULL); + + p = parms; + for (int i = 0; i < parm_count; ++i) { + p = getParm(p); + // Set the lname parameter. + Printv(f_go_wrappers, ", ", Getattr(p, "lname"), " ", NULL); + String *tm = goType(p, Getattr(p, "type")); + Printv(f_go_wrappers, tm, NULL); + Delete(tm); + p = nextParm(p); + } + + Printv(f_go_wrappers, ") ", cn, " {\n", NULL); + + Printv(f_go_wrappers, "\tp := &", director_struct_name, "{0, v}\n", + NULL); + Printv(f_go_wrappers, "\tp.", class_receiver, " = ", fn_name, NULL); + if (overname != NULL) { + Printv(f_go_wrappers, overname, NULL); + } + Printv(f_go_wrappers, "(p", NULL); + + p = parms; + for (int i = 0; i < parm_count; ++i) { + p = getParm(p); + Printv(f_go_wrappers, ", ", Getattr(p, "lname"), NULL); + p = nextParm(p); + } + + Printv(f_go_wrappers, ")\n", NULL); + Printv(f_go_wrappers, "\treturn p\n", NULL); + Printv(f_go_wrappers, "}\n\n", NULL); + + SwigType *result = Copy(Getattr(parentNode(n), "classtypeobj")); + SwigType_add_pointer(result); + + Swig_save("classDirectorConstructor", n, "wrap:name", "wrap:action", + NULL); + + Setattr(n, "wrap:name", Swig_name_wrapper(name)); + + String *action = NewString(""); + Printv(action, "result = new SwigDirector_", class_name, "(", NULL); + String *pname = Swig_cparm_name(NULL, 0); + Printv(action, pname, NULL); + Delete(pname); + p = parms; + for (int i = 0; i < parm_count; ++i) { + p = getParm(p); + String *pname = Swig_cparm_name(NULL, i + 1); + Printv(action, ", ", NULL); + if (SwigType_isreference(Getattr(p, "type"))) { + Printv(action, "*", NULL); + } + Printv(action, pname, NULL); + Delete(pname); + p = nextParm(p); + } + Printv(action, ");", NULL); + Setattr(n, "wrap:action", action); + + if (!gccgo_flag) { + int r = gcFunctionWrapper(n, fn_name, fn_name, overname, wname, + first_parm, result, is_static, false); + if (r != SWIG_OK) { + return r; + } + r = gccFunctionWrapper(n, NULL, wname, first_parm, result); + if (r != SWIG_OK) { + return r; + } + } else { + int r = gccgoFunctionWrapper(n, NULL, wname, first_parm, result); + if (r != SWIG_OK) { + return r; + } + } + + Swig_restore(n); + + Delete(result); + } + + String *cxx_director_name = NewString("SwigDirector_"); + Append(cxx_director_name, class_name); + + String *decl = Swig_method_decl(NULL, Getattr(n, "decl"), + cxx_director_name, first_parm, 0, 0); + Printv(f_c_directors_h, " ", decl, ";\n", NULL); + Delete(decl); + + decl = Swig_method_decl(NULL, Getattr(n, "decl"), + cxx_director_name, first_parm, 0, 0); + Printv(f_c_directors, cxx_director_name, "::", decl, "\n", NULL); + Delete(decl); + + Printv(f_c_directors, " : ", Getattr(parentNode(n), "classtype"), "(", + NULL); + + p = parms; + for (int i = 0; i < parm_count; ++i) { + p = getParm(p); + if (i > 0) { + Printv(f_c_directors, ", ", NULL); + } + String *pn = Getattr(p, "name"); + assert(pn != NULL); + Printv(f_c_directors, pn, NULL); + p = nextParm(p); + } + Printv(f_c_directors, "),\n", NULL); + Printv(f_c_directors, " go_val(swig_p)\n", NULL); + Printv(f_c_directors, "{ }\n\n", NULL); + + if (Getattr(n, "sym:overloaded") && Getattr(n, "sym:nextSibling") == NULL) { + int r = makeDispatchFunction(n, func_name, cn, is_static, + Getattr(parentNode(n), "classtypeobj"), + false); + if (r != SWIG_OK) { + return r; + } + } + + Delete(cxx_director_name); + Delete(go_name); + Delete(cn); + Delete(go_type_name); + Delete(director_struct_name); + Delete(fn_name); + Delete(func_name); + Delete(func_with_over_name); + Delete(wname); + Delete(first_type); + Delete(first_parm); + + return SWIG_OK; + } + + /* ------------------------------------------------------------ + * classDirectorDestructor + * + * Emit a destructor for a director class. + * ------------------------------------------------------------ */ + + int classDirectorDestructor(Node *n) { + if (!is_public(n)) { + return SWIG_OK; + } + + bool is_ignored = GetFlag(n, "feature:ignore"); + + if (!is_ignored) { + String *fnname = NewString("DeleteDirector"); + String *c1 = exportedName(class_name); + Append(fnname, c1); + Delete(c1); + + String *wname = Swig_name_wrapper(fnname); + + Setattr(n, "wrap:name", fnname); + + Swig_DestructorToFunction(n, getNSpace(), + Getattr(parentNode(n), "classtype"), + CPlusPlus, Extend); + + ParmList *parms = Getattr(n, "parms"); + Setattr(n, "wrap:parms", parms); + + String *result = NewString("void"); + int r = makeWrappers(n, fnname, fnname, NULL, wname, NULL, parms, result, + isStatic(n)); + if (r != SWIG_OK) { + return r; + } + + Delete(result); + Delete(fnname); + Delete(wname); + } + + // Generate the destructor for the C++ director class. Since the + // Go code is keeping a pointer to the C++ object, we need to call + // back to the Go code to let it know that the C++ object is gone. + + String *wname = NewString("_swiggo_wrap_DeleteDirector_"); + Append(wname, class_name); + + String *go_name = NewString("Swiggo_DeleteDirector_"); + Append(go_name, class_name); + + String *cn = exportedName(class_name); + + String *director_struct_name = NewString("_swig_Director"); + Append(director_struct_name, cn); + + Printv(f_c_directors_h, " virtual ~SwigDirector_", class_name, "()", + NULL); + + String *throws = buildThrow(n); + if (throws != NULL) { + Printv(f_c_directors_h, " ", throws, NULL); + } + + Printv(f_c_directors_h, ";\n", NULL); + + if (!is_ignored) { + if (!gccgo_flag) { + Printv(f_c_directors, "extern \"C\" void ", wname, "(void*, int);\n", + NULL); + } else { + Printv(f_c_directors, "extern \"C\" void ", wname, "(void*) __asm__(\"", + go_prefix, ".", package, ".", go_name, "\");\n", NULL); + } + } + + Printv(f_c_directors, "SwigDirector_", class_name, "::~SwigDirector_", + class_name, "()", NULL); + + if (throws != NULL) { + Printv(f_c_directors, " ", throws, NULL); + Delete(throws); + } + + Printv(f_c_directors, "\n", NULL); + Printv(f_c_directors, "{\n", NULL); + + if (!is_ignored) { + if (!gccgo_flag) { + Printv(f_c_directors, " struct { void *p; } a;\n", NULL); + Printv(f_c_directors, " a.p = go_val;\n", NULL); + Printv(f_c_directors, " crosscall2(", wname, + ", &a, (int) sizeof a);\n", NULL); + + Printv(f_gc_wrappers, "#pragma dynexport ", wname, " ", wname, "\n", + NULL); + Printv(f_gc_wrappers, "extern void \xc2\xb7", go_name, "();\n", NULL); + Printv(f_gc_wrappers, "void\n", NULL); + Printv(f_gc_wrappers, wname, "(void *a, int32 n)\n", NULL); + Printv(f_gc_wrappers, "{\n", NULL); + Printv(f_gc_wrappers, "\tcgocallback(\xc2\xb7", go_name, ", a, n);\n", + NULL); + Printv(f_gc_wrappers, "}\n\n", NULL); + } else { + Printv(f_c_directors, " ", wname, "(go_val);\n", NULL); + } + } + + Printv(f_c_directors, "}\n\n", NULL); + + if (!is_ignored) { + Printv(f_go_wrappers, "func ", go_name, "(p *", director_struct_name, + ") {\n", NULL); + Printv(f_go_wrappers, "\tp.", class_receiver, " = 0\n", NULL); + Printv(f_go_wrappers, "}\n\n", NULL); + } + + Delete(wname); + Delete(go_name); + Delete(cn); + Delete(director_struct_name); + + return SWIG_OK; + } + + /* ------------------------------------------------------------ + * classDirectorMethod + * + * Emit a method for a director class, plus its overloads. + * ------------------------------------------------------------ */ + + int classDirectorMethod(Node *n, Node *parent, String *super) { + (void) super; + + bool is_ignored = GetFlag(n, "feature:ignore"); + bool is_pure_virtual = (Cmp(Getattr(n, "storage"), "virtual") == 0 + && Cmp(Getattr(n, "value"), "0") == 0); + + // We don't need explicit calls. + if (GetFlag(n, "explicitcall")) { + return SWIG_OK; + } + + String *name = Getattr(n, "sym:name"); + if (name == NULL) { + assert(is_ignored); + name = Getattr(n, "name"); + } + + if (Getattr(class_methods, name) != NULL) { + // We need to emit a pure virtual function, even if it is + // overloaded. Otherwise we won't be able to create an instance + // of the director class. The function doesn't need to actually + // do anything. + if (!is_pure_virtual || Getattr(n, "sym:overloaded") != NULL) { + return SWIG_OK; + } + } + Setattr(class_methods, name, NewString("")); + + if (Getattr(n, "sym:overloaded") == NULL) { + int r = oneClassDirectorMethod(n, parent); + if (r != SWIG_OK) { + return r; + } + } else { + // Handle overloaded methods here, because otherwise we will + // reject them in the class_methods hash table. We need to use + // class_methods so that we correctly handle cases where a + // function in one class hides a function of the same name in a + // parent class. + for (Node *on = Getattr(n, "sym:overloaded"); + on != NULL; + on = Getattr(on, "sym:nextSibling")) { + int r = oneClassDirectorMethod(on, parent); + if (r != SWIG_OK) { + return r; + } + + // Swig_overload_rank expects wrap:name and wrap:parms to be + // set. + String *wn = Swig_name_wrapper(Getattr(on, "sym:name")); + Append(wn, Getattr(on, "sym:overname")); + Setattr(on, "wrap:name", wn); + Delete(wn); + Setattr(on, "wrap:parms", Getattr(on, "parms")); + } + + bool is_static = isStatic(n); + + String *cn = exportedName(Getattr(parent, "sym:name")); + String *go_name = buildGoName(name, is_static, false); + + String *director_struct_name = NewString("_swig_Director"); + Append(director_struct_name, cn); + + int r = makeDispatchFunction(n, go_name, director_struct_name, is_static, + director_struct_name, false); + if (r != SWIG_OK) { + return r; + } + + String *go_upcall = NewString("Director"); + Append(go_upcall, cn); + Append(go_upcall, go_name); + r = makeDispatchFunction(n, go_upcall, director_struct_name, is_static, + director_struct_name, true); + if (r != SWIG_OK) { + return r; + } + + Delete(cn); + Delete(go_name); + Delete(director_struct_name); + Delete(go_upcall); + } + + return SWIG_OK; + } + + /* ------------------------------------------------------------ + * oneClassDirectorMethod + * + * Emit a method for a director class. + * ------------------------------------------------------------ */ + + int oneClassDirectorMethod(Node *n, Node *parent) { + bool is_ignored = GetFlag(n, "feature:ignore"); + bool is_pure_virtual = (Cmp(Getattr(n, "storage"), "virtual") == 0 + && Cmp(Getattr(n, "value"), "0") == 0); + + String *name = Getattr(n, "sym:name"); + if (name == NULL) { + assert(is_ignored); + name = Getattr(n, "name"); + } + + String *overname = NULL; + if (Getattr(n, "sym:overloaded")) { + overname = Getattr(n, "sym:overname"); + } + + String *cn = exportedName(Getattr(parent, "sym:name")); + + String *go_type_name = goCPointerType(Getattr(parent, "classtypeobj"), + true); + + String *director_struct_name = NewString("_swig_Director"); + Append(director_struct_name, cn); + + bool is_static = isStatic(n); + + String *go_name = buildGoName(name, is_static, false); + + ParmList *parms = Getattr(n, "parms"); + Setattr(n, "wrap:parms", parms); + + Wrapper *dummy = NewWrapper(); + emit_attach_parmmaps(parms, dummy); + DelWrapper(dummy); + + Swig_typemap_attach_parms("go", parms, NULL); + int parm_count = emit_num_arguments(parms); + + SwigType *result = Getattr(n, "returntype"); + if (result == NULL) { + // This can happen when following overloads. + result = NewString(Getattr(n, "type")); + SwigType_push(result, Getattr(n, "decl")); + if (SwigType_isqualifier(result)) { + Delete(SwigType_pop(result)); + } + Delete(SwigType_pop_function(result)); + Setattr(n, "returntype", result); + } + + // Save the type for overload processing. + Setattr(n, "go:type", result); + + String *interface_name = NewString("_swig_DirectorInterface"); + Append(interface_name, cn); + Append(interface_name, go_name); + if (overname != NULL) { + Append(interface_name, overname); + } + + String *callback_name = Copy(director_struct_name); + Append(callback_name, "_callback_"); + Append(callback_name, name); + Replace(callback_name, "_swig", "Swig", DOH_REPLACE_FIRST); + if (overname != NULL) { + Append(callback_name, overname); + } + + String *callback_wname = Swig_name_wrapper(callback_name); + + String *upcall_name = Copy(director_struct_name); + Append(upcall_name, "_upcall_"); + Append(upcall_name, go_name); + + String *upcall_wname = Swig_name_wrapper(upcall_name); + + String *go_with_over_name = Copy(go_name); + if (overname != NULL) { + Append(go_with_over_name, overname); + } + + Wrapper *f = NewWrapper(); + + Parm *p = parms; + for (int i = 0; i < parm_count; ++i) { + p = getParm(p); + Swig_cparm_name(p, i); + if (Getattr(p, "name") == NULL) { + String *pn = NewString(""); + Printf(pn, "arg%d", i); + Setattr(p, "name", pn); + } + p = nextParm(p); + } + + Swig_typemap_attach_parms("directorin", parms, f); + + if (!is_ignored) { + // We use an interface to see if this method is defined in Go. + Printv(f_go_wrappers, "type ", interface_name, " interface {\n", NULL); + Printv(f_go_wrappers, "\t", go_with_over_name, "(", NULL); + + p = parms; + for (int i = 0; i < parm_count; ++i) { + p = getParm(p); + if (i > 0) { + Printv(f_go_wrappers, ", ", NULL); + } + String *tm = goType(p, Getattr(p, "type")); + Printv(f_go_wrappers, tm, NULL); + Delete(tm); + p = nextParm(p); + } + + Printv(f_go_wrappers, ")", NULL); + + if (SwigType_type(result) != T_VOID) { + String *tm = goType(n, result); + Printv(f_go_wrappers, " ", tm, NULL); + Delete(tm); + } + + Printv(f_go_wrappers, "\n", NULL); + Printv(f_go_wrappers, "}\n\n", NULL); + + // Declare the upcall function, which calls the method on the + // parent class. + + if (overname != NULL) { + Append(upcall_wname, overname); + } + + String *upcall_gc_name = buildGoWrapperName(upcall_name, overname); + + Printv(f_go_wrappers, "func ", upcall_gc_name, "(", + go_type_name, NULL); + + p = parms; + for (int i = 0; i < parm_count; ++i) { + p = getParm(p); + String *tm = goWrapperType(p, Getattr(p, "type"), false); + Printv(f_go_wrappers, ", ", tm, NULL); + Delete(tm); + p = nextParm(p); + } + + Printv(f_go_wrappers, ")", NULL); + + if (SwigType_type(result) != T_VOID) { + String *tm = goWrapperType(n, result, true); + Printv(f_go_wrappers, " ", tm, NULL); + Delete(tm); + } + + if (gccgo_flag) { + Printv(f_go_wrappers, " __asm__(\"", go_prefix, "_", upcall_wname, + "\")", NULL); + } + + Printv(f_go_wrappers, "\n", NULL); + + // Define the method on the director class in Go. + + Printv(f_go_wrappers, "func (swig_p *", director_struct_name, ") ", + go_with_over_name, "(", NULL); + + p = parms; + for (int i = 0; i < parm_count; ++i) { + p = getParm(p); + if (i > 0) { + Printv(f_go_wrappers, ", ", NULL); + } + Printv(f_go_wrappers, Getattr(p, "lname"), " ", NULL); + String *tm = goType(p, Getattr(p, "type")); + Printv(f_go_wrappers, tm, NULL); + Delete(tm); + p = nextParm(p); + } + + Printv(f_go_wrappers, ")", NULL); + + if (SwigType_type(result) != T_VOID) { + String *tm = goType(n, result); + Printv(f_go_wrappers, " ", tm, NULL); + Delete(tm); + } + + Printv(f_go_wrappers, " {\n", NULL); + + Printv(f_go_wrappers, "\tif swig_g, swig_ok := swig_p.v.(", + interface_name, "); swig_ok {\n", NULL); + Printv(f_go_wrappers, "\t\t", NULL); + if (SwigType_type(result) != T_VOID) { + Printv(f_go_wrappers, "return ", NULL); + } + Printv(f_go_wrappers, "swig_g.", go_with_over_name, "(", NULL); + + p = parms; + for (int i = 0; i < parm_count; ++i) { + p = getParm(p); + if (i > 0) { + Printv(f_go_wrappers, ", ", NULL); + } + Printv(f_go_wrappers, Getattr(p, "lname"), NULL); + p = nextParm(p); + } + + Printv(f_go_wrappers, ")\n", NULL); + if (SwigType_type(result) == T_VOID) { + Printv(f_go_wrappers, "\t\treturn\n", NULL); + } + Printv(f_go_wrappers, "\t}\n", NULL); + Printv(f_go_wrappers, "\t", NULL); + if (SwigType_type(result) != T_VOID) { + Printv(f_go_wrappers, "return ", NULL); + } + Printv(f_go_wrappers, upcall_gc_name, "(swig_p.", go_type_name, NULL); + + p = parms; + for (int i = 0; i < parm_count; ++i) { + p = getParm(p); + SwigType *pt = Getattr(p, "type"); + Printv(f_go_wrappers, ", ", Getattr(p, "lname"), NULL); + if (goTypeIsInterface(p, pt)) { + Printv(f_go_wrappers, ".Swigcptr()", NULL); + } + p = nextParm(p); + } + + Printv(f_go_wrappers, ")\n", NULL); + Printv(f_go_wrappers, "}\n\n", NULL); + + // Define a method in the C++ director class that the C++ upcall + // function can call. This permits an upcall to a protected + // method. + + String *upcall_method_name = NewString("_swig_upcall_"); + Append(upcall_method_name, name); + if (overname != NULL) { + Append(upcall_method_name, overname); + } + String *upcall_decl = Swig_method_decl(Getattr(n, "type"), + Getattr(n, "decl"), + upcall_method_name, parms, 0, 0); + Printv(f_c_directors_h, " ", upcall_decl, " {\n", NULL); + Delete(upcall_decl); + + Printv(f_c_directors_h, " ", NULL); + if (SwigType_type(result) != T_VOID) { + Printv(f_c_directors_h, "return ", NULL); + } + Printv(f_c_directors_h, Getattr(parent, "classtype"), "::", + Getattr(n, "name"), "(", NULL); + + p = parms; + for (int i = 0; i < parm_count; ++i) { + p = getParm(p); + if (i > 0) { + Printv(f_c_directors_h, ", ", NULL); + } + String *pn = Getattr(p, "name"); + assert(pn != NULL); + Printv(f_c_directors_h, pn, NULL); + p = nextParm(p); + } + + Printv(f_c_directors_h, ");\n", NULL); + Printv(f_c_directors_h, " }\n", NULL); + + + // Define the C++ function that the Go function calls. + + SwigType *first_type = NULL; + Parm *first_parm = parms; + if (!is_static) { + first_type = NewString("SwigDirector_"); + Append(first_type, class_name); + SwigType_add_pointer(first_type); + first_parm = NewParm(first_type, "p", n); + set_nextSibling(first_parm, parms); + } + + Swig_save("classDirectorMethod", n, "wrap:name", "wrap:action", NULL); + + Setattr(n, "wrap:name", upcall_wname); + + String *action = NewString(""); + if (SwigType_type(result) != T_VOID) { + Printv(action, "result = (", SwigType_lstr(result, 0), ")", NULL); + if (SwigType_isreference(result)) { + Printv(action, "&", NULL); + } + } + Printv(action, Swig_cparm_name(NULL, 0), "->", upcall_method_name, "(", + NULL); + + p = parms; + for (int i = 0; i < parm_count; ++i) { + p = getParm(p); + String *pname = Swig_cparm_name(NULL, i + 1); + if (i > 0) { + Printv(action, ", ", NULL); + } + // A parameter whose type is a reference is converted into a + // pointer type by gcCTypeForGoValue. We are calling a + // function which expects a reference so we need to convert + // back. + if (SwigType_isreference(Getattr(p, "type"))) { + Printv(action, "*", NULL); + } + Printv(action, pname, NULL); + Delete(pname); + p = nextParm(p); + } + Printv(action, ");", NULL); + Setattr(n, "wrap:action", action); + + if (!gccgo_flag) { + // Write the upcall wrapper function. This is compiled by gc + // and calls the C++ function. + int r = gcFunctionWrapper(n, upcall_name, upcall_name, + overname, upcall_wname, first_parm, result, + is_static, true); + if (r != SWIG_OK) { + return r; + } + r = gccFunctionWrapper(n, NULL, upcall_wname, first_parm, result); + if (r != SWIG_OK) { + return r; + } + } else { + int r = gccgoFunctionWrapper(n, NULL, upcall_wname, first_parm, result); + if (r != SWIG_OK) { + return r; + } + } + + if (first_type != NULL) { + Delete(first_type); + } + if (first_parm != parms) { + Delete(first_parm); + } + + Swig_restore(n); + + // Define a function which uses the Go director type that other + // methods in the Go type can call to get parent methods. + + Printv(f_go_wrappers, "func Director", cn, go_with_over_name, "(p ", cn, + NULL); + + p = parms; + for (int i = 0; i < parm_count; ++i) { + p = getParm(p); + Printv(f_go_wrappers, ", ", Getattr(p, "lname"), " ", NULL); + String *tm = goType(p, Getattr(p, "type")); + Printv(f_go_wrappers, tm, NULL); + Delete(tm); + p = nextParm(p); + } + + Printv(f_go_wrappers, ")", NULL); + + if (SwigType_type(result) != T_VOID) { + String *tm = goType(n, result); + Printv(f_go_wrappers, " ", tm, NULL); + Delete(tm); + } + + Printv(f_go_wrappers, " {\n", NULL); + + Printv(f_go_wrappers, "\t", NULL); + if (SwigType_type(result) != T_VOID) { + Printv(f_go_wrappers, "return ", NULL); + } + Printv(f_go_wrappers, upcall_gc_name, "(p.(*", + director_struct_name, ").", go_type_name, NULL); + + p = parms; + for (int i = 0; i < parm_count; ++i) { + p = getParm(p); + SwigType *pt = Getattr(p, "type"); + Printv(f_go_wrappers, ", ", Getattr(p, "lname"), NULL); + if (goTypeIsInterface(p, pt)) { + Printv(f_go_wrappers, ".Swigcptr()", NULL); + } + p = nextParm(p); + } + + Printv(f_go_wrappers, ")\n", NULL); + Printv(f_go_wrappers, "}\n\n", NULL); + + // The Go function which invokes the method. This is called + // from by the C++ method on the director class. + + Printv(f_go_wrappers, "func ", callback_name, "(p *", + director_struct_name, NULL); + + p = parms; + for (int i = 0; i < parm_count; ++i) { + p = getParm(p); + String *tm = goWrapperType(p, Getattr(p, "type"), false); + Printv(f_go_wrappers, ", ", Getattr(p, "lname"), " ", tm, NULL); + Delete(tm); + p = nextParm(p); + } + + Printv(f_go_wrappers, ") ", NULL); + String *result_wrapper = NULL; + if (SwigType_type(result) != T_VOID) { + result_wrapper = goWrapperType(n, result, true); + Printv(f_go_wrappers, "(swig_result ", result_wrapper, ") ", NULL); + } + Printv(f_go_wrappers, "{\n", NULL); + Printv(f_go_wrappers, "\t", NULL); + + if (is_ignored) { + Printv(f_go_wrappers, "return\n", NULL); + } else { + bool result_is_interface = false; + if (SwigType_type(result) != T_VOID) { + Printv(f_go_wrappers, "return ", NULL); + result_is_interface = goTypeIsInterface(NULL, result); + if (result_is_interface) { + Printv(f_go_wrappers, result_wrapper, "(", NULL); + } + } + Printv(f_go_wrappers, "p.", go_with_over_name, "(", NULL); + + p = parms; + for (int i = 0; i < parm_count; ++i) { + p = getParm(p); + if (i > 0) { + Printv(f_go_wrappers, ", ", NULL); + } + SwigType *pt = Getattr(p, "type"); + + // If the Go representation is an interface type class, then + // we are receiving a uintptr, and must convert to the + // interface. + bool is_interface = goTypeIsInterface(p, pt); + if (is_interface) { + // Passing is_result as true to goWrapperType gives us the + // name of the Go type we need to convert to an interface. + String *wt = goWrapperType(p, pt, true); + Printv(f_go_wrappers, wt, "(", NULL); + Delete(wt); + } + + Printv(f_go_wrappers, Getattr(p, "lname"), NULL); + + if (is_interface) { + Printv(f_go_wrappers, ")", NULL); + } + + p = nextParm(p); + } + + Printv(f_go_wrappers, ")", NULL); + + if (result_is_interface) { + Printv(f_go_wrappers, ".Swigcptr())", NULL); + } + + Printv(f_go_wrappers, "\n", NULL); + + Delete(upcall_gc_name); + } + + Printv(f_go_wrappers, "}\n\n", NULL); + + if (result_wrapper != NULL) { + Delete(result_wrapper); + } + + // Build the C++ functions. + + Delete(upcall_wname); + + if (!gccgo_flag) { + Printv(f_c_directors, "extern \"C\" void ", callback_wname, + "(void*, int);\n", NULL); + } else { + Printv(f_c_directors, "extern \"C\" ", NULL); + + String *fnname = NewString(""); + Printv(fnname, callback_wname, "(void*", NULL); + + p = parms; + while (p != NULL) { + while (checkAttribute(p, "tmap:directorin:numinputs", "0")) { + p = Getattr(p, "tmap:directorin:next"); + } + String *cg = gccgoCTypeForGoValue(p, Getattr(p, "type"), + Getattr(p, "lname")); + Printv(fnname, ", ", cg, NULL); + Delete(cg); + p = Getattr(p, "tmap:directorin:next"); + } + + Printv(fnname, ")", NULL); + + if (SwigType_type(result) == T_VOID) { + Printv(f_c_directors, "void ", fnname, NULL); + } else { + String *tm = gccgoCTypeForGoValue(n, result, fnname); + Printv(f_c_directors, tm, NULL); + Delete(tm); + } + + Delete(fnname); + + Printv(f_c_directors, " __asm__(\"", go_prefix, ".", package, ".", + callback_name, "\");\n", NULL); + } + + Delete(upcall_method_name); + Delete(go_with_over_name); + } + + if (!is_ignored || is_pure_virtual) { + // Declare the method for the director class. + + SwigType *rtype = (Getattr(n, "conversion_operator") + ? NULL + : Getattr(n, "type")); + String *decl = Swig_method_decl(rtype, Getattr(n, "decl"), + Getattr(n, "name"), parms, + 0, 0); + Printv(f_c_directors_h, " virtual ", decl, NULL); + Delete(decl); + + String *qname = NewString(""); + Printv(qname, "SwigDirector_", class_name, "::", Getattr(n, "name"), + NULL); + decl = Swig_method_decl(rtype, Getattr(n, "decl"), qname, parms, 0, 0); + Printv(f->def, decl, NULL); + Delete(decl); + Delete(qname); + + String *throws = buildThrow(n); + if (throws != NULL) { + Printv(f_c_directors_h, " ", throws, NULL); + Printv(f->def, " ", throws, NULL); + Delete(throws); + } + + Printv(f_c_directors_h, ";\n", NULL); + + Printv(f->def, " {\n", NULL); + + if (SwigType_type(result) != T_VOID) { + Wrapper_add_local(f, "c_result", + SwigType_lstr(Getattr(n, "returntype"), "c_result")); + } + + if (!is_ignored) { + if (!gccgo_flag) { + Printv(f->code, " struct {\n", NULL); + Printv(f->code, " void *go_val;\n", NULL); + + p = parms; + while (p != NULL) { + while (checkAttribute(p, "tmap:directorin:numinputs", "0")) { + p = Getattr(p, "tmap:directorin:next"); + } + String *ln = Getattr(p, "lname"); + String *cg = gcCTypeForGoValue(p, Getattr(p, "type"), ln); + Printv(f->code, " ", cg, ";\n", NULL); + Delete(cg); + p = Getattr(p, "tmap:directorin:next"); + } + if (SwigType_type(result) != T_VOID) { + Printv(f->code, " int : 0;\n", NULL); + String *rname = NewString("result"); + String *cg = gcCTypeForGoValue(n, result, rname); + Printv(f->code, " ", cg, ";\n", NULL); + Delete(cg); + Delete(rname); + } + + Printv(f->code, " } swig_a;\n", NULL); + Printv(f->code, " swig_a.go_val = go_val;\n", NULL); + + p = parms; + while (p != NULL) { + while (checkAttribute(p, "tmap:directorin:numinputs", "0")) { + p = Getattr(p, "tmap:directorin:next"); + } + String *tm = Getattr(p, "tmap:directorin"); + if (tm == NULL) { + Swig_warning(WARN_TYPEMAP_DIRECTORIN_UNDEF, input_file, + line_number, + "Unable to use type %s as director method argument\n", + SwigType_str(Getattr(p, "type"), 0)); + } else { + String *ln = Getattr(p, "lname"); + String *input = NewString(""); + Printv(input, "swig_a.", ln, NULL); + Replaceall(tm, "$input", input); + Replaceall(tm, "$owner", "0"); + Delete(input); + Printv(f->code, "\t", tm, "\n", NULL); + } + p = Getattr(p, "tmap:directorin:next"); + } + + Printv(f->code, " crosscall2(", callback_wname, + ", &swig_a, (int) sizeof swig_a);\n", NULL); + + if (SwigType_type(result) != T_VOID) { + String *rname = NewString("c_result"); + Parm *rp = NewParm(Getattr(n, "returntype"), rname, n); + String *tm = Swig_typemap_lookup("directorout", rp, rname, NULL); + if (tm == NULL) { + Swig_warning(WARN_TYPEMAP_DIRECTOROUT_UNDEF, input_file, line_number, + "Unable to use type %s as director method result\n", + SwigType_str(result, 0)); + } else { + Replaceall(tm, "$input", "swig_a.result"); + Replaceall(tm, "$result", "c_result"); + Printv(f->code, " ", tm, "\n", NULL); + String *retstr = SwigType_rcaststr(Getattr(n, "returntype"), + "c_result"); + Printv(f->code, " return ", retstr, ";\n", NULL); + Delete(retstr); + Delete(tm); + } + Delete(rp); + Delete(rname); + } + + // The C wrapper code which calls the Go function. + Printv(f_gc_wrappers, "#pragma dynexport ", callback_wname, " ", + callback_wname, "\n", NULL); + Printv(f_gc_wrappers, "extern void \xc2\xb7", callback_name, "();\n", + NULL); + Printv(f_gc_wrappers, "void\n", NULL); + Printv(f_gc_wrappers, callback_wname, "(void *a, int32 n)\n", NULL); + Printv(f_gc_wrappers, "{\n", NULL); + Printv(f_gc_wrappers, "\tcgocallback(\xc2\xb7", callback_name, + ", a, n);\n", NULL); + Printv(f_gc_wrappers, "}\n\n", NULL); + } else { + if (SwigType_type(result) != T_VOID) { + String *r = NewString("result"); + String *tm = gccgoCTypeForGoValue(n, result, r); + Wrapper_add_local(f, r, tm); + Delete(tm); + Delete(r); + } + + String *args = NewString(""); + + p = parms; + while (p != NULL) { + while (checkAttribute(p, "tmap:directorin:numinputs", "0")) { + p = Getattr(p, "tmap:directorin:next"); + } + + String *pn = NewString("g"); + Append(pn, Getattr(p, "lname")); + Setattr(p, "emit:input", pn); + + String *tm = gccgoCTypeForGoValue(n, Getattr(p, "type"), pn); + Wrapper_add_local(f, pn, tm); + Delete(tm); + + tm = Getattr(p, "tmap:directorin"); + if (tm == NULL) { + Swig_warning(WARN_TYPEMAP_DIRECTORIN_UNDEF, input_file, + line_number, + "Unable to use type %s as director method argument\n", + SwigType_str(Getattr(p, "type"), 0)); + } else { + Replaceall(tm, "$input", pn); + Replaceall(tm, "$owner", 0); + Printv(f->code, " ", tm, "\n", NULL); + + Printv(args, ", ", pn, NULL); + } + + p = Getattr(p, "tmap:directorin:next"); + } + + Printv(f->code, " ", NULL); + if (SwigType_type(result) != T_VOID) { + Printv(f->code, "result = ", NULL); + } + Printv(f->code, callback_wname, "(go_val", args, ");\n", NULL); + + if (SwigType_type(result) != T_VOID) { + String *rname = NewString("c_result"); + Parm *rp = NewParm(Getattr(n, "returntype"), rname, n); + String *tm = Swig_typemap_lookup("directorout", rp, rname, NULL); + if (tm == NULL) { + Swig_warning(WARN_TYPEMAP_DIRECTOROUT_UNDEF, input_file, line_number, + "Unable to use type %s as director method result\n", + SwigType_str(result, 0)); + } else { + Replaceall(tm, "$input", "result"); + Replaceall(tm, "$result", "c_result"); + Printv(f->code, " ", tm, "\n", NULL); + String *retstr = SwigType_rcaststr(Getattr(n, "returntype"), + "c_result"); + Printv(f->code, " return ", retstr, ";\n", NULL); + Delete(retstr); + Delete(tm); + } + Delete(rp); + Delete(rname); + } + } + } else { + assert(is_pure_virtual); + Printv(f->code, " _swig_gopanic(\"call to pure virtual function ", + Getattr(parent, "sym:name"), name, "\");\n"); + if (SwigType_type(result) != T_VOID) { + String *retstr = SwigType_rcaststr(Getattr(n, "returntype"), + "c_result"); + Printv(f->code, " return ", retstr, ";\n", NULL); + Delete(retstr); + } + } + + Printv(f->code, "}", NULL); + + Wrapper_print(f, f_c_directors); + + DelWrapper(f); + } + + Delete(cn); + Delete(go_type_name); + Delete(director_struct_name); + Delete(interface_name); + Delete(upcall_name); + Delete(callback_wname); + Delete(go_name); + + return SWIG_OK; + } + + /* ------------------------------------------------------------ + * classDirectorEnd + * + * Complete support for a director class. + * ------------------------------------------------------------ */ + + int classDirectorEnd(Node *n) { + (void) n; + + Printv(f_c_directors_h, " private:\n", NULL); + Printv(f_c_directors_h, " void *go_val;\n", NULL); + Printv(f_c_directors_h, "};\n\n", NULL); + + class_name = NULL; + class_node = NULL; + + Delete(class_receiver); + class_receiver = NULL; + + Delete(class_methods); + class_methods = NULL; + + return SWIG_OK; + } + + /* ------------------------------------------------------------ + * classDirectorDisown + * + * I think Go does not require a disown method. + * ------------------------------------------------------------ */ + + int classDirectorDisown(Node *n) { + (void) n; + return SWIG_OK; + } + + /*---------------------------------------------------------------------- + * buildThrow() + * + * Build and return a throw clause if needed. + *--------------------------------------------------------------------*/ + + String *buildThrow(Node *n) { + ParmList *throw_parm_list = Getattr(n, "throws"); + if (throw_parm_list == NULL && Getattr(n, "throw") == NULL) + return NULL; + String *ret = NewString("throw("); + if (throw_parm_list != NULL) { + Swig_typemap_attach_parms("throws", throw_parm_list, NULL); + } + bool first = true; + for (Parm *p = throw_parm_list; p != NULL; p = nextSibling(p)) { + if (Getattr(p, "tmap:throws") != NULL) { + if (first) { + first = false; + } else { + Printv(ret, ", ", NULL); + } + String *s = SwigType_str(Getattr(p, "type"), 0); + Printv(ret, s, NULL); + Delete(s); + } + } + Printv(ret, ")", NULL); + return ret; + } + + /*---------------------------------------------------------------------- + * extraDirectorProtectedCPPMethodsRequired() + * + * We don't need to check upcall when calling methods. + *--------------------------------------------------------------------*/ + + bool extraDirectorProtectedCPPMethodsRequired() const { + return false; + } + + /*---------------------------------------------------------------------- + * makeDispatchFunction + * + * Make a dispatch function for an overloaded C++ function. The + * receiver parameter is the receiver for a method, unless is_upcall + * is true. If is_upcall is true, then the receiver parameter is + * the type of the first argument to the function. + *--------------------------------------------------------------------*/ + + int makeDispatchFunction(Node *n, String *go_name, String *receiver, + bool is_static, SwigType *director_struct, + bool is_upcall) { + bool is_director = director_struct != NULL; + + String *nodetype = Getattr(n, "nodeType"); + bool is_constructor = Cmp(nodetype, "constructor") == 0; + bool is_destructor = Cmp(nodetype, "destructor") == 0; + + bool can_use_receiver = (!is_constructor + && !is_destructor + && !is_upcall); + + bool use_receiver = (!is_static + && can_use_receiver); + + bool add_to_interface = (interfaces != NULL + && !is_constructor + && !is_destructor + && !is_static + && !is_upcall); + + List *dispatch = Swig_overload_rank(n, false); + int nfunc = Len(dispatch); + + SwigType *all_result; + bool mismatch; + if (is_constructor) { + assert(!is_upcall); + if (!is_director) { + all_result = Getattr(class_node, "classtypeobj"); + } else { + all_result = director_struct; + } + mismatch = false; + } else { + all_result = NULL; + mismatch = false; + bool any_void = false; + for (int i = 0; i < nfunc; ++i) { + Node *ni = Getitem(dispatch, i); + SwigType *result = Getattr(ni, "go:type"); + assert(result != NULL); + + if (SwigType_type(result) == T_VOID) { + if (all_result != NULL) { + mismatch = true; + } + any_void = true; + } else { + if (any_void) { + mismatch = true; + } else if (all_result == NULL) { + all_result = Copy(result); + } else if (Cmp(result, all_result) != 0) { + mismatch = true; + } + } + } + if (mismatch) { + if (all_result != NULL) { + Delete(all_result); + } + all_result = NULL; + } else if (all_result != NULL) { + ; + } else { + all_result = NewString("void"); + } + } + + Printv(f_go_wrappers, "func ", NULL); + + if (receiver != NULL && use_receiver) { + Printv(f_go_wrappers, "(p ", receiver, ") ", NULL); + } + + Printv(f_go_wrappers, go_name, "(", NULL); + if (is_director && is_constructor) { + Printv(f_go_wrappers, "abi interface{}, ", NULL); + assert(!add_to_interface); + } + if (is_upcall) { + Printv(f_go_wrappers, "p *", receiver, ", ", NULL); + assert(!add_to_interface); + } + Printv(f_go_wrappers, "a ...interface{})", NULL); + + if (add_to_interface) { + Printv(interfaces, "\t", go_name, "(a ...interface{})", NULL); + } + + if (mismatch) { + Printv(f_go_wrappers, " interface{}", NULL); + if (add_to_interface) { + Printv(interfaces, " interface{}", NULL); + } + } else if (all_result != NULL && SwigType_type(all_result) != T_VOID) { + if (is_director && is_constructor) { + Printv(f_go_wrappers, " ", receiver, NULL); + if (add_to_interface) { + Printv(interfaces, " ", receiver, NULL); + } + } else { + String *tm = goType(n, all_result); + Printv(f_go_wrappers, " ", tm, NULL); + if (add_to_interface) { + Printv(interfaces, " ", tm, NULL); + } + Delete(tm); + } + } + Printv(f_go_wrappers, " {\n", NULL); + if (add_to_interface) { + Printv(interfaces, "\n", NULL); + } + + Printv(f_go_wrappers, "\targc := len(a)\n", NULL); + + for (int i = 0; i < nfunc; ++i) { + int fn = 0; + Node *ni = Getitem(dispatch, i); + Parm *pi = Getattr(ni, "wrap:parms"); + + // If we are using a receiver, we want to ignore a leading self + // parameter. Because of the way this is called, there may or + // may not be a self parameter at this point. + if (use_receiver && pi != NULL && Getattr(pi, "self") != NULL) { + pi = getParm(pi); + if (pi != NULL) { + pi = nextParm(pi); + } + } + + int num_required = emit_num_required(pi); + int num_arguments = emit_num_arguments(pi); + bool varargs = emit_isvarargs(pi); + + if (varargs) { + Printf(f_go_wrappers, "\tif argc >= %d {\n", num_required); + } else { + if (num_required == num_arguments) { + Printf(f_go_wrappers, "\tif argc == %d {\n", num_required); + } else { + Printf(f_go_wrappers, "\tif argc >= %d && argc <= %d {\n", + num_required, num_arguments); + } + } + + // Build list of collisions with the same number of arguments. + List *coll = NewList(); + for (int k = i + 1; k < nfunc; ++k) { + Node *nk = Getitem(dispatch, k); + Parm *pk = Getattr(nk, "wrap:parms"); + if (use_receiver && pk != NULL && Getattr(pk, "self") != NULL) { + pk = getParm(pk); + if (pk != NULL) { + pk = nextParm(pk); + } + } + int nrk = emit_num_required(pk); + int nak = emit_num_arguments(pk); + if ((nrk >= num_required && nrk <= num_arguments) + || (nak >= num_required && nak <= num_arguments) + || (nrk <= num_required && nak >= num_arguments)) { + Append(coll, nk); + } + } + + int num_braces = 0; + if (Len(coll) > 0 && num_arguments > 0) { + int j = 0; + Parm *pj = pi; + while (pj != NULL) { + pj = getParm(pj); + if (pj == NULL) { + break; + } + + // If all the wrappers have the same type in this position, + // we can omit the check. + SwigType *tm = goWrapperType(pj, Getattr(pj, "type"), true); + bool emitcheck = false; + for (int k = 0; k < Len(coll) && !emitcheck; ++k) { + Node *nk = Getitem(coll, k); + Parm *pk = Getattr(nk, "wrap:parms"); + if (use_receiver && pk != NULL && Getattr(pk, "self") != NULL) { + pk = getParm(pk); + if (pk != NULL) { + pk = nextParm(pk); + } + } + int nak = emit_num_arguments(pk); + if (nak <= j) + continue; + int l = 0; + Parm *pl = pk; + while (pl != NULL && l <= j) { + pl = getParm(pl); + if (pl == NULL) { + break; + } + if (l == j) { + SwigType *tml = goWrapperType(pl, Getattr(pl, "type"), true); + if (Cmp(tm, tml) != 0) { + emitcheck = true; + } + Delete(tml); + } + pl = nextParm(pl); + ++l; + } + } + + if (emitcheck) { + if (j >= num_required) { + Printf(f_go_wrappers, "\t\tif argc > %d {\n", j); + ++num_braces; + } + + fn = i + 1; + Printf(f_go_wrappers, "\t\tif _, ok := a[%d].(%s); !ok {\n", j, tm); + Printf(f_go_wrappers, "\t\t\tgoto check_%d\n", fn); + Printv(f_go_wrappers, "\t\t}\n", NULL); + } + + Delete(tm); + + pj = nextParm(pj); + + ++j; + } + } + + for (; num_braces > 0; --num_braces) { + Printv(f_go_wrappers, "\t\t}\n", NULL); + } + + // We may need to generate multiple calls if there are variable + // argument lists involved. Build the start of the call. + + String *start = NewString(""); + + SwigType *result = Getattr(ni, "go:type"); + + if (is_constructor) { + result = all_result; + } else if (is_destructor) { + result = NULL; + } + + if (result != NULL + && SwigType_type(result) != T_VOID + && (all_result == NULL + || SwigType_type(all_result) != T_VOID)) { + Printv(start, "return ", NULL); + } + + bool advance_parm = false; + + if (receiver != NULL && use_receiver) { + Printv(start, "p.", go_name, NULL); + } else if (can_use_receiver + && !isStatic(ni) + && pi != NULL + && Getattr(pi, "self") != NULL) { + // This is an overload of a static function and a non-static + // function. + assert(num_required > 0); + SwigType *tm = goWrapperType(pi, Getattr(pi, "type"), true); + String *nm = buildGoName(Getattr(ni, "sym:name"), false, + isFriend(ni)); + Printv(start, "a[0].(", tm, ").", nm, NULL); + Delete(nm); + Delete(tm); + advance_parm = true; + } else { + Printv(start, go_name, NULL); + } + + Printv(start, Getattr(ni, "sym:overname"), "(", NULL); + + bool need_comma = false; + + if (is_director && is_constructor) { + Printv(start, "abi", NULL); + need_comma = true; + } + if (is_upcall) { + Printv(start, "p", NULL); + need_comma = true; + } + Parm *p = pi; + int pn = 0; + if (advance_parm) { + p = getParm(p); + if (p != NULL) { + p = nextParm(p); + } + ++pn; + } + while (pn < num_required) { + p = getParm(p); + + if (need_comma) { + Printv(start, ", ", NULL); + } + + SwigType *tm = goType(p, Getattr(p, "type")); + Printf(start, "a[%d].(%s)", pn, tm); + Delete(tm); + + need_comma = true; + ++pn; + p = nextParm(p); + } + + String *end = NULL; + if (result == NULL + || SwigType_type(result) == T_VOID + || (all_result != NULL && SwigType_type(all_result) == T_VOID)) { + end = NewString(""); + Printv(end, "return", NULL); + if (all_result == NULL || SwigType_type(all_result) != T_VOID) { + Printv(end, " 0", NULL); + } + } + + if (num_required == num_arguments) { + Printv(f_go_wrappers, "\t\t", start, ")\n", NULL); + if (end != NULL) { + Printv(f_go_wrappers, "\t\t", end, "\n", NULL); + } + } else { + Printv(f_go_wrappers, "\t\tswitch argc {\n", NULL); + for (int j = num_required; j <= num_arguments; ++j) { + Printf(f_go_wrappers, "\t\tcase %d:\n", j); + Printv(f_go_wrappers, "\t\t\t", start, NULL); + bool nc = need_comma; + for (int k = num_required; k < j; ++k) { + if (nc) { + Printv(f_go_wrappers, ", ", NULL); + } + Printf(f_go_wrappers, "a[%d]", k); + nc = true; + } + Printv(f_go_wrappers, ")\n", NULL); + if (end != NULL) { + Printv(f_go_wrappers, "\t\t\t", end, "\n", NULL); + } + } + Printv(f_go_wrappers, "\t\t}\n", NULL); + } + + Printv(f_go_wrappers, "\t}\n", NULL); + + if (fn != 0) { + Printf(f_go_wrappers, "check_%d:\n", fn); + } + + Delete(coll); + } + + Printv(f_go_wrappers, "fail:\n", NULL); + Printv(f_go_wrappers, + "\tpanic(\"No match for overloaded function call\")\n", NULL); + Printv(f_go_wrappers, "}\n\n", NULL); + + if (all_result != NULL) { + Delete(all_result); + } + Delete(dispatch); + + return SWIG_OK; + } + + /* ---------------------------------------------------------------------- + * exportedName() + * + * Given a C/C++ name, return a name in Go which will be exported. + * If the first character is an upper case letter, this returns a + * copy of its argment. If the first character is a lower case + * letter, this forces it to upper case. Otherwise, this prepends + * 'X'. + * ---------------------------------------------------------------------- */ + + String *exportedName(String *name) { + String *copy = Copy(name); + char c = *Char(copy); + if (islower(c)) { + char l[2]; + char u[2]; + l[0] = c; + l[1] = '\0'; + u[0] = toupper(c); + u[1] = '\0'; + Replace(copy, l, u, DOH_REPLACE_FIRST); + } else if (!isalpha(c)) { + char l[2]; + char u[3]; + l[0] = c; + l[1] = '\0'; + u[0] = 'X'; + u[1] = c; + u[2] = '\0'; + Replace(copy, l, u, DOH_REPLACE_FIRST); + } + String *ret = Swig_name_mangle(copy); + Delete(copy); + return ret; + } + + /* ---------------------------------------------------------------------- + * removeClassname() + * + * If the name starts with the current class name, followed by an + * underscore, remove it. If there is no current class name, this + * simply returns a copy of the name. This undoes Swig's way of + * recording the class name in a member name. + * ---------------------------------------------------------------------- */ + + String *removeClassname(String *name) { + String *copy = Copy(name); + if (class_name != NULL) { + char *p = Char(name); + if (Strncmp(name, class_name, Len(class_name)) == 0 + && p[Len(class_name)] == '_') { + Replace(copy, class_name, "", DOH_REPLACE_FIRST); + Replace(copy, "_", "", DOH_REPLACE_FIRST); + } + } + return copy; + } + + /* ---------------------------------------------------------------------- + * buildGoName() + * + * Build the name to use for an ordinary function, variable, or + * whatever in Go. The name argument is something like the sym:name + * attribute of the node. If is_static is false, this could be a + * method, and the returned name will be the name of the + * method--i.e., it will not include the class name. + * ---------------------------------------------------------------------- */ + + String *buildGoName(String *name, bool is_static, bool is_friend) { + String *nw = NewString(""); + if (is_static && !is_friend && class_name != NULL) { + String *c1 = exportedName(class_name); + Append(nw, c1); + Delete(c1); + } + String *c2 = removeClassname(name); + String *c3 = exportedName(c2); + Append(nw, c3); + Delete(c2); + Delete(c3); + String *ret = Swig_name_mangle(nw); + Delete(nw); + return ret; + } + + /* ---------------------------------------------------------------------- + * buildGoWrapperName() + * + * Build the name to use for a Go wrapper function. This is a + * function called by the real Go function in order to convert C++ + * classes from interfaces to pointers, and other such conversions + * between the Go type and the C++ type. + * ---------------------------------------------------------------------- */ + + String *buildGoWrapperName(String *name, String *overname) { + String *s1 = NewString("_swig_wrap_"); + Append(s1, name); + String *s2 = Swig_name_mangle(s1); + Delete(s1); + if (overname != NULL) { + Append(s2, overname); + } + return s2; + } + + /* ---------------------------------------------------------------------- + * goType() + * + * Given a SWIG type, return a string for the type in Go. + * ---------------------------------------------------------------------- */ + + String *goType(Node *n, SwigType *type) { + return goTypeWithInfo(n, type, NULL); + } + + /* ---------------------------------------------------------------------- + * goTypeWithInfo() + * + * Like goType, but return some more information. + * + * If the p_is_interface parameter is not NULL, this sets + * *p_is_interface to indicate whether this type is going to be + * represented by a Go interface type. These are cases where the Go + * code needs to make some adjustments when passing values back and + * forth with C/C++. + * ---------------------------------------------------------------------- */ + + String *goTypeWithInfo(Node *n, SwigType *type, bool *p_is_interface) { + if (p_is_interface != NULL) { + *p_is_interface = false; + } + + String *ret; + if (n != NULL && Cmp(type, Getattr(n, "type")) == 0) { + ret = NULL; + if (Strcmp(Getattr(n, "nodeType"), "parm") == 0) { + ret = Getattr(n, "tmap:go"); + } + if (ret == NULL) { + ret = Swig_typemap_lookup("go", n, "", NULL); + } + } else { + Parm *p = NewParmWithoutFileLineInfo(type, "goType"); + ret = Swig_typemap_lookup("go", p, "", NULL); + Delete(p); + } + + if (Strstr(ret, "$gotypename") != NULL) { + ret = NULL; + } + + if (ret != NULL) { + return Copy(ret); + } + + SwigType *t = SwigType_typedef_resolve_all(type); + + Node *e = Language::enumLookup(t); + if (e != NULL) { + ret = goEnumName(e); + } else if (Strcmp(t, "enum ") == 0) { + ret = NewString("int"); + } else if (SwigType_isfunctionpointer(type) || SwigType_isfunction(type)) { + ret = NewString("_swig_fnptr"); + } else if (SwigType_ismemberpointer(type)) { + ret = NewString("_swig_memberptr"); + } else if (SwigType_issimple(t)) { + Node *cn = classLookup(t); + if (cn != NULL) { + ret = Getattr(cn, "sym:name"); + if (ret == NULL) { + ret = Getattr(cn, "name"); + } + ret = exportedName(ret); + + Node *cnmod = Getattr(cn, "module"); + if (cnmod == NULL || Strcmp(Getattr(cnmod, "name"), package) == 0) { + Setattr(undefined_types, t, t); + } else { + String *nw = NewString(""); + Printv(nw, Getattr(cnmod, "name"), ".", ret, NULL); + Delete(ret); + ret = nw; + } + } else { + // SWIG does not know about this type. + ret = exportedName(t); + Setattr(undefined_types, t, t); + } + if (p_is_interface != NULL) { + *p_is_interface = true; + } + } else if (SwigType_ispointer(t) || SwigType_isarray(t)) { + SwigType *r = Copy(t); + if (SwigType_ispointer(r)) { + SwigType_del_pointer(r); + } else { + SwigType_del_array(r); + } + + if (SwigType_type(r) == T_VOID) { + ret = NewString("uintptr"); + } else { + bool is_interface; + String *base = goTypeWithInfo(n, r, &is_interface); + + // At the Go level, an unknown or class type is handled as an + // interface wrapping a pointer. This means that if a + // function returns the C type X, we will be wrapping the C + // type X*. In Go we will call that type X. That means that + // if a C function expects X*, we can pass the Go type X. And + // that means that when we see the C type X*, we should use + // the Go type X. + + // The is_interface variable tells us this. However, it will + // be true both for the case of X and for the case of X*. If + // r is a pointer here, then we are looking at X**. There is + // really no good way for us to handle that. + bool is_pointer_to_pointer = false; + if (is_interface) { + SwigType *c = Copy(r); + if (SwigType_isqualifier(c)) { + SwigType_del_qualifier(c); + if (SwigType_ispointer(c) || SwigType_isarray(c)) { + is_pointer_to_pointer = true; + } + } + Delete(c); + } + + if (is_interface) { + if (!is_pointer_to_pointer) { + ret = base; + if (p_is_interface != NULL) { + *p_is_interface = true; + } + } else { + ret = NewString("uintptr"); + } + } else { + ret = NewString("*"); + Append(ret, base); + Delete(base); + } + } + + Delete(r); + } else if (SwigType_isreference(t)) { + SwigType *r = Copy(t); + SwigType_del_reference(r); + + // If this is a const reference, and we are looking at a pointer + // to it, then we just use the pointer we already have. + bool add_pointer = true; + if (SwigType_isqualifier(r)) { + String *q = SwigType_parm(r); + if (Strcmp(q, "const") == 0) { + SwigType *c = Copy(r); + SwigType_del_qualifier(c); + if (SwigType_ispointer(c)) { + add_pointer = false; + } + Delete(c); + } + } + if (add_pointer) { + SwigType_add_pointer(r); + } + ret = goTypeWithInfo(n, r, p_is_interface); + Delete(r); + } else if (SwigType_isqualifier(t)) { + SwigType *r = Copy(t); + SwigType_del_qualifier(r); + ret = goTypeWithInfo(n, r, p_is_interface); + Delete(r); + } + + Delete(t); + + if (ret == NULL) { + Swig_warning(WARN_LANG_NATIVE_UNIMPL, input_file, line_number, + "No Go typemap defined for %s\n", + SwigType_str(type, 0)); + ret = NewString("uintptr"); + } + + return ret; + } + + /* ---------------------------------------------------------------------- + * goWrapperType() + * + * Given a type, return a string for the type to use for the wrapped + * Go function. This function exists because for a C++ class we + * need to convert interface and reference types. + * ---------------------------------------------------------------------- */ + + String *goWrapperType(Node *n, SwigType *type, bool is_result) { + bool is_interface; + String *ret = goTypeWithInfo(n, type, &is_interface); + + // If this is an interface, we want to pass the real type. + if (is_interface) { + Delete(ret); + if (!is_result) { + ret = NewString("uintptr"); + } else { + SwigType *ty = SwigType_typedef_resolve_all(type); + while (true) { + if (SwigType_ispointer(ty)) { + SwigType_del_pointer(ty); + } else if (SwigType_isarray(ty)) { + SwigType_del_array(ty); + } else if (SwigType_isreference(ty)) { + SwigType_del_reference(ty); + } else if (SwigType_isqualifier(ty)) { + SwigType_del_qualifier(ty); + } else { + break; + } + } + assert(SwigType_issimple(ty)); + String *p = goCPointerType(ty, true); + Delete(ty); + ret = p; + } + } + + return ret; + } + + /* ---------------------------------------------------------------------- + * goCPointerType() + * + * Return the name of the Go type to use for the C pointer value. + * The regular C type is the name of an interface type which wraps a + * pointer whose name is returned by this function. + * ---------------------------------------------------------------------- */ + + String *goCPointerType(SwigType *type, bool add_to_hash) { + SwigType *ty = SwigType_typedef_resolve_all(type); + Node *cn = classLookup(ty); + String *ex; + String *ret; + if (cn == NULL) { + if (add_to_hash) { + Setattr(undefined_types, ty, ty); + } + ret = NewString("Swigcptr"); + ex = exportedName(ty); + Append(ret, ex); + } else { + String *cname = Getattr(cn, "sym:name"); + if (cname == NULL) { + cname = Getattr(cn, "name"); + } + ex = exportedName(cname); + Node *cnmod = Getattr(cn, "module"); + if (cnmod == NULL || Strcmp(Getattr(cnmod, "name"), package) == 0) { + if (add_to_hash) { + Setattr(undefined_types, ty, ty); + } + ret = NewString("Swigcptr"); + Append(ret, ex); + } else { + ret = NewString(""); + Printv(ret, Getattr(cnmod, "name"), ".Swigcptr", ex, NULL); + } + } + Delete(ty); + Delete(ex); + return ret; + } + + /* ---------------------------------------------------------------------- + * gcCTypeForGoValue() + * + * Given a type, return the C/C++ type which will be used to catch + * the value in Go. This is the 6g/8g version. + * ---------------------------------------------------------------------- */ + + String *gcCTypeForGoValue(Node *n, SwigType *type, String *name) { + bool is_interface; + String *gt = goTypeWithInfo(n, type, &is_interface); + bool is_string = Strcmp(gt, "string") == 0; + bool is_slice = Strncmp(gt, "[]", 2) == 0; + bool is_function = Strcmp(gt, "_swig_fnptr") == 0; + bool is_member = Strcmp(gt, "_swig_memberptr") == 0; + bool is_complex = Strcmp(gt, "complex") == 0; + bool is_complex64 = Strcmp(gt, "complex64") == 0; + bool is_complex128 = Strcmp(gt, "complex128") == 0; + Delete(gt); + + String *ret; + if (is_string) { + // Note that we don't turn a reference to a string into a + // pointer to a string. Strings are immutable anyhow. + ret = NewString("_gostring_ "); + Append(ret, name); + return ret; + } else if (is_slice) { + ret = NewString("_goslice_ "); + } else if (is_function || is_member) { + ret = NewString("void *"); + Append(ret, name); + return ret; + } else if (is_complex || is_complex64) { + ret = NewString("_Complex float "); + } else if (is_complex128) { + ret = NewString("_Complex double "); + } else if (is_interface) { + SwigType *t = SwigType_typedef_resolve_all(type); + SwigType_strip_qualifiers(t); + if (SwigType_ispointer(t)) { + SwigType_del_pointer(t); + SwigType_strip_qualifiers(t); + } + if (SwigType_isreference(t)) { + SwigType_del_reference(t); + SwigType_strip_qualifiers(t); + } + SwigType_add_pointer(t); + ret = SwigType_lstr(t, name); + Delete(t); + return ret; + } else { + SwigType *t = SwigType_typedef_resolve_all(type); + if (SwigType_isreference(t)) { + // A const reference to a known type, or to a pointer, is not + // mapped to a pointer. + SwigType_del_reference(t); + if (SwigType_isqualifier(t)) { + String *q = SwigType_parm(t); + if (Strcmp(q, "const") == 0) { + SwigType_del_qualifier(t); + if (hasGoTypemap(t) || SwigType_ispointer(t)) { + ret = SwigType_lstr(t, name); + Delete(q); + Delete(t); + return ret; + } + } + Delete(q); + } + } + Delete(t); + return SwigType_lstr(type, name); + } + + if (SwigType_isreference(type)) { + Append(ret, "* "); + } + Append(ret, name); + return ret; + } + + /* ---------------------------------------------------------------------- + * gcCTypeForGoValue() + * + * Given a type, return the C/C++ type which will be used to catch + * the value in Go. This is the gccgo version. + * ---------------------------------------------------------------------- */ + + String *gccgoCTypeForGoValue(Node *n, SwigType *type, String *name) { + return gcCTypeForGoValue(n, type, name); + } + + /* ------------------------------------------------------------ + * goTypeIsInterface + * + * Return whether this C++ type is represented as an interface type + * in Go. These types require adjustments in the Go code when + * passing them back and forth between Go and C++. + * ------------------------------------------------------------ */ + + bool goTypeIsInterface(Node *n, SwigType *type) { + bool is_interface; + Delete(goTypeWithInfo(n, type, &is_interface)); + return is_interface; + } + + /* ------------------------------------------------------------ + * hasGoTypemap + * + * Return whether a type has a "go" typemap entry. + * ------------------------------------------------------------ */ + + bool hasGoTypemap(SwigType *type) { + Parm *p = NewParmWithoutFileLineInfo(type, "test"); + SwigType *tm = Swig_typemap_lookup("go", p, "", NULL); + Delete(p); + if (tm != NULL && Strstr(tm, "$gotypename") == NULL) { + Delete(tm); + return true; + } + if (tm != NULL) { + Delete(tm); + } + return false; + } + + /* ---------------------------------------------------------------------- + * goEnumName() + * + * Given an enum node, return a string to use for the enum type in + * Go. + * ---------------------------------------------------------------------- */ + + String *goEnumName(Node *n) { + String *ret = Getattr(n, "go:enumname"); + if (ret != NULL) { + return Copy(ret); + } + + if (Strcmp(Getattr(n, "type"), "enum ") == 0) { + return NewString("int"); + } + + String *type = Getattr(n, "enumtype"); + assert(type != NULL); + char *p = Char(type); + int len = Len(type); + String *s = NewString(""); + bool capitalize = true; + for (int i = 0; i < len; ++i, ++p) { + if (*p == ':') { + ++i; + ++p; + assert(*p == ':'); + capitalize = true; + } else if (capitalize) { + Putc(toupper(*p), s); + capitalize = false; + } else { + Putc(*p, s); + } + } + + ret = Swig_name_mangle(s); + Delete(s); + return ret; + } + + + /* ------------------------------------------------------------ + * getParm() + * + * Get the real parameter to use. + * ------------------------------------------------------------ */ + + Parm *getParm(Parm *p) { + while (p != NULL && checkAttribute(p, "tmap:in:numinputs", "0")) { + p = Getattr(p, "tmap:in:next"); + } + return p; + } + + /* ------------------------------------------------------------ + * nextParm() + * + * Return the next parameter. + * ------------------------------------------------------------ */ + + Parm *nextParm(Parm *p) { + if (p == NULL) { + return NULL; + } else if (Getattr(p, "tmap:in") != NULL) { + return Getattr(p, "tmap:in:next"); + } else { + return nextSibling(p); + } + } + + /* ------------------------------------------------------------ + * isStatic + * + * Return whether a node should be considered as static rather than + * as a member. + * ------------------------------------------------------------ */ + + bool isStatic(Node *n) { + String *storage = Getattr(n, "storage"); + return (storage != NULL + && (Strcmp(storage, "static") == 0 + || Strcmp(storage, "friend") == 0) + && (!SmartPointer + || Getattr(n, "allocate:smartpointeraccess") == NULL)); + } + + /* ------------------------------------------------------------ + * isFriend + * + * Return whether a node is a friend. + * ------------------------------------------------------------ */ + + bool isFriend(Node *n) { + String *storage = Getattr(n, "storage"); + return storage != NULL && Strcmp(storage, "friend") == 0; + } + +}; /* class GO */ + +/* ----------------------------------------------------------------------------- + * swig_go() - Instantiate module + * ----------------------------------------------------------------------------- */ + +static Language *new_swig_go() { + return new GO(); +} +extern "C" Language *swig_go(void) { + return new_swig_go(); +} + +/* ----------------------------------------------------------------------------- + * Static member variables + * ----------------------------------------------------------------------------- */ + +// Usage message. +const char * const GO::usage = (char *) "\ +Go Options (available with -go)\n\ + -package - set name of the Go package to \n\ + -gccgo - generate code for gccgo rather than 6g/8g\n\ + -go-prefix

      - like gccgo -fgo-prefix option\n\ + -soname - name for shared library holding C/C++ code\n\ + -longsize - set size of C/C++ long type--32 or 64 bits\n\ + -rename = - rename symbols\n\ +\n"; diff --git a/Source/Modules/overload.cxx b/Source/Modules/overload.cxx index 65deee2de..a62bdc1bf 100644 --- a/Source/Modules/overload.cxx +++ b/Source/Modules/overload.cxx @@ -59,7 +59,7 @@ void Wrapper_cast_dispatch_mode_set(int flag) { * languages ignore the first method parsed. * ----------------------------------------------------------------------------- */ -static List *Swig_overload_rank(Node *n, bool script_lang_wrapping) { +List *Swig_overload_rank(Node *n, bool script_lang_wrapping) { Overloaded nodes[MAX_OVERLOAD]; int nnodes = 0; Node *o = Getattr(n, "sym:overloaded"); diff --git a/Source/Modules/r.cxx b/Source/Modules/r.cxx index e4b246c4e..8f5503743 100644 --- a/Source/Modules/r.cxx +++ b/Source/Modules/r.cxx @@ -1299,6 +1299,8 @@ void R::addAccessor(String *memberName, Wrapper *wrapper, String *name, Printf(stderr, "Adding accessor: %s (%s) => %s\n", memberName, name, tmp); } +#define Swig_overload_rank R_swig_overload_rank + #define MAX_OVERLOAD 256 struct Overloaded { diff --git a/Source/Modules/swigmain.cxx b/Source/Modules/swigmain.cxx index 1ed85e82e..86cccdf88 100644 --- a/Source/Modules/swigmain.cxx +++ b/Source/Modules/swigmain.cxx @@ -51,6 +51,7 @@ extern "C" { Language *swig_cffi(void); Language *swig_uffi(void); Language *swig_r(void); + Language *swig_go(void); } struct swig_module { @@ -69,6 +70,7 @@ static swig_module modules[] = { {"-clisp", swig_clisp, "CLISP"}, {"-cffi", swig_cffi, "CFFI"}, {"-csharp", swig_csharp, "C#"}, + {"-go", swig_go, "Go"}, {"-guile", swig_guile, "Guile"}, {"-java", swig_java, "Java"}, {"-lua", swig_lua, "Lua"}, diff --git a/Source/Modules/swigmod.h b/Source/Modules/swigmod.h index 016ccc8d4..b0b488d6f 100644 --- a/Source/Modules/swigmod.h +++ b/Source/Modules/swigmod.h @@ -344,6 +344,7 @@ void Swig_overload_check(Node *n); String *Swig_overload_dispatch(Node *n, const_String_or_char_ptr fmt, int *); String *Swig_overload_dispatch_cast(Node *n, const_String_or_char_ptr fmt, int *); String *Swig_overload_dispatch_fast(Node *n, const_String_or_char_ptr fmt, int *); +List *Swig_overload_rank(Node *n, bool script_lang_wrapping); SwigType *cplus_value_type(SwigType *t); /* directors.cxx start */ diff --git a/configure.in b/configure.in index fe95fa7c0..f08ad4615 100644 --- a/configure.in +++ b/configure.in @@ -1950,6 +1950,35 @@ fi AC_SUBST(RBIN) +#---------------------------------------------------------------- +# Look for Go compilers +#---------------------------------------------------------------- + +AC_ARG_WITH(go, AS_HELP_STRING([--without-go], [Disable Go]) +AS_HELP_STRING([--with-go=path], [Set location of Go compiler]),[GOBIN="$withval"], [GOBIN=yes]) + +if test x"${GOBIN}" = xno -o x"${with_alllang}" = xno ; then +AC_MSG_NOTICE([Disabling Go]) +GO= +GOGCC=false +else + + if test "x$GOBIN" = xyes; then + AC_CHECK_PROGS(GO, 6g 8g gccgo) + else + GO="$GOBIN" + fi + + GOGCC=false + if $GO --help 2>/dev/null | grep gccgo >/dev/null 2>&1 ; then + GOGCC=true + fi + +fi + +AC_SUBST(GOGCC) +AC_SUBST(GO) + #---------------------------------------------------------------- # Determine which languages to use for examples/test-suite #---------------------------------------------------------------- @@ -2100,6 +2129,12 @@ SKIP_UFFI= #fi AC_SUBST(SKIP_UFFI) +SKIP_GO= +if test -z "$GO" ; then + SKIP_GO="1" +fi +AC_SUBST(SKIP_GO) + #---------------------------------------------------------------- # Additional language dependencies #---------------------------------------------------------------- @@ -2178,6 +2213,7 @@ AC_CONFIG_FILES([ \ Examples/test-suite/cffi/Makefile \ Examples/test-suite/uffi/Makefile \ Examples/test-suite/r/Makefile \ + Examples/test-suite/go/Makefile \ Lib/ocaml/swigp4.ml ]) AC_CONFIG_FILES([preinst-swig], [chmod +x preinst-swig]) From c7a6e3dad4d41c111b81b75f92a1b8cf56a85991 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Thu, 10 Jun 2010 02:34:25 +0000 Subject: [PATCH 0922/1680] Fix // comments to /* */ in typemaps which should be usable from C code. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12109 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/php/globalvar.i | 2 +- Lib/php/phprun.swg | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Lib/php/globalvar.i b/Lib/php/globalvar.i index 3463691d5..17f4995a6 100644 --- a/Lib/php/globalvar.i +++ b/Lib/php/globalvar.i @@ -96,7 +96,7 @@ MAKE_STD_ZVAL(z_var); z_var->type = IS_STRING; if ($1) { - // varinit char [ANY] + /* varinit char [ANY] */ ZVAL_STRINGL(z_var,(char*)$1, $1_dim0, 1); } zend_hash_add(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void*)&z_var, sizeof(zval *), NULL); diff --git a/Lib/php/phprun.swg b/Lib/php/phprun.swg index e76f7033a..a7573f35d 100644 --- a/Lib/php/phprun.swg +++ b/Lib/php/phprun.swg @@ -24,11 +24,11 @@ extern "C" { #endif #ifndef Z_SET_ISREF_P -// For PHP < 5.3 +/* For PHP < 5.3 */ # define Z_SET_ISREF_P(z) (z)->is_ref = 1 #endif #ifndef Z_SET_REFCOUNT_P -// For PHP < 5.3 +/* For PHP < 5.3 */ # define Z_SET_REFCOUNT_P(z, rc) (z)->refcount = (rc) #endif From f67c0fa12c35026d804bf9ccafa0ca464106a403 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Thu, 10 Jun 2010 04:41:11 +0000 Subject: [PATCH 0923/1680] [PHP] Fix directors to correctly call a method with has a different name in PHP to C++ (we were always using the C++ name in this case). git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12110 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 5 +++++ Source/Modules/php.cxx | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index 331e9d8dd..471a9c5f4 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,11 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.1 (in progress) =========================== +2010-06-10: olly + [PHP] Fix directors to correctly call a method with has a + different name in PHP to C++ (we were always using the C++ name + in this case). + 2010-06-03: wsfulton Fix uncompileable code when %rename results in two enum items with the same name. Reported by Vadim Zeitlin. diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index bd751f767..e82c5041d 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -2565,7 +2565,7 @@ done: } 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); + Printf(w->code, "ZVAL_STRING(&funcname, (char *)\"%s\", 0);\n", GetChar(n, "sym: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"); From 1a317ff3dbc032a5410437ce2f86c3712434c984 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 10 Jun 2010 06:06:12 +0000 Subject: [PATCH 0924/1680] Add C# example showing how to modify the underlying enum type git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12111 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/CSharp.html | 33 +++++++++++++++++++++++++++ Examples/test-suite/csharp_typemaps.i | 7 ++++++ 2 files changed, 40 insertions(+) diff --git a/Doc/Manual/CSharp.html b/Doc/Manual/CSharp.html index ea8b66e65..909357f37 100644 --- a/Doc/Manual/CSharp.html +++ b/Doc/Manual/CSharp.html @@ -38,6 +38,7 @@

    • A date example demonstrating marshalling of C# properties
    • Turning wrapped classes into partial classes
    • Extending proxy classes with additional C# code +
    • Underlying type for enums
    @@ -2400,6 +2401,38 @@ public class ExtendMe : IDisposable { +

    18.6.7 Underlying type for enums

    + + +

    +C# enums use int as the underlying type for each enum item. +If you wish to change the underlying type to something else, then use the csbase typemap. +For example when your C++ code uses a value larget than int, this is necessary as the C# compiler will not compile values which are too large to fit into an int. +Here is an example: +

    + +
    +
    +%typemap(csbase) BigNumbers "uint"
    +%inline %{
    +  enum BigNumbers { big=0x80000000, bigger };
    +%}
    +
    +
    + +

    +The generated enum will then use the given underlying type and compile correctly: +

    + +
    +
    +public enum BigNumbers : uint {
    +  big = 0x80000000,
    +  bigger
    +}
    +
    +
    + diff --git a/Examples/test-suite/csharp_typemaps.i b/Examples/test-suite/csharp_typemaps.i index b940f25a3..18896456e 100644 --- a/Examples/test-suite/csharp_typemaps.i +++ b/Examples/test-suite/csharp_typemaps.i @@ -110,3 +110,10 @@ struct WasCrashing {}; void hoop(WasCrashing was) {} %} + +// Enum underlying type +%typemap(csbase) BigNumbers "uint" +%inline %{ +enum BigNumbers { big=0x80000000, bigger }; +%} + From 863aab5b4c388342a5839c4728458ca2ea5a2608 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 10 Jun 2010 06:10:55 +0000 Subject: [PATCH 0925/1680] Chapter renumbering after Go added git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12112 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Contents.html | 62 +++++++++--- Doc/Manual/Extending.html | 100 +++++++++---------- Doc/Manual/Guile.html | 42 ++++---- Doc/Manual/Java.html | 204 +++++++++++++++++++------------------- Doc/Manual/Lisp.html | 22 ++-- Doc/Manual/Lua.html | 74 +++++++------- Doc/Manual/Modula3.html | 40 ++++---- Doc/Manual/Mzscheme.html | 4 +- Doc/Manual/Ocaml.html | 62 ++++++------ Doc/Manual/Octave.html | 46 ++++----- Doc/Manual/Perl5.html | 94 +++++++++--------- Doc/Manual/Php.html | 48 ++++----- Doc/Manual/Pike.html | 24 ++--- Doc/Manual/Python.html | 146 +++++++++++++-------------- Doc/Manual/R.html | 16 +-- Doc/Manual/Ruby.html | 196 ++++++++++++++++++------------------ Doc/Manual/Tcl.html | 92 ++++++++--------- 17 files changed, 651 insertions(+), 621 deletions(-) diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index 27337ea7a..25d2dbf9c 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -657,6 +657,7 @@
  • A date example demonstrating marshalling of C# properties
  • Turning wrapped classes into partial classes
  • Extending proxy classes with additional C# code +
  • Underlying type for enums @@ -700,7 +701,36 @@ -

    20 SWIG and Guile

    +

    20 SWIG and Go

    + + + + + +

    21 SWIG and Guile

    @@ -735,7 +765,7 @@
    -

    21 SWIG and Java

    +

    22 SWIG and Java

    @@ -877,7 +907,7 @@
    -

    22 SWIG and Common Lisp

    +

    23 SWIG and Common Lisp

    @@ -900,7 +930,7 @@
    -

    23 SWIG and Lua

    +

    24 SWIG and Lua

    @@ -957,7 +987,7 @@
    -

    24 SWIG and Modula-3

    +

    25 SWIG and Modula-3

    @@ -995,7 +1025,7 @@
    -

    25 SWIG and MzScheme

    +

    26 SWIG and MzScheme

    @@ -1005,7 +1035,7 @@
    -

    26 SWIG and Ocaml

    +

    27 SWIG and Ocaml

    @@ -1056,7 +1086,7 @@
    -

    27 SWIG and Octave

    +

    28 SWIG and Octave

    @@ -1091,7 +1121,7 @@
    -

    28 SWIG and Perl5

    +

    29 SWIG and Perl5

    @@ -1158,7 +1188,7 @@
    -

    29 SWIG and PHP

    +

    30 SWIG and PHP

    @@ -1198,7 +1228,7 @@
    -

    30 SWIG and Pike

    +

    31 SWIG and Pike

    @@ -1222,7 +1252,7 @@
    -

    31 SWIG and Python

    +

    32 SWIG and Python

    @@ -1325,7 +1355,7 @@
    -

    32 SWIG and Ruby

    +

    33 SWIG and Ruby

    @@ -1459,7 +1489,7 @@
    -

    33 SWIG and Tcl

    +

    34 SWIG and Tcl

    @@ -1525,7 +1555,7 @@
    -

    34 SWIG and R

    +

    35 SWIG and R

    @@ -1541,7 +1571,7 @@
    -

    35 Extending SWIG to support new languages

    +

    36 Extending SWIG to support new languages

    diff --git a/Doc/Manual/Extending.html b/Doc/Manual/Extending.html index bb50d3878..c554d9f05 100644 --- a/Doc/Manual/Extending.html +++ b/Doc/Manual/Extending.html @@ -6,7 +6,7 @@ -

    35 Extending SWIG to support new languages

    +

    36 Extending SWIG to support new languages

      @@ -75,7 +75,7 @@ -

      35.1 Introduction

      +

      36.1 Introduction

      @@ -91,7 +91,7 @@ Also, this chapter is not meant to be a hand-holding tutorial. As a starting po you should probably look at one of SWIG's existing modules.

      -

      35.2 Prerequisites

      +

      36.2 Prerequisites

      @@ -121,7 +121,7 @@ obvious, but almost all SWIG directives as well as the low-level generation of wrapper code are driven by C++ datatypes.

      -

      35.3 The Big Picture

      +

      36.3 The Big Picture

      @@ -158,7 +158,7 @@ role in making the system work. For example, both typemaps and declaration anno based on pattern matching and interact heavily with the underlying type system.

      -

      35.4 Execution Model

      +

      36.4 Execution Model

      @@ -203,7 +203,7 @@ latter stage of compilation. The next few sections briefly describe some of these stages.

      -

      35.4.1 Preprocessing

      +

      36.4.1 Preprocessing

      @@ -284,7 +284,7 @@ been expanded as well as everything else that goes into the low-level construction of the wrapper code.

      -

      35.4.2 Parsing

      +

      36.4.2 Parsing

      @@ -385,7 +385,7 @@ returning a foo and taking types a and b as arguments).

      -

      35.4.3 Parse Trees

      +

      36.4.3 Parse Trees

      @@ -640,7 +640,7 @@ $ swig -c++ -python -debug-module 4 example.i

    -

    35.4.4 Attribute namespaces

    +

    36.4.4 Attribute namespaces

    @@ -659,7 +659,7 @@ that matches the name of the target language. For example, python:foo perl:foo.

    -

    35.4.5 Symbol Tables

    +

    36.4.5 Symbol Tables

    @@ -750,7 +750,7 @@ example.i:5. Previous declaration is foo_i(int )

    -

    35.4.6 The %feature directive

    +

    36.4.6 The %feature directive

    @@ -806,7 +806,7 @@ For example, the exception code above is simply stored without any modifications.

    -

    35.4.7 Code Generation

    +

    36.4.7 Code Generation

    @@ -928,7 +928,7 @@ public : The role of these functions is described shortly.

    -

    35.4.8 SWIG and XML

    +

    36.4.8 SWIG and XML

    @@ -941,7 +941,7 @@ internal data structures, it may be useful to keep XML in the back of your mind as a model.

    -

    35.5 Primitive Data Structures

    +

    36.5 Primitive Data Structures

    @@ -987,7 +987,7 @@ typedef Hash Typetab; -

    35.5.1 Strings

    +

    36.5.1 Strings

    @@ -1128,7 +1128,7 @@ Returns the number of replacements made (if any). -

    35.5.2 Hashes

    +

    36.5.2 Hashes

    @@ -1205,7 +1205,7 @@ Returns the list of hash table keys. -

    35.5.3 Lists

    +

    36.5.3 Lists

    @@ -1294,7 +1294,7 @@ If t is not a standard object, it is assumed to be a char * and is used to create a String object. -

    35.5.4 Common operations

    +

    36.5.4 Common operations

    The following operations are applicable to all datatypes. @@ -1349,7 +1349,7 @@ objects and report errors. Gets the line number associated with x. -

    35.5.5 Iterating over Lists and Hashes

    +

    36.5.5 Iterating over Lists and Hashes

    To iterate over the elements of a list or a hash table, the following functions are used: @@ -1394,7 +1394,7 @@ for (j = First(j); j.item; j= Next(j)) { -

    35.5.6 I/O

    +

    36.5.6 I/O

    Special I/O functions are used for all internal I/O. These operations @@ -1531,7 +1531,7 @@ Similarly, the preprocessor and parser all operate on string-files. -

    35.6 Navigating and manipulating parse trees

    +

    36.6 Navigating and manipulating parse trees

    Parse trees are built as collections of hash tables. Each node is a hash table in which @@ -1665,7 +1665,7 @@ Deletes a node from the parse tree. Deletion reconnects siblings and properly u the parent so that sibling nodes are unaffected. -

    35.7 Working with attributes

    +

    36.7 Working with attributes

    @@ -1782,7 +1782,7 @@ the attribute is optional. Swig_restore() must always be called after function. -

    35.8 Type system

    +

    36.8 Type system

    @@ -1791,7 +1791,7 @@ pointers, references, and pointers to members. A detailed discussion of type theory is impossible here. However, let's cover the highlights.

    -

    35.8.1 String encoding of types

    +

    36.8.1 String encoding of types

    @@ -1892,7 +1892,7 @@ make the final type, the two parts are just joined together using string concatenation.

    -

    35.8.2 Type construction

    +

    36.8.2 Type construction

    @@ -2061,7 +2061,7 @@ Returns the prefix of a type. For example, if ty is ty is unmodified. -

    35.8.3 Type tests

    +

    36.8.3 Type tests

    @@ -2148,7 +2148,7 @@ Checks if ty is a varargs type. Checks if ty is a templatized type. -

    35.8.4 Typedef and inheritance

    +

    36.8.4 Typedef and inheritance

    @@ -2250,7 +2250,7 @@ Fully reduces ty according to typedef rules. Resulting datatype will consist only of primitive typenames. -

    35.8.5 Lvalues

    +

    36.8.5 Lvalues

    @@ -2287,7 +2287,7 @@ Literal y; // type = 'Literal', ltype='p.char' -

    35.8.6 Output functions

    +

    36.8.6 Output functions

    @@ -2349,7 +2349,7 @@ SWIG, but is most commonly associated with type-descriptor objects that appear in wrappers (e.g., SWIGTYPE_p_double). -

    35.9 Parameters

    +

    36.9 Parameters

    @@ -2448,7 +2448,7 @@ included. Used to emit prototypes. Returns the number of required (non-optional) arguments in p. -

    35.10 Writing a Language Module

    +

    36.10 Writing a Language Module

    @@ -2463,7 +2463,7 @@ describes the creation of a minimal Python module. You should be able to extra this to other languages.

    -

    35.10.1 Execution model

    +

    36.10.1 Execution model

    @@ -2473,7 +2473,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

    +

    36.10.2 Starting out

    @@ -2581,7 +2581,7 @@ that activates your module. For example, swig -python foo.i. The messages from your new module should appear.

    -

    35.10.3 Command line options

    +

    36.10.3 Command line options

    @@ -2640,7 +2640,7 @@ to mark the option as valid. If you forget to do this, SWIG will terminate wit unrecognized command line option error.

    -

    35.10.4 Configuration and preprocessing

    +

    36.10.4 Configuration and preprocessing

    @@ -2689,7 +2689,7 @@ an implementation file python.cxx and a configuration file python.swg.

    -

    35.10.5 Entry point to code generation

    +

    36.10.5 Entry point to code generation

    @@ -2747,7 +2747,7 @@ int Python::top(Node *n) { -

    35.10.6 Module I/O and wrapper skeleton

    +

    36.10.6 Module I/O and wrapper skeleton

    @@ -2895,7 +2895,7 @@ functionWrapper : void Shape_y_set(Shape *self,double y) -

    35.10.7 Low-level code generators

    +

    36.10.7 Low-level code generators

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

    -

    35.10.8 Configuration files

    +

    36.10.8 Configuration files

    @@ -3193,7 +3193,7 @@ politely displays the ignoring language message. -

    35.10.9 Runtime support

    +

    36.10.9 Runtime support

    @@ -3202,7 +3202,7 @@ Discuss the kinds of functions typically needed for SWIG runtime support (e.g. the SWIG files that implement those functions.

    -

    35.10.10 Standard library files

    +

    36.10.10 Standard library files

    @@ -3221,7 +3221,7 @@ The following are the minimum that are usually supported: Please copy these and modify for any new language.

    -

    35.10.11 User examples

    +

    36.10.11 User examples

    @@ -3250,7 +3250,7 @@ during this process, see the section on .

    -

    35.10.12 Test driven development and the test-suite

    +

    36.10.12 Test driven development and the test-suite

    @@ -3309,7 +3309,7 @@ It is therefore essential that the runtime tests are written in a manner that di but error/exception out with an error message on stderr on failure.

    -

    35.10.12.1 Running the test-suite

    +

    36.10.12.1 Running the test-suite

    @@ -3477,7 +3477,7 @@ A debugger can also be invoked easily on an individual test, for example gdb: make ret_by_value.ctest RUNTOOL="gdb --args" -

    35.10.13 Documentation

    +

    36.10.13 Documentation

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

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

    +

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

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

    -

    35.10.15 Coding style guidelines

    +

    36.10.15 Coding style guidelines

    @@ -3590,7 +3590,7 @@ 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 Debugging Options

    +

    36.11 Debugging Options

    @@ -3615,7 +3615,7 @@ There are various command line options which can aid debugging a SWIG interface The complete list of command line options for SWIG are available by running swig -help.

    -

    35.12 Guide to parse tree nodes

    +

    36.12 Guide to parse tree nodes

    @@ -4023,7 +4023,7 @@ extern "X" { ... } declaration. -

    35.13 Further Development Information

    +

    36.13 Further Development Information

    diff --git a/Doc/Manual/Guile.html b/Doc/Manual/Guile.html index 8f3c5f85c..75c3d3473 100644 --- a/Doc/Manual/Guile.html +++ b/Doc/Manual/Guile.html @@ -8,7 +8,7 @@ -

    20 SWIG and Guile

    +

    21 SWIG and Guile

      @@ -47,7 +47,7 @@

      This section details guile-specific support in SWIG. -

      20.1 Meaning of "Module"

      +

      21.1 Meaning of "Module"

      @@ -55,7 +55,7 @@ There are three different concepts of "module" involved, defined separately for SWIG, Guile, and Libtool. To avoid horrible confusion, we explicitly prefix the context, e.g., "guile-module". -

      20.2 Using the SCM or GH Guile API

      +

      21.2 Using the SCM or GH Guile API

      The guile module can currently export wrapper files that use the guile GH interface or the @@ -103,7 +103,7 @@ for the specific API. Currently only the guile language module has created a ma but there is no reason other languages (like mzscheme or chicken) couldn't also use this. If that happens, there is A LOT less code duplication in the standard typemaps.

      -

      20.3 Linkage

      +

      21.3 Linkage

      @@ -111,7 +111,7 @@ Guile support is complicated by a lack of user community cohesiveness, which manifests in multiple shared-library usage conventions. A set of policies implementing a usage convention is called a linkage. -

      20.3.1 Simple Linkage

      +

      21.3.1 Simple Linkage

      @@ -206,7 +206,7 @@ placed between the define-module form and the SWIG_init via a preprocessor define to avoid symbol clashes. For this case, however, passive linkage is available. -

      20.3.2 Passive Linkage

      +

      21.3.2 Passive Linkage

      Passive linkage is just like simple linkage, but it generates an @@ -216,7 +216,7 @@ package name (see below).

      You should use passive linkage rather than simple linkage when you are using multiple modules. -

      20.3.3 Native Guile Module Linkage

      +

      21.3.3 Native Guile Module Linkage

      SWIG can also generate wrapper code that does all the Guile module @@ -257,7 +257,7 @@ Newer Guile versions have a shorthand procedure for this:

    -

    20.3.4 Old Auto-Loading Guile Module Linkage

    +

    21.3.4 Old Auto-Loading Guile Module Linkage

    Guile used to support an autoloading facility for object-code @@ -283,7 +283,7 @@ option, SWIG generates an exported module initialization function with an appropriate name. -

    20.3.5 Hobbit4D Linkage

    +

    21.3.5 Hobbit4D Linkage

    @@ -308,7 +308,7 @@ my/lib/libfoo.so.X.Y.Z and friends. This scheme is still very experimental; the (hobbit4d link) conventions are not well understood.

    -

    20.4 Underscore Folding

    +

    21.4 Underscore Folding

    @@ -320,7 +320,7 @@ complained so far. %rename to specify the Guile name of the wrapped functions and variables (see CHANGES). -

    20.5 Typemaps

    +

    21.5 Typemaps

    @@ -412,7 +412,7 @@ constant will appear as a scheme variable. See Features and the %feature directive for info on how to apply the %feature.

    -

    20.6 Representation of pointers as smobs

    +

    21.6 Representation of pointers as smobs

    @@ -433,7 +433,7 @@ representing the expected pointer type. See also If the Scheme object passed was not a SWIG smob representing a compatible pointer, a wrong-type-arg exception is raised. -

    20.6.1 GH Smobs

    +

    21.6.1 GH Smobs

    @@ -462,7 +462,7 @@ that created them, so the first module we check will most likely be correct. Once we have a swig_type_info structure, we loop through the linked list of casts, using pointer comparisons.

    -

    20.6.2 SCM Smobs

    +

    21.6.2 SCM Smobs

    The SCM interface (using the "-scm" argument to swig) uses swigrun.swg. @@ -477,7 +477,7 @@ in the smob tag. If a generated GOOPS module has been loaded, smobs will be wra GOOPS class.

    -

    20.6.3 Garbage Collection

    +

    21.6.3 Garbage Collection

    Garbage collection is a feature of the new SCM interface, and it is automatically included @@ -491,7 +491,7 @@ is exactly like described in 20.7 Exception Handling +

    21.7 Exception Handling

    @@ -517,7 +517,7 @@ mapping: The default when not specified here is to use "swig-error". See Lib/exception.i for details. -

    20.8 Procedure documentation

    +

    21.8 Procedure documentation

    If invoked with the command-line option -procdoc @@ -553,7 +553,7 @@ like this: typemap argument doc. See Lib/guile/typemaps.i for details. -

    20.9 Procedures with setters

    +

    21.9 Procedures with setters

    For global variables, SWIG creates a single wrapper procedure @@ -581,7 +581,7 @@ struct members, the procedures (struct-member-get pointer) and (struct-member-set pointer value) are not generated. -

    20.10 GOOPS Proxy Classes

    +

    21.10 GOOPS Proxy Classes

    SWIG can also generate classes and generic functions for use with @@ -730,7 +730,7 @@ Notice that <Foo> is used before it is defined. The fix is to just put th %import "foo.h" before the %inline block.

    -

    20.10.1 Naming Issues

    +

    21.10.1 Naming Issues

    As you can see in the example above, there are potential naming conflicts. The default exported @@ -767,7 +767,7 @@ guile-modules. For example,

    (use-modules ((Test) #:renamer (symbol-prefix-proc 'goops:))) -

    20.10.2 Linking

    +

    21.10.2 Linking

    The guile-modules generated above all need to be linked together. GOOPS support requires diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html index c5778c432..f572ffa32 100644 --- a/Doc/Manual/Java.html +++ b/Doc/Manual/Java.html @@ -5,7 +5,7 @@ -

    21 SWIG and Java

    +

    22 SWIG and Java

      @@ -154,7 +154,7 @@ It covers most SWIG features, but certain low-level details are covered in less

      -

      21.1 Overview

      +

      22.1 Overview

      @@ -189,7 +189,7 @@ Various customisation tips and techniques using SWIG directives are covered. The latter sections cover the advanced techniques of using typemaps for complete control of the wrapping process.

      -

      21.2 Preliminaries

      +

      22.2 Preliminaries

      @@ -205,7 +205,7 @@ Run make -k check from the SWIG root directory after installing SWIG on The Java module requires your system to support shared libraries and dynamic loading. This is the commonly used method to load JNI code so your system will more than likely support this.

      -

      21.2.1 Running SWIG

      +

      22.2.1 Running SWIG

      @@ -264,7 +264,7 @@ The following sections have further practical examples and details on how you mi compiling and using the generated files.

      -

      21.2.2 Additional Commandline Options

      +

      22.2.2 Additional Commandline Options

      @@ -301,7 +301,7 @@ swig -java -help Their use will become clearer by the time you have finished reading this section on SWIG and Java.

      -

      21.2.3 Getting the right header files

      +

      22.2.3 Getting the right header files

      @@ -316,7 +316,7 @@ They are usually in directories like this:

      The exact location may vary on your machine, but the above locations are typical.

      -

      21.2.4 Compiling a dynamic module

      +

      22.2.4 Compiling a dynamic module

      @@ -352,7 +352,7 @@ The name of the shared library output file is important. If the name of your SWIG module is "example", the name of the corresponding shared library file should be "libexample.so" (or equivalent depending on your machine, see Dynamic linking problems for more information). The name of the module is specified using the %module directive or -module command line option.

      -

      21.2.5 Using your module

      +

      22.2.5 Using your module

      @@ -387,7 +387,7 @@ $ If it doesn't work have a look at the following section which discusses problems loading the shared library.

      -

      21.2.6 Dynamic linking problems

      +

      22.2.6 Dynamic linking problems

      @@ -474,7 +474,7 @@ The following section also contains some C++ specific linking problems and solut

      -

      21.2.7 Compilation problems and compiling with C++

      +

      22.2.7 Compilation problems and compiling with C++

      @@ -527,7 +527,7 @@ Finally make sure the version of JDK header files matches the version of Java th

      -

      21.2.8 Building on Windows

      +

      22.2.8 Building on Windows

      @@ -536,7 +536,7 @@ You will want to produce a DLL that can be loaded by the Java Virtual Machine. This section covers the process of using SWIG with Microsoft Visual C++ 6 although the procedure may be similar with other compilers. In order for everything to work, you will need to have a JDK installed on your machine in order to read the JNI header files.

      -

      21.2.8.1 Running SWIG from Visual Studio

      +

      22.2.8.1 Running SWIG from Visual Studio

      @@ -575,7 +575,7 @@ To run the native code in the DLL (example.dll), make sure that it is in your pa If the library fails to load have a look at Dynamic linking problems.

      -

      21.2.8.2 Using NMAKE

      +

      22.2.8.2 Using NMAKE

      @@ -634,7 +634,7 @@ Of course you may want to make changes for it to work for C++ by adding in the -

      -

      21.3 A tour of basic C/C++ wrapping

      +

      22.3 A tour of basic C/C++ wrapping

      @@ -644,7 +644,7 @@ variables are wrapped with JavaBean type getters and setters and so forth. This section briefly covers the essential aspects of this wrapping.

      -

      21.3.1 Modules, packages and generated Java classes

      +

      22.3.1 Modules, packages and generated Java classes

      @@ -680,7 +680,7 @@ 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

      +

      22.3.2 Functions

      @@ -714,7 +714,7 @@ System.out.println(example.fact(4));

    -

    21.3.3 Global variables

    +

    22.3.3 Global variables

    @@ -801,7 +801,7 @@ extern char *path; // Read-only (due to %immutable) -

    21.3.4 Constants

    +

    22.3.4 Constants

    @@ -941,7 +941,7 @@ Or if you decide this practice isn't so bad and your own class implements ex

    -

    21.3.5 Enumerations

    +

    22.3.5 Enumerations

    @@ -955,7 +955,7 @@ The final two approaches use simple integers for each enum item. Before looking at the various approaches for wrapping named C/C++ enums, anonymous enums are considered.

    -

    21.3.5.1 Anonymous enums

    +

    22.3.5.1 Anonymous enums

    @@ -1018,7 +1018,7 @@ As in the case of constants, you can access them through either the module class

    -

    21.3.5.2 Typesafe enums

    +

    22.3.5.2 Typesafe enums

    @@ -1112,7 +1112,7 @@ When upgrading to JDK 1.5 or later, proper Java enums could be used instead, wit The following section details proper Java enum generation.

    -

    21.3.5.3 Proper Java enums

    +

    22.3.5.3 Proper Java enums

    @@ -1165,7 +1165,7 @@ The additional support methods need not be generated if none of the enum items h Simpler Java enums for enums without initializers section.

    -

    21.3.5.4 Type unsafe enums

    +

    22.3.5.4 Type unsafe enums

    @@ -1213,7 +1213,7 @@ Note that unlike typesafe enums, this approach requires users to mostly use diff Thus the upgrade path to proper enums provided in JDK 1.5 is more painful.

    -

    21.3.5.5 Simple enums

    +

    22.3.5.5 Simple enums

    @@ -1232,7 +1232,7 @@ SWIG-1.3.21 and earlier versions wrapped all enums using this approach. The type unsafe approach is preferable to this one and this simple approach is only included for backwards compatibility with these earlier versions of SWIG.

    -

    21.3.6 Pointers

    +

    22.3.6 Pointers

    @@ -1320,7 +1320,7 @@ C-style cast may return a bogus result whereas as the C++-style cast will return a NULL pointer if the conversion can't be performed.

    -

    21.3.7 Structures

    +

    22.3.7 Structures

    @@ -1488,7 +1488,7 @@ x.setA(3); // Modify x.a - this is the same as b.f.a -

    21.3.8 C++ classes

    +

    22.3.8 C++ classes

    @@ -1551,7 +1551,7 @@ int bar = Spam.getBar(); -

    21.3.9 C++ inheritance

    +

    22.3.9 C++ inheritance

    @@ -1612,7 +1612,7 @@ Note that Java does not support multiple inheritance so any multiple inheritance A warning is given when multiple inheritance is detected and only the first base class is used.

    -

    21.3.10 Pointers, references, arrays and pass by value

    +

    22.3.10 Pointers, references, arrays and pass by value

    @@ -1667,7 +1667,7 @@ to hold the result and a pointer is returned (Java will release this memory when the returned object's finalizer is run by the garbage collector).

    -

    21.3.10.1 Null pointers

    +

    22.3.10.1 Null pointers

    @@ -1691,7 +1691,7 @@ For spam1 and spam4 above the Java null gets translat The converse also occurs, that is, NULL pointers are translated into null Java objects when returned from a C/C++ function.

    -

    21.3.11 C++ overloaded functions

    +

    22.3.11 C++ overloaded functions

    @@ -1806,7 +1806,7 @@ void spam(unsigned short); // Ignored -

    21.3.12 C++ default arguments

    +

    22.3.12 C++ default arguments

    @@ -1849,7 +1849,7 @@ Further details on default arguments and how to restore this approach are given

    -

    21.3.13 C++ namespaces

    +

    22.3.13 C++ namespaces

    @@ -1927,7 +1927,7 @@ with -package - Java does not support types declared in a named package accessin -

    21.3.14 C++ templates

    +

    22.3.14 C++ templates

    @@ -1976,7 +1976,7 @@ Obviously, there is more to template wrapping than shown in this example. More details can be found in the SWIG and C++ chapter.

    -

    21.3.15 C++ Smart Pointers

    +

    22.3.15 C++ Smart Pointers

    @@ -2060,7 +2060,7 @@ Foo f = p.__deref__(); // Returns underlying Foo * -

    21.4 Further details on the generated Java classes

    +

    22.4 Further details on the generated Java classes

    @@ -2075,7 +2075,7 @@ Finally enum classes are covered. First, the crucial intermediary JNI class is considered.

    -

    21.4.1 The intermediary JNI class

    +

    22.4.1 The intermediary JNI class

    @@ -2195,7 +2195,7 @@ If name is the same as modulename then the module class name g from modulename to modulenameModule.

    -

    21.4.1.1 The intermediary JNI class pragmas

    +

    22.4.1.1 The intermediary JNI class pragmas

    @@ -2274,7 +2274,7 @@ For example, let's change the intermediary JNI class access to just the default All the methods in the intermediary JNI class will then not be callable outside of the package as the method modifiers have been changed from public access to default access. This is useful if you want to prevent users calling these low level functions.

    -

    21.4.2 The Java module class

    +

    22.4.2 The Java module class

    @@ -2305,7 +2305,7 @@ example.egg(new Foo()); The primary reason for having the module class wrapping the calls in the intermediary JNI class is to implement static type checking. In this case only a Foo can be passed to the egg function, whereas any long can be passed to the egg function in the intermediary JNI class.

    -

    21.4.2.1 The Java module class pragmas

    +

    22.4.2.1 The Java module class pragmas

    @@ -2356,7 +2356,7 @@ See The intermediary JNI class pragmas secti

    -

    21.4.3 Java proxy classes

    +

    22.4.3 Java proxy classes

    @@ -2432,7 +2432,7 @@ int y = f.spam(5, new Foo()); -

    21.4.3.1 Memory management

    +

    22.4.3.1 Memory management

    @@ -2594,7 +2594,7 @@ and

    -

    21.4.3.2 Inheritance

    +

    22.4.3.2 Inheritance

    @@ -2710,7 +2710,7 @@ However, true cross language polymorphism can be achieved using the 21.4.3.3 Proxy classes and garbage collection +

    22.4.3.3 Proxy classes and garbage collection

    @@ -2793,7 +2793,7 @@ The section on Java typemaps details how to specify See the How to Handle Java Finalization's Memory-Retention Issues article for alternative approaches to managing memory by avoiding finalizers altogether.

    -

    21.4.3.4 The premature garbage collection prevention parameter for proxy class marshalling

    +

    22.4.3.4 The premature garbage collection prevention parameter for proxy class marshalling

    @@ -2915,7 +2915,7 @@ For example: Compatibility note: The generation of this additional parameter did not occur in versions prior to SWIG-1.3.30.

    -

    21.4.3.5 Single threaded applications and thread safety

    +

    22.4.3.5 Single threaded applications and thread safety

    @@ -3003,7 +3003,7 @@ for (int i=0; i<100000; i++) { -

    21.4.4 Type wrapper classes

    +

    22.4.4 Type wrapper classes

    @@ -3090,7 +3090,7 @@ public static void spam(SWIGTYPE_p_int x, SWIGTYPE_p_int y, int z) { ... } -

    21.4.5 Enum classes

    +

    22.4.5 Enum classes

    @@ -3099,7 +3099,7 @@ The Enumerations section discussed these but om The following sub-sections detail the various types of enum classes that can be generated.

    -

    21.4.5.1 Typesafe enum classes

    +

    22.4.5.1 Typesafe enum classes

    @@ -3183,7 +3183,7 @@ The swigValue method is used for marshalling in the other direction. The toString method is overridden so that the enum name is available.

    -

    21.4.5.2 Proper Java enum classes

    +

    22.4.5.2 Proper Java enum classes

    @@ -3261,7 +3261,7 @@ These needn't be generated if the enum being wrapped does not have any initializ Simpler Java enums for enums without initializers section describes how typemaps can be used to achieve this.

    -

    21.4.5.3 Type unsafe enum classes

    +

    22.4.5.3 Type unsafe enum classes

    @@ -3292,7 +3292,7 @@ public final class Beverage { -

    21.5 Cross language polymorphism using directors

    +

    22.5 Cross language polymorphism using directors

    @@ -3314,7 +3314,7 @@ The upshot is that C++ classes can be extended in Java and from C++ these extens Neither C++ code nor Java code needs to know where a particular method is implemented: the combination of proxy classes, director classes, and C wrapper functions transparently takes care of all the cross-language method routing.

    -

    21.5.1 Enabling directors

    +

    22.5.1 Enabling directors

    @@ -3385,7 +3385,7 @@ public: -

    21.5.2 Director classes

    +

    22.5.2 Director classes

    @@ -3412,7 +3412,7 @@ If the correct implementation is in Java, the Java API is used to call the metho

    -

    21.5.3 Overhead and code bloat

    +

    22.5.3 Overhead and code bloat

    @@ -3430,7 +3430,7 @@ This situation can be optimized by selectively enabling director methods (using

    -

    21.5.4 Simple directors example

    +

    22.5.4 Simple directors example

    @@ -3495,7 +3495,7 @@ DirectorDerived::upcall_method() invoked. -

    21.5.5 Director threading issues

    +

    22.5.5 Director threading issues

    @@ -3515,7 +3515,7 @@ Macros can be defined on the commandline when compiling your C++ code, or altern -

    21.6 Accessing protected members

    +

    22.6 Accessing protected members

    @@ -3611,7 +3611,7 @@ class MyProtectedBase extends ProtectedBase -

    21.7 Common customization features

    +

    22.7 Common customization features

    @@ -3623,7 +3623,7 @@ be awkward. This section describes some common SWIG features that are used to improve the interface to existing C/C++ code.

    -

    21.7.1 C/C++ helper functions

    +

    22.7.1 C/C++ helper functions

    @@ -3689,7 +3689,7 @@ hard to implement. It is possible to improve on this using Java code, typemaps, customization features as covered in later sections, but sometimes helper functions are a quick and easy solution to difficult cases.

    -

    21.7.2 Class extension with %extend

    +

    22.7.2 Class extension with %extend

    @@ -3752,7 +3752,7 @@ Vector(2,3,4) in any way---the extensions only show up in the Java interface.

    -

    21.7.3 Exception handling with %exception and %javaexception

    +

    22.7.3 Exception handling with %exception and %javaexception

    @@ -3911,7 +3911,7 @@ to raise exceptions. See the SWIG Library ch The typemap example Handling C++ exception specifications as Java exceptions provides further exception handling capabilities.

    -

    21.7.4 Method access with %javamethodmodifiers

    +

    22.7.4 Method access with %javamethodmodifiers

    @@ -3937,7 +3937,7 @@ protected static void protect_me() { -

    21.8 Tips and techniques

    +

    22.8 Tips and techniques

    @@ -3947,7 +3947,7 @@ strings and arrays. This chapter discusses the common techniques for solving these problems.

    -

    21.8.1 Input and output parameters using primitive pointers and references

    +

    22.8.1 Input and output parameters using primitive pointers and references

    @@ -4121,7 +4121,7 @@ void foo(Bar *OUTPUT); will not have the intended effect since typemaps.i does not define an OUTPUT rule for Bar.

    -

    21.8.2 Simple pointers

    +

    22.8.2 Simple pointers

    @@ -4187,7 +4187,7 @@ System.out.println("3 + 4 = " + result); See the SWIG Library chapter for further details.

    -

    21.8.3 Wrapping C arrays with Java arrays

    +

    22.8.3 Wrapping C arrays with Java arrays

    @@ -4254,7 +4254,7 @@ Please be aware that the typemaps in this library are not efficient as all the e There is an alternative approach using the SWIG array library and this is covered in the next section.

    -

    21.8.4 Unbounded C Arrays

    +

    22.8.4 Unbounded C Arrays

    @@ -4399,7 +4399,7 @@ well suited for applications in which you need to create buffers, package binary data, etc.

    -

    21.8.5 Overriding new and delete to allocate from Java heap

    +

    22.8.5 Overriding new and delete to allocate from Java heap

    @@ -4516,7 +4516,7 @@ model and use these functions in place of malloc and free in your own code.

    -

    21.9 Java typemaps

    +

    22.9 Java typemaps

    @@ -4537,7 +4537,7 @@ Before proceeding, it should be stressed that typemaps are not a required part of using SWIG---the default wrapping behavior is enough in most cases. Typemaps are only used if you want to change some aspect of the generated code. -

    21.9.1 Default primitive type mappings

    +

    22.9.1 Default primitive type mappings

    @@ -4689,7 +4689,7 @@ However, the mappings allow the full range of values for each C type from Java.

    -

    21.9.2 Default typemaps for non-primitive types

    +

    22.9.2 Default typemaps for non-primitive types

    @@ -4704,7 +4704,7 @@ So in summary, the C/C++ pointer to non-primitive types is cast into the 64 bit The Java type is either the proxy class or type wrapper class.

    -

    21.9.3 Sixty four bit JVMs

    +

    22.9.3 Sixty four bit JVMs

    @@ -4717,7 +4717,7 @@ Unfortunately it won't of course hold true for JNI code.

    -

    21.9.4 What is a typemap?

    +

    22.9.4 What is a typemap?

    @@ -4840,7 +4840,7 @@ int c = example.count('e',"Hello World"); -

    21.9.5 Typemaps for mapping C/C++ types to Java types

    +

    22.9.5 Typemaps for mapping C/C++ types to Java types

    @@ -5100,7 +5100,7 @@ These are listed below: -

    21.9.6 Java typemap attributes

    +

    22.9.6 Java typemap attributes

    @@ -5146,7 +5146,7 @@ The "javain" typemap has the optional 'pre', 'post' and 'pgcppname' attributes. Note that when the 'pre' or 'post' attributes are specified and the associated type is used in a constructor, a constructor helper function is generated. This is necessary as the Java proxy constructor wrapper makes a call to a support constructor using a this call. In Java the this call must be the first statement in the constructor body. The constructor body thus calls the helper function and the helper function instead makes the JNI call, ensuring the 'pre' code is called before the JNI call is made. There is a Date marshalling example showing 'pre', 'post' and 'pgcppname' attributes in action.

    -

    21.9.7 Java special variables

    +

    22.9.7 Java special variables

    @@ -5297,7 +5297,7 @@ This special variable expands to the intermediary class name. Usually this is th unless the jniclassname attribute is specified in the %module directive.

    -

    21.9.8 Typemaps for both C and C++ compilation

    +

    22.9.8 Typemaps for both C and C++ compilation

    @@ -5334,7 +5334,7 @@ If you do not intend your code to be targeting both C and C++ then your typemaps

    -

    21.9.9 Java code typemaps

    +

    22.9.9 Java code typemaps

    @@ -5540,7 +5540,7 @@ For the typemap to be used in all type wrapper classes, all the different types Again this is the same that is in "java.swg", barring the method modifier for getCPtr.

    -

    21.9.10 Director specific typemaps

    +

    22.9.10 Director specific typemaps

    @@ -5765,7 +5765,7 @@ The basic strategy here is to provide a default package typemap for the majority -

    21.10 Typemap Examples

    +

    22.10 Typemap Examples

    @@ -5775,7 +5775,7 @@ the SWIG library.

    -

    21.10.1 Simpler Java enums for enums without initializers

    +

    22.10.1 Simpler Java enums for enums without initializers

    @@ -5854,7 +5854,7 @@ This would be done by using the original versions of these typemaps in "enums.sw

    -

    21.10.2 Handling C++ exception specifications as Java exceptions

    +

    22.10.2 Handling C++ exception specifications as Java exceptions

    @@ -5979,7 +5979,7 @@ We could alternatively have used %rename to rename what() into

    -

    21.10.3 NaN Exception - exception handling for a particular type

    +

    22.10.3 NaN Exception - exception handling for a particular type

    @@ -6134,7 +6134,7 @@ If we were a martyr to the JNI cause, we could replace the succinct code within If we had, we would have put it in the "in" typemap which, like all JNI and Java typemaps, also supports the 'throws' attribute.

    -

    21.10.4 Converting Java String arrays to char **

    +

    22.10.4 Converting Java String arrays to char **

    @@ -6278,7 +6278,7 @@ Lastly the "jni", "jtype" and "jstype" typemaps are also required to specify what Java types to use.

    -

    21.10.5 Expanding a Java object to multiple arguments

    +

    22.10.5 Expanding a Java object to multiple arguments

    @@ -6360,7 +6360,7 @@ example.foo(new String[]{"red", "green", "blue", "white"}); -

    21.10.6 Using typemaps to return arguments

    +

    22.10.6 Using typemaps to return arguments

    @@ -6478,7 +6478,7 @@ $ java runme 1 12.0 340.0 -

    21.10.7 Adding Java downcasts to polymorphic return types

    +

    22.10.7 Adding Java downcasts to polymorphic return types

    @@ -6684,7 +6684,7 @@ SWIG usually generates code which constructs the proxy classes using Java code a Note that the JNI code above uses a number of string lookups to call a constructor, whereas this would not occur using byte compiled Java code.

    -

    21.10.8 Adding an equals method to the Java classes

    +

    22.10.8 Adding an equals method to the Java classes

    @@ -6728,7 +6728,7 @@ System.out.println("foo1? " + foo1.equals(foo2)); -

    21.10.9 Void pointers and a common Java base class

    +

    22.10.9 Void pointers and a common Java base class

    @@ -6787,7 +6787,7 @@ This example contains some useful functionality which you may want in your code.

  • It also has a function which effectively implements a cast from the type of the proxy/type wrapper class to a void pointer. This is necessary for passing a proxy class or a type wrapper class to a function that takes a void pointer. -

    21.10.10 Struct pointer to pointer

    +

    22.10.10 Struct pointer to pointer

    @@ -6967,7 +6967,7 @@ The C functional interface has been completely morphed into an object-oriented i the Butler class would behave much like any pure Java class and feel more natural to Java users.

    -

    21.10.11 Memory management when returning references to member variables

    +

    22.10.11 Memory management when returning references to member variables

    @@ -7090,7 +7090,7 @@ public class Bike { Note the addReference call.

    -

    21.10.12 Memory management for objects passed to the C++ layer

    +

    22.10.12 Memory management for objects passed to the C++ layer

    @@ -7206,7 +7206,7 @@ The 'javacode' typemap simply adds in the specified code into the Java proxy cla -

    21.10.13 Date marshalling using the javain typemap and associated attributes

    +

    22.10.13 Date marshalling using the javain typemap and associated attributes

    @@ -7383,7 +7383,7 @@ A few things to note: -

    21.11 Living with Java Directors

    +

    22.11 Living with Java Directors

    @@ -7564,10 +7564,10 @@ public abstract class UserVisibleFoo extends Foo {

  • -

    21.12 Odds and ends

    +

    22.12 Odds and ends

    -

    21.12.1 JavaDoc comments

    +

    22.12.1 JavaDoc comments

    @@ -7623,7 +7623,7 @@ public class Barmy { -

    21.12.2 Functional interface without proxy classes

    +

    22.12.2 Functional interface without proxy classes

    @@ -7684,7 +7684,7 @@ All destructors have to be called manually for example the delete_Foo(foo) -

    21.12.3 Using your own JNI functions

    +

    22.12.3 Using your own JNI functions

    @@ -7734,7 +7734,7 @@ This directive is only really useful if you want to mix your own hand crafted JN

    -

    21.12.4 Performance concerns and hints

    +

    22.12.4 Performance concerns and hints

    @@ -7755,7 +7755,7 @@ However, you will have to be careful about memory management and make sure that This method normally calls the C++ destructor or free() for C code.

    -

    21.12.5 Debugging

    +

    22.12.5 Debugging

    @@ -7777,7 +7777,7 @@ The -verbose:jni and -verbose:gc are also useful options for monitoring code beh

    -

    21.13 Examples

    +

    22.13 Examples

    diff --git a/Doc/Manual/Lisp.html b/Doc/Manual/Lisp.html index aa62250b9..b9b5b6c1e 100644 --- a/Doc/Manual/Lisp.html +++ b/Doc/Manual/Lisp.html @@ -6,7 +6,7 @@ -

    22 SWIG and Common Lisp

    +

    23 SWIG and Common Lisp

      @@ -41,7 +41,7 @@ Lisp, Common Foreign Function Interface(CFFI), CLisp and UFFI foreign function interfaces.

      -

      22.1 Allegro Common Lisp

      +

      23.1 Allegro Common Lisp

      @@ -50,7 +50,7 @@ here

      -

      22.2 Common Foreign Function Interface(CFFI)

      +

      23.2 Common Foreign Function Interface(CFFI)

      @@ -77,7 +77,7 @@ swig -cffi -module module-name file-name files and the various things which you can do with them.

      -

      22.2.1 Additional Commandline Options

      +

      23.2.1 Additional Commandline Options

      @@ -118,7 +118,7 @@ swig -cffi -help -

      22.2.2 Generating CFFI bindings

      +

      23.2.2 Generating CFFI bindings

      As we mentioned earlier the ideal way to use SWIG is to use interface @@ -392,7 +392,7 @@ The feature intern_function ensures that all C names are
    -

    22.2.3 Generating CFFI bindings for C++ code

    +

    23.2.3 Generating CFFI bindings for C++ code

    This feature to SWIG (for CFFI) is very new and still far from @@ -568,7 +568,7 @@ If you have any questions, suggestions, patches, etc., related to CFFI module feel free to contact us on the SWIG mailing list, and also please add a "[CFFI]" tag in the subject line. -

    22.2.4 Inserting user code into generated files

    +

    23.2.4 Inserting user code into generated files

    @@ -608,7 +608,7 @@ Note that the block %{ ... %} is effectively a shortcut for

    -

    22.3 CLISP

    +

    23.3 CLISP

    @@ -638,7 +638,7 @@ swig -clisp -module module-name file-name interface file for the CLISP module. The CLISP module tries to produce code which is both human readable and easily modifyable.

    -

    22.3.1 Additional Commandline Options

    +

    23.3.1 Additional Commandline Options

    @@ -671,7 +671,7 @@ and global variables will be created otherwise only definitions for
    -

    22.3.2 Details on CLISP bindings

    +

    23.3.2 Details on CLISP bindings

    @@ -795,7 +795,7 @@ struct bar { -

    22.4 UFFI

    +

    23.4 UFFI

    diff --git a/Doc/Manual/Lua.html b/Doc/Manual/Lua.html index a1544d21e..c07fe66c8 100644 --- a/Doc/Manual/Lua.html +++ b/Doc/Manual/Lua.html @@ -6,7 +6,7 @@ -

    23 SWIG and Lua

    +

    24 SWIG and Lua

      @@ -67,13 +67,13 @@

      Lua is an extension programming language designed to support general procedural programming with data description facilities. It also offers good support for object-oriented programming, functional programming, and data-driven programming. Lua is intended to be used as a powerful, light-weight configuration language for any program that needs one. Lua is implemented as a library, written in clean C (that is, in the common subset of ANSI C and C++). Its also a really tiny language, less than 6000 lines of code, which compiles to <100 kilobytes of binary code. It can be found at http://www.lua.org

      -

      23.1 Preliminaries

      +

      24.1 Preliminaries

      The current SWIG implementation is designed to work with Lua 5.0.x and Lua 5.1.x. It should work with later versions of Lua, but certainly not with Lua 4.0 due to substantial API changes. ((Currently SWIG generated code has only been tested on Windows with MingW, though given the nature of Lua, is should not have problems on other OS's)). It is possible to either static link or dynamic link a Lua module into the interpreter (normally Lua static links its libraries, as dynamic linking is not available on all platforms).

      -

      23.2 Running SWIG

      +

      24.2 Running SWIG

      @@ -105,7 +105,7 @@ This creates a C/C++ source file example_wrap.c or example_wrap.cxx

      The name of the wrapper file is derived from the name of the input file. For example, if the input file is example.i, the name of the wrapper file is example_wrap.c. To change this, you can use the -o option. The wrappered module will export one function "int luaopen_example(lua_State* L)" which must be called to register the module with the Lua interpreter. The name "luaopen_example" depends upon the name of the module.

      -

      23.2.1 Compiling and Linking and Interpreter

      +

      24.2.1 Compiling and Linking and Interpreter

      @@ -152,7 +152,7 @@ $ gcc -c example.c -o example.o $ gcc -I/usr/include/lua -L/usr/lib/lua min.o example_wrap.o example.o -o my_lua

    -

    23.2.2 Compiling a dynamic module

    +

    24.2.2 Compiling a dynamic module

    @@ -220,7 +220,7 @@ Is quite obvious (Go back and consult the Lua documents on how to enable loadlib -

    23.2.3 Using your module

    +

    24.2.3 Using your module

    @@ -238,19 +238,19 @@ $ ./my_lua > -

    23.3 A tour of basic C/C++ wrapping

    +

    24.3 A tour of basic C/C++ wrapping

    By default, SWIG tries to build a very natural Lua interface to your C/C++ code. This section briefly covers the essential aspects of this wrapping.

    -

    23.3.1 Modules

    +

    24.3.1 Modules

    The SWIG module directive specifies the name of the Lua module. If you specify `module example', then everything is wrapped into a Lua table 'example' containing all the functions and variables. When choosing a module name, make sure you don't use the same name as a built-in Lua command or standard module name.

    -

    23.3.2 Functions

    +

    24.3.2 Functions

    @@ -288,7 +288,7 @@ It is also possible to rename the module with an assignment. 24 -

    23.3.3 Global variables

    +

    24.3.3 Global variables

    @@ -362,7 +362,7 @@ nil 3.142 -

    23.3.4 Constants and enums

    +

    24.3.4 Constants and enums

    @@ -385,7 +385,7 @@ example.SUNDAY=0

    Constants are not guaranteed to remain constant in Lua. The name of the constant could be accidentally reassigned to refer to some other object. Unfortunately, there is no easy way for SWIG to generate code that prevents this. You will just have to be careful.

    -

    23.3.5 Pointers

    +

    24.3.5 Pointers

    @@ -423,7 +423,7 @@ Lua enforces the integrity of its userdata, so it is virtually impossible to cor nil -

    23.3.6 Structures

    +

    24.3.6 Structures

    @@ -509,7 +509,7 @@ Because the pointer points inside the structure, you can modify the contents and > x.a = 3 -- Modifies the same structure -

    23.3.7 C++ classes

    +

    24.3.7 C++ classes

    @@ -570,7 +570,7 @@ It is not (currently) possible to access static members of an instance: -- does NOT work -

    23.3.8 C++ inheritance

    +

    24.3.8 C++ inheritance

    @@ -595,7 +595,7 @@ then the function spam() accepts a Foo pointer or a pointer to any clas

    It is safe to use multiple inheritance with SWIG.

    -

    23.3.9 Pointers, references, values, and arrays

    +

    24.3.9 Pointers, references, values, and arrays

    @@ -626,7 +626,7 @@ Foo spam7();

    then all three functions will return a pointer to some Foo object. Since the third function (spam7) returns a value, newly allocated memory is used to hold the result and a pointer is returned (Lua will release this memory when the return value is garbage collected). The other two are pointers which are assumed to be managed by the C code and so will not be garbage collected.

    -

    23.3.10 C++ overloaded functions

    +

    24.3.10 C++ overloaded functions

    @@ -712,7 +712,7 @@ Please refer to the "SWIG and C++" chapter for more information about overloadin

    Dealing with the Lua coercion mechanism, the priority is roughly (integers, floats, strings, userdata). But it is better to rename the functions rather than rely upon the ordering.

    -

    23.3.11 C++ operators

    +

    24.3.11 C++ operators

    @@ -824,7 +824,7 @@ It is also possible to overload the operator[], but currently this cann }; -

    23.3.12 Class extension with %extend

    +

    24.3.12 Class extension with %extend

    @@ -879,7 +879,7 @@ true

    Extend works with both C and C++ code, on classes and structs. It does not modify the underlying object in any way---the extensions only show up in the Lua interface. The only item to take note of is the code has to use the '$self' instead of 'this', and that you cannot access protected/private members of the code (as you are not officially part of the class).

    -

    23.3.13 C++ templates

    +

    24.3.13 C++ templates

    @@ -914,7 +914,7 @@ In Lua:

    Obviously, there is more to template wrapping than shown in this example. More details can be found in the SWIG and C++ chapter. Some more complicated examples will appear later.

    -

    23.3.14 C++ Smart Pointers

    +

    24.3.14 C++ Smart Pointers

    @@ -966,7 +966,7 @@ If you ever need to access the underlying pointer returned by operator->( > f = p:__deref__() -- Returns underlying Foo * -

    23.3.15 C++ Exceptions

    +

    24.3.15 C++ Exceptions

    @@ -1110,12 +1110,12 @@ add exception specification to functions or globally (respectively).

    -

    23.4 Typemaps

    +

    24.4 Typemaps

    This section explains what typemaps are and the usage of them. The default wrappering behaviour of SWIG is enough in most cases. However sometimes SWIG may need a little additional assistance to know which typemap to apply to provide the best wrappering. This section will be explaining how to use typemaps to best effect

    -

    23.4.1 What is a typemap?

    +

    24.4.1 What is a typemap?

    A typemap is nothing more than a code generation rule that is attached to a specific C datatype. For example, to convert integers from Lua to C, you might define a typemap like this:

    @@ -1143,7 +1143,7 @@ Received an integer : 6 720 -

    23.4.2 Using typemaps

    +

    24.4.2 Using typemaps

    There are many ready written typemaps built into SWIG for all common types (int, float, short, long, char*, enum and more), which SWIG uses automatically, with no effort required on your part.

    @@ -1196,7 +1196,7 @@ void swap(int *sx, int *sy);

    Note: C++ references must be handled exactly the same way. However SWIG will automatically wrap a const int& as an input parameter (since that it obviously input).

    -

    23.4.3 Typemaps and arrays

    +

    24.4.3 Typemaps and arrays

    Arrays present a challenge for SWIG, because like pointers SWIG does not know whether these are input or output values, nor @@ -1260,7 +1260,7 @@ and Lua tables to be 1..N, (the indexing follows the norm for the language). In

    Note: SWIG also can support arrays of pointers in a similar manner.

    -

    23.4.4 Typemaps and pointer-pointer functions

    +

    24.4.4 Typemaps and pointer-pointer functions

    Several C++ libraries use a pointer-pointer functions to create its objects. These functions require a pointer to a pointer which is then filled with the pointer to the new object. Microsoft's COM and DirectX as well as many other libraries have this kind of function. An example is given below:

    @@ -1294,7 +1294,7 @@ int Create_Math(iMath** pptr); // its creator (assume it mallocs) ptr=nil -- the iMath* will be GC'ed as normal -

    23.5 Writing typemaps

    +

    24.5 Writing typemaps

    This section describes how you can modify SWIG's default wrapping behavior for various C/C++ datatypes using the %typemap directive. This is an advanced topic that assumes familiarity with the Lua C API as well as the material in the "Typemaps" chapter.

    @@ -1303,7 +1303,7 @@ ptr=nil -- the iMath* will be GC'ed as normal

    Before proceeding, you should read the previous section on using typemaps, as well as read the ready written typemaps found in luatypemaps.swg and typemaps.i. These are both well documented and fairly easy to read. You should not attempt to write your own typemaps until you have read and can understand both of these files (they may well also give you a idea to base your worn on).

    -

    23.5.1 Typemaps you can write

    +

    24.5.1 Typemaps you can write

    There are many different types of typemap that can be written, the full list can be found in the "Typemaps" chapter. However the following are the most commonly used ones.

    @@ -1316,7 +1316,7 @@ ptr=nil -- the iMath* will be GC'ed as normal (the syntax for the typecheck is different from the typemap, see typemaps for details). -

    23.5.2 SWIG's Lua-C API

    +

    24.5.2 SWIG's Lua-C API

    This section explains the SWIG specific Lua-C API. It does not cover the main Lua-C api, as this is well documented and not worth covering.

    @@ -1365,7 +1365,7 @@ This macro, when called within the context of a SWIG wrappered function, will di
    Similar to SWIG_fail_arg, except that it will display the swig_type_info information instead.
    -

    23.6 Customization of your Bindings

    +

    24.6 Customization of your Bindings

    @@ -1374,7 +1374,7 @@ This section covers adding of some small extra bits to your module to add the la -

    23.6.1 Writing your own custom wrappers

    +

    24.6.1 Writing your own custom wrappers

    @@ -1393,7 +1393,7 @@ int native_function(lua_State*L) // my native code The %native directive in the above example, tells SWIG that there is a function int native_function(lua_State*L); which is to be added into the module under the name 'my_func'. SWIG will not add any wrappering for this function, beyond adding it into the function table. How you write your code is entirely up to you.

    -

    23.6.2 Adding additional Lua code

    +

    24.6.2 Adding additional Lua code

    @@ -1431,7 +1431,7 @@ Good uses for this feature is adding of new code, or writing helper functions to See Examples/lua/arrays for an example of this code.

    -

    23.7 Details on the Lua binding

    +

    24.7 Details on the Lua binding

    @@ -1442,7 +1442,7 @@ See Examples/lua/arrays for an example of this code.

    -

    23.7.1 Binding global data into the module.

    +

    24.7.1 Binding global data into the module.

    @@ -1502,7 +1502,7 @@ end

    That way when you call 'a=example.Foo', the interpreter looks at the table 'example' sees that there is no field 'Foo' and calls __index. This will in turn check in '.get' table and find the existence of 'Foo' and then return the value of the C function call 'Foo_get()'. Similarly for the code 'example.Foo=10', the interpreter will check the table, then call the __newindex which will then check the '.set' table and call the C function 'Foo_set(10)'.

    -

    23.7.2 Userdata and Metatables

    +

    24.7.2 Userdata and Metatables

    @@ -1582,7 +1582,7 @@ Note: Both the opaque structures (like the FILE*) and normal wrappered classes/s

    Note: Operator overloads are basically done in the same way, by adding functions such as '__add' & '__call' to the classes metatable. The current implementation is a bit rough as it will add any member function beginning with '__' into the metatable too, assuming its an operator overload.

    -

    23.7.3 Memory management

    +

    24.7.3 Memory management

    diff --git a/Doc/Manual/Modula3.html b/Doc/Manual/Modula3.html index ee7d2785d..71611e3c5 100644 --- a/Doc/Manual/Modula3.html +++ b/Doc/Manual/Modula3.html @@ -5,7 +5,7 @@ -

    24 SWIG and Modula-3

    +

    25 SWIG and Modula-3

      @@ -54,7 +54,7 @@ especially typemaps.

      -

      24.1 Overview

      +

      25.1 Overview

      @@ -84,7 +84,7 @@ FFTW -

      24.1.1 Motivation

      +

      25.1.1 Motivation

      @@ -131,10 +131,10 @@ functions), but it doesn't allow you to easily integrate a Module-3 module into a C/C++ project.

      -

      24.2 Conception

      +

      25.2 Conception

      -

      24.2.1 Interfaces to C libraries

      +

      25.2.1 Interfaces to C libraries

      @@ -283,7 +283,7 @@ and the principal type must be renamed (%typemap).

      -

      24.2.2 Interfaces to C++ libraries

      +

      25.2.2 Interfaces to C++ libraries

      @@ -384,10 +384,10 @@ There is no C++ library I wrote a SWIG interface for, so I'm not sure if this is possible or sensible, yet.

      -

      24.3 Preliminaries

      +

      25.3 Preliminaries

      -

      24.3.1 Compilers

      +

      25.3.1 Compilers

      @@ -401,7 +401,7 @@ For testing examples I use Critical Mass cm3.

      -

      24.3.2 Additional Commandline Options

      +

      25.3.2 Additional Commandline Options

      @@ -478,10 +478,10 @@ Instead generate templates for some basic typemaps. -

      24.4 Modula-3 typemaps

      +

      25.4 Modula-3 typemaps

      -

      24.4.1 Inputs and outputs

      +

      25.4.1 Inputs and outputs

      @@ -697,7 +697,7 @@ consist of the following parts: -

      24.4.2 Subranges, Enumerations, Sets

      +

      25.4.2 Subranges, Enumerations, Sets

      @@ -749,7 +749,7 @@ that I'd like to automate.

      -

      24.4.3 Objects

      +

      25.4.3 Objects

      @@ -762,7 +762,7 @@ is not really useful, yet.

      -

      24.4.4 Imports

      +

      25.4.4 Imports

      @@ -797,7 +797,7 @@ IMPORT M3toC;

    -

    24.4.5 Exceptions

    +

    25.4.5 Exceptions

    @@ -821,7 +821,7 @@ you should declare %typemap("m3wrapinconv:throws") blah * %{OSError.E%}.

    -

    24.4.6 Example

    +

    25.4.6 Example

    @@ -868,10 +868,10 @@ where almost everything is generated by a typemap: -

    24.5 More hints to the generator

    +

    25.5 More hints to the generator

    -

    24.5.1 Features

    +

    25.5.1 Features

    @@ -908,7 +908,7 @@ where almost everything is generated by a typemap:
    -

    24.5.2 Pragmas

    +

    25.5.2 Pragmas

    @@ -931,7 +931,7 @@ where almost everything is generated by a typemap:
    -

    24.6 Remarks

    +

    25.6 Remarks

      diff --git a/Doc/Manual/Mzscheme.html b/Doc/Manual/Mzscheme.html index 008e3aeb3..4351e34a7 100644 --- a/Doc/Manual/Mzscheme.html +++ b/Doc/Manual/Mzscheme.html @@ -8,7 +8,7 @@ -

      25 SWIG and MzScheme

      +

      26 SWIG and MzScheme

        @@ -22,7 +22,7 @@

        This section contains information on SWIG's support of MzScheme. -

        25.1 Creating native MzScheme structures

        +

        26.1 Creating native MzScheme structures

        diff --git a/Doc/Manual/Ocaml.html b/Doc/Manual/Ocaml.html index b65831192..6cbfa5510 100644 --- a/Doc/Manual/Ocaml.html +++ b/Doc/Manual/Ocaml.html @@ -6,7 +6,7 @@ -

        26 SWIG and Ocaml

        +

        27 SWIG and Ocaml

          @@ -80,7 +80,7 @@ If you're not familiar with the Objective Caml language, you can visit The Ocaml Website.

          -

          26.1 Preliminaries

          +

          27.1 Preliminaries

          @@ -99,7 +99,7 @@ file Examples/Makefile illustrate how to compile and link SWIG modules that will be loaded dynamically. This has only been tested on Linux so far.

          -

          26.1.1 Running SWIG

          +

          27.1.1 Running SWIG

          @@ -122,7 +122,7 @@ you will compile the file example_wrap.c with ocamlc or the resulting .ml and .mli files as well, and do the final link with -custom (not needed for native link).

          -

          26.1.2 Compiling the code

          +

          27.1.2 Compiling the code

          @@ -158,7 +158,7 @@ the user more freedom with respect to custom typing.

        -

        26.1.3 The camlp4 module

        +

        27.1.3 The camlp4 module

        @@ -234,7 +234,7 @@ let b = C_string (getenv "PATH") -

        26.1.4 Using your module

        +

        27.1.4 Using your module

        @@ -248,7 +248,7 @@ When linking any ocaml bytecode with your module, use the -custom option is not needed when you build native code.

        -

        26.1.5 Compilation problems and compiling with C++

        +

        27.1.5 Compilation problems and compiling with C++

        @@ -259,7 +259,7 @@ liberal with pointer types may not compile under the C++ compiler. Most code meant to be compiled as C++ will not have problems.

        -

        26.2 The low-level Ocaml/C interface

        +

        27.2 The low-level Ocaml/C interface

        @@ -360,7 +360,7 @@ is that you must append them to the return list with swig_result = caml_list_a signature for a function that uses value in this way.

        -

        26.2.1 The generated module

        +

        27.2.1 The generated module

        @@ -394,7 +394,7 @@ it describes the output SWIG will generate for class definitions. -

        26.2.2 Enums

        +

        27.2.2 Enums

        @@ -457,7 +457,7 @@ val x : Enum_test.c_obj = C_enum `a

      -

      26.2.2.1 Enum typing in Ocaml

      +

      27.2.2.1 Enum typing in Ocaml

      @@ -470,10 +470,10 @@ functions imported from different modules. You must convert values to master values using the swig_val function before sharing them with another module.

      -

      26.2.3 Arrays

      +

      27.2.3 Arrays

      -

      26.2.3.1 Simple types of bounded arrays

      +

      27.2.3.1 Simple types of bounded arrays

      @@ -494,7 +494,7 @@ arrays of simple types with known bounds in your code, but this only works for arrays whose bounds are completely specified.

      -

      26.2.3.2 Complex and unbounded arrays

      +

      27.2.3.2 Complex and unbounded arrays

      @@ -507,7 +507,7 @@ SWIG can't predict which of these methods will be used in the array, so you have to specify it for yourself in the form of a typemap.

      -

      26.2.3.3 Using an object

      +

      27.2.3.3 Using an object

      @@ -521,7 +521,7 @@ Consider writing an object when the ending condition of your array is complex, such as using a required sentinel, etc.

      -

      26.2.3.4 Example typemap for a function taking float * and int

      +

      27.2.3.4 Example typemap for a function taking float * and int

      @@ -572,7 +572,7 @@ void printfloats( float *tab, int len ); -

      26.2.4 C++ Classes

      +

      27.2.4 C++ Classes

      @@ -615,7 +615,7 @@ the underlying pointer, so using create_[x]_from_ptr alters the returned value for the same object.

      -

      26.2.4.1 STL vector and string Example

      +

      27.2.4.1 STL vector and string Example

      @@ -695,7 +695,7 @@ baz # -

      26.2.4.2 C++ Class Example

      +

      27.2.4.2 C++ Class Example

      @@ -725,7 +725,7 @@ public: }; -

      26.2.4.3 Compiling the example

      +

      27.2.4.3 Compiling the example

      @@ -743,7 +743,7 @@ bash-2.05a$ ocamlmktop -custom swig.cmo -I `camlp4 -where` \
         -L$QTPATH/lib -cclib -lqt
       
      -

      26.2.4.4 Sample Session

      +

      27.2.4.4 Sample Session

      @@ -770,10 +770,10 @@ Assuming you have a working installation of QT, you will see a window
       containing the string "hi" in a button.  
       

      -

      26.2.5 Director Classes

      +

      27.2.5 Director Classes

      -

      26.2.5.1 Director Introduction

      +

      27.2.5.1 Director Introduction

      @@ -800,7 +800,7 @@ class foo { };

      -

      26.2.5.2 Overriding Methods in Ocaml

      +

      27.2.5.2 Overriding Methods in Ocaml

      @@ -828,7 +828,7 @@ In this example, I'll examine the objective caml code involved in providing an overloaded class. This example is contained in Examples/ocaml/shapes.

      -

      26.2.5.3 Director Usage Example

      +

      27.2.5.3 Director Usage Example

      @@ -887,7 +887,7 @@ in a more effortless style in ocaml, while leaving the "engine" part of the program in C++.

      -

      26.2.5.4 Creating director objects

      +

      27.2.5.4 Creating director objects

      @@ -928,7 +928,7 @@ object from causing a core dump, as long as the object is destroyed properly.

      -

      26.2.5.5 Typemaps for directors, directorin, directorout, directorargout

      +

      27.2.5.5 Typemaps for directors, directorin, directorout, directorargout

      @@ -939,7 +939,7 @@ well as a function return value in the same way you provide function arguments, and to receive arguments the same way you normally receive function returns.

      -

      26.2.5.6 directorin typemap

      +

      27.2.5.6 directorin typemap

      @@ -950,7 +950,7 @@ code receives when you are called. In general, a simple directorin typ can use the same body as a simple out typemap.

      -

      26.2.5.7 directorout typemap

      +

      27.2.5.7 directorout typemap

      @@ -961,7 +961,7 @@ for the same type, except when there are special requirements for object ownership, etc.

      -

      26.2.5.8 directorargout typemap

      +

      27.2.5.8 directorargout typemap

      @@ -978,7 +978,7 @@ In the event that you don't specify all of the necessary values, integral values will read zero, and struct or object returns have undefined results.

      -

      26.2.6 Exceptions

      +

      27.2.6 Exceptions

      diff --git a/Doc/Manual/Octave.html b/Doc/Manual/Octave.html index de28a1427..be512f0ce 100644 --- a/Doc/Manual/Octave.html +++ b/Doc/Manual/Octave.html @@ -8,7 +8,7 @@ -

      27 SWIG and Octave

      +

      28 SWIG and Octave

        @@ -54,14 +54,14 @@ More information can be found at www.octave.org< Also, there are a dozen or so examples in the Examples/octave directory, and hundreds in the test suite (Examples/test-suite and Examples/test-suite/octave).

        -

        27.1 Preliminaries

        +

        28.1 Preliminaries

        The SWIG implemention was first based on Octave 2.9.12, so this is the minimum version required. Testing has only been done on Linux.

        -

        27.2 Running SWIG

        +

        28.2 Running SWIG

        @@ -97,7 +97,7 @@ This creates a C++ source file example_wrap.cxx. A C++ file is generate The swig command line has a number of options you can use, like to redirect it's output. Use swig --help to learn about these.

        -

        27.2.1 Compiling a dynamic module

        +

        28.2.1 Compiling a dynamic module

        @@ -124,7 +124,7 @@ $ mkoctfile example_wrap.cxx example.c

        octave:1> example
        -

        27.2.2 Using your module

        +

        28.2.2 Using your module

        @@ -142,10 +142,10 @@ octave:4> example.cvar.Foo=4; octave:5> example.cvar.Foo ans = 4

      -

      27.3 A tour of basic C/C++ wrapping

      +

      28.3 A tour of basic C/C++ wrapping

      -

      27.3.1 Modules

      +

      28.3.1 Modules

      @@ -187,7 +187,7 @@ One can also rename it by simple assignment, e.g., octave:1> some_vars = cvar; -

      27.3.2 Functions

      +

      28.3.2 Functions

      @@ -204,7 +204,7 @@ int fact(int n);

      octave:1> example.fact(4)
       24 
      -

      27.3.3 Global variables

      +

      28.3.3 Global variables

      @@ -257,7 +257,7 @@ octave:2> example.PI=3.142; octave:3> example.PI ans = 3.1420 -

      27.3.4 Constants and enums

      +

      28.3.4 Constants and enums

      @@ -279,7 +279,7 @@ example.SCONST="Hello World" example.SUNDAY=0 .... -

      27.3.5 Pointers

      +

      28.3.5 Pointers

      @@ -326,7 +326,7 @@ octave:2> f=example.fopen("not there","r"); error: value on right hand side of assignment is undefined error: evaluating assignment expression near line 2, column 2 -

      27.3.6 Structures and C++ classes

      +

      28.3.6 Structures and C++ classes

      @@ -461,7 +461,7 @@ ans = 1 Depending on the ownership setting of a swig_ref, it may call C++ destructors when its reference count goes to zero. See the section on memory management below for details.

      -

      27.3.7 C++ inheritance

      +

      28.3.7 C++ inheritance

      @@ -470,7 +470,7 @@ This information contains the full class hierarchy. When an indexing operation ( the tree is walked to find a match in the current class as well as any of its bases. The lookup is then cached in the swig_ref.

      -

      27.3.8 C++ overloaded functions

      +

      28.3.8 C++ overloaded functions

      @@ -480,7 +480,7 @@ The dispatch function selects which overload to call (if any) based on the passe typecheck typemaps are used to analyze each argument, as well as assign precedence. See the chapter on typemaps for details.

      -

      27.3.9 C++ operators

      +

      28.3.9 C++ operators

      @@ -580,7 +580,7 @@ On the C++ side, the default mappings are as follows: %rename(__brace) *::operator[]; -

      27.3.10 Class extension with %extend

      +

      28.3.10 Class extension with %extend

      @@ -610,7 +610,7 @@ octave:3> printf("%s\n",a); octave:4> a.__str() 4 -

      27.3.11 C++ templates

      +

      28.3.11 C++ templates

      @@ -687,14 +687,14 @@ ans = -

      27.3.12 C++ Smart Pointers

      +

      28.3.12 C++ Smart Pointers

      C++ smart pointers are fully supported as in other modules.

      -

      27.3.13 Directors (calling Octave from C++ code)

      +

      28.3.13 Directors (calling Octave from C++ code)

      @@ -774,14 +774,14 @@ c-side routine called octave-side routine called -

      27.3.14 Threads

      +

      28.3.14 Threads

      The use of threads in wrapped Director code is not supported; i.e., an Octave-side implementation of a C++ class must be called from the Octave interpreter's thread. Anything fancier (apartment/queue model, whatever) is left to the user. Without anything fancier, this amounts to the limitation that Octave must drive the module... like, for example, an optimization package that calls Octave to evaluate an objective function.

      -

      27.3.15 Memory management

      +

      28.3.15 Memory management

      @@ -815,14 +815,14 @@ The %newobject directive may be used to control this behavior for pointers retur In the case where one wishes for the C++ side to own an object that was created in Octave (especially a Director object), one can use the __disown() method to invert this logic. Then letting the Octave reference count go to zero will not destroy the object, but destroying the object will invalidate the Octave-side object if it still exists (and call destructors of other C++ bases in the case of multiple inheritance/subclass()'ing).

      -

      27.3.16 STL support

      +

      28.3.16 STL support

      Various STL library files are provided for wrapping STL containers.

      -

      27.3.17 Matrix typemaps

      +

      28.3.17 Matrix typemaps

      diff --git a/Doc/Manual/Perl5.html b/Doc/Manual/Perl5.html index 777c2f6a2..0c2733c0e 100644 --- a/Doc/Manual/Perl5.html +++ b/Doc/Manual/Perl5.html @@ -6,7 +6,7 @@ -

      28 SWIG and Perl5

      +

      29 SWIG and Perl5

        @@ -87,7 +87,7 @@ later. Earlier versions are problematic and SWIG generated extensions may not compile or run correctly.

        -

        28.1 Overview

        +

        29.1 Overview

        @@ -108,7 +108,7 @@ described. Advanced customization features, typemaps, and other options are found near the end of the chapter.

        -

        28.2 Preliminaries

        +

        29.2 Preliminaries

        @@ -133,7 +133,7 @@ To build the module, you will need to compile the file example_wrap.c and link it with the rest of your program.

        -

        28.2.1 Getting the right header files

        +

        29.2.1 Getting the right header files

        @@ -165,7 +165,7 @@ loaded, an easy way to find out is to run Perl itself.

      -

      28.2.2 Compiling a dynamic module

      +

      29.2.2 Compiling a dynamic module

      @@ -198,7 +198,7 @@ the target should be named `example.so', `example.sl', or the appropriate dynamic module name on your system.

      -

      28.2.3 Building a dynamic module with MakeMaker

      +

      29.2.3 Building a dynamic module with MakeMaker

      @@ -232,7 +232,7 @@ the preferred approach to compilation. More information about MakeMaker can be found in "Programming Perl, 2nd ed." by Larry Wall, Tom Christiansen, and Randal Schwartz.

      -

      28.2.4 Building a static version of Perl

      +

      29.2.4 Building a static version of Perl

      @@ -301,7 +301,7 @@ added to it. Depending on your machine, you may need to link with additional libraries such as -lsocket, -lnsl, -ldl, etc.

      -

      28.2.5 Using the module

      +

      29.2.5 Using the module

      @@ -456,7 +456,7 @@ system configuration (this requires root access and you will need to read the man pages).

      -

      28.2.6 Compilation problems and compiling with C++

      +

      29.2.6 Compilation problems and compiling with C++

      @@ -599,7 +599,7 @@ have to find the macro that conflicts and add an #undef into the .i file. Pleas any conflicting macros you find to swig-user mailing list.

      -

      28.2.7 Compiling for 64-bit platforms

      +

      29.2.7 Compiling for 64-bit platforms

      @@ -626,7 +626,7 @@ also introduce problems on platforms that support more than one linking standard (e.g., -o32 and -n32 on Irix).

      -

      28.3 Building Perl Extensions under Windows

      +

      29.3 Building Perl Extensions under Windows

      @@ -637,7 +637,7 @@ section assumes you are using SWIG with Microsoft Visual C++ although the procedure may be similar with other compilers.

      -

      28.3.1 Running SWIG from Developer Studio

      +

      29.3.1 Running SWIG from Developer Studio

      @@ -700,7 +700,7 @@ print "$a\n"; -

      28.3.2 Using other compilers

      +

      29.3.2 Using other compilers

      @@ -708,7 +708,7 @@ SWIG is known to work with Cygwin and may work with other compilers on Windows. For general hints and suggestions refer to the Windows chapter.

      -

      28.4 The low-level interface

      +

      29.4 The low-level interface

      @@ -718,7 +718,7 @@ can be used to control your application. However, it is also used to construct more user-friendly proxy classes as described in the next section.

      -

      28.4.1 Functions

      +

      29.4.1 Functions

      @@ -741,7 +741,7 @@ use example; $a = &example::fact(2); -

      28.4.2 Global variables

      +

      29.4.2 Global variables

      @@ -811,7 +811,7 @@ extern char *path; // Declared later in the input -

      28.4.3 Constants

      +

      29.4.3 Constants

      @@ -851,7 +851,7 @@ print example::FOO,"\n"; -

      28.4.4 Pointers

      +

      29.4.4 Pointers

      @@ -960,7 +960,7 @@ as XS and xsubpp. Given the advancement of the SWIG typesystem and the SWIG and XS, this is no longer supported.

      -

      28.4.5 Structures

      +

      29.4.5 Structures

      @@ -1094,7 +1094,7 @@ void Bar_f_set(Bar *b, Foo *val) { -

      28.4.6 C++ classes

      +

      29.4.6 C++ classes

      @@ -1159,7 +1159,7 @@ provides direct access to C++ objects. A higher level interface using Perl prox can be built using these low-level accessors. This is described shortly.

      -

      28.4.7 C++ classes and type-checking

      +

      29.4.7 C++ classes and type-checking

      @@ -1195,7 +1195,7 @@ If necessary, the type-checker also adjusts the value of the pointer (as is nece multiple inheritance is used).

      -

      28.4.8 C++ overloaded functions

      +

      29.4.8 C++ overloaded functions

      @@ -1239,7 +1239,7 @@ example::Spam_foo_d($s,3.14); Please refer to the "SWIG Basics" chapter for more information.

      -

      28.4.9 Operators

      +

      29.4.9 Operators

      @@ -1266,7 +1266,7 @@ The following C++ operators are currently supported by the Perl module:

    • operator or
    • -

      28.4.10 Modules and packages

      +

      29.4.10 Modules and packages

      @@ -1361,7 +1361,7 @@ print Foo::fact(4),"\n"; # Call a function in package FooBar --> -

      28.5 Input and output parameters

      +

      29.5 Input and output parameters

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

      +

      29.6 Exception handling

      @@ -1745,7 +1745,7 @@ This is still supported, but it is deprecated. The newer %exception di functionality, but it has additional capabilities that make it more powerful.

      -

      28.7 Remapping datatypes with typemaps

      +

      29.7 Remapping datatypes with typemaps

      @@ -1762,7 +1762,7 @@ Typemaps are only used if you want to change some aspect of the primitive C-Perl interface.

      -

      28.7.1 A simple typemap example

      +

      29.7.1 A simple typemap example

      @@ -1866,7 +1866,7 @@ example::count("e","Hello World"); -

      28.7.2 Perl5 typemaps

      +

      29.7.2 Perl5 typemaps

      @@ -1971,7 +1971,7 @@ Return of C++ member data (all languages). Check value of input parameter. -

      28.7.3 Typemap variables

      +

      29.7.3 Typemap variables

      @@ -2042,7 +2042,7 @@ properly assigned. The Perl name of the wrapper function being created. -

      28.7.4 Useful functions

      +

      29.7.4 Useful functions

      @@ -2111,7 +2111,7 @@ int sv_isa(SV *, char *0; -

      28.8 Typemap Examples

      +

      29.8 Typemap Examples

      @@ -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 **

      +

      29.8.1 Converting a Perl5 array to a char **

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

      28.8.2 Return values

      +

      29.8.2 Return values

      @@ -2241,7 +2241,7 @@ can be done using the EXTEND() macro as in : } -

      28.8.3 Returning values from arguments

      +

      29.8.3 Returning values from arguments

      @@ -2295,7 +2295,7 @@ print "multout(7,13) = @r\n"; ($x,$y) = multout(7,13); -

      28.8.4 Accessing array structure members

      +

      29.8.4 Accessing array structure members

      @@ -2358,7 +2358,7 @@ the "in" typemap in the previous section would be used to convert an to copy the converted array into a C data structure.

      -

      28.8.5 Turning Perl references into C pointers

      +

      29.8.5 Turning Perl references into C pointers

      @@ -2423,7 +2423,7 @@ print "$c\n"; -

      28.8.6 Pointer handling

      +

      29.8.6 Pointer handling

      @@ -2502,7 +2502,7 @@ For example: -

      28.9 Proxy classes

      +

      29.9 Proxy classes

      @@ -2518,7 +2518,7 @@ to the underlying code. This section describes the implementation details of the proxy interface.

      -

      28.9.1 Preliminaries

      +

      29.9.1 Preliminaries

      @@ -2540,7 +2540,7 @@ SWIG creates a collection of high-level Perl wrappers. In your scripts, you wil high level wrappers. The wrappers, in turn, interact with the low-level procedural module.

      -

      28.9.2 Structure and class wrappers

      +

      29.9.2 Structure and class wrappers

      @@ -2666,7 +2666,7 @@ $v->DESTROY(); -

      28.9.3 Object Ownership

      +

      29.9.3 Object Ownership

      @@ -2753,7 +2753,7 @@ counting, garbage collection, or advanced features one might find in sophisticated languages.

      -

      28.9.4 Nested Objects

      +

      29.9.4 Nested Objects

      @@ -2806,7 +2806,7 @@ $p->{f}->{x} = 0.0; %${$p->{v}} = ( x=>0, y=>0, z=>0); -

      28.9.5 Proxy Functions

      +

      29.9.5 Proxy Functions

      @@ -2840,7 +2840,7 @@ This function replaces the original function, but operates in an identical manner.

      -

      28.9.6 Inheritance

      +

      29.9.6 Inheritance

      @@ -2916,7 +2916,7 @@ particular, inheritance of data members is extremely tricky (and I'm not even sure if it really works).

      -

      28.9.7 Modifying the proxy methods

      +

      29.9.7 Modifying the proxy methods

      @@ -2944,7 +2944,7 @@ public: }; -

      28.10 Adding additional Perl code

      +

      29.10 Adding additional Perl code

      diff --git a/Doc/Manual/Php.html b/Doc/Manual/Php.html index f3bf720d9..c9ee74f38 100644 --- a/Doc/Manual/Php.html +++ b/Doc/Manual/Php.html @@ -7,7 +7,7 @@ -

      29 SWIG and PHP

      +

      30 SWIG and PHP

        @@ -75,7 +75,7 @@ your extension into php directly, you will need the complete PHP source tree available.

        -

        29.1 Generating PHP Extensions

        +

        30.1 Generating PHP Extensions

        @@ -122,7 +122,7 @@ and it doesn't play nicely with package system. We don't recommend this approach, or provide explicit support for it.

        -

        29.1.1 Building a loadable extension

        +

        30.1.1 Building a loadable extension

        @@ -137,7 +137,7 @@ least work for Linux though): gcc -shared example_wrap.o -o example.so

      -

      29.1.2 Using PHP Extensions

      +

      30.1.2 Using PHP Extensions

      @@ -168,7 +168,7 @@ attempts to do the dl() call for you: include("example.php"); -

      29.2 Basic PHP interface

      +

      30.2 Basic PHP interface

      @@ -178,7 +178,7 @@ possible for names of symbols in one extension module to clash with other symbols unless care is taken to %rename them.

      -

      29.2.1 Constants

      +

      30.2.1 Constants

      @@ -303,7 +303,7 @@ both point to the same value, without the case test taking place. ( Apologies, this paragraph needs rewriting to make some sense. )

      -

      29.2.2 Global Variables

      +

      30.2.2 Global Variables

      @@ -352,7 +352,7 @@ undefined. At this time SWIG does not support custom accessor methods.

      -

      29.2.3 Functions

      +

      30.2.3 Functions

      @@ -405,7 +405,7 @@ print $s; # The value of $s was not changed. --> -

      29.2.4 Overloading

      +

      30.2.4 Overloading

      @@ -461,7 +461,7 @@ taking the integer argument.

      --> -

      29.2.5 Pointers and References

      +

      30.2.5 Pointers and References

      @@ -593,7 +593,7 @@ PHP in a number of ways: by using unset on an existing variable, or assigning NULL to a variable.

      -

      29.2.6 Structures and C++ classes

      +

      30.2.6 Structures and C++ classes

      @@ -652,7 +652,7 @@ Would be used in the following way from PHP5: Member variables and methods are accessed using the -> operator.

      -

      29.2.6.1 Using -noproxy

      +

      30.2.6.1 Using -noproxy

      @@ -678,7 +678,7 @@ Complex_im_set($obj,$d); Complex_im_get($obj); -

      29.2.6.2 Constructors and Destructors

      +

      30.2.6.2 Constructors and Destructors

      @@ -719,7 +719,7 @@ the programmer can either reassign the variable or call unset($v)

      -

      29.2.6.3 Static Member Variables

      +

      30.2.6.3 Static Member Variables

      @@ -762,7 +762,7 @@ Ko::threats(10); echo "There has now been " . Ko::threats() . " threats\n"; -

      29.2.6.4 Static Member Functions

      +

      30.2.6.4 Static Member Functions

      @@ -784,7 +784,7 @@ Ko::threats(); -

      29.2.7 PHP Pragmas, Startup and Shutdown code

      +

      30.2.7 PHP Pragmas, Startup and Shutdown code

      @@ -872,7 +872,7 @@ The %rinit and %rshutdown statements are very similar but inse into the request init (PHP_RINIT_FUNCTION) and request shutdown (PHP_RSHUTDOWN_FUNCTION) code respectively.

      -

      29.3 Cross language polymorphism

      +

      30.3 Cross language polymorphism

      @@ -907,7 +907,7 @@ wrapper functions takes care of all the cross-language method routing transparently.

      -

      29.3.1 Enabling directors

      +

      30.3.1 Enabling directors

      @@ -999,7 +999,7 @@ class MyFoo extends Foo { -

      29.3.2 Director classes

      +

      30.3.2 Director classes

      @@ -1079,7 +1079,7 @@ so there is no need for the extra overhead involved with routing the calls through PHP.

      -

      29.3.3 Ownership and object destruction

      +

      30.3.3 Ownership and object destruction

      @@ -1135,7 +1135,7 @@ 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

      +

      30.3.4 Exception unrolling

      @@ -1194,7 +1194,7 @@ Swig::DirectorMethodException is thrown, PHP will register the exception as soon as the C wrapper function returns.

      -

      29.3.5 Overhead and code bloat

      +

      30.3.5 Overhead and code bloat

      @@ -1227,7 +1227,7 @@ 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

      +

      30.3.6 Typemaps

      @@ -1241,7 +1241,7 @@ need to be supported.

      -

      29.3.7 Miscellaneous

      +

      30.3.7 Miscellaneous

      Director typemaps for STL classes are mostly in place, and hence you diff --git a/Doc/Manual/Pike.html b/Doc/Manual/Pike.html index ad8976a14..8f9e43735 100644 --- a/Doc/Manual/Pike.html +++ b/Doc/Manual/Pike.html @@ -6,7 +6,7 @@ -

      30 SWIG and Pike

      +

      31 SWIG and Pike

        @@ -46,10 +46,10 @@ least, make sure you read the "SWIG Basics" chapter.

        -

        30.1 Preliminaries

        +

        31.1 Preliminaries

        -

        30.1.1 Running SWIG

        +

        31.1.1 Running SWIG

        @@ -94,7 +94,7 @@ can use the -o option:

        $ swig -pike -o pseudonym.c example.i
        -

        30.1.2 Getting the right header files

        +

        31.1.2 Getting the right header files

        @@ -114,7 +114,7 @@ You're looking for files with the names global.h, program.h and so on.

        -

        30.1.3 Using your module

        +

        31.1.3 Using your module

        @@ -129,10 +129,10 @@ Pike v7.4 release 10 running Hilfe v3.5 (Incremental Pike Frontend) (1) Result: 24

      -

      30.2 Basic C/C++ Mapping

      +

      31.2 Basic C/C++ Mapping

      -

      30.2.1 Modules

      +

      31.2.1 Modules

      @@ -143,7 +143,7 @@ concerned), SWIG's %module directive doesn't really have any significance.

      -

      30.2.2 Functions

      +

      31.2.2 Functions

      @@ -168,7 +168,7 @@ exactly as you'd expect it to: (1) Result: 24 -

      30.2.3 Global variables

      +

      31.2.3 Global variables

      @@ -197,7 +197,7 @@ will result in two functions, Foo_get() and Foo_set(): (3) Result: 3.141590 -

      30.2.4 Constants and enumerated types

      +

      31.2.4 Constants and enumerated types

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

      -

      30.2.5 Constructors and Destructors

      +

      31.2.5 Constructors and Destructors

      @@ -213,7 +213,7 @@ Constructors are wrapped as create() methods, and destructors are wrapped as destroy() methods, for Pike classes.

      -

      30.2.6 Static Members

      +

      31.2.6 Static Members

      diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html index 1cef3683a..23271e649 100644 --- a/Doc/Manual/Python.html +++ b/Doc/Manual/Python.html @@ -6,7 +6,7 @@ -

      31 SWIG and Python

      +

      32 SWIG and Python

        @@ -128,7 +128,7 @@ very least, make sure you read the "SWIG Basics" chapter.

        -

        31.1 Overview

        +

        32.1 Overview

        @@ -155,10 +155,10 @@ described followed by a discussion of low-level implementation details.

        -

        31.2 Preliminaries

        +

        32.2 Preliminaries

        -

        31.2.1 Running SWIG

        +

        32.2.1 Running SWIG

        @@ -256,7 +256,7 @@ The following sections have further practical examples and details on how you might go about compiling and using the generated files.

        -

        31.2.2 Using distutils

        +

        32.2.2 Using distutils

        @@ -348,7 +348,7 @@ This same approach works on all platforms if the appropriate compiler is install can even build extensions to the standard Windows Python using MingGW)

        -

        31.2.3 Hand compiling a dynamic module

        +

        32.2.3 Hand compiling a dynamic module

        @@ -396,7 +396,7 @@ module actually consists of two files; socket.py and

        -

        31.2.4 Static linking

        +

        32.2.4 Static linking

        @@ -475,7 +475,7 @@ If using static linking, you might want to rely on a different approach (perhaps using distutils).

        -

        31.2.5 Using your module

        +

        32.2.5 Using your module

        @@ -632,7 +632,7 @@ system configuration (this requires root access and you will need to read the man pages).

        -

        31.2.6 Compilation of C++ extensions

        +

        32.2.6 Compilation of C++ extensions

        @@ -724,7 +724,7 @@ erratic program behavior. If working with lots of software components, you might want to investigate using a more formal standard such as COM.

        -

        31.2.7 Compiling for 64-bit platforms

        +

        32.2.7 Compiling for 64-bit platforms

        @@ -761,7 +761,7 @@ and -m64 allow you to choose the desired binary format for your python extension.

        -

        31.2.8 Building Python Extensions under Windows

        +

        32.2.8 Building Python Extensions under Windows

        @@ -870,7 +870,7 @@ SWIG Wiki.

        -

        31.3 A tour of basic C/C++ wrapping

        +

        32.3 A tour of basic C/C++ wrapping

        @@ -879,7 +879,7 @@ to your C/C++ code. Functions are wrapped as functions, classes are wrapped as This section briefly covers the essential aspects of this wrapping.

        -

        31.3.1 Modules

        +

        32.3.1 Modules

        @@ -892,7 +892,7 @@ module name, make sure you don't use the same name as a built-in Python command or standard module name.

        -

        31.3.2 Functions

        +

        32.3.2 Functions

        @@ -916,7 +916,7 @@ like you think it does: >>>

      -

      31.3.3 Global variables

      +

      32.3.3 Global variables

      @@ -1054,7 +1054,7 @@ that starts with a leading underscore. SWIG does not create cvar if there are no global variables in a module.

      -

      31.3.4 Constants and enums

      +

      32.3.4 Constants and enums

      @@ -1094,7 +1094,7 @@ other object. Unfortunately, there is no easy way for SWIG to generate code that prevents this. You will just have to be careful.

      -

      31.3.5 Pointers

      +

      32.3.5 Pointers

      @@ -1235,7 +1235,7 @@ C-style cast may return a bogus result whereas as the C++-style cast will return None if the conversion can't be performed.

      -

      31.3.6 Structures

      +

      32.3.6 Structures

      @@ -1424,7 +1424,7 @@ everything works just like you would expect. For example: -

      31.3.7 C++ classes

      +

      32.3.7 C++ classes

      @@ -1513,7 +1513,7 @@ they are accessed through cvar like this: -

      31.3.8 C++ inheritance

      +

      32.3.8 C++ inheritance

      @@ -1568,7 +1568,7 @@ then the function spam() accepts Foo * or a pointer to any cla It is safe to use multiple inheritance with SWIG.

      -

      31.3.9 Pointers, references, values, and arrays

      +

      32.3.9 Pointers, references, values, and arrays

      @@ -1629,7 +1629,7 @@ treated as a returning value, and it will follow the same allocation/deallocation process.

      -

      31.3.10 C++ overloaded functions

      +

      32.3.10 C++ overloaded functions

      @@ -1752,7 +1752,7 @@ first declaration takes precedence. Please refer to the "SWIG and C++" chapter for more information about overloading.

      -

      31.3.11 C++ operators

      +

      32.3.11 C++ operators

      @@ -1841,7 +1841,7 @@ Also, be aware that certain operators don't map cleanly to Python. For instance overloaded assignment operators don't map to Python semantics and will be ignored.

      -

      31.3.12 C++ namespaces

      +

      32.3.12 C++ namespaces

      @@ -1908,7 +1908,7 @@ utilizes thousands of small deeply nested namespaces each with identical symbol names, well, then you get what you deserve.

      -

      31.3.13 C++ templates

      +

      32.3.13 C++ templates

      @@ -1962,7 +1962,7 @@ Some more complicated examples will appear later.

      -

      31.3.14 C++ Smart Pointers

      +

      32.3.14 C++ Smart Pointers

      @@ -2047,7 +2047,7 @@ simply use the __deref__() method. For example: -

      31.3.15 C++ Reference Counted Objects (ref/unref)

      +

      32.3.15 C++ Reference Counted Objects (ref/unref)

      @@ -2190,7 +2190,7 @@ python releases the proxy instance.

      -

      31.4 Further details on the Python class interface

      +

      32.4 Further details on the Python class interface

      @@ -2203,7 +2203,7 @@ of low-level details were omitted. This section provides a brief overview of how the proxy classes work.

      -

      31.4.1 Proxy classes

      +

      32.4.1 Proxy classes

      @@ -2292,7 +2292,7 @@ you can attach new Python methods to the class and you can even inherit from it by Python built-in types until Python 2.2).

      -

      31.4.2 Memory management

      +

      32.4.2 Memory management

      @@ -2484,7 +2484,7 @@ It is also possible to deal with situations like this using typemaps--an advanced topic discussed later.

      -

      31.4.3 Python 2.2 and classic classes

      +

      32.4.3 Python 2.2 and classic classes

      @@ -2521,7 +2521,7 @@ class itself. In Python-2.1 and earlier, they have to be accessed as a global function or through an instance (see the earlier section).

      -

      31.5 Cross language polymorphism

      +

      32.5 Cross language polymorphism

      @@ -2555,7 +2555,7 @@ proxy classes, director classes, and C wrapper functions takes care of all the cross-language method routing transparently.

      -

      31.5.1 Enabling directors

      +

      32.5.1 Enabling directors

      @@ -2648,7 +2648,7 @@ class MyFoo(mymodule.Foo): -

      31.5.2 Director classes

      +

      32.5.2 Director classes

      @@ -2730,7 +2730,7 @@ so there is no need for the extra overhead involved with routing the calls through Python.

      -

      31.5.3 Ownership and object destruction

      +

      32.5.3 Ownership and object destruction

      @@ -2797,7 +2797,7 @@ deleting all the Foo pointers it contains at some point. Note that no hard references to the Foo objects remain in Python.

      -

      31.5.4 Exception unrolling

      +

      32.5.4 Exception unrolling

      @@ -2856,7 +2856,7 @@ Swig::DirectorMethodException is thrown, Python will register the exception as soon as the C wrapper function returns.

      -

      31.5.5 Overhead and code bloat

      +

      32.5.5 Overhead and code bloat

      @@ -2890,7 +2890,7 @@ directive) for only those methods that are likely to be extended in Python.

      -

      31.5.6 Typemaps

      +

      32.5.6 Typemaps

      @@ -2904,7 +2904,7 @@ need to be supported.

      -

      31.5.7 Miscellaneous

      +

      32.5.7 Miscellaneous

      @@ -2951,7 +2951,7 @@ methods that return const references.

      -

      31.6 Common customization features

      +

      32.6 Common customization features

      @@ -2964,7 +2964,7 @@ This section describes some common SWIG features that are used to improve your the interface to an extension module.

      -

      31.6.1 C/C++ helper functions

      +

      32.6.1 C/C++ helper functions

      @@ -3045,7 +3045,7 @@ hard to implement. It is possible to clean this up using Python code, typemaps, customization features as covered in later sections.

      -

      31.6.2 Adding additional Python code

      +

      32.6.2 Adding additional Python code

      @@ -3194,7 +3194,7 @@ public: -

      31.6.3 Class extension with %extend

      +

      32.6.3 Class extension with %extend

      @@ -3283,7 +3283,7 @@ Vector(12,14,16) in any way---the extensions only show up in the Python interface.

      -

      31.6.4 Exception handling with %exception

      +

      32.6.4 Exception handling with %exception

      @@ -3409,7 +3409,7 @@ The language-independent exception.i library file can also be used to raise exceptions. See the SWIG Library chapter.

      -

      31.7 Tips and techniques

      +

      32.7 Tips and techniques

      @@ -3419,7 +3419,7 @@ strings, binary data, and arrays. This chapter discusses the common techniques solving these problems.

      -

      31.7.1 Input and output parameters

      +

      32.7.1 Input and output parameters

      @@ -3632,7 +3632,7 @@ void foo(Bar *OUTPUT); may not have the intended effect since typemaps.i does not define an OUTPUT rule for Bar.

      -

      31.7.2 Simple pointers

      +

      32.7.2 Simple pointers

      @@ -3701,7 +3701,7 @@ If you replace %pointer_functions() by %pointer_class(type,name)SWIG Library chapter for further details.

      -

      31.7.3 Unbounded C Arrays

      +

      32.7.3 Unbounded C Arrays

      @@ -3763,7 +3763,7 @@ well suited for applications in which you need to create buffers, package binary data, etc.

      -

      31.7.4 String handling

      +

      32.7.4 String handling

      @@ -3832,7 +3832,7 @@ If you need to return binary data, you might use the also be used to extra binary data from arbitrary pointers.

      -

      31.8 Typemaps

      +

      32.8 Typemaps

      @@ -3849,7 +3849,7 @@ Typemaps are only used if you want to change some aspect of the primitive C-Python interface or if you want to elevate your guru status.

      -

      31.8.1 What is a typemap?

      +

      32.8.1 What is a typemap?

      @@ -3965,7 +3965,7 @@ parameter is omitted): -

      31.8.2 Python typemaps

      +

      32.8.2 Python typemaps

      @@ -4006,7 +4006,7 @@ a look at the SWIG library version 1.3.20 or so.

      -

      31.8.3 Typemap variables

      +

      32.8.3 Typemap variables

      @@ -4077,7 +4077,7 @@ properly assigned. The Python name of the wrapper function being created. -

      31.8.4 Useful Python Functions

      +

      32.8.4 Useful Python Functions

      @@ -4205,7 +4205,7 @@ write me -

      31.9 Typemap Examples

      +

      32.9 Typemap Examples

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

      -

      31.9.1 Converting Python list to a char **

      +

      32.9.1 Converting Python list to a char **

      @@ -4294,7 +4294,7 @@ memory allocation is used to allocate memory for the array, the the C function.

      -

      31.9.2 Expanding a Python object into multiple arguments

      +

      32.9.2 Expanding a Python object into multiple arguments

      @@ -4373,7 +4373,7 @@ to supply the argument count. This is automatically set by the typemap code. F -

      31.9.3 Using typemaps to return arguments

      +

      32.9.3 Using typemaps to return arguments

      @@ -4462,7 +4462,7 @@ function can now be used as follows: >>> -

      31.9.4 Mapping Python tuples into small arrays

      +

      32.9.4 Mapping Python tuples into small arrays

      @@ -4511,7 +4511,7 @@ array, such an approach would not be recommended for huge arrays, but for small structures, this approach works fine.

      -

      31.9.5 Mapping sequences to C arrays

      +

      32.9.5 Mapping sequences to C arrays

      @@ -4600,7 +4600,7 @@ static int convert_darray(PyObject *input, double *ptr, int size) { -

      31.9.6 Pointer handling

      +

      32.9.6 Pointer handling

      @@ -4697,7 +4697,7 @@ class object (if applicable). -

      31.10 Docstring Features

      +

      32.10 Docstring Features

      @@ -4725,7 +4725,7 @@ of your users much simpler.

      -

      31.10.1 Module docstring

      +

      32.10.1 Module docstring

      @@ -4759,7 +4759,7 @@ layout of controls on a panel, etc. to be loaded from an XML file." -

      31.10.2 %feature("autodoc")

      +

      32.10.2 %feature("autodoc")

      @@ -4786,7 +4786,7 @@ names, default values if any, and return type if any. There are also three options for autodoc controlled by the value given to the feature, described below. -

      31.10.2.1 %feature("autodoc", "0")

      +

      32.10.2.1 %feature("autodoc", "0")

      @@ -4815,7 +4815,7 @@ def function_name(*args, **kwargs): -

      31.10.2.2 %feature("autodoc", "1")

      +

      32.10.2.2 %feature("autodoc", "1")

      @@ -4840,7 +4840,7 @@ def function_name(*args, **kwargs): -

      31.10.2.3 %feature("autodoc", "docstring")

      +

      32.10.2.3 %feature("autodoc", "docstring")

      @@ -4859,7 +4859,7 @@ void GetPosition(int* OUTPUT, int* OUTPUT); -

      31.10.3 %feature("docstring")

      +

      32.10.3 %feature("docstring")

      @@ -4891,7 +4891,7 @@ with more than one line. -

      31.11 Python Packages

      +

      32.11 Python Packages

      @@ -4918,7 +4918,7 @@ and also in base class declarations, etc. if the package name is different than its own.

      -

      31.12 Python 3 Support

      +

      32.12 Python 3 Support

      @@ -4945,7 +4945,7 @@ The following are Python 3.0 new features that are currently supported by SWIG.

      -

      31.12.1 Function annotation

      +

      32.12.1 Function annotation

      @@ -4977,7 +4977,7 @@ all overloaded functions share the same function in SWIG generated proxy class. For detailed usage of function annotation, see PEP 3107.

      -

      31.12.2 Buffer interface

      +

      32.12.2 Buffer interface

      @@ -5129,7 +5129,7 @@ modify the buffer. -

      31.12.3 Abstract base classes

      +

      32.12.3 Abstract base classes

      diff --git a/Doc/Manual/R.html b/Doc/Manual/R.html index e8cee6448..ceea32146 100644 --- a/Doc/Manual/R.html +++ b/Doc/Manual/R.html @@ -6,7 +6,7 @@ -

      34 SWIG and R

      +

      35 SWIG and R

        @@ -33,7 +33,7 @@ compile and run an R interface to QuantLib running on Mandriva Linux with gcc. The R bindings also work on Microsoft Windows using Visual C++.

        -

        34.1 Bugs

        +

        35.1 Bugs

        @@ -45,7 +45,7 @@ Currently the following features are not implemented or broken:

      • C Array wrappings
      -

      34.2 Using R and SWIG

      +

      35.2 Using R and SWIG

      @@ -119,7 +119,7 @@ Without it, inheritance of wrapped objects may fail. These two files can be loaded in any order

      -

      34.3 Precompiling large R files

      +

      35.3 Precompiling large R files

      In cases where the R file is large, one make save a lot of loading @@ -137,7 +137,7 @@ will save a large amount of loading time. -

      34.4 General policy

      +

      35.4 General policy

      @@ -146,7 +146,7 @@ wrapping over the underlying functions and rely on the R type system to provide R syntax.

      -

      34.5 Language conventions

      +

      35.5 Language conventions

      @@ -155,7 +155,7 @@ and [ are overloaded to allow for R syntax (one based indices and slices)

      -

      34.6 C++ classes

      +

      35.6 C++ classes

      @@ -167,7 +167,7 @@ keep track of the pointer object which removes the necessity for a lot of the proxy class baggage you see in other languages.

      -

      34.7 Enumerations

      +

      35.7 Enumerations

      diff --git a/Doc/Manual/Ruby.html b/Doc/Manual/Ruby.html index 8b43962c5..b61ded8e5 100644 --- a/Doc/Manual/Ruby.html +++ b/Doc/Manual/Ruby.html @@ -26,7 +26,7 @@ -

      32 SWIG and Ruby

      +

      33 SWIG and Ruby

        @@ -167,7 +167,7 @@ -

        32.1 Preliminaries

        +

        33.1 Preliminaries

        SWIG 1.3 is known to work with Ruby versions 1.6 and later. @@ -190,7 +190,7 @@ of Ruby.

        -

        32.1.1 Running SWIG

        +

        33.1.1 Running SWIG

        To build a Ruby module, run SWIG using the -ruby @@ -244,7 +244,7 @@ to compile this file and link it with the rest of your program.

        -

        32.1.2 Getting the right header files

        +

        33.1.2 Getting the right header files

        In order to compile the wrapper code, the compiler needs the ruby.h @@ -288,7 +288,7 @@ installed, you can run Ruby to find out. For example:

        -

        32.1.3 Compiling a dynamic module

        +

        33.1.3 Compiling a dynamic module

        Ruby extension modules are typically compiled into shared @@ -443,7 +443,7 @@ manual pages for your compiler and linker to determine the correct set of options. You might also check the SWIG Wiki for additional information.

        -

        32.1.4 Using your module

        +

        33.1.4 Using your module

        Ruby module names must be capitalized, @@ -498,7 +498,7 @@ begins with:

        -

        32.1.5 Static linking

        +

        33.1.5 Static linking

        An alternative approach to dynamic linking is to rebuild the @@ -519,7 +519,7 @@ finally rebuilding Ruby.

        -

        32.1.6 Compilation of C++ extensions

        +

        33.1.6 Compilation of C++ extensions

        On most machines, C++ extension modules should be linked @@ -571,7 +571,7 @@ extension, e.g.

        -

        32.2 Building Ruby Extensions under Windows 95/NT

        +

        33.2 Building Ruby Extensions under Windows 95/NT

        Building a SWIG extension to Ruby under Windows 95/NT is @@ -610,7 +610,7 @@ files.

        -

        32.2.1 Running SWIG from Developer Studio

        +

        33.2.1 Running SWIG from Developer Studio

        If you are developing your application within Microsoft @@ -752,7 +752,7 @@ directory, then run the Ruby script from the DOS/Command prompt:

        -

        32.3 The Ruby-to-C/C++ Mapping

        +

        33.3 The Ruby-to-C/C++ Mapping

        This section describes the basics of how SWIG maps C or C++ @@ -762,7 +762,7 @@ declarations in your SWIG interface files to Ruby constructs.

        -

        32.3.1 Modules

        +

        33.3.1 Modules

        The SWIG %module directive specifies @@ -931,7 +931,7 @@ Ruby's built-in names.

        -

        32.3.2 Functions

        +

        33.3.2 Functions

        Global functions are wrapped as Ruby module methods. For @@ -994,7 +994,7 @@ module that can be used like so:

        -

        32.3.3 Variable Linking

        +

        33.3.3 Variable Linking

        C/C++ global variables are wrapped as a pair of singleton @@ -1094,7 +1094,7 @@ effect until it is explicitly disabled using %mutable. -

        32.3.4 Constants

        +

        33.3.4 Constants

        C/C++ constants are wrapped as module constants initialized @@ -1138,7 +1138,7 @@ constant values, e.g.

        -

        32.3.5 Pointers

        +

        33.3.5 Pointers

        "Opaque" pointers to arbitrary C/C++ types (i.e. types that @@ -1190,7 +1190,7 @@ the Ruby nil object.

        -

        32.3.6 Structures

        +

        33.3.6 Structures

        C/C++ structs are wrapped as Ruby classes, with accessor @@ -1365,7 +1365,7 @@ pointers. For example,

        -

        32.3.7 C++ classes

        +

        33.3.7 C++ classes

        Like structs, C++ classes are wrapped by creating a new Ruby @@ -1451,7 +1451,7 @@ class. -

        32.3.8 C++ Inheritance

        +

        33.3.8 C++ Inheritance

        The SWIG type-checker is fully aware of C++ inheritance. @@ -1682,7 +1682,7 @@ Typing").

        -

        32.3.9 C++ Overloaded Functions

        +

        33.3.9 C++ Overloaded Functions

        C++ overloaded functions, methods, and constructors are @@ -1882,7 +1882,7 @@ and C++" chapter for more information about overloading.

        -

        32.3.10 C++ Operators

        +

        33.3.10 C++ Operators

        For the most part, overloaded operators are handled @@ -1963,7 +1963,7 @@ on operator overloading.

        -

        32.3.11 C++ namespaces

        +

        33.3.11 C++ namespaces

        SWIG is aware of C++ namespaces, but namespace names do not @@ -2039,7 +2039,7 @@ identical symbol names, well, then you get what you deserve.

        -

        32.3.12 C++ templates

        +

        33.3.12 C++ templates

        C++ templates don't present a huge problem for SWIG. However, @@ -2083,7 +2083,7 @@ directive. For example:

        -

        32.3.13 C++ Standard Template Library (STL)

        +

        33.3.13 C++ Standard Template Library (STL)

        On a related note, the standard SWIG library contains a @@ -2336,7 +2336,7 @@ chapter.

        -

        32.3.14 C++ STL Functors

        +

        33.3.14 C++ STL Functors

        Some containers in the STL allow you to modify their default @@ -2536,7 +2536,7 @@ b
        -

        32.3.15 C++ STL Iterators

        +

        33.3.15 C++ STL Iterators

        The STL is well known for the use of iterators.  There @@ -2747,7 +2747,7 @@ i
        -

        32.3.16 C++ Smart Pointers

        +

        33.3.16 C++ Smart Pointers

        In certain C++ programs, it is common to use classes that @@ -2872,7 +2872,7 @@ method. For example:

        -

        32.3.17 Cross-Language Polymorphism

        +

        33.3.17 Cross-Language Polymorphism

        SWIG's Ruby module supports cross-language polymorphism @@ -2885,7 +2885,7 @@ using this feature with Ruby.

        -

        32.3.17.1 Exception Unrolling

        +

        33.3.17.1 Exception Unrolling

        Whenever a C++ director class routes one of its virtual @@ -2923,7 +2923,7 @@ caught here and a C++ exception is raised in its place.

        -

        32.4 Naming

        +

        33.4 Naming

        Ruby has several common naming conventions. Constants are @@ -3019,7 +3019,7 @@ planned to become the default option in future releases.

        -

        32.4.1 Defining Aliases

        +

        33.4.1 Defining Aliases

        It's a fairly common practice in the Ruby built-ins and @@ -3111,7 +3111,7 @@ Features") for more details).

        -

        32.4.2 Predicate Methods

        +

        33.4.2 Predicate Methods

        Ruby methods that return a boolean value and end in a @@ -3200,7 +3200,7 @@ Features") for more details).

        -

        32.4.3 Bang Methods

        +

        33.4.3 Bang Methods

        Ruby methods that modify an object in-place and end in an @@ -3264,7 +3264,7 @@ Features") for more details).

        -

        32.4.4 Getters and Setters

        +

        33.4.4 Getters and Setters

        Often times a C++ library will expose properties through @@ -3334,7 +3334,7 @@ methods to be exposed in Ruby as value and value=. -

        32.5 Input and output parameters

        +

        33.5 Input and output parameters

        A common problem in some C programs is handling parameters @@ -3585,10 +3585,10 @@ of %apply

        -

        32.6 Exception handling

        +

        33.6 Exception handling

        -

        32.6.1 Using the %exception directive

        +

        33.6.1 Using the %exception directive

        The SWIG %exception directive can be @@ -3683,7 +3683,7 @@ Features for more examples.

        -

        32.6.2 Handling Ruby Blocks

        +

        33.6.2 Handling Ruby Blocks

        One of the highlights of Ruby and most of its standard library @@ -3864,7 +3864,7 @@ RUBY_YIELD_SELF );

        For more information on typemaps, see Typemaps.

        -

        32.6.3 Raising exceptions

        +

        33.6.3 Raising exceptions

        There are three ways to raise exceptions from C++ code to @@ -4625,7 +4625,7 @@ the built-in Ruby exception types.

        -

        32.6.4 Exception classes

        +

        33.6.4 Exception classes

        Starting with SWIG 1.3.28, the Ruby module supports the %exceptionclass @@ -4683,7 +4683,7 @@ providing for a more natural integration between C++ code and Ruby code.

        -

        32.7 Typemaps

        +

        33.7 Typemaps

        This section describes how you can modify SWIG's default @@ -4706,7 +4706,7 @@ of the primitive C-Ruby interface.

        -

        32.7.1 What is a typemap?

        +

        33.7.1 What is a typemap?

        A typemap is nothing more than a code generation rule that is @@ -4968,7 +4968,7 @@ to be used as follows (notice how the length parameter is omitted):

        -

        32.7.2 Typemap scope

        +

        33.7.2 Typemap scope

        Once defined, a typemap remains in effect for all of the @@ -5016,7 +5016,7 @@ where the class itself is defined. For example:

        -

        32.7.3 Copying a typemap

        +

        33.7.3 Copying a typemap

        A typemap is copied by using assignment. For example:

        @@ -5118,7 +5118,7 @@ rules as for -

        32.7.4 Deleting a typemap

        +

        33.7.4 Deleting a typemap

        A typemap can be deleted by simply defining no code. For @@ -5170,7 +5170,7 @@ typemaps immediately after the clear operation.

        -

        32.7.5 Placement of typemaps

        +

        33.7.5 Placement of typemaps

        Typemap declarations can be declared in the global scope, @@ -5254,7 +5254,7 @@ string -

        32.7.6 Ruby typemaps

        +

        33.7.6 Ruby typemaps

        The following list details all of the typemap methods that @@ -5264,7 +5264,7 @@ can be used by the Ruby module:

        -

        32.7.6.1  "in" typemap

        +

        33.7.6.1  "in" typemap

        Converts Ruby objects to input @@ -5507,7 +5507,7 @@ arguments to be specified. For example:

        -

        32.7.6.2 "typecheck" typemap

        +

        33.7.6.2 "typecheck" typemap

        The "typecheck" typemap is used to support overloaded @@ -5548,7 +5548,7 @@ on "Typemaps and Overloading."

        -

        32.7.6.3  "out" typemap

        +

        33.7.6.3  "out" typemap

        Converts return value of a C function @@ -5780,7 +5780,7 @@ version of the C datatype matched by the typemap. -

        32.7.6.4 "arginit" typemap

        +

        33.7.6.4 "arginit" typemap

        The "arginit" typemap is used to set the initial value of a @@ -5805,7 +5805,7 @@ applications. For example:

        -

        32.7.6.5 "default" typemap

        +

        33.7.6.5 "default" typemap

        The "default" typemap is used to turn an argument into a @@ -5847,7 +5847,7 @@ default argument wrapping.

        -

        32.7.6.6 "check" typemap

        +

        33.7.6.6 "check" typemap

        The "check" typemap is used to supply value checking code @@ -5871,7 +5871,7 @@ arguments have been converted. For example:

        -

        32.7.6.7 "argout" typemap

        +

        33.7.6.7 "argout" typemap

        The "argout" typemap is used to return values from arguments. @@ -6029,7 +6029,7 @@ some function like SWIG_Ruby_AppendOutput.

        -

        32.7.6.8 "freearg" typemap

        +

        33.7.6.8 "freearg" typemap

        The "freearg" typemap is used to cleanup argument data. It is @@ -6065,7 +6065,7 @@ abort prematurely.

        -

        32.7.6.9 "newfree" typemap

        +

        33.7.6.9 "newfree" typemap

        The "newfree" typemap is used in conjunction with the %newobject @@ -6096,7 +6096,7 @@ ownership and %newobject for further details.

        -

        32.7.6.10 "memberin" typemap

        +

        33.7.6.10 "memberin" typemap

        The "memberin" typemap is used to copy data from an @@ -6129,7 +6129,7 @@ other objects.

        -

        32.7.6.11 "varin" typemap

        +

        33.7.6.11 "varin" typemap

        The "varin" typemap is used to convert objects in the target @@ -6140,7 +6140,7 @@ This is implementation specific.

        -

        32.7.6.12 "varout" typemap

        +

        33.7.6.12 "varout" typemap

        The "varout" typemap is used to convert a C/C++ object to an @@ -6151,7 +6151,7 @@ This is implementation specific.

        -

        32.7.6.13 "throws" typemap

        +

        33.7.6.13 "throws" typemap

        The "throws" typemap is only used when SWIG parses a C++ @@ -6210,7 +6210,7 @@ handling with %exception section.

        -

        32.7.6.14 directorin typemap

        +

        33.7.6.14 directorin typemap

        Converts C++ objects in director @@ -6464,7 +6464,7 @@ referring to the class itself. -

        32.7.6.15 directorout typemap

        +

        33.7.6.15 directorout typemap

        Converts Ruby objects in director @@ -6724,7 +6724,7 @@ exception.
        -

        32.7.6.16 directorargout typemap

        +

        33.7.6.16 directorargout typemap

        Output argument processing in director @@ -6964,7 +6964,7 @@ referring to the instance of the class itself -

        32.7.6.17 ret typemap

        +

        33.7.6.17 ret typemap

        Cleanup of function return values @@ -6974,7 +6974,7 @@ referring to the instance of the class itself -

        32.7.6.18 globalin typemap

        +

        33.7.6.18 globalin typemap

        Setting of C global variables @@ -6984,7 +6984,7 @@ referring to the instance of the class itself -

        32.7.7 Typemap variables

        +

        33.7.7 Typemap variables

        @@ -7094,7 +7094,7 @@ being created.

      -

      32.7.8 Useful Functions

      +

      33.7.8 Useful Functions

      When you write a typemap, you usually have to work directly @@ -7118,7 +7118,7 @@ across multiple languages.

      -

      32.7.8.1 C Datatypes to Ruby Objects

      +

      33.7.8.1 C Datatypes to Ruby Objects

      @@ -7174,7 +7174,7 @@ SWIG_From_float(float) -

      32.7.8.2 Ruby Objects to C Datatypes

      +

      33.7.8.2 Ruby Objects to C Datatypes

      Here, while the Ruby versions return the value directly, the SWIG @@ -7263,7 +7263,7 @@ Ruby_Format_TypeError( "$1_name", "$1_type","$symname", $argnum, $input -

      32.7.8.3 Macros for VALUE

      +

      33.7.8.3 Macros for VALUE

      RSTRING_LEN(str)

      @@ -7326,7 +7326,7 @@ Ruby_Format_TypeError( "$1_name", "$1_type","$symname", $argnum, $input -

      32.7.8.4 Exceptions

      +

      33.7.8.4 Exceptions

      void rb_raise(VALUE exception, const char *fmt, @@ -7493,7 +7493,7 @@ arguments are interpreted as with printf().

      -

      32.7.8.5 Iterators

      +

      33.7.8.5 Iterators

      void rb_iter_break()

      @@ -7595,7 +7595,7 @@ VALUE), VALUE value)

      -

      32.7.9 Typemap Examples

      +

      33.7.9 Typemap Examples

      This section includes a few examples of typemaps. For more @@ -7606,7 +7606,7 @@ directory.

      -

      32.7.10 Converting a Ruby array to a char **

      +

      33.7.10 Converting a Ruby array to a char **

      A common problem in many C programs is the processing of @@ -7661,7 +7661,7 @@ after the execution of the C function.

      -

      32.7.11 Collecting arguments in a hash

      +

      33.7.11 Collecting arguments in a hash

      Ruby's solution to the "keyword arguments" capability of some @@ -7940,7 +7940,7 @@ directory of the SWIG distribution.

      -

      32.7.12 Pointer handling

      +

      33.7.12 Pointer handling

      Occasionally, it might be necessary to convert pointer values @@ -8039,7 +8039,7 @@ For example:

      -

      32.7.12.1 Ruby Datatype Wrapping

      +

      33.7.12.1 Ruby Datatype Wrapping

      VALUE Data_Wrap_Struct(VALUE class, void @@ -8090,7 +8090,7 @@ and assigns that pointer to ptr.

      -

      32.7.13 Example: STL Vector to Ruby Array

      +

      33.7.13 Example: STL Vector to Ruby Array

      Another use for macros and type maps is to create a Ruby array @@ -8199,7 +8199,7 @@ the C++ Standard Template Library.
      -

      32.8 Docstring Features

      +

      33.8 Docstring Features

      @@ -8260,7 +8260,7 @@ generate ri documentation from a c wrap file, you could do:

      -

      32.8.1 Module docstring

      +

      33.8.1 Module docstring

      @@ -8311,7 +8311,7 @@ macro. For example: -

      32.8.2 %feature("autodoc")

      +

      33.8.2 %feature("autodoc")

      Since SWIG does know everything about the function it wraps, @@ -8340,7 +8340,7 @@ feature, described below. -

      32.8.2.1 %feature("autodoc", "0")

      +

      33.8.2.1 %feature("autodoc", "0")

      @@ -8388,7 +8388,7 @@ Then Ruby code like this will be generated: -

      32.8.2.2 %feature("autodoc", "1")

      +

      33.8.2.2 %feature("autodoc", "1")

      @@ -8420,7 +8420,7 @@ this: -

      32.8.2.3 %feature("autodoc", "2")

      +

      33.8.2.3 %feature("autodoc", "2")

      @@ -8436,7 +8436,7 @@ this: -

      32.8.2.4 %feature("autodoc", "3")

      +

      33.8.2.4 %feature("autodoc", "3")

      @@ -8464,7 +8464,7 @@ this: -

      32.8.2.5 %feature("autodoc", "docstring")

      +

      33.8.2.5 %feature("autodoc", "docstring")

      @@ -8492,7 +8492,7 @@ generated string. For example: -

      32.8.3 %feature("docstring")

      +

      33.8.3 %feature("docstring")

      @@ -8507,10 +8507,10 @@ docstring and they are output together.

      -

      32.9 Advanced Topics

      +

      33.9 Advanced Topics

      -

      32.9.1 Operator overloading

      +

      33.9.1 Operator overloading

      SWIG allows operator overloading with, by using the %extend @@ -9527,7 +9527,7 @@ parses the expression a != b as !(a == b). -

      32.9.2 Creating Multi-Module Packages

      +

      33.9.2 Creating Multi-Module Packages

      The chapter on Working @@ -9708,7 +9708,7 @@ initialized:

      -

      32.9.3 Specifying Mixin Modules

      +

      33.9.3 Specifying Mixin Modules

      The Ruby language doesn't support multiple inheritance, but @@ -9806,7 +9806,7 @@ Features") for more details).

      -

      32.10 Memory Management

      +

      33.10 Memory Management

      One of the most common issues in generating SWIG bindings for @@ -9853,7 +9853,7 @@ understanding of how the underlying library manages memory.

      -

      32.10.1 Mark and Sweep Garbage Collector

      +

      33.10.1 Mark and Sweep Garbage Collector

      Ruby uses a mark and sweep garbage collector. When the garbage @@ -9901,7 +9901,7 @@ this memory.

      -

      32.10.2 Object Ownership

      +

      33.10.2 Object Ownership

      As described above, memory management depends on clearly @@ -10128,7 +10128,7 @@ classes is:

      -

      32.10.3 Object Tracking

      +

      33.10.3 Object Tracking

      The remaining parts of this section will use the class library @@ -10342,7 +10342,7 @@ methods.

      -

      32.10.4 Mark Functions

      +

      33.10.4 Mark Functions

      With a bit more testing, we see that our class library still @@ -10460,7 +10460,7 @@ test suite.

      -

      32.10.5 Free Functions

      +

      33.10.5 Free Functions

      By default, SWIG creates a "free" function that is called when @@ -10615,7 +10615,7 @@ been freed, and thus raises a runtime exception.

      -

      32.10.6 Embedded Ruby and the C++ Stack

      +

      33.10.6 Embedded Ruby and the C++ Stack

      As has been said, the Ruby GC runs and marks objects before diff --git a/Doc/Manual/Tcl.html b/Doc/Manual/Tcl.html index b37df2853..d47dae5de 100644 --- a/Doc/Manual/Tcl.html +++ b/Doc/Manual/Tcl.html @@ -6,7 +6,7 @@ -

      33 SWIG and Tcl

      +

      34 SWIG and Tcl

        @@ -83,7 +83,7 @@ Tcl 8.0 or a later release. Earlier releases of SWIG supported Tcl 7.x, but this is no longer supported.

        -

        33.1 Preliminaries

        +

        34.1 Preliminaries

        @@ -109,7 +109,7 @@ build a Tcl extension module. To finish building the module, you need to compile this file and link it with the rest of your program.

        -

        33.1.1 Getting the right header files

        +

        34.1.1 Getting the right header files

        @@ -127,7 +127,7 @@ this is the case, you should probably make a symbolic link so that tcl.h -

        33.1.2 Compiling a dynamic module

        +

        34.1.2 Compiling a dynamic module

        @@ -162,7 +162,7 @@ The name of the module is specified using the %module directive or the -module command line option.

        -

        33.1.3 Static linking

        +

        34.1.3 Static linking

        @@ -228,7 +228,7 @@ minimal in most situations (and quite frankly not worth the extra hassle in the opinion of this author).

        -

        33.1.4 Using your module

        +

        34.1.4 Using your module

        @@ -356,7 +356,7 @@ to the default system configuration (this requires root access and you will need the man pages).

        -

        33.1.5 Compilation of C++ extensions

        +

        34.1.5 Compilation of C++ extensions

        @@ -439,7 +439,7 @@ erratic program behavior. If working with lots of software components, you might want to investigate using a more formal standard such as COM.

        -

        33.1.6 Compiling for 64-bit platforms

        +

        34.1.6 Compiling for 64-bit platforms

        @@ -466,7 +466,7 @@ also introduce problems on platforms that support more than one linking standard (e.g., -o32 and -n32 on Irix).

        -

        33.1.7 Setting a package prefix

        +

        34.1.7 Setting a package prefix

        @@ -485,7 +485,7 @@ option will append the prefix to the name when creating a command and call it "Foo_bar".

        -

        33.1.8 Using namespaces

        +

        34.1.8 Using namespaces

        @@ -507,7 +507,7 @@ When the -namespace option is used, objects in the module are always accessed with the namespace name such as Foo::bar.

        -

        33.2 Building Tcl/Tk Extensions under Windows 95/NT

        +

        34.2 Building Tcl/Tk Extensions under Windows 95/NT

        @@ -518,7 +518,7 @@ covers the process of using SWIG with Microsoft Visual C++. although the procedure may be similar with other compilers.

        -

        33.2.1 Running SWIG from Developer Studio

        +

        34.2.1 Running SWIG from Developer Studio

        @@ -576,7 +576,7 @@ MSDOS > tclsh80 %

      -

      33.2.2 Using NMAKE

      +

      34.2.2 Using NMAKE

      @@ -639,7 +639,7 @@ to get you started. With a little practice, you'll be making lots of Tcl extensions.

      -

      33.3 A tour of basic C/C++ wrapping

      +

      34.3 A tour of basic C/C++ wrapping

      @@ -650,7 +650,7 @@ classes. This section briefly covers the essential aspects of this wrapping.

      -

      33.3.1 Modules

      +

      34.3.1 Modules

      @@ -684,7 +684,7 @@ To fix this, supply an extra argument to load like this: -

      33.3.2 Functions

      +

      34.3.2 Functions

      @@ -709,7 +709,7 @@ like you think it does: % -

      33.3.3 Global variables

      +

      34.3.3 Global variables

      @@ -789,7 +789,7 @@ extern char *path; // Read-only (due to %immutable) -

      33.3.4 Constants and enums

      +

      34.3.4 Constants and enums

      @@ -873,7 +873,7 @@ When an identifier name is given, it is used to perform an implicit hash-table l conversion. This allows the global statement to be omitted.

      -

      33.3.5 Pointers

      +

      34.3.5 Pointers

      @@ -969,7 +969,7 @@ C-style cast may return a bogus result whereas as the C++-style cast will return None if the conversion can't be performed.

      -

      33.3.6 Structures

      +

      34.3.6 Structures

      @@ -1251,7 +1251,7 @@ Note: Tcl only destroys the underlying object if it has ownership. See the memory management section that appears shortly.

      -

      33.3.7 C++ classes

      +

      34.3.7 C++ classes

      @@ -1318,7 +1318,7 @@ In Tcl, the static member is accessed as follows: -

      33.3.8 C++ inheritance

      +

      34.3.8 C++ inheritance

      @@ -1367,7 +1367,7 @@ For instance: It is safe to use multiple inheritance with SWIG.

      -

      33.3.9 Pointers, references, values, and arrays

      +

      34.3.9 Pointers, references, values, and arrays

      @@ -1421,7 +1421,7 @@ to hold the result and a pointer is returned (Tcl will release this memory when the return value is garbage collected).

      -

      33.3.10 C++ overloaded functions

      +

      34.3.10 C++ overloaded functions

      @@ -1544,7 +1544,7 @@ first declaration takes precedence. Please refer to the "SWIG and C++" chapter for more information about overloading.

      -

      33.3.11 C++ operators

      +

      34.3.11 C++ operators

      @@ -1646,7 +1646,7 @@ There are ways to make this operator appear as part of the class using the % Keep reading.

      -

      33.3.12 C++ namespaces

      +

      34.3.12 C++ namespaces

      @@ -1710,7 +1710,7 @@ utilizes thousands of small deeply nested namespaces each with identical symbol names, well, then you get what you deserve.

      -

      33.3.13 C++ templates

      +

      34.3.13 C++ templates

      @@ -1762,7 +1762,7 @@ More details can be found in the SWIG and C++ -

      33.3.14 C++ Smart Pointers

      +

      34.3.14 C++ Smart Pointers

      @@ -1846,7 +1846,7 @@ simply use the __deref__() method. For example: -

      33.4 Further details on the Tcl class interface

      +

      34.4 Further details on the Tcl class interface

      @@ -1859,7 +1859,7 @@ of low-level details were omitted. This section provides a brief overview of how the proxy classes work.

      -

      33.4.1 Proxy classes

      +

      34.4.1 Proxy classes

      @@ -1924,7 +1924,7 @@ function. This allows objects to be encapsulated objects that look a lot like as shown in the last section.

      -

      33.4.2 Memory management

      +

      34.4.2 Memory management

      @@ -2112,7 +2112,7 @@ typemaps--an advanced topic discussed later.

      -

      33.5 Input and output parameters

      +

      34.5 Input and output parameters

      @@ -2300,7 +2300,7 @@ set c [lindex $dim 1] -

      33.6 Exception handling

      +

      34.6 Exception handling

      @@ -2434,7 +2434,7 @@ Since SWIG's exception handling is user-definable, you are not limited to C++ ex See the chapter on "Customization Features" for more examples.

      -

      33.7 Typemaps

      +

      34.7 Typemaps

      @@ -2451,7 +2451,7 @@ Typemaps are only used if you want to change some aspect of the primitive C-Tcl interface.

      -

      33.7.1 What is a typemap?

      +

      34.7.1 What is a typemap?

      @@ -2568,7 +2568,7 @@ parameter is omitted): -

      33.7.2 Tcl typemaps

      +

      34.7.2 Tcl typemaps

      @@ -2706,7 +2706,7 @@ Initialize an argument to a value before any conversions occur. Examples of these methods will appear shortly.

      -

      33.7.3 Typemap variables

      +

      34.7.3 Typemap variables

      @@ -2777,7 +2777,7 @@ properly assigned. The Tcl name of the wrapper function being created. -

      33.7.4 Converting a Tcl list to a char **

      +

      34.7.4 Converting a Tcl list to a char **

      @@ -2839,7 +2839,7 @@ argv[2] = Larry 3 -

      33.7.5 Returning values in arguments

      +

      34.7.5 Returning values in arguments

      @@ -2881,7 +2881,7 @@ result, a Tcl function using these typemaps will work like this : % -

      33.7.6 Useful functions

      +

      34.7.6 Useful functions

      @@ -2958,7 +2958,7 @@ int Tcl_IsShared(Tcl_Obj *obj); -

      33.7.7 Standard typemaps

      +

      34.7.7 Standard typemaps

      @@ -3042,7 +3042,7 @@ work) -

      33.7.8 Pointer handling

      +

      34.7.8 Pointer handling

      @@ -3118,7 +3118,7 @@ For example: -

      33.8 Turning a SWIG module into a Tcl Package.

      +

      34.8 Turning a SWIG module into a Tcl Package.

      @@ -3190,7 +3190,7 @@ As a final note, most SWIG examples do not yet use the to use the load command instead.

      -

      33.9 Building new kinds of Tcl interfaces (in Tcl)

      +

      34.9 Building new kinds of Tcl interfaces (in Tcl)

      @@ -3289,7 +3289,7 @@ danger of blowing something up (although it is easily accomplished with an out of bounds array access).

      -

      33.9.1 Proxy classes

      +

      34.9.1 Proxy classes

      @@ -3410,7 +3410,7 @@ short, but clever Tcl script can be combined with SWIG to do many interesting things.

      -

      33.10 Tcl/Tk Stubs

      +

      34.10 Tcl/Tk Stubs

      From 041cee306d0ea3dece381fabca6cf75ecb7d46d9 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 10 Jun 2010 06:14:24 +0000 Subject: [PATCH 0926/1680] html fixes git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12113 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Contents.html | 4 ++-- Doc/Manual/Go.html | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index 25d2dbf9c..66bf41264 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -720,9 +720,9 @@

    • Go Enumerations
    • Go Classes -
    • Go Templates +
    • Go Templates
    • Go Director Classes
    • Default Go primitive type mappings diff --git a/Doc/Manual/Go.html b/Doc/Manual/Go.html index 7d2ce9db8..f6e87afb4 100644 --- a/Doc/Manual/Go.html +++ b/Doc/Manual/Go.html @@ -23,9 +23,9 @@
    • Go Enumerations
    • Go Classes -
    • Go Templates +
    • Go Templates
    • Go Director Classes
    • Default Go primitive type mappings @@ -289,7 +289,7 @@ to reinterpret_cast. This should only be used for very special cases, such as where C++ would use a dynamic_cast.

      -

      20.3.5.1 Go Class Inheritance

      +

      20.3.5.1 Go Class Inheritance

      @@ -301,7 +301,7 @@ Doing the reverse will require an explicit type assertion, which will be checked dynamically.

      -

      20.3.6 Go Templates

      +

      20.3.6 Go Templates

      @@ -341,7 +341,7 @@ For example: type GoClass struct { } func (p *GoClass) VirtualFunction() { } func MakeClass() ClassName { - return NewDirectorClassName(&GoClass{}) + return NewDirectorClassName(&GoClass{}) } From f10c7868fdbd12b50bed63255758d75d371acad2 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 10 Jun 2010 19:21:07 +0000 Subject: [PATCH 0927/1680] Fix SWIG_lua_isnilstring multiply defined when using multiple modules and wrapping strings. Patch from 'Number Cruncher'. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12114 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++++ Lib/lua/luatypemaps.swg | 12 ++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 471a9c5f4..00d1bec5b 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,10 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.1 (in progress) =========================== +2010-06-10: wsfulton + [Lua] Fix SWIG_lua_isnilstring multiply defined when using multiple + modules and wrapping strings. Patch from 'Number Cruncher'. + 2010-06-10: olly [PHP] Fix directors to correctly call a method with has a different name in PHP to C++ (we were always using the C++ name diff --git a/Lib/lua/luatypemaps.swg b/Lib/lua/luatypemaps.swg index aff116192..13cd66f4c 100644 --- a/Lib/lua/luatypemaps.swg +++ b/Lib/lua/luatypemaps.swg @@ -91,12 +91,12 @@ temp=($basetype)lua_tonumber(L,$input); $1=&temp;%} // strings (char * and char[]) %fragment("SWIG_lua_isnilstring", "header") { - int SWIG_lua_isnilstring(lua_State *L, int idx) { - int ret = lua_isstring(L, idx); - if (!ret) - ret = lua_isnil(L, idx); - return ret; - } +SWIGINTERN int SWIG_lua_isnilstring(lua_State *L, int idx) { + int ret = lua_isstring(L, idx); + if (!ret) + ret = lua_isnil(L, idx); + return ret; +} } %typemap(in,checkfn="SWIG_lua_isnilstring",fragment="SWIG_lua_isnilstring") const char *, char * From aa953c89089f769c6b4917700a3c62d72ab66586 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 10 Jun 2010 20:08:19 +0000 Subject: [PATCH 0928/1680] Syntactic sugar - go help display to conform to other help style git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12115 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/go.cxx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Source/Modules/go.cxx b/Source/Modules/go.cxx index 91a0f457b..c7a305167 100644 --- a/Source/Modules/go.cxx +++ b/Source/Modules/go.cxx @@ -4815,10 +4815,10 @@ extern "C" Language *swig_go(void) { // Usage message. const char * const GO::usage = (char *) "\ Go Options (available with -go)\n\ - -package - set name of the Go package to \n\ - -gccgo - generate code for gccgo rather than 6g/8g\n\ - -go-prefix

      - like gccgo -fgo-prefix option\n\ - -soname - name for shared library holding C/C++ code\n\ - -longsize - set size of C/C++ long type--32 or 64 bits\n\ - -rename = - rename symbols\n\ + -package - Set name of the Go package to \n\ + -gccgo - Generate code for gccgo rather than 6g/8g\n\ + -go-prefix

      - Like gccgo -fgo-prefix option\n\ + -soname - Set shared library holding C/C++ code to \n\ + -longsize - Set size of C/C++ long type--32 or 64 bits\n\ + -rename = - Rename symbols from to \n\ \n"; From 92f5c379b8c837ec4c2f98621d78cf5f86922303 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 11 Jun 2010 06:29:32 +0000 Subject: [PATCH 0929/1680] Fix 6g/8g detection git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12116 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/go/Makefile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/test-suite/go/Makefile.in b/Examples/test-suite/go/Makefile.in index d666c81bf..4af612799 100644 --- a/Examples/test-suite/go/Makefile.in +++ b/Examples/test-suite/go/Makefile.in @@ -3,7 +3,7 @@ ####################################################################### LANGUAGE = go -GO = 6g +GO = @GO@ GOGCC = false SCRIPTSUFFIX = _runme.go From 02ec28ff55feb664cd25ca1f85b6814ed0206a66 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 11 Jun 2010 06:36:51 +0000 Subject: [PATCH 0930/1680] make beautify-file fixes and other cosmetics git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12117 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Makefile.am | 2 +- Source/Modules/go.cxx | 497 +++++++++++++----------------------------- 2 files changed, 155 insertions(+), 344 deletions(-) diff --git a/Source/Makefile.am b/Source/Makefile.am index 4677002e6..ddf8018ec 100644 --- a/Source/Makefile.am +++ b/Source/Makefile.am @@ -115,7 +115,7 @@ distclean-local: # swig executable as a way of checking before and after the 'beautifying'. # Single files can be beautified with the beautify-file target, eg: 'make beautify-file INDENTFILE=chosenfile.c' -SWIGTYPEDEFS=-T File -T DohObjInfo -T Parm -T Language -T List -T Typetab -T ModuleFactory -T ErrorMessageFormat -T Symtab -T Hash -T String -T DohBase -T Node -T String_or_char -T SwigType -T Dispatcher -T Wrapper -T DohStringMethods -T DohFileMethods -T DohListMethods -T DohHashMethods -T DOH -T DohIterator -T ParmList -T FILE -T HashNode -T DOHString_or_char +SWIGTYPEDEFS=-T bool -T File -T DohObjInfo -T Parm -T Language -T List -T Typetab -T ModuleFactory -T ErrorMessageFormat -T Symtab -T Hash -T String -T DohBase -T Node -T String_or_char -T SwigType -T Dispatcher -T Wrapper -T DohStringMethods -T DohFileMethods -T DohListMethods -T DohHashMethods -T DOH -T DohIterator -T ParmList -T FILE -T HashNode -T DOHString_or_char INDENTBAKSDIR=../IndentBaks beautify: diff --git a/Source/Modules/go.cxx b/Source/Modules/go.cxx index c7a305167..cb6e3ad5a 100644 --- a/Source/Modules/go.cxx +++ b/Source/Modules/go.cxx @@ -15,7 +15,7 @@ char cvsroot_go_cxx[] = "$Id"; #include class GO:public Language { - static const char * const usage; + static const char *const usage; // Go package name. String *package; @@ -116,8 +116,7 @@ public: making_variable_wrappers(false), is_static_member_function(false), undefined_types(NULL), - defined_types(NULL) - { + defined_types(NULL) { director_multiple_inheritance = 1; director_language = 1; director_prot_ctor_code = NewString("_swig_gopanic(\"accessing abstract class or protected constructor\");"); @@ -367,14 +366,12 @@ private: Printf(f_c_runtime, "#define SWIG_DIRECTORS\n"); Swig_banner(f_c_directors_h); - Printf(f_c_directors_h, - "\n/* This file should be compiled with gcc. */\n"); + Printf(f_c_directors_h, "\n/* This file should be compiled with gcc. */\n"); Printf(f_c_directors_h, "#ifndef SWIG_%s_WRAP_H_\n", module); Printf(f_c_directors_h, "#define SWIG_%s_WRAP_H_\n\n", module); Printf(f_c_directors, "\n// C++ director class methods.\n"); - Printf(f_c_directors, "#include \"%s\"\n\n", - Swig_file_filename(c_filename_h)); + Printf(f_c_directors, "#include \"%s\"\n\n", Swig_file_filename(c_filename_h)); } Swig_banner(f_go_begin); @@ -409,8 +406,7 @@ private: Printv(f_go_wrappers, "type ", ty, " interface {\n", NULL); Printv(f_go_wrappers, "\tSwigcptr() uintptr;\n", NULL); Printv(f_go_wrappers, "}\n", NULL); - Printv(f_go_wrappers, "func (p ", cp, ") Swigcptr() uintptr {\n", - NULL); + Printv(f_go_wrappers, "func (p ", cp, ") Swigcptr() uintptr {\n", NULL); Printv(f_go_wrappers, "\treturn uintptr(p)\n", NULL); Printv(f_go_wrappers, "}\n\n", NULL); } @@ -574,10 +570,8 @@ private: Delete(c2); Delete(c1); - if (Swig_methodclass(n) != NULL - && Swig_directorclass(n) - && Strcmp(Char(Getattr(n, "wrap:action")), - director_prot_ctor_code) != 0) { + if (Swig_methodclass(n) != NULL && Swig_directorclass(n) + && Strcmp(Char(Getattr(n, "wrap:action")), director_prot_ctor_code) != 0) { // The core SWIG code skips the first parameter when // generating the $nondirector_new string. Recreate the // action in this case. But don't it if we are using the @@ -643,8 +637,7 @@ private: ParmList *parms = Getattr(n, "parms"); Setattr(n, "wrap:parms", parms); - int r = makeWrappers(n, name, go_name, overname, wname, NULL, parms, - result, is_static); + int r = makeWrappers(n, name, go_name, overname, wname, NULL, parms, result, is_static); if (r != SWIG_OK) { return r; } @@ -703,22 +696,18 @@ private: * IS_STATIC: Whether this is a static method or member. * ---------------------------------------------------------------------- */ - int makeWrappers(Node *n, String *name, String *go_name, String *overname, - String *wname, List *base, ParmList *parms, - SwigType *result, bool is_static) { + int makeWrappers(Node *n, String *name, String *go_name, String *overname, String *wname, List *base, ParmList *parms, SwigType *result, bool is_static) { assert(result != NULL); bool needs_wrapper; - int r = goFunctionWrapper(n, name, go_name, overname, wname, base, parms, - result, is_static, &needs_wrapper); + int r = goFunctionWrapper(n, name, go_name, overname, wname, base, parms, result, is_static, &needs_wrapper); if (r != SWIG_OK) { return r; } if (!gccgo_flag) { - r = gcFunctionWrapper(n, name, go_name, overname, wname, parms, result, - is_static, needs_wrapper); + r = gcFunctionWrapper(n, name, go_name, overname, wname, parms, result, is_static, needs_wrapper); if (r != SWIG_OK) { return r; } @@ -751,10 +740,7 @@ private: * base class. * ---------------------------------------------------------------------- */ - int goFunctionWrapper(Node *n, String *name, String *go_name, - String *overname, String *wname, List *base, - ParmList *parms, SwigType *result, bool is_static, - bool *p_needs_wrapper) { + int goFunctionWrapper(Node *n, String *name, String *go_name, String *overname, String *wname, List *base, ParmList *parms, SwigType *result, bool is_static, bool *p_needs_wrapper) { Wrapper *dummy = NewWrapper(); emit_attach_parmmaps(parms, dummy); Swig_typemap_attach_parms("default", parms, dummy); @@ -776,18 +762,9 @@ private: receiver = NULL; } - bool add_to_interface = (interfaces != NULL - && !is_constructor - && !is_destructor - && !is_static - && overname == NULL - && is_public(n)); + bool add_to_interface = (interfaces != NULL && !is_constructor && !is_destructor && !is_static && overname == NULL && is_public(n)); - bool needs_wrapper = (gccgo_flag - || receiver != NULL - || is_constructor - || is_destructor - || parm_count > required_count); + bool needs_wrapper = (gccgo_flag || receiver != NULL || is_constructor || is_destructor || parm_count > required_count); // See whether any of the function parameters are represented by // interface values When calling the C++ code, we need to convert @@ -845,9 +822,7 @@ private: p = getParm(p); // Give the parameter a name we will use below. Swig_cparm_name(p, i); - if (i > 0 - || (base != NULL && receiver != NULL) - || parm_count > required_count) { + if (i > 0 || (base != NULL && receiver != NULL) || parm_count > required_count) { Printv(f_go_wrappers, ", ", NULL); } String *tm = goWrapperType(p, Getattr(p, "type"), false); @@ -867,8 +842,7 @@ private: } if (gccgo_flag) { - Printv(f_go_wrappers, " __asm__ (\"", go_prefix, "_", wname, "\")", - NULL); + Printv(f_go_wrappers, " __asm__ (\"", go_prefix, "_", wname, "\")", NULL); } Printv(f_go_wrappers, "\n\n", NULL); @@ -968,12 +942,9 @@ private: for (; i < parm_count; ++i) { p = getParm(p); String *tm = goType(p, Getattr(p, "type")); - Printv(f_go_wrappers, "\tvar ", Getattr(p, "lname"), " ", tm, "\n", - NULL); - Printf(f_go_wrappers, "\tif len(_swig_args) > %d {\n", - i - required_count); - Printf(f_go_wrappers, "\t\t%s = _swig_args[%d].(%s)\n", - Getattr(p, "lname"), i - required_count, tm); + Printv(f_go_wrappers, "\tvar ", Getattr(p, "lname"), " ", tm, "\n", NULL); + Printf(f_go_wrappers, "\tif len(_swig_args) > %d {\n", i - required_count); + Printf(f_go_wrappers, "\t\t%s = _swig_args[%d].(%s)\n", Getattr(p, "lname"), i - required_count, tm); Printv(f_go_wrappers, "\t}\n", NULL); Delete(tm); p = nextParm(p); @@ -1001,8 +972,7 @@ private: Parm *p = parms; for (int i = 0; i < parm_count; ++i) { p = getParm(p); - if (i > 0 - || (base != NULL && receiver != NULL) + if (i > 0 || (base != NULL && receiver != NULL) || parm_count > required_count) { Printv(f_go_wrappers, ", ", NULL); } @@ -1024,8 +994,7 @@ private: Printv(f_go_wrappers, "}\n", NULL); } else { if (gccgo_flag) { - Printv(f_go_wrappers, " __asm__ (\"", go_prefix, "_", - wname, "\")\n", NULL); + Printv(f_go_wrappers, " __asm__ (\"", go_prefix, "_", wname, "\")\n", NULL); } } @@ -1044,13 +1013,10 @@ private: * wrapper which will be compiled with 6c/8c. * ---------------------------------------------------------------------- */ - int gcFunctionWrapper(Node *n, String *name, String *go_name, - String *overname, String *wname, ParmList *parms, - SwigType *result, bool is_static, bool needs_wrapper) { + int gcFunctionWrapper(Node *n, String *name, String *go_name, String *overname, String *wname, ParmList *parms, SwigType *result, bool is_static, bool needs_wrapper) { Wrapper *f = NewWrapper(); - Printv(f->def, "#pragma dynimport ", wname, " ", wname, " \"", - soname, "\"\n", NULL); + Printv(f->def, "#pragma dynimport ", wname, " ", wname, " \"", soname, "\"\n", NULL); Printv(f->def, "void (*", wname, ")(void*);\n", NULL); Printv(f->def, "\n", NULL); Printv(f->def, "void\n", NULL); @@ -1101,8 +1067,7 @@ private: } // \xc2\xb7 is UTF-8 for U+00B7 which is Unicode 'Middle Dot' - Printv(f->def, "\xc2\xb7", fn_name, - "(struct { uint8 x[", parm_size, "];} p)", NULL); + Printv(f->def, "\xc2\xb7", fn_name, "(struct { uint8 x[", parm_size, "];} p)", NULL); Delete(fn_name); Delete(parm_size); @@ -1161,8 +1126,7 @@ private: * executing the SWIG wrapper code. * ---------------------------------------------------------------------- */ - int gccFunctionWrapper(Node *n, List *base, String *wname, ParmList *parms, - SwigType *result) { + int gccFunctionWrapper(Node *n, List *base, String *wname, ParmList *parms, SwigType *result) { Wrapper *f = NewWrapper(); Swig_save("gccFunctionWrapper", n, "parms", NULL); @@ -1185,11 +1149,7 @@ private: // Start the function definition. - Printv(f->def, - "#ifdef __cplusplus\n", - "extern \"C\"\n", - "#endif\n", - NULL); + Printv(f->def, "#ifdef __cplusplus\n", "extern \"C\"\n", "#endif\n", NULL); Printv(f->def, "void\n", wname, "(void *swig_v)\n", "{\n", NULL); @@ -1233,9 +1193,7 @@ private: String *tm = Getattr(p, "tmap:in"); if (tm == NULL) { - Swig_warning(WARN_TYPEMAP_IN_UNDEF, input_file, line_number, - "Unable to use type %s as a function argument\n", - SwigType_str(Getattr(p, "type"), 0)); + Swig_warning(WARN_TYPEMAP_IN_UNDEF, input_file, line_number, "Unable to use type %s as a function argument\n", SwigType_str(Getattr(p, "type"), 0)); } else { String *ln = Getattr(p, "lname"); String *input = NewString(""); @@ -1245,8 +1203,7 @@ private: if (i < required_count) { Printv(f->code, "\t", tm, "\n", NULL); } else { - Printf(f->code, "\tif (swig_a->_swig_optargc > %d) {\n", - i - required_count); + Printf(f->code, "\tif (swig_a->_swig_optargc > %d) {\n", i - required_count); Printv(f->code, "\t\t", tm, "\n", NULL); Printv(f->code, "\t}\n", NULL); } @@ -1289,8 +1246,7 @@ private: * executing the SWIG wrapper code. * ---------------------------------------------------------------------- */ - int gccgoFunctionWrapper(Node *n, List *base, String *wname, ParmList *parms, - SwigType *result) { + int gccgoFunctionWrapper(Node *n, List *base, String *wname, ParmList *parms, SwigType *result) { Wrapper *f = NewWrapper(); Swig_save("gccgoFunctionWrapper", n, "parms", NULL); @@ -1313,11 +1269,7 @@ private: // Start the function definition. - Printv(f->def, - "#ifdef __cplusplus\n", - "extern \"C\"\n", - "#endif\n", - NULL); + Printv(f->def, "#ifdef __cplusplus\n", "extern \"C\"\n", "#endif\n", NULL); String *fnname = NewString(""); Printv(fnname, go_prefix, "_", wname, "(", NULL); @@ -1374,8 +1326,7 @@ private: String *tm = Getattr(p, "tmap:in"); if (tm == NULL) { Swig_warning(WARN_TYPEMAP_IN_UNDEF, input_file, line_number, - "Unable to use type %s as a function argument\n", - SwigType_str(Getattr(p, "type"), 0)); + "Unable to use type %s as a function argument\n", SwigType_str(Getattr(p, "type"), 0)); } else { String *ln = Getattr(p, "lname"); String *pn = NewString("g"); @@ -1452,8 +1403,7 @@ private: * Get the action of the function. This is used for C/C++ function. * ----------------------------------------------------------------------- */ - void emitGoAction(Node *n, List *base, ParmList *parms, SwigType *result, - Wrapper *f) { + void emitGoAction(Node *n, List *base, ParmList *parms, SwigType *result, Wrapper *f) { String *actioncode; if (base == NULL || isStatic(n)) { Swig_director_emit_dynamic_cast(n, f); @@ -1471,8 +1421,7 @@ private: String *last = NULL; int vc = 0; for (Iterator bi = First(base); bi.item != NULL; bi = Next(bi)) { - Printf(actioncode, " %s *swig_b%d = (%s *)%s;\n", bi.item, vc, - bi.item, current); + Printf(actioncode, " %s *swig_b%d = (%s *)%s;\n", bi.item, vc, bi.item, current); Delete(current); current = NewString(""); Printf(current, "swig_b%d", vc); @@ -1491,9 +1440,7 @@ private: String *tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode); if (tm == NULL) { - Swig_warning(WARN_TYPEMAP_OUT_UNDEF, input_file, line_number, - "Unable to use return type %s\n", - SwigType_str(result, 0)); + Swig_warning(WARN_TYPEMAP_OUT_UNDEF, input_file, line_number, "Unable to use return type %s\n", SwigType_str(result, 0)); } else { if (!gccgo_flag) { Replaceall(tm, "$result", "swig_a->result"); @@ -1611,10 +1558,9 @@ private: return goComplexConstant(n, type); } - if (Getattr(n, "storage") != NULL - && Strcmp(Getattr(n, "storage"), "static") == 0) { + if (Getattr(n, "storage") != NULL && Strcmp(Getattr(n, "storage"), "static") == 0) { return goComplexConstant(n, type); - } + } String *go_name = buildGoName(Getattr(n, "sym:name"), false, false); @@ -1631,8 +1577,7 @@ private: if (Cmp(value, "true") != 0 && Cmp(value, "false") != 0) { return goComplexConstant(n, type); } - } else if (SwigType_type(type) == T_STRING - || SwigType_type(type) == T_CHAR) { + } else if (SwigType_type(type) == T_STRING || SwigType_type(type) == T_CHAR) { // Backslash sequences are somewhat different in Go and C/C++. if (Strchr(value, '\\') != NULL) { return goComplexConstant(n, type); @@ -1661,11 +1606,9 @@ private: } for (; i < len; ++i) { switch (p[i]) { - case '0': case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': + case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': break; - case 'a': case 'b': case 'c': case 'd': case 'f': - case 'A': case 'B': case 'C': case 'D': case 'F': + case 'a': case 'b': case 'c': case 'd': case 'f': case 'A': case 'B': case 'C': case 'D': case 'F': if (!is_hex) { return goComplexConstant(n, type); } @@ -1778,7 +1721,7 @@ private: Printv(get, ";\n", NULL); Setattr(n, "wrap:action", get); - String* symname = Getattr(n, "sym:name"); + String *symname = Getattr(n, "sym:name"); if (symname == NULL) { symname = Getattr(n, "name"); } @@ -1799,8 +1742,7 @@ private: String *wname = Swig_name_wrapper(sname); Setattr(n, "wrap:name", wname); - int r = makeWrappers(n, sname, go_name, NULL, wname, NULL, NULL, type, - true); + int r = makeWrappers(n, sname, go_name, NULL, wname, NULL, NULL, type, true); if (r != SWIG_OK) { return r; @@ -1808,8 +1750,7 @@ private: String *varname = buildGoName(symname, true, false); String *t = goType(n, type); - Printv(f_go_wrappers, "var ", varname, " ", t, " = ", go_name, "()\n", - NULL); + Printv(f_go_wrappers, "var ", varname, " ", t, " = ", go_name, "()\n", NULL); Delete(varname); Delete(t); @@ -1854,21 +1795,18 @@ private: // A method to return the pointer to the C++ class. This is used // by generated code to convert between the interface and the C++ // value. - Printv(f_go_wrappers, "func (p ", go_type_name, ") Swigcptr() uintptr {\n", - NULL); + Printv(f_go_wrappers, "func (p ", go_type_name, ") Swigcptr() uintptr {\n", NULL); Printv(f_go_wrappers, "\treturn (uintptr)(p)\n", NULL); Printv(f_go_wrappers, "}\n\n", NULL); // A method used as a marker for the class, to avoid invalid // interface conversions when using multiple inheritance. - Printv(f_go_wrappers, "func (p ", go_type_name, ") SwigIs", go_name, - "() {\n", NULL); + Printv(f_go_wrappers, "func (p ", go_type_name, ") SwigIs", go_name, "() {\n", NULL); Printv(f_go_wrappers, "}\n\n", NULL); if (is_director) { // Return the interface passed to the NewDirector function. - Printv(f_go_wrappers, "func (p ", go_type_name, - ") DirectorInterface() interface{} {\n", NULL); + Printv(f_go_wrappers, "func (p ", go_type_name, ") DirectorInterface() interface{} {\n", NULL); Printv(f_go_wrappers, "\treturn nil\n", NULL); Printv(f_go_wrappers, "}\n\n", NULL); } @@ -1891,9 +1829,7 @@ private: // differently in Go and in C++. Hash *local = NewHash(); - for (Node *ni = Getattr(n, "firstChild"); - ni != NULL; - ni = nextSibling(ni)) { + for (Node *ni = Getattr(n, "firstChild"); ni != NULL; ni = nextSibling(ni)) { if (!is_public(ni)) { continue; @@ -1970,9 +1906,7 @@ private: return SWIG_OK; } - for (Node *ni = Getattr(base, "firstChild"); - ni != NULL; - ni = nextSibling(ni)) { + for (Node *ni = Getattr(base, "firstChild"); ni != NULL; ni = nextSibling(ni)) { if (GetFlag(ni, "feature:ignore")) { continue; @@ -1983,10 +1917,7 @@ private: } String *type = Getattr(ni, "nodeType"); - if (Strcmp(type, "constructor") == 0 - || Strcmp(type, "destructor") == 0 - || Strcmp(type, "enum") == 0 - || Strcmp(type, "using") == 0) { + if (Strcmp(type, "constructor") == 0 || Strcmp(type, "destructor") == 0 || Strcmp(type, "enum") == 0 || Strcmp(type, "using") == 0) { continue; } String *storage = Getattr(ni, "storage"); @@ -2022,9 +1953,7 @@ private: } if (Getattr(ni, "sym:overloaded") != NULL) { - for (Node *on = Getattr(ni, "sym:nextSibling"); - on != NULL; - on = Getattr(on, "sym:nextSibling")) { + for (Node *on = Getattr(ni, "sym:nextSibling"); on != NULL; on = Getattr(on, "sym:nextSibling")) { r = goBaseMethod(n, bases, on); if (r != SWIG_OK) { return r; @@ -2036,10 +1965,8 @@ private: if (is_static) { receiver = NULL; } - String *go_name = buildGoName(Getattr(ni, "sym:name"), is_static, - false); - r = makeDispatchFunction(ni, go_name, receiver, is_static, NULL, - false); + String *go_name = buildGoName(Getattr(ni, "sym:name"), is_static, false); + r = makeDispatchFunction(ni, go_name, receiver, is_static, NULL, false); Delete(go_name); if (r != SWIG_OK) { return r; @@ -2108,11 +2035,7 @@ private: Swig_save("goBaseMethod", method, "wrap:action", "parms", NULL); if (Getattr(method, "wrap:action") == NULL) { if (!is_static) { - Swig_MethodToFunction(method, getNSpace(), getClassType(), - (Getattr(method, "template") != NULL - ? SmartPointer - : Extend | SmartPointer), - NULL, false); + Swig_MethodToFunction(method, getNSpace(), getClassType(), (Getattr(method, "template") != NULL ? SmartPointer : Extend | SmartPointer), NULL, false); // Remove any self parameter that was just added. ParmList *parms = Getattr(method, "parms"); if (parms != NULL && Getattr(parms, "self") != NULL) { @@ -2120,15 +2043,12 @@ private: Setattr(method, "parms", parms); } } else { - String *call = Swig_cfunction_call(Getattr(method, "name"), - Getattr(method, "parms")); - Setattr(method, "wrap:action", Swig_cresult(Getattr(method, "type"), - "result", call)); + String *call = Swig_cfunction_call(Getattr(method, "name"), Getattr(method, "parms")); + Setattr(method, "wrap:action", Swig_cresult(Getattr(method, "type"), "result", call)); } } - int r = makeWrappers(method, name, go_name, overname, wname, bases, - Getattr(method, "parms"), result, is_static); + int r = makeWrappers(method, name, go_name, overname, wname, bases, Getattr(method, "parms"), result, is_static); Swig_restore(method); @@ -2170,9 +2090,7 @@ private: flags |= CWRAP_ALL_PROTECTED_ACCESS; } - String *mname = Swig_name_member(getNSpace(), - Getattr(var_class, "sym:name"), - var_name); + String *mname = Swig_name_member(getNSpace(), Getattr(var_class, "sym:name"), var_name); if (is_assignable(var)) { for (Iterator ki = First(var); ki.key != NULL; ki = Next(ki)) { @@ -2193,8 +2111,7 @@ private: String *wname = Swig_name_wrapper(mname_set); ParmList *parms = NewParm(vt, var_name, var); String *result = NewString("void"); - int r = makeWrappers(var, mname_set, go_name, NULL, wname, bases, parms, - result, false); + int r = makeWrappers(var, mname_set, go_name, NULL, wname, bases, parms, result, false); if (r != SWIG_OK) { return r; } @@ -2222,8 +2139,7 @@ private: String *wname = Swig_name_wrapper(mname_get); - int r = makeWrappers(var, mname_get, go_name, NULL, wname, bases, NULL, - vt, false); + int r = makeWrappers(var, mname_get, go_name, NULL, wname, bases, NULL, vt, false); if (r != SWIG_OK) { return r; } @@ -2266,24 +2182,18 @@ private: String *go_type_name = goCPointerType(Getattr(n, "classtypeobj"), true); String *go_base_name = exportedName(Getattr(b.item, "sym:name")); String *go_base_type = goType(n, Getattr(b.item, "classtypeobj")); - String *go_base_type_name = goCPointerType(Getattr(b.item, - "classtypeobj"), - true); + String *go_base_type_name = goCPointerType(Getattr(b.item, "classtypeobj"), true); - Printv(f_go_wrappers, "func (p ", go_type_name, ") SwigIs", go_base_name, - "() {\n", NULL); + Printv(f_go_wrappers, "func (p ", go_type_name, ") SwigIs", go_base_name, "() {\n", NULL); Printv(f_go_wrappers, "}\n\n", NULL); Printv(interfaces, "\tSwigIs", go_base_name, "()\n", NULL); - Printv(f_go_wrappers, "func (p ", go_type_name, ") SwigGet", go_base_name, - "() ", go_base_type, " {\n", NULL); - Printv(f_go_wrappers, "\treturn ", go_base_type_name, - "(p.Swigcptr())\n", NULL); + Printv(f_go_wrappers, "func (p ", go_type_name, ") SwigGet", go_base_name, "() ", go_base_type, " {\n", NULL); + Printv(f_go_wrappers, "\treturn ", go_base_type_name, "(p.Swigcptr())\n", NULL); Printv(f_go_wrappers, "}\n\n", NULL); - Printv(interfaces, "\tSwigGet", go_base_name, "() ", go_base_type, "\n", - NULL); + Printv(interfaces, "\tSwigGet", go_base_name, "() ", go_base_type, "\n", NULL); Setattr(parents, go_base_name, NewString("")); @@ -2315,8 +2225,7 @@ private: String *go_base_name = exportedName(Getattr(b.item, "sym:name")); - Swig_save("addExtraBaseInterface", n, "wrap:action", "wrap:name", - "wrap:parms", NULL); + Swig_save("addExtraBaseInterface", n, "wrap:action", "wrap:name", "wrap:parms", NULL); SwigType *type = Copy(Getattr(n, "classtypeobj")); SwigType_add_pointer(type); @@ -2325,8 +2234,7 @@ private: String *pn = Swig_cparm_name(parm, 0); String *action = NewString(""); - Printv(action, "result = (", Getattr(b.item, "classtype"), "*)", pn, - ";", NULL); + Printv(action, "result = (", Getattr(b.item, "classtype"), "*)", pn, ";", NULL); Delete(pn); Setattr(n, "wrap:action", action); @@ -2383,8 +2291,7 @@ private: * classes of parents other than the first base class at each level. * ------------------------------------------------------------ */ - void addParentExtraBaseInterfaces(Node *n, Hash *parents, Node *base, - bool is_base_first, String *sofar) { + void addParentExtraBaseInterfaces(Node *n, Hash *parents, Node *base, bool is_base_first, String *sofar) { List *baselist = Getattr(base, "bases"); if (baselist == NULL || Len(baselist) == 0) { return; @@ -2419,14 +2326,11 @@ private: String *go_base_name = exportedName(Getattr(b.item, "sym:name")); if (Getattr(parents, go_base_name) == NULL) { - Printv(f_go_wrappers, "func (p ", go_type_name, ") SwigGet", - go_base_name, "() ", go_base_name, " {\n", NULL); - Printv(f_go_wrappers, "\treturn p", sf, ".SwigGet", go_base_name, - "()\n", NULL); + Printv(f_go_wrappers, "func (p ", go_type_name, ") SwigGet", go_base_name, "() ", go_base_name, " {\n", NULL); + Printv(f_go_wrappers, "\treturn p", sf, ".SwigGet", go_base_name, "()\n", NULL); Printv(f_go_wrappers, "}\n\n", NULL); - Printv(interfaces, "\tSwigGet", go_base_name, "() ", go_base_name, "\n", - NULL); + Printv(interfaces, "\tSwigGet", go_base_name, "() ", go_base_name, "\n", NULL); addParentExtraBaseInterfaces(n, parents, b.item, false, sf); @@ -2478,7 +2382,7 @@ private: String *director_struct_name = NewString("_swig_Director"); Append(director_struct_name, go_name); - String* cxx_director_name = NewString("SwigDirector_"); + String *cxx_director_name = NewString("SwigDirector_"); Append(cxx_director_name, name); // The Go type of the director class. @@ -2487,23 +2391,19 @@ private: Printv(f_go_wrappers, "\tv interface{}\n", NULL); Printv(f_go_wrappers, "}\n\n", NULL); - Printv(f_go_wrappers, "func (p *", director_struct_name, - ") Swigcptr() uintptr {\n", NULL); + Printv(f_go_wrappers, "func (p *", director_struct_name, ") Swigcptr() uintptr {\n", NULL); Printv(f_go_wrappers, "\treturn p.", go_type_name, ".Swigcptr()\n", NULL); Printv(f_go_wrappers, "}\n\n", NULL); - Printv(f_go_wrappers, "func (p *", director_struct_name, ") SwigIs", - go_name, "() {\n", NULL); + Printv(f_go_wrappers, "func (p *", director_struct_name, ") SwigIs", go_name, "() {\n", NULL); Printv(f_go_wrappers, "}\n\n", NULL); - Printv(f_go_wrappers, "func (p *", director_struct_name, - ") DirectorInterface() interface{} {\n", NULL); + Printv(f_go_wrappers, "func (p *", director_struct_name, ") DirectorInterface() interface{} {\n", NULL); Printv(f_go_wrappers, "\treturn p.v\n", NULL); Printv(f_go_wrappers, "}\n\n", NULL); // Start defining the director class. - Printv(f_c_directors_h, "class ", cxx_director_name, " : public ", - Getattr(n, "classtype"), "\n", NULL); + Printv(f_c_directors_h, "class ", cxx_director_name, " : public ", Getattr(n, "classtype"), "\n", NULL); Printv(f_c_directors_h, "{\n", NULL); Printv(f_c_directors_h, " public:\n", NULL); @@ -2542,9 +2442,7 @@ private: String *cn = exportedName(Getattr(parentNode(n), "sym:name")); - String *go_type_name = goCPointerType(Getattr(parentNode(n), - "classtypeobj"), - true); + String *go_type_name = goCPointerType(Getattr(parentNode(n), "classtypeobj"), true); String *director_struct_name = NewString("_swig_Director"); Append(director_struct_name, cn); @@ -2616,14 +2514,12 @@ private: Printv(f_go_wrappers, ") ", go_type_name, NULL); if (gccgo_flag) { - Printv(f_go_wrappers, " __asm__(\"", go_prefix, "_", wname, "\")", - NULL); + Printv(f_go_wrappers, " __asm__(\"", go_prefix, "_", wname, "\")", NULL); } Printv(f_go_wrappers, "\n\n", NULL); - Printv(f_go_wrappers, "func ", func_with_over_name, "(v interface{}", - NULL); + Printv(f_go_wrappers, "func ", func_with_over_name, "(v interface{}", NULL); p = parms; for (int i = 0; i < parm_count; ++i) { @@ -2638,8 +2534,7 @@ private: Printv(f_go_wrappers, ") ", cn, " {\n", NULL); - Printv(f_go_wrappers, "\tp := &", director_struct_name, "{0, v}\n", - NULL); + Printv(f_go_wrappers, "\tp := &", director_struct_name, "{0, v}\n", NULL); Printv(f_go_wrappers, "\tp.", class_receiver, " = ", fn_name, NULL); if (overname != NULL) { Printv(f_go_wrappers, overname, NULL); @@ -2660,8 +2555,7 @@ private: SwigType *result = Copy(Getattr(parentNode(n), "classtypeobj")); SwigType_add_pointer(result); - Swig_save("classDirectorConstructor", n, "wrap:name", "wrap:action", - NULL); + Swig_save("classDirectorConstructor", n, "wrap:name", "wrap:action", NULL); Setattr(n, "wrap:name", Swig_name_wrapper(name)); @@ -2715,13 +2609,11 @@ private: Printv(f_c_directors_h, " ", decl, ";\n", NULL); Delete(decl); - decl = Swig_method_decl(NULL, Getattr(n, "decl"), - cxx_director_name, first_parm, 0, 0); + decl = Swig_method_decl(NULL, Getattr(n, "decl"), cxx_director_name, first_parm, 0, 0); Printv(f_c_directors, cxx_director_name, "::", decl, "\n", NULL); Delete(decl); - Printv(f_c_directors, " : ", Getattr(parentNode(n), "classtype"), "(", - NULL); + Printv(f_c_directors, " : ", Getattr(parentNode(n), "classtype"), "(", NULL); p = parms; for (int i = 0; i < parm_count; ++i) { @@ -2739,9 +2631,7 @@ private: Printv(f_c_directors, "{ }\n\n", NULL); if (Getattr(n, "sym:overloaded") && Getattr(n, "sym:nextSibling") == NULL) { - int r = makeDispatchFunction(n, func_name, cn, is_static, - Getattr(parentNode(n), "classtypeobj"), - false); + int r = makeDispatchFunction(n, func_name, cn, is_static, Getattr(parentNode(n), "classtypeobj"), false); if (r != SWIG_OK) { return r; } @@ -2785,9 +2675,7 @@ private: Setattr(n, "wrap:name", fnname); - Swig_DestructorToFunction(n, getNSpace(), - Getattr(parentNode(n), "classtype"), - CPlusPlus, Extend); + Swig_DestructorToFunction(n, getNSpace(), Getattr(parentNode(n), "classtype"), CPlusPlus, Extend); ParmList *parms = Getattr(n, "parms"); Setattr(n, "wrap:parms", parms); @@ -2819,8 +2707,7 @@ private: String *director_struct_name = NewString("_swig_Director"); Append(director_struct_name, cn); - Printv(f_c_directors_h, " virtual ~SwigDirector_", class_name, "()", - NULL); + Printv(f_c_directors_h, " virtual ~SwigDirector_", class_name, "()", NULL); String *throws = buildThrow(n); if (throws != NULL) { @@ -2831,16 +2718,13 @@ private: if (!is_ignored) { if (!gccgo_flag) { - Printv(f_c_directors, "extern \"C\" void ", wname, "(void*, int);\n", - NULL); + Printv(f_c_directors, "extern \"C\" void ", wname, "(void*, int);\n", NULL); } else { - Printv(f_c_directors, "extern \"C\" void ", wname, "(void*) __asm__(\"", - go_prefix, ".", package, ".", go_name, "\");\n", NULL); + Printv(f_c_directors, "extern \"C\" void ", wname, "(void*) __asm__(\"", go_prefix, ".", package, ".", go_name, "\");\n", NULL); } } - Printv(f_c_directors, "SwigDirector_", class_name, "::~SwigDirector_", - class_name, "()", NULL); + Printv(f_c_directors, "SwigDirector_", class_name, "::~SwigDirector_", class_name, "()", NULL); if (throws != NULL) { Printv(f_c_directors, " ", throws, NULL); @@ -2854,17 +2738,14 @@ private: if (!gccgo_flag) { Printv(f_c_directors, " struct { void *p; } a;\n", NULL); Printv(f_c_directors, " a.p = go_val;\n", NULL); - Printv(f_c_directors, " crosscall2(", wname, - ", &a, (int) sizeof a);\n", NULL); + Printv(f_c_directors, " crosscall2(", wname, ", &a, (int) sizeof a);\n", NULL); - Printv(f_gc_wrappers, "#pragma dynexport ", wname, " ", wname, "\n", - NULL); + Printv(f_gc_wrappers, "#pragma dynexport ", wname, " ", wname, "\n", NULL); Printv(f_gc_wrappers, "extern void \xc2\xb7", go_name, "();\n", NULL); Printv(f_gc_wrappers, "void\n", NULL); Printv(f_gc_wrappers, wname, "(void *a, int32 n)\n", NULL); Printv(f_gc_wrappers, "{\n", NULL); - Printv(f_gc_wrappers, "\tcgocallback(\xc2\xb7", go_name, ", a, n);\n", - NULL); + Printv(f_gc_wrappers, "\tcgocallback(\xc2\xb7", go_name, ", a, n);\n", NULL); Printv(f_gc_wrappers, "}\n\n", NULL); } else { Printv(f_c_directors, " ", wname, "(go_val);\n", NULL); @@ -2874,8 +2755,7 @@ private: Printv(f_c_directors, "}\n\n", NULL); if (!is_ignored) { - Printv(f_go_wrappers, "func ", go_name, "(p *", director_struct_name, - ") {\n", NULL); + Printv(f_go_wrappers, "func ", go_name, "(p *", director_struct_name, ") {\n", NULL); Printv(f_go_wrappers, "\tp.", class_receiver, " = 0\n", NULL); Printv(f_go_wrappers, "}\n\n", NULL); } @@ -2898,8 +2778,7 @@ private: (void) super; bool is_ignored = GetFlag(n, "feature:ignore"); - bool is_pure_virtual = (Cmp(Getattr(n, "storage"), "virtual") == 0 - && Cmp(Getattr(n, "value"), "0") == 0); + bool is_pure_virtual = (Cmp(Getattr(n, "storage"), "virtual") == 0 && Cmp(Getattr(n, "value"), "0") == 0); // We don't need explicit calls. if (GetFlag(n, "explicitcall")) { @@ -2934,9 +2813,7 @@ private: // class_methods so that we correctly handle cases where a // function in one class hides a function of the same name in a // parent class. - for (Node *on = Getattr(n, "sym:overloaded"); - on != NULL; - on = Getattr(on, "sym:nextSibling")) { + for (Node *on = Getattr(n, "sym:overloaded"); on != NULL; on = Getattr(on, "sym:nextSibling")) { int r = oneClassDirectorMethod(on, parent); if (r != SWIG_OK) { return r; @@ -2959,8 +2836,7 @@ private: String *director_struct_name = NewString("_swig_Director"); Append(director_struct_name, cn); - int r = makeDispatchFunction(n, go_name, director_struct_name, is_static, - director_struct_name, false); + int r = makeDispatchFunction(n, go_name, director_struct_name, is_static, director_struct_name, false); if (r != SWIG_OK) { return r; } @@ -2968,8 +2844,7 @@ private: String *go_upcall = NewString("Director"); Append(go_upcall, cn); Append(go_upcall, go_name); - r = makeDispatchFunction(n, go_upcall, director_struct_name, is_static, - director_struct_name, true); + r = makeDispatchFunction(n, go_upcall, director_struct_name, is_static, director_struct_name, true); if (r != SWIG_OK) { return r; } @@ -2991,8 +2866,7 @@ private: int oneClassDirectorMethod(Node *n, Node *parent) { bool is_ignored = GetFlag(n, "feature:ignore"); - bool is_pure_virtual = (Cmp(Getattr(n, "storage"), "virtual") == 0 - && Cmp(Getattr(n, "value"), "0") == 0); + bool is_pure_virtual = (Cmp(Getattr(n, "storage"), "virtual") == 0 && Cmp(Getattr(n, "value"), "0") == 0); String *name = Getattr(n, "sym:name"); if (name == NULL) { @@ -3007,8 +2881,7 @@ private: String *cn = exportedName(Getattr(parent, "sym:name")); - String *go_type_name = goCPointerType(Getattr(parent, "classtypeobj"), - true); + String *go_type_name = goCPointerType(Getattr(parent, "classtypeobj"), true); String *director_struct_name = NewString("_swig_Director"); Append(director_struct_name, cn); @@ -3123,8 +2996,7 @@ private: String *upcall_gc_name = buildGoWrapperName(upcall_name, overname); - Printv(f_go_wrappers, "func ", upcall_gc_name, "(", - go_type_name, NULL); + Printv(f_go_wrappers, "func ", upcall_gc_name, "(", go_type_name, NULL); p = parms; for (int i = 0; i < parm_count; ++i) { @@ -3144,16 +3016,14 @@ private: } if (gccgo_flag) { - Printv(f_go_wrappers, " __asm__(\"", go_prefix, "_", upcall_wname, - "\")", NULL); + Printv(f_go_wrappers, " __asm__(\"", go_prefix, "_", upcall_wname, "\")", NULL); } Printv(f_go_wrappers, "\n", NULL); // Define the method on the director class in Go. - Printv(f_go_wrappers, "func (swig_p *", director_struct_name, ") ", - go_with_over_name, "(", NULL); + Printv(f_go_wrappers, "func (swig_p *", director_struct_name, ") ", go_with_over_name, "(", NULL); p = parms; for (int i = 0; i < parm_count; ++i) { @@ -3178,8 +3048,7 @@ private: Printv(f_go_wrappers, " {\n", NULL); - Printv(f_go_wrappers, "\tif swig_g, swig_ok := swig_p.v.(", - interface_name, "); swig_ok {\n", NULL); + Printv(f_go_wrappers, "\tif swig_g, swig_ok := swig_p.v.(", interface_name, "); swig_ok {\n", NULL); Printv(f_go_wrappers, "\t\t", NULL); if (SwigType_type(result) != T_VOID) { Printv(f_go_wrappers, "return ", NULL); @@ -3230,9 +3099,7 @@ private: if (overname != NULL) { Append(upcall_method_name, overname); } - String *upcall_decl = Swig_method_decl(Getattr(n, "type"), - Getattr(n, "decl"), - upcall_method_name, parms, 0, 0); + String *upcall_decl = Swig_method_decl(Getattr(n, "type"), Getattr(n, "decl"), upcall_method_name, parms, 0, 0); Printv(f_c_directors_h, " ", upcall_decl, " {\n", NULL); Delete(upcall_decl); @@ -3240,8 +3107,7 @@ private: if (SwigType_type(result) != T_VOID) { Printv(f_c_directors_h, "return ", NULL); } - Printv(f_c_directors_h, Getattr(parent, "classtype"), "::", - Getattr(n, "name"), "(", NULL); + Printv(f_c_directors_h, Getattr(parent, "classtype"), "::", Getattr(n, "name"), "(", NULL); p = parms; for (int i = 0; i < parm_count; ++i) { @@ -3282,8 +3148,7 @@ private: Printv(action, "&", NULL); } } - Printv(action, Swig_cparm_name(NULL, 0), "->", upcall_method_name, "(", - NULL); + Printv(action, Swig_cparm_name(NULL, 0), "->", upcall_method_name, "(", NULL); p = parms; for (int i = 0; i < parm_count; ++i) { @@ -3309,9 +3174,7 @@ private: if (!gccgo_flag) { // Write the upcall wrapper function. This is compiled by gc // and calls the C++ function. - int r = gcFunctionWrapper(n, upcall_name, upcall_name, - overname, upcall_wname, first_parm, result, - is_static, true); + int r = gcFunctionWrapper(n, upcall_name, upcall_name, overname, upcall_wname, first_parm, result, is_static, true); if (r != SWIG_OK) { return r; } @@ -3338,8 +3201,7 @@ private: // Define a function which uses the Go director type that other // methods in the Go type can call to get parent methods. - Printv(f_go_wrappers, "func Director", cn, go_with_over_name, "(p ", cn, - NULL); + Printv(f_go_wrappers, "func Director", cn, go_with_over_name, "(p ", cn, NULL); p = parms; for (int i = 0; i < parm_count; ++i) { @@ -3365,8 +3227,7 @@ private: if (SwigType_type(result) != T_VOID) { Printv(f_go_wrappers, "return ", NULL); } - Printv(f_go_wrappers, upcall_gc_name, "(p.(*", - director_struct_name, ").", go_type_name, NULL); + Printv(f_go_wrappers, upcall_gc_name, "(p.(*", director_struct_name, ").", go_type_name, NULL); p = parms; for (int i = 0; i < parm_count; ++i) { @@ -3385,8 +3246,7 @@ private: // The Go function which invokes the method. This is called // from by the C++ method on the director class. - Printv(f_go_wrappers, "func ", callback_name, "(p *", - director_struct_name, NULL); + Printv(f_go_wrappers, "func ", callback_name, "(p *", director_struct_name, NULL); p = parms; for (int i = 0; i < parm_count; ++i) { @@ -3466,12 +3326,11 @@ private: } // Build the C++ functions. - + Delete(upcall_wname); if (!gccgo_flag) { - Printv(f_c_directors, "extern \"C\" void ", callback_wname, - "(void*, int);\n", NULL); + Printv(f_c_directors, "extern \"C\" void ", callback_wname, "(void*, int);\n", NULL); } else { Printv(f_c_directors, "extern \"C\" ", NULL); @@ -3502,8 +3361,7 @@ private: Delete(fnname); - Printv(f_c_directors, " __asm__(\"", go_prefix, ".", package, ".", - callback_name, "\");\n", NULL); + Printv(f_c_directors, " __asm__(\"", go_prefix, ".", package, ".", callback_name, "\");\n", NULL); } Delete(upcall_method_name); @@ -3513,18 +3371,13 @@ private: if (!is_ignored || is_pure_virtual) { // Declare the method for the director class. - SwigType *rtype = (Getattr(n, "conversion_operator") - ? NULL - : Getattr(n, "type")); - String *decl = Swig_method_decl(rtype, Getattr(n, "decl"), - Getattr(n, "name"), parms, - 0, 0); + SwigType *rtype = (Getattr(n, "conversion_operator") ? NULL : Getattr(n, "type")); + String *decl = Swig_method_decl(rtype, Getattr(n, "decl"), Getattr(n, "name"), parms, 0, 0); Printv(f_c_directors_h, " virtual ", decl, NULL); Delete(decl); String *qname = NewString(""); - Printv(qname, "SwigDirector_", class_name, "::", Getattr(n, "name"), - NULL); + Printv(qname, "SwigDirector_", class_name, "::", Getattr(n, "name"), NULL); decl = Swig_method_decl(rtype, Getattr(n, "decl"), qname, parms, 0, 0); Printv(f->def, decl, NULL); Delete(decl); @@ -3542,8 +3395,7 @@ private: Printv(f->def, " {\n", NULL); if (SwigType_type(result) != T_VOID) { - Wrapper_add_local(f, "c_result", - SwigType_lstr(Getattr(n, "returntype"), "c_result")); + Wrapper_add_local(f, "c_result", SwigType_lstr(Getattr(n, "returntype"), "c_result")); } if (!is_ignored) { @@ -3582,9 +3434,7 @@ private: String *tm = Getattr(p, "tmap:directorin"); if (tm == NULL) { Swig_warning(WARN_TYPEMAP_DIRECTORIN_UNDEF, input_file, - line_number, - "Unable to use type %s as director method argument\n", - SwigType_str(Getattr(p, "type"), 0)); + line_number, "Unable to use type %s as director method argument\n", SwigType_str(Getattr(p, "type"), 0)); } else { String *ln = Getattr(p, "lname"); String *input = NewString(""); @@ -3597,8 +3447,7 @@ private: p = Getattr(p, "tmap:directorin:next"); } - Printv(f->code, " crosscall2(", callback_wname, - ", &swig_a, (int) sizeof swig_a);\n", NULL); + Printv(f->code, " crosscall2(", callback_wname, ", &swig_a, (int) sizeof swig_a);\n", NULL); if (SwigType_type(result) != T_VOID) { String *rname = NewString("c_result"); @@ -3606,14 +3455,12 @@ private: String *tm = Swig_typemap_lookup("directorout", rp, rname, NULL); if (tm == NULL) { Swig_warning(WARN_TYPEMAP_DIRECTOROUT_UNDEF, input_file, line_number, - "Unable to use type %s as director method result\n", - SwigType_str(result, 0)); + "Unable to use type %s as director method result\n", SwigType_str(result, 0)); } else { Replaceall(tm, "$input", "swig_a.result"); Replaceall(tm, "$result", "c_result"); Printv(f->code, " ", tm, "\n", NULL); - String *retstr = SwigType_rcaststr(Getattr(n, "returntype"), - "c_result"); + String *retstr = SwigType_rcaststr(Getattr(n, "returntype"), "c_result"); Printv(f->code, " return ", retstr, ";\n", NULL); Delete(retstr); Delete(tm); @@ -3623,15 +3470,12 @@ private: } // The C wrapper code which calls the Go function. - Printv(f_gc_wrappers, "#pragma dynexport ", callback_wname, " ", - callback_wname, "\n", NULL); - Printv(f_gc_wrappers, "extern void \xc2\xb7", callback_name, "();\n", - NULL); + Printv(f_gc_wrappers, "#pragma dynexport ", callback_wname, " ", callback_wname, "\n", NULL); + Printv(f_gc_wrappers, "extern void \xc2\xb7", callback_name, "();\n", NULL); Printv(f_gc_wrappers, "void\n", NULL); Printv(f_gc_wrappers, callback_wname, "(void *a, int32 n)\n", NULL); Printv(f_gc_wrappers, "{\n", NULL); - Printv(f_gc_wrappers, "\tcgocallback(\xc2\xb7", callback_name, - ", a, n);\n", NULL); + Printv(f_gc_wrappers, "\tcgocallback(\xc2\xb7", callback_name, ", a, n);\n", NULL); Printv(f_gc_wrappers, "}\n\n", NULL); } else { if (SwigType_type(result) != T_VOID) { @@ -3661,9 +3505,7 @@ private: tm = Getattr(p, "tmap:directorin"); if (tm == NULL) { Swig_warning(WARN_TYPEMAP_DIRECTORIN_UNDEF, input_file, - line_number, - "Unable to use type %s as director method argument\n", - SwigType_str(Getattr(p, "type"), 0)); + line_number, "Unable to use type %s as director method argument\n", SwigType_str(Getattr(p, "type"), 0)); } else { Replaceall(tm, "$input", pn); Replaceall(tm, "$owner", 0); @@ -3687,14 +3529,12 @@ private: String *tm = Swig_typemap_lookup("directorout", rp, rname, NULL); if (tm == NULL) { Swig_warning(WARN_TYPEMAP_DIRECTOROUT_UNDEF, input_file, line_number, - "Unable to use type %s as director method result\n", - SwigType_str(result, 0)); + "Unable to use type %s as director method result\n", SwigType_str(result, 0)); } else { Replaceall(tm, "$input", "result"); Replaceall(tm, "$result", "c_result"); Printv(f->code, " ", tm, "\n", NULL); - String *retstr = SwigType_rcaststr(Getattr(n, "returntype"), - "c_result"); + String *retstr = SwigType_rcaststr(Getattr(n, "returntype"), "c_result"); Printv(f->code, " return ", retstr, ";\n", NULL); Delete(retstr); Delete(tm); @@ -3705,11 +3545,9 @@ private: } } else { assert(is_pure_virtual); - Printv(f->code, " _swig_gopanic(\"call to pure virtual function ", - Getattr(parent, "sym:name"), name, "\");\n"); + Printv(f->code, " _swig_gopanic(\"call to pure virtual function ", Getattr(parent, "sym:name"), name, "\");\n"); if (SwigType_type(result) != T_VOID) { - String *retstr = SwigType_rcaststr(Getattr(n, "returntype"), - "c_result"); + String *retstr = SwigType_rcaststr(Getattr(n, "returntype"), "c_result"); Printv(f->code, " return ", retstr, ";\n", NULL); Delete(retstr); } @@ -3819,27 +3657,18 @@ private: * the type of the first argument to the function. *--------------------------------------------------------------------*/ - int makeDispatchFunction(Node *n, String *go_name, String *receiver, - bool is_static, SwigType *director_struct, - bool is_upcall) { + int makeDispatchFunction(Node *n, String *go_name, String *receiver, bool is_static, SwigType *director_struct, bool is_upcall) { bool is_director = director_struct != NULL; String *nodetype = Getattr(n, "nodeType"); bool is_constructor = Cmp(nodetype, "constructor") == 0; bool is_destructor = Cmp(nodetype, "destructor") == 0; - bool can_use_receiver = (!is_constructor - && !is_destructor - && !is_upcall); + bool can_use_receiver = (!is_constructor && !is_destructor && !is_upcall); - bool use_receiver = (!is_static - && can_use_receiver); + bool use_receiver = (!is_static && can_use_receiver); - bool add_to_interface = (interfaces != NULL - && !is_constructor - && !is_destructor - && !is_static - && !is_upcall); + bool add_to_interface = (interfaces != NULL && !is_constructor && !is_destructor && !is_static && !is_upcall); List *dispatch = Swig_overload_rank(n, false); int nfunc = Len(dispatch); @@ -3963,8 +3792,7 @@ private: if (num_required == num_arguments) { Printf(f_go_wrappers, "\tif argc == %d {\n", num_required); } else { - Printf(f_go_wrappers, "\tif argc >= %d && argc <= %d {\n", - num_required, num_arguments); + Printf(f_go_wrappers, "\tif argc >= %d && argc <= %d {\n", num_required, num_arguments); } } @@ -4070,10 +3898,7 @@ private: result = NULL; } - if (result != NULL - && SwigType_type(result) != T_VOID - && (all_result == NULL - || SwigType_type(all_result) != T_VOID)) { + if (result != NULL && SwigType_type(result) != T_VOID && (all_result == NULL || SwigType_type(all_result) != T_VOID)) { Printv(start, "return ", NULL); } @@ -4081,16 +3906,12 @@ private: if (receiver != NULL && use_receiver) { Printv(start, "p.", go_name, NULL); - } else if (can_use_receiver - && !isStatic(ni) - && pi != NULL - && Getattr(pi, "self") != NULL) { + } else if (can_use_receiver && !isStatic(ni) && pi != NULL && Getattr(pi, "self") != NULL) { // This is an overload of a static function and a non-static // function. assert(num_required > 0); SwigType *tm = goWrapperType(pi, Getattr(pi, "type"), true); - String *nm = buildGoName(Getattr(ni, "sym:name"), false, - isFriend(ni)); + String *nm = buildGoName(Getattr(ni, "sym:name"), false, isFriend(ni)); Printv(start, "a[0].(", tm, ").", nm, NULL); Delete(nm); Delete(tm); @@ -4137,9 +3958,7 @@ private: } String *end = NULL; - if (result == NULL - || SwigType_type(result) == T_VOID - || (all_result != NULL && SwigType_type(all_result) == T_VOID)) { + if (result == NULL || SwigType_type(result) == T_VOID || (all_result != NULL && SwigType_type(all_result) == T_VOID)) { end = NewString(""); Printv(end, "return", NULL); if (all_result == NULL || SwigType_type(all_result) != T_VOID) { @@ -4183,8 +4002,7 @@ private: } Printv(f_go_wrappers, "fail:\n", NULL); - Printv(f_go_wrappers, - "\tpanic(\"No match for overloaded function call\")\n", NULL); + Printv(f_go_wrappers, "\tpanic(\"No match for overloaded function call\")\n", NULL); Printv(f_go_wrappers, "}\n\n", NULL); if (all_result != NULL) { @@ -4244,8 +4062,7 @@ private: String *copy = Copy(name); if (class_name != NULL) { char *p = Char(name); - if (Strncmp(name, class_name, Len(class_name)) == 0 - && p[Len(class_name)] == '_') { + if (Strncmp(name, class_name, Len(class_name)) == 0 && p[Len(class_name)] == '_') { Replace(copy, class_name, "", DOH_REPLACE_FIRST); Replace(copy, "_", "", DOH_REPLACE_FIRST); } @@ -4475,9 +4292,7 @@ private: Delete(t); if (ret == NULL) { - Swig_warning(WARN_LANG_NATIVE_UNIMPL, input_file, line_number, - "No Go typemap defined for %s\n", - SwigType_str(type, 0)); + Swig_warning(WARN_LANG_NATIVE_UNIMPL, input_file, line_number, "No Go typemap defined for %s\n", SwigType_str(type, 0)); ret = NewString("uintptr"); } @@ -4662,13 +4477,13 @@ private: return gcCTypeForGoValue(n, type, name); } - /* ------------------------------------------------------------ + /* ---------------------------------------------------------------------- * goTypeIsInterface * * Return whether this C++ type is represented as an interface type * in Go. These types require adjustments in the Go code when * passing them back and forth between Go and C++. - * ------------------------------------------------------------ */ + * ---------------------------------------------------------------------- */ bool goTypeIsInterface(Node *n, SwigType *type) { bool is_interface; @@ -4676,11 +4491,11 @@ private: return is_interface; } - /* ------------------------------------------------------------ + /* ---------------------------------------------------------------------- * hasGoTypemap * * Return whether a type has a "go" typemap entry. - * ------------------------------------------------------------ */ + * ---------------------------------------------------------------------- */ bool hasGoTypemap(SwigType *type) { Parm *p = NewParmWithoutFileLineInfo(type, "test"); @@ -4699,8 +4514,7 @@ private: /* ---------------------------------------------------------------------- * goEnumName() * - * Given an enum node, return a string to use for the enum type in - * Go. + * Given an enum node, return a string to use for the enum type in Go. * ---------------------------------------------------------------------- */ String *goEnumName(Node *n) { @@ -4739,11 +4553,11 @@ private: } - /* ------------------------------------------------------------ + /* ---------------------------------------------------------------------- * getParm() * * Get the real parameter to use. - * ------------------------------------------------------------ */ + * ---------------------------------------------------------------------- */ Parm *getParm(Parm *p) { while (p != NULL && checkAttribute(p, "tmap:in:numinputs", "0")) { @@ -4752,11 +4566,11 @@ private: return p; } - /* ------------------------------------------------------------ + /* ---------------------------------------------------------------------- * nextParm() * * Return the next parameter. - * ------------------------------------------------------------ */ + * ---------------------------------------------------------------------- */ Parm *nextParm(Parm *p) { if (p == NULL) { @@ -4768,27 +4582,24 @@ private: } } - /* ------------------------------------------------------------ + /* ---------------------------------------------------------------------- * isStatic * * Return whether a node should be considered as static rather than * as a member. - * ------------------------------------------------------------ */ + * ---------------------------------------------------------------------- */ bool isStatic(Node *n) { String *storage = Getattr(n, "storage"); - return (storage != NULL - && (Strcmp(storage, "static") == 0 - || Strcmp(storage, "friend") == 0) - && (!SmartPointer - || Getattr(n, "allocate:smartpointeraccess") == NULL)); + return (storage != NULL && (Strcmp(storage, "static") == 0 || Strcmp(storage, "friend") == 0) + && (!SmartPointer || Getattr(n, "allocate:smartpointeraccess") == NULL)); } - /* ------------------------------------------------------------ + /* ---------------------------------------------------------------------- * isFriend * * Return whether a node is a friend. - * ------------------------------------------------------------ */ + * ---------------------------------------------------------------------- */ bool isFriend(Node *n) { String *storage = Getattr(n, "storage"); From 5408fe8f00b7fde3464e4497ebbf7c7c219b134e Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 11 Jun 2010 19:03:53 +0000 Subject: [PATCH 0931/1680] minor typo fixes git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12119 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Go.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/Manual/Go.html b/Doc/Manual/Go.html index f6e87afb4..8d106858b 100644 --- a/Doc/Manual/Go.html +++ b/Doc/Manual/Go.html @@ -71,7 +71,7 @@ borne in mind when reading the rest of the SWIG documentation.

      To generate Go code, use the -go option with SWIG. By default SWIG will generate code for the gc compilers. To generate -code for gccgo, you should use the -gccgo option. +code for gccgo, you should also use the -gccgo option.

      20.2.1 Additional Commandline Options

      @@ -151,7 +151,7 @@ may be helpful to include it in your code, compiled with the usual C or C++ compiler.
    • If using the gc compiler, MODULE_gc.c will contain C code which should -be compiled with the C compiler which part of the gc compiler: 6c, 8c, +be compiled with the C compiler distributed as part of the gc compiler: 6c, 8c, or 5c. It should then be combined with the compiled MODULE.go using gopack. This file will not be generated when using gccgo. From 7e7bd74ff21412d37a694e77458e6d3db074d880 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 11 Jun 2010 19:05:30 +0000 Subject: [PATCH 0932/1680] Remove Go director hack just to please the SWIG test-suite git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12120 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/director_extend.i | 5 ++++- Lib/go/goruntime.swg | 10 ---------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/Examples/test-suite/director_extend.i b/Examples/test-suite/director_extend.i index 515866ac6..cec930a42 100644 --- a/Examples/test-suite/director_extend.i +++ b/Examples/test-suite/director_extend.i @@ -18,6 +18,8 @@ namespace Swig { #endif %} +// Some director implementations do not have Swig::director +#if !defined(SWIGGO) %extend SpObject { size_t ExceptionMethod() @@ -29,7 +31,8 @@ namespace Swig { size_t size = sizeof(Swig::Director); return size; } -}; +} +#endif %inline %{ diff --git a/Lib/go/goruntime.swg b/Lib/go/goruntime.swg index 5a51fd4b6..246814818 100644 --- a/Lib/go/goruntime.swg +++ b/Lib/go/goruntime.swg @@ -196,13 +196,3 @@ void __go_panic_msg(const char *); if (!(expr)) { _swig_gopanic(msg); } else %} -#ifdef __cplusplus -/* We don't need a Swig::Director class, but the Swig testsuite - expects one. */ -%insert(runtime) %{ -namespace Swig { - typedef int Director; -} -%} - -#endif From 688db4ee295fe9f941f709005e9be07ca4cf8ef0 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 11 Jun 2010 22:36:58 +0000 Subject: [PATCH 0933/1680] Fix std::map warning keyword hack in Go git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12121 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/li_std_map.i | 9 +++++++++ Lib/go/gokw.swg | 4 +++- Lib/go/std_map.i | 4 ---- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Examples/test-suite/li_std_map.i b/Examples/test-suite/li_std_map.i index d5929d786..bf24c35e1 100644 --- a/Examples/test-suite/li_std_map.i +++ b/Examples/test-suite/li_std_map.i @@ -1,6 +1,15 @@ %module("templatereduce") li_std_map %feature("trackobjects"); +%inline %{ +namespace another { +struct map { + int val; + map(int x) : val(x) {} +}; +} +%} + %include "std_pair.i" %include "std_map.i" %include "std_string.i" diff --git a/Lib/go/gokw.swg b/Lib/go/gokw.swg index e7506d053..dd9f35aa3 100644 --- a/Lib/go/gokw.swg +++ b/Lib/go/gokw.swg @@ -1,6 +1,7 @@ /* Rename keywords. */ #define GOKW(x) %keywordwarn("'" `x` "' is a Go keyword, renaming to 'X"`x`"'",rename="X%s") `x` +#define GOBN(x) %builtinwarn("'" `x` "' conflicts with a built-in name in Go") "::"`x` GOKW(break); GOKW(case); @@ -18,7 +19,6 @@ GOKW(goto); GOKW(if); GOKW(import); GOKW(interface); -GOKW(map); GOKW(package); GOKW(range); GOKW(return); @@ -28,4 +28,6 @@ GOKW(switch); GOKW(type); GOKW(var); +GOBN(map); + #undef GOKW diff --git a/Lib/go/std_map.i b/Lib/go/std_map.i index e37a9e676..84b0c74ff 100644 --- a/Lib/go/std_map.i +++ b/Lib/go/std_map.i @@ -10,11 +10,7 @@ // std::map // ------------------------------------------------------------------------ -// "map" is a keyword in Go. -#define map cmap - %{ -#define map cmap #include #include #include From 8bf4b5a7dc180d254bfe0071954fc4d2df0140b2 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 14 Jun 2010 18:33:57 +0000 Subject: [PATCH 0934/1680] Minor comment fix git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12122 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/go.cxx | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Source/Modules/go.cxx b/Source/Modules/go.cxx index cb6e3ad5a..45f6ef1da 100644 --- a/Source/Modules/go.cxx +++ b/Source/Modules/go.cxx @@ -684,16 +684,16 @@ private: * makeWrappers() * * Write out the various function wrappers. - * N: The function we are emitting. - * NAME: The function name. - * GO_NAME: The name of the function in Go. - * OVERNAME: The overload string for overloaded function. - * WNAME: The SWIG wrapped name--the name of the C function. - * BASE: A list of the names of base classes, in the case where this + * n: The function we are emitting. + * name: The function name. + * go_name: The name of the function in Go. + * overname: The overload string for overloaded function. + * wname: The SWIG wrapped name--the name of the C function. + * base: A list of the names of base classes, in the case where this * is is a vritual method not defined in the current class. - * PARMS: The parameters. - * RESULT: The result type. - * IS_STATIC: Whether this is a static method or member. + * parms: The parameters. + * result: The result type. + * is_static: Whether this is a static method or member. * ---------------------------------------------------------------------- */ int makeWrappers(Node *n, String *name, String *go_name, String *overname, String *wname, List *base, ParmList *parms, SwigType *result, bool is_static) { From 96d86b0fec03e4e520f0a986058f9f72cb845dd3 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 14 Jun 2010 19:08:11 +0000 Subject: [PATCH 0935/1680] Fix 'make partialcheck' for go git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12123 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/go/Makefile.in | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Examples/test-suite/go/Makefile.in b/Examples/test-suite/go/Makefile.in index 4af612799..6126e77ee 100644 --- a/Examples/test-suite/go/Makefile.in +++ b/Examples/test-suite/go/Makefile.in @@ -69,25 +69,25 @@ multi_import.multicpptest: # Runs the testcase. run_testcase = \ if test -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); then \ - $(GO) -I . $(GOCOMPILEARG) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \ + $(COMPILETOOL) $(GO) -I . $(GOCOMPILEARG) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \ if $(GOGCC) ; then \ - $(GO) -o $*_runme $(SCRIPTPREFIX)$*_runme.@OBJEXT@ $*.@OBJEXT@ $*$(SO); \ + $(COMPILETOOL) $(GO) -o $*_runme $(SCRIPTPREFIX)$*_runme.@OBJEXT@ $*.@OBJEXT@ $*$(SO); \ else \ - $(GOLD) -L . -r $${GOROOT}/pkg/$${GOOS}_$${GOARCH}:. -o $*_runme $(SCRIPTPREFIX)$*_runme.$(GOOBJEXT); \ + $(COMPILETOOL) $(GOLD) -L . -r $${GOROOT}/pkg/$${GOOS}_$${GOARCH}:. -o $*_runme $(SCRIPTPREFIX)$*_runme.$(GOOBJEXT); \ fi && \ - env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH ./$*_runme; \ + env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) ./$*_runme; \ fi run_multi_testcase = \ if test -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); then \ - $(GO) -I . $(GOCOMPILEARG) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \ + $(COMPILETOOL) $(GO) -I . $(GOCOMPILEARG) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \ if $(GOGCC) ; then \ files=`cat $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list`; \ - $(GO) -o $*_runme $(SCRIPTPREFIX)$*_runme.@OBJEXT@ `for f in $$files; do echo $$f.@OBJEXT@ $$f$(SO); done`; \ + $(COMPILETOOL) $(GO) -o $*_runme $(SCRIPTPREFIX)$*_runme.@OBJEXT@ `for f in $$files; do echo $$f.@OBJEXT@ $$f$(SO); done`; \ else \ - $(GOLD) -L . -r $${GOROOT}/pkg/$${GOOS}_$${GOARCH}:. -o $*_runme $(SCRIPTPREFIX)$*_runme.$(GOOBJEXT); \ + $(COMPILETOOL) $(GOLD) -L . -r $${GOROOT}/pkg/$${GOOS}_$${GOARCH}:. -o $*_runme $(SCRIPTPREFIX)$*_runme.$(GOOBJEXT); \ fi && \ - env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH ./$*_runme; \ + env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) ./$*_runme; \ fi %.clean: From 07e3d62ae85e20572d0260a71db43e3dbd49647a Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Tue, 15 Jun 2010 17:58:42 +0000 Subject: [PATCH 0936/1680] Use a single extern "C" around all the wrappers, not one per wrapper. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12126 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/go.cxx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Source/Modules/go.cxx b/Source/Modules/go.cxx index 45f6ef1da..e958a0a7f 100644 --- a/Source/Modules/go.cxx +++ b/Source/Modules/go.cxx @@ -385,6 +385,10 @@ private: Printf(f_go_begin, "\npackage %s\n\n", package); + // All the C++ wrappers should be extern "C". + + Printv(f_c_wrappers, "#ifdef __cplusplus\n", "extern \"C\" {\n", "#endif\n\n", NULL); + // Set up the hash table for types not defined by SWIG. undefined_types = NewHash(); @@ -433,6 +437,9 @@ private: f_c_directors = NULL; } + // End the extern "C". + Printv(f_c_wrappers, "#ifdef __cplusplus\n", "}\n", "#endif\n\n", NULL); + Dump(f_c_runtime, f_c_begin); Dump(f_c_wrappers, f_c_begin); Dump(f_c_init, f_c_begin); @@ -1149,8 +1156,6 @@ private: // Start the function definition. - Printv(f->def, "#ifdef __cplusplus\n", "extern \"C\"\n", "#endif\n", NULL); - Printv(f->def, "void\n", wname, "(void *swig_v)\n", "{\n", NULL); // The single function parameter is a pointer to the real argument @@ -1269,8 +1274,6 @@ private: // Start the function definition. - Printv(f->def, "#ifdef __cplusplus\n", "extern \"C\"\n", "#endif\n", NULL); - String *fnname = NewString(""); Printv(fnname, go_prefix, "_", wname, "(", NULL); From 9d466dd4088ddf256ba689e46325d55ce63d5466 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Tue, 15 Jun 2010 17:59:32 +0000 Subject: [PATCH 0937/1680] Rename size checking macros to avoid leading double underscore. Also change goswig to swiggo. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12127 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/go/goruntime.swg | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Lib/go/goruntime.swg b/Lib/go/goruntime.swg index 246814818..057f81d01 100644 --- a/Lib/go/goruntime.swg +++ b/Lib/go/goruntime.swg @@ -19,16 +19,16 @@ typedef struct { void* array; unsigned int len; unsigned int cap; } _goslice_; with gcc. */ %insert(runtime) %{ -#define __goswig_size_assert_eq(x, y, name) typedef char name[(x-y)*(x-y)*-2+1]; -#define __goswig_size_assert(t, n) __goswig_size_assert_eq(sizeof(t), n, _goswig_sizeof_##t##_is_not_##n) +#define swiggo_size_assert_eq(x, y, name) typedef char name[(x-y)*(x-y)*-2+1]; +#define swiggo_size_assert(t, n) swiggo_size_assert_eq(sizeof(t), n, swiggo_sizeof_##t##_is_not_##n) -__goswig_size_assert(char, 1) -__goswig_size_assert(short, 2) -__goswig_size_assert(int, 4) -typedef long long __goswig_long_long; -__goswig_size_assert(__goswig_long_long, 8) -__goswig_size_assert(float, 4) -__goswig_size_assert(double, 8) +swiggo_size_assert(char, 1) +swiggo_size_assert(short, 2) +swiggo_size_assert(int, 4) +typedef long long swiggo_long_long; +swiggo_size_assert(swiggo_long_long, 8) +swiggo_size_assert(float, 4) +swiggo_size_assert(double, 8) extern #ifdef __cplusplus From 0d80b4011db6bd3facf1dba1ebec9dfc940e9978 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Tue, 15 Jun 2010 18:06:18 +0000 Subject: [PATCH 0938/1680] Add run test for li_std_vector_ptr. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12128 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/go/li_std_vector_ptr_runme.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 Examples/test-suite/go/li_std_vector_ptr_runme.go diff --git a/Examples/test-suite/go/li_std_vector_ptr_runme.go b/Examples/test-suite/go/li_std_vector_ptr_runme.go new file mode 100644 index 000000000..cee997ad0 --- /dev/null +++ b/Examples/test-suite/go/li_std_vector_ptr_runme.go @@ -0,0 +1,12 @@ +package main + +import . "./li_std_vector_ptr" + +func main() { + ip1 := MakeIntPtr(11) + ip2 := MakeIntPtr(22) + vi := NewIntPtrVector() + vi.Add(ip1) + vi.Add(ip2) + DisplayVector(vi) +} From da5e02f81c9f04ca66b54fa6a0608fd7c8ef3b51 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Tue, 15 Jun 2010 19:40:34 +0000 Subject: [PATCH 0939/1680] Rename "go" typemap to "gotype". git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12129 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Go.html | 2 +- Examples/go/multimap/example.i | 6 +-- Examples/test-suite/namespace_typemap.i | 4 +- Examples/test-suite/typemap_namespace.i | 2 +- Lib/go/cdata.i | 2 +- Lib/go/go.swg | 60 ++++++++++++------------- Lib/go/std_string.i | 2 +- Lib/go/typemaps.i | 6 +-- Source/Modules/go.cxx | 16 +++---- 9 files changed, 50 insertions(+), 50 deletions(-) diff --git a/Doc/Manual/Go.html b/Doc/Manual/Go.html index 8d106858b..1082a8f66 100644 --- a/Doc/Manual/Go.html +++ b/Doc/Manual/Go.html @@ -454,7 +454,7 @@ value.

      -These type mappings are defined by the "go" typemap. You may change +These type mappings are defined by the "gotype" typemap. You may change that typemap, or add new values, to control how C/C++ types are mapped into Go types.

      diff --git a/Examples/go/multimap/example.i b/Examples/go/multimap/example.i index 04d6eea20..8de6b0dc3 100644 --- a/Examples/go/multimap/example.i +++ b/Examples/go/multimap/example.i @@ -12,7 +12,7 @@ extern int squareCubed (int n, int *OUTPUT); extern int gcd(int x, int y); -%typemap(go) (int argc, char *argv[]) "[]string" +%typemap(gotype) (int argc, char *argv[]) "[]string" %typemap(in) (int argc, char *argv[]) %{ @@ -40,7 +40,7 @@ extern int gcd(int x, int y); extern int gcdmain(int argc, char *argv[]); -%typemap(go) (char *bytes, int len) "string" +%typemap(gotype) (char *bytes, int len) "string" %typemap(in) (char *bytes, int len) %{ @@ -55,7 +55,7 @@ extern int count(char *bytes, int len, char c); * modified. */ -%typemap(go) (char *str, int len) "[]string" +%typemap(gotype) (char *str, int len) "[]string" %typemap(in) (char *str, int len) %{ diff --git a/Examples/test-suite/namespace_typemap.i b/Examples/test-suite/namespace_typemap.i index 4952aa7ad..f25f88574 100644 --- a/Examples/test-suite/namespace_typemap.i +++ b/Examples/test-suite/namespace_typemap.i @@ -71,7 +71,7 @@ namespace test { } #endif #ifdef SWIGGO -%typemap(go) test::test_complex * "complex128" +%typemap(gotype) test::test_complex * "complex128" %typemap(in) test::test_complex * { $1 = new test_complex(__real__ $input, __imag__ $input); } @@ -107,7 +107,7 @@ namespace test { } #endif #ifdef SWIGGO - %typemap(go) string_class * "string" + %typemap(gotype) string_class * "string" %typemap(in) string_class * { $1 = new string_class($input.p); } diff --git a/Examples/test-suite/typemap_namespace.i b/Examples/test-suite/typemap_namespace.i index 6bf53e989..6614e0372 100644 --- a/Examples/test-suite/typemap_namespace.i +++ b/Examples/test-suite/typemap_namespace.i @@ -27,7 +27,7 @@ namespace Foo { %typemap(javaout) Str1 * = char *; #endif #ifdef SWIGGO - %typemap(go) Str1 * = char *; + %typemap(gotype) Str1 * = char *; #endif %typemap(in) Str1 * = char *; #if !(defined(SWIGCSHARP) || defined(SWIGLUA) || defined(SWIGPHP) || defined(SWIGMZSCHEME) || defined(SWIGOCAML) || defined(SWIGGO)) diff --git a/Lib/go/cdata.i b/Lib/go/cdata.i index c3307945a..decf297c1 100644 --- a/Lib/go/cdata.i +++ b/Lib/go/cdata.i @@ -11,7 +11,7 @@ typedef struct SWIGCDATA { } SWIGCDATA; %} -%typemap(go) SWIGCDATA %{ []byte %} +%typemap(gotype) SWIGCDATA %{ []byte %} %typemap(out) SWIGCDATA (swigcdata argp) { argp = _swig_makegobyteslice($1.data, $1.len); $result.data = (char*)argp.data; diff --git a/Lib/go/go.swg b/Lib/go/go.swg index b1b8860df..648e112e1 100644 --- a/Lib/go/go.swg +++ b/Lib/go/go.swg @@ -6,27 +6,27 @@ /* Basic types */ -%typemap(go) bool, const bool & "bool" -%typemap(go) char, const char & "byte" -%typemap(go) signed char, const signed char & "int8" -%typemap(go) unsigned char, const unsigned char & "byte" -%typemap(go) short, const short & "int16" -%typemap(go) unsigned short, const unsigned short & "uint16" -%typemap(go) int, const int & "int" -%typemap(go) unsigned int, const unsigned int & "uint" +%typemap(gotype) bool, const bool & "bool" +%typemap(gotype) char, const char & "byte" +%typemap(gotype) signed char, const signed char & "int8" +%typemap(gotype) unsigned char, const unsigned char & "byte" +%typemap(gotype) short, const short & "int16" +%typemap(gotype) unsigned short, const unsigned short & "uint16" +%typemap(gotype) int, const int & "int" +%typemap(gotype) unsigned int, const unsigned int & "uint" #if SWIGGO_LONG_TYPE_SIZE == 32 -%typemap(go) long, const long & "int32" -%typemap(go) unsigned long, const unsigned long & "uint32" +%typemap(gotype) long, const long & "int32" +%typemap(gotype) unsigned long, const unsigned long & "uint32" #elif SWIGGO_LONG_TYPE_SIZE == 64 -%typemap(go) long, const long & "int64" -%typemap(go) unsigned long, const unsigned long & "uint64" +%typemap(gotype) long, const long & "int64" +%typemap(gotype) unsigned long, const unsigned long & "uint64" #else #error "SWIGGO_LONG_TYPE_SIZE not 32 or 64" #endif -%typemap(go) long long, const long long & "int64" -%typemap(go) unsigned long long, const unsigned long long & "uint64" -%typemap(go) float, const float & "float32" -%typemap(go) double, const double & "float64" +%typemap(gotype) long long, const long long & "int64" +%typemap(gotype) unsigned long long, const unsigned long long & "uint64" +%typemap(gotype) float, const float & "float32" +%typemap(gotype) double, const double & "float64" %typemap(in) bool, char, @@ -164,9 +164,9 @@ /* The size_t type. */ #if SWIGGO_LONG_TYPE_SIZE == 32 -%typemap(go) size_t, const size_t & %{int%} +%typemap(gotype) size_t, const size_t & %{int%} #else -%typemap(go) size_t, const size_t & %{int64%} +%typemap(gotype) size_t, const size_t & %{int64%} #endif %typemap(in) size_t @@ -198,7 +198,7 @@ /* Member pointers. */ -%typemap(go) SWIGTYPE (CLASS::*) +%typemap(gotype) SWIGTYPE (CLASS::*) %{$gotypename%} %typemap(in) SWIGTYPE (CLASS::*) @@ -223,7 +223,7 @@ /* We can't translate pointers using a typemap, so that is handled in the C++ code. */ -%typemap(go) SWIGTYPE * +%typemap(gotype) SWIGTYPE * %{$gotypename%} %typemap(in) SWIGTYPE * @@ -242,7 +242,7 @@ /* Pointer references. */ -%typemap(go) SWIGTYPE *const& +%typemap(gotype) SWIGTYPE *const& %{$gotypename%} %typemap(in) SWIGTYPE *const& ($*1_ltype temp = 0) @@ -266,7 +266,7 @@ type _swig_memberptr *byte /* Converting a C++ reference to Go has to be handled in the C++ code. */ -%typemap(go) SWIGTYPE & +%typemap(gotype) SWIGTYPE & %{$gotypename%} %typemap(in) SWIGTYPE & @@ -284,7 +284,7 @@ type _swig_memberptr *byte /* C arrays turn into Go pointers. If we know the length we can use a slice. */ -%typemap(go) SWIGTYPE [] +%typemap(gotype) SWIGTYPE [] %{$gotypename%} %typemap(in) SWIGTYPE [] @@ -301,7 +301,7 @@ type _swig_memberptr *byte /* Strings. */ -%typemap(go) +%typemap(gotype) char *, char *&, char[ANY], char[], signed char *, signed char *&, signed char[ANY], signed char[], unsigned char *, unsigned char *&, unsigned char[ANY], unsigned char[] @@ -309,8 +309,8 @@ type _swig_memberptr *byte /* Needed to avoid confusion with the way the go module handles references. */ -%typemap(go) char&, unsigned char& "*byte" -%typemap(go) signed char& "*int8" +%typemap(gotype) char&, unsigned char& "*byte" +%typemap(gotype) signed char& "*int8" %typemap(in) char *, char[ANY], char[], @@ -341,11 +341,11 @@ type _swig_memberptr *byte unsigned char *, unsigned char *&, unsigned char[ANY], unsigned char[] %{ $result = ($1_ltype)$input.p; %} -/* Enums. We can't do the right thing for enums in typemap(go) so we - deliberately don't define them. The right thing would be to +/* Enums. We can't do the right thing for enums in typemap(gotype) so + we deliberately don't define them. The right thing would be to capitalize the name. This is instead done in go.cxx. */ -%typemap(go) enum SWIGTYPE +%typemap(gotype) enum SWIGTYPE %{$gotypename%} %typemap(in) enum SWIGTYPE @@ -364,7 +364,7 @@ type _swig_memberptr *byte We convert it to a pointer for the Go code. Note that all basic types are explicitly handled above. */ -%typemap(go) SWIGTYPE +%typemap(gotype) SWIGTYPE %{$gotypename%} %typemap(in) SWIGTYPE ($&1_type argp) diff --git a/Lib/go/std_string.i b/Lib/go/std_string.i index 3c94cbe10..fb99ccdcd 100644 --- a/Lib/go/std_string.i +++ b/Lib/go/std_string.i @@ -19,7 +19,7 @@ namespace std { class string; -%typemap(go) string, const string & "string" +%typemap(gotype) string, const string & "string" %typemap(in) string %{ $1.assign($input.p, $input.n); %} diff --git a/Lib/go/typemaps.i b/Lib/go/typemaps.i index 17da80c23..b03daf626 100644 --- a/Lib/go/typemaps.i +++ b/Lib/go/typemaps.i @@ -60,7 +60,7 @@ char * typemaps instead: */ %define INPUT_TYPEMAP(TYPE, GOTYPE) -%typemap(go) TYPE *INPUT, TYPE &INPUT "GOTYPE" +%typemap(gotype) TYPE *INPUT, TYPE &INPUT "GOTYPE" %typemap(in) TYPE *INPUT %{ $1 = ($1_ltype)&$input; %} @@ -163,7 +163,7 @@ char * typemaps instead: */ %define OUTPUT_TYPEMAP(TYPE, GOTYPE) -%typemap(go) TYPE *OUTPUT, TYPE &OUTPUT %{[]GOTYPE%} +%typemap(gotype) TYPE *OUTPUT, TYPE &OUTPUT %{[]GOTYPE%} %typemap(in) TYPE *OUTPUT($*1_ltype temp) { @@ -287,7 +287,7 @@ char * typemaps instead: */ %define INOUT_TYPEMAP(TYPE, GOTYPE) -%typemap(go) TYPE *INOUT, TYPE &INOUT %{[]GOTYPE%} +%typemap(gotype) TYPE *INOUT, TYPE &INOUT %{[]GOTYPE%} %typemap(in) TYPE *INOUT { if ($input.len == 0) { diff --git a/Source/Modules/go.cxx b/Source/Modules/go.cxx index e958a0a7f..29fb245da 100644 --- a/Source/Modules/go.cxx +++ b/Source/Modules/go.cxx @@ -751,7 +751,7 @@ private: Wrapper *dummy = NewWrapper(); emit_attach_parmmaps(parms, dummy); Swig_typemap_attach_parms("default", parms, dummy); - Swig_typemap_attach_parms("go", parms, dummy); + Swig_typemap_attach_parms("gotype", parms, dummy); int parm_count = emit_num_arguments(parms); int required_count = emit_num_required(parms); @@ -2473,7 +2473,7 @@ private: emit_attach_parmmaps(parms, dummy); DelWrapper(dummy); - Swig_typemap_attach_parms("go", parms, NULL); + Swig_typemap_attach_parms("gotype", parms, NULL); int parm_count = emit_num_arguments(parms); String *func_name = NewString("NewDirector"); @@ -2900,7 +2900,7 @@ private: emit_attach_parmmaps(parms, dummy); DelWrapper(dummy); - Swig_typemap_attach_parms("go", parms, NULL); + Swig_typemap_attach_parms("gotype", parms, NULL); int parm_count = emit_num_arguments(parms); SwigType *result = Getattr(n, "returntype"); @@ -4151,14 +4151,14 @@ private: if (n != NULL && Cmp(type, Getattr(n, "type")) == 0) { ret = NULL; if (Strcmp(Getattr(n, "nodeType"), "parm") == 0) { - ret = Getattr(n, "tmap:go"); + ret = Getattr(n, "tmap:gotype"); } if (ret == NULL) { - ret = Swig_typemap_lookup("go", n, "", NULL); + ret = Swig_typemap_lookup("gotype", n, "", NULL); } } else { Parm *p = NewParmWithoutFileLineInfo(type, "goType"); - ret = Swig_typemap_lookup("go", p, "", NULL); + ret = Swig_typemap_lookup("gotype", p, "", NULL); Delete(p); } @@ -4497,12 +4497,12 @@ private: /* ---------------------------------------------------------------------- * hasGoTypemap * - * Return whether a type has a "go" typemap entry. + * Return whether a type has a "gotype" typemap entry. * ---------------------------------------------------------------------- */ bool hasGoTypemap(SwigType *type) { Parm *p = NewParmWithoutFileLineInfo(type, "test"); - SwigType *tm = Swig_typemap_lookup("go", p, "", NULL); + SwigType *tm = Swig_typemap_lookup("gotype", p, "", NULL); Delete(p); if (tm != NULL && Strstr(tm, "$gotypename") == NULL) { Delete(tm); From 814eaab177e4720405adebebbbfdf096b011697c Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Tue, 15 Jun 2010 20:15:11 +0000 Subject: [PATCH 0940/1680] Remove comments about compiling file with gcc. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12130 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/go.cxx | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Source/Modules/go.cxx b/Source/Modules/go.cxx index 29fb245da..f1c7d89c1 100644 --- a/Source/Modules/go.cxx +++ b/Source/Modules/go.cxx @@ -355,9 +355,6 @@ private: } Swig_banner(f_c_begin); - if (!gccgo_flag) { - Printf(f_c_begin, "\n/* This file should be compiled with gcc. */\n"); - } if (renames != NULL) { Printf(f_c_begin, "%s\n", renames); } @@ -366,7 +363,6 @@ private: Printf(f_c_runtime, "#define SWIG_DIRECTORS\n"); Swig_banner(f_c_directors_h); - Printf(f_c_directors_h, "\n/* This file should be compiled with gcc. */\n"); Printf(f_c_directors_h, "#ifndef SWIG_%s_WRAP_H_\n", module); Printf(f_c_directors_h, "#define SWIG_%s_WRAP_H_\n\n", module); From b2c07c39f337c880db3203e5ba0ae57ac99bb800 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 15 Jun 2010 21:18:30 +0000 Subject: [PATCH 0941/1680] Correct number of referenced paragraphs in license as pointed out by Amaury Forgeot d'Arc git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12131 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- LICENSE-UNIVERSITIES | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/LICENSE-UNIVERSITIES b/LICENSE-UNIVERSITIES index fdb73d916..40042a84a 100644 --- a/LICENSE-UNIVERSITIES +++ b/LICENSE-UNIVERSITIES @@ -73,8 +73,8 @@ 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 +(1) The above copyright notice and the following paragraph +appears 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 From e7fde8c432fcbbcd80662a8696d614247ec20746 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Wed, 16 Jun 2010 15:43:05 +0000 Subject: [PATCH 0942/1680] Set wrap:name attribute when generating a call to a method in a base class. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12132 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/go.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/Modules/go.cxx b/Source/Modules/go.cxx index f1c7d89c1..bc219acfd 100644 --- a/Source/Modules/go.cxx +++ b/Source/Modules/go.cxx @@ -2031,7 +2031,8 @@ private: Delete(SwigType_pop_function(result)); // If the base method is imported, wrap:action may not be set. - Swig_save("goBaseMethod", method, "wrap:action", "parms", NULL); + Swig_save("goBaseMethod", method, "wrap:name", "wrap:action", "parms", NULL); + Setattr(method, "wrap:name", wname); if (Getattr(method, "wrap:action") == NULL) { if (!is_static) { Swig_MethodToFunction(method, getNSpace(), getClassType(), (Getattr(method, "template") != NULL ? SmartPointer : Extend | SmartPointer), NULL, false); From 683dafb6d3e0f04a6f51480ab00202c6f38d11c9 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Wed, 16 Jun 2010 15:47:15 +0000 Subject: [PATCH 0943/1680] Update the instructions to say that you also need to compile the code itself. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12133 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/go/simple/index.html | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Examples/go/simple/index.html b/Examples/go/simple/index.html index 82372ef37..21dfc239e 100644 --- a/Examples/go/simple/index.html +++ b/Examples/go/simple/index.html @@ -74,8 +74,10 @@ rather than gccgo.
    • Compile the example_wrap.c file using your standard C compiler with the -fpic option; e.g., gcc -c -O -fpic example_wrap.c. -
    • Put the gcc compiled object file into a shared library; - e.g., gcc -shared -o example.so example_wrap.o. +
    • Also compile the actual code, not generated by SWIG; e.g., gcc + -c -O -fpic example.c. +
    • Put the gcc compiled object files into a shared library; + e.g., gcc -shared -o example.so example_wrap.o example.o.
    • Compile the program which demonstrates how to use the library; e.g., 6g runme.go.
    • Link the program; e.g., 6l -o runme runme.6. From 2970f53c21c406389e1e24c9cd285317a1678f2c Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Thu, 17 Jun 2010 18:59:26 +0000 Subject: [PATCH 0944/1680] Remove the -rename option in the Go language support. Do a much better job of checking for name conflicts. Ignore conflicting names with a warning. Adjust the testsuite accordingly. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12135 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Go.html | 9 - Examples/test-suite/constant_pointers.i | 1 + Examples/test-suite/director_finalizer.i | 3 + Examples/test-suite/enum_thorough.i | 2 + Examples/test-suite/go/Makefile.in | 16 -- Examples/test-suite/go/director_enum_runme.go | 2 +- .../test-suite/go/overload_simple_runme.go | 26 +- .../go/smart_pointer_member_runme.go | 4 +- .../go/special_variable_macros_runme.go | 2 +- Examples/test-suite/mixed_types.i | 2 + Examples/test-suite/overload_simple.i | 3 + Examples/test-suite/preproc.i | 2 + Examples/test-suite/smart_pointer_member.i | 2 +- Examples/test-suite/special_variable_macros.i | 2 + .../test-suite/template_specialization_enum.i | 1 + Source/Include/swigwarn.h | 3 + Source/Modules/go.cxx | 241 ++++++++++++++---- Source/Modules/lang.cxx | 5 +- 18 files changed, 232 insertions(+), 94 deletions(-) diff --git a/Doc/Manual/Go.html b/Doc/Manual/Go.html index 1082a8f66..5e99a5156 100644 --- a/Doc/Manual/Go.html +++ b/Doc/Manual/Go.html @@ -116,15 +116,6 @@ swig -go -help or int64. The <s> argument should be 32 or 64. -
    • - - - -
      -rename <old>=<new>Rename <old%gt; to <new> when processing the C/C++ code - and also the SWIG input file. This is a convenient way to rename - names in the C/C++ code which are the same expect for the first - letter, to avoid conflicts when applying the Go renaming rules - described below.

      20.2.2 Go Output Files

      diff --git a/Examples/test-suite/constant_pointers.i b/Examples/test-suite/constant_pointers.i index 277d3cc75..7d46cdb31 100644 --- a/Examples/test-suite/constant_pointers.i +++ b/Examples/test-suite/constant_pointers.i @@ -5,6 +5,7 @@ This testcase primarily test constant pointers, eg int* const. Only a getter is %module constant_pointers %warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK); /* memory leak when setting a ptr/ref variable */ +%warnfilter(SWIGWARN_GO_NAME_CONFLICT); /* Ignoring 'Foo' due to Go name ('Foo') conflict with 'foo' */ %inline %{ diff --git a/Examples/test-suite/director_finalizer.i b/Examples/test-suite/director_finalizer.i index 52cdb1f52..fb45421b9 100644 --- a/Examples/test-suite/director_finalizer.i +++ b/Examples/test-suite/director_finalizer.i @@ -1,4 +1,7 @@ %module(directors="1") director_finalizer + +%warnfilter(SWIGWARN_GO_NAME_CONFLICT); /* Ignoring 'deleteFoo' due to Go name ('DeleteFoo') conflict with '~Foo' */ + %{ int status = 0; diff --git a/Examples/test-suite/enum_thorough.i b/Examples/test-suite/enum_thorough.i index 974227a01..cb2288574 100644 --- a/Examples/test-suite/enum_thorough.i +++ b/Examples/test-suite/enum_thorough.i @@ -43,6 +43,8 @@ %warnfilter(SWIGWARN_RUBY_WRONG_NAME) Instances::memberinstance2; %warnfilter(SWIGWARN_RUBY_WRONG_NAME) Instances::memberinstance3; +%warnfilter(SWIGWARN_GO_NAME_CONFLICT); /* Ignoring 'one' due to Go name ('ObscureOne') conflict with 'Obscure::One' */ + %inline %{ enum { AnonEnum1, AnonEnum2 = 100 }; diff --git a/Examples/test-suite/go/Makefile.in b/Examples/test-suite/go/Makefile.in index 6126e77ee..12a3f7919 100644 --- a/Examples/test-suite/go/Makefile.in +++ b/Examples/test-suite/go/Makefile.in @@ -21,22 +21,6 @@ top_builddir = @top_builddir@ include $(srcdir)/../common.mk -# Custom tests - tests with additional commandline options -constant_pointers.cpptest: SWIGOPT += -rename foo=foofn -director_enum.cpptest: SWIGOPT += -rename Hello=Helloe -director_finalizer.cpptest: SWIGOPT += -rename deleteFoo=deleteFooFn -enum_thorough.cpptest: SWIGOPT += -rename One=Onee -rename Two=Twoe -mixed_types.cpptest: SWIGOPT += -rename Hello=Helloe -overload_simple.cpptest: SWIGOPT += -rename foo=foofn -smart_pointer_extend.cpptest: SWIGOPT += -rename CPtrFoo=CPtrFoos -smart_pointer_member.cpptest: SWIGOPT += -rename Foo=Foos -special_variable_macros.cpptest: SWIGOPT += -rename Name=Names -template_partial_specialization.cpptest: SWIGOPT += -rename b=bfn -template_partial_specialization_typedef.cpptest: SWIGOPT += -rename b=bfn -template_specialization_enum.cpptest: SWIGOPT += -rename Hello=Helloe -preproc.ctest: SWIGOPT += -rename a5=a5c -rename a6=a6c -mod.multicpptest: SWIGOPT += -rename GetC=GetCFn - .SUFFIXES: .cpptest .ctest .multicpptest # Rules for the different types of tests diff --git a/Examples/test-suite/go/director_enum_runme.go b/Examples/test-suite/go/director_enum_runme.go index e0dad900b..5653fda40 100644 --- a/Examples/test-suite/go/director_enum_runme.go +++ b/Examples/test-suite/go/director_enum_runme.go @@ -3,7 +3,7 @@ package main import "./director_enum" type MyFoo struct{} // From director_enum.Foo -func (p *MyFoo) Say_hi(val director_enum.EnumDirectorHelloe) director_enum.EnumDirectorHelloe { +func (p *MyFoo) Say_hi(val director_enum.EnumDirectorHello) director_enum.EnumDirectorHello { return val } diff --git a/Examples/test-suite/go/overload_simple_runme.go b/Examples/test-suite/go/overload_simple_runme.go index 58fe46dab..9fca9061a 100644 --- a/Examples/test-suite/go/overload_simple_runme.go +++ b/Examples/test-suite/go/overload_simple_runme.go @@ -3,57 +3,57 @@ package main import . "./overload_simple" func main() { - if Foofn(3) != "foo:int" { + if Foo(3) != "foo:int" { panic("foo(int)") } - if Foofn(float64(3.0)) != "foo:double" { + if Foo(float64(3.0)) != "foo:double" { panic("foo(double)") } - if Foofn("hello") != "foo:char *" { + if Foo("hello") != "foo:char *" { panic("foo(char *)") } - f := NewFoo() + f := NewFoos() b := NewBar() - if Foofn(f) != "foo:Foo *" { + if Foo(f) != "foo:Foo *" { panic("foo(Foo *)") } - if Foofn(b) != "foo:Bar *" { + if Foo(b) != "foo:Bar *" { panic("foo(Bar *)") } v := Malloc_void(32) - if Foofn(v) != "foo:void *" { + if Foo(v) != "foo:void *" { panic("foo(void *)") } s := NewSpam() - if s.Foofn(3) != "foo:int" { + if s.Foo(3) != "foo:int" { panic("Spam::foo(int)") } - if s.Foofn(float64(3.0)) != "foo:double" { + if s.Foo(float64(3.0)) != "foo:double" { panic("Spam::foo(double)") } - if s.Foofn("hello") != "foo:char *" { + if s.Foo("hello") != "foo:char *" { panic("Spam::foo(char *)") } - if s.Foofn(f) != "foo:Foo *" { + if s.Foo(f) != "foo:Foo *" { panic("Spam::foo(Foo *)") } - if s.Foofn(b) != "foo:Bar *" { + if s.Foo(b) != "foo:Bar *" { panic("Spam::foo(Bar *)") } - if s.Foofn(v) != "foo:void *" { + if s.Foo(v) != "foo:void *" { panic("Spam::foo(void *)") } diff --git a/Examples/test-suite/go/smart_pointer_member_runme.go b/Examples/test-suite/go/smart_pointer_member_runme.go index d0da83cef..bf09fe5fc 100644 --- a/Examples/test-suite/go/smart_pointer_member_runme.go +++ b/Examples/test-suite/go/smart_pointer_member_runme.go @@ -4,7 +4,7 @@ import "fmt" import . "./smart_pointer_member" func main() { - f := NewFoos() + f := NewFoo() f.SetY(1) if f.GetY() != 1 { @@ -24,7 +24,7 @@ func main() { panic(0) } - if b.GetZ() != GetFoosZ() { + if b.GetZ() != GetFooZ() { panic(0) } } diff --git a/Examples/test-suite/go/special_variable_macros_runme.go b/Examples/test-suite/go/special_variable_macros_runme.go index 366575551..d049af606 100644 --- a/Examples/test-suite/go/special_variable_macros_runme.go +++ b/Examples/test-suite/go/special_variable_macros_runme.go @@ -3,7 +3,7 @@ package main import "./special_variable_macros" func main() { - name := special_variable_macros.NewNames() + name := special_variable_macros.NewName() if special_variable_macros.TestFred(name) != "none" { panic("test failed") } diff --git a/Examples/test-suite/mixed_types.i b/Examples/test-suite/mixed_types.i index 274cfcf7f..e2be55a61 100644 --- a/Examples/test-suite/mixed_types.i +++ b/Examples/test-suite/mixed_types.i @@ -3,6 +3,8 @@ %warnfilter(SWIGWARN_RUBY_WRONG_NAME) hi; /* Ruby, wrong constant name */ %warnfilter(SWIGWARN_RUBY_WRONG_NAME) hello; /* Ruby, wrong constant name */ +%warnfilter(SWIGWARN_GO_NAME_CONFLICT); /* Ignoring 'hello' due to Go name ('Hello') conflict with 'Hello' */ + %inline { const void* ref_pointer(const void*& a) { diff --git a/Examples/test-suite/overload_simple.i b/Examples/test-suite/overload_simple.i index b08777854..d23807641 100644 --- a/Examples/test-suite/overload_simple.i +++ b/Examples/test-suite/overload_simple.i @@ -14,7 +14,10 @@ %warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) fid; #endif +#ifdef SWIGGO %warnfilter(SWIGWARN_PARSE_KEYWORD) type; // 'type' is a Go keyword, renamed as 'Xtype' +%rename(Foos) Foo; +#endif #ifndef SWIG_NO_OVERLOAD %immutable Spam::type; diff --git a/Examples/test-suite/preproc.i b/Examples/test-suite/preproc.i index b9f357b90..fec4daeba 100644 --- a/Examples/test-suite/preproc.i +++ b/Examples/test-suite/preproc.i @@ -7,6 +7,8 @@ %warnfilter(SWIGWARN_RUBY_WRONG_NAME) __GMP_HAVE_PROTOTYPES; /* Ruby, wrong constant name */ %warnfilter(SWIGWARN_RUBY_WRONG_NAME) __GMP_HAVE_TOKEN_PASTE; /* Ruby, wrong constant name */ +#pragma SWIG nowarn=890 /* lots of Go name conflicts */ + /* check __cplusplus case */ %header %{ diff --git a/Examples/test-suite/smart_pointer_member.i b/Examples/test-suite/smart_pointer_member.i index 7a776261a..e4f1ae2c6 100644 --- a/Examples/test-suite/smart_pointer_member.i +++ b/Examples/test-suite/smart_pointer_member.i @@ -1,6 +1,6 @@ %module smart_pointer_member - +%warnfilter(SWIGWARN_GO_NAME_CONFLICT); /* Ignoring 'foo' due to Go name ('Foo') conflict with 'Foo' */ %inline %{ diff --git a/Examples/test-suite/special_variable_macros.i b/Examples/test-suite/special_variable_macros.i index f27bbd619..c168b4747 100644 --- a/Examples/test-suite/special_variable_macros.i +++ b/Examples/test-suite/special_variable_macros.i @@ -3,6 +3,8 @@ // test $typemap() special variable function // these tests are not typical of how $typemap() should be used, but it checks that it is mostly working +%warnfilter(SWIGWARN_GO_NAME_CONFLICT); /* Ignoring 'NewName' due to Go name ('NewName') conflict with 'Name' */ + %inline %{ struct Name { Name(const char *n="none") : name(n) {} diff --git a/Examples/test-suite/template_specialization_enum.i b/Examples/test-suite/template_specialization_enum.i index 5fc51fbe0..07d73b583 100644 --- a/Examples/test-suite/template_specialization_enum.i +++ b/Examples/test-suite/template_specialization_enum.i @@ -3,6 +3,7 @@ %warnfilter(SWIGWARN_RUBY_WRONG_NAME) Hello; /* Ruby, wrong class name */ %warnfilter(SWIGWARN_RUBY_WRONG_NAME) Hi; /* Ruby, wrong class name */ +%warnfilter(SWIGWARN_GO_NAME_CONFLICT); /* Ignoring 'hello due to Go name ('Hello) conflict with 'Hello' */ %inline %{ diff --git a/Source/Include/swigwarn.h b/Source/Include/swigwarn.h index 9f0729a98..46f5b79a5 100644 --- a/Source/Include/swigwarn.h +++ b/Source/Include/swigwarn.h @@ -258,6 +258,9 @@ /* please leave 870-889 free for PHP */ +#define WARN_GO_NAME_CONFLICT 890 + +/* please leave 890-899 free for Go */ /* Feel free to claim any number in this space that's not currently being used. Just make sure you add an entry here */ diff --git a/Source/Modules/go.cxx b/Source/Modules/go.cxx index bc219acfd..59e9e6f9d 100644 --- a/Source/Modules/go.cxx +++ b/Source/Modules/go.cxx @@ -27,8 +27,6 @@ class GO:public Language { String *soname; // Size in bits of the C type "long". int long_type_size; - // Rename directives. - String *renames; /* Output files */ File *f_c_begin; @@ -90,7 +88,6 @@ public: go_prefix(NULL), soname(NULL), long_type_size(32), - renames(NULL), f_c_begin(NULL), f_go_begin(NULL), f_gc_begin(NULL), @@ -176,26 +173,6 @@ private: } else { Swig_arg_error(); } - } else if (strcmp(argv[i], "-rename") == 0) { - if (argv[i + 1] != NULL) { - String *d = NewString(argv[i + 1]); - Replace(d, "=", " ", DOH_REPLACE_FIRST); - Preprocessor_define(d, 0); - if (renames == NULL) { - renames = NewString(""); - } - Printv(renames, "#define ", d, "\n", NULL); - Delete(d); - Swig_mark_arg(i); - Swig_mark_arg(i + 1); - ++i; - // Prevent SWIG from trying to define this for the - // preprocessor, which breaks if there are multiple - // -rename options. - argv[i] = NULL; - } else { - Swig_arg_error(); - } } else if (strcmp(argv[i], "-help") == 0) { Printf(stdout, "%s\n", usage); } @@ -355,9 +332,6 @@ private: } Swig_banner(f_c_begin); - if (renames != NULL) { - Printf(f_c_begin, "%s\n", renames); - } if (directorsEnabled()) { Printf(f_c_runtime, "#define SWIG_DIRECTORS\n"); @@ -560,6 +534,11 @@ private: } Delete(c2); Delete(c1); + + if (!checkIgnoredParameters(n, go_name)) { + Delete(go_name); + return SWIG_NOWRAP; + } } else if (Cmp(nodetype, "constructor") == 0) { is_ctor_dtor = true; @@ -612,23 +591,28 @@ private: } go_name = buildGoName(name, is_static, is_friend); + + if (!checkIgnoredParameters(n, go_name)) { + Delete(go_name); + return SWIG_NOWRAP; + } } String *overname = NULL; if (Getattr(n, "sym:overloaded")) { overname = Getattr(n, "sym:overname"); - } else if (class_name == NULL || is_static) { - if (!addSymbol(go_name, n)) { - return SWIG_ERROR; - } } else { - String *c = Copy(class_name); - Putc('+', c); - Append(c, go_name); - if (!addSymbol(c, n)) { - return SWIG_ERROR; + String *scope; + if (class_name == NULL || is_static || is_ctor_dtor) { + scope = NULL; + } else { + scope = NewString("swiggoscope."); + Append(scope, class_name); + } + if (!checkNameConflict(go_name, n, scope)) { + Delete(go_name); + return SWIG_NOWRAP; } - Delete(c); } String *wname = Swig_name_wrapper(name); @@ -646,6 +630,18 @@ private: } if (Getattr(n, "sym:overloaded") && Getattr(n, "sym:nextSibling") == NULL) { + String *scope ; + if (class_name == NULL || is_static || is_ctor_dtor) { + scope = NULL; + } else { + scope = NewString("swiggoscope."); + Append(scope, class_name); + } + if (!checkNameConflict(go_name, n, scope)) { + Delete(go_name); + return SWIG_NOWRAP; + } + String *receiver = class_receiver; if (is_static || is_ctor_dtor) { receiver = NULL; @@ -1563,11 +1559,6 @@ private: String *go_name = buildGoName(Getattr(n, "sym:name"), false, false); - if (!addSymbol(go_name, n)) { - Delete(go_name); - return SWIG_ERROR; - } - String *tm = goType(n, type); String *value = Getattr(n, "value"); @@ -1625,6 +1616,15 @@ private: } } + if (!checkNameConflict(go_name, n, NULL)) { + Delete(tm); + Delete(go_name); + if (copy != NULL) { + Delete(copy); + } + return SWIG_NOWRAP; + } + Printv(f_go_wrappers, "const ", go_name, " ", tm, " = ", NULL); if (SwigType_type(type) == T_STRING) { Printv(f_go_wrappers, "\"", value, "\"", NULL); @@ -1655,6 +1655,10 @@ private: String *name = goEnumName(n); if (Strcmp(name, "int") != 0) { if (!ImportMode || imported_package == NULL) { + if (!checkNameConflict(name, n, NULL)) { + Delete(name); + return SWIG_NOWRAP; + } Printv(f_go_wrappers, "type ", name, " int\n", NULL); } else { String *nw = NewString(""); @@ -1693,6 +1697,18 @@ private: * ------------------------------------------------------------------------ */ int goComplexConstant(Node *n, SwigType *type) { + String *symname = Getattr(n, "sym:name"); + if (symname == NULL) { + symname = Getattr(n, "name"); + } + + String *varname = buildGoName(symname, true, false); + + if (!checkNameConflict(varname, n, NULL)) { + Delete(varname); + return SWIG_NOWRAP; + } + String *get = NewString(""); Printv(get, "result = ", NULL); @@ -1720,11 +1736,6 @@ private: Printv(get, ";\n", NULL); Setattr(n, "wrap:action", get); - String *symname = Getattr(n, "sym:name"); - if (symname == NULL) { - symname = Getattr(n, "name"); - } - String *sname = Copy(symname); if (class_name != NULL) { Append(sname, "_"); @@ -1747,7 +1758,6 @@ private: return r; } - String *varname = buildGoName(symname, true, false); String *t = goType(n, type); Printv(f_go_wrappers, "var ", varname, " ", t, " = ", go_name, "()\n", NULL); @@ -1779,6 +1789,12 @@ private: String *go_name = exportedName(name); + if (!checkNameConflict(go_name, n, NULL)) { + Delete(go_name); + SetFlag(n, "go:conflict"); + return SWIG_NOWRAP; + } + String *go_type_name = goCPointerType(Getattr(n, "classtypeobj"), true); class_name = name; @@ -2452,8 +2468,8 @@ private: Append(fn_name, go_name); if (overname == NULL && !is_ignored) { - if (!addSymbol(fn_name, n)) { - return SWIG_ERROR; + if (!checkNameConflict(fn_name, n, NULL)) { + return SWIG_NOWRAP; } } @@ -4117,6 +4133,132 @@ private: return s2; } + /* ---------------------------------------------------------------------- + * checkNameConflict() + * + * Check for a name conflict on the name we are going to use in Go. + * These conflicts are likely because of the enforced + * capitalization. When we find one, issue a warning and return + * false. If the name is OK, return true. + * ---------------------------------------------------------------------- */ + + bool checkNameConflict(String* name, Node* n, const_String_or_char_ptr scope) { + Node *lk = symbolLookup(name, scope); + if (lk != NULL) { + String *n1 = Getattr(n, "sym:name"); + if (n1 == NULL) { + n1 = Getattr(n, "name"); + } + String *n2 = Getattr(lk, "sym:name"); + if (n2 == NULL) { + n2 = Getattr(lk, "name"); + } + Swig_warning(WARN_GO_NAME_CONFLICT, input_file, line_number, + "Ignoring '%s' due to Go name ('%s') conflict with '%s'\n", + n1, name, n2); + return false; + } + bool r = addSymbol(name, n, scope); + assert(r); + return true; + } + + /* ---------------------------------------------------------------------- + * checkIgnoredParameters() + * + * If any of the parameters of this function, or the return type, + * are ignored due to a name conflict, give a warning and return + * false. + * ---------------------------------------------------------------------- */ + + bool checkIgnoredParameters(Node *n, String *go_name) { + ParmList *parms = Getattr(n, "parms"); + if (parms != NULL) { + Wrapper *dummy = NewWrapper(); + emit_attach_parmmaps(parms, dummy); + int parm_count = emit_num_arguments(parms); + Parm *p = parms; + + for (int i = 0; i < parm_count; ++i) { + p = getParm(p); + if (!checkIgnoredType(n, go_name, Getattr(p, "type"))) { + DelWrapper(dummy); + return false; + } + p = nextParm(p); + } + + DelWrapper(dummy); + } + + if (!checkIgnoredType(n, go_name, Getattr(n, "type"))) { + return false; + } + + return true; + } + + /* ---------------------------------------------------------------------- + * checkIgnoredType() + * + * If this type is being ignored due to a name conflict, give a + * warning and return false. + * ---------------------------------------------------------------------- */ + + bool checkIgnoredType(Node *n, String *go_name, SwigType *type) { + if (hasGoTypemap(type)) { + return true; + } + + SwigType *t = SwigType_typedef_resolve_all(type); + + bool ret = true; + bool is_conflict = false; + Node *e = Language::enumLookup(t); + if (e != NULL) { + if (GetFlag(e, "go:conflict")) { + is_conflict = true; + } + } else if (SwigType_issimple(t)) { + Node *cn = classLookup(t); + if (cn != NULL) { + if (GetFlag(cn, "go:conflict")) { + is_conflict = true; + } + } + } else if (SwigType_ispointer(t) || SwigType_isarray(t) || SwigType_isqualifier(t) || SwigType_isreference(t)) { + SwigType *r = Copy(t); + if (SwigType_ispointer(r)) { + SwigType_del_pointer(r); + } else if (SwigType_isarray(r)) { + SwigType_del_array(r); + } else if (SwigType_isqualifier(r)) { + SwigType_del_qualifier(r); + } else { + SwigType_del_reference(r); + } + + if (!checkIgnoredType(n, go_name, r)) { + ret = false; + } + + Delete(r); + } + + if (is_conflict) { + String *s = SwigType_str(t, NULL); + Swig_warning(WARN_GO_NAME_CONFLICT, input_file, line_number, + "Ignoring '%s' (Go name '%s') due to Go name conflict for parameter or result type '%s'\n", + Getattr(n, "name"), go_name, s); + Delete(s); + ret = false; + } + + Delete(t); + + return ret; + } + /* ---------------------------------------------------------------------- * goType() * @@ -4631,5 +4773,4 @@ Go Options (available with -go)\n\ -go-prefix

      - Like gccgo -fgo-prefix option\n\ -soname - Set shared library holding C/C++ code to \n\ -longsize - Set size of C/C++ long type--32 or 64 bits\n\ - -rename = - Rename symbols from to \n\ \n"; diff --git a/Source/Modules/lang.cxx b/Source/Modules/lang.cxx index fb3d58ce4..83103180c 100644 --- a/Source/Modules/lang.cxx +++ b/Source/Modules/lang.cxx @@ -2995,7 +2995,10 @@ void Language::dumpSymbols() { * ----------------------------------------------------------------------------- */ Node *Language::symbolLookup(String *s, const_String_or_char_ptr scope) { - Hash *symbols = Getattr(symtabs, scope); + Hash *symbols = Getattr(symtabs, scope ? scope : ""); + if (symbols == NULL) { + return NULL; + } return Getattr(symbols, s); } From 07ca3eb9f88562bb356a40676631f6be45e222c1 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 17 Jun 2010 23:03:18 +0000 Subject: [PATCH 0945/1680] remove unnecessary NULL check before calling Delete git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12136 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/go.cxx | 40 ++++++++++------------------------------ 1 file changed, 10 insertions(+), 30 deletions(-) diff --git a/Source/Modules/go.cxx b/Source/Modules/go.cxx index 59e9e6f9d..91ab66039 100644 --- a/Source/Modules/go.cxx +++ b/Source/Modules/go.cxx @@ -654,9 +654,7 @@ private: Delete(wname); Delete(go_name); - if (r1 != NULL) { - Delete(r1); - } + Delete(r1); return SWIG_OK; } @@ -1227,9 +1225,7 @@ private: Swig_restore(n); DelWrapper(f); - if (base_parm != NULL) { - Delete(base_parm); - } + Delete(base_parm); return SWIG_OK; } @@ -1363,9 +1359,7 @@ private: Swig_restore(n); DelWrapper(f); - if (base_parm != NULL) { - Delete(base_parm); - } + Delete(base_parm); return SWIG_OK; } @@ -1619,9 +1613,7 @@ private: if (!checkNameConflict(go_name, n, NULL)) { Delete(tm); Delete(go_name); - if (copy != NULL) { - Delete(copy); - } + Delete(copy); return SWIG_NOWRAP; } @@ -1638,9 +1630,7 @@ private: Delete(tm); Delete(go_name); - if (copy != NULL) { - Delete(copy); - } + Delete(copy); return SWIG_OK; } @@ -3205,9 +3195,7 @@ private: } } - if (first_type != NULL) { - Delete(first_type); - } + Delete(first_type); if (first_parm != parms) { Delete(first_parm); } @@ -3337,9 +3325,7 @@ private: Printv(f_go_wrappers, "}\n\n", NULL); - if (result_wrapper != NULL) { - Delete(result_wrapper); - } + Delete(result_wrapper); // Build the C++ functions. @@ -3724,9 +3710,7 @@ private: } } if (mismatch) { - if (all_result != NULL) { - Delete(all_result); - } + Delete(all_result); all_result = NULL; } else if (all_result != NULL) { ; @@ -4021,9 +4005,7 @@ private: Printv(f_go_wrappers, "\tpanic(\"No match for overloaded function call\")\n", NULL); Printv(f_go_wrappers, "}\n\n", NULL); - if (all_result != NULL) { - Delete(all_result); - } + Delete(all_result); Delete(dispatch); return SWIG_OK; @@ -4647,9 +4629,7 @@ private: Delete(tm); return true; } - if (tm != NULL) { - Delete(tm); - } + Delete(tm); return false; } From 95a3eb5a7d5b34f91dec4e52d316d0b5f4462c2b Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 17 Jun 2010 23:49:12 +0000 Subject: [PATCH 0946/1680] code style: fix inconsistent NULL pointer comparisons git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12137 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/go.cxx | 365 ++++++++++++++++++------------------- Source/Modules/guile.cxx | 8 +- Source/Modules/lang.cxx | 2 +- Source/Modules/modula3.cxx | 6 +- Source/Modules/ocaml.cxx | 2 +- Source/Modules/octave.cxx | 2 +- Source/Modules/perl5.cxx | 2 +- Source/Modules/php.cxx | 6 +- Source/Modules/python.cxx | 26 +-- Source/Modules/r.cxx | 2 +- Source/Modules/ruby.cxx | 12 +- Source/Swig/misc.c | 2 +- 12 files changed, 216 insertions(+), 219 deletions(-) diff --git a/Source/Modules/go.cxx b/Source/Modules/go.cxx index 91ab66039..f62586b92 100644 --- a/Source/Modules/go.cxx +++ b/Source/Modules/go.cxx @@ -131,7 +131,7 @@ private: for (int i = 1; i < argc; i++) { if (argv[i]) { if (strcmp(argv[i], "-package") == 0) { - if (argv[i + 1] != NULL) { + if (argv[i + 1]) { package = NewString(argv[i + 1]); Swig_mark_arg(i); Swig_mark_arg(i + 1); @@ -143,7 +143,7 @@ private: Swig_mark_arg(i); gccgo_flag = true; } else if (strcmp(argv[i], "-go-prefix") == 0) { - if (argv[i + 1] != NULL) { + if (argv[i + 1]) { go_prefix = NewString(argv[i + 1]); Swig_mark_arg(i); Swig_mark_arg(i + 1); @@ -152,7 +152,7 @@ private: Swig_arg_error(); } } else if (strcmp(argv[i], "-soname") == 0) { - if (argv[i + 1] != NULL) { + if (argv[i + 1]) { soname = NewString(argv[i + 1]); Swig_mark_arg(i); Swig_mark_arg(i + 1); @@ -161,7 +161,7 @@ private: Swig_arg_error(); } } else if (strcmp(argv[i], "-longsize") == 0) { - if (argv[i + 1] != NULL) { + if (argv[i + 1]) { long_type_size = atoi(argv[i + 1]); if (long_type_size != 32 && long_type_size != 64) { Printf(stderr, "-longsize not 32 or 64\n"); @@ -179,7 +179,7 @@ private: } } - if (gccgo_flag && go_prefix == NULL) { + if (gccgo_flag && !go_prefix) { go_prefix = NewString("go"); } @@ -228,7 +228,7 @@ private: virtual int top(Node *n) { Node *optionsnode = Getattr(Getattr(n, "module"), "options"); - if (optionsnode != NULL) { + if (optionsnode) { if (Getattr(optionsnode, "directors")) { allow_directors(); } @@ -239,10 +239,10 @@ private: } String *module = Getattr(n, "name"); - if (package == NULL) { + if (!package) { package = Copy(module); } - if (soname == NULL) { + if (!soname) { soname = Copy(package); Append(soname, ".so"); } @@ -371,11 +371,11 @@ private: // Write out definitions for the types not defined by SWIG. Printv(f_go_wrappers, "\n", NULL); - for (Iterator p = First(undefined_types); p.key != NULL; p = Next(p)) { + for (Iterator p = First(undefined_types); p.key; p = Next(p)) { String *ty = goType(NULL, p.key); - if (Getattr(defined_types, ty) == NULL) { + if (!Getattr(defined_types, ty)) { String *cp = goCPointerType(p.key, false); - if (Getattr(defined_types, cp) == NULL) { + if (!Getattr(defined_types, cp)) { Printv(f_go_wrappers, "type ", cp, " uintptr\n", NULL); Printv(f_go_wrappers, "type ", ty, " interface {\n", NULL); Printv(f_go_wrappers, "\tSwigcptr() uintptr;\n", NULL); @@ -463,7 +463,7 @@ private: virtual int importDirective(Node *n) { String *hold_import = imported_package; String *modname = Getattr(n, "module"); - if (modname != NULL) { + if (modname) { Printv(f_go_begin, "import \"", modname, "\"\n", NULL); imported_package = modname; saw_import = true; @@ -517,7 +517,7 @@ private: // If this is a static variable, put in the class name, // capitalized. - if (is_static && class_name != NULL) { + if (is_static && class_name) { String *ccn = exportedName(class_name); Append(go_name, ccn); Delete(ccn); @@ -552,7 +552,7 @@ private: Delete(c2); Delete(c1); - if (Swig_methodclass(n) != NULL && Swig_directorclass(n) + if (Swig_methodclass(n) && Swig_directorclass(n) && Strcmp(Char(Getattr(n, "wrap:action")), director_prot_ctor_code) != 0) { // The core SWIG code skips the first parameter when // generating the $nondirector_new string. Recreate the @@ -603,7 +603,7 @@ private: overname = Getattr(n, "sym:overname"); } else { String *scope; - if (class_name == NULL || is_static || is_ctor_dtor) { + if (!class_name || is_static || is_ctor_dtor) { scope = NULL; } else { scope = NewString("swiggoscope."); @@ -616,7 +616,7 @@ private: } String *wname = Swig_name_wrapper(name); - if (overname != NULL) { + if (overname) { Append(wname, overname); } Setattr(n, "wrap:name", wname); @@ -629,9 +629,9 @@ private: return r; } - if (Getattr(n, "sym:overloaded") && Getattr(n, "sym:nextSibling") == NULL) { + if (Getattr(n, "sym:overloaded") && !Getattr(n, "sym:nextSibling")) { String *scope ; - if (class_name == NULL || is_static || is_ctor_dtor) { + if (!class_name || is_static || is_ctor_dtor) { scope = NULL; } else { scope = NewString("swiggoscope."); @@ -695,7 +695,7 @@ private: int makeWrappers(Node *n, String *name, String *go_name, String *overname, String *wname, List *base, ParmList *parms, SwigType *result, bool is_static) { - assert(result != NULL); + assert(result); bool needs_wrapper; int r = goFunctionWrapper(n, name, go_name, overname, wname, base, parms, result, is_static, &needs_wrapper); @@ -719,7 +719,7 @@ private: } } - if (class_methods != NULL) { + if (class_methods) { Setattr(class_methods, Getattr(n, "name"), NewString("")); } @@ -746,7 +746,7 @@ private: int required_count = emit_num_required(parms); String *receiver = class_receiver; - if (receiver != NULL && is_static) { + if (receiver && is_static) { receiver = NULL; } @@ -754,14 +754,14 @@ private: bool is_constructor = Cmp(nodetype, "constructor") == 0; bool is_destructor = Cmp(nodetype, "destructor") == 0; if (is_constructor || is_destructor) { - assert(class_receiver != NULL); - assert(base == NULL); + assert(class_receiver); + assert(!base); receiver = NULL; } - bool add_to_interface = (interfaces != NULL && !is_constructor && !is_destructor && !is_static && overname == NULL && is_public(n)); + bool add_to_interface = (interfaces && !is_constructor && !is_destructor && !is_static && !overname && is_public(n)); - bool needs_wrapper = (gccgo_flag || receiver != NULL || is_constructor || is_destructor || parm_count > required_count); + bool needs_wrapper = (gccgo_flag || receiver || is_constructor || is_destructor || parm_count > required_count); // See whether any of the function parameters are represented by // interface values When calling the C++ code, we need to convert @@ -805,12 +805,12 @@ private: Printv(f_go_wrappers, "uintptr", NULL); ++i; p = nextParm(p); - } else if (receiver != NULL && (base != NULL || !is_constructor)) { + } else if (receiver && (base || !is_constructor)) { if (parm_count > required_count) { Printv(f_go_wrappers, ", ", NULL); } Printv(f_go_wrappers, receiver, NULL); - if (base == NULL) { + if (!base) { ++i; p = nextParm(p); } @@ -819,7 +819,7 @@ private: p = getParm(p); // Give the parameter a name we will use below. Swig_cparm_name(p, i); - if (i > 0 || (base != NULL && receiver != NULL) || parm_count > required_count) { + if (i > 0 || (base && receiver) || parm_count > required_count) { Printv(f_go_wrappers, ", ", NULL); } String *tm = goWrapperType(p, Getattr(p, "type"), false); @@ -853,9 +853,9 @@ private: int pi = 0; // Add the receiver if this is a method. - if (receiver != NULL) { + if (receiver) { Printv(f_go_wrappers, "(", NULL); - if (base != NULL && receiver != NULL) { + if (base && receiver) { Printv(f_go_wrappers, "_swig_base", NULL); } else { Printv(f_go_wrappers, Getattr(p, "lname"), NULL); @@ -866,7 +866,7 @@ private: } Printv(f_go_wrappers, go_name, NULL); - if (overname != NULL) { + if (overname) { Printv(f_go_wrappers, overname, NULL); } Printv(f_go_wrappers, "(", NULL); @@ -888,7 +888,7 @@ private: Printv(parm_print, Getattr(p, "lname"), " ", cl, NULL); Delete(cl); } else { - if (pi > (receiver != NULL && base == NULL ? 1 : 0)) { + if (pi > (receiver && !base ? 1 : 0)) { Printv(parm_print, ", ", NULL); } if (pi >= required_count) { @@ -959,7 +959,7 @@ private: Printv(f_go_wrappers, "len(_swig_args)", NULL); } - if (base != NULL && receiver != NULL) { + if (base && receiver) { if (parm_count > required_count) { Printv(f_go_wrappers, ", ", NULL); } @@ -969,7 +969,7 @@ private: Parm *p = parms; for (int i = 0; i < parm_count; ++i) { p = getParm(p); - if (i > 0 || (base != NULL && receiver != NULL) + if (i > 0 || (base && receiver) || parm_count > required_count) { Printv(f_go_wrappers, ", ", NULL); } @@ -979,9 +979,7 @@ private: // C++ value, and we have the interface. We need to get the // C++ value. The same is true for a type represented as an // interface. - if ((i == 0 && is_destructor) - || ((i > 0 || receiver == NULL || base != NULL || is_constructor) - && goTypeIsInterface(p, Getattr(p, "type")))) { + if ((i == 0 && is_destructor) || ((i > 0 || !receiver || base || is_constructor) && goTypeIsInterface(p, Getattr(p, "type")))) { Printv(f_go_wrappers, ".Swigcptr()", NULL); } @@ -1031,7 +1029,7 @@ private: Append(parm_size, "SWIG_PARM_SIZE"); } - if (class_receiver != NULL && !is_static) { + if (class_receiver && !is_static) { if (Len(parm_size) > 0) { Append(parm_size, " + "); } @@ -1056,7 +1054,7 @@ private: String *fn_name; if (!needs_wrapper) { fn_name = Copy(go_name); - if (overname != NULL) { + if (overname) { Append(fn_name, overname); } } else { @@ -1129,7 +1127,7 @@ private: Swig_save("gccFunctionWrapper", n, "parms", NULL); Parm *base_parm = NULL; - if (base != NULL && !isStatic(n)) { + if (base && !isStatic(n)) { SwigType *base_type = Copy(Getattr(class_node, "classtype")); SwigType_add_pointer(base_type); base_parm = NewParm(base_type, NewString("arg1"), n); @@ -1187,7 +1185,7 @@ private: p = getParm(p); String *tm = Getattr(p, "tmap:in"); - if (tm == NULL) { + if (!tm) { Swig_warning(WARN_TYPEMAP_IN_UNDEF, input_file, line_number, "Unable to use type %s as a function argument\n", SwigType_str(Getattr(p, "type"), 0)); } else { String *ln = Getattr(p, "lname"); @@ -1245,7 +1243,7 @@ private: Swig_save("gccgoFunctionWrapper", n, "parms", NULL); Parm *base_parm = NULL; - if (base != NULL && !isStatic(n)) { + if (base && !isStatic(n)) { SwigType *base_type = Copy(Getattr(class_node, "classtype")); SwigType_add_pointer(base_type); base_parm = NewParm(base_type, NewString("arg1"), n); @@ -1315,7 +1313,7 @@ private: p = getParm(p); String *tm = Getattr(p, "tmap:in"); - if (tm == NULL) { + if (!tm) { Swig_warning(WARN_TYPEMAP_IN_UNDEF, input_file, line_number, "Unable to use type %s as a function argument\n", SwigType_str(Getattr(p, "type"), 0)); } else { @@ -1374,9 +1372,9 @@ private: void checkConstraints(ParmList *parms, Wrapper *f) { Parm *p = parms; - while (p != NULL) { + while (p) { String *tm = Getattr(p, "tmap:check"); - if (tm == NULL) { + if (!tm) { p = nextSibling(p); } else { Replaceall(tm, "$input", Getattr(p, "emit:input")); @@ -1394,7 +1392,7 @@ private: void emitGoAction(Node *n, List *base, ParmList *parms, SwigType *result, Wrapper *f) { String *actioncode; - if (base == NULL || isStatic(n)) { + if (!base || isStatic(n)) { Swig_director_emit_dynamic_cast(n, f); actioncode = emit_action(n); } else { @@ -1409,7 +1407,7 @@ private: String *last = NULL; int vc = 0; - for (Iterator bi = First(base); bi.item != NULL; bi = Next(bi)) { + for (Iterator bi = First(base); bi.item; bi = Next(bi)) { Printf(actioncode, " %s *swig_b%d = (%s *)%s;\n", bi.item, vc, bi.item, current); Delete(current); current = NewString(""); @@ -1428,7 +1426,7 @@ private: Setattr(n, "type", result); String *tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode); - if (tm == NULL) { + if (!tm) { Swig_warning(WARN_TYPEMAP_OUT_UNDEF, input_file, line_number, "Unable to use return type %s\n", SwigType_str(result, 0)); } else { if (!gccgo_flag) { @@ -1458,9 +1456,9 @@ private: void argout(ParmList *parms, Wrapper *f) { Parm *p = parms; - while (p != NULL) { + while (p) { String *tm = Getattr(p, "tmap:argout"); - if (tm == NULL) { + if (!tm) { p = nextSibling(p); } else { Replaceall(tm, "$result", "result"); @@ -1482,9 +1480,9 @@ private: String *freearg(ParmList *parms) { String *ret = NewString(""); Parm *p = parms; - while (p != NULL) { + while (p) { String *tm = Getattr(p, "tmap:freearg"); - if (tm == NULL) { + if (!tm) { p = nextSibling(p); } else { Replaceall(tm, "$input", Getattr(p, "emit:input")); @@ -1507,7 +1505,7 @@ private: if (GetFlag(n, "feature:new")) { String *tm = Swig_typemap_lookup("newfree", n, "result", 0); - if (tm != NULL) { + if (tm) { Replaceall(tm, "$source", "result"); Printv(f->code, tm, "\n", NULL); Delete(tm); @@ -1547,7 +1545,7 @@ private: return goComplexConstant(n, type); } - if (Getattr(n, "storage") != NULL && Strcmp(Getattr(n, "storage"), "static") == 0) { + if (Getattr(n, "storage") && Strcmp(Getattr(n, "storage"), "static") == 0) { return goComplexConstant(n, type); } @@ -1563,7 +1561,7 @@ private: } } else if (SwigType_type(type) == T_STRING || SwigType_type(type) == T_CHAR) { // Backslash sequences are somewhat different in Go and C/C++. - if (Strchr(value, '\\') != NULL) { + if (Strchr(value, '\\') != 0) { return goComplexConstant(n, type); } } else { @@ -1644,7 +1642,7 @@ private: virtual int enumDeclaration(Node *n) { String *name = goEnumName(n); if (Strcmp(name, "int") != 0) { - if (!ImportMode || imported_package == NULL) { + if (!ImportMode || !imported_package) { if (!checkNameConflict(name, n, NULL)) { Delete(name); return SWIG_NOWRAP; @@ -1672,7 +1670,7 @@ private: if (!is_public(n)) { return SWIG_OK; } - if (Getattr(parentNode(n), "unnamed") != NULL) { + if (Getattr(parentNode(n), "unnamed")) { Setattr(n, "type", NewString("int")); } else { Setattr(n, "type", Getattr(parentNode(n), "enumtype")); @@ -1688,7 +1686,7 @@ private: int goComplexConstant(Node *n, SwigType *type) { String *symname = Getattr(n, "sym:name"); - if (symname == NULL) { + if (!symname) { symname = Getattr(n, "name"); } @@ -1703,7 +1701,7 @@ private: Printv(get, "result = ", NULL); char quote; - if (Getattr(n, "wrappedasconstant") != NULL) { + if (Getattr(n, "wrappedasconstant")) { quote = '\0'; } else if (SwigType_type(type) == T_CHAR) { quote = '\''; @@ -1727,13 +1725,13 @@ private: Setattr(n, "wrap:action", get); String *sname = Copy(symname); - if (class_name != NULL) { + if (class_name) { Append(sname, "_"); Append(sname, class_name); } String *go_name = NewString("_swig_get"); - if (class_name != NULL) { + if (class_name) { Append(go_name, class_name); Append(go_name, "_"); } @@ -1773,7 +1771,7 @@ private: class_node = n; List *baselist = Getattr(n, "bases"); - bool has_base_classes = baselist != NULL && Len(baselist) > 0; + bool has_base_classes = baselist && Len(baselist) > 0; String *name = Getattr(n, "sym:name"); @@ -1834,7 +1832,7 @@ private: // differently in Go and in C++. Hash *local = NewHash(); - for (Node *ni = Getattr(n, "firstChild"); ni != NULL; ni = nextSibling(ni)) { + for (Node *ni = Getattr(n, "firstChild"); ni; ni = nextSibling(ni)) { if (!is_public(ni)) { continue; @@ -1846,15 +1844,15 @@ private: } String *cname = Getattr(ni, "sym:name"); - if (cname == NULL) { + if (!cname) { cname = Getattr(ni, "name"); } - if (cname != NULL) { + if (cname) { Setattr(local, cname, NewString("")); } } - for (Iterator b = First(baselist); b.item != NULL; b = Next(b)) { + for (Iterator b = First(baselist); b.item; b = Next(b)) { List *bases = NewList(); Append(bases, Getattr(b.item, "classtype")); int r = addBase(n, b.item, bases, local); @@ -1911,7 +1909,7 @@ private: return SWIG_OK; } - for (Node *ni = Getattr(base, "firstChild"); ni != NULL; ni = nextSibling(ni)) { + for (Node *ni = Getattr(base, "firstChild"); ni; ni = nextSibling(ni)) { if (GetFlag(ni, "feature:ignore")) { continue; @@ -1931,15 +1929,15 @@ private: } String *mname = Getattr(ni, "sym:name"); - if (mname == NULL) { + if (!mname) { continue; } String *lname = Getattr(ni, "name"); - if (Getattr(class_methods, lname) != NULL) { + if (Getattr(class_methods, lname)) { continue; } - if (Getattr(local, lname) != NULL) { + if (Getattr(local, lname)) { continue; } Setattr(local, lname, NewString("")); @@ -1957,8 +1955,8 @@ private: return r; } - if (Getattr(ni, "sym:overloaded") != NULL) { - for (Node *on = Getattr(ni, "sym:nextSibling"); on != NULL; on = Getattr(on, "sym:nextSibling")) { + if (Getattr(ni, "sym:overloaded")) { + for (Node *on = Getattr(ni, "sym:nextSibling"); on; on = Getattr(on, "sym:nextSibling")) { r = goBaseMethod(n, bases, on); if (r != SWIG_OK) { return r; @@ -1986,8 +1984,8 @@ private: } List *baselist = Getattr(base, "bases"); - if (baselist != NULL && Len(baselist) > 0) { - for (Iterator b = First(baselist); b.item != NULL; b = Next(b)) { + if (baselist && Len(baselist) > 0) { + for (Iterator b = First(baselist); b.item; b = Next(b)) { List *nb = Copy(bases); Append(nb, Getattr(b.item, "classtype")); int r = addBase(n, b.item, nb, local); @@ -2025,7 +2023,7 @@ private: overname = Getattr(method, "sym:overname"); } String *wname = Swig_name_wrapper(name); - if (overname != NULL) { + if (overname) { Append(wname, overname); } @@ -2039,12 +2037,12 @@ private: // If the base method is imported, wrap:action may not be set. Swig_save("goBaseMethod", method, "wrap:name", "wrap:action", "parms", NULL); Setattr(method, "wrap:name", wname); - if (Getattr(method, "wrap:action") == NULL) { + if (!Getattr(method, "wrap:action")) { if (!is_static) { - Swig_MethodToFunction(method, getNSpace(), getClassType(), (Getattr(method, "template") != NULL ? SmartPointer : Extend | SmartPointer), NULL, false); + Swig_MethodToFunction(method, getNSpace(), getClassType(), (Getattr(method, "template") ? SmartPointer : Extend | SmartPointer), NULL, false); // Remove any self parameter that was just added. ParmList *parms = Getattr(method, "parms"); - if (parms != NULL && Getattr(parms, "self") != NULL) { + if (parms && Getattr(parms, "self")) { parms = CopyParmList(nextSibling(parms)); Setattr(method, "parms", parms); } @@ -2099,7 +2097,7 @@ private: String *mname = Swig_name_member(getNSpace(), Getattr(var_class, "sym:name"), var_name); if (is_assignable(var)) { - for (Iterator ki = First(var); ki.key != NULL; ki = Next(ki)) { + for (Iterator ki = First(var); ki.key; ki = Next(ki)) { if (Strncmp(ki.key, "tmap:", 5) == 0) { Delattr(var, ki.key); } @@ -2128,7 +2126,7 @@ private: Delete(mname_set); Swig_restore(var); - for (Iterator ki = First(var); ki.key != NULL; ki = Next(ki)) { + for (Iterator ki = First(var); ki.key; ki = Next(ki)) { if (Strncmp(ki.key, "tmap:", 5) == 0) { Delattr(var, ki.key); } @@ -2179,7 +2177,7 @@ private: * ------------------------------------------------------------ */ void addFirstBaseInterface(Node *n, Hash *parents, List *bases) { - if (bases == NULL || Len(bases) == 0) { + if (!bases || Len(bases) == 0) { return; } Iterator b = First(bases); @@ -2224,7 +2222,7 @@ private: Node *fb = b.item; - for (b = Next(b); b.item != NULL; b = Next(b)) { + for (b = Next(b); b.item; b = Next(b)) { if (GetFlag(b.item, "feature:ignore")) { continue; } @@ -2299,7 +2297,7 @@ private: void addParentExtraBaseInterfaces(Node *n, Hash *parents, Node *base, bool is_base_first, String *sofar) { List *baselist = Getattr(base, "bases"); - if (baselist == NULL || Len(baselist) == 0) { + if (!baselist || Len(baselist) == 0) { return; } @@ -2316,7 +2314,7 @@ private: } b = Next(b); - if (b.item == NULL) { + if (!b.item) { return; } } @@ -2324,14 +2322,14 @@ private: String *go_name = buildGoName(Getattr(n, "sym:name"), false, false); String *go_type_name = goCPointerType(Getattr(n, "classtypeobj"), true); - for (; b.item != NULL; b = Next(b)) { + for (; b.item; b = Next(b)) { if (GetFlag(b.item, "feature:ignore")) { continue; } String *go_base_name = exportedName(Getattr(b.item, "sym:name")); - if (Getattr(parents, go_base_name) == NULL) { + if (!Getattr(parents, go_base_name)) { Printv(f_go_wrappers, "func (p ", go_type_name, ") SwigGet", go_base_name, "() ", go_base_name, " {\n", NULL); Printv(f_go_wrappers, "\treturn p", sf, ".SwigGet", go_base_name, "()\n", NULL); Printv(f_go_wrappers, "}\n\n", NULL); @@ -2375,14 +2373,14 @@ private: String *name = Getattr(n, "sym:name"); - assert(class_name == NULL); + assert(!class_name); class_name = name; String *go_name = exportedName(name); String *go_type_name = goCPointerType(Getattr(n, "classtypeobj"), true); - assert(class_receiver == NULL); + assert(!class_receiver); class_receiver = go_type_name; String *director_struct_name = NewString("_swig_Director"); @@ -2431,7 +2429,7 @@ private: bool is_ignored = GetFlag(n, "feature:ignore"); String *name = Getattr(n, "sym:name"); - if (name == NULL) { + if (!name) { assert(is_ignored); name = Getattr(n, "name"); } @@ -2457,7 +2455,7 @@ private: Append(fn_name, cn); Append(fn_name, go_name); - if (overname == NULL && !is_ignored) { + if (!overname && !is_ignored) { if (!checkNameConflict(fn_name, n, NULL)) { return SWIG_NOWRAP; } @@ -2465,7 +2463,7 @@ private: String *wname = Swig_name_wrapper(fn_name); - if (overname != NULL) { + if (overname) { Append(wname, overname); } Setattr(n, "wrap:name", wname); @@ -2483,7 +2481,7 @@ private: Append(func_name, go_name); String *func_with_over_name = Copy(func_name); - if (overname != NULL) { + if (overname) { Append(func_with_over_name, overname); } @@ -2503,7 +2501,7 @@ private: if (!is_ignored) { // Declare the C++ wrapper. Printv(f_go_wrappers, "func ", fn_name, NULL); - if (overname != NULL) { + if (overname) { Printv(f_go_wrappers, overname, NULL); } Printv(f_go_wrappers, "(*", director_struct_name, NULL); @@ -2542,7 +2540,7 @@ private: Printv(f_go_wrappers, "\tp := &", director_struct_name, "{0, v}\n", NULL); Printv(f_go_wrappers, "\tp.", class_receiver, " = ", fn_name, NULL); - if (overname != NULL) { + if (overname) { Printv(f_go_wrappers, overname, NULL); } Printv(f_go_wrappers, "(p", NULL); @@ -2628,7 +2626,7 @@ private: Printv(f_c_directors, ", ", NULL); } String *pn = Getattr(p, "name"); - assert(pn != NULL); + assert(pn); Printv(f_c_directors, pn, NULL); p = nextParm(p); } @@ -2636,7 +2634,7 @@ private: Printv(f_c_directors, " go_val(swig_p)\n", NULL); Printv(f_c_directors, "{ }\n\n", NULL); - if (Getattr(n, "sym:overloaded") && Getattr(n, "sym:nextSibling") == NULL) { + if (Getattr(n, "sym:overloaded") && !Getattr(n, "sym:nextSibling")) { int r = makeDispatchFunction(n, func_name, cn, is_static, Getattr(parentNode(n), "classtypeobj"), false); if (r != SWIG_OK) { return r; @@ -2716,7 +2714,7 @@ private: Printv(f_c_directors_h, " virtual ~SwigDirector_", class_name, "()", NULL); String *throws = buildThrow(n); - if (throws != NULL) { + if (throws) { Printv(f_c_directors_h, " ", throws, NULL); } @@ -2732,7 +2730,7 @@ private: Printv(f_c_directors, "SwigDirector_", class_name, "::~SwigDirector_", class_name, "()", NULL); - if (throws != NULL) { + if (throws) { Printv(f_c_directors, " ", throws, NULL); Delete(throws); } @@ -2792,23 +2790,23 @@ private: } String *name = Getattr(n, "sym:name"); - if (name == NULL) { + if (!name) { assert(is_ignored); name = Getattr(n, "name"); } - if (Getattr(class_methods, name) != NULL) { + if (Getattr(class_methods, name)) { // We need to emit a pure virtual function, even if it is // overloaded. Otherwise we won't be able to create an instance // of the director class. The function doesn't need to actually // do anything. - if (!is_pure_virtual || Getattr(n, "sym:overloaded") != NULL) { + if (!is_pure_virtual || Getattr(n, "sym:overloaded")) { return SWIG_OK; } } Setattr(class_methods, name, NewString("")); - if (Getattr(n, "sym:overloaded") == NULL) { + if (!Getattr(n, "sym:overloaded")) { int r = oneClassDirectorMethod(n, parent); if (r != SWIG_OK) { return r; @@ -2819,7 +2817,7 @@ private: // class_methods so that we correctly handle cases where a // function in one class hides a function of the same name in a // parent class. - for (Node *on = Getattr(n, "sym:overloaded"); on != NULL; on = Getattr(on, "sym:nextSibling")) { + for (Node *on = Getattr(n, "sym:overloaded"); on; on = Getattr(on, "sym:nextSibling")) { int r = oneClassDirectorMethod(on, parent); if (r != SWIG_OK) { return r; @@ -2875,7 +2873,7 @@ private: bool is_pure_virtual = (Cmp(Getattr(n, "storage"), "virtual") == 0 && Cmp(Getattr(n, "value"), "0") == 0); String *name = Getattr(n, "sym:name"); - if (name == NULL) { + if (!name) { assert(is_ignored); name = Getattr(n, "name"); } @@ -2907,7 +2905,7 @@ private: int parm_count = emit_num_arguments(parms); SwigType *result = Getattr(n, "returntype"); - if (result == NULL) { + if (!result) { // This can happen when following overloads. result = NewString(Getattr(n, "type")); SwigType_push(result, Getattr(n, "decl")); @@ -2924,7 +2922,7 @@ private: String *interface_name = NewString("_swig_DirectorInterface"); Append(interface_name, cn); Append(interface_name, go_name); - if (overname != NULL) { + if (overname) { Append(interface_name, overname); } @@ -2932,7 +2930,7 @@ private: Append(callback_name, "_callback_"); Append(callback_name, name); Replace(callback_name, "_swig", "Swig", DOH_REPLACE_FIRST); - if (overname != NULL) { + if (overname) { Append(callback_name, overname); } @@ -2945,7 +2943,7 @@ private: String *upcall_wname = Swig_name_wrapper(upcall_name); String *go_with_over_name = Copy(go_name); - if (overname != NULL) { + if (overname) { Append(go_with_over_name, overname); } @@ -2955,7 +2953,7 @@ private: for (int i = 0; i < parm_count; ++i) { p = getParm(p); Swig_cparm_name(p, i); - if (Getattr(p, "name") == NULL) { + if (!Getattr(p, "name")) { String *pn = NewString(""); Printf(pn, "arg%d", i); Setattr(p, "name", pn); @@ -2996,7 +2994,7 @@ private: // Declare the upcall function, which calls the method on the // parent class. - if (overname != NULL) { + if (overname) { Append(upcall_wname, overname); } @@ -3102,7 +3100,7 @@ private: String *upcall_method_name = NewString("_swig_upcall_"); Append(upcall_method_name, name); - if (overname != NULL) { + if (overname) { Append(upcall_method_name, overname); } String *upcall_decl = Swig_method_decl(Getattr(n, "type"), Getattr(n, "decl"), upcall_method_name, parms, 0, 0); @@ -3122,7 +3120,7 @@ private: Printv(f_c_directors_h, ", ", NULL); } String *pn = Getattr(p, "name"); - assert(pn != NULL); + assert(pn); Printv(f_c_directors_h, pn, NULL); p = nextParm(p); } @@ -3340,7 +3338,7 @@ private: Printv(fnname, callback_wname, "(void*", NULL); p = parms; - while (p != NULL) { + while (p) { while (checkAttribute(p, "tmap:directorin:numinputs", "0")) { p = Getattr(p, "tmap:directorin:next"); } @@ -3386,7 +3384,7 @@ private: Delete(qname); String *throws = buildThrow(n); - if (throws != NULL) { + if (throws) { Printv(f_c_directors_h, " ", throws, NULL); Printv(f->def, " ", throws, NULL); Delete(throws); @@ -3406,7 +3404,7 @@ private: Printv(f->code, " void *go_val;\n", NULL); p = parms; - while (p != NULL) { + while (p) { while (checkAttribute(p, "tmap:directorin:numinputs", "0")) { p = Getattr(p, "tmap:directorin:next"); } @@ -3429,12 +3427,12 @@ private: Printv(f->code, " swig_a.go_val = go_val;\n", NULL); p = parms; - while (p != NULL) { + while (p) { while (checkAttribute(p, "tmap:directorin:numinputs", "0")) { p = Getattr(p, "tmap:directorin:next"); } String *tm = Getattr(p, "tmap:directorin"); - if (tm == NULL) { + if (!tm) { Swig_warning(WARN_TYPEMAP_DIRECTORIN_UNDEF, input_file, line_number, "Unable to use type %s as director method argument\n", SwigType_str(Getattr(p, "type"), 0)); } else { @@ -3455,7 +3453,7 @@ private: String *rname = NewString("c_result"); Parm *rp = NewParm(Getattr(n, "returntype"), rname, n); String *tm = Swig_typemap_lookup("directorout", rp, rname, NULL); - if (tm == NULL) { + if (!tm) { Swig_warning(WARN_TYPEMAP_DIRECTOROUT_UNDEF, input_file, line_number, "Unable to use type %s as director method result\n", SwigType_str(result, 0)); } else { @@ -3491,7 +3489,7 @@ private: String *args = NewString(""); p = parms; - while (p != NULL) { + while (p) { while (checkAttribute(p, "tmap:directorin:numinputs", "0")) { p = Getattr(p, "tmap:directorin:next"); } @@ -3505,7 +3503,7 @@ private: Delete(tm); tm = Getattr(p, "tmap:directorin"); - if (tm == NULL) { + if (!tm) { Swig_warning(WARN_TYPEMAP_DIRECTORIN_UNDEF, input_file, line_number, "Unable to use type %s as director method argument\n", SwigType_str(Getattr(p, "type"), 0)); } else { @@ -3529,7 +3527,7 @@ private: String *rname = NewString("c_result"); Parm *rp = NewParm(Getattr(n, "returntype"), rname, n); String *tm = Swig_typemap_lookup("directorout", rp, rname, NULL); - if (tm == NULL) { + if (!tm) { Swig_warning(WARN_TYPEMAP_DIRECTOROUT_UNDEF, input_file, line_number, "Unable to use type %s as director method result\n", SwigType_str(result, 0)); } else { @@ -3617,15 +3615,15 @@ private: String *buildThrow(Node *n) { ParmList *throw_parm_list = Getattr(n, "throws"); - if (throw_parm_list == NULL && Getattr(n, "throw") == NULL) + if (!throw_parm_list && !Getattr(n, "throw")) return NULL; String *ret = NewString("throw("); - if (throw_parm_list != NULL) { + if (throw_parm_list) { Swig_typemap_attach_parms("throws", throw_parm_list, NULL); } bool first = true; - for (Parm *p = throw_parm_list; p != NULL; p = nextSibling(p)) { - if (Getattr(p, "tmap:throws") != NULL) { + for (Parm *p = throw_parm_list; p; p = nextSibling(p)) { + if (Getattr(p, "tmap:throws")) { if (first) { first = false; } else { @@ -3660,7 +3658,7 @@ private: *--------------------------------------------------------------------*/ int makeDispatchFunction(Node *n, String *go_name, String *receiver, bool is_static, SwigType *director_struct, bool is_upcall) { - bool is_director = director_struct != NULL; + bool is_director = director_struct ? true : false; String *nodetype = Getattr(n, "nodeType"); bool is_constructor = Cmp(nodetype, "constructor") == 0; @@ -3670,7 +3668,7 @@ private: bool use_receiver = (!is_static && can_use_receiver); - bool add_to_interface = (interfaces != NULL && !is_constructor && !is_destructor && !is_static && !is_upcall); + bool add_to_interface = (interfaces && !is_constructor && !is_destructor && !is_static && !is_upcall); List *dispatch = Swig_overload_rank(n, false); int nfunc = Len(dispatch); @@ -3692,17 +3690,17 @@ private: for (int i = 0; i < nfunc; ++i) { Node *ni = Getitem(dispatch, i); SwigType *result = Getattr(ni, "go:type"); - assert(result != NULL); + assert(result); if (SwigType_type(result) == T_VOID) { - if (all_result != NULL) { + if (all_result) { mismatch = true; } any_void = true; } else { if (any_void) { mismatch = true; - } else if (all_result == NULL) { + } else if (!all_result) { all_result = Copy(result); } else if (Cmp(result, all_result) != 0) { mismatch = true; @@ -3712,7 +3710,7 @@ private: if (mismatch) { Delete(all_result); all_result = NULL; - } else if (all_result != NULL) { + } else if (all_result) { ; } else { all_result = NewString("void"); @@ -3721,7 +3719,7 @@ private: Printv(f_go_wrappers, "func ", NULL); - if (receiver != NULL && use_receiver) { + if (receiver && use_receiver) { Printv(f_go_wrappers, "(p ", receiver, ") ", NULL); } @@ -3745,7 +3743,7 @@ private: if (add_to_interface) { Printv(interfaces, " interface{}", NULL); } - } else if (all_result != NULL && SwigType_type(all_result) != T_VOID) { + } else if (all_result && SwigType_type(all_result) != T_VOID) { if (is_director && is_constructor) { Printv(f_go_wrappers, " ", receiver, NULL); if (add_to_interface) { @@ -3775,9 +3773,9 @@ private: // If we are using a receiver, we want to ignore a leading self // parameter. Because of the way this is called, there may or // may not be a self parameter at this point. - if (use_receiver && pi != NULL && Getattr(pi, "self") != NULL) { + if (use_receiver && pi && Getattr(pi, "self")) { pi = getParm(pi); - if (pi != NULL) { + if (pi) { pi = nextParm(pi); } } @@ -3801,9 +3799,9 @@ private: for (int k = i + 1; k < nfunc; ++k) { Node *nk = Getitem(dispatch, k); Parm *pk = Getattr(nk, "wrap:parms"); - if (use_receiver && pk != NULL && Getattr(pk, "self") != NULL) { + if (use_receiver && pk && Getattr(pk, "self")) { pk = getParm(pk); - if (pk != NULL) { + if (pk) { pk = nextParm(pk); } } @@ -3820,9 +3818,9 @@ private: if (Len(coll) > 0 && num_arguments > 0) { int j = 0; Parm *pj = pi; - while (pj != NULL) { + while (pj) { pj = getParm(pj); - if (pj == NULL) { + if (!pj) { break; } @@ -3833,9 +3831,9 @@ private: for (int k = 0; k < Len(coll) && !emitcheck; ++k) { Node *nk = Getitem(coll, k); Parm *pk = Getattr(nk, "wrap:parms"); - if (use_receiver && pk != NULL && Getattr(pk, "self") != NULL) { + if (use_receiver && pk && Getattr(pk, "self")) { pk = getParm(pk); - if (pk != NULL) { + if (pk) { pk = nextParm(pk); } } @@ -3844,9 +3842,9 @@ private: continue; int l = 0; Parm *pl = pk; - while (pl != NULL && l <= j) { + while (pl && l <= j) { pl = getParm(pl); - if (pl == NULL) { + if (!pl) { break; } if (l == j) { @@ -3898,15 +3896,15 @@ private: result = NULL; } - if (result != NULL && SwigType_type(result) != T_VOID && (all_result == NULL || SwigType_type(all_result) != T_VOID)) { + if (result && SwigType_type(result) != T_VOID && (!all_result || SwigType_type(all_result) != T_VOID)) { Printv(start, "return ", NULL); } bool advance_parm = false; - if (receiver != NULL && use_receiver) { + if (receiver && use_receiver) { Printv(start, "p.", go_name, NULL); - } else if (can_use_receiver && !isStatic(ni) && pi != NULL && Getattr(pi, "self") != NULL) { + } else if (can_use_receiver && !isStatic(ni) && pi && Getattr(pi, "self")) { // This is an overload of a static function and a non-static // function. assert(num_required > 0); @@ -3936,7 +3934,7 @@ private: int pn = 0; if (advance_parm) { p = getParm(p); - if (p != NULL) { + if (p) { p = nextParm(p); } ++pn; @@ -3958,17 +3956,17 @@ private: } String *end = NULL; - if (result == NULL || SwigType_type(result) == T_VOID || (all_result != NULL && SwigType_type(all_result) == T_VOID)) { + if (!result || SwigType_type(result) == T_VOID || (all_result && SwigType_type(all_result) == T_VOID)) { end = NewString(""); Printv(end, "return", NULL); - if (all_result == NULL || SwigType_type(all_result) != T_VOID) { + if (!all_result || SwigType_type(all_result) != T_VOID) { Printv(end, " 0", NULL); } } if (num_required == num_arguments) { Printv(f_go_wrappers, "\t\t", start, ")\n", NULL); - if (end != NULL) { + if (end) { Printv(f_go_wrappers, "\t\t", end, "\n", NULL); } } else { @@ -3985,7 +3983,7 @@ private: nc = true; } Printv(f_go_wrappers, ")\n", NULL); - if (end != NULL) { + if (end) { Printv(f_go_wrappers, "\t\t\t", end, "\n", NULL); } } @@ -4058,7 +4056,7 @@ private: String *removeClassname(String *name) { String *copy = Copy(name); - if (class_name != NULL) { + if (class_name) { char *p = Char(name); if (Strncmp(name, class_name, Len(class_name)) == 0 && p[Len(class_name)] == '_') { Replace(copy, class_name, "", DOH_REPLACE_FIRST); @@ -4080,7 +4078,7 @@ private: String *buildGoName(String *name, bool is_static, bool is_friend) { String *nw = NewString(""); - if (is_static && !is_friend && class_name != NULL) { + if (is_static && !is_friend && class_name) { String *c1 = exportedName(class_name); Append(nw, c1); Delete(c1); @@ -4109,7 +4107,7 @@ private: Append(s1, name); String *s2 = Swig_name_mangle(s1); Delete(s1); - if (overname != NULL) { + if (overname) { Append(s2, overname); } return s2; @@ -4126,13 +4124,13 @@ private: bool checkNameConflict(String* name, Node* n, const_String_or_char_ptr scope) { Node *lk = symbolLookup(name, scope); - if (lk != NULL) { + if (lk) { String *n1 = Getattr(n, "sym:name"); - if (n1 == NULL) { + if (!n1) { n1 = Getattr(n, "name"); } String *n2 = Getattr(lk, "sym:name"); - if (n2 == NULL) { + if (!n2) { n2 = Getattr(lk, "name"); } Swig_warning(WARN_GO_NAME_CONFLICT, input_file, line_number, @@ -4155,7 +4153,7 @@ private: bool checkIgnoredParameters(Node *n, String *go_name) { ParmList *parms = Getattr(n, "parms"); - if (parms != NULL) { + if (parms) { Wrapper *dummy = NewWrapper(); emit_attach_parmmaps(parms, dummy); int parm_count = emit_num_arguments(parms); @@ -4197,13 +4195,13 @@ private: bool ret = true; bool is_conflict = false; Node *e = Language::enumLookup(t); - if (e != NULL) { + if (e) { if (GetFlag(e, "go:conflict")) { is_conflict = true; } } else if (SwigType_issimple(t)) { Node *cn = classLookup(t); - if (cn != NULL) { + if (cn) { if (GetFlag(cn, "go:conflict")) { is_conflict = true; } @@ -4264,17 +4262,17 @@ private: * ---------------------------------------------------------------------- */ String *goTypeWithInfo(Node *n, SwigType *type, bool *p_is_interface) { - if (p_is_interface != NULL) { + if (p_is_interface) { *p_is_interface = false; } String *ret; - if (n != NULL && Cmp(type, Getattr(n, "type")) == 0) { + if (n && Cmp(type, Getattr(n, "type")) == 0) { ret = NULL; if (Strcmp(Getattr(n, "nodeType"), "parm") == 0) { ret = Getattr(n, "tmap:gotype"); } - if (ret == NULL) { + if (!ret) { ret = Swig_typemap_lookup("gotype", n, "", NULL); } } else { @@ -4283,18 +4281,18 @@ private: Delete(p); } - if (Strstr(ret, "$gotypename") != NULL) { + if (Strstr(ret, "$gotypename") != 0) { ret = NULL; } - if (ret != NULL) { + if (ret) { return Copy(ret); } SwigType *t = SwigType_typedef_resolve_all(type); Node *e = Language::enumLookup(t); - if (e != NULL) { + if (e) { ret = goEnumName(e); } else if (Strcmp(t, "enum ") == 0) { ret = NewString("int"); @@ -4304,15 +4302,15 @@ private: ret = NewString("_swig_memberptr"); } else if (SwigType_issimple(t)) { Node *cn = classLookup(t); - if (cn != NULL) { + if (cn) { ret = Getattr(cn, "sym:name"); - if (ret == NULL) { + if (!ret) { ret = Getattr(cn, "name"); } ret = exportedName(ret); Node *cnmod = Getattr(cn, "module"); - if (cnmod == NULL || Strcmp(Getattr(cnmod, "name"), package) == 0) { + if (!cnmod || Strcmp(Getattr(cnmod, "name"), package) == 0) { Setattr(undefined_types, t, t); } else { String *nw = NewString(""); @@ -4325,7 +4323,7 @@ private: ret = exportedName(t); Setattr(undefined_types, t, t); } - if (p_is_interface != NULL) { + if (p_is_interface) { *p_is_interface = true; } } else if (SwigType_ispointer(t) || SwigType_isarray(t)) { @@ -4369,7 +4367,7 @@ private: if (is_interface) { if (!is_pointer_to_pointer) { ret = base; - if (p_is_interface != NULL) { + if (p_is_interface) { *p_is_interface = true; } } else { @@ -4415,7 +4413,7 @@ private: Delete(t); - if (ret == NULL) { + if (!ret) { Swig_warning(WARN_LANG_NATIVE_UNIMPL, input_file, line_number, "No Go typemap defined for %s\n", SwigType_str(type, 0)); ret = NewString("uintptr"); } @@ -4478,7 +4476,7 @@ private: Node *cn = classLookup(ty); String *ex; String *ret; - if (cn == NULL) { + if (!cn) { if (add_to_hash) { Setattr(undefined_types, ty, ty); } @@ -4487,12 +4485,12 @@ private: Append(ret, ex); } else { String *cname = Getattr(cn, "sym:name"); - if (cname == NULL) { + if (!cname) { cname = Getattr(cn, "name"); } ex = exportedName(cname); Node *cnmod = Getattr(cn, "module"); - if (cnmod == NULL || Strcmp(Getattr(cnmod, "name"), package) == 0) { + if (!cnmod || Strcmp(Getattr(cnmod, "name"), package) == 0) { if (add_to_hash) { Setattr(undefined_types, ty, ty); } @@ -4625,7 +4623,7 @@ private: Parm *p = NewParmWithoutFileLineInfo(type, "test"); SwigType *tm = Swig_typemap_lookup("gotype", p, "", NULL); Delete(p); - if (tm != NULL && Strstr(tm, "$gotypename") == NULL) { + if (tm && Strstr(tm, "$gotypename") == 0) { Delete(tm); return true; } @@ -4641,7 +4639,7 @@ private: String *goEnumName(Node *n) { String *ret = Getattr(n, "go:enumname"); - if (ret != NULL) { + if (ret) { return Copy(ret); } @@ -4650,7 +4648,7 @@ private: } String *type = Getattr(n, "enumtype"); - assert(type != NULL); + assert(type); char *p = Char(type); int len = Len(type); String *s = NewString(""); @@ -4682,7 +4680,7 @@ private: * ---------------------------------------------------------------------- */ Parm *getParm(Parm *p) { - while (p != NULL && checkAttribute(p, "tmap:in:numinputs", "0")) { + while (p && checkAttribute(p, "tmap:in:numinputs", "0")) { p = Getattr(p, "tmap:in:next"); } return p; @@ -4695,9 +4693,9 @@ private: * ---------------------------------------------------------------------- */ Parm *nextParm(Parm *p) { - if (p == NULL) { + if (!p) { return NULL; - } else if (Getattr(p, "tmap:in") != NULL) { + } else if (Getattr(p, "tmap:in")) { return Getattr(p, "tmap:in:next"); } else { return nextSibling(p); @@ -4713,8 +4711,7 @@ private: bool isStatic(Node *n) { String *storage = Getattr(n, "storage"); - return (storage != NULL && (Strcmp(storage, "static") == 0 || Strcmp(storage, "friend") == 0) - && (!SmartPointer || Getattr(n, "allocate:smartpointeraccess") == NULL)); + return (storage && (Strcmp(storage, "static") == 0 || Strcmp(storage, "friend") == 0) && (!SmartPointer || !Getattr(n, "allocate:smartpointeraccess"))); } /* ---------------------------------------------------------------------- @@ -4725,7 +4722,7 @@ private: bool isFriend(Node *n) { String *storage = Getattr(n, "storage"); - return storage != NULL && Strcmp(storage, "friend") == 0; + return storage && Strcmp(storage, "friend") == 0; } }; /* class GO */ diff --git a/Source/Modules/guile.cxx b/Source/Modules/guile.cxx index 029978ede..fc0418496 100644 --- a/Source/Modules/guile.cxx +++ b/Source/Modules/guile.cxx @@ -114,7 +114,7 @@ static String *memberfunction_name = 0; extern "C" { static int has_classname(Node *class_node) { - return Getattr(class_node, "guile:goopsclassname") != NULL; + return Getattr(class_node, "guile:goopsclassname") ? 1 : 0; } } @@ -254,7 +254,7 @@ public: } // set default value for primsuffix - if (primsuffix == NULL) + if (!primsuffix) primsuffix = NewString("primitive"); //goops support can only be enabled if passive or module linkage is used @@ -628,7 +628,7 @@ public: if (maybe_delimiter && Len(output) > 0 && Len(tm) > 0) { Printv(output, maybe_delimiter, NIL); } - const String *pn = (name == NULL) ? (const String *) Getattr(p, "name") : name; + const String *pn = !name ? (const String *) Getattr(p, "name") : name; String *pt = Getattr(p, "type"); Replaceall(tm, "$name", pn); // legacy for $parmname Replaceall(tm, "$type", SwigType_str(pt, 0)); @@ -781,7 +781,7 @@ public: if (strcmp("void", Char(pt)) != 0) { Node *class_node = Swig_symbol_clookup_check(pb, Getattr(n, "sym:symtab"), has_classname); - String *goopsclassname = (class_node == NULL) ? NULL : Getattr(class_node, "guile:goopsclassname"); + String *goopsclassname = !class_node ? NULL : Getattr(class_node, "guile:goopsclassname"); /* do input conversion */ if (goopsclassname) { Printv(method_signature, " (", argname, " ", goopsclassname, ")", NIL); diff --git a/Source/Modules/lang.cxx b/Source/Modules/lang.cxx index 83103180c..f5055ae4b 100644 --- a/Source/Modules/lang.cxx +++ b/Source/Modules/lang.cxx @@ -2996,7 +2996,7 @@ void Language::dumpSymbols() { Node *Language::symbolLookup(String *s, const_String_or_char_ptr scope) { Hash *symbols = Getattr(symtabs, scope ? scope : ""); - if (symbols == NULL) { + if (!symbols) { return NULL; } return Getattr(symbols, s); diff --git a/Source/Modules/modula3.cxx b/Source/Modules/modula3.cxx index 602b43d4f..edd6690ce 100644 --- a/Source/Modules/modula3.cxx +++ b/Source/Modules/modula3.cxx @@ -1324,7 +1324,7 @@ MODULA3(): Parm *p; attachParameterNames(n, "tmap:name", "c:wrapname", "m3arg%d"); bool gencomma = false; - for (p = skipIgnored(l, "in"); p != NULL; p = skipIgnored(p, "in")) { + for (p = skipIgnored(l, "in"); p; p = skipIgnored(p, "in")) { String *arg = Getattr(p, "c:wrapname"); { @@ -1545,7 +1545,7 @@ MODULA3(): Parm *p; writeArgState state; attachParameterNames(n, "tmap:rawinname", "modula3:rawname", "arg%d"); - for (p = skipIgnored(l, "m3rawintype"); p != NULL; p = skipIgnored(p, "m3rawintype")) { + for (p = skipIgnored(l, "m3rawintype"); p; p = skipIgnored(p, "m3rawintype")) { /* Get argument passing mode, should be one of VALUE, VAR, READONLY */ String *mode = Getattr(p, "tmap:m3rawinmode"); @@ -1928,7 +1928,7 @@ MODULA3(): } else if (Strcmp(code, "unsafe") == 0) { unsafe_module = true; } else if (Strcmp(code, "library") == 0) { - if (targetlibrary != NULL) { + if (targetlibrary) { Delete(targetlibrary); } targetlibrary = Copy(strvalue); diff --git a/Source/Modules/ocaml.cxx b/Source/Modules/ocaml.cxx index 4c266a7ab..82e3f846a 100644 --- a/Source/Modules/ocaml.cxx +++ b/Source/Modules/ocaml.cxx @@ -1599,7 +1599,7 @@ public: tm = Getattr(n, "feature:director:except"); } if ((tm) && Len(tm) && (Strcmp(tm, "1") != 0)) { - Printf(w->code, "if (result == NULL) {\n"); + Printf(w->code, "if (!result) {\n"); Printf(w->code, " CAML_VALUE error = *caml_named_value(\"director_except\");\n"); Replaceall(tm, "$error", "error"); Printv(w->code, Str(tm), "\n", NIL); diff --git a/Source/Modules/octave.cxx b/Source/Modules/octave.cxx index 6c89794ec..ad425e3c8 100644 --- a/Source/Modules/octave.cxx +++ b/Source/Modules/octave.cxx @@ -1244,7 +1244,7 @@ public: idx = 0; p = l; int use_parse = 0; - while (p != NULL) { + while (p) { if (checkAttribute(p, "tmap:in:numinputs", "0")) { p = Getattr(p, "tmap:in:next"); continue; diff --git a/Source/Modules/perl5.cxx b/Source/Modules/perl5.cxx index f6ea029fe..01e557b1a 100644 --- a/Source/Modules/perl5.cxx +++ b/Source/Modules/perl5.cxx @@ -308,7 +308,7 @@ public: if (no_pmfile) { f_pm = NewString(0); } else { - if (pmfile == NULL) { + if (!pmfile) { char *m = Char(module) + Len(module); while (m != Char(module)) { if (*m == ':') { diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index e82c5041d..3a725ee1a 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -1206,7 +1206,7 @@ public: } if (!pname_cstr) { // Unnamed parameter, e.g. int foo(int); - } else if (pname == NULL) { + } else if (!pname) { pname = NewString(pname_cstr); } else { size_t len = strlen(pname_cstr); @@ -1290,7 +1290,7 @@ public: if (errno || *p) { Clear(value); Append(value, "?"); - } else if (strchr(Char(value), '.') == NULL) { + } else if (strchr(Char(value), '.') == 0) { // Ensure value is a double constant, not an integer one. Append(value, ".0"); double val2 = strtod(Char(value), &p); @@ -2496,7 +2496,7 @@ done: idx = 0; p = l; int use_parse = 0; - while (p != NULL) { + while (p) { if (checkAttribute(p, "tmap:in:numinputs", "0")) { p = Getattr(p, "tmap:in:next"); continue; diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 42a6b234f..fed5205e1 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -1073,7 +1073,7 @@ public: bool have_docstring(Node *n) { String *str = Getattr(n, "feature:docstring"); - return (str != NULL && Len(str) > 0) || (Getattr(n, "feature:autodoc") && !GetFlag(n, "feature:noautodoc")); + return (str && Len(str) > 0) || (Getattr(n, "feature:autodoc") && !GetFlag(n, "feature:noautodoc")); } /* ------------------------------------------------------------ @@ -1085,7 +1085,7 @@ public: String *docstring(Node *n, autodoc_t ad_type, const String *indent, bool use_triple = true) { String *str = Getattr(n, "feature:docstring"); - bool have_ds = (str != NULL && Len(str) > 0); + bool have_ds = (str && Len(str) > 0); bool have_auto = (Getattr(n, "feature:autodoc") && !GetFlag(n, "feature:noautodoc")); const char *triple_double = use_triple ? "\"\"\"" : ""; String *autodoc = NULL; @@ -1101,7 +1101,7 @@ public: if (have_auto) { autodoc = make_autodoc(n, ad_type); - have_auto = (autodoc != NULL && Len(autodoc) > 0); + have_auto = (autodoc && Len(autodoc) > 0); } // If there is more than one line then make docstrings like this: // @@ -1116,14 +1116,14 @@ public: doc = NewString(""); Printv(doc, triple_double, "\n", pythoncode(autodoc, indent), "\n", pythoncode(str, indent), indent, triple_double, NIL); } else if (!have_auto && have_ds) { // only docstring - if (Strchr(str, '\n') == NULL) { + if (Strchr(str, '\n') == 0) { doc = NewStringf("%s%s%s", triple_double, str, triple_double); } else { doc = NewString(""); Printv(doc, triple_double, "\n", pythoncode(str, indent), indent, triple_double, NIL); } } else if (have_auto && !have_ds) { // only autodoc - if (Strchr(autodoc, '\n') == NULL) { + if (Strchr(autodoc, '\n') == 0) { doc = NewStringf("%s%s%s", triple_double, autodoc, triple_double); } else { doc = NewString(""); @@ -1361,7 +1361,7 @@ public: { // Only do the autodoc if there isn't a docstring for the class String *str = Getattr(n, "feature:docstring"); - if (str == NULL || Len(str) == 0) { + if (!str || Len(str) == 0) { if (CPlusPlus) { Printf(doc, "Proxy of C++ %s class", real_classname); } else { @@ -1557,7 +1557,7 @@ public: bool have_pythonprepend(Node *n) { String *str = Getattr(n, "feature:pythonprepend"); - return (str != NULL && Len(str) > 0); + return (str && Len(str) > 0); } /* ------------------------------------------------------------ @@ -1584,7 +1584,7 @@ public: String *str = Getattr(n, "feature:pythonappend"); if (!str) str = Getattr(n, "feature:addtofunc"); - return (str != NULL && Len(str) > 0); + return (str && Len(str) > 0); } /* ------------------------------------------------------------ @@ -2741,7 +2741,7 @@ public: Printf(f_directors_h, " if (!method) {\n"); Printf(f_directors_h, " swig::SwigVar_PyObject name = SWIG_Python_str_FromChar(method_name);\n"); Printf(f_directors_h, " method = PyObject_GetAttr(swig_get_self(), name);\n"); - Printf(f_directors_h, " if (method == NULL) {\n"); + Printf(f_directors_h, " if (!method) {\n"); Printf(f_directors_h, " std::string msg = \"Method in class %s doesn't exist, undefined \";\n", classname); Printf(f_directors_h, " msg += method_name;\n"); Printf(f_directors_h, " Swig::DirectorMethodException::raise(msg.c_str());\n"); @@ -2904,7 +2904,7 @@ public: Printf(f_shadow, ":\n"); if (have_docstring(n)) { String *str = docstring(n, AUTODOC_CLASS, tab4); - if (str != NULL && Len(str)) + if (str && Len(str)) Printv(f_shadow, tab4, str, "\n", NIL); } if (!modern) { @@ -3723,7 +3723,7 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) { idx = 0; p = l; int use_parse = 0; - while (p != NULL) { + while (p) { if (checkAttribute(p, "tmap:in:numinputs", "0")) { p = Getattr(p, "tmap:in:next"); continue; @@ -3910,13 +3910,13 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) { if (tm) tm = Copy(tm); } - Append(w->code, "if (result == NULL) {\n"); + Append(w->code, "if (!result) {\n"); Append(w->code, " PyObject *error = PyErr_Occurred();\n"); if ((tm) && Len(tm) && (Strcmp(tm, "1") != 0)) { Replaceall(tm, "$error", "error"); Printv(w->code, Str(tm), "\n", NIL); } else { - Append(w->code, " if (error != NULL) {\n"); + Append(w->code, " if (error) {\n"); Printf(w->code, " Swig::DirectorMethodException::raise(\"Error detected when calling '%s.%s'\");\n", classname, pyname); Append(w->code, " }\n"); } diff --git a/Source/Modules/r.cxx b/Source/Modules/r.cxx index 8f5503743..749797c78 100644 --- a/Source/Modules/r.cxx +++ b/Source/Modules/r.cxx @@ -2514,7 +2514,7 @@ int R::membervariableHandler(Node *n) { int status(Language::membervariableHandler(n)); - if(opaqueClassDeclaration == NULL && debugMode) + if(!opaqueClassDeclaration && debugMode) Printf(stderr, " %s %s\n", Getattr(n, "name"), Getattr(n, "type")); processing_member_access_function = 0; diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx index 8fc41813f..bcdfd69d3 100644 --- a/Source/Modules/ruby.cxx +++ b/Source/Modules/ruby.cxx @@ -231,7 +231,7 @@ private: bool have_docstring(Node *n) { String *str = Getattr(n, "feature:docstring"); - return (str != NULL && Len(str) > 0) || (Getattr(n, "feature:autodoc") && !GetFlag(n, "feature:noautodoc")); + return (str && Len(str) > 0) || (Getattr(n, "feature:autodoc") && !GetFlag(n, "feature:noautodoc")); } /* ------------------------------------------------------------ @@ -244,7 +244,7 @@ private: String *docstring(Node *n, autodoc_t ad_type) { String *str = Getattr(n, "feature:docstring"); - bool have_ds = (str != NULL && Len(str) > 0); + bool have_ds = (str && Len(str) > 0); bool have_auto = (Getattr(n, "feature:autodoc") && !GetFlag(n, "feature:noautodoc")); String *autodoc = NULL; String *doc = NULL; @@ -259,7 +259,7 @@ private: if (have_auto) { autodoc = make_autodoc(n, ad_type); - have_auto = (autodoc != NULL && Len(autodoc) > 0); + have_auto = (autodoc && Len(autodoc) > 0); } // If there is more than one line then make docstrings like this: // @@ -272,14 +272,14 @@ private: doc = NewString(""); Printv(doc, "\n", autodoc, "\n", str, NIL); } else if (!have_auto && have_ds) { // only docstring - if (Strchr(str, '\n') == NULL) { + if (Strchr(str, '\n') == 0) { doc = NewString(str); } else { doc = NewString(""); Printv(doc, str, NIL); } } else if (have_auto && !have_ds) { // only autodoc - if (Strchr(autodoc, '\n') == NULL) { + if (Strchr(autodoc, '\n') == 0) { doc = NewStringf("%s", autodoc); } else { doc = NewString(""); @@ -618,7 +618,7 @@ private: { // Only do the autodoc if there isn't a docstring for the class String *str = Getattr(n, "feature:docstring"); - if (counter == 0 && (str == NULL || Len(str) == 0)) { + if (counter == 0 && (str == 0 || Len(str) == 0)) { if (CPlusPlus) { Printf(doc, " Proxy of C++ %s class", full_name); } else { diff --git a/Source/Swig/misc.c b/Source/Swig/misc.c index 2ba7827a1..f0a9155eb 100644 --- a/Source/Swig/misc.c +++ b/Source/Swig/misc.c @@ -1092,7 +1092,7 @@ String *Swig_string_strip(String *s) { } else { const char *cs = Char(s); const char *ce = Strchr(cs, ']'); - if (*cs != '[' || ce == NULL) { + if (*cs != '[' || !ce) { ns = NewString(s); } else { String *fmt = NewStringf("%%.%ds", ce-cs-1); From 49fb2f8550d569d25153cad1eacc825537445289 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 17 Jun 2010 23:54:21 +0000 Subject: [PATCH 0947/1680] Missing changes for rev 12123 to fix 'make partialcheck' for go git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12138 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/Makefile.in | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Examples/Makefile.in b/Examples/Makefile.in index 5960d79fb..582c75f29 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -1171,10 +1171,10 @@ go: $(SRCS) $(SWIG) -go $(GOSWIGARG) $(SWIGOPT) $(INTERFACEPATH) $(CC) -g -c $(CCSHARED) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO) - $(GO) -I . $(GOCOMPILEARG) $(GOSRCS) + $(COMPILETOOL) $(GO) -I . $(GOCOMPILEARG) $(GOSRCS) if ! $(GOGCC) ; then \ - $(GOC) -I $${GOROOT}/pkg/$${GOOS}_$${GOARCH} $(GOCSRCS) && \ - gopack grc $(GOPACKAGE) $(GOGCOBJS) $(GOCSRCS:.c=.$(GOOBJEXT)); \ + $(COMPILETOOL) $(GOC) -I $${GOROOT}/pkg/$${GOOS}_$${GOARCH} $(GOCSRCS) && \ + $(COMPILETOOL) gopack grc $(GOPACKAGE) $(GOGCOBJS) $(GOCSRCS:.c=.$(GOOBJEXT)); \ fi # ---------------------------------------------------------------- @@ -1185,11 +1185,11 @@ go_cpp: $(SRCS) $(SWIG) -go -c++ $(GOSWIGARG) $(SWIGOPT) $(INTERFACEPATH) $(CXX) -g -c $(CCSHARED) $(CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO) - $(GO) -I . $(GOCOMPILEARG) $(GOSRCS) + $(COMPILETOOL) $(GO) -I . $(GOCOMPILEARG) $(GOSRCS) if ! $(GOGCC) ; then \ - $(GOC) -I $${GOROOT}/pkg/$${GOOS}_$${GOARCH} $(GOCSRCS) && \ - gopack grc $(GOPACKAGE) $(GOGCOBJS) $(GOCSRCS:.c=.$(GOOBJEXT)); \ - else true; fi + $(COMPILETOOL) $(GOC) -I $${GOROOT}/pkg/$${GOOS}_$${GOARCH} $(GOCSRCS) && \ + $(COMPILETOOL) gopack grc $(GOPACKAGE) $(GOGCOBJS) $(GOCSRCS:.c=.$(GOOBJEXT)); \ + fi # ----------------------------------------------------------------- # Running a Go example @@ -1198,11 +1198,11 @@ go_cpp: $(SRCS) go_run: runme.go $(GO) $(GOCOMPILEARG) runme.go if $(GOGCC) ; then \ - $(GO) -o runme runme.@OBJEXT@ $(GOGCCOBJS) $(LIBPREFIX)$(TARGET)$(SO); \ + $(COMPILETOOL) $(GO) -o runme runme.@OBJEXT@ $(GOGCCOBJS) $(LIBPREFIX)$(TARGET)$(SO); \ else \ - $(GOLD) -r $${GOROOT}/pkg/$${GOOS}_$${GOARCH}:. -o runme runme.$(GOOBJEXT); \ + $(COMPILETOOL) $(GOLD) -r $${GOROOT}/pkg/$${GOOS}_$${GOARCH}:. -o runme runme.$(GOOBJEXT); \ fi - env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH ./runme + env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) ./runme # ----------------------------------------------------------------- # Cleaning the Go examples From 6bd53139fbc2ee82c5578891a01d22e19f305936 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Sun, 20 Jun 2010 15:27:34 +0000 Subject: [PATCH 0948/1680] Fix typo in comment git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12139 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/swigrun.swg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/swigrun.swg b/Lib/swigrun.swg index a8e9ad74c..e5afb62c4 100644 --- a/Lib/swigrun.swg +++ b/Lib/swigrun.swg @@ -51,7 +51,7 @@ /* Flags/methods for returning states. - The SWIG conversion methods, as ConvertPtr, return and integer + The SWIG conversion methods, as ConvertPtr, return an integer that tells if the conversion was successful or not. And if not, an error code can be returned (see swigerrors.swg for the codes). From c4768e54cb27e01d1cc190e6849932503c59df81 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Mon, 21 Jun 2010 03:37:08 +0000 Subject: [PATCH 0949/1680] Fix grammatical error introduced by previous fix. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12140 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- LICENSE-UNIVERSITIES | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE-UNIVERSITIES b/LICENSE-UNIVERSITIES index 40042a84a..44fcaa13f 100644 --- a/LICENSE-UNIVERSITIES +++ b/LICENSE-UNIVERSITIES @@ -74,7 +74,7 @@ Permission is hereby granted, without written agreement and without license or royalty fees, to use, copy, modify, and distribute this software and its documentation for any purpose, provided that (1) The above copyright notice and the following paragraph -appears in all copies of the source code and (2) redistributions +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 From 9ed2d0165c4bc858ee84f39be1bf0158262e9933 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Mon, 21 Jun 2010 03:44:29 +0000 Subject: [PATCH 0950/1680] Fix comment typo. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12141 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Swig/cwrap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Swig/cwrap.c b/Source/Swig/cwrap.c index 539ae6e18..b8812563e 100644 --- a/Source/Swig/cwrap.c +++ b/Source/Swig/cwrap.c @@ -830,7 +830,7 @@ int Swig_MethodToFunction(Node *n, const_String_or_char_ptr nspace, String *clas These two lines just transfer the ownership of the 'this' pointer from the input to the output wrapping object. - This happens in python, but may also happens in other target + This happens in python, but may also happen in other target languages. */ if (GetFlag(n, "feature:self:disown")) { From 0bfeb75be2cd5a2080fbf365edfc9f22679b5f16 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 21 Jun 2010 06:18:54 +0000 Subject: [PATCH 0951/1680] update example version numbers and clarification of inputs git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12142 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Tools/mkwindows.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Tools/mkwindows.sh b/Tools/mkwindows.sh index fb2547e14..869fce01a 100755 --- a/Tools/mkwindows.sh +++ b/Tools/mkwindows.sh @@ -1,6 +1,7 @@ #!/bin/sh -# Build Windows distribution (swigwin-1.3.x.zip) -- requires running in either: +# Build Windows distribution (swigwin-2.0.x.zip) from source tarball (swig-2.0.x.tar.gz) +# Requires running in either: # - MinGW environment # - Linux using MinGW cross compiler # - Cygwin using MinGW compiler @@ -21,8 +22,8 @@ if test x$1 != x; then fi else echo "Usage: mkwindows.sh version [zip]" - echo " Build Windows distribution. Works on Cygwin, MinGW or Linux" - echo " version should be 1.3.x" + echo " Build SWIG Windows distribution from source tarball. Works on Cygwin, MinGW or Linux" + echo " version should be 2.0.x" echo " zip is full path to zip program - default is /c/cygwin/bin/zip on MinGW, zip on Linux and Cygwin" exit 1 fi From 4dd5ce25ee5f0f9ce88cc3bc759ff43f4267083f Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Tue, 22 Jun 2010 11:52:44 +0000 Subject: [PATCH 0952/1680] Fix typo. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12143 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Customization.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/Manual/Customization.html b/Doc/Manual/Customization.html index b43075991..7f164ac57 100644 --- a/Doc/Manual/Customization.html +++ b/Doc/Manual/Customization.html @@ -83,7 +83,7 @@ How the exception is handled depends on the target language, for example, Python

      When defined, the code enclosed in braces is inserted directly into the low-level wrapper functions. The special variable $action is one of a few -%exception special variable +%exception special variables supported and gets replaced with the actual operation to be performed (a function call, method invocation, attribute access, etc.). An exception handler remains in effect until it is explicitly deleted. This is done by using either %exception From 3f1b4e40f35a6da99727b82c76f368cad627cb56 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Tue, 22 Jun 2010 13:02:08 +0000 Subject: [PATCH 0953/1680] Fix a typo in the documentation (inlne => inline) git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12144 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Arguments.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/Manual/Arguments.html b/Doc/Manual/Arguments.html index 8ab51faf6..1ae9a6d2f 100644 --- a/Doc/Manual/Arguments.html +++ b/Doc/Manual/Arguments.html @@ -81,7 +81,7 @@ One way to deal with this is to use the %include "typemaps.i" %apply double *OUTPUT { double *result }; -%inlne %{ +%inline %{ extern void add(double a, double b, double *result); %} From 0d7863c8104ecb5d2b452126f3bc819021fae652 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Thu, 24 Jun 2010 14:16:16 +0000 Subject: [PATCH 0954/1680] Wrapping pointer to member function types is likely to be rare, so use %fragment to only pull in the required machinery if it is going to be used. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12145 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/php/globalvar.i | 2 +- Lib/php/php.swg | 2 +- Lib/php/phpinit.swg | 14 +++++++++++++- Lib/php/phprun.swg | 9 --------- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/Lib/php/globalvar.i b/Lib/php/globalvar.i index 17f4995a6..9a8e84d6e 100644 --- a/Lib/php/globalvar.i +++ b/Lib/php/globalvar.i @@ -223,7 +223,7 @@ $1 = ($1_ltype)_temp; } -%typemap(varin) SWIGTYPE (CLASS::*) +%typemap(varin, fragment="swig_php_init_member_ptr") SWIGTYPE (CLASS::*) { zval **z_var; diff --git a/Lib/php/php.swg b/Lib/php/php.swg index 2471a0992..4ce55b4eb 100644 --- a/Lib/php/php.swg +++ b/Lib/php/php.swg @@ -362,7 +362,7 @@ SWIG_SetPointerZval(return_value, (void *)&$1, $1_descriptor, $owner); } -%typemap(in) SWIGTYPE (CLASS::*) +%typemap(in, fragment="swig_php_init_member_ptr") SWIGTYPE (CLASS::*) { void * p = (void*)zend_fetch_resource($input TSRMLS_CC, -1, SWIG_MEMBER_PTR, NULL, 1, le_member_ptr); memcpy(&$1, p, sizeof($1)); diff --git a/Lib/php/phpinit.swg b/Lib/php/phpinit.swg index 5d8278ba4..777d7723a 100644 --- a/Lib/php/phpinit.swg +++ b/Lib/php/phpinit.swg @@ -8,6 +8,18 @@ %init %{ SWIG_php_minit { SWIG_InitializeModule(0); - le_member_ptr = zend_register_list_destructors_ex(member_ptr_dtor, NULL, SWIG_MEMBER_PTR, module_number); %} +%fragment("swig_php_init_member_ptr2", "header") { +#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; +} + +%fragment("swig_php_init_member_ptr", "init", fragment="swig_php_init_member_ptr2") { + 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 a7573f35d..a4417fe68 100644 --- a/Lib/php/phprun.swg +++ b/Lib/php/phprun.swg @@ -259,12 +259,3 @@ 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 ae40eff993caca94cbb92b596350996365969202 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Thu, 24 Jun 2010 14:44:06 +0000 Subject: [PATCH 0955/1680] The default visibility for methods is public, so don't specify that explicitly to keep the wrapper size down. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12146 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/php.cxx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index 3a725ee1a..47afa7d1d 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -1575,14 +1575,21 @@ public: } if (Getattr(n, "access") && haspublicbase) { Delete(acc); - acc = NewString("public"); + acc = NewStringEmpty(); // implicitly public Swig_warning(WARN_PHP_PUBLIC_BASE, input_file, line_number, Char(warnmsg)); Delete(warnmsg); } } - if (Cmp(acc, "") != 0) { + + if (Cmp(acc, "public") == 0) { + // The default visibility for methods is public, so don't specify + // that explicitly to keep the wrapper size down. + Delete(acc); + acc = NewStringEmpty(); + } else if (Cmp(acc, "") != 0) { Append(acc, " "); } + if (constructor) { const char * arg0; if (max_num_of_arguments > 0) { From b946430c8aee3de17dc425433520becd2f665cf0 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 24 Jun 2010 19:33:21 +0000 Subject: [PATCH 0956/1680] Remove potential symbol clash with wrapped code (php) git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12147 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/php/globalvar.i | 6 +++--- Lib/php/php.swg | 4 ++-- Lib/php/phpinit.swg | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Lib/php/globalvar.i b/Lib/php/globalvar.i index 9a8e84d6e..d0b4ffe0a 100644 --- a/Lib/php/globalvar.i +++ b/Lib/php/globalvar.i @@ -108,7 +108,7 @@ memcpy(p, &$1, sizeof($1)); zval * resource; MAKE_STD_ZVAL(resource); - ZEND_REGISTER_RESOURCE(resource, p, le_member_ptr); + ZEND_REGISTER_RESOURCE(resource, p, swig_member_ptr); zend_hash_add(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void*)&resource, sizeof(zval *), NULL); } @@ -228,7 +228,7 @@ 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); + void * p = (void*)zend_fetch_resource(*z_var TSRMLS_CC, -1, SWIG_MEMBER_PTR, NULL, 1, swig_member_ptr); memcpy(&$1, p, sizeof($1)); } @@ -350,6 +350,6 @@ deliberate error cos this code looks bogus to me memcpy(p, &$1, sizeof($1)); zval * resource; MAKE_STD_ZVAL(resource); - ZEND_REGISTER_RESOURCE(resource, p, le_member_ptr); + ZEND_REGISTER_RESOURCE(resource, p, swig_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 4ce55b4eb..1ccf58246 100644 --- a/Lib/php/php.swg +++ b/Lib/php/php.swg @@ -357,14 +357,14 @@ memcpy(p, &$1, sizeof($1)); zval * resource; MAKE_STD_ZVAL(resource); - ZEND_REGISTER_RESOURCE(resource, p, le_member_ptr); + ZEND_REGISTER_RESOURCE(resource, p, swig_member_ptr); SWIG_SetPointerZval(return_value, (void *)&$1, $1_descriptor, $owner); } %typemap(in, fragment="swig_php_init_member_ptr") SWIGTYPE (CLASS::*) { - void * p = (void*)zend_fetch_resource($input TSRMLS_CC, -1, SWIG_MEMBER_PTR, NULL, 1, le_member_ptr); + void * p = (void*)zend_fetch_resource($input TSRMLS_CC, -1, SWIG_MEMBER_PTR, NULL, 1, swig_member_ptr); memcpy(&$1, p, sizeof($1)); } diff --git a/Lib/php/phpinit.swg b/Lib/php/phpinit.swg index 777d7723a..d4985c28d 100644 --- a/Lib/php/phpinit.swg +++ b/Lib/php/phpinit.swg @@ -17,9 +17,9 @@ static void member_ptr_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC) { efree(rsrc->ptr); } -static int le_member_ptr; +static int swig_member_ptr = 0; } %fragment("swig_php_init_member_ptr", "init", fragment="swig_php_init_member_ptr2") { - le_member_ptr = zend_register_list_destructors_ex(member_ptr_dtor, NULL, SWIG_MEMBER_PTR, module_number); + swig_member_ptr = zend_register_list_destructors_ex(member_ptr_dtor, NULL, SWIG_MEMBER_PTR, module_number); } From b36ae8aaf4acc021ff50aa088d1f3da0b163d00f Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Fri, 25 Jun 2010 01:48:33 +0000 Subject: [PATCH 0957/1680] Attach the swig_php_init_member_ptr fragment to all the typemaps which need it. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12148 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/php/globalvar.i | 4 ++-- Lib/php/php.swg | 2 +- Lib/php/phpinit.swg | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Lib/php/globalvar.i b/Lib/php/globalvar.i index d0b4ffe0a..45fb0223b 100644 --- a/Lib/php/globalvar.i +++ b/Lib/php/globalvar.i @@ -102,7 +102,7 @@ zend_hash_add(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void*)&z_var, sizeof(zval *), NULL); } -%typemap(varinit) SWIGTYPE (CLASS::*) +%typemap(varinit, fragment="swig_php_init_member_ptr") SWIGTYPE (CLASS::*) { void * p = emalloc(sizeof($1)); memcpy(p, &$1, sizeof($1)); @@ -344,7 +344,7 @@ deliberate error cos this code looks bogus to me SWIG_SetPointerZval(*z_var, (void*)$1, $1_descriptor, 0); } -%typemap(varout) SWIGTYPE (CLASS::*) +%typemap(varout, fragment="swig_php_init_member_ptr") SWIGTYPE (CLASS::*) { void * p = emalloc(sizeof($1)); memcpy(p, &$1, sizeof($1)); diff --git a/Lib/php/php.swg b/Lib/php/php.swg index 1ccf58246..f4cc8d2b2 100644 --- a/Lib/php/php.swg +++ b/Lib/php/php.swg @@ -351,7 +351,7 @@ SWIG_SetPointerZval($input, (void *)&$1_name, $1_descriptor, $owner); %} -%typemap(out) SWIGTYPE (CLASS::*) +%typemap(out, fragment="swig_php_init_member_ptr") SWIGTYPE (CLASS::*) { void * p = emalloc(sizeof($1)); memcpy(p, &$1, sizeof($1)); diff --git a/Lib/php/phpinit.swg b/Lib/php/phpinit.swg index d4985c28d..6e5cc29d2 100644 --- a/Lib/php/phpinit.swg +++ b/Lib/php/phpinit.swg @@ -13,7 +13,7 @@ %fragment("swig_php_init_member_ptr2", "header") { #define SWIG_MEMBER_PTR ((char*)"CLASS::*") -static void member_ptr_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC) { +static void swig_member_ptr_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC) { efree(rsrc->ptr); } @@ -21,5 +21,5 @@ static int swig_member_ptr = 0; } %fragment("swig_php_init_member_ptr", "init", fragment="swig_php_init_member_ptr2") { - swig_member_ptr = zend_register_list_destructors_ex(member_ptr_dtor, NULL, SWIG_MEMBER_PTR, module_number); + swig_member_ptr = zend_register_list_destructors_ex(swig_member_ptr_dtor, NULL, SWIG_MEMBER_PTR, module_number); } From d0d40db326f4e8412567e1404284033a41974487 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Fri, 25 Jun 2010 02:41:27 +0000 Subject: [PATCH 0958/1680] Use SWIG_PTR rather than literal "_cPtr". git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12149 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 47afa7d1d..365fcd370 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -1702,7 +1702,7 @@ public: 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"); + Printf(output, "\t\t\t$c->"SWIG_PTR" = $r;\n"); Printf(output, "\t\t\treturn $c;\n"); } Printf(output, "\t\t}\n\t\treturn $r;\n"); From cca92f4188b7ae98ed72b4952ee84ae67b003b34 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 7 Jul 2010 18:19:01 +0000 Subject: [PATCH 0959/1680] Fix #3024875 - shared_ptr of classes with non-public destructors. This also fixes the 'unref' feature when used on classes with non-public destructors. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12155 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 + .../csharp/li_boost_shared_ptr_bits_runme.cs | 3 + .../java/li_boost_shared_ptr_bits_runme.java | 3 + .../test-suite/li_boost_shared_ptr_bits.i | 78 +++++++++++++++++++ .../python/li_boost_shared_ptr_bits_runme.py | 3 + Source/Modules/lang.cxx | 2 +- 6 files changed, 92 insertions(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index 00d1bec5b..510ec0dfe 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,10 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.1 (in progress) =========================== +2010-07-08: wsfulton + Fix #3024875 - shared_ptr of classes with non-public destructors. This also fixes + the "unref" feature when used on classes with non-public destructors. + 2010-06-10: wsfulton [Lua] Fix SWIG_lua_isnilstring multiply defined when using multiple modules and wrapping strings. Patch from 'Number Cruncher'. diff --git a/Examples/test-suite/csharp/li_boost_shared_ptr_bits_runme.cs b/Examples/test-suite/csharp/li_boost_shared_ptr_bits_runme.cs index 2b8c84e1b..b4ec47f02 100644 --- a/Examples/test-suite/csharp/li_boost_shared_ptr_bits_runme.cs +++ b/Examples/test-suite/csharp/li_boost_shared_ptr_bits_runme.cs @@ -13,5 +13,8 @@ public class runme int sum = li_boost_shared_ptr_bits.sum(v); if (sum != 66) throw new ApplicationException("sum is wrong"); + + HiddenDestructor hidden = HiddenDestructor.create(); + hidden.Dispose(); } } diff --git a/Examples/test-suite/java/li_boost_shared_ptr_bits_runme.java b/Examples/test-suite/java/li_boost_shared_ptr_bits_runme.java index ffa0c5e64..d1489edf4 100644 --- a/Examples/test-suite/java/li_boost_shared_ptr_bits_runme.java +++ b/Examples/test-suite/java/li_boost_shared_ptr_bits_runme.java @@ -20,5 +20,8 @@ public class li_boost_shared_ptr_bits_runme { int sum = li_boost_shared_ptr_bits.sum(v); if (sum != 66) throw new RuntimeException("sum is wrong"); + + HiddenDestructor hidden = HiddenDestructor.create(); + hidden.delete(); } } diff --git a/Examples/test-suite/li_boost_shared_ptr_bits.i b/Examples/test-suite/li_boost_shared_ptr_bits.i index b43e1b137..7d6fa7b63 100644 --- a/Examples/test-suite/li_boost_shared_ptr_bits.i +++ b/Examples/test-suite/li_boost_shared_ptr_bits.i @@ -48,3 +48,81 @@ int sum(std::vector< boost::shared_ptr > v) { %template(VectorIntHolder) std::vector< boost::shared_ptr >; + +///////////////////////////////////////////////// +// Test non public destructor - was leading to memory leaks as the destructor was not wrapped +// Bug 3024875 +///////////////////////////////////////////////// + +%shared_ptr(HiddenDestructor) + +%inline %{ +class HiddenDestructor; +typedef boost::shared_ptr< HiddenDestructor > FooPtr; + +class HiddenDestructor { +public: + static FooPtr create(); + virtual void doit(); + +protected: + HiddenDestructor(); + static void Foo_body( FooPtr self ); + virtual ~HiddenDestructor(); +private: + HiddenDestructor( const HiddenDestructor& ); + class Impl; + Impl* impl_; + + class FooDeleter { + public: + void operator()(HiddenDestructor* hidden) { + delete hidden; + } + }; +}; +%} + +%{ +#include +using namespace std; + +/* Impl would generally hold a weak_ptr to HiddenDestructor a.s.o, but this stripped down example should suffice */ +class HiddenDestructor::Impl { +public: + int mymember; +}; + +FooPtr HiddenDestructor::create() +{ + FooPtr hidden( new HiddenDestructor(), HiddenDestructor::FooDeleter() ); + Foo_body( hidden ); + return hidden; +} + +void HiddenDestructor::doit() +{ + // whatever +} + +HiddenDestructor::HiddenDestructor() +{ +// cout << "HiddenDestructor::HiddenDestructor()" << endl; + // always empty +} + +void HiddenDestructor::Foo_body( FooPtr self ) +{ + // init self as you would do in ctor + self->impl_ = new Impl(); +} + +HiddenDestructor::~HiddenDestructor() +{ +// cout << "HiddenDestructor::~HiddenDestructor()" << endl; + // destruct (e.g. delete Pimpl object) + delete impl_; +} +%} +//////////////////////////// + diff --git a/Examples/test-suite/python/li_boost_shared_ptr_bits_runme.py b/Examples/test-suite/python/li_boost_shared_ptr_bits_runme.py index 9e5668e57..931317615 100644 --- a/Examples/test-suite/python/li_boost_shared_ptr_bits_runme.py +++ b/Examples/test-suite/python/li_boost_shared_ptr_bits_runme.py @@ -29,3 +29,6 @@ sum = sum(v) if sum != 66: raise "sum is wrong" +################################ +p = HiddenDestructor.create() + diff --git a/Source/Modules/lang.cxx b/Source/Modules/lang.cxx index f5055ae4b..e28fcbb89 100644 --- a/Source/Modules/lang.cxx +++ b/Source/Modules/lang.cxx @@ -2697,7 +2697,7 @@ int Language::destructorDeclaration(Node *n) { if (!CurrentClass) return SWIG_NOWRAP; - if (cplus_mode != PUBLIC) + if (cplus_mode != PUBLIC && !Getattr(CurrentClass, "feature:unref")) return SWIG_NOWRAP; if (ImportMode) return SWIG_NOWRAP; From 2d8b51684d74c206019d8d40ef0cbd9c33bd7cf8 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 16 Jul 2010 17:39:11 +0000 Subject: [PATCH 0960/1680] remove svn:executable property git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12156 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/python/iadd_runme.py | 0 Examples/test-suite/python/overload_complicated_runme.py | 0 Examples/test-suite/python/threads_exception_runme.py | 0 3 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 Examples/test-suite/python/iadd_runme.py mode change 100755 => 100644 Examples/test-suite/python/overload_complicated_runme.py mode change 100755 => 100644 Examples/test-suite/python/threads_exception_runme.py diff --git a/Examples/test-suite/python/iadd_runme.py b/Examples/test-suite/python/iadd_runme.py old mode 100755 new mode 100644 diff --git a/Examples/test-suite/python/overload_complicated_runme.py b/Examples/test-suite/python/overload_complicated_runme.py old mode 100755 new mode 100644 diff --git a/Examples/test-suite/python/threads_exception_runme.py b/Examples/test-suite/python/threads_exception_runme.py old mode 100755 new mode 100644 From 568607c5ea1479084276da13bb867092741f31c8 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 16 Jul 2010 18:45:22 +0000 Subject: [PATCH 0961/1680] Fix wrapping of function pointers and member function pointers when the function returns by reference git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12157 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 +++ Examples/test-suite/common.mk | 1 + Examples/test-suite/funcptr_cpp.i | 16 ++++++++++++ Examples/test-suite/member_pointer.i | 26 +++++++++++++++++++ .../test-suite/python/funcptr_cpp_runme.py | 9 +++++++ .../test-suite/python/member_pointer_runme.py | 3 +++ Source/Swig/stype.c | 12 ++++++--- 7 files changed, 67 insertions(+), 4 deletions(-) create mode 100644 Examples/test-suite/funcptr_cpp.i create mode 100644 Examples/test-suite/python/funcptr_cpp_runme.py diff --git a/CHANGES.current b/CHANGES.current index 510ec0dfe..63af7206d 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,10 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.1 (in progress) =========================== +2010-07-16: wsfulton + Fix wrapping of function pointers and member function pointers when the function + returns by reference. + 2010-07-08: wsfulton Fix #3024875 - shared_ptr of classes with non-public destructors. This also fixes the "unref" feature when used on classes with non-public destructors. diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 5033f1957..1463ce63c 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -201,6 +201,7 @@ CPP_TEST_CASES += \ features \ fragments \ friends \ + funcptr_cpp \ fvirtual \ global_namespace \ global_ns_arg \ diff --git a/Examples/test-suite/funcptr_cpp.i b/Examples/test-suite/funcptr_cpp.i new file mode 100644 index 000000000..d59f970ee --- /dev/null +++ b/Examples/test-suite/funcptr_cpp.i @@ -0,0 +1,16 @@ +%module funcptr_cpp + +%inline %{ + +int addByValue(const int &a, int b) { return a+b; } +int * addByPointer(const int &a, int b) { static int val; val = a+b; return &val; } +int & addByReference(const int &a, int b) { static int val; val = a+b; return val; } + +int call1(int (*d)(const int &, int), int a, int b) { return d(a, b); } +int call2(int * (*d)(const int &, int), int a, int b) { return *d(a, b); } +int call3(int & (*d)(const int &, int), int a, int b) { return d(a, b); } +%} + +%constant int (*ADD_BY_VALUE)(const int &, int) = addByValue; +%constant int * (*ADD_BY_POINTER)(const int &, int) = addByPointer; +%constant int & (*ADD_BY_REFERENCE)(const int &, int) = addByReference; diff --git a/Examples/test-suite/member_pointer.i b/Examples/test-suite/member_pointer.i index f03528cd5..d9d5cbef5 100644 --- a/Examples/test-suite/member_pointer.i +++ b/Examples/test-suite/member_pointer.i @@ -99,3 +99,29 @@ double (Shape::*perimetervar)(void) = &Shape::perimeter; %constant double (Shape::*PERIMPT)(void) = &Shape::perimeter; %constant double (Shape::*NULLPT)(void) = 0; +/* +%inline %{ + struct Funktions { + void retByRef(int & (*d)(double)) {} + }; + void byRef(int & (Funktions::*d)(double)) {} +%} +*/ + +%inline %{ + +struct Funktions { + int addByValue(const int &a, int b) { return a+b; } + int * addByPointer(const int &a, int b) { static int val; val = a+b; return &val; } + int & addByReference(const int &a, int b) { static int val; val = a+b; return val; } +}; + +int call1(int (Funktions::*d)(const int &, int), int a, int b) { Funktions f; return (f.*d)(a, b); } +int call2(int * (Funktions::*d)(const int &, int), int a, int b) { Funktions f; return *(f.*d)(a, b); } +int call3(int & (Funktions::*d)(const int &, int), int a, int b) { Funktions f; return (f.*d)(a, b); } +%} + +%constant int (Funktions::*ADD_BY_VALUE)(const int &, int) = &Funktions::addByValue; +%constant int * (Funktions::*ADD_BY_POINTER)(const int &, int) = &Funktions::addByPointer; +%constant int & (Funktions::*ADD_BY_REFERENCE)(const int &, int) = &Funktions::addByReference; + diff --git a/Examples/test-suite/python/funcptr_cpp_runme.py b/Examples/test-suite/python/funcptr_cpp_runme.py new file mode 100644 index 000000000..ae8616e94 --- /dev/null +++ b/Examples/test-suite/python/funcptr_cpp_runme.py @@ -0,0 +1,9 @@ +from funcptr_cpp import * + +if call1(ADD_BY_VALUE, 10, 11) != 21: + raise RuntimeError +if call2(ADD_BY_POINTER, 12, 13) != 25: + raise RuntimeError +if call3(ADD_BY_REFERENCE, 14, 15) != 29: + raise RuntimeError + diff --git a/Examples/test-suite/python/member_pointer_runme.py b/Examples/test-suite/python/member_pointer_runme.py index 27e7a483d..3d68e916d 100644 --- a/Examples/test-suite/python/member_pointer_runme.py +++ b/Examples/test-suite/python/member_pointer_runme.py @@ -41,3 +41,6 @@ memberPtr = NULLPT check ("Square area ", 100.0, do_op(s,AREAPT)) check ("Square perim", 40.0, do_op(s,PERIMPT)) +check ("Add by value", 3, call1(ADD_BY_VALUE, 1, 2)) +check ("Add by pointer", 7, call2(ADD_BY_POINTER, 3, 4)) +check ("Add by reference", 11, call3(ADD_BY_REFERENCE, 5, 6)) diff --git a/Source/Swig/stype.c b/Source/Swig/stype.c index c984d639b..dd2aea688 100644 --- a/Source/Swig/stype.c +++ b/Source/Swig/stype.c @@ -735,6 +735,7 @@ String *SwigType_rcaststr(SwigType *s, const_String_or_char_ptr name) { int clear = 1; int firstarray = 1; int isreference = 0; + int isfunction = 0; int isarray = 0; result = NewStringEmpty(); @@ -835,6 +836,7 @@ String *SwigType_rcaststr(SwigType *s, const_String_or_char_ptr name) { } Append(result, ")"); Delete(parms); + isfunction = 1; } else { String *bs = SwigType_namestr(element); Insert(result, 0, " "); @@ -850,10 +852,12 @@ String *SwigType_rcaststr(SwigType *s, const_String_or_char_ptr name) { cast = NewStringf("(%s)", result); } if (name) { - if (isreference) { - if (isarray) - Clear(cast); - Append(cast, "*"); + if (!isfunction) { + if (isreference) { + if (isarray) + Clear(cast); + Append(cast, "*"); + } } Append(cast, name); } From 53ad9822f5483c1c52cc41a23cd128ef753a3b67 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 17 Jul 2010 14:48:13 +0000 Subject: [PATCH 0962/1680] Fix for languages that don't have %shared_ptr macro git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12158 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/li_boost_shared_ptr_bits.i | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Examples/test-suite/li_boost_shared_ptr_bits.i b/Examples/test-suite/li_boost_shared_ptr_bits.i index 7d6fa7b63..610edb4b4 100644 --- a/Examples/test-suite/li_boost_shared_ptr_bits.i +++ b/Examples/test-suite/li_boost_shared_ptr_bits.i @@ -54,8 +54,12 @@ int sum(std::vector< boost::shared_ptr > v) { // Bug 3024875 ///////////////////////////////////////////////// +#if defined(SHARED_PTR_WRAPPERS_IMPLEMENTED) + %shared_ptr(HiddenDestructor) +#endif + %inline %{ class HiddenDestructor; typedef boost::shared_ptr< HiddenDestructor > FooPtr; From 7338f3993653f121e3fbd8158d625740a840b17b Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 18 Jul 2010 00:06:40 +0000 Subject: [PATCH 0963/1680] Fix out of source builds for the test-suite which broke in 1.3.37 git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12159 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/common.mk | 2 +- Examples/test-suite/csharp/Makefile.in | 1 - Examples/test-suite/java/Makefile.in | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 1463ce63c..c1952543f 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -69,7 +69,7 @@ INCLUDES = -I$(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE) LIBS = -L. LIBPREFIX = lib ACTION = check -INTERFACEDIR = ../ +INTERFACEDIR = $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/ # # Please keep test cases in alphabetical order. diff --git a/Examples/test-suite/csharp/Makefile.in b/Examples/test-suite/csharp/Makefile.in index afb29dfbf..5f50095a1 100644 --- a/Examples/test-suite/csharp/Makefile.in +++ b/Examples/test-suite/csharp/Makefile.in @@ -27,7 +27,6 @@ include $(srcdir)/../common.mk # Overridden variables here SWIGOPT += -namespace $*Namespace -INTERFACEDIR = ../../ CSHARPFLAGSSPECIAL = diff --git a/Examples/test-suite/java/Makefile.in b/Examples/test-suite/java/Makefile.in index 3cb7c0c53..ba225f6e9 100644 --- a/Examples/test-suite/java/Makefile.in +++ b/Examples/test-suite/java/Makefile.in @@ -39,7 +39,6 @@ include $(srcdir)/../common.mk # Overridden variables here JAVA_PACKAGE = $* SWIGOPT += -package $(JAVA_PACKAGE) -INTERFACEDIR = ../../ # Custom tests - tests with additional commandline options nspace.%: JAVA_PACKAGE = $*Package From a615d8dd1d27bcd0df78c90c15fc8cce4290360e Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 20 Jul 2010 22:58:37 +0000 Subject: [PATCH 0964/1680] minor clarification about directors git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12163 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Java.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html index f572ffa32..d014feef6 100644 --- a/Doc/Manual/Java.html +++ b/Doc/Manual/Java.html @@ -166,7 +166,7 @@ SWIG wraps C/C++ code using Java proxy classes and is very useful if you want to If only one or two JNI functions are needed then using SWIG may be overkill. SWIG enables a Java program to easily call into C/C++ code from Java. Historically, SWIG was not able to generate any code to call into Java code from C++. -However, SWIG now supports full cross language polymorphism and code is generated to call up from C++ to Java when wrapping C++ virtual methods. +However, SWIG now supports full cross language polymorphism and code is generated to call up from C++ to Java when wrapping C++ virtual methods via the director feature.

      From 1f939323a4e0700172db875ebd3ef9c9a7b4c33a Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 22 Jul 2010 16:59:08 +0000 Subject: [PATCH 0965/1680] Fix PYTHONPATH value when running Python tests outside source directory. PYTHONPATH needs to include the current directory and not (just) the source directory as the SWIG-generated files are produced here and not under the source directory when the top build directory is different from it. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12166 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/python/Makefile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/test-suite/python/Makefile.in b/Examples/test-suite/python/Makefile.in index 4938ddc27..a05542b70 100644 --- a/Examples/test-suite/python/Makefile.in +++ b/Examples/test-suite/python/Makefile.in @@ -117,7 +117,7 @@ VALGRIND_OPT += --suppressions=pythonswig.supp # Runs the testcase. A testcase is only run if # a file is found which has _runme.py (or _runme3.py for Python 3) appended after the testcase name. -run_python = env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PYTHONPATH=$(srcdir):$$PYTHONPATH $(RUNTOOL) $(PYTHON) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) +run_python = env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PYTHONPATH=.:$(srcdir):$$PYTHONPATH $(RUNTOOL) $(PYTHON) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) py2_runme = $(srcdir)/$(SCRIPTPREFIX)$*$(PY2SCRIPTSUFFIX) py3_runme = $(srcdir)/$(SCRIPTPREFIX)$*$(PY3SCRIPTSUFFIX) From ac5ddb03150577ab5d7f53bde0c1aa801e975855 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 22 Jul 2010 16:59:29 +0000 Subject: [PATCH 0966/1680] Make argument of DohWrite() const. Writing a buffer to a DOH object doesn't modify so it should be const. This allows the code using const pointers to pass them to DohWrite() without neither the casts nor gcc warnings. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12167 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/DOH/base.c | 2 +- Source/DOH/doh.h | 2 +- Source/DOH/dohint.h | 2 +- Source/DOH/file.c | 2 +- Source/DOH/string.c | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Source/DOH/base.c b/Source/DOH/base.c index 36ceb7ae3..cfbd2bdc4 100644 --- a/Source/DOH/base.c +++ b/Source/DOH/base.c @@ -645,7 +645,7 @@ int DohRead(DOH *obj, void *buffer, int length) { * DohWrite() * ----------------------------------------------------------------------------- */ -int DohWrite(DOH *obj, void *buffer, int length) { +int DohWrite(DOH *obj, const void *buffer, int length) { DohBase *b = (DohBase *) obj; DohObjInfo *objinfo; if (DohCheck(obj)) { diff --git a/Source/DOH/doh.h b/Source/DOH/doh.h index 1ed196058..e46d103de 100644 --- a/Source/DOH/doh.h +++ b/Source/DOH/doh.h @@ -221,7 +221,7 @@ extern int DohDelslice(DOH *obj, int sindex, int eindex); /* File methods */ -extern int DohWrite(DOHFile * obj, void *buffer, int length); +extern int DohWrite(DOHFile * obj, const void *buffer, int length); extern int DohRead(DOHFile * obj, void *buffer, int length); extern int DohSeek(DOHFile * obj, long offset, int whence); extern long DohTell(DOHFile * obj); diff --git a/Source/DOH/dohint.h b/Source/DOH/dohint.h index 661bed075..3d812b849 100644 --- a/Source/DOH/dohint.h +++ b/Source/DOH/dohint.h @@ -43,7 +43,7 @@ typedef struct { /* File methods */ typedef struct { int (*doh_read) (DOH *obj, void *buffer, int nbytes); /* Read bytes */ - int (*doh_write) (DOH *obj, void *buffer, int nbytes); /* Write bytes */ + int (*doh_write) (DOH *obj, const void *buffer, int nbytes); /* Write bytes */ int (*doh_putc) (DOH *obj, int ch); /* Put character */ int (*doh_getc) (DOH *obj); /* Get character */ int (*doh_ungetc) (DOH *obj, int ch); /* Unget character */ diff --git a/Source/DOH/file.c b/Source/DOH/file.c index a9ee332bf..11482fa7f 100644 --- a/Source/DOH/file.c +++ b/Source/DOH/file.c @@ -67,7 +67,7 @@ static int File_read(DOH *fo, void *buffer, int len) { * File_write() * ----------------------------------------------------------------------------- */ -static int File_write(DOH *fo, void *buffer, int len) { +static int File_write(DOH *fo, const void *buffer, int len) { DohFile *f = (DohFile *) ObjData(fo); if (f->filep) { int ret = (int) fwrite(buffer, 1, len, f->filep); diff --git a/Source/DOH/string.c b/Source/DOH/string.c index bd36c4094..05ae6e963 100644 --- a/Source/DOH/string.c +++ b/Source/DOH/string.c @@ -419,7 +419,7 @@ static int String_read(DOH *so, void *buffer, int len) { /* ----------------------------------------------------------------------------- * int String_write() - Write data to a string * ----------------------------------------------------------------------------- */ -static int String_write(DOH *so, void *buffer, int len) { +static int String_write(DOH *so, const void *buffer, int len) { int newlen; String *s = (String *) ObjData(so); s->hashkey = -1; From f2a5ef0c57767d972edc583c66ef31cb32a53b1c Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 22 Jul 2010 16:59:45 +0000 Subject: [PATCH 0967/1680] Document advanced %rename capabilities. Document the possibility to apply %rename to all declarations or only those of a particular type. Also document extended format strings used with it and the functions which can be used in them. Also clarify that %ignore is basically just a %rename alias. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12168 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/SWIG.html | 194 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 188 insertions(+), 6 deletions(-) diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html index d523bee77..e68003325 100644 --- a/Doc/Manual/SWIG.html +++ b/Doc/Manual/SWIG.html @@ -1661,6 +1661,7 @@ generate a warning message. Simply change the directives to %immutable;5.4.7 Renaming and ignoring declarations +

      5.4.7.1 Simple renaming of specific identifiers

      Normally, the name of a C declaration is used when that declaration is @@ -1741,12 +1742,6 @@ to add conditional compilation to the header. However, it should be stressed t declarations. If you need to remove a whole section of problematic code, the SWIG preprocessor should be used instead.

      -

      -More powerful variants of %rename and %ignore directives can be used to help -wrap C++ overloaded functions and methods or C++ methods which use default arguments. This is described in the -Ambiguity resolution and renaming section in the C++ chapter. -

      -

      Compatibility note: Older versions of SWIG provided a special %name directive for renaming declarations. For example: @@ -1763,6 +1758,193 @@ This directive is still supported, but it is deprecated and should probably be a directive is more powerful and better supports wrapping of raw header file information.

      +

      5.4.7.2 Advanced renaming support

      + +

      +While writing %rename for specific declarations is simple enough, +sometimes the same renaming rule needs to be applied to many, maybe all, +identifiers in the SWIG input. For example, it may be necessary to apply some +transformation to all the names in the target language to better follow its +naming conventions, e.g. add a specific prefix to all the functions. Doing it +for each function is impractical so SWIG supports applying a renaming rule to +all declarations if the name of the identifier to be renamed is not specified: +

      + +
      +
      +%rename("myprefix_%s") ""; // print -> myprefix_print
      +
      +
      + +

      +This also shows that the argument of %rename doesn't have to be a +literal string but can be a printf()-like format string. In the +simplest form, "%s" is replaced with the name of the original +declaration, as shown above. However this is not always enough and SWIG +provides extensions to the usual format string syntax to allow applying a +(SWIG-defined) function to the argument. For example, to wrap all C functions +do_something_long() as more Java-like doSomethingLong() you +can use the "lowercamelcase" extended format specifier like this: +

      + +
      +
      +%rename("%(lowercamelcase)s") ""; // foo_bar -> fooBar; FooBar -> fooBar
      +
      +
      + +

      +Some functions can be parametrized, for example the "strip" one +strips the provided prefix from its argument. The prefix is specified as part +of the format string, following a colon after the function name: +

      +
      +%rename("%(strip:[wx])s") ""; // wxHello -> Hello; FooBar -> fooBar
      +
      +
      +

      + +

      +Here is the table summarizing all currently defined functions with an example +of applying each one (notice that some of them have two names, a shorter one +and a more descriptive one, but the two functions are otherwise equivalent): +

      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      FunctionReturnsExample (in/out)
      upper or uppercaseUpper-case version of the string.PrintPRINT
      lower or lowercaseLower-case version of the string.Printprint
      titleString with first letter capitalized and the rest in lower case.printPrint
      firstuppercaseString with the first letter capitalized and the rest unchanged.printItPrintIt
      firstlowercaseString with the first letter in lower case and the rest unchanged.PrintItprintIt
      ctitle or camelcaseString with capitalized first letter and any letter following an + underscore (which are removed in the process) and rest in lower case.print_itPrintIt
      lctitle or lowercamelcaseString with every letter following an underscore (which is removed in + the process) capitalized and rest, including the first letter, in lower + case.print_itprintIt
      utitle or undercaseLower case string with underscores inserted before every upper-case + letter in the original string and any number not at the end of string. + Logically, this is the reverse of ccase.PrintItprint_it
      schemifyString with all underscores replaced with dashes, resulting in more + Lispers/Schemers-pleasing name.print_itprint-it
      strip:[prefix]String without the given prefix or the original string if it doesn't + start with this prefix. Note that square brackets should be used + literally, e.g. %rename("strip:[wx]")wxPrintPrint
      command:cmdOutput of an external command cmd with the string passed to + it as input. Notice that this function is extremely slow compared to all + the other ones as it involves spawning a separate process and using it for + many declarations is not recommended. The cmd is not enclosed in + square brackets but must be terminated with a triple '<' sign, + e.g. %rename("command:tr -d aeiou <<<") + (nonsensical example removing all vowels)PrintPrnt
      + +

      +As before, everything that was said above about %rename also applies to +%ignore. In fact, the latter is just a special case of the former and +ignoring an identifier is the same as renaming it to the special +"$ignore" value. So the following snippets +

      + +
      +
      +%ignore print;
      +
      +
      + +

      +and +

      + +
      +
      +%rename("$ignore") print;
      +
      +
      + +

      +are exactly equivalent and %rename can be used to selectively ignore +multiple declarations using the previously described matching possibilities. +

      + +

      5.4.7.3 Limiting global renaming rules

      + +

      +As explained in the previous sections, it is possible to either rename +individual declarations or apply a rename rule to all of them at once. In +practice, the latter is however rarely appropriate as there are always some +exceptions to the general rules. To deal with them, the scope of an unnamed +%rename can be limited using a second parameter. +

      + +

      +The simplest possibility is to match the declaration type, for example: +

      +
      +
      +%rename("%(title)s", %$isenumitem) "";
      +
      +
      +

      +will capitalize the names of all the enum elements but not change the case of +the other declarations. Similarly, %$isclass, %$isfunction +and %$isvariable can be used. Many other checks are possible and this +documentation is not exhaustive, see "%rename predicates" section of +Lib/swig.swg for the full list of supported match expressions. +

      + +

      +Finally, even more powerful variants of %rename and %ignore directives can be used to help +wrap C++ overloaded functions and methods or C++ methods which use default arguments. This is described in the +Ambiguity resolution and renaming section in the C++ chapter. +

      + +

      5.4.8 Default/optional arguments

      From 6399502719dcc04c816536d7a4231e0164b4402f Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 22 Jul 2010 17:00:16 +0000 Subject: [PATCH 0968/1680] Add a check for PCRE library to configure. We use standard AX_PATH_GENERIC() macro from Autoconf archive to do the check to keep our own code as simple as possible. Notice that this script must be used, just adding the include and library directories to {C,LD}FLAGS is not enough, notably -DPCRE_STATIC which is output by pcre-config for static builds only is crucial. Also use LIBS instead of LDFLAGS to fix linking when using static libraries. Also note that this allows to pass PCRE_CONFIG variable value to configure to force the use of the specified script (and not the one first found in PATH), which is especially important when cross-compiling. Finally, PCRE is required by default now, --without-pcre must be explicitly used to build without it. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12169 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Tools/config/ax_compare_version.m4 | 177 +++++++++++++++++++++++++++++ Tools/config/ax_path_generic.m4 | 142 +++++++++++++++++++++++ configure.in | 26 ++++- 3 files changed, 344 insertions(+), 1 deletion(-) create mode 100644 Tools/config/ax_compare_version.m4 create mode 100644 Tools/config/ax_path_generic.m4 diff --git a/Tools/config/ax_compare_version.m4 b/Tools/config/ax_compare_version.m4 new file mode 100644 index 000000000..74dc0fdd9 --- /dev/null +++ b/Tools/config/ax_compare_version.m4 @@ -0,0 +1,177 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_compare_version.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_COMPARE_VERSION(VERSION_A, OP, VERSION_B, [ACTION-IF-TRUE], [ACTION-IF-FALSE]) +# +# DESCRIPTION +# +# This macro compares two version strings. Due to the various number of +# minor-version numbers that can exist, and the fact that string +# comparisons are not compatible with numeric comparisons, this is not +# necessarily trivial to do in a autoconf script. This macro makes doing +# these comparisons easy. +# +# The six basic comparisons are available, as well as checking equality +# limited to a certain number of minor-version levels. +# +# The operator OP determines what type of comparison to do, and can be one +# of: +# +# eq - equal (test A == B) +# ne - not equal (test A != B) +# le - less than or equal (test A <= B) +# ge - greater than or equal (test A >= B) +# lt - less than (test A < B) +# gt - greater than (test A > B) +# +# Additionally, the eq and ne operator can have a number after it to limit +# the test to that number of minor versions. +# +# eq0 - equal up to the length of the shorter version +# ne0 - not equal up to the length of the shorter version +# eqN - equal up to N sub-version levels +# neN - not equal up to N sub-version levels +# +# When the condition is true, shell commands ACTION-IF-TRUE are run, +# otherwise shell commands ACTION-IF-FALSE are run. The environment +# variable 'ax_compare_version' is always set to either 'true' or 'false' +# as well. +# +# Examples: +# +# AX_COMPARE_VERSION([3.15.7],[lt],[3.15.8]) +# AX_COMPARE_VERSION([3.15],[lt],[3.15.8]) +# +# would both be true. +# +# AX_COMPARE_VERSION([3.15.7],[eq],[3.15.8]) +# AX_COMPARE_VERSION([3.15],[gt],[3.15.8]) +# +# would both be false. +# +# AX_COMPARE_VERSION([3.15.7],[eq2],[3.15.8]) +# +# would be true because it is only comparing two minor versions. +# +# AX_COMPARE_VERSION([3.15.7],[eq0],[3.15]) +# +# would be true because it is only comparing the lesser number of minor +# versions of the two values. +# +# Note: The characters that separate the version numbers do not matter. An +# empty string is the same as version 0. OP is evaluated by autoconf, not +# configure, so must be a string, not a variable. +# +# The author would like to acknowledge Guido Draheim whose advice about +# the m4_case and m4_ifvaln functions make this macro only include the +# portions necessary to perform the specific comparison specified by the +# OP argument in the final configure script. +# +# LICENSE +# +# Copyright (c) 2008 Tim Toolan +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 11 + +dnl ######################################################################### +AC_DEFUN([AX_COMPARE_VERSION], [ + AC_REQUIRE([AC_PROG_AWK]) + + # Used to indicate true or false condition + ax_compare_version=false + + # Convert the two version strings to be compared into a format that + # allows a simple string comparison. The end result is that a version + # string of the form 1.12.5-r617 will be converted to the form + # 0001001200050617. In other words, each number is zero padded to four + # digits, and non digits are removed. + AS_VAR_PUSHDEF([A],[ax_compare_version_A]) + A=`echo "$1" | sed -e 's/\([[0-9]]*\)/Z\1Z/g' \ + -e 's/Z\([[0-9]]\)Z/Z0\1Z/g' \ + -e 's/Z\([[0-9]][[0-9]]\)Z/Z0\1Z/g' \ + -e 's/Z\([[0-9]][[0-9]][[0-9]]\)Z/Z0\1Z/g' \ + -e 's/[[^0-9]]//g'` + + AS_VAR_PUSHDEF([B],[ax_compare_version_B]) + B=`echo "$3" | sed -e 's/\([[0-9]]*\)/Z\1Z/g' \ + -e 's/Z\([[0-9]]\)Z/Z0\1Z/g' \ + -e 's/Z\([[0-9]][[0-9]]\)Z/Z0\1Z/g' \ + -e 's/Z\([[0-9]][[0-9]][[0-9]]\)Z/Z0\1Z/g' \ + -e 's/[[^0-9]]//g'` + + dnl # In the case of le, ge, lt, and gt, the strings are sorted as necessary + dnl # then the first line is used to determine if the condition is true. + dnl # The sed right after the echo is to remove any indented white space. + m4_case(m4_tolower($2), + [lt],[ + ax_compare_version=`echo "x$A +x$B" | sed 's/^ *//' | sort -r | sed "s/x${A}/false/;s/x${B}/true/;1q"` + ], + [gt],[ + ax_compare_version=`echo "x$A +x$B" | sed 's/^ *//' | sort | sed "s/x${A}/false/;s/x${B}/true/;1q"` + ], + [le],[ + ax_compare_version=`echo "x$A +x$B" | sed 's/^ *//' | sort | sed "s/x${A}/true/;s/x${B}/false/;1q"` + ], + [ge],[ + ax_compare_version=`echo "x$A +x$B" | sed 's/^ *//' | sort -r | sed "s/x${A}/true/;s/x${B}/false/;1q"` + ],[ + dnl Split the operator from the subversion count if present. + m4_bmatch(m4_substr($2,2), + [0],[ + # A count of zero means use the length of the shorter version. + # Determine the number of characters in A and B. + ax_compare_version_len_A=`echo "$A" | $AWK '{print(length)}'` + ax_compare_version_len_B=`echo "$B" | $AWK '{print(length)}'` + + # Set A to no more than B's length and B to no more than A's length. + A=`echo "$A" | sed "s/\(.\{$ax_compare_version_len_B\}\).*/\1/"` + B=`echo "$B" | sed "s/\(.\{$ax_compare_version_len_A\}\).*/\1/"` + ], + [[0-9]+],[ + # A count greater than zero means use only that many subversions + A=`echo "$A" | sed "s/\(\([[0-9]]\{4\}\)\{m4_substr($2,2)\}\).*/\1/"` + B=`echo "$B" | sed "s/\(\([[0-9]]\{4\}\)\{m4_substr($2,2)\}\).*/\1/"` + ], + [.+],[ + AC_WARNING( + [illegal OP numeric parameter: $2]) + ],[]) + + # Pad zeros at end of numbers to make same length. + ax_compare_version_tmp_A="$A`echo $B | sed 's/./0/g'`" + B="$B`echo $A | sed 's/./0/g'`" + A="$ax_compare_version_tmp_A" + + # Check for equality or inequality as necessary. + m4_case(m4_tolower(m4_substr($2,0,2)), + [eq],[ + test "x$A" = "x$B" && ax_compare_version=true + ], + [ne],[ + test "x$A" != "x$B" && ax_compare_version=true + ],[ + AC_WARNING([illegal OP parameter: $2]) + ]) + ]) + + AS_VAR_POPDEF([A])dnl + AS_VAR_POPDEF([B])dnl + + dnl # Execute ACTION-IF-TRUE / ACTION-IF-FALSE. + if test "$ax_compare_version" = "true" ; then + m4_ifvaln([$4],[$4],[:])dnl + m4_ifvaln([$5],[else $5])dnl + fi +]) dnl AX_COMPARE_VERSION diff --git a/Tools/config/ax_path_generic.m4 b/Tools/config/ax_path_generic.m4 new file mode 100644 index 000000000..4db2da11b --- /dev/null +++ b/Tools/config/ax_path_generic.m4 @@ -0,0 +1,142 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_path_generic.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_PATH_GENERIC(LIBRARY,[MINIMUM-VERSION,[SED-EXPR-EXTRACTOR]],[ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND],[CONFIG-SCRIPTS],[CFLAGS-ARG],[LIBS-ARG]) +# +# DESCRIPTION +# +# Runs the LIBRARY-config script and defines LIBRARY_CFLAGS and +# LIBRARY_LIBS +# +# The script must support `--cflags' and `--libs' args. If MINIMUM-VERSION +# is specified, the script must also support the `--version' arg. If the +# `--with-library-[exec-]prefix' arguments to ./configure are given, it +# must also support `--prefix' and `--exec-prefix'. Prefereable use +# CONFIG-SCRIPTS as config script, CFLAGS-ARG instead of `--cflags` and +# LIBS-ARG instead of `--libs`, if given. +# +# The SED-EXPR-EXTRACTOR parameter representes the expression used in sed +# to extract the version number. Use it if your 'foo-config --version' +# dumps something like 'Foo library v1.0.0 (alfa)' instead of '1.0.0'. +# +# Example: +# +# AX_PATH_GENERIC(Foo, 1.0.0) +# +# would run `foo-config --version' and check that it is at least 1.0.0, if +# successful the following variables would be defined and substituted: +# +# FOO_CFLAGS to `foo-config --cflags` +# FOO_LIBS to `foo-config --libs` +# +# Example: +# +# AX_PATH_GENERIC([Bar],,,[ +# AC_MSG_ERROR([Cannot find Bar library]) +# ]) +# +# would check for bar-config program, defining and substituting the +# following variables: +# +# BAR_CFLAGS to `bar-config --cflags` +# BAR_LIBS to `bar-config --libs` +# +# This macro is a rearranged version of AC_PATH_GENERIC from Angus Lees. +# +# LICENSE +# +# Copyright (c) 2009 Francesco Salvestrini +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 10 + +AU_ALIAS([AC_PATH_GENERIC], [AX_PATH_GENERIC]) +AC_DEFUN([AX_PATH_GENERIC],[ + AC_REQUIRE([AC_PROG_SED]) + + dnl we're going to need uppercase and lowercase versions of the + dnl string `LIBRARY' + pushdef([UP], translit([$1], [a-z], [A-Z]))dnl + pushdef([DOWN], translit([$1], [A-Z], [a-z]))dnl + + AC_ARG_WITH(DOWN-prefix,[AS_HELP_STRING([--with-]DOWN[-prefix=PREFIX], [Prefix where $1 is installed (optional)])], + DOWN[]_config_prefix="$withval", DOWN[]_config_prefix="") + AC_ARG_WITH(DOWN-exec-prefix,[AS_HELP_STRING([--with-]DOWN[-exec-prefix=EPREFIX], [Exec prefix where $1 is installed (optional)])], + DOWN[]_config_exec_prefix="$withval", DOWN[]_config_exec_prefix="") + + AC_ARG_VAR(UP[]_CONFIG, [config script used for $1]) + AC_ARG_VAR(UP[]_CFLAGS, [CFLAGS used for $1]) + AC_ARG_VAR(UP[]_LIBS, [LIBS used for $1]) + + AS_IF([test x$DOWN[]_config_exec_prefix != x],[ + DOWN[]_config_args="$DOWN[]_config_args --exec-prefix=$DOWN[]_config_exec_prefix" + AS_IF([test x${UP[]_CONFIG+set} != xset],[ + UP[]_CONFIG=$DOWN[]_config_exec_prefix/bin/DOWN-config + ]) + ]) + AS_IF([test x$DOWN[]_config_prefix != x],[ + DOWN[]_config_args="$DOWN[]_config_args --prefix=$DOWN[]_config_prefix" + AS_IF([test x${UP[]_CONFIG+set} != xset],[ + UP[]_CONFIG=$DOWN[]_config_prefix/bin/DOWN-config + ]) + ]) + + AC_PATH_PROGS(UP[]_CONFIG,[$6 DOWN-config],[no]) + AS_IF([test "$UP[]_CONFIG" == "no"],[ + : + $5 + ],[ + dnl Get the CFLAGS from LIBRARY-config script + AS_IF([test x"$7" == x],[ + UP[]_CFLAGS="`$UP[]_CONFIG $DOWN[]_config_args --cflags`" + ],[ + UP[]_CFLAGS="`$UP[]_CONFIG $DOWN[]_config_args $7`" + ]) + + dnl Get the LIBS from LIBRARY-config script + AS_IF([test x"$8" == x],[ + UP[]_LIBS="`$UP[]_CONFIG $DOWN[]_config_args --libs`" + ],[ + UP[]_LIBS="`$UP[]_CONFIG $DOWN[]_config_args $8`" + ]) + + AS_IF([test x"$2" != x],[ + dnl Check for provided library version + AS_IF([test x"$3" != x],[ + dnl Use provided sed expression + DOWN[]_version="`$UP[]_CONFIG $DOWN[]_config_args --version | $SED -e $3`" + ],[ + DOWN[]_version="`$UP[]_CONFIG $DOWN[]_config_args --version | $SED -e 's/^\ *\(.*\)\ *$/\1/'`" + ]) + + AC_MSG_CHECKING([for $1 ($DOWN[]_version) >= $2]) + AX_COMPARE_VERSION($DOWN[]_version,[ge],[$2],[ + AC_MSG_RESULT([yes]) + + AC_SUBST(UP[]_CFLAGS) + AC_SUBST(UP[]_LIBS) + : + $4 + ],[ + AC_MSG_RESULT([no]) + : + $5 + ]) + ],[ + AC_SUBST(UP[]_CFLAGS) + AC_SUBST(UP[]_LIBS) + : + $4 + ]) + ]) + + popdef([UP]) + popdef([DOWN]) +]) diff --git a/configure.in b/configure.in index f08ad4615..e5e2752d9 100644 --- a/configure.in +++ b/configure.in @@ -49,7 +49,31 @@ else AC_CHECK_FUNC(popen, AC_DEFINE(HAVE_POPEN, 1, [Define if popen is available]), AC_MSG_NOTICE([Disabling popen])) fi -dnl Look for RxSpencer +dnl PCRE +AC_ARG_WITH([pcre], + [AS_HELP_STRING([--without-pcre], + [Disable support for regular expressions using PCRE])], + [], + [with_pcre=yes]) + +AS_IF([test "x$with_pcre" != xno], + [AX_PATH_GENERIC([pcre], + [], dnl Minimal version of PCRE we need -- accept any + [], dnl custom sed script for version parsing is not needed + [AC_DEFINE([HAVE_PCRE], [1], [Define if you have PCRE library]) + LIBS="$LIBS $PCRE_LIBS" + CPPFLAGS="$CPPFLAGS $PCRE_CFLAGS" + ], + [AC_MSG_FAILURE( + Can't find pcre-config script from PCRE (Perl Compatible Regular + Expressions) library package. You need to either download PCRE from + www.pcre.org and install it or use --without-pcre configure option to + disable regular expressions support in SWIG.) + ]) + ]) + + +dnl Look for RxSpencer AC_ARG_WITH(rxspencer, AS_HELP_STRING([--with-rxspencer], [Enable RxSpencer]), with_rxspencer="yes") if test x"${with_rxspencer}" = xyes ; then #check first for the header From c4e9043288e2136dd7ae9e0515ad79164ad00d95 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 22 Jul 2010 17:00:37 +0000 Subject: [PATCH 0969/1680] Add support for regex encoder for %rename. This allows to write %rename("%(regex:/pattern/subst/)s") to apply a regex-based replacement to a declaration name. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12170 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 12 +++++ Doc/Manual/SWIG.html | 12 +++++ Source/Swig/misc.c | 106 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 130 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 63af7206d..9954ae05b 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -9,6 +9,18 @@ Version 2.0.1 (in progress) Fix wrapping of function pointers and member function pointers when the function returns by reference. +2010-07-13: vadz + Add the new "regex" encoder that can be used in %rename, e.g. + + %rename("regex:/(\\w+)_(.*)/\\2/") ""; + + to remove any alphabetical prefix from all identifiers. The syntax + of the regular expressions is Perl-like and PCRE library + (http://www.pcre.org/) is used to implement this feature but notice + that backslashes need to be escaped as usual inside C strings. + + Original patch from Torsten Landschoff. + 2010-07-08: wsfulton Fix #3024875 - shared_ptr of classes with non-public destructors. This also fixes the "unref" feature when used on classes with non-public destructors. diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html index e68003325..3fb1e86cc 100644 --- a/Doc/Manual/SWIG.html +++ b/Doc/Manual/SWIG.html @@ -1871,6 +1871,18 @@ and a more descriptive one, but the two functions are otherwise equivalent): literally, e.g. %rename("strip:[wx]") wxPrintPrint + + regex:/pattern/subst/ + String after (Perl-like) regex substitution operation. This function + allows to apply arbitrary regular expressions to the identifier names. The + pattern part is a regular expression in Perl syntax (as supported + by PCRE) and the subst string + can contain back-references introduced by '\' or, as backslashes need + to be escaped in C strings, rather by "\\". For example, to remove + any alphabetic prefix before an underscore you could use the following directive: + %rename("regex:/(\\w+)_(.*)/\\2/") + Prefix_PrintPrint + command:cmd Output of an external command cmd with the string passed to diff --git a/Source/Swig/misc.c b/Source/Swig/misc.c index f0a9155eb..b23a99b60 100644 --- a/Source/Swig/misc.c +++ b/Source/Swig/misc.c @@ -1214,6 +1214,111 @@ String *Swig_string_rxspencer(String *s) { } #endif +#ifdef HAVE_PCRE +#include + +static int split_regex_pattern_subst(String *s, String **pattern, String **subst, const char **input) +{ + const char *pats, *pate; + const char *subs, *sube; + + /* Locate the search pattern */ + const char *p = Char(s); + if (*p++ != '/') goto err_out; + pats = p; + p = strchr(p, '/'); + if (!p) goto err_out; + pate = p; + + /* Locate the substitution string */ + subs = ++p; + p = strchr(p, '/'); + if (!p) goto err_out; + sube = p; + + *pattern = NewStringWithSize(pats, pate - pats); + *subst = NewStringWithSize(subs, sube - subs); + *input = p + 1; + return 1; + +err_out: + Swig_error("SWIG", Getline(s), "Invalid regex substitution: '%s'.\n", s); + exit(1); +} + +String *replace_captures(const char *input, String *subst, int captures[]) +{ + String *result = NewStringEmpty(); + const char *p = Char(subst); + + while (*p) { + /* Copy part without substitutions */ + const char *q = strchr(p, '\\'); + if (!q) { + Write(result, p, strlen(p)); + break; + } + Write(result, p, q - p); + p = q + 1; + + /* Handle substitution */ + if (*p == '\0') { + Putc('\\', result); + } else if (isdigit(*p)) { + int group = *p++ - '0'; + int l = captures[group*2], r = captures[group*2 + 1]; + if (l != -1) { + Write(result, input + l, r - l); + } + } + } + + return result; +} + +/* ----------------------------------------------------------------------------- + * Swig_string_regex() + * + * Executes a regexp substitution. For example: + * + * Printf(stderr,"gsl%(regex:/GSL_.*_/\\1/)s","GSL_Hello_") -> gslHello + * ----------------------------------------------------------------------------- */ +String *Swig_string_regex(String *s) { + const int pcre_options = 0; + + String *res = 0; + pcre *compiled_pat = 0; + const char *pcre_error, *input; + int pcre_errorpos; + String *pattern = 0, *subst = 0; + int captures[30]; + + if (split_regex_pattern_subst(s, &pattern, &subst, &input)) { + compiled_pat = pcre_compile( + Char(pattern), pcre_options, &pcre_error, &pcre_errorpos, NULL); + if (!compiled_pat) { + Swig_error("SWIG", Getline(s), "PCRE compilation failed: '%s' in '%s':%i.\n", + pcre_error, Char(pattern), pcre_errorpos); + exit(1); + } + pcre_exec(compiled_pat, NULL, input, strlen(input), 0, 0, captures, 30); + res = replace_captures(input, subst, captures); + } + + DohDelete(pattern); + DohDelete(subst); + pcre_free(compiled_pat); + return res ? res : NewStringEmpty(); +} + +#else + +String *Swig_string_regex(String *s) { + Swig_error("SWIG", Getline(s), "PCRE regex support not enabled in this SWIG build.\n"); + exit(1); +} + +#endif /* ----------------------------------------------------------------------------- * Swig_init() @@ -1236,6 +1341,7 @@ void Swig_init() { DohEncoding("rxspencer", Swig_string_rxspencer); DohEncoding("schemify", Swig_string_schemify); DohEncoding("strip", Swig_string_strip); + DohEncoding("regex", Swig_string_regex); /* aliases for the case encoders */ DohEncoding("uppercase", Swig_string_upper); From 0b2561f300484470478849a3aa5e1cb9d91b3942 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 22 Jul 2010 17:00:59 +0000 Subject: [PATCH 0970/1680] Add a test case for the regex encoder inside %rename. Simple unit test checking that %rename("%(regex:...)") works as expected. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12171 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/common.mk | 1 + .../python/rename_pcre_encoder_runme.py | 8 +++++++ Examples/test-suite/rename_pcre_encoder.i | 21 +++++++++++++++++++ 3 files changed, 30 insertions(+) create mode 100644 Examples/test-suite/python/rename_pcre_encoder_runme.py create mode 100644 Examples/test-suite/rename_pcre_encoder.i diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index c1952543f..c7afb6647 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -284,6 +284,7 @@ CPP_TEST_CASES += \ rename4 \ rename_scope \ rename_strip_encoder \ + rename_pcre_encoder \ restrict_cplusplus \ return_const_value \ return_value_scope \ diff --git a/Examples/test-suite/python/rename_pcre_encoder_runme.py b/Examples/test-suite/python/rename_pcre_encoder_runme.py new file mode 100644 index 000000000..f06c3d25a --- /dev/null +++ b/Examples/test-suite/python/rename_pcre_encoder_runme.py @@ -0,0 +1,8 @@ +from rename_pcre_encoder import * + +s = SomeWidget() +a = AnotherWidget() +a.DoSomething() + +evt = wxEVTSomeEvent() +t = xUnchangedName() diff --git a/Examples/test-suite/rename_pcre_encoder.i b/Examples/test-suite/rename_pcre_encoder.i new file mode 100644 index 000000000..568a2a82d --- /dev/null +++ b/Examples/test-suite/rename_pcre_encoder.i @@ -0,0 +1,21 @@ +%module rename_pcre_encoder + +// strip the wx prefix from all identifiers except those starting with wxEVT +%rename("%(regex:/wx(?!EVT)(.*)/\\1/)s") ""; + +%inline %{ + +class wxSomeWidget { +}; + +struct wxAnotherWidget { + void wxDoSomething() {} +}; + +class wxEVTSomeEvent { +}; + +class xUnchangedName { +}; + +%} From 409ae85a745a68615778b0b5029b3ef933412f81 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 22 Jul 2010 17:01:16 +0000 Subject: [PATCH 0971/1680] Improve %rename(match) documentation. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12172 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/SWIG.html | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html index 3fb1e86cc..7ce49529a 100644 --- a/Doc/Manual/SWIG.html +++ b/Doc/Manual/SWIG.html @@ -1931,14 +1931,30 @@ As explained in the previous sections, it is possible to either rename individual declarations or apply a rename rule to all of them at once. In practice, the latter is however rarely appropriate as there are always some exceptions to the general rules. To deal with them, the scope of an unnamed -%rename can be limited using a second parameter. +%rename can be limited using subsequent match parameters. +They can be applied to any of the attributes associated by SWIG with the +declarations appearing in its input. One of them is the declaration name and

      - +
      +
      +%rename("foo", match$name="bar") "";
      +
      +

      -The simplest possibility is to match the declaration type, for example: +can be used to achieve the same effect as the simpler

      +%rename("foo") bar;
      +
      +
      +

      +However match can also be applied to the declaration type, for +example match="class" restricts the match to class declarations only +(in C++) and match="enumitem" restricts it to the enum elements. SWIG +also provides convenience macros for such match expressions, for example +

      +
       %rename("%(title)s", %$isenumitem) "";
       
      @@ -1950,6 +1966,22 @@ documentation is not exhaustive, see "%rename predicates" section of Lib/swig.swg for the full list of supported match expressions.

      +

      +Another important feature of match is that it can be applied not +only to the declaration itself but also to its enclosing declaration. So +match$parentNode$name="SomeClass" would be true only for members of +the C++ class with the specified name. This can, of course, be combined with +more complicated matches making it possible to write +

      +
      +
      +%rename("%(lower)s", match$parentNode$name="SomeClass", %$isenum) "";
      +
      +
      +

      +to rename all enums nested in the given class to lower case. +

      +

      Finally, even more powerful variants of %rename and %ignore directives can be used to help wrap C++ overloaded functions and methods or C++ methods which use default arguments. This is described in the From 48a2e0bdea237f658507650e6b7233205385d72a Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 22 Jul 2010 17:01:36 +0000 Subject: [PATCH 0972/1680] Correct top_{src,build}dir definitions in csharp and java test suite. The ".." artificially appended to these variables was enough to make the build work in the source directory but broke down when the build directory was different from the source one. Remove this hack and use absolute path to the build directory instead to ensure that it's still valid even when csharp/java makefiles invoke swig_and_compile_{c,cpp} macros from a subdirectory. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12173 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/csharp/Makefile.in | 6 +++--- Examples/test-suite/java/Makefile.in | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Examples/test-suite/csharp/Makefile.in b/Examples/test-suite/csharp/Makefile.in index 5f50095a1..18718ffe8 100644 --- a/Examples/test-suite/csharp/Makefile.in +++ b/Examples/test-suite/csharp/Makefile.in @@ -8,8 +8,8 @@ INTERPRETER = @CSHARPCILINTERPRETER@ CSHARPPATHSEPARATOR = "@CSHARPPATHSEPARATOR@" CSHARPCYGPATH_W = @CSHARPCYGPATH_W@ srcdir = @srcdir@ -top_srcdir = @top_srcdir@/.. -top_builddir = @top_builddir@/.. +top_srcdir = @top_srcdir@ +top_builddir = $(abspath @top_builddir@) CPP_TEST_CASES = \ csharp_attributes \ @@ -66,7 +66,7 @@ setup = \ # Note C# uses LD_LIBRARY_PATH under Unix, PATH under Cygwin/Windows and SHLIB_PATH on HPUX. run_testcase = \ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ - $(MAKE) -f $*/$(top_builddir)/$(EXAMPLES)/Makefile \ + $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile \ CSHARPFLAGS='-nologo $(CSHARPFLAGSSPECIAL) -out:$*_runme.exe' \ CSHARPSRCS='`$(CSHARPCYGPATH_W) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX)` `find $* -name "*.cs" -exec $(CSHARPCYGPATH_W) "{}" \+`' csharp_compile && \ env LD_LIBRARY_PATH="$*:$$LD_LIBRARY_PATH" PATH="$*:$$PATH" SHLIB_PATH="$*:$$SHLIB_PATH" $(RUNTOOL) $(INTERPRETER) $*_runme.exe; \ diff --git a/Examples/test-suite/java/Makefile.in b/Examples/test-suite/java/Makefile.in index ba225f6e9..0fc8c0511 100644 --- a/Examples/test-suite/java/Makefile.in +++ b/Examples/test-suite/java/Makefile.in @@ -7,8 +7,8 @@ JAVA = java JAVAC = javac SCRIPTSUFFIX = _runme.java srcdir = @srcdir@ -top_srcdir = @top_srcdir@/.. -top_builddir = @top_builddir@/.. +top_srcdir = @top_srcdir@ +top_builddir = $(abspath @top_builddir@) C_TEST_CASES = \ java_lib_arrays \ From 70c5bb5a47d7380cf5b5371a2b84ad04f330053a Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 22 Jul 2010 17:02:10 +0000 Subject: [PATCH 0973/1680] Add support for "[not]regexmatch" and "regextarget" to %rename. "regexmatch" and "notregexmatch" can be used with anonymous %renames in the same way as "match" and "notmatch" while "regextarget" specifies that the argument of a non-anonymous %rename should be interpreted as a regular expression. Document the new functions. Also add a new unit test for %regex also testing regexmatch &c and provide test code for C# and Java verifying that it works as intended. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12174 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 18 ++++++ Doc/Manual/SWIG.html | 45 ++++++++++++-- Examples/test-suite/common.mk | 1 + .../csharp/rename_pcre_enum_runme.cs | 24 ++++++++ .../java/rename_pcre_enum_runme.java | 26 ++++++++ Examples/test-suite/rename_pcre_enum.i | 49 +++++++++++++++ Source/Swig/naming.c | 61 ++++++++++++++++++- 7 files changed, 216 insertions(+), 8 deletions(-) create mode 100644 Examples/test-suite/csharp/rename_pcre_enum_runme.cs create mode 100644 Examples/test-suite/java/rename_pcre_enum_runme.java create mode 100644 Examples/test-suite/rename_pcre_enum.i diff --git a/CHANGES.current b/CHANGES.current index 9954ae05b..8c8b426b1 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -9,6 +9,24 @@ Version 2.0.1 (in progress) Fix wrapping of function pointers and member function pointers when the function returns by reference. +2010-07-13: vadz + Add "regexmatch", "regextarget" and "notregexmatch" which can be + used to apply %rename directives to the declarations matching the + specified regular expression only. The first two can be used + interchangeably, both of the %renames below do the same thing: + + %rename("$ignore", regexmatch$name="Old$") ""; + %rename("$ignore", regextarget=1) "Old$"; + + (namely ignore the declarations having "Old" suffix). + + "notregexmatch" restricts the match to only the declarations which + do not match the regular expression, e.g. here is how to rename to + lower case versions all declarations except those consisting from + capital letters only: + + %rename("$(lower)s", notregexmatch$name="^[A-Z]+$") ""; + 2010-07-13: vadz Add the new "regex" encoder that can be used in %rename, e.g. diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html index 7ce49529a..1d8f28f1c 100644 --- a/Doc/Manual/SWIG.html +++ b/Doc/Manual/SWIG.html @@ -1949,10 +1949,12 @@ can be used to achieve the same effect as the simpler

      -However match can also be applied to the declaration type, for -example match="class" restricts the match to class declarations only -(in C++) and match="enumitem" restricts it to the enum elements. SWIG -also provides convenience macros for such match expressions, for example +and so is not very interesting on its own. However match can also be +applied to the declaration type, for example match="class" restricts +the match to class declarations only (in C++) and match="enumitem" +restricts it to the enum elements. SWIG also provides convenience macros for +such match expressions, for example +

       %rename("%(title)s", %$isenumitem) "";
      @@ -1983,7 +1985,40 @@ to rename all enums nested in the given class to lower case.
       

      -Finally, even more powerful variants of %rename and %ignore directives can be used to help +And in addition to literally matching some string with match you can +also use regexmatch or notregexmatchto match a string +against a regular expression. For example, to ignore all functions having +"Old" suffix you could use +

      +
      +
      +%rename("$ignore", regexmatch$name="Old$") "";
      +
      +
      +

      +For simple cases like this, specifying the regular expression for the +declaration name directly can be preferable and can be done using +regextarget: +

      +
      +
      +%rename("$ignore", regextarget=1) "Old$";
      +
      +
      + +

      +As for notregexmatch, it restricts the match only to the strings not +matching the specified regular expression. So to rename to lower case versions +all declarations except those consisting from capital letters only: +

      +
      +
      +%rename("$(lower)s", notregexmatch$name="^[A-Z]+$") "";
      +
      +
      + +

      +Finally, variants of %rename and %ignore directives can be used to help wrap C++ overloaded functions and methods or C++ methods which use default arguments. This is described in the Ambiguity resolution and renaming section in the C++ chapter.

      diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index c7afb6647..af9316656 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -285,6 +285,7 @@ CPP_TEST_CASES += \ rename_scope \ rename_strip_encoder \ rename_pcre_encoder \ + rename_pcre_enum \ restrict_cplusplus \ return_const_value \ return_value_scope \ diff --git a/Examples/test-suite/csharp/rename_pcre_enum_runme.cs b/Examples/test-suite/csharp/rename_pcre_enum_runme.cs new file mode 100644 index 000000000..0143eda33 --- /dev/null +++ b/Examples/test-suite/csharp/rename_pcre_enum_runme.cs @@ -0,0 +1,24 @@ +using System; +using rename_pcre_enumNamespace; + +public class runme { + static void Main() { + Foo foo = Foo.First; + if ( foo == Foo.Second ) + throw new Exception("Enum values should be different"); + + // Check that Foo_Max enum element was ignored. + int numFooEnumElements = Enum.GetValues(typeof(Foo)).Length; + if ( numFooEnumElements != 2 ) + throw new Exception(String.Format("Enum should have 2 elements, not {0}", + numFooEnumElements)); + + BoundaryCondition bc = BoundaryCondition.MaxMax; + if ( (int)bc != 2 ) + throw new Exception("Wrong enum value"); + + Colour c = Colour.red; + if ( c == Colour.blue ) + throw new Exception("Enum values should be different"); + } +} diff --git a/Examples/test-suite/java/rename_pcre_enum_runme.java b/Examples/test-suite/java/rename_pcre_enum_runme.java new file mode 100644 index 000000000..a8bfef46a --- /dev/null +++ b/Examples/test-suite/java/rename_pcre_enum_runme.java @@ -0,0 +1,26 @@ +import rename_pcre_enum.*; + +public class rename_pcre_enum_runme { + static { System.loadLibrary("rename_pcre_enum"); } + + public static void main(String argv[]) + { + Foo foo = Foo.First; + if ( foo == Foo.Second ) + throw new RuntimeException("Enum values should be different"); + + // Check that Foo_Max enum element was ignored. + int numFooEnumElements = Foo.values().length; + if ( numFooEnumElements != 2 ) + throw new RuntimeException(String.format("Enum should have 2 elements, not %d", + numFooEnumElements)); + + BoundaryCondition bc = BoundaryCondition.MaxMax; + if ( bc.ordinal() != 2 ) + throw new RuntimeException("Wrong enum value"); + + Colour c = Colour.red; + if ( c == Colour.blue ) + throw new RuntimeException("Enum values should be different"); + } +} diff --git a/Examples/test-suite/rename_pcre_enum.i b/Examples/test-suite/rename_pcre_enum.i new file mode 100644 index 000000000..1bb7c1b8b --- /dev/null +++ b/Examples/test-suite/rename_pcre_enum.i @@ -0,0 +1,49 @@ +%module rename_pcre_enum + +// This file is needed for proper enum support in C#/Java backends +#if defined(SWIGCSHARP) || defined(SWIGJAVA) +%include "enums.swg" +#endif + +// Apply a rule for renaming the enum elements to avoid the common prefixes +// redundant in C#/Java +%rename("%(regex:/([A-Z][a-z]+)+_(.*)/\\2/)s",%$isenumitem) ""; + +// Also don't export special end of enum markers which are often used in C++ +// code to just have a symbolic name for the number of enum elements but are +// not needed in target language. +%rename("$ignore", regexmatch$name="([A-Z][a-z]+)+_Max$",%$isenumitem) ""; + +// Test another way of doing the same thing with regextarget: +%rename("$ignore", %$isenumitem, regextarget=1) "([A-Z][a-z]+)+_Internal$"; + +// Apply this renaming rule to all enum elements that don't contain more than +// one capital letter. +%rename("%(lower)s", notregexmatch$name="[A-Z]\\w*[A-Z]", %$isenumitem) ""; + +%inline %{ + +// Foo_Internal and Foo_Max won't be exported. +enum Foo { + Foo_Internal = -1, + Foo_First, + Foo_Second, + Foo_Max +}; + +// All elements of this enum will be exported because they do not match the +// excluding regex. +enum BoundaryCondition { + BoundaryCondition_MinMax, + BoundaryCondition_MaxMin, + BoundaryCondition_MaxMax +}; + +// The elements of this enum will have lower-case names. +enum Colour { + Red, + Blue, + Green +}; + +%} diff --git a/Source/Swig/naming.c b/Source/Swig/naming.c index 07e42f2d4..44daf30c9 100644 --- a/Source/Swig/naming.c +++ b/Source/Swig/naming.c @@ -1062,10 +1062,13 @@ static void Swig_name_object_attach_keys(const char *keys[], Hash *nameobj) { const char **rkey; int isnotmatch = 0; int isrxsmatch = 0; + int isregexmatch = 0; if ((strncmp(ckey, "match", 5) == 0) || (isnotmatch = (strncmp(ckey, "notmatch", 8) == 0)) || (isrxsmatch = (strncmp(ckey, "rxsmatch", 8) == 0)) - || (isnotmatch = isrxsmatch = (strncmp(ckey, "notrxsmatch", 11) == 0))) { + || (isregexmatch = (strncmp(ckey, "regexmatch", 10) == 0)) + || (isnotmatch = isrxsmatch = (strncmp(ckey, "notrxsmatch", 11) == 0)) + || (isnotmatch = isregexmatch = (strncmp(ckey, "notregexmatch", 13) == 0))) { Hash *mi = NewHash(); List *attrlist = Swig_make_attrlist(ckey); if (!matchlist) @@ -1080,6 +1083,8 @@ static void Swig_name_object_attach_keys(const char *keys[], Hash *nameobj) { SetFlag(mi, "notmatch"); if (isrxsmatch) SetFlag(mi, "rxsmatch"); + if (isregexmatch) + SetFlag(mi, "regexmatch"); Delete(attrlist); Append(matchlist, mi); Delete(mi); @@ -1155,6 +1160,51 @@ static DOH *Swig_get_lattr(Node *n, List *lattr) { return res; } +#ifdef HAVE_PCRE +#include + +int Swig_name_regexmatch_value(Node *n, String *pattern, String *s) { + pcre *compiled_pat; + const char *err; + int errpos; + int rc; + + compiled_pat = pcre_compile(Char(pattern), 0, &err, &errpos, NULL); + if (!compiled_pat) { + Swig_error("SWIG", Getline(n), + "Invalid regex \"%s\": compilation failed at %d: %s\n", + Char(pattern), errpos, err); + exit(1); + } + + rc = pcre_exec(compiled_pat, NULL, Char(s), Len(s), 0, 0, NULL, 0); + pcre_free(compiled_pat); + + if (rc == PCRE_ERROR_NOMATCH) + return 0; + + if (rc < 0 ) { + Swig_error("SWIG", Getline(n), + "Matching \"%s\" against regex \"%s\" failed: %d\n", + Char(s), Char(pattern), rc); + exit(1); + } + + return 1; +} + +#else /* !HAVE_PCRE */ + +int Swig_name_regexmatch_value(Node *n, String *pattern, String *s) { + (void)pattern; + (void)s; + Swig_error("SWIG", Getline(n), + "PCRE regex matching is not available in this SWIG build.\n"); + exit(1); +} + +#endif /* HAVE_PCRE/!HAVE_PCRE */ + #if defined(HAVE_RXSPENCER) #include #include @@ -1228,6 +1278,7 @@ int Swig_name_match_nameobj(Hash *rn, Node *n) { String *nval = Swig_get_lattr(n, lattr); int notmatch = GetFlag(mi, "notmatch"); int rxsmatch = GetFlag(mi, "rxsmatch"); + int regexmatch = GetFlag(mi, "regexmatch"); #ifdef SWIG_DEBUG Printf(stdout, "mi %d %s re %d not %d \n", i, nval, notmatch, rxsmatch); if (rxsmatch) { @@ -1238,6 +1289,7 @@ int Swig_name_match_nameobj(Hash *rn, Node *n) { if (nval) { String *kwval = Getattr(mi, "value"); match = rxsmatch ? Swig_name_rxsmatch_value(kwval, nval) + : regexmatch ? Swig_name_regexmatch_value(n, kwval, nval) : Swig_name_match_value(kwval, nval); #ifdef SWIG_DEBUG Printf(stdout, "val %s %s %d %d \n", nval, kwval, match, ilen); @@ -1278,6 +1330,7 @@ Hash *Swig_name_nameobj_lget(List *namelist, Node *n, String *prefix, String *na String *sname = 0; int fullname = GetFlag(rn, "fullname"); int rxstarget = GetFlag(rn, "rxstarget"); + int regextarget = GetFlag(rn, "regextarget"); if (sfmt) { if (fullname && prefix) { String *pname = NewStringf("%s::%s", prefix, name); @@ -1294,7 +1347,9 @@ Hash *Swig_name_nameobj_lget(List *namelist, Node *n, String *prefix, String *na DohIncref(name); } } - match = rxstarget ? Swig_name_rxsmatch_value(tname, sname) : Swig_name_match_value(tname, sname); + match = rxstarget ? Swig_name_rxsmatch_value(tname, sname) + : regextarget ? Swig_name_regexmatch_value(n, tname, sname) + : Swig_name_match_value(tname, sname); Delete(sname); } else { match = 1; @@ -1393,7 +1448,7 @@ void Swig_name_rename_add(String *prefix, String *name, SwigType *decl, Hash *ne ParmList *declparms = declaratorparms; - const char *rename_keys[] = { "fullname", "sourcefmt", "targetfmt", "continue", "rxstarget", 0 }; + const char *rename_keys[] = { "fullname", "sourcefmt", "targetfmt", "continue", "rxstarget", "regextarget", 0 }; Swig_name_object_attach_keys(rename_keys, newname); /* Add the name */ From 587d8435211cddb1389733c462a7d1d02af17fea Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 22 Jul 2010 17:02:35 +0000 Subject: [PATCH 0974/1680] Remove old experimental rxspencer encoder and rxsmatch function. They are replaced with the new, officially supported PCRE-based regex and regexmatch. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12175 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 11 +++ Examples/test-suite/enum_rename.i | 2 +- Examples/test-suite/rename_camel.i | 4 +- Source/Swig/misc.c | 107 ----------------------------- Source/Swig/naming.c | 56 +-------------- configure.in | 18 ----- 6 files changed, 17 insertions(+), 181 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 8c8b426b1..6cd13990c 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -9,6 +9,17 @@ Version 2.0.1 (in progress) Fix wrapping of function pointers and member function pointers when the function returns by reference. +2010-07-13: vadz + Removed support for the old experimental "rxspencer" encoder and + "[not]rxsmatch" in %rename (see the 01/16/2006 entry). The new and + officially supported "regex" encoder and "[not]regexmatch" checks + should be used instead (see the two previous entries). Please + replace "%(rxspencer:[pat][subst])s" with "%(regex:/pat/subst/)s" + when upgrading. Notice that you will also need to replace the back- + references of form "@1" with the more standard "\\1" and may need to + adjust your regular expressions syntax as the new regex encoder uses + Perl-compatible syntax and not (extended) POSIX syntax as the old one. + 2010-07-13: vadz Add "regexmatch", "regextarget" and "notregexmatch" which can be used to apply %rename directives to the declarations matching the diff --git a/Examples/test-suite/enum_rename.i b/Examples/test-suite/enum_rename.i index 455826f8b..0cab4d0d8 100644 --- a/Examples/test-suite/enum_rename.i +++ b/Examples/test-suite/enum_rename.i @@ -2,7 +2,7 @@ %warnfilter(SWIGWARN_PARSE_REDEFINED) S_May; -// %rename with rxspencer can do the equivalent of these two renames, which was resulting in uncompileable code +// %rename using regex can do the equivalent of these two renames, which was resulting in uncompileable code %rename(May) M_May; %rename(May) S_May; diff --git a/Examples/test-suite/rename_camel.i b/Examples/test-suite/rename_camel.i index 54f06f967..970bb9215 100644 --- a/Examples/test-suite/rename_camel.i +++ b/Examples/test-suite/rename_camel.i @@ -33,7 +33,7 @@ %rename(awk_cmd) ""; -%rename("%(title)s",rxsmatch$parentNode$type="enum .*") ""; +%rename("%(title)s",regexmatch$parentNode$type="enum .*") ""; %inline { @@ -59,7 +59,7 @@ } -%rename("%(lowercase)s",sourcefmt="%(rxspencer:[GSL_(.*)][@1])s",%$isfunction) ""; +%rename("%(lowercase)s",sourcefmt="%(regex:/GSL_(.*)/\\1/)s",%$isfunction) ""; %inline { void GSL_Hello() {} } diff --git a/Source/Swig/misc.c b/Source/Swig/misc.c index b23a99b60..14470485e 100644 --- a/Source/Swig/misc.c +++ b/Source/Swig/misc.c @@ -1108,112 +1108,6 @@ String *Swig_string_strip(String *s) { } -/* ----------------------------------------------------------------------------- - * Swig_string_rxspencer() - * - * Executes a regexp substitution via the RxSpencer library. For example: - * - * Printf(stderr,"gsl%(rxspencer:[GSL_.*_][@1])s","GSL_Hello_") -> gslHello - * ----------------------------------------------------------------------------- */ -#if defined(HAVE_RXSPENCER) -#include -#include -#define USE_RXSPENCER -#endif - -const char *skip_delim(char pb, char pe, const char *ce) { - int end = 0; - int lb = 0; - while (!end && *ce != '\0') { - if (*ce == pb) { - ++lb; - } - if (*ce == pe) { - if (!lb) { - end = 1; - --ce; - } else { - --lb; - } - } - ++ce; - } - return end ? ce : 0; -} - - -#if defined(USE_RXSPENCER) -String *Swig_string_rxspencer(String *s) { - String *res = 0; - if (Len(s)) { - const char *cs = Char(s); - const char *cb; - const char *ce; - if (*cs == '[') { - int retval; - regex_t compiled; - cb = ++cs; - ce = skip_delim('[', ']', cb); - if (ce) { - char bregexp[512]; - strncpy(bregexp, cb, ce - cb); - bregexp[ce - cb] = '\0'; - ++ce; - retval = regcomp(&compiled, bregexp, REG_EXTENDED); - if (retval == 0) { - cs = ce; - if (*cs == '[') { - cb = ++cs; - ce = skip_delim('[', ']', cb); - if (ce) { - const char *cvalue = ce + 1; - int nsub = (int) compiled.re_nsub + 1; - regmatch_t *pmatch = (regmatch_t *) malloc(sizeof(regmatch_t) * (nsub)); - retval = regexec(&compiled, cvalue, nsub, pmatch, 0); - if (retval != REG_NOMATCH) { - char *spos = 0; - res = NewStringWithSize(cb, ce - cb); - spos = Strchr(res, '@'); - while (spos) { - char cd = *(++spos); - if (isdigit(cd)) { - char arg[8]; - size_t len; - int i = cd - '0'; - sprintf(arg, "@%d", i); - if (i < nsub && (len = pmatch[i].rm_eo - pmatch[i].rm_so)) { - char value[256]; - strncpy(value, cvalue + pmatch[i].rm_so, len); - value[len] = 0; - Replaceall(res, arg, value); - } else { - Replaceall(res, arg, ""); - } - spos = Strchr(res, '@'); - } else if (cd == '@') { - spos = strchr(spos + 1, '@'); - } - } - } - free(pmatch); - } - } - } - regfree(&compiled); - } - } - } - if (!res) - res = NewStringEmpty(); - return res; -} -#else -String *Swig_string_rxspencer(String *s) { - (void) s; - return NewStringEmpty(); -} -#endif - #ifdef HAVE_PCRE #include @@ -1338,7 +1232,6 @@ void Swig_init() { DohEncoding("typecode", Swig_string_typecode); DohEncoding("mangle", Swig_string_emangle); DohEncoding("command", Swig_string_command); - DohEncoding("rxspencer", Swig_string_rxspencer); DohEncoding("schemify", Swig_string_schemify); DohEncoding("strip", Swig_string_strip); DohEncoding("regex", Swig_string_regex); diff --git a/Source/Swig/naming.c b/Source/Swig/naming.c index 44daf30c9..5bf42f7cc 100644 --- a/Source/Swig/naming.c +++ b/Source/Swig/naming.c @@ -1061,13 +1061,10 @@ static void Swig_name_object_attach_keys(const char *keys[], Hash *nameobj) { if (ckey) { const char **rkey; int isnotmatch = 0; - int isrxsmatch = 0; int isregexmatch = 0; if ((strncmp(ckey, "match", 5) == 0) || (isnotmatch = (strncmp(ckey, "notmatch", 8) == 0)) - || (isrxsmatch = (strncmp(ckey, "rxsmatch", 8) == 0)) || (isregexmatch = (strncmp(ckey, "regexmatch", 10) == 0)) - || (isnotmatch = isrxsmatch = (strncmp(ckey, "notrxsmatch", 11) == 0)) || (isnotmatch = isregexmatch = (strncmp(ckey, "notregexmatch", 13) == 0))) { Hash *mi = NewHash(); List *attrlist = Swig_make_attrlist(ckey); @@ -1075,14 +1072,8 @@ static void Swig_name_object_attach_keys(const char *keys[], Hash *nameobj) { matchlist = NewList(); Setattr(mi, "value", Getattr(kw, "value")); Setattr(mi, "attrlist", attrlist); -#ifdef SWIG_DEBUG - if (isrxsmatch) - Printf(stdout, "rxsmatch to use: %s %s %s\n", ckey, Getattr(kw, "value"), attrlist); -#endif if (isnotmatch) SetFlag(mi, "notmatch"); - if (isrxsmatch) - SetFlag(mi, "rxsmatch"); if (isregexmatch) SetFlag(mi, "regexmatch"); Delete(attrlist); @@ -1205,37 +1196,6 @@ int Swig_name_regexmatch_value(Node *n, String *pattern, String *s) { #endif /* HAVE_PCRE/!HAVE_PCRE */ -#if defined(HAVE_RXSPENCER) -#include -#include -#define USE_RXSPENCER -#endif - -#if defined(USE_RXSPENCER) -int Swig_name_rxsmatch_value(String *mvalue, String *value) { - int match = 0; - char *cvalue = Char(value); - char *cmvalue = Char(mvalue); - regex_t compiled; - int retval = regcomp(&compiled, cmvalue, REG_EXTENDED | REG_NOSUB); - if (retval != 0) - return 0; - retval = regexec(&compiled, cvalue, 0, 0, 0); - match = (retval == REG_NOMATCH) ? 0 : 1; -#ifdef SWIG_DEBUG - Printf(stdout, "rxsmatch_value: %s %s %d\n", cvalue, cmvalue, match); -#endif - regfree(&compiled); - return match; -} -#else -int Swig_name_rxsmatch_value(String *mvalue, String *value) { - (void) mvalue; - (void) value; - return 0; -} -#endif - int Swig_name_match_value(String *mvalue, String *value) { #if defined(SWIG_USE_SIMPLE_MATCHOR) int match = 0; @@ -1277,19 +1237,11 @@ int Swig_name_match_nameobj(Hash *rn, Node *n) { List *lattr = Getattr(mi, "attrlist"); String *nval = Swig_get_lattr(n, lattr); int notmatch = GetFlag(mi, "notmatch"); - int rxsmatch = GetFlag(mi, "rxsmatch"); int regexmatch = GetFlag(mi, "regexmatch"); -#ifdef SWIG_DEBUG - Printf(stdout, "mi %d %s re %d not %d \n", i, nval, notmatch, rxsmatch); - if (rxsmatch) { - Printf(stdout, "rxsmatch %s\n", lattr); - } -#endif match = 0; if (nval) { String *kwval = Getattr(mi, "value"); - match = rxsmatch ? Swig_name_rxsmatch_value(kwval, nval) - : regexmatch ? Swig_name_regexmatch_value(n, kwval, nval) + match = regexmatch ? Swig_name_regexmatch_value(n, kwval, nval) : Swig_name_match_value(kwval, nval); #ifdef SWIG_DEBUG Printf(stdout, "val %s %s %d %d \n", nval, kwval, match, ilen); @@ -1329,7 +1281,6 @@ Hash *Swig_name_nameobj_lget(List *namelist, Node *n, String *prefix, String *na String *sfmt = Getattr(rn, "sourcefmt"); String *sname = 0; int fullname = GetFlag(rn, "fullname"); - int rxstarget = GetFlag(rn, "rxstarget"); int regextarget = GetFlag(rn, "regextarget"); if (sfmt) { if (fullname && prefix) { @@ -1347,8 +1298,7 @@ Hash *Swig_name_nameobj_lget(List *namelist, Node *n, String *prefix, String *na DohIncref(name); } } - match = rxstarget ? Swig_name_rxsmatch_value(tname, sname) - : regextarget ? Swig_name_regexmatch_value(n, tname, sname) + match = regextarget ? Swig_name_regexmatch_value(n, tname, sname) : Swig_name_match_value(tname, sname); Delete(sname); } else { @@ -1448,7 +1398,7 @@ void Swig_name_rename_add(String *prefix, String *name, SwigType *decl, Hash *ne ParmList *declparms = declaratorparms; - const char *rename_keys[] = { "fullname", "sourcefmt", "targetfmt", "continue", "rxstarget", "regextarget", 0 }; + const char *rename_keys[] = { "fullname", "sourcefmt", "targetfmt", "continue", "regextarget", 0 }; Swig_name_object_attach_keys(rename_keys, newname); /* Add the name */ diff --git a/configure.in b/configure.in index e5e2752d9..1a6b37b57 100644 --- a/configure.in +++ b/configure.in @@ -73,24 +73,6 @@ AS_IF([test "x$with_pcre" != xno], ]) -dnl Look for RxSpencer -AC_ARG_WITH(rxspencer, AS_HELP_STRING([--with-rxspencer], [Enable RxSpencer]), with_rxspencer="yes") -if test x"${with_rxspencer}" = xyes ; then -#check first for the header - AC_CHECK_HEADER(rxspencer/regex.h,with_rxspencer="yes",with_rxspencer="no") - if test x"${with_rxspencer}" = xyes ; then -# now check for the library - AC_CHECK_LIB(rxspencer, regcomp,with_rxspencer="yes",with_rxspencer="no") - fi - if test x"${with_rxspencer}" = xyes ; then -# library and header are available - AC_DEFINE(HAVE_RXSPENCER, 1,[Define if rxspencer is available]) - LIBS="$LIBS -lrxspencer" - else - AC_MSG_NOTICE([RxSpencer not found. Obtain it at http://arglist.com/regex or http://gnuwin32.sourceforge.net/packages.html]) - fi -fi - dnl CCache AC_ARG_ENABLE([ccache], AS_HELP_STRING([--disable-ccache], [disable building and installation of ccache-swig executable (default enabled)]), [enable_ccache=$enableval], [enable_ccache=yes]) AC_MSG_CHECKING([whether to enable ccache-swig]) From 89a7ab06856f3f0d7e879d6c3df9c6db85792d6b Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 22 Jul 2010 17:02:55 +0000 Subject: [PATCH 0975/1680] Include the values of configurable options in `swig -version`. Show the value of important compilation options in swig -version output. Currently there is just one such option, for PCRE use, but more may be added in the future. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12176 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/main.cxx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx index f0e941f22..3f2008d7d 100644 --- a/Source/Modules/main.cxx +++ b/Source/Modules/main.cxx @@ -622,7 +622,14 @@ void SWIG_getoptions(int argc, char *argv[]) { } else if (strcmp(argv[i], "-version") == 0) { fprintf(stdout, "\nSWIG Version %s\n", Swig_package_version()); fprintf(stdout, "\nCompiled with %s [%s]\n", SWIG_CXX, SWIG_PLATFORM); - fprintf(stdout, "Please see %s for reporting bugs and further information\n", PACKAGE_BUGREPORT); + fprintf(stdout, "\nConfigured options: %cpcre\n", +#ifdef HAVE_PCRE + '+' +#else + '-' +#endif + ); + fprintf(stdout, "\nPlease see %s for reporting bugs and further information\n", PACKAGE_BUGREPORT); SWIG_exit(EXIT_SUCCESS); } else if (strcmp(argv[i], "-copyright") == 0) { fprintf(stdout, "\nSWIG Version %s\n", Swig_package_version()); From d2ad66a9a9aec4ed7bf96af716a8f87a57eb7a45 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 23 Jul 2010 07:17:15 +0000 Subject: [PATCH 0976/1680] remove duplicate definition of %$isextend git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12178 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/swig.swg | 1 - 1 file changed, 1 deletion(-) diff --git a/Lib/swig.swg b/Lib/swig.swg index ec903533c..4ec3d35e6 100644 --- a/Lib/swig.swg +++ b/Lib/swig.swg @@ -269,7 +269,6 @@ static int NAME(TYPE x) { %define %$isaccess "match"="access" %enddef %define %$isclass "match"="class","notmatch$template$templatetype"="class" %enddef %define %$isextend "match"="extend" %enddef -%define %$isextend "match"="extend" %enddef %define %$isconstructor "match"="constructor" %enddef %define %$isdestructor "match"="destructor" %enddef %define %$isnamespace "match"="namespace" %enddef From f6346b3df1252b9745164d1759fab32e9e1cbea4 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 23 Jul 2010 07:21:46 +0000 Subject: [PATCH 0977/1680] minor edits in %rename sections git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12179 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/SWIG.html | 48 ++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html index 1d8f28f1c..4ea55621e 100644 --- a/Doc/Manual/SWIG.html +++ b/Doc/Manual/SWIG.html @@ -1765,7 +1765,7 @@ While writing %rename for specific declarations is simple enough, sometimes the same renaming rule needs to be applied to many, maybe all, identifiers in the SWIG input. For example, it may be necessary to apply some transformation to all the names in the target language to better follow its -naming conventions, e.g. add a specific prefix to all the functions. Doing it +naming conventions, like adding a specific prefix to all wrapped functions. Doing it individually for each function is impractical so SWIG supports applying a renaming rule to all declarations if the name of the identifier to be renamed is not specified:

      @@ -1799,28 +1799,28 @@ strips the provided prefix from its argument. The prefix is specified as part of the format string, following a colon after the function name:
      -%rename("%(strip:[wx])s") ""; // wxHello -> Hello; FooBar -> fooBar
      +%rename("%(strip:[wx])s") ""; // wxHello -> Hello; FooBar -> FooBar
       

      -Here is the table summarizing all currently defined functions with an example -of applying each one (notice that some of them have two names, a shorter one -and a more descriptive one, but the two functions are otherwise equivalent): +Below is the table summarizing all currently defined functions with an example +of applying each one. Note that some of them have two names, a shorter one +and a more descriptive one, but the two functions are otherwise equivalent:

      - - + + - - + + @@ -1839,23 +1839,23 @@ and a more descriptive one, but the two functions are otherwise equivalent): - + - + - - + + Logically, this is the reverse of camelcase. @@ -1933,7 +1933,7 @@ practice, the latter is however rarely appropriate as there are always some exceptions to the general rules. To deal with them, the scope of an unnamed %rename can be limited using subsequent match parameters. They can be applied to any of the attributes associated by SWIG with the -declarations appearing in its input. One of them is the declaration name and +declarations appearing in its input. For example:

      @@ -1965,7 +1965,7 @@ will capitalize the names of all the enum elements but not change the case of
       the other declarations. Similarly, %$isclass, %$isfunction
       and %$isvariable can be used. Many other checks are possible and this
       documentation is not exhaustive, see "%rename predicates" section of
      -Lib/swig.swg for the full list of supported match expressions.
      +swig.swg for the full list of supported match expressions.
       

      @@ -1985,10 +1985,10 @@ to rename all enums nested in the given class to lower case.

      -And in addition to literally matching some string with match you can -also use regexmatch or notregexmatchto match a string +In addition to literally matching some string with match you can +also use regexmatch or notregexmatch to match a string against a regular expression. For example, to ignore all functions having -"Old" suffix you could use +"Old" as a suffix you could use

      @@ -1997,7 +1997,7 @@ against a regular expression. For example, to ignore all functions having
       

      For simple cases like this, specifying the regular expression for the -declaration name directly can be preferable and can be done using +declaration name directly can be preferable and can also be done using regextarget:

      @@ -2008,8 +2008,8 @@ declaration name directly can be preferable and can be done using

      As for notregexmatch, it restricts the match only to the strings not -matching the specified regular expression. So to rename to lower case versions -all declarations except those consisting from capital letters only: +matching the specified regular expression. So to rename all declarations to lower case +except those consisting of capital letters only:

      @@ -2187,7 +2187,7 @@ normally, just use the original function name such as add().
       

      SWIG provides a number of extensions to standard C printf formatting that may be useful in this context. For instance, the following -variation installs the callbacks as all upper-case constants such as +variation installs the callbacks as all upper case constants such as ADD, SUB, and MUL:

      @@ -2201,7 +2201,7 @@ int mul(int,int);

      -A format string of "%(lower)s" converts all characters to lower-case. +A format string of "%(lower)s" converts all characters to lower case. A string of "%(title)s" capitalizes the first character and converts the rest to lower case.

      From c6c2c87e2ac9a9816ab056c1b90b1d9f119e0526 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 23 Jul 2010 07:23:10 +0000 Subject: [PATCH 0978/1680] Add message about whether pcre is enabled or not git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12180 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- configure.in | 2 ++ 1 file changed, 2 insertions(+) diff --git a/configure.in b/configure.in index 1a6b37b57..1e51956d9 100644 --- a/configure.in +++ b/configure.in @@ -56,6 +56,8 @@ AC_ARG_WITH([pcre], [], [with_pcre=yes]) +AC_MSG_CHECKING([whether to enable PCRE support]) +AC_MSG_RESULT([$with_pcre]) AS_IF([test "x$with_pcre" != xno], [AX_PATH_GENERIC([pcre], [], dnl Minimal version of PCRE we need -- accept any From af96789c14eb45eb874996a603eb8a1eab960244 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 23 Jul 2010 19:34:17 +0000 Subject: [PATCH 0979/1680] Minor comment changes and html changes git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12181 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 +++- Doc/Manual/Contents.html | 5 +++++ Doc/Manual/SWIG.html | 23 ++++++++++++++++------- Source/Swig/misc.c | 2 +- 4 files changed, 25 insertions(+), 9 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 6cd13990c..3dc3556a1 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -20,6 +20,8 @@ Version 2.0.1 (in progress) adjust your regular expressions syntax as the new regex encoder uses Perl-compatible syntax and not (extended) POSIX syntax as the old one. + *** POTENTIAL INCOMPATIBILITY *** + 2010-07-13: vadz Add "regexmatch", "regextarget" and "notregexmatch" which can be used to apply %rename directives to the declarations matching the @@ -36,7 +38,7 @@ Version 2.0.1 (in progress) lower case versions all declarations except those consisting from capital letters only: - %rename("$(lower)s", notregexmatch$name="^[A-Z]+$") ""; + %rename("$(lowercase)s", notregexmatch$name="^[A-Z]+$") ""; 2010-07-13: vadz Add the new "regex" encoder that can be used in %rename, e.g. diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index 66bf41264..ec99a6511 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -152,6 +152,11 @@
    • Arrays
    • Creating read-only variables
    • Renaming and ignoring declarations +
    • Default/optional arguments
    • Pointers to functions and callbacks diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html index 4ea55621e..32fbe3815 100644 --- a/Doc/Manual/SWIG.html +++ b/Doc/Manual/SWIG.html @@ -44,6 +44,11 @@
    • Arrays
    • Creating read-only variables
    • Renaming and ignoring declarations +
    • Default/optional arguments
    • Pointers to functions and callbacks @@ -1661,7 +1666,9 @@ generate a warning message. Simply change the directives to %immutable;5.4.7 Renaming and ignoring declarations -

      5.4.7.1 Simple renaming of specific identifiers

      + +

      5.4.7.1 Simple renaming of specific identifiers

      +

      Normally, the name of a C declaration is used when that declaration is @@ -1758,7 +1765,8 @@ This directive is still supported, but it is deprecated and should probably be a directive is more powerful and better supports wrapping of raw header file information.

      -

      5.4.7.2 Advanced renaming support

      +

      5.4.7.2 Advanced renaming support

      +

      While writing %rename for specific declarations is simple enough, @@ -1797,12 +1805,12 @@ can use the "lowercamelcase" extended format specifier like this: Some functions can be parametrized, for example the "strip" one strips the provided prefix from its argument. The prefix is specified as part of the format string, following a colon after the function name: +

       %rename("%(strip:[wx])s") ""; // wxHello -> Hello; FooBar -> FooBar
       
      -

      Below is the table summarizing all currently defined functions with an example @@ -1924,7 +1932,8 @@ are exactly equivalent and %rename can be used to selectively ignore multiple declarations using the previously described matching possibilities.

      -

      5.4.7.3 Limiting global renaming rules

      +

      5.4.7.3 Limiting global renaming rules

      +

      As explained in the previous sections, it is possible to either rename @@ -1977,7 +1986,7 @@ more complicated matches making it possible to write

      -%rename("%(lower)s", match$parentNode$name="SomeClass", %$isenum) "";
      +%rename("%(lowercase)s", match$parentNode$name="SomeClass", %$isenum) "";
       

      @@ -2193,7 +2202,7 @@ variation installs the callbacks as all upper case constants such as

       /* Some callback functions */
      -%callback("%(upper)s");
      +%callback("%(uppercase)s");
       int add(int,int);
       int sub(int,int);
       int mul(int,int);
      @@ -2201,7 +2210,7 @@ int mul(int,int);
       

      -A format string of "%(lower)s" converts all characters to lower case. +A format string of "%(lowercase)s" converts all characters to lower case. A string of "%(title)s" capitalizes the first character and converts the rest to lower case.

      diff --git a/Source/Swig/misc.c b/Source/Swig/misc.c index 14470485e..b3c647546 100644 --- a/Source/Swig/misc.c +++ b/Source/Swig/misc.c @@ -1173,7 +1173,7 @@ String *replace_captures(const char *input, String *subst, int captures[]) /* ----------------------------------------------------------------------------- * Swig_string_regex() * - * Executes a regexp substitution. For example: + * Executes a regular expression substitution. For example: * * Printf(stderr,"gsl%(regex:/GSL_.*_/\\1/)s","GSL_Hello_") -> gslHello * ----------------------------------------------------------------------------- */ From 70b4d1231743911806b8a9625926187ce914560b Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 28 Jul 2010 05:53:17 +0000 Subject: [PATCH 0980/1680] Restore in source and out of source builds for the test-suite. Note that configure must be invoked using a relative path for out of source builds git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12186 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 7 +++++++ Examples/test-suite/csharp/Makefile.in | 6 +++--- Examples/test-suite/java/Makefile.in | 4 ++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 3dc3556a1..8fbb9a47f 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,13 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.1 (in progress) =========================== +2010-07-28: wsfulton + Restore configuring out of source for the test-suite since it broke in 1.3.37. + As previously, if running 'make check-test-suite' out of source, it needs to be + done by invoking configure with a relative path. Invoking configure with an + absolute path will not work. Running the full 'make check' still needs to be + done in the source tree. + 2010-07-16: wsfulton Fix wrapping of function pointers and member function pointers when the function returns by reference. diff --git a/Examples/test-suite/csharp/Makefile.in b/Examples/test-suite/csharp/Makefile.in index 18718ffe8..48731f82b 100644 --- a/Examples/test-suite/csharp/Makefile.in +++ b/Examples/test-suite/csharp/Makefile.in @@ -8,8 +8,8 @@ INTERPRETER = @CSHARPCILINTERPRETER@ CSHARPPATHSEPARATOR = "@CSHARPPATHSEPARATOR@" CSHARPCYGPATH_W = @CSHARPCYGPATH_W@ srcdir = @srcdir@ -top_srcdir = @top_srcdir@ -top_builddir = $(abspath @top_builddir@) +top_srcdir = ../@top_srcdir@ +top_builddir = ../@top_builddir@ CPP_TEST_CASES = \ csharp_attributes \ @@ -66,7 +66,7 @@ setup = \ # Note C# uses LD_LIBRARY_PATH under Unix, PATH under Cygwin/Windows and SHLIB_PATH on HPUX. run_testcase = \ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ - $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile \ + $(MAKE) -f $*/$(top_builddir)/$(EXAMPLES)/Makefile \ CSHARPFLAGS='-nologo $(CSHARPFLAGSSPECIAL) -out:$*_runme.exe' \ CSHARPSRCS='`$(CSHARPCYGPATH_W) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX)` `find $* -name "*.cs" -exec $(CSHARPCYGPATH_W) "{}" \+`' csharp_compile && \ env LD_LIBRARY_PATH="$*:$$LD_LIBRARY_PATH" PATH="$*:$$PATH" SHLIB_PATH="$*:$$SHLIB_PATH" $(RUNTOOL) $(INTERPRETER) $*_runme.exe; \ diff --git a/Examples/test-suite/java/Makefile.in b/Examples/test-suite/java/Makefile.in index 0fc8c0511..1ba888fc1 100644 --- a/Examples/test-suite/java/Makefile.in +++ b/Examples/test-suite/java/Makefile.in @@ -7,8 +7,8 @@ JAVA = java JAVAC = javac SCRIPTSUFFIX = _runme.java srcdir = @srcdir@ -top_srcdir = @top_srcdir@ -top_builddir = $(abspath @top_builddir@) +top_srcdir = ../@top_srcdir@ +top_builddir = ../@top_builddir@ C_TEST_CASES = \ java_lib_arrays \ From 024ed6ce2a3191c57c5c030dd133bf0e9e2a1971 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 14 Aug 2010 14:12:23 +0000 Subject: [PATCH 0981/1680] Fix bug in applying regex replacement to non-matching strings. We didn't handle pcre_exec() return code properly and so the replacement could be still done even if there was no match if the replacement part contained anything else than back-references (in this, the only tested so far, case the replacement was still done but the result turned out to be empty and the calling code assumed the regex didn't match). Do check for PCRE_ERROR_NOMATCH now and also give an error message if another error unexpectedly occurred. Add a test case for the bug that was fixed. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12187 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/rename_pcre_encoder.i | 7 ++++++- Source/Swig/misc.c | 13 +++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/Examples/test-suite/rename_pcre_encoder.i b/Examples/test-suite/rename_pcre_encoder.i index 568a2a82d..1bee1dca8 100644 --- a/Examples/test-suite/rename_pcre_encoder.i +++ b/Examples/test-suite/rename_pcre_encoder.i @@ -3,9 +3,14 @@ // strip the wx prefix from all identifiers except those starting with wxEVT %rename("%(regex:/wx(?!EVT)(.*)/\\1/)s") ""; +// Replace "Set" prefix with "put" in all functions +%rename("%(regex:/^Set(.*)/put\\1/)s", %$isfunction) ""; + %inline %{ -class wxSomeWidget { +struct wxSomeWidget { + void SetBorderWidth(int); + void SetSize(int, int); }; struct wxAnotherWidget { diff --git a/Source/Swig/misc.c b/Source/Swig/misc.c index b3c647546..2105f0c51 100644 --- a/Source/Swig/misc.c +++ b/Source/Swig/misc.c @@ -1188,6 +1188,8 @@ String *Swig_string_regex(String *s) { int captures[30]; if (split_regex_pattern_subst(s, &pattern, &subst, &input)) { + int rc; + compiled_pat = pcre_compile( Char(pattern), pcre_options, &pcre_error, &pcre_errorpos, NULL); if (!compiled_pat) { @@ -1195,8 +1197,15 @@ String *Swig_string_regex(String *s) { pcre_error, Char(pattern), pcre_errorpos); exit(1); } - pcre_exec(compiled_pat, NULL, input, strlen(input), 0, 0, captures, 30); - res = replace_captures(input, subst, captures); + rc = pcre_exec(compiled_pat, NULL, input, strlen(input), 0, 0, captures, 30); + if (rc >= 0) { + res = replace_captures(input, subst, captures); + } + else if (rc != PCRE_ERROR_NOMATCH) { + Swig_error("SWIG", Getline(s), "PCRE execution failed: error %d while matching \"%s\" in \"%s\".\n", + rc, Char(pattern), input); + exit(1); + } } DohDelete(pattern); From 9b097847158aea3429cdf555dd40961133bffb52 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 14 Aug 2010 14:12:39 +0000 Subject: [PATCH 0982/1680] Add more regex function usage examples in %rename section. Mention the examples from the test suite and the change log file in the manual as well. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12188 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/SWIG.html | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html index 32fbe3815..bdd0edb8b 100644 --- a/Doc/Manual/SWIG.html +++ b/Doc/Manual/SWIG.html @@ -1904,6 +1904,28 @@ and a more descriptive one, but the two functions are otherwise equivalent:
    • FunctionReturnsExample (in/out)
      upper or uppercaseUpper-case version of the string.uppercase or upperUpper case version of the string. PrintPRINT
      lower or lowercaseLower-case version of the string.lowercase or lowerLower case version of the string. Printprint
      PrintItprintIt
      ctitle or camelcasecamelcase or ctitle String with capitalized first letter and any letter following an underscore (which are removed in the process) and rest in lower case. print_itPrintIt
      lctitle or lowercamelcaselowercamelcase or lctitle String with every letter following an underscore (which is removed in the process) capitalized and rest, including the first letter, in lower case. print_itprintIt
      utitle or undercaseLower case string with underscores inserted before every upper-case + undercase or utitleLower case string with underscores inserted before every upper case letter in the original string and any number not at the end of string. - Logically, this is the reverse of ccase. PrintItprint_it
      +

      +The most general function of all of the above ones (not counting +command which is even more powerful in principle but which should +generally be avoided because of performance considerations) is the +regex one. Here are some more examples of its use: +

      +
      +// Strip the wx prefix from all identifiers except those starting with wxEVT
      +%rename("%(regex:/wx(?!EVT)(.*)/\\1/)s") ""; // wxSomeWidget -> SomeWidget
      +                                             // wxEVT_PAINT -> wxEVT_PAINT
      +
      +// Apply a rule for renaming the enum elements to avoid the common prefixes
      +// which are redundant in C#/Java
      +%rename("%(regex:/^([A-Z][a-z]+)+_(.*)/\\2/)s", %$isenumitem) ""; // Colour_Red -> Red
      +
      +// Remove all "Set/Get" prefixes.
      +%rename("%(regex:/^(Set|Get)(.*)/\\2/)s") ""; // SetValue -> Value
      +                                              // GetValue -> Value
      +
      +
      +

      +

      As before, everything that was said above about %rename also applies to %ignore. In fact, the latter is just a special case of the former and From 1c8618d6355f3d246dd7b7b986454672d1092430 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 17 Aug 2010 18:40:14 +0000 Subject: [PATCH 0983/1680] Modified patch from Torsten Landschoff for fixing make distclean when the target languages that have no examples are detected - the default target was erroneously being run for clean and check of the examples git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12189 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++++ Makefile.in | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index 8fbb9a47f..d24f6c312 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,10 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.1 (in progress) =========================== +2010-08-17: wsfulton + Fix make distclean when some of the more obscure languages are detected by + configure - fixes from Torsten Landschoff. + 2010-07-28: wsfulton Restore configuring out of source for the test-suite since it broke in 1.3.37. As previously, if running 'make check-test-suite' out of source, it needs to be diff --git a/Makefile.in b/Makefile.in index 180ad3451..e1f06d0c5 100644 --- a/Makefile.in +++ b/Makefile.in @@ -160,7 +160,7 @@ clisp_examples := uffi_examples := cffi_examples := r_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/r/check.list) -go_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/go/check.list) +go_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/go/check.list) # all examples check-%-examples : @@ -170,6 +170,8 @@ check-%-examples : fi @if $(skip-$*); then \ echo skipping $* $(ACTION); \ + elif test -z "$($(strip $*_examples))"; then \ + echo empty $* $(ACTION); \ else \ $(MAKE) -k -s $($*_examples:=.actionexample) LANGUAGE=$* ACTION=$(ACTION); \ fi From 8f8804b7a1b949786c6366494786efb14ea8713a Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 17 Aug 2010 19:10:14 +0000 Subject: [PATCH 0984/1680] Fix corner case marshalling of doubles - errno was not being correctly set before calling strtod - patch from Justin Vallon git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12190 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++++ Lib/perl5/perlprimtypes.swg | 1 + 2 files changed, 5 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index d24f6c312..e4022a642 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,10 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.1 (in progress) =========================== +2010-08-17: wsfulton + [Perl] Fix corner case marshalling of doubles - errno was not being correctly + set before calling strtod - patch from Justin Vallon. + 2010-08-17: wsfulton Fix make distclean when some of the more obscure languages are detected by configure - fixes from Torsten Landschoff. diff --git a/Lib/perl5/perlprimtypes.swg b/Lib/perl5/perlprimtypes.swg index ae7bb3886..f2a614030 100644 --- a/Lib/perl5/perlprimtypes.swg +++ b/Lib/perl5/perlprimtypes.swg @@ -311,6 +311,7 @@ SWIG_AsVal_dec(double)(SV *obj, double *val) const char *nptr = SvPV_nolen(obj); if (nptr) { char *endptr; + errno = 0; double v = strtod(nptr, &endptr); if (errno == ERANGE) { errno = 0; From 69af82caa4c0207cdc150f92cac1f0498ea91928 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 26 Aug 2010 18:06:02 +0000 Subject: [PATCH 0985/1680] Fix __LINE__ and __FILE__ expansion. Mostly this did not work at all. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12192 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 6 ++- Examples/test-suite/common.mk | 1 + .../java/preproc_line_file_runme.java | 41 ++++++++++++++++ Examples/test-suite/preproc_line_file.i | 33 +++++++++++++ Source/Preprocessor/cpp.c | 48 ++++++++++++++----- 5 files changed, 116 insertions(+), 13 deletions(-) create mode 100644 Examples/test-suite/java/preproc_line_file_runme.java create mode 100644 Examples/test-suite/preproc_line_file.i diff --git a/CHANGES.current b/CHANGES.current index e4022a642..aaaf2254b 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,9 +5,13 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.1 (in progress) =========================== +2010-08-26: wsfulton + Fix __LINE__ and __FILE__ expansion reported by Camille Gillot. Mostly this + did not work at all. + 2010-08-17: wsfulton [Perl] Fix corner case marshalling of doubles - errno was not being correctly - set before calling strtod - patch from Justin Vallon. + set before calling strtod - patch from Justin Vallon - SF Bug #3038936. 2010-08-17: wsfulton Fix make distclean when some of the more obscure languages are detected by diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index af9316656..e385b11dd 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -486,6 +486,7 @@ C_TEST_CASES += \ overload_extendc \ preproc \ preproc_constants_c \ + preproc_line_file \ ret_by_value \ simple_array \ sizeof_pointer \ diff --git a/Examples/test-suite/java/preproc_line_file_runme.java b/Examples/test-suite/java/preproc_line_file_runme.java new file mode 100644 index 000000000..6550e4a78 --- /dev/null +++ b/Examples/test-suite/java/preproc_line_file_runme.java @@ -0,0 +1,41 @@ +import preproc_line_file.*; + +public class preproc_line_file_runme { + + static { + try { + System.loadLibrary("preproc_line_file"); + } catch (UnsatisfiedLinkError e) { + System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); + System.exit(1); + } + } + + public static void main(String argv[]) throws Throwable + { + int myline = preproc_line_file.MYLINE; + int myline_adjusted = preproc_line_file.MYLINE_ADJUSTED; + if (myline != 4) + throw new RuntimeException("preproc failure"); + if (myline + 100 + 1 != myline_adjusted) + throw new RuntimeException("preproc failure"); + + String myfile = preproc_line_file.MYFILE; + String myfile_adjusted = preproc_line_file.MYFILE_ADJUSTED; + if (!(myfile.equals("../../../../Examples/test-suite/preproc_line_file.i") || myfile.equals("..\\..\\..\\..\\Examples\\test-suite\\preproc_line_file.i"))) + throw new RuntimeException("preproc failure"); + + if (!(myfile_adjusted.equals("../../../../Examples/test-suite/preproc_line_file.i.bak") || myfile_adjusted.equals("..\\..\\..\\..\\Examples\\test-suite\\preproc_line_file.i.bak"))) + throw new RuntimeException("preproc failure"); + + if (!preproc_line_file.MY_STRINGNUM_A.equals("my15")) + throw new RuntimeException("preproc failed MY_STRINGNUM_A"); + + if (!preproc_line_file.MY_STRINGNUM_B.equals("my16")) + throw new RuntimeException("preproc failed MY_STRINGNUM_B"); + + int myline2 = preproc_line_file.MYLINE2; + if (myline2 != 23) + throw new RuntimeException("preproc failure"); + } +} diff --git a/Examples/test-suite/preproc_line_file.i b/Examples/test-suite/preproc_line_file.i new file mode 100644 index 000000000..11465e0d0 --- /dev/null +++ b/Examples/test-suite/preproc_line_file.i @@ -0,0 +1,33 @@ +%module preproc_line_file +%javaconst(1); +// Test __LINE__ and __FILE__ (don't change line numbers in here else runtime tests will need modifying) +#define MYLINE __LINE__ +#define MYLINE_ADJUSTED __LINE__ + 100 + +#define MYFILE __FILE__ +#define MYFILE_ADJUSTED __FILE__ ".bak" + + +#define STRINGNUM_HELP(a,b) #a#b +#define STRINGNUM(a,b) STRINGNUM_HELP(a,b) +#define STRINGNUM_UNIQUE(a) STRINGNUM(a,__LINE__) + +#define MY_STRINGNUM_A STRINGNUM_UNIQUE(my) +#define MY_STRINGNUM_B STRINGNUM_UNIQUE(my) + + +#define NUMBER_HELP(a,b) a##b +#define NUMBER(a,b) NUMBER_HELP(a,b) +#define NUMBER_UNIQUE(a) NUMBER(a,__LINE__) + +#define MYLINE2 __LINE__ + +/* +TODO: __LINE__ is wrong +struct Struct { + static const int line_num = __LINE__; +}; +const int NUMBER_UNIQUE(thing) = 0; +const int NUMBER_UNIQUE(thingamebob) = 0; +#define MYLINE3 __LINE__ +*/ diff --git a/Source/Preprocessor/cpp.c b/Source/Preprocessor/cpp.c index 5dd320994..63e6ab547 100644 --- a/Source/Preprocessor/cpp.c +++ b/Source/Preprocessor/cpp.c @@ -33,6 +33,9 @@ static Hash *included_files = 0; static List *dependencies = 0; static Scanner *id_scan = 0; static int error_as_warning = 0; /* Understand the cpp #error directive as a special #warning */ +static int macro_level = 0; +static int macro_start_line = 0; +static const String * macro_start_file = 0; /* Test a character to see if it starts an identifier */ #define isidentifier(c) ((isalpha(c)) || (c == '_') || (c == '$')) @@ -40,7 +43,7 @@ static int error_as_warning = 0; /* Understand the cpp #error directive as a spe /* Test a character to see if it valid in an identifier (after the first letter) */ #define isidchar(c) ((isalnum(c)) || (c == '_') || (c == '$')) -DOH *Preprocessor_replace(DOH *); +static DOH *Preprocessor_replace(DOH *); /* Skip whitespace */ static void skip_whitespace(String *s, String *out) { @@ -499,6 +502,10 @@ Hash *Preprocessor_define(const_String_or_char_ptr _str, int swigmacro) { Setattr(macro, kpp_varargs, "1"); } } + Setline(macrovalue, line); + Setfile(macrovalue, file); + Setline(macroname, line); + Setfile(macroname, file); Setattr(macro, kpp_value, macrovalue); Setline(macro, line); Setfile(macro, file); @@ -710,6 +717,14 @@ static String *expand_macro(String *name, List *args) { macro = Getattr(symbols, name); if (!macro) return 0; + + if (macro_level == 0) { + /* Store the start of the macro should the macro contain __LINE__ and __FILE__ for expansion */ + macro_start_line = Getline(args); + macro_start_file = Getfile(args); + } + macro_level++; + if (Getattr(macro, kpp_expanded)) { ns = NewStringEmpty(); Append(ns, name); @@ -725,6 +740,7 @@ static String *expand_macro(String *name, List *args) { if (i) Putc(')', ns); } + macro_level--; return ns; } @@ -764,11 +780,13 @@ static String *expand_macro(String *name, List *args) { Swig_error(Getfile(args), Getline(args), "Macro '%s' expects 1 argument\n", name); else Swig_error(Getfile(args), Getline(args), "Macro '%s' expects no arguments\n", name); + macro_level--; return 0; } /* If the macro expects arguments, but none were supplied, we leave it in place */ if (!args && (margs) && Len(margs) > 0) { + macro_level--; return NewString(name); } @@ -922,6 +940,7 @@ static String *expand_macro(String *name, List *args) { Delete(e); e = f; } + macro_level--; Delete(temp); Delete(tempa); return e; @@ -954,7 +973,7 @@ List *evaluate_args(List *x) { /* #define SWIG_PUT_BUFF */ -DOH *Preprocessor_replace(DOH *s) { +static DOH *Preprocessor_replace(DOH *s) { DOH *ns, *symbols, *m; int c, i, state = 0; @@ -999,7 +1018,7 @@ DOH *Preprocessor_replace(DOH *s) { if (Equal(kpp_defined, id)) { int lenargs = 0; DOH *args = 0; - /* See whether or not a paranthesis has been used */ + /* See whether or not a parenthesis has been used */ skip_whitespace(s, 0); c = Getc(s); if (c == '(') { @@ -1042,22 +1061,19 @@ DOH *Preprocessor_replace(DOH *s) { Delete(args); state = 0; break; - } - if (Equal(kpp_LINE, id)) { - Printf(ns, "%d", Getline(s)); + } else if (Equal(kpp_LINE, id)) { + Printf(ns, "%d", macro_level > 0 ? macro_start_line : Getline(s)); state = 0; break; - } - if (Equal(kpp_FILE, id)) { - String *fn = Copy(Getfile(s)); + } else if (Equal(kpp_FILE, id)) { + String *fn = Copy(macro_level > 0 ? macro_start_file : Getfile(s)); Replaceall(fn, "\\", "\\\\"); Printf(ns, "\"%s\"", fn); Delete(fn); state = 0; break; - } - /* See if the macro is defined in the preprocessor symbol table */ - if ((m = Getattr(symbols, id))) { + } else if ((m = Getattr(symbols, id))) { + /* See if the macro is defined in the preprocessor symbol table */ DOH *args = 0; DOH *e; /* See if the macro expects arguments */ @@ -1123,6 +1139,13 @@ DOH *Preprocessor_replace(DOH *s) { /* See if this is the special "defined" macro */ if (Equal(kpp_defined, id)) { Swig_error(Getfile(s), Getline(s), "No arguments given to defined()\n"); + } else if (Equal(kpp_LINE, id)) { + Printf(ns, "%d", macro_level > 0 ? macro_start_line : Getline(s)); + } else if (Equal(kpp_FILE, id)) { + String *fn = Copy(macro_level > 0 ? macro_start_file : Getfile(s)); + Replaceall(fn, "\\", "\\\\"); + Printf(ns, "\"%s\"", fn); + Delete(fn); } else if ((m = Getattr(symbols, id))) { DOH *e; /* Yes. There is a macro here */ @@ -1457,6 +1480,7 @@ String *Preprocessor_parse(String *s) { m = Preprocessor_define(value, 0); if ((m) && !(Getattr(m, kpp_args))) { v = Copy(Getattr(m, kpp_value)); + copy_location(m, v); if (Len(v)) { Swig_error_silent(1); v1 = Preprocessor_replace(v); From 13d18e4c3f094f7464530d205faae71c2da47a86 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 26 Aug 2010 18:18:11 +0000 Subject: [PATCH 0986/1680] Fix test for non Java langs git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12193 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/preproc_line_file.i | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/test-suite/preproc_line_file.i b/Examples/test-suite/preproc_line_file.i index 11465e0d0..9da137e94 100644 --- a/Examples/test-suite/preproc_line_file.i +++ b/Examples/test-suite/preproc_line_file.i @@ -1,5 +1,5 @@ %module preproc_line_file -%javaconst(1); + // Test __LINE__ and __FILE__ (don't change line numbers in here else runtime tests will need modifying) #define MYLINE __LINE__ #define MYLINE_ADJUSTED __LINE__ + 100 From 5a6443ebcfaf0865b347d24704b3acb06b4f20d9 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 29 Aug 2010 22:11:03 +0000 Subject: [PATCH 0987/1680] Fix some more instances of __LINE__ and __FILE__ numbering git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12194 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- .../java/preproc_line_file_runme.java | 12 +++++++-- Examples/test-suite/preproc_line_file.i | 27 ++++++++++++------- Source/Preprocessor/cpp.c | 12 ++++----- 3 files changed, 33 insertions(+), 18 deletions(-) diff --git a/Examples/test-suite/java/preproc_line_file_runme.java b/Examples/test-suite/java/preproc_line_file_runme.java index 6550e4a78..e390b0c19 100644 --- a/Examples/test-suite/java/preproc_line_file_runme.java +++ b/Examples/test-suite/java/preproc_line_file_runme.java @@ -34,8 +34,16 @@ public class preproc_line_file_runme { if (!preproc_line_file.MY_STRINGNUM_B.equals("my16")) throw new RuntimeException("preproc failed MY_STRINGNUM_B"); - int myline2 = preproc_line_file.MYLINE2; - if (myline2 != 23) + if (preproc_line_file.getThing27() != -1) + throw new RuntimeException("preproc failure"); + + if (preproc_line_file.getThing28() != -2) + throw new RuntimeException("preproc failure"); + + if (preproc_line_file.MYLINE2 != 30) + throw new RuntimeException("preproc failure"); + + if (SillyStruct.LINE_NUMBER != 41) throw new RuntimeException("preproc failure"); } } diff --git a/Examples/test-suite/preproc_line_file.i b/Examples/test-suite/preproc_line_file.i index 9da137e94..1a75be83a 100644 --- a/Examples/test-suite/preproc_line_file.i +++ b/Examples/test-suite/preproc_line_file.i @@ -1,6 +1,6 @@ %module preproc_line_file -// Test __LINE__ and __FILE__ (don't change line numbers in here else runtime tests will need modifying) +// Test __LINE__ and __FILE__ (don't change line numbering in here else runtime tests will need modifying) #define MYLINE __LINE__ #define MYLINE_ADJUSTED __LINE__ + 100 @@ -20,14 +20,23 @@ #define NUMBER(a,b) NUMBER_HELP(a,b) #define NUMBER_UNIQUE(a) NUMBER(a,__LINE__) +%{ +const int thing27 = -1; +const int thing28 = -2; +%} +const int NUMBER_UNIQUE(thing) = -1; /* resolves to thing27 */ +const int NUMBER_UNIQUE(thing) = -2; /* resolves to thing28 */ + #define MYLINE2 __LINE__ -/* -TODO: __LINE__ is wrong -struct Struct { - static const int line_num = __LINE__; +%javaconst(1); +%{ +struct SillyStruct { + int num; + /* static const int line_num = __LINE__; */ +}; +%} +struct SillyStruct { + int num; + static const int LINE_NUMBER = __LINE__; /* This is a C test case, but we can still use a C++ feature to wrap a constant to test __LINE__ here */ }; -const int NUMBER_UNIQUE(thing) = 0; -const int NUMBER_UNIQUE(thingamebob) = 0; -#define MYLINE3 __LINE__ -*/ diff --git a/Source/Preprocessor/cpp.c b/Source/Preprocessor/cpp.c index 63e6ab547..32f3a3bd4 100644 --- a/Source/Preprocessor/cpp.c +++ b/Source/Preprocessor/cpp.c @@ -353,8 +353,6 @@ Hash *Preprocessor_define(const_String_or_char_ptr _str, int swigmacro) { break; } } else { - /*Swig_error(Getfile(str),Getline(str),"Illegal character in macro name\n"); - goto macro_error; */ Ungetc(c, str); break; } @@ -1287,8 +1285,8 @@ String *Preprocessor_parse(String *s) { case 0: /* Initial state - in first column */ /* Look for C preprocessor directives. Otherwise, go directly to state 1 */ if (c == '#') { - add_chunk(ns, chunk, allow); copy_location(s, chunk); + add_chunk(ns, chunk, allow); cpp_lines = 1; state = 40; } else if (isspace(c)) { @@ -1682,8 +1680,8 @@ String *Preprocessor_parse(String *s) { /* %{,%} block */ if (c == '{') { start_line = Getline(s); - add_chunk(ns, chunk, allow); copy_location(s, chunk); + add_chunk(ns, chunk, allow); Putc('%', chunk); Putc(c, chunk); state = 105; @@ -1759,8 +1757,8 @@ String *Preprocessor_parse(String *s) { s1 = cpp_include(fn, sysfile); if (s1) { char *dirname; - add_chunk(ns, chunk, allow); copy_location(s, chunk); + add_chunk(ns, chunk, allow); Printf(ns, "%sfile%s \"%s\" [\n", decl, opt, Swig_filename_escape(Swig_last_file())); if (Equal(decl, kpp_dimport)) { push_imported(); @@ -1793,8 +1791,8 @@ String *Preprocessor_parse(String *s) { } else if (Equal(decl, kpp_ddefine)) { /* Got a define directive */ dlevel++; - add_chunk(ns, chunk, allow); copy_location(s, chunk); + add_chunk(ns, chunk, allow); Clear(value); copy_location(s, value); state = 150; @@ -1868,8 +1866,8 @@ String *Preprocessor_parse(String *s) { if ((state >= 30) && (state < 40)) { Swig_error(Getfile(s), -1, "Unterminated comment starting on line %d\n", start_line); } - add_chunk(ns, chunk, allow); copy_location(s, chunk); + add_chunk(ns, chunk, allow); /* DelScope(scp); */ Delete(decl); From 31b5f36b741f2eaaa44c52d0e21cd6598e8cc73f Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 29 Aug 2010 23:32:49 +0000 Subject: [PATCH 0988/1680] Fix line number and file name reporting for some macro preprocessor warnings. The line number of the macro argument has been corrected and the line number of the start of the macro instead of one past the end is used. Some examples: file.h:11: Error: Illegal macro argument name '..' file.h:19: Error: Macro 'DUPLICATE' redefined, file.h:15: Error: previous definition of 'DUPLICATE'. file.h:25: Error: Variable-length macro argument must be last parameter file.h:32: Error: Illegal character in macro argument name file.i:37: Error: Macro 'SIT' expects 2 arguments Code used for testing: // file.h %define SIT(ax,b) abc( %enddef %define MISSING_DOT1(a, b, ..) xxx %enddef %define MISSING_DOT2(..) xxx %enddef %define DUPLICATE(a,b) abc %enddef %define DUPLICATE(b) xxx %enddef %define VARARGS_WRONG(a, x, ..., b) xxx %enddef %define BAD_ARGNAME( a, b{c ) xxx %enddef SIT(1) git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12195 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Preprocessor/cpp.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Source/Preprocessor/cpp.c b/Source/Preprocessor/cpp.c index 32f3a3bd4..38a52dc3f 100644 --- a/Source/Preprocessor/cpp.c +++ b/Source/Preprocessor/cpp.c @@ -337,7 +337,7 @@ Hash *Preprocessor_define(const_String_or_char_ptr _str, int swigmacro) { Putc(c, argstr); } if (c != ')') { - Swig_error(Getfile(str), Getline(str), "Missing \')\' in macro parameters\n"); + Swig_error(Getfile(argstr), Getline(argstr), "Missing \')\' in macro parameters\n"); goto macro_error; } break; @@ -372,10 +372,10 @@ Hash *Preprocessor_define(const_String_or_char_ptr _str, int swigmacro) { argname = NewStringEmpty(); while ((c = Getc(argstr)) != EOF) { if (c == ',') { - varargname = Macro_vararg_name(argname, str); + varargname = Macro_vararg_name(argname, argstr); if (varargname) { Delete(varargname); - Swig_error(Getfile(str), Getline(str), "Variable-length macro argument must be last parameter\n"); + Swig_error(Getfile(argstr), Getline(argstr), "Variable length macro argument must be last parameter\n"); } else { Append(arglist, argname); } @@ -385,13 +385,13 @@ Hash *Preprocessor_define(const_String_or_char_ptr _str, int swigmacro) { Putc(c, argname); } else if (!(isspace(c) || (c == '\\'))) { Delete(argname); - Swig_error(Getfile(str), Getline(str), "Illegal character in macro argument name\n"); + Swig_error(Getfile(argstr), Getline(argstr), "Illegal character in macro argument name\n"); goto macro_error; } } if (Len(argname)) { /* Check for varargs */ - varargname = Macro_vararg_name(argname, str); + varargname = Macro_vararg_name(argname, argstr); if (varargname) { Append(arglist, varargname); Delete(varargname); @@ -513,7 +513,7 @@ Hash *Preprocessor_define(const_String_or_char_ptr _str, int swigmacro) { symbols = Getattr(cpp, kpp_symbols); if ((m1 = Getattr(symbols, macroname))) { if (!Checkattr(m1, kpp_value, macrovalue)) { - Swig_error(Getfile(str), Getline(str), "Macro '%s' redefined,\n", macroname); + Swig_error(Getfile(macroname), Getline(macroname), "Macro '%s' redefined,\n", macroname); Swig_error(Getfile(m1), Getline(m1), "previous definition of '%s'.\n", macroname); goto macro_error; } From 41bc29c9f0b09247e34d9a3f6314975f0bd8d7e5 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 31 Aug 2010 06:02:10 +0000 Subject: [PATCH 0989/1680] Add missing changes documentation for rev 12195 git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12196 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index aaaf2254b..90391fbfb 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,9 +5,20 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.1 (in progress) =========================== +2010-08-30: wsfulton + Fix line number and file name reporting for some macro preprocessor warnings. + The line number of the macro argument has been corrected and the line number + of the start of the macro instead of one past the end is used. Some examples: + file.h:11: Error: Illegal macro argument name '..' + file.h:19: Error: Macro 'DUPLICATE' redefined, + file.h:15: Error: previous definition of 'DUPLICATE'. + file.h:25: Error: Variable-length macro argument must be last parameter + file.h:32: Error: Illegal character in macro argument name + file.i:37: Error: Macro 'SIT' expects 2 arguments + 2010-08-26: wsfulton Fix __LINE__ and __FILE__ expansion reported by Camille Gillot. Mostly this - did not work at all. + did not work at all. Also fixes SF #2822822. 2010-08-17: wsfulton [Perl] Fix corner case marshalling of doubles - errno was not being correctly From aa728ece671c7e135d6d6dc7ab299dc6bfc78308 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 1 Sep 2010 21:06:10 +0000 Subject: [PATCH 0990/1680] Fix __LINE__ and __FILE__ expansion in macros with no arguments git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12197 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- .../test-suite/java/preproc_line_file_runme.java | 3 +++ Examples/test-suite/preproc_line_file.i | 10 ++++++++++ Source/Preprocessor/cpp.c | 16 ++++++++++------ 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/Examples/test-suite/java/preproc_line_file_runme.java b/Examples/test-suite/java/preproc_line_file_runme.java index e390b0c19..7200e4a53 100644 --- a/Examples/test-suite/java/preproc_line_file_runme.java +++ b/Examples/test-suite/java/preproc_line_file_runme.java @@ -45,5 +45,8 @@ public class preproc_line_file_runme { if (SillyStruct.LINE_NUMBER != 41) throw new RuntimeException("preproc failure"); + + if (SillyMacroClass.LINE_NUM != 45) + throw new RuntimeException("preproc failure"); } } diff --git a/Examples/test-suite/preproc_line_file.i b/Examples/test-suite/preproc_line_file.i index 1a75be83a..2ef43b017 100644 --- a/Examples/test-suite/preproc_line_file.i +++ b/Examples/test-suite/preproc_line_file.i @@ -40,3 +40,13 @@ struct SillyStruct { int num; static const int LINE_NUMBER = __LINE__; /* This is a C test case, but we can still use a C++ feature to wrap a constant to test __LINE__ here */ }; + +#define SILLY_CLASS struct SillyMacroClass { int num; static const int LINE_NUM = __LINE__; }; +SILLY_CLASS + +%{ +#define SILLY_CLASS struct SillyMacroClass { int num; }; +SILLY_CLASS +%} + + diff --git a/Source/Preprocessor/cpp.c b/Source/Preprocessor/cpp.c index 38a52dc3f..f044e344c 100644 --- a/Source/Preprocessor/cpp.c +++ b/Source/Preprocessor/cpp.c @@ -699,9 +699,12 @@ static String *get_options(String *str) { * * Perform macro expansion and return a new string. Returns NULL if some sort * of error occurred. + * name - name of the macro + * args - arguments passed to the macro + * line_file - only used for line/file name when reporting errors * ----------------------------------------------------------------------------- */ -static String *expand_macro(String *name, List *args) { +static String *expand_macro(String *name, List *args, String *line_file) { String *ns; DOH *symbols, *macro, *margs, *mvalue, *temp, *tempa, *e; int i, l; @@ -718,8 +721,8 @@ static String *expand_macro(String *name, List *args) { if (macro_level == 0) { /* Store the start of the macro should the macro contain __LINE__ and __FILE__ for expansion */ - macro_start_line = Getline(args); - macro_start_file = Getfile(args); + macro_start_line = Getline(args ? args : line_file); + macro_start_file = Getfile(args ? args : line_file); } macro_level++; @@ -1085,7 +1088,7 @@ static DOH *Preprocessor_replace(DOH *s) { } else { args = 0; } - e = expand_macro(id, args); + e = expand_macro(id, args, s); if (e) { Append(ns, e); } @@ -1151,8 +1154,9 @@ static DOH *Preprocessor_replace(DOH *s) { /* if (Getattr(m,"args")) { Swig_error(Getfile(id),Getline(id),"Macro arguments expected.\n"); } */ - e = expand_macro(id, 0); - Append(ns, e); + e = expand_macro(id, 0, s); + if (e) + Append(ns, e); Delete(e); } else { Append(ns, id); From 1e6ed0843fdc303abffab1e117b062e6c26de4fa Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 1 Sep 2010 21:11:09 +0000 Subject: [PATCH 0991/1680] minor clarification in test comment git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12198 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/varargs.i | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Examples/test-suite/varargs.i b/Examples/test-suite/varargs.i index 41e4903f0..c7931fed2 100644 --- a/Examples/test-suite/varargs.i +++ b/Examples/test-suite/varargs.i @@ -1,4 +1,5 @@ -// Tests SWIG's *default* handling of varargs. The default behavior is to simply ignore the varargs. +// Tests SWIG's *default* handling of varargs (function varargs, not preprocessor varargs). +// The default behavior is to simply ignore the varargs. %module varargs %varargs(int mode = 0) test_def; From a44f83cf0538c48c47ebae71545269fa0fa04a64 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 3 Sep 2010 06:03:48 +0000 Subject: [PATCH 0992/1680] Fix line numbers in error and warning messages which were accumulately one less than they should have been after parsing each %include/%import - bug introduced in swig-1.3.32. Also fix line numbers in error and warning messages when new line characters appear between the %include / %import statement and the filename. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12199 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 12 ++++++++++-- Source/CParse/parser.y | 2 +- Source/Preprocessor/cpp.c | 13 ++++++++----- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 90391fbfb..7213a66c0 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,10 +5,18 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.1 (in progress) =========================== +2010-09-02: wsfulton + Fix line numbers in error and warning messages which were accumulately one + less than they should have been after parsing each %include/%import - bug + introduced in swig-1.3.32. Also fix line numbers in error and warning messages + when new line characters appear between the %include / %import statement and + the filename. + 2010-08-30: wsfulton Fix line number and file name reporting for some macro preprocessor warnings. The line number of the macro argument has been corrected and the line number - of the start of the macro instead of one past the end is used. Some examples: + of the start of the macro instead of one past the end of the macro is used. + Some examples: file.h:11: Error: Illegal macro argument name '..' file.h:19: Error: Macro 'DUPLICATE' redefined, file.h:15: Error: previous definition of 'DUPLICATE'. @@ -50,7 +58,7 @@ Version 2.0.1 (in progress) adjust your regular expressions syntax as the new regex encoder uses Perl-compatible syntax and not (extended) POSIX syntax as the old one. - *** POTENTIAL INCOMPATIBILITY *** + *** POTENTIAL INCOMPATIBILITY *** 2010-07-13: vadz Add "regexmatch", "regextarget" and "notregexmatch" which can be diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index 6e41fa565..f0df6684d 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -2121,7 +2121,7 @@ include_directive: includetype options string LBRACKET { } interface RBRACKET { String *mname = 0; $$ = $6; - scanner_set_location($1.filename,$1.line); + scanner_set_location($1.filename,$1.line+1); if (strcmp($1.type,"include") == 0) set_nodeType($$,"include"); if (strcmp($1.type,"import") == 0) { mname = $2 ? Getattr($2,"module") : 0; diff --git a/Source/Preprocessor/cpp.c b/Source/Preprocessor/cpp.c index f044e344c..83ccdfca9 100644 --- a/Source/Preprocessor/cpp.c +++ b/Source/Preprocessor/cpp.c @@ -642,7 +642,6 @@ static String *get_filename(String *str, int *sysfile) { String *fn; int c; - skip_whitespace(str, 0); fn = NewStringEmpty(); copy_location(str, fn); c = Getc(str); @@ -668,9 +667,7 @@ static String *get_filename(String *str, int *sysfile) { } static String *get_options(String *str) { - int c; - skip_whitespace(str, 0); c = Getc(str); if (c == '(') { String *opt; @@ -1648,8 +1645,8 @@ String *Preprocessor_parse(String *s) { pop_imported(); } Delete(s2); + Delete(s1); } - Delete(s1); Delete(fn); } } else if (Equal(id, kpp_pragma)) { @@ -1749,6 +1746,8 @@ String *Preprocessor_parse(String *s) { /* Got some kind of file inclusion directive */ if (allow) { DOH *s1, *s2, *fn, *opt; + String *options_whitespace = NewString(""); + String *filename_whitespace = NewString(""); int sysfile = 0; if (Equal(decl, kpp_dextern)) { @@ -1756,14 +1755,16 @@ String *Preprocessor_parse(String *s) { Clear(decl); Append(decl, "%%import"); } + skip_whitespace(s, options_whitespace); opt = get_options(s); + skip_whitespace(s, filename_whitespace); fn = get_filename(s, &sysfile); s1 = cpp_include(fn, sysfile); if (s1) { char *dirname; copy_location(s, chunk); add_chunk(ns, chunk, allow); - Printf(ns, "%sfile%s \"%s\" [\n", decl, opt, Swig_filename_escape(Swig_last_file())); + Printf(ns, "%sfile%s%s%s\"%s\" [\n", decl, options_whitespace, opt, filename_whitespace, Swig_filename_escape(Swig_last_file())); if (Equal(decl, kpp_dimport)) { push_imported(); } @@ -1787,6 +1788,8 @@ String *Preprocessor_parse(String *s) { Delete(s1); } Delete(fn); + Delete(filename_whitespace); + Delete(options_whitespace); } state = 1; } else if (Equal(decl, kpp_dline)) { From 45601f24b4209b1f00b6897a01afc3ecfcf07b40 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 3 Sep 2010 17:47:12 +0000 Subject: [PATCH 0993/1680] Fix line numbers in error and warning messages for preprocessor messages within %inline. Also fixes __LINE__ within %inline git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12200 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 9 +++++++ .../java/preproc_line_file_runme.java | 16 ++++++++++-- Examples/test-suite/preproc_line_file.i | 26 +++++++++++++++++++ Source/CParse/parser.y | 3 +-- 4 files changed, 50 insertions(+), 4 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 7213a66c0..6d5cc9327 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,15 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.1 (in progress) =========================== +2010-09-02: wsfulton + Fix line numbers in error and warning messages for preprocessor messages within + %inline, for example: + + %inline %{ + #define FOOBAR 1 + #define FOOBAR "hi" + %} + 2010-09-02: wsfulton Fix line numbers in error and warning messages which were accumulately one less than they should have been after parsing each %include/%import - bug diff --git a/Examples/test-suite/java/preproc_line_file_runme.java b/Examples/test-suite/java/preproc_line_file_runme.java index 7200e4a53..8119824e9 100644 --- a/Examples/test-suite/java/preproc_line_file_runme.java +++ b/Examples/test-suite/java/preproc_line_file_runme.java @@ -11,6 +11,8 @@ public class preproc_line_file_runme { } } + public static String FILENAME_WINDOWS = "..\\..\\..\\..\\Examples\\test-suite\\preproc_line_file.i"; + public static String FILENAME_UNIX = "../../../../Examples/test-suite/preproc_line_file.i"; public static void main(String argv[]) throws Throwable { int myline = preproc_line_file.MYLINE; @@ -22,10 +24,10 @@ public class preproc_line_file_runme { String myfile = preproc_line_file.MYFILE; String myfile_adjusted = preproc_line_file.MYFILE_ADJUSTED; - if (!(myfile.equals("../../../../Examples/test-suite/preproc_line_file.i") || myfile.equals("..\\..\\..\\..\\Examples\\test-suite\\preproc_line_file.i"))) + if (!(myfile.equals(FILENAME_UNIX) || myfile.equals(FILENAME_WINDOWS))) throw new RuntimeException("preproc failure"); - if (!(myfile_adjusted.equals("../../../../Examples/test-suite/preproc_line_file.i.bak") || myfile_adjusted.equals("..\\..\\..\\..\\Examples\\test-suite\\preproc_line_file.i.bak"))) + if (!(myfile_adjusted.equals(FILENAME_UNIX + ".bak") || myfile_adjusted.equals(FILENAME_WINDOWS + ".bak"))) throw new RuntimeException("preproc failure"); if (!preproc_line_file.MY_STRINGNUM_A.equals("my15")) @@ -48,5 +50,15 @@ public class preproc_line_file_runme { if (SillyMacroClass.LINE_NUM != 45) throw new RuntimeException("preproc failure"); + + if (SillyMultipleMacroStruct.LINE_NUM != 70) + throw new RuntimeException("preproc failure"); + + if (preproc_line_file.INLINE_LINE != 76) + throw new RuntimeException("preproc failure"); + + String inlineFile = preproc_line_file.INLINE_FILE; + if (!(inlineFile.equals(FILENAME_UNIX) || inlineFile.equals(FILENAME_WINDOWS))) + throw new RuntimeException("preproc failure"); } } diff --git a/Examples/test-suite/preproc_line_file.i b/Examples/test-suite/preproc_line_file.i index 2ef43b017..5b75d0a20 100644 --- a/Examples/test-suite/preproc_line_file.i +++ b/Examples/test-suite/preproc_line_file.i @@ -50,3 +50,29 @@ SILLY_CLASS %} +%inline %{ +#ifdef SWIG +%define BODY + int num; + static const int LINE_NUM = __LINE__; +%enddef +%define KLASS(NAME) +struct NAME { + BODY +}; +%enddef +#else +#define KLASS(NAME) \ +struct NAME { \ + int num; \ +}; +#endif +KLASS(SillyMultipleMacroStruct) +%} + +%inline %{ + +#define INLINE_FILE __FILE__ +#define INLINE_LINE __LINE__ +%} + diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index f0df6684d..09ed9bcf2 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -2176,15 +2176,14 @@ inline_directive : INLINE HBLOCK { String *cpps; if (Namespaceprefix) { Swig_error(cparse_file, cparse_start_line, "%%inline directive inside a namespace is disallowed.\n"); - $$ = 0; } else { $$ = new_node("insert"); Setattr($$,"code",$2); /* Need to run through the preprocessor */ + Seek($2,0,SEEK_SET); Setline($2,cparse_start_line); Setfile($2,cparse_file); - Seek($2,0,SEEK_SET); cpps = Preprocessor_parse($2); start_inline(Char(cpps), cparse_start_line); Delete($2); From 197c8e899d8d3bf16bf696728cfe8edcd7829a8f Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 3 Sep 2010 18:44:01 +0000 Subject: [PATCH 0994/1680] Fix erroneous line numbers in argument count error messages for macro expansions git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12201 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 10 ++++++++++ Source/Preprocessor/cpp.c | 6 +++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 6d5cc9327..c09ff3409 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,16 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.1 (in progress) =========================== +2010-09-03: wsfulton + Fix erroneous line numbers in error messages for macro expansions, for example, + the error message now points to instantation of the macro, ie the last line here: + + #define MACRO2(a, b) + + #define MACRO1(NAME) MACRO2(NAME,2,3) + + MACRO1(abc) + 2010-09-02: wsfulton Fix line numbers in error and warning messages for preprocessor messages within %inline, for example: diff --git a/Source/Preprocessor/cpp.c b/Source/Preprocessor/cpp.c index 83ccdfca9..16a9ce1d3 100644 --- a/Source/Preprocessor/cpp.c +++ b/Source/Preprocessor/cpp.c @@ -773,11 +773,11 @@ static String *expand_macro(String *name, List *args, String *line_file) { /* If there are arguments, see if they match what we were given */ if (args && (margs) && (Len(margs) != Len(args))) { if (Len(margs) > (1 + isvarargs)) - Swig_error(Getfile(args), Getline(args), "Macro '%s' expects %d arguments\n", name, Len(margs) - isvarargs); + Swig_error(macro_start_file, macro_start_line, "Macro '%s' expects %d arguments\n", name, Len(margs) - isvarargs); else if (Len(margs) == (1 + isvarargs)) - Swig_error(Getfile(args), Getline(args), "Macro '%s' expects 1 argument\n", name); + Swig_error(macro_start_file, macro_start_line, "Macro '%s' expects 1 argument\n", name); else - Swig_error(Getfile(args), Getline(args), "Macro '%s' expects no arguments\n", name); + Swig_error(macro_start_file, macro_start_line, "Macro '%s' expects no arguments\n", name); macro_level--; return 0; } From 04c3e6b7d33663b8976251a6a6a48421c7227d19 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 6 Sep 2010 17:30:18 +0000 Subject: [PATCH 0995/1680] Fix line numbering for 'Unterminated call invoking macro' error git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12202 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- .../errors/pp_macro_defined_unterminated.i | 6 ++++++ Source/Preprocessor/cpp.c | 17 +++++++++-------- 2 files changed, 15 insertions(+), 8 deletions(-) create mode 100644 Examples/test-suite/errors/pp_macro_defined_unterminated.i diff --git a/Examples/test-suite/errors/pp_macro_defined_unterminated.i b/Examples/test-suite/errors/pp_macro_defined_unterminated.i new file mode 100644 index 000000000..bc44d07c6 --- /dev/null +++ b/Examples/test-suite/errors/pp_macro_defined_unterminated.i @@ -0,0 +1,6 @@ +%module xxx + + +#if defined(a +#endif + diff --git a/Source/Preprocessor/cpp.c b/Source/Preprocessor/cpp.c index 16a9ce1d3..b4866ee9c 100644 --- a/Source/Preprocessor/cpp.c +++ b/Source/Preprocessor/cpp.c @@ -325,6 +325,7 @@ Hash *Preprocessor_define(const_String_or_char_ptr _str, int swigmacro) { /* Now look for a macro name */ macroname = NewStringEmpty(); + copy_location(str, macroname); while ((c = Getc(str)) != EOF) { if (c == '(') { argstr = NewStringEmpty(); @@ -360,6 +361,7 @@ Hash *Preprocessor_define(const_String_or_char_ptr _str, int swigmacro) { if (!swigmacro) skip_whitespace(str, 0); macrovalue = NewStringEmpty(); + copy_location(str, macrovalue); while ((c = Getc(str)) != EOF) { Putc(c, macrovalue); } @@ -500,10 +502,6 @@ Hash *Preprocessor_define(const_String_or_char_ptr _str, int swigmacro) { Setattr(macro, kpp_varargs, "1"); } } - Setline(macrovalue, line); - Setfile(macrovalue, file); - Setline(macroname, line); - Setfile(macroname, file); Setattr(macro, kpp_value, macrovalue); Setline(macro, line); Setfile(macro, file); @@ -556,7 +554,7 @@ void Preprocessor_undef(const_String_or_char_ptr str) { * Isolates macro arguments and returns them in a list. For each argument, * leading and trailing whitespace is stripped (ala K&R, pg. 230). * ----------------------------------------------------------------------------- */ -static List *find_args(String *s) { +static List *find_args(String *s, int ismacro, String *macro_name) { List *args; String *str; int c, level; @@ -627,7 +625,10 @@ static List *find_args(String *s) { c = Getc(s); } unterm: - Swig_error(Getfile(args), Getline(args), "Unterminated macro call.\n"); + if (ismacro) + Swig_error(Getfile(args), Getline(args), "Unterminated call invoking macro '%s'\n", macro_name); + else + Swig_error(Getfile(args), Getline(args), "Unterminated call to '%s'\n", macro_name); return args; } @@ -1021,7 +1022,7 @@ static DOH *Preprocessor_replace(DOH *s) { c = Getc(s); if (c == '(') { Ungetc(c, s); - args = find_args(s); + args = find_args(s, 0, kpp_defined); } else if (isidchar(c)) { DOH *arg = NewStringEmpty(); args = NewList(); @@ -1077,7 +1078,7 @@ static DOH *Preprocessor_replace(DOH *s) { /* See if the macro expects arguments */ if (Getattr(m, kpp_args)) { /* Yep. We need to go find the arguments and do a substitution */ - args = find_args(s); + args = find_args(s, 1, id); if (!Len(args)) { Delete(args); args = 0; From b0609c3be210925c543633ec558cde312e3d2fc4 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 6 Sep 2010 18:10:43 +0000 Subject: [PATCH 0996/1680] Add some more preprocessor tests git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12203 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/errors/make.sh | 7 ++++++- Examples/test-suite/errors/pp_deprecated.i | 9 +++++++++ .../test-suite/errors/pp_illegal_argument.i | 20 +++++++++++++++++++ Examples/test-suite/errors/pp_pragma.i | 6 ++++++ Examples/test-suite/errors/pp_variable_args.i | 10 ++++++++++ 5 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 Examples/test-suite/errors/pp_deprecated.i create mode 100644 Examples/test-suite/errors/pp_illegal_argument.i create mode 100644 Examples/test-suite/errors/pp_pragma.i create mode 100644 Examples/test-suite/errors/pp_variable_args.i diff --git a/Examples/test-suite/errors/make.sh b/Examples/test-suite/errors/make.sh index ae38ca879..e50fd22dc 100755 --- a/Examples/test-suite/errors/make.sh +++ b/Examples/test-suite/errors/make.sh @@ -24,9 +24,12 @@ c_missing_semi c_redefine c_varargs c_varargs_neg -nomodule +nomodule pp_badeval +pp_deprecated pp_defined +pp_macro_defined_unterminated +pp_illegal_argument pp_macro_args pp_macro_badchar pp_macro_nargs @@ -39,9 +42,11 @@ pp_missing_enddef pp_missing_endif pp_missing_file pp_missing_rblock +pp_pragma pp_unterm_char pp_unterm_comment pp_unterm_string +pp_variable_args swig_apply_nargs swig_identifier swig_insert_bad diff --git a/Examples/test-suite/errors/pp_deprecated.i b/Examples/test-suite/errors/pp_deprecated.i new file mode 100644 index 000000000..68f81317b --- /dev/null +++ b/Examples/test-suite/errors/pp_deprecated.i @@ -0,0 +1,9 @@ +%module xxx + + +%extern ext; + +#warning Print this warning + +#error This is an error + diff --git a/Examples/test-suite/errors/pp_illegal_argument.i b/Examples/test-suite/errors/pp_illegal_argument.i new file mode 100644 index 000000000..13ffa4559 --- /dev/null +++ b/Examples/test-suite/errors/pp_illegal_argument.i @@ -0,0 +1,20 @@ +%module xxx + + +%define MISSING_DOT1(a, +b, +..) +xxx +%enddef + +%define MISSING_DOT2(..) +xxx +%enddef + +%define BAD_ARGNAME( +a, +b{c +) +xxx +%enddef + diff --git a/Examples/test-suite/errors/pp_pragma.i b/Examples/test-suite/errors/pp_pragma.i new file mode 100644 index 000000000..8d928690c --- /dev/null +++ b/Examples/test-suite/errors/pp_pragma.i @@ -0,0 +1,6 @@ +%module xxx + + +#pragma SWIG rubbish() + + diff --git a/Examples/test-suite/errors/pp_variable_args.i b/Examples/test-suite/errors/pp_variable_args.i new file mode 100644 index 000000000..c5f72fff9 --- /dev/null +++ b/Examples/test-suite/errors/pp_variable_args.i @@ -0,0 +1,10 @@ +%module xxx + + +%define VARARGS_WRONG(a, +x, +..., + b) +xxx +%enddef + From 46bd4a26c673babd36a551191c596cac300d8992 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 6 Sep 2010 18:12:13 +0000 Subject: [PATCH 0997/1680] Add expected error/warning messages log git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12204 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/errors/expected.log | 241 ++++++++++++++++++++++++ 1 file changed, 241 insertions(+) create mode 100644 Examples/test-suite/errors/expected.log diff --git a/Examples/test-suite/errors/expected.log b/Examples/test-suite/errors/expected.log new file mode 100644 index 000000000..ff56d9b2b --- /dev/null +++ b/Examples/test-suite/errors/expected.log @@ -0,0 +1,241 @@ +SWIG error and warning test. opts= +----------------------------------------------------------- + +:::::::::::::::::::::::::::::::: c_bad_name.i ::::::::::::::::::::::::::::::::::: +c_bad_name.i:3: Warning 121: %name is deprecated. Use %rename instead. +c_bad_name.i:3: Error: Missing argument to %name directive. + +:::::::::::::::::::::::::::::::: c_bad_native.i ::::::::::::::::::::::::::::::::::: +c_bad_native.i:3: Error: %native declaration 'foo' is not a function. + +:::::::::::::::::::::::::::::::: c_class.i ::::::::::::::::::::::::::::::::::: +c_class.i:3: Warning 301: class keyword used, but not in C++ mode. + +:::::::::::::::::::::::::::::::: c_default_error.i ::::::::::::::::::::::::::::::::::: + +:::::::::::::::::::::::::::::::: c_deprecated.i ::::::::::::::::::::::::::::::::::: +c_deprecated.i:3: Warning 102: %val directive deprecated (ignored). +c_deprecated.i:3: Warning 103: %out directive deprecated (ignored). + +:::::::::::::::::::::::::::::::: c_empty_char.i ::::::::::::::::::::::::::::::::::: +c_empty_char.i:3: Error: Empty character constant +0 + +:::::::::::::::::::::::::::::::: c_enum_badvalue.i ::::::::::::::::::::::::::::::::::: +c_enum_badvalue.i:6: Error: Type error. Expecting an integral type + +:::::::::::::::::::::::::::::::: c_extra_rblock.i ::::::::::::::::::::::::::::::::::: +c_extra_rblock.i:5: Error: Syntax error in input(1). + +:::::::::::::::::::::::::::::::: c_extra_rbrace.i ::::::::::::::::::::::::::::::::::: +c_extra_rbrace.i:5: Error: Syntax error. Extraneous '}' + +:::::::::::::::::::::::::::::::: c_extra_unsigned.i ::::::::::::::::::::::::::::::::::: +c_extra_unsigned.i:3: Error: Extra unsigned specifier. +c_extra_unsigned.i:4: Error: Extra signed specifier. +c_extra_unsigned.i:5: Error: Extra signed specifier. + +:::::::::::::::::::::::::::::::: c_insert_missing.i ::::::::::::::::::::::::::::::::::: +c_insert_missing.i:3: Error: Couldn't find 'missing_file.i'. + +:::::::::::::::::::::::::::::::: c_long_short.i ::::::::::::::::::::::::::::::::::: +c_long_short.i:3: Error: Extra long specifier. +c_long_short.i:4: Error: Extra short specifier. +c_long_short.i:5: Error: Extra long specifier. +c_long_short.i:6: Error: Extra short specifier. + +:::::::::::::::::::::::::::::::: c_missing_rbrace.i ::::::::::::::::::::::::::::::::::: +:168430090: Error: Missing '}'. Reached end of input. +c_missing_rbrace.i:3: Error: Syntax error in input(1). + +:::::::::::::::::::::::::::::::: c_missing_semi.i ::::::::::::::::::::::::::::::::::: +c_missing_semi.i:3: Error: Syntax error in input(1). + +:::::::::::::::::::::::::::::::: c_redefine.i ::::::::::::::::::::::::::::::::::: +c_redefine.i:4: Warning 302: Identifier 'foo' redefined (ignored), +c_redefine.i:3: Warning 302: previous definition of 'foo'. +c_redefine.i:8: Warning 302: Identifier 'bar' redefined (ignored), +c_redefine.i:6: Warning 302: previous definition of 'bar'. +c_redefine.i:14: Warning 322: Redundant redeclaration of 'bar' (Renamed from 'spam'), +c_redefine.i:6: Warning 322: previous declaration of 'bar'. + +:::::::::::::::::::::::::::::::: c_varargs.i ::::::::::::::::::::::::::::::::::: + +:::::::::::::::::::::::::::::::: c_varargs_neg.i ::::::::::::::::::::::::::::::::::: +c_varargs_neg.i:3: Error: Argument count in %varargs must be positive. + +:::::::::::::::::::::::::::::::: nomodule.i ::::::::::::::::::::::::::::::::::: +No module name specified using %module or -module. + +:::::::::::::::::::::::::::::::: pp_badeval.i ::::::::::::::::::::::::::::::::::: +pp_badeval.i:4: Warning 202: Could not evaluate 'FOO==4+' +pp_badeval.i:4: Warning 202: Error: 'Expected an expression' + +:::::::::::::::::::::::::::::::: pp_deprecated.i ::::::::::::::::::::::::::::::::::: +pp_deprecated.i:4: Warning 101: %extern is deprecated. Use %import instead. +pp_deprecated.i:4: Error: Unable to find 'ext;' +pp_deprecated.i:6: Warning 204: CPP #warning, Print this warning +pp_deprecated.i:8: Error: CPP #error "This is an error". Use the -cpperraswarn option to continue swig processing. + +:::::::::::::::::::::::::::::::: pp_defined.i ::::::::::::::::::::::::::::::::::: +pp_defined.i:6: Error: No arguments given to defined() +pp_defined.i:6: Warning 202: Could not evaluate 'defined' +pp_defined.i:6: Warning 202: Error: 'Expected an expression' + +:::::::::::::::::::::::::::::::: pp_macro_defined_unterminated.i ::::::::::::::::::::::::::::::::::: +pp_macro_defined_unterminated.i:4: Error: Unterminated call to 'defined' + +:::::::::::::::::::::::::::::::: pp_illegal_argument.i ::::::::::::::::::::::::::::::::::: +pp_illegal_argument.i:6: Error: Illegal macro argument name '..' +pp_illegal_argument.i:10: Error: Illegal macro argument name '..' +pp_illegal_argument.i:16: Error: Illegal character in macro argument name + +:::::::::::::::::::::::::::::::: pp_macro_args.i ::::::::::::::::::::::::::::::::::: + +:::::::::::::::::::::::::::::::: pp_macro_badchar.i ::::::::::::::::::::::::::::::::::: +pp_macro_badchar.i:4: Error: Illegal character in macro argument name + +:::::::::::::::::::::::::::::::: pp_macro_nargs.i ::::::::::::::::::::::::::::::::::: +pp_macro_nargs.i:7: Error: Macro 'foo' expects 2 arguments +pp_macro_nargs.i:8: Error: Macro 'foo' expects 2 arguments +pp_macro_nargs.i:10: Error: Macro 'bar' expects 1 argument +pp_macro_nargs.i:11: Error: Macro 'spam' expects no arguments + +:::::::::::::::::::::::::::::::: pp_macro_redef.i ::::::::::::::::::::::::::::::::::: +pp_macro_redef.i:4: Error: Macro 'foo' redefined, +pp_macro_redef.i:3: Error: previous definition of 'foo'. +pp_macro_redef.i:7: Error: Macro 'foo' redefined, +pp_macro_redef.i:3: Error: previous definition of 'foo'. + +:::::::::::::::::::::::::::::::: pp_macro_rparen.i ::::::::::::::::::::::::::::::::::: +pp_macro_rparen.i:3: Error: Missing ')' in macro parameters + +:::::::::::::::::::::::::::::::: pp_macro_unterminated.i ::::::::::::::::::::::::::::::::::: +pp_macro_unterminated.i:5: Error: Unterminated call invoking macro 'foo' + +:::::::::::::::::::::::::::::::: pp_misplaced_elif.i ::::::::::::::::::::::::::::::::::: +pp_misplaced_elif.i:4: Error: Misplaced #elif. +pp_misplaced_elif.i:6: Error: Extraneous #endif. + +:::::::::::::::::::::::::::::::: pp_misplaced_else.i ::::::::::::::::::::::::::::::::::: +pp_misplaced_else.i:4: Error: Misplaced #else. +pp_misplaced_else.i:6: Error: Extraneous #endif. + +:::::::::::::::::::::::::::::::: pp_missing_enddef.i ::::::::::::::::::::::::::::::::::: +pp_missing_enddef.i:EOF: Error: Missing %enddef for macro starting on line 3 + +:::::::::::::::::::::::::::::::: pp_missing_endif.i ::::::::::::::::::::::::::::::::::: +pp_missing_endif.i:EOF: Error: Missing #endif for conditional starting on line 3 + +:::::::::::::::::::::::::::::::: pp_missing_file.i ::::::::::::::::::::::::::::::::::: +pp_missing_file.i:3: Error: Unable to find 'missing_filename.i' + +:::::::::::::::::::::::::::::::: pp_missing_rblock.i ::::::::::::::::::::::::::::::::::: +pp_missing_rblock.i:EOF: Error: Unterminated %{ ... %} block starting on line 3 + +:::::::::::::::::::::::::::::::: pp_pragma.i ::::::::::::::::::::::::::::::::::: +pp_pragma.i:4: Error: Unknown SWIG pragma: rubbish() + +:::::::::::::::::::::::::::::::: pp_unterm_char.i ::::::::::::::::::::::::::::::::::: +pp_unterm_char.i:EOF: Error: Unterminated character constant starting at line 4 + +:::::::::::::::::::::::::::::::: pp_unterm_comment.i ::::::::::::::::::::::::::::::::::: +pp_unterm_comment.i:EOF: Error: Unterminated comment starting on line 3 + +:::::::::::::::::::::::::::::::: pp_unterm_string.i ::::::::::::::::::::::::::::::::::: +pp_unterm_string.i:EOF: Error: Unterminated string constant starting at line 4 + +:::::::::::::::::::::::::::::::: pp_variable_args.i ::::::::::::::::::::::::::::::::::: +pp_variable_args.i:6: Error: Variable length macro argument must be last parameter + +:::::::::::::::::::::::::::::::: swig_apply_nargs.i ::::::::::::::::::::::::::::::::::: +swig_apply_nargs.i:6: Error: Can't apply (char *str,int len) to (int x). Number of arguments don't match. + +:::::::::::::::::::::::::::::::: swig_identifier.i ::::::::::::::::::::::::::::::::::: +swig_identifier.i:5: Warning 503: Can't wrap 'foo bar' unless renamed to a valid identifier. + +:::::::::::::::::::::::::::::::: swig_insert_bad.i ::::::::::::::::::::::::::::::::::: +swig_insert_bad.i:5: Error: Unknown target 'foobar' for %insert directive. + +:::::::::::::::::::::::::::::::: swig_typemap_copy.i ::::::::::::::::::::::::::::::::::: +swig_typemap_copy.i:3: Error: Can't copy typemap (in) blah = int + +:::::::::::::::::::::::::::::::: swig_typemap_old.i ::::::::::::::::::::::::::::::::::: +swig_typemap_old.i:6: Warning 450: Deprecated typemap feature ($source/$target). +swig_typemap_old.i:6: Warning 450: The use of $source and $target in a typemap declaration is deprecated. +For typemaps related to argument input (in,ignore,default,arginit,check), replace +$source by $input and $target by $1. For typemaps related to return values (out, +argout,ret,except), replace $source by $1 and $target by $result. See the file +Doc/Manual/Typemaps.html for complete details. + +:::::::::::::::::::::::::::::::: cpp_bad_extern.i ::::::::::::::::::::::::::::::::::: +cpp_bad_extern.i:5: Warning 313: Unrecognized extern type "INTERCAL". +cpp_bad_extern.i:7: Warning 313: Unrecognized extern type "INTERCAL". + +:::::::::::::::::::::::::::::::: cpp_extend_redefine.i ::::::::::::::::::::::::::::::::::: +cpp_extend_redefine.i:9: Warning 302: Identifier 'bar' redefined by %extend (ignored), +cpp_extend_redefine.i:5: Warning 302: %extend definition of 'bar'. +cpp_extend_redefine.i:14: Warning 322: Redundant redeclaration of 'spam', +cpp_extend_redefine.i:10: Warning 322: previous declaration of 'spam'. + +:::::::::::::::::::::::::::::::: cpp_extend_undefined.i ::::::::::::::::::::::::::::::::::: +cpp_extend_undefined.i:6: Warning 303: %extend defined for an undeclared class foo. + +:::::::::::::::::::::::::::::::: cpp_inline_namespace.i ::::::::::::::::::::::::::::::::::: +cpp_inline_namespace.i:4: Error: %inline directive inside a namespace is disallowed. + +:::::::::::::::::::::::::::::::: cpp_missing_rtemplate.i ::::::::::::::::::::::::::::::::::: +cpp_missing_rtemplate.i:4: Error: Syntax error in input(1). + +:::::::::::::::::::::::::::::::: cpp_namespace_alias.i ::::::::::::::::::::::::::::::::::: +cpp_namespace_alias.i:8: Warning 308: Namespace alias 'B' not allowed here. Assuming 'blah' + +:::::::::::::::::::::::::::::::: cpp_namespace_aliasnot.i ::::::::::::::::::::::::::::::::::: +cpp_namespace_aliasnot.i:4: Error: 'blah' is not a namespace + +:::::::::::::::::::::::::::::::: cpp_namespace_aliasundef.i ::::::::::::::::::::::::::::::::::: +cpp_namespace_aliasundef.i:3: Error: Unknown namespace 'blah' + +:::::::::::::::::::::::::::::::: cpp_nested.i ::::::::::::::::::::::::::::::::::: +cpp_nested.i:6: Warning 325: Nested class not currently supported (Bar ignored) +cpp_nested.i:12: Warning 325: Nested class not currently supported (Grok ignored) + +:::::::::::::::::::::::::::::::: cpp_no_access.i ::::::::::::::::::::::::::::::::::: +cpp_no_access.i:3: Warning 319: No access specifier given for base class foo (ignored). + +:::::::::::::::::::::::::::::::: cpp_nobase.i ::::::::::::::::::::::::::::::::::: +cpp_nobase.i:3: Warning 401: Nothing known about base class 'Bar'. Ignored. +cpp_nobase.i:6: Warning 401: Nothing known about base class 'Bar< int >'. Ignored. +cpp_nobase.i:6: Warning 401: Maybe you forgot to instantiate 'Bar< int >' using %template. + +:::::::::::::::::::::::::::::::: cpp_overload.i ::::::::::::::::::::::::::::::::::: + +:::::::::::::::::::::::::::::::: cpp_private_defvalue.i ::::::::::::::::::::::::::::::::::: + +:::::::::::::::::::::::::::::::: cpp_private_inherit.i ::::::::::::::::::::::::::::::::::: +cpp_private_inherit.i:6: Warning 309: private inheritance ignored. +cpp_private_inherit.i:9: Warning 309: protected inheritance ignored. + +:::::::::::::::::::::::::::::::: cpp_template_argname.i ::::::::::::::::::::::::::::::::::: + +:::::::::::::::::::::::::::::::: cpp_template_nargs.i ::::::::::::::::::::::::::::::::::: +cpp_template_nargs.i:5: Error: Template 'blah' undefined. +cpp_template_nargs.i:6: Error: Template 'blah' undefined. + +:::::::::::::::::::::::::::::::: cpp_template_not.i ::::::::::::::::::::::::::::::::::: +cpp_template_not.i:5: Error: 'blah' is not defined as a template. (cdecl) + +:::::::::::::::::::::::::::::::: cpp_template_partial.i ::::::::::::::::::::::::::::::::::: +cpp_template_partial.i:3: Warning 317: Specialization of non-template 'vector'. + +:::::::::::::::::::::::::::::::: cpp_template_repeat.i ::::::::::::::::::::::::::::::::::: + +:::::::::::::::::::::::::::::::: cpp_template_undef.i ::::::::::::::::::::::::::::::::::: +cpp_template_undef.i:3: Error: Template 'blah' undefined. + +:::::::::::::::::::::::::::::::: cpp_using_not.i ::::::::::::::::::::::::::::::::::: +cpp_using_not.i:4: Error: 'blah' is not a namespace. + +:::::::::::::::::::::::::::::::: cpp_using_undef.i ::::::::::::::::::::::::::::::::::: +cpp_using_undef.i:4: Error: Nothing known about namespace 'foo' +cpp_using_undef.i:3: Warning 315: Nothing known about 'foo::bar'. From b2e2cb8f6607ae29ef78e59390aa05c4ab354440 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 6 Sep 2010 18:25:22 +0000 Subject: [PATCH 0998/1680] Add test for line number reporting for multiple macro expansions git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12205 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/errors/make.sh | 1 + Examples/test-suite/errors/pp_macro_expansion.i | 10 ++++++++++ 2 files changed, 11 insertions(+) create mode 100644 Examples/test-suite/errors/pp_macro_expansion.i diff --git a/Examples/test-suite/errors/make.sh b/Examples/test-suite/errors/make.sh index e50fd22dc..3b58d6ab0 100755 --- a/Examples/test-suite/errors/make.sh +++ b/Examples/test-suite/errors/make.sh @@ -32,6 +32,7 @@ pp_macro_defined_unterminated pp_illegal_argument pp_macro_args pp_macro_badchar +pp_macro_expansion pp_macro_nargs pp_macro_redef pp_macro_rparen diff --git a/Examples/test-suite/errors/pp_macro_expansion.i b/Examples/test-suite/errors/pp_macro_expansion.i new file mode 100644 index 000000000..e23a0da01 --- /dev/null +++ b/Examples/test-suite/errors/pp_macro_expansion.i @@ -0,0 +1,10 @@ +%module xxx + +/* Test line number reporting for multiple macro expansions */ + +#define MACRO2(a, b) + +#define MACRO1(NAME) MACRO2(NAME,2,3) + +MACRO1(abc) + From 547019e0d457fe9427ff716737b8fdb82eab1cd8 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Wed, 8 Sep 2010 00:54:31 +0000 Subject: [PATCH 0999/1680] Change HTML to be more suitable for human edits. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12207 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Ruby.html | 249 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 201 insertions(+), 48 deletions(-) diff --git a/Doc/Manual/Ruby.html b/Doc/Manual/Ruby.html index b61ded8e5..736b6137d 100644 --- a/Doc/Manual/Ruby.html +++ b/Doc/Manual/Ruby.html @@ -1,30 +1,11 @@ - - - - - - - - - - - - - - SWIG and Ruby - - - - - - +

      33 SWIG and Ruby

      @@ -255,7 +236,9 @@ header file. This file is usually contained in a directory such as

      -
      /usr/lib/ruby/1.8/x86_64-linux-gnu/ruby.h
      /usr/local/lib/ruby/1.6/i686-linux/ruby.h
      +
      /usr/lib/ruby/1.8/x86_64-linux-gnu/ruby.h
      +/usr/local/lib/ruby/1.6/i686-linux/ruby.h
      +
      @@ -276,7 +259,10 @@ installed, you can run Ruby to find out. For example:

      -
      $ ruby -e 'puts $:.join("\n")'
      /usr/local/lib/ruby/site_ruby/1.6 /usr/local/lib/ruby/site_ruby/1.6/i686-linux
      /usr/local/lib/ruby/site_ruby /usr/local/lib/ruby/1.6 /usr/local/lib/ruby/1.6/i686-linux .
      +
      $ ruby -e 'puts $:.join("\n")'
      +/usr/local/lib/ruby/site_ruby/1.6 /usr/local/lib/ruby/site_ruby/1.6/i686-linux
      +/usr/local/lib/ruby/site_ruby /usr/local/lib/ruby/1.6 /usr/local/lib/ruby/1.6/i686-linux .
      +
      @@ -324,16 +310,7 @@ looks like the following:

      - - - -
      require 'mkmf'
      create_makefile('example')
      - - - - -
      @@ -401,7 +378,12 @@ can add this:

      -
      open("Makefile", "a") { |mf|
      puts <<EOM
      # Your make rules go here
      EOM
      }
      +
      open("Makefile", "a") { |mf|
      + puts <<EOM
      + # Your make rules go here
      + EOM
      +}
      +
      @@ -424,7 +406,10 @@ operating system would look something like this:

      -
      $ swig -ruby example.i
      $ gcc -c example.c
      $ gcc -c example_wrap.c -I/usr/local/lib/ruby/1.6/i686-linux
      $ gcc -shared example.o example_wrap.o -o example.so +
      $ swig -ruby example.i
      +$ gcc -c example.c
      +$ gcc -c example_wrap.c -I/usr/local/lib/ruby/1.6/i686-linux 
      +$ gcc -shared example.o example_wrap.o -o example.so
       
      @@ -456,7 +441,12 @@ module is imported by requiring the etc feature:

      -
      # The feature name begins with a lowercase letter...
      require 'etc'

      # ... but the module name begins with an uppercase letter
      puts "Your login name: #{Etc.getlogin}"
      +
      # The feature name begins with a lowercase letter...
      +require 'etc'
      +
      +# ... but the module name begins with an uppercase letter
      +puts "Your login name: #{Etc.getlogin}"
      +
      @@ -2733,7 +2723,7 @@ i
      ->> [3, 4, 5 ]
      +>> [3, 4, 5 ]
      @@ -10098,7 +10088,38 @@ classes is:

      -
      /* File RubyOwnershipExample.i */

      %module RubyOwnershipExample

      %{
      #include "RubyOwnershipExample.h"
      %}

      class Foo
      {
      public:
      Foo();
      ~Foo();
      };

      class Bar
      {
      Foo *foo_;
      public:
      Bar();
      ~Bar();
      Foo* get_foo();

      %newobject get_new_foo;
      Foo* get_new_foo();

      %apply SWIGTYPE *DISOWN {Foo *foo};
      void set_foo(Foo *foo);
      %clear Foo *foo;
      };

      +
      /* File RubyOwnershipExample.i */
      +
      +%module RubyOwnershipExample
      +
      +%{
      +#include "RubyOwnershipExample.h"
      +%}
      +
      +class Foo
      +{
      +public:
      + Foo();
      + ~Foo();
      +};
      +
      +class Bar
      +{
      + Foo *foo_;
      +public:
      + Bar();
      + ~Bar();
      + Foo* get_foo();
      +
      + %newobject get_new_foo;
      + Foo* get_new_foo();
      +
      + %apply SWIGTYPE *DISOWN {Foo *foo};
      + void set_foo(Foo *foo);
      + %clear Foo *foo;
      +};
      +
      +
      @@ -10165,7 +10186,35 @@ class library models a zoo and the animals it contains.

      -
      $ irb
      irb(main):001:0> require 'example'
      => true

      irb(main):002:0> tiger1 = Example::Animal.new("tiger1")
      => #<Example::Animal:0x2be3820>

      irb(main):004:0> tiger1.get_name()
      => "tiger1"

      irb(main):003:0> zoo = Example::Zoo.new()
      => #<Example::Zoo:0x2be0a60>

      irb(main):006:0> zoo.add_animal(tiger)
      => nil

      irb(main):007:0> zoo.get_num_animals()
      => 1

      irb(main):007:0> tiger2 = zoo.remove_animal(0)
      => #<Example::Animal:0x2bd4a18>

      irb(main):008:0> tiger2.get_name()
      => "tiger1"

      irb(main):009:0> tiger1.equal?(tiger2)
      => false

      +
      $ irb
      +irb(main):001:0> require 'example'
      +=> true
      +
      +irb(main):002:0> tiger1 = Example::Animal.new("tiger1")
      +=> #<Example::Animal:0x2be3820>
      +
      +irb(main):004:0> tiger1.get_name()
      +=> "tiger1"
      +
      +irb(main):003:0> zoo = Example::Zoo.new()
      +=> #<Example::Zoo:0x2be0a60>
      +
      +irb(main):006:0> zoo.add_animal(tiger)
      +=> nil
      +
      +irb(main):007:0> zoo.get_num_animals()
      +=> 1
      +
      +irb(main):007:0> tiger2 = zoo.remove_animal(0)
      +=> #<Example::Animal:0x2bd4a18>
      +
      +irb(main):008:0> tiger2.get_name()
      +=> "tiger1"
      +
      +irb(main):009:0> tiger1.equal?(tiger2)
      +=> false
      +
      +
      @@ -10192,7 +10241,16 @@ the same underlying C++ object. This can cause problems. For example:
      -
      irb(main):010:0> tiger1 = nil
      => nil

      irb(main):011:0> GC.start
      => nil

      irb(main):012:0> tiger2.get_name()
      (irb):12: [BUG] Segmentation fault

      +
      irb(main):010:0> tiger1 = nil
      +=> nil
      +
      +irb(main):011:0> GC.start
      +=> nil
      +
      +irb(main):012:0> tiger2.get_name()
      +(irb):12: [BUG] Segmentation fault
      +
      +
      @@ -10251,7 +10309,7 @@ class-by-class basis if needed. To fix the example above:

      -
      %module example

      %{
      #include "example.h"
      %}

      /* Tell SWIG that create_animal creates a new object */
      %newobject Zoo::create_animal;

      /* Tell SWIG to keep track of mappings between C/C++ structs/classes. */
      %trackobjects;

      %include "example.h"
      +
      %module example

      %{
      #include "example.h"
      %}

      /* Tell SWIG that create_animal creates a new object */
      %newobject Zoo::create_animal;

      /* Tell SWIG to keep track of mappings between C/C++ structs/classes. */
      %trackobjects;

      %include "example.h"
      @@ -10282,7 +10340,7 @@ class-by-class basis if needed. To fix the example above:

      -
      $ irb
      irb(main):001:0> require 'example'
      => true

      irb(main):002:0> tiger1 = Example::Animal.new("tiger1")
      => #<Example::Animal:0x2be37d8>

      irb(main):003:0> zoo = Example::Zoo.new()
      => #<Example::Zoo:0x2be0a18>

      irb(main):004:0> zoo.add_animal(tiger1)
      => nil

      irb(main):006:0> tiger2 = zoo.remove_animal(0)
      => #<Example::Animal:0x2be37d8>

      irb(main):007:0> tiger1.equal?(tiger2)
      => true

      irb(main):008:0> tiger1 = nil
      => nil

      irb(main):009:0> GC.start
      => nil

      irb(main):010:0> tiger.get_name()
      => "tiger1"
      irb(main):011:0>

      +
      $ irb
      irb(main):001:0> require 'example'
      => true

      irb(main):002:0> tiger1 = Example::Animal.new("tiger1")
      => #<Example::Animal:0x2be37d8>

      irb(main):003:0> zoo = Example::Zoo.new()
      => #<Example::Zoo:0x2be0a18>

      irb(main):004:0> zoo.add_animal(tiger1)
      => nil

      irb(main):006:0> tiger2 = zoo.remove_animal(0)
      => #<Example::Animal:0x2be37d8>

      irb(main):007:0> tiger1.equal?(tiger2)
      => true

      irb(main):008:0> tiger1 = nil
      => nil

      irb(main):009:0> GC.start
      => nil

      irb(main):010:0> tiger.get_name()
      => "tiger1"
      irb(main):011:0>

      @@ -10359,7 +10417,7 @@ has problems. For example:
      -
      $ irb
      irb(main):001:0> require 'example'
      => true

      irb(main):002:0> tiger1 = Example::Animal.new("tiger1")
      => #<Example::Animal:0x2bea6a8>

      irb(main):003:0> zoo = Example::Zoo.new()
      => #<Example::Zoo:0x2be7960>

      irb(main):004:0> zoo.add_animal(tiger1)
      => nil

      irb(main):007:0> tiger1 = nil
      => nil

      irb(main):007:0> GC.start
      => nil

      irb(main):005:0> tiger2 = zoo.get_animal(0)
      (irb):12: [BUG] Segmentation fault
      +
      $ irb
      irb(main):001:0> require 'example'
      => true

      irb(main):002:0> tiger1 = Example::Animal.new("tiger1")
      => #<Example::Animal:0x2bea6a8>

      irb(main):003:0> zoo = Example::Zoo.new()
      => #<Example::Zoo:0x2be7960>

      irb(main):004:0> zoo.add_animal(tiger1)
      => nil

      irb(main):007:0> tiger1 = nil
      => nil

      irb(main):007:0> GC.start
      => nil

      irb(main):005:0> tiger2 = zoo.get_animal(0)
      (irb):12: [BUG] Segmentation fault
      @@ -10407,7 +10465,7 @@ implementation is:

      -
      %module example

      %{
      #include "example.h"
      %}

      /* Keep track of mappings between C/C++ structs/classes
      and Ruby objects so we can implement a mark function. */
      %trackobjects;

      /* Specify the mark function */
      %markfunc Zoo "mark_Zoo";

      %include "example.h"

      %header %{

      static void mark_Zoo(void* ptr) {
      Zoo* zoo = (Zoo*) ptr;

      /* Loop over each object and tell the garbage collector
      that we are holding a reference to them. */
      int count = zoo->get_num_animals();

      for(int i = 0; i < count; ++i) {
      Animal* animal = zoo->get_animal(i);
      VALUE object = SWIG_RubyInstanceFor(animal);

      if (object != Qnil) {
      rb_gc_mark(object);
      }
      }
      }
      %}

      +
      %module example

      %{
      #include "example.h"
      %}

      /* Keep track of mappings between C/C++ structs/classes
      and Ruby objects so we can implement a mark function. */
      %trackobjects;

      /* Specify the mark function */
      %markfunc Zoo "mark_Zoo";

      %include "example.h"

      %header %{

      static void mark_Zoo(void* ptr) {
      Zoo* zoo = (Zoo*) ptr;

      /* Loop over each object and tell the garbage collector
      that we are holding a reference to them. */
      int count = zoo->get_num_animals();

      for(int i = 0; i < count; ++i) {
      Animal* animal = zoo->get_animal(i);
      VALUE object = SWIG_RubyInstanceFor(animal);

      if (object != Qnil) {
      rb_gc_mark(object);
      }
      }
      }
      %}

      @@ -10436,7 +10494,7 @@ test suite.

      -
      $ irb
      irb(main):002:0> tiger1=Example::Animal.new("tiger1")
      => #<Example::Animal:0x2be3bf8>

      irb(main):003:0> Example::Zoo.new()
      => #<Example::Zoo:0x2be1780>

      irb(main):004:0> zoo = Example::Zoo.new()
      => #<Example::Zoo:0x2bde9c0>

      irb(main):005:0> zoo.add_animal(tiger1)
      => nil

      irb(main):009:0> tiger1 = nil
      => nil

      irb(main):010:0> GC.start
      => nil
      irb(main):014:0> tiger2 = zoo.get_animal(0)
      => #<Example::Animal:0x2be3bf8>

      irb(main):015:0> tiger2.get_name()
      => "tiger1"
      irb(main):016:0>

      +
      $ irb
      irb(main):002:0> tiger1=Example::Animal.new("tiger1")
      => #<Example::Animal:0x2be3bf8>

      irb(main):003:0> Example::Zoo.new()
      => #<Example::Zoo:0x2be1780>

      irb(main):004:0> zoo = Example::Zoo.new()
      => #<Example::Zoo:0x2bde9c0>

      irb(main):005:0> zoo.add_animal(tiger1)
      => nil

      irb(main):009:0> tiger1 = nil
      => nil

      irb(main):010:0> GC.start
      => nil
      irb(main):014:0> tiger2 = zoo.get_animal(0)
      => #<Example::Animal:0x2be3bf8>

      irb(main):015:0> tiger2.get_name()
      => "tiger1"
      irb(main):016:0>

      @@ -10512,14 +10570,22 @@ directive, let's slightly change our example. Assume that the zoo object is responsible for freeing animal that it contains. This means that the Zoo::add_animal function should be marked with a DISOWN typemap -and the destructor should be updated as below::

      +and the destructor should be updated as below:

      -
      Zoo::~Zoo() {
      IterType iter = this->animals.begin();
      IterType end = this->animals.end();

      for(iter; iter != end; ++iter) {
      Animal* animal = *iter;
      delete animal;
      }
      }
      +
      Zoo::~Zoo() {
      + IterType iter = this->animals.begin();
      + IterType end = this->animals.end();
      +
      + for(iter; iter != end; ++iter) {
      + Animal* animal = *iter;
      + delete animal;
      + }
      +}
      @@ -10538,7 +10604,29 @@ and the destructor should be updated as below::

      -
      $irb
      irb(main):002:0> require 'example'
      => true

      irb(main):003:0> zoo = Example::Zoo.new()
      => #<Example::Zoo:0x2be0fe8>

      irb(main):005:0> tiger1 = Example::Animal.new("tiger1")
      => #<Example::Animal:0x2bda760>

      irb(main):006:0> zoo.add_animal(tiger1)
      => nil

      irb(main):007:0> zoo = nil
      => nil

      irb(main):008:0> GC.start
      => nil

      irb(main):009:0> tiger1.get_name()
      (irb):12: [BUG] Segmentation fault

      +
      $irb
      +irb(main):002:0> require 'example'
      +=> true
      +
      +irb(main):003:0> zoo = Example::Zoo.new()
      +=> #<Example::Zoo:0x2be0fe8>
      +
      +irb(main):005:0> tiger1 = Example::Animal.new("tiger1")
      +=> #<Example::Animal:0x2bda760>
      +
      +irb(main):006:0> zoo.add_animal(tiger1)
      +=> nil
      +
      +irb(main):007:0> zoo = nil
      +=> nil
      +
      +irb(main):008:0> GC.start
      +=> nil
      +
      +irb(main):009:0> tiger1.get_name()
      +(irb):12: [BUG] Segmentation fault
      +
      +
      @@ -10571,7 +10659,49 @@ existing Ruby object to the destroyed C++ object and raise an exception.
      -
      %module example

      %{
      #include "example.h"
      %}

      /* Specify that ownership is transferred to the zoo
      when calling add_animal */
      %apply SWIGTYPE *DISOWN { Animal* animal };

      /* Track objects */
      %trackobjects;

      /* Specify the mark function */
      %freefunc Zoo "free_Zoo";

      %include "example.h"

      %header %{
      static void free_Zoo(void* ptr) {
      Zoo* zoo = (Zoo*) ptr;

      /* Loop over each animal */
      int count = zoo->get_num_animals();

      for(int i = 0; i < count; ++i) {
      /* Get an animal */
      Animal* animal = zoo->get_animal(i);

      /* Unlink the Ruby object from the C++ object */
      SWIG_RubyUnlinkObjects(animal);

      /* Now remove the tracking for this animal */
      SWIG_RubyRemoveTracking(animal);
      }

      /* Now call SWIG_RubyRemoveTracking for the zoo */
      SWIG_RubyRemoveTracking(ptr);

      /* Now free the zoo which will free the animals it contains */
      delete zoo;
      }
      %}
      +
      %module example
      +
      +%{
      +#include "example.h"
      +%}
      +
      +/* Specify that ownership is transferred to the zoo
      +	when calling add_animal */
      +%apply SWIGTYPE *DISOWN { Animal* animal };
      +
      +/* Track objects */
      +%trackobjects;
      +
      +/* Specify the mark function */
      +%freefunc Zoo "free_Zoo";
      +
      +%include "example.h"
      +
      +%header %{
      + static void free_Zoo(void* ptr) {
      + Zoo* zoo = (Zoo*) ptr;
      +
      + /* Loop over each animal */
      + int count = zoo->get_num_animals();
      +
      + for(int i = 0; i < count; ++i) {
      + /* Get an animal */
      + Animal* animal = zoo->get_animal(i);
      +
      + /* Unlink the Ruby object from the C++ object */
      + SWIG_RubyUnlinkObjects(animal);
      +
      + /* Now remove the tracking for this animal */
      + SWIG_RubyRemoveTracking(animal);
      + }
      +
      + /* Now call SWIG_RubyRemoveTracking for the zoo */
      + SWIG_RubyRemoveTracking(ptr);
      + 
      + /* Now free the zoo which will free the animals it contains */
      + delete zoo;
      + }
      +%} 
      @@ -10590,7 +10720,30 @@ existing Ruby object to the destroyed C++ object and raise an exception.
      -
      $irb
      irb(main):002:0> require 'example'
      => true

      irb(main):003:0> zoo = Example::Zoo.new()
      => #<Example::Zoo:0x2be0fe8>

      irb(main):005:0> tiger1 = Example::Animal.new("tiger1")
      => #<Example::Animal:0x2bda760>

      irb(main):006:0> zoo.add_animal(tiger1)
      => nil

      irb(main):007:0> zoo = nil
      => nil

      irb(main):008:0> GC.start
      => nil

      irb(main):009:0> tiger1.get_name()
      RuntimeError: This Animal * already released
      from (irb):10:in `get_name'
      from (irb):10
      irb(main):011:0>
      +
      $irb
      +irb(main):002:0> require 'example'
      +=> true
      +
      +irb(main):003:0> zoo = Example::Zoo.new()
      +=> #<Example::Zoo:0x2be0fe8>
      +
      +irb(main):005:0> tiger1 = Example::Animal.new("tiger1")
      +=> #<Example::Animal:0x2bda760>
      +
      +irb(main):006:0> zoo.add_animal(tiger1)
      +=> nil
      +
      +irb(main):007:0> zoo = nil
      +=> nil
      +
      +irb(main):008:0> GC.start
      +=> nil
      +
      +irb(main):009:0> tiger1.get_name()
      +RuntimeError: This Animal * already released
      + from (irb):10:in `get_name'
      + from (irb):10
      +irb(main):011:0>
      From a25ccbf58b5d45a5916cf81821659c1730f0e793 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Wed, 8 Sep 2010 02:40:56 +0000 Subject: [PATCH 1000/1680] [PHP] Fix handling of OUTPUT typemaps (Patch from Ryan in SF#3058394). git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12208 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 3 +++ Examples/php/cpointer/runme.php | 26 ++++++++++++++------------ Source/Modules/php.cxx | 4 +++- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index c09ff3409..b480728d7 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,9 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.1 (in progress) =========================== +2010-09-08: olly + [PHP] Fix handling of OUTPUT typemaps (Patch from Ryan in SF#3058394). + 2010-09-03: wsfulton Fix erroneous line numbers in error messages for macro expansions, for example, the error message now points to instantation of the macro, ie the last line here: diff --git a/Examples/php/cpointer/runme.php b/Examples/php/cpointer/runme.php index 48f0ad631..22e8a681a 100644 --- a/Examples/php/cpointer/runme.php +++ b/Examples/php/cpointer/runme.php @@ -6,40 +6,42 @@ print "Testing the pointer library\n"; - $a = new_intp(); - $b = new_intp(); - $c = new_intp(); - intp_assign($a,37); - intp_assign($b,42); + $a = example::new_intp(); + $b = example::new_intp(); + $c = example::new_intp(); + example::intp_assign($a,37); + example::intp_assign($b,42); print " a = $a\n"; print " b = $b\n"; print " c = $c\n"; # Call the add() function wuth some pointers - add($a,$b,$c); + example::add($a,$b,$c); # Now get the result - $r = intp_value($c); + $r = example::intp_value($c); print " 37 + 42 = $r\n"; # Clean up the pointers - delete_intp($a); - delete_intp($b); - delete_intp($c); + example::delete_intp($a); + example::delete_intp($b); + example::delete_intp($c); # Now try the typemap library # This should be much easier. Now how it is no longer # necessary to manufacture pointers. print "Trying the typemap library\n"; - $r = sub(37,42); + $r = example::sub(37,42); print " 37 - 42 = $r\n"; # Now try the version with multiple return values # print "Testing multiple return values\n"; - # ($q,$r) = divide(42,37); + # $a = example::divide(42,37); + # $q = $a[0] + # $r = $a[1] # print " 42/37 = $q remainder $r\n"; ?> diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index 365fcd370..89204d7bf 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -915,8 +915,10 @@ public: } /* Insert argument output code */ + bool hasargout = false; for (i = 0, p = l; p; i++) { if ((tm = Getattr(p, "tmap:argout"))) { + hasargout = true; Replaceall(tm, "$source", Getattr(p, "lname")); // Replaceall(tm,"$input",Getattr(p,"lname")); Replaceall(tm, "$target", "return_value"); @@ -1663,7 +1665,7 @@ public: } } Printf(output, "%s", prepare); - } else if (Cmp(d, "void") == 0) { + } else if (Cmp(d, "void") == 0 && !hasargout) { if (Cmp(invoke, "$r") != 0) Printf(output, "\t\t%s;\n", invoke); } else if (is_class(d)) { From 52819796ca8c9c36175c48a9a0f454376e5b2185 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Wed, 8 Sep 2010 02:43:32 +0000 Subject: [PATCH 1001/1680] Fix a couple of typos git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12209 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++-- Examples/test-suite/preproc_line_file.i | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index b480728d7..660e73eeb 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -10,7 +10,7 @@ Version 2.0.1 (in progress) 2010-09-03: wsfulton Fix erroneous line numbers in error messages for macro expansions, for example, - the error message now points to instantation of the macro, ie the last line here: + the error message now points to instantiation of the macro, ie the last line here: #define MACRO2(a, b) @@ -28,7 +28,7 @@ Version 2.0.1 (in progress) %} 2010-09-02: wsfulton - Fix line numbers in error and warning messages which were accumulately one + Fix line numbers in error and warning messages which were cumulatively one less than they should have been after parsing each %include/%import - bug introduced in swig-1.3.32. Also fix line numbers in error and warning messages when new line characters appear between the %include / %import statement and diff --git a/Examples/test-suite/preproc_line_file.i b/Examples/test-suite/preproc_line_file.i index 5b75d0a20..e8ca47cbc 100644 --- a/Examples/test-suite/preproc_line_file.i +++ b/Examples/test-suite/preproc_line_file.i @@ -29,11 +29,11 @@ const int NUMBER_UNIQUE(thing) = -2; /* resolves to thing28 */ #define MYLINE2 __LINE__ +#ifdef SWIGJAVA %javaconst(1); +#endif %{ -struct SillyStruct { - int num; - /* static const int line_num = __LINE__; */ +struct SillyStruct { int num; /* static const int line_num = __LINE__; */ }; %} struct SillyStruct { From f6cd7912e324cdf2633a3e4e0c626a26f627be96 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Wed, 8 Sep 2010 02:45:23 +0000 Subject: [PATCH 1002/1680] Revert change inadvertently included in previous commit. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12210 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/preproc_line_file.i | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Examples/test-suite/preproc_line_file.i b/Examples/test-suite/preproc_line_file.i index e8ca47cbc..5b75d0a20 100644 --- a/Examples/test-suite/preproc_line_file.i +++ b/Examples/test-suite/preproc_line_file.i @@ -29,11 +29,11 @@ const int NUMBER_UNIQUE(thing) = -2; /* resolves to thing28 */ #define MYLINE2 __LINE__ -#ifdef SWIGJAVA %javaconst(1); -#endif %{ -struct SillyStruct { int num; /* static const int line_num = __LINE__; */ +struct SillyStruct { + int num; + /* static const int line_num = __LINE__; */ }; %} struct SillyStruct { From 122bc852f98500360c9d7d920bf3bee220085770 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 10 Sep 2010 06:08:45 +0000 Subject: [PATCH 1003/1680] Fix #2149523 - Incorrect line number reporting in errors after parsing macros. Remove extraneous extra line in preprocessed output which would sometimes lead to error/warning messages two lines after the end of the file git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12211 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 9 ++++ Examples/test-suite/errors/make.sh | 6 ++- Examples/test-suite/errors/pp_constant.i | 43 +++++++++++++++++++ .../errors/pp_macro_inline_unterminated.i | 11 +++++ Source/Preprocessor/cpp.c | 11 ++--- Source/Swig/include.c | 2 + 6 files changed, 73 insertions(+), 9 deletions(-) create mode 100644 Examples/test-suite/errors/pp_constant.i create mode 100644 Examples/test-suite/errors/pp_macro_inline_unterminated.i diff --git a/CHANGES.current b/CHANGES.current index 660e73eeb..227f5218c 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,15 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.1 (in progress) =========================== +2010-09-10: wsfulton + Remove extraneous extra line in preprocessed output after including files + which would sometimes lead to error/warning messages two lines after the + end of the file. + +2010-09-10: wsfulton + Fix #2149523 - Incorrect line number reporting in errors after parsing macros + containing C++ comments. + 2010-09-08: olly [PHP] Fix handling of OUTPUT typemaps (Patch from Ryan in SF#3058394). diff --git a/Examples/test-suite/errors/make.sh b/Examples/test-suite/errors/make.sh index 3b58d6ab0..45c5c1733 100755 --- a/Examples/test-suite/errors/make.sh +++ b/Examples/test-suite/errors/make.sh @@ -26,13 +26,15 @@ c_varargs c_varargs_neg nomodule pp_badeval -pp_deprecated +pp_constant pp_defined -pp_macro_defined_unterminated +pp_deprecated pp_illegal_argument pp_macro_args pp_macro_badchar +pp_macro_defined_unterminated pp_macro_expansion +pp_macro_inline_unterminated pp_macro_nargs pp_macro_redef pp_macro_rparen diff --git a/Examples/test-suite/errors/pp_constant.i b/Examples/test-suite/errors/pp_constant.i new file mode 100644 index 000000000..84846f1c5 --- /dev/null +++ b/Examples/test-suite/errors/pp_constant.i @@ -0,0 +1,43 @@ +%module xxx + +/* Test preprocessor comments and their effect on line number reporting on later errors */ + +#define A1 1234 +#define A2 1234 /*C comment*/ +#define A3 1234 + +%constant int aaa=; + +#define B1 1234 +#define B2 1234 //C++ comment +#define B3 1234 + +%constant int bbb=; + +#define C1 1234 +#define C2 1234 /*multiline +C +comment */ +#define C3 1234 + +%constant int ccc=; + +#define D1 1234 +#define /*C Comment*/ D2 1234 +#define D3 1234 + +%constant int ddd=; + +#define E1 1234 +#/*C comment*/define E2 1234 +#define E3 1234 + +%constant int eee=; + +#define F1 1234 +#define F2 1234 \ +// C comment +#define F3 1234 + +%constant int fff=; + diff --git a/Examples/test-suite/errors/pp_macro_inline_unterminated.i b/Examples/test-suite/errors/pp_macro_inline_unterminated.i new file mode 100644 index 000000000..67de0942c --- /dev/null +++ b/Examples/test-suite/errors/pp_macro_inline_unterminated.i @@ -0,0 +1,11 @@ +%module xxx + +%define foo(a,x) +int ii; +%enddef + +%inline %{ +struct Struct { +foo(2, +}; +%} diff --git a/Source/Preprocessor/cpp.c b/Source/Preprocessor/cpp.c index b4866ee9c..bb56c21d2 100644 --- a/Source/Preprocessor/cpp.c +++ b/Source/Preprocessor/cpp.c @@ -1445,15 +1445,14 @@ String *Preprocessor_parse(String *s) { state = 43; } break; - case 46: + case 46: /* in C++ comment */ if (c == '\n') { Ungetc(c, s); - cpp_lines++; state = 50; } else Putc(c, comment); break; - case 47: + case 47: /* in C comment */ if (c == '*') state = 48; else @@ -1638,7 +1637,7 @@ String *Preprocessor_parse(String *s) { } s2 = Preprocessor_parse(s1); addline(ns, s2, allow); - Append(ns, "\n]"); + Append(ns, "]"); if (dirname) { Swig_pop_directory(); } @@ -1784,7 +1783,7 @@ String *Preprocessor_parse(String *s) { pop_imported(); } addline(ns, s2, allow); - Append(ns, "\n]"); + Append(ns, "]"); Delete(s2); Delete(s1); } @@ -1845,7 +1844,6 @@ String *Preprocessor_parse(String *s) { Seek(value, 0, SEEK_SET); Preprocessor_define(value, 1); } - /* Putc('\n',ns); */ addline(ns, value, 0); state = 0; } @@ -1884,6 +1882,5 @@ String *Preprocessor_parse(String *s) { Delete(comment); Delete(chunk); - /* fprintf(stderr,"cpp: %d\n", Len(Getattr(cpp,"symbols"))); */ return ns; } diff --git a/Source/Swig/include.c b/Source/Swig/include.c index baae44bb8..e3f256901 100644 --- a/Source/Swig/include.c +++ b/Source/Swig/include.c @@ -221,6 +221,8 @@ String *Swig_read_file(FILE *f) { Append(str, buffer); } len = Len(str); + /* Add a newline if not present on last line -- the preprocessor seems to + * rely on \n and not EOF terminating lines */ if (len) { char *cstr = Char(str); if (cstr[len - 1] != '\n') { From e3092a6150860764792767d375d22ec9ced2d54f Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 10 Sep 2010 06:40:42 +0000 Subject: [PATCH 1004/1680] Remove java specifics from testcase git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12212 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/java/preproc_line_file_runme.java | 8 ++++---- Examples/test-suite/preproc_line_file.i | 11 +++++++++++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/Examples/test-suite/java/preproc_line_file_runme.java b/Examples/test-suite/java/preproc_line_file_runme.java index 8119824e9..9b47ae4bd 100644 --- a/Examples/test-suite/java/preproc_line_file_runme.java +++ b/Examples/test-suite/java/preproc_line_file_runme.java @@ -45,16 +45,16 @@ public class preproc_line_file_runme { if (preproc_line_file.MYLINE2 != 30) throw new RuntimeException("preproc failure"); - if (SillyStruct.LINE_NUMBER != 41) + if (SillyStruct.LINE_NUMBER != 52) throw new RuntimeException("preproc failure"); - if (SillyMacroClass.LINE_NUM != 45) + if (SillyMacroClass.LINE_NUM != 56) throw new RuntimeException("preproc failure"); - if (SillyMultipleMacroStruct.LINE_NUM != 70) + if (SillyMultipleMacroStruct.LINE_NUM != 81) throw new RuntimeException("preproc failure"); - if (preproc_line_file.INLINE_LINE != 76) + if (preproc_line_file.INLINE_LINE != 87) throw new RuntimeException("preproc failure"); String inlineFile = preproc_line_file.INLINE_FILE; diff --git a/Examples/test-suite/preproc_line_file.i b/Examples/test-suite/preproc_line_file.i index 5b75d0a20..e28259e76 100644 --- a/Examples/test-suite/preproc_line_file.i +++ b/Examples/test-suite/preproc_line_file.i @@ -29,7 +29,18 @@ const int NUMBER_UNIQUE(thing) = -2; /* resolves to thing28 */ #define MYLINE2 __LINE__ +#if defined (SWIGJAVA) %javaconst(1); +#elif defined(SWIGCSHARP) +%csconst(1); +#else +%ignore LINE_NUMBER; +%ignore LINE_NUM; +/* spare space */ + + +#endif + %{ struct SillyStruct { int num; From 4435fe4f4adec4c04d6c1df1949dfc3080d85fd4 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 10 Sep 2010 23:39:03 +0000 Subject: [PATCH 1005/1680] Update expected error/warning results since last commit git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12213 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/errors/expected.log | 29 +++++++++++++++++++------ 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/Examples/test-suite/errors/expected.log b/Examples/test-suite/errors/expected.log index ff56d9b2b..fa8114aad 100644 --- a/Examples/test-suite/errors/expected.log +++ b/Examples/test-suite/errors/expected.log @@ -71,19 +71,24 @@ No module name specified using %module or -module. pp_badeval.i:4: Warning 202: Could not evaluate 'FOO==4+' pp_badeval.i:4: Warning 202: Error: 'Expected an expression' -:::::::::::::::::::::::::::::::: pp_deprecated.i ::::::::::::::::::::::::::::::::::: -pp_deprecated.i:4: Warning 101: %extern is deprecated. Use %import instead. -pp_deprecated.i:4: Error: Unable to find 'ext;' -pp_deprecated.i:6: Warning 204: CPP #warning, Print this warning -pp_deprecated.i:8: Error: CPP #error "This is an error". Use the -cpperraswarn option to continue swig processing. +:::::::::::::::::::::::::::::::: pp_constant.i ::::::::::::::::::::::::::::::::::: +pp_constant.i:9: Warning 305: Bad constant value (ignored). +pp_constant.i:15: Warning 305: Bad constant value (ignored). +pp_constant.i:23: Warning 305: Bad constant value (ignored). +pp_constant.i:29: Warning 305: Bad constant value (ignored). +pp_constant.i:35: Warning 305: Bad constant value (ignored). +pp_constant.i:42: Warning 305: Bad constant value (ignored). :::::::::::::::::::::::::::::::: pp_defined.i ::::::::::::::::::::::::::::::::::: pp_defined.i:6: Error: No arguments given to defined() pp_defined.i:6: Warning 202: Could not evaluate 'defined' pp_defined.i:6: Warning 202: Error: 'Expected an expression' -:::::::::::::::::::::::::::::::: pp_macro_defined_unterminated.i ::::::::::::::::::::::::::::::::::: -pp_macro_defined_unterminated.i:4: Error: Unterminated call to 'defined' +:::::::::::::::::::::::::::::::: pp_deprecated.i ::::::::::::::::::::::::::::::::::: +pp_deprecated.i:4: Warning 101: %extern is deprecated. Use %import instead. +pp_deprecated.i:4: Error: Unable to find 'ext;' +pp_deprecated.i:6: Warning 204: CPP #warning, Print this warning +pp_deprecated.i:8: Error: CPP #error "This is an error". Use the -cpperraswarn option to continue swig processing. :::::::::::::::::::::::::::::::: pp_illegal_argument.i ::::::::::::::::::::::::::::::::::: pp_illegal_argument.i:6: Error: Illegal macro argument name '..' @@ -95,6 +100,16 @@ pp_illegal_argument.i:16: Error: Illegal character in macro argument name :::::::::::::::::::::::::::::::: pp_macro_badchar.i ::::::::::::::::::::::::::::::::::: pp_macro_badchar.i:4: Error: Illegal character in macro argument name +:::::::::::::::::::::::::::::::: pp_macro_defined_unterminated.i ::::::::::::::::::::::::::::::::::: +pp_macro_defined_unterminated.i:4: Error: Unterminated call to 'defined' + +:::::::::::::::::::::::::::::::: pp_macro_expansion.i ::::::::::::::::::::::::::::::::::: +pp_macro_expansion.i:9: Error: Macro 'MACRO2' expects 2 arguments + +:::::::::::::::::::::::::::::::: pp_macro_inline_unterminated.i ::::::::::::::::::::::::::::::::::: +pp_macro_inline_unterminated.i:9: Error: Unterminated call invoking macro 'foo' +pp_macro_inline_unterminated.i:12: Error: Syntax error in input(3). + :::::::::::::::::::::::::::::::: pp_macro_nargs.i ::::::::::::::::::::::::::::::::::: pp_macro_nargs.i:7: Error: Macro 'foo' expects 2 arguments pp_macro_nargs.i:8: Error: Macro 'foo' expects 2 arguments From f82811dbcd135f37544d20d75354efe70f5d548d Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 10 Sep 2010 23:44:27 +0000 Subject: [PATCH 1006/1680] Fix incorrect line number reporting in errors/warnings after parsing macro invocations with parameters given over more than one line. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12214 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 +++ Examples/test-suite/errors/expected.log | 6 ++++ Examples/test-suite/errors/make.sh | 1 + .../errors/pp_macro_expansion_multiline.i | 32 +++++++++++++++++++ Source/Preprocessor/cpp.c | 7 ++++ 5 files changed, 50 insertions(+) create mode 100644 Examples/test-suite/errors/pp_macro_expansion_multiline.i diff --git a/CHANGES.current b/CHANGES.current index 227f5218c..20c0a6b0a 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,10 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.1 (in progress) =========================== +2010-09-11: wsfulton + Fix incorrect line number reporting in errors/warnings after parsing + macro invocations with parameters given over more than one line. + 2010-09-10: wsfulton Remove extraneous extra line in preprocessed output after including files which would sometimes lead to error/warning messages two lines after the diff --git a/Examples/test-suite/errors/expected.log b/Examples/test-suite/errors/expected.log index fa8114aad..56e10a066 100644 --- a/Examples/test-suite/errors/expected.log +++ b/Examples/test-suite/errors/expected.log @@ -106,6 +106,12 @@ pp_macro_defined_unterminated.i:4: Error: Unterminated call to 'defined' :::::::::::::::::::::::::::::::: pp_macro_expansion.i ::::::::::::::::::::::::::::::::::: pp_macro_expansion.i:9: Error: Macro 'MACRO2' expects 2 arguments +:::::::::::::::::::::::::::::::: pp_macro_expansion_multiline.i ::::::::::::::::::::::::::::::::::: +pp_macro_expansion_multiline.i:13: Warning 509: Overloaded method foo(int const *) effectively ignored, +pp_macro_expansion_multiline.i:12: Warning 509: as it is shadowed by foo(int *). +pp_macro_expansion_multiline.i:31: Warning 509: Overloaded method bar(int const *) effectively ignored, +pp_macro_expansion_multiline.i:30: Warning 509: as it is shadowed by bar(int *). + :::::::::::::::::::::::::::::::: pp_macro_inline_unterminated.i ::::::::::::::::::::::::::::::::::: pp_macro_inline_unterminated.i:9: Error: Unterminated call invoking macro 'foo' pp_macro_inline_unterminated.i:12: Error: Syntax error in input(3). diff --git a/Examples/test-suite/errors/make.sh b/Examples/test-suite/errors/make.sh index 45c5c1733..0fb3e14a4 100755 --- a/Examples/test-suite/errors/make.sh +++ b/Examples/test-suite/errors/make.sh @@ -34,6 +34,7 @@ pp_macro_args pp_macro_badchar pp_macro_defined_unterminated pp_macro_expansion +pp_macro_expansion_multiline pp_macro_inline_unterminated pp_macro_nargs pp_macro_redef diff --git a/Examples/test-suite/errors/pp_macro_expansion_multiline.i b/Examples/test-suite/errors/pp_macro_expansion_multiline.i new file mode 100644 index 000000000..b0777de60 --- /dev/null +++ b/Examples/test-suite/errors/pp_macro_expansion_multiline.i @@ -0,0 +1,32 @@ +%module xxx +// Testing macros split over multiple lines - ensure the warning message for the ignored functions contain the correct line numbering + +#define MYMACRO(NAME, A, B, C) void NAME(int A, int B, int C); + +MYMACRO(funk, x, +y, + +z +) + +void foo(int *); +void foo(const int *); + +%define MYSWIGMACRO(A, B, C) +MYMACRO(funk1, + AA, + BB, + CC) +MYMACRO(funk2, + AA, + BB, + CC) +%enddef + +MYSWIGMACRO(xx, + yy, + zz) + +void bar(int *); +void bar(const int *); + diff --git a/Source/Preprocessor/cpp.c b/Source/Preprocessor/cpp.c index bb56c21d2..23896fc50 100644 --- a/Source/Preprocessor/cpp.c +++ b/Source/Preprocessor/cpp.c @@ -1075,10 +1075,14 @@ static DOH *Preprocessor_replace(DOH *s) { /* See if the macro is defined in the preprocessor symbol table */ DOH *args = 0; DOH *e; + int macro_additional_lines = 0; /* See if the macro expects arguments */ if (Getattr(m, kpp_args)) { /* Yep. We need to go find the arguments and do a substitution */ + int line = Getline(s); args = find_args(s, 1, id); + macro_additional_lines = Getline(s) - line; + assert(macro_additional_lines >= 0); if (!Len(args)) { Delete(args); args = 0; @@ -1090,6 +1094,9 @@ static DOH *Preprocessor_replace(DOH *s) { if (e) { Append(ns, e); } + while (macro_additional_lines--) { + Putc('\n', ns); + } Delete(e); Delete(args); } else { From efb9090a87d557b4fe244485aa0756f944a765f5 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 11 Sep 2010 11:02:18 +0000 Subject: [PATCH 1007/1680] Fix correct line number reporting in errors/warnings when a macro definition ends with '/' and it is not the end of a C comment - swig.swg has some of these macro definitions. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12215 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++++ Examples/test-suite/errors/expected.log | 2 ++ Examples/test-suite/errors/pp_constant.i | 7 +++++++ Examples/test-suite/java/preproc_line_file_runme.java | 4 ++++ Examples/test-suite/preproc_line_file.i | 6 ++++++ Source/Preprocessor/cpp.c | 1 - 6 files changed, 23 insertions(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index 20c0a6b0a..64770055f 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,10 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.1 (in progress) =========================== +2010-09-11: wsfulton + Fix incorrect line number reporting in errors/warnings when a macro + definition ends with '/' and it is not the end of a C comment. + 2010-09-11: wsfulton Fix incorrect line number reporting in errors/warnings after parsing macro invocations with parameters given over more than one line. diff --git a/Examples/test-suite/errors/expected.log b/Examples/test-suite/errors/expected.log index 56e10a066..1fd592f04 100644 --- a/Examples/test-suite/errors/expected.log +++ b/Examples/test-suite/errors/expected.log @@ -78,6 +78,8 @@ pp_constant.i:23: Warning 305: Bad constant value (ignored). pp_constant.i:29: Warning 305: Bad constant value (ignored). pp_constant.i:35: Warning 305: Bad constant value (ignored). pp_constant.i:42: Warning 305: Bad constant value (ignored). +pp_constant.i:46: Warning 305: Bad constant value (ignored). +pp_constant.i:49: Warning 305: Bad constant value (ignored). :::::::::::::::::::::::::::::::: pp_defined.i ::::::::::::::::::::::::::::::::::: pp_defined.i:6: Error: No arguments given to defined() diff --git a/Examples/test-suite/errors/pp_constant.i b/Examples/test-suite/errors/pp_constant.i index 84846f1c5..2be108e83 100644 --- a/Examples/test-suite/errors/pp_constant.i +++ b/Examples/test-suite/errors/pp_constant.i @@ -41,3 +41,10 @@ comment */ %constant int fff=; +// Test macro ending in /, that is not a C comment terminator +#define G1 1234 +#define G2 1234 / +#define G3 1234 + +%constant int ggg=; + diff --git a/Examples/test-suite/java/preproc_line_file_runme.java b/Examples/test-suite/java/preproc_line_file_runme.java index 9b47ae4bd..c29cef680 100644 --- a/Examples/test-suite/java/preproc_line_file_runme.java +++ b/Examples/test-suite/java/preproc_line_file_runme.java @@ -60,5 +60,9 @@ public class preproc_line_file_runme { String inlineFile = preproc_line_file.INLINE_FILE; if (!(inlineFile.equals(FILENAME_UNIX) || inlineFile.equals(FILENAME_WINDOWS))) throw new RuntimeException("preproc failure"); + + if (Slash.LINE_NUM != 93) + throw new RuntimeException("preproc failure"); + } } diff --git a/Examples/test-suite/preproc_line_file.i b/Examples/test-suite/preproc_line_file.i index e28259e76..353aa999f 100644 --- a/Examples/test-suite/preproc_line_file.i +++ b/Examples/test-suite/preproc_line_file.i @@ -87,3 +87,9 @@ KLASS(SillyMultipleMacroStruct) #define INLINE_LINE __LINE__ %} +#define MACRO_END_WITH_SLASH ABCD/ + +%inline %{ +KLASS(Slash) +%} + diff --git a/Source/Preprocessor/cpp.c b/Source/Preprocessor/cpp.c index 23896fc50..0e8c3fb84 100644 --- a/Source/Preprocessor/cpp.c +++ b/Source/Preprocessor/cpp.c @@ -1444,7 +1444,6 @@ String *Preprocessor_parse(String *s) { else if (c == '\n') { Putc('/', value); Ungetc(c, s); - cpp_lines++; state = 50; } else { Putc('/', value); From a26d6188a701ab8d17cca306cbe869a12d22e1c7 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 11 Sep 2010 11:44:08 +0000 Subject: [PATCH 1008/1680] Work around autoconf 2.60 requirement due to use of AC_PROG_SED. We currently require autoconf 2.58 only but AC_PROG_SED used by AX_PATH_GENERIC internally is only defined by autoconf 2.60. To avoid requiring a newer autoconf version just for this macro, predefine it as just "sed" for the old versions. This fixes the build with autoconf 2.58. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12216 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- configure.in | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/configure.in b/configure.in index 1e51956d9..856d02d4a 100644 --- a/configure.in +++ b/configure.in @@ -3,7 +3,11 @@ dnl The macros which aren't shipped with the autotools are stored in the dnl Tools/config directory in .m4 files. AC_INIT([swig],[2.0.1],[http://www.swig.org]) + +dnl NB: When this requirement is increased to 2.60 or later, AC_PROG_SED +dnl definition below can be removed AC_PREREQ(2.58) + AC_CONFIG_SRCDIR([Source/Swig/swig.h]) AC_CONFIG_AUX_DIR([Tools/config]) AC_CONFIG_HEADERS([Source/Include/swigconfig.h]) @@ -50,6 +54,11 @@ AC_CHECK_FUNC(popen, AC_DEFINE(HAVE_POPEN, 1, [Define if popen is available]), A fi dnl PCRE + +dnl AX_PATH_GENERIC() relies on AC_PROG_SED() but it is defined only in +dnl autoconf 2.60 so trivially predefine it ourselves for the older versions +m4_ifdef([AC_PROG_SED],, [AC_DEFUN([AC_PROG_SED], [AC_PATH_PROG([SED], sed)])]) + AC_ARG_WITH([pcre], [AS_HELP_STRING([--without-pcre], [Disable support for regular expressions using PCRE])], From f89181d4c8eba9384f904688940c0cb65f62f7d0 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 11 Sep 2010 11:44:26 +0000 Subject: [PATCH 1009/1680] Fix the rename_pcre_encoder unit test for Python. Due to a bug in the way %rename() directives without a name currently work, the second %rename in rename_pcre_encoder.i overrides the first one and the function wxDoSomething() is not renamed to DoSomething() any more. Remove the test for this renaming that doesn't work to at least let the rest of the test to pass. Also test that SetXXX() functions from the .i file really are renamed to putXXX() as expected. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12217 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/python/rename_pcre_encoder_runme.py | 2 ++ Examples/test-suite/rename_pcre_encoder.i | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Examples/test-suite/python/rename_pcre_encoder_runme.py b/Examples/test-suite/python/rename_pcre_encoder_runme.py index f06c3d25a..ed7ca48b1 100644 --- a/Examples/test-suite/python/rename_pcre_encoder_runme.py +++ b/Examples/test-suite/python/rename_pcre_encoder_runme.py @@ -1,6 +1,8 @@ from rename_pcre_encoder import * s = SomeWidget() +s.putBorderWidth(3) +s.putSize(4, 5) a = AnotherWidget() a.DoSomething() diff --git a/Examples/test-suite/rename_pcre_encoder.i b/Examples/test-suite/rename_pcre_encoder.i index 1bee1dca8..c90af164d 100644 --- a/Examples/test-suite/rename_pcre_encoder.i +++ b/Examples/test-suite/rename_pcre_encoder.i @@ -9,12 +9,12 @@ %inline %{ struct wxSomeWidget { - void SetBorderWidth(int); - void SetSize(int, int); + void SetBorderWidth(int) {} + void SetSize(int, int) {} }; struct wxAnotherWidget { - void wxDoSomething() {} + void DoSomething() {} }; class wxEVTSomeEvent { From c0fe7400d2a4fa334558c73be3a6f1f2dd0f0bf7 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 14 Sep 2010 06:34:57 +0000 Subject: [PATCH 1010/1680] Fix undefined behaviour with Ruby and autodoc generation git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12218 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/ruby.cxx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx index bcdfd69d3..3887d8a98 100644 --- a/Source/Modules/ruby.cxx +++ b/Source/Modules/ruby.cxx @@ -121,6 +121,7 @@ public: /* flags for the make_autodoc function */ enum autodoc_t { + AUTODOC_NOTSET, AUTODOC_CLASS, AUTODOC_CTOR, AUTODOC_DTOR, @@ -580,6 +581,9 @@ private: case AUTODOC_SETTER: Printf(doc, " Document-method: %s.%s=\n\n", full_name, symname); break; + case AUTODOC_NOTSET: + assert(0); + break; } } @@ -608,6 +612,9 @@ private: if (type) Printf(doc, " -> %s", type); break; } + case AUTODOC_NOTSET: + assert(0); + break; default: break; } @@ -665,6 +672,9 @@ private: if (type) Printf(doc, " -> %s", type); break; } + case AUTODOC_NOTSET: + assert(0); + break; } } @@ -698,6 +708,9 @@ private: case AUTODOC_SETTER: Printf(doc, "Set new value for attribute.\n"); break; + case AUTODOC_NOTSET: + assert(0); + break; } } @@ -762,6 +775,7 @@ public: modvar = 0; feature = 0; prefix = 0; + last_mode = AUTODOC_NOTSET, last_autodoc = NewString(""); current = NO_CPP; classes = 0; From cfcad4ab696deb4af525a7f8a8ee9a97d8d9af1b Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 14 Sep 2010 18:50:04 +0000 Subject: [PATCH 1011/1680] Fix/Workaround unexpected call to Hash_str() when running make director_protected_overloaded.cpptest and director_using.cpptest git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12219 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Swig/tree.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/Swig/tree.c b/Source/Swig/tree.c index c76ac958e..e66670c7c 100644 --- a/Source/Swig/tree.c +++ b/Source/Swig/tree.c @@ -291,10 +291,10 @@ void Swig_require(const char *ns, Node *n, ...) { if (view) { if (Strcmp(view, ns) != 0) { Setattr(n, NewStringf("%s:view", ns), view); - Setattr(n, "view", ns); + Setattr(n, "view", NewString(ns)); } } else { - Setattr(n, "view", ns); + Setattr(n, "view", NewString(ns)); } } } @@ -337,10 +337,10 @@ void Swig_save(const char *ns, Node *n, ...) { if (view) { if (Strcmp(view, ns) != 0) { Setattr(n, NewStringf("%s:view", ns), view); - Setattr(n, "view", ns); + Setattr(n, "view", NewString(ns)); } } else { - Setattr(n, "view", ns); + Setattr(n, "view", NewString(ns)); } } } From a202bf98183f8ef66d83d3c75e22078bcfdc4922 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 14 Sep 2010 18:52:18 +0000 Subject: [PATCH 1012/1680] Fix undefined behaviour git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12220 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/ruby.cxx | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx index 3887d8a98..bcdfd69d3 100644 --- a/Source/Modules/ruby.cxx +++ b/Source/Modules/ruby.cxx @@ -121,7 +121,6 @@ public: /* flags for the make_autodoc function */ enum autodoc_t { - AUTODOC_NOTSET, AUTODOC_CLASS, AUTODOC_CTOR, AUTODOC_DTOR, @@ -581,9 +580,6 @@ private: case AUTODOC_SETTER: Printf(doc, " Document-method: %s.%s=\n\n", full_name, symname); break; - case AUTODOC_NOTSET: - assert(0); - break; } } @@ -612,9 +608,6 @@ private: if (type) Printf(doc, " -> %s", type); break; } - case AUTODOC_NOTSET: - assert(0); - break; default: break; } @@ -672,9 +665,6 @@ private: if (type) Printf(doc, " -> %s", type); break; } - case AUTODOC_NOTSET: - assert(0); - break; } } @@ -708,9 +698,6 @@ private: case AUTODOC_SETTER: Printf(doc, "Set new value for attribute.\n"); break; - case AUTODOC_NOTSET: - assert(0); - break; } } @@ -775,7 +762,6 @@ public: modvar = 0; feature = 0; prefix = 0; - last_mode = AUTODOC_NOTSET, last_autodoc = NewString(""); current = NO_CPP; classes = 0; From d1e66431613ad092aa91770f52a2a2e5dede5a23 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 15 Sep 2010 20:17:11 +0000 Subject: [PATCH 1013/1680] Expand the family of debug print functions for displaying DOH types. Provide gdb support for calling these. Document improved debugging experience. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12221 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 5 ++ Doc/Devel/internals.html | 164 +++++++++++++++++++++++++++++++++------ Doc/Devel/tree.html | 35 +++++++-- Source/DOH/doh.h | 4 + Source/DOH/hash.c | 53 ++++++++++--- Source/DOH/list.c | 2 +- Source/Modules/lang.cxx | 2 +- Source/Modules/swigmod.h | 9 ++- Source/Modules/utils.cxx | 113 +++++++++++++++++++++++++++ Source/Swig/error.c | 35 +++++++++ Source/Swig/misc.c | 1 - Source/Swig/swig.h | 4 +- Tools/swig.gdb | 41 ++++++++++ 13 files changed, 421 insertions(+), 47 deletions(-) create mode 100644 Tools/swig.gdb diff --git a/CHANGES.current b/CHANGES.current index 64770055f..ff5b40fb6 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,11 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.1 (in progress) =========================== +2010-09-15: wsfulton + A much improved debugging of SWIG source experience is now available and + documented in the "Debugging SWIG" section in the Doc/Devel/internals.html + file, including a swig.dbg support file for the gdb debugger. + 2010-09-11: wsfulton Fix incorrect line number reporting in errors/warnings when a macro definition ends with '/' and it is not the end of a C comment. diff --git a/Doc/Devel/internals.html b/Doc/Devel/internals.html index 6ac3947f7..d24869d10 100644 --- a/Doc/Devel/internals.html +++ b/Doc/Devel/internals.html @@ -7,11 +7,6 @@

      SWIG Internals Manual

      -Thien-Thi Nguyen
      - -

      -David M. Beazley
      -

      @@ -45,6 +40,9 @@ David M. Beazley
    • 5. C/C++ Wrapper Support Functions
    • 6. Symbol Naming Guidelines for Generated C/C++ Code
    • 7. Debugging SWIG +
    @@ -1015,15 +1013,139 @@ In the past SWIG has generated many symbols which flout the standard especially

    7. Debugging SWIG

    -Warning. Debugging SWIG is for the very patient. + +

    +The DOH types used in the SWIG source code are all typedefined to void. +Consequently, it is impossible for debuggers to automatically extract any information about DOH objects. +The easiest approach to debugging and viewing the contents of DOH objects is to make a call into one of the family of SWIG print functions from the debugger. +The "Debugging Functions" section in SWIG Parse Tree Handling lists them. +It is sometimes easier to debug by placing a few calls to these functions in code of interest and recompile, especially if your debugger cannot easily make calls into functions within a debugged binary. +

    + +

    +The SWIG distribution comes with some additional support for the gdb debugger in the Tools/swig.gdb file. +Follow the instructions in this file for 'installing'. +This support file provides an easy way to call into some of the family of SWIG print functions via additional user-defined gdb commands. +Some usage of the swigprint and locswigprint user-defined commands are demonstrated below. +

    + +

    +More often than not, a parse tree node needs to be examined. +The session below displays the node n in one of the Java language module wrapper functions. +The swigprint method is used to show the symbol name (symname - a DOH String type) and the node (n - a DOH Hash type). +

    +
    +
    +Breakpoint 1, JAVA::functionWrapper (this=0x97ea5f0, n=0xb7d2afc8) at Modules/java.cxx:799
    +799	    String *symname = Getattr(n, "sym:name");
    +(gdb) next
    +800	    SwigType *t = Getattr(n, "type");
    +(gdb) swigprint symname
    +Shape_x_set
    +(gdb) swigprint n
    +Hash(0xb7d2afc8) {
    +  'membervariableHandler:view' : variableHandler, 
    +  'feature:except' : 0, 
    +  'name' : x, 
    +  'ismember' : 1, 
    +  'sym:symtab' : Hash(0xb7d2aca8) {......}, 
    +  'nodeType' : cdecl, 
    +  'nextSibling' : Hash(0xb7d2af98) {.............}, 
    +  'kind' : variable, 
    +  'variableHandler:feature:immutable' : <Object 'VoidObj' at 0xb7cfa008>, 
    +  'sym:name' : Shape_x_set, 
    +  'view' : membervariableHandler, 
    +  'membervariableHandler:sym:name' : x, 
    +  'membervariableHandler:type' : double, 
    +  'membervariableHandler:parms' : <Object 'VoidObj' at 0xb7cfa008>, 
    +  'parentNode' : Hash(0xb7d2abc8) {..............................}, 
    +  'feature:java:enum' : typesafe, 
    +  'access' : public, 
    +  'parms' : Hash(0xb7cb9408) {......}, 
    +  'wrap:action' : if (arg1) (arg1)->x = arg2;, 
    +  'type' : void, 
    +  'memberset' : 1, 
    +  'sym:overname' : __SWIG_0, 
    +  'membervariableHandler:name' : x, 
    +}
    +
    +
    + +

    +Note that all the attributes in the Hash are shown, including the 'sym:name' attribute which was assigned to the symname variable. +

    + +

    +Hash types can be shown either expanded or collapsed. +When a Hash is shown expanded, all the attributes are displayed along with their values, otherwise a '.' replaces each attribute when collapsed. +Therefore a count of the dots provides the number of attributes within an unexpanded Hash. +Below shows the 'parms' Hash being displayed with the default Hash expansion of 1, then with 2 provided as the second argument to swigprint to expand to two Hash levels in order to view the contents of the collapsed 'nextSibling' Hash. +

    + +
    +
    +(gdb) swigprint 0xb7cb9408
    +Hash(0xb7cb9408) {
    +  'name' : self, 
    +  'type' : p.Shape, 
    +  'self' : 1, 
    +  'nextSibling' : Hash(0xb7cb9498) {...}, 
    +  'hidden' : 1, 
    +  'nodeType' : parm, 
    +}
    +(gdb) swigprint 0xb7cb9408 2
    +Hash(0xb7cb9408) {
    +  'name' : self, 
    +  'type' : p.Shape, 
    +  'self' : 1, 
    +  'nextSibling' : Hash(0xb7cb9498) {
    +    'name' : x, 
    +    'type' : double, 
    +    'nodeType' : parm, 
    +  }, 
    +  'hidden' : 1, 
    +  'nodeType' : parm, 
    +}
    +
    +
    + +

    +The same Hash can also be displayed with file and line location information via the locswigprint command. +

    + +
    +
    +(gdb) locswigprint 0xb7cb9408
    +example.h:11: [Hash(0xb7cb9408) {
    +Hash(0xb7cb9408) {
    +  'name' : self, 
    +  'type' : p.Shape, 
    +  'self' : 1, 
    +  'nextSibling' : Hash(0xb7cb9498) {...}, 
    +  'hidden' : 1, 
    +  'nodeType' : parm, 
    +}]
    +
    +
    + +

    +Tip: Commands in gdb can be shortened with whatever makes them unique and can be command completed with the tab key. +Thus swigprint can usually be shortened to sw and locswigprint to loc. +The help for each command can also be obtained within the debugging session, for example, 'help swigprint'. +

    + +

    +The sub-section below gives pointers for debugging DOH objects using casts and provides an insight into why it can be hard to debug SWIG without the family of print functions.

    -The DOH types are all typedefined to void. -Consequently, it is impossible for debuggers to extract any information about DOH objects. -Most debuggers will be able to display useful variable information when an object is cast to the appropriate type. -Below are some tips for displaying some of the DOH objects. -Be sure to compile with compiler optimisations turned off before attempting the casts shown in a debugger window else they are unlikely to work. -Even displaying the underlying string in a String* doesn't work straight off in all debuggers due to the multiple definition of String as a struct and a void. + +

    7.1 Debugging DOH Types The Hard Way

    + +The DOH types used in SWIG are all typedefined to void and hence the lack of type information for inspecting types within a debugger. +Most debuggers will however be able to display useful variable information when an object is cast to the appropriate type. +Getting at the underlying C string within DOH types is cumbersome, but possible with appropriate casts. +The casts below can be used in a debugger windows, but be sure to compile with compiler optimisations turned off before attempting the casts else they are unlikely to work. +Even displaying the underlying string in a String * doesn't work straight off in all debuggers due to the multiple definitions of String as a struct and a void.

    Below are a list of common SWIG types. @@ -1033,36 +1155,30 @@ With each is the cast that can be used in the debugger to extract the underlying

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

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

  • const_String_or_char_ptr sc;
  • Either
    -(*(struct String *)(((DohBase *)sc)->data)).str +(*(struct String *)(((DohBase *)sc)->data)).str
    or
    -(char *)sc +(char *)sc
    will work depending on whether the underlying type is really a String * or char *. -

    -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-2010 SWIG Development Team. diff --git a/Doc/Devel/tree.html b/Doc/Devel/tree.html index 43ad191f6..db3c6fee4 100644 --- a/Doc/Devel/tree.html +++ b/Doc/Devel/tree.html @@ -6,13 +6,6 @@

    SWIG Parse Tree Handling

    - -

    -David M. Beazley
    -dave-swig@dabeaz.com
    -December, 2006
    - -

    Introduction

    @@ -210,7 +203,33 @@ This function restores a node to the state it was in prior to the last Swig_

    Debugging Functions

    -The following functions are used to help debug SWIG parse trees. +

    +The following functions can be used to help debug any SWIG DOH object. +

    + +void Swig_print(DOH *object, int count = -1) + +
    +Prints to stdout a string representation of any DOH type. +The number of nested Hash types to expand is set by count (default is 1 if count<0). See Swig_set_max_hash_expand() to change default. +
    +
    +
    + +void Swig_print_with_location(DOH *object, int count = -1) + +
    +Prints to stdout a string representation of any DOH type, within [] brackets +for Hash and List types, prefixed by line and file information. +The number of nested Hash types to expand is set by count (default is 1 if count<0). See Swig_set_max_hash_expand() to change default. +
    +
    +
    + + +

    +The following functions can be used to help debug SWIG parse trees. +

    void Swig_print_tags(Node *node, String_or_char *prefix) diff --git a/Source/DOH/doh.h b/Source/DOH/doh.h index e46d103de..6fa352547 100644 --- a/Source/DOH/doh.h +++ b/Source/DOH/doh.h @@ -267,6 +267,8 @@ extern int DohIsSequence(const DOH *obj); extern int DohIsString(const DOH *obj); extern int DohIsFile(const DOH *obj); +extern void DohSetMaxHashExpand(int count); +extern int DohGetMaxHashExpand(void); extern void DohSetmark(DOH *obj, int x); extern int DohGetmark(DOH *obj); @@ -424,6 +426,8 @@ extern void DohMemoryDebug(void); #define SplitLines DohSplitLines #define Setmark DohSetmark #define Getmark DohGetmark +#define SetMaxHashExpand DohSetMaxHashExpand +#define GetMaxHashExpand DohGetMaxHashExpand #define None DohNone #define Call DohCall #define First DohFirst diff --git a/Source/DOH/hash.c b/Source/DOH/hash.c index 87f8e3c40..48afd2e54 100644 --- a/Source/DOH/hash.c +++ b/Source/DOH/hash.c @@ -42,6 +42,7 @@ typedef struct KeyValue { } KeyValue; static KeyValue *root = 0; +static int max_expand = 1; /* Find or create a key in the interned key table */ static DOH *find_key(DOH *doh_c) { @@ -378,6 +379,26 @@ static DOH *Hash_keys(DOH *so) { return keys; } +/* ----------------------------------------------------------------------------- + * DohSetMaxHashExpand() + * + * Controls how many Hash objects are displayed in full in Hash_str + * ----------------------------------------------------------------------------- */ + +void DohSetMaxHashExpand(int count) { + max_expand = count; +} + +/* ----------------------------------------------------------------------------- + * DohGetMaxHashExpand() + * + * Returns how many Hash objects are displayed in full in Hash_str + * ----------------------------------------------------------------------------- */ + +int DohGetMaxHashExpand(void) { + return max_expand; +} + /* ----------------------------------------------------------------------------- * Hash_str() * @@ -388,7 +409,8 @@ static DOH *Hash_str(DOH *ho) { int i, j; HashNode *n; DOH *s; - static int indent = 4; + static int expanded = 0; + static const char *tab = " "; Hash *h = (Hash *) ObjData(ho); s = NewStringEmpty(); @@ -396,22 +418,35 @@ static DOH *Hash_str(DOH *ho) { Printf(s, "Hash(0x%x)", ho); return s; } + if (expanded >= max_expand) { + /* replace each hash attribute with a '.' */ + Printf(s, "Hash(0x%x) {", ho); + for (i = 0; i < h->hashsize; i++) { + n = h->hashtable[i]; + while (n) { + Putc('.', s); + n = n->next; + } + } + Putc('}', s); + return s; + } ObjSetMark(ho, 1); - Printf(s, "Hash {\n"); + Printf(s, "Hash(0x%x) {\n", ho); for (i = 0; i < h->hashsize; i++) { n = h->hashtable[i]; while (n) { - for (j = 0; j < indent; j++) - Putc(' ', s); - indent += 4; + for (j = 0; j < expanded + 1; j++) + Printf(s, tab); + expanded += 1; Printf(s, "'%s' : %s, \n", n->key, n->object); - indent -= 4; + expanded -= 1; n = n->next; } } - for (j = 0; j < (indent - 4); j++) - Putc(' ', s); - Printf(s, "}\n"); + for (j = 0; j < expanded; j++) + Printf(s, tab); + Printf(s, "}"); ObjSetMark(ho, 0); return s; } diff --git a/Source/DOH/list.c b/Source/DOH/list.c index a08cadb5a..d5b532409 100644 --- a/Source/DOH/list.c +++ b/Source/DOH/list.c @@ -252,7 +252,7 @@ static DOH *List_str(DOH *lo) { if ((i + 1) < l->nitems) Printf(s, ", "); } - Printf(s, " ]\n"); + Printf(s, " ]"); ObjSetMark(lo, 0); return s; } diff --git a/Source/Modules/lang.cxx b/Source/Modules/lang.cxx index e28fcbb89..6ec0463fa 100644 --- a/Source/Modules/lang.cxx +++ b/Source/Modules/lang.cxx @@ -52,7 +52,7 @@ extern "C" { return all_protected_mode; } void Language_replace_special_variables(String *method, String *tm, Parm *parm) { - Language::instance()->replaceSpecialVariables(method, tm, parm); + Language::instance()->replaceSpecialVariables(method, tm, parm); } } diff --git a/Source/Modules/swigmod.h b/Source/Modules/swigmod.h index b0b488d6f..d3074105f 100644 --- a/Source/Modules/swigmod.h +++ b/Source/Modules/swigmod.h @@ -380,9 +380,15 @@ void Wrapper_fast_dispatch_mode_set(int); void Wrapper_cast_dispatch_mode_set(int); void Wrapper_naturalvar_mode_set(int); - void clean_overloaded(Node *n); +extern "C" { + const char *Swig_to_string(DOH *object, int count = -1); + const char *Swig_to_string_with_location(DOH *object, int count = -1); + void Swig_print(DOH *object, int count = -1); + void Swig_print_with_location(DOH *object, int count = -1); +} + /* Contracts */ void Swig_contracts(Node *n); @@ -395,5 +401,4 @@ void Swig_browser(Node *n, int); void Swig_default_allocators(Node *n); void Swig_process_types(Node *n); - #endif diff --git a/Source/Modules/utils.cxx b/Source/Modules/utils.cxx index 3fe7a2709..13a504bcf 100644 --- a/Source/Modules/utils.cxx +++ b/Source/Modules/utils.cxx @@ -100,3 +100,116 @@ void clean_overloaded(Node *n) { Delattr(n, "sym:overloaded"); } } + +/* ----------------------------------------------------------------------------- + * Swig_set_max_hash_expand() + * + * Controls how many Hash objects are displayed when displaying nested Hash objects. + * Makes DohSetMaxHashExpand an externally callable function (for debugger). + * ----------------------------------------------------------------------------- */ + +void Swig_set_max_hash_expand(int count) { + SetMaxHashExpand(count); +} + +extern "C" { + +/* ----------------------------------------------------------------------------- + * Swig_get_max_hash_expand() + * + * Returns how many Hash objects are displayed when displaying nested Hash objects. + * Makes DohGetMaxHashExpand an externally callable function (for debugger). + * ----------------------------------------------------------------------------- */ + +int Swig_get_max_hash_expand() { + return GetMaxHashExpand(); +} + +/* ----------------------------------------------------------------------------- + * Swig_to_doh_string() + * + * DOH version of Swig_to_string() + * ----------------------------------------------------------------------------- */ + +static String *Swig_to_doh_string(DOH *object, int count) { + int old_count = Swig_get_max_hash_expand(); + if (count >= 0) + Swig_set_max_hash_expand(count); + + String *debug_string = object ? NewStringf("%s", object) : NewString("NULL"); + + Swig_set_max_hash_expand(old_count); + return debug_string; +} + +/* ----------------------------------------------------------------------------- + * Swig_to_doh_string_with_location() + * + * DOH version of Swig_to_string_with_location() + * ----------------------------------------------------------------------------- */ + +static String *Swig_to_doh_string_with_location(DOH *object, int count) { + int old_count = Swig_get_max_hash_expand(); + if (count >= 0) + Swig_set_max_hash_expand(count); + + String *debug_string = Swig_stringify_with_location(object); + + Swig_set_max_hash_expand(old_count); + return debug_string; +} + +/* ----------------------------------------------------------------------------- + * Swig_to_string() + * + * Swig debug - return C string representation of any DOH type. + * Nested Hash types expand count is value of Swig_get_max_hash_expand when count<0 + * Note: leaks memory. + * ----------------------------------------------------------------------------- */ + +const char *Swig_to_string(DOH *object, int count) { + return Char(Swig_to_doh_string(object, count)); +} + +/* ----------------------------------------------------------------------------- + * Swig_to_string_with_location() + * + * Swig debug - return C string representation of any DOH type, within [] brackets + * for Hash and List types, prefixed by line and file information. + * Nested Hash types expand count is value of Swig_get_max_hash_expand when count<0 + * Note: leaks memory. + * ----------------------------------------------------------------------------- */ + +const char *Swig_to_string_with_location(DOH *object, int count) { + return Char(Swig_to_doh_string_with_location(object, count)); +} + +/* ----------------------------------------------------------------------------- + * Swig_print() + * + * Swig debug - display string representation of any DOH type. + * Nested Hash types expand count is value of Swig_get_max_hash_expand when count<0 + * ----------------------------------------------------------------------------- */ + +void Swig_print(DOH *object, int count) { + String *output = Swig_to_doh_string(object, count); + Printf(stdout, "%s\n", output); + Delete(output); +} + +/* ----------------------------------------------------------------------------- + * Swig_to_string_with_location() + * + * Swig debug - display string representation of any DOH type, within [] brackets + * for Hash and List types, prefixed by line and file information. + * Nested Hash types expand count is value of Swig_get_max_hash_expand when count<0 + * ----------------------------------------------------------------------------- */ + +void Swig_print_with_location(DOH *object, int count) { + String *output = Swig_to_doh_string_with_location(object, count); + Printf(stdout, "%s\n", output); + Delete(output); +} + +} // extern "C" + diff --git a/Source/Swig/error.c b/Source/Swig/error.c index fa82ad8d9..5dfcf605b 100644 --- a/Source/Swig/error.c +++ b/Source/Swig/error.c @@ -284,6 +284,41 @@ static String *format_filename(const_String_or_char_ptr filename) { return formatted_filename; } +/* ----------------------------------------------------------------------------- + * Swig_stringify_with_location() + * + * Return a string representation of any DOH object with line and file location + * information in the appropriate error message format. The string representation + * is enclosed within [] brackets after the line and file information. + * ----------------------------------------------------------------------------- */ + +String *Swig_stringify_with_location(DOH *object) { + String *str = NewStringEmpty(); + + if (!init_fmt) + Swig_error_msg_format(DEFAULT_ERROR_MSG_FORMAT); + + if (object) { + int line = Getline(object); + String *formatted_filename = format_filename(Getfile(object)); + if (line > 0) { + Printf(str, diag_line_fmt, formatted_filename, line); + } else { + Printf(str, diag_eof_fmt, formatted_filename); + } + if (Len(object) == 0) { + Printf(str, "[EMPTY]"); + } else { + Printf(str, "[%s]", object); + } + Delete(formatted_filename); + } else { + Printf(str, "[NULL]"); + } + + return str; +} + /* ----------------------------------------------------------------------------- * Swig_diagnostic() * diff --git a/Source/Swig/misc.c b/Source/Swig/misc.c index 2105f0c51..a57c7cf33 100644 --- a/Source/Swig/misc.c +++ b/Source/Swig/misc.c @@ -527,7 +527,6 @@ String *Swig_string_schemify(String *s) { return ns; } - /* ----------------------------------------------------------------------------- * Swig_string_typecode() * diff --git a/Source/Swig/swig.h b/Source/Swig/swig.h index f90a5ffb1..021c5611f 100644 --- a/Source/Swig/swig.h +++ b/Source/Swig/swig.h @@ -319,7 +319,6 @@ extern int ParmList_is_compactdefargs(ParmList *p); extern String *Swig_string_lower(String *s); extern String *Swig_string_upper(String *s); extern String *Swig_string_title(String *s); - extern void Swig_init(void); extern int Swig_value_wrapper_mode(int mode); @@ -334,6 +333,7 @@ extern int ParmList_is_compactdefargs(ParmList *p); extern int Swig_warn_count(void); extern void Swig_error_msg_format(ErrorMessageFormat format); extern void Swig_diagnostic(const_String_or_char_ptr filename, int line, const char *fmt, ...); + extern String *Swig_stringify_with_location(DOH *object); /* --- C Wrappers --- */ extern String *Swig_cparm_name(Parm *p, int i); @@ -408,6 +408,8 @@ extern int ParmList_is_compactdefargs(ParmList *p); extern void Wrapper_director_protected_mode_set(int); extern void Wrapper_all_protected_mode_set(int); extern void Language_replace_special_variables(String *method, String *tm, Parm *parm); + extern void Swig_print(DOH *object, int count); + extern void Swig_print_with_location(DOH *object, int count); /* -- template init -- */ diff --git a/Tools/swig.gdb b/Tools/swig.gdb new file mode 100644 index 000000000..195032955 --- /dev/null +++ b/Tools/swig.gdb @@ -0,0 +1,41 @@ +# User-defined commands for easier debugging of SWIG in gdb +# +# This file can be "included" into your main .gdbinit file using: +# source swig.gdb +# or otherwise paste the contents into .gdbinit +# +# Note all user defined commands can be seen using: +# (gdb) show user +# The documentation for each command can be easily viewed, for example: +# (gdb) help swigprint + +define swigprint + if ($argc == 2) + set $expand_count = $arg1 + else + set $expand_count = -1 + end + call Swig_print($arg0, $expand_count) +end +document swigprint +Displays any SWIG DOH object +Usage: swigprint swigobject [hashexpandcount] + swigobject - The object to display. + hashexpandcount - Number of nested Hash types to expand (default is 1). See Swig_set_max_hash_expand() to change default. +end + + +define locswigprint + if ($argc == 2) + set $expand_count = $arg1 + else + set $expand_count = -1 + end + call Swig_print_with_location($arg0, $expand_count) +end +document locswigprint +Displays any SWIG DOH object prefixed with file and line location +Usage: locswigprint swigobject [hashexpandcount] + swigobject - The object to display. + hashexpandcount - Number of nested Hash types to expand (default is 1). See Swig_set_max_hash_expand() to change default. +end From 8b31a92f6168b1bb1e17ca64aebbe6e29c5fc24a Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 15 Sep 2010 22:26:34 +0000 Subject: [PATCH 1014/1680] Add missing typemap debug options to docs git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12222 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Extending.html | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Doc/Manual/Extending.html b/Doc/Manual/Extending.html index c554d9f05..072f28963 100644 --- a/Doc/Manual/Extending.html +++ b/Doc/Manual/Extending.html @@ -3609,6 +3609,8 @@ There are various command line options which can aid debugging a SWIG interface -debug-top <n> - Display entire parse tree at stages 1-4, <n> is a csv list of stages -debug-typedef - Display information about the types and typedefs in the interface -debug-typemap - Display information for debugging typemaps +-debug-tmsearch - Display typemap search debugging information +-debug-tmused - Display typemaps used debugging information

    From b01277a19be53421d66f800c942e5b8663100a46 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 18 Sep 2010 01:14:21 +0000 Subject: [PATCH 1015/1680] Various inherited class warning/error line number fixes git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12223 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++ Examples/test-suite/errors/cpp_inherit.i | 47 ++++++++++++++++++++++++ Examples/test-suite/errors/expected.log | 24 ++++++++++-- Examples/test-suite/errors/make.sh | 1 + Source/CParse/cscanner.c | 6 +-- Source/CParse/parser.y | 40 ++++++++++++-------- Source/Modules/typepass.cxx | 17 ++++----- 7 files changed, 108 insertions(+), 31 deletions(-) create mode 100644 Examples/test-suite/errors/cpp_inherit.i diff --git a/CHANGES.current b/CHANGES.current index ff5b40fb6..d98b99f1a 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,10 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.1 (in progress) =========================== +2010-09-18: wsfulton + More file and line error/warning reporting fixes for various inherited + class problems. + 2010-09-15: wsfulton A much improved debugging of SWIG source experience is now available and documented in the "Debugging SWIG" section in the Doc/Devel/internals.html diff --git a/Examples/test-suite/errors/cpp_inherit.i b/Examples/test-suite/errors/cpp_inherit.i new file mode 100644 index 000000000..fdc77d1d5 --- /dev/null +++ b/Examples/test-suite/errors/cpp_inherit.i @@ -0,0 +1,47 @@ +%module xxx + +%inline %{ +struct A5; +int A6; +template struct A7 +{ +}; +template struct A8 +{ +}; + +struct A0 +: + public A1 + , + A2, + private A3 + , + private A4 + , + A5 + , + A6 + , + A7 + , + protected A8 +{ +}; + +struct A1 +{ +}; + +class B1 {}; + +class B0 : + B1, + B2 +{ +}; + +struct Recursive : Recursive +{ +}; +%} diff --git a/Examples/test-suite/errors/expected.log b/Examples/test-suite/errors/expected.log index 1fd592f04..7cbce4c30 100644 --- a/Examples/test-suite/errors/expected.log +++ b/Examples/test-suite/errors/expected.log @@ -207,6 +207,24 @@ cpp_extend_undefined.i:6: Warning 303: %extend defined for an undeclared class f :::::::::::::::::::::::::::::::: cpp_inline_namespace.i ::::::::::::::::::::::::::::::::::: cpp_inline_namespace.i:4: Error: %inline directive inside a namespace is disallowed. +:::::::::::::::::::::::::::::::: cpp_inherit.i ::::::::::::::::::::::::::::::::::: +cpp_inherit.i:18: Warning 309: private inheritance from base 'A3' (ignored). +cpp_inherit.i:20: Warning 309: private inheritance from base 'A4' (ignored). +cpp_inherit.i:28: Warning 309: protected inheritance from base 'A8< double >' (ignored). +cpp_inherit.i:39: Warning 319: No access specifier given for base class 'B1' (ignored). +cpp_inherit.i:40: Warning 319: No access specifier given for base class 'B2< int >' (ignored). +cpp_inherit.i:15: Warning 401: Base class 'A1' undefined. +cpp_inherit.i:33: Warning 401: 'A1' must be defined before it is used as a base class. +cpp_inherit.i:17: Warning 401: Nothing known about base class 'A2'. Ignored. +cpp_inherit.i:22: Warning 402: Base class 'A5' is incomplete. +cpp_inherit.i:4: Warning 402: Only forward declaration 'A5' was found. +cpp_inherit.i:24: Error: 'A6' is not a valid base class. +cpp_inherit.i:5: Error: See definition of 'A6'. +cpp_inherit.i:24: Warning 401: Nothing known about base class 'A6'. Ignored. +cpp_inherit.i:26: Warning 401: Nothing known about base class 'A7< int >'. Ignored. +cpp_inherit.i:26: Warning 401: Maybe you forgot to instantiate 'A7< int >' using %template. +cpp_inherit.i:45: Warning 323: Recursive scope inheritance of 'Recursive'. + :::::::::::::::::::::::::::::::: cpp_missing_rtemplate.i ::::::::::::::::::::::::::::::::::: cpp_missing_rtemplate.i:4: Error: Syntax error in input(1). @@ -224,7 +242,7 @@ cpp_nested.i:6: Warning 325: Nested class not currently supported (Bar ignored) cpp_nested.i:12: Warning 325: Nested class not currently supported (Grok ignored) :::::::::::::::::::::::::::::::: cpp_no_access.i ::::::::::::::::::::::::::::::::::: -cpp_no_access.i:3: Warning 319: No access specifier given for base class foo (ignored). +cpp_no_access.i:3: Warning 319: No access specifier given for base class 'foo' (ignored). :::::::::::::::::::::::::::::::: cpp_nobase.i ::::::::::::::::::::::::::::::::::: cpp_nobase.i:3: Warning 401: Nothing known about base class 'Bar'. Ignored. @@ -236,8 +254,8 @@ cpp_nobase.i:6: Warning 401: Maybe you forgot to instantiate 'Bar< int >' using :::::::::::::::::::::::::::::::: cpp_private_defvalue.i ::::::::::::::::::::::::::::::::::: :::::::::::::::::::::::::::::::: cpp_private_inherit.i ::::::::::::::::::::::::::::::::::: -cpp_private_inherit.i:6: Warning 309: private inheritance ignored. -cpp_private_inherit.i:9: Warning 309: protected inheritance ignored. +cpp_private_inherit.i:6: Warning 309: private inheritance from base 'Foo' (ignored). +cpp_private_inherit.i:9: Warning 309: protected inheritance from base 'Foo' (ignored). :::::::::::::::::::::::::::::::: cpp_template_argname.i ::::::::::::::::::::::::::::::::::: diff --git a/Examples/test-suite/errors/make.sh b/Examples/test-suite/errors/make.sh index 0fb3e14a4..0a81254f4 100755 --- a/Examples/test-suite/errors/make.sh +++ b/Examples/test-suite/errors/make.sh @@ -64,6 +64,7 @@ cpp_bad_extern cpp_extend_redefine cpp_extend_undefined cpp_inline_namespace +cpp_inherit cpp_missing_rtemplate cpp_namespace_alias cpp_namespace_aliasnot diff --git a/Source/CParse/cscanner.c b/Source/CParse/cscanner.c index f88841c09..7d848878c 100644 --- a/Source/CParse/cscanner.c +++ b/Source/CParse/cscanner.c @@ -791,7 +791,7 @@ int yylex(void) { if (strcmp(yytext, "typename") == 0) return (TYPENAME); if (strcmp(yytext, "template") == 0) { - yylval.ivalue = cparse_line; + yylval.intvalue = cparse_line; return (TEMPLATE); } if (strcmp(yytext, "delete") == 0) { @@ -833,7 +833,7 @@ int yylex(void) { return (SIZEOF); if (strcmp(yytext, "typedef") == 0) { - yylval.ivalue = 0; + yylval.intvalue = 0; return (TYPEDEF); } @@ -875,7 +875,7 @@ int yylex(void) { if (strcmp(yytext, "%constant") == 0) return (CONSTANT); if (strcmp(yytext, "%typedef") == 0) { - yylval.ivalue = 1; + yylval.intvalue = 1; return (TYPEDEF); } if (strcmp(yytext, "%native") == 0) diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index 09ed9bcf2..d792021c6 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -1628,7 +1628,7 @@ static void tag_nodes(Node *n, const_String_or_char_ptr attrname, DOH *value) { String *str; Parm *p; ParmList *pl; - int ivalue; + int intvalue; Node *node; }; @@ -1639,7 +1639,7 @@ static void tag_nodes(Node *n, const_String_or_char_ptr attrname, DOH *value) { %token INCLUDE IMPORT INSERT %token CHARCONST %token NUM_INT NUM_FLOAT NUM_UNSIGNED NUM_LONG NUM_ULONG NUM_LONGLONG NUM_ULONGLONG NUM_BOOL -%token TYPEDEF +%token TYPEDEF %token TYPE_INT TYPE_UNSIGNED TYPE_SHORT TYPE_LONG TYPE_FLOAT TYPE_DOUBLE TYPE_CHAR TYPE_WCHAR TYPE_VOID TYPE_SIGNED TYPE_BOOL TYPE_COMPLEX TYPE_TYPEDEF TYPE_RAW TYPE_NON_ISO_INT8 TYPE_NON_ISO_INT16 TYPE_NON_ISO_INT32 TYPE_NON_ISO_INT64 %token LPAREN RPAREN COMMA SEMI EXTERN INIT LBRACE RBRACE PERIOD %token CONST_QUAL VOLATILE REGISTER STRUCT UNION EQUAL SIZEOF MODULE LBRACKET RBRACKET @@ -1657,7 +1657,7 @@ static void tag_nodes(Node *n, const_String_or_char_ptr attrname, DOH *value) { %token QUESTIONMARK %token TYPES PARMS %token NONID DSTAR DCNOT -%token TEMPLATE +%token TEMPLATE %token OPERATOR %token COPERATOR %token PARSETYPE PARSEPARM PARSEPARMS @@ -1728,7 +1728,7 @@ static void tag_nodes(Node *n, const_String_or_char_ptr attrname, DOH *value) { %type string stringnum ; %type template_parms; %type cpp_end cpp_vend; -%type rename_namewarn; +%type rename_namewarn; %type type_specifier primitive_type_list ; %type fname stringtype; %type featattr; @@ -4540,7 +4540,8 @@ cpp_protection_decl : PUBLIC COLON { ------------------------------------------------------------ */ cpp_nested : storage_class cpptype idcolon inherit LBRACE { - cparse_start_line = cparse_line; skip_balanced('{','}'); + cparse_start_line = cparse_line; + skip_balanced('{','}'); $$ = NewString(scanner_ccode); /* copied as initializers overwrite scanner_ccode */ } cpp_opt_declarators { $$ = 0; @@ -4565,7 +4566,8 @@ cpp_nested : storage_class cpptype idcolon inherit LBRACE { ------------------------------------------------------------ */ | storage_class cpptype inherit LBRACE { - cparse_start_line = cparse_line; skip_balanced('{','}'); + cparse_start_line = cparse_line; + skip_balanced('{','}'); $$ = NewString(scanner_ccode); /* copied as initializers overwrite scanner_ccode */ } cpp_opt_declarators { $$ = 0; @@ -5883,28 +5885,34 @@ base_list : base_specifier { } ; -base_specifier : opt_virtual idcolon { +base_specifier : opt_virtual { + $$ = cparse_line; + } idcolon { $$ = NewHash(); Setfile($$,cparse_file); - Setline($$,cparse_line); - Setattr($$,"name",$2); + Setline($$,$2); + Setattr($$,"name",$3); + Setfile($3,cparse_file); + Setline($3,$2); if (last_cpptype && (Strcmp(last_cpptype,"struct") != 0)) { Setattr($$,"access","private"); - Swig_warning(WARN_PARSE_NO_ACCESS,cparse_file,cparse_line, - "No access specifier given for base class %s (ignored).\n",$2); + Swig_warning(WARN_PARSE_NO_ACCESS, Getfile($$), Getline($$), "No access specifier given for base class '%s' (ignored).\n", SwigType_namestr($3)); } else { Setattr($$,"access","public"); } } - | opt_virtual access_specifier opt_virtual idcolon { + | opt_virtual access_specifier { + $$ = cparse_line; + } opt_virtual idcolon { $$ = NewHash(); Setfile($$,cparse_file); - Setline($$,cparse_line); - Setattr($$,"name",$4); + Setline($$,$3); + Setattr($$,"name",$5); + Setfile($5,cparse_file); + Setline($5,$3); Setattr($$,"access",$2); if (Strcmp($2,"public") != 0) { - Swig_warning(WARN_PARSE_PRIVATE_INHERIT, cparse_file, - cparse_line,"%s inheritance ignored.\n", $2); + Swig_warning(WARN_PARSE_PRIVATE_INHERIT, Getfile($$), Getline($$), "%s inheritance from base '%s' (ignored).\n", $2, SwigType_namestr($5)); } } ; diff --git a/Source/Modules/typepass.cxx b/Source/Modules/typepass.cxx index e0e06d54e..438b66617 100644 --- a/Source/Modules/typepass.cxx +++ b/Source/Modules/typepass.cxx @@ -175,10 +175,10 @@ class TypePass:private Dispatcher { } } if (Strcmp(nodeType(bcls), "classforward") != 0) { - Swig_error(Getfile(cls), Getline(cls), "'%s' does not have a valid base class.\n", Getattr(cls, "name")); - Swig_error(Getfile(bcls), Getline(bcls), "'%s' is not a valid base class.\n", SwigType_namestr(bname)); + Swig_error(Getfile(bname), Getline(bname), "'%s' is not a valid base class.\n", SwigType_namestr(bname)); + Swig_error(Getfile(bcls), Getline(bcls), "See definition of '%s'.\n", SwigType_namestr(bname)); } else { - Swig_warning(WARN_TYPE_INCOMPLETE, Getfile(cls), Getline(cls), "Base class '%s' is incomplete.\n", SwigType_namestr(bname)); + Swig_warning(WARN_TYPE_INCOMPLETE, Getfile(bname), Getline(bname), "Base class '%s' is incomplete.\n", SwigType_namestr(bname)); Swig_warning(WARN_TYPE_INCOMPLETE, Getfile(bcls), Getline(bcls), "Only forward declaration '%s' was found.\n", SwigType_namestr(bname)); clsforward = 1; } @@ -189,7 +189,7 @@ class TypePass:private Dispatcher { ilist = alist = NewList(); Append(ilist, bcls); } else { - Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(cls), Getline(cls), "Base class '%s' undefined.\n", SwigType_namestr(bname)); + Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(bname), Getline(bname), "Base class '%s' undefined.\n", SwigType_namestr(bname)); Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(bcls), Getline(bcls), "'%s' must be defined before it is used as a base class.\n", SwigType_namestr(bname)); } } @@ -202,10 +202,9 @@ class TypePass:private Dispatcher { if (!bcls) { if (!clsforward) { if (ispublic && !Getmeta(bname, "already_warned")) { - Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(cls), Getline(cls), "Nothing known about base class '%s'. Ignored.\n", SwigType_namestr(bname)); + Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(bname), Getline(bname), "Nothing known about base class '%s'. Ignored.\n", SwigType_namestr(bname)); if (Strchr(bname, '<')) { - Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(cls), Getline(cls), "Maybe you forgot to instantiate '%s' using %%template.\n", - SwigType_namestr(bname)); + Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(bname), Getline(bname), "Maybe you forgot to instantiate '%s' using %%template.\n", SwigType_namestr(bname)); } Setmeta(bname, "already_warned", "1"); } @@ -259,7 +258,7 @@ class TypePass:private Dispatcher { Delete(bsmart); Delete(smart); } else { - Swig_error(Getfile(first), Getline(first), "Invalid type (%s) in 'smartptr' feature for class %s.\n", smartptr, clsname); + Swig_error(Getfile(first), Getline(first), "Invalid type (%s) in 'smartptr' feature for class %s.\n", SwigType_namestr(smartptr), SwigType_namestr(clsname)); } } if (!importmode) { @@ -275,7 +274,7 @@ class TypePass:private Dispatcher { Symtab *st = Getattr(cls, "symtab"); Symtab *bst = Getattr(bclass, "symtab"); if (st == bst) { - Swig_warning(WARN_PARSE_REC_INHERITANCE, Getfile(cls), Getline(cls), "Recursive scope inheritance of '%s'.\n", Getattr(cls, "name")); + Swig_warning(WARN_PARSE_REC_INHERITANCE, Getfile(cls), Getline(cls), "Recursive scope inheritance of '%s'.\n", SwigType_namestr(Getattr(cls, "name"))); continue; } Symtab *s = Swig_symbol_current(); From 6c094629cbd6df08a20c68656a487965b7072d30 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 20 Sep 2010 19:11:55 +0000 Subject: [PATCH 1016/1680] File and line number corrections for warnings WARN_JAVA_MULTIPLE_INHERITANCE WARN_MODULA3_MULTIPLE_INHERITANCE WARN_CSHARP_MULTIPLE_INHERITANCE and errors 'The javabase typemap for proxy' 'No methodname attribute...' 'No methodmodifiers attribute...' 'The csbase typemap for proxy...' git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12224 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/csharp.cxx | 16 ++++++++-------- Source/Modules/java.cxx | 18 ++++++++---------- Source/Modules/modula3.cxx | 11 ++++------- 3 files changed, 20 insertions(+), 25 deletions(-) diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index 8ffd9768a..e0c4a4332 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -1640,10 +1640,10 @@ public: base = Next(base); continue; } - String *proxyclassname = SwigType_str(Getattr(n, "classtypeobj"), 0); - String *baseclassname = SwigType_str(Getattr(base.item, "name"), 0); - Swig_warning(WARN_CSHARP_MULTIPLE_INHERITANCE, input_file, line_number, - "Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in C#.\n", proxyclassname, baseclassname); + String *proxyclassname = Getattr(n, "classtypeobj"); + String *baseclassname = Getattr(base.item, "name"); + Swig_warning(WARN_CSHARP_MULTIPLE_INHERITANCE, Getfile(n), Getline(n), + "Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Java.\n", SwigType_namestr(proxyclassname), SwigType_namestr(baseclassname)); base = Next(base); } } @@ -1661,9 +1661,9 @@ public: Delete(baseclass); baseclass = NULL; if (purebase_notderived) - Swig_error(input_file, line_number, "The csbase typemap for proxy %s must contain just one of the 'replace' or 'notderived' attributes.\n", typemap_lookup_type); + Swig_error(Getfile(n), Getline(n), "The csbase typemap for proxy %s must contain just one of the 'replace' or 'notderived' attributes.\n", typemap_lookup_type); } else if (Len(pure_baseclass) > 0 && Len(baseclass) > 0) { - Swig_warning(WARN_CSHARP_MULTIPLE_INHERITANCE, input_file, line_number, + Swig_warning(WARN_CSHARP_MULTIPLE_INHERITANCE, Getfile(n), Getline(n), "Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in C#. " "Perhaps you need one of the 'replace' or 'notderived' attributes in the csbase typemap?\n", typemap_lookup_type, pure_baseclass); } @@ -1704,10 +1704,10 @@ public: } if (tm && *Char(tm)) { if (!destruct_methodname) { - Swig_error(input_file, line_number, "No methodname attribute defined in csdestruct%s typemap for %s\n", (derived ? "_derived" : ""), proxy_class_name); + Swig_error(Getfile(n), Getline(n), "No methodname attribute defined in csdestruct%s typemap for %s\n", (derived ? "_derived" : ""), proxy_class_name); } if (!destruct_methodmodifiers) { - Swig_error(input_file, line_number, + Swig_error(Getfile(n), Getline(n), "No methodmodifiers attribute defined in csdestruct%s typemap for %s.\n", (derived ? "_derived" : ""), proxy_class_name); } } diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index 4a6abd569..c8769a876 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -1714,10 +1714,10 @@ public: base = Next(base); continue; } - String *proxyclassname = SwigType_str(Getattr(n, "classtypeobj"), 0); - String *baseclassname = SwigType_str(Getattr(base.item, "name"), 0); - Swig_warning(WARN_JAVA_MULTIPLE_INHERITANCE, input_file, line_number, - "Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Java.\n", proxyclassname, baseclassname); + String *proxyclassname = Getattr(n, "classtypeobj"); + String *baseclassname = Getattr(base.item, "name"); + Swig_warning(WARN_JAVA_MULTIPLE_INHERITANCE, Getfile(n), Getline(n), + "Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Java.\n", SwigType_namestr(proxyclassname), SwigType_namestr(baseclassname)); base = Next(base); } } @@ -1735,9 +1735,9 @@ public: Delete(baseclass); baseclass = NULL; if (purebase_notderived) - Swig_error(input_file, line_number, "The javabase typemap for proxy %s must contain just one of the 'replace' or 'notderived' attributes.\n", typemap_lookup_type); + Swig_error(Getfile(n), Getline(n), "The javabase typemap for proxy %s must contain just one of the 'replace' or 'notderived' attributes.\n", typemap_lookup_type); } else if (Len(pure_baseclass) > 0 && Len(baseclass) > 0) { - Swig_warning(WARN_JAVA_MULTIPLE_INHERITANCE, input_file, line_number, + Swig_warning(WARN_JAVA_MULTIPLE_INHERITANCE, Getfile(n), Getline(n), "Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Java. " "Perhaps you need one of the 'replace' or 'notderived' attributes in the csbase typemap?\n", typemap_lookup_type, pure_baseclass); } @@ -1772,12 +1772,10 @@ public: } if (tm && *Char(tm)) { if (!destruct_methodname) { - Swig_error(input_file, line_number, - "No methodname attribute defined in javadestruct%s typemap for %s\n", (derived ? "_derived" : ""), proxy_class_name); + Swig_error(Getfile(n), Getline(n), "No methodname attribute defined in javadestruct%s typemap for %s\n", (derived ? "_derived" : ""), proxy_class_name); } if (!destruct_methodmodifiers) { - Swig_error(input_file, line_number, - "No methodmodifiers attribute defined in javadestruct%s typemap for %s.\n", (derived ? "_derived" : ""), proxy_class_name); + Swig_error(Getfile(n), Getline(n), "No methodmodifiers attribute defined in javadestruct%s typemap for %s.\n", (derived ? "_derived" : ""), proxy_class_name); } } // Emit the finalize and delete methods diff --git a/Source/Modules/modula3.cxx b/Source/Modules/modula3.cxx index edd6690ce..ede63f802 100644 --- a/Source/Modules/modula3.cxx +++ b/Source/Modules/modula3.cxx @@ -2222,8 +2222,7 @@ MODULA3(): } base = Next(base); if (base.item != NIL) { - Swig_warning(WARN_MODULA3_MULTIPLE_INHERITANCE, input_file, - line_number, + Swig_warning(WARN_MODULA3_MULTIPLE_INHERITANCE, Getfile(n), Getline(n), "Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Modula 3.\n", classDeclarationName, Getattr(base.item, "name")); } @@ -2236,8 +2235,7 @@ MODULA3(): // Inheritance from pure Modula 3 classes 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, + Swig_warning(WARN_MODULA3_MULTIPLE_INHERITANCE, Getfile(n), Getline(n), "Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Modula 3.\n", classDeclarationName, pure_baseclass); } // Pure Modula 3 interfaces @@ -2273,7 +2271,7 @@ MODULA3(): destruct_methodname = Getattr(attributes, "tmap:m3destruct:methodname"); } if (!destruct_methodname) { - Swig_error(input_file, line_number, "No methodname attribute defined in m3destruct%s typemap for %s\n", (derived ? "_derived" : ""), proxy_class_name); + Swig_error(Getfile(n), Getline(n), "No methodname attribute defined in m3destruct%s typemap for %s\n", (derived ? "_derived" : ""), proxy_class_name); } // Emit the Finalize and Dispose methods if (tm) { @@ -2466,8 +2464,7 @@ MODULA3(): Append(baseclassname, Getattr(base.item, "sym:name")); base = Next(base); if (base.item != NIL) { - Swig_warning(WARN_MODULA3_MULTIPLE_INHERITANCE, input_file, - line_number, + 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", proxy_class_name, Getattr(base.item, "name")); } From 1e051820ec601ca34bbd8abc4926193319708e3e Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 21 Sep 2010 06:07:06 +0000 Subject: [PATCH 1017/1680] Line/file reporting corrections for warnings: WARN_RUBY_MULTIPLE_INHERITANCE, WARN_TYPE_UNDEFINED_CLASS, WARN_MODULA3_MULTIPLE_INHERITANCE git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12225 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/modula3.cxx | 2 +- Source/Modules/python.cxx | 2 +- Source/Modules/ruby.cxx | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/Modules/modula3.cxx b/Source/Modules/modula3.cxx index ede63f802..45ceba1a4 100644 --- a/Source/Modules/modula3.cxx +++ b/Source/Modules/modula3.cxx @@ -2464,7 +2464,7 @@ MODULA3(): Append(baseclassname, Getattr(base.item, "sym:name")); base = Next(base); if (base.item != NIL) { - Swig_warning(WARN_MODULA3_MULTIPLE_INHERITANCE, input_file, line_number, + Swig_warning(WARN_MODULA3_MULTIPLE_INHERITANCE, Getfile(n), Getline(n), "Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Modula 3.\n", proxy_class_name, Getattr(base.item, "name")); } diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index fed5205e1..b807cc627 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -2866,7 +2866,7 @@ public: bool ignore = GetFlag(b.item, "feature:ignore") ? true : false; if (!bname || ignore) { if (!bname && !ignore) { - Swig_warning(WARN_TYPE_UNDEFINED_CLASS, input_file, line_number, + Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(n), Getline(n), "Base class '%s' ignored - unknown module name for base. Either import the appropriate module interface file or specify the name of the module in the %%import directive.\n", SwigType_namestr(Getattr(b.item, "name"))); } b = Next(b); diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx index bcdfd69d3..ab1210a79 100644 --- a/Source/Modules/ruby.cxx +++ b/Source/Modules/ruby.cxx @@ -2395,7 +2395,7 @@ public: } String *proxyclassname = SwigType_str(Getattr(n, "classtypeobj"), 0); String *baseclassname = SwigType_str(Getattr(base.item, "name"), 0); - Swig_warning(WARN_RUBY_MULTIPLE_INHERITANCE, input_file, line_number, + Swig_warning(WARN_RUBY_MULTIPLE_INHERITANCE, Getfile(n), Getline(n), "Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Ruby.\n", proxyclassname, baseclassname); base = Next(base); } From ea9275ca08756f6cf886d6f083ee94eda3b57156 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 21 Sep 2010 18:09:20 +0000 Subject: [PATCH 1018/1680] html fixes git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12226 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Ruby.html | 2 +- Doc/Manual/SWIG.html | 3 ++- Doc/Manual/chapters | 1 - 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Doc/Manual/Ruby.html b/Doc/Manual/Ruby.html index 736b6137d..bda2af60c 100644 --- a/Doc/Manual/Ruby.html +++ b/Doc/Manual/Ruby.html @@ -5,7 +5,7 @@ - +

    33 SWIG and Ruby

    diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html index bdd0edb8b..52b9db339 100644 --- a/Doc/Manual/SWIG.html +++ b/Doc/Manual/SWIG.html @@ -1909,6 +1909,8 @@ The most general function of all of the above ones (not counting command which is even more powerful in principle but which should generally be avoided because of performance considerations) is the regex one. Here are some more examples of its use: +

    +
     // Strip the wx prefix from all identifiers except those starting with wxEVT
    @@ -1924,7 +1926,6 @@ generally be avoided because of performance considerations) is the
                                                   // GetValue -> Value
     
    -

    As before, everything that was said above about %rename also applies to diff --git a/Doc/Manual/chapters b/Doc/Manual/chapters index cd399996b..014029c74 100644 --- a/Doc/Manual/chapters +++ b/Doc/Manual/chapters @@ -34,4 +34,3 @@ Ruby.html Tcl.html R.html Extending.html - From 31af118c41b44a74244613b4eb8e54d06d5cee6a Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 24 Sep 2010 22:13:13 +0000 Subject: [PATCH 1019/1680] Move Swig_locator from scanner.c to cscanner.c. Fix file and line error/warning reporting fixes where SWIG macros are used within {} braces (where the preprocessor expands macros), for example macros within %inline {...} and %fragment(...) {...} and nested structs. Basically anything that results ina call to skip_balanced() in the parser/preprocessor. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12227 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 6 + .../test-suite/errors/cpp_macro_locator.i | 103 ++++++++++++ Examples/test-suite/errors/expected.log | 23 +++ Examples/test-suite/errors/make.sh | 1 + Source/CParse/cscanner.c | 99 +---------- Source/Swig/scanner.c | 159 ++++++++++++++++-- Source/Swig/swigscan.h | 2 +- 7 files changed, 284 insertions(+), 109 deletions(-) create mode 100644 Examples/test-suite/errors/cpp_macro_locator.i diff --git a/CHANGES.current b/CHANGES.current index d98b99f1a..a227d8e66 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,12 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.1 (in progress) =========================== +2010-09-24: wsfulton + More file and line error/warning reporting fixes where SWIG macros + are used within {} braces (where the preprocessor expands macros), + for example macros within %inline {...} and %fragment(...) {...} + and nested structs. + 2010-09-18: wsfulton More file and line error/warning reporting fixes for various inherited class problems. diff --git a/Examples/test-suite/errors/cpp_macro_locator.i b/Examples/test-suite/errors/cpp_macro_locator.i new file mode 100644 index 000000000..bd441a121 --- /dev/null +++ b/Examples/test-suite/errors/cpp_macro_locator.i @@ -0,0 +1,103 @@ +%module xxx + +// Test the SWIG preprocessor locator effects on reporting line numbers in warnings when processing SWIG (multiline) macros + +// The ignored overloaded methods warnings should have the correct line number reporting +// {} blocks are tested, where the preprocessor expands the macros + +%define CLASSMACRO(KLASS) +class KLASS +{ +public: + KLASS() {} + void methodX(int *) {} + void methodX(const int *) {} +}; +%enddef + +%{ +#define CLASSMACRO(KLASS) \ +class KLASS \ +{ \ +public: \ + KLASS() {} \ + void methodX(int *) {} \ + void methodX(const int *) {} \ +}; +%} + +%{ +#define VARIABLEMACRO(NAME) double NAME; +struct Outer { + struct Inner { + VARIABLEMACRO(MyInnerVar) + }; +}; +void overload1(int *) {} +void overload1(const int *) {} +void overload2(int *) {} +void overload2(const int *) {} +void overload3(int *) {} +void overload3(const int *) {} +%} + +%define VARIABLEMACRO(NAME) +double NAME; +%enddef +struct Outer { + struct Inner { + VARIABLEMACRO(MyInnerVar) + }; +}; +void overload1(int *) {} +void overload1(const int *) {} + +%fragment("FragmentMethod", "header") { +void fragmentMethod() { +} +VARIABLEMACRO(fragVar) +} +void overload2(int *) {} +void overload2(const int *) {} + +%inline { +CLASSMACRO(Klass1) +} +#warning inline warning message one +void overload3(int *) {} +void overload3(const int *) {} + +%{ +struct Classic { + Classic() { + VARIABLEMACRO(inconstructor) + } + double value; +}; +void overload4(int *) {} +void overload4(const int *) {} +void overload5(int *) {} +void overload5(const int *) {} +%} + +struct Classic { + Classic() { + VARIABLEMACRO(inconstructor) + } + double value; +}; +void overload4(int *) {} +void overload4(const int *) {} + +%inline { +void overloadinline1(int *) {} +void overloadinline1(const int *) {} +CLASSMACRO(Klass2) +#warning an inline warning message 2 +void overloadinline2(int *) {} +void overloadinline2(const int *) {} +} +void overload5(int *) {} +void overload5(const int *) {} + + diff --git a/Examples/test-suite/errors/expected.log b/Examples/test-suite/errors/expected.log index 7cbce4c30..06942064f 100644 --- a/Examples/test-suite/errors/expected.log +++ b/Examples/test-suite/errors/expected.log @@ -225,6 +225,29 @@ cpp_inherit.i:26: Warning 401: Nothing known about base class 'A7< int >'. Ignor cpp_inherit.i:26: Warning 401: Maybe you forgot to instantiate 'A7< int >' using %template. cpp_inherit.i:45: Warning 323: Recursive scope inheritance of 'Recursive'. +:::::::::::::::::::::::::::::::: cpp_macro_locator.i ::::::::::::::::::::::::::::::::::: +cpp_macro_locator.i:66: Warning 204: CPP #warning, inline warning message one +cpp_macro_locator.i:96: Warning 204: CPP #warning, an inline warning message 2 +cpp_macro_locator.i:50: Warning 325: Nested struct not currently supported (Inner ignored) +cpp_macro_locator.i:53: Warning 509: Overloaded method overload1(int const *) effectively ignored, +cpp_macro_locator.i:52: Warning 509: as it is shadowed by overload1(int *). +cpp_macro_locator.i:61: Warning 509: Overloaded method overload2(int const *) effectively ignored, +cpp_macro_locator.i:60: Warning 509: as it is shadowed by overload2(int *). +cpp_macro_locator.i:64: Warning 509: Overloaded method Klass1::methodX(int const *) effectively ignored, +cpp_macro_locator.i:64: Warning 509: as it is shadowed by Klass1::methodX(int *). +cpp_macro_locator.i:68: Warning 509: Overloaded method overload3(int const *) effectively ignored, +cpp_macro_locator.i:67: Warning 509: as it is shadowed by overload3(int *). +cpp_macro_locator.i:90: Warning 509: Overloaded method overload4(int const *) effectively ignored, +cpp_macro_locator.i:89: Warning 509: as it is shadowed by overload4(int *). +cpp_macro_locator.i:94: Warning 509: Overloaded method overloadinline1(int const *) effectively ignored, +cpp_macro_locator.i:93: Warning 509: as it is shadowed by overloadinline1(int *). +cpp_macro_locator.i:95: Warning 509: Overloaded method Klass2::methodX(int const *) effectively ignored, +cpp_macro_locator.i:95: Warning 509: as it is shadowed by Klass2::methodX(int *). +cpp_macro_locator.i:98: Warning 509: Overloaded method overloadinline2(int const *) effectively ignored, +cpp_macro_locator.i:97: Warning 509: as it is shadowed by overloadinline2(int *). +cpp_macro_locator.i:101: Warning 509: Overloaded method overload5(int const *) effectively ignored, +cpp_macro_locator.i:100: Warning 509: as it is shadowed by overload5(int *). + :::::::::::::::::::::::::::::::: cpp_missing_rtemplate.i ::::::::::::::::::::::::::::::::::: cpp_missing_rtemplate.i:4: Error: Syntax error in input(1). diff --git a/Examples/test-suite/errors/make.sh b/Examples/test-suite/errors/make.sh index 0a81254f4..52d6c8967 100755 --- a/Examples/test-suite/errors/make.sh +++ b/Examples/test-suite/errors/make.sh @@ -65,6 +65,7 @@ cpp_extend_redefine cpp_extend_undefined cpp_inline_namespace cpp_inherit +cpp_macro_locator cpp_missing_rtemplate cpp_namespace_alias cpp_namespace_aliasnot diff --git a/Source/CParse/cscanner.c b/Source/CParse/cscanner.c index 7d848878c..bf684c4cc 100644 --- a/Source/CParse/cscanner.c +++ b/Source/CParse/cscanner.c @@ -45,8 +45,6 @@ static int num_brace = 0; static int last_brace = 0; static int last_id = 0; static int rename_active = 0; -static int expanding_macro = 0; -static int follow_locators = 0; /* ----------------------------------------------------------------------------- * Swig_cparse_cplusplus() @@ -56,101 +54,6 @@ void Swig_cparse_cplusplus(int v) { cparse_cplusplus = v; } -/* ---------------------------------------------------------------------- - * locator() - * - * Support for locator strings. These are strings of the form - * @SWIG:filename,line,id@ emitted by the SWIG preprocessor. They - * are primarily used for macro line number reporting - * ---------------------------------------------------------------------- */ - -typedef struct Locator { - String *filename; - int line_number; - struct Locator *next; -} Locator; - -static Locator *locs = 0; - -/* we just use the locator to mark when active/deactive the linecounting */ - -static void scanner_locator(String *loc) { - if (!follow_locators) { - if (Equal(loc, "/*@SWIG@*/")) { - /* End locator. */ - if (expanding_macro) - --expanding_macro; - } else { - /* Begin locator. */ - ++expanding_macro; - } - /* Freeze line number processing in Scanner */ - Scanner_freeze_line(scan,expanding_macro); - } else { - int c; - Locator *l; - Seek(loc, 7, SEEK_SET); - c = Getc(loc); - if (c == '@') { - /* Empty locator. We pop the last location off */ - if (locs) { - Scanner_set_location(scan,locs->filename,locs->line_number); - cparse_file = locs->filename; - cparse_line = locs->line_number; - l = locs->next; - free(locs); - locs = l; - } - return; - } - - /* We're going to push a new location */ - l = (Locator *) malloc(sizeof(Locator)); - l->filename = cparse_file; - l->line_number = cparse_line; - l->next = locs; - locs = l; - - /* Now, parse the new location out of the locator string */ - { - String *fn = NewStringEmpty(); - /* Putc(c, fn); */ - - while ((c = Getc(loc)) != EOF) { - if ((c == '@') || (c == ',')) - break; - Putc(c, fn); - } - cparse_file = Swig_copy_string(Char(fn)); - Clear(fn); - cparse_line = 1; - /* Get the line number */ - while ((c = Getc(loc)) != EOF) { - if ((c == '@') || (c == ',')) - break; - Putc(c, fn); - } - cparse_line = atoi(Char(fn)); - Clear(fn); - - /* Get the rest of it */ - while ((c = Getc(loc)) != EOF) { - if (c == '@') - break; - Putc(c, fn); - } - /* Swig_diagnostic(cparse_file, cparse_line, "Scanner_set_location\n"); */ - Scanner_set_location(scan,cparse_file,cparse_line); - Delete(fn); - } - } -} - -void Swig_cparse_follow_locators(int v) { - follow_locators = v; -} - - /* ---------------------------------------------------------------------------- * scanner_init() * @@ -432,7 +335,7 @@ static int yylook(void) { String *cmt = Scanner_text(scan); char *loc = Char(cmt); if ((strncmp(loc,"/*@SWIG",7) == 0) && (loc[Len(cmt)-3] == '@')) { - scanner_locator(cmt); + Scanner_locator(scan, cmt); } } break; diff --git a/Source/Swig/scanner.c b/Source/Swig/scanner.c index 9b5b35f96..0cdadaa7f 100644 --- a/Source/Swig/scanner.c +++ b/Source/Swig/scanner.c @@ -20,6 +20,7 @@ char cvsroot_scanner_c[] = "$Id$"; #include extern String *cparse_file; +extern int cparse_line; extern int cparse_cplusplus; extern int cparse_start_line; @@ -38,6 +39,13 @@ struct Scanner { int freeze_line; /* Suspend line number updates */ }; +typedef struct Locator { + String *filename; + int line_number; + struct Locator *next; +} Locator; +static int follow_locators = 0; + /* ----------------------------------------------------------------------------- * NewScanner() * @@ -230,8 +238,7 @@ static void set_error(Scanner *s, int line, const_String_or_char_ptr msg) { * Returns error information (if any) * ----------------------------------------------------------------------------- */ -String * -Scanner_errmsg(Scanner *s) { +String *Scanner_errmsg(Scanner *s) { return s->error; } @@ -241,13 +248,12 @@ Scanner_errline(Scanner *s) { } /* ----------------------------------------------------------------------------- - * Scanner_freeze_line() + * freeze_line() * * Freezes the current line number. * ----------------------------------------------------------------------------- */ -void -Scanner_freeze_line(Scanner *s, int val) { +static void freeze_line(Scanner *s, int val) { s->freeze_line = val; } @@ -1153,6 +1159,7 @@ int Scanner_skip_balanced(Scanner * s, int startchar, int endchar) { int l; int state = 0; char temp[2] = { 0, 0 }; + String *locator = 0; l = s->line; temp[0] = (char) startchar; Clear(s->text); @@ -1162,6 +1169,7 @@ int Scanner_skip_balanced(Scanner * s, int startchar, int endchar) { Append(s->text, temp); while (num_levels > 0) { if ((c = nextchar(s)) == 0) { + Delete(locator); return -1; } switch (state) { @@ -1195,17 +1203,25 @@ int Scanner_skip_balanced(Scanner * s, int startchar, int endchar) { else state = 11; break; - case 12: + case 12: /* first character inside C comment */ if (c == '*') + state = 14; + else if (c == '@') + state = 40; + else state = 13; break; case 13: if (c == '*') - state = 13; + state = 14; + break; + case 14: /* possible end of C comment */ + if (c == '*') + state = 14; else if (c == '/') state = 0; else - state = 12; + state = 13; break; case 20: if (c == '\"') @@ -1225,10 +1241,43 @@ int Scanner_skip_balanced(Scanner * s, int startchar, int endchar) { case 31: state = 30; break; + /* 40-45 SWIG locator checks - a C comment with contents starting: @SWIG */ + case 40: + state = (c == 'S') ? 41 : (c == '*') ? 14 : 13; + break; + case 41: + state = (c == 'W') ? 42 : (c == '*') ? 14 : 13; + break; + case 42: + state = (c == 'I') ? 43 : (c == '*') ? 14 : 13; + break; + case 43: + state = (c == 'G') ? 44 : (c == '*') ? 14 : 13; + if (c == 'G') { + Delete(locator); + locator = NewString("/*@SWIG"); + } + break; + case 44: + if (c == '*') + state = 45; + Putc(c, locator); + break; + case 45: /* end of SWIG locator in C comment */ + if (c == '/') { + state = 0; + Putc(c, locator); + Scanner_locator(s, locator); + } else { + /* malformed locator */ + state = (c == '*') ? 14 : 13; + } + break; default: break; } } + Delete(locator); return 0; } @@ -1239,8 +1288,98 @@ int Scanner_skip_balanced(Scanner * s, int startchar, int endchar) { * operator. * ----------------------------------------------------------------------------- */ -int -Scanner_isoperator(int tokval) { +int Scanner_isoperator(int tokval) { if (tokval >= 100) return 1; return 0; } + +/* ---------------------------------------------------------------------- + * locator() + * + * Support for locator strings. These are strings of the form + * @SWIG:filename,line,id@ emitted by the SWIG preprocessor. They + * are primarily used for macro line number reporting. + * We just use the locator to mark when to activate/deactivate linecounting. + * ---------------------------------------------------------------------- */ + + +void Scanner_locator(Scanner *s, String *loc) { + static Locator *locs = 0; + static int expanding_macro = 0; + + if (!follow_locators) { + if (Equal(loc, "/*@SWIG@*/")) { + /* End locator. */ + if (expanding_macro) + --expanding_macro; + } else { + /* Begin locator. */ + ++expanding_macro; + } + /* Freeze line number processing in Scanner */ + freeze_line(s,expanding_macro); + } else { + int c; + Locator *l; + Seek(loc, 7, SEEK_SET); + c = Getc(loc); + if (c == '@') { + /* Empty locator. We pop the last location off */ + if (locs) { + Scanner_set_location(s, locs->filename, locs->line_number); + cparse_file = locs->filename; + cparse_line = locs->line_number; + l = locs->next; + free(locs); + locs = l; + } + return; + } + + /* We're going to push a new location */ + l = (Locator *) malloc(sizeof(Locator)); + l->filename = cparse_file; + l->line_number = cparse_line; + l->next = locs; + locs = l; + + /* Now, parse the new location out of the locator string */ + { + String *fn = NewStringEmpty(); + /* Putc(c, fn); */ + + while ((c = Getc(loc)) != EOF) { + if ((c == '@') || (c == ',')) + break; + Putc(c, fn); + } + cparse_file = Swig_copy_string(Char(fn)); + Clear(fn); + cparse_line = 1; + /* Get the line number */ + while ((c = Getc(loc)) != EOF) { + if ((c == '@') || (c == ',')) + break; + Putc(c, fn); + } + cparse_line = atoi(Char(fn)); + Clear(fn); + + /* Get the rest of it */ + while ((c = Getc(loc)) != EOF) { + if (c == '@') + break; + Putc(c, fn); + } + /* Swig_diagnostic(cparse_file, cparse_line, "Scanner_set_location\n"); */ + Scanner_set_location(s, cparse_file, cparse_line); + Delete(fn); + } + } +} + +void Swig_cparse_follow_locators(int v) { + follow_locators = v; +} + + diff --git a/Source/Swig/swigscan.h b/Source/Swig/swigscan.h index b07812fbe..a2d5911bd 100644 --- a/Source/Swig/swigscan.h +++ b/Source/Swig/swigscan.h @@ -30,7 +30,7 @@ extern void Scanner_idstart(Scanner *, const char *idchar); extern String *Scanner_errmsg(Scanner *); extern int Scanner_errline(Scanner *); extern int Scanner_isoperator(int tokval); -extern void Scanner_freeze_line(Scanner *s, int val); +extern void Scanner_locator(Scanner *, String *loc); /* Note: Tokens in range 100+ are for C/C++ operators */ From e1ddf0ea3a778bf5bac48009004f2a4a7ac9d9ea Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 25 Sep 2010 17:08:13 +0000 Subject: [PATCH 1020/1680] Apply SF patch #3075150 - Java directors using static variables in named namespace git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12228 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++++ Source/Modules/java.cxx | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index a227d8e66..2767abb7a 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,10 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.1 (in progress) =========================== +2010-09-25: wsfulton + Apply SF patch #3075150 - Java directors using static variables in + named namespace. + 2010-09-24: wsfulton More file and line error/warning reporting fixes where SWIG macros are used within {} braces (where the preprocessor expands macros), diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index c8769a876..1d4e522c6 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -3324,8 +3324,10 @@ public: } Printf(f_runtime, "namespace Swig {\n"); - Printf(f_runtime, " static jclass jclass_%s = NULL;\n", imclass_name); - Printf(f_runtime, " static jmethodID director_methids[%d];\n", n_methods); + Printf(f_runtime, " namespace {\n"); + Printf(f_runtime, " jclass jclass_%s = NULL;\n", imclass_name); + Printf(f_runtime, " jmethodID director_methids[%d];\n", n_methods); + Printf(f_runtime, " }\n"); Printf(f_runtime, "}\n"); Printf(w->def, "SWIGEXPORT void JNICALL Java_%s%s_%s(JNIEnv *jenv, jclass jcls) {", jnipackage, jni_imclass_name, swig_module_init_jni); From 5437d71d73569400cc2f544a7934f2c768efa8f5 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Mon, 27 Sep 2010 01:16:29 +0000 Subject: [PATCH 1021/1680] [Python] Improve error message given when a parameter of the wrong type is passed to an overloaded method (SF#3027355). git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12229 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 b807cc627..80f2e68df 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -1799,7 +1799,7 @@ public: } while ((sibl = Getattr(sibl, "sym:nextSibling"))); Append(f->code, "fail:\n"); Printf(f->code, "SWIG_SetErrorMsg(PyExc_NotImplementedError," - "\"Wrong number of arguments for overloaded function '%s'.\\n\"" "\n\" Possible C/C++ prototypes are:\\n\"%s);\n", symname, protoTypes); + "\"Wrong number or type of arguments for overloaded function '%s'.\\n\"" "\n\" Possible C/C++ prototypes are:\\n\"%s);\n", symname, protoTypes); Append(f->code, "return NULL;\n"); Delete(protoTypes); } From 40e64b14f148b3d58dc13cca7df59a0193926e68 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 27 Sep 2010 05:40:14 +0000 Subject: [PATCH 1022/1680] Allocate warnings 700-799 for languages modules. Note 900-999 was and is documented as reserved for user defined warnings. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12230 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Warnings.html | 2 +- Source/Include/swigwarn.h | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Doc/Manual/Warnings.html b/Doc/Manual/Warnings.html index 96e35902a..4bbf18205 100644 --- a/Doc/Manual/Warnings.html +++ b/Doc/Manual/Warnings.html @@ -515,7 +515,7 @@ example.i(4) : Syntax error in input.

  • 519. %template() contains no name. Template method ignored: declaration -

    14.9.6 Language module specific (800-899)

    +

    14.9.6 Language module specific (700-899)

      diff --git a/Source/Include/swigwarn.h b/Source/Include/swigwarn.h index 46f5b79a5..5db30e6e9 100644 --- a/Source/Include/swigwarn.h +++ b/Source/Include/swigwarn.h @@ -196,11 +196,16 @@ /* -- Reserved (600-799) -- */ -/* -- Language module specific warnings (800 - 999) -- */ +/* -- Language module specific warnings (700 - 899) -- */ + +/* Feel free to claim any number in this space that's not currently being used. Just make sure you + add an entry here */ #define WARN_RUBY_WRONG_NAME 801 #define WARN_RUBY_MULTIPLE_INHERITANCE 802 +/* please leave 800-809 free for Ruby */ + #define WARN_JAVA_TYPEMAP_JNI_UNDEF 810 #define WARN_JAVA_TYPEMAP_JTYPE_UNDEF 811 #define WARN_JAVA_TYPEMAP_JSTYPE_UNDEF 812 @@ -262,7 +267,6 @@ /* please leave 890-899 free for Go */ -/* Feel free to claim any number in this space that's not currently being used. Just make sure you - add an entry here */ +/* -- User defined warnings (900 - 999) -- */ #endif From 8a05a236124fc511d8559a37fa36d5aa96b9b818 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 28 Sep 2010 06:36:42 +0000 Subject: [PATCH 1023/1680] Apply patch from Tomas Dirvanauskas for std::map wrappers to avoid throwing exceptions with normal usage of iterators. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12231 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++++ Lib/csharp/std_map.i | 24 +++++++++++++----------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 2767abb7a..b0647a336 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,10 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.1 (in progress) =========================== +2010-09-28: wsfulton + [C#] Apply patch from Tomas Dirvanauskas for std::map wrappers to avoid + throwing exceptions with normal usage of iterators. + 2010-09-25: wsfulton Apply SF patch #3075150 - Java directors using static variables in named namespace. diff --git a/Lib/csharp/std_map.i b/Lib/csharp/std_map.i index 2db6ddf5b..a4bf02397 100644 --- a/Lib/csharp/std_map.i +++ b/Lib/csharp/std_map.i @@ -67,12 +67,13 @@ public System.Collections.Generic.ICollection<$typemap(cstype, K)> Keys { get { System.Collections.Generic.ICollection<$typemap(cstype, K)> keys = new System.Collections.Generic.List<$typemap(cstype, K)>(); - IntPtr iter = create_iterator_begin(); - try { - while (true) { + int size = this.Count; + if (size > 0) { + IntPtr iter = create_iterator_begin(); + for (int i = 0; i < size; i++) { keys.Add(get_next_key(iter)); } - } catch (ArgumentOutOfRangeException) { + destroy_iterator(iter); } return keys; } @@ -258,7 +259,7 @@ return false; } - // create_iterator_begin() and get_next_key() work together to provide a collection of keys to C# + // create_iterator_begin(), get_next_key() and destroy_iterator work together to provide a collection of keys to C# %apply void *VOID_INT_PTR { std::map< K, T >::iterator *create_iterator_begin } %apply void *VOID_INT_PTR { std::map< K, T >::iterator *swigiterator } @@ -266,15 +267,15 @@ return new std::map< K, T >::iterator($self->begin()); } - const key_type& get_next_key(std::map< K, T >::iterator *swigiterator) throw (std::out_of_range) { + const key_type& get_next_key(std::map< K, T >::iterator *swigiterator) { std::map< K, T >::iterator iter = *swigiterator; - if (iter == $self->end()) { - delete swigiterator; - throw std::out_of_range("no more map elements"); - } - (*swigiterator)++; + swigiterator++; return (*iter).first; } + + void destroy_iterator(std::map< K, T >::iterator *swigiterator) { + delete swigiterator; + } } @@ -285,6 +286,7 @@ %csmethodmodifiers std::map::setitem "private" %csmethodmodifiers std::map::create_iterator_begin "private" %csmethodmodifiers std::map::get_next_key "private" +%csmethodmodifiers std::map::destroy_iterator "private" // Default implementation namespace std { From 5ff65533190a31afd5d5fdcf1c485c4ed3a3c376 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 28 Sep 2010 17:37:33 +0000 Subject: [PATCH 1024/1680] testcase warning suppression git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12232 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/constant_pointers.i | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Examples/test-suite/constant_pointers.i b/Examples/test-suite/constant_pointers.i index 7d46cdb31..394c0e5ec 100644 --- a/Examples/test-suite/constant_pointers.i +++ b/Examples/test-suite/constant_pointers.i @@ -6,6 +6,8 @@ This testcase primarily test constant pointers, eg int* const. Only a getter is %warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK); /* memory leak when setting a ptr/ref variable */ %warnfilter(SWIGWARN_GO_NAME_CONFLICT); /* Ignoring 'Foo' due to Go name ('Foo') conflict with 'foo' */ +%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG); /* Setting a pointer/reference variable may leak memory. */ + %inline %{ From 9f41fa27cb9eee42c0fc003139ce9a6fdc485031 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 28 Sep 2010 17:56:48 +0000 Subject: [PATCH 1025/1680] remove latin-1 characters git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12233 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Java.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html index d014feef6..d32a7fb9a 100644 --- a/Doc/Manual/Java.html +++ b/Doc/Manual/Java.html @@ -363,7 +363,7 @@ To load your shared native library module in Java, simply use Java's System. public class runme { static { -  System.loadLibrary("example"); +  System.loadLibrary("example"); } public static void main(String argv[]) { @@ -6234,7 +6234,7 @@ public class runme { static { try { -  System.loadLibrary("example"); +  System.loadLibrary("example"); } catch (UnsatisfiedLinkError e) { System.err.println("Native code library failed to load. " + e); System.exit(1); @@ -6453,7 +6453,7 @@ public class runme { static { try { -  System.loadLibrary("example"); +  System.loadLibrary("example"); } catch (UnsatisfiedLinkError e) { System.err.println("Native code library failed to load. " + e); System.exit(1); From 83f17b43ce2049cc1a36237d7930d0507c46cbc6 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Fri, 1 Oct 2010 03:16:56 +0000 Subject: [PATCH 1026/1680] Add entry corresponding to r12229 which I failed to commit before. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12234 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index b0647a336..a281023b6 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -9,6 +9,10 @@ Version 2.0.1 (in progress) [C#] Apply patch from Tomas Dirvanauskas for std::map wrappers to avoid throwing exceptions with normal usage of iterators. +2010-09-27: olly + [Python] Improve error message given when a parameter of the wrong + type is passed to an overloaded method (SF#3027355). + 2010-09-25: wsfulton Apply SF patch #3075150 - Java directors using static variables in named namespace. From c636855bcc31ae71e8303cbfad46466508707a1c Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Fri, 1 Oct 2010 04:01:08 +0000 Subject: [PATCH 1027/1680] [Python] Allow reinitialisation to work with an embedded Python interpreter (patch from Jim Carroll in SF#3075178). git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12235 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++++ Lib/python/pyrun.swg | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index a281023b6..c2d2d52f2 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,10 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.1 (in progress) =========================== +2010-10-01: olly + [Python] Allow reinitialisation to work with an embedded Python + interpreter (patch from Jim Carroll in SF#3075178). + 2010-09-28: wsfulton [C#] Apply patch from Tomas Dirvanauskas for std::map wrappers to avoid throwing exceptions with normal usage of iterators. diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index d46628551..5043e6ec0 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -979,10 +979,13 @@ _SWIG_This(void) return SWIG_Python_str_FromChar("this"); } +static PyObject *swig_this = NULL; + SWIGRUNTIME PyObject * SWIG_This(void) { - static PyObject *SWIG_STATIC_POINTER(swig_this) = _SWIG_This(); + if (swig_this == NULL) + swig_this = _SWIG_This(); return swig_this; } @@ -1413,6 +1416,7 @@ SWIG_Python_DestroyModule(void *vptr) } } Py_DECREF(SWIG_This()); + swig_this = NULL; } SWIGRUNTIME void From 045066e802dd3c56e0e3c6e91fb078ecc75a8d42 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Fri, 1 Oct 2010 04:17:55 +0000 Subject: [PATCH 1028/1680] Fix typo in comment git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12236 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/ruby/rubyerrors.swg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/ruby/rubyerrors.swg b/Lib/ruby/rubyerrors.swg index e2564980f..434544bc9 100644 --- a/Lib/ruby/rubyerrors.swg +++ b/Lib/ruby/rubyerrors.swg @@ -9,7 +9,7 @@ /* Define custom exceptions for errors that do not map to existing Ruby exceptions. Note this only works for C++ since a global cannot be - initialized by a funtion in C. For C, fallback to rb_eRuntimeError.*/ + initialized by a function in C. For C, fallback to rb_eRuntimeError.*/ SWIGINTERN VALUE getNullReferenceError(void) { From eaada32f264f828ec326f4c91f5c1a73399a8897 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Fri, 1 Oct 2010 04:42:29 +0000 Subject: [PATCH 1029/1680] [Ruby] Avoid segfault when a method node has no parentNode (SF#3034054). git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12237 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++++ Source/Modules/ruby.cxx | 11 +++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index c2d2d52f2..d3c8c21d0 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,10 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.1 (in progress) =========================== +2010-10-01: olly + [Ruby] Avoid segfault when a method node has no parentNode + (SF#3034054). + 2010-10-01: olly [Python] Allow reinitialisation to work with an embedded Python interpreter (patch from Jim Carroll in SF#3075178). diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx index ab1210a79..8461b8bef 100644 --- a/Source/Modules/ruby.cxx +++ b/Source/Modules/ruby.cxx @@ -2054,8 +2054,15 @@ public: // Construct real method name String* methodName = NewString(""); - if ( isMethod ) - Printv( methodName, Getattr(parentNode(sibl),"sym:name"), ".", NIL ); + if ( isMethod ) { + // Sometimes a method node has no parent (SF#3034054). + // This value is used in an exception message, so just skip the class + // name in this case so at least we don't segfault. This is probably + // just working around a problem elsewhere though. + Node *parent_node = parentNode(sibl); + if (parent_node) + Printv( methodName, Getattr(parent_node,"sym:name"), ".", NIL ); + } Append( methodName, Getattr(sibl,"sym:name" ) ); if ( isCtor ) Append( methodName, ".new" ); From db6bf51067db6beb701f4e9f5b25e14acf360c2d Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 1 Oct 2010 22:46:22 +0000 Subject: [PATCH 1030/1680] Add pcre-build.sh script for easier building of pcre and configuring with SWIG if PCRE not installed git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12238 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- README | 3 +++ Tools/mkwindows.sh | 14 ++++++++++-- Tools/pcre-build.sh | 53 +++++++++++++++++++++++++++++++++++++++++++++ configure.in | 30 ++++++++++++++++++++----- 4 files changed, 93 insertions(+), 7 deletions(-) create mode 100755 Tools/pcre-build.sh diff --git a/README b/README index 3c6ee27a0..b5379d84d 100644 --- a/README +++ b/README @@ -57,6 +57,9 @@ You must use GNU `make' to build SWIG. http://www.gnu.org/software/make/ +PCRE needs to be installed on your system to build SWIG. The configure +script will provide instructions for obtaining PCRE if it cannot be found. + To build and install SWIG, simply type the following: % ./configure diff --git a/Tools/mkwindows.sh b/Tools/mkwindows.sh index 869fce01a..6042361b3 100755 --- a/Tools/mkwindows.sh +++ b/Tools/mkwindows.sh @@ -43,7 +43,7 @@ else if test x$zip = x; then zip=zip fi - extraconfigureoptions="--host=i586-mingw32msvc --build=i686-linux CXXFLAGS=-O2 CFLAGS=-O2" + extraconfigureoptions="--host=i586-mingw32msvc --build=i686-linux" else if test "$cygwin"; then echo "Building native Windows executable on Cygwin" @@ -61,6 +61,13 @@ fi swigbasename=swig-$version swigwinbasename=swigwin-$version tarball=$swigbasename.tar.gz +pcre_tarball=`ls pcre-*.tar.*` + +if ! test -f "$pcre_tarball"; then + echo "Could not find PCRE tarball. Please download a PCRE source tarball from http://www.pcre.org" + echo "and place in the same directory as the SWIG tarball." + exit 1 +fi if test -f "$tarball"; then builddir=build-$version @@ -78,8 +85,11 @@ if test -f "$tarball"; then mv $swigbasename $swigwinbasename tar -zxf ../$tarball cd $swigbasename + (cd ../.. && cp $pcre_tarball $builddir/$swigbasename) + echo Running: Tools/pcre-build.sh $extraconfigureoptions CFLAGS="$compileflags" CXXFLAGS="$compileflags" + ./Tools/pcre-build.sh $extraconfigureoptions CFLAGS="$compileflags" CXXFLAGS="$compileflags" || exit 1 echo Running: ./configure $extraconfigureoptions CFLAGS="$compileflags" CXXFLAGS="$compileflags" - ./configure $extraconfigureoptions CFLAGS="$compileflags" CXXFLAGS="$compileflags" + ./configure $extraconfigureoptions CFLAGS="$compileflags" CXXFLAGS="$compileflags" || exit 1 echo "Compiling (quietly)..." make > build.log echo "Simple check to see if swig.exe runs..." diff --git a/Tools/pcre-build.sh b/Tools/pcre-build.sh new file mode 100755 index 000000000..876a58a7e --- /dev/null +++ b/Tools/pcre-build.sh @@ -0,0 +1,53 @@ +#!/bin/sh + +pcre_subdir=pcre/pcre-swig-install +pcre_install_dir=`pwd`/$pcre_subdir + +usage() { + echo "Helper script to build PCRE as a static library from a tarball just for use during the" + echo "SWIG build. It does not install PCRE for global use on your system." + echo "Usage: pcre-build.sh [--help] [args]" + echo " args - optional additional arguments passed on to the PCRE configure script (leave out" + echo " unless you are an expert at configure)" + echo " --help - Display this help information." + echo "Instructions:" + echo " - Download the latest PCRE source tarball from http://www.pcre.org and place in the" + echo " directory that you will configure and build SWIG." + echo " - Run this script in the same directory that you intend to configure and build SWIG in." + echo " - Afterwards run the SWIG configure scrip which will then find and use the PCRE static" + echo " libraries in the $pcre_subdir subdirectory." + exit 0 +} + +bail() { + echo $1 >&2 + exit 1 +} + +if test "$1" = "-h" -o "$1" = "-help" -o "$1" = "--help" ; then + usage +fi + +if test -f "pcre-build.sh" ; then + echo "Error: this script should not be run in the Tools directory" >&2 + echo "" + usage +fi + +echo "Looking for PCRE tarball..." +rm -rf pcre +pcre_tarball=`ls pcre-*.tar.*` +test -f "$pcre_tarball" || bail "Could not find tarball" + +echo "Extracting tarball: $pcre_tarball" +tar -xf $pcre_tarball || bail "Could not untar $pcre_tarball" +pcre_dir=`echo $pcre_tarball | sed -e "s/\.tar.*//"` +echo "Configuring PCRE in directory: pcre" +mv $pcre_dir pcre || bail "Could not create pcre directory" +cd pcre && ./configure --prefix=$pcre_install_dir --disable-shared $* || bail "PCRE configure failed" +echo "Building PCRE..." +make -s || bail "Could not build PCRE" +echo "Installing PCRE locally to $pcre_install_dir..." +make -s install || bail "Could not install PCRE" +echo "" +echo "The SWIG configure script can now be run, whereupon PCRE will automatically be detected and used from $pcre_install_dir/bin/pcre-config." diff --git a/configure.in b/configure.in index 856d02d4a..2976aca66 100644 --- a/configure.in +++ b/configure.in @@ -67,6 +67,19 @@ AC_ARG_WITH([pcre], AC_MSG_CHECKING([whether to enable PCRE support]) AC_MSG_RESULT([$with_pcre]) + +dnl To make configuring easier, check for a locally built PCRE using the Tools/pcre-build.sh script +if test x"${with_pcre}" = xyes ; then + AC_MSG_CHECKING([whether to use local PCRE]) + local_pcre_config=no + if test -z $PCRE_CONFIG; then + if test -f `pwd`/pcre/pcre-swig-install/bin/pcre-config; then + PCRE_CONFIG=`pwd`/pcre/pcre-swig-install/bin/pcre-config + local_pcre_config=$PCRE_CONFIG + fi + fi + AC_MSG_RESULT([$local_pcre_config]) +fi AS_IF([test "x$with_pcre" != xno], [AX_PATH_GENERIC([pcre], [], dnl Minimal version of PCRE we need -- accept any @@ -75,11 +88,18 @@ AS_IF([test "x$with_pcre" != xno], LIBS="$LIBS $PCRE_LIBS" CPPFLAGS="$CPPFLAGS $PCRE_CFLAGS" ], - [AC_MSG_FAILURE( - Can't find pcre-config script from PCRE (Perl Compatible Regular - Expressions) library package. You need to either download PCRE from - www.pcre.org and install it or use --without-pcre configure option to - disable regular expressions support in SWIG.) + [AC_MSG_FAILURE([ + Can't find pcre-config script from PCRE (Perl Compatible Regular Expressions) + library package. This dependency is needed for configure to complete, + Either: + - Install the PCRE developer package on your system (preferred approach). + - Download the PCRE source tarball, build and install on your system + as you would for any package built from source distribution. + - Use the Tools/pcre-build.sh script to build PCRE just for SWIG to statically + link against. Run 'Tools/pcre-build.sh --help' for instructions. + (quite easy and does not require privileges to install PCRE on your system) + - Use configure --without-pcre to disable regular expressions support in SWIG + (not recommended).]) ]) ]) From 766ed8db375f47ef0ed4751bcd28eba31e40f3d7 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 1 Oct 2010 23:52:46 +0000 Subject: [PATCH 1031/1680] Add -pcreversion option to display PCRE version information git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12239 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 3 +++ Doc/Manual/SWIG.html | 1 + Source/Modules/main.cxx | 7 +++++++ Source/Swig/misc.c | 8 ++++++++ Source/Swig/swig.h | 1 + 5 files changed, 20 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index d3c8c21d0..f312793e4 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,9 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.1 (in progress) =========================== +2010-10-01: wsfulton + Add -pcreversion option to display PCRE version information. + 2010-10-01: olly [Ruby] Avoid segfault when a method node has no parentNode (SF#3034054). diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html index 52b9db339..23a5e1643 100644 --- a/Doc/Manual/SWIG.html +++ b/Doc/Manual/SWIG.html @@ -147,6 +147,7 @@ can be obtained by typing swig -help or swig -o outfile Name of output file -outcurrentdir Set default output dir to current dir instead of input file's path -outdir dir Set language specific files output directory +-pcreversion Display PCRE version information -swiglib Show location of SWIG library -version Show SWIG version number diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx index 3f2008d7d..95327018d 100644 --- a/Source/Modules/main.cxx +++ b/Source/Modules/main.cxx @@ -129,6 +129,7 @@ static const char *usage3 = (const char *) "\ -oh - Set name of the output header file to \n\ -outcurrentdir - Set default output dir to current dir instead of input file's path\n\ -outdir - Set language specific files output directory to \n\ + -pcreversion - Display PCRE version information\n\ -small - Compile in virtual elimination & compact mode\n\ -swiglib - Report location of SWIG library and exit\n\ -templatereduce - Reduce all the typedefs in templates\n\ @@ -515,6 +516,12 @@ void SWIG_getoptions(int argc, char *argv[]) { } else if (strcmp(argv[i], "-nodirprot") == 0) { Wrapper_director_protected_mode_set(0); Swig_mark_arg(i); + } else if (strcmp(argv[i], "-pcreversion") == 0) { + String *version = Swig_pcre_version(); + Printf(stdout, "%s\n", version); + Delete(version); + Swig_mark_arg(i); + SWIG_exit(EXIT_SUCCESS); } else if (strcmp(argv[i], "-small") == 0) { Wrapper_compact_print_mode_set(1); Wrapper_virtual_elimination_mode_set(1); diff --git a/Source/Swig/misc.c b/Source/Swig/misc.c index a57c7cf33..73510b513 100644 --- a/Source/Swig/misc.c +++ b/Source/Swig/misc.c @@ -1213,6 +1213,10 @@ String *Swig_string_regex(String *s) { return res ? res : NewStringEmpty(); } +String *Swig_pcre_version(void) { + return NewStringf("PCRE Version: %s", pcre_version()); +} + #else String *Swig_string_regex(String *s) { @@ -1220,6 +1224,10 @@ String *Swig_string_regex(String *s) { exit(1); } +String *Swig_pcre_version(void) { + return NewStringf("PCRE not used"); +} + #endif /* ----------------------------------------------------------------------------- diff --git a/Source/Swig/swig.h b/Source/Swig/swig.h index 021c5611f..0194664fc 100644 --- a/Source/Swig/swig.h +++ b/Source/Swig/swig.h @@ -319,6 +319,7 @@ extern int ParmList_is_compactdefargs(ParmList *p); extern String *Swig_string_lower(String *s); extern String *Swig_string_upper(String *s); extern String *Swig_string_title(String *s); + extern String *Swig_pcre_version(void); extern void Swig_init(void); extern int Swig_value_wrapper_mode(int mode); From 3219746776bb1bcb9f46f895c68040303f0d4b33 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 3 Oct 2010 13:12:00 +0000 Subject: [PATCH 1032/1680] Apply patch #3066958 from Mikael Johansson to fix default smart pointer handling when the smart pointer contains both a const and non-const operator->. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12240 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 + Examples/test-suite/common.mk | 1 + .../smart_pointer_const_overload_runme.java | 99 ++++++++++++++ .../smart_pointer_const_overload_runme.py | 123 ++++++++++++++++++ .../test-suite/smart_pointer_const_overload.i | 74 +++++++++++ Source/Modules/allocate.cxx | 6 +- Source/Modules/lang.cxx | 7 +- Source/Swig/cwrap.c | 40 ++++-- Source/Swig/swig.h | 1 + 9 files changed, 343 insertions(+), 12 deletions(-) create mode 100644 Examples/test-suite/java/smart_pointer_const_overload_runme.java create mode 100644 Examples/test-suite/python/smart_pointer_const_overload_runme.py create mode 100644 Examples/test-suite/smart_pointer_const_overload.i diff --git a/CHANGES.current b/CHANGES.current index f312793e4..18694e492 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,10 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.1 (in progress) =========================== +2010-10-03: wsfulton + Apply patch #3066958 from Mikael Johansson to fix default smart pointer + handling when the smart pointer contains both a const and non-const operator->. + 2010-10-01: wsfulton Add -pcreversion option to display PCRE version information. diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index e385b11dd..026612db5 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -294,6 +294,7 @@ CPP_TEST_CASES += \ sizet \ smart_pointer_const \ smart_pointer_const2 \ + smart_pointer_const_overload \ smart_pointer_extend \ smart_pointer_member \ smart_pointer_multi \ diff --git a/Examples/test-suite/java/smart_pointer_const_overload_runme.java b/Examples/test-suite/java/smart_pointer_const_overload_runme.java new file mode 100644 index 000000000..bb4ae2c8f --- /dev/null +++ b/Examples/test-suite/java/smart_pointer_const_overload_runme.java @@ -0,0 +1,99 @@ +import smart_pointer_const_overload.*; + +public class smart_pointer_const_overload_runme { + static int CONST_ACCESS = 1; + static int MUTABLE_ACCESS = 2; + + static { + System.loadLibrary("smart_pointer_const_overload"); + } + + public static void test(Bar b, Foo f) { + Assert(f.getX() == 0); + + // Test member variable get + Assert(b.getX() == 0); + Assert(f.getAccess() == CONST_ACCESS); + + // Test member variable set + b.setX(1); + Assert(f.getX() == 1); + Assert(f.getAccess() == MUTABLE_ACCESS); + + // Test const method + Assert(b.getx() == 1); + Assert(f.getAccess() == CONST_ACCESS); + + // Test mutable method + b.setx(2); + + Assert(f.getX() == 2); + Assert(f.getAccess() == MUTABLE_ACCESS); + + // Test extended const method + Assert(b.getx2() == 2); + Assert(f.getAccess() == CONST_ACCESS); + + // Test extended mutable method + b.setx2(3); + + Assert(f.getX() == 3); + Assert(f.getAccess() == MUTABLE_ACCESS); + + // Test static method + b.stat(); + + Assert(f.getAccess() == CONST_ACCESS); + + // Test const member + f.setAccess(MUTABLE_ACCESS); + + Assert(b.getY() == 0); + Assert(f.getAccess() == CONST_ACCESS); + + // Test get through mutable pointer to const member + f.setAccess(MUTABLE_ACCESS); + + Assert(smart_pointer_const_overload.get_int(b.getYp()) == 0); + Assert(f.getAccess() == CONST_ACCESS); + + // Test get through const pointer to mutable member + f.setX(4); + f.setAccess(MUTABLE_ACCESS); + + Assert(smart_pointer_const_overload.get_int(b.getXp()) == 4); + Assert(f.getAccess() == CONST_ACCESS); + + // Test set through const pointer to mutable member + f.setAccess(MUTABLE_ACCESS); + smart_pointer_const_overload.set_int(b.getXp(), 5); + + Assert(f.getX() == 5); + Assert(f.getAccess() == CONST_ACCESS); + + // Test set pointer to const member + b.setYp(smart_pointer_const_overload.new_int(6)); + + Assert(f.getY() == 0); + Assert(smart_pointer_const_overload.get_int(f.getYp()) == 6); + Assert(f.getAccess() == MUTABLE_ACCESS); + + smart_pointer_const_overload.delete_int(f.getYp()); + } + + public static void main(String argv[]) { + Foo f = new Foo(); + Bar b = new Bar(f); + + //Foo f2 = new Foo(); + //Bar b2 = new Bar2(f2); + + test(b, f); + //test(b2, f2); + } + + public static void Assert(boolean b) { + if (!b) + throw new RuntimeException("Assertion failed"); + } +} diff --git a/Examples/test-suite/python/smart_pointer_const_overload_runme.py b/Examples/test-suite/python/smart_pointer_const_overload_runme.py new file mode 100644 index 000000000..f1be315a5 --- /dev/null +++ b/Examples/test-suite/python/smart_pointer_const_overload_runme.py @@ -0,0 +1,123 @@ +from smart_pointer_const_overload import * + +CONST_ACCESS = 1 +MUTABLE_ACCESS = 2 + +def test(b, f): + if f.x != 0: + raise RuntimeError + + # Test member variable get + if b.x != 0: + raise RuntimeError + + if f.access != CONST_ACCESS: + raise RuntimeError + + # Test member variable set + b.x = 1 + + if f.x != 1: + raise RuntimeError + + if f.access != MUTABLE_ACCESS: + raise RuntimeError + + # Test const method + if b.getx() != 1: + raise RuntimeError + + if f.access != CONST_ACCESS: + raise RuntimeError + + # Test mutable method + b.setx(2) + + if f.x != 2: + raise RuntimeError + + if f.access != MUTABLE_ACCESS: + raise RuntimeError + + # Test extended const method + if b.getx2() != 2: + raise RuntimeError + + if f.access != CONST_ACCESS: + raise RuntimeError + + # Test extended mutable method + b.setx2(3) + + if f.x != 3: + raise RuntimeError + + if f.access != MUTABLE_ACCESS: + raise RuntimeError + + # Test static method + b.stat() + + if f.access != CONST_ACCESS: + raise RuntimeError + + # Test const member + f.access = MUTABLE_ACCESS + + if b.y != 0: + raise RuntimeError + + if f.access != CONST_ACCESS: + raise RuntimeError + + # Test get through mutable pointer to const member + f.access = MUTABLE_ACCESS + + if get_int(b.yp) != 0: + raise RuntimeError + + if f.access != CONST_ACCESS: + raise RuntimeError + + # Test get through const pointer to mutable member + f.x = 4 + f.access = MUTABLE_ACCESS + + if get_int(b.xp) != 4: + raise RuntimeError + + if f.access != CONST_ACCESS: + raise RuntimeError + + # Test set through const pointer to mutable member + f.access = MUTABLE_ACCESS + set_int(b.xp, 5) + + if f.x != 5: + raise RuntimeError + + if f.access != CONST_ACCESS: + raise RuntimeError + + # Test set pointer to const member + b.yp = new_int(6) + + if f.y != 0: + raise RuntimeError + + if get_int(f.yp) != 6: + raise RuntimeError + + if f.access != MUTABLE_ACCESS: + raise RuntimeError + + delete_int(f.yp); + +f = Foo() +b = Bar(f) + +f2 = Foo() +b2 = Bar2(f2) + +test(b, f) +test(b2, f2) diff --git a/Examples/test-suite/smart_pointer_const_overload.i b/Examples/test-suite/smart_pointer_const_overload.i new file mode 100644 index 000000000..e3b000b52 --- /dev/null +++ b/Examples/test-suite/smart_pointer_const_overload.i @@ -0,0 +1,74 @@ +%module smart_pointer_const_overload + +%warnfilter(SWIGWARN_LANG_OVERLOAD_IGNORED) Bar::operator->; // Overloaded method Bar::operator ->() ignored +%warnfilter(SWIGWARN_LANG_OVERLOAD_IGNORED) Bar2::operator->; // Overloaded method Bar2::operator ->() ignored + +%inline %{ +int CONST_ACCESS = 1; +int MUTABLE_ACCESS = 2; + +int *new_int(int ivalue) { + int *i = (int *) malloc(sizeof(ivalue)); + *i = ivalue; + return i; +} + +int get_int(int *i) { + return *i; +} + +void set_int(int *i, int ivalue) { + *i = ivalue; +} + +void delete_int(int *i) { + free(i); +} + +struct Foo { + int x; + int * const xp; + const int y; + const int *yp; + int access; + Foo() : x(0), xp(&x), y(0), yp(&y), access(0) { } + int getx() const { return x; } + void setx(int x_) { x = x_; } + static void stat() {} +}; +%} + +%extend Foo { + int getx2() const { return self->x; } + void setx2(int x_) { self->x = x_; } +}; + +%inline %{ +class Bar { + Foo *f; +public: + Bar(Foo *f) : f(f) { } + const Foo *operator->() const { + f->access = CONST_ACCESS; + return f; + } + Foo *operator->() { + f->access = MUTABLE_ACCESS; + return f; + } +}; + +class Bar2 { + Foo *f; +public: + Bar2(Foo *f) : f(f) { } + Foo *operator->() { + f->access = MUTABLE_ACCESS; + return f; + } + const Foo *operator->() const { + f->access = CONST_ACCESS; + return f; + } +}; +%} diff --git a/Source/Modules/allocate.cxx b/Source/Modules/allocate.cxx index 2e05fd190..31f7c20ae 100644 --- a/Source/Modules/allocate.cxx +++ b/Source/Modules/allocate.cxx @@ -824,9 +824,12 @@ Allocate(): int isconst = 0; Delete(SwigType_pop(type)); if (SwigType_isconst(type)) { - isconst = 1; + isconst = !Getattr(inclass, "allocate:smartpointermutable"); Setattr(inclass, "allocate:smartpointerconst", "1"); } + else { + Setattr(inclass, "allocate:smartpointermutable", "1"); + } List *methods = smart_pointer_methods(sc, 0, isconst); Setattr(inclass, "allocate:smartpointer", methods); Setattr(inclass, "allocate:smartpointerbase", base); @@ -834,7 +837,6 @@ Allocate(): /* Hmmm. The return value is not a pointer. If the type is a value or reference. We're going to chase it to see if another operator->() can be found */ - if ((SwigType_check_decl(type, "")) || (SwigType_check_decl(type, "r."))) { Node *nn = Swig_symbol_clookup((char *) "operator ->", Getattr(sc, "symtab")); if (nn) { diff --git a/Source/Modules/lang.cxx b/Source/Modules/lang.cxx index 6ec0463fa..0110b6ea1 100644 --- a/Source/Modules/lang.cxx +++ b/Source/Modules/lang.cxx @@ -1344,7 +1344,7 @@ int Language::variableHandler(Node *n) { Swig_save("variableHandler", n, "feature:immutable", NIL); if (SmartPointer) { /* If a smart-pointer and it's a constant access, we have to set immutable */ - if (Getattr(CurrentClass, "allocate:smartpointerconst")) { + if (!Getattr(CurrentClass, "allocate:smartpointermutable")) { SetFlag(n, "feature:immutable"); } } @@ -1391,7 +1391,7 @@ int Language::membervariableHandler(Node *n) { int assignable = is_assignable(n); if (SmartPointer) { - if (Getattr(CurrentClass, "allocate:smartpointerconst")) { + if (!Getattr(CurrentClass, "allocate:smartpointermutable")) { assignable = 0; } } @@ -2443,6 +2443,9 @@ int Language::classHandler(Node *n) { List *methods = Getattr(n, "allocate:smartpointer"); cplus_mode = PUBLIC; SmartPointer = CWRAP_SMART_POINTER; + if (Getattr(n, "allocate:smartpointerconst") && Getattr(n, "allocate:smartpointermutable")) { + SmartPointer |= CWRAP_SMART_POINTER_OVERLOAD; + } Iterator c; for (c = First(methods); c.item; c = Next(c)) { emit_one(c.item); diff --git a/Source/Swig/cwrap.c b/Source/Swig/cwrap.c index b8812563e..799d434a6 100644 --- a/Source/Swig/cwrap.c +++ b/Source/Swig/cwrap.c @@ -783,15 +783,32 @@ int Swig_add_extension_code(Node *n, const String *function_name, ParmList *parm * ----------------------------------------------------------------------------- */ int Swig_MethodToFunction(Node *n, const_String_or_char_ptr nspace, String *classname, int flags, SwigType *director_type, int is_director) { - String *name, *qualifier; + String *name; ParmList *parms; SwigType *type; Parm *p; String *self = 0; - - /* If smart pointer, change self dereferencing */ + int is_smart_pointer_overload = 0; + String *qualifier = Getattr(n, "qualifier"); + + /* If smart pointer without const overload or mutable method, change self dereferencing */ if (flags & CWRAP_SMART_POINTER) { - self = NewString("(*this)->"); + if (flags & CWRAP_SMART_POINTER_OVERLOAD) { + String *cname = Getattr(n, "classname") ? Getattr(n, "classname") : classname; + if (qualifier && strncmp(Char(qualifier), "q(const)", 8) == 0) { + self = NewString("(*(this))->"); + is_smart_pointer_overload = 1; + } + else if (Cmp(Getattr(n, "storage"), "static") == 0) { + self = NewStringf("(*(%s const *)this)->", cname); + is_smart_pointer_overload = 1; + } + else { + self = NewString("(*this)->"); + } + } else { + self = NewString("(*this)->"); + } } /* If node is a member template expansion, we don't allow added code */ @@ -799,7 +816,6 @@ int Swig_MethodToFunction(Node *n, const_String_or_char_ptr nspace, String *clas flags &= ~(CWRAP_EXTEND); name = Getattr(n, "name"); - qualifier = Getattr(n, "qualifier"); parms = CopyParmList(nonvoid_parms(Getattr(n, "parms"))); type = NewString(classname); @@ -921,10 +937,16 @@ int Swig_MethodToFunction(Node *n, const_String_or_char_ptr nspace, String *clas if (Cmp(Getattr(n, "storage"), "static") != 0) { String *pname = Swig_cparm_name(pp, i); - String *ctname = SwigType_namestr(cname); - String *fadd = NewStringf("(%s*)(%s)->operator ->()", ctname, pname); + String *ctname = SwigType_namestr(cname); + String *fadd = 0; + if (is_smart_pointer_overload) { + fadd = NewStringf("(%s const *)((%s const *)%s)->operator ->()", ctname, classname, pname); + } + else { + fadd = NewStringf("(%s*)(%s)->operator ->()", ctname, pname); + } Append(func, fadd); - Delete(ctname); + Delete(ctname); Delete(fadd); Delete(pname); pp = nextSibling(pp); @@ -1310,6 +1332,8 @@ int Swig_MembergetToFunction(Node *n, String *classname, int flags) { Node *sn = Getattr(n, "cplus:staticbase"); String *base = Getattr(sn, "name"); self = NewStringf("%s::", base); + } else if (flags & CWRAP_SMART_POINTER_OVERLOAD) { + self = NewStringf("(*(%s const *)this)->", classname); } else { self = NewString("(*this)->"); } diff --git a/Source/Swig/swig.h b/Source/Swig/swig.h index 0194664fc..8058216c3 100644 --- a/Source/Swig/swig.h +++ b/Source/Swig/swig.h @@ -370,6 +370,7 @@ extern int ParmList_is_compactdefargs(ParmList *p); #define CWRAP_DIRECTOR_ONE_CALL 0x08 #define CWRAP_DIRECTOR_TWO_CALLS 0x10 #define CWRAP_ALL_PROTECTED_ACCESS 0x20 +#define CWRAP_SMART_POINTER_OVERLOAD 0x40 /* --- Director Helpers --- */ extern Node *Swig_methodclass(Node *n); From 70c9dc5dcc532b104861962c170b2bf94ac2fd57 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 3 Oct 2010 15:01:24 +0000 Subject: [PATCH 1033/1680] Fix warning running under Go git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12241 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/constant_pointers.i | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Examples/test-suite/constant_pointers.i b/Examples/test-suite/constant_pointers.i index 394c0e5ec..388970c4d 100644 --- a/Examples/test-suite/constant_pointers.i +++ b/Examples/test-suite/constant_pointers.i @@ -5,7 +5,6 @@ This testcase primarily test constant pointers, eg int* const. Only a getter is %module constant_pointers %warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK); /* memory leak when setting a ptr/ref variable */ -%warnfilter(SWIGWARN_GO_NAME_CONFLICT); /* Ignoring 'Foo' due to Go name ('Foo') conflict with 'foo' */ %warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG); /* Setting a pointer/reference variable may leak memory. */ @@ -52,7 +51,7 @@ public: private: MemberVariablesTest& operator=(const MemberVariablesTest&); }; -void foo(const int *const i) {} +void foofunction(const int *const i) {} typedef int *typedef1, typedef2, *const typedef3; int int1, int2=2, *int3, *const int4 = &GlobalInt; From 378ce60b495f2a8fba61cc5034ed072d434b2d55 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 3 Oct 2010 15:08:03 +0000 Subject: [PATCH 1034/1680] Lua warning fix since previous commit changed max to maximum git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12242 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/wrapmacro.i | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/test-suite/wrapmacro.i b/Examples/test-suite/wrapmacro.i index bd5e48b15..4d2cd67be 100644 --- a/Examples/test-suite/wrapmacro.i +++ b/Examples/test-suite/wrapmacro.i @@ -1,7 +1,7 @@ %module wrapmacro #ifdef SWIGLUA // lua only has one numeric type, so some overloads shadow each other creating warnings -%warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) SWIGMACRO_max; +%warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) SWIGMACRO_maximum; #endif /* Testing technique for wrapping macros */ From 77a45b263102a22bb6d854760e8ecef32f956d1e Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 3 Oct 2010 16:42:22 +0000 Subject: [PATCH 1035/1680] visual c++ warning fixes git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12243 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/go.cxx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Source/Modules/go.cxx b/Source/Modules/go.cxx index f62586b92..4b1d05b92 100644 --- a/Source/Modules/go.cxx +++ b/Source/Modules/go.cxx @@ -1945,7 +1945,7 @@ private: String *ty = NewString(Getattr(ni, "type")); SwigType_push(ty, Getattr(ni, "decl")); String *fullty = SwigType_typedef_resolve_all(ty); - bool is_function = SwigType_isfunction(fullty); + bool is_function = SwigType_isfunction(fullty) ? true : false; Delete(ty); Delete(fullty); @@ -2426,7 +2426,7 @@ private: * ------------------------------------------------------------ */ int classDirectorConstructor(Node *n) { - bool is_ignored = GetFlag(n, "feature:ignore"); + bool is_ignored = GetFlag(n, "feature:ignore") ? true : false; String *name = Getattr(n, "sym:name"); if (!name) { @@ -2667,7 +2667,7 @@ private: return SWIG_OK; } - bool is_ignored = GetFlag(n, "feature:ignore"); + bool is_ignored = GetFlag(n, "feature:ignore") ? true : false; if (!is_ignored) { String *fnname = NewString("DeleteDirector"); @@ -2781,7 +2781,7 @@ private: int classDirectorMethod(Node *n, Node *parent, String *super) { (void) super; - bool is_ignored = GetFlag(n, "feature:ignore"); + bool is_ignored = GetFlag(n, "feature:ignore") ? true : false; bool is_pure_virtual = (Cmp(Getattr(n, "storage"), "virtual") == 0 && Cmp(Getattr(n, "value"), "0") == 0); // We don't need explicit calls. @@ -2869,7 +2869,7 @@ private: * ------------------------------------------------------------ */ int oneClassDirectorMethod(Node *n, Node *parent) { - bool is_ignored = GetFlag(n, "feature:ignore"); + bool is_ignored = GetFlag(n, "feature:ignore") ? true : false; bool is_pure_virtual = (Cmp(Getattr(n, "storage"), "virtual") == 0 && Cmp(Getattr(n, "value"), "0") == 0); String *name = Getattr(n, "sym:name"); @@ -3782,7 +3782,7 @@ private: int num_required = emit_num_required(pi); int num_arguments = emit_num_arguments(pi); - bool varargs = emit_isvarargs(pi); + bool varargs = emit_isvarargs(pi) ? true : false; if (varargs) { Printf(f_go_wrappers, "\tif argc >= %d {\n", num_required); @@ -4138,7 +4138,7 @@ private: n1, name, n2); return false; } - bool r = addSymbol(name, n, scope); + bool r = addSymbol(name, n, scope) ? true : false; assert(r); return true; } From c7b4336a6cb9e22bd779c9cad7cd02839927343e Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 3 Oct 2010 16:47:30 +0000 Subject: [PATCH 1036/1680] add missing return to testcase git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12244 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/csharp_attributes.i | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/test-suite/csharp_attributes.i b/Examples/test-suite/csharp_attributes.i index bca595d9a..f679d8c08 100644 --- a/Examples/test-suite/csharp_attributes.i +++ b/Examples/test-suite/csharp_attributes.i @@ -56,7 +56,7 @@ double MoreStations::WestonSuperMare = 0.0; %inline %{ struct YetMoreStations { - virtual int Slough(int x) {} + virtual int Slough(int x) { return x; } virtual ~YetMoreStations() {} }; %} From 22dd2292cadd62b0e8d88fc89da584efcfceb5d2 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 3 Oct 2010 16:58:51 +0000 Subject: [PATCH 1037/1680] Fix for compiling as C code git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12245 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/perl5/perlprimtypes.swg | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Lib/perl5/perlprimtypes.swg b/Lib/perl5/perlprimtypes.swg index f2a614030..86a78c5bf 100644 --- a/Lib/perl5/perlprimtypes.swg +++ b/Lib/perl5/perlprimtypes.swg @@ -311,8 +311,9 @@ SWIG_AsVal_dec(double)(SV *obj, double *val) const char *nptr = SvPV_nolen(obj); if (nptr) { char *endptr; + double v; errno = 0; - double v = strtod(nptr, &endptr); + v = strtod(nptr, &endptr); if (errno == ERANGE) { errno = 0; return SWIG_OverflowError; From 61e9073e0777c7b2d35c9a1d4591058755ee9590 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 3 Oct 2010 20:47:45 +0000 Subject: [PATCH 1038/1680] Add missing return value in testcase git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12246 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/return_const_value.i | 1 + 1 file changed, 1 insertion(+) diff --git a/Examples/test-suite/return_const_value.i b/Examples/test-suite/return_const_value.i index 473878521..6be5760c1 100644 --- a/Examples/test-suite/return_const_value.i +++ b/Examples/test-suite/return_const_value.i @@ -42,6 +42,7 @@ public: _ptr = f._ptr; _own = f._own; f._own = 0; + return *this; } ~Foo_ptr() { From 22a12bf08fab301446fe9bfeea6ada9a6a47570e Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 4 Oct 2010 05:34:54 +0000 Subject: [PATCH 1039/1680] Add 2.0.1 release notes git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12247 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- ANNOUNCE | 2 +- CHANGES.current | 4 ++-- Doc/Manual/SWIG.html | 3 ++- Doc/Manual/Sections.html | 2 +- README | 2 +- RELEASENOTES | 9 +++++++++ 6 files changed, 16 insertions(+), 6 deletions(-) diff --git a/ANNOUNCE b/ANNOUNCE index ad3e8f8d6..d14a77042 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -1,4 +1,4 @@ -*** ANNOUNCE: SWIG 2.0.1 (in progress) *** +*** ANNOUNCE: SWIG 2.0.1 (4 October 2010) *** http://www.swig.org diff --git a/CHANGES.current b/CHANGES.current index 18694e492..9b02c475f 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -2,8 +2,8 @@ This file contains the changes for the current release. See the CHANGES file for changes in older releases. See the RELEASENOTES file for a summary of changes in each release. -Version 2.0.1 (in progress) -=========================== +Version 2.0.1 (4 October 2010) +============================== 2010-10-03: wsfulton Apply patch #3066958 from Mikael Johansson to fix default smart pointer diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html index 23a5e1643..e45fc5f9f 100644 --- a/Doc/Manual/SWIG.html +++ b/Doc/Manual/SWIG.html @@ -1885,7 +1885,8 @@ and a more descriptive one, but the two functions are otherwise equivalent: String after (Perl-like) regex substitution operation. This function allows to apply arbitrary regular expressions to the identifier names. The pattern part is a regular expression in Perl syntax (as supported - by PCRE) and the subst string + by the Perl Compatible Regular Expressions (PCRE)) + library and the subst string can contain back-references introduced by '\' or, as backslashes need to be escaped in C strings, rather by "\\". For example, to remove any alphabetic prefix before an underscore you could use the following directive: diff --git a/Doc/Manual/Sections.html b/Doc/Manual/Sections.html index 8693adc07..74d821b17 100644 --- a/Doc/Manual/Sections.html +++ b/Doc/Manual/Sections.html @@ -6,7 +6,7 @@

      SWIG-2.0 Documentation

      -Last update : SWIG-2.0.1 (in progress) +Last update : SWIG-2.0.1 (4 October 2010)

      Sections

      diff --git a/README b/README index b5379d84d..085fafd7e 100644 --- a/README +++ b/README @@ -1,6 +1,6 @@ SWIG (Simplified Wrapper and Interface Generator) -Version: 2.0.1 (in progress) +Version: 2.0.1 (4 October 2010) Tagline: SWIG is a compiler that integrates C and C++ with languages including Perl, Python, Tcl, Ruby, PHP, Java, Ocaml, Lua, diff --git a/RELEASENOTES b/RELEASENOTES index 5f41df04f..e8ff30285 100644 --- a/RELEASENOTES +++ b/RELEASENOTES @@ -5,6 +5,15 @@ and CHANGES files. Release Notes ============= +SWIG-2.0.1 summary: +- New language module: Go +- New regular expression (regex) encoder for renaming symbols based on + the Perl Compatible Regular Expressions (PCRE) library. +- Numerous fixes in reporting file and line numbers in error and warning + messages. +- Various bug fixes and improvements in the C#, Lua, Perl, PHP, Ruby + and Python language modules. + SWIG-2.0.0 summary: - License changes, see LICENSE file and http://www.swig.org/legal.html. - Much better nested class/struct support. From 2e28d85e5dd71cb75388ca6a93df459ac3db1105 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 4 Oct 2010 05:36:49 +0000 Subject: [PATCH 1040/1680] Warning section doc update git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12248 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Contents.html | 2 +- Doc/Manual/Warnings.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index ec99a6511..5b18d38de 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -494,7 +494,7 @@
    • C/C++ Parser (300-399)
    • Types and typemaps (400-499)
    • Code generation (500-599) -
    • Language module specific (800-899) +
    • Language module specific (700-899)
    • User defined (900-999)
  • History diff --git a/Doc/Manual/Warnings.html b/Doc/Manual/Warnings.html index 4bbf18205..2c71b6a31 100644 --- a/Doc/Manual/Warnings.html +++ b/Doc/Manual/Warnings.html @@ -25,7 +25,7 @@
  • C/C++ Parser (300-399)
  • Types and typemaps (400-499)
  • Code generation (500-599) -
  • Language module specific (800-899) +
  • Language module specific (700-899)
  • User defined (900-999)
  • History From 197b25147e120dc5403a2f948707e4362d463488 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 4 Oct 2010 05:46:42 +0000 Subject: [PATCH 1041/1680] html fixes git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12249 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/SWIG.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html index e45fc5f9f..e51e55986 100644 --- a/Doc/Manual/SWIG.html +++ b/Doc/Manual/SWIG.html @@ -1881,7 +1881,7 @@ and a more descriptive one, but the two functions are otherwise equivalent: wxPrintPrint - regex:/pattern/subst/ + regex:/pattern/subst/ String after (Perl-like) regex substitution operation. This function allows to apply arbitrary regular expressions to the identifier names. The pattern part is a regular expression in Perl syntax (as supported From eff2a7f9e9f22b4c47a82a16386a4edc8b84e52e Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 4 Oct 2010 06:10:41 +0000 Subject: [PATCH 1042/1680] dependency fix for the .book files generation git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12250 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/Manual/Makefile b/Doc/Manual/Makefile index 69d361f07..2e50b7767 100644 --- a/Doc/Manual/Makefile +++ b/Doc/Manual/Makefile @@ -38,13 +38,13 @@ generate: swightml.book swigpdf.book htmldoc --batch swigpdf.book || true python fixstyle.py SWIGDocumentation.html -swigpdf.book: +swigpdf.book chapters Sections.html: echo "#HTMLDOC 1.8.24" > swigpdf.book echo -t pdf13 -f SWIGDocumentation.pdf $(HTMLDOC_OPTIONS) --stylesheet style.css >> swigpdf.book echo "Sections.html" >> swigpdf.book cat chapters >> swigpdf.book -swightml.book: +swightml.book chapters Sections.html: echo "#HTMLDOC 1.8.24" > swightml.book echo -t html -f SWIGDocumentation.html $(HTMLDOC_OPTIONS) >> swightml.book echo "Sections.html" >> swightml.book From 13f861220a0dc8c12512f8bf82c07083b53812f6 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 4 Oct 2010 06:15:53 +0000 Subject: [PATCH 1043/1680] dependency fix for the .book files generation git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12251 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Doc/Manual/Makefile b/Doc/Manual/Makefile index 2e50b7767..011261e76 100644 --- a/Doc/Manual/Makefile +++ b/Doc/Manual/Makefile @@ -15,7 +15,7 @@ # Note the # and " are escaped HTMLDOC_OPTIONS = "--book --toclevels 4 --no-numbered --toctitle \"Table of Contents\" --title --titleimage swig16.png --linkcolor \#0000ff --linkstyle underline --size Universal --left 0.50in --right 0.50in --top 0.50in --bottom 0.50in --header .t. --footer h.1 --nup 1 --tocheader .t. --tocfooter ..i --portrait --color --no-pscommands --no-xrxcomments --compression=1 --jpeg=0 --fontsize 10.0 --fontspacing 1.2 --headingfont Helvetica --bodyfont Times --headfootsize 10.0 --headfootfont Helvetica --charset iso-8859-1 --links --no-embedfonts --pagemode outline --pagelayout single --firstpage c1 --pageeffect none --pageduration 10 --effectduration 1.0 --no-encryption --permissions all --owner-password \"\" --user-password \"\" --browserwidth 680" -.PHONY: maketoc check generate all clean validate test +.PHONY: maketoc check generate all maintainer-clean validate test all: maketoc check generate @@ -38,13 +38,13 @@ generate: swightml.book swigpdf.book htmldoc --batch swigpdf.book || true python fixstyle.py SWIGDocumentation.html -swigpdf.book chapters Sections.html: +swigpdf.book: chapters Sections.html echo "#HTMLDOC 1.8.24" > swigpdf.book echo -t pdf13 -f SWIGDocumentation.pdf $(HTMLDOC_OPTIONS) --stylesheet style.css >> swigpdf.book echo "Sections.html" >> swigpdf.book cat chapters >> swigpdf.book -swightml.book chapters Sections.html: +swightml.book: chapters Sections.html echo "#HTMLDOC 1.8.24" > swightml.book echo -t html -f SWIGDocumentation.html $(HTMLDOC_OPTIONS) >> swightml.book echo "Sections.html" >> swightml.book From 29b4dbdac1098bbdaf1500a3eb8fb677c0f99db5 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 4 Oct 2010 06:16:21 +0000 Subject: [PATCH 1044/1680] Not all languages were not in alphabetical order git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12252 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Contents.html | 36 +++---- Doc/Manual/R.html | 16 ++-- Doc/Manual/Ruby.html | 196 +++++++++++++++++++-------------------- Doc/Manual/Sections.html | 6 +- Doc/Manual/Tcl.html | 92 +++++++++--------- Doc/Manual/chapters | 2 +- 6 files changed, 174 insertions(+), 174 deletions(-) diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index 5b18d38de..f4fdb9d24 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -1360,7 +1360,23 @@ -

    33 SWIG and Ruby

    +

    33 SWIG and R

    + + + + + +

    34 SWIG and Ruby

    @@ -1494,7 +1510,7 @@
    -

    34 SWIG and Tcl

    +

    35 SWIG and Tcl

    @@ -1560,22 +1576,6 @@
    -

    35 SWIG and R

    - - - - -

    36 Extending SWIG to support new languages

    diff --git a/Doc/Manual/R.html b/Doc/Manual/R.html index ceea32146..679718400 100644 --- a/Doc/Manual/R.html +++ b/Doc/Manual/R.html @@ -6,7 +6,7 @@ -

    35 SWIG and R

    +

    33 SWIG and R

      @@ -33,7 +33,7 @@ compile and run an R interface to QuantLib running on Mandriva Linux with gcc. The R bindings also work on Microsoft Windows using Visual C++.

      -

      35.1 Bugs

      +

      33.1 Bugs

      @@ -45,7 +45,7 @@ Currently the following features are not implemented or broken:

    • C Array wrappings
    -

    35.2 Using R and SWIG

    +

    33.2 Using R and SWIG

    @@ -119,7 +119,7 @@ Without it, inheritance of wrapped objects may fail. These two files can be loaded in any order

    -

    35.3 Precompiling large R files

    +

    33.3 Precompiling large R files

    In cases where the R file is large, one make save a lot of loading @@ -137,7 +137,7 @@ will save a large amount of loading time. -

    35.4 General policy

    +

    33.4 General policy

    @@ -146,7 +146,7 @@ wrapping over the underlying functions and rely on the R type system to provide R syntax.

    -

    35.5 Language conventions

    +

    33.5 Language conventions

    @@ -155,7 +155,7 @@ and [ are overloaded to allow for R syntax (one based indices and slices)

    -

    35.6 C++ classes

    +

    33.6 C++ classes

    @@ -167,7 +167,7 @@ keep track of the pointer object which removes the necessity for a lot of the proxy class baggage you see in other languages.

    -

    35.7 Enumerations

    +

    33.7 Enumerations

    diff --git a/Doc/Manual/Ruby.html b/Doc/Manual/Ruby.html index bda2af60c..a08f497d5 100644 --- a/Doc/Manual/Ruby.html +++ b/Doc/Manual/Ruby.html @@ -7,7 +7,7 @@ -

    33 SWIG and Ruby

    +

    34 SWIG and Ruby

      @@ -148,7 +148,7 @@ -

      33.1 Preliminaries

      +

      34.1 Preliminaries

      SWIG 1.3 is known to work with Ruby versions 1.6 and later. @@ -171,7 +171,7 @@ of Ruby.

      -

      33.1.1 Running SWIG

      +

      34.1.1 Running SWIG

      To build a Ruby module, run SWIG using the -ruby @@ -225,7 +225,7 @@ to compile this file and link it with the rest of your program.

      -

      33.1.2 Getting the right header files

      +

      34.1.2 Getting the right header files

      In order to compile the wrapper code, the compiler needs the ruby.h @@ -274,7 +274,7 @@ installed, you can run Ruby to find out. For example:

      -

      33.1.3 Compiling a dynamic module

      +

      34.1.3 Compiling a dynamic module

      Ruby extension modules are typically compiled into shared @@ -428,7 +428,7 @@ manual pages for your compiler and linker to determine the correct set of options. You might also check the SWIG Wiki for additional information.

      -

      33.1.4 Using your module

      +

      34.1.4 Using your module

      Ruby module names must be capitalized, @@ -488,7 +488,7 @@ begins with:

      -

      33.1.5 Static linking

      +

      34.1.5 Static linking

      An alternative approach to dynamic linking is to rebuild the @@ -509,7 +509,7 @@ finally rebuilding Ruby.

      -

      33.1.6 Compilation of C++ extensions

      +

      34.1.6 Compilation of C++ extensions

      On most machines, C++ extension modules should be linked @@ -561,7 +561,7 @@ extension, e.g.

      -

      33.2 Building Ruby Extensions under Windows 95/NT

      +

      34.2 Building Ruby Extensions under Windows 95/NT

      Building a SWIG extension to Ruby under Windows 95/NT is @@ -600,7 +600,7 @@ files.

      -

      33.2.1 Running SWIG from Developer Studio

      +

      34.2.1 Running SWIG from Developer Studio

      If you are developing your application within Microsoft @@ -742,7 +742,7 @@ directory, then run the Ruby script from the DOS/Command prompt:

      -

      33.3 The Ruby-to-C/C++ Mapping

      +

      34.3 The Ruby-to-C/C++ Mapping

      This section describes the basics of how SWIG maps C or C++ @@ -752,7 +752,7 @@ declarations in your SWIG interface files to Ruby constructs.

      -

      33.3.1 Modules

      +

      34.3.1 Modules

      The SWIG %module directive specifies @@ -921,7 +921,7 @@ Ruby's built-in names.

      -

      33.3.2 Functions

      +

      34.3.2 Functions

      Global functions are wrapped as Ruby module methods. For @@ -984,7 +984,7 @@ module that can be used like so:

      -

      33.3.3 Variable Linking

      +

      34.3.3 Variable Linking

      C/C++ global variables are wrapped as a pair of singleton @@ -1084,7 +1084,7 @@ effect until it is explicitly disabled using %mutable. -

      33.3.4 Constants

      +

      34.3.4 Constants

      C/C++ constants are wrapped as module constants initialized @@ -1128,7 +1128,7 @@ constant values, e.g.

      -

      33.3.5 Pointers

      +

      34.3.5 Pointers

      "Opaque" pointers to arbitrary C/C++ types (i.e. types that @@ -1180,7 +1180,7 @@ the Ruby nil object.

      -

      33.3.6 Structures

      +

      34.3.6 Structures

      C/C++ structs are wrapped as Ruby classes, with accessor @@ -1355,7 +1355,7 @@ pointers. For example,

      -

      33.3.7 C++ classes

      +

      34.3.7 C++ classes

      Like structs, C++ classes are wrapped by creating a new Ruby @@ -1441,7 +1441,7 @@ class. -

      33.3.8 C++ Inheritance

      +

      34.3.8 C++ Inheritance

      The SWIG type-checker is fully aware of C++ inheritance. @@ -1672,7 +1672,7 @@ Typing").

      -

      33.3.9 C++ Overloaded Functions

      +

      34.3.9 C++ Overloaded Functions

      C++ overloaded functions, methods, and constructors are @@ -1872,7 +1872,7 @@ and C++" chapter for more information about overloading.

      -

      33.3.10 C++ Operators

      +

      34.3.10 C++ Operators

      For the most part, overloaded operators are handled @@ -1953,7 +1953,7 @@ on operator overloading.

      -

      33.3.11 C++ namespaces

      +

      34.3.11 C++ namespaces

      SWIG is aware of C++ namespaces, but namespace names do not @@ -2029,7 +2029,7 @@ identical symbol names, well, then you get what you deserve.

      -

      33.3.12 C++ templates

      +

      34.3.12 C++ templates

      C++ templates don't present a huge problem for SWIG. However, @@ -2073,7 +2073,7 @@ directive. For example:

      -

      33.3.13 C++ Standard Template Library (STL)

      +

      34.3.13 C++ Standard Template Library (STL)

      On a related note, the standard SWIG library contains a @@ -2326,7 +2326,7 @@ chapter.

      -

      33.3.14 C++ STL Functors

      +

      34.3.14 C++ STL Functors

      Some containers in the STL allow you to modify their default @@ -2526,7 +2526,7 @@ b
      -

      33.3.15 C++ STL Iterators

      +

      34.3.15 C++ STL Iterators

      The STL is well known for the use of iterators.  There @@ -2737,7 +2737,7 @@ i
      -

      33.3.16 C++ Smart Pointers

      +

      34.3.16 C++ Smart Pointers

      In certain C++ programs, it is common to use classes that @@ -2862,7 +2862,7 @@ method. For example:

      -

      33.3.17 Cross-Language Polymorphism

      +

      34.3.17 Cross-Language Polymorphism

      SWIG's Ruby module supports cross-language polymorphism @@ -2875,7 +2875,7 @@ using this feature with Ruby.

      -

      33.3.17.1 Exception Unrolling

      +

      34.3.17.1 Exception Unrolling

      Whenever a C++ director class routes one of its virtual @@ -2913,7 +2913,7 @@ caught here and a C++ exception is raised in its place.

      -

      33.4 Naming

      +

      34.4 Naming

      Ruby has several common naming conventions. Constants are @@ -3009,7 +3009,7 @@ planned to become the default option in future releases.

      -

      33.4.1 Defining Aliases

      +

      34.4.1 Defining Aliases

      It's a fairly common practice in the Ruby built-ins and @@ -3101,7 +3101,7 @@ Features") for more details).

      -

      33.4.2 Predicate Methods

      +

      34.4.2 Predicate Methods

      Ruby methods that return a boolean value and end in a @@ -3190,7 +3190,7 @@ Features") for more details).

      -

      33.4.3 Bang Methods

      +

      34.4.3 Bang Methods

      Ruby methods that modify an object in-place and end in an @@ -3254,7 +3254,7 @@ Features") for more details).

      -

      33.4.4 Getters and Setters

      +

      34.4.4 Getters and Setters

      Often times a C++ library will expose properties through @@ -3324,7 +3324,7 @@ methods to be exposed in Ruby as value and value=. -

      33.5 Input and output parameters

      +

      34.5 Input and output parameters

      A common problem in some C programs is handling parameters @@ -3575,10 +3575,10 @@ of %apply

      -

      33.6 Exception handling

      +

      34.6 Exception handling

      -

      33.6.1 Using the %exception directive

      +

      34.6.1 Using the %exception directive

      The SWIG %exception directive can be @@ -3673,7 +3673,7 @@ Features for more examples.

      -

      33.6.2 Handling Ruby Blocks

      +

      34.6.2 Handling Ruby Blocks

      One of the highlights of Ruby and most of its standard library @@ -3854,7 +3854,7 @@ RUBY_YIELD_SELF );

      For more information on typemaps, see Typemaps.

      -

      33.6.3 Raising exceptions

      +

      34.6.3 Raising exceptions

      There are three ways to raise exceptions from C++ code to @@ -4615,7 +4615,7 @@ the built-in Ruby exception types.

      -

      33.6.4 Exception classes

      +

      34.6.4 Exception classes

      Starting with SWIG 1.3.28, the Ruby module supports the %exceptionclass @@ -4673,7 +4673,7 @@ providing for a more natural integration between C++ code and Ruby code.

      -

      33.7 Typemaps

      +

      34.7 Typemaps

      This section describes how you can modify SWIG's default @@ -4696,7 +4696,7 @@ of the primitive C-Ruby interface.

      -

      33.7.1 What is a typemap?

      +

      34.7.1 What is a typemap?

      A typemap is nothing more than a code generation rule that is @@ -4958,7 +4958,7 @@ to be used as follows (notice how the length parameter is omitted):

      -

      33.7.2 Typemap scope

      +

      34.7.2 Typemap scope

      Once defined, a typemap remains in effect for all of the @@ -5006,7 +5006,7 @@ where the class itself is defined. For example:

      -

      33.7.3 Copying a typemap

      +

      34.7.3 Copying a typemap

      A typemap is copied by using assignment. For example:

      @@ -5108,7 +5108,7 @@ rules as for -

      33.7.4 Deleting a typemap

      +

      34.7.4 Deleting a typemap

      A typemap can be deleted by simply defining no code. For @@ -5160,7 +5160,7 @@ typemaps immediately after the clear operation.

      -

      33.7.5 Placement of typemaps

      +

      34.7.5 Placement of typemaps

      Typemap declarations can be declared in the global scope, @@ -5244,7 +5244,7 @@ string -

      33.7.6 Ruby typemaps

      +

      34.7.6 Ruby typemaps

      The following list details all of the typemap methods that @@ -5254,7 +5254,7 @@ can be used by the Ruby module:

      -

      33.7.6.1  "in" typemap

      +

      34.7.6.1  "in" typemap

      Converts Ruby objects to input @@ -5497,7 +5497,7 @@ arguments to be specified. For example:

      -

      33.7.6.2 "typecheck" typemap

      +

      34.7.6.2 "typecheck" typemap

      The "typecheck" typemap is used to support overloaded @@ -5538,7 +5538,7 @@ on "Typemaps and Overloading."

      -

      33.7.6.3  "out" typemap

      +

      34.7.6.3  "out" typemap

      Converts return value of a C function @@ -5770,7 +5770,7 @@ version of the C datatype matched by the typemap. -

      33.7.6.4 "arginit" typemap

      +

      34.7.6.4 "arginit" typemap

      The "arginit" typemap is used to set the initial value of a @@ -5795,7 +5795,7 @@ applications. For example:

      -

      33.7.6.5 "default" typemap

      +

      34.7.6.5 "default" typemap

      The "default" typemap is used to turn an argument into a @@ -5837,7 +5837,7 @@ default argument wrapping.

      -

      33.7.6.6 "check" typemap

      +

      34.7.6.6 "check" typemap

      The "check" typemap is used to supply value checking code @@ -5861,7 +5861,7 @@ arguments have been converted. For example:

      -

      33.7.6.7 "argout" typemap

      +

      34.7.6.7 "argout" typemap

      The "argout" typemap is used to return values from arguments. @@ -6019,7 +6019,7 @@ some function like SWIG_Ruby_AppendOutput.

      -

      33.7.6.8 "freearg" typemap

      +

      34.7.6.8 "freearg" typemap

      The "freearg" typemap is used to cleanup argument data. It is @@ -6055,7 +6055,7 @@ abort prematurely.

      -

      33.7.6.9 "newfree" typemap

      +

      34.7.6.9 "newfree" typemap

      The "newfree" typemap is used in conjunction with the %newobject @@ -6086,7 +6086,7 @@ ownership and %newobject for further details.

      -

      33.7.6.10 "memberin" typemap

      +

      34.7.6.10 "memberin" typemap

      The "memberin" typemap is used to copy data from an @@ -6119,7 +6119,7 @@ other objects.

      -

      33.7.6.11 "varin" typemap

      +

      34.7.6.11 "varin" typemap

      The "varin" typemap is used to convert objects in the target @@ -6130,7 +6130,7 @@ This is implementation specific.

      -

      33.7.6.12 "varout" typemap

      +

      34.7.6.12 "varout" typemap

      The "varout" typemap is used to convert a C/C++ object to an @@ -6141,7 +6141,7 @@ This is implementation specific.

      -

      33.7.6.13 "throws" typemap

      +

      34.7.6.13 "throws" typemap

      The "throws" typemap is only used when SWIG parses a C++ @@ -6200,7 +6200,7 @@ handling with %exception section.

      -

      33.7.6.14 directorin typemap

      +

      34.7.6.14 directorin typemap

      Converts C++ objects in director @@ -6454,7 +6454,7 @@ referring to the class itself. -

      33.7.6.15 directorout typemap

      +

      34.7.6.15 directorout typemap

      Converts Ruby objects in director @@ -6714,7 +6714,7 @@ exception.
      -

      33.7.6.16 directorargout typemap

      +

      34.7.6.16 directorargout typemap

      Output argument processing in director @@ -6954,7 +6954,7 @@ referring to the instance of the class itself -

      33.7.6.17 ret typemap

      +

      34.7.6.17 ret typemap

      Cleanup of function return values @@ -6964,7 +6964,7 @@ referring to the instance of the class itself -

      33.7.6.18 globalin typemap

      +

      34.7.6.18 globalin typemap

      Setting of C global variables @@ -6974,7 +6974,7 @@ referring to the instance of the class itself -

      33.7.7 Typemap variables

      +

      34.7.7 Typemap variables

      @@ -7084,7 +7084,7 @@ being created.

    -

    33.7.8 Useful Functions

    +

    34.7.8 Useful Functions

    When you write a typemap, you usually have to work directly @@ -7108,7 +7108,7 @@ across multiple languages.

    -

    33.7.8.1 C Datatypes to Ruby Objects

    +

    34.7.8.1 C Datatypes to Ruby Objects

    @@ -7164,7 +7164,7 @@ SWIG_From_float(float) -

    33.7.8.2 Ruby Objects to C Datatypes

    +

    34.7.8.2 Ruby Objects to C Datatypes

    Here, while the Ruby versions return the value directly, the SWIG @@ -7253,7 +7253,7 @@ Ruby_Format_TypeError( "$1_name", "$1_type","$symname", $argnum, $input -

    33.7.8.3 Macros for VALUE

    +

    34.7.8.3 Macros for VALUE

    RSTRING_LEN(str)

    @@ -7316,7 +7316,7 @@ Ruby_Format_TypeError( "$1_name", "$1_type","$symname", $argnum, $input -

    33.7.8.4 Exceptions

    +

    34.7.8.4 Exceptions

    void rb_raise(VALUE exception, const char *fmt, @@ -7483,7 +7483,7 @@ arguments are interpreted as with printf().

    -

    33.7.8.5 Iterators

    +

    34.7.8.5 Iterators

    void rb_iter_break()

    @@ -7585,7 +7585,7 @@ VALUE), VALUE value)

    -

    33.7.9 Typemap Examples

    +

    34.7.9 Typemap Examples

    This section includes a few examples of typemaps. For more @@ -7596,7 +7596,7 @@ directory.

    -

    33.7.10 Converting a Ruby array to a char **

    +

    34.7.10 Converting a Ruby array to a char **

    A common problem in many C programs is the processing of @@ -7651,7 +7651,7 @@ after the execution of the C function.

    -

    33.7.11 Collecting arguments in a hash

    +

    34.7.11 Collecting arguments in a hash

    Ruby's solution to the "keyword arguments" capability of some @@ -7930,7 +7930,7 @@ directory of the SWIG distribution.

    -

    33.7.12 Pointer handling

    +

    34.7.12 Pointer handling

    Occasionally, it might be necessary to convert pointer values @@ -8029,7 +8029,7 @@ For example:

    -

    33.7.12.1 Ruby Datatype Wrapping

    +

    34.7.12.1 Ruby Datatype Wrapping

    VALUE Data_Wrap_Struct(VALUE class, void @@ -8080,7 +8080,7 @@ and assigns that pointer to ptr.

    -

    33.7.13 Example: STL Vector to Ruby Array

    +

    34.7.13 Example: STL Vector to Ruby Array

    Another use for macros and type maps is to create a Ruby array @@ -8189,7 +8189,7 @@ the C++ Standard Template Library.
    -

    33.8 Docstring Features

    +

    34.8 Docstring Features

    @@ -8250,7 +8250,7 @@ generate ri documentation from a c wrap file, you could do:

    -

    33.8.1 Module docstring

    +

    34.8.1 Module docstring

    @@ -8301,7 +8301,7 @@ macro. For example: -

    33.8.2 %feature("autodoc")

    +

    34.8.2 %feature("autodoc")

    Since SWIG does know everything about the function it wraps, @@ -8330,7 +8330,7 @@ feature, described below. -

    33.8.2.1 %feature("autodoc", "0")

    +

    34.8.2.1 %feature("autodoc", "0")

    @@ -8378,7 +8378,7 @@ Then Ruby code like this will be generated: -

    33.8.2.2 %feature("autodoc", "1")

    +

    34.8.2.2 %feature("autodoc", "1")

    @@ -8410,7 +8410,7 @@ this: -

    33.8.2.3 %feature("autodoc", "2")

    +

    34.8.2.3 %feature("autodoc", "2")

    @@ -8426,7 +8426,7 @@ this: -

    33.8.2.4 %feature("autodoc", "3")

    +

    34.8.2.4 %feature("autodoc", "3")

    @@ -8454,7 +8454,7 @@ this: -

    33.8.2.5 %feature("autodoc", "docstring")

    +

    34.8.2.5 %feature("autodoc", "docstring")

    @@ -8482,7 +8482,7 @@ generated string. For example: -

    33.8.3 %feature("docstring")

    +

    34.8.3 %feature("docstring")

    @@ -8497,10 +8497,10 @@ docstring and they are output together.

    -

    33.9 Advanced Topics

    +

    34.9 Advanced Topics

    -

    33.9.1 Operator overloading

    +

    34.9.1 Operator overloading

    SWIG allows operator overloading with, by using the %extend @@ -9517,7 +9517,7 @@ parses the expression a != b as !(a == b). -

    33.9.2 Creating Multi-Module Packages

    +

    34.9.2 Creating Multi-Module Packages

    The chapter on Working @@ -9698,7 +9698,7 @@ initialized:

    -

    33.9.3 Specifying Mixin Modules

    +

    34.9.3 Specifying Mixin Modules

    The Ruby language doesn't support multiple inheritance, but @@ -9796,7 +9796,7 @@ Features") for more details).

    -

    33.10 Memory Management

    +

    34.10 Memory Management

    One of the most common issues in generating SWIG bindings for @@ -9843,7 +9843,7 @@ understanding of how the underlying library manages memory.

    -

    33.10.1 Mark and Sweep Garbage Collector

    +

    34.10.1 Mark and Sweep Garbage Collector

    Ruby uses a mark and sweep garbage collector. When the garbage @@ -9891,7 +9891,7 @@ this memory.

    -

    33.10.2 Object Ownership

    +

    34.10.2 Object Ownership

    As described above, memory management depends on clearly @@ -10149,7 +10149,7 @@ public: -

    33.10.3 Object Tracking

    +

    34.10.3 Object Tracking

    The remaining parts of this section will use the class library @@ -10400,7 +10400,7 @@ methods.

    -

    33.10.4 Mark Functions

    +

    34.10.4 Mark Functions

    With a bit more testing, we see that our class library still @@ -10518,7 +10518,7 @@ test suite.

    -

    33.10.5 Free Functions

    +

    34.10.5 Free Functions

    By default, SWIG creates a "free" function that is called when @@ -10768,7 +10768,7 @@ been freed, and thus raises a runtime exception.

    -

    33.10.6 Embedded Ruby and the C++ Stack

    +

    34.10.6 Embedded Ruby and the C++ Stack

    As has been said, the Ruby GC runs and marks objects before diff --git a/Doc/Manual/Sections.html b/Doc/Manual/Sections.html index 74d821b17..05282f40c 100644 --- a/Doc/Manual/Sections.html +++ b/Doc/Manual/Sections.html @@ -19,7 +19,7 @@ Last update : SWIG-2.0.1 (4 October 2010)

  • SWIG Basics (Read this!)
  • SWIG and C++
  • The SWIG preprocessor
  • -
  • The SWIG Library
  • +
  • The SWIG library
  • Argument handling
  • Typemaps
  • Customization features
  • @@ -39,8 +39,8 @@ Last update : SWIG-2.0.1 (4 October 2010)
  • Go support
  • Guile support
  • Java support
  • -
  • Lua support
  • Common Lisp support
  • +
  • Lua support
  • Modula3 support
  • MzScheme support
  • Ocaml support
  • @@ -49,8 +49,8 @@ Last update : SWIG-2.0.1 (4 October 2010)
  • PHP support
  • Pike support
  • Python support
  • -
  • Ruby support
  • R support
  • +
  • Ruby support
  • Tcl support
  • diff --git a/Doc/Manual/Tcl.html b/Doc/Manual/Tcl.html index d47dae5de..7a4a85de9 100644 --- a/Doc/Manual/Tcl.html +++ b/Doc/Manual/Tcl.html @@ -6,7 +6,7 @@ -

    34 SWIG and Tcl

    +

    35 SWIG and Tcl

      @@ -83,7 +83,7 @@ Tcl 8.0 or a later release. Earlier releases of SWIG supported Tcl 7.x, but this is no longer supported.

      -

      34.1 Preliminaries

      +

      35.1 Preliminaries

      @@ -109,7 +109,7 @@ build a Tcl extension module. To finish building the module, you need to compile this file and link it with the rest of your program.

      -

      34.1.1 Getting the right header files

      +

      35.1.1 Getting the right header files

      @@ -127,7 +127,7 @@ this is the case, you should probably make a symbolic link so that tcl.h -

      34.1.2 Compiling a dynamic module

      +

      35.1.2 Compiling a dynamic module

      @@ -162,7 +162,7 @@ The name of the module is specified using the %module directive or the -module command line option.

      -

      34.1.3 Static linking

      +

      35.1.3 Static linking

      @@ -228,7 +228,7 @@ minimal in most situations (and quite frankly not worth the extra hassle in the opinion of this author).

      -

      34.1.4 Using your module

      +

      35.1.4 Using your module

      @@ -356,7 +356,7 @@ to the default system configuration (this requires root access and you will need the man pages).

      -

      34.1.5 Compilation of C++ extensions

      +

      35.1.5 Compilation of C++ extensions

      @@ -439,7 +439,7 @@ erratic program behavior. If working with lots of software components, you might want to investigate using a more formal standard such as COM.

      -

      34.1.6 Compiling for 64-bit platforms

      +

      35.1.6 Compiling for 64-bit platforms

      @@ -466,7 +466,7 @@ also introduce problems on platforms that support more than one linking standard (e.g., -o32 and -n32 on Irix).

      -

      34.1.7 Setting a package prefix

      +

      35.1.7 Setting a package prefix

      @@ -485,7 +485,7 @@ option will append the prefix to the name when creating a command and call it "Foo_bar".

      -

      34.1.8 Using namespaces

      +

      35.1.8 Using namespaces

      @@ -507,7 +507,7 @@ When the -namespace option is used, objects in the module are always accessed with the namespace name such as Foo::bar.

      -

      34.2 Building Tcl/Tk Extensions under Windows 95/NT

      +

      35.2 Building Tcl/Tk Extensions under Windows 95/NT

      @@ -518,7 +518,7 @@ covers the process of using SWIG with Microsoft Visual C++. although the procedure may be similar with other compilers.

      -

      34.2.1 Running SWIG from Developer Studio

      +

      35.2.1 Running SWIG from Developer Studio

      @@ -576,7 +576,7 @@ MSDOS > tclsh80 %

    -

    34.2.2 Using NMAKE

    +

    35.2.2 Using NMAKE

    @@ -639,7 +639,7 @@ to get you started. With a little practice, you'll be making lots of Tcl extensions.

    -

    34.3 A tour of basic C/C++ wrapping

    +

    35.3 A tour of basic C/C++ wrapping

    @@ -650,7 +650,7 @@ classes. This section briefly covers the essential aspects of this wrapping.

    -

    34.3.1 Modules

    +

    35.3.1 Modules

    @@ -684,7 +684,7 @@ To fix this, supply an extra argument to load like this: -

    34.3.2 Functions

    +

    35.3.2 Functions

    @@ -709,7 +709,7 @@ like you think it does: % -

    34.3.3 Global variables

    +

    35.3.3 Global variables

    @@ -789,7 +789,7 @@ extern char *path; // Read-only (due to %immutable) -

    34.3.4 Constants and enums

    +

    35.3.4 Constants and enums

    @@ -873,7 +873,7 @@ When an identifier name is given, it is used to perform an implicit hash-table l conversion. This allows the global statement to be omitted.

    -

    34.3.5 Pointers

    +

    35.3.5 Pointers

    @@ -969,7 +969,7 @@ C-style cast may return a bogus result whereas as the C++-style cast will return None if the conversion can't be performed.

    -

    34.3.6 Structures

    +

    35.3.6 Structures

    @@ -1251,7 +1251,7 @@ Note: Tcl only destroys the underlying object if it has ownership. See the memory management section that appears shortly.

    -

    34.3.7 C++ classes

    +

    35.3.7 C++ classes

    @@ -1318,7 +1318,7 @@ In Tcl, the static member is accessed as follows: -

    34.3.8 C++ inheritance

    +

    35.3.8 C++ inheritance

    @@ -1367,7 +1367,7 @@ For instance: It is safe to use multiple inheritance with SWIG.

    -

    34.3.9 Pointers, references, values, and arrays

    +

    35.3.9 Pointers, references, values, and arrays

    @@ -1421,7 +1421,7 @@ to hold the result and a pointer is returned (Tcl will release this memory when the return value is garbage collected).

    -

    34.3.10 C++ overloaded functions

    +

    35.3.10 C++ overloaded functions

    @@ -1544,7 +1544,7 @@ first declaration takes precedence. Please refer to the "SWIG and C++" chapter for more information about overloading.

    -

    34.3.11 C++ operators

    +

    35.3.11 C++ operators

    @@ -1646,7 +1646,7 @@ There are ways to make this operator appear as part of the class using the % Keep reading.

    -

    34.3.12 C++ namespaces

    +

    35.3.12 C++ namespaces

    @@ -1710,7 +1710,7 @@ utilizes thousands of small deeply nested namespaces each with identical symbol names, well, then you get what you deserve.

    -

    34.3.13 C++ templates

    +

    35.3.13 C++ templates

    @@ -1762,7 +1762,7 @@ More details can be found in the SWIG and C++ -

    34.3.14 C++ Smart Pointers

    +

    35.3.14 C++ Smart Pointers

    @@ -1846,7 +1846,7 @@ simply use the __deref__() method. For example: -

    34.4 Further details on the Tcl class interface

    +

    35.4 Further details on the Tcl class interface

    @@ -1859,7 +1859,7 @@ of low-level details were omitted. This section provides a brief overview of how the proxy classes work.

    -

    34.4.1 Proxy classes

    +

    35.4.1 Proxy classes

    @@ -1924,7 +1924,7 @@ function. This allows objects to be encapsulated objects that look a lot like as shown in the last section.

    -

    34.4.2 Memory management

    +

    35.4.2 Memory management

    @@ -2112,7 +2112,7 @@ typemaps--an advanced topic discussed later.

    -

    34.5 Input and output parameters

    +

    35.5 Input and output parameters

    @@ -2300,7 +2300,7 @@ set c [lindex $dim 1] -

    34.6 Exception handling

    +

    35.6 Exception handling

    @@ -2434,7 +2434,7 @@ Since SWIG's exception handling is user-definable, you are not limited to C++ ex See the chapter on "Customization Features" for more examples.

    -

    34.7 Typemaps

    +

    35.7 Typemaps

    @@ -2451,7 +2451,7 @@ Typemaps are only used if you want to change some aspect of the primitive C-Tcl interface.

    -

    34.7.1 What is a typemap?

    +

    35.7.1 What is a typemap?

    @@ -2568,7 +2568,7 @@ parameter is omitted): -

    34.7.2 Tcl typemaps

    +

    35.7.2 Tcl typemaps

    @@ -2706,7 +2706,7 @@ Initialize an argument to a value before any conversions occur. Examples of these methods will appear shortly.

    -

    34.7.3 Typemap variables

    +

    35.7.3 Typemap variables

    @@ -2777,7 +2777,7 @@ properly assigned. The Tcl name of the wrapper function being created. -

    34.7.4 Converting a Tcl list to a char **

    +

    35.7.4 Converting a Tcl list to a char **

    @@ -2839,7 +2839,7 @@ argv[2] = Larry 3 -

    34.7.5 Returning values in arguments

    +

    35.7.5 Returning values in arguments

    @@ -2881,7 +2881,7 @@ result, a Tcl function using these typemaps will work like this : % -

    34.7.6 Useful functions

    +

    35.7.6 Useful functions

    @@ -2958,7 +2958,7 @@ int Tcl_IsShared(Tcl_Obj *obj); -

    34.7.7 Standard typemaps

    +

    35.7.7 Standard typemaps

    @@ -3042,7 +3042,7 @@ work) -

    34.7.8 Pointer handling

    +

    35.7.8 Pointer handling

    @@ -3118,7 +3118,7 @@ For example: -

    34.8 Turning a SWIG module into a Tcl Package.

    +

    35.8 Turning a SWIG module into a Tcl Package.

    @@ -3190,7 +3190,7 @@ As a final note, most SWIG examples do not yet use the to use the load command instead.

    -

    34.9 Building new kinds of Tcl interfaces (in Tcl)

    +

    35.9 Building new kinds of Tcl interfaces (in Tcl)

    @@ -3289,7 +3289,7 @@ danger of blowing something up (although it is easily accomplished with an out of bounds array access).

    -

    34.9.1 Proxy classes

    +

    35.9.1 Proxy classes

    @@ -3410,7 +3410,7 @@ short, but clever Tcl script can be combined with SWIG to do many interesting things.

    -

    34.10 Tcl/Tk Stubs

    +

    35.10 Tcl/Tk Stubs

    diff --git a/Doc/Manual/chapters b/Doc/Manual/chapters index 014029c74..e918e234a 100644 --- a/Doc/Manual/chapters +++ b/Doc/Manual/chapters @@ -30,7 +30,7 @@ Perl5.html Php.html Pike.html Python.html +R.html Ruby.html Tcl.html -R.html Extending.html From 0d49656a54ebb80d488b1d60c702b10c857b3340 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 4 Oct 2010 18:44:38 +0000 Subject: [PATCH 1045/1680] minor tweak to release notes git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12253 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- RELEASENOTES | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RELEASENOTES b/RELEASENOTES index e8ff30285..e07b8a14a 100644 --- a/RELEASENOTES +++ b/RELEASENOTES @@ -6,7 +6,7 @@ Release Notes ============= SWIG-2.0.1 summary: -- New language module: Go +- Go language added to list of supported languages. - New regular expression (regex) encoder for renaming symbols based on the Perl Compatible Regular Expressions (PCRE) library. - Numerous fixes in reporting file and line numbers in error and warning From 2e4cff569953a1eefd4e47d80ca1b1e10afd643b Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 4 Oct 2010 19:16:12 +0000 Subject: [PATCH 1046/1680] minor tweak to release notes git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12254 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- RELEASENOTES | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RELEASENOTES b/RELEASENOTES index e07b8a14a..829cd4d03 100644 --- a/RELEASENOTES +++ b/RELEASENOTES @@ -6,7 +6,7 @@ Release Notes ============= SWIG-2.0.1 summary: -- Go language added to list of supported languages. +- Support for the Go language has been added. - New regular expression (regex) encoder for renaming symbols based on the Perl Compatible Regular Expressions (PCRE) library. - Numerous fixes in reporting file and line numbers in error and warning From 9b3d2ec9b0c7a02b9e85058821cb820057544851 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 4 Oct 2010 19:30:15 +0000 Subject: [PATCH 1047/1680] Add missing Go language CHANGES entry git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12255 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 9b02c475f..bbaf8443a 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -175,6 +175,9 @@ Version 2.0.1 (4 October 2010) Fix #3024875 - shared_ptr of classes with non-public destructors. This also fixes the "unref" feature when used on classes with non-public destructors. +2010-06-17: ianlancetaylor + [Go] Add the Go language module. + 2010-06-10: wsfulton [Lua] Fix SWIG_lua_isnilstring multiply defined when using multiple modules and wrapping strings. Patch from 'Number Cruncher'. From aabd75f3d83b365850e3c1c4fa77a471b2231914 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 4 Oct 2010 19:30:53 +0000 Subject: [PATCH 1048/1680] New major contributors git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12256 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- COPYRIGHT | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/COPYRIGHT b/COPYRIGHT index 40d09a1d6..1e5d080d4 100644 --- a/COPYRIGHT +++ b/COPYRIGHT @@ -42,7 +42,7 @@ Past SWIG developers and major contributors include: 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) + Ahmon Dancy (dancy@franz.com) (Allegro CL) Dirk Gerrits (Allegro CL) Neil Cawse (C#) Harco de Hilster (Java) @@ -55,6 +55,8 @@ Past SWIG developers and major contributors include: 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) + Ian Lance Taylor (Go) + Vadim Zeitlin (PCRE) Past contributors include: James Michael DuPont, Clark McGrew, Dustin Mitchell, Ian Cooke, Catalin Dumitrescu, Baran From a56ee9cb1bcdea85480e2678aff97c14c9aa1856 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 5 Oct 2010 06:11:50 +0000 Subject: [PATCH 1049/1680] Bump version to 2.0.2 and move CHANGES.current to CHANGES git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12260 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- ANNOUNCE | 2 +- CHANGES | 189 +++++++++++++++++++++++++++++++++++++++ CHANGES.current | 189 +-------------------------------------- Doc/Manual/Sections.html | 2 +- README | 2 +- configure.in | 2 +- 6 files changed, 195 insertions(+), 191 deletions(-) diff --git a/ANNOUNCE b/ANNOUNCE index d14a77042..cdf246e07 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -1,4 +1,4 @@ -*** ANNOUNCE: SWIG 2.0.1 (4 October 2010) *** +*** ANNOUNCE: SWIG 2.0.2 (in progress) *** http://www.swig.org diff --git a/CHANGES b/CHANGES index f243ff7c6..bf5e20da1 100644 --- a/CHANGES +++ b/CHANGES @@ -3,6 +3,195 @@ SWIG (Simplified Wrapper and Interface Generator) See the CHANGES.current file for changes in the current version. See the RELEASENOTES file for a summary of changes in each release. +Version 2.0.1 (4 October 2010) +============================== + +2010-10-03: wsfulton + Apply patch #3066958 from Mikael Johansson to fix default smart pointer + handling when the smart pointer contains both a const and non-const operator->. + +2010-10-01: wsfulton + Add -pcreversion option to display PCRE version information. + +2010-10-01: olly + [Ruby] Avoid segfault when a method node has no parentNode + (SF#3034054). + +2010-10-01: olly + [Python] Allow reinitialisation to work with an embedded Python + interpreter (patch from Jim Carroll in SF#3075178). + +2010-09-28: wsfulton + [C#] Apply patch from Tomas Dirvanauskas for std::map wrappers to avoid + throwing exceptions with normal usage of iterators. + +2010-09-27: olly + [Python] Improve error message given when a parameter of the wrong + type is passed to an overloaded method (SF#3027355). + +2010-09-25: wsfulton + Apply SF patch #3075150 - Java directors using static variables in + named namespace. + +2010-09-24: wsfulton + More file and line error/warning reporting fixes where SWIG macros + are used within {} braces (where the preprocessor expands macros), + for example macros within %inline {...} and %fragment(...) {...} + and nested structs. + +2010-09-18: wsfulton + More file and line error/warning reporting fixes for various inherited + class problems. + +2010-09-15: wsfulton + A much improved debugging of SWIG source experience is now available and + documented in the "Debugging SWIG" section in the Doc/Devel/internals.html + file, including a swig.dbg support file for the gdb debugger. + +2010-09-11: wsfulton + Fix incorrect line number reporting in errors/warnings when a macro + definition ends with '/' and it is not the end of a C comment. + +2010-09-11: wsfulton + Fix incorrect line number reporting in errors/warnings after parsing + macro invocations with parameters given over more than one line. + +2010-09-10: wsfulton + Remove extraneous extra line in preprocessed output after including files + which would sometimes lead to error/warning messages two lines after the + end of the file. + +2010-09-10: wsfulton + Fix #2149523 - Incorrect line number reporting in errors after parsing macros + containing C++ comments. + +2010-09-08: olly + [PHP] Fix handling of OUTPUT typemaps (Patch from Ryan in SF#3058394). + +2010-09-03: wsfulton + Fix erroneous line numbers in error messages for macro expansions, for example, + the error message now points to instantiation of the macro, ie the last line here: + + #define MACRO2(a, b) + + #define MACRO1(NAME) MACRO2(NAME,2,3) + + MACRO1(abc) + +2010-09-02: wsfulton + Fix line numbers in error and warning messages for preprocessor messages within + %inline, for example: + + %inline %{ + #define FOOBAR 1 + #define FOOBAR "hi" + %} + +2010-09-02: wsfulton + Fix line numbers in error and warning messages which were cumulatively one + less than they should have been after parsing each %include/%import - bug + introduced in swig-1.3.32. Also fix line numbers in error and warning messages + when new line characters appear between the %include / %import statement and + the filename. + +2010-08-30: wsfulton + Fix line number and file name reporting for some macro preprocessor warnings. + The line number of the macro argument has been corrected and the line number + of the start of the macro instead of one past the end of the macro is used. + Some examples: + file.h:11: Error: Illegal macro argument name '..' + file.h:19: Error: Macro 'DUPLICATE' redefined, + file.h:15: Error: previous definition of 'DUPLICATE'. + file.h:25: Error: Variable-length macro argument must be last parameter + file.h:32: Error: Illegal character in macro argument name + file.i:37: Error: Macro 'SIT' expects 2 arguments + +2010-08-26: wsfulton + Fix __LINE__ and __FILE__ expansion reported by Camille Gillot. Mostly this + did not work at all. Also fixes SF #2822822. + +2010-08-17: wsfulton + [Perl] Fix corner case marshalling of doubles - errno was not being correctly + set before calling strtod - patch from Justin Vallon - SF Bug #3038936. + +2010-08-17: wsfulton + Fix make distclean when some of the more obscure languages are detected by + configure - fixes from Torsten Landschoff. + +2010-07-28: wsfulton + Restore configuring out of source for the test-suite since it broke in 1.3.37. + As previously, if running 'make check-test-suite' out of source, it needs to be + done by invoking configure with a relative path. Invoking configure with an + absolute path will not work. Running the full 'make check' still needs to be + done in the source tree. + +2010-07-16: wsfulton + Fix wrapping of function pointers and member function pointers when the function + returns by reference. + +2010-07-13: vadz + Removed support for the old experimental "rxspencer" encoder and + "[not]rxsmatch" in %rename (see the 01/16/2006 entry). The new and + officially supported "regex" encoder and "[not]regexmatch" checks + should be used instead (see the two previous entries). Please + replace "%(rxspencer:[pat][subst])s" with "%(regex:/pat/subst/)s" + when upgrading. Notice that you will also need to replace the back- + references of form "@1" with the more standard "\\1" and may need to + adjust your regular expressions syntax as the new regex encoder uses + Perl-compatible syntax and not (extended) POSIX syntax as the old one. + + *** POTENTIAL INCOMPATIBILITY *** + +2010-07-13: vadz + Add "regexmatch", "regextarget" and "notregexmatch" which can be + used to apply %rename directives to the declarations matching the + specified regular expression only. The first two can be used + interchangeably, both of the %renames below do the same thing: + + %rename("$ignore", regexmatch$name="Old$") ""; + %rename("$ignore", regextarget=1) "Old$"; + + (namely ignore the declarations having "Old" suffix). + + "notregexmatch" restricts the match to only the declarations which + do not match the regular expression, e.g. here is how to rename to + lower case versions all declarations except those consisting from + capital letters only: + + %rename("$(lowercase)s", notregexmatch$name="^[A-Z]+$") ""; + +2010-07-13: vadz + Add the new "regex" encoder that can be used in %rename, e.g. + + %rename("regex:/(\\w+)_(.*)/\\2/") ""; + + to remove any alphabetical prefix from all identifiers. The syntax + of the regular expressions is Perl-like and PCRE library + (http://www.pcre.org/) is used to implement this feature but notice + that backslashes need to be escaped as usual inside C strings. + + Original patch from Torsten Landschoff. + +2010-07-08: wsfulton + Fix #3024875 - shared_ptr of classes with non-public destructors. This also fixes + the "unref" feature when used on classes with non-public destructors. + +2010-06-17: ianlancetaylor + [Go] Add the Go language module. + +2010-06-10: wsfulton + [Lua] Fix SWIG_lua_isnilstring multiply defined when using multiple + modules and wrapping strings. Patch from 'Number Cruncher'. + +2010-06-10: olly + [PHP] Fix directors to correctly call a method with has a + different name in PHP to C++ (we were always using the C++ name + in this case). + +2010-06-03: wsfulton + Fix uncompileable code when %rename results in two enum items + with the same name. Reported by Vadim Zeitlin. + Version 2.0.0 (2 June 2010) =========================== diff --git a/CHANGES.current b/CHANGES.current index bbaf8443a..26977a25d 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -2,191 +2,6 @@ This file contains the changes for the current release. See the CHANGES file for changes in older releases. See the RELEASENOTES file for a summary of changes in each release. -Version 2.0.1 (4 October 2010) -============================== +Version 2.0.2 (in progress) +=========================== -2010-10-03: wsfulton - Apply patch #3066958 from Mikael Johansson to fix default smart pointer - handling when the smart pointer contains both a const and non-const operator->. - -2010-10-01: wsfulton - Add -pcreversion option to display PCRE version information. - -2010-10-01: olly - [Ruby] Avoid segfault when a method node has no parentNode - (SF#3034054). - -2010-10-01: olly - [Python] Allow reinitialisation to work with an embedded Python - interpreter (patch from Jim Carroll in SF#3075178). - -2010-09-28: wsfulton - [C#] Apply patch from Tomas Dirvanauskas for std::map wrappers to avoid - throwing exceptions with normal usage of iterators. - -2010-09-27: olly - [Python] Improve error message given when a parameter of the wrong - type is passed to an overloaded method (SF#3027355). - -2010-09-25: wsfulton - Apply SF patch #3075150 - Java directors using static variables in - named namespace. - -2010-09-24: wsfulton - More file and line error/warning reporting fixes where SWIG macros - are used within {} braces (where the preprocessor expands macros), - for example macros within %inline {...} and %fragment(...) {...} - and nested structs. - -2010-09-18: wsfulton - More file and line error/warning reporting fixes for various inherited - class problems. - -2010-09-15: wsfulton - A much improved debugging of SWIG source experience is now available and - documented in the "Debugging SWIG" section in the Doc/Devel/internals.html - file, including a swig.dbg support file for the gdb debugger. - -2010-09-11: wsfulton - Fix incorrect line number reporting in errors/warnings when a macro - definition ends with '/' and it is not the end of a C comment. - -2010-09-11: wsfulton - Fix incorrect line number reporting in errors/warnings after parsing - macro invocations with parameters given over more than one line. - -2010-09-10: wsfulton - Remove extraneous extra line in preprocessed output after including files - which would sometimes lead to error/warning messages two lines after the - end of the file. - -2010-09-10: wsfulton - Fix #2149523 - Incorrect line number reporting in errors after parsing macros - containing C++ comments. - -2010-09-08: olly - [PHP] Fix handling of OUTPUT typemaps (Patch from Ryan in SF#3058394). - -2010-09-03: wsfulton - Fix erroneous line numbers in error messages for macro expansions, for example, - the error message now points to instantiation of the macro, ie the last line here: - - #define MACRO2(a, b) - - #define MACRO1(NAME) MACRO2(NAME,2,3) - - MACRO1(abc) - -2010-09-02: wsfulton - Fix line numbers in error and warning messages for preprocessor messages within - %inline, for example: - - %inline %{ - #define FOOBAR 1 - #define FOOBAR "hi" - %} - -2010-09-02: wsfulton - Fix line numbers in error and warning messages which were cumulatively one - less than they should have been after parsing each %include/%import - bug - introduced in swig-1.3.32. Also fix line numbers in error and warning messages - when new line characters appear between the %include / %import statement and - the filename. - -2010-08-30: wsfulton - Fix line number and file name reporting for some macro preprocessor warnings. - The line number of the macro argument has been corrected and the line number - of the start of the macro instead of one past the end of the macro is used. - Some examples: - file.h:11: Error: Illegal macro argument name '..' - file.h:19: Error: Macro 'DUPLICATE' redefined, - file.h:15: Error: previous definition of 'DUPLICATE'. - file.h:25: Error: Variable-length macro argument must be last parameter - file.h:32: Error: Illegal character in macro argument name - file.i:37: Error: Macro 'SIT' expects 2 arguments - -2010-08-26: wsfulton - Fix __LINE__ and __FILE__ expansion reported by Camille Gillot. Mostly this - did not work at all. Also fixes SF #2822822. - -2010-08-17: wsfulton - [Perl] Fix corner case marshalling of doubles - errno was not being correctly - set before calling strtod - patch from Justin Vallon - SF Bug #3038936. - -2010-08-17: wsfulton - Fix make distclean when some of the more obscure languages are detected by - configure - fixes from Torsten Landschoff. - -2010-07-28: wsfulton - Restore configuring out of source for the test-suite since it broke in 1.3.37. - As previously, if running 'make check-test-suite' out of source, it needs to be - done by invoking configure with a relative path. Invoking configure with an - absolute path will not work. Running the full 'make check' still needs to be - done in the source tree. - -2010-07-16: wsfulton - Fix wrapping of function pointers and member function pointers when the function - returns by reference. - -2010-07-13: vadz - Removed support for the old experimental "rxspencer" encoder and - "[not]rxsmatch" in %rename (see the 01/16/2006 entry). The new and - officially supported "regex" encoder and "[not]regexmatch" checks - should be used instead (see the two previous entries). Please - replace "%(rxspencer:[pat][subst])s" with "%(regex:/pat/subst/)s" - when upgrading. Notice that you will also need to replace the back- - references of form "@1" with the more standard "\\1" and may need to - adjust your regular expressions syntax as the new regex encoder uses - Perl-compatible syntax and not (extended) POSIX syntax as the old one. - - *** POTENTIAL INCOMPATIBILITY *** - -2010-07-13: vadz - Add "regexmatch", "regextarget" and "notregexmatch" which can be - used to apply %rename directives to the declarations matching the - specified regular expression only. The first two can be used - interchangeably, both of the %renames below do the same thing: - - %rename("$ignore", regexmatch$name="Old$") ""; - %rename("$ignore", regextarget=1) "Old$"; - - (namely ignore the declarations having "Old" suffix). - - "notregexmatch" restricts the match to only the declarations which - do not match the regular expression, e.g. here is how to rename to - lower case versions all declarations except those consisting from - capital letters only: - - %rename("$(lowercase)s", notregexmatch$name="^[A-Z]+$") ""; - -2010-07-13: vadz - Add the new "regex" encoder that can be used in %rename, e.g. - - %rename("regex:/(\\w+)_(.*)/\\2/") ""; - - to remove any alphabetical prefix from all identifiers. The syntax - of the regular expressions is Perl-like and PCRE library - (http://www.pcre.org/) is used to implement this feature but notice - that backslashes need to be escaped as usual inside C strings. - - Original patch from Torsten Landschoff. - -2010-07-08: wsfulton - Fix #3024875 - shared_ptr of classes with non-public destructors. This also fixes - the "unref" feature when used on classes with non-public destructors. - -2010-06-17: ianlancetaylor - [Go] Add the Go language module. - -2010-06-10: wsfulton - [Lua] Fix SWIG_lua_isnilstring multiply defined when using multiple - modules and wrapping strings. Patch from 'Number Cruncher'. - -2010-06-10: olly - [PHP] Fix directors to correctly call a method with has a - different name in PHP to C++ (we were always using the C++ name - in this case). - -2010-06-03: wsfulton - Fix uncompileable code when %rename results in two enum items - with the same name. Reported by Vadim Zeitlin. diff --git a/Doc/Manual/Sections.html b/Doc/Manual/Sections.html index 05282f40c..855244790 100644 --- a/Doc/Manual/Sections.html +++ b/Doc/Manual/Sections.html @@ -6,7 +6,7 @@

    SWIG-2.0 Documentation

    -Last update : SWIG-2.0.1 (4 October 2010) +Last update : SWIG-2.0.2 (in progress)

    Sections

    diff --git a/README b/README index 085fafd7e..975870626 100644 --- a/README +++ b/README @@ -1,6 +1,6 @@ SWIG (Simplified Wrapper and Interface Generator) -Version: 2.0.1 (4 October 2010) +Version: 2.0.2 (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 2976aca66..36337b41d 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],[2.0.1],[http://www.swig.org]) +AC_INIT([swig],[2.0.2],[http://www.swig.org]) dnl NB: When this requirement is increased to 2.60 or later, AC_PROG_SED dnl definition below can be removed From a4a56acd33cae770a6aacba0df72a6147b611aa1 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 7 Oct 2010 06:06:12 +0000 Subject: [PATCH 1050/1680] dos to unix fileformatting git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12261 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/csharp/wchar.i | 204 ++++++++++++++++++++++----------------------- 1 file changed, 102 insertions(+), 102 deletions(-) diff --git a/Lib/csharp/wchar.i b/Lib/csharp/wchar.i index f02c09a53..1d95edded 100644 --- a/Lib/csharp/wchar.i +++ b/Lib/csharp/wchar.i @@ -1,102 +1,102 @@ -/* ----------------------------------------------------------------------------- - * wchar.i - * - * Typemaps for the wchar_t type - * These are mapped to a C# String and are passed around by value. - * - * Support code for wide strings can be turned off by defining SWIG_CSHARP_NO_WSTRING_HELPER - * - * ----------------------------------------------------------------------------- */ - -#if !defined(SWIG_CSHARP_NO_WSTRING_HELPER) -#if !defined(SWIG_CSHARP_WSTRING_HELPER_) -#define SWIG_CSHARP_WSTRING_HELPER_ -%insert(runtime) %{ -/* Callback for returning strings to C# without leaking memory */ -typedef void * (SWIGSTDCALL* SWIG_CSharpWStringHelperCallback)(const wchar_t *); -static SWIG_CSharpWStringHelperCallback SWIG_csharp_wstring_callback = NULL; -%} - -%pragma(csharp) imclasscode=%{ - protected class SWIGWStringHelper { - - public delegate string SWIGWStringDelegate(IntPtr message); - static SWIGWStringDelegate wstringDelegate = new SWIGWStringDelegate(CreateWString); - - [DllImport("$dllimport", EntryPoint="SWIGRegisterWStringCallback_$module")] - public static extern void SWIGRegisterWStringCallback_$module(SWIGWStringDelegate wstringDelegate); - - static string CreateWString([MarshalAs(UnmanagedType.LPWStr)]IntPtr cString) { - return System.Runtime.InteropServices.Marshal.PtrToStringUni(cString); - } - - static SWIGWStringHelper() { - SWIGRegisterWStringCallback_$module(wstringDelegate); - } - } - - static protected SWIGWStringHelper swigWStringHelper = new SWIGWStringHelper(); -%} - -%insert(runtime) %{ -#ifdef __cplusplus -extern "C" -#endif -SWIGEXPORT void SWIGSTDCALL SWIGRegisterWStringCallback_$module(SWIG_CSharpWStringHelperCallback callback) { - SWIG_csharp_wstring_callback = callback; -} -%} -#endif // SWIG_CSHARP_WSTRING_HELPER_ -#endif // SWIG_CSHARP_NO_WSTRING_HELPER - - -// wchar_t -%typemap(ctype) wchar_t "wchar_t" -%typemap(imtype) wchar_t "char" -%typemap(cstype) wchar_t "char" - -%typemap(csin) wchar_t "$csinput" -%typemap(csout, excode=SWIGEXCODE) wchar_t { - char ret = $imcall;$excode - return ret; - } -%typemap(csvarin, excode=SWIGEXCODE2) wchar_t %{ - set { - $imcall;$excode - } %} -%typemap(csvarout, excode=SWIGEXCODE2) wchar_t %{ - get { - char ret = $imcall;$excode - return ret; - } %} - -%typemap(in) wchar_t %{ $1 = ($1_ltype)$input; %} -%typemap(out) wchar_t %{ $result = (wchar_t)$1; %} - -%typemap(typecheck) wchar_t = char; - -// wchar_t * -%typemap(ctype) wchar_t * "wchar_t *" -%typemap(imtype, inattributes="[MarshalAs(UnmanagedType.LPWStr)]", out="IntPtr" ) wchar_t * "string" -%typemap(cstype) wchar_t * "string" - -%typemap(csin) wchar_t * "$csinput" -%typemap(csout, excode=SWIGEXCODE) wchar_t * { - string ret = System.Runtime.InteropServices.Marshal.PtrToStringUni($imcall);$excode - return ret; - } -%typemap(csvarin, excode=SWIGEXCODE2) wchar_t * %{ - set { - $imcall;$excode - } %} -%typemap(csvarout, excode=SWIGEXCODE2) wchar_t * %{ - get { - string ret = $imcall;$excode - return ret; - } %} - -%typemap(in) wchar_t * %{ $1 = ($1_ltype)$input; %} -%typemap(out) wchar_t * %{ $result = (wchar_t *)$1; %} - -%typemap(typecheck) wchar_t * = char *; - +/* ----------------------------------------------------------------------------- + * wchar.i + * + * Typemaps for the wchar_t type + * These are mapped to a C# String and are passed around by value. + * + * Support code for wide strings can be turned off by defining SWIG_CSHARP_NO_WSTRING_HELPER + * + * ----------------------------------------------------------------------------- */ + +#if !defined(SWIG_CSHARP_NO_WSTRING_HELPER) +#if !defined(SWIG_CSHARP_WSTRING_HELPER_) +#define SWIG_CSHARP_WSTRING_HELPER_ +%insert(runtime) %{ +/* Callback for returning strings to C# without leaking memory */ +typedef void * (SWIGSTDCALL* SWIG_CSharpWStringHelperCallback)(const wchar_t *); +static SWIG_CSharpWStringHelperCallback SWIG_csharp_wstring_callback = NULL; +%} + +%pragma(csharp) imclasscode=%{ + protected class SWIGWStringHelper { + + public delegate string SWIGWStringDelegate(IntPtr message); + static SWIGWStringDelegate wstringDelegate = new SWIGWStringDelegate(CreateWString); + + [DllImport("$dllimport", EntryPoint="SWIGRegisterWStringCallback_$module")] + public static extern void SWIGRegisterWStringCallback_$module(SWIGWStringDelegate wstringDelegate); + + static string CreateWString([MarshalAs(UnmanagedType.LPWStr)]IntPtr cString) { + return System.Runtime.InteropServices.Marshal.PtrToStringUni(cString); + } + + static SWIGWStringHelper() { + SWIGRegisterWStringCallback_$module(wstringDelegate); + } + } + + static protected SWIGWStringHelper swigWStringHelper = new SWIGWStringHelper(); +%} + +%insert(runtime) %{ +#ifdef __cplusplus +extern "C" +#endif +SWIGEXPORT void SWIGSTDCALL SWIGRegisterWStringCallback_$module(SWIG_CSharpWStringHelperCallback callback) { + SWIG_csharp_wstring_callback = callback; +} +%} +#endif // SWIG_CSHARP_WSTRING_HELPER_ +#endif // SWIG_CSHARP_NO_WSTRING_HELPER + + +// wchar_t +%typemap(ctype) wchar_t "wchar_t" +%typemap(imtype) wchar_t "char" +%typemap(cstype) wchar_t "char" + +%typemap(csin) wchar_t "$csinput" +%typemap(csout, excode=SWIGEXCODE) wchar_t { + char ret = $imcall;$excode + return ret; + } +%typemap(csvarin, excode=SWIGEXCODE2) wchar_t %{ + set { + $imcall;$excode + } %} +%typemap(csvarout, excode=SWIGEXCODE2) wchar_t %{ + get { + char ret = $imcall;$excode + return ret; + } %} + +%typemap(in) wchar_t %{ $1 = ($1_ltype)$input; %} +%typemap(out) wchar_t %{ $result = (wchar_t)$1; %} + +%typemap(typecheck) wchar_t = char; + +// wchar_t * +%typemap(ctype) wchar_t * "wchar_t *" +%typemap(imtype, inattributes="[MarshalAs(UnmanagedType.LPWStr)]", out="IntPtr" ) wchar_t * "string" +%typemap(cstype) wchar_t * "string" + +%typemap(csin) wchar_t * "$csinput" +%typemap(csout, excode=SWIGEXCODE) wchar_t * { + string ret = System.Runtime.InteropServices.Marshal.PtrToStringUni($imcall);$excode + return ret; + } +%typemap(csvarin, excode=SWIGEXCODE2) wchar_t * %{ + set { + $imcall;$excode + } %} +%typemap(csvarout, excode=SWIGEXCODE2) wchar_t * %{ + get { + string ret = $imcall;$excode + return ret; + } %} + +%typemap(in) wchar_t * %{ $1 = ($1_ltype)$input; %} +%typemap(out) wchar_t * %{ $result = (wchar_t *)$1; %} + +%typemap(typecheck) wchar_t * = char *; + From c9ede7e62278085ce4560f8ff1ff227d11e6d4a6 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 13 Oct 2010 05:48:59 +0000 Subject: [PATCH 1051/1680] Fix unary scope operator (::) (global scope) regression introduced in 2.0.0. The mangled symbol names were incorrect, sometimes resulting in types being incorrectly treated as opaque types. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12264 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++ Examples/test-suite/global_namespace.i | 22 ++++++++++ .../java/global_namespace_runme.java | 34 +++++++++++++++- .../python/global_namespace_runme.py | 40 +++++++++++++++++++ Source/Swig/stype.c | 11 ++--- 5 files changed, 104 insertions(+), 7 deletions(-) create mode 100644 Examples/test-suite/python/global_namespace_runme.py diff --git a/CHANGES.current b/CHANGES.current index 26977a25d..2a9de5cf1 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,3 +5,7 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.2 (in progress) =========================== +2010-10-12: wsfulton + Fix unary scope operator (::) (global scope) regression introduced in 2.0.0, reported by + Ben Walker. The mangled symbol names were incorrect, sometimes resulting in types being + incorrectly treated as opaque types. diff --git a/Examples/test-suite/global_namespace.i b/Examples/test-suite/global_namespace.i index 7b575614f..37195c76b 100644 --- a/Examples/test-suite/global_namespace.i +++ b/Examples/test-suite/global_namespace.i @@ -58,3 +58,25 @@ struct TheEnumMethods { } %} +%inline %{ +Klass1 getKlass1A() { return ::Klass1(); } +::Klass1 getKlass1B() { return ::Klass1(); } + +Klass2 getKlass2A() { return ::Klass2(); } +::Klass2 getKlass2B() { return ::Klass2(); } + +Klass3 getKlass3A() { return ::Klass3(); } +::Klass3 getKlass3B() { return ::Klass3(); } + +Klass4 getKlass4A() { return ::Klass4(); } +::Klass4 getKlass4B() { return ::Klass4(); } + +Klass5 getKlass5A() { return ::Klass5(); } +::Klass5 getKlass5B() { return ::Klass5(); } + +Klass6 getKlass6A() { return ::Klass6(); } +::Klass6 getKlass6B() { return ::Klass6(); } + +Klass7 getKlass7A() { return ::Klass7(); } +::Klass7 getKlass7B() { return ::Klass7(); } +%} diff --git a/Examples/test-suite/java/global_namespace_runme.java b/Examples/test-suite/java/global_namespace_runme.java index faab7d4ba..205e149b0 100644 --- a/Examples/test-suite/java/global_namespace_runme.java +++ b/Examples/test-suite/java/global_namespace_runme.java @@ -13,8 +13,38 @@ public class global_namespace_runme { public static void main(String argv[]) { - KlassMethods.methodA(new Klass1(), new Klass2(), new Klass3(), new Klass4(), new Klass5(), new Klass6(), new Klass7()); - KlassMethods.methodB(new Klass1(), new Klass2(), new Klass3(), new Klass4(), new Klass5(), new Klass6(), new Klass7()); + Klass1 k1 = new Klass1(); + Klass2 k2 = new Klass2(); + Klass3 k3 = new Klass3(); + Klass4 k4 = new Klass4(); + Klass5 k5 = new Klass5(); + Klass6 k6 = new Klass6(); + Klass7 k7 = new Klass7(); + + KlassMethods.methodA(k1, k2, k3, k4, k5, k6, k7); + KlassMethods.methodB(k1, k2, k3, k4, k5, k6, k7); + + k1 = global_namespace.getKlass1A(); + k2 = global_namespace.getKlass2A(); + k3 = global_namespace.getKlass3A(); + k4 = global_namespace.getKlass4A(); + k5 = global_namespace.getKlass5A(); + k6 = global_namespace.getKlass6A(); + k7 = global_namespace.getKlass7A(); + + KlassMethods.methodA(k1, k2, k3, k4, k5, k6, k7); + KlassMethods.methodB(k1, k2, k3, k4, k5, k6, k7); + + k1 = global_namespace.getKlass1B(); + k2 = global_namespace.getKlass2B(); + k3 = global_namespace.getKlass3B(); + k4 = global_namespace.getKlass4B(); + k5 = global_namespace.getKlass5B(); + k6 = global_namespace.getKlass6B(); + k7 = global_namespace.getKlass7B(); + + KlassMethods.methodA(k1, k2, k3, k4, k5, k6, k7); + KlassMethods.methodB(k1, k2, k3, k4, k5, k6, k7); XYZMethods.methodA(new XYZ1(), new XYZ2(), new XYZ3(), new XYZ4(), new XYZ5(), new XYZ6(), new XYZ7()); XYZMethods.methodB(new XYZ1(), new XYZ2(), new XYZ3(), new XYZ4(), new XYZ5(), new XYZ6(), new XYZ7()); diff --git a/Examples/test-suite/python/global_namespace_runme.py b/Examples/test-suite/python/global_namespace_runme.py new file mode 100644 index 000000000..b64e75ca1 --- /dev/null +++ b/Examples/test-suite/python/global_namespace_runme.py @@ -0,0 +1,40 @@ +from global_namespace import * + +k1 = Klass1() +k2 = Klass2() +k3 = Klass3() +k4 = Klass4() +k5 = Klass5() +k6 = Klass6() +k7 = Klass7() + +KlassMethods.methodA(k1, k2, k3, k4, k5, k6, k7) +KlassMethods.methodB(k1, k2, k3, k4, k5, k6, k7) + +k1 = getKlass1A() +k2 = getKlass2A() +k3 = getKlass3A() +k4 = getKlass4A() +k5 = getKlass5A() +k6 = getKlass6A() +k7 = getKlass7A() + +KlassMethods.methodA(k1, k2, k3, k4, k5, k6, k7) +KlassMethods.methodB(k1, k2, k3, k4, k5, k6, k7) + +k1 = getKlass1B() +k2 = getKlass2B() +k3 = getKlass3B() +k4 = getKlass4B() +k5 = getKlass5B() +k6 = getKlass6B() +k7 = getKlass7B() + +KlassMethods.methodA(k1, k2, k3, k4, k5, k6, k7) +KlassMethods.methodB(k1, k2, k3, k4, k5, k6, k7) + +XYZMethods.methodA(XYZ1(), XYZ2(), XYZ3(), XYZ4(), XYZ5(), XYZ6(), XYZ7()) +XYZMethods.methodB(XYZ1(), XYZ2(), XYZ3(), XYZ4(), XYZ5(), XYZ6(), XYZ7()) + +TheEnumMethods.methodA(theenum1, theenum2, theenum3) +TheEnumMethods.methodA(theenum1, theenum2, theenum3) diff --git a/Source/Swig/stype.c b/Source/Swig/stype.c index dd2aea688..a13f87cfc 100644 --- a/Source/Swig/stype.c +++ b/Source/Swig/stype.c @@ -906,8 +906,9 @@ String *SwigType_manglestr_default(SwigType *s) { String *result = 0; String *base = 0; SwigType *lt; - SwigType *sr = SwigType_typedef_qualified(s); - SwigType *ss = SwigType_typedef_resolve_all(sr); + SwigType *sr = SwigType_typedef_resolve_all(s); + SwigType *sq = SwigType_typedef_qualified(sr); + SwigType *ss = SwigType_remove_global_scope_prefix(sq); s = ss; @@ -917,7 +918,6 @@ String *SwigType_manglestr_default(SwigType *s) { ss = ty; s = ss; } - Delete(sr); lt = SwigType_ltype(s); result = SwigType_prefix(lt); @@ -966,8 +966,9 @@ String *SwigType_manglestr_default(SwigType *s) { Insert(result, 0, "_"); Delete(lt); Delete(base); - if (ss) - Delete(ss); + Delete(ss); + Delete(sq); + Delete(sr); return result; } From 9eaf5ba1be143ea16eb7bfc096122be3c7bead19 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Thu, 14 Oct 2010 05:13:09 +0000 Subject: [PATCH 1052/1680] [PHP] Allow compilation on non-conforming Microsoft C++ compilers which don't accept: return function_returning_void(); Reported by Frank Vanden Berghen on the SWIG mailing list. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12265 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 5 +++++ Source/Modules/php.cxx | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index 2a9de5cf1..5a7493206 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,11 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.2 (in progress) =========================== +2010-10-14: olly + [PHP] Allow compilation on non-conforming Microsoft C++ compilers + which don't accept: return function_returning_void(); + Reported by Frank Vanden Berghen on the SWIG mailing list. + 2010-10-12: wsfulton Fix unary scope operator (::) (global scope) regression introduced in 2.0.0, reported by Ben Walker. The mangled symbol names were incorrect, sometimes resulting in types being diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index 89204d7bf..05f2082c2 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -666,7 +666,7 @@ public: /* We have an extra 'this' parameter. */ SetFlag(n, "wrap:this"); } - String *dispatch = Swig_overload_dispatch(n, "return %s(INTERNAL_FUNCTION_PARAM_PASSTHRU);", &maxargs); + String *dispatch = Swig_overload_dispatch(n, "%s(INTERNAL_FUNCTION_PARAM_PASSTHRU); return;", &maxargs); /* Generate a dispatch wrapper for all overloaded functions */ From 2453aee4e7345c28df8baca801b1f1c69b9810b5 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Thu, 14 Oct 2010 12:43:15 +0000 Subject: [PATCH 1053/1680] 2010-10-14: Sylvestre Ledru Fails the configure if cannot find a yacc implementation (like bison) git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12269 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++++ configure.in | 14 ++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 5a7493206..a5f149421 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -14,3 +14,7 @@ Version 2.0.2 (in progress) Fix unary scope operator (::) (global scope) regression introduced in 2.0.0, reported by Ben Walker. The mangled symbol names were incorrect, sometimes resulting in types being incorrectly treated as opaque types. + +2010-10-14: Sylvestre Ledru + Fails the configure if cannot find a yacc implementation + (like bison) diff --git a/configure.in b/configure.in index 36337b41d..7f584e5d6 100644 --- a/configure.in +++ b/configure.in @@ -122,6 +122,20 @@ echo "Note : None of the following packages are required for users to compile an echo "" AC_PROG_YACC +echo "YACC $YACC" +if test -z "$YACC"; then + AC_MSG_ERROR([No implementation of Yacc (bison, yacc) detected.]) +fi +# Actually, AC_PROG_YACC is lying. It sometimes put yacc into $YACC even it +# hasn't been able to find it. +# AC_CHECK_PROG(YACC_PRESENT, $YACC, AC_MSG_ERROR([No implementation of Yacc (bison, yacc) detected. Please install it (package bison)]) ) + +AC_CHECK_PROG(yacc_present, $YACC, "yes","no") +if test "x$yacc_present" != "xyes"; then + AC_MSG_ERROR([No implementation of Yacc (bison, yacc) detected. Please install it (package bison)]) +fi + + AC_PROG_RANLIB AC_CHECK_PROGS(AR, ar aal, ar) AC_SUBST(AR) From 98441fc6ad6d6097c98baf28b54c7059045806b6 Mon Sep 17 00:00:00 2001 From: Joseph Wang Date: Sun, 17 Oct 2010 07:33:58 +0000 Subject: [PATCH 1054/1680] [R] Fix failure in overloaded functions which was breaking QuantLib-SWIG git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12282 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++++ Source/Modules/r.cxx | 14 +++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index a5f149421..65489354c 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,10 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.2 (in progress) =========================== +2010-10-17: drjoe + [R] Fix failure in overloaded functions which was breaking + QuantLib-SWIG + 2010-10-14: olly [PHP] Allow compilation on non-conforming Microsoft C++ compilers which don't accept: return function_returning_void(); diff --git a/Source/Modules/r.cxx b/Source/Modules/r.cxx index 749797c78..61cbcdd79 100644 --- a/Source/Modules/r.cxx +++ b/Source/Modules/r.cxx @@ -1603,6 +1603,16 @@ void R::dispatchFunction(Node *n) { j == 0 ? "" : " && ", j+1); } + else if (DohStrcmp(tm,"integer")==0) { + Printf(f->code, "%s(is.integer(argv[[%d]]) || is.numeric(argv[[%d]]))", + j == 0 ? "" : " && ", + j+1, j+1); + } + else if (DohStrcmp(tm,"character")==0) { + Printf(f->code, "%sis.character(argv[[%d]])", + j == 0 ? "" : " && ", + j+1); + } else { Printf(f->code, "%sextends(argtypes[%d], '%s')", j == 0 ? "" : " && ", @@ -1617,7 +1627,9 @@ void R::dispatchFunction(Node *n) { } } if (cur_args != -1) { - Printv(f->code, "}", NIL); + Printf(f->code, "} else {\n" + "stop(\"cannot find overloaded function for %s\");\n" + "}", sfname); } Printv(f->code, ";\nf(...)", NIL); Printv(f->code, ";\n}", NIL); From f77ccd81d5c0b09ba0d99833e60945edf381f2f5 Mon Sep 17 00:00:00 2001 From: Joseph Wang Date: Sun, 17 Oct 2010 09:35:34 +0000 Subject: [PATCH 1055/1680] [R] Improve error message for missing argtypes git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12283 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/r.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/Modules/r.cxx b/Source/Modules/r.cxx index 61cbcdd79..8eb784c68 100644 --- a/Source/Modules/r.cxx +++ b/Source/Modules/r.cxx @@ -1628,7 +1628,8 @@ void R::dispatchFunction(Node *n) { } if (cur_args != -1) { Printf(f->code, "} else {\n" - "stop(\"cannot find overloaded function for %s\");\n" + "stop(\"cannot find overloaded function for %s with argtypes (\"," + "toString(argtypes),\")\");\n" "}", sfname); } Printv(f->code, ";\nf(...)", NIL); From 383230d734280c8cbd8ca159d30fe5677134883d Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 18 Oct 2010 18:59:57 +0000 Subject: [PATCH 1056/1680] minor clarification about %{ %} blocks git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12284 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Introduction.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Doc/Manual/Introduction.html b/Doc/Manual/Introduction.html index 3bac9484e..24579d946 100644 --- a/Doc/Manual/Introduction.html +++ b/Doc/Manual/Introduction.html @@ -195,9 +195,9 @@ extern int my_mod(int n, int m);

    The interface file contains ANSI C function prototypes and variable declarations. The %module directive defines the name of the -module that will be created by SWIG. The %{,%} block -provides a location for inserting additional code such as C header -files or additional C declarations. +module that will be created by SWIG. The %{ %} block +provides a location for inserting additional code, such as C header +files or additional C declarations, into the generated C wrapper code.

    2.3.2 The swig command

    From 28e277f8c59322fd1041bb3cc68c5ed779bff407 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Tue, 19 Oct 2010 06:31:31 +0000 Subject: [PATCH 1057/1680] Fix typo "the the" -> "the" git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12285 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/octave/octcontainer.swg | 3 +-- Lib/python/pycontainer.swg | 3 +-- Lib/ruby/rubycontainer.swg | 3 +-- Source/Swig/cwrap.c | 2 +- Source/Swig/stype.c | 2 +- 5 files changed, 5 insertions(+), 8 deletions(-) diff --git a/Lib/octave/octcontainer.swg b/Lib/octave/octcontainer.swg index 6613fcfff..4f14ccef1 100644 --- a/Lib/octave/octcontainer.swg +++ b/Lib/octave/octcontainer.swg @@ -4,8 +4,7 @@ * Octave cell <-> C++ container wrapper * * This wrapper, and its iterator, allows a general use (and reuse) of - * the the mapping between C++ and Octave, thanks to the C++ - * templates. + * the mapping between C++ and Octave, thanks to the C++ templates. * * Of course, it needs the C++ compiler to support templates, but * since we will use this wrapper with the STL containers, that should diff --git a/Lib/python/pycontainer.swg b/Lib/python/pycontainer.swg index efca86cf1..40506e15b 100644 --- a/Lib/python/pycontainer.swg +++ b/Lib/python/pycontainer.swg @@ -4,8 +4,7 @@ * Python sequence <-> C++ container wrapper * * This wrapper, and its iterator, allows a general use (and reuse) of - * the the mapping between C++ and Python, thanks to the C++ - * templates. + * the mapping between C++ and Python, thanks to the C++ templates. * * Of course, it needs the C++ compiler to support templates, but * since we will use this wrapper with the STL containers, that should diff --git a/Lib/ruby/rubycontainer.swg b/Lib/ruby/rubycontainer.swg index fa4b619f9..f643e84b3 100644 --- a/Lib/ruby/rubycontainer.swg +++ b/Lib/ruby/rubycontainer.swg @@ -4,8 +4,7 @@ * Ruby sequence <-> C++ container wrapper * * This wrapper, and its iterator, allows a general use (and reuse) of - * the the mapping between C++ and Ruby, thanks to the C++ - * templates. + * the mapping between C++ and Ruby, thanks to the C++ templates. * * Of course, it needs the C++ compiler to support templates, but * since we will use this wrapper with the STL containers, that should diff --git a/Source/Swig/cwrap.c b/Source/Swig/cwrap.c index 799d434a6..28401f89f 100644 --- a/Source/Swig/cwrap.c +++ b/Source/Swig/cwrap.c @@ -216,7 +216,7 @@ int Swig_cargs(Wrapper *w, ParmList *p) { SwigType_del_reference(tvalue); tycode = SwigType_type(tvalue); if (tycode != T_USER) { - /* plain primitive type, we copy the the def value */ + /* plain primitive type, we copy the def value */ String *lstr = SwigType_lstr(tvalue, defname); defvalue = NewStringf("%s = %s", lstr, qvalue); Delete(lstr); diff --git a/Source/Swig/stype.c b/Source/Swig/stype.c index a13f87cfc..742b6232a 100644 --- a/Source/Swig/stype.c +++ b/Source/Swig/stype.c @@ -366,7 +366,7 @@ SwigType *SwigType_default_create(SwigType *ty) { * SwigType_default_create() before calling this function. * * Example deductions (matching the examples described in SwigType_default_create), - * where the the most specialized matches are highest in the list: + * where the most specialized matches are highest in the list: * * a(ANY).a(ANY).SWIGTYPE * a(ANY).a().SWIGTYPE From 43794d90cdcaa6a4c477ef331c37e3076951c800 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Fri, 29 Oct 2010 10:22:03 +0000 Subject: [PATCH 1058/1680] Revert of commit 12269 see: http://sourceforge.net/mailarchive/forum.php?thread_name=4CC08FAA.5050009%40fultondesigns.co.uk&forum_name=swig-devel git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12286 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ---- configure.in | 14 -------------- 2 files changed, 18 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 65489354c..ebfb2cb81 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -18,7 +18,3 @@ Version 2.0.2 (in progress) Fix unary scope operator (::) (global scope) regression introduced in 2.0.0, reported by Ben Walker. The mangled symbol names were incorrect, sometimes resulting in types being incorrectly treated as opaque types. - -2010-10-14: Sylvestre Ledru - Fails the configure if cannot find a yacc implementation - (like bison) diff --git a/configure.in b/configure.in index 7f584e5d6..36337b41d 100644 --- a/configure.in +++ b/configure.in @@ -122,20 +122,6 @@ echo "Note : None of the following packages are required for users to compile an echo "" AC_PROG_YACC -echo "YACC $YACC" -if test -z "$YACC"; then - AC_MSG_ERROR([No implementation of Yacc (bison, yacc) detected.]) -fi -# Actually, AC_PROG_YACC is lying. It sometimes put yacc into $YACC even it -# hasn't been able to find it. -# AC_CHECK_PROG(YACC_PRESENT, $YACC, AC_MSG_ERROR([No implementation of Yacc (bison, yacc) detected. Please install it (package bison)]) ) - -AC_CHECK_PROG(yacc_present, $YACC, "yes","no") -if test "x$yacc_present" != "xyes"; then - AC_MSG_ERROR([No implementation of Yacc (bison, yacc) detected. Please install it (package bison)]) -fi - - AC_PROG_RANLIB AC_CHECK_PROGS(AR, ar aal, ar) AC_SUBST(AR) From 77b87aa9196c226b8625218b8608b5696b335d06 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 11 Nov 2010 19:30:44 +0000 Subject: [PATCH 1059/1680] typo fix in help message git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12288 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 80f2e68df..6d5f500a4 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -130,7 +130,7 @@ static const char *usage2 = (char *) "\ -nofastproxy - Use traditional proxy mechanism for member methods (default) \n\ -nofastquery - Use traditional query mechanism for types (default) \n\ -noh - Don't generate the output header file\n\ - -nomodern - Don't use modern python features which are not back compatible \n\ + -nomodern - Don't use modern python features which are not backwards compatible \n\ -nomodernargs - Use classic ParseTuple/CallFunction methods to pack/unpack the function arguments (default) \n"; static const char *usage3 = (char *) "\ -noolddefs - Don't emit the old method definitions even when using fastproxy (default) \n\ From 580f2549582602399553fded9e12bca6f9746143 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Fri, 12 Nov 2010 16:43:03 +0000 Subject: [PATCH 1060/1680] Update for recent runtime name changes (a better mechanism is clearly needed here). git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12290 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/go/cdata.i | 4 ++-- Lib/go/goruntime.swg | 12 ++++++------ Source/Modules/go.cxx | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Lib/go/cdata.i b/Lib/go/cdata.i index decf297c1..6cfdffea1 100644 --- a/Lib/go/cdata.i +++ b/Lib/go/cdata.i @@ -59,8 +59,8 @@ void _swig_gc_makegobyteslice(void *a, int32 n) { cgocallback(·_swig_internal_makegobyteslice, a, n); } void ·_swig_allocategobyteslice(byte *data, int32 len, swigcdata ret) { - ret.data = mal(len); - mcpy(ret.data, data, len); + ret.data = runtime·mal(len); + runtime·mcpy(ret.data, data, len); ret.len = len; FLUSH(&ret); } diff --git a/Lib/go/goruntime.swg b/Lib/go/goruntime.swg index 057f81d01..6cde68f55 100644 --- a/Lib/go/goruntime.swg +++ b/Lib/go/goruntime.swg @@ -109,23 +109,23 @@ static void _swig_gopanic(const char *p) { extern void ·_swig_internal_allocate(void); #pragma dynexport _swig_gc_allocate _swig_gc_allocate void _swig_gc_allocate(void *a, int32 n) { - cgocallback(·_swig_internal_allocate, a, n); + runtime·cgocallback(·_swig_internal_allocate, a, n); } void ·_swig_allocatememory(int32 len, byte *ret) { - ret = mal(len); + ret = runtime·mal(len); FLUSH(&ret); } extern void ·_swig_internal_makegostring(void); #pragma dynexport _swig_gc_makegostring _swig_gc_makegostring void _swig_gc_makegostring(void *a, int32 n) { - cgocallback(·_swig_internal_makegostring, a, n); + runtime·cgocallback(·_swig_internal_makegostring, a, n); } void ·_swig_allocatestring(byte *p, int32 l, String ret) { - ret.str = mal(l+1); - mcpy(ret.str, p, l); + ret.str = runtime·mal(l+1); + runtime·mcpy(ret.str, p, l); ret.len = l; FLUSH(&ret); } @@ -133,7 +133,7 @@ void ·_swig_allocatestring(byte *p, int32 l, String ret) { extern void ·_swig_internal_gopanic(void); #pragma dynexport _swig_gc_gopanic _swig_gc_gopanic void _swig_gc_gopanic(void *a, int32 n) { - cgocallback(·_swig_internal_gopanic, a, n); + runtime·cgocallback(·_swig_internal_gopanic, a, n); } %} diff --git a/Source/Modules/go.cxx b/Source/Modules/go.cxx index 4b1d05b92..d3de53f8f 100644 --- a/Source/Modules/go.cxx +++ b/Source/Modules/go.cxx @@ -1068,7 +1068,7 @@ private: Delete(parm_size); Printv(f->code, "{\n", NULL); - Printv(f->code, "\tcgocall(", wname, ", &p);\n", NULL); + Printv(f->code, "\truntime\xc2\xb7" "cgocall(", wname, ", &p);\n", NULL); Printv(f->code, "}\n", NULL); Printv(f->code, "\n", NULL); @@ -2749,7 +2749,7 @@ private: Printv(f_gc_wrappers, "void\n", NULL); Printv(f_gc_wrappers, wname, "(void *a, int32 n)\n", NULL); Printv(f_gc_wrappers, "{\n", NULL); - Printv(f_gc_wrappers, "\tcgocallback(\xc2\xb7", go_name, ", a, n);\n", NULL); + Printv(f_gc_wrappers, "\truntime\xc2\xb7" "cgocallback(\xc2\xb7", go_name, ", a, n);\n", NULL); Printv(f_gc_wrappers, "}\n\n", NULL); } else { Printv(f_c_directors, " ", wname, "(go_val);\n", NULL); @@ -3475,7 +3475,7 @@ private: Printv(f_gc_wrappers, "void\n", NULL); Printv(f_gc_wrappers, callback_wname, "(void *a, int32 n)\n", NULL); Printv(f_gc_wrappers, "{\n", NULL); - Printv(f_gc_wrappers, "\tcgocallback(\xc2\xb7", callback_name, ", a, n);\n", NULL); + Printv(f_gc_wrappers, "\truntime\xc2\xb7" "cgocallback(\xc2\xb7", callback_name, ", a, n);\n", NULL); Printv(f_gc_wrappers, "}\n\n", NULL); } else { if (SwigType_type(result) != T_VOID) { From e30befd13806fb89c1591c56a7a66a5c24d1a14e Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 16 Nov 2010 14:08:50 +0000 Subject: [PATCH 1061/1680] Correct explanation of how to match on class name in %rename. Replace incorrect documentation of $parentNode from %rename discussion: it advised using match$parentNode but this doesn't work because the parent node is not yet set when %rename is parsed. Document the "fullname" attribute of %rename which can be used to restrict the match to the given full name of a declaration only. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12291 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/SWIG.html | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html index e51e55986..b8e3e2260 100644 --- a/Doc/Manual/SWIG.html +++ b/Doc/Manual/SWIG.html @@ -2002,22 +2002,6 @@ documentation is not exhaustive, see "%rename predicates" section of swig.swg for the full list of supported match expressions.

    -

    -Another important feature of match is that it can be applied not -only to the declaration itself but also to its enclosing declaration. So -match$parentNode$name="SomeClass" would be true only for members of -the C++ class with the specified name. This can, of course, be combined with -more complicated matches making it possible to write -

    -
    -
    -%rename("%(lowercase)s", match$parentNode$name="SomeClass", %$isenum) "";
    -
    -
    -

    -to rename all enums nested in the given class to lower case. -

    -

    In addition to literally matching some string with match you can also use regexmatch or notregexmatch to match a string @@ -2039,6 +2023,14 @@ declaration name directly can be preferable and can also be done using %rename("$ignore", regextarget=1) "Old$"; +Notice that the check is done only against the name of the declaration +itself, if you need to match the full name of a C++ declaration you +must use fullname attribute: +

    +
    +%rename("$ignore", regextarget=1, fullname=1) "NameSpace::ClassName::.*Old$";
    +
    +

    As for notregexmatch, it restricts the match only to the strings not From 953c4abacaad7c8cab4eb5c5f87e5164c7e414c8 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 16 Nov 2010 14:09:09 +0000 Subject: [PATCH 1062/1680] Use rename list and not hash for renames with regextarget attribute. Renames which are regular expressions can't be put in the regex hash as they don't literally match the real declarations names. Instead, put them in the rename list against which we will match the declarations names later. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12292 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Swig/naming.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Swig/naming.c b/Source/Swig/naming.c index 5bf42f7cc..70744586c 100644 --- a/Source/Swig/naming.c +++ b/Source/Swig/naming.c @@ -1110,7 +1110,7 @@ void Swig_name_nameobj_add(Hash *name_hash, List *name_list, String *prefix, Str } if (!nname || !Len(nname) || Getattr(nameobj, "fullname") || /* any of these options trigger a 'list' nameobj */ - Getattr(nameobj, "sourcefmt") || Getattr(nameobj, "matchlist")) { + Getattr(nameobj, "sourcefmt") || Getattr(nameobj, "matchlist") || Getattr(nameobj, "regextarget")) { if (decl) Setattr(nameobj, "decl", decl); if (nname && Len(nname)) From f6cab0170abdb69b1ac562b223d101bf55e5700f Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 16 Nov 2010 14:09:39 +0000 Subject: [PATCH 1063/1680] Ignore non-matching regex renames when searching renames list. Skip over %renames with non-matching %(regex)s expansion when looking for the one to apply to the given name. This allows to have multiple anonymous renames using regex as now the first _matching_ one will be used instead of always using the first one and ignoring all the rest of them. Extend unit tests to verify that applying two anonymous %renames does work as expected. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12293 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 10 ++++++++++ .../test-suite/csharp/rename_pcre_encoder_runme.cs | 12 ++++++++++++ .../test-suite/java/rename_pcre_encoder_runme.java | 14 ++++++++++++++ .../test-suite/python/rename_pcre_encoder_runme.py | 3 +++ Examples/test-suite/rename_pcre_encoder.i | 9 +++++++-- Source/Swig/naming.c | 8 +++++++- 6 files changed, 53 insertions(+), 3 deletions(-) create mode 100644 Examples/test-suite/csharp/rename_pcre_encoder_runme.cs create mode 100644 Examples/test-suite/java/rename_pcre_encoder_runme.java diff --git a/CHANGES.current b/CHANGES.current index ebfb2cb81..f18011e1a 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,16 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.2 (in progress) =========================== +2010-11-12: vadz + Fix handling of multiple regex-using %renames attached to the same + declaration. For example, now + + %rename("%(regex/^Set(.*)/put\\1/)s") ""; + %rename("%(regex/^Get(.*)/get\\1/)s") ""; + + works as expected whereas before only the last anonymous rename was + taken into account. + 2010-10-17: drjoe [R] Fix failure in overloaded functions which was breaking QuantLib-SWIG diff --git a/Examples/test-suite/csharp/rename_pcre_encoder_runme.cs b/Examples/test-suite/csharp/rename_pcre_encoder_runme.cs new file mode 100644 index 000000000..f6289e7e2 --- /dev/null +++ b/Examples/test-suite/csharp/rename_pcre_encoder_runme.cs @@ -0,0 +1,12 @@ +using System; +using rename_pcre_encoderNamespace; + +public class runme { + static void Main() { + SomeWidget w = new SomeWidget(); + w.putBorderWidth(17); + if ( w.getBorderWidth() != 17 ) + throw new Exception(String.Format("Border with should be 17, not {0}", + w.getBorderWidth())); + } +} diff --git a/Examples/test-suite/java/rename_pcre_encoder_runme.java b/Examples/test-suite/java/rename_pcre_encoder_runme.java new file mode 100644 index 000000000..cb843338b --- /dev/null +++ b/Examples/test-suite/java/rename_pcre_encoder_runme.java @@ -0,0 +1,14 @@ +import rename_pcre_encoder.*; + +public class rename_pcre_encoder_runme { + static { System.loadLibrary("rename_pcre_encoder"); } + + public static void main(String argv[]) + { + SomeWidget w = new SomeWidget(); + w.putBorderWidth(17); + if ( w.getBorderWidth() != 17 ) + throw new RuntimeException(String.format("Border with should be 17, not %d", + w.getBorderWidth())); + } +} diff --git a/Examples/test-suite/python/rename_pcre_encoder_runme.py b/Examples/test-suite/python/rename_pcre_encoder_runme.py index ed7ca48b1..1186703a0 100644 --- a/Examples/test-suite/python/rename_pcre_encoder_runme.py +++ b/Examples/test-suite/python/rename_pcre_encoder_runme.py @@ -2,6 +2,9 @@ from rename_pcre_encoder import * s = SomeWidget() s.putBorderWidth(3) +if s.getBorderWidth() != 3: + raise RuntimeError("Border should be 3, not %d" % (s.getBorderWidth(),)) + s.putSize(4, 5) a = AnotherWidget() a.DoSomething() diff --git a/Examples/test-suite/rename_pcre_encoder.i b/Examples/test-suite/rename_pcre_encoder.i index c90af164d..66f30c7bc 100644 --- a/Examples/test-suite/rename_pcre_encoder.i +++ b/Examples/test-suite/rename_pcre_encoder.i @@ -3,14 +3,19 @@ // strip the wx prefix from all identifiers except those starting with wxEVT %rename("%(regex:/wx(?!EVT)(.*)/\\1/)s") ""; -// Replace "Set" prefix with "put" in all functions +// Replace "Set" and "Get" prefixes with "put" and "get" respectively. %rename("%(regex:/^Set(.*)/put\\1/)s", %$isfunction) ""; +%rename("%(regex:/^Get(.*)/get\\1/)s", %$isfunction) ""; %inline %{ struct wxSomeWidget { - void SetBorderWidth(int) {} + void SetBorderWidth(int width) { m_width = width; } + int GetBorderWidth() const { return m_width; } + void SetSize(int, int) {} + + int m_width; }; struct wxAnotherWidget { diff --git a/Source/Swig/naming.c b/Source/Swig/naming.c index 70744586c..6beecc130 100644 --- a/Source/Swig/naming.c +++ b/Source/Swig/naming.c @@ -1302,7 +1302,13 @@ Hash *Swig_name_nameobj_lget(List *namelist, Node *n, String *prefix, String *na : Swig_name_match_value(tname, sname); Delete(sname); } else { - match = 1; + /* Applying the renaming rule may fail if it contains a %(regex)s expression that doesn't match the given name. */ + String *sname = NewStringf(Getattr(rn, "name"), name); + if (sname) { + if (Len(sname)) + match = 1; + Delete(sname); + } } } if (match) { From ee1c2f3ef086080a54cf5aec99f8b46e3f4d910d Mon Sep 17 00:00:00 2001 From: David Nadlinger Date: Thu, 18 Nov 2010 00:15:13 +0000 Subject: [PATCH 1064/1680] Renamed 'immutable' test-case to 'immutable_values'. This is a part of the pending merge of the D module, where 'immutable' is a keyword (and thus not a valid module name). git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12294 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/common.mk | 2 +- Examples/test-suite/{immutable.i => immutable_values.i} | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename Examples/test-suite/{immutable.i => immutable_values.i} (90%) diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 026612db5..05d2f80c8 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -466,7 +466,7 @@ C_TEST_CASES += \ extern_declaration \ funcptr \ function_typedef \ - immutable \ + immutable_values \ inctest \ integers \ keyword_rename \ diff --git a/Examples/test-suite/immutable.i b/Examples/test-suite/immutable_values.i similarity index 90% rename from Examples/test-suite/immutable.i rename to Examples/test-suite/immutable_values.i index ff5081e9c..1c1978661 100644 --- a/Examples/test-suite/immutable.i +++ b/Examples/test-suite/immutable_values.i @@ -1,6 +1,6 @@ // test to make sure setters are not generated for constants -%module immutable +%module immutable_values %immutable; From 0fb77ce2068128e02217cdddd6a388e6c6d30d9f Mon Sep 17 00:00:00 2001 From: David Nadlinger Date: Thu, 18 Nov 2010 00:15:41 +0000 Subject: [PATCH 1065/1680] Renamed 'template' test-case to 'template_basic'. This is a part of the pending merge of the D module, where 'template' is a keyword (and thus not a valid module name). git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12295 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/common.mk | 2 +- Examples/test-suite/{template.i => template_basic.i} | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) rename Examples/test-suite/{template.i => template_basic.i} (89%) diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 05d2f80c8..f0fe4af1c 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -318,11 +318,11 @@ CPP_TEST_CASES += \ struct_initialization_cpp \ struct_value \ symbol_clash \ - template \ template_arg_replace \ template_arg_scope \ template_arg_typename \ template_array_numeric \ + template_basic \ template_base_template \ template_classes \ template_const_ref \ diff --git a/Examples/test-suite/template.i b/Examples/test-suite/template_basic.i similarity index 89% rename from Examples/test-suite/template.i rename to Examples/test-suite/template_basic.i index d2c7a91ed..570392bf6 100644 --- a/Examples/test-suite/template.i +++ b/Examples/test-suite/template_basic.i @@ -1,5 +1,5 @@ -/* File : example.i */ -%module "template" +/* File: template_basic.i */ +%module "template_basic" %warnfilter(SWIGWARN_RUBY_WRONG_NAME) vector; /* Ruby, wrong class name */ %warnfilter(SWIGWARN_RUBY_WRONG_NAME) vector; /* Ruby, wrong class name */ @@ -31,7 +31,7 @@ template class vector { void set(int index, T &val) { v[index] = val; } - // This really doesn't do anything except test const handling + // This really doesn't do anything except test const handling void testconst(const T x) { } }; From 4d09774cefd745dc6a0e38db0a3ab320d79c992c Mon Sep 17 00:00:00 2001 From: David Nadlinger Date: Thu, 18 Nov 2010 00:16:02 +0000 Subject: [PATCH 1066/1680] Minor rename in the 'smart_pointer_templatemethods' test-case to avoid special casing for D. This is a part of the pending merge of the D module, where 'Object' is a keyword. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12296 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/smart_pointer_templatemethods.i | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Examples/test-suite/smart_pointer_templatemethods.i b/Examples/test-suite/smart_pointer_templatemethods.i index 7baa6386a..f79bbcc9d 100644 --- a/Examples/test-suite/smart_pointer_templatemethods.i +++ b/Examples/test-suite/smart_pointer_templatemethods.i @@ -1,4 +1,3 @@ - %module smart_pointer_templatemethods %inline %{ @@ -29,21 +28,21 @@ public: void DisposeObjekt (void) {} }; -class Object +class Objct { public: - Object () {} - virtual ~Object () {} + Objct () {} + virtual ~Objct () {} template Ptr QueryInterface (InterfaceId iid) const { return Ptr(); } - void DisposeObject (void) {} + void DisposeObjct (void) {} }; #ifdef SWIG -%template(PtrObject) Ptr; +%template(PtrObjct) Ptr; %template(PtrInt) Ptr; %template(ObjektInt) Objekt; %template(PtrObjektInt) Ptr >; -%template(QueryInterfaceObject) Object::QueryInterface; +%template(QueryInterfaceObjct) Objct::QueryInterface; #endif }; // namespace From 2070812f09468e17b6a1e027dcaa6b5ae3774570 Mon Sep 17 00:00:00 2001 From: David Nadlinger Date: Thu, 18 Nov 2010 00:16:23 +0000 Subject: [PATCH 1067/1680] Minor rename in the 'operbool' test-case to avoid special casing for D. This is a part of the pending merge of the D module, where a method having the same name as the module would lead to ambiguities. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12297 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/operbool.i | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/test-suite/operbool.i b/Examples/test-suite/operbool.i index 793c0174e..ee8c889e9 100644 --- a/Examples/test-suite/operbool.i +++ b/Examples/test-suite/operbool.i @@ -1,6 +1,6 @@ %module operbool -%rename(operbool) operator bool(); +%rename(operator_bool) operator bool(); %inline %{ class Test { From a355d2d46af56c655816c37f24bb59fa6bade43f Mon Sep 17 00:00:00 2001 From: David Nadlinger Date: Thu, 18 Nov 2010 00:17:37 +0000 Subject: [PATCH 1068/1680] Added special cases to the test-suite as required for D. This is a part of the pending merge of the D module. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12298 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/abstract_virtual.i | 6 ++-- Examples/test-suite/contract.i | 7 ++++- Examples/test-suite/default_constructor.i | 6 ++-- Examples/test-suite/dynamic_cast.i | 13 +++++++-- Examples/test-suite/enums.i | 5 ++++ Examples/test-suite/evil_diamond.i | 3 +- Examples/test-suite/evil_diamond_ns.i | 3 +- Examples/test-suite/evil_diamond_prop.i | 1 + Examples/test-suite/import_nomodule.i | 8 ++--- Examples/test-suite/inherit_target_language.i | 8 ++++- Examples/test-suite/li_boost_shared_ptr.i | 2 +- .../test-suite/li_boost_shared_ptr_bits.i | 2 +- Examples/test-suite/li_std_combinations.i | 2 +- Examples/test-suite/minherit2.i | 29 +++++++++++++++++-- Examples/test-suite/multiple_inheritance.i | 6 ++-- Examples/test-suite/namespace_class.i | 4 +++ Examples/test-suite/preproc_line_file.i | 4 +-- Examples/test-suite/pure_virtual.i | 5 ++-- Examples/test-suite/samename.i | 2 +- Examples/test-suite/special_variable_macros.i | 14 +++++++++ Examples/test-suite/static_const_member.i | 3 ++ Examples/test-suite/template_enum.i | 4 +++ .../test-suite/template_inherit_abstract.i | 5 ++-- Examples/test-suite/typemap_namespace.i | 9 +++++- Examples/test-suite/typemap_out_optimal.i | 6 +++- Examples/test-suite/typemap_subst.i | 4 +-- Examples/test-suite/using_composition.i | 9 ++++-- Examples/test-suite/using_extend.i | 3 +- Examples/test-suite/using_namespace.i | 3 +- 29 files changed, 137 insertions(+), 39 deletions(-) diff --git a/Examples/test-suite/abstract_virtual.i b/Examples/test-suite/abstract_virtual.i index 2e4d105b1..d8372c936 100644 --- a/Examples/test-suite/abstract_virtual.i +++ b/Examples/test-suite/abstract_virtual.i @@ -2,10 +2,12 @@ %warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE, SWIGWARN_CSHARP_MULTIPLE_INHERITANCE, - SWIGWARN_PHP_MULTIPLE_INHERITANCE) D; /* C#, Java, PHP multiple inheritance */ + SWIGWARN_D_MULTIPLE_INHERITANCE, + SWIGWARN_PHP_MULTIPLE_INHERITANCE) D; /* C#, D, Java, PHP multiple inheritance */ %warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE, SWIGWARN_CSHARP_MULTIPLE_INHERITANCE, - SWIGWARN_PHP_MULTIPLE_INHERITANCE) E; /* C#, Java, PHP multiple inheritance */ + SWIGWARN_D_MULTIPLE_INHERITANCE, + SWIGWARN_PHP_MULTIPLE_INHERITANCE) E; /* C#, D, Java, PHP multiple inheritance */ %inline %{ #if defined(_MSC_VER) diff --git a/Examples/test-suite/contract.i b/Examples/test-suite/contract.i index b979ef19e..0ad7e8e7c 100644 --- a/Examples/test-suite/contract.i +++ b/Examples/test-suite/contract.i @@ -3,12 +3,17 @@ %warnfilter(SWIGWARN_RUBY_MULTIPLE_INHERITANCE, SWIGWARN_JAVA_MULTIPLE_INHERITANCE, SWIGWARN_CSHARP_MULTIPLE_INHERITANCE, - SWIGWARN_PHP_MULTIPLE_INHERITANCE) C; /* Ruby, C#, Java, PHP multiple inheritance */ + SWIGWARN_D_MULTIPLE_INHERITANCE, + SWIGWARN_PHP_MULTIPLE_INHERITANCE) C; /* Ruby, C#, D, Java, PHP multiple inheritance */ #ifdef SWIGCSHARP %ignore B::bar; // otherwise get a warning: `C.bar' no suitable methods found to override #endif +#ifdef SWIGD +%ignore B::bar; // Prevents getting an error that C.bar does not override any function because multiple inheritance is not supported. +#endif + %contract test_preassert(int a, int b) { require: a > 0; diff --git a/Examples/test-suite/default_constructor.i b/Examples/test-suite/default_constructor.i index ff22c7834..091adff20 100644 --- a/Examples/test-suite/default_constructor.i +++ b/Examples/test-suite/default_constructor.i @@ -5,11 +5,13 @@ %warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE, SWIGWARN_CSHARP_MULTIPLE_INHERITANCE, - SWIGWARN_PHP_MULTIPLE_INHERITANCE) EB; /* C#, Java, PHP multiple inheritance */ + SWIGWARN_D_MULTIPLE_INHERITANCE, + SWIGWARN_PHP_MULTIPLE_INHERITANCE) EB; /* C#, D, Java, PHP multiple inheritance */ %warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE, SWIGWARN_CSHARP_MULTIPLE_INHERITANCE, - SWIGWARN_PHP_MULTIPLE_INHERITANCE) AD; /* C#, Java, PHP multiple inheritance */ + SWIGWARN_D_MULTIPLE_INHERITANCE, + SWIGWARN_PHP_MULTIPLE_INHERITANCE) AD; /* C#, D, Java, PHP multiple inheritance */ %warnfilter(SWIGWARN_LANG_FRIEND_IGNORE) F; /* friend function */ diff --git a/Examples/test-suite/dynamic_cast.i b/Examples/test-suite/dynamic_cast.i index ccbaa5b47..17850985a 100644 --- a/Examples/test-suite/dynamic_cast.i +++ b/Examples/test-suite/dynamic_cast.i @@ -1,7 +1,7 @@ /* File : example.i */ %module dynamic_cast -#if !defined(SWIGJAVA) && !defined(SWIGCSHARP) && !defined(SWIGGO) +#if !defined(SWIGJAVA) && !defined(SWIGCSHARP) && !defined(SWIGGO) && !defined(SWIGD) %apply SWIGTYPE *DYNAMIC { Foo * }; #endif @@ -17,7 +17,7 @@ public: }; %} -#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGGO) +#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGGO) || defined(SWIGD) %typemap(out) Foo *blah { Bar *downcast = dynamic_cast($1); *(Bar **)&$result = downcast; @@ -37,6 +37,13 @@ public: } #endif +#if defined(SWIGD) +%typemap(dout, excode=SWIGEXCODE) Foo * { + Bar ret = new Bar($wcall, $owner);$excode + return ret; +} +#endif + #if defined(SWIGGO) %insert(go_runtime) %{ func FooToBar(f Foo) Bar { @@ -62,7 +69,7 @@ char *do_test(Bar *b) { } %} -#if !defined(SWIGJAVA) && !defined(SWIGCSHARP) && !defined(SWIGGO) +#if !defined(SWIGJAVA) && !defined(SWIGCSHARP) && !defined(SWIGGO) && !defined(SWIGD) // A general purpose function for dynamic casting of a Foo * %{ static swig_type_info * diff --git a/Examples/test-suite/enums.i b/Examples/test-suite/enums.i index 5632b5e97..14c6efbba 100644 --- a/Examples/test-suite/enums.i +++ b/Examples/test-suite/enums.i @@ -58,6 +58,11 @@ typedef struct _Foo { %warnfilter(SWIGWARN_RUBY_WRONG_NAME) _iFoo; +#ifdef SWIGD +/* Work around missing support for proper char quoting due to parser shortcomings. */ +%dconstvalue("'a'") _iFoo::Char; +#endif + #ifndef __cplusplus %inline %{ typedef struct _iFoo diff --git a/Examples/test-suite/evil_diamond.i b/Examples/test-suite/evil_diamond.i index 7b2e9152f..a8d48b30b 100644 --- a/Examples/test-suite/evil_diamond.i +++ b/Examples/test-suite/evil_diamond.i @@ -6,7 +6,8 @@ %warnfilter(SWIGWARN_RUBY_WRONG_NAME, SWIGWARN_JAVA_MULTIPLE_INHERITANCE, SWIGWARN_CSHARP_MULTIPLE_INHERITANCE, - SWIGWARN_PHP_MULTIPLE_INHERITANCE) spam; // Ruby, wrong class name - C# & Java, PHP multiple inheritance + SWIGWARN_D_MULTIPLE_INHERITANCE, + SWIGWARN_PHP_MULTIPLE_INHERITANCE) spam; // Ruby, wrong class name - C#, D & Java, PHP multiple inheritance %inline %{ diff --git a/Examples/test-suite/evil_diamond_ns.i b/Examples/test-suite/evil_diamond_ns.i index 515044007..0227b31ee 100644 --- a/Examples/test-suite/evil_diamond_ns.i +++ b/Examples/test-suite/evil_diamond_ns.i @@ -6,7 +6,8 @@ %warnfilter(SWIGWARN_RUBY_WRONG_NAME, SWIGWARN_JAVA_MULTIPLE_INHERITANCE, SWIGWARN_CSHARP_MULTIPLE_INHERITANCE, - SWIGWARN_PHP_MULTIPLE_INHERITANCE) Blah::spam; // Ruby, wrong class name - C# & Java, PHP multiple inheritance + SWIGWARN_D_MULTIPLE_INHERITANCE, + SWIGWARN_PHP_MULTIPLE_INHERITANCE) Blah::spam; // Ruby, wrong class name - C#, D & Java, PHP multiple inheritance %inline %{ namespace Blah { diff --git a/Examples/test-suite/evil_diamond_prop.i b/Examples/test-suite/evil_diamond_prop.i index 804ea66b4..2dac6eab7 100644 --- a/Examples/test-suite/evil_diamond_prop.i +++ b/Examples/test-suite/evil_diamond_prop.i @@ -6,6 +6,7 @@ %warnfilter(SWIGWARN_RUBY_WRONG_NAME, SWIGWARN_JAVA_MULTIPLE_INHERITANCE, SWIGWARN_CSHARP_MULTIPLE_INHERITANCE, + SWIGWARN_D_MULTIPLE_INHERITANCE, SWIGWARN_PHP_MULTIPLE_INHERITANCE) spam; // Ruby, wrong class name - C# & Java, PHP multiple inheritance %inline %{ diff --git a/Examples/test-suite/import_nomodule.i b/Examples/test-suite/import_nomodule.i index a1ba9ad7a..4fd5cbf65 100644 --- a/Examples/test-suite/import_nomodule.i +++ b/Examples/test-suite/import_nomodule.i @@ -8,16 +8,16 @@ %import "import_nomodule.h" -#if !defined(SWIGJAVA) && !defined(SWIGRUBY) && !defined(SWIGCSHARP) +#if !defined(SWIGJAVA) && !defined(SWIGRUBY) && !defined(SWIGCSHARP) && !defined(SWIGD) /** * The proxy class does not have Bar derived from Foo, yet an instance of Bar * can successfully be passed to a proxy function taking a Foo pointer (for some * language modules). * - * This violation of the type system is not possible in Java and C# due to static - * type checking. It's also not (currently) possible in Ruby, but this may be - * fixable (needs more investigation). + * This violation of the type system is not possible in Java, C# and D due to + * static type checking. It's also not (currently) possible in Ruby, but this may + * be fixable (needs more investigation). */ %newobject create_Foo; diff --git a/Examples/test-suite/inherit_target_language.i b/Examples/test-suite/inherit_target_language.i index 20fb93fda..88801f3f6 100644 --- a/Examples/test-suite/inherit_target_language.i +++ b/Examples/test-suite/inherit_target_language.i @@ -1,4 +1,4 @@ -// Test using a target language specified base class, primarily for Java/C# and possibly other single inheritance languages +// Test using a target language specified base class, primarily for Java/C#/D and possibly other single inheritance languages // Note the multiple inheritance warnings don't appear because of the two techniques used in here: typemaps and %ignore @@ -6,6 +6,8 @@ #if defined(SWIGJAVA) # define csbase javabase +#elif defined(SWIGD) +# define csbase dbase #endif %pragma(csharp) moduleimports=%{ @@ -20,6 +22,10 @@ class TargetLanguageBase { public void targetLanguageBaseMethod() {} }; class TargetLanguageBase2 { public void targetLanguageBase2Method() {} }; %} +%pragma(d) globalproxyimports=%{ +private class TargetLanguageBase { public void targetLanguageBaseMethod() {} }; +private class TargetLanguageBase2 { public void targetLanguageBase2Method() {} }; +%} %typemap(csbase) SWIGTYPE "TargetLanguageBase" diff --git a/Examples/test-suite/li_boost_shared_ptr.i b/Examples/test-suite/li_boost_shared_ptr.i index f92df23a9..fc51e7b5a 100644 --- a/Examples/test-suite/li_boost_shared_ptr.i +++ b/Examples/test-suite/li_boost_shared_ptr.i @@ -34,7 +34,7 @@ # define SWIG_SHARED_PTR_NAMESPACE SwigBoost #endif -#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) +#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGD) #define SHARED_PTR_WRAPPERS_IMPLEMENTED #endif diff --git a/Examples/test-suite/li_boost_shared_ptr_bits.i b/Examples/test-suite/li_boost_shared_ptr_bits.i index 610edb4b4..2232b6cf6 100644 --- a/Examples/test-suite/li_boost_shared_ptr_bits.i +++ b/Examples/test-suite/li_boost_shared_ptr_bits.i @@ -1,6 +1,6 @@ %module li_boost_shared_ptr_bits -#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) +#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGD) #define SHARED_PTR_WRAPPERS_IMPLEMENTED #endif diff --git a/Examples/test-suite/li_std_combinations.i b/Examples/test-suite/li_std_combinations.i index 9acc8f23d..57f945bcd 100644 --- a/Examples/test-suite/li_std_combinations.i +++ b/Examples/test-suite/li_std_combinations.i @@ -14,7 +14,7 @@ %template(VectorVectorString) std::vector< std::vector >; %template(PairIntPairIntString) std::pair< int, std::pair >; -#if defined(SWIGCSHARP) +#if defined(SWIGCSHARP) || defined(SWIGD) // Checks macro containing a type with a comma SWIG_STD_VECTOR_ENHANCED(std::pair< double, std::string >) #endif diff --git a/Examples/test-suite/minherit2.i b/Examples/test-suite/minherit2.i index 1bca4fc48..7d470d30e 100644 --- a/Examples/test-suite/minherit2.i +++ b/Examples/test-suite/minherit2.i @@ -1,16 +1,18 @@ %module minherit2 -// A multiple inheritance example, mainly for Java and C#. -// The example shows how it is possible to turn C++ abstract base classes into Java/C# interface. +// A multiple inheritance example, mainly for Java, C# and D. +// The example shows how it is possible to turn C++ abstract base classes into +// Java/C#/D interfaces. // In the future, all this trouble might be more automated. %warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE, SWIGWARN_CSHARP_MULTIPLE_INHERITANCE, + SWIGWARN_D_MULTIPLE_INHERITANCE, SWIGWARN_RUBY_MULTIPLE_INHERITANCE, SWIGWARN_PHP_MULTIPLE_INHERITANCE) RemoteMpe; -#if defined(SWIGJAVA) || defined(SWIGCSHARP) +#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGD) #if defined(SWIGCSHARP) #define javaclassmodifiers csclassmodifiers @@ -22,6 +24,21 @@ #define javabase csbase #endif +#if defined(SWIGD) +#define javaclassmodifiers dclassmodifiers +#define javabody dbody +#define javafinalize ddestructor +#define javadestruct ddispose +#define javaout dout +#define javainterfaces dinterfaces +#define javabase dbase + +%typemap(dimports) RemoteMpe %{ +$importtype(IRemoteSyncIO) +$importtype(IRemoteAsyncIO) +%} +#endif + // Modify multiple inherited base classes into inheriting interfaces %typemap(javainterfaces) RemoteMpe "IRemoteSyncIO, IRemoteAsyncIO"; %typemap(javabase, replace="1") RemoteMpe ""; @@ -51,6 +68,12 @@ // Features are inherited by derived classes, so override this %csmethodmodifiers RemoteMpe::syncmethod "public" %csmethodmodifiers RemoteMpe::asyncmethod "public" +#elif defined(SWIGD) +%dmethodmodifiers IRemoteSyncIO::syncmethod ""; +%dmethodmodifiers IRemoteAsyncIO::asyncmethod ""; +// Features are inherited by derived classes, so override this +%dmethodmodifiers RemoteMpe::syncmethod "public" +%dmethodmodifiers RemoteMpe::asyncmethod "public" #endif #endif diff --git a/Examples/test-suite/multiple_inheritance.i b/Examples/test-suite/multiple_inheritance.i index 1fc68eef9..044345020 100644 --- a/Examples/test-suite/multiple_inheritance.i +++ b/Examples/test-suite/multiple_inheritance.i @@ -5,11 +5,13 @@ It tests basic multiple inheritance */ %warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE, SWIGWARN_CSHARP_MULTIPLE_INHERITANCE, - SWIGWARN_PHP_MULTIPLE_INHERITANCE) FooBar; /* C#, Java, PHP multiple inheritance */ + SWIGWARN_D_MULTIPLE_INHERITANCE, + SWIGWARN_PHP_MULTIPLE_INHERITANCE) FooBar; /* C#, D, Java, PHP multiple inheritance */ %warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE, SWIGWARN_CSHARP_MULTIPLE_INHERITANCE, - SWIGWARN_PHP_MULTIPLE_INHERITANCE) FooBarSpam; /* C#, Java, PHP multiple inheritance */ + SWIGWARN_D_MULTIPLE_INHERITANCE, + SWIGWARN_PHP_MULTIPLE_INHERITANCE) FooBarSpam; /* C#, D, Java, PHP multiple inheritance */ %inline %{ diff --git a/Examples/test-suite/namespace_class.i b/Examples/test-suite/namespace_class.i index 7dc9139cd..aea5362d1 100644 --- a/Examples/test-suite/namespace_class.i +++ b/Examples/test-suite/namespace_class.i @@ -2,6 +2,10 @@ %warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Ala::Ola; +#ifdef SWIGD +%warnfilter(SWIGWARN_IGNORE_OPERATOR_LT); +#endif + %inline %{ template void foobar(T t) {} namespace test { diff --git a/Examples/test-suite/preproc_line_file.i b/Examples/test-suite/preproc_line_file.i index 353aa999f..91ff2133e 100644 --- a/Examples/test-suite/preproc_line_file.i +++ b/Examples/test-suite/preproc_line_file.i @@ -33,12 +33,12 @@ const int NUMBER_UNIQUE(thing) = -2; /* resolves to thing28 */ %javaconst(1); #elif defined(SWIGCSHARP) %csconst(1); +#elif defined(SWIGD) +%dnativeconst; #else %ignore LINE_NUMBER; %ignore LINE_NUM; /* spare space */ - - #endif %{ diff --git a/Examples/test-suite/pure_virtual.i b/Examples/test-suite/pure_virtual.i index 5bda283cf..9e345e2a4 100644 --- a/Examples/test-suite/pure_virtual.i +++ b/Examples/test-suite/pure_virtual.i @@ -9,7 +9,8 @@ %warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE, SWIGWARN_CSHARP_MULTIPLE_INHERITANCE, - SWIGWARN_PHP_MULTIPLE_INHERITANCE) E; /* C#, Java, PHP multiple inheritance */ + SWIGWARN_D_MULTIPLE_INHERITANCE, + SWIGWARN_PHP_MULTIPLE_INHERITANCE) E; /* C#, D, Java, PHP multiple inheritance */ %nodefaultctor C; %nodefaultdtor C; @@ -65,7 +66,7 @@ public: %} /* Fill in method from AA. This class should be constructable */ -#ifdef SWIGCSHARP +#if defined(SWIGCSHARP) || defined(SWIGD) %ignore F::method2(); // Work around for lack of multiple inheritance support - base AA is ignored. #endif diff --git a/Examples/test-suite/samename.i b/Examples/test-suite/samename.i index 819cb4abd..cc03995bc 100644 --- a/Examples/test-suite/samename.i +++ b/Examples/test-suite/samename.i @@ -1,6 +1,6 @@ %module samename -#if !(defined(SWIGCSHARP) || defined(SWIGJAVA)) +#if !(defined(SWIGCSHARP) || defined(SWIGJAVA) || defined(SWIGD)) class samename { public: void do_something() { diff --git a/Examples/test-suite/special_variable_macros.i b/Examples/test-suite/special_variable_macros.i index c168b4747..45eab0507 100644 --- a/Examples/test-suite/special_variable_macros.i +++ b/Examples/test-suite/special_variable_macros.i @@ -165,6 +165,20 @@ namespace Space { return new $typemap(jstype, Space::RenameMe)( new $typemap(jstype, Name)(s) ); } %} +#elif defined(SWIGD) +#if (SWIG_D_VERSION == 1) +%typemap(dcode) Space::RenameMe %{ + public static NewName factory(char[] s) { + return new $typemap(dptype, Space::RenameMe)( new $typemap(dptype, Name)(s) ); + } +%} +#else +%typemap(dcode) Space::RenameMe %{ + public static NewName factory(string s) { + return new $typemap(dptype, Space::RenameMe)( new $typemap(dptype, Name)(s) ); + } +%} +#endif #endif %rename(NewName) Space::RenameMe; diff --git a/Examples/test-suite/static_const_member.i b/Examples/test-suite/static_const_member.i index 3db60b4c2..945e28490 100644 --- a/Examples/test-suite/static_const_member.i +++ b/Examples/test-suite/static_const_member.i @@ -11,6 +11,9 @@ #elif SWIGCSHARP %csconst(1) EN; %csconst(1) CHARTEST; +#elif SWIGD +%dnativeconst EN; +%dnativeconst CHARTEST; #endif %inline %{ diff --git a/Examples/test-suite/template_enum.i b/Examples/test-suite/template_enum.i index 0d6fbf5b9..f36d5dc40 100644 --- a/Examples/test-suite/template_enum.i +++ b/Examples/test-suite/template_enum.i @@ -13,6 +13,10 @@ public: %template(foo_i) foo; %template(foo_d) foo; +#ifdef SWIGD +// Workaround for the D module which uses the literal value in the generated wrapper code. +%dconstvalue("3") Manta::ColorSpace::NumComponents; +#endif %inline { diff --git a/Examples/test-suite/template_inherit_abstract.i b/Examples/test-suite/template_inherit_abstract.i index 2f83433a5..87c921eab 100644 --- a/Examples/test-suite/template_inherit_abstract.i +++ b/Examples/test-suite/template_inherit_abstract.i @@ -4,7 +4,8 @@ %warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE, SWIGWARN_CSHARP_MULTIPLE_INHERITANCE, - SWIGWARN_PHP_MULTIPLE_INHERITANCE) oss::Module; /* C#, Java, PHP multiple inheritance */ + SWIGWARN_D_MULTIPLE_INHERITANCE, + SWIGWARN_PHP_MULTIPLE_INHERITANCE) oss::Module; /* C#, D, Java, PHP multiple inheritance */ %inline %{ @@ -56,7 +57,7 @@ namespace oss %inline %{ namespace oss { -#if defined(SWIG) && defined(SWIGCSHARP) +#if defined(SWIG) && (defined(SWIGCSHARP) || defined(SWIGD)) %ignore HModule::get(); // Work around for lack of multiple inheritance support - base ModuleBase is ignored. #endif struct test : HModule diff --git a/Examples/test-suite/typemap_namespace.i b/Examples/test-suite/typemap_namespace.i index 6614e0372..5a198b554 100644 --- a/Examples/test-suite/typemap_namespace.i +++ b/Examples/test-suite/typemap_namespace.i @@ -28,9 +28,16 @@ namespace Foo { #endif #ifdef SWIGGO %typemap(gotype) Str1 * = char *; +#endif +#ifdef SWIGD + %typemap(cwtype) Str1 * = char *; + %typemap(dwtype) Str1 * = char *; + %typemap(dptype) Str1 * = char *; + %typemap(din) Str1 * = char *; + %typemap(dout) Str1 * = char *; #endif %typemap(in) Str1 * = char *; -#if !(defined(SWIGCSHARP) || defined(SWIGLUA) || defined(SWIGPHP) || defined(SWIGMZSCHEME) || defined(SWIGOCAML) || defined(SWIGGO)) +#if !(defined(SWIGCSHARP) || defined(SWIGLUA) || defined(SWIGPHP) || defined(SWIGMZSCHEME) || defined(SWIGOCAML) || defined(SWIGGO) || defined(SWIGD)) %typemap(freearg) Str1 * = char *; #endif %typemap(typecheck) Str1 * = char *; diff --git a/Examples/test-suite/typemap_out_optimal.i b/Examples/test-suite/typemap_out_optimal.i index 23cd2ad3f..d707ed2d5 100644 --- a/Examples/test-suite/typemap_out_optimal.i +++ b/Examples/test-suite/typemap_out_optimal.i @@ -2,7 +2,7 @@ %module typemap_out_optimal // Just the following languages tested -#if defined (SWIGCSHARP) +#if defined (SWIGCSHARP) || defined (SWIGD) %typemap(out, optimal="1") SWIGTYPE %{ $result = new $1_ltype((const $1_ltype &)$1); %} @@ -18,6 +18,10 @@ %ignore XX::operator=; +#ifdef SWIGD +%rename(trace) XX::debug; +#endif + %inline %{ #include using namespace std; diff --git a/Examples/test-suite/typemap_subst.i b/Examples/test-suite/typemap_subst.i index 1b1f8a3f4..91ac62020 100644 --- a/Examples/test-suite/typemap_subst.i +++ b/Examples/test-suite/typemap_subst.i @@ -61,8 +61,8 @@ $1 = ($ltype) temp; } -/* Java, C# and Go modules don't use SWIG's runtime type system */ -#if !defined(SWIGJAVA) && !defined(SWIGCSHARP) && !defined(SWIGGO) +/* Java, C#, Go and D modules don't use SWIG's runtime type system */ +#if !defined(SWIGJAVA) && !defined(SWIGCSHARP) && !defined(SWIGGO) && !defined(SWIGD) %inline %{ void foo(const struct xyzzy **TEST) {} %} diff --git a/Examples/test-suite/using_composition.i b/Examples/test-suite/using_composition.i index bd0f712b5..052412b5f 100644 --- a/Examples/test-suite/using_composition.i +++ b/Examples/test-suite/using_composition.i @@ -2,13 +2,16 @@ %warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE, SWIGWARN_CSHARP_MULTIPLE_INHERITANCE, - SWIGWARN_PHP_MULTIPLE_INHERITANCE) FooBar; // C#, Java, PHP multiple inheritance + SWIGWARN_D_MULTIPLE_INHERITANCE, + SWIGWARN_PHP_MULTIPLE_INHERITANCE) FooBar; // C#, D, Java, PHP multiple inheritance %warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE, SWIGWARN_CSHARP_MULTIPLE_INHERITANCE, - SWIGWARN_PHP_MULTIPLE_INHERITANCE) FooBar2; // C#, Java, PHP multiple inheritance + SWIGWARN_D_MULTIPLE_INHERITANCE, + SWIGWARN_PHP_MULTIPLE_INHERITANCE) FooBar2; // C#, D, Java, PHP multiple inheritance %warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE, SWIGWARN_CSHARP_MULTIPLE_INHERITANCE, - SWIGWARN_PHP_MULTIPLE_INHERITANCE) FooBar3; // C#, Java, PHP multiple inheritance + SWIGWARN_D_MULTIPLE_INHERITANCE, + SWIGWARN_PHP_MULTIPLE_INHERITANCE) FooBar3; // C#, D, Java, PHP multiple inheritance #ifdef SWIGLUA // lua only has one numeric type, so some overloads shadow each other creating warnings %warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) blah; #endif diff --git a/Examples/test-suite/using_extend.i b/Examples/test-suite/using_extend.i index e14cc28e8..c52f65c23 100644 --- a/Examples/test-suite/using_extend.i +++ b/Examples/test-suite/using_extend.i @@ -2,7 +2,8 @@ %warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE, SWIGWARN_CSHARP_MULTIPLE_INHERITANCE, - SWIGWARN_PHP_MULTIPLE_INHERITANCE) FooBar; // C#, Java, PHP multiple inheritance + SWIGWARN_D_MULTIPLE_INHERITANCE, + SWIGWARN_PHP_MULTIPLE_INHERITANCE) FooBar; // C#, D, Java, PHP multiple inheritance #ifdef SWIGLUA // lua only has one numeric type, so some overloads shadow each other creating warnings %warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) blah; #endif diff --git a/Examples/test-suite/using_namespace.i b/Examples/test-suite/using_namespace.i index ce02e9a87..1119b46f7 100644 --- a/Examples/test-suite/using_namespace.i +++ b/Examples/test-suite/using_namespace.i @@ -5,7 +5,8 @@ %warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE, SWIGWARN_CSHARP_MULTIPLE_INHERITANCE, - SWIGWARN_PHP_MULTIPLE_INHERITANCE) Hi; // C#, Java, PHP multiple inheritance + SWIGWARN_D_MULTIPLE_INHERITANCE, + SWIGWARN_PHP_MULTIPLE_INHERITANCE) Hi; // C#, D, Java, PHP multiple inheritance %inline %{ namespace hello From 03aefbc6e95d094a6de231e1f5264c0946e209a3 Mon Sep 17 00:00:00 2001 From: David Nadlinger Date: Thu, 18 Nov 2010 00:24:02 +0000 Subject: [PATCH 1069/1680] Added support for the D programming languge. It is still a bit rough around some edges, particularly with regard to multi-threading and operator overloading, and there are some documentation bits missing, but it should be fine for basic use. The test-suite should build and run fine with the current versions of DMD, LDC and Tango (at least) on Linux x86_64 and Mac OS X 10.6. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12299 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/D.html | 401 ++ Doc/Manual/Sections.html | 1 + Doc/Manual/chapters | 1 + Examples/Makefile.in | 89 +- Examples/d/callback/Makefile | 28 + Examples/d/callback/d1/runme.d | 36 + Examples/d/callback/d2/runme.d | 36 + Examples/d/callback/example.cxx | 4 + Examples/d/callback/example.h | 24 + Examples/d/callback/example.i | 13 + Examples/d/check.list | 9 + Examples/d/class/Makefile | 28 + Examples/d/class/d1/runme.d | 58 + Examples/d/class/d2/runme.d | 58 + Examples/d/class/example.cxx | 28 + Examples/d/class/example.h | 34 + Examples/d/class/example.i | 10 + Examples/d/constants/Makefile | 28 + Examples/d/constants/d1/runme.d | 28 + Examples/d/constants/d2/runme.d | 28 + Examples/d/constants/example.d | 23 + Examples/d/constants/example.i | 32 + Examples/d/enum/Makefile | 28 + Examples/d/enum/d1/runme.d | 28 + Examples/d/enum/d2/runme.d | 28 + Examples/d/enum/example.cxx | 37 + Examples/d/enum/example.h | 13 + Examples/d/enum/example.i | 11 + Examples/d/extend/Makefile | 28 + Examples/d/extend/d1/runme.d | 75 + Examples/d/extend/d2/runme.d | 75 + Examples/d/extend/example.cxx | 4 + Examples/d/extend/example.h | 56 + Examples/d/extend/example.i | 14 + Examples/d/funcptr/Makefile | 28 + Examples/d/funcptr/d1/runme.d | 34 + Examples/d/funcptr/d2/runme.d | 34 + Examples/d/funcptr/example.c | 19 + Examples/d/funcptr/example.h | 9 + Examples/d/funcptr/example.i | 16 + Examples/d/simple/Makefile | 28 + Examples/d/simple/d1/runme.d | 27 + Examples/d/simple/d2/runme.d | 27 + Examples/d/simple/example.c | 18 + Examples/d/simple/example.i | 7 + Examples/d/variables/Makefile | 28 + Examples/d/variables/d1/runme.d | 71 + Examples/d/variables/d2/runme.d | 71 + Examples/d/variables/example.c | 91 + Examples/d/variables/example.h | 6 + Examples/d/variables/example.i | 49 + Examples/test-suite/d/Makefile.in | 80 + Examples/test-suite/d/README | 7 + Examples/test-suite/d/aggregate_runme.1.d | 25 + Examples/test-suite/d/aggregate_runme.2.d | 25 + Examples/test-suite/d/allprotected_runme.1.d | 65 + Examples/test-suite/d/allprotected_runme.2.d | 65 + Examples/test-suite/d/apply_strings_runme.1.d | 12 + Examples/test-suite/d/apply_strings_runme.2.d | 12 + Examples/test-suite/d/bools_runme.1.d | 20 + Examples/test-suite/d/bools_runme.2.d | 20 + Examples/test-suite/d/catches_runme.1.d | 33 + Examples/test-suite/d/catches_runme.2.d | 33 + Examples/test-suite/d/char_strings_runme.1.d | 151 + Examples/test-suite/d/char_strings_runme.2.d | 123 + Examples/test-suite/d/constover_runme.1.d | 31 + Examples/test-suite/d/constover_runme.2.d | 16 + .../test-suite/d/d_nativepointers_runme.1.d | 23 + .../test-suite/d/d_nativepointers_runme.2.d | 23 + Examples/test-suite/d/default_args_runme.1.d | 127 + Examples/test-suite/d/default_args_runme.2.d | 84 + .../d/default_constructor_runme.1.d | 30 + .../d/default_constructor_runme.2.d | 25 + .../test-suite/d/director_basic_runme.1.d | 59 + .../test-suite/d/director_basic_runme.2.d | 46 + .../test-suite/d/director_classes_runme.1.d | 168 + .../test-suite/d/director_classes_runme.2.d | 169 + .../test-suite/d/director_classic_runme.1.d | 207 + .../test-suite/d/director_classic_runme.2.d | 202 + .../test-suite/d/director_ignore_runme.1.d | 39 + .../test-suite/d/director_ignore_runme.2.d | 38 + .../d/director_primitives_runme.1.d | 122 + .../d/director_primitives_runme.2.d | 123 + .../test-suite/d/director_protected_runme.1.d | 50 + .../test-suite/d/director_protected_runme.2.d | 36 + .../test-suite/d/director_string_runme.1.d | 46 + .../test-suite/d/director_string_runme.2.d | 42 + Examples/test-suite/d/enum_thorough_runme.1.d | 424 ++ Examples/test-suite/d/enum_thorough_runme.2.d | 425 ++ .../d/inherit_target_language_runme.1.d | 29 + .../d/inherit_target_language_runme.2.d | 29 + Examples/test-suite/d/li_attribute_runme.1.d | 75 + Examples/test-suite/d/li_attribute_runme.2.d | 58 + .../d/li_boost_shared_ptr_bits_runme.1.d | 21 + .../d/li_boost_shared_ptr_bits_runme.2.d | 19 + .../d/li_boost_shared_ptr_runme.1.d | 604 +++ .../d/li_boost_shared_ptr_runme.2.d | 602 +++ Examples/test-suite/d/li_std_except_runme.1.d | 40 + Examples/test-suite/d/li_std_except_runme.2.d | 34 + Examples/test-suite/d/li_std_string_runme.1.d | 97 + Examples/test-suite/d/li_std_string_runme.2.d | 86 + Examples/test-suite/d/li_std_vector_runme.1.d | 219 + Examples/test-suite/d/li_std_vector_runme.2.d | 207 + Examples/test-suite/d/li_typemaps_runme.1.d | 94 + Examples/test-suite/d/li_typemaps_runme.2.d | 91 + Examples/test-suite/d/long_long_runme.1.d | 35 + Examples/test-suite/d/long_long_runme.2.d | 32 + .../test-suite/d/member_pointer_runme.1.d | 43 + .../test-suite/d/member_pointer_runme.2.d | 42 + .../d/overload_complicated_runme.1.d | 50 + .../d/overload_complicated_runme.2.d | 34 + .../test-suite/d/overload_template_runme.1.d | 146 + .../test-suite/d/overload_template_runme.2.d | 80 + .../test-suite/d/pointer_reference_runme.1.d | 13 + .../test-suite/d/pointer_reference_runme.2.d | 14 + .../d/preproc_constants_c_runme.1.d | 63 + .../d/preproc_constants_c_runme.2.d | 63 + .../test-suite/d/preproc_constants_runme.1.d | 62 + .../test-suite/d/preproc_constants_runme.2.d | 62 + Examples/test-suite/d/sizet_runme.1.d | 15 + Examples/test-suite/d/sizet_runme.2.d | 14 + Examples/test-suite/d/sneaky1_runme.1.d | 21 + Examples/test-suite/d/sneaky1_runme.2.d | 11 + .../d/special_variable_macros_runme.1.d | 39 + .../d/special_variable_macros_runme.2.d | 21 + Examples/test-suite/d/threads_runme.1.d | 70 + Examples/test-suite/d/threads_runme.2.d | 55 + .../test-suite/d/throw_exception_runme.1.d | 30 + .../test-suite/d/throw_exception_runme.2.d | 30 + .../test-suite/d/typemap_namespace_runme.1.d | 13 + .../test-suite/d/typemap_namespace_runme.2.d | 9 + .../d/typemap_out_optimal_runme.1.d | 9 + .../d/typemap_out_optimal_runme.2.d | 9 + Examples/test-suite/d/varargs_runme.1.d | 20 + Examples/test-suite/d/varargs_runme.2.d | 13 + Examples/test-suite/d/virtual_poly_runme.1.d | 27 + Examples/test-suite/d/virtual_poly_runme.2.d | 22 + Examples/test-suite/d_nativepointers.i | 18 + Lib/allkw.swg | 1 + Lib/d/boost_shared_ptr.i | 201 + Lib/d/carrays.i | 111 + Lib/d/cpointer.i | 171 + Lib/d/d.swg | 46 + Lib/d/dclassgen.swg | 172 + Lib/d/ddirectives.swg | 11 + Lib/d/denums.swg | 60 + Lib/d/dexception.swg | 30 + Lib/d/dhead.swg | 310 ++ Lib/d/director.swg | 46 + Lib/d/dkw.swg | 126 + Lib/d/dmemberfunctionpointers.swg | 92 + Lib/d/doperators.swg | 77 + Lib/d/dprimitives.swg | 158 + Lib/d/dstrings.swg | 80 + Lib/d/dswigtype.swg | 177 + Lib/d/dvoid.swg | 18 + Lib/d/std_common.i | 5 + Lib/d/std_deque.i | 1 + Lib/d/std_except.i | 30 + Lib/d/std_map.i | 59 + Lib/d/std_pair.i | 34 + Lib/d/std_shared_ptr.i | 2 + Lib/d/std_string.i | 98 + Lib/d/std_vector.i | 591 +++ Lib/d/stl.i | 12 + Lib/d/typemaps.i | 298 ++ Lib/d/wrapperloader.swg | 303 ++ Lib/exception.i | 36 +- Lib/std_except.i | 2 +- Lib/swig.swg | 4 +- Makefile.in | 17 +- Source/Include/swigwarn.h | 21 +- Source/Makefile.am | 1 + Source/Modules/d.cxx | 4359 +++++++++++++++++ Source/Modules/swigmain.cxx | 2 + configure.in | 43 + 176 files changed, 16449 insertions(+), 29 deletions(-) create mode 100644 Doc/Manual/D.html create mode 100644 Examples/d/callback/Makefile create mode 100644 Examples/d/callback/d1/runme.d create mode 100644 Examples/d/callback/d2/runme.d create mode 100644 Examples/d/callback/example.cxx create mode 100644 Examples/d/callback/example.h create mode 100644 Examples/d/callback/example.i create mode 100644 Examples/d/check.list create mode 100644 Examples/d/class/Makefile create mode 100644 Examples/d/class/d1/runme.d create mode 100644 Examples/d/class/d2/runme.d create mode 100644 Examples/d/class/example.cxx create mode 100644 Examples/d/class/example.h create mode 100644 Examples/d/class/example.i create mode 100644 Examples/d/constants/Makefile create mode 100644 Examples/d/constants/d1/runme.d create mode 100644 Examples/d/constants/d2/runme.d create mode 100644 Examples/d/constants/example.d create mode 100644 Examples/d/constants/example.i create mode 100644 Examples/d/enum/Makefile create mode 100644 Examples/d/enum/d1/runme.d create mode 100644 Examples/d/enum/d2/runme.d create mode 100644 Examples/d/enum/example.cxx create mode 100644 Examples/d/enum/example.h create mode 100644 Examples/d/enum/example.i create mode 100644 Examples/d/extend/Makefile create mode 100644 Examples/d/extend/d1/runme.d create mode 100644 Examples/d/extend/d2/runme.d create mode 100644 Examples/d/extend/example.cxx create mode 100644 Examples/d/extend/example.h create mode 100644 Examples/d/extend/example.i create mode 100644 Examples/d/funcptr/Makefile create mode 100644 Examples/d/funcptr/d1/runme.d create mode 100644 Examples/d/funcptr/d2/runme.d create mode 100644 Examples/d/funcptr/example.c create mode 100644 Examples/d/funcptr/example.h create mode 100644 Examples/d/funcptr/example.i create mode 100644 Examples/d/simple/Makefile create mode 100644 Examples/d/simple/d1/runme.d create mode 100644 Examples/d/simple/d2/runme.d create mode 100644 Examples/d/simple/example.c create mode 100644 Examples/d/simple/example.i create mode 100644 Examples/d/variables/Makefile create mode 100644 Examples/d/variables/d1/runme.d create mode 100644 Examples/d/variables/d2/runme.d create mode 100644 Examples/d/variables/example.c create mode 100644 Examples/d/variables/example.h create mode 100644 Examples/d/variables/example.i create mode 100644 Examples/test-suite/d/Makefile.in create mode 100644 Examples/test-suite/d/README create mode 100644 Examples/test-suite/d/aggregate_runme.1.d create mode 100644 Examples/test-suite/d/aggregate_runme.2.d create mode 100644 Examples/test-suite/d/allprotected_runme.1.d create mode 100644 Examples/test-suite/d/allprotected_runme.2.d create mode 100644 Examples/test-suite/d/apply_strings_runme.1.d create mode 100644 Examples/test-suite/d/apply_strings_runme.2.d create mode 100644 Examples/test-suite/d/bools_runme.1.d create mode 100644 Examples/test-suite/d/bools_runme.2.d create mode 100644 Examples/test-suite/d/catches_runme.1.d create mode 100644 Examples/test-suite/d/catches_runme.2.d create mode 100644 Examples/test-suite/d/char_strings_runme.1.d create mode 100644 Examples/test-suite/d/char_strings_runme.2.d create mode 100644 Examples/test-suite/d/constover_runme.1.d create mode 100644 Examples/test-suite/d/constover_runme.2.d create mode 100644 Examples/test-suite/d/d_nativepointers_runme.1.d create mode 100644 Examples/test-suite/d/d_nativepointers_runme.2.d create mode 100644 Examples/test-suite/d/default_args_runme.1.d create mode 100644 Examples/test-suite/d/default_args_runme.2.d create mode 100644 Examples/test-suite/d/default_constructor_runme.1.d create mode 100644 Examples/test-suite/d/default_constructor_runme.2.d create mode 100644 Examples/test-suite/d/director_basic_runme.1.d create mode 100644 Examples/test-suite/d/director_basic_runme.2.d create mode 100644 Examples/test-suite/d/director_classes_runme.1.d create mode 100644 Examples/test-suite/d/director_classes_runme.2.d create mode 100644 Examples/test-suite/d/director_classic_runme.1.d create mode 100644 Examples/test-suite/d/director_classic_runme.2.d create mode 100644 Examples/test-suite/d/director_ignore_runme.1.d create mode 100644 Examples/test-suite/d/director_ignore_runme.2.d create mode 100644 Examples/test-suite/d/director_primitives_runme.1.d create mode 100644 Examples/test-suite/d/director_primitives_runme.2.d create mode 100644 Examples/test-suite/d/director_protected_runme.1.d create mode 100644 Examples/test-suite/d/director_protected_runme.2.d create mode 100644 Examples/test-suite/d/director_string_runme.1.d create mode 100644 Examples/test-suite/d/director_string_runme.2.d create mode 100644 Examples/test-suite/d/enum_thorough_runme.1.d create mode 100644 Examples/test-suite/d/enum_thorough_runme.2.d create mode 100644 Examples/test-suite/d/inherit_target_language_runme.1.d create mode 100644 Examples/test-suite/d/inherit_target_language_runme.2.d create mode 100644 Examples/test-suite/d/li_attribute_runme.1.d create mode 100644 Examples/test-suite/d/li_attribute_runme.2.d create mode 100644 Examples/test-suite/d/li_boost_shared_ptr_bits_runme.1.d create mode 100644 Examples/test-suite/d/li_boost_shared_ptr_bits_runme.2.d create mode 100644 Examples/test-suite/d/li_boost_shared_ptr_runme.1.d create mode 100644 Examples/test-suite/d/li_boost_shared_ptr_runme.2.d create mode 100644 Examples/test-suite/d/li_std_except_runme.1.d create mode 100644 Examples/test-suite/d/li_std_except_runme.2.d create mode 100644 Examples/test-suite/d/li_std_string_runme.1.d create mode 100644 Examples/test-suite/d/li_std_string_runme.2.d create mode 100644 Examples/test-suite/d/li_std_vector_runme.1.d create mode 100644 Examples/test-suite/d/li_std_vector_runme.2.d create mode 100644 Examples/test-suite/d/li_typemaps_runme.1.d create mode 100644 Examples/test-suite/d/li_typemaps_runme.2.d create mode 100644 Examples/test-suite/d/long_long_runme.1.d create mode 100644 Examples/test-suite/d/long_long_runme.2.d create mode 100644 Examples/test-suite/d/member_pointer_runme.1.d create mode 100644 Examples/test-suite/d/member_pointer_runme.2.d create mode 100644 Examples/test-suite/d/overload_complicated_runme.1.d create mode 100644 Examples/test-suite/d/overload_complicated_runme.2.d create mode 100644 Examples/test-suite/d/overload_template_runme.1.d create mode 100644 Examples/test-suite/d/overload_template_runme.2.d create mode 100644 Examples/test-suite/d/pointer_reference_runme.1.d create mode 100644 Examples/test-suite/d/pointer_reference_runme.2.d create mode 100644 Examples/test-suite/d/preproc_constants_c_runme.1.d create mode 100644 Examples/test-suite/d/preproc_constants_c_runme.2.d create mode 100644 Examples/test-suite/d/preproc_constants_runme.1.d create mode 100644 Examples/test-suite/d/preproc_constants_runme.2.d create mode 100644 Examples/test-suite/d/sizet_runme.1.d create mode 100644 Examples/test-suite/d/sizet_runme.2.d create mode 100644 Examples/test-suite/d/sneaky1_runme.1.d create mode 100644 Examples/test-suite/d/sneaky1_runme.2.d create mode 100644 Examples/test-suite/d/special_variable_macros_runme.1.d create mode 100644 Examples/test-suite/d/special_variable_macros_runme.2.d create mode 100644 Examples/test-suite/d/threads_runme.1.d create mode 100644 Examples/test-suite/d/threads_runme.2.d create mode 100644 Examples/test-suite/d/throw_exception_runme.1.d create mode 100644 Examples/test-suite/d/throw_exception_runme.2.d create mode 100644 Examples/test-suite/d/typemap_namespace_runme.1.d create mode 100644 Examples/test-suite/d/typemap_namespace_runme.2.d create mode 100644 Examples/test-suite/d/typemap_out_optimal_runme.1.d create mode 100644 Examples/test-suite/d/typemap_out_optimal_runme.2.d create mode 100644 Examples/test-suite/d/varargs_runme.1.d create mode 100644 Examples/test-suite/d/varargs_runme.2.d create mode 100644 Examples/test-suite/d/virtual_poly_runme.1.d create mode 100644 Examples/test-suite/d/virtual_poly_runme.2.d create mode 100644 Examples/test-suite/d_nativepointers.i create mode 100644 Lib/d/boost_shared_ptr.i create mode 100644 Lib/d/carrays.i create mode 100644 Lib/d/cpointer.i create mode 100644 Lib/d/d.swg create mode 100644 Lib/d/dclassgen.swg create mode 100644 Lib/d/ddirectives.swg create mode 100644 Lib/d/denums.swg create mode 100644 Lib/d/dexception.swg create mode 100644 Lib/d/dhead.swg create mode 100644 Lib/d/director.swg create mode 100644 Lib/d/dkw.swg create mode 100644 Lib/d/dmemberfunctionpointers.swg create mode 100644 Lib/d/doperators.swg create mode 100644 Lib/d/dprimitives.swg create mode 100644 Lib/d/dstrings.swg create mode 100644 Lib/d/dswigtype.swg create mode 100644 Lib/d/dvoid.swg create mode 100644 Lib/d/std_common.i create mode 100644 Lib/d/std_deque.i create mode 100644 Lib/d/std_except.i create mode 100644 Lib/d/std_map.i create mode 100644 Lib/d/std_pair.i create mode 100644 Lib/d/std_shared_ptr.i create mode 100644 Lib/d/std_string.i create mode 100644 Lib/d/std_vector.i create mode 100644 Lib/d/stl.i create mode 100644 Lib/d/typemaps.i create mode 100644 Lib/d/wrapperloader.swg create mode 100644 Source/Modules/d.cxx diff --git a/Doc/Manual/D.html b/Doc/Manual/D.html new file mode 100644 index 000000000..2b563788f --- /dev/null +++ b/Doc/Manual/D.html @@ -0,0 +1,401 @@ + + + +SWIG and D + + + + +

    20 SWIG and D

    + + + + + + +

    20.1 Introduction

    + + +

    From the D Programming Language web site: »D is a systems programming language. Its focus is on combining the power and high performance of C and C++ with the programmer productivity of modern languages like Ruby and Python. […] The D language is statically typed and compiles directly to machine code.« As such, it is not very surprising that D is able to directly interface with C libraries. Why would a SWIG module for D be needed then in the first place?

    + +

    Well, besides the obvious downside that the C header files have to be manually converted to D modules for this to work, there is one major inconvenience with this approach: D code usually is on a higher abstraction level than C, and many of the features that make D interesting are simply not available when dealing with C libraries, requiring you e.g. to manually convert strings between pointers to \0-terminated char arrays and D char arrays, making the algorithms from the D2 standard library unusable with C arrays and data structures, and so on.

    + +

    While these issues can be worked around relatively easy by hand-coding a thin wrapper layer around the C library in question, there is another issue where writing wrapper code per hand is not feasible: C++ libraries. D did not support interfacing to C++ in version 1 at all, and even if extern(C++) has been added to D2, the support is still very limited, and a custom wrapper layer is still required in many cases.

    + +

    To help addressing these issues, the SWIG C# module has been forked to support D. Is has evolved quite a lot since then, but there are still many similarities, so if you do not find what you are looking for on this page, it might be worth having a look at the chapter on C# (and also on Java, since the C# module was in turn forked from it).

    + + +

    20.2 Command line invocation

    + + +

    To activate the D module, pass the -d option to SWIG at the command line. The same standard command line switches as with any other language module are available, plus the following D specific ones:

    + +
    +
    -splitproxy
    +
    +

    By default, SWIG generates two D modules: the proxy module, named like the source module (either specified via the %module directive or via the module command line switch), which contains all the proxy classes, functions, enums, etc., and the wrap module (named like the proxy module, but suffixed with _wrap), which contains all the extern(C) function declarations and other private parts only used internally by the proxy module.

    +

    If the split proxy mode is enabled by passing this switch at the command line, all proxy classes and enums are emitted to their own D module instead. The main proxy module only contains free functions and constants in this case.

    +
    + +
    -package <pkg>
    +
    +

    By default, the proxy D modules and the wrap D module are written to the root package. Using this option, you can specify another target package instead.

    +
    + +
    -wrapperlibrary <wl>
    +
    +

    The code SWIG generates to dynamically load the C/C++ wrapper layer looks for a library called $module_wrap, just like the wrap D module is. With this switch, you can override the name of the file the wrapper code loads at runtime (the lib prefix and the suffix for shared libraries are appended automatically, depending on the OS).

    +

    This might especially be useful if you want to invoke SWIG several times on separate modules, but compile the resulting code into a single shared library.

    +
    +
    + + +

    20.3 Typemaps

    + + +

    20.3.1 C# <-> D name comparison

    + + +
    + ctype                  <->  cwtype
    + imtype                 <->  dwtype
    + cstype                 <->  dptype
    + csin                   <->  din
    + csout                  <->  dout
    + csdirectorin           <->  ddirectorin
    + csdirectorout          <->  ddirectorout
    + csinterfaces           <->  dinterfaces
    + csinterfaces_derived   <->  dinterfaces_derived
    + csbase                 <->  dbase
    + csclassmodifiers       <->  dclassmodifiers
    + cscode                 <->  dcode
    + csimports              <->  dimports
    + csbody                 <->  dbody
    + csfinalize             <->  ddestructor
    + csdestruct             <->  ddispose
    + csdestruct_derived     <->  ddispose_derived
    +
    + + +

    20.3.2 cwtype, dwtype, dptype

    + + +

    Mapping of types between the C/C++ library, the C/C++ library wrapper exposing the C functions, the D wrapper module importing these functions and the D proxy code.

    + +

    The cwtype typemap is used to determine the types to use in the C wrapper functions. The types from the dwtype typemap are used in the extern(C) declarations of these functions in the D wrap module. The dptype typemap contains the D types used in the D proxy module/class.

    + + +

    20.3.3 in, out, directorin, directorout

    + + +

    Used for converting between the types for C/C++ and D when generating the code for the wrapper functions (on the C++ side).

    + +

    The code from the in typemap is used to convert arguments to the C wrapper function to the type used in the wrapped code (cwtype->original C++ type), the out typemap is utilized to convert values from the wrapped code to wrapper function return types (original C++ type->cwtype).

    + +

    The directorin typemap is used to convert parameters to the type used in the D director callback function, its return value is processed by directorout (see below).

    + + +

    20.3.4 din, dout, ddirectorin, ddirectorout

    + + +

    Typemaps for code generation in D proxy and type wrapper classes.

    + +

    The din typemap is used for converting function parameter types from the type used in the proxy module or class to the type used in the D wrap module (the $dinput macro is replaced).

    + +

    The dout typemap is used for converting function return values from the return type used in the wrap D module to the type returned by the proxy function. The $excode special variable in dout typemaps is replaced by the excode typemap attribute code if the method can throw any exceptions from unmanaged code, otherwise by nothing (the $wcall and $owner macros are replaced).

    + +

    The code from the ddirectorin and ddirectorout typemaps is used for conversion in director callback functions. Arguments are converted to the type used in the proxy class method they are calling by using the code from ddirectorin, the proxy class method return value is converted to the type the C++ code expects via the ddirectorout typemap (the $dpcall and $winput macros are replaced).

    + +

    The full chain of type conversions when a director callback is invoked looks like this:

    + +
          type CPPClass::method(type a)
    +        ↑                     ↓
    +   <directorout>         <directorin>
    +        ↑                     ↓
    +     cwtype methodCallback(cwtype a)    C++
    + ::::::::::::::::::::::::::::::::::::::::::
    +     dwtype methodCallback(dwtype a)    D
    +        ↑                     ↓
    +  <ddirectorout>       <ddirectorin>
    +        ↑                     ↓
    +      dptype DClass.method(dptype a)
    + + +

    20.3.5 typecheck typemaps

    + + +

    Because, unlike many scripting languages supported by SWIG, D does not need any dynamic dispatch helper to access an overloaded function, the purpose of these is merely to issue a warning for overloaded C++ functions that cannot be overloaded in D (as more than one C++ type maps to a single D type).

    + + +

    20.3.6 Code injection typemaps

    + + +

    These typemaps are used for generating the skeleton of proxy classes for C++ types.

    + +

    By overriding dbase, dinterfaces or dinterfaces_derived, the inheritance chain of the generated proxy class for a type can be modified. dclassmodifiers allows you to add any custom modifiers around the class keyword.

    + +

    Using dcode and dimports, you can specify additional D code which will be emitted into the class body respectively the imports section of the D module the class is written to.

    + +

    dconstructor, ddestructor, ddispose and ddispose_derived are used to generate the class constructor, destructor and dispose() method, respectively. The auxiliary code for handling the pointer to the C++ object is stored in dbody and dbody_derived. You can override them for specific types.

    + + +

    20.3.7 Special variable macros

    + + +

    The standard SWIG special variables are available for use within typemaps as described in the Typemaps documentation, for example $1, $input, $result etc.

    + +

    When generating D wrappers, a few additional macros are available:

    +
    +
    $dclassname (C#: $csclassname)
    +
    +

    This special variable works similar to $n_type in that it returns the name of a type – it expands to the D proxy class name of the type being wrapped. If the type does not have an associated proxy class, it expands to the type wrapper class name, for example, SWIGTYPE_p_p_SomeCppClass is generated when wrapping SomeCppClass **.

    +

    There are two other variants available, $&dclassname and $*dclassname. The former adds a level of indirection, while the latter removes one. For instance, when wrapping Foo **, $*dclassname would be replaced by the proxy class name corresponding to Foo *.

    +
    + +
    $null
    +

    In code inserted into the generated C/C++ wrapper functions, this variable is replaced by either 0 or nothing at all, depending on whether the function has a return value or not. It can be used to bail out early e.g. in case of errors (return $null;).

    + +
    $dinput (C#: $csinput)
    +
    +

    This variable is used in din typemaps and is replaced by the expression which is to be passed to C/C++.

    +

    For example, this input

    +
    +%typemap(din) SomeClass * "SomeClass.getCPointer($dinput)"
    +
    +%inline %{
    +  class SomeClass {};
    +  void foo(SomeClass *arg);
    +%}
    +

    leads to the following D proxy code being generated:

    +
    +void foo(SomeClass arg) {
    +  example_wrap.foo(SomeClass.getCPointer(arg));
    +}
    + +
    $wcall and $owner (C#: $imcall)
    +
    +

    These variables are used in dout typemaps. $wcall contains the call to the wrapper layer which provides the value to be used, and $owner signals if the caller is responsible for managing the object lifetime (that is, if the called method is a constructor or has been marked via %newobject).

    +

    Consider the following example:

    +
    +%typemap(dout) SomeClass * {
    +  return new SomeClass($wcall, $owner);
    +}
    +
    +%inline %{
    +  class SomeClass;
    +  SomeClass *foo();
    +
    +  %newobject bar();
    +  SomeClass *bar();
    +%}
    +

    The code generated for foo() and bar() looks like this:

    +
    +SomeClass foo() {
    +  return new SomeClass(example_wrap.foo(), false);
    +}
    +
    +SomeClass bar() {
    +  return new SomeClass(example_wrap.bar(), true);
    +}
    +
    +
    + +
    $dpcall and $winput (C#: $cscall, $iminput)
    +

    These variables are used in the director-specific typemaps ddirectorin and ddirectorout. They are more or less the reverse of the $wcall and $dinput macros: $dpcall contains the invocation of the D proxy method of which the return value is to be passed back to C++, $winput contains the parameter value from C++.

    + +
    $excode
    +

    This variable is used in dout and dconstructor typemaps and is filled with the contents of the excode typemap attribute if an exception could be thrown from the C++ side. See the C# documentation for details.

    + +
    $dbaseclass
    +

    Currently for internal use only, it contains the D name of the C++ base class (if any) inside proxy classes.

    + +
    $directorconnect
    +
    +

    This macro is only valid inside the dconstructor typemap and contains the value of the dconstructor typemap attribute if the currently wrapped class has directors enabled.

    +

    This is how the default dconstructor typemap looks like (you usually do not want to specify a custom one):

    +
    +%typemap(dconstructor, excode=SWIGEXCODE,directorconnect="\n  swigDirectorConnect();") SWIGTYPE {
    +  this($wcall, true);$excode$directorconnect
    +}
    +
    +
    + +
    $importtype(SomeDType)
    +
    +

    This macro is used in the dimports typemap if a dependency on another D type generated by SWIG is added by a custom typemap.

    +

    Consider the following code snippet:

    +
    +%typemap(dinterfaces) SomeClass "AnInterface, AnotherInterface";
    +
    +

    This causes SWIG to add AnInterface and AnotherInterface to the base class list of SomeClass:

    +
    +class SomeClass : AnInterface, AnotherInterface {
    +  …
    +}
    +
    +

    For this to work, AnInterface and AnotherInterface have to be in scope. If SWIG is not in split proxy mode, this is already the case, but it it is, they have to be added to the import list via the dimports typemap. Additionally, the import statement depends on the package SWIG is configured to emit the modules to.

    +

    The $importtype macro helps you to elegantly solve this problem:

    +
    +%typemap(dimports) RemoteMpe %{
    +$importtype(AnInterface)
    +$importtype(AnotherInterface)
    +%}
    +
    +

    If SWIG is in split proxy mode, it expands to an import statement for the specified type, to nothing if not.

    +
    + +
    $module
    +

    Expands to the name of the main proxy D module.

    + +
    $wrapdmodule
    +

    Contains the fully qualified name of the wrap D module.

    +
    + + +

    20.4 %features

    + + +

    The D module defines a number of directives which modify the SWIG features set globally or for a specific declaration:

    + + +
    +
    %dnativeconst and %dconstvalue(value)
    +
    +

    Out of the box, SWIG generates accessor methods for C #defines and C++ constants. The %dnativeconst directive enables wrapping these constants as D manifest constants (const in D1, enum in D2).

    +

    For this to work, the C/C++ code for the constant value must directly compile as D code, though. If this is not the case, you can manually override the expression written to the D wrapper using the %dconstvalue directive, passing the new value as parameter.

    +

    For enums, again %dconstvalue can be used to override the value of an enum item if the initializer should not compile in D.

    +
    + +
    %dmethodmodifiers
    +
    +

    This directive can be used to override the modifiers for a proxy function. For instance, you could make a public C++ member function private in D like this:

    +
    +%dmethodmodifiers A::foo "private";
    +
    +%inline %{
    +struct A {
    +  void foo();
    +};
    +%}
    +
    +
    +
    + + +

    20.5 Pragmas

    + + +

    There are a few SWIG pragmas specific to the D module, which you can use to influence the D code SWIG generates:

    + +
    +
    %pragma(d) wrapdmodulecode
    +

    The passed text (D code) is copied verbatim to the wrap D module. For example, it can be (and is, internally) used to emit additional private helper code for the use by proxy typemaps.

    + +
    %pragma(d) wrapdmoduleimports
    +

    Additional code to be emitted to the imports section of the wrap D module (the $importtype macro can be used here). You probably want to use this in conjunction with the wrapdmodulecode pragma.

    + +
    %pragma(d) proxydmodulecode
    +

    Just like proxydmodulecode, the argument is copied to the proxy D module (if SWIG is in split proxy mode, it is emitted to the main proxy D module only).

    + +
    %pragma(d) globalproxyimports
    +
    +

    The D module currently does not support specifying dependencies on external modules (e.g. from the standard library) for the D typemaps. To add the import statements to the proxy modules (resp. to all proxy modules if in split proxy mode), you can use the globalproxyimports directive.

    +

    For example:

    +
    +%typemap(din) char[] "($dinput ? tango.stdc.stringz.toStringz($dinput) : null)"
    +%pragma(d) globalproxyimports = "static import tango.stdc.stringz;";
    +
    +
    + +
    %pragma(d) wrapperloadercode
    +
    +

    The D code for loading the wrapper library (it is copied to the wrap D module). The $wrapperloaderbindcode variable is replaced by the list of commands for binding the functions from the wrapper library to the symbols in the wrap D module.

    +

    Each time this pragma is specified, the previous value is overwritten.

    +
    + +
    %pragma(d) wrapperloaderbindcommand
    +
    +

    The D command to use for binding the wrapper functions from the C/C++ library to the symbols in the wrap D module. The $function variable contains the name of the D function in the wrap module, the $symbol variable is replaced by the name of the symbol in the library.

    +

    Each time this pragma is specified, the previous value is overwritten.

    +
    +
    + + +

    20.6 D Exceptions

    + + +

    Out of the box, C++ exceptions are fundamentally incompatible to their equivalent in the D world and cannot simply be propagated to a calling D method. There is, however, an easy way to solve this problem: Just catch the exception in the C/C++ wrapper layer, pass the contents to D, and make the wrapper code rethrow the exception in the D world.

    + +

    The implementation details of this are a bit crude, but the SWIG D module automatically takes care of this, as long as it is able to detect that an exception could potentially be thrown (e.g. because the C++ method has a throw(…) exception specification).

    + +

    As this feature is implemented in exactly the same way it is for C#, please see the C# documentation for a more detailed explanation.

    + + +

    20.7 D Directors

    + + +

    When the directors feature is activated, SWIG generates extra code on both the C++ and the D side to enable cross-language polymorphism. Essentially, this means that if you subclass a proxy class in D, C++ code can access any overridden virtual methods just as if you created a derived class in C++.

    + +

    There is no D specific documentation yet, but the way the feature is implemented is very similar to how it is done in Java and C#. +

    + + +

    20.8 Other features

    + + +

    The nspace feature of SWIG is not yet supported for D – all class modules are written to the same package, regardless of which C++ namespace they are in.

    + +

    Support of pointers to primitive types.

    + + +

    20.9 D Typemap examples

    + + +

    There are no D-specific typemap examples yet. However, with the above name comparison table, you should be able to get an idea what can be done by looking at the corresponding C# section.

    + + + +

    20.10 Work in progress and planned features

    + + +

    There are a couple of features which are not implemented yet, but would be very useful and might be added in the near future:

    + +
      +
    • Static linking: Currently, the C wrapper code is compiled into a dynamic library, out of which the symbol addresses are looked up at runtime by the D part. If statically linking the different languages into one binary was supported, a tool-chain capable of performing IPO at link time could inline the wrapping code, effectively reducing the overhead for simple calls to zero.
    • +
    • C array handling: Many data structures in some C/C++ libraries contain array containing of a pointer to the first element and the element count. Currently, one must manually writing wrapper code to be able to access these from D. It should be possible to add a set of SWIG macros to semi-automatically generate conversion code.
    • +
    • Operator overloading: Currently, operator overloading is supported only to a very limited extent – many C++ operators are just ignored with a warning. The problem here is that the way D handles operator overloading differs quite a lot from the way C++ does it, both syntactically and semantically, and even more so since the advent of template-based operator overloading in D2.
    • +
    + +

    Some generated code might also be a bit rough around the edges, particularly in the following areas:

    + +
      +
    • Memory management: Although the currently generated wrapper code works fine with regard to the GC for the test-suite, there might be issues coming up in real-world multi-threaded usage.
    • +
    • D2 support: Originally, the module has been developed for the use with D1, D2/Phobos support has been added in later. The basic features should work equally well for both, but there could be issues concerning const-correctness etc.
    • +
    + + + + + diff --git a/Doc/Manual/Sections.html b/Doc/Manual/Sections.html index 855244790..a44571992 100644 --- a/Doc/Manual/Sections.html +++ b/Doc/Manual/Sections.html @@ -52,6 +52,7 @@ Last update : SWIG-2.0.2 (in progress)
  • R support
  • Ruby support
  • Tcl support
  • +
  • D support
  • Developer Documentation

    diff --git a/Doc/Manual/chapters b/Doc/Manual/chapters index e918e234a..924c8cfde 100644 --- a/Doc/Manual/chapters +++ b/Doc/Manual/chapters @@ -17,6 +17,7 @@ CCache.html Allegrocl.html CSharp.html Chicken.html +D.html Go.html Guile.html Java.html diff --git a/Examples/Makefile.in b/Examples/Makefile.in index 582c75f29..5d5590311 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -69,7 +69,7 @@ IOBJS = $(IWRAP:.i=.@OBJEXT@) CPP_DLLIBS = #-L/usr/local/lib/gcc-lib/sparc-sun-solaris2.5.1/2.7.2 \ -L/usr/local/lib -lg++ -lstdc++ -lgcc -# Solaris workshop 5.0 +# Solaris workshop 5.0 # CPP_DLLIBS = -L/opt/SUNWspro/lib -lCrun # Symbols used for using shared libraries @@ -159,7 +159,7 @@ tcl_cpp: $(SRCS) # ----------------------------------------------------------------- tcl_clean: - rm -f *_wrap* *~ .~* mytclsh@EXEEXT@ + rm -f *_wrap* *~ .~* mytclsh@EXEEXT@ rm -f core @EXTRA_CLEAN@ rm -f *.@OBJEXT@ *@SO@ @@ -296,9 +296,9 @@ python_static_cpp: $(SRCS) $(CXX) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) \ $(PYTHON_INCLUDE) $(LIBS) -L$(PYTHON_LIB) $(PYTHON_LIBOPTS) -o $(TARGET) -# ----------------------------------------------------------------- +# ----------------------------------------------------------------- # Running a Python example -# ----------------------------------------------------------------- +# ----------------------------------------------------------------- ifeq (,$(PY3)) PYSCRIPT = runme.py @@ -313,7 +313,7 @@ python_run: $(PYSCRIPT) runme3.py: runme.py cp $< $@ - $(PY2TO3) -w $@ >/dev/null 2>&1 + $(PY2TO3) -w $@ >/dev/null 2>&1 # ----------------------------------------------------------------- # Cleaning the python examples @@ -332,7 +332,7 @@ python_clean: # Make sure these locate your Octave installation OCTAVE_INCLUDE= $(DEFS) @OCTAVEEXT@ -OCTAVE_LIB = +OCTAVE_LIB = # Extra Octave specific dynamic linking options OCTAVE_DLNK = @OCTAVEDYNAMICLINKING@ @@ -548,14 +548,14 @@ mzscheme: $(SRCS) mzscheme_cpp: $(SRCS) $(SWIG) -mzscheme -c++ $(SWIGOPT) $(INTERFACEPATH) $(COMPILETOOL) $(MZC) `echo $(INCLUDES) | sed 's/-I/++ccf -I/g'` --cc $(ICXXSRCS) $(SRCS) $(CXXSRCS) - $(CXXSHARED) $(CFLAGS) -o $(LIBPREFIX)$(TARGET)$(MZSCHEME_SO) $(OBJS) $(IOBJS) $(MZDYNOBJ) $(CPP_DLLIBS) + $(CXXSHARED) $(CFLAGS) -o $(LIBPREFIX)$(TARGET)$(MZSCHEME_SO) $(OBJS) $(IOBJS) $(MZDYNOBJ) $(CPP_DLLIBS) # ----------------------------------------------------------------- # Cleaning the mzscheme examples # ----------------------------------------------------------------- mzscheme_clean: - rm -f *_wrap* *~ .~* + rm -f *_wrap* *~ .~* rm -f core @EXTRA_CLEAN@ rm -f *.@OBJEXT@ *@SO@ @@ -643,7 +643,7 @@ ocaml_static_cpp: $(SRCS) $(INTERFACE:%.i=%.cmo) \ $(PROGFILE:%.ml=%.cmo) \ $(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) \ - -cclib "$(LIBS)" -cc '$(CXX)' + -cclib "$(LIBS)" -cc '$(CXX)' ocaml_static_cpp_toplevel: $(SRCS) $(OCAMLCORE) @@ -661,7 +661,7 @@ ocaml_static_cpp_toplevel: $(SRCS) -g -ccopt -g -cclib -g -custom -o $(TARGET)_top \ $(INTERFACE:%.i=%.cmo) \ $(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) \ - -cclib "$(LIBS)" -cc '$(CXX)' + -cclib "$(LIBS)" -cc '$(CXX)' ocaml_dynamic_cpp: $(SRCS) $(OCAMLCORE) @@ -844,7 +844,7 @@ pike_cpp_static: $(SRCS) # ----------------------------------------------------------------- pike_clean: - rm -f *_wrap* *~ .~* mypike@EXEEXT@ + rm -f *_wrap* *~ .~* mypike@EXEEXT@ rm -f core @EXTRA_CLEAN@ rm -f *.@OBJEXT@ *@SO@ @@ -861,7 +861,7 @@ CHICKEN_CFLAGS = @CHICKENOPTS@ CHICKENOPTS = -quiet CHICKEN_MAIN = -# SWIG produces $(ISRCS) (the C wrapper file) +# SWIG produces $(ISRCS) (the C wrapper file) # and $(CHICKEN_GENERATED_SCHEME) (the Scheme wrapper file): CHICKEN_GENERATED_SCHEME = $(INTERFACE:.i=.scm) CHICKEN_COMPILED_SCHEME = $(INTERFACE:.i=_chicken.c) @@ -1053,12 +1053,12 @@ lua_clean: allegrocl: $(SRCS) $(SWIG) -allegrocl -cwrap $(SWIGOPT) $(INTERFACEPATH) - $(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(INCLUDES) $(SRCS) + $(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(INCLUDES) $(SRCS) $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO) allegrocl_cpp: $(SRCS) $(SWIG) -c++ -allegrocl $(SWIGOPT) $(INTERFACEPATH) - $(CXX) -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) + $(CXX) -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO) allegrocl_clean: @@ -1087,12 +1087,12 @@ clisp_clean: cffi: $(SRCS) $(SWIG) -cffi $(SWIGOPT) $(INTERFACEPATH) -# $(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(INCLUDES) $(SRCS) +# $(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(INCLUDES) $(SRCS) # $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO) cffi_cpp: $(SRCS) $(SWIG) -c++ -cffi $(SWIGOPT) $(INTERFACEPATH) - $(CXX) -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) + $(CXX) -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO) cffi_clean: @@ -1106,12 +1106,12 @@ cffi_clean: uffi: $(SRCS) $(SWIG) -uffi $(SWIGOPT) $(INTERFACEPATH) -# $(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(INCLUDES) $(SRCS) +# $(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(INCLUDES) $(SRCS) # $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO) uffi_cpp: $(SRCS) $(SWIG) -c++ -uffi $(SWIGOPT) $(INTERFACEPATH) -# $(CXX) -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) +# $(CXX) -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) # $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO) uffi_clean: @@ -1212,3 +1212,56 @@ go_clean: rm -f *_wrap* *_gc* .~* runme rm -f core @EXTRA_CLEAN@ rm -f *.@OBJEXT@ *.[568] *.a *@SO@ + +################################################################## +##### D ###### +################################################################## + +DLIBPREFIX = @DLIBPREFIX@ + +ifeq (2,$(D_VERSION)) + SWIGD = $(SWIG) -d -d2 + DCOMPILER = @D2COMPILER@ +else + SWIGD = $(SWIG) -d + DCOMPILER = @D1COMPILER@ +endif + +ifeq (dmd,$(DCOMPILER)) + # DMD is 32bit only by now + CFLAGS += -m32 +endif + +# ---------------------------------------------------------------- +# Build a dynamically loadable D wrapper for a C module +# ---------------------------------------------------------------- + +d: $(SRCS) + $(SWIGD) $(SWIGOPT) $(INTERFACEPATH) + $(CC) -c $(CCSHARED) $(CFLAGS) $(EXTRA_CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) + $(LDSHARED) $(CFLAGS) $(EXTRA_LDFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(DLIBPREFIX)$(TARGET)$(SO) + +# ---------------------------------------------------------------- +# Build a dynamically loadable D wrapper for a C++ module +# ---------------------------------------------------------------- + +d_cpp: $(SRCS) + $(SWIGD) -c++ $(SWIGOPT) $(INTERFACEPATH) + $(CXX) -c $(CCSHARED) $(CFLAGS) $(EXTRA_CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) + $(CXXSHARED) $(CFLAGS) $(EXTRA_LDFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(DLIBPREFIX)$(TARGET)$(SO) + +# ---------------------------------------------------------------- +# Compile D files +# ---------------------------------------------------------------- + +d_compile: $(SRCS) + $(COMPILETOOL) $(DCOMPILER) $(DFLAGS) $(DSRCS) + +# ----------------------------------------------------------------- +# Clean the D examples +# ----------------------------------------------------------------- + +d_clean: + rm -f *_wrap* *~ .~* runme runme.exe `find . -name \*.d | grep -v runme.d` + rm -f core @EXTRA_CLEAN@ + rm -f *.@OBJEXT@ *@SO@ diff --git a/Examples/d/callback/Makefile b/Examples/d/callback/Makefile new file mode 100644 index 000000000..bc16dd0fc --- /dev/null +++ b/Examples/d/callback/Makefile @@ -0,0 +1,28 @@ +ifeq (2,$(D_VERSION)) + WORKING_DIR = d2/ +else + WORKING_DIR = d1/ +endif + +TOP = ../../.. +SWIG = $(TOP)/../preinst-swig +EXTRA_CFLAGS = -I../ ../example.cxx example_wrap.cxx +EXTRA_LDFLAGS = example.o example_wrap.o +TARGET = example_wrap +SWIGOPT = +DSRCS = *.d +DFLAGS = -ofrunme + + +all:: d + +d:: + cd $(WORKING_DIR); \ + $(MAKE) -f $(TOP)/Makefile EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -outcurrentdir ../example.i' TARGET='$(TARGET)' d_cpp; \ + $(MAKE) -f $(TOP)/Makefile DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile + +clean:: + cd $(WORKING_DIR); \ + $(MAKE) -f $(TOP)/Makefile d_clean + +check: all diff --git a/Examples/d/callback/d1/runme.d b/Examples/d/callback/d1/runme.d new file mode 100644 index 000000000..e34e09603 --- /dev/null +++ b/Examples/d/callback/d1/runme.d @@ -0,0 +1,36 @@ +module runme; + +import tango.io.Stdout; +import example; + +public class DCallback : Callback { + public override void run() { + Stdout( "DCallback.run()" ).newline; + } +} + +void main() { + auto caller = new Caller(); + + Stdout( "Adding and calling a normal C++ callback" ).newline; + Stdout( "----------------------------------------" ).newline; + { + scope auto callback = new Callback(); + caller.setCallback(callback); + caller.call(); + caller.resetCallback(); + } + + Stdout.newline; + Stdout( "Adding and calling a D callback" ).newline; + Stdout( "-------------------------------" ).newline; + { + scope auto callback = new DCallback(); + caller.setCallback(callback); + caller.call(); + caller.resetCallback(); + } + + Stdout.newline; + Stdout( "D exit" ).newline; +} diff --git a/Examples/d/callback/d2/runme.d b/Examples/d/callback/d2/runme.d new file mode 100644 index 000000000..88ffcdefd --- /dev/null +++ b/Examples/d/callback/d2/runme.d @@ -0,0 +1,36 @@ +module runme; + +import std.stdio; +import example; + +public class DCallback : Callback { + public override void run() { + writeln( "DCallback.run()" ); + } +} + +void main() { + auto caller = new Caller(); + + writeln( "Adding and calling a normal C++ callback" ); + writeln( "----------------------------------------" ); + { + scope auto callback = new Callback(); + caller.setCallback(callback); + caller.call(); + caller.resetCallback(); + } + + writeln(); + writeln( "Adding and calling a D callback" ); + writeln( "-------------------------------" ); + { + scope auto callback = new DCallback(); + caller.setCallback(callback); + caller.call(); + caller.resetCallback(); + } + + writeln(); + writeln( "D exit" ); +} diff --git a/Examples/d/callback/example.cxx b/Examples/d/callback/example.cxx new file mode 100644 index 000000000..450d75608 --- /dev/null +++ b/Examples/d/callback/example.cxx @@ -0,0 +1,4 @@ +/* File : example.cxx */ + +#include "example.h" + diff --git a/Examples/d/callback/example.h b/Examples/d/callback/example.h new file mode 100644 index 000000000..38d25a043 --- /dev/null +++ b/Examples/d/callback/example.h @@ -0,0 +1,24 @@ +/* File : example.h */ + +#include +#include + +class Callback { +public: + virtual ~Callback() { std::cout << "Callback::~Callback()" << std:: endl; } + virtual void run() { std::cout << "Callback::run()" << std::endl; } +}; + + +class Caller { +private: + Callback *_callback; +public: + Caller(): _callback(0) {} + ~Caller() { delCallback(); } + void delCallback() { delete _callback; _callback = 0; } + void setCallback(Callback *cb) { delCallback(); _callback = cb; } + void resetCallback() { _callback = 0; } + void call() { if (_callback) _callback->run(); } +}; + diff --git a/Examples/d/callback/example.i b/Examples/d/callback/example.i new file mode 100644 index 000000000..90beda01a --- /dev/null +++ b/Examples/d/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/d/check.list b/Examples/d/check.list new file mode 100644 index 000000000..010e7bbfc --- /dev/null +++ b/Examples/d/check.list @@ -0,0 +1,9 @@ +# See top-level Makefile.in. +callback +class +constants +enum +extend +funcptr +simple +variables diff --git a/Examples/d/class/Makefile b/Examples/d/class/Makefile new file mode 100644 index 000000000..bc16dd0fc --- /dev/null +++ b/Examples/d/class/Makefile @@ -0,0 +1,28 @@ +ifeq (2,$(D_VERSION)) + WORKING_DIR = d2/ +else + WORKING_DIR = d1/ +endif + +TOP = ../../.. +SWIG = $(TOP)/../preinst-swig +EXTRA_CFLAGS = -I../ ../example.cxx example_wrap.cxx +EXTRA_LDFLAGS = example.o example_wrap.o +TARGET = example_wrap +SWIGOPT = +DSRCS = *.d +DFLAGS = -ofrunme + + +all:: d + +d:: + cd $(WORKING_DIR); \ + $(MAKE) -f $(TOP)/Makefile EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -outcurrentdir ../example.i' TARGET='$(TARGET)' d_cpp; \ + $(MAKE) -f $(TOP)/Makefile DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile + +clean:: + cd $(WORKING_DIR); \ + $(MAKE) -f $(TOP)/Makefile d_clean + +check: all diff --git a/Examples/d/class/d1/runme.d b/Examples/d/class/d1/runme.d new file mode 100644 index 000000000..b0c4263a2 --- /dev/null +++ b/Examples/d/class/d1/runme.d @@ -0,0 +1,58 @@ +// This example illustrates how C++ classes can be used from D using SWIG. +// The D class gets mapped onto the C++ class and behaves as if it is a D class. +module runme; + +import tango.io.Stdout; +import example; + +void main() { + // ----- Object creation ----- + + Stdout( "Creating some objects:" ).newline; + + { + scope Square s = new Square(10); + scope Circle c = new Circle(10); + + // ----- Access a static member ----- + Stdout.format( "{} shapes were created.", Shape.nshapes ).newline; + + // ----- Member data access ----- + + // Notice how we can do this using functions specific to + // the 'Circle' class. + c.x = 20; + c.y = 30; + + // Now use the same functions in the base class + Shape shape = s; + shape.x = -10; + shape.y = 5; + + Stdout( "\nHere is their current position:" ).newline; + Stdout.format( " Circle = ( {}, {} )", c.x, c.y ).newline; + Stdout.format( " Square = ( {}, {} )", s.x, s.y ).newline; + + // ----- Call some methods ----- + + Stdout( "\nHere are some properties of the shapes:" ).newline; + Shape[] shapes = [ cast(Shape) c, cast(Shape) s ]; + foreach ( currentShape; shapes ) + { + Stdout.format( " {}", currentShape.classinfo.name ).newline; + Stdout.format( " area = {}", currentShape.area() ).newline; + Stdout.format( " perimeter = {}", currentShape.perimeter() ).newline; + } + + // Notice how the area() and perimeter() functions really + // invoke the appropriate virtual method on each object. + + // ----- Delete everything ----- + Stdout( "\nGuess I'll clean up now:" ).newline; + // Note: when this using scope is exited the D destructors are called which + // in turn call the C++ destructors. + } + + Stdout.format( "{} shapes remain", Shape.nshapes ).newline; + Stdout( "\nGoodbye!" ).newline; +} diff --git a/Examples/d/class/d2/runme.d b/Examples/d/class/d2/runme.d new file mode 100644 index 000000000..2e86c5fc7 --- /dev/null +++ b/Examples/d/class/d2/runme.d @@ -0,0 +1,58 @@ +// This example illustrates how C++ classes can be used from D using SWIG. +// The D class gets mapped onto the C++ class and behaves as if it is a D class. +module runme; + +import std.stdio; +import example; + +void main() { + // ----- Object creation ----- + + writeln( "Creating some objects:" ); + + { + scope Square s = new Square(10); + scope Circle c = new Circle(10); + + // ----- Access a static member ----- + writefln( "%s shapes were created.", Shape.nshapes ); + + // ----- Member data access ----- + + // Notice how we can do this using functions specific to + // the 'Circle' class. + c.x = 20; + c.y = 30; + + // Now use the same functions in the base class + Shape shape = s; + shape.x = -10; + shape.y = 5; + + writeln( "\nHere is their current position:" ); + writefln( " Circle = ( %s, %s )", c.x, c.y ); + writefln( " Square = ( %s, %s )", s.x, s.y ); + + // ----- Call some methods ----- + + writeln( "\nHere are some properties of the shapes:" ); + Shape[] shapes = [ cast(Shape) c, cast(Shape) s ]; + foreach ( currentShape; shapes ) + { + writefln( " %s", currentShape.classinfo.name ); + writefln( " area = %s", currentShape.area() ); + writefln( " perimeter = %s", currentShape.perimeter() ); + } + + // Notice how the area() and perimeter() functions really + // invoke the appropriate virtual method on each object. + + // ----- Delete everything ----- + writeln( "\nGuess I'll clean up now:" ); + // Note: when this using scope is exited the D destructors are called which + // in turn call the C++ destructors. + } + + writefln( "%s shapes remain", Shape.nshapes ); + writeln( "\nGoodbye!" ); +} diff --git a/Examples/d/class/example.cxx b/Examples/d/class/example.cxx new file mode 100644 index 000000000..1e8e203dd --- /dev/null +++ b/Examples/d/class/example.cxx @@ -0,0 +1,28 @@ +/* File : example.c */ + +#include "example.h" +#define M_PI 3.14159265358979323846 + +/* Move the shape to a new location */ +void Shape::move(double dx, double dy) { + x += dx; + y += dy; +} + +int Shape::nshapes = 0; + +double Circle::area(void) { + return M_PI*radius*radius; +} + +double Circle::perimeter(void) { + return 2*M_PI*radius; +} + +double Square::area(void) { + return width*width; +} + +double Square::perimeter(void) { + return 4*width; +} diff --git a/Examples/d/class/example.h b/Examples/d/class/example.h new file mode 100644 index 000000000..0d4527e92 --- /dev/null +++ b/Examples/d/class/example.h @@ -0,0 +1,34 @@ +/* File : example.h */ + +class Shape { +public: + Shape() { + nshapes++; + } + virtual ~Shape() { + nshapes--; + }; + double x, y; + void move(double dx, double dy); + virtual double area(void) = 0; + virtual double perimeter(void) = 0; + static int nshapes; +}; + +class Circle : public Shape { +private: + double radius; +public: + Circle(double r) : radius(r) { }; + virtual double area(void); + virtual double perimeter(void); +}; + +class Square : public Shape { +private: + double width; +public: + Square(double w) : width(w) { }; + virtual double area(void); + virtual double perimeter(void); +}; diff --git a/Examples/d/class/example.i b/Examples/d/class/example.i new file mode 100644 index 000000000..75700b305 --- /dev/null +++ b/Examples/d/class/example.i @@ -0,0 +1,10 @@ +/* File : example.i */ +%module example + +%{ +#include "example.h" +%} + +/* Let's just grab the original header file here */ +%include "example.h" + diff --git a/Examples/d/constants/Makefile b/Examples/d/constants/Makefile new file mode 100644 index 000000000..ce17134ec --- /dev/null +++ b/Examples/d/constants/Makefile @@ -0,0 +1,28 @@ +ifeq (2,$(D_VERSION)) + WORKING_DIR = d2/ +else + WORKING_DIR = d1/ +endif + +TOP = ../../.. +SWIG = $(TOP)/../preinst-swig +EXTRA_CFLAGS = -I../ example_wrap.c +EXTRA_LDFLAGS = example_wrap.o +TARGET = example_wrap +SWIGOPT = +DSRCS = *.d +DFLAGS = -ofrunme + + +all:: d + +d:: + cd $(WORKING_DIR); \ + $(MAKE) -f $(TOP)/Makefile EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -outcurrentdir ../example.i' TARGET='$(TARGET)' d; \ + $(MAKE) -f $(TOP)/Makefile DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile + +clean:: + cd $(WORKING_DIR); \ + $(MAKE) -f $(TOP)/Makefile d_clean + +check: all diff --git a/Examples/d/constants/d1/runme.d b/Examples/d/constants/d1/runme.d new file mode 100644 index 000000000..47362cbf3 --- /dev/null +++ b/Examples/d/constants/d1/runme.d @@ -0,0 +1,28 @@ +module runme; + +import tango.io.Stdout; +static import example; + +void main() { + Stdout.formatln("ICONST = {} (should be 42)", example.ICONST); + Stdout.formatln("FCONST = {} (should be 2.18)", example.FCONST); + Stdout.formatln("CCONST = {} (should be 'x')", example.CCONST); + Stdout.formatln("CCONST2 = {} (this should be on a new line)", example.CCONST2); + Stdout.formatln("SCONST = {} (should be 'Hello World')", example.SCONST); + Stdout.formatln("SCONST2 = {} (should be '\"Hello World\"')", example.SCONST2); + Stdout.formatln("EXPR = {} (should be 48.55)", example.EXPR); + Stdout.formatln("iconst = {} (should be 37)", example.iconst); + Stdout.formatln("fconst = {} (should be 3.14)", example.fconst); + + static if (is(typeof(example.EXTERN))) { + Stdout.formatln("EXTERN should not be defined, but is: {}.", example.EXTERN ); + } else { + Stdout.formatln("EXTERN isn't defined (good)"); + } + + static if (is(typeof(example.FOO))) { + Stdout.formatln("FOO should not be defined, but is: {}.", example.FOO); + } else { + Stdout.formatln("FOO isn't defined (good)"); + } +} diff --git a/Examples/d/constants/d2/runme.d b/Examples/d/constants/d2/runme.d new file mode 100644 index 000000000..4be510d16 --- /dev/null +++ b/Examples/d/constants/d2/runme.d @@ -0,0 +1,28 @@ +module runme; + +import std.stdio; +static import example; + +void main() { + writefln("ICONST = %s (should be 42)", example.ICONST); + writefln("FCONST = %s (should be 2.1828)", example.FCONST); + writefln("CCONST = %s (should be 'x')", example.CCONST); + writefln("CCONST2 = %s (this should be on a new line)", example.CCONST2); + writefln("SCONST = %s (should be 'Hello World')", example.SCONST); + writefln("SCONST2 = %s (should be '\"Hello World\"')", example.SCONST2); + writefln("EXPR = %s (should be 48.5484)", example.EXPR); + writefln("iconst = %s (should be 37)", example.iconst); + writefln("fconst = %s (should be 3.14)", example.fconst); + + static if (is(typeof(example.EXTERN))) { + writefln("EXTERN should not be defined, but is: %s.", example.EXTERN ); + } else { + writeln("EXTERN isn't defined (good)"); + } + + static if (is(typeof(example.FOO))) { + writefln("FOO should not be defined, but is: %s.", example.FOO); + } else { + writeln("FOO isn't defined (good)"); + } +} diff --git a/Examples/d/constants/example.d b/Examples/d/constants/example.d new file mode 100644 index 000000000..7448d0ad9 --- /dev/null +++ b/Examples/d/constants/example.d @@ -0,0 +1,23 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 1.3.41 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +module example; + +static import example_wrap; + +static import tango.stdc.stringz; + +public const int ICONST = 42; +public const double FCONST = 2.1828; +public const char CCONST = 'x'; +public const char CCONST2 = '\n'; +public const char[] SCONST = "Hello World"; +public const char[] SCONST2 = "\"Hello World\""; +public const double EXPR = 42+3*(2.1828); +public const int iconst = 37; +public const double fconst = 3.14; diff --git a/Examples/d/constants/example.i b/Examples/d/constants/example.i new file mode 100644 index 000000000..5eb541919 --- /dev/null +++ b/Examples/d/constants/example.i @@ -0,0 +1,32 @@ +/* File : example.i */ +%module example + +/* Force the generated D code to use the C constant values rather than + retrieving them at runtime. You can also try disabling the feature and + compare the generated code. */ +%dnativeconst; + + +/* A few preprocessor macros */ + +#define ICONST 42 +#define FCONST 2.1828 +#define CCONST 'x' +#define CCONST2 '\n' +#define SCONST "Hello World" +#define SCONST2 "\"Hello World\"" + +/* This should work just fine */ +#define EXPR ICONST + 3*(FCONST) + +/* This shouldn't do anything */ +#define EXTERN extern + +/* Neither should this (BAR isn't defined) */ +#define FOO (ICONST + BAR) + + +/* The following directives also produce constants */ + +%constant int iconst = 37; +%constant double fconst = 3.14; diff --git a/Examples/d/enum/Makefile b/Examples/d/enum/Makefile new file mode 100644 index 000000000..bc16dd0fc --- /dev/null +++ b/Examples/d/enum/Makefile @@ -0,0 +1,28 @@ +ifeq (2,$(D_VERSION)) + WORKING_DIR = d2/ +else + WORKING_DIR = d1/ +endif + +TOP = ../../.. +SWIG = $(TOP)/../preinst-swig +EXTRA_CFLAGS = -I../ ../example.cxx example_wrap.cxx +EXTRA_LDFLAGS = example.o example_wrap.o +TARGET = example_wrap +SWIGOPT = +DSRCS = *.d +DFLAGS = -ofrunme + + +all:: d + +d:: + cd $(WORKING_DIR); \ + $(MAKE) -f $(TOP)/Makefile EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -outcurrentdir ../example.i' TARGET='$(TARGET)' d_cpp; \ + $(MAKE) -f $(TOP)/Makefile DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile + +clean:: + cd $(WORKING_DIR); \ + $(MAKE) -f $(TOP)/Makefile d_clean + +check: all diff --git a/Examples/d/enum/d1/runme.d b/Examples/d/enum/d1/runme.d new file mode 100644 index 000000000..d986986d1 --- /dev/null +++ b/Examples/d/enum/d1/runme.d @@ -0,0 +1,28 @@ +module runme; + +import tango.io.Stdout; +import example; + +void main() { + Stdout( "Printing out some enum values:" ).newline; + Stdout(" color:").newline; + Stdout.formatln(" {} = {}", color.RED, cast(int)color.RED); + Stdout.formatln(" {} = {}", color.BLUE, cast(int)color.BLUE); + Stdout.formatln(" {} = {}", color.GREEN, cast(int)color.GREEN); + + Stdout("\n Foo.speed:").newline; + Stdout.formatln(" Foo.{} = {}", Foo.speed.IMPULSE, cast(int)Foo.speed.IMPULSE); + Stdout.formatln(" Foo.{} = {}", Foo.speed.WARP, cast(int)Foo.speed.WARP); + Stdout.formatln(" Foo.{} = {}", Foo.speed.LUDICROUS , cast(int)Foo.speed.LUDICROUS); + + Stdout("\nTesting use of enums with functions:").newline; + example.enum_test(color.RED, Foo.speed.IMPULSE); + example.enum_test(color.BLUE, Foo.speed.WARP); + example.enum_test(color.GREEN, Foo.speed.LUDICROUS); + + Stdout( "\nTesting use of enum with class method:" ).newline; + scope f = new Foo(); + f.enum_test(Foo.speed.IMPULSE); + f.enum_test(Foo.speed.WARP); + f.enum_test(Foo.speed.LUDICROUS); +} diff --git a/Examples/d/enum/d2/runme.d b/Examples/d/enum/d2/runme.d new file mode 100644 index 000000000..acaec8ae8 --- /dev/null +++ b/Examples/d/enum/d2/runme.d @@ -0,0 +1,28 @@ +module runme; + +import std.stdio; +import example; + +void main() { + writeln( "Printing out some enum values:" ); + writeln(" color:"); + writefln(" %s = %s", color.RED, cast(int)color.RED); + writefln(" %s = %s", color.BLUE, cast(int)color.BLUE); + writefln(" %s = %s", color.GREEN, cast(int)color.GREEN); + + writeln("\n Foo.speed:"); + writefln(" Foo.%s = %s", Foo.speed.IMPULSE, cast(int)Foo.speed.IMPULSE); + writefln(" Foo.%s = %s", Foo.speed.WARP, cast(int)Foo.speed.WARP); + writefln(" Foo.%s = %s", Foo.speed.LUDICROUS , cast(int)Foo.speed.LUDICROUS); + + writeln("\nTesting use of enums with functions:"); + example.enum_test(color.RED, Foo.speed.IMPULSE); + example.enum_test(color.BLUE, Foo.speed.WARP); + example.enum_test(color.GREEN, Foo.speed.LUDICROUS); + + writeln( "\nTesting use of enum with class method:" ); + scope f = new Foo(); + f.enum_test(Foo.speed.IMPULSE); + f.enum_test(Foo.speed.WARP); + f.enum_test(Foo.speed.LUDICROUS); +} diff --git a/Examples/d/enum/example.cxx b/Examples/d/enum/example.cxx new file mode 100644 index 000000000..df7bb6328 --- /dev/null +++ b/Examples/d/enum/example.cxx @@ -0,0 +1,37 @@ +/* File : example.cxx */ + +#include "example.h" +#include + +void Foo::enum_test(speed s) { + if (s == IMPULSE) { + printf("IMPULSE speed\n"); + } else if (s == WARP) { + printf("WARP speed\n"); + } else if (s == LUDICROUS) { + printf("LUDICROUS speed\n"); + } else { + printf("Unknown speed\n"); + } +} + +void enum_test(color c, Foo::speed s) { + if (c == RED) { + printf("color = RED, "); + } else if (c == BLUE) { + printf("color = BLUE, "); + } else if (c == GREEN) { + printf("color = GREEN, "); + } else { + printf("color = Unknown color!, "); + } + if (s == Foo::IMPULSE) { + printf("speed = IMPULSE speed\n"); + } else if (s == Foo::WARP) { + printf("speed = WARP speed\n"); + } else if (s == Foo::LUDICROUS) { + printf("speed = LUDICROUS speed\n"); + } else { + printf("speed = Unknown speed!\n"); + } +} diff --git a/Examples/d/enum/example.h b/Examples/d/enum/example.h new file mode 100644 index 000000000..9119cd9fc --- /dev/null +++ b/Examples/d/enum/example.h @@ -0,0 +1,13 @@ +/* File : example.h */ + +enum color { RED, BLUE, GREEN }; + +class Foo { + public: + Foo() { } + enum speed { IMPULSE=10, WARP=20, LUDICROUS=30 }; + void enum_test(speed s); +}; + +void enum_test(color c, Foo::speed s); + diff --git a/Examples/d/enum/example.i b/Examples/d/enum/example.i new file mode 100644 index 000000000..23ee8a822 --- /dev/null +++ b/Examples/d/enum/example.i @@ -0,0 +1,11 @@ +/* File : example.i */ +%module example + +%{ +#include "example.h" +%} + +/* Let's just grab the original header file here */ + +%include "example.h" + diff --git a/Examples/d/extend/Makefile b/Examples/d/extend/Makefile new file mode 100644 index 000000000..bc16dd0fc --- /dev/null +++ b/Examples/d/extend/Makefile @@ -0,0 +1,28 @@ +ifeq (2,$(D_VERSION)) + WORKING_DIR = d2/ +else + WORKING_DIR = d1/ +endif + +TOP = ../../.. +SWIG = $(TOP)/../preinst-swig +EXTRA_CFLAGS = -I../ ../example.cxx example_wrap.cxx +EXTRA_LDFLAGS = example.o example_wrap.o +TARGET = example_wrap +SWIGOPT = +DSRCS = *.d +DFLAGS = -ofrunme + + +all:: d + +d:: + cd $(WORKING_DIR); \ + $(MAKE) -f $(TOP)/Makefile EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -outcurrentdir ../example.i' TARGET='$(TARGET)' d_cpp; \ + $(MAKE) -f $(TOP)/Makefile DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile + +clean:: + cd $(WORKING_DIR); \ + $(MAKE) -f $(TOP)/Makefile d_clean + +check: all diff --git a/Examples/d/extend/d1/runme.d b/Examples/d/extend/d1/runme.d new file mode 100644 index 000000000..96501d1a4 --- /dev/null +++ b/Examples/d/extend/d1/runme.d @@ -0,0 +1,75 @@ +/// This file illustrates the cross language polymorphism using directors. +module runme; + +import example; +import tango.io.Stdout; + +// CEO class, which overrides Employee.getPosition(). +class CEO : Manager { +public: + this( char[] name ) { + super( name ); + } + + override char[] getPosition() { + return "CEO"; + } + + // Public method to stop the SWIG proxy base class from thinking it owns the underlying C++ memory. + void disownMemory() { + swigCMemOwn = false; + } +} + +void main() { + // Create an instance of CEO, a class derived from the D proxy of the + // underlying C++ class. The calls to getName() and getPosition() are standard, + // the call to getTitle() uses the director wrappers to call CEO.getPosition(). + + auto e = new CEO( "Alice" ); + Stdout.formatln( "{} is a {}.", e.getName(), e.getPosition() ); + Stdout.formatln( "Just call her '{}'.", e.getTitle() ); + Stdout( "----------------------" ).newline; + + { + // Create a new EmployeeList instance. This class does not have a C++ + // director wrapper, but can be used freely with other classes that do. + scope auto list = new EmployeeList(); + + // EmployeeList owns its items, so we must surrender ownership of objects we add. + e.disownMemory(); + list.addEmployee(e); + Stdout( "----------------------" ).newline; + + // Now we access the first four items in list (three are C++ objects that + // EmployeeList's constructor adds, the last is our CEO). The virtual + // methods of all these instances are treated the same. For items 0, 1, and + // 2, all methods resolve in C++. For item 3, our CEO, getTitle calls + // getPosition which resolves in D. The call to getPosition is + // slightly different, however, because of the overidden getPosition() call, since + // now the object reference has been "laundered" by passing through + // EmployeeList as an Employee*. Previously, D resolved the call + // immediately in CEO, but now D thinks the object is an instance of + // class Employee. So the call passes through the + // Employee proxy class and on to the C wrappers and C++ director, + // eventually ending up back at the D CEO implementation of getPosition(). + // The call to getTitle() for item 3 runs the C++ Employee::getTitle() + // method, which in turn calls getPosition(). This virtual method call + // passes down through the C++ director class to the D implementation + // in CEO. All this routing takes place transparently. + + Stdout( "(position, title) for items 0-3:" ).newline; + Stdout.formatln( " {}, '{}'", list.getItem(0).getPosition(), list.getItem(0).getTitle() ); + Stdout.formatln( " {}, '{}'", list.getItem(1).getPosition(), list.getItem(1).getTitle() ); + Stdout.formatln( " {}, '{}'", list.getItem(2).getPosition(), list.getItem(2).getTitle() ); + Stdout.formatln( " {}, '{}'", list.getItem(3).getPosition(), list.getItem(3).getTitle() ); + Stdout( "----------------------" ).newline; + + // All Employees will be destroyed when the EmployeeList goes out of scope, + // including the CEO instance. + } + Stdout( "----------------------" ).newline; + + // All done. + Stdout( "Exiting cleanly from D code." ).newline; +} diff --git a/Examples/d/extend/d2/runme.d b/Examples/d/extend/d2/runme.d new file mode 100644 index 000000000..1ea6dfd21 --- /dev/null +++ b/Examples/d/extend/d2/runme.d @@ -0,0 +1,75 @@ +/// This file illustrates the cross language polymorphism using directors. +module runme; + +import std.stdio; +import example; + +// CEO class, which overrides Employee.getPosition(). +class CEO : Manager { +public: + this( string name ) { + super( name ); + } + + override string getPosition() const { + return "CEO"; + } + + // Public method to stop the SWIG proxy base class from thinking it owns the underlying C++ memory. + void disownMemory() { + swigCMemOwn = false; + } +} + +void main() { + // Create an instance of CEO, a class derived from the D proxy of the + // underlying C++ class. The calls to getName() and getPosition() are standard, + // the call to getTitle() uses the director wrappers to call CEO.getPosition(). + + auto e = new CEO( "Alice" ); + writefln( "%s is a %s.", e.getName(), e.getPosition() ); + writefln( "Just call her '%s'.", e.getTitle() ); + writeln( "----------------------" ); + + { + // Create a new EmployeeList instance. This class does not have a C++ + // director wrapper, but can be used freely with other classes that do. + scope auto list = new EmployeeList(); + + // EmployeeList owns its items, so we must surrender ownership of objects we add. + e.disownMemory(); + list.addEmployee(e); + writeln( "----------------------" ); + + // Now we access the first four items in list (three are C++ objects that + // EmployeeList's constructor adds, the last is our CEO). The virtual + // methods of all these instances are treated the same. For items 0, 1, and + // 2, all methods resolve in C++. For item 3, our CEO, getTitle calls + // getPosition which resolves in D. The call to getPosition is + // slightly different, however, because of the overidden getPosition() call, since + // now the object reference has been "laundered" by passing through + // EmployeeList as an Employee*. Previously, D resolved the call + // immediately in CEO, but now D thinks the object is an instance of + // class Employee. So the call passes through the + // Employee proxy class and on to the C wrappers and C++ director, + // eventually ending up back at the D CEO implementation of getPosition(). + // The call to getTitle() for item 3 runs the C++ Employee::getTitle() + // method, which in turn calls getPosition(). This virtual method call + // passes down through the C++ director class to the D implementation + // in CEO. All this routing takes place transparently. + + writeln( "(position, title) for items 0-3:" ); + writefln( " %s, '%s'", list.getItem(0).getPosition(), list.getItem(0).getTitle() ); + writefln( " %s, '%s'", list.getItem(1).getPosition(), list.getItem(1).getTitle() ); + writefln( " %s, '%s'", list.getItem(2).getPosition(), list.getItem(2).getTitle() ); + writefln( " %s, '%s'", list.getItem(3).getPosition(), list.getItem(3).getTitle() ); + writeln( "----------------------" ); + + // All Employees will be destroyed when the EmployeeList goes out of scope, + // including the CEO instance. + } + writeln( "----------------------" ); + + // All done. + writeln( "Exiting cleanly from D code." ); +} diff --git a/Examples/d/extend/example.cxx b/Examples/d/extend/example.cxx new file mode 100644 index 000000000..450d75608 --- /dev/null +++ b/Examples/d/extend/example.cxx @@ -0,0 +1,4 @@ +/* File : example.cxx */ + +#include "example.h" + diff --git a/Examples/d/extend/example.h b/Examples/d/extend/example.h new file mode 100644 index 000000000..7ad93fbc1 --- /dev/null +++ b/Examples/d/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 *getItem(int i) { + return list[i]; + } + ~EmployeeList() { + std::vector::iterator i; + std::cout << "~EmployeeList, deleting " << list.size() << " employees." << std::endl; + for (i=list.begin(); i!=list.end(); i++) { + delete *i; + } + std::cout << "~EmployeeList empty." << std::endl; + } +}; + diff --git a/Examples/d/extend/example.i b/Examples/d/extend/example.i new file mode 100644 index 000000000..0647e1319 --- /dev/null +++ b/Examples/d/extend/example.i @@ -0,0 +1,14 @@ +/* File : example.i */ +%module(directors="1") example +%{ +#include "example.h" +%} + +%include "std_string.i" + +/* turn on director wrapping for Manager */ +%feature("director") Employee; +%feature("director") Manager; + +%include "example.h" + diff --git a/Examples/d/funcptr/Makefile b/Examples/d/funcptr/Makefile new file mode 100644 index 000000000..616102926 --- /dev/null +++ b/Examples/d/funcptr/Makefile @@ -0,0 +1,28 @@ +ifeq (2,$(D_VERSION)) + WORKING_DIR = d2/ +else + WORKING_DIR = d1/ +endif + +TOP = ../../.. +SWIG = $(TOP)/../preinst-swig +EXTRA_CFLAGS = -I../ ../example.c example_wrap.c +EXTRA_LDFLAGS = example.o example_wrap.o +TARGET = example_wrap +SWIGOPT = +DSRCS = *.d +DFLAGS = -ofrunme + + +all:: d + +d:: + cd $(WORKING_DIR); \ + $(MAKE) -f $(TOP)/Makefile EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -outcurrentdir ../example.i' TARGET='$(TARGET)' d; \ + $(MAKE) -f $(TOP)/Makefile DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile + +clean:: + cd $(WORKING_DIR); \ + $(MAKE) -f $(TOP)/Makefile d_clean + +check: all diff --git a/Examples/d/funcptr/d1/runme.d b/Examples/d/funcptr/d1/runme.d new file mode 100644 index 000000000..2947602a5 --- /dev/null +++ b/Examples/d/funcptr/d1/runme.d @@ -0,0 +1,34 @@ +module runme; + +import tango.io.Stdout; +static import example; + +extern(C) int add(int a, int b) { + return a + b; +} + +extern(C) int sub(int a, int b) { + return a - b; +} + +extern(C) int mul(int a, int b) { + return a * b; +} + +void main() { + int a = 37; + int b = 42; + + Stdout( "a = " )( a ).newline; + Stdout( "b = " )( b ).newline; + + Stdout( "Trying some C callback functions:" ).newline; + Stdout( " ADD(a,b) = " )( example.do_op( a, b, example.ADD ) ).newline; + Stdout( " SUB(a,b) = " )( example.do_op( a, b, example.SUB ) ).newline; + Stdout( " MUL(a,b) = " )( example.do_op( a, b, example.MUL ) ).newline; + + Stdout( "Now the same with callback functions defined in D:" ).newline; + Stdout( " add(a,b) = " )( example.do_op( a, b, &add ) ).newline; + Stdout( " sub(a,b) = " )( example.do_op( a, b, &sub ) ).newline; + Stdout( " mul(a,b) = " )( example.do_op( a, b, &mul ) ).newline; +} diff --git a/Examples/d/funcptr/d2/runme.d b/Examples/d/funcptr/d2/runme.d new file mode 100644 index 000000000..929911d6c --- /dev/null +++ b/Examples/d/funcptr/d2/runme.d @@ -0,0 +1,34 @@ +module runme; + +import std.stdio; +static import example; + +extern(C) int add(int a, int b) { + return a + b; +} + +extern(C) int sub(int a, int b) { + return a - b; +} + +extern(C) int mul(int a, int b) { + return a * b; +} + +void main() { + int a = 37; + int b = 42; + + writefln( "a = %s", a ); + writefln( "b = %s", b ); + + writeln( "Trying some C callback functions:" ); + writefln( " ADD(a,b) = %s", example.do_op( a, b, example.ADD ) ); + writefln( " SUB(a,b) = %s", example.do_op( a, b, example.SUB ) ); + writefln( " MUL(a,b) = %s", example.do_op( a, b, example.MUL ) ); + + writeln( "Now the same with callback functions defined in D:" ); + writefln( " add(a,b) = %s", example.do_op( a, b, &add ) ); + writefln( " sub(a,b) = %s", example.do_op( a, b, &sub ) ); + writefln( " mul(a,b) = %s", example.do_op( a, b, &mul ) ); +} diff --git a/Examples/d/funcptr/example.c b/Examples/d/funcptr/example.c new file mode 100644 index 000000000..5c4a3dabf --- /dev/null +++ b/Examples/d/funcptr/example.c @@ -0,0 +1,19 @@ +/* File : example.c */ + +int do_op(int a, int b, int (*op)(int,int)) { + return (*op)(a,b); +} + +int add(int a, int b) { + return a+b; +} + +int sub(int a, int b) { + return a-b; +} + +int mul(int a, int b) { + return a*b; +} + +int (*funcvar)(int,int) = add; diff --git a/Examples/d/funcptr/example.h b/Examples/d/funcptr/example.h new file mode 100644 index 000000000..9936e24fc --- /dev/null +++ b/Examples/d/funcptr/example.h @@ -0,0 +1,9 @@ +/* file: example.h */ + +extern int do_op(int,int, int (*op)(int,int)); +extern int add(int,int); +extern int sub(int,int); +extern int mul(int,int); + +extern int (*funcvar)(int,int); + diff --git a/Examples/d/funcptr/example.i b/Examples/d/funcptr/example.i new file mode 100644 index 000000000..8b3bef678 --- /dev/null +++ b/Examples/d/funcptr/example.i @@ -0,0 +1,16 @@ +/* File : example.i */ +%module example +%{ +#include "example.h" +%} + +/* Wrap a function taking a pointer to a function */ +extern int do_op(int a, int b, int (*op)(int, int)); + +/* Now install a bunch of "ops" as constants */ +%constant int (*ADD)(int,int) = add; +%constant int (*SUB)(int,int) = sub; +%constant int (*MUL)(int,int) = mul; + +extern int (*funcvar)(int,int); + diff --git a/Examples/d/simple/Makefile b/Examples/d/simple/Makefile new file mode 100644 index 000000000..312e6a9e9 --- /dev/null +++ b/Examples/d/simple/Makefile @@ -0,0 +1,28 @@ +ifeq (2,$(D_VERSION)) + WORKING_DIR = d2/ +else + WORKING_DIR = d1/ +endif + +TOP = ../../.. +SWIG = $(TOP)/../preinst-swig +EXTRA_CFLAGS = -I../ ../example.c example_wrap.c +EXTRA_LDFLAGS = example.o example_wrap.o +TARGET = example_wrap +SWIGOPT = +DSRCS = *.d +DFLAGS = -ofrunme + + +all:: d + +d:: + cd $(WORKING_DIR); \ + $(MAKE) -f $(TOP)/Makefile EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -outcurrentdir ../example.i' TARGET='$(TARGET)' d; \ + $(MAKE) -f $(TOP)/Makefile DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile + +clean:: + cd $(WORKING_DIR); \ + $(MAKE) -f $(TOP)/Makefile d_clean + +check: all diff --git a/Examples/d/simple/d1/runme.d b/Examples/d/simple/d1/runme.d new file mode 100644 index 000000000..1293f1839 --- /dev/null +++ b/Examples/d/simple/d1/runme.d @@ -0,0 +1,27 @@ +module runme; + +import tango.io.Stdout; +static import example; + +void main() { + /* + * Call our gcd() function. + */ + int x = 42; + int y = 105; + int g = example.gcd( x, y ); + Stdout.format( "The gcd of {} and {} is {}.", x, y, g ).newline; + + /* + * Manipulate the Foo global variable. + */ + + // Output its current value + Stdout.format( "Foo = {}", example.Foo ).newline; + + // Change its value + example.Foo = 3.1415926; + + // See if the change took effect + Stdout.format( "Foo = {}", example.Foo ).newline; +} diff --git a/Examples/d/simple/d2/runme.d b/Examples/d/simple/d2/runme.d new file mode 100644 index 000000000..7f278923b --- /dev/null +++ b/Examples/d/simple/d2/runme.d @@ -0,0 +1,27 @@ +module runme; + +import std.stdio; +static import example; + +void main() { + /* + * Call our gcd() function. + */ + int x = 42; + int y = 105; + int g = example.gcd(x, y); + writefln("The gcd of %s and %s is %s.", x, y, g); + + /* + * Manipulate the Foo global variable. + */ + + // Output its current value + writefln("Foo = %s", example.Foo); + + // Change its value + example.Foo = 3.1415926; + + // See if the change took effect + writefln("Foo = %s", example.Foo); +} diff --git a/Examples/d/simple/example.c b/Examples/d/simple/example.c new file mode 100644 index 000000000..1c2af789c --- /dev/null +++ b/Examples/d/simple/example.c @@ -0,0 +1,18 @@ +/* File : example.c */ + +/* A global variable */ +double Foo = 3.0; + +/* Compute the greatest common divisor of positive integers */ +int gcd(int x, int y) { + int g; + g = y; + while (x > 0) { + g = x; + x = y % x; + y = g; + } + return g; +} + + diff --git a/Examples/d/simple/example.i b/Examples/d/simple/example.i new file mode 100644 index 000000000..24093b9bf --- /dev/null +++ b/Examples/d/simple/example.i @@ -0,0 +1,7 @@ +/* File : example.i */ +%module example + +%inline %{ +extern int gcd(int x, int y); +extern double Foo; +%} diff --git a/Examples/d/variables/Makefile b/Examples/d/variables/Makefile new file mode 100644 index 000000000..312e6a9e9 --- /dev/null +++ b/Examples/d/variables/Makefile @@ -0,0 +1,28 @@ +ifeq (2,$(D_VERSION)) + WORKING_DIR = d2/ +else + WORKING_DIR = d1/ +endif + +TOP = ../../.. +SWIG = $(TOP)/../preinst-swig +EXTRA_CFLAGS = -I../ ../example.c example_wrap.c +EXTRA_LDFLAGS = example.o example_wrap.o +TARGET = example_wrap +SWIGOPT = +DSRCS = *.d +DFLAGS = -ofrunme + + +all:: d + +d:: + cd $(WORKING_DIR); \ + $(MAKE) -f $(TOP)/Makefile EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -outcurrentdir ../example.i' TARGET='$(TARGET)' d; \ + $(MAKE) -f $(TOP)/Makefile DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile + +clean:: + cd $(WORKING_DIR); \ + $(MAKE) -f $(TOP)/Makefile d_clean + +check: all diff --git a/Examples/d/variables/d1/runme.d b/Examples/d/variables/d1/runme.d new file mode 100644 index 000000000..35c896bdc --- /dev/null +++ b/Examples/d/variables/d1/runme.d @@ -0,0 +1,71 @@ +// This example illustrates global variable access from C#. +module runme; + +import tango.io.Stdout; +static import example; + +void main() { + // Try to set the values of some global variables + example.ivar = 42; + example.svar = -31000; + example.lvar = 65537; + example.uivar = 123456; + example.usvar = 61000; + example.ulvar = 654321; + example.scvar = -13; + example.ucvar = 251; + example.cvar = 'S'; + example.fvar = 3.14159f; + example.dvar = 2.1828; + example.strvar = "Hello World"; + example.iptrvar = example.new_int(37); + example.ptptr = example.new_Point(37,42); + example.name = "Bill"; + + // Now print out the values of the variables + Stdout.formatln( "Variables (printed from D):" ); + Stdout.formatln( "ivar = {}", example.ivar ); + Stdout.formatln( "svar = {}", example.svar ); + Stdout.formatln( "lvar = {}", example.lvar ); + Stdout.formatln( "uivar = {}", example.uivar ); + Stdout.formatln( "usvar = {}", example.usvar ); + Stdout.formatln( "ulvar = {}", example.ulvar ); + Stdout.formatln( "scvar = {}", example.scvar ); + Stdout.formatln( "ucvar = {}", example.ucvar ); + Stdout.formatln( "fvar = {}", example.fvar ); + Stdout.formatln( "dvar = {}", example.dvar ); + Stdout.formatln( "cvar = {}", example.cvar ); + Stdout.formatln( "strvar = {}", example.strvar ); + Stdout.formatln( "cstrvar = {}", example.cstrvar ); + Stdout.formatln( "iptrvar = {}", example.iptrvar ); + Stdout.formatln( "name = {}", example.name ); + Stdout.formatln( "ptptr = {} {}", example.ptptr, example.Point_print(example.ptptr) ); + Stdout.formatln( "pt = {} {}", example.pt, example.Point_print(example.pt) ); + Stdout.formatln( "status = {}", example.status ); + + Stdout.formatln( "\nVariables (printed from the C library):" ); + example.print_vars(); + + Stdout.formatln( "\nNow I'm going to try and modify some read only variables:" ); + Stdout.formatln( "Checking that the read only variables are readonly..." ); + + Stdout( " 'path'..." ); + static if ( is( typeof( example.path = "a" ) ) ) + Stdout.formatln("Oh dear, this variable is not read only!"); + else + Stdout.formatln("Good."); + + Stdout( " 'status'..." ); + static if ( is( typeof( example.status = 2 ) ) ) + Stdout.formatln("Oh dear, this variable is not read only!"); + else + Stdout.formatln("Good."); + + Stdout.formatln( "\nI'm going to try and update a structure variable:" ); + + example.pt = example.ptptr; + + Stdout( "The new value is " ).flush; + example.pt_print(); + Stdout.formatln( "You should see the value {}", example.Point_print(example.ptptr) ); +} diff --git a/Examples/d/variables/d2/runme.d b/Examples/d/variables/d2/runme.d new file mode 100644 index 000000000..f80b81819 --- /dev/null +++ b/Examples/d/variables/d2/runme.d @@ -0,0 +1,71 @@ +// This example illustrates global variable access from C#. +module runme; + +import std.stdio; +static import example; + +void main() { + // Try to set the values of some global variables + example.ivar = 42; + example.svar = -31000; + example.lvar = 65537; + example.uivar = 123456; + example.usvar = 61000; + example.ulvar = 654321; + example.scvar = -13; + example.ucvar = 251; + example.cvar = 'S'; + example.fvar = 3.14159f; + example.dvar = 2.1828; + example.strvar = "Hello World"; + example.iptrvar = example.new_int(37); + example.ptptr = example.new_Point(37,42); + example.name = "Bill"; + + // Now print out the values of the variables + writefln( "Variables (printed from D):" ); + writefln( "ivar = %s", example.ivar ); + writefln( "svar = %s", example.svar ); + writefln( "lvar = %s", example.lvar ); + writefln( "uivar = %s", example.uivar ); + writefln( "usvar = %s", example.usvar ); + writefln( "ulvar = %s", example.ulvar ); + writefln( "scvar = %s", example.scvar ); + writefln( "ucvar = %s", example.ucvar ); + writefln( "fvar = %s", example.fvar ); + writefln( "dvar = %s", example.dvar ); + writefln( "cvar = %s", example.cvar ); + writefln( "strvar = %s", example.strvar ); + writefln( "cstrvar = %s", example.cstrvar ); + writefln( "iptrvar = %s", example.iptrvar ); + writefln( "name = %s", example.name ); + writefln( "ptptr = %s %s", example.ptptr, example.Point_print(example.ptptr) ); + writefln( "pt = %s %s", example.pt, example.Point_print(example.pt) ); + writefln( "status = %s", example.status ); + + writefln( "\nVariables (printed from the C library):" ); + example.print_vars(); + + writefln( "\nNow I'm going to try and modify some read only variables:" ); + writefln( "Checking that the read only variables are readonly..." ); + + writeln( " 'path'..." ); + static if ( is( typeof( example.path = "a" ) ) ) + writefln("Oh dear, this variable is not read only!"); + else + writefln("Good."); + + writeln( " 'status'..." ); + static if ( is( typeof( example.status = 2 ) ) ) + writefln("Oh dear, this variable is not read only!"); + else + writefln("Good."); + + writefln( "\nI'm going to try and update a structure variable:" ); + + example.pt = example.ptptr; + + write( "The new value is " ); + example.pt_print(); + writefln( "You should see the value %s", example.Point_print(example.ptptr) ); +} diff --git a/Examples/d/variables/example.c b/Examples/d/variables/example.c new file mode 100644 index 000000000..1bf9c120f --- /dev/null +++ b/Examples/d/variables/example.c @@ -0,0 +1,91 @@ +/* File : example.c */ + +/* I'm a file containing some C global variables */ + +/* Deal with Microsoft's attempt at deprecating C standard runtime functions */ +#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) +# define _CRT_SECURE_NO_DEPRECATE +#endif + +#include +#include +#include "example.h" + +int ivar = 0; +short svar = 0; +long lvar = 0; +unsigned int uivar = 0; +unsigned short usvar = 0; +unsigned long ulvar = 0; +signed char scvar = 0; +unsigned char ucvar = 0; +char cvar = 0; +float fvar = 0; +double dvar = 0; +char *strvar = 0; +const char cstrvar[] = "Goodbye"; +int *iptrvar = 0; +char name[256] = "Dave"; +char path[256] = "/home/beazley"; + + +/* Global variables involving a structure */ +Point *ptptr = 0; +Point pt = { 10, 20 }; + +/* A variable that we will make read-only in the interface */ +int status = 1; + +/* A debugging function to print out their values */ + +void print_vars() { + printf("ivar = %d\n", ivar); + printf("svar = %d\n", svar); + printf("lvar = %ld\n", lvar); + printf("uivar = %u\n", uivar); + printf("usvar = %u\n", usvar); + printf("ulvar = %lu\n", ulvar); + printf("scvar = %d\n", scvar); + printf("ucvar = %u\n", ucvar); + printf("fvar = %g\n", fvar); + printf("dvar = %g\n", dvar); + printf("cvar = %c\n", cvar); + printf("strvar = %s\n", strvar ? strvar : "(null)"); + printf("cstrvar = %s\n", cstrvar ? cstrvar : "(null)"); + printf("iptrvar = %p\n", iptrvar); + printf("name = %s\n", name); + printf("ptptr = %p (%d, %d)\n", ptptr, ptptr ? ptptr->x : 0, ptptr ? ptptr->y : 0); + printf("pt = (%d, %d)\n", pt.x, pt.y); + printf("status = %d\n", status); +} + +/* A function to create an integer (to test iptrvar) */ + +int *new_int(int value) { + int *ip = (int *) malloc(sizeof(int)); + *ip = value; + return ip; +} + +/* A function to create a point */ + +Point *new_Point(int x, int y) { + Point *p = (Point *) malloc(sizeof(Point)); + p->x = x; + p->y = y; + return p; +} + +char * Point_print(Point *p) { + static char buffer[256]; + if (p) { + sprintf(buffer,"(%d, %d)", p->x,p->y); + } else { + sprintf(buffer,"null"); + } + return buffer; +} + +void pt_print() { + printf("(%d, %d)\n", pt.x, pt.y); +} diff --git a/Examples/d/variables/example.h b/Examples/d/variables/example.h new file mode 100644 index 000000000..0f7e89594 --- /dev/null +++ b/Examples/d/variables/example.h @@ -0,0 +1,6 @@ +/* File: example.h */ + +typedef struct { + int x,y; +} Point; + diff --git a/Examples/d/variables/example.i b/Examples/d/variables/example.i new file mode 100644 index 000000000..591b871ed --- /dev/null +++ b/Examples/d/variables/example.i @@ -0,0 +1,49 @@ +/* File : example.i */ +%module example +%{ +#include "example.h" +%} + +/* Some global variable declarations */ +%inline %{ +extern int ivar; +extern short svar; +extern long lvar; +extern unsigned int uivar; +extern unsigned short usvar; +extern unsigned long ulvar; +extern signed char scvar; +extern unsigned char ucvar; +extern char cvar; +extern float fvar; +extern double dvar; +extern char *strvar; +extern const char cstrvar[]; +extern int *iptrvar; +extern char name[256]; + +extern Point *ptptr; +extern Point pt; +%} + + +/* Some read-only variables */ + +%immutable; + +%inline %{ +extern int status; +extern char path[256]; +%} + +%mutable; + +/* Some helper functions to make it easier to test */ +%inline %{ +extern void print_vars(); +extern int *new_int(int value); +extern Point *new_Point(int x, int y); +extern char *Point_print(Point *p); +extern void pt_print(); +%} + diff --git a/Examples/test-suite/d/Makefile.in b/Examples/test-suite/d/Makefile.in new file mode 100644 index 000000000..2e9eb827f --- /dev/null +++ b/Examples/test-suite/d/Makefile.in @@ -0,0 +1,80 @@ +####################################################################### +# Makefile for D test-suite +####################################################################### + +LANGUAGE = d +srcdir = @srcdir@ +top_srcdir = ../@top_srcdir@ +top_builddir = ../@top_builddir@ + +ifeq (2,$(D_VERSION)) + VERSIONSUFFIX = .2 +else + VERSIONSUFFIX = .1 +endif + +TESTSUFFIX = _runme$(VERSIONSUFFIX).d + +CPP_TEST_CASES = \ + d_nativepointers \ + exception_partial_info + +include $(srcdir)/../common.mk + +# Override some variables from common.mk: + +TARGETSUFFIX = _wrap + +SWIGOPT+=-splitproxy -package $* + +# Rules for the different types of tests +%.cpptest: + $(setup) + +(cd $*$(VERSIONSUFFIX) && $(swig_and_compile_cpp)) + +$(run_testcase) + +%.ctest: + $(setup) + +(cd $*$(VERSIONSUFFIX) && $(swig_and_compile_c)) + +$(run_testcase) + +%.multicpptest: + $(setup) + +(cd $*$(VERSIONSUFFIX) && $(swig_and_compile_multi_cpp)) + +$(run_testcase) + +# Makes a directory for the testcase if it does not exist +setup = \ + if [ -f $(srcdir)/$(TESTPREFIX)$*$(TESTSUFFIX) ]; then \ + echo "$(ACTION)ing testcase $* (with run test) under $(LANGUAGE)" ; \ + else \ + echo "$(ACTION)ing testcase $* under $(LANGUAGE)" ; \ + fi; \ + if [ ! -d $*$(VERSIONSUFFIX) ]; then \ + mkdir $*$(VERSIONSUFFIX); \ + fi; \ + if [ ! -d $*$(VERSIONSUFFIX)/$* ]; then \ + mkdir $*$(VERSIONSUFFIX)/$*; \ + fi + +# Compiles D files then runs the testcase. A testcase is only run if +# a file is found which has _runme.d appended after the testcase name. +run_testcase = \ + if [ -f $(srcdir)/$(TESTPREFIX)$*$(TESTSUFFIX) ]; then \ + cd $*$(VERSIONSUFFIX) && \ + $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile \ + DFLAGS='-of$*_runme' \ + DSRCS='../$(srcdir)/$(TESTPREFIX)$*$(TESTSUFFIX) $*/*.d' d_compile && \ + env LD_LIBRARY_PATH=".:$$LD_LIBRARY_PATH" $(RUNTOOL) ./$*_runme; \ + else \ + cd $*$(VERSIONSUFFIX) && \ + $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile \ + DFLAGS='-c' \ + DSRCS='$*/*.d' d_compile && cd .. ; \ + fi + +# Clean: remove testcase directories +%.clean: + @if [ -d $* ]; then \ + rm -rf $*; \ + fi diff --git a/Examples/test-suite/d/README b/Examples/test-suite/d/README new file mode 100644 index 000000000..bb5372882 --- /dev/null +++ b/Examples/test-suite/d/README @@ -0,0 +1,7 @@ +D language module testsuite +--------------------------- + +Please see ../README for the common readme file. + +By default the D1 version is built, set D_VERSION=2 (in the environment or at +the make command line) to run it for D2 instead. diff --git a/Examples/test-suite/d/aggregate_runme.1.d b/Examples/test-suite/d/aggregate_runme.1.d new file mode 100644 index 000000000..a00d34c25 --- /dev/null +++ b/Examples/test-suite/d/aggregate_runme.1.d @@ -0,0 +1,25 @@ +module aggregate_runme; + +import aggregate.aggregate; + +void main() { + // Confirm that move() returns correct results under normal use. + int result = move(UP); + if (result != UP) throw new Exception("UP failed"); + + result = move(DOWN); + if (result != DOWN) throw new Exception("DOWN failed"); + + result = move(LEFT); + if (result != LEFT) throw new Exception("LEFT failed"); + + result = move(RIGHT); + if (result != RIGHT) throw new Exception("RIGHT failed"); + + // Confirm that move() raises an exception when the contract is violated. + try { + move(0); + throw new Exception("0 test failed"); + } + catch (Exception e) {} +} diff --git a/Examples/test-suite/d/aggregate_runme.2.d b/Examples/test-suite/d/aggregate_runme.2.d new file mode 100644 index 000000000..a00d34c25 --- /dev/null +++ b/Examples/test-suite/d/aggregate_runme.2.d @@ -0,0 +1,25 @@ +module aggregate_runme; + +import aggregate.aggregate; + +void main() { + // Confirm that move() returns correct results under normal use. + int result = move(UP); + if (result != UP) throw new Exception("UP failed"); + + result = move(DOWN); + if (result != DOWN) throw new Exception("DOWN failed"); + + result = move(LEFT); + if (result != LEFT) throw new Exception("LEFT failed"); + + result = move(RIGHT); + if (result != RIGHT) throw new Exception("RIGHT failed"); + + // Confirm that move() raises an exception when the contract is violated. + try { + move(0); + throw new Exception("0 test failed"); + } + catch (Exception e) {} +} diff --git a/Examples/test-suite/d/allprotected_runme.1.d b/Examples/test-suite/d/allprotected_runme.1.d new file mode 100644 index 000000000..82a180e66 --- /dev/null +++ b/Examples/test-suite/d/allprotected_runme.1.d @@ -0,0 +1,65 @@ +module allprotected_runme; + +import allprotected.Klass; +import allprotected.ProtectedBase; + +void main() { + auto mpb = new MyProtectedBase("MyProtectedBase"); + mpb.accessProtected(); +} + +class MyProtectedBase : ProtectedBase { +public: + this(char[] name) { + super(name); + } + + void accessProtected() { + char[] s = virtualMethod(); + if (s != "ProtectedBase") + throw new Exception("Failed"); + + Klass k = instanceMethod(new Klass("xyz")); + if (k.getName() != "xyz") + throw new Exception("Failed"); + + k = instanceOverloaded(new Klass("xyz")); + if (k.getName() != "xyz") + throw new Exception("Failed"); + + k = instanceOverloaded(new Klass("xyz"), "abc"); + if (k.getName() != "abc") + throw new Exception("Failed"); + + k = staticMethod(new Klass("abc")); + if (k.getName() != "abc") + throw new Exception("Failed"); + + k = staticOverloaded(new Klass("xyz")); + if (k.getName() != "xyz") + throw new Exception("Failed"); + + k = staticOverloaded(new Klass("xyz"), "abc"); + if (k.getName() != "abc") + throw new Exception("Failed"); + + instanceMemberVariable = 30; + int i = instanceMemberVariable; + if (i != 30) + throw new Exception("Failed"); + + staticMemberVariable = 40; + i = staticMemberVariable; + if (i != 40) + throw new Exception("Failed"); + + i = staticConstMemberVariable; + if (i != 20) + throw new Exception("Failed"); + + anEnum = ProtectedBase.AnEnum.EnumVal1; + ProtectedBase.AnEnum ae = anEnum; + if (ae != ProtectedBase.AnEnum.EnumVal1) + throw new Exception("Failed"); + } +} diff --git a/Examples/test-suite/d/allprotected_runme.2.d b/Examples/test-suite/d/allprotected_runme.2.d new file mode 100644 index 000000000..799230291 --- /dev/null +++ b/Examples/test-suite/d/allprotected_runme.2.d @@ -0,0 +1,65 @@ +module allprotected_runme; + +import allprotected.Klass; +import allprotected.ProtectedBase; + +void main() { + auto mpb = new MyProtectedBase("MyProtectedBase"); + mpb.accessProtected(); +} + +class MyProtectedBase : ProtectedBase { +public: + this(string name) { + super(name); + } + + void accessProtected() { + string s = virtualMethod(); + if (s != "ProtectedBase") + throw new Exception("Failed"); + + Klass k = instanceMethod(new Klass("xyz")); + if (k.getName() != "xyz") + throw new Exception("Failed"); + + k = instanceOverloaded(new Klass("xyz")); + if (k.getName() != "xyz") + throw new Exception("Failed"); + + k = instanceOverloaded(new Klass("xyz"), "abc"); + if (k.getName() != "abc") + throw new Exception("Failed"); + + k = staticMethod(new Klass("abc")); + if (k.getName() != "abc") + throw new Exception("Failed"); + + k = staticOverloaded(new Klass("xyz")); + if (k.getName() != "xyz") + throw new Exception("Failed"); + + k = staticOverloaded(new Klass("xyz"), "abc"); + if (k.getName() != "abc") + throw new Exception("Failed"); + + instanceMemberVariable = 30; + int i = instanceMemberVariable; + if (i != 30) + throw new Exception("Failed"); + + staticMemberVariable = 40; + i = staticMemberVariable; + if (i != 40) + throw new Exception("Failed"); + + i = staticConstMemberVariable; + if (i != 20) + throw new Exception("Failed"); + + anEnum = ProtectedBase.AnEnum.EnumVal1; + ProtectedBase.AnEnum ae = anEnum; + if (ae != ProtectedBase.AnEnum.EnumVal1) + throw new Exception("Failed"); + } +} diff --git a/Examples/test-suite/d/apply_strings_runme.1.d b/Examples/test-suite/d/apply_strings_runme.1.d new file mode 100644 index 000000000..960caa4ca --- /dev/null +++ b/Examples/test-suite/d/apply_strings_runme.1.d @@ -0,0 +1,12 @@ +module apply_strings_runme; + +import apply_strings.apply_strings; + +const char[] TEST_MESSAGE = "A message from target language to the C++ world and back again."; + +void main() { + if (UCharFunction(TEST_MESSAGE) != TEST_MESSAGE) throw new Exception("UCharFunction failed"); + if (SCharFunction(TEST_MESSAGE) != TEST_MESSAGE) throw new Exception("SCharFunction failed"); + auto pChar = CharFunction(null); + if (pChar !is null) throw new Exception("CharFunction failed"); +} diff --git a/Examples/test-suite/d/apply_strings_runme.2.d b/Examples/test-suite/d/apply_strings_runme.2.d new file mode 100644 index 000000000..86183f8a3 --- /dev/null +++ b/Examples/test-suite/d/apply_strings_runme.2.d @@ -0,0 +1,12 @@ +module apply_strings_runme; + +import apply_strings.apply_strings; + +enum string TEST_MESSAGE = "A message from target language to the C++ world and back again."; + +void main() { + if (UCharFunction(TEST_MESSAGE) != TEST_MESSAGE) throw new Exception("UCharFunction failed"); + if (SCharFunction(TEST_MESSAGE) != TEST_MESSAGE) throw new Exception("SCharFunction failed"); + auto pChar = CharFunction(null); + if (pChar !is null) throw new Exception("CharFunction failed"); +} diff --git a/Examples/test-suite/d/bools_runme.1.d b/Examples/test-suite/d/bools_runme.1.d new file mode 100644 index 000000000..f501b0762 --- /dev/null +++ b/Examples/test-suite/d/bools_runme.1.d @@ -0,0 +1,20 @@ +/// This is the bool runtime testcase. It checks that the C++ bool type works. +module bools_runme; + +import bools.bools; + +void main() { + bool t = true; + bool f = false; + + check_bo(f); + check_bo(t); +} + +void check_bo(bool input) { + for (int i = 0; i < 1000; ++i) { + if (bo(input) != input) { + throw new Exception("Runtime test check_bo failed."); + } + } +} diff --git a/Examples/test-suite/d/bools_runme.2.d b/Examples/test-suite/d/bools_runme.2.d new file mode 100644 index 000000000..f501b0762 --- /dev/null +++ b/Examples/test-suite/d/bools_runme.2.d @@ -0,0 +1,20 @@ +/// This is the bool runtime testcase. It checks that the C++ bool type works. +module bools_runme; + +import bools.bools; + +void main() { + bool t = true; + bool f = false; + + check_bo(f); + check_bo(t); +} + +void check_bo(bool input) { + for (int i = 0; i < 1000; ++i) { + if (bo(input) != input) { + throw new Exception("Runtime test check_bo failed."); + } + } +} diff --git a/Examples/test-suite/d/catches_runme.1.d b/Examples/test-suite/d/catches_runme.1.d new file mode 100644 index 000000000..55b18132d --- /dev/null +++ b/Examples/test-suite/d/catches_runme.1.d @@ -0,0 +1,33 @@ +module catches_runme; + +import catches.catches; + +void main() { + test({ test_catches(1); }, "C++ int exception thrown, value: 1"); + test({ test_catches(2); }, "two"); + test({ test_catches(3); }, "C++ ThreeException const & exception thrown"); + + test({ test_exception_specification(1); }, "C++ int exception thrown, value: 1"); + test({ test_exception_specification(2); }, "unknown exception"); + test({ test_exception_specification(3); }, "unknown exception"); + + test({ test_catches_all(1); }, "unknown exception"); +} + +void test(void delegate() command, char[] expectedMessage) { + bool didntThrow; + try { + command(); + didntThrow = true; + } catch (Exception e) { + if (e.msg != expectedMessage) { + throw new Exception("Failed to propagate C++ exception. Expected '" ~ + expectedMessage ~ "', but received '" ~ e.msg ~ "'."); + } + } + + if (didntThrow) { + throw new Exception("Failed to propagate C++ exception. Expected '" ~ + expectedMessage ~ "', but no exception was thrown."); + } +} diff --git a/Examples/test-suite/d/catches_runme.2.d b/Examples/test-suite/d/catches_runme.2.d new file mode 100644 index 000000000..508558485 --- /dev/null +++ b/Examples/test-suite/d/catches_runme.2.d @@ -0,0 +1,33 @@ +module catches_runme; + +import catches.catches; + +void main() { + test({ test_catches(1); }, "C++ int exception thrown, value: 1"); + test({ test_catches(2); }, "two"); + test({ test_catches(3); }, "C++ ThreeException const & exception thrown"); + + test({ test_exception_specification(1); }, "C++ int exception thrown, value: 1"); + test({ test_exception_specification(2); }, "unknown exception"); + test({ test_exception_specification(3); }, "unknown exception"); + + test({ test_catches_all(1); }, "unknown exception"); +} + +void test(void delegate() command, string expectedMessage) { + bool didntThrow; + try { + command(); + didntThrow = true; + } catch (Exception e) { + if (e.msg != expectedMessage) { + throw new Exception("Failed to propagate C++ exception. Expected '" ~ + expectedMessage ~ "', but received '" ~ e.msg ~ "'."); + } + } + + if (didntThrow) { + throw new Exception("Failed to propagate C++ exception. Expected '" ~ + expectedMessage ~ "', but no exception was thrown."); + } +} diff --git a/Examples/test-suite/d/char_strings_runme.1.d b/Examples/test-suite/d/char_strings_runme.1.d new file mode 100644 index 000000000..cde6fe0f7 --- /dev/null +++ b/Examples/test-suite/d/char_strings_runme.1.d @@ -0,0 +1,151 @@ +module char_strings_runme; + +import tango.text.convert.Integer; +import char_strings.char_strings; + +const char[] CPLUSPLUS_MSG = "A message from the deep dark world of C++, where anything is possible."; +const char[] OTHERLAND_MSG = "Little message from the safe world."; + +void main() { + const uint count = 10000; + uint i = 0; + + // get functions + for (i=0; i