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.
-
-
-
-
-
-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