summaryrefslogtreecommitdiff
path: root/SWIG
diff options
context:
space:
mode:
Diffstat (limited to 'SWIG')
-rw-r--r--SWIG/ANNOUNCE27
-rw-r--r--SWIG/CHANGES388
-rw-r--r--SWIG/Doc/engineering.html75
-rw-r--r--SWIG/Doc/index.html6
-rw-r--r--SWIG/Doc/internals.html237
-rw-r--r--SWIG/Doc/jswig.html538
-rw-r--r--SWIG/Examples/C++/.cvsignore1
-rw-r--r--SWIG/Examples/C++/Java/.cvsignore7
-rw-r--r--SWIG/Examples/C++/Java/Makefile13
-rw-r--r--SWIG/Examples/C++/Python/.cvsignore3
-rw-r--r--SWIG/Examples/C++/Python/Makefile8
-rw-r--r--SWIG/Examples/C++/common.mk2
-rw-r--r--SWIG/Examples/C++/interface/cpptest.i2
-rw-r--r--SWIG/Examples/GIFPlot/.cvsignore4
-rw-r--r--SWIG/Examples/GIFPlot/Guile/full/.cvsignore3
-rw-r--r--SWIG/Examples/GIFPlot/Guile/simple/.cvsignore4
-rw-r--r--SWIG/Examples/GIFPlot/Include/gifplot.h6
-rw-r--r--SWIG/Examples/GIFPlot/Interface/gifplot.i6
-rw-r--r--SWIG/Examples/GIFPlot/Java/.cvsignore3
-rw-r--r--SWIG/Examples/GIFPlot/Java/Makefile5
-rw-r--r--SWIG/Examples/GIFPlot/Java/gifplot.i6
-rw-r--r--SWIG/Examples/GIFPlot/Lib/.cvsignore1
-rw-r--r--SWIG/Examples/GIFPlot/Lib/pixmap.c4
-rw-r--r--SWIG/Examples/GIFPlot/Perl/full/.cvsignore2
-rw-r--r--SWIG/Examples/GIFPlot/Perl/shadow/.cvsignore2
-rw-r--r--SWIG/Examples/GIFPlot/Perl/simple/.cvsignore2
-rw-r--r--SWIG/Examples/GIFPlot/Python/full/.cvsignore1
-rw-r--r--SWIG/Examples/GIFPlot/Python/shadow/.cvsignore2
-rw-r--r--SWIG/Examples/GIFPlot/Python/simple/.cvsignore1
-rw-r--r--SWIG/Examples/GIFPlot/README4
-rw-r--r--SWIG/Examples/GIFPlot/Ruby/full/.cvsignore1
-rw-r--r--SWIG/Examples/GIFPlot/Ruby/shadow/.cvsignore1
-rw-r--r--SWIG/Examples/GIFPlot/Ruby/simple/.cvsignore1
-rw-r--r--SWIG/Examples/GIFPlot/Tcl/full/.cvsignore1
-rw-r--r--SWIG/Examples/GIFPlot/Tcl/mandel/.cvsignore1
-rw-r--r--SWIG/Examples/GIFPlot/Tcl/simple/.cvsignore1
-rwxr-xr-xSWIG/Examples/GIFPlot/configure1299
-rw-r--r--SWIG/Examples/Makefile.in33
-rw-r--r--SWIG/Examples/README2
-rw-r--r--SWIG/Examples/guile/Makefile.in17
-rw-r--r--SWIG/Examples/guile/matrix/Makefile2
-rw-r--r--SWIG/Examples/guile/matrix/matrix.c2
-rw-r--r--SWIG/Examples/guile/matrix/vector.c2
-rw-r--r--SWIG/Examples/guile/port/Makefile2
-rw-r--r--SWIG/Examples/guile/port/port.i2
-rw-r--r--SWIG/Examples/guile/simple/Makefile2
-rw-r--r--SWIG/Examples/guile/simple/example.c2
-rw-r--r--SWIG/Examples/guile/test-suite/.cvsignore3
-rw-r--r--SWIG/Examples/guile/test-suite/Makefile.in60
-rw-r--r--SWIG/Examples/guile/test-suite/README7
-rw-r--r--SWIG/Examples/guile/test-suite/casts.i19
-rw-r--r--SWIG/Examples/guile/test-suite/casts.scm8
-rw-r--r--SWIG/Examples/guile/test-suite/char-constant.i6
-rw-r--r--SWIG/Examples/guile/test-suite/char-constant.scm3
-rw-r--r--SWIG/Examples/guile/test-suite/const-const.i9
-rw-r--r--SWIG/Examples/guile/test-suite/cplusplus-throw.i10
-rw-r--r--SWIG/Examples/guile/test-suite/import-a.h10
-rw-r--r--SWIG/Examples/guile/test-suite/import-a.i12
-rw-r--r--SWIG/Examples/guile/test-suite/import-b.h12
-rw-r--r--SWIG/Examples/guile/test-suite/import-b.i14
-rw-r--r--SWIG/Examples/guile/test-suite/import-main.cc24
-rw-r--r--SWIG/Examples/guile/test-suite/import.scm13
-rw-r--r--SWIG/Examples/guile/test-suite/long-long.i26
-rw-r--r--SWIG/Examples/guile/test-suite/macro-2.i17
-rw-r--r--SWIG/Examples/guile/test-suite/name.i15
-rw-r--r--SWIG/Examples/guile/test-suite/name.scm5
-rw-r--r--SWIG/Examples/guile/test-suite/pointer-reference.i13
-rw-r--r--SWIG/Examples/guile/test-suite/template-whitespace.i13
-rw-r--r--SWIG/Examples/index.html2
-rw-r--r--SWIG/Examples/java/class/.cvsignore3
-rw-r--r--SWIG/Examples/java/class/Makefile20
-rw-r--r--SWIG/Examples/java/class/example.cxx29
-rw-r--r--SWIG/Examples/java/class/example.h40
-rw-r--r--SWIG/Examples/java/class/example.i10
-rw-r--r--SWIG/Examples/java/class/index.html222
-rw-r--r--SWIG/Examples/java/class/main.java76
-rw-r--r--SWIG/Examples/java/constants/.cvsignore3
-rw-r--r--SWIG/Examples/java/constants/Makefile20
-rw-r--r--SWIG/Examples/java/constants/example.i26
-rw-r--r--SWIG/Examples/java/constants/index.html53
-rw-r--r--SWIG/Examples/java/constants/main.java45
-rw-r--r--SWIG/Examples/java/enum/.cvsignore3
-rw-r--r--SWIG/Examples/java/enum/Makefile20
-rw-r--r--SWIG/Examples/java/enum/example.cxx37
-rw-r--r--SWIG/Examples/java/enum/example.h13
-rw-r--r--SWIG/Examples/java/enum/example.i13
-rw-r--r--SWIG/Examples/java/enum/index.html37
-rw-r--r--SWIG/Examples/java/enum/main.java40
-rw-r--r--SWIG/Examples/java/index.html64
-rw-r--r--SWIG/Examples/java/native/.cvsignore4
-rw-r--r--SWIG/Examples/java/native/Makefile3
-rw-r--r--SWIG/Examples/java/native/README6
-rw-r--r--SWIG/Examples/java/native/example.i10
-rw-r--r--SWIG/Examples/java/native/index.html33
-rw-r--r--SWIG/Examples/java/native/main.java1
-rw-r--r--SWIG/Examples/java/reference/.cvsignore3
-rw-r--r--SWIG/Examples/java/reference/Makefile20
-rw-r--r--SWIG/Examples/java/reference/example.cxx41
-rw-r--r--SWIG/Examples/java/reference/example.h26
-rw-r--r--SWIG/Examples/java/reference/example.i46
-rw-r--r--SWIG/Examples/java/reference/index.html149
-rw-r--r--SWIG/Examples/java/reference/main.java91
-rw-r--r--SWIG/Examples/java/simple/.cvsignore4
-rw-r--r--SWIG/Examples/java/simple/Makefile3
-rw-r--r--SWIG/Examples/java/simple/README8
-rw-r--r--SWIG/Examples/java/simple/index.html112
-rw-r--r--SWIG/Examples/java/typemap/.cvsignore4
-rw-r--r--SWIG/Examples/java/typemap/Makefile1
-rw-r--r--SWIG/Examples/java/typemap/README8
-rw-r--r--SWIG/Examples/java/typemap/example.i4
-rw-r--r--SWIG/Examples/java/typemap/index.html34
-rw-r--r--SWIG/Examples/mzscheme/simple/.cvsignore1
-rw-r--r--SWIG/Examples/perl5/class/.cvsignore2
-rw-r--r--SWIG/Examples/perl5/constants/.cvsignore2
-rw-r--r--SWIG/Examples/perl5/funcptr/.cvsignore2
-rw-r--r--SWIG/Examples/perl5/pointer-cxx/.cvsignore2
-rw-r--r--SWIG/Examples/perl5/pointer-cxx/Makefile18
-rw-r--r--SWIG/Examples/perl5/pointer-cxx/README5
-rw-r--r--SWIG/Examples/perl5/pointer-cxx/example.c16
-rw-r--r--SWIG/Examples/perl5/pointer-cxx/example.i23
-rw-r--r--SWIG/Examples/perl5/pointer-cxx/example.pl42
-rw-r--r--SWIG/Examples/perl5/pointer/.cvsignore2
-rw-r--r--SWIG/Examples/perl5/reference/.cvsignore2
-rw-r--r--SWIG/Examples/perl5/simple/.cvsignore2
-rw-r--r--SWIG/Examples/perl5/value/.cvsignore2
-rw-r--r--SWIG/Examples/perl5/variables/.cvsignore2
-rw-r--r--SWIG/Examples/python/class/.cvsignore1
-rw-r--r--SWIG/Examples/python/constants/.cvsignore1
-rw-r--r--SWIG/Examples/python/enum/.cvsignore1
-rw-r--r--SWIG/Examples/python/funcptr/.cvsignore1
-rw-r--r--SWIG/Examples/python/pointer/.cvsignore1
-rw-r--r--SWIG/Examples/python/reference/.cvsignore1
-rw-r--r--SWIG/Examples/python/shadow/.cvsignore2
-rw-r--r--SWIG/Examples/python/shadow/Makefile7
-rw-r--r--SWIG/Examples/python/simple/.cvsignore1
-rw-r--r--SWIG/Examples/python/value/.cvsignore1
-rw-r--r--SWIG/Examples/python/variables/.cvsignore1
-rw-r--r--SWIG/Examples/ruby/class/.cvsignore1
-rw-r--r--SWIG/Examples/ruby/constants/.cvsignore1
-rw-r--r--SWIG/Examples/ruby/enum/.cvsignore1
-rw-r--r--SWIG/Examples/ruby/funcptr/.cvsignore1
-rw-r--r--SWIG/Examples/ruby/pointer/.cvsignore1
-rw-r--r--SWIG/Examples/ruby/reference/.cvsignore1
-rw-r--r--SWIG/Examples/ruby/simple/.cvsignore1
-rw-r--r--SWIG/Examples/ruby/value/.cvsignore1
-rw-r--r--SWIG/Examples/ruby/variables/.cvsignore1
-rw-r--r--SWIG/Examples/tcl/class/.cvsignore1
-rw-r--r--SWIG/Examples/tcl/constants/.cvsignore1
-rw-r--r--SWIG/Examples/tcl/enum/.cvsignore1
-rw-r--r--SWIG/Examples/tcl/funcptr/.cvsignore1
-rw-r--r--SWIG/Examples/tcl/pointer/.cvsignore1
-rw-r--r--SWIG/Examples/tcl/reference/.cvsignore1
-rw-r--r--SWIG/Examples/tcl/simple/.cvsignore1
-rw-r--r--SWIG/Examples/tcl/value/.cvsignore1
-rw-r--r--SWIG/Examples/tcl/variables/.cvsignore1
-rw-r--r--SWIG/INSTALL226
-rw-r--r--SWIG/Lib/common.swg7
-rw-r--r--SWIG/Lib/guile/guile.i2
-rw-r--r--SWIG/Lib/guile/guile.swg62
-rw-r--r--SWIG/Lib/guile/guiledec.swg51
-rw-r--r--SWIG/Lib/guile/guilemain.i8
-rw-r--r--SWIG/Lib/guile/list-vector.i222
-rw-r--r--SWIG/Lib/guile/pointer-in-out.i68
-rw-r--r--SWIG/Lib/guile/ports.i3
-rw-r--r--SWIG/Lib/guile/typemaps.i77
-rw-r--r--SWIG/Lib/java/java_arrays.i11
-rw-r--r--SWIG/Lib/java/stl_string.i82
-rw-r--r--SWIG/Lib/java/typemaps.i84
-rw-r--r--SWIG/Lib/mzscheme/mzscheme.i14
-rw-r--r--SWIG/Lib/mzscheme/mzscheme.swg2
-rw-r--r--SWIG/Lib/mzscheme/mzschemedec.swg8
-rw-r--r--SWIG/Lib/mzscheme/typemaps.i28
-rw-r--r--SWIG/Lib/perl5/perl5.swg8
-rw-r--r--SWIG/Lib/perl5/ptrlang.i8
-rw-r--r--SWIG/Lib/ruby/rubydec.swg2
-rw-r--r--SWIG/Lib/tcl/object.swg22
-rw-r--r--SWIG/Lib/tcl/swigtcl8.swg10
-rw-r--r--SWIG/Lib/tcl/tclsh.i4
-rw-r--r--SWIG/Lib/tcl/wish.i7
-rw-r--r--SWIG/Makefile.in239
-rw-r--r--SWIG/NEW2
-rw-r--r--SWIG/README160
-rw-r--r--SWIG/Runtime/.cvsignore7
-rw-r--r--SWIG/Runtime/Makefile.in57
-rw-r--r--SWIG/Source/DOH/Doh/Makefile50
-rw-r--r--SWIG/Source/DOH/configure.in2
-rw-r--r--SWIG/Source/Include/.cvsignore1
-rw-r--r--SWIG/Source/Include/swigconfig.h.in16
-rw-r--r--SWIG/Source/Include/swigver.h4
-rw-r--r--SWIG/Source/Modules/.cvsignore1
-rw-r--r--SWIG/Source/Modules1.1/Makefile.in4
-rw-r--r--SWIG/Source/Modules1.1/guile.cxx371
-rw-r--r--SWIG/Source/Modules1.1/guile.h17
-rw-r--r--SWIG/Source/Modules1.1/java.cxx1795
-rw-r--r--SWIG/Source/Modules1.1/java.h12
-rw-r--r--SWIG/Source/Modules1.1/mzscheme.cxx125
-rw-r--r--SWIG/Source/Modules1.1/perl5.cxx259
-rw-r--r--SWIG/Source/Modules1.1/python.cxx45
-rw-r--r--SWIG/Source/Modules1.1/ruby.cxx71
-rw-r--r--SWIG/Source/Modules1.1/swigmain.cxx4
-rw-r--r--SWIG/Source/Modules1.1/tcl8.cxx11
-rw-r--r--SWIG/Source/Preprocessor/cpp.c60
-rw-r--r--SWIG/Source/SWIG1.1/.cvsignore8
-rw-r--r--SWIG/Source/SWIG1.1/cplus.cxx10
-rw-r--r--SWIG/Source/SWIG1.1/lang.cxx39
-rw-r--r--SWIG/Source/SWIG1.1/main.cxx18
-rw-r--r--SWIG/Source/SWIG1.1/parser.yxx56
-rw-r--r--SWIG/Source/SWIG1.1/scanner.cxx1
-rw-r--r--SWIG/Source/SWIG1.1/swig11.h2
-rw-r--r--SWIG/Source/Swig/cwrap.c55
-rw-r--r--SWIG/Source/Swig/misc.c4
-rw-r--r--SWIG/Source/Swig/stype.c4
-rw-r--r--SWIG/Source/Swig/swig.h2
-rw-r--r--SWIG/Source/Swig/typemap.c9
-rw-r--r--SWIG/TODO77
-rw-r--r--SWIG/Tools/.cvsignore4
-rw-r--r--SWIG/VERSION6
-rwxr-xr-xSWIG/autogen.sh6
-rw-r--r--SWIG/configure.in144
-rw-r--r--SWIG/debian/.cvsignore1
-rw-r--r--SWIG/debian/README20
-rw-r--r--SWIG/debian/changelog60
-rw-r--r--SWIG/debian/control18
-rw-r--r--SWIG/debian/copyright83
-rw-r--r--SWIG/debian/dirs4
-rw-r--r--SWIG/debian/docs10
-rw-r--r--SWIG/debian/postinst45
-rwxr-xr-xSWIG/debian/rules76
-rw-r--r--SWIG/debian/substvars1
229 files changed, 6613 insertions, 3058 deletions
diff --git a/SWIG/ANNOUNCE b/SWIG/ANNOUNCE
index df906961f..c514b4bb1 100644
--- a/SWIG/ANNOUNCE
+++ b/SWIG/ANNOUNCE
@@ -1,31 +1,32 @@
-*** ANNOUNCE : SWIG1.3 (Alpha 4) ***
+*** ANNOUNCE: SWIG 1.3.6 ***
-September 4, 2000
+July 9, 2001
Overview
--------
+
We're pleased to announce the next installment of the SWIG1.3
-redevelopment effort. This release represents a reasonably stable
-snapshot of the CVS repository that has undergone extensive testing
-and debugging. However, this release also represents work in progress
-so there may be obscure bugs and problems that we haven't found yet.
-Please send us your feedback.
+redevelopment effort. This release represents a new stable release of
+SWIG, aiming to replace versions 1.1p5 and 1.1-883. It has been
+derived from the reasonably stable release 1.3a5; many bugs have been
+fixed since, the Java module has been brought back into action, and
+the Guile module has been improved a lot.
Availability:
-------------
The release is available for download on Sourceforge at
- http://download.sourceforge.net/swig/swig1.3a4.tar.gz
+ http://download.sourceforge.net/swig/
What's new?
-----------
On the surface, this release still looks a lot like SWIG1.1p5 except
that a lot of bugs have been fixed and the language modules tend to
generate smaller and more efficient wrappers. New modules have also
-been added to support Ruby and Mzscheme. In addition, Python, Perl,
+been added to support Java, Ruby and Mzscheme. In addition, Python, Perl,
and Guile support has been enhanced to support new releases such as
-Python1.6 and Perl5.6.
+Python1.6 and Perl5.6.
Under the hood, you will find that this release is an almost complete
reimplementation of SWIG's internals. In fact the only code that
@@ -41,8 +42,7 @@ What's broken?
--------------
As this is a work in progress, a number of features are still missing
or incomplete. The documentation system is still missing and won't be
-reimplemented for some time. The Java module is also temporarily out
-of service for this release. In addition, C++ programmers who make
+reimplemented for some time. C++ programmers who make
extensive use of typemaps may encounter a few strange problems
(although SWIG will generate warning messages).
@@ -68,6 +68,5 @@ David Beazley
Thien-Thi Nguyen
Matthias Köppe
Masaki Fukushima
-Harco de Hilster
Loic Dachary
-Oleg Tolmatcev
+William Fulton
diff --git a/SWIG/CHANGES b/SWIG/CHANGES
index 462b674c8..b2724a193 100644
--- a/SWIG/CHANGES
+++ b/SWIG/CHANGES
@@ -1,5 +1,393 @@
SWIG (Simplified Wrapper and Interface Generator)
+The Stable Development Branch
+=============================
+
+In this CVS branch "mkoeppe-1-3-a5-patches", fixes in the SWIG core
+and improvements to the language modules take place, starting from the
+relatively stable release 1.3a5. It works towards the new stable
+release 1.3.6.
+
+This branch is also the basis for the "swig1.3" Debian package
+(currently unofficial, available from
+http://www.math.uni-magdeburg.de/~mkoeppe/imo-debian).
+
+Eventually this branch will be merged with the development on the
+trunk of the CVS tree.
+
+Version 1.3.6 (July 9, 2001)
+=============================
+
+7/09/2001: cheetah (william fulton)
+ * GIFPlot examples: FOREGROUND and BACKGROUND definition missing
+ after TRANSPARENT #define fix in GIFPlot
+
+7/03/2001: beazley
+ Fixed up the version numbers so that the release is known
+ as 1.3.6. All future releases should have a similar
+ version format.
+
+7/02/2001: mkoeppe
+ * [Python]: Prevent the problem of self.thisown not being
+ defined if the C++ class constructor raised an exception.
+ Thanks to Luigi Ballabio <ballabio@mac.com>.
+
+6/29/2001: mkoeppe
+ * More portability fixes; fixed "gcc -Wall" warnings.
+
+6/29/2001: cheetah (william fulton)
+ * GIFPlot examples: TRANSPARENT #define multiple times on Solaris
+ (clashes with stream.h).
+ * Multiple definition bug fix for shadow classes. The perl and python
+ modules had workarounds which have been replaced with fixes in
+ the core. Many of the Language::cpp_xxxx functions now set a
+ flag which the derived classes can access through
+ is_multiple_definition() to see whether or not code should be
+ generated. The code below would have produced varying degrees
+ of incorrect shadow class code for the various modules:
+ class TestClass
+ {
+ public:
+ TestClass() {};
+ TestClass(int a) {};
+ ~TestClass() {};
+ unsigned long xyz(short k) {};
+ unsigned long xyz(int n) {};
+ static void static_func() {};
+ static void static_func(int a) {};
+ };
+ void delete_TestClass(int a);
+
+6/27/2001: mkoeppe
+ * [Perl] Another const-related portability fix.
+
+6/26/2001: cheetah (william fulton)
+ * [Java] Added in cpp_pragma() support with a host of new pragmas - see
+ jswig.html. These are designed for better mixing of Java and c++. It
+ enables the user to specify pure Java classes as bases and/or interfaces
+ for the wrapped c/c++.
+ * [Java] Old pragmas renamed. Warning given for the moment if used.
+ *** POTENTIAL INCOMPATIBILITY FOR JAVA MODULE ***
+
+6/25/2001: mkoeppe
+ * Incorporated more build changes contributed by Wyss Clemens
+ <WYS@helbling.ch> for swig/ruby on cygwin.
+
+6/20/2001: cheetah (william fulton)
+ * Makefile mods so that 'make check' uses the swig options in the makefiles
+ * [Java] Removed Generating wrappers message
+ * [Java] NULL pointer bug fix
+ * [Java] Bug fix for Kaffe JVM
+
+6/20/2001: mkoeppe
+ * SWIG_TypeQuery from common.swg now returns a
+ swig_type_info* rather than a void*. This fixes a problem
+ when using pointer.i and C++, as illustrated by the new
+ test-suite example perl5/pointer-cxx.
+ * Portability fixes (const char *).
+ * Incorporated build changes contributed by Wyss Clemens
+ <WYS@helbling.ch>, which make swig runnable on cygwin.
+
+6/19/2001: cheetah (william fulton)
+ * [Java] Bug fix for SF bug #211144. This fix is a workaround
+ until fixed in the core.
+
+6/19/2001: mkoeppe
+ * [Guile]: Portability fixes for use with the Sun Forte
+ compilers.
+ * [Tcl]: Portability fix (const char *).
+ * [Tcl]: Configure now first tries to find a tclConfig.sh
+ file in order to find the Tcl include directory, library
+ location and library name.
+ * [Python]: Added a few possible library locations.
+
+6/18/2001: mkoeppe
+ * [Guile]: Don't call scm_c_export if nothing is to be
+ exported. Don't warn on %module if module has been set
+ already (this frequently occurs when %import is used).
+
+6/16/2001: mkoeppe
+ * [Guile]: New "passive" linkage, which is appropriate for
+ multi-module extensions without Guile module magic.
+
+6/15/2001: mkoeppe
+ * [Guile]: Fixed printing of smobs (space and angle were
+ missing).
+ * Properly generate type information for base classes
+ imported with the %import directive. Thanks to Marcelo
+ Matus <mmatus@acms.arizona.edu> for the report and the
+ patch; this closes SF bug #231619; see also
+ Examples/guile/test-suite/import*.
+ * [Guile]: Fix casting between class and base class; the
+ runtime type system had it the wrong way around; see
+ Examples/guile/test-suite/casts.i
+ * Make typemaps for SWIGPOINTER * with arg name take
+ precedence over those without arg name, to match normal
+ typemap precedence rules.
+ * Fixed the random-line-numbers problem reported as SF bug
+ #217310; thanks to Michael Scharf <scharf@users.sf.net>.
+ * [Guile]: Handle the %name and %rename directives.
+ * New syntax: %name and %rename now optionally take double
+ quotes around the scripting name. This is to allow scripting
+ names that aren't valid C identifiers.
+
+6/14/2001: beazley
+ Made a minor change to the way files are loaded in
+ order to get file/line number reporting correct in
+ the preprocessor.
+
+6/14/2001: mkoeppe
+ * The parser now understands the (non-standard) "long long"
+ types. It is up to the individual language modules to
+ provide typemaps if needed. Reported by Sam Steingold, SF
+ bug #429176.
+ * The parser now understands arguments like "const int *
+ const i". This fixes SF bug #215649.
+ * Fixed the Guile test-suite.
+
+6/13/2001: mkoeppe
+ Partial merge from the CVS trunk at tag
+ "mkoeppe-merge-1". This covers the following changes:
+
+| 01/16/01: ttn
+| Wrote table of contents for Doc/engineering.html. Added section
+| on CVS tagging conventions. Added copyright to other docs.
+| 9/25/00 : beazley
+| Modified the preprocessor so that macro names can start with a '%'.
+| This may allow new SWIG "directives" to be defined as macros instead
+| of having to be hard-coded into the parser.
+|
+| *** Also a yet-to-be-documented quoting mechanism with backquotes
+| *** has been implemented?
+
+6/13/2001: mkoeppe
+ * When configure does not find a language, don't use default
+ paths like /usr/local/include; this only causes build
+ problems.
+ * New directory: Examples/Guile/test-suite, where a few
+ bugs in 1.3a5 are demonstrated.
+ * Handle C++ methods that have both a "const" and a "throw"
+ directive (see Examples/Guile/test-suite/cplusplus-throw.i);
+ thanks to Scott B. Drummonds for the report and the fix.
+ * Handle C++ pointer-reference arguments (like "int *& arg")
+ (see Examples/Guile/test-suite/pointer-reference.i,
+ reported as SF bug #432224).
+ * [Ruby] Fixed typo in rubydec.swg; thanks to Lyle Johnson!
+ * Don't stop testing when one test fails.
+ * [Guile, MzScheme] Don't print "Generating wrappers...".
+
+6/12/2001: mkoeppe
+ [Guile] VECTORLENINPUT and LISTLENINPUT now have separate
+ list length variables. TYPEMAP_POINTER_INPUT_OUTPUT
+ attaches argument documentation involving SCM_TYPE to the
+ standard pointer typemaps. INOUT is now an alias for BOTH.
+
+6/12/2001: cheetah (william fulton)
+ Some Java documentation added.
+ [Java] Fixed bugs in import pragma and shadow pragma.
+
+6/12/2001: mkoeppe
+ Fix declarations of SWIG_define_class
+ (Lib/ruby/rubydec.swg) and SWIG_TypeQuery
+ (Lib/common.swg). Thanks to Lyle Johnson
+ <ljohnson@resgen.com> for the patches.
+
+6/11/2001: mkoeppe
+ [Guile] Use long instead of scm_bits_t; this makes the
+ generated wrapper code compatible with Guile 1.3.4
+ again. Thanks to Masaki Fukushima for pointing this out.
+
+6/11/2001: cheetah (william fulton)
+ The generic INSTALL file from autoconf added. Few changes to README file.
+
+6/11/2001: mkoeppe
+ Fixed typo in Makefile.in; thanks to Greg Troxel
+ <gdt@ir.bbn.com>.
+
+6/08/2001: cheetah (william fulton)
+ make check works again. Examples/GIFPlot configure generated by
+ top level autoconf now.
+
+6/08/2001: mkoeppe
+ Another build change: The new script autogen.sh runs
+ autoconf in the appropriate directories. The top-level
+ configure also configures in Examples/GIFPlot.
+
+6/07/2001: mkoeppe
+ Made the Makefile work with non-GNU make again.
+
+6/07/2001: cheetah (william fulton)
+ [Java] Class/struct members that are arrays of pointers to classes/structs -
+ Shadow class's get/set accessors now use Java classes instead of longs (pointers).
+ [Java] Shadow classes will now clean up memory if function return type
+ is a class/struct.
+ [Java] New example called reference based on the same example from other modules.
+
+6/06/2001: mkoeppe
+ New configure option --with-release-suffix allows for
+ attaching a suffix to the swig binary and the swig runtime
+ libraries. Minor changes to the build system. "swig
+ -swiglib" works again. If invoked with the new option
+ "-ldflags", SWIG prints a line of linker flags needed to
+ link with the runtime library of the selected language
+ module.
+
+6/06/2001: mkoeppe
+ [Guile] gswig_list_p is an int, not a SCM. This typo
+ caused warnings when compiling with a Guile configured with
+ strict C type checking. In INPUT and BOTH typemaps
+ generated by the SIMPLE_MAP macro, use the SCM_TO_C
+ function to convert from Guile to C (rather than C_TO_SCM).
+ Use scm_intprint to print pointers (rather than
+ sprintf). Allow using "-linkage" instead of "-Linkage".
+
+6/05/2001: cheetah (william fulton)
+ [Java] Mods for using inherited c++ classes from Java
+ [Java] New example called class based on the same example from other modules
+
+6/05/2001: cheetah (william fulton)
+ [Java] destructor (_delete()) was not aware of %name renaming
+ [Java] extends baseclass did not know about %name renaming
+ [Java] extends baseclass did extend even when the baseclass was not known to swig
+ [Java] sometimes enum-declarations occured before the Java class declaration
+ [Java] unrelated enum initialisations no longer appear in Java class
+ [Java] if module ends in '_' correct JNI names are now produced
+
+6/04/2001: cheetah (william fulton)
+ [Java] Shadow class mods - Modified constructor replaces
+ newInstance(). _delete() now thread safe. getCPtr() replaces
+ _self. _selfClass() removed as now redundant.
+ *** POTENTIAL INCOMPATIBILITY FOR JAVA MODULE ***
+
+ [Java] Not all output java files had SWIG banner. New banner.
+
+ [Java] Shadow class finalizers are output by default: Command
+ line option -finalize deprecated and replaced with -nofinalize.
+ *** POTENTIAL INCOMPATIBILITY FOR JAVA MODULE ***
+
+6/ 1/2001: mkoeppe
+ [Guile] Cast SCM_CAR() to scm_bits_t before shifting it.
+ This is required for compiling with a Guile configured with
+ strict C type checking.
+
+6/ 1/2001: mkoeppe
+ Added configure option "--with-swiglibdir".
+
+5/31/2001: mkoeppe
+ [Guile] Support multiple parallel lists or vectors in
+ the typemaps provided by list-vector.i. New typemaps file,
+ pointer-in-out.i.
+
+5/25/2001: cheetah (william fulton)
+ [Java] HTML update for examples.
+
+5/28/2001: mkoeppe
+ Minor changes to the build system. Added subdirectory for
+ Debian package control files.
+
+5/28/2001: mkoeppe
+ [Guile] Build a runtime library, libswigguile.
+
+5/28/2001: mkoeppe
+ [Guile] New typemap substitution $*descriptor. Use the {}
+ syntax, rather than the "" syntax for the standard
+ typemaps, in order to work around strange macro-expansion
+ behavior of the SWIG preprocessor. This introduces some
+ extra braces.
+
+5/27/2001: mkoeppe
+ [Guile] Handle pointer types with typemaps, rather than
+ hard-coded. New typemap substitutions $descriptor,
+ $basedescriptor; see documentation. Some clean-up in the
+ variable/constants wrapper generator code. New convenience
+ macro SWIG_Guile_MustGetPtr, which allows getting pointers
+ from smobs in a functional style. New typemap file
+ "list-vector.i", providing macros that define typemaps for
+ converting between C arrays and Scheme lists and vectors.
+
+5/25/2001: cheetah (william fulton)
+ [Java] STL string moved into its own typemap as it is c++ code and
+ it break any c code using the typemaps.i file.
+ - Fixes for wrappers around global variables - applies to primitive
+ types and user types (class/struct) and pointers to these.
+ - Structure member variables and class public member variables getters
+ and setters pass a pointer to the member as was in 1.3a3 and 1.1
+ (1.3a5 was passing by value)
+ - Parameters that were arrays and return types were incorrectly
+ being passed to create_function() as pointers.
+ - Fix for arrays of enums.
+ [Java] Updated java examples and added two more.
+ [Java] Java module updated from SWIG1.3a3 including code cleanup etc.
+ [Java] enum support added.
+ [Java] Array support implemented
+ [Java] Shadow classes improved - Java objects used rather than
+ longs holding the c pointer to the wrapped structure/c++class
+
+5/22/2001: mkoeppe
+ [Guile] Fixed extern "C" declarations in C++ mode. Thanks
+ to Greg Troxel <gdt@ir.bbn.com>.
+
+5/21/2001: mkoeppe
+ [Guile] New linkage "module" for creating Guile modules for
+ Guile versions >= 1.5.0.
+
+4/18/2001: mkoeppe
+ [MzScheme] Added typemaps for passing through Scheme_Object
+ pointers.
+
+4/9/2001 : mkoeppe
+ [MzScheme] Added typemaps for `bool'. Inclusion of headers
+ and support routines is now data-driven via mzscheme.i.
+ Headers come from the new file mzschemdec.swg. Don't abort
+ immediately when a type-handling error is reported. When
+ searching for typemaps for enums, fall back to using int,
+ like the Guile backend does. Support char constants. Emit
+ correct wrapper code for variables.
+
+3/12/2001: mkoeppe
+ [Guile] Fixed typemaps for char **OUTPUT, char **BOTH.
+
+3/2/2001 : mkoeppe
+ [Guile] Every wrapper function now gets a boolean variable
+ gswig_list_p which indicates whether multiple values are
+ present. The macros GUILE_APPEND_RESULT, GUILE_MAYBE_VALUES
+ and GUILE_MAYBE_VECTOR use this variable, rather than
+ checking whether the current return value is a list. This
+ allows for typemaps returning a list as a single value (a
+ list was erroneously converted into a vector or a
+ multiple-value object in this case).
+
+3/1/2001 : mkoeppe
+ [Guile] Added support for returning multiple values as
+ vectors, or passing them to a muliple-value
+ continuation. By default, multiple values still get
+ returned as a list.
+
+3/1/2001 : mkoeppe
+ [Guile] Added a "beforereturn" pragma. The value of this
+ pragma is inserted just before every return statement.
+
+3/1/2001 : mkoeppe
+ [Guile] Added support for Guile 1.4.1 procedure
+ documentation formats, see internals.html.
+
+2/26/2001: mkoeppe
+ [Guile] Made the wrapper code compile with C++ if the
+ "-c++" command-line switch is given. Thanks to
+ <monkeyiq@dingoblue.net.au>.
+
+2/26/2001: mkoeppe
+ [Guile] Now two type tables, swig_types and
+ swig_types_initial, are used, as all other SWIG language
+ modules do. This removes the need for the tricky
+ construction used before that the broken Redhat 7.0 gcc
+ doesn't parse. Reported by <monkeyiq@dingoblue.net.au>.
+
+2/26/2001: mkoeppe
+ [Guile] Fixed typemaps for char *OUTPUT, char *BOTH; a bad
+ free() would be emitted. Added typemap for SCM.
+
+
Version 1.3 Alpha 5
===================
diff --git a/SWIG/Doc/engineering.html b/SWIG/Doc/engineering.html
index 9d01ebb60..e9d60b347 100644
--- a/SWIG/Doc/engineering.html
+++ b/SWIG/Doc/engineering.html
@@ -20,7 +20,24 @@ beazley@cs.uchicago.edu <br>
<p>
(Note : This is a work in progress.)
+<h2>Table of Contents</h2>
+<ul>
+<li><a name="i1" href="#1">1. Introduction</a>
+<li><a name="i2" href="#2">2. Programming Languages and Libraries</a>
+<li><a name="i3" href="#3">3. The Source Directory and Module Names</a>
+<li><a name="i4" href="#4">4. Include Files</a>
+<li><a name="i5" href="#5">5. File Structure</a>
+<li><a name="i6" href="#6">6. Bottom-Up Design</a>
+<li><a name="i7" href="#7">7. Functions</a>
+<li><a name="i8" href="#8">8. Naming Conventions</a>
+<li><a name="i9" href="#9">9. Visibility</a>
+<li><a name="i10" href="#10">10. Miscellaneous Coding Guidelines</a>
+<li><a name="i11" href="#11">11. CVS Tagging Conventions</a>
+</ul>
+
+<a name="1" href="#i1">
<h2>1. Introduction</h2>
+</a>
The purpose of this document is to describe various coding conventions
and organizational aspects for SWIG developers. The idea for this
@@ -58,7 +75,9 @@ should be developed within the SWIG project. These rules are
primarily drawn from my own experience developing software and
observing the practices of other successful projects.
+<a name="2" href="#i2">
<h2>2. Programming Languages and Libraries </h2>
+</a>
All SWIG modules must be written in either ANSI C or one of the
scripting languages for which SWIG can generate an interface (e.g.,
@@ -81,7 +100,9 @@ should always be included inside a conditional compilation block so
that it can be omitted on problematic platforms. If you are unsure
about a library call, check the man page or contact Dave.
+<a name="3" href="#i3">
<h2>3. The Source Directory and Module Names</h2>
+</a>
All SWIG modules are contained within the "Source" directory. Within
this directory, each module is placed into its own subdirectory. The
@@ -100,7 +121,9 @@ sure the first letter is capitalized. Also, module names should not
start with numbers, include underscores or any other special
non-alphanumeric characters.
-<h2>4. Include files </h2>
+<a name="4" href="#i4">
+<h2>4. Include Files </h2>
+</a>
All modules should include a header file that defines the public interface.
The name of this header file should be of the form "swigmodule.h" where
@@ -150,7 +173,9 @@ extern "C" {
<p>
To minimize compilation time, please include as few other header files as possible.
+<a name="5" href="#i5">
<h2>5. File Structure </h2>
+</a>
Each file in a module should be given a filename that is all lowercase letters
such as "parser.c", not "Parser.c" or "PARSER.c". Please note that filenames
@@ -210,7 +235,9 @@ multiple files. Similarly, you should avoid the temptation to create
many small files as this increases compilation time and makes the
directory structure too complicated.
+<a name="6" href="#i6">
<h2>6. Bottom-Up Design </h2>
+</a>
Within each source file, the preferred organization is to use what is
known as "bottom-up" design. Under this scheme, lower-level functions
@@ -248,7 +275,9 @@ benefits particular to C. In particular, a bottom-up design generally
eliminates the need to include forward references--resulting in
cleaner code and fewer compilation errors.
+<a name="7" href="#i7">
<h2>7. Functions</h2>
+</a>
All functions should have a function header that gives the function name
and a short description like this:
@@ -279,7 +308,9 @@ Function declarations should <b>NOT</b> use the pre-ANSI function
declaration syntax. The ANSI standard has been around long enough for
this to be a non-issue.
+<a name="8" href="#i8">
<h2>8. Naming Conventions</h2>
+</a>
The following conventions are used to name various objects throughout SWIG.
@@ -362,7 +393,9 @@ typedef struct SwigScanner {
Static declarations are free to use any naming convention that is appropriate. However, most
existing parts of SWIG use lower-case names and follow the same convention as described for functions.
+<a name="9" href="#i9">
<h2>9. Visibility</h2>
+</a>
Modules should keep the following rules in mind when exposing their internals:
@@ -403,12 +436,50 @@ making your changes.
</ul>
-<h2>10. Miscellaneous </h2>
+<a name="10" href="#i10">
+<h2>10. Miscellaneous Coding Guidelines</h2>
+</a>
<ul>
<li> Do not use the ternary ?: operator. It is unnecessarily error prone,
hard for people to read, and hard to maintain code that uses it.
+[I don't agree w/ this guideline. ?: operator can be abused
+just like everything else, but it can also be used cleanly. In some styles of
+programming, it is the best tool for the job. --ttn]
+</ul>
+
+<a name="11" href="#i11">
+<h2>11. CVS Tagging Conventions</h2>
+</a>
+
+Use <tt>cvs tag</tt> to declare some set of file revisions as related in some
+symbolic way. This eases reference, retrieval and manipulation of these files
+later. At the moment (2001/01/16 14:02:53), the conventions are very simple;
+let's hope they stay that way!
+
+<p>
+There are two types of tags, internal (aka personal) and external.
+Internal tags are used by SWIG developers primarily, whereas external
+tags are used when communicating with people w/ anonymous cvs access.
+<ul>
+<li> Internal tags should start with the developer name and a hyphen.
+<li> External tags should start with "v-".
+</ul>
+
+That's all there is to it. Some example tags:
+
+<ul>
+<li> ttn-pre-xml-patch
+<li> ttn-post-xml-patch
+<li> ttn-going-on-vacation-so-dutifully-tagging-now
+<li> v-1-3-a37-fixes-bug-2432
+<li> v-1-3-a37-fixes-bug-2433
+<li> v-1-3-a37-fixes-bug-2432-again
+<li> v-1-3-a37-release
</ul>
+<hr>
+Copyright (C) 1999-2001
+<a href="mailto:swig-dev@cs.uchicago.edu">SWIG Development Team</a>
</body>
</html>
diff --git a/SWIG/Doc/index.html b/SWIG/Doc/index.html
index f1e60ce4a..cd2a5da61 100644
--- a/SWIG/Doc/index.html
+++ b/SWIG/Doc/index.html
@@ -10,7 +10,13 @@ This directory contains SWIG documentation:
<li><a href="whitepaper.html">Project Overview Whitepaper</a>
<li><a href="engineering.html">Engineering Manual</a>
<li><a href="internals.html">Internals Manual</a>
+<li><a href="jswig.html">Some Java User Documentation</a>
+<li><a href="migrate.txt">SWIG1.3 Migration Guide</a>
</ul>
+<hr>
+Copyright (C) 1999-2001
+<a href="mailto:swig-dev@cs.uchicago.edu">SWIG Development Team</a>
+
</body>
</html>
diff --git a/SWIG/Doc/internals.html b/SWIG/Doc/internals.html
index 1da79154e..76b5d055a 100644
--- a/SWIG/Doc/internals.html
+++ b/SWIG/Doc/internals.html
@@ -940,7 +940,7 @@ for specifying local variable declarations and argument conversions.
<h2>10. Guile Support</h2>
</a>
-Revised: Matthias K&ouml;ppe (August 30, 2000)
+Revised: Matthias K&ouml;ppe (May 29, 2001)
<p>
@@ -963,27 +963,129 @@ we explicitly prefix the context, e.g., "guile-module".
Guile support is complicated by a lack of user community cohesiveness,
which manifests in multiple shared-library usage conventions. A set of
policies implementing a usage convention is called a <b>linkage</b>.
+
+<h4>Simple Linkage</h4>
+
The default linkage is the simplest; nothing special is done. In this
-case <code>SWIG_init()</code> is provided and users must do something
-like this:
+case the function <code>SWIG_init()</code> is exported. Simple linkage
+can be used in several ways:
+<ul>
+<li><b>Embedded Guile, no modules.</b> You want to embed a Guile
+interpreter into your program; all bindings made by SWIG shall show up
+in the root module. Then call <code>SWIG_init()</code> in the
+<code>inner_main()</code> function. See the "simple" and "matrix" examples under
+<code>Examples/guile</code>.
+
+<li><b>Dynamic module mix-in.</b> You want to create a Guile module
+using <code>define-module</code>, containing both Scheme code and
+bindings made by SWIG; you want to load the SWIG modules as shared
+libraries into Guile.
<blockquote>
<pre>
+(define-module (my module))
(define my-so (dynamic-link "./example.so"))
-(dynamic-call "SWIG_init" my-so)
+(dynamic-call "SWIG_init" my-so) ; make SWIG bindings
+;; Scheme definitions can go here
</pre>
</blockquote>
+Newer Guile versions provide a shorthand for <code>dynamic-link</code>
+and <code>dynamic-call</code>:
+<blockquote>
+<pre>
+(load-extension "./example.so" "SWIG_init")
+</pre>
+</blockquote>
+You need to explicitly export those bindings made by SWIG that you
+want to import into other modules:
+<blockquote>
+<pre>
+(export foo bar)
+</pre>
+</blockquote>
+In this example, the procedures <code>foo</code> and <code>bar</code>
+would be exported.
+</ul>
-At this time, the name <code>SWIG_init</code> is hardcoded; this
-approach does not work with multiple swig-modules. NOTE: The "simple"
-and "matrix" examples under Examples/guile include guilemain.i; the
-resulting standalone interpreter does not require calls to
-<code>dynamic-link</code> and <code>dynamic-call</code>, as shown here.
+If you want to include several SWIG modules, you would need to rename
+<code>SWIG_init</code> via a preprocessor define to avoid symbol
+clashes. For this case, however, passive linkage is available.
-<p>
-A second linkage creates "libtool dl module" wrappers, and currently is
-broken. Whoever fixes this needs to track Guile's libtool dl module
-convention, since that is not finalized.
+<h4>Passive Linkage</h4>
+
+<p>Passive linkage is just like simple linkage, but it generates an
+initialization function whose name is derived from the module and
+package name (see below).
+
+<p>You should use passive linkage rather than simple linkage when you
+are using multiple modules.
+
+<h4>Native Guile Module Linkage</h4>
+
+<p>SWIG can also generate wrapper code that does all the Guile module
+declarations on its own if you pass it the <code>-Linkage
+module</code> command-line option. This requires Guile 1.5.0 or later.
+
+<p>The module name is set with the <code>-package</code> and
+<code>-module</code> command-line options. Suppose you want to define
+a module with name <code>(my lib foo)</code>; then you would have to
+pass the options <code>-package <var>my</var>/<var>lib</var> -module
+<var>foo</var></code>. Note that the last part of the name can also be set
+via the SWIG directive <code>%module</code>.
+
+<p>You can use this linkage in several ways:
+
+<ul>
+<li><b>Embedded Guile with SWIG modules.</b> You want to embed a Guile
+interpreter into your program; the SWIG bindings shall be put into
+different modules. Simply call the function
+<code>scm_init_<var>my</var>_<var>modules</var>_<var>foo</var>_module</code>
+in the <code>inner_main()</code> function.
+
+<li><b>Dynamic Guile modules.</b> You want to load the SWIG modules as
+shared libraries into Guile; all bindings are automatically put in
+newly created Guile modules.
+<blockquote>
+<pre>
+(define my-so (dynamic-link "./foo.so"))
+;; create new module and put bindings there:
+(dynamic-call "scm_init_my_modules_foo_module" my-so)
+</pre>
+</blockquote>
+Newer Guile versions have a shorthand procedure for this:
+<blockquote>
+<pre>
+(load-extension "./foo.so" "scm_init_my_modules_foo_module")
+</pre>
+</blockquote>
+</ul>
+
+<h4>Old Auto-Loading Guile Module Linkage</h4>
+
+<p>Guile used to support an autoloading facility for object-code
+modules. This support has been marked deprecated in version 1.4.1 and
+is going to disappear sooner or later. SWIG still supports building
+auto-loading modules if you pass it the <code>-Linkage ltdlmod</code>
+command-line option.
+
+<p>Auto-loading worked like this: Suppose a module with name <code>(my
+lib foo)</code> is required and not loaded yet. Guile will then search
+all directories in its search path
+for a Scheme file <code>my/modules/foo.scm</code> or a shared library
+<code><var>my</var>/<var>modules</var>/lib<var>foo</var>.so</code> (or
+<code><var>my</var>/<var>modules</var>/lib<var>foo</var>.la</code>;
+see the GNU libtool documentation). If a
+shared library is found that contains the symbol
+<code>scm_init_<var>my</var>_<var>modules</var>_<var>foo</var>_module</code>,
+the library is loaded, and the function at that symbol is called with
+no arguments in order to initialize the module.
+
+<p>When invoked with the <code>-Linkage ltdlmod</code> command-line
+option, SWIG generates an exported module initialization function with
+an apropriate name.
+
+
+<h4>Hobbit4D Linkage</h4>
<p>
The only other linkage supported at this time creates shared object
@@ -991,7 +1093,6 @@ libraries suitable for use by hobbit's <code>(hobbit4d link)</code>
guile module. This is called the "hobbit" linkage, and requires also
using the "-package" command line option to set the part of the module
name before the last symbol. For example, both command lines:
-[checkme:ttn]
<blockquote>
<pre>
@@ -1005,10 +1106,25 @@ case foo.i declares the module to be "foo"). The installed files are
my/lib/libfoo.so.X.Y.Z and friends. This scheme is still very
experimental; the (hobbit4d link) conventions are not well understood.
-<p>
-There are no other linkage types planned, but that could change... To
-add a new type, add the name to the enum in guile.h and add the case to
-<code>GUILE::emit_linkage()</code>.
+
+<h4>General Remarks on Multiple SWIG Modules</h4>
+
+If you want to use multiple SWIG modules, they have to share some
+run-time data for the typing system. You have two options:
+
+<ul>
+<li>Either generate all but one wrapper module with
+the <code>-c</code> command-line argument. Compile all wrapper files
+with the C compiler switch <code>-DSWIG_GLOBAL</code>.
+
+<li>Or generate all wrapper modules with the <code>-c</code>
+command-line argument and compile all wrapper files with the C
+compiler switch <code>-DSWIG_GLOBAL</code>. Then link against the
+runtime library <code>libswigguile</code>, which is built by
+<code>make runtime</code>. The needed linker flags are reported by
+SWIG if you invoke it with the <code>-guile -ldflags</code>
+command-line arguments.
+</ul>
<a name="10.3" href="#i10.3">
<h3>10.3 Underscore Folding</h3>
@@ -1019,14 +1135,69 @@ Underscores are converted to dashes in identifiers. Guile support may
grow an option to inhibit this folding in the future, but no one has
complained so far.
+<p>You can use the SWIG directives <code>%name</code> and
+<code>%rename</code> to specify the Guile name of the wrapped
+functions and variables (see CHANGES).
+
<a name="10.4" href="#i10.4">
<h3>10.4 Typemaps</h3>
</a>
<p>
-The Guile module handles all non-pointer types via typemaps. This
+The Guile module handles all types via typemaps. This
information is read from <code>Lib/guile/typemaps.i</code>.
+Some non-standard typemap substitutions are supported:
+<ul>
+<li><code>$descriptor</code> expands to a type descriptor for use with
+the <code>SWIG_Guile_MakePtr()</code> and
+<code>SWIG_Guile_GetPtr</code> functions.
+<li>For pointer types, <code>$*descriptor</code> expands to a
+descriptor for the direct base type (i.e., one pointer is stripped),
+whereas <code>$basedescriptor</code> expands to a
+descriptor for the base type (i.e., all pointers are stripped).
+</ul>
+
+<p>A function returning <code>void</code> (more precisely, a function
+whose <code>out</code> typemap returns <code>GH_UNSPECIFIED</code>) is
+treated as returning no values. In <code>argout</code> typemaps, one
+can use the macro <code>GUILE_APPEND_RESULT</code> in order to append
+a value to the list of function return values.
+
+<p>Multiple values can be passed up to Scheme in one of three ways:
+<ul>
+<li><em>Multiple values as lists.</em>
+By default, if more than one value is to
+be returned, a list of the values is created and returned.
+<li><em>Multiple values as vectors.</em>
+By issueing
+<blockquote>
+<pre>%pragma(guile) beforereturn = "GUILE_MAYBE_VECTOR"</pre>
+</blockquote>
+vectors instead of lists will be used.
+<li><em>Multiple values for multiple-value continuations.</em>
+<strong>This is the most elegant way.</strong> By issueing
+<blockquote>
+<pre>%pragma(guile) beforereturn = "GUILE_MAYBE_VALUES"</pre>
+</blockquote>
+multiple values are passed to the multiple-value
+continuation, as created by <code>call-with-values</code> or the
+convenience macro <code>receive</code>. The latter is available if you
+issue <code>(use-modules (srfi srfi-8))</code>. Assuming that your
+<code>divide</code> function
+wants to return two values, a quotient and a remainder, you can write:
+<blockquote>
+<pre>
+(receive (quotient remainder)
+ (divide 35 17)
+ <var>body</var>...)
+</pre>
+</blockquote>
+In <code><var>body</var></code>, the first result of
+<code>divide</code> will be bound to the variable
+<code>quotient</code>, and the second result to <code>remainder</code>.
+</ul>
+
<a name="10.5" href="#i10.5">
<h3>10.5 Smobs</h3>
</a>
@@ -1035,14 +1206,6 @@ information is read from <code>Lib/guile/typemaps.i</code>.
For pointer types, SWIG uses Guile smobs.
<p>
-Currently, one wrapper module must be generated without
-<code>-c</code> and compiled with <code>-DSWIG_GLOBAL</code>, all the
-other wrapper modules must be generated with <code>-c</code>. Maybe
-one should move all the global helper functions that come from
-<code>guile.swg</code> into a library, which is built by <code>make
-runtime</code>.
-
-<p>
In earlier versions of SWIG, C pointers were represented as Scheme
strings containing a hexadecimal rendering of the pointer value and a
mangled type name. As Guile allows registering user types, so-called
@@ -1106,7 +1269,20 @@ See Lib/exception.i for details.
<p>If invoked with the command-line option <code>-procdoc
<var>file</var></code>, SWIG creates documentation strings for the
generated wrapper functions, describing the procedure signature and
-return value, and writes them to <var>file</var>.
+return value, and writes them to <var>file</var>. You need Guile 1.4
+or later to make use of the documentation files.
+
+<p>SWIG can generate documentation strings in three formats, which are
+selected via the command-line option <code>-procdocformat
+<var>format</var></code>:
+<ul>
+<li><code>guile-1.4</code> (default): Generates a format suitable for Guile 1.4.
+<li><code>plain</code>: Generates a format suitable for Guile 1.4.1 and
+later.
+<li><code>texinfo</code>: Generates texinfo source, which must be run
+through texinfo in order to get a format suitable for Guile 1.4.1 and
+later.
+</ul>
<p>You need to register the generated documentation file with Guile
like this:
@@ -1115,7 +1291,6 @@ like this:
(set! documentation-files
(cons "<var>file</var>" documentation-files))
</pre>
-This requires Guile 1.4 or later.
<p>Documentation strings can be configured using the Guile-specific
typemaps <code>indoc</code>, <code>outdoc</code>,
@@ -1163,5 +1338,9 @@ is created, so you can use <code>(<var>struct</var>-<var>member</var>
[TODO]
+<hr>
+Copyright (C) 1999-2001
+<a href="mailto:swig-dev@cs.uchicago.edu">SWIG Development Team</a>
+
</body>
</html>
diff --git a/SWIG/Doc/jswig.html b/SWIG/Doc/jswig.html
new file mode 100644
index 000000000..2225c36cc
--- /dev/null
+++ b/SWIG/Doc/jswig.html
@@ -0,0 +1,538 @@
+<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="GENERATOR" content="Mozilla/4.5 [en] (X11; I; IRIX 6.2 IP22) [Netscape]">
+</head>
+<body bgcolor="#FFFFFF">
+
+<h1>
+The Java SWIG module [1% pure Java]</h1>
+
+<h2>
+Introduction</h2>
+The Java module extension for <a href="http://www.swig.org/">SWIG</a> (Simplified
+Wrapper Interface Generator) is a Java JNI wrapper generator. It generates
+Java and JNI wrapper code based on an interface definition file.
+<p>See the 1.1 release SWIG documentation for a full description of the interface
+format. Only the issues specific to the Java implementation are addressed here.
+<p>The 100% Pure Java
+effort is a great idea however, in the real world programmers either need to re-use their existing code or in some situations want to take advantage
+of Java but have to use some native code.
+With this Java extension to SWIG it is very easy to plumb in existing c/c++ code for access from Java, as SWIG writes the JNI code for you.
+It is different to using the 'javah' tool as SWIG will wrap existing c/c++ code, whereas javah takes java functions and creates c/c++ function prototypes.
+<br>&nbsp;
+
+<h2>Usage</h2>
+swig -java [options] &lt;interface file&gt;
+<br>
+swig -java -help
+<table>
+<tr>
+<th>Java specific options</th>
+</tr>
+
+<tr>
+<td>-module</td>
+<td>&lt;module&gt;</td>
+<td>use a module name other than the one specified in %module</td>
+</tr>
+
+<tr>
+<td>-package</td>
+<td>&lt;java package&gt;</td>
+<td>put the generated classes in this package</td>
+</tr>
+
+<tr>
+<td>-jnic</td>
+<td></td>
+<td>generate c calling interface (default depends on -c++ flag)</td>
+</tr>
+
+<tr>
+<td>-jnicpp</td>
+<td></td>
+<td>generate c++ calling interface (default depends on -c++ flag)</td>
+</tr>
+
+<tr>
+<td>-shadow</td>
+<td></td>
+<td>generate shadow classes</td>
+</tr>
+
+<tr>
+<td>-nofinalize</td>
+<td></td>
+<td>do not emit finalizers in shadow classes</td>
+</tr>
+
+<tr>
+<th>Useful SWIG options</th>
+</tr>
+
+<tr>
+<td>-c++</td>
+<td></td>
+<td>accept c++ syntax in input file</td>
+</tr>
+
+<tr>
+<td>-o</td>
+<td>&lt;output file></td>
+<td>name the generate c output file (defaults to &lt;module>_wrap.c)</td>
+</tr>
+</table>
+
+<h2>
+Quick Introduction</h2>
+
+The directory Examples/java has a number of examples which is the best way to learn how the SWIG Java extension works. The <a href="../Examples/index.html">SWIG Examples Documentation</a> in the parent directory is a useful starting point.
+
+<h2>
+Argument mapping</h2>
+&nbsp;
+<table BORDER>
+<tr>
+<td>c type</td>
+<td>Java type</td>
+<td>JNI type</td>
+</tr>
+
+<tr>
+<td>char</td>
+<td>byte</td>
+<td>jbyte</td>
+</tr>
+
+<tr>
+<td>unsigned char</td>
+<td>short</td>
+<td>jshort</td>
+</tr>
+
+<tr>
+<td>short</td>
+<td>short</td>
+<td>jshort</td>
+</tr>
+
+<tr>
+<td>unsigned short</td>
+<td>int</td>
+<td>jint</td>
+</tr>
+
+<tr>
+<td>int</td>
+<td>int</td>
+<td>jint</td>
+</tr>
+
+<tr>
+<td>unsigned int</td>
+<td>long</td>
+<td>jlong</td>
+</tr>
+
+<tr>
+<td>long</td>
+<td>long</td>
+<td>jlong</td>
+</tr>
+
+<tr>
+<td>long</td>
+<td>long</td>
+<td>jlong</td>
+</tr>
+
+<tr>
+<td>float</td>
+<td>float</td>
+<td>jfloat</td>
+</tr>
+
+<tr>
+<td>double</td>
+<td>double</td>
+<td>jdouble</td>
+</tr>
+
+<tr>
+<td>bool</td>
+<td>int</td>
+<td>jint</td>
+</tr>
+
+<tr>
+<td>void</td>
+<td>void</td>
+<td>void</td>
+</tr>
+
+</table>
+<br>
+Arrays are implemented using the same mappings, for example a c array, char[size], is mapped to a Java array, byte[size].
+<br><br>
+When SWIG is being used without shadow classes, longs are used for all pointers. All complex types (c/c++ structs and classes) are accessible using a Java long which contains a pointer to the underlying c/c++ object. Arrays of complex types are mapped as arrays of pointers to the type, that is a Java long[].
+<br><br>
+The output is different when SWIG is being used to generate shadow classes. Primitive types and pointers to these types remain the same; so a Java long is used for pointers to primitive types. However, for complex types, the shadow classes use a Java class which wraps the struct/class instead of a Java long. This applies to both argument parameters and return types that are complex types or pointers to complex types. Arrays of complex types turn into arrays of Java classes rather than arrays of longs.
+<br><br>
+For example, given the following c++ function call:
+<blockquote> <pre>
+void AClass::func(int a, int* b, SomeClass c, SomeClass* d, SomeClass& e, SomeClass f[10]);
+</blockquote> </pre>
+The non shadow access from Java is shown below, where the first parameter, ptr, is a long containing the pointer to an object of type AClass:
+<blockquote> <pre>
+public final static native void AClass_func(long ptr, int a, long b, long c, long d, long e, long[] f);
+</blockquote> </pre>
+The Java shadow class, AClass, will contain the following function:
+<blockquote> <pre>
+public void func(int a, long b, SomeClass c, SomeClass d, SomeClass e, SomeClass f[]) {...}
+</blockquote> </pre>
+
+Also note that SWIG converts c/c++ enums into integers.
+<br>
+<h2>
+Typemaps</h2>
+With typemaps, you can change the default conversion (input, output and
+return value) for a specific type.
+<p>The following typemaps are supported.
+<br>&nbsp;
+<table BORDER>
+<tr>
+<td><b>typemap</b></td>
+
+<td><b>description</b></td>
+</tr>
+
+<tr>
+<td>typemap(java,in)</td>
+
+<td>Converts function arguments from the java representation to a C representation.</td>
+</tr>
+
+<tr>
+<td>typemap(java,argout)</td>
+
+<td>Return values through function arguments</td>
+</tr>
+
+<tr>
+<td>typemap(java,out)</td>
+
+<td>Converts the result of a C function to a java representation.</td>
+</tr>
+
+<tr>
+<td>typemap(java,jtype)</td>
+<td>Override the default mapping of basic types from C to Java. Always provide jni, in, argout and out typemaps if you use this typemap.</td>
+</tr>
+
+<tr>
+<td>typemap(java,jni)</td>
+<td>Override the default mapping of basic types from C to jni. Always provide jtype, in, argout and out typemaps if you use this typemap.</td>
+</tr>
+</table>
+
+Other typemaps might work (check, freearg, newfree, ret), but are not tested.
+
+<br>&nbsp;
+<p>The following typemaps are predefined, but user defined typemaps can
+be included in the interface file.
+<br>&nbsp;
+<table BORDER>
+<tr VALIGN=TOP>
+<td><b>C Type</b></td>
+<td><b>Typemap</b></td>
+<td><b>Kind</b></td>
+<td><b>Java Type</b></td>
+<td><b>Function</b></td>
+</tr>
+
+<tr>
+<td>char *</td>
+<td>STRING</td>
+<td>input
+<br>output
+<br>return</td>
+
+<td>String</td>
+<td VALIGN=TOP>\0 terminated string&nbsp;
+<br>Java string is converted to c string, which is released afterwards</td>
+</tr>
+
+<tr VALIGN=TOP>
+<td></td>
+<td>BYTE</td>
+<td>input
+<br>output</td>
+<td>byte[]</td>
+
+<td VALIGN=TOP>Java byte array is converted to char array which
+is release afterwards</td>
+</tr>
+
+<tr>
+<td>char **</td>
+<td>STRING_IN</td>
+<td>input</td>
+<td>String[]</td>
+<td>\0 terminated array of \0 terminated strings
+<br>the array is malloc-ed and released afterwards</td>
+</tr>
+
+<tr>
+<td></td>
+<td>STRING_OUT</td>
+<td>output</td>
+<td>String[]</td>
+<td>&amp;char*
+<br>the argument is the address of an '\0' terminated string</td>
+</tr>
+
+<tr>
+<td></td>
+<td>STRING_RET</td>
+<td>return</td>
+<td>String[]</td>
+<td>\0 terminated array of \0 terminated strings
+<br>the array is not free-ed.</td>
+</tr>
+
+<tr>
+<td>int *</td>
+<td>INT_OUT</td>
+<td>output</td>
+<td>int[]</td>
+<td>&amp;int
+
+<br>value is returned in an int, which is stored in the Java int[0]</td>
+</tr>
+</table>
+
+<br>&nbsp;
+<h2>
+Pragmas</h2>
+There are two groups of pragmas in the Java module. The first group modify the Java module output file and the second modify the Java shadow output file. The pragmas beginning with <b>module</b> apply to the module output file. The pragmas beginning with <b>allshadow</b> apply to all shadow output classes. The pragmas beginning with <b>shadow</b> apply to the currently active shadow class so these pragmas can only be specified within the definition of a class or struct. For example:
+<blockquote><pre>
+/* TestStruct.i */
+#ifdef SWIG
+%pragma(java) modulecode="/*This code gets added to the module class*/"
+%pragma(java) allshadowcode="/*This code gets added to every shadow class*/"
+#endif
+typedef struct TestStruct {
+#ifdef SWIG
+%pragma(java) shadowcode="/*This code gets added to the TestStruct shadow class only*/"
+#endif
+ int myInt;
+} TestStruct;
+</pre></blockquote>
+<br>
+A complete list of pragmas follows:
+<br><br>
+<table BORDER>
+<tr VALIGN=TOP>
+<td><b>Pragma</b></td>
+<td><b>Description</b></td>
+<td><b>Example</b></td>
+</tr>
+<tr>
+<td>modulebase</td>
+<td>Specifies a base class for the Java module class.</td>
+<td>%pragma(java) modulebase="BaseClass"</td>
+</tr>
+<tr>
+<td>shadowbase</td>
+<td>Specifies a base class for the Java shadow class.</td>
+<td>%pragma(java) shadowbase="BaseClass"</td>
+</tr>
+<tr>
+<td>allshadowbase</td>
+<td>Specifies a base class for all Java shadow classes.</td>
+<td>%pragma(java) allshadowbase="BaseClass"</td>
+</tr>
+<tr>
+<td>modulecode</td>
+<td>Adds code to the Java module class.</td>
+<td>%pragma(java) modulecode="/*module code*/"</td>
+</tr>
+<tr>
+<td>shadowcode</td>
+<td>Adds code to the Java shadow class.</td>
+<td>%pragma(java) shadowcode="/*shadow code*/"</td>
+</tr>
+<tr>
+<td>allshadowcode</td>
+<td>Adds code to all Java classes.</td>
+<td>%pragma(java) allshadowcode="/*all shadow code*/"</td>
+</tr>
+<tr>
+<td>moduleclassmodifiers</td>
+<td>Overrides the default Java module class modifiers. The default is public.</td>
+<td>%pragma(java) moduleclassmodifiers="public final"</td>
+</tr>
+<tr>
+<td>shadowclassmodifiers</td>
+<td>Overrides the default Java shadow class modifiers. The default is public. Also overrides allshadowclassmodifiers if present.</td>
+<td>%pragma(java) shadowclassmodifiers="public final"</td>
+</tr>
+<tr>
+<td>allshadowclassmodifiers</td>
+<td>Overrides the default modifiers for all Java classes. The default is public.</td>
+<td>%pragma(java) allshadowclassmodifiers="public final"</td>
+</tr>
+<tr>
+<td>moduleimport</td>
+<td>Adds an import statement to the Java module class file.</td>
+<td>%pragma(java) moduleimport="java.lang.*"</td>
+</tr>
+<tr>
+<td>shadowimport</td>
+<td>Adds an import statement to the Java shadow class file. Adds to any imports specified in allshadowimport.</td>
+<td>%pragma(java) shadowimport="java.lang.*"</td>
+</tr>
+<tr>
+<td>allshadowimport</td>
+<td>Adds an import statement to all Java shadow class files.</td>
+<td>%pragma(java) allshadowimport="java.lang.*"</td>
+</tr>
+<tr>
+<td>moduleinterface</td>
+<td>Specifies an interface which the Java module output class implements. Can be used multiple times as Java supports multiple interfaces.</td>
+<td>%pragma(java) moduleinterface="SomeInterface"</td>
+</tr>
+<tr>
+<td>shadowinterface</td>
+<td>Specifies an interface which the Java shadow class implements. Can be used multiple times as Java supports multiple interfaces. Adds to any interfaces specified in allshadowinterface.</td>
+<td>%pragma(java) shadowinterface="SomeInterface"</td>
+</tr>
+<tr>
+<td>allshadowinterface</td>
+<td>Specifies an interface which all Java shadow classes implement. Can be used multiple times as Java supports multiple interfaces.</td>
+<td>%pragma(java) allshadowinterface="SomeInterface"</td>
+</tr>
+<tr>
+<td>modulemethodmodifiers</td>
+<td>Overrides the native default method modifiers for the module class. The default is public final static.</td>
+<td>%pragma(java) modulemethodmodifiers="protected final static synchronized"</td>
+</tr>
+</table>
+
+</dl>
+
+<h3> Deprecated pragmas</h3>
+The following pragmas were in Swig 1.3a3 and have been deprecated:<br>
+<b>import</b>: Please replace with <b>moduleimport</b>, <b>shadowimport</b> and/or <b>allshadowimport</b> pragmas.<br>
+<b>module</b>: Please replace with the <b>modulecode</b> pragma.<br>
+<b>shadow</b>: Please replace with the <b>allshadowcode</b> pragma.<br>
+<b>modifiers</b>: Please replace with the <b>modulemethodmodifiers</b> pragma.<br>
+
+<h3> Pragma uses</h3>
+The pragmas are used primarily to modify the default Java output code. They provide flexibility as to how Java and C++ interact. In the pragma notation below, <b>xxxcode</b> for example would be used to denote the 3 similar 'code' pragmas, that is <b>modulecode</b>, <b>shadowcode</b> and <b>allshadowcode</b>.
+
+<h4> Derive C++ from Java and visa-versa</h4>
+It is possible to derive a Java class from a shadow class (i.e. a C++ class) with the Java module. However, with the pragmas it is also possible to derive the SWIG produced Java shadow classes (i.e. C++ class) from your own Java class by using the <b>xxxbase</b> pragma with the <b>xxximport</b>, <b>xxxcode</b> and <b>xxxclassmodifiers</b> pragmas. It is also possible for the SWIG produced Java classes to implement interfaces using the <b>xxxinterface</b> pragmas.
+
+<!--
+<h3> JavaDoc </h3>
+The SWIG documentation system that was shipped with SWIG 1.1 is currently disabled and will be replaced in the future. If you require some documentation in the meantime in your Java module class or shadow class, it can be added using the <b>xxxcode</b> pragmas. JavaDoc comments can be inserted instead of Java code. Although you can insert as many of these code pragmas as you like scattered throughout the c/c++ code, they are all output together in the Java class. Thus you can have a block of JavaDoc comments per class, but it is not flexible enough to have a JavaDoc comment above each member function. <b> Does not work! The documenation only gets added to one method!!</b>
+-->
+
+<h2>
+Shadow Classes and Garbage Collection</h2>
+If you get SWIG to produce shadow classes, you will notice the generated <code>_delete()</code> and <code>finalize()</code> methods. The <code>finalize()</code> method calls <code>_delete()</code> which frees any SWIG malloced c memory for wrapped structs or deletes any SWIG wrapped classes created on the heap, which in turn calls the class' destructor. The idea is for <code>_delete()</code> to be called when you have finished with the c/c++ object. Ideally you need not call <code>_delete()</code>, but rather leave it to the garbage collector to call it from the finalizer. The unfortunate thing is that Sun, in their wisdom, do not guarantee that the finalizers will be called. When a program exits, the garbage collector does not always call the finalizers. Depending on what the finalizers do and which operating system you use, this may or may not be a problem.
+<br><br>
+
+If the <code>_delete()</code> call into JNI code is just for memory handling, there is not a problem when run on Windows and Unix. Say your JNI code creates memory on the heap which your finalizers will clean up, the finalizers may or may not be called before the program exits. In Windows and Unix all memory that a process uses is returned to the system, so this isn't a problem. This is not the case in some operating systems like vxWorks. If however, your finalizers call into JNI code invokes a c++ destructor which in turn releases a socket for example, there is no guarantee that it will be released. Note that the garbage collector will eventually run, so long running programs will have their finalizers called periodically.
+<br><br>
+
+Some not so ideal solutions are:
+<ol>
+<li start=1>
+Call the <code>System.runFinalizersOnExit(true)</code> or <code>Runtime.getRuntime().runFinalizersOnExit(true)</code> to ensure the finalizers are called before the program exits. The catch is that this is a deprecated function call as the documenation says:
+<blockquote><i>
+This method is inherently unsafe. It may result in finalizers being called on live objects while other threads are concurrently manipulating those objects, resulting in erratic behavior or deadlock.
+</i></blockquote>
+In many cases you will be lucky and find that it works, but it is not to be advocated. Have a look at <a href=http://java.sun.com>Sun's Java web site</a> and search for <code>runFinalizersOnExit</code>.
+</li>
+<p>
+<li>
+From jdk1.3 onwards a new function, <code>addShutdownHook()</code>, was introduced which is guaranteed to be called when your program exits. You can encourage the garbage collector to call the finalizers, for example, add this static block to the class that has the <code>main()</code> function:
+<blockquote><pre>
+ static {
+ Runtime.getRuntime().addShutdownHook(
+ new Thread() {
+ public void run() { System.gc(); System.runFinalization(); }
+ }
+ );
+ }
+</pre></blockquote>
+Although this usually works, the documentation doesn't guarantee that <code>runFinalization()</code> will actually call the finalizers. As the the shutdown hook is guaranteed you could also make a JNI call to clean up any resources that are being tracked in the c/c++ code.
+</li>
+<p>
+<li>
+Call the <code>_delete()</code> function manually. As a suggestion it may be a good idea to set the object to null so that should the object be inadvertantly used again a Java null pointer exception is thrown, the alternative would crash the JVM by using a null c pointer. For example given a SWIG generated class A:
+<blockquote><pre>
+A myA = new A();
+// use myA ...
+myA._delete();
+// any use of myA here would crash the JVM
+myA=null;
+// any use of myA here would cause a java null pointer exception to be thrown
+</pre></blockquote>
+The SWIG generated code ensures that the memory is not deleted twice, in the event the finalizers get called in addition to the manual <code>_delete()</code> call.
+</li>
+
+<p>
+<li>
+Write your own object manager in Java. You could derive all SWIG classes from a single base class which could track which objects have had their finalizers run, then call the rest of them on program termination. Currently you cannot tell SWIG to derive a SWIG shadow class from any named Java class, but this is planned in the near future. An alternative is to add the object handling code to all generated shadow classes using the shadow pragma.
+</li>
+</ol>
+
+<h2>
+Dynamic Linking Problems</h2>
+The code to load a native library is <code>System.loadLibrary("name")</code>. Commonly this will fail and it can be due to a number of reasons. The most common is an incorrect naming of the native library for the name passed to the <code>loadLibrary</code> function. The text passed to the <code>loadLibrary</code> function must not include the the extension name in the text, that is <i>.dll</i> or <i>.so</i>. The text must be <i>name</i> and not <i>libname</i> for all platforms. On Windows the native library must then be called <i>name.dll</i> and on Unix it must be called <i>libname.so</i>. If you are debugging using <code> java -debug</code>, then the native library must be called <i>name_g.dll</i> on Windows and <i>libname_g.so</i> on Unix.
+
+<h2>
+Tips</h2>
+
+<ul>
+<li>
+Use %name to rename the shadow classes.</li>
+
+<pre>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; %name(JPasswd) struct passwd {
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ....
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; };</pre>
+<li>
+The %native directive can be used to mix hand written JNI functions with the auto generated functions.
+</ul>
+
+<h2>
+Caveats</h2>
+
+<ul>
+<li>
+Pointers are stored in a Java long, which is represented as a c long long
+on most machines. The pointer address is stored in the high order long
+of the long long, and cannot be manipulated directly from Java.</li>
+
+<li>
+If a typemap(java,in) is specified, the typemap(java,argout) must also
+be specified, because the default 'argout' code depends on the default
+'in' code.</li>
+</ul>
+
+<h2>
+Bugs</h2>
+<ul>
+<li>Wrapping of static c++ member variables does not work.</li>
+<li>Global arrays do not work.</li>
+</ul>
+
+<h2>Contact</h2>
+Use the SWIG mailing list for all queries <a href=mailto:swig@cs.uchicago.edu>swig@cs.uchicago.edu</a> or have a look at <a href=http://www.swig.org>http://www.swig.org</a>.
+</body>
+</html>
diff --git a/SWIG/Examples/C++/.cvsignore b/SWIG/Examples/C++/.cvsignore
new file mode 100644
index 000000000..61c36bb2c
--- /dev/null
+++ b/SWIG/Examples/C++/.cvsignore
@@ -0,0 +1 @@
+test_conf.py
diff --git a/SWIG/Examples/C++/Java/.cvsignore b/SWIG/Examples/C++/Java/.cvsignore
new file mode 100644
index 000000000..8b64264a0
--- /dev/null
+++ b/SWIG/Examples/C++/Java/.cvsignore
@@ -0,0 +1,7 @@
+class
+cpptest.jar
+cpptest.java
+cpptestJava.java
+cpptest_base.java
+cpptest_empty.java
+cpptest_wrap.c
diff --git a/SWIG/Examples/C++/Java/Makefile b/SWIG/Examples/C++/Java/Makefile
index c41ac5d58..0edb0c66a 100644
--- a/SWIG/Examples/C++/Java/Makefile
+++ b/SWIG/Examples/C++/Java/Makefile
@@ -17,4 +17,15 @@ clean::
PYTHON = jpython
-TESTS = $(wildcard ../test_repo/*.py)
+TESTS =
+
+# We haven't checked for JPython in the configure step, so don't run
+# any tests that require it.
+
+# ../test_repo/constructor.py \
+# ../test_repo/constructor_user_type.py \
+# ../test_repo/inheritence_map_to_base_class.py \
+# ../test_repo/object_method.py \
+# ../test_repo/object_method_user_type.py \
+# ../test_repo/primitive_method.py \
+# ../test_repo/primitive_method_user_type.py
diff --git a/SWIG/Examples/C++/Python/.cvsignore b/SWIG/Examples/C++/Python/.cvsignore
new file mode 100644
index 000000000..8f1708aea
--- /dev/null
+++ b/SWIG/Examples/C++/Python/.cvsignore
@@ -0,0 +1,3 @@
+cpptest.py
+cpptest.pyc
+cpptest_wrap.c
diff --git a/SWIG/Examples/C++/Python/Makefile b/SWIG/Examples/C++/Python/Makefile
index ecbbdb8bc..d8640fbee 100644
--- a/SWIG/Examples/C++/Python/Makefile
+++ b/SWIG/Examples/C++/Python/Makefile
@@ -13,4 +13,10 @@ clean:
PYTHON = python
-TESTS = $(wildcard ../test_repo/*.py)
+TESTS = ../test_repo/constructor.py \
+ ../test_repo/constructor_user_type.py \
+ ../test_repo/inheritence_map_to_base_class.py \
+ ../test_repo/object_method.py \
+ ../test_repo/object_method_user_type.py \
+ ../test_repo/primitive_method.py \
+ ../test_repo/primitive_method_user_type.py
diff --git a/SWIG/Examples/C++/common.mk b/SWIG/Examples/C++/common.mk
index 8a8903bf3..44648eed8 100644
--- a/SWIG/Examples/C++/common.mk
+++ b/SWIG/Examples/C++/common.mk
@@ -18,7 +18,7 @@ INCLUDE = -I$(TOP)/../Lib -I../class -I../typemaps -I$(TOP)/../Lib
check:: all
bad_status="" ; \
- for i in $(TESTS); do \
+ tests="$(TESTS)"; for i in $$tests; do \
LD_LIBRARY_PATH=. PYTHONPATH=. CLASSPATH=./$(JAR) ; \
( $(PYTHON) $$i && echo "$$i: PASSED" ) || echo "$$i: FAILED"; \
done
diff --git a/SWIG/Examples/C++/interface/cpptest.i b/SWIG/Examples/C++/interface/cpptest.i
index a0d1c1697..2255db4da 100644
--- a/SWIG/Examples/C++/interface/cpptest.i
+++ b/SWIG/Examples/C++/interface/cpptest.i
@@ -19,7 +19,7 @@
%include "cpptest.H"
#ifdef SWIGJAVA
-%pragma(java) module="
+%pragma(java) modulecode="
static {
System.loadLibrary(\"cpptest\");
}";
diff --git a/SWIG/Examples/GIFPlot/.cvsignore b/SWIG/Examples/GIFPlot/.cvsignore
new file mode 100644
index 000000000..167ec79ae
--- /dev/null
+++ b/SWIG/Examples/GIFPlot/.cvsignore
@@ -0,0 +1,4 @@
+Makefile
+config.log
+config.status
+configure
diff --git a/SWIG/Examples/GIFPlot/Guile/full/.cvsignore b/SWIG/Examples/GIFPlot/Guile/full/.cvsignore
new file mode 100644
index 000000000..7b4d35ff7
--- /dev/null
+++ b/SWIG/Examples/GIFPlot/Guile/full/.cvsignore
@@ -0,0 +1,3 @@
+gifplot-guile
+gifplot_wrap.c
+image.gif
diff --git a/SWIG/Examples/GIFPlot/Guile/simple/.cvsignore b/SWIG/Examples/GIFPlot/Guile/simple/.cvsignore
new file mode 100644
index 000000000..46c5ec496
--- /dev/null
+++ b/SWIG/Examples/GIFPlot/Guile/simple/.cvsignore
@@ -0,0 +1,4 @@
+gifguile
+image.gif
+simple-guile
+simple_wrap.c
diff --git a/SWIG/Examples/GIFPlot/Include/gifplot.h b/SWIG/Examples/GIFPlot/Include/gifplot.h
index f0fb3b183..158b393e7 100644
--- a/SWIG/Examples/GIFPlot/Include/gifplot.h
+++ b/SWIG/Examples/GIFPlot/Include/gifplot.h
@@ -125,9 +125,9 @@ extern void delete_PixMap(PixMap *pm);
extern void PixMap_set(PixMap *pm, int x, int y, int pix);
extern void FrameBuffer_drawpixmap(FrameBuffer *f, PixMap *pm, int x, int y, int fgcolor, int bgcolor);
-#define TRANSPARENT 0
-#define FOREGROUND 1
-#define BACKGROUND 2
+#define GIFPLOT_TRANSPARENT 0
+#define GIFPLOT_FOREGROUND 1
+#define GIFPLOT_BACKGROUND 2
/* ------------------------------------------------------------------------
Plot2D
diff --git a/SWIG/Examples/GIFPlot/Interface/gifplot.i b/SWIG/Examples/GIFPlot/Interface/gifplot.i
index 69a7cdbb9..ad4485798 100644
--- a/SWIG/Examples/GIFPlot/Interface/gifplot.i
+++ b/SWIG/Examples/GIFPlot/Interface/gifplot.i
@@ -119,9 +119,9 @@ extern PixMap *new_PixMap(int width, int height, int centerx, int centery);
extern void delete_PixMap(PixMap *pm);
extern void PixMap_set(PixMap *pm, int x, int y, int pix);
-#define TRANSPARENT 0
-#define FOREGROUND 1
-#define BACKGROUND 2
+#define GIFPLOT_TRANSPARENT 0
+#define GIFPLOT_FOREGROUND 1
+#define GIFPLOT_BACKGROUND 2
/* --------------------------------------------------------------------------
Plot2D
diff --git a/SWIG/Examples/GIFPlot/Java/.cvsignore b/SWIG/Examples/GIFPlot/Java/.cvsignore
new file mode 100644
index 000000000..da1b55938
--- /dev/null
+++ b/SWIG/Examples/GIFPlot/Java/.cvsignore
@@ -0,0 +1,3 @@
+*.java
+*.class
+gifplot_wrap.c
diff --git a/SWIG/Examples/GIFPlot/Java/Makefile b/SWIG/Examples/GIFPlot/Java/Makefile
index 6017e1a77..7c45d05b7 100644
--- a/SWIG/Examples/GIFPlot/Java/Makefile
+++ b/SWIG/Examples/GIFPlot/Java/Makefile
@@ -1,6 +1,6 @@
TOP = ../..
-SWIG = $(TOP)/../swig -shadow
-SWIGOPT = -I../Include
+SWIG = $(TOP)/../swig
+SWIGOPT = -I../Include -shadow
SRCS =
TARGET = libjgifplot
INTERFACE = gifplot.i
@@ -11,6 +11,7 @@ all::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
INCLUDE='$(INCLUDE)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java
+ javac *.java
clean::
rm -f *_wrap* *.o *~ *.so .~* core *.gif *.class ColorMap.java FrameBuffer.java Plot2D.java Plot3D.java gifplot.java
diff --git a/SWIG/Examples/GIFPlot/Java/gifplot.i b/SWIG/Examples/GIFPlot/Java/gifplot.i
index b8f17f657..397e3995a 100644
--- a/SWIG/Examples/GIFPlot/Java/gifplot.i
+++ b/SWIG/Examples/GIFPlot/Java/gifplot.i
@@ -119,9 +119,9 @@ extern PixMap *new_PixMap(int width, int height, int centerx, int centery);
extern void delete_PixMap(PixMap *pm);
extern void PixMap_set(PixMap *pm, int x, int y, int pix);
-#define TRANSPARENT 0
-#define FOREGROUND 1
-#define BACKGROUND 2
+#define GIFPLOT_TRANSPARENT 0
+#define GIFPLOT_FOREGROUND 1
+#define GIFPLOT_BACKGROUND 2
/* --------------------------------------------------------------------------
Plot2D
diff --git a/SWIG/Examples/GIFPlot/Lib/.cvsignore b/SWIG/Examples/GIFPlot/Lib/.cvsignore
new file mode 100644
index 000000000..f3c7a7c5d
--- /dev/null
+++ b/SWIG/Examples/GIFPlot/Lib/.cvsignore
@@ -0,0 +1 @@
+Makefile
diff --git a/SWIG/Examples/GIFPlot/Lib/pixmap.c b/SWIG/Examples/GIFPlot/Lib/pixmap.c
index ff8e0bff0..a55cf041f 100644
--- a/SWIG/Examples/GIFPlot/Lib/pixmap.c
+++ b/SWIG/Examples/GIFPlot/Lib/pixmap.c
@@ -99,10 +99,10 @@ FrameBuffer_drawpixmap(FrameBuffer *f, PixMap *pm, int x, int y, int fgcolor, in
for (i = startx; i < endx; i++) {
c = pm->map[py*pm->width + px];
switch (c) {
- case FOREGROUND:
+ case GIFPLOT_FOREGROUND:
f->pixels[j][i] = fgcolor;
break;
- case BACKGROUND:
+ case GIFPLOT_BACKGROUND:
f->pixels[j][i] = bgcolor;
break;
default:
diff --git a/SWIG/Examples/GIFPlot/Perl/full/.cvsignore b/SWIG/Examples/GIFPlot/Perl/full/.cvsignore
new file mode 100644
index 000000000..7f6373577
--- /dev/null
+++ b/SWIG/Examples/GIFPlot/Perl/full/.cvsignore
@@ -0,0 +1,2 @@
+gifplot.pm
+gifplot_wrap.c
diff --git a/SWIG/Examples/GIFPlot/Perl/shadow/.cvsignore b/SWIG/Examples/GIFPlot/Perl/shadow/.cvsignore
new file mode 100644
index 000000000..7f6373577
--- /dev/null
+++ b/SWIG/Examples/GIFPlot/Perl/shadow/.cvsignore
@@ -0,0 +1,2 @@
+gifplot.pm
+gifplot_wrap.c
diff --git a/SWIG/Examples/GIFPlot/Perl/simple/.cvsignore b/SWIG/Examples/GIFPlot/Perl/simple/.cvsignore
new file mode 100644
index 000000000..b7c62a43e
--- /dev/null
+++ b/SWIG/Examples/GIFPlot/Perl/simple/.cvsignore
@@ -0,0 +1,2 @@
+simple.pm
+simple_wrap.c
diff --git a/SWIG/Examples/GIFPlot/Python/full/.cvsignore b/SWIG/Examples/GIFPlot/Python/full/.cvsignore
new file mode 100644
index 000000000..497030761
--- /dev/null
+++ b/SWIG/Examples/GIFPlot/Python/full/.cvsignore
@@ -0,0 +1 @@
+gifplot_wrap.c
diff --git a/SWIG/Examples/GIFPlot/Python/shadow/.cvsignore b/SWIG/Examples/GIFPlot/Python/shadow/.cvsignore
new file mode 100644
index 000000000..e3746b3a3
--- /dev/null
+++ b/SWIG/Examples/GIFPlot/Python/shadow/.cvsignore
@@ -0,0 +1,2 @@
+gifplot.py
+gifplot_wrap.c
diff --git a/SWIG/Examples/GIFPlot/Python/simple/.cvsignore b/SWIG/Examples/GIFPlot/Python/simple/.cvsignore
new file mode 100644
index 000000000..9f3a540a7
--- /dev/null
+++ b/SWIG/Examples/GIFPlot/Python/simple/.cvsignore
@@ -0,0 +1 @@
+simple_wrap.c
diff --git a/SWIG/Examples/GIFPlot/README b/SWIG/Examples/GIFPlot/README
index 7960a6f98..73ecddd76 100644
--- a/SWIG/Examples/GIFPlot/README
+++ b/SWIG/Examples/GIFPlot/README
@@ -4,7 +4,7 @@ GIFPlot
To illustrate various SWIG features, the following examples involve
building an interface to a small, but somewhat useful graphics library
for creating 2D and 3D images in the form of GIF files. The Perl,
-Python, Tcl, and Ruby directories contain various examples specific to
+Python, Tcl, Java and Ruby directories contain various examples specific to
those languages.
This library was originally developed as part of the SPaSM molecular
@@ -36,7 +36,7 @@ On Windows, you can probably just do this:
Running the Examples
====================
-Once the library has been built, go the Perl, Python, Tcl, or Ruby directory
+Once the library has been built, go the Perl, Python, Tcl, Java or Ruby directory
to see various SWIG examples. Each example should have a README file with a
description.
diff --git a/SWIG/Examples/GIFPlot/Ruby/full/.cvsignore b/SWIG/Examples/GIFPlot/Ruby/full/.cvsignore
new file mode 100644
index 000000000..497030761
--- /dev/null
+++ b/SWIG/Examples/GIFPlot/Ruby/full/.cvsignore
@@ -0,0 +1 @@
+gifplot_wrap.c
diff --git a/SWIG/Examples/GIFPlot/Ruby/shadow/.cvsignore b/SWIG/Examples/GIFPlot/Ruby/shadow/.cvsignore
new file mode 100644
index 000000000..497030761
--- /dev/null
+++ b/SWIG/Examples/GIFPlot/Ruby/shadow/.cvsignore
@@ -0,0 +1 @@
+gifplot_wrap.c
diff --git a/SWIG/Examples/GIFPlot/Ruby/simple/.cvsignore b/SWIG/Examples/GIFPlot/Ruby/simple/.cvsignore
new file mode 100644
index 000000000..9f3a540a7
--- /dev/null
+++ b/SWIG/Examples/GIFPlot/Ruby/simple/.cvsignore
@@ -0,0 +1 @@
+simple_wrap.c
diff --git a/SWIG/Examples/GIFPlot/Tcl/full/.cvsignore b/SWIG/Examples/GIFPlot/Tcl/full/.cvsignore
new file mode 100644
index 000000000..497030761
--- /dev/null
+++ b/SWIG/Examples/GIFPlot/Tcl/full/.cvsignore
@@ -0,0 +1 @@
+gifplot_wrap.c
diff --git a/SWIG/Examples/GIFPlot/Tcl/mandel/.cvsignore b/SWIG/Examples/GIFPlot/Tcl/mandel/.cvsignore
new file mode 100644
index 000000000..463988cd3
--- /dev/null
+++ b/SWIG/Examples/GIFPlot/Tcl/mandel/.cvsignore
@@ -0,0 +1 @@
+mandel_wrap.c
diff --git a/SWIG/Examples/GIFPlot/Tcl/simple/.cvsignore b/SWIG/Examples/GIFPlot/Tcl/simple/.cvsignore
new file mode 100644
index 000000000..9f3a540a7
--- /dev/null
+++ b/SWIG/Examples/GIFPlot/Tcl/simple/.cvsignore
@@ -0,0 +1 @@
+simple_wrap.c
diff --git a/SWIG/Examples/GIFPlot/configure b/SWIG/Examples/GIFPlot/configure
deleted file mode 100755
index 3997b4d84..000000000
--- a/SWIG/Examples/GIFPlot/configure
+++ /dev/null
@@ -1,1299 +0,0 @@
-#! /bin/sh
-
-# Guess values for system-dependent variables and create Makefiles.
-# Generated automatically using autoconf version 2.13
-# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc.
-#
-# This configure script is free software; the Free Software Foundation
-# gives unlimited permission to copy, distribute and modify it.
-
-# Defaults:
-ac_help=
-ac_default_prefix=/usr/local
-# Any additions from configure.in:
-
-# Initialize some variables set by options.
-# The variables have the same names as the options, with
-# dashes changed to underlines.
-build=NONE
-cache_file=./config.cache
-exec_prefix=NONE
-host=NONE
-no_create=
-nonopt=NONE
-no_recursion=
-prefix=NONE
-program_prefix=NONE
-program_suffix=NONE
-program_transform_name=s,x,x,
-silent=
-site=
-srcdir=
-target=NONE
-verbose=
-x_includes=NONE
-x_libraries=NONE
-bindir='${exec_prefix}/bin'
-sbindir='${exec_prefix}/sbin'
-libexecdir='${exec_prefix}/libexec'
-datadir='${prefix}/share'
-sysconfdir='${prefix}/etc'
-sharedstatedir='${prefix}/com'
-localstatedir='${prefix}/var'
-libdir='${exec_prefix}/lib'
-includedir='${prefix}/include'
-oldincludedir='/usr/include'
-infodir='${prefix}/info'
-mandir='${prefix}/man'
-
-# Initialize some other variables.
-subdirs=
-MFLAGS= MAKEFLAGS=
-SHELL=${CONFIG_SHELL-/bin/sh}
-# Maximum number of lines to put in a shell here document.
-ac_max_here_lines=12
-
-ac_prev=
-for ac_option
-do
-
- # If the previous option needs an argument, assign it.
- if test -n "$ac_prev"; then
- eval "$ac_prev=\$ac_option"
- ac_prev=
- continue
- fi
-
- case "$ac_option" in
- -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
- *) ac_optarg= ;;
- esac
-
- # Accept the important Cygnus configure options, so we can diagnose typos.
-
- case "$ac_option" in
-
- -bindir | --bindir | --bindi | --bind | --bin | --bi)
- ac_prev=bindir ;;
- -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
- bindir="$ac_optarg" ;;
-
- -build | --build | --buil | --bui | --bu)
- ac_prev=build ;;
- -build=* | --build=* | --buil=* | --bui=* | --bu=*)
- build="$ac_optarg" ;;
-
- -cache-file | --cache-file | --cache-fil | --cache-fi \
- | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
- ac_prev=cache_file ;;
- -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
- | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
- cache_file="$ac_optarg" ;;
-
- -datadir | --datadir | --datadi | --datad | --data | --dat | --da)
- ac_prev=datadir ;;
- -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \
- | --da=*)
- datadir="$ac_optarg" ;;
-
- -disable-* | --disable-*)
- ac_feature=`echo $ac_option|sed -e 's/-*disable-//'`
- # Reject names that are not valid shell variable names.
- if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then
- { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
- fi
- ac_feature=`echo $ac_feature| sed 's/-/_/g'`
- eval "enable_${ac_feature}=no" ;;
-
- -enable-* | --enable-*)
- ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'`
- # Reject names that are not valid shell variable names.
- if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then
- { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
- fi
- ac_feature=`echo $ac_feature| sed 's/-/_/g'`
- case "$ac_option" in
- *=*) ;;
- *) ac_optarg=yes ;;
- esac
- eval "enable_${ac_feature}='$ac_optarg'" ;;
-
- -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
- | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
- | --exec | --exe | --ex)
- ac_prev=exec_prefix ;;
- -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
- | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
- | --exec=* | --exe=* | --ex=*)
- exec_prefix="$ac_optarg" ;;
-
- -gas | --gas | --ga | --g)
- # Obsolete; use --with-gas.
- with_gas=yes ;;
-
- -help | --help | --hel | --he)
- # Omit some internal or obsolete options to make the list less imposing.
- # This message is too long to be a string in the A/UX 3.1 sh.
- cat << EOF
-Usage: configure [options] [host]
-Options: [defaults in brackets after descriptions]
-Configuration:
- --cache-file=FILE cache test results in FILE
- --help print this message
- --no-create do not create output files
- --quiet, --silent do not print \`checking...' messages
- --version print the version of autoconf that created configure
-Directory and file names:
- --prefix=PREFIX install architecture-independent files in PREFIX
- [$ac_default_prefix]
- --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
- [same as prefix]
- --bindir=DIR user executables in DIR [EPREFIX/bin]
- --sbindir=DIR system admin executables in DIR [EPREFIX/sbin]
- --libexecdir=DIR program executables in DIR [EPREFIX/libexec]
- --datadir=DIR read-only architecture-independent data in DIR
- [PREFIX/share]
- --sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc]
- --sharedstatedir=DIR modifiable architecture-independent data in DIR
- [PREFIX/com]
- --localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var]
- --libdir=DIR object code libraries in DIR [EPREFIX/lib]
- --includedir=DIR C header files in DIR [PREFIX/include]
- --oldincludedir=DIR C header files for non-gcc in DIR [/usr/include]
- --infodir=DIR info documentation in DIR [PREFIX/info]
- --mandir=DIR man documentation in DIR [PREFIX/man]
- --srcdir=DIR find the sources in DIR [configure dir or ..]
- --program-prefix=PREFIX prepend PREFIX to installed program names
- --program-suffix=SUFFIX append SUFFIX to installed program names
- --program-transform-name=PROGRAM
- run sed PROGRAM on installed program names
-EOF
- cat << EOF
-Host type:
- --build=BUILD configure for building on BUILD [BUILD=HOST]
- --host=HOST configure for HOST [guessed]
- --target=TARGET configure for TARGET [TARGET=HOST]
-Features and packages:
- --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
- --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
- --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
- --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
- --x-includes=DIR X include files are in DIR
- --x-libraries=DIR X library files are in DIR
-EOF
- if test -n "$ac_help"; then
- echo "--enable and --with options recognized:$ac_help"
- fi
- exit 0 ;;
-
- -host | --host | --hos | --ho)
- ac_prev=host ;;
- -host=* | --host=* | --hos=* | --ho=*)
- host="$ac_optarg" ;;
-
- -includedir | --includedir | --includedi | --included | --include \
- | --includ | --inclu | --incl | --inc)
- ac_prev=includedir ;;
- -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
- | --includ=* | --inclu=* | --incl=* | --inc=*)
- includedir="$ac_optarg" ;;
-
- -infodir | --infodir | --infodi | --infod | --info | --inf)
- ac_prev=infodir ;;
- -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
- infodir="$ac_optarg" ;;
-
- -libdir | --libdir | --libdi | --libd)
- ac_prev=libdir ;;
- -libdir=* | --libdir=* | --libdi=* | --libd=*)
- libdir="$ac_optarg" ;;
-
- -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
- | --libexe | --libex | --libe)
- ac_prev=libexecdir ;;
- -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
- | --libexe=* | --libex=* | --libe=*)
- libexecdir="$ac_optarg" ;;
-
- -localstatedir | --localstatedir | --localstatedi | --localstated \
- | --localstate | --localstat | --localsta | --localst \
- | --locals | --local | --loca | --loc | --lo)
- ac_prev=localstatedir ;;
- -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
- | --localstate=* | --localstat=* | --localsta=* | --localst=* \
- | --locals=* | --local=* | --loca=* | --loc=* | --lo=*)
- localstatedir="$ac_optarg" ;;
-
- -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
- ac_prev=mandir ;;
- -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
- mandir="$ac_optarg" ;;
-
- -nfp | --nfp | --nf)
- # Obsolete; use --without-fp.
- with_fp=no ;;
-
- -no-create | --no-create | --no-creat | --no-crea | --no-cre \
- | --no-cr | --no-c)
- no_create=yes ;;
-
- -no-recursion | --no-recursion | --no-recursio | --no-recursi \
- | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
- no_recursion=yes ;;
-
- -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
- | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
- | --oldin | --oldi | --old | --ol | --o)
- ac_prev=oldincludedir ;;
- -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
- | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
- | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
- oldincludedir="$ac_optarg" ;;
-
- -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
- ac_prev=prefix ;;
- -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
- prefix="$ac_optarg" ;;
-
- -program-prefix | --program-prefix | --program-prefi | --program-pref \
- | --program-pre | --program-pr | --program-p)
- ac_prev=program_prefix ;;
- -program-prefix=* | --program-prefix=* | --program-prefi=* \
- | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
- program_prefix="$ac_optarg" ;;
-
- -program-suffix | --program-suffix | --program-suffi | --program-suff \
- | --program-suf | --program-su | --program-s)
- ac_prev=program_suffix ;;
- -program-suffix=* | --program-suffix=* | --program-suffi=* \
- | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
- program_suffix="$ac_optarg" ;;
-
- -program-transform-name | --program-transform-name \
- | --program-transform-nam | --program-transform-na \
- | --program-transform-n | --program-transform- \
- | --program-transform | --program-transfor \
- | --program-transfo | --program-transf \
- | --program-trans | --program-tran \
- | --progr-tra | --program-tr | --program-t)
- ac_prev=program_transform_name ;;
- -program-transform-name=* | --program-transform-name=* \
- | --program-transform-nam=* | --program-transform-na=* \
- | --program-transform-n=* | --program-transform-=* \
- | --program-transform=* | --program-transfor=* \
- | --program-transfo=* | --program-transf=* \
- | --program-trans=* | --program-tran=* \
- | --progr-tra=* | --program-tr=* | --program-t=*)
- program_transform_name="$ac_optarg" ;;
-
- -q | -quiet | --quiet | --quie | --qui | --qu | --q \
- | -silent | --silent | --silen | --sile | --sil)
- silent=yes ;;
-
- -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
- ac_prev=sbindir ;;
- -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
- | --sbi=* | --sb=*)
- sbindir="$ac_optarg" ;;
-
- -sharedstatedir | --sharedstatedir | --sharedstatedi \
- | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
- | --sharedst | --shareds | --shared | --share | --shar \
- | --sha | --sh)
- ac_prev=sharedstatedir ;;
- -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
- | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
- | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
- | --sha=* | --sh=*)
- sharedstatedir="$ac_optarg" ;;
-
- -site | --site | --sit)
- ac_prev=site ;;
- -site=* | --site=* | --sit=*)
- site="$ac_optarg" ;;
-
- -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
- ac_prev=srcdir ;;
- -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
- srcdir="$ac_optarg" ;;
-
- -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
- | --syscon | --sysco | --sysc | --sys | --sy)
- ac_prev=sysconfdir ;;
- -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
- | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
- sysconfdir="$ac_optarg" ;;
-
- -target | --target | --targe | --targ | --tar | --ta | --t)
- ac_prev=target ;;
- -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
- target="$ac_optarg" ;;
-
- -v | -verbose | --verbose | --verbos | --verbo | --verb)
- verbose=yes ;;
-
- -version | --version | --versio | --versi | --vers)
- echo "configure generated by autoconf version 2.13"
- exit 0 ;;
-
- -with-* | --with-*)
- ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'`
- # Reject names that are not valid shell variable names.
- if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then
- { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
- fi
- ac_package=`echo $ac_package| sed 's/-/_/g'`
- case "$ac_option" in
- *=*) ;;
- *) ac_optarg=yes ;;
- esac
- eval "with_${ac_package}='$ac_optarg'" ;;
-
- -without-* | --without-*)
- ac_package=`echo $ac_option|sed -e 's/-*without-//'`
- # Reject names that are not valid shell variable names.
- if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then
- { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
- fi
- ac_package=`echo $ac_package| sed 's/-/_/g'`
- eval "with_${ac_package}=no" ;;
-
- --x)
- # Obsolete; use --with-x.
- with_x=yes ;;
-
- -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
- | --x-incl | --x-inc | --x-in | --x-i)
- ac_prev=x_includes ;;
- -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
- | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
- x_includes="$ac_optarg" ;;
-
- -x-libraries | --x-libraries | --x-librarie | --x-librari \
- | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
- ac_prev=x_libraries ;;
- -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
- | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
- x_libraries="$ac_optarg" ;;
-
- -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; }
- ;;
-
- *)
- if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then
- echo "configure: warning: $ac_option: invalid host type" 1>&2
- fi
- if test "x$nonopt" != xNONE; then
- { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; }
- fi
- nonopt="$ac_option"
- ;;
-
- esac
-done
-
-if test -n "$ac_prev"; then
- { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; }
-fi
-
-trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
-
-# File descriptor usage:
-# 0 standard input
-# 1 file creation
-# 2 errors and warnings
-# 3 some systems may open it to /dev/tty
-# 4 used on the Kubota Titan
-# 6 checking for... messages and results
-# 5 compiler messages saved in config.log
-if test "$silent" = yes; then
- exec 6>/dev/null
-else
- exec 6>&1
-fi
-exec 5>./config.log
-
-echo "\
-This file contains any messages produced by compilers while
-running configure, to aid debugging if configure makes a mistake.
-" 1>&5
-
-# Strip out --no-create and --no-recursion so they do not pile up.
-# Also quote any args containing shell metacharacters.
-ac_configure_args=
-for ac_arg
-do
- case "$ac_arg" in
- -no-create | --no-create | --no-creat | --no-crea | --no-cre \
- | --no-cr | --no-c) ;;
- -no-recursion | --no-recursion | --no-recursio | --no-recursi \
- | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;;
- *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*)
- ac_configure_args="$ac_configure_args '$ac_arg'" ;;
- *) ac_configure_args="$ac_configure_args $ac_arg" ;;
- esac
-done
-
-# NLS nuisances.
-# Only set these to C if already set. These must not be set unconditionally
-# because not all systems understand e.g. LANG=C (notably SCO).
-# Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'!
-# Non-C LC_CTYPE values break the ctype check.
-if test "${LANG+set}" = set; then LANG=C; export LANG; fi
-if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi
-if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi
-if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi
-
-# confdefs.h avoids OS command line length limits that DEFS can exceed.
-rm -rf conftest* confdefs.h
-# AIX cpp loses on an empty file, so make sure it contains at least a newline.
-echo > confdefs.h
-
-# A filename unique to this package, relative to the directory that
-# configure is in, which we can look for to find out if srcdir is correct.
-ac_unique_file=Include/gifplot.h
-
-# Find the source files, if location was not specified.
-if test -z "$srcdir"; then
- ac_srcdir_defaulted=yes
- # Try the directory containing this script, then its parent.
- ac_prog=$0
- ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'`
- test "x$ac_confdir" = "x$ac_prog" && ac_confdir=.
- srcdir=$ac_confdir
- if test ! -r $srcdir/$ac_unique_file; then
- srcdir=..
- fi
-else
- ac_srcdir_defaulted=no
-fi
-if test ! -r $srcdir/$ac_unique_file; then
- if test "$ac_srcdir_defaulted" = yes; then
- { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; }
- else
- { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; }
- fi
-fi
-srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'`
-
-# Prefer explicitly selected file to automatically selected ones.
-if test -z "$CONFIG_SITE"; then
- if test "x$prefix" != xNONE; then
- CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site"
- else
- CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site"
- fi
-fi
-for ac_site_file in $CONFIG_SITE; do
- if test -r "$ac_site_file"; then
- echo "loading site script $ac_site_file"
- . "$ac_site_file"
- fi
-done
-
-if test -r "$cache_file"; then
- echo "loading cache $cache_file"
- . $cache_file
-else
- echo "creating cache $cache_file"
- > $cache_file
-fi
-
-ac_ext=c
-# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
-ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
-cross_compiling=$ac_cv_prog_cc_cross
-
-ac_exeext=
-ac_objext=o
-if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
- # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu.
- if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
- ac_n= ac_c='
-' ac_t=' '
- else
- ac_n=-n ac_c= ac_t=
- fi
-else
- ac_n= ac_c='\c' ac_t=
-fi
-
-
-
-
-# Set name for machine-dependent library files
-
-echo $ac_n "checking MACHDEP""... $ac_c" 1>&6
-echo "configure:530: checking MACHDEP" >&5
-if test -z "$MACHDEP"
-then
- if test -f /usr/lib/NextStep/software_version; then
- set X `hostinfo | grep 'NeXT Mach.*:' | \
- sed -e 's/://' -e 's/\./_/'` && \
- ac_sys_system=next && ac_sys_release=$4
- MACHDEP="$ac_sys_system$ac_sys_release$ac_sys_cpu"
- else
- ac_sys_system=`uname -s`
- if test "$ac_sys_system" = "AIX" ; then
- ac_sys_release=`uname -v`
- else
- ac_sys_release=`uname -r`
- fi
- ac_md_system=`echo $ac_sys_system |
- tr -d '/ ' | tr '[A-Z]' '[a-z]'`
- ac_md_release=`echo $ac_sys_release |
- tr -d '/ ' | sed 's/\..*//'`
- MACHDEP="$ac_md_system$ac_md_release"
- fi
- case MACHDEP in
- '') MACHDEP=unknown;;
- esac
-fi
-echo "$ac_t""$MACHDEP" 1>&6
-
-ac_ext=c
-# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
-ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
-cross_compiling=$ac_cv_prog_cc_cross
-
-
-# Extract the first word of "gcc", so it can be a program name with args.
-set dummy gcc; ac_word=$2
-echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:568: checking for $ac_word" >&5
-if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- if test -n "$CC"; then
- ac_cv_prog_CC="$CC" # Let the user override the test.
-else
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
- ac_dummy="$PATH"
- for ac_dir in $ac_dummy; do
- test -z "$ac_dir" && ac_dir=.
- if test -f $ac_dir/$ac_word; then
- ac_cv_prog_CC="gcc"
- break
- fi
- done
- IFS="$ac_save_ifs"
-fi
-fi
-CC="$ac_cv_prog_CC"
-if test -n "$CC"; then
- echo "$ac_t""$CC" 1>&6
-else
- echo "$ac_t""no" 1>&6
-fi
-
-if test -z "$CC"; then
- # Extract the first word of "cc", so it can be a program name with args.
-set dummy cc; ac_word=$2
-echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:598: checking for $ac_word" >&5
-if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- if test -n "$CC"; then
- ac_cv_prog_CC="$CC" # Let the user override the test.
-else
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
- ac_prog_rejected=no
- ac_dummy="$PATH"
- for ac_dir in $ac_dummy; do
- test -z "$ac_dir" && ac_dir=.
- if test -f $ac_dir/$ac_word; then
- if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then
- ac_prog_rejected=yes
- continue
- fi
- ac_cv_prog_CC="cc"
- break
- fi
- done
- IFS="$ac_save_ifs"
-if test $ac_prog_rejected = yes; then
- # We found a bogon in the path, so make sure we never use it.
- set dummy $ac_cv_prog_CC
- shift
- if test $# -gt 0; then
- # We chose a different compiler from the bogus one.
- # However, it has the same basename, so the bogon will be chosen
- # first if we set CC to just the basename; use the full file name.
- shift
- set dummy "$ac_dir/$ac_word" "$@"
- shift
- ac_cv_prog_CC="$@"
- fi
-fi
-fi
-fi
-CC="$ac_cv_prog_CC"
-if test -n "$CC"; then
- echo "$ac_t""$CC" 1>&6
-else
- echo "$ac_t""no" 1>&6
-fi
-
- if test -z "$CC"; then
- case "`uname -s`" in
- *win32* | *WIN32*)
- # Extract the first word of "cl", so it can be a program name with args.
-set dummy cl; ac_word=$2
-echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:649: checking for $ac_word" >&5
-if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- if test -n "$CC"; then
- ac_cv_prog_CC="$CC" # Let the user override the test.
-else
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
- ac_dummy="$PATH"
- for ac_dir in $ac_dummy; do
- test -z "$ac_dir" && ac_dir=.
- if test -f $ac_dir/$ac_word; then
- ac_cv_prog_CC="cl"
- break
- fi
- done
- IFS="$ac_save_ifs"
-fi
-fi
-CC="$ac_cv_prog_CC"
-if test -n "$CC"; then
- echo "$ac_t""$CC" 1>&6
-else
- echo "$ac_t""no" 1>&6
-fi
- ;;
- esac
- fi
- test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; }
-fi
-
-echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
-echo "configure:681: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
-
-ac_ext=c
-# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
-ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
-cross_compiling=$ac_cv_prog_cc_cross
-
-cat > conftest.$ac_ext << EOF
-
-#line 692 "configure"
-#include "confdefs.h"
-
-main(){return(0);}
-EOF
-if { (eval echo configure:697: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
- ac_cv_prog_cc_works=yes
- # If we can't run a trivial program, we are probably using a cross compiler.
- if (./conftest; exit) 2>/dev/null; then
- ac_cv_prog_cc_cross=no
- else
- ac_cv_prog_cc_cross=yes
- fi
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- ac_cv_prog_cc_works=no
-fi
-rm -fr conftest*
-ac_ext=c
-# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
-ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
-cross_compiling=$ac_cv_prog_cc_cross
-
-echo "$ac_t""$ac_cv_prog_cc_works" 1>&6
-if test $ac_cv_prog_cc_works = no; then
- { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; }
-fi
-echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
-echo "configure:723: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
-echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6
-cross_compiling=$ac_cv_prog_cc_cross
-
-echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
-echo "configure:728: checking whether we are using GNU C" >&5
-if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.c <<EOF
-#ifdef __GNUC__
- yes;
-#endif
-EOF
-if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:737: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
- ac_cv_prog_gcc=yes
-else
- ac_cv_prog_gcc=no
-fi
-fi
-
-echo "$ac_t""$ac_cv_prog_gcc" 1>&6
-
-if test $ac_cv_prog_gcc = yes; then
- GCC=yes
-else
- GCC=
-fi
-
-ac_test_CFLAGS="${CFLAGS+set}"
-ac_save_CFLAGS="$CFLAGS"
-CFLAGS=
-echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
-echo "configure:756: checking whether ${CC-cc} accepts -g" >&5
-if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- echo 'void f(){}' > conftest.c
-if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then
- ac_cv_prog_cc_g=yes
-else
- ac_cv_prog_cc_g=no
-fi
-rm -f conftest*
-
-fi
-
-echo "$ac_t""$ac_cv_prog_cc_g" 1>&6
-if test "$ac_test_CFLAGS" = set; then
- CFLAGS="$ac_save_CFLAGS"
-elif test $ac_cv_prog_cc_g = yes; then
- if test "$GCC" = yes; then
- CFLAGS="-g -O2"
- else
- CFLAGS="-g"
- fi
-else
- if test "$GCC" = yes; then
- CFLAGS="-O2"
- else
- CFLAGS=
- fi
-fi
-
-# Extract the first word of "ranlib", so it can be a program name with args.
-set dummy ranlib; ac_word=$2
-echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:790: checking for $ac_word" >&5
-if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- if test -n "$RANLIB"; then
- ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
-else
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
- ac_dummy="$PATH"
- for ac_dir in $ac_dummy; do
- test -z "$ac_dir" && ac_dir=.
- if test -f $ac_dir/$ac_word; then
- ac_cv_prog_RANLIB="ranlib"
- break
- fi
- done
- IFS="$ac_save_ifs"
- test -z "$ac_cv_prog_RANLIB" && ac_cv_prog_RANLIB=":"
-fi
-fi
-RANLIB="$ac_cv_prog_RANLIB"
-if test -n "$RANLIB"; then
- echo "$ac_t""$RANLIB" 1>&6
-else
- echo "$ac_t""no" 1>&6
-fi
-
-
-for ac_prog in ar aal
-do
-# Extract the first word of "$ac_prog", so it can be a program name with args.
-set dummy $ac_prog; ac_word=$2
-echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:823: checking for $ac_word" >&5
-if eval "test \"`echo '$''{'ac_cv_prog_AR'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- if test -n "$AR"; then
- ac_cv_prog_AR="$AR" # Let the user override the test.
-else
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
- ac_dummy="$PATH"
- for ac_dir in $ac_dummy; do
- test -z "$ac_dir" && ac_dir=.
- if test -f $ac_dir/$ac_word; then
- ac_cv_prog_AR="$ac_prog"
- break
- fi
- done
- IFS="$ac_save_ifs"
-fi
-fi
-AR="$ac_cv_prog_AR"
-if test -n "$AR"; then
- echo "$ac_t""$AR" 1>&6
-else
- echo "$ac_t""no" 1>&6
-fi
-
-test -n "$AR" && break
-done
-test -n "$AR" || AR="ar"
-
-
-echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
-echo "configure:855: checking how to run the C preprocessor" >&5
-# On Suns, sometimes $CPP names a directory.
-if test -n "$CPP" && test -d "$CPP"; then
- CPP=
-fi
-if test -z "$CPP"; then
-if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- # This must be in double quotes, not single quotes, because CPP may get
- # substituted into the Makefile and "${CC-cc}" will confuse make.
- CPP="${CC-cc} -E"
- # On the NeXT, cc -E runs the code through the compiler's parser,
- # not just through cpp.
- cat > conftest.$ac_ext <<EOF
-#line 870 "configure"
-#include "confdefs.h"
-#include <assert.h>
-Syntax Error
-EOF
-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:876: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
-if test -z "$ac_err"; then
- :
-else
- echo "$ac_err" >&5
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- CPP="${CC-cc} -E -traditional-cpp"
- cat > conftest.$ac_ext <<EOF
-#line 887 "configure"
-#include "confdefs.h"
-#include <assert.h>
-Syntax Error
-EOF
-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:893: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
-if test -z "$ac_err"; then
- :
-else
- echo "$ac_err" >&5
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- CPP="${CC-cc} -nologo -E"
- cat > conftest.$ac_ext <<EOF
-#line 904 "configure"
-#include "confdefs.h"
-#include <assert.h>
-Syntax Error
-EOF
-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:910: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
-if test -z "$ac_err"; then
- :
-else
- echo "$ac_err" >&5
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- CPP=/lib/cpp
-fi
-rm -f conftest*
-fi
-rm -f conftest*
-fi
-rm -f conftest*
- ac_cv_prog_CPP="$CPP"
-fi
- CPP="$ac_cv_prog_CPP"
-else
- ac_cv_prog_CPP="$CPP"
-fi
-echo "$ac_t""$CPP" 1>&6
-
-echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
-echo "configure:935: checking for ANSI C header files" >&5
-if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 940 "configure"
-#include "confdefs.h"
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-#include <float.h>
-EOF
-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:948: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
-if test -z "$ac_err"; then
- rm -rf conftest*
- ac_cv_header_stdc=yes
-else
- echo "$ac_err" >&5
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- ac_cv_header_stdc=no
-fi
-rm -f conftest*
-
-if test $ac_cv_header_stdc = yes; then
- # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
-cat > conftest.$ac_ext <<EOF
-#line 965 "configure"
-#include "confdefs.h"
-#include <string.h>
-EOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- egrep "memchr" >/dev/null 2>&1; then
- :
-else
- rm -rf conftest*
- ac_cv_header_stdc=no
-fi
-rm -f conftest*
-
-fi
-
-if test $ac_cv_header_stdc = yes; then
- # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
-cat > conftest.$ac_ext <<EOF
-#line 983 "configure"
-#include "confdefs.h"
-#include <stdlib.h>
-EOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- egrep "free" >/dev/null 2>&1; then
- :
-else
- rm -rf conftest*
- ac_cv_header_stdc=no
-fi
-rm -f conftest*
-
-fi
-
-if test $ac_cv_header_stdc = yes; then
- # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
-if test "$cross_compiling" = yes; then
- :
-else
- cat > conftest.$ac_ext <<EOF
-#line 1004 "configure"
-#include "confdefs.h"
-#include <ctype.h>
-#define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
-#define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
-#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
-int main () { int i; for (i = 0; i < 256; i++)
-if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
-exit (0); }
-
-EOF
-if { (eval echo configure:1015: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
-then
- :
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -fr conftest*
- ac_cv_header_stdc=no
-fi
-rm -fr conftest*
-fi
-
-fi
-fi
-
-echo "$ac_t""$ac_cv_header_stdc" 1>&6
-if test $ac_cv_header_stdc = yes; then
- cat >> confdefs.h <<\EOF
-#define STDC_HEADERS 1
-EOF
-
-fi
-
-
-trap '' 1 2 15
-cat > confcache <<\EOF
-# This file is a shell script that caches the results of configure
-# tests run on this system so they can be shared between configure
-# scripts and configure runs. It is not useful on other systems.
-# If it contains results you don't want to keep, you may remove or edit it.
-#
-# By default, configure uses ./config.cache as the cache file,
-# creating it if it does not exist already. You can give configure
-# the --cache-file=FILE option to use a different cache file; that is
-# what configure does when it calls configure scripts in
-# subdirectories, so they share the cache.
-# Giving --cache-file=/dev/null disables caching, for debugging configure.
-# config.status only pays attention to the cache file if you give it the
-# --recheck option to rerun configure.
-#
-EOF
-# The following way of writing the cache mishandles newlines in values,
-# but we know of no workaround that is simple, portable, and efficient.
-# So, don't put newlines in cache variables' values.
-# Ultrix sh set writes to stderr and can't be redirected directly,
-# and sets the high bit in the cache file unless we assign to the vars.
-(set) 2>&1 |
- case `(ac_space=' '; set | grep ac_space) 2>&1` in
- *ac_space=\ *)
- # `set' does not quote correctly, so add quotes (double-quote substitution
- # turns \\\\ into \\, and sed turns \\ into \).
- sed -n \
- -e "s/'/'\\\\''/g" \
- -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p"
- ;;
- *)
- # `set' quotes correctly as required by POSIX, so do not add quotes.
- sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p'
- ;;
- esac >> confcache
-if cmp -s $cache_file confcache; then
- :
-else
- if test -w $cache_file; then
- echo "updating cache $cache_file"
- cat confcache > $cache_file
- else
- echo "not updating unwritable cache $cache_file"
- fi
-fi
-rm -f confcache
-
-trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
-
-test "x$prefix" = xNONE && prefix=$ac_default_prefix
-# Let make expand exec_prefix.
-test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
-
-# Any assignment to VPATH causes Sun make to only execute
-# the first set of double-colon rules, so remove it if not needed.
-# If there is a colon in the path, we need to keep it.
-if test "x$srcdir" = x.; then
- ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d'
-fi
-
-trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15
-
-# Transform confdefs.h into DEFS.
-# Protect against shell expansion while executing Makefile rules.
-# Protect against Makefile macro expansion.
-cat > conftest.defs <<\EOF
-s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%-D\1=\2%g
-s%[ `~#$^&*(){}\\|;'"<>?]%\\&%g
-s%\[%\\&%g
-s%\]%\\&%g
-s%\$%$$%g
-EOF
-DEFS=`sed -f conftest.defs confdefs.h | tr '\012' ' '`
-rm -f conftest.defs
-
-
-# Without the "./", some shells look in PATH for config.status.
-: ${CONFIG_STATUS=./config.status}
-
-echo creating $CONFIG_STATUS
-rm -f $CONFIG_STATUS
-cat > $CONFIG_STATUS <<EOF
-#! /bin/sh
-# Generated automatically by configure.
-# Run this file to recreate the current configuration.
-# This directory was configured as follows,
-# on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
-#
-# $0 $ac_configure_args
-#
-# Compiler output produced by configure, useful for debugging
-# configure, is in ./config.log if it exists.
-
-ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]"
-for ac_option
-do
- case "\$ac_option" in
- -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
- echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion"
- exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;;
- -version | --version | --versio | --versi | --vers | --ver | --ve | --v)
- echo "$CONFIG_STATUS generated by autoconf version 2.13"
- exit 0 ;;
- -help | --help | --hel | --he | --h)
- echo "\$ac_cs_usage"; exit 0 ;;
- *) echo "\$ac_cs_usage"; exit 1 ;;
- esac
-done
-
-ac_given_srcdir=$srcdir
-
-trap 'rm -fr `echo "Makefile Lib/Makefile" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
-EOF
-cat >> $CONFIG_STATUS <<EOF
-
-# Protect against being on the right side of a sed subst in config.status.
-sed 's/%@/@@/; s/@%/@@/; s/%g\$/@g/; /@g\$/s/[\\\\&%]/\\\\&/g;
- s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > conftest.subs <<\\CEOF
-$ac_vpsub
-$extrasub
-s%@SHELL@%$SHELL%g
-s%@CFLAGS@%$CFLAGS%g
-s%@CPPFLAGS@%$CPPFLAGS%g
-s%@CXXFLAGS@%$CXXFLAGS%g
-s%@FFLAGS@%$FFLAGS%g
-s%@DEFS@%$DEFS%g
-s%@LDFLAGS@%$LDFLAGS%g
-s%@LIBS@%$LIBS%g
-s%@exec_prefix@%$exec_prefix%g
-s%@prefix@%$prefix%g
-s%@program_transform_name@%$program_transform_name%g
-s%@bindir@%$bindir%g
-s%@sbindir@%$sbindir%g
-s%@libexecdir@%$libexecdir%g
-s%@datadir@%$datadir%g
-s%@sysconfdir@%$sysconfdir%g
-s%@sharedstatedir@%$sharedstatedir%g
-s%@localstatedir@%$localstatedir%g
-s%@libdir@%$libdir%g
-s%@includedir@%$includedir%g
-s%@oldincludedir@%$oldincludedir%g
-s%@infodir@%$infodir%g
-s%@mandir@%$mandir%g
-s%@MACHDEP@%$MACHDEP%g
-s%@CC@%$CC%g
-s%@RANLIB@%$RANLIB%g
-s%@AR@%$AR%g
-s%@CPP@%$CPP%g
-
-CEOF
-EOF
-
-cat >> $CONFIG_STATUS <<\EOF
-
-# Split the substitutions into bite-sized pieces for seds with
-# small command number limits, like on Digital OSF/1 and HP-UX.
-ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script.
-ac_file=1 # Number of current file.
-ac_beg=1 # First line for current file.
-ac_end=$ac_max_sed_cmds # Line after last line for current file.
-ac_more_lines=:
-ac_sed_cmds=""
-while $ac_more_lines; do
- if test $ac_beg -gt 1; then
- sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file
- else
- sed "${ac_end}q" conftest.subs > conftest.s$ac_file
- fi
- if test ! -s conftest.s$ac_file; then
- ac_more_lines=false
- rm -f conftest.s$ac_file
- else
- if test -z "$ac_sed_cmds"; then
- ac_sed_cmds="sed -f conftest.s$ac_file"
- else
- ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file"
- fi
- ac_file=`expr $ac_file + 1`
- ac_beg=$ac_end
- ac_end=`expr $ac_end + $ac_max_sed_cmds`
- fi
-done
-if test -z "$ac_sed_cmds"; then
- ac_sed_cmds=cat
-fi
-EOF
-
-cat >> $CONFIG_STATUS <<EOF
-
-CONFIG_FILES=\${CONFIG_FILES-"Makefile Lib/Makefile"}
-EOF
-cat >> $CONFIG_STATUS <<\EOF
-for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then
- # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
- case "$ac_file" in
- *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'`
- ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
- *) ac_file_in="${ac_file}.in" ;;
- esac
-
- # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories.
-
- # Remove last slash and all that follows it. Not all systems have dirname.
- ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'`
- if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
- # The file is in a subdirectory.
- test ! -d "$ac_dir" && mkdir "$ac_dir"
- ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`"
- # A "../" for each directory in $ac_dir_suffix.
- ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'`
- else
- ac_dir_suffix= ac_dots=
- fi
-
- case "$ac_given_srcdir" in
- .) srcdir=.
- if test -z "$ac_dots"; then top_srcdir=.
- else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;;
- /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;;
- *) # Relative path.
- srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix"
- top_srcdir="$ac_dots$ac_given_srcdir" ;;
- esac
-
-
- echo creating "$ac_file"
- rm -f "$ac_file"
- configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure."
- case "$ac_file" in
- *Makefile*) ac_comsub="1i\\
-# $configure_input" ;;
- *) ac_comsub= ;;
- esac
-
- ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"`
- sed -e "$ac_comsub
-s%@configure_input@%$configure_input%g
-s%@srcdir@%$srcdir%g
-s%@top_srcdir@%$top_srcdir%g
-" $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file
-fi; done
-rm -f conftest.s*
-
-EOF
-cat >> $CONFIG_STATUS <<EOF
-
-EOF
-cat >> $CONFIG_STATUS <<\EOF
-
-exit 0
-EOF
-chmod +x $CONFIG_STATUS
-rm -fr confdefs* $ac_clean_files
-test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1
-
-
-
-
-
-
-
diff --git a/SWIG/Examples/Makefile.in b/SWIG/Examples/Makefile.in
index 6ae82386d..0703dcd35 100644
--- a/SWIG/Examples/Makefile.in
+++ b/SWIG/Examples/Makefile.in
@@ -32,7 +32,7 @@ INCLUDE =
LIBS =
INTERFACE =
SWIGOPT =
-SWIG = SWIG
+SWIG = swig@release_suffix@
LIBM = @LIBM@
LIBC = @LIBC@
@@ -68,12 +68,12 @@ CPP_DLLIBS = #-L/usr/local/lib/gcc-lib/sparc-sun-solaris2.5.1/2.7.2 \
SO= @SO@
LDSHARED= @LDSHARED@
CCSHARED= @CCSHARED@
-CXXSHARED= @LDSHARED@
+CXXSHARED= @CXXSHARED@
# This is used for building shared libraries with a number of C++
# compilers. If it doesn't work, comment it out.
-CXXSHARED= @CXX@ -shared
+@TRYLINKINGWITHCXX@
OBJS = $(SRCS:.c=.o) $(CXXSRCS:.cxx=.o)
IOBJS = $(ISRCS:.c=.o)
@@ -86,7 +86,7 @@ IOBJS = $(ISRCS:.c=.o)
TCL_INCLUDE = @TCLINCLUDE@
TCL_LIB = @TCLLIB@
-TCL_OPTS = -ltcl @LIBS@
+TCL_OPTS = @LIBS@
TK_OPTS = -ltk -ltcl @LIBS@
# -----------------------------------------------------------
@@ -260,7 +260,7 @@ guile: $(SRCS)
guile_cpp: $(SRCS)
$(SWIG) -c++ -guile -Linkage ltdlmod $(SWIGOPT) $(INTERFACE)
$(CXX) -c $(CCSHARED) $(CFLAGS) $(INCLUDE) $(GUILE_INCLUDE) $(ISRCS) $(SRCS) $(CXXSRCS)
- $(LDSHARED) $(OBJS) $(IOBJS) $(LIBS) -o lib$(TARGET)$(SO)
+ $(CXXSHARED) $(OBJS) $(IOBJS) $(LIBS) -o lib$(TARGET)$(SO)
# -----------------------------------------------------------------
# Build statically linked Guile interpreter
@@ -329,7 +329,11 @@ mzscheme: $(SRCS)
##################################################################
# Make sure these locate your Ruby installation
-RUBY_INCLUDE= -DHAVE_CONFIG_H @RUBYINCLUDE@
+RUBY_CFLAGS= @RUBYCCDLFLAGS@ -DHAVE_CONFIG_H
+RUBY_INCLUDE= @RUBYINCLUDE@
+RUBY_LIB = @RUBYLIB@
+RUBY_LIBOPTS = @RUBYLINK@ @LIBS@ $(SYSLIBS)
+RUBY_LIBRUBYARG= @RUBYLIBRUBYARG@
# ----------------------------------------------------------------
# Build a C dynamically loadable module
@@ -337,8 +341,8 @@ RUBY_INCLUDE= -DHAVE_CONFIG_H @RUBYINCLUDE@
ruby: $(SRCS)
$(SWIG) -ruby $(SWIGOPT) $(INTERFACE)
- $(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(SRCS) $(INCLUDE) $(RUBY_INCLUDE)
- $(LDSHARED) $(OBJS) $(IOBJS) $(LIBS) -o $(TARGET)$(SO)
+ $(CC) -c $(CCSHARED) $(CFLAGS) $(RUBY_CFLAGS) $(ISRCS) $(SRCS) $(INCLUDE) $(RUBY_INCLUDE)
+ $(LDSHARED) $(OBJS) $(IOBJS) $(LIBS) $(RUBY_LIBRUBYARG) -o $(TARGET)$(SO)
# -----------------------------------------------------------------
# Build a C++ dynamically loadable module
@@ -346,8 +350,8 @@ ruby: $(SRCS)
ruby_cpp: $(SRCS)
$(SWIG) -c++ -ruby $(SWIGOPT) $(INTERFACE)
- $(CXX) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(SRCS) $(CXXSRCS) $(INCLUDE) $(RUBY_INCLUDE)
- $(CXXSHARED) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(TARGET)$(SO)
+ $(CXX) -c $(CCSHARED) $(CFLAGS) $(RUBY_CFLAGS) $(ISRCS) $(SRCS) $(CXXSRCS) $(INCLUDE) $(RUBY_INCLUDE)
+ $(CXXSHARED) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) $(RUBY_LIBRUBYARG) -o $(TARGET)$(SO)
# -----------------------------------------------------------------
# Build statically linked Ruby interpreter
@@ -356,17 +360,14 @@ ruby_cpp: $(SRCS)
# library file
# -----------------------------------------------------------------
-RUBY_LIB = @RUBYLIB@
-RUBY_LIBOPTS = @RUBYLINK@ @LIBS@ $(SYSLIBS)
-
ruby_static: $(SRCS)
$(SWIG) -ruby -lembed.i $(SWIGOPT) $(INTERFACE)
- $(CC) $(CFLAGS) @LINKFORSHARED@ $(ISRCS) $(SRCS) $(INCLUDE) \
+ $(CC) $(CFLAGS) $(RUBY_CFLAGS) @LINKFORSHARED@ $(ISRCS) $(SRCS) $(INCLUDE) \
$(RUBY_INCLUDE) $(LIBS) -L$(RUBY_LIB) $(RUBY_LIBOPTS) -o $(TARGET)
-ruby_static_cpp: $(SRCS)
+ruby_cpp_static: $(SRCS)
$(SWIG) -c++ -ruby -lembed.i $(SWIGOPT) $(INTERFACE)
- $(CXX) $(CFLAGS) $(ISRCS) $(SRCS) $(CXXSRCS) $(INCLUDE) \
+ $(CXX) $(CFLAGS) $(RUBY_CFLAGS) $(ISRCS) $(SRCS) $(CXXSRCS) $(INCLUDE) \
$(RUBY_INCLUDE) $(LIBS) -L$(RUBY_LIB) $(RUBY_LIBOPTS) -o $(TARGET)
diff --git a/SWIG/Examples/README b/SWIG/Examples/README
index 3a476a79a..c18d30ed7 100644
--- a/SWIG/Examples/README
+++ b/SWIG/Examples/README
@@ -37,8 +37,6 @@ the rules of thumb for making C++ work:
This can be set by modifying the setting of CPP_DLLIBS in the
Makefile.
- - RTM (sorry)
-
*** Special note for SWIG Maintainers ***
diff --git a/SWIG/Examples/guile/Makefile.in b/SWIG/Examples/guile/Makefile.in
index 1c31a6725..bac046ce9 100644
--- a/SWIG/Examples/guile/Makefile.in
+++ b/SWIG/Examples/guile/Makefile.in
@@ -1,11 +1,15 @@
# Makefile for Guile. Used by all of the example programs.
-subdirs = simple matrix
+subdirs = simple matrix port
top_srcdir = @top_srcdir@
-
+SWIG = ../$(top_srcdir)/swig@release_suffix@
+CC = @CC@
+CXX = @CXX@
+CFLAGS = @CFLAGS@
GUILEINCLUDE = @GUILEINCLUDE@
GUILELINK = @GUILELINK@
+SWIGOPT =
WRAP = $(IFILE:.i=_wrap.c)
@@ -15,13 +19,18 @@ all:
clean::
cd simple; make clean
cd matrix; make clean
+ cd port; make clean
rm -f *~ .~*
# This is meant to be used w/ "make -f ../Makefile" from subdirs.
# Doesn't make sense to use it from here.
sub-all::
- ../$(top_srcdir)/swig -guile $(IFILE)
- $(CC) -o $(TARGET) $(SRCS) $(WRAP) $(GUILEINCLUDE) $(GUILELINK)
+ $(SWIG) -guile $(SWIGOPT) $(IFILE)
+ $(CC) $(CFLAGS) -o $(TARGET) $(SRCS) $(WRAP) $(GUILEINCLUDE) $(GUILELINK)
+
+sub-all-cxx::
+ $(SWIG) -c++ -guile $(SWIGOPT) $(IFILE)
+ $(CXX) $(CFLAGS) -o $(TARGET) $(SRCS) $(WRAP) $(GUILEINCLUDE) $(GUILELINK)
# Makefile ends here
diff --git a/SWIG/Examples/guile/matrix/Makefile b/SWIG/Examples/guile/matrix/Makefile
index bbe78539a..f90d9aa43 100644
--- a/SWIG/Examples/guile/matrix/Makefile
+++ b/SWIG/Examples/guile/matrix/Makefile
@@ -1,4 +1,3 @@
-CC = gcc
SRCS = matrix.c vector.c
TARGET = matrix
IFILE = package.i
@@ -10,7 +9,6 @@ all::
SRCS='$(SRCS)' \
TARGET=$(TARGET) \
IFILE=$(IFILE) \
- CC=$(CC) \
MODULE=$(MODULE) \
sub-all
diff --git a/SWIG/Examples/guile/matrix/matrix.c b/SWIG/Examples/guile/matrix/matrix.c
index 7ecb6ddd4..6ce10098b 100644
--- a/SWIG/Examples/guile/matrix/matrix.c
+++ b/SWIG/Examples/guile/matrix/matrix.c
@@ -1,4 +1,6 @@
/* FILE : matrix.c : some simple 4x4 matrix operations */
+#include <stdlib.h>
+#include <stdio.h>
double **new_matrix() {
diff --git a/SWIG/Examples/guile/matrix/vector.c b/SWIG/Examples/guile/matrix/vector.c
index cdb726ad5..3012993f8 100644
--- a/SWIG/Examples/guile/matrix/vector.c
+++ b/SWIG/Examples/guile/matrix/vector.c
@@ -1,5 +1,7 @@
/* File : vector.c */
+#include <stdlib.h>
+#include <stdio.h>
#include "vector.h"
Vector *createv(double x, double y, double z, double w) {
diff --git a/SWIG/Examples/guile/port/Makefile b/SWIG/Examples/guile/port/Makefile
index 668c66bd3..7e0250c03 100644
--- a/SWIG/Examples/guile/port/Makefile
+++ b/SWIG/Examples/guile/port/Makefile
@@ -1,4 +1,3 @@
-CC = gcc
SRCS = port.c
TARGET = port
IFILE = port.i
@@ -10,7 +9,6 @@ all::
SRCS='$(SRCS)' \
TARGET=$(TARGET) \
IFILE=$(IFILE) \
- CC=$(CC) \
MODULE=$(MODULE) \
sub-all
diff --git a/SWIG/Examples/guile/port/port.i b/SWIG/Examples/guile/port/port.i
index 553cfba23..1a1122dbc 100644
--- a/SWIG/Examples/guile/port/port.i
+++ b/SWIG/Examples/guile/port/port.i
@@ -7,5 +7,7 @@
#include <stdio.h>
%}
+%inline %{
void print_int(FILE *f, int i);
int read_int(FILE *f);
+%}
diff --git a/SWIG/Examples/guile/simple/Makefile b/SWIG/Examples/guile/simple/Makefile
index 151dcc4b3..87ee2ecbb 100644
--- a/SWIG/Examples/guile/simple/Makefile
+++ b/SWIG/Examples/guile/simple/Makefile
@@ -1,4 +1,3 @@
-CC = gcc
SRCS = example.c
TARGET = my-guile
IFILE = example.i
@@ -9,7 +8,6 @@ all::
SRCS='$(SRCS)' \
TARGET=$(TARGET) \
IFILE=$(IFILE) \
- CC=$(CC) \
sub-all
clean::
diff --git a/SWIG/Examples/guile/simple/example.c b/SWIG/Examples/guile/simple/example.c
index 0e6b284b6..dcafc4dc4 100644
--- a/SWIG/Examples/guile/simple/example.c
+++ b/SWIG/Examples/guile/simple/example.c
@@ -1,7 +1,7 @@
/* Simple example from documentation */
/* File : example.c */
-#include </usr/include/time.h>
+#include <time.h>
double My_variable = 3.0;
diff --git a/SWIG/Examples/guile/test-suite/.cvsignore b/SWIG/Examples/guile/test-suite/.cvsignore
new file mode 100644
index 000000000..4cc1c69cb
--- /dev/null
+++ b/SWIG/Examples/guile/test-suite/.cvsignore
@@ -0,0 +1,3 @@
+*_wrap*
+*test-x
+Makefile
diff --git a/SWIG/Examples/guile/test-suite/Makefile.in b/SWIG/Examples/guile/test-suite/Makefile.in
new file mode 100644
index 000000000..2350cac00
--- /dev/null
+++ b/SWIG/Examples/guile/test-suite/Makefile.in
@@ -0,0 +1,60 @@
+top_srcdir = @top_srcdir@
+SWIG = ../$(top_srcdir)/swig@release_suffix@
+CC = @CC@
+CXX = @CXX@
+CFLAGS = @CFLAGS@
+GUILEINCLUDE = @GUILEINCLUDE@
+GUILELINK = @GUILELINK@
+
+all:: macro-2.test \
+ long-long.test const-const.test \
+ cplusplus-throw.cplusplustest \
+ char-constant.runtest \
+ pointer-reference.cplusplustest \
+ casts.cplusplusruntest \
+ import.cplusplusruntest \
+ name.runtest \
+ template-whitespace.cplusplustest
+
+.SUFFIXES: .i .test .cplusplustest .runtest .cplusplusruntest
+
+.i.test:
+ @echo Checking Examples/guile/test-suite/$<
+ @$(SWIG) -guile -lguilemain.i $< || (echo "Examples/guile/test-suite/$<: SWIG FAILED "; exit 1)
+ @$(CC) $(CFLAGS) $*_wrap.c -o $@-x $(GUILEINCLUDE) $(GUILELINK) || (echo "Examples/guile/test-suite/$<: COMPILE/LINK FAILED"; exit 1)
+ @echo "Examples/guile/test-suite/$<: PASSED"
+
+.i.cplusplustest:
+ @echo Checking Examples/guile/test-suite/$<
+ @$(SWIG) -guile -c++ -lguilemain.i $< || (echo "Examples/guile/test-suite/$<: SWIG FAILED "; exit 1)
+ @$(CXX) $(CFLAGS) $*_wrap.c -o $@-x $(GUILEINCLUDE) $(GUILELINK) || (echo "Examples/guile/test-suite/$<: COMPILE/LINK FAILED"; exit 1)
+ @echo "Examples/guile/test-suite/$<: PASSED"
+
+.i.runtest:
+ @echo Checking Examples/guile/test-suite/$<
+ @$(SWIG) -guile -lguilemain.i $< || (echo "Examples/guile/test-suite/$<: SWIG FAILED "; exit 1)
+ @$(CC) $(CFLAGS) $*_wrap.c -o $@-x $(GUILEINCLUDE) $(GUILELINK) || (echo "Examples/guile/test-suite/$<: COMPILE/LINK FAILED"; exit 1)
+ @./$@-x -l $*.scm || (echo "Examples/guile/test-suite/$<: RUN TEST FAILED"; exit 1)
+ @echo "Examples/guile/test-suite/$<: PASSED"
+
+.i.cplusplusruntest:
+ @echo Checking Examples/guile/test-suite/$<
+ @$(SWIG) -guile -c++ -lguilemain.i $< || (echo "Examples/guile/test-suite/$<: SWIG FAILED "; exit 1)
+ @$(CXX) $(CFLAGS) $*_wrap.c -o $@-x $(GUILEINCLUDE) $(GUILELINK) || (echo "Examples/guile/test-suite/$<: COMPILE/LINK FAILED"; exit 1)
+ @./$@-x -l $*.scm || (echo "Examples/guile/test-suite/$<: RUN TEST FAILED"; exit 1)
+ @echo "Examples/guile/test-suite/$<: PASSED"
+
+import.cplusplusruntest:
+ @echo Checking Examples/guile/test-suite/import
+ @$(SWIG) -c++ -guile -Linkage passive -c import-a.i || (echo "Examples/guile/test-suite/import: SWIG FAILED "; exit 1)
+ @$(SWIG) -c++ -guile -Linkage passive import-b.i || (echo "Examples/guile/test-suite/import: SWIG FAILED "; exit 1)
+ @$(CXX) $(CFLAGS) -DSWIG_GLOBAL -o import-a_wrap.o -c import-a_wrap.c $(GUILEINCLUDE) || (echo "Examples/guile/test-suite/import: COMPILE FAILED "; exit 1)
+ @$(CXX) $(CFLAGS) -DSWIG_GLOBAL -o import-b_wrap.o -c import-b_wrap.c $(GUILEINCLUDE)|| (echo "Examples/guile/test-suite/import: COMPILE FAILED "; exit 1)
+ @$(CXX) $(CFLAGS) -o $@-x import-a_wrap.o import-b_wrap.o import-main.cc $(GUILEINCLUDE) $(GUILELINK)|| (echo "Examples/guile/test-suite/import: LINK FAILED "; exit 1)
+ @./$@-x -l $*.scm || (echo "Examples/guile/test-suite/import: RUN TEST FAILED"; exit 1)
+ @echo "Examples/guile/test-suite/import: PASSED"
+
+clean::
+ rm -f matrix *_wrap* *test-x *~ .~* core
+
+check: all
diff --git a/SWIG/Examples/guile/test-suite/README b/SWIG/Examples/guile/test-suite/README
new file mode 100644
index 000000000..6cf4064aa
--- /dev/null
+++ b/SWIG/Examples/guile/test-suite/README
@@ -0,0 +1,7 @@
+This directory contains a test suite for SWIG. The idea is that
+whenever a bug in SWIG is discovered, we add a test that fails,
+showing the bug. When we believe to have fixed the bug, we can check
+whether test works. The tests are kept here when the bug is fixed --
+so we can make sure that the bug (or related bugs) don't creep back
+into SWIG.
+
diff --git a/SWIG/Examples/guile/test-suite/casts.i b/SWIG/Examples/guile/test-suite/casts.i
new file mode 100644
index 000000000..d26c18b31
--- /dev/null
+++ b/SWIG/Examples/guile/test-suite/casts.i
@@ -0,0 +1,19 @@
+%inline %{
+
+class A {
+ public:
+ A() {}
+
+ void hello()
+ {
+ }
+};
+
+class B : public A
+{
+ public:
+ B() {}
+
+};
+
+%}
diff --git a/SWIG/Examples/guile/test-suite/casts.scm b/SWIG/Examples/guile/test-suite/casts.scm
new file mode 100644
index 000000000..8a566ec3c
--- /dev/null
+++ b/SWIG/Examples/guile/test-suite/casts.scm
@@ -0,0 +1,8 @@
+(define x (new-B))
+
+;; This fails in 1.3a5 because the SWIG/Guile runtime code gets the
+;; source and the target of a cast the wrong way around.
+
+(A-hello x)
+
+(exit 0)
diff --git a/SWIG/Examples/guile/test-suite/char-constant.i b/SWIG/Examples/guile/test-suite/char-constant.i
new file mode 100644
index 000000000..69d9b7018
--- /dev/null
+++ b/SWIG/Examples/guile/test-suite/char-constant.i
@@ -0,0 +1,6 @@
+/* This interface file tests whether character constants are correctly
+ wrapped as procedures returning Scheme characters (rather than
+ Scheme strings).
+*/
+
+#define CHAR_CONSTANT 'x'
diff --git a/SWIG/Examples/guile/test-suite/char-constant.scm b/SWIG/Examples/guile/test-suite/char-constant.scm
new file mode 100644
index 000000000..7601f32c3
--- /dev/null
+++ b/SWIG/Examples/guile/test-suite/char-constant.scm
@@ -0,0 +1,3 @@
+(if (char? (CHAR-CONSTANT))
+ (exit 0)
+ (exit 1))
diff --git a/SWIG/Examples/guile/test-suite/const-const.i b/SWIG/Examples/guile/test-suite/const-const.i
new file mode 100644
index 000000000..39eb3b060
--- /dev/null
+++ b/SWIG/Examples/guile/test-suite/const-const.i
@@ -0,0 +1,9 @@
+/* This interface file tests whether SWIG handles types like
+ "const int *const" right.
+
+ SWIG 1.3a5 signals a syntax error.
+*/
+
+%inline %{
+void foo(const int *const i) {}
+%}
diff --git a/SWIG/Examples/guile/test-suite/cplusplus-throw.i b/SWIG/Examples/guile/test-suite/cplusplus-throw.i
new file mode 100644
index 000000000..b68e485b9
--- /dev/null
+++ b/SWIG/Examples/guile/test-suite/cplusplus-throw.i
@@ -0,0 +1,10 @@
+/* This interface file checks whether the SWIG parses the throw
+ directive in combination with the const directive. Bug reported by
+ Scott B. Drummonds, 08 June 2001.
+*/
+
+class bar {
+ void baz() const;
+ void foo() throw (exception);
+ void bazfoo() const throw ();
+}
diff --git a/SWIG/Examples/guile/test-suite/import-a.h b/SWIG/Examples/guile/test-suite/import-a.h
new file mode 100644
index 000000000..d9e7bc3a3
--- /dev/null
+++ b/SWIG/Examples/guile/test-suite/import-a.h
@@ -0,0 +1,10 @@
+#include <iostream.h>
+
+class A {
+ public:
+ A() {}
+
+ void hello()
+ {
+ }
+};
diff --git a/SWIG/Examples/guile/test-suite/import-a.i b/SWIG/Examples/guile/test-suite/import-a.i
new file mode 100644
index 000000000..186525b2a
--- /dev/null
+++ b/SWIG/Examples/guile/test-suite/import-a.i
@@ -0,0 +1,12 @@
+/* This file is part of a test for SF bug #231619.
+ It shows that the %import directive does not work properly in SWIG
+ 1.3a5: Type information is not properly generated if a base class
+ comes from an %import-ed file. */
+
+%module a
+
+%{
+ #include "import-a.h"
+%}
+
+%include "import-a.h"
diff --git a/SWIG/Examples/guile/test-suite/import-b.h b/SWIG/Examples/guile/test-suite/import-b.h
new file mode 100644
index 000000000..0d48e2693
--- /dev/null
+++ b/SWIG/Examples/guile/test-suite/import-b.h
@@ -0,0 +1,12 @@
+#include "import-a.h"
+
+class B : public A
+{
+ public:
+ B() {}
+
+ void bye()
+ {
+ }
+};
+
diff --git a/SWIG/Examples/guile/test-suite/import-b.i b/SWIG/Examples/guile/test-suite/import-b.i
new file mode 100644
index 000000000..ef378e34d
--- /dev/null
+++ b/SWIG/Examples/guile/test-suite/import-b.i
@@ -0,0 +1,14 @@
+/* This file is part of a test for SF bug #231619.
+ It shows that the %import directive does not work properly in SWIG
+ 1.3a5: Type information is not properly generated if a base class
+ comes from an %import-ed file. */
+
+%module b
+
+%{
+#include "import-b.h"
+%}
+
+%import "import-a.h"
+
+%include "import-b.h"
diff --git a/SWIG/Examples/guile/test-suite/import-main.cc b/SWIG/Examples/guile/test-suite/import-main.cc
new file mode 100644
index 000000000..ff3d317f9
--- /dev/null
+++ b/SWIG/Examples/guile/test-suite/import-main.cc
@@ -0,0 +1,24 @@
+#include <libguile.h>
+
+extern "C" {
+
+ SCM scm_init_a_module();
+ SCM scm_init_b_module();
+
+ static void
+ inner_main(void *closure, int argc, char **argv)
+ {
+ scm_init_a_module();
+ scm_init_b_module();
+ scm_shell(argc, argv); /* scheme interpreter */
+ /* never reached: scm_shell will perform an exit */
+ }
+
+}
+
+int
+main(int argc, char **argv)
+{
+ scm_boot_guile(argc, argv, inner_main, 0);
+ return 0;
+}
diff --git a/SWIG/Examples/guile/test-suite/import.scm b/SWIG/Examples/guile/test-suite/import.scm
new file mode 100644
index 000000000..663cc8bc0
--- /dev/null
+++ b/SWIG/Examples/guile/test-suite/import.scm
@@ -0,0 +1,13 @@
+;;; This file is part of a test for SF bug #231619.
+;;; It shows that the %import directive does not work properly in SWIG
+;;; 1.3a5: Type information is not properly generated if a base class
+;;; comes from an %import-ed file.
+
+(define x (new-B))
+
+;; This fails in 1.3a5 because the SWIG runtime code does not know
+;; that x (an instance of class B) can be passed to methods of class A.
+
+(A-hello x)
+
+(exit 0)
diff --git a/SWIG/Examples/guile/test-suite/long-long.i b/SWIG/Examples/guile/test-suite/long-long.i
new file mode 100644
index 000000000..a2ee10f72
--- /dev/null
+++ b/SWIG/Examples/guile/test-suite/long-long.i
@@ -0,0 +1,26 @@
+/* This interface file tests whether SWIG handles the (non-standard)
+ long long types.
+
+ SWIG 1.3a5 throws a syntax error.
+*/
+
+/* Silly sample typemaps */
+%typemap(in) long long, unsigned long long "$target = 42;";
+%typemap(out) long long, unsigned long long "$target = SCM_BOOL_F;";
+
+%inline %{
+void foo1(long long x) {}
+void foo2(long long int x) {}
+void foo3(signed long long int x) {}
+void foo4(unsigned long long int x) {}
+void foo5(signed long long x) {}
+void foo6(unsigned long long x) {}
+
+long long bar1() {return 0;}
+long long int bar2() {return 0;}
+signed long long int bar3() {return 0;}
+unsigned long long int bar4() {return 0;}
+signed long long bar5() {return 0;}
+unsigned long long bar6() {return 0;}
+%}
+
diff --git a/SWIG/Examples/guile/test-suite/macro-2.i b/SWIG/Examples/guile/test-suite/macro-2.i
new file mode 100644
index 000000000..cfd5fa722
--- /dev/null
+++ b/SWIG/Examples/guile/test-suite/macro-2.i
@@ -0,0 +1,17 @@
+/* This interface file tests whether SWIG's extended C
+ preprocessor is working right.
+
+ In this example, SWIG 1.3a5 reports missing macro arguments, which
+ is bogus.
+*/
+
+%define FOO(C_TYPE, GETLENGTH)
+ /* nothing */
+%enddef
+
+%define BAR(XYZZY)
+ FOO(XYZZY, 1)
+%enddef
+
+BAR(int)
+
diff --git a/SWIG/Examples/guile/test-suite/name.i b/SWIG/Examples/guile/test-suite/name.i
new file mode 100644
index 000000000..8be6b80ec
--- /dev/null
+++ b/SWIG/Examples/guile/test-suite/name.i
@@ -0,0 +1,15 @@
+/* This interface file tests whether SWIG/Guile handle the %rename and
+ %name directives, which was not the case in 1.3a5.
+*/
+
+%rename foo_1 "foo-2";
+%inline %{
+void foo_1() {}
+%}
+
+%name("bar-2")
+%inline %{
+int bar_1 = 17;
+%}
+
+%constant(int) baz_1 = 47;
diff --git a/SWIG/Examples/guile/test-suite/name.scm b/SWIG/Examples/guile/test-suite/name.scm
new file mode 100644
index 000000000..60cdba3b0
--- /dev/null
+++ b/SWIG/Examples/guile/test-suite/name.scm
@@ -0,0 +1,5 @@
+(foo-2)
+bar-2
+baz-1
+
+(exit 0)
diff --git a/SWIG/Examples/guile/test-suite/pointer-reference.i b/SWIG/Examples/guile/test-suite/pointer-reference.i
new file mode 100644
index 000000000..1215a5e4e
--- /dev/null
+++ b/SWIG/Examples/guile/test-suite/pointer-reference.i
@@ -0,0 +1,13 @@
+/* This interface file tests whether SWIG handles pointer-reference
+ (*&) arguments.
+
+ SWIG 1.3a5 signals a syntax error.
+*/
+
+/* A silly testing typemap for feeding a doubly indirect integer */
+%typemap(in) int *&XYZZY (int temp1, int *temp2)
+ "temp1 = gh_scm2int($source); temp2 = &temp1; $target = &temp2;";
+
+%inline %{
+void foo(int *&XYZZY) {}
+%}
diff --git a/SWIG/Examples/guile/test-suite/template-whitespace.i b/SWIG/Examples/guile/test-suite/template-whitespace.i
new file mode 100644
index 000000000..79d56aa40
--- /dev/null
+++ b/SWIG/Examples/guile/test-suite/template-whitespace.i
@@ -0,0 +1,13 @@
+/* This interface file tests whether whitespace in angle brackets
+ effects the SWIG types. SF Bug #221917, reported by
+ burchanb@cs.tamu.edu. */
+
+%{
+#include <vector>
+%}
+
+%typemap(in) vector<int> "";
+
+%inline %{
+void foo(vector<int > v) {}
+%}
diff --git a/SWIG/Examples/index.html b/SWIG/Examples/index.html
index 7737e1bdc..647981984 100644
--- a/SWIG/Examples/index.html
+++ b/SWIG/Examples/index.html
@@ -41,7 +41,7 @@ language:
<li><a href="perl5/index.html">Perl5</a>
<li><a href="tcl/index.html">Tcl</a>
<li><a href="guile/">Guile</a>
-<li><a href="java/">Java</a>
+<li><a href="java/index.html/">Java</a>
<li><a href="mzscheme/">Mzscheme</a>
<li><a href="ruby/index.html">Ruby</a>
</ul>
diff --git a/SWIG/Examples/java/class/.cvsignore b/SWIG/Examples/java/class/.cvsignore
new file mode 100644
index 000000000..c4072f651
--- /dev/null
+++ b/SWIG/Examples/java/class/.cvsignore
@@ -0,0 +1,3 @@
+*.java
+*.class
+example_wrap.c
diff --git a/SWIG/Examples/java/class/Makefile b/SWIG/Examples/java/class/Makefile
new file mode 100644
index 000000000..554974fc3
--- /dev/null
+++ b/SWIG/Examples/java/class/Makefile
@@ -0,0 +1,20 @@
+TOP = ../..
+SWIG = $(TOP)/../swig
+SRCS = example.cxx
+TARGET = libexample
+INTERFACE = example.i
+SWIGOPT = -shadow
+
+all:: java
+
+java::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp
+ javac *.java
+
+clean::
+ mv main.java main.java.tmp
+ rm -f *_wrap* *.o core *~ *.so *.class *.java
+ mv main.java.tmp main.java
+
+check: all
diff --git a/SWIG/Examples/java/class/example.cxx b/SWIG/Examples/java/class/example.cxx
new file mode 100644
index 000000000..d12685321
--- /dev/null
+++ b/SWIG/Examples/java/class/example.cxx
@@ -0,0 +1,29 @@
+/* File : example.c */
+
+#include "example.h"
+#include <math.h>
+
+/* Move the shape to a new location */
+void Shape::move(double dx, double dy) {
+ x += dx;
+ y += dy;
+}
+
+int nshapes = 0; //global variable temporarily replacing static member variable due to static member variable bug in swig core
+//int Shape::nshapes = 0;
+
+double Circle::area() {
+ return M_PI*radius*radius;
+}
+
+double Circle::perimeter() {
+ return 2*M_PI*radius;
+}
+
+double Square::area() {
+ return width*width;
+}
+
+double Square::perimeter() {
+ return 4*width;
+}
diff --git a/SWIG/Examples/java/class/example.h b/SWIG/Examples/java/class/example.h
new file mode 100644
index 000000000..94162e43c
--- /dev/null
+++ b/SWIG/Examples/java/class/example.h
@@ -0,0 +1,40 @@
+/* File : example.h */
+
+extern int nshapes; //global variable temporarily replacing static member variable due to static member variable bug in swig core
+class Shape {
+public:
+ Shape() {
+ nshapes++;
+ }
+ virtual ~Shape() {
+ nshapes--;
+ };
+ double x, y;
+ void move(double dx, double dy);
+ virtual double area() = 0;
+ virtual double perimeter() = 0;
+// static int nshapes;
+};
+
+class Circle : public Shape {
+private:
+ double radius;
+public:
+ Circle(double r) : radius(r) { };
+ virtual double area();
+ virtual double perimeter();
+};
+
+class Square : public Shape {
+private:
+ double width;
+public:
+ Square(double w) : width(w) { };
+ virtual double area();
+ virtual double perimeter();
+};
+
+
+
+
+
diff --git a/SWIG/Examples/java/class/example.i b/SWIG/Examples/java/class/example.i
new file mode 100644
index 000000000..75700b305
--- /dev/null
+++ b/SWIG/Examples/java/class/example.i
@@ -0,0 +1,10 @@
+/* File : example.i */
+%module example
+
+%{
+#include "example.h"
+%}
+
+/* Let's just grab the original header file here */
+%include "example.h"
+
diff --git a/SWIG/Examples/java/class/index.html b/SWIG/Examples/java/class/index.html
new file mode 100644
index 000000000..2b13565b9
--- /dev/null
+++ b/SWIG/Examples/java/class/index.html
@@ -0,0 +1,222 @@
+<html>
+<head>
+<title>SWIG:Examples:java:class</title>
+</head>
+
+<body bgcolor="#ffffff">
+
+
+<tt>SWIG/Examples/java/class/</tt>
+<hr>
+
+<H2>Wrapping a simple C++ class</H2>
+
+<tt>$Header$</tt><br>
+
+<p>
+This example illustrates the high level form of C++ class wrapping performed
+by SWIG. In this case, a C++ class has a proxy Java class, which
+provides access to C++ class members.
+
+<h2>The C++ Code</h2>
+
+Suppose you have some C++ classes described by the following (and admittedly lame)
+header file:
+
+<blockquote>
+<pre>
+/* File : example.h */
+
+class Shape {
+public:
+ Shape() {
+ nshapes++;
+ }
+ virtual ~Shape() {
+ nshapes--;
+ };
+ double x, y;
+ void move(double dx, double dy);
+ virtual double area() = 0;
+ virtual double perimeter() = 0;
+ static int nshapes;
+};
+
+class Circle : public Shape {
+private:
+ double radius;
+public:
+ Circle(double r) : radius(r) { };
+ virtual double area();
+ virtual double perimeter();
+};
+
+class Square : public Shape {
+private:
+ double width;
+public:
+ Square(double w) : width(w) { };
+ virtual double area();
+ virtual double perimeter();
+};
+</pre>
+</blockquote>
+
+<h2>The SWIG interface</h2>
+
+A simple SWIG interface for this can be built by simply grabbing the header file
+like this:
+
+<blockquote>
+<pre>
+/* File : example.i */
+%module example
+
+%{
+#include "example.h"
+%}
+
+/* Let's just grab the original header file here */
+%include "example.h"
+</pre>
+</blockquote>
+
+Note: when creating a C++ extension, you must run SWIG with the <tt>-c++</tt> option like this:
+<blockquote>
+<pre>
+% swig -c++ -java example.i
+</pre>
+</blockquote>
+
+<h2>A sample Java script</h2>
+
+Click <a href="main.java">here</a> to see a script that calls the C++ functions from Java.
+
+<h2>Key points</h2>
+
+<ul>
+<li>To create a new object, you call a constructor like this:
+
+<blockquote>
+<pre>
+Circle c = new Circle(10);
+</pre>
+</blockquote>
+
+<p>
+<li>To access member data, a pair of accessor functions are used.
+For example:
+
+<blockquote>
+<pre>
+c.setX(15); // Set member data
+x = c.getX(); // Get member data
+</pre>
+</blockquote>
+
+<p>
+<li>To invoke a member function, you simply do this
+
+<blockquote>
+<pre>
+System.out.println( "The area is " + c.area() );
+</pre>
+</blockquote>
+
+<p>
+<li>To invoke a destructor, simply do this
+
+<blockquote>
+<pre>
+c._delete(); // Deletes a shape
+</pre>
+</blockquote>
+
+<p>
+<li>Static member variables are wrapped with java static get and set access functions. For example:
+
+<blockquote>
+<pre>
+n = Shape.getNshapes(); // Get a static data member
+Shape.setNshapes(13); // Set a static data member
+</pre>
+</blockquote>
+
+</ul>
+
+<h2>General Comments</h2>
+
+<ul>
+<li>This high-level interface using shadow classes is not the only way to handle C++ code.
+A low level interface using c functions to access member variables and member functions is the alternative SWIG
+approach. This entails passing around the c pointer or c++ 'this' pointer and as such it is not difficult to crash the JVM.
+The abstraction of the underlying pointer by the java shadow classes far better fits the java programming paradigm.
+
+<p>
+<li>SWIG *does* know how to properly perform upcasting of objects in an inheritance
+hierarchy (including multiple inheritance). However Java classes can only derive from one base class so multiple inheritance
+is not implemented. Java classes can implement more than one interface so there is scope for improvement in the future.
+
+<p>
+<li>A wide variety of C++ features are not currently supported by SWIG. Here is the
+short and incomplete list:
+
+<p>
+<ul>
+<li>Overloaded methods and functions. SWIG wrappers don't know how to resolve name
+conflicts so you must give an alternative name to any overloaded method name using the
+%name directive like this:
+
+<blockquote>
+<pre>
+void foo(int a);
+%name(foo2) void foo(double a, double b);
+</pre>
+</blockquote>
+
+<p>
+<li>Overloaded operators. Not supported at all. The only workaround for this is
+to write a helper function. For example:
+
+<blockquote>
+<pre>
+%inline %{
+ Vector *vector_add(Vector *a, Vector *b) {
+ ... whatever ...
+ }
+%}
+</pre>
+</blockquote>
+
+<p>
+<li>Namespaces. Not supported at all. Won't be supported until SWIG2.0 (if at all).
+
+<p>
+<li>Templates. Not supported at all. SWIG throws out anything that looks like a template.
+You can work around the problem by aliasing a template class behind a typedef however.
+For example:
+
+<blockquote>
+<pre>
+%{
+typedef vector<int> IntVector;
+%}
+
+class IntVector {
+public:
+ ... methods ...
+};
+</pre>
+</blockquote>
+</ul>
+<p>
+<li>There is no guarantee that an extremely complex C++ application will be able to compile
+as a Java extension. Sorry.
+
+<p>
+
+</ul>
+
+<hr>
+</body>
+</html>
diff --git a/SWIG/Examples/java/class/main.java b/SWIG/Examples/java/class/main.java
new file mode 100644
index 000000000..77103f389
--- /dev/null
+++ b/SWIG/Examples/java/class/main.java
@@ -0,0 +1,76 @@
+// file: main.java
+
+// This file illustrates the high level C++ interface
+// created by SWIG. The java class gets mapped onto the c++ class
+// and behaves as if it is a java class.
+
+import example;
+
+public class main {
+ static {
+ try {
+ System.loadLibrary("example");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Cannot load the example native code.\nMake sure your LD_LIBRARY_PATH contains \'.\'\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[])
+ {
+ // ----- Object creation -----
+
+ System.out.println( "Creating some objects:" );
+ Circle c = new Circle(10);
+ System.out.println( " Created circle " + c );
+ Square s = new Square(10);
+ System.out.println( " Created square " + s );
+
+ // ----- Access a static member -----
+
+ System.out.println( "\n----- Static member variables broken. Using a global variable instead -----" );
+ System.out.println( "\nA total of " + example.get_nshapes() + " shapes were created" );
+
+ // ----- Member data access -----
+
+ // Notice how we can do this using functions specific to
+ // the 'Circle' class.
+ c.setX(20);
+ c.setY(30);
+
+ // Now use the same functions in the base class
+ Shape shape = s;
+ shape.setX(-10);
+ shape.setY(5);
+
+ System.out.println( "\nHere is their current position:" );
+ System.out.println( " Circle = (" + c.getX() + " " + c.getY() + ")" );
+ System.out.println( " Square = (" + s.getX() + " " + s.getY() + ")" );
+
+ // ----- Call some methods -----
+
+ System.out.println( "\nHere are some properties of the shapes:" );
+ Shape[] shapes = {c,s};
+ for (int i=0; i<shapes.length; i++)
+ {
+ System.out.println( " " + shapes[i].toString() );
+ System.out.println( " area = " + shapes[i].area() );
+ System.out.println( " perimeter = " + shapes[i].perimeter() );
+ }
+
+ // Notice how the area() and perimeter() functions really
+ // invoke the appropriate virtual method on each object.
+
+ // ----- Delete everything -----
+
+ System.out.println( "\nGuess I'll clean up now" );
+
+ // Note: this invokes the virtual destructor
+ // You could leave this to the garbage collector
+ c._delete();
+ s._delete();
+
+ System.out.println( example.get_nshapes() + " shapes remain" );
+ System.out.println( "Goodbye" );
+ }
+}
diff --git a/SWIG/Examples/java/constants/.cvsignore b/SWIG/Examples/java/constants/.cvsignore
new file mode 100644
index 000000000..c4072f651
--- /dev/null
+++ b/SWIG/Examples/java/constants/.cvsignore
@@ -0,0 +1,3 @@
+*.java
+*.class
+example_wrap.c
diff --git a/SWIG/Examples/java/constants/Makefile b/SWIG/Examples/java/constants/Makefile
new file mode 100644
index 000000000..0a5478cd5
--- /dev/null
+++ b/SWIG/Examples/java/constants/Makefile
@@ -0,0 +1,20 @@
+TOP = ../..
+SWIG = $(TOP)/../swig
+SRCS =
+TARGET = libexample
+INTERFACE = example.i
+SWIGOPT = -shadow
+
+all:: java
+
+java::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp
+ javac *.java
+
+clean::
+ mv main.java main.java.tmp
+ rm -f *_wrap* *.o core *~ *.so *.class *.java
+ mv main.java.tmp main.java
+
+check: all
diff --git a/SWIG/Examples/java/constants/example.i b/SWIG/Examples/java/constants/example.i
new file mode 100644
index 000000000..29a1a7f11
--- /dev/null
+++ b/SWIG/Examples/java/constants/example.i
@@ -0,0 +1,26 @@
+/* File : example.i */
+%module example
+
+/* A few preprocessor macros */
+
+#define ICONST 42
+#define FCONST 2.1828
+#define CCONST 'x'
+#define CCONST2 '\n'
+#define SCONST "Hello World"
+#define SCONST2 "\"Hello World\""
+
+/* This should work just fine */
+#define EXPR ICONST + 3*(FCONST)
+
+/* This shouldn't do anything */
+#define EXTERN extern
+
+/* Neither should this (BAR isn't defined) */
+#define FOO (ICONST + BAR)
+
+/* The following statements also produce constants */
+const int iconst = 37;
+const double fconst = 3.14;
+
+
diff --git a/SWIG/Examples/java/constants/index.html b/SWIG/Examples/java/constants/index.html
new file mode 100644
index 000000000..390acc649
--- /dev/null
+++ b/SWIG/Examples/java/constants/index.html
@@ -0,0 +1,53 @@
+<html>
+<head>
+<title>SWIG:Examples:java:constants</title>
+</head>
+
+<body bgcolor="#ffffff">
+
+<tt>SWIG/Examples/java/constants/</tt>
+<hr>
+
+<H2>Wrapping C Constants</H2>
+
+<tt>$Header$</tt><br>
+
+<p>
+When SWIG encounters C preprocessor macros and C declarations that look like constants,
+it creates Java constant with an identical value. Click <a href="example.i">here</a>
+to see a SWIG interface with some constant declarations in it.
+
+<h2>Accessing Constants from Java</h2>
+
+Click <a href="main.java">here</a> to see a Java program that prints out the values
+of the constants contained in the above file.
+
+<h2>Key points</h2>
+
+<ul>
+<li>The values of preprocessor macros are converted into Java constants.
+<li>Types are inferred by syntax (e.g., "3" is an integer and "3.5" is a float).
+<li>Character constants such as 'x' are converted into Java strings.
+<li>C string literals such as "Hello World" are converted into Java strings.
+<li>Macros that are not fully defined are simply ignored. For example:
+<blockquote>
+<pre>
+#define EXTERN extern
+</pre>
+</blockquote>
+is ignored because SWIG has no idea what type of variable this would be.
+
+<p>
+<li>Expressions are allowed provided that all of their components are defined. Otherwise, the constant is ignored.
+
+<li>Certain C declarations involving 'const' are also turned into Java constants.
+<li>The constants that appear in a SWIG interface file do not have to appear in any sort
+of matching C source file since the creation of a constant does not require linkage
+to a stored value (i.e., a value held in a C global variable or memory location).
+</ul>
+
+<hr>
+
+
+</body>
+</html>
diff --git a/SWIG/Examples/java/constants/main.java b/SWIG/Examples/java/constants/main.java
new file mode 100644
index 000000000..af793f4a7
--- /dev/null
+++ b/SWIG/Examples/java/constants/main.java
@@ -0,0 +1,45 @@
+import example;
+import java.lang.reflect.*;
+
+public class main {
+ static {
+ try {
+ System.loadLibrary("example");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Cannot load the example native code.\nMake sure your LD_LIBRARY_PATH contains \'.\'\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[])
+ {
+ System.out.println("ICONST = " + example.ICONST + " (should be 42)");
+ System.out.println("FCONST = " + example.FCONST + " (should be 2.1828)");
+ System.out.println("CCONST = " + example.CCONST + " (should be 'x')");
+ System.out.println("CCONST2 = " + example.CCONST2 + " (this should be on a new line)");
+ System.out.println("SCONST = " + example.SCONST + " (should be 'Hello World')");
+ System.out.println("SCONST2 = " + example.SCONST2 + " (should be '\"Hello World\"')");
+ System.out.println("EXPR = " + example.EXPR + " (should be 48.5484)");
+ System.out.println("iconst = " + example.iconst + " (should be 37)");
+ System.out.println("fconst = " + example.fconst + " (should be 3.14)");
+
+// Use reflection to check if these variables are defined:
+ try
+ {
+ System.out.println("EXTERN = " + example.class.getField("EXTERN") + " (Arg! This shouldn't print anything)");
+ }
+ catch (NoSuchFieldException e)
+ {
+ System.out.println("EXTERN isn't defined (good)");
+ }
+
+ try
+ {
+ System.out.println("FOO = " + example.class.getField("FOO") + " (Arg! This shouldn't print anything)");
+ }
+ catch (NoSuchFieldException e)
+ {
+ System.out.println("FOO isn't defined (good)");
+ }
+ }
+}
diff --git a/SWIG/Examples/java/enum/.cvsignore b/SWIG/Examples/java/enum/.cvsignore
new file mode 100644
index 000000000..c4072f651
--- /dev/null
+++ b/SWIG/Examples/java/enum/.cvsignore
@@ -0,0 +1,3 @@
+*.java
+*.class
+example_wrap.c
diff --git a/SWIG/Examples/java/enum/Makefile b/SWIG/Examples/java/enum/Makefile
new file mode 100644
index 000000000..554974fc3
--- /dev/null
+++ b/SWIG/Examples/java/enum/Makefile
@@ -0,0 +1,20 @@
+TOP = ../..
+SWIG = $(TOP)/../swig
+SRCS = example.cxx
+TARGET = libexample
+INTERFACE = example.i
+SWIGOPT = -shadow
+
+all:: java
+
+java::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp
+ javac *.java
+
+clean::
+ mv main.java main.java.tmp
+ rm -f *_wrap* *.o core *~ *.so *.class *.java
+ mv main.java.tmp main.java
+
+check: all
diff --git a/SWIG/Examples/java/enum/example.cxx b/SWIG/Examples/java/enum/example.cxx
new file mode 100644
index 000000000..df7bb6328
--- /dev/null
+++ b/SWIG/Examples/java/enum/example.cxx
@@ -0,0 +1,37 @@
+/* File : example.cxx */
+
+#include "example.h"
+#include <stdio.h>
+
+void Foo::enum_test(speed s) {
+ if (s == IMPULSE) {
+ printf("IMPULSE speed\n");
+ } else if (s == WARP) {
+ printf("WARP speed\n");
+ } else if (s == LUDICROUS) {
+ printf("LUDICROUS speed\n");
+ } else {
+ printf("Unknown speed\n");
+ }
+}
+
+void enum_test(color c, Foo::speed s) {
+ if (c == RED) {
+ printf("color = RED, ");
+ } else if (c == BLUE) {
+ printf("color = BLUE, ");
+ } else if (c == GREEN) {
+ printf("color = GREEN, ");
+ } else {
+ printf("color = Unknown color!, ");
+ }
+ if (s == Foo::IMPULSE) {
+ printf("speed = IMPULSE speed\n");
+ } else if (s == Foo::WARP) {
+ printf("speed = WARP speed\n");
+ } else if (s == Foo::LUDICROUS) {
+ printf("speed = LUDICROUS speed\n");
+ } else {
+ printf("speed = Unknown speed!\n");
+ }
+}
diff --git a/SWIG/Examples/java/enum/example.h b/SWIG/Examples/java/enum/example.h
new file mode 100644
index 000000000..525d62afc
--- /dev/null
+++ b/SWIG/Examples/java/enum/example.h
@@ -0,0 +1,13 @@
+/* File : example.h */
+
+enum color { RED, BLUE, GREEN };
+
+class Foo {
+ public:
+ Foo() { }
+ enum speed { IMPULSE, WARP, LUDICROUS };
+ void enum_test(speed s);
+};
+
+void enum_test(color c, Foo::speed s);
+
diff --git a/SWIG/Examples/java/enum/example.i b/SWIG/Examples/java/enum/example.i
new file mode 100644
index 000000000..4c873824c
--- /dev/null
+++ b/SWIG/Examples/java/enum/example.i
@@ -0,0 +1,13 @@
+/* File : example.i */
+%module example
+
+%{
+#include "example.h"
+%}
+
+%pragma make_default
+
+/* Let's just grab the original header file here */
+
+%include "example.h"
+
diff --git a/SWIG/Examples/java/enum/index.html b/SWIG/Examples/java/enum/index.html
new file mode 100644
index 000000000..cd81244e3
--- /dev/null
+++ b/SWIG/Examples/java/enum/index.html
@@ -0,0 +1,37 @@
+<html>
+<head>
+<title>SWIG:Examples:java:enum</title>
+</head>
+
+<body bgcolor="#ffffff">
+
+
+<tt>SWIG/Examples/java/enum/</tt>
+<hr>
+
+<H2>Wrapping enumerations</H2>
+
+<tt>$Header$</tt><br>
+
+<p>
+This example tests SWIG's ability to wrap enumerations. By default, SWIG
+converts enumeration specifications into integer constants. Further use
+of enumerated types are handled as integers.
+
+<ul>
+<li><a href="example.h">example.h</a>. Header file containing some enums.
+<li><a href="example.i">example.i</a>. Interface file.
+<li><a href="main.java">main.java</a>. Sample Java program.
+</ul>
+
+<h2>Notes</h2>
+
+<ul>
+<li>SWIG allows arbitrary integers to be passed as enum values. However,
+the result of passing an integer not corresponding to any of the values
+specified in the <tt>enum</tt> specification is undefined.
+</ul>
+
+<hr>
+</body>
+</html>
diff --git a/SWIG/Examples/java/enum/main.java b/SWIG/Examples/java/enum/main.java
new file mode 100644
index 000000000..aa7e54238
--- /dev/null
+++ b/SWIG/Examples/java/enum/main.java
@@ -0,0 +1,40 @@
+import example;
+
+public class main {
+ static {
+ try {
+ System.loadLibrary("example");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Cannot load the example native code.\nMake sure your LD_LIBRARY_PATH contains \'.\'\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[])
+ {
+ // Print out the value of some enums
+ System.out.println("*** color ***");
+ System.out.println(" RED = " + example.RED);
+ System.out.println(" BLUE = " + example.BLUE);
+ System.out.println(" GREEN = " + example.GREEN);
+
+ System.out.println("\n*** Foo::speed ***");
+ System.out.println(" Foo::IMPULSE = " + Foo.IMPULSE);
+ System.out.println(" Foo::WARP = " + Foo.WARP);
+ System.out.println(" Foo::LUDICROUS = " + Foo.LUDICROUS);
+
+ System.out.println("\nTesting use of enums with functions\n");
+
+ example.enum_test(example.RED, Foo.IMPULSE);
+ example.enum_test(example.BLUE, Foo.WARP);
+ example.enum_test(example.GREEN, Foo.LUDICROUS);
+ example.enum_test(1234,5678);
+
+ System.out.println( "\nTesting use of enum with class method" );
+ Foo f = new Foo();
+
+ f.enum_test(Foo.IMPULSE);
+ f.enum_test(Foo.WARP);
+ f.enum_test(Foo.LUDICROUS);
+ }
+}
diff --git a/SWIG/Examples/java/index.html b/SWIG/Examples/java/index.html
new file mode 100644
index 000000000..a084367e9
--- /dev/null
+++ b/SWIG/Examples/java/index.html
@@ -0,0 +1,64 @@
+<html>
+<head>
+<title>SWIG:Examples:java</title>
+</head>
+
+<body bgcolor="#ffffff">
+<H1>SWIG Java Examples</H1>
+
+<tt>$Header$</tt><br>
+
+<p>
+The following examples illustrate the use of SWIG with Java.
+
+<ul>
+<li><a href="simple/index.html">simple</a>. A minimal example showing how SWIG can
+be used to wrap a C function, a global variable, and a constant.
+<li><a href="native/index.html">native</a>. Comparing the manual and the SWIG approach to calling native code.
+<li><a href="typemap/index.html">typemap</a>. Modifying the Java module's default behaviour by using typemaps.
+<li><a href="constants/index.html">constants</a>. This shows how preprocessor macros and
+certain C declarations are turned into constants.
+<li><a href="enum/index.html">enum</a>. Wrapping enumerations.
+<li><a href="class/index.html">class</a>. How to wrap a simple C++ class.
+<li><a href="reference/index.html">reference</a>. C++ references.
+</ul>
+
+<h2>Running the examples</h2>
+Most of the examples work by making the Makefile before executing the program main.java. The Makefile will output the swig generated JNI c code as well as the java wrapper classes. Additionally the JNI c/c++ code is compiled into the shared object (dynamic link library) which is needed for dynamic linking to the native code. The Makefiles also compile the java files using javac.
+<p>
+Ensure that the dynamic link library file is in the appropriate path before executing the java program. For example in unix, libexample.so must be in the LD_LIBRARY_PATH.
+<p>
+An example:
+<blockquote>
+<pre>
+$ make
+$ export LD_LIBRARY_PATH=. #ksh
+$ java main
+</pre>
+</blockquote>
+<p>
+
+</ul>
+
+<h2>Compatibility</h2>
+
+The examples have been extensively tested on the following platforms:
+
+<ul>
+<li>Solaris
+</ul>
+
+All of the examples were last tested with the following configuration (28 May 2001):
+
+<ul>
+<li>Sparc Solaris 2.6.
+<li>gcc-2.95.2
+<li>Java jdk1.2.1
+</ul>
+
+Your mileage may vary. If you experience a problem, please let us know by
+sending a message to <a href="mailto:swig-dev@cs.uchicago.edu">swig-dev@cs.uchicago.edu</a>.
+</body>
+</html>
+
+
diff --git a/SWIG/Examples/java/native/.cvsignore b/SWIG/Examples/java/native/.cvsignore
new file mode 100644
index 000000000..e5527722d
--- /dev/null
+++ b/SWIG/Examples/java/native/.cvsignore
@@ -0,0 +1,4 @@
+*.class
+*.java
+example_wrap.c
+
diff --git a/SWIG/Examples/java/native/Makefile b/SWIG/Examples/java/native/Makefile
index 1bd5ddd3a..facac6e35 100644
--- a/SWIG/Examples/java/native/Makefile
+++ b/SWIG/Examples/java/native/Makefile
@@ -1,15 +1,16 @@
TOP = ../..
SWIG = $(TOP)/../swig
-SWIGOPT =
SRCS =
TARGET = libexample
INTERFACE = example.i
+SWIGOPT =
all:: java
java::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java
+ javac *.java
clean::
rm -f *_wrap* example.java *.class *.o *~ .~* core *.so *.sl so_locations
diff --git a/SWIG/Examples/java/native/README b/SWIG/Examples/java/native/README
deleted file mode 100644
index 2b5bbcdb4..000000000
--- a/SWIG/Examples/java/native/README
+++ /dev/null
@@ -1,6 +0,0 @@
-type:
-make
-javac *.java
-export LD_LIBRARY_PATH=. # sh
-setenv LD_LIBRARY_PATH . # csh
-java main
diff --git a/SWIG/Examples/java/native/example.i b/SWIG/Examples/java/native/example.i
index 331a2265b..dcbe149fa 100644
--- a/SWIG/Examples/java/native/example.i
+++ b/SWIG/Examples/java/native/example.i
@@ -20,11 +20,11 @@ Point *point_create(int x, int y) {
/* this function will be wrapped by jswig */
char *point_toString1(Point *p) {
- char buf[80];
+ static char buf[80];
sprintf(buf, "(%d,%d)", p->x, p->y);
- return strdup(buf); /* memory leak */
+ return buf;
}
/* this one we wrapped manually*/
@@ -45,10 +45,8 @@ JNIEXPORT jstring JNICALL Java_example_point_1toString2(JNIEnv *jenv, jclass jcl
Point *point_create(int x, int y);
char *point_toString1(Point *p);
-/*
- Use %new to free the memory returned by point_toString1
- %new char *point_toString1(Point *p);
-*/
+/* give access to free() for memory cleanup of the malloc'd Point */
+extern void free(void *memblock);
%native(point_toString2) char *point_toString2(Point *p);
diff --git a/SWIG/Examples/java/native/index.html b/SWIG/Examples/java/native/index.html
new file mode 100644
index 000000000..1942d7440
--- /dev/null
+++ b/SWIG/Examples/java/native/index.html
@@ -0,0 +1,33 @@
+<html>
+<head>
+<title>SWIG:Examples:java:native</title>
+</head>
+
+<body bgcolor="#ffffff">
+
+
+<tt>SWIG/Examples/java/native/</tt>
+<hr>
+
+<H2>SWIG wrapped and manually wrapped functions in Java</H2>
+
+<tt>$Header$</tt><br>
+
+<p>
+This example compares wrapping a c global function using the manual way and the SWIG way.
+
+<ul>
+<li><a href="example.i">example.i</a>. Interface file comparing code wrapped by SWIG and wrapped manually.
+<li><a href="main.java">main.java</a>. Sample Java program showing calls to both manually wrapped and SWIG wrapped c functions.
+</ul>
+
+<h2>Notes</h2>
+
+<ul>
+<li>SWIG writes all the awkward JNI code for you. You just have to tell SWIG which functions to wrap.
+<li>If memory is allocated in c it needs to be free'd. A function, such as free(), can be provided with access from Java to free the memory.
+</ul>
+
+<hr>
+</body>
+</html>
diff --git a/SWIG/Examples/java/native/main.java b/SWIG/Examples/java/native/main.java
index 444d53b58..78448f177 100644
--- a/SWIG/Examples/java/native/main.java
+++ b/SWIG/Examples/java/native/main.java
@@ -15,5 +15,6 @@ public class main {
long p = example.point_create(1, 2);
System.out.println("auto wrapped : " + example.point_toString1(p));
System.out.println("manual wrapped: " + example.point_toString2(p));
+ example.free(p); //clean up c allocated memory
}
}
diff --git a/SWIG/Examples/java/reference/.cvsignore b/SWIG/Examples/java/reference/.cvsignore
new file mode 100644
index 000000000..c4072f651
--- /dev/null
+++ b/SWIG/Examples/java/reference/.cvsignore
@@ -0,0 +1,3 @@
+*.java
+*.class
+example_wrap.c
diff --git a/SWIG/Examples/java/reference/Makefile b/SWIG/Examples/java/reference/Makefile
new file mode 100644
index 000000000..554974fc3
--- /dev/null
+++ b/SWIG/Examples/java/reference/Makefile
@@ -0,0 +1,20 @@
+TOP = ../..
+SWIG = $(TOP)/../swig
+SRCS = example.cxx
+TARGET = libexample
+INTERFACE = example.i
+SWIGOPT = -shadow
+
+all:: java
+
+java::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp
+ javac *.java
+
+clean::
+ mv main.java main.java.tmp
+ rm -f *_wrap* *.o core *~ *.so *.class *.java
+ mv main.java.tmp main.java
+
+check: all
diff --git a/SWIG/Examples/java/reference/example.cxx b/SWIG/Examples/java/reference/example.cxx
new file mode 100644
index 000000000..384e40bb7
--- /dev/null
+++ b/SWIG/Examples/java/reference/example.cxx
@@ -0,0 +1,41 @@
+/* File : example.cxx */
+
+#include "example.h"
+#include <stdio.h>
+#include <stdlib.h>
+
+Vector operator+(const Vector &a, const Vector &b) {
+ Vector r;
+ r.x = a.x + b.x;
+ r.y = a.y + b.y;
+ r.z = a.z + b.z;
+ return r;
+}
+
+char *Vector::print() {
+ static char temp[512];
+ sprintf(temp,"Vector %x (%g,%g,%g)", this, x,y,z);
+ return temp;
+}
+
+VectorArray::VectorArray(int size) {
+ items = new Vector[size];
+ maxsize = size;
+}
+
+VectorArray::~VectorArray() {
+ delete [] items;
+}
+
+Vector &VectorArray::operator[](int index) {
+ if ((index < 0) || (index >= maxsize)) {
+ printf("Panic! Array index out of bounds.\n");
+ exit(1);
+ }
+ return items[index];
+}
+
+int VectorArray::size() {
+ return maxsize;
+}
+
diff --git a/SWIG/Examples/java/reference/example.h b/SWIG/Examples/java/reference/example.h
new file mode 100644
index 000000000..4915adb1b
--- /dev/null
+++ b/SWIG/Examples/java/reference/example.h
@@ -0,0 +1,26 @@
+/* File : example.h */
+
+class Vector {
+private:
+ double x,y,z;
+public:
+ Vector() : x(0), y(0), z(0) { };
+ Vector(double x, double y, double z) : x(x), y(y), z(z) { };
+ friend Vector operator+(const Vector &a, const Vector &b);
+ char *print();
+};
+
+class VectorArray {
+private:
+ Vector *items;
+ int maxsize;
+public:
+ VectorArray(int maxsize);
+ ~VectorArray();
+ Vector &operator[](int);
+ int size();
+};
+
+
+
+
diff --git a/SWIG/Examples/java/reference/example.i b/SWIG/Examples/java/reference/example.i
new file mode 100644
index 000000000..8538326f6
--- /dev/null
+++ b/SWIG/Examples/java/reference/example.i
@@ -0,0 +1,46 @@
+/* File : example.i */
+
+/* This file has a few "typical" uses of C++ references. */
+
+%module example
+
+%{
+#include "example.h"
+%}
+
+class Vector {
+public:
+ Vector(double x, double y, double z);
+ ~Vector();
+ char *print();
+};
+
+/* This helper function calls an overloaded operator */
+%inline %{
+Vector addv(Vector &a, Vector &b) {
+ return a+b;
+}
+%}
+
+/* Wrapper around an array of vectors class */
+
+class VectorArray {
+public:
+ VectorArray(int maxsize);
+ ~VectorArray();
+ int size();
+
+ /* This wrapper provides an alternative to the [] operator */
+ %addmethods {
+ Vector &get(int index) {
+ return (*self)[index];
+ }
+ void set(int index, Vector &a) {
+ (*self)[index] = a;
+ }
+ }
+};
+
+
+
+
diff --git a/SWIG/Examples/java/reference/index.html b/SWIG/Examples/java/reference/index.html
new file mode 100644
index 000000000..2e35ba250
--- /dev/null
+++ b/SWIG/Examples/java/reference/index.html
@@ -0,0 +1,149 @@
+<html>
+<head>
+<title>SWIG:Examples:java:reference</title>
+</head>
+
+<body bgcolor="#ffffff">
+
+
+<tt>SWIG/Examples/java/reference/</tt>
+<hr>
+
+<H2>C++ Reference Handling</H2>
+
+<tt>$Header$</tt><br>
+
+<p>
+This example tests SWIG's handling of C++ references. Since C++
+references are closely related to pointers (as both refer to a
+location in memory), SWIG simply collapses all references into
+pointers when creating wrappers.
+
+<h2>Some examples</h2>
+
+References are most commonly used as function parameter. For example,
+you might have an operator like this:
+
+<blockquote>
+<pre>
+Vector operator+(const Vector &a, const Vector &b) {
+ Vector result;
+ result.x = a.x + b.x;
+ result.y = a.y + b.y;
+ result.z = a.z + b.z;
+ return result;
+}
+</pre>
+</blockquote>
+
+or a function:
+
+<blockquote>
+<pre>
+Vector addv(const Vector &a, const Vector &b) {
+ Vector result;
+ result.x = a.x + b.x;
+ result.y = a.y + b.y;
+ result.z = a.z + b.z;
+ return result;
+}
+</pre>
+</blockquote>
+
+In these cases, SWIG transforms everything into a pointer and creates a wrapper
+that looks like this:
+
+<blockquote>
+<pre>
+Vector wrap_addv(Vector *a, Vector *b) {
+ return addv(*a,*b);
+}
+</pre>
+</blockquote>
+
+Occasionally, a reference is used as a return value of a function
+when the return result is to be used as an lvalue in an expression.
+The prototypical example is an operator like this:
+
+<blockquote>
+<pre>
+Vector &operator[](int index);
+</pre>
+</blockquote>
+
+or a method:
+
+<blockquote>
+<pre>
+Vector &get(int index);
+</pre>
+</blockquote>
+
+For functions returning references, a wrapper like this is created:
+
+<blockquote>
+<pre>
+Vector *wrap_Object_get(Object *self, int index) {
+ Vector &result = self->get(index);
+ return &result;
+}
+</pre>
+</blockquote>
+
+The following <a href="example.h">header file</a> contains some class
+definitions with some operators and use of references.
+
+<h2>SWIG Interface</h2>
+
+SWIG does NOT support overloaded operators so it can not directly build
+an interface to the classes in the above file. However, a number of workarounds
+can be made. For example, an overloaded operator can be stuck behind a function
+call such as the <tt>addv()</tt> function above. Array access can be handled
+with a pair of set/get functions like this:
+
+<blockquote>
+<pre>
+class VectorArray {
+public:
+ ...
+ %addmethods {
+ Vector &get(int index) {
+ return (*self)[index];
+ }
+ void set(int index, Vector &a) {
+ (*self)[index] = a;
+ }
+ }
+ ...
+}
+</pre>
+</blockquote>
+
+Click <a href="example.i">here</a> to see a SWIG interface file with these additions.
+
+<h2>Sample Java script</h2>
+
+Click <a href="main.java">here</a> to see a script that manipulates some C++ references.
+
+<h2>Notes:</h2>
+
+<ul>
+<li>C++ references primarily provide notational convenience for C++
+source code. However, Java only supports the 'x.a'
+notation so it doesn't much matter.
+
+<p>
+<li>When a program returns a reference, a pointer is returned.
+Unlike return by value, memory is not allocated to hold the
+return result.
+
+<p>
+<li>SWIG has particular trouble handling various combinations of references
+and pointers. This is side effect of an old parsing scheme and
+type representation that will be replaced in future versions.
+
+</ul>
+
+<hr>
+</body>
+</html>
diff --git a/SWIG/Examples/java/reference/main.java b/SWIG/Examples/java/reference/main.java
new file mode 100644
index 000000000..6eca4a775
--- /dev/null
+++ b/SWIG/Examples/java/reference/main.java
@@ -0,0 +1,91 @@
+// file: main.java
+
+// This file illustrates the manipulation of C++ references in Java.
+
+import example;
+
+public class main {
+ static {
+ try {
+ System.loadLibrary("example");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Cannot load the example native code.\nMake sure your LD_LIBRARY_PATH contains \'.\'\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[])
+ {
+ System.out.println( "Creating some objects:" );
+ Vector a = new Vector(3,4,5);
+ Vector b = new Vector(10,11,12);
+
+ System.out.println( " Created " + a.print() );
+ System.out.println( " Created " + b.print() );
+
+ // ----- Call an overloaded operator -----
+
+ // This calls the wrapper we placed around
+ //
+ // operator+(const Vector &a, const Vector &)
+ //
+ // It returns a new allocated object.
+
+ System.out.println( "Adding a+b" );
+ Vector c = new Vector (example.addv(a.getCPtr(),b.getCPtr()), false);
+ System.out.println( " a+b = " + c.print() );
+
+ // Note: Unless we free the result, a memory leak will occur
+ // This is because we used 'false' for cMemoryOwn in the constructor of c.
+ // If we had used 'true', the memory management is best left to the garbage collector.
+ // You can still call _delete(). It will free the c++ memory immediately, but not the
+ // Java memory! You then must be careful not to call any member functions as it will
+ // use a NULL c pointer on the underlying c++ object.
+ c._delete();
+
+ // ----- Create a vector array -----
+
+ // Note: Using the high-level interface here
+ System.out.println( "Creating an array of vectors" );
+ VectorArray va = new VectorArray(10);
+ System.out.println( " va = " + va.toString() );
+
+ // ----- Set some values in the array -----
+
+ // These operators copy the value of Vector a and Vector b to the vector array
+ va.set(0,a);
+ va.set(1,b);
+
+ // This will work, but it will cause a memory leak!
+ // This is the low level way of using Java with SWIG and isn't very readable!
+
+ example.VectorArray_set(va.getCPtr(),2,example.addv(a.getCPtr(),b.getCPtr()));
+
+ // The non-leaky way to do it. This is the high level way of using Java with SWIG.
+ // This relies on the garbage collector for freeing memory
+ // An even better way would have been possible if addv was a static function in the
+ // c++ class. The code would then instead be:
+ // c = Vector.addv(a,b);
+
+ c = new Vector(example.addv(a.getCPtr(),b.getCPtr()), true);
+ va.set(3,c);
+
+ // Get some values from the array
+
+ System.out.println( "Getting some array values" );
+ for (int i=0; i<5; i++)
+ System.out.println( " va(" + i + ") = " + va.get(i).print() );
+
+ // Watch under resource meter to check on this
+ System.out.println( "Making sure we don't leak memory." );
+ for (int i=0; i<1000000; i++)
+ c = va.get(i%10);
+
+ // ----- Clean up -----
+ // This could be omitted. The garbage collector would then clean up for us.
+ System.out.println( "Cleaning up" );
+ va._delete();
+ a._delete();
+ b._delete();
+ }
+}
diff --git a/SWIG/Examples/java/simple/.cvsignore b/SWIG/Examples/java/simple/.cvsignore
new file mode 100644
index 000000000..e5527722d
--- /dev/null
+++ b/SWIG/Examples/java/simple/.cvsignore
@@ -0,0 +1,4 @@
+*.class
+*.java
+example_wrap.c
+
diff --git a/SWIG/Examples/java/simple/Makefile b/SWIG/Examples/java/simple/Makefile
index f55601b9c..5f0944e5a 100644
--- a/SWIG/Examples/java/simple/Makefile
+++ b/SWIG/Examples/java/simple/Makefile
@@ -3,13 +3,14 @@ SWIG = $(TOP)/../swig
SRCS = example.c
TARGET = libexample
INTERFACE = example.i
-SWIGOPT =
+SWIGOPT = -shadow
all:: java
java::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java
+ javac *.java
clean::
rm -f *_wrap* *.o core *~ *.so *.class example.java
diff --git a/SWIG/Examples/java/simple/README b/SWIG/Examples/java/simple/README
deleted file mode 100644
index b52b7d7b0..000000000
--- a/SWIG/Examples/java/simple/README
+++ /dev/null
@@ -1,8 +0,0 @@
-Simple example from users manual.
-
-type:
-make
-javac *.java
-export LD_LIBRARY_PATH=. # sh
-setenv LD_LIBRARY_PATH . # csh
-java main
diff --git a/SWIG/Examples/java/simple/index.html b/SWIG/Examples/java/simple/index.html
new file mode 100644
index 000000000..654e43bda
--- /dev/null
+++ b/SWIG/Examples/java/simple/index.html
@@ -0,0 +1,112 @@
+<html>
+<head>
+<title>SWIG:Examples:java:simple</title>
+</head>
+
+<body bgcolor="#ffffff">
+
+
+<tt>SWIG/Examples/java/simple/</tt>
+<hr>
+
+<H2>Simple Java Example</H2>
+
+<tt>$Header$</tt><br>
+
+<p>
+This example illustrates how you can hook Java to a very simple C program containing
+a function and a global variable.
+
+<h2>The C Code</h2>
+
+Suppose you have the following C code:
+
+<blockquote>
+<pre>
+/* File : example.c */
+
+/* A global variable */
+double Foo = 3.0;
+
+/* Compute the greatest common divisor of positive integers */
+int gcd(int x, int y) {
+ int g;
+ g = y;
+ while (x > 0) {
+ g = x;
+ x = y % x;
+ y = g;
+ }
+ return g;
+}
+</pre>
+</blockquote>
+
+<h2>The SWIG interface</h2>
+
+Here is a simple SWIG interface file:
+
+<blockquote>
+<pre>
+/* File: example.i */
+%module example
+
+extern int gcd(int x, int y);
+extern double Foo;
+</pre>
+</blockquote>
+
+<h2>Compilation</h2>
+
+<ol>
+<li><tt>swig -java <a href="example.i">example.i</a></tt>
+<p>
+<li>Compile <tt><a href="example_wrap.c">example_wrap.c</a></tt> and <tt><a href="example.c">example.c</a></tt>
+to create the extension <tt>libexample.so (unix)</tt>.
+</ol>
+
+<h2>Using the extension</h2>
+
+Click <a href="main.java">here</a> to see a program that calls our C functions from Java.
+<p>
+Compile the java files <tt><a href="example.java">example.java</a></tt> and <tt><a href="main.java">main.java</a></tt>
+to create the class files example.class and main.class before running main in the JVM. Ensure that the libexample.so file is in your LD_LIBRARY_PATH before running. For example:
+<blockquote>
+<pre>
+export LD_LIBRARY_PATH=. #ksh
+javac *.java
+java main
+</pre>
+</blockquote>
+
+<h2>Key points</h2>
+
+<ul>
+<li>Use the <tt>import</tt> and <tt>import</tt> statements from java to load and access the generated java classes. For example:
+<blockquote>
+<pre>
+import example;
+
+System.loadLibrary("example");
+</pre>
+</blockquote>
+
+<li>C functions work just like Java functions. For example:
+<blockquote>
+<pre>
+int g = example.gcd(42,105);
+</pre>
+</blockquote>
+
+<li>C global variables are accessed through get and set functions in the module class. For example:
+<blockquote>
+<pre>
+double a = example.get_Foo();
+example.set_Foo(20.0);
+</pre>
+</blockquote>
+</ul>
+
+<hr>
+</body>
+</html>
diff --git a/SWIG/Examples/java/typemap/.cvsignore b/SWIG/Examples/java/typemap/.cvsignore
new file mode 100644
index 000000000..e5527722d
--- /dev/null
+++ b/SWIG/Examples/java/typemap/.cvsignore
@@ -0,0 +1,4 @@
+*.class
+*.java
+example_wrap.c
+
diff --git a/SWIG/Examples/java/typemap/Makefile b/SWIG/Examples/java/typemap/Makefile
index ddba664d9..562acf789 100644
--- a/SWIG/Examples/java/typemap/Makefile
+++ b/SWIG/Examples/java/typemap/Makefile
@@ -10,6 +10,7 @@ all:: java
java::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java
+ javac *.java
clean::
rm -f *_wrap* *.o core *~ *.so *.class example.java
diff --git a/SWIG/Examples/java/typemap/README b/SWIG/Examples/java/typemap/README
deleted file mode 100644
index 67dabbfdc..000000000
--- a/SWIG/Examples/java/typemap/README
+++ /dev/null
@@ -1,8 +0,0 @@
-Example of a typemap to handle return values in char * arguments.
-
-type:
-make
-javac *.java
-export LD_LIBRARY_PATH=. # sh
-setenv LD_LIBRARY_PATH . # csh
-java main
diff --git a/SWIG/Examples/java/typemap/example.i b/SWIG/Examples/java/typemap/example.i
index 46c137431..00921b4cb 100644
--- a/SWIG/Examples/java/typemap/example.i
+++ b/SWIG/Examples/java/typemap/example.i
@@ -18,11 +18,11 @@ void f1(char *s) {
}
void f2(char *s) {
- return f1(s);
+ f1(s);
}
void f3(char *s) {
- return f1(s);
+ f1(s);
}
%}
diff --git a/SWIG/Examples/java/typemap/index.html b/SWIG/Examples/java/typemap/index.html
new file mode 100644
index 000000000..259f42953
--- /dev/null
+++ b/SWIG/Examples/java/typemap/index.html
@@ -0,0 +1,34 @@
+<html>
+<head>
+<title>SWIG:Examples:java:typemap</title>
+</head>
+
+<body bgcolor="#ffffff">
+
+
+<tt>SWIG/Examples/java/typemap/</tt>
+<hr>
+
+<H2>Typemaps in Java</H2>
+
+<tt>$Header$</tt><br>
+
+<p>
+This example shows how typemaps can be used to modify the default behaviour of the Java SWIG module.
+
+<ul>
+<li><a href="example.i">example.i</a>. Interface file.
+<li><a href="main.java">main.java</a>. Sample Java program.
+</ul>
+
+<h2>Notes</h2>
+
+<ul>
+<li>Shows how to pass strings to Java from c and visa versa.
+<li>Typemaps can modify the default behaviour of the Java SWIG module.
+<li>The default c to java mapping can be modified using typemaps.
+</ul>
+
+<hr>
+</body>
+</html>
diff --git a/SWIG/Examples/mzscheme/simple/.cvsignore b/SWIG/Examples/mzscheme/simple/.cvsignore
new file mode 100644
index 000000000..11550eb76
--- /dev/null
+++ b/SWIG/Examples/mzscheme/simple/.cvsignore
@@ -0,0 +1 @@
+example_wrap.c
diff --git a/SWIG/Examples/perl5/class/.cvsignore b/SWIG/Examples/perl5/class/.cvsignore
new file mode 100644
index 000000000..68fb437b3
--- /dev/null
+++ b/SWIG/Examples/perl5/class/.cvsignore
@@ -0,0 +1,2 @@
+example.pm
+example_wrap.c
diff --git a/SWIG/Examples/perl5/constants/.cvsignore b/SWIG/Examples/perl5/constants/.cvsignore
new file mode 100644
index 000000000..68fb437b3
--- /dev/null
+++ b/SWIG/Examples/perl5/constants/.cvsignore
@@ -0,0 +1,2 @@
+example.pm
+example_wrap.c
diff --git a/SWIG/Examples/perl5/funcptr/.cvsignore b/SWIG/Examples/perl5/funcptr/.cvsignore
new file mode 100644
index 000000000..68fb437b3
--- /dev/null
+++ b/SWIG/Examples/perl5/funcptr/.cvsignore
@@ -0,0 +1,2 @@
+example.pm
+example_wrap.c
diff --git a/SWIG/Examples/perl5/pointer-cxx/.cvsignore b/SWIG/Examples/perl5/pointer-cxx/.cvsignore
new file mode 100644
index 000000000..68fb437b3
--- /dev/null
+++ b/SWIG/Examples/perl5/pointer-cxx/.cvsignore
@@ -0,0 +1,2 @@
+example.pm
+example_wrap.c
diff --git a/SWIG/Examples/perl5/pointer-cxx/Makefile b/SWIG/Examples/perl5/pointer-cxx/Makefile
new file mode 100644
index 000000000..3e91dd291
--- /dev/null
+++ b/SWIG/Examples/perl5/pointer-cxx/Makefile
@@ -0,0 +1,18 @@
+TOP = ../..
+SWIG = $(TOP)/../swig
+CXXSRCS = example.c
+TARGET = example
+INTERFACE = example.i
+SWIGOPT =
+all::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5_cpp
+
+static::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_cpp_static
+
+clean::
+ rm -f *_wrap* *.o core *~ *.so *.pm myperl
+
+check: all
diff --git a/SWIG/Examples/perl5/pointer-cxx/README b/SWIG/Examples/perl5/pointer-cxx/README
new file mode 100644
index 000000000..f706c07c1
--- /dev/null
+++ b/SWIG/Examples/perl5/pointer-cxx/README
@@ -0,0 +1,5 @@
+The example in this directory is a copy of the `pointer' example,
+except that it used C++ instead of C.
+
+It is provided here only for the purpose of SWIG's test suite; it did
+not compile in SWIG 1.3a5.
diff --git a/SWIG/Examples/perl5/pointer-cxx/example.c b/SWIG/Examples/perl5/pointer-cxx/example.c
new file mode 100644
index 000000000..b877d9a5b
--- /dev/null
+++ b/SWIG/Examples/perl5/pointer-cxx/example.c
@@ -0,0 +1,16 @@
+/* File : example.c */
+
+void add(int *x, int *y, int *result) {
+ *result = *x + *y;
+}
+
+void sub(int *x, int *y, int *result) {
+ *result = *x - *y;
+}
+
+int divide(int n, int d, int *r) {
+ int q;
+ q = n/d;
+ *r = n - q*d;
+ return q;
+}
diff --git a/SWIG/Examples/perl5/pointer-cxx/example.i b/SWIG/Examples/perl5/pointer-cxx/example.i
new file mode 100644
index 000000000..2ed2b5bbf
--- /dev/null
+++ b/SWIG/Examples/perl5/pointer-cxx/example.i
@@ -0,0 +1,23 @@
+/* File : example.i */
+%module example
+
+/* This example illustrates a couple of different techniques
+ for manipulating C pointers */
+
+/* First we'll use the pointer library */
+extern void add(int *x, int *y, int *result);
+%include pointer.i
+
+/* Next we'll use some typemaps */
+
+%include typemaps.i
+extern void sub(int *INPUT, int *INPUT, int *OUTPUT);
+
+/* Next we'll use typemaps and the %apply directive */
+
+%apply int *OUTPUT { int *r };
+extern int divide(int n, int d, int *r);
+
+
+
+
diff --git a/SWIG/Examples/perl5/pointer-cxx/example.pl b/SWIG/Examples/perl5/pointer-cxx/example.pl
new file mode 100644
index 000000000..dc18144cf
--- /dev/null
+++ b/SWIG/Examples/perl5/pointer-cxx/example.pl
@@ -0,0 +1,42 @@
+# file: example.pl
+
+use example;
+
+# First create some objects using the pointer library.
+print "Testing the pointer library\n";
+$a = example::ptrcreate("int",37);
+$b = example::ptrcreate("int",42);
+$c = example::ptrcreate("int");
+
+print " a = $a\n";
+print " b = $b\n";
+print " c = $c\n";
+
+# Call the add() function with some pointers
+example::add($a,$b,$c);
+
+# Now get the result
+$r = example::ptrvalue($c);
+print " 37 + 42 = $r\n";
+
+# Clean up the pointers
+example::ptrfree($a);
+example::ptrfree($b);
+example::ptrfree($c);
+
+# Now try the typemap library
+# This should be much easier. Now how it is no longer
+# necessary to manufacture pointers.
+
+print "Trying the typemap library\n";
+$r = example::sub(37,42);
+print " 37 - 42 = $r\n";
+
+# Now try the version with multiple return values
+
+print "Testing multiple return values\n";
+($q,$r) = example::divide(42,37);
+print " 42/37 = $q remainder $r\n";
+
+
+
diff --git a/SWIG/Examples/perl5/pointer/.cvsignore b/SWIG/Examples/perl5/pointer/.cvsignore
new file mode 100644
index 000000000..68fb437b3
--- /dev/null
+++ b/SWIG/Examples/perl5/pointer/.cvsignore
@@ -0,0 +1,2 @@
+example.pm
+example_wrap.c
diff --git a/SWIG/Examples/perl5/reference/.cvsignore b/SWIG/Examples/perl5/reference/.cvsignore
new file mode 100644
index 000000000..68fb437b3
--- /dev/null
+++ b/SWIG/Examples/perl5/reference/.cvsignore
@@ -0,0 +1,2 @@
+example.pm
+example_wrap.c
diff --git a/SWIG/Examples/perl5/simple/.cvsignore b/SWIG/Examples/perl5/simple/.cvsignore
new file mode 100644
index 000000000..68fb437b3
--- /dev/null
+++ b/SWIG/Examples/perl5/simple/.cvsignore
@@ -0,0 +1,2 @@
+example.pm
+example_wrap.c
diff --git a/SWIG/Examples/perl5/value/.cvsignore b/SWIG/Examples/perl5/value/.cvsignore
new file mode 100644
index 000000000..68fb437b3
--- /dev/null
+++ b/SWIG/Examples/perl5/value/.cvsignore
@@ -0,0 +1,2 @@
+example.pm
+example_wrap.c
diff --git a/SWIG/Examples/perl5/variables/.cvsignore b/SWIG/Examples/perl5/variables/.cvsignore
new file mode 100644
index 000000000..68fb437b3
--- /dev/null
+++ b/SWIG/Examples/perl5/variables/.cvsignore
@@ -0,0 +1,2 @@
+example.pm
+example_wrap.c
diff --git a/SWIG/Examples/python/class/.cvsignore b/SWIG/Examples/python/class/.cvsignore
new file mode 100644
index 000000000..11550eb76
--- /dev/null
+++ b/SWIG/Examples/python/class/.cvsignore
@@ -0,0 +1 @@
+example_wrap.c
diff --git a/SWIG/Examples/python/constants/.cvsignore b/SWIG/Examples/python/constants/.cvsignore
new file mode 100644
index 000000000..11550eb76
--- /dev/null
+++ b/SWIG/Examples/python/constants/.cvsignore
@@ -0,0 +1 @@
+example_wrap.c
diff --git a/SWIG/Examples/python/enum/.cvsignore b/SWIG/Examples/python/enum/.cvsignore
new file mode 100644
index 000000000..11550eb76
--- /dev/null
+++ b/SWIG/Examples/python/enum/.cvsignore
@@ -0,0 +1 @@
+example_wrap.c
diff --git a/SWIG/Examples/python/funcptr/.cvsignore b/SWIG/Examples/python/funcptr/.cvsignore
new file mode 100644
index 000000000..11550eb76
--- /dev/null
+++ b/SWIG/Examples/python/funcptr/.cvsignore
@@ -0,0 +1 @@
+example_wrap.c
diff --git a/SWIG/Examples/python/pointer/.cvsignore b/SWIG/Examples/python/pointer/.cvsignore
new file mode 100644
index 000000000..11550eb76
--- /dev/null
+++ b/SWIG/Examples/python/pointer/.cvsignore
@@ -0,0 +1 @@
+example_wrap.c
diff --git a/SWIG/Examples/python/reference/.cvsignore b/SWIG/Examples/python/reference/.cvsignore
new file mode 100644
index 000000000..11550eb76
--- /dev/null
+++ b/SWIG/Examples/python/reference/.cvsignore
@@ -0,0 +1 @@
+example_wrap.c
diff --git a/SWIG/Examples/python/shadow/.cvsignore b/SWIG/Examples/python/shadow/.cvsignore
new file mode 100644
index 000000000..5beee967c
--- /dev/null
+++ b/SWIG/Examples/python/shadow/.cvsignore
@@ -0,0 +1,2 @@
+example.py
+example_wrap.c
diff --git a/SWIG/Examples/python/shadow/Makefile b/SWIG/Examples/python/shadow/Makefile
index 908edc992..0e9c1b172 100644
--- a/SWIG/Examples/python/shadow/Makefile
+++ b/SWIG/Examples/python/shadow/Makefile
@@ -1,17 +1,18 @@
TOP = ../..
-SWIG = $(TOP)/../swig -shadow
+SWIG = $(TOP)/../swig
CXXSRCS = example.cxx
TARGET = examplec
INTERFACE = example.i
LIBS = -lm
+SWIGOPT = -shadow
all::
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
- TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp
static::
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
- TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static
+ SWIGOPT='$(SWIGOPT)' TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static
clean::
rm -f *_wrap* *.o *~ *.so mypython *.pyc .~* core
diff --git a/SWIG/Examples/python/simple/.cvsignore b/SWIG/Examples/python/simple/.cvsignore
new file mode 100644
index 000000000..11550eb76
--- /dev/null
+++ b/SWIG/Examples/python/simple/.cvsignore
@@ -0,0 +1 @@
+example_wrap.c
diff --git a/SWIG/Examples/python/value/.cvsignore b/SWIG/Examples/python/value/.cvsignore
new file mode 100644
index 000000000..11550eb76
--- /dev/null
+++ b/SWIG/Examples/python/value/.cvsignore
@@ -0,0 +1 @@
+example_wrap.c
diff --git a/SWIG/Examples/python/variables/.cvsignore b/SWIG/Examples/python/variables/.cvsignore
new file mode 100644
index 000000000..11550eb76
--- /dev/null
+++ b/SWIG/Examples/python/variables/.cvsignore
@@ -0,0 +1 @@
+example_wrap.c
diff --git a/SWIG/Examples/ruby/class/.cvsignore b/SWIG/Examples/ruby/class/.cvsignore
new file mode 100644
index 000000000..11550eb76
--- /dev/null
+++ b/SWIG/Examples/ruby/class/.cvsignore
@@ -0,0 +1 @@
+example_wrap.c
diff --git a/SWIG/Examples/ruby/constants/.cvsignore b/SWIG/Examples/ruby/constants/.cvsignore
new file mode 100644
index 000000000..11550eb76
--- /dev/null
+++ b/SWIG/Examples/ruby/constants/.cvsignore
@@ -0,0 +1 @@
+example_wrap.c
diff --git a/SWIG/Examples/ruby/enum/.cvsignore b/SWIG/Examples/ruby/enum/.cvsignore
new file mode 100644
index 000000000..11550eb76
--- /dev/null
+++ b/SWIG/Examples/ruby/enum/.cvsignore
@@ -0,0 +1 @@
+example_wrap.c
diff --git a/SWIG/Examples/ruby/funcptr/.cvsignore b/SWIG/Examples/ruby/funcptr/.cvsignore
new file mode 100644
index 000000000..11550eb76
--- /dev/null
+++ b/SWIG/Examples/ruby/funcptr/.cvsignore
@@ -0,0 +1 @@
+example_wrap.c
diff --git a/SWIG/Examples/ruby/pointer/.cvsignore b/SWIG/Examples/ruby/pointer/.cvsignore
new file mode 100644
index 000000000..11550eb76
--- /dev/null
+++ b/SWIG/Examples/ruby/pointer/.cvsignore
@@ -0,0 +1 @@
+example_wrap.c
diff --git a/SWIG/Examples/ruby/reference/.cvsignore b/SWIG/Examples/ruby/reference/.cvsignore
new file mode 100644
index 000000000..11550eb76
--- /dev/null
+++ b/SWIG/Examples/ruby/reference/.cvsignore
@@ -0,0 +1 @@
+example_wrap.c
diff --git a/SWIG/Examples/ruby/simple/.cvsignore b/SWIG/Examples/ruby/simple/.cvsignore
new file mode 100644
index 000000000..11550eb76
--- /dev/null
+++ b/SWIG/Examples/ruby/simple/.cvsignore
@@ -0,0 +1 @@
+example_wrap.c
diff --git a/SWIG/Examples/ruby/value/.cvsignore b/SWIG/Examples/ruby/value/.cvsignore
new file mode 100644
index 000000000..11550eb76
--- /dev/null
+++ b/SWIG/Examples/ruby/value/.cvsignore
@@ -0,0 +1 @@
+example_wrap.c
diff --git a/SWIG/Examples/ruby/variables/.cvsignore b/SWIG/Examples/ruby/variables/.cvsignore
new file mode 100644
index 000000000..11550eb76
--- /dev/null
+++ b/SWIG/Examples/ruby/variables/.cvsignore
@@ -0,0 +1 @@
+example_wrap.c
diff --git a/SWIG/Examples/tcl/class/.cvsignore b/SWIG/Examples/tcl/class/.cvsignore
new file mode 100644
index 000000000..11550eb76
--- /dev/null
+++ b/SWIG/Examples/tcl/class/.cvsignore
@@ -0,0 +1 @@
+example_wrap.c
diff --git a/SWIG/Examples/tcl/constants/.cvsignore b/SWIG/Examples/tcl/constants/.cvsignore
new file mode 100644
index 000000000..11550eb76
--- /dev/null
+++ b/SWIG/Examples/tcl/constants/.cvsignore
@@ -0,0 +1 @@
+example_wrap.c
diff --git a/SWIG/Examples/tcl/enum/.cvsignore b/SWIG/Examples/tcl/enum/.cvsignore
new file mode 100644
index 000000000..11550eb76
--- /dev/null
+++ b/SWIG/Examples/tcl/enum/.cvsignore
@@ -0,0 +1 @@
+example_wrap.c
diff --git a/SWIG/Examples/tcl/funcptr/.cvsignore b/SWIG/Examples/tcl/funcptr/.cvsignore
new file mode 100644
index 000000000..11550eb76
--- /dev/null
+++ b/SWIG/Examples/tcl/funcptr/.cvsignore
@@ -0,0 +1 @@
+example_wrap.c
diff --git a/SWIG/Examples/tcl/pointer/.cvsignore b/SWIG/Examples/tcl/pointer/.cvsignore
new file mode 100644
index 000000000..11550eb76
--- /dev/null
+++ b/SWIG/Examples/tcl/pointer/.cvsignore
@@ -0,0 +1 @@
+example_wrap.c
diff --git a/SWIG/Examples/tcl/reference/.cvsignore b/SWIG/Examples/tcl/reference/.cvsignore
new file mode 100644
index 000000000..11550eb76
--- /dev/null
+++ b/SWIG/Examples/tcl/reference/.cvsignore
@@ -0,0 +1 @@
+example_wrap.c
diff --git a/SWIG/Examples/tcl/simple/.cvsignore b/SWIG/Examples/tcl/simple/.cvsignore
new file mode 100644
index 000000000..11550eb76
--- /dev/null
+++ b/SWIG/Examples/tcl/simple/.cvsignore
@@ -0,0 +1 @@
+example_wrap.c
diff --git a/SWIG/Examples/tcl/value/.cvsignore b/SWIG/Examples/tcl/value/.cvsignore
new file mode 100644
index 000000000..11550eb76
--- /dev/null
+++ b/SWIG/Examples/tcl/value/.cvsignore
@@ -0,0 +1 @@
+example_wrap.c
diff --git a/SWIG/Examples/tcl/variables/.cvsignore b/SWIG/Examples/tcl/variables/.cvsignore
new file mode 100644
index 000000000..11550eb76
--- /dev/null
+++ b/SWIG/Examples/tcl/variables/.cvsignore
@@ -0,0 +1 @@
+example_wrap.c
diff --git a/SWIG/INSTALL b/SWIG/INSTALL
new file mode 100644
index 000000000..666ffd9f8
--- /dev/null
+++ b/SWIG/INSTALL
@@ -0,0 +1,226 @@
+Basic Installation
+==================
+
+ These are generic installation instructions.
+
+ The `configure' shell script attempts to guess correct values for
+various system-dependent variables used during compilation. It uses
+those values to create a `Makefile' in each directory of the package.
+It may also create one or more `.h' files containing system-dependent
+definitions. Finally, it creates a shell script `config.status' that
+you can run in the future to recreate the current configuration, and a
+file `config.log' containing compiler output (useful mainly for
+debugging `configure').
+
+ It can also use an optional file (typically called `config.cache'
+and enabled with `--cache-file=config.cache' or simply `-C') that saves
+the results of its tests to speed up reconfiguring. (Caching is
+disabled by default to prevent problems with accidental use of stale
+cache files.)
+
+ If you need to do unusual things to compile the package, please try
+to figure out how `configure' could check whether to do them, and mail
+diffs or instructions to the address given in the `README' so they can
+be considered for the next release. If you are using the cache, and at
+some point `config.cache' contains results you don't want to keep, you
+may remove or edit it.
+
+ The file `configure.ac' (or `configure.in') is used to create
+`configure' by a program called `autoconf'. You only need
+`configure.ac' if you want to change it or regenerate `configure' using
+a newer version of `autoconf'.
+
+The simplest way to compile this package is:
+
+ 1. `cd' to the directory containing the package's source code and type
+ `./configure' to configure the package for your system. If you're
+ using `csh' on an old version of System V, you might need to type
+ `sh ./configure' instead to prevent `csh' from trying to execute
+ `configure' itself.
+
+ Running `configure' takes awhile. While running, it prints some
+ messages telling which features it is checking for.
+
+ 2. Type `make' to compile the package.
+
+ 3. Optionally, type `make check' to run any self-tests that come with
+ the package.
+
+ 4. Type `make install' to install the programs and any data files and
+ documentation.
+
+ 5. You can remove the program binaries and object files from the
+ source code directory by typing `make clean'. To also remove the
+ files that `configure' created (so you can compile the package for
+ a different kind of computer), type `make distclean'. There is
+ also a `make maintainer-clean' target, but that is intended mainly
+ for the package's developers. If you use it, you may have to get
+ all sorts of other programs in order to regenerate files that came
+ with the distribution.
+
+Compilers and Options
+=====================
+
+ Some systems require unusual options for compilation or linking that
+the `configure' script does not know about. Run `./configure --help'
+for details on some of the pertinent environment variables.
+
+ You can give `configure' initial values for variables by setting
+them in the environment. You can do that on the command line like this:
+
+ ./configure CC=c89 CFLAGS=-O2 LIBS=-lposix
+
+ *Note Environment Variables::, for more details.
+
+Compiling For Multiple Architectures
+====================================
+
+ You can compile the package for more than one kind of computer at the
+same time, by placing the object files for each architecture in their
+own directory. To do this, you must use a version of `make' that
+supports the `VPATH' variable, such as GNU `make'. `cd' to the
+directory where you want the object files and executables to go and run
+the `configure' script. `configure' automatically checks for the
+source code in the directory that `configure' is in and in `..'.
+
+ If you have to use a `make' that does not support the `VPATH'
+variable, you have to compile the package for one architecture at a time
+in the source code directory. After you have installed the package for
+one architecture, use `make distclean' before reconfiguring for another
+architecture.
+
+Installation Names
+==================
+
+ By default, `make install' will install the package's files in
+`/usr/local/bin', `/usr/local/man', etc. You can specify an
+installation prefix other than `/usr/local' by giving `configure' the
+option `--prefix=PATH'.
+
+ You can specify separate installation prefixes for
+architecture-specific files and architecture-independent files. If you
+give `configure' the option `--exec-prefix=PATH', the package will use
+PATH as the prefix for installing programs and libraries.
+Documentation and other data files will still use the regular prefix.
+
+ In addition, if you use an unusual directory layout you can give
+options like `--bindir=PATH' to specify different values for particular
+kinds of files. Run `configure --help' for a list of the directories
+you can set and what kinds of files go in them.
+
+ If the package supports it, you can cause programs to be installed
+with an extra prefix or suffix on their names by giving `configure' the
+option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
+
+Optional Features
+=================
+
+ Some packages pay attention to `--enable-FEATURE' options to
+`configure', where FEATURE indicates an optional part of the package.
+They may also pay attention to `--with-PACKAGE' options, where PACKAGE
+is something like `gnu-as' or `x' (for the X Window System). The
+`README' should mention any `--enable-' and `--with-' options that the
+package recognizes.
+
+ For packages that use the X Window System, `configure' can usually
+find the X include and library files automatically, but if it doesn't,
+you can use the `configure' options `--x-includes=DIR' and
+`--x-libraries=DIR' to specify their locations.
+
+Specifying the System Type
+==========================
+
+ There may be some features `configure' cannot figure out
+automatically, but needs to determine by the type of host the package
+will run on. Usually `configure' can figure that out, but if it prints
+a message saying it cannot guess the host type, give it the
+`--build=TYPE' option. TYPE can either be a short name for the system
+type, such as `sun4', or a canonical name which has the form:
+
+ CPU-COMPANY-SYSTEM
+
+where SYSTEM can have one of these forms:
+
+ OS
+ KERNEL-OS
+
+ See the file `config.sub' for the possible values of each field. If
+`config.sub' isn't included in this package, then this package doesn't
+need to know the host type.
+
+ If you are _building_ compiler tools for cross-compiling, you should
+use the `--target=TYPE' option to select the type of system they will
+produce code for.
+
+ If you want to _use_ a cross compiler, that generates code for a
+platform different from the build platform, you should specify the host
+platform (i.e., that on which the generated programs will eventually be
+run) with `--host=TYPE'. In this case, you should also specify the
+build platform with `--build=TYPE', because, in this case, it may not
+be possible to guess the build platform (it sometimes involves
+compiling and running simple test programs, and this can't be done if
+the compiler is a cross compiler).
+
+Sharing Defaults
+================
+
+ If you want to set default values for `configure' scripts to share,
+you can create a site shell script called `config.site' that gives
+default values for variables like `CC', `cache_file', and `prefix'.
+`configure' looks for `PREFIX/share/config.site' if it exists, then
+`PREFIX/etc/config.site' if it exists. Or, you can set the
+`CONFIG_SITE' environment variable to the location of the site script.
+A warning: not all `configure' scripts look for a site script.
+
+Environment Variables
+=====================
+
+ Variables not defined in a site shell script can be set in the
+environment passed to configure. However, some packages may run
+configure again during the build, and the customized values of these
+variables may be lost. In order to avoid this problem, you should set
+them in the `configure' command line, using `VAR=value'. For example:
+
+ ./configure CC=/usr/local2/bin/gcc
+
+will cause the specified gcc to be used as the C compiler (unless it is
+overridden in the site shell script).
+
+`configure' Invocation
+======================
+
+ `configure' recognizes the following options to control how it
+operates.
+
+`--help'
+`-h'
+ Print a summary of the options to `configure', and exit.
+
+`--version'
+`-V'
+ Print the version of Autoconf used to generate the `configure'
+ script, and exit.
+
+`--cache-file=FILE'
+ Enable the cache: use and save the results of the tests in FILE,
+ traditionally `config.cache'. FILE defaults to `/dev/null' to
+ disable caching.
+
+`--config-cache'
+`-C'
+ Alias for `--cache-file=config.cache'.
+
+`--quiet'
+`--silent'
+`-q'
+ Do not print messages saying which checks are being made. To
+ suppress all normal output, redirect it to `/dev/null' (any error
+ messages will still be shown).
+
+`--srcdir=DIR'
+ Look for the package's source code in directory DIR. Usually
+ `configure' can determine that directory automatically.
+
+`configure' also accepts some other, not widely useful, options. Run
+`configure --help' for more details.
+
diff --git a/SWIG/Lib/common.swg b/SWIG/Lib/common.swg
index 6a51b84e0..214ef421c 100644
--- a/SWIG/Lib/common.swg
+++ b/SWIG/Lib/common.swg
@@ -44,9 +44,9 @@ extern "C" {
#endif
typedef struct swig_type_info {
- char *name;
+ const char *name;
void *(*converter)(void *);
- char *str;
+ const char *str;
struct swig_type_info *next;
struct swig_type_info *prev;
} swig_type_info;
@@ -55,6 +55,7 @@ typedef struct swig_type_info {
SWIGEXPORT(swig_type_info *) SWIG_TypeRegister(swig_type_info *);
SWIGEXPORT(swig_type_info *) SWIG_TypeCheck(char *c, swig_type_info *);
SWIGEXPORT(void *) SWIG_TypeCast(swig_type_info *, void *);
+SWIGEXPORT(swig_type_info *) SWIG_TypeQuery(const char *);
#else
static swig_type_info *swig_type_list = 0;
@@ -132,7 +133,7 @@ SWIG_TypeCast(swig_type_info *ty, void *ptr)
}
/* Search for a swig_type_info structure */
-SWIGRUNTIME(void *)
+SWIGRUNTIME(swig_type_info *)
SWIG_TypeQuery(const char *name) {
swig_type_info *ty = swig_type_list;
while (ty) {
diff --git a/SWIG/Lib/guile/guile.i b/SWIG/Lib/guile/guile.i
index df81de988..f4fc1ea36 100644
--- a/SWIG/Lib/guile/guile.i
+++ b/SWIG/Lib/guile/guile.i
@@ -1,4 +1,4 @@
-/* SWIG Configuration File for Guile.
+/* SWIG Configuration File for Guile. -*-c-*-
This file is parsed by SWIG before reading any other interface
file. */
diff --git a/SWIG/Lib/guile/guile.swg b/SWIG/Lib/guile/guile.swg
index 3b5dd1e24..841115a08 100644
--- a/SWIG/Lib/guile/guile.swg
+++ b/SWIG/Lib/guile/guile.swg
@@ -7,6 +7,10 @@
/* SWIG pointer structure */
+#ifdef __cplusplus
+extern "C" {
+#endif
+
struct SwigCast {
unsigned short type; /* Index into SwigPtrTbl */
void *(*cast)(void *); /* Pointer casting function */
@@ -14,8 +18,8 @@ struct SwigCast {
};
struct SwigPtrType {
- char *name; /* Datatype name */
- char *prettyname; /* Pretty datatype name */
+ const char *name; /* Datatype name */
+ const char *prettyname; /* Pretty datatype name */
unsigned short tag; /* Index in SwigPtrTable */
struct SwigCast *cast; /* List of compatible types */
};
@@ -45,7 +49,7 @@ swigsort (const void *data1, const void *data2)
/* Register a new datatype with the type-checker */
SWIGSTATIC size_t
-SWIG_RegisterType (char *type, char *prettyname)
+SWIG_RegisterType (const char *type, const char *prettyname)
{
int i;
@@ -90,9 +94,8 @@ SWIG_RegisterType (char *type, char *prettyname)
/* Register two data types and their mapping with the type checker. */
SWIGSTATIC void
-SWIG_RegisterMapping (char *origtype, char *newtype, void *(*cast)(void *))
+SWIG_RegisterMapping (const char *origtype, const char *newtype, void *(*cast)(void *))
{
- int i;
size_t t = SWIG_RegisterType(origtype, NULL);
if (newtype!=NULL) {
@@ -118,7 +121,6 @@ SWIG_RegisterMapping (char *origtype, char *newtype, void *(*cast)(void *))
static void
SWIG_SortTable (void)
{
- int i;
qsort ((void *) SwigPtrTbl, SwigPtrN, sizeof(size_t), swigsort);
/* Indicate that everything is sorted */
SwigPtrSort = 1;
@@ -137,10 +139,9 @@ swigcmp (const void *key, const void *data)
static SwigPtrType *
SWIG_GetPtrType (const char *_t)
{
- int start, end;
size_t *result;
if (!SwigPtrSort) SWIG_SortTable();
- result = bsearch(_t, SwigPtrTbl, SwigPtrN, sizeof(size_t), swigcmp);
+ result = (size_t *) bsearch(_t, SwigPtrTbl, SwigPtrN, sizeof(size_t), swigcmp);
if (result!=NULL) return SwigPtrList+*result;
else return NULL;
}
@@ -156,8 +157,8 @@ SWIG_Cast (void *source, size_t source_type,
mapping table to figure out whether or not we can accept this
datatype. */
struct SwigCast *c;
- for (c = SwigPtrList[source_type].cast;
- c && c->type!=dest_type; c = c->next) /* nothing */;
+ for (c = SwigPtrList[dest_type].cast;
+ c && c->type!=source_type; c = c->next) /* nothing */;
if (c) {
/* Get pointer value. */
if (c->cast) *ptr = (*(c->cast))(source);
@@ -199,7 +200,7 @@ SWIG_Guile_GetPtr(SCM s, void **result, swig_type_info *type)
&& (unsigned long) SCM_TYP16(s) == swig_tag) {
if (type)
return !SWIG_Cast((void *) SCM_CDR(s),
- SCM_CAR(s) >> 16,
+ (long) SCM_CAR(s) >> 16,
result, type->tag);
else {
*result = (void *) SCM_CDR(s);
@@ -209,18 +210,30 @@ SWIG_Guile_GetPtr(SCM s, void **result, swig_type_info *type)
return 1;
}
+SWIGSTATIC void *
+SWIG_Guile_MustGetPtr_ (SCM s, swig_type_info *type,
+ int argnum, const char *func_name)
+{
+ void *result;
+ if (SWIG_Guile_GetPtr(s, &result, type)) {
+ /* type mismatch */
+ scm_wrong_type_arg((char *) func_name, argnum, s);
+ }
+ return result;
+}
+
/* Init */
static int
print_swig (SCM swig_smob, SCM port, scm_print_state *pstate)
{
- char buf[16];
scm_puts("#<swig ", port);
- if (SwigPtrList[SCM_CAR(swig_smob) >> 16].prettyname != NULL)
- scm_puts(SwigPtrList[SCM_CAR(swig_smob) >> 16].prettyname, port);
- else scm_puts(SwigPtrList[SCM_CAR(swig_smob) >> 16].name, port);
- sprintf(buf, " 0x%lx>", SCM_CDR(swig_smob));
- scm_puts(buf, port);
+ if (SwigPtrList[(long) SCM_CAR(swig_smob) >> 16].prettyname != NULL)
+ scm_puts(SwigPtrList[(long) SCM_CAR(swig_smob) >> 16].prettyname, port);
+ else scm_puts(SwigPtrList[(long) SCM_CAR(swig_smob) >> 16].name, port);
+ scm_puts(" ", port);
+ scm_intprint((long) SCM_CDR(swig_smob), 16, port);
+ scm_puts(">", port);
/* non-zero means success */
return 1;
}
@@ -238,7 +251,7 @@ SWIGSTATIC void
SWIG_Guile_Init (void)
{
if (swig_tag == 0) {
- swig_tag = scm_make_smob_type_mfpe("swig", 0, NULL, NULL,
+ swig_tag = scm_make_smob_type_mfpe((char *) "swig", 0, NULL, NULL,
print_swig, equalp_swig);
}
}
@@ -246,11 +259,12 @@ SWIG_Guile_Init (void)
/* Convert datatype table */
SWIGSTATIC
-void SWIG_Guile_RegisterTypes(swig_type_info **table)
+void SWIG_Guile_RegisterTypes(swig_type_info **table,
+ swig_type_info **init)
{
- for (; *table; table++) {
- swig_type_info *type = *table;
- char *origname = type->name;
+ for (; *init; table++, init++) {
+ swig_type_info *type = *table = *init;
+ const char *origname = type->name;
/* Register datatype itself and store pointer back */
type->tag = SWIG_RegisterType(origname, type->str);
/* Register compatible types */
@@ -267,7 +281,7 @@ SWIG_Guile_GetArgs (SCM *dest, SCM rest,
int i;
for (i = 0; i<reqargs; i++) {
if (!SCM_CONSP(rest))
- scm_wrong_num_args(gh_str02scm(procname));
+ scm_wrong_num_args(gh_str02scm((char *) procname));
*dest++ = SCM_CAR(rest);
rest = SCM_CDR(rest);
}
@@ -278,7 +292,7 @@ SWIG_Guile_GetArgs (SCM *dest, SCM rest,
for (; i<optargs; i++)
*dest++ = GH_NOT_PASSED;
if (!SCM_NULLP(rest))
- scm_wrong_num_args(gh_str02scm(procname));
+ scm_wrong_num_args(gh_str02scm((char *) procname));
}
#ifdef __cplusplus
diff --git a/SWIG/Lib/guile/guiledec.swg b/SWIG/Lib/guile/guiledec.swg
index 947619c57..d763f0809 100644
--- a/SWIG/Lib/guile/guiledec.swg
+++ b/SWIG/Lib/guile/guiledec.swg
@@ -27,17 +27,29 @@ extern "C" {
#define GH_NOT_PASSED SCM_UNDEFINED
#define GH_UNSPECIFIED SCM_UNSPECIFIED
-#define GUILE_APPEND_RESULT(object) \
- if (gswig_result == GH_UNSPECIFIED) \
- gswig_result = object; \
- else { \
- if (!gh_pair_p(gswig_result)) \
- gswig_result = gh_list(gswig_result, object, GH_NOT_PASSED); \
- else \
- gswig_result = gh_append2(gswig_result, \
- gh_list(object, GH_NOT_PASSED)); \
+#define GUILE_APPEND_RESULT(object) \
+ if (gswig_result == GH_UNSPECIFIED) \
+ gswig_result = object; \
+ else { \
+ if (!gswig_list_p) { \
+ gswig_list_p = 1; \
+ gswig_result = gh_list(gswig_result, object, GH_NOT_PASSED); \
+ } \
+ else \
+ gswig_result = gh_append2(gswig_result, \
+ gh_list(object, GH_NOT_PASSED)); \
}
+/* scm_values was implemented on C level in 1.4.1, and the prototype
+ is not included in libguile.h, so play safe and lookup `values'... */
+#define GUILE_MAYBE_VALUES \
+ if (gswig_list_p) \
+ gswig_result = gh_apply(gh_lookup("values"), gswig_result);
+
+#define GUILE_MAYBE_VECTOR \
+ if (gswig_list_p) \
+ gswig_result = gh_list_to_vector(gswig_result);
+
static char *
GSWIG_scm2str (SCM s)
{
@@ -72,16 +84,15 @@ GSWIG_scm2char (SCM s)
typedef struct SwigPtrType SwigPtrType;
typedef struct swig_type_info {
- char *name;
+ const char *name;
void *(*converter)(void *);
- char *str;
+ const char *str;
size_t tag;
} swig_type_info;
-#define swig_types_initial swig_types
-
SWIGSTATIC void
-SWIG_Guile_RegisterTypes (swig_type_info **table);
+SWIG_Guile_RegisterTypes (swig_type_info **table,
+ swig_type_info **init);
/* Register a new type-mapping with the type-checker. origtype is the
original datatype and newtype is an equivalent type. cast is optional
@@ -90,7 +101,7 @@ SWIG_Guile_RegisterTypes (swig_type_info **table);
C++). */
SWIGSTATIC void
-SWIG_RegisterMapping (char *origtype, char *newtype,
+SWIG_RegisterMapping (const char *origtype, const char *newtype,
void *(*cast)(void *));
/* Register SWIG smobs with Guile. */
@@ -106,6 +117,16 @@ SWIG_Guile_Init();
SWIGSTATIC int
SWIG_Guile_GetPtr (SCM s, void **result, swig_type_info *type);
+/* Get a pointer value from a smob. If there is a type-mismatch,
+ signal a wrong-type-arg error for the given argument number. */
+SWIGSTATIC void *
+SWIG_Guile_MustGetPtr_ (SCM s, swig_type_info *type,
+ int argnum, const char *func_name);
+
+/* Use this convenience macro instead of the above function. */
+#define SWIG_Guile_MustGetPtr(s, type, argnum) \
+ SWIG_Guile_MustGetPtr_(s, type, argnum, FUNC_NAME)
+
/* Make a smob from a pointer and typeinfo. */
SWIGSTATIC SCM
SWIG_Guile_MakePtr (void *ptr, swig_type_info *type);
diff --git a/SWIG/Lib/guile/guilemain.i b/SWIG/Lib/guile/guilemain.i
index cd7da9813..7d5eacf30 100644
--- a/SWIG/Lib/guile/guilemain.i
+++ b/SWIG/Lib/guile/guilemain.i
@@ -27,6 +27,10 @@
%{
#include <libguile.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/* Debugger interface (don't change the order of the following lines) */
#define GDB_TYPE SCM
#include <libguile/gdb_interface.h>
@@ -44,6 +48,10 @@ inner_main(void *closure, int argc, char **argv)
/* never reached: scm_shell will perform an exit */
}
+#ifdef __cplusplus
+}
+#endif
+
int
main(int argc, char **argv)
{
diff --git a/SWIG/Lib/guile/list-vector.i b/SWIG/Lib/guile/list-vector.i
new file mode 100644
index 000000000..97a5c7d9d
--- /dev/null
+++ b/SWIG/Lib/guile/list-vector.i
@@ -0,0 +1,222 @@
+/* list-vector.i --- Guile typemaps for converting between -*- c -*- arrays
+ and Scheme lists or vectors
+
+ Copyright (C) 2001 Matthias Koeppe <mkoeppe@mail.math.uni-magdeburg.de>
+
+ $Header$
+*/
+
+/* Here is a macro that will define typemaps for converting between C
+ arrays and Scheme lists or vectors when passing arguments to the C
+ function.
+
+ TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(C_TYPE, SCM_TO_C, C_TO_SCM, SCM_TYPE)
+
+ Supported calling conventions:
+
+ func(int VECTORLENINPUT, [const] C_TYPE *VECTORINPUT) or
+ func([const] C_TYPE *VECTORINPUT, int VECTORLENINPUT)
+
+ Scheme wrapper will take one argument, a vector. A temporary C
+ array of elements of type C_TYPE will be allocated and filled
+ with the elements of the vectors, converted to C with the
+ SCM_TO_C function. Length and address of the array are passed
+ to the C function.
+
+ SCM_TYPE is used to describe the Scheme type of the elements in
+ the Guile procedure documentation.
+
+ func(int LISTLENINPUT, [const] C_TYPE *LISTINPUT) or
+ func([const] C_TYPE *LISTINPUT, int LISTLENINPUT)
+
+ Likewise, but the Scheme wrapper will take one argument, a list.
+
+ func(int *VECTORLENOUTPUT, C_TYPE **VECTOROUTPUT) or
+ func(C_TYPE **VECTOROUTPUT, int *VECTORLENOUTPUT)
+
+ Scheme wrapper will take no arguments. Addresses of an integer
+ and a C_TYPE * variable will be passed to the C function. The
+ C function is expected to return address and length of a
+ freshly allocated array of elements of type C_TYPE through
+ these pointers. The elements of this array are converted to
+ Scheme with the C_TO_SCM function and returned as a Scheme
+ vector.
+
+ If the function has a void return value, the vector constructed
+ by this typemap becomes the return value of the Scheme wrapper.
+ Otherwise, the function returns multiple values. (See
+ Doc/internals.html on how to deal with multiple values.)
+
+ func(int *LISTLENOUTPUT, C_TYPE **LISTOUTPUT) or
+ func(C_TYPE **LISTOUTPUT, int *LISTLENOUTPUT)
+
+ Likewise, but the Scheme wrapper will return a list instead of
+ a vector.
+
+ Multiple parallel lists and vectors (sharing one length argument
+ each) are also supported. */
+
+%define TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(C_TYPE, SCM_TO_C, C_TO_SCM, SCM_TYPE)
+
+ /* input */
+
+ /* Passing data is a little complicated here; just remember:
+ IGNORE typemaps come first, then IN, then CHECK. But if
+ IGNORE is given, IN won't be used for this type.
+
+ We need to "ignore" one of the parameters because there shall
+ be only one argument on the Scheme side. Here we only
+ initialize the array length to 0 but save its address for a
+ later change. */
+
+ %typemap(ignore) int VECTORLENINPUT (int *vector_length)
+ {
+ $target = 0;
+ vector_length = &$target;
+ }
+
+ %typemap(ignore) int LISTLENINPUT (int *list_length)
+ {
+ $target = 0;
+ list_length = &$target;
+ }
+
+ /* All the work is done in IN. */
+
+ %typemap(in) C_TYPE *VECTORINPUT,
+ const C_TYPE *VECTORINPUT
+ {
+ SCM_VALIDATE_VECTOR($argnum, $source);
+ *vector_length = gh_vector_length($source);
+ if (*vector_length > 0) {
+ int i;
+ $target = SCM_MUST_MALLOC(sizeof(C_TYPE)
+ * (*vector_length));
+ for (i = 0; i<*vector_length; i++) {
+ SCM elt = gh_vector_ref($source, gh_int2scm(i));
+ $target[i] = SCM_TO_C(elt);
+ }
+ }
+ else $target = NULL;
+ }
+
+ %typemap(in) C_TYPE *LISTINPUT,
+ const C_TYPE *LISTINPUT
+ {
+ SCM_VALIDATE_LIST($argnum, $source);
+ *list_length = gh_length($source);
+ if (*list_length > 0) {
+ int i;
+ SCM rest;
+ $target = SCM_MUST_MALLOC(sizeof(C_TYPE)
+ * (*list_length));
+ for (i = 0, rest = $source;
+ i<*list_length;
+ i++, rest = gh_cdr(rest)) {
+ SCM elt = gh_car(rest);
+ $target[i] = SCM_TO_C(elt);
+ }
+ }
+ else $target = NULL;
+ }
+
+ /* Don't check for NULL pointers (override checks). */
+
+ %typemap(check) C_TYPE *VECTORINPUT,
+ const C_TYPE *VECTORINPUT,
+ C_TYPE *LISTINPUT,
+ const C_TYPE *LISTINPUT
+ "/* no check for NULL pointer */";
+
+ /* Discard the temporary array after the call. */
+
+ %typemap(freearg) C_TYPE *VECTORINPUT,
+ const C_TYPE *VECTORINPUT,
+ C_TYPE *LISTINPUT,
+ const C_TYPE *LISTINPUT
+ "if ($target!=NULL) scm_must_free($target);";
+
+ /* On the Scheme side, the argument is a vector or a list, so say
+ so in the arglist documentation. */
+
+ %typemap(indoc) C_TYPE *VECTORINPUT,
+ const C_TYPE *VECTORINPUT
+ "($arg <vector of <SCM_TYPE>>)";
+
+ %typemap(indoc) C_TYPE *LISTINPUT,
+ const C_TYPE *LISTINPUT
+ "($arg <list of <SCM_TYPE>>)";
+
+ /* output */
+
+ /* First we make a temporary variable ARRAYLENTEMP, use its
+ address as the ...LENOUTPUT argument for the C function and
+ "ignore" the ...LENOUTPUT argument for Scheme. */
+
+ %typemap(ignore) int *VECTORLENOUTPUT (int arraylentemp),
+ int *LISTLENOUTPUT (int arraylentemp)
+ "$target = &arraylentemp;";
+
+ /* We also need to ignore the ...OUTPUT argument. */
+
+ %typemap(ignore) C_TYPE **VECTOROUTPUT (C_TYPE *arraytemp),
+ C_TYPE **LISTOUTPUT (C_TYPE *arraytemp)
+ "$target = &arraytemp;";
+
+ /* In the ARGOUT typemaps, we convert the array into a vector or
+ a list and append it to the results. */
+
+ %typemap(argout) C_TYPE **VECTOROUTPUT
+ {
+ int i;
+ SCM res = gh_make_vector(gh_int2scm(arraylentemp),
+ SCM_BOOL_F);
+ for (i = 0; i<arraylentemp; i++) {
+ SCM elt = C_TO_SCM((*$target)[i]);
+ gh_vector_set_x(res, gh_int2scm(i), elt);
+ }
+ if ((*$target)!=NULL) free(*$target);
+ GUILE_APPEND_RESULT(res);
+ }
+
+ %typemap(argout) C_TYPE **LISTOUTPUT
+ {
+ int i;
+ SCM res = SCM_EOL;
+ for (i = arraylentemp - 1; i>=0; i--) {
+ SCM elt = C_TO_SCM((*$target)[i]);
+ res = gh_cons(elt, res);
+ }
+ if ((*$target)!=NULL) free(*$target);
+ GUILE_APPEND_RESULT(res);
+ }
+
+ /* We return a vector or a list, so say so in the procedure
+ documentation. */
+
+ %typemap(argoutdoc) C_TYPE **VECTOROUTPUT
+ "($arg <vector of <SCM_TYPE>>)";
+
+ %typemap(argoutdoc) C_TYPE **LISTOUTPUT
+ "($arg <list of <SCM_TYPE>>)";
+
+%enddef
+
+/* We use the macro to define typemaps for some standard types. */
+
+TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(bool, gh_scm2bool, gh_bool2scm, boolean);
+TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(char, GSWIG_scm2char, gh_char2scm, char);
+TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(unsigned char, GSWIG_scm2char, gh_char2scm, char);
+TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(int, gh_scm2int, gh_int2scm, integer);
+TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(short, gh_scm2int, gh_int2scm, integer);
+TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(long, gh_scm2long, gh_long2scm, integer);
+TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(ptrdiff_t, gh_scm2long, gh_long2scm, integer);
+TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(unsigned int, gh_scm2ulong, gh_ulong2scm, integer);
+TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(unsigned short, gh_scm2ulong, gh_ulong2scm, integer);
+TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(unsigned long, gh_scm2ulong, gh_ulong2scm, integer);
+TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(size_t, gh_scm2ulong, gh_ulong2scm, integer);
+TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(float, gh_scm2double, gh_double2scm, real);
+TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(double, gh_scm2double, gh_double2scm, real);
+TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(char *, GSWIG_scm2str, gh_str02scm, string);
+TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(const char *, GSWIG_scm2str, gh_str02scm, string);
+
diff --git a/SWIG/Lib/guile/pointer-in-out.i b/SWIG/Lib/guile/pointer-in-out.i
new file mode 100644
index 000000000..761b9e5f0
--- /dev/null
+++ b/SWIG/Lib/guile/pointer-in-out.i
@@ -0,0 +1,68 @@
+/* pointer-in-out.i --- Guile typemaps for passing -*- c -*- pointers indirectly
+
+ Copyright (C) 2001 Matthias Koeppe <mkoeppe@mail.math.uni-magdeburg.de>
+
+ $Header$
+*/
+
+/* Here is a macro that will define typemaps for converting between C
+ arrays and Scheme lists or vectors when passing arguments to the C
+ function.
+
+ TYPEMAP_POINTER_INPUT_OUTPUT(PTRTYPE, SCM_TYPE)
+
+ Supported calling conventions (in this example, PTRTYPE is int *):
+
+ func(int **INPUT)
+
+ Scheme wrapper will take one argument, a wrapped C pointer.
+ The address of a variable containing this pointer will be
+ passed to the function.
+
+ func(int **OUTPUT)
+
+ Scheme wrapper will take no arguments. The address of an int *
+ variable will be passed to the function. The function is
+ expected to modify the variable; its value is wrapped and
+ becomes an extra return value. (See Doc/internals.html on how
+ to deal with multiple values.)
+
+ func(int **BOTH)
+
+ This annotation combines INPUT and OUTPUT.
+
+*/
+
+%define TYPEMAP_POINTER_INPUT_OUTPUT(PTRTYPE, SCM_TYPE)
+
+%typemap(in) PTRTYPE *INPUT(PTRTYPE temp)
+{
+ if (SWIG_Guile_GetPtr($source, (void **) &temp, $*descriptor)) {
+ scm_wrong_type_arg(FUNC_NAME, $argnum, $source);
+ }
+ $target = &temp;
+}
+%typemap(indoc) PTRTYPE *INPUT "($arg <SCM_TYPE>)";
+
+%typemap(ignore) PTRTYPE *OUTPUT(PTRTYPE temp)
+ "$target = &temp;";
+
+%typemap(argout) PTRTYPE *OUTPUT
+ "GUILE_APPEND_RESULT(SWIG_Guile_MakePtr(*$target, $*descriptor));";
+
+%typemap(argoutdoc) PTRTYPE *OUTPUT "<SCM_TYPE>";
+
+%typemap(in) PTRTYPE *BOTH = PTRTYPE *INPUT;
+%typemap(argout) PTRTYPE *BOTH = PTRTYPE *OUTPUT;
+%typemap(argoutdoc) PTRTYPE *BOTH = PTRTYPE *OUTPUT;
+%typemap(in) PTRTYPE *INOUT = PTRTYPE *INPUT;
+%typemap(argout) PTRTYPE *INOUT = PTRTYPE *OUTPUT;
+%typemap(argoutdoc) PTRTYPE *INOUT = PTRTYPE *OUTPUT;
+
+/* As a special convenience measure, also attach docs involving
+ SCM_TYPE to the standard pointer typemaps */
+
+%typemap(indoc) PTRTYPE "<($arg <SCM_TYPE>)>";
+%typemap(outdoc) PTRTYPE "<SCM_TYPE>";
+
+%enddef
diff --git a/SWIG/Lib/guile/ports.i b/SWIG/Lib/guile/ports.i
index 3741070b0..33737e1c4 100644
--- a/SWIG/Lib/guile/ports.i
+++ b/SWIG/Lib/guile/ports.i
@@ -7,10 +7,11 @@
%{
#ifndef _POSIX_SOURCE
/* This is needed on Solaris for fdopen(). */
- # define _POSIX_SOURCE=199506L
+ # define _POSIX_SOURCE 199506L
#endif
#include <stdio.h>
#include <errno.h>
+ #include <unistd.h>
%}
/* Feed FILE * arguments from file ports */
diff --git a/SWIG/Lib/guile/typemaps.i b/SWIG/Lib/guile/typemaps.i
index 21d6150db..90dee2ae8 100644
--- a/SWIG/Lib/guile/typemaps.i
+++ b/SWIG/Lib/guile/typemaps.i
@@ -4,33 +4,68 @@
$Header$ */
/* Unlike other SWIG language modules, the Guile module handles all
- non-pointer types uniformly via typemaps. Here are the
- definitions.
+ types uniformly via typemaps. Here are the definitions.
+*/
- The SIMPLE_MAP macro below defines the whole set of typemaps needed
+/* Pointers */
+
+%typemap(in) SWIGPOINTER * {
+ if (SWIG_Guile_GetPtr($source, (void **) &$target, $descriptor))
+ scm_wrong_type_arg(FUNC_NAME, $argnum, $source);
+}
+
+%typemap(in) void * {
+ if (SWIG_Guile_GetPtr($source, (void **) &$target, NULL))
+ scm_wrong_type_arg(FUNC_NAME, $argnum, $source);
+}
+
+%typemap(varin) SWIGPOINTER * {
+ if (SWIG_Guile_GetPtr($source, (void **) &$target, $descriptor))
+ scm_wrong_type_arg(FUNC_NAME, $argnum, $source);
+}
+
+%typemap(varin) void * {
+ if (SWIG_Guile_GetPtr($source, (void **) &$target, NULL))
+ scm_wrong_type_arg(FUNC_NAME, $argnum, $source);
+}
+
+%typemap(out) SWIGPOINTER * {
+ $target = SWIG_Guile_MakePtr ($source, $descriptor);
+}
+
+%typemap(varout) SWIGPOINTER * {
+ $target = SWIG_Guile_MakePtr ($source, $descriptor);
+}
+
+/* The SIMPLE_MAP macro below defines the whole set of typemaps needed
for simple types. */
%define SIMPLE_MAP(C_NAME, SCM_TO_C, C_TO_SCM, SCM_NAME)
- %typemap (guile, in) C_NAME "$target = SCM_TO_C($source);";
- %typemap (guile, varin) C_NAME "$target = SCM_TO_C($source);";
- %typemap (guile, out) C_NAME "$target = C_TO_SCM($source);";
- %typemap (guile, varout) C_NAME "$target = C_TO_SCM($source);";
+ %typemap (guile, in) C_NAME {$target = SCM_TO_C($source);}
+ %typemap (guile, varin) C_NAME {$target = SCM_TO_C($source);}
+ %typemap (guile, out) C_NAME {$target = C_TO_SCM($source);}
+ %typemap (guile, varout) C_NAME {$target = C_TO_SCM($source);}
%typemap (guile, indoc) C_NAME "($arg <SCM_NAME>)";
%typemap (guile, varindoc) C_NAME "($arg <SCM_NAME>)";
%typemap (guile, outdoc) C_NAME "<SCM_NAME>";
%typemap (guile, varoutdoc) C_NAME "<SCM_NAME>";
- %typemap (guile, in) C_NAME *INPUT (C_NAME temp)
- "temp = (C_NAME) C_TO_SCM($source); $target = &temp;"
+ %typemap (guile, in) C_NAME *INPUT (C_NAME temp) {
+ temp = (C_NAME) SCM_TO_C($source); $target = &temp;
+ }
%typemap (guile, indoc) C_NAME *INPUT "($arg <SCM_NAME>)";
%typemap (guile, ignore) C_NAME *OUTPUT (C_NAME temp)
- "$target = &temp;"
+ {$target = &temp;}
%typemap (guile, argout) C_NAME *OUTPUT
- "GUILE_APPEND_RESULT(C_TO_SCM(*$target));";
+ {GUILE_APPEND_RESULT(C_TO_SCM(*$target));}
%typemap (guile, argoutdoc) C_NAME *OUTPUT "($arg <SCM_NAME>)";
%typemap (guile, in) C_NAME *BOTH = C_NAME *INPUT;
%typemap (guile, indoc) C_NAME *BOTH = C_NAME *INPUT;
%typemap (guile, argout) C_NAME *BOTH = C_NAME *OUTPUT;
%typemap (guile, argoutdoc) C_NAME *BOTH = C_NAME *OUTPUT;
+ %typemap (guile, in) C_NAME *INOUT = C_NAME *INPUT;
+ %typemap (guile, indoc) C_NAME *INOUT = C_NAME *INPUT;
+ %typemap (guile, argout) C_NAME *INOUT = C_NAME *OUTPUT;
+ %typemap (guile, argoutdoc) C_NAME *INOUT = C_NAME *OUTPUT;
%enddef
SIMPLE_MAP(bool, gh_scm2bool, gh_bool2scm, boolean);
@@ -54,9 +89,29 @@
%typemap (guile, freearg) char *, const char * "if ($target) scm_must_free($target);";
+%typemap (guile, freearg) char **OUTPUT, char **BOTH "if (*$target) scm_must_free(*$target);"
+
+/* But this shall not apply if we try to pass a single char by
+ reference. */
+
+%typemap (guile, freearg) char *OUTPUT, char *BOTH "";
+
+/* If we set a string variable, delete the old result first. */
+
+%typemap (varin) char *, const char * {
+ if ($target) free($target);
+ $target = GSWIG_scm2str($source);
+}
+
/* Void */
%typemap (guile, out) void "gswig_result = GH_UNSPECIFIED;";
%typemap (guile, outdoc) void "";
+/* SCM is passed through */
+
+typedef unsigned long SCM;
+%typemap (guile, in) SCM "$target=$source;";
+%typemap (guile, out) SCM "$target=$source;";
+
/* typemaps.i ends here */
diff --git a/SWIG/Lib/java/java_arrays.i b/SWIG/Lib/java/java_arrays.i
new file mode 100644
index 000000000..198c43017
--- /dev/null
+++ b/SWIG/Lib/java/java_arrays.i
@@ -0,0 +1,11 @@
+/*
+Support for setting values in arrays. This is intended to cover all types of
+arrays, that is arrays of basic types, eg int, unsigned int, arrays of
+structures/classes, arrays of enums and arrays of pointers.
+*/
+%typemap(java, memberin) SWIGARRAY [] {
+ int i;
+ for (i=0; i<$dim0; i++)
+ $target[i] = $source[i];
+}
+
diff --git a/SWIG/Lib/java/stl_string.i b/SWIG/Lib/java/stl_string.i
new file mode 100644
index 000000000..d3afcdccb
--- /dev/null
+++ b/SWIG/Lib/java/stl_string.i
@@ -0,0 +1,82 @@
+//-*-c++-*-
+/*
+ * typemaps for standard C++ string and wstring
+ * by: Tal Shalif <tal@slt.atr.co.jp>
+ */
+/* what type to use in java source code */
+%typemap(java,jtype) const string & {String}
+
+/* what is the corresponding jni type */
+%typemap(java,jni) const string & {jstring}
+
+/* how to convert the c++ type to the java type */
+%typemap(java,out) const string & {
+ $target = JCALL(NewStringUTF, jenv) $source->c_str());
+}
+
+/* how to convert java type to requested c++ type */
+%typemap(java,in) const string & {
+ $target = NULL;
+ if($source != NULL) {
+ /* get the String from the StringBuffer */
+ char *p = (char *)jenv->GetStringUTFChars($source, 0);
+ $target = new string(p);
+ JCALL(ReleaseStringUTFChars, jenv) $source, p);
+ }
+}
+/* free resource once finished using */
+%typemap(java,freearg) const string & {
+ delete $target;
+}
+
+%typemap(java,jtype) string & = const string &;
+%typemap(java,jni) string & = const string &;
+%typemap(java,in) string & = const string &;
+%typemap(java,out) string & = const string &;
+%typemap(java,freearg) string & = const string &;
+
+/* what type to use in java source code */
+%typemap(java,jtype) const wstring & {String}
+
+/* what is the corresponding jni type */
+%typemap(java,jni) const wstring & {jstring}
+
+/* how to convert the c++ type to the java type */
+%typemap(java,out) const wstring & {
+ unsigned int len = $source->length();
+ jchar *conv_buf = new jchar[len];
+ for (unsigned int i = 0; i < len; ++i) {
+ conv_buf[i] = (jchar)(*$source)[i];
+ }
+ $target = JCALL(NewString, jenv) conv_buf, len);
+ delete [] conv_buf;
+}
+
+/* how to convert java type to requested c++ type */
+%typemap(java,in) const wstring & {
+ $target = NULL;
+ if($source != NULL) {
+ /* get the String from the StringBuffer */
+ const jchar *jchar_p = jenv->GetStringChars($source, 0);
+ unsigned int len;
+ for (len = 0; jchar_p[len]; ++len);
+ if (len) {
+ wchar_t *conv_buf = new wchar_t[len];
+ for (unsigned int i = 0; i < len; ++i) {
+ conv_buf[i] = jchar_p[i];
+ }
+ $target = new wstring(conv_buf, len);
+ delete [] conv_buf;
+ }
+
+ JCALL(ReleaseStringChars, jenv) $source, jchar_p);
+ }
+}
+
+
+%typemap(java,jtype) wstring & = const wstring &;
+%typemap(java,jni) wstring & = const wstring &;
+%typemap(java,in) wstring & = const wstring &;
+%typemap(java,out) wstring & = const wstring &;
+%typemap(java,freearg) wstring & = const wstring &;
+
diff --git a/SWIG/Lib/java/typemaps.i b/SWIG/Lib/java/typemaps.i
index 307cc5660..2b2ab55fb 100644
--- a/SWIG/Lib/java/typemaps.i
+++ b/SWIG/Lib/java/typemaps.i
@@ -1,4 +1,4 @@
-//-*-c++-*-
+//
// SWIG Typemap library
// for Java
@@ -125,85 +125,3 @@
%typemap(java,ignore) jobject jobj {
$target = jobj;
}
-
-/*
- * typemaps for standard C++ string and wstring
- * by: Tal Shalif <tal@slt.atr.co.jp>
- */
-/* what type to use in java source code */
-%typemap(java,jtype) const string & {String}
-
-/* what is the corresponding jni type */
-%typemap(java,jni) const string & {jstring}
-
-/* how to convert the c++ type to the java type */
-%typemap(java,out) const string & {
- $target = JCALL(NewStringUTF, jenv) $source->c_str());
-}
-
-/* how to convert java type to requested c++ type */
-%typemap(java,in) const string & {
- $target = NULL;
- if($source != NULL) {
- /* get the String from the StringBuffer */
- char *p = (char *)jenv->GetStringUTFChars($source, 0);
- $target = new string(p);
- JCALL(ReleaseStringUTFChars, jenv) $source, p);
- }
-}
-/* free resource once finished using */
-%typemap(java,freearg) const string & {
- delete $target;
-}
-
-%typemap(java,jtype) string & = const string &;
-%typemap(java,jni) string & = const string &;
-%typemap(java,in) string & = const string &;
-%typemap(java,out) string & = const string &;
-%typemap(java,freearg) string & = const string &;
-
-/* what type to use in java source code */
-%typemap(java,jtype) const wstring & {String}
-
-/* what is the corresponding jni type */
-%typemap(java,jni) const wstring & {jstring}
-
-/* how to convert the c++ type to the java type */
-%typemap(java,out) const wstring & {
- unsigned int len = $source->length();
- jchar *conv_buf = new jchar[len];
- for (unsigned int i = 0; i < len; ++i) {
- conv_buf[i] = (jchar)(*$source)[i];
- }
- $target = JCALL(NewString, jenv) conv_buf, len);
- delete [] conv_buf;
-}
-
-/* how to convert java type to requested c++ type */
-%typemap(java,in) const wstring & {
- $target = NULL;
- if($source != NULL) {
- /* get the String from the StringBuffer */
- const jchar *jchar_p = jenv->GetStringChars($source, 0);
- unsigned int len;
- for (len = 0; jchar_p[len]; ++len);
- if (len) {
- wchar_t *conv_buf = new wchar_t[len];
- for (unsigned int i = 0; i < len; ++i) {
- conv_buf[i] = jchar_p[i];
- }
- $target = new wstring(conv_buf, len);
- delete [] conv_buf;
- }
-
- JCALL(ReleaseStringChars, jenv) $source, jchar_p);
- }
-}
-
-
-%typemap(java,jtype) wstring & = const wstring &;
-%typemap(java,jni) wstring & = const wstring &;
-%typemap(java,in) wstring & = const wstring &;
-%typemap(java,out) wstring & = const wstring &;
-%typemap(java,freearg) wstring & = const wstring &;
-
diff --git a/SWIG/Lib/mzscheme/mzscheme.i b/SWIG/Lib/mzscheme/mzscheme.i
new file mode 100644
index 000000000..bea4e401b
--- /dev/null
+++ b/SWIG/Lib/mzscheme/mzscheme.i
@@ -0,0 +1,14 @@
+/* SWIG Configuration File for MzScheme. -*-c-*-
+ This file is parsed by SWIG before reading any other interface
+ file. */
+
+/* Include headers */
+%insert(runtime) "mzschemedec.swg"
+
+/*#ifndef SWIG_NOINCLUDE*/
+%insert(runtime) "mzscheme.swg"
+/*#endif*/
+
+/* Read in standard typemaps. */
+%include "typemaps.i"
+
diff --git a/SWIG/Lib/mzscheme/mzscheme.swg b/SWIG/Lib/mzscheme/mzscheme.swg
index cd0a732eb..c97cd2ced 100644
--- a/SWIG/Lib/mzscheme/mzscheme.swg
+++ b/SWIG/Lib/mzscheme/mzscheme.swg
@@ -1,4 +1,4 @@
-#include <escheme.h>
+/* -*-c-*- */
typedef struct swig_proxy {
Scheme_Type type;
diff --git a/SWIG/Lib/mzscheme/mzschemedec.swg b/SWIG/Lib/mzscheme/mzschemedec.swg
new file mode 100644
index 000000000..f17b168b3
--- /dev/null
+++ b/SWIG/Lib/mzscheme/mzschemedec.swg
@@ -0,0 +1,8 @@
+/* -*-c-*- */
+/* Implementation : MZSCHEME */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include <escheme.h>
diff --git a/SWIG/Lib/mzscheme/typemaps.i b/SWIG/Lib/mzscheme/typemaps.i
index ea5989ad2..6f4b18623 100644
--- a/SWIG/Lib/mzscheme/typemaps.i
+++ b/SWIG/Lib/mzscheme/typemaps.i
@@ -1,4 +1,4 @@
-/*
+/* -*-c-*-
--------------------------------------------------
argout typemaps
convert arguments from C to Scheme
@@ -71,6 +71,12 @@ void m_output_helper(Scheme_Object **target, Scheme_Object *s, int *_lenv) {
-------------------------------------------------
*/
+%typemap(mzscheme, in) bool {
+ if(!SCHEME_BOOLP($source))
+ scheme_wrong_type("$name", "boolean", $argnum, argc, argv);
+ $target = SCHEME_TRUEP($source);
+}
+
%typemap(mzscheme, in) char {
if(!SCHEME_CHARP($source))
scheme_wrong_type("$name", "character", $argnum, argc, argv);
@@ -263,6 +269,10 @@ void m_output_helper(Scheme_Object **target, Scheme_Object *s, int *_lenv) {
------------------------------------
*/
+%typemap(mzscheme, out) bool {
+ $target = $source ? scheme_true : scheme_false;
+}
+
%typemap(mzscheme, out) char {
$target = scheme_make_character($source);
}
@@ -374,6 +384,12 @@ void m_output_helper(Scheme_Object **target, Scheme_Object *s, int *_lenv) {
------------------------------------------------------------
*/
+%typemap(mzscheme, varin) bool {
+ if(!SCHEME_BOOLP($source))
+ scheme_wrong_type("$name", "boolean", $argnum, argc, argv);
+ $target = SCHEME_TRUEP($source);
+}
+
%typemap(mzscheme, varin) char {
if(!SCHEME_CHARP($source))
scheme_wrong_type("$name", "character", $argnum, argc, argv);
@@ -567,6 +583,10 @@ void m_output_helper(Scheme_Object **target, Scheme_Object *s, int *_lenv) {
-----------------------------------
*/
+%typemap(mzscheme, varout) bool {
+ $target = $source ? scheme_true : scheme_false;
+}
+
%typemap(mzscheme, varout) char {
$target = scheme_make_character($source);
}
@@ -671,3 +691,9 @@ void m_output_helper(Scheme_Object **target, Scheme_Object *s, int *_lenv) {
$target = scheme_make_double(*$source);
}
*/
+
+/* Pass through Scheme_Object * */
+
+%typemap (guile, in) Scheme_Object * "$target=$source;";
+%typemap (guile, out) Scheme_Object * "$target=$source;";
+
diff --git a/SWIG/Lib/perl5/perl5.swg b/SWIG/Lib/perl5/perl5.swg
index 80d33a496..b9e760082 100644
--- a/SWIG/Lib/perl5/perl5.swg
+++ b/SWIG/Lib/perl5/perl5.swg
@@ -153,19 +153,19 @@ SWIGRUNTIME(int *)
_SWIG_MakePtr(CPerlObj *pPerl, SV *sv, void *ptr, swig_type_info *t)
#endif
{
- sv_setref_pv(sv, t->name, ptr);
+ sv_setref_pv(sv, (char *) t->name, ptr);
}
/* Magic variable code */
#ifndef PERL_OBJECT
#define swig_create_magic(s,a,b,c) _swig_create_magic(s,a,b,c)
-static void _swig_create_magic(SV *sv, char *name, int (*set)(SV *, MAGIC *), int (*get)(SV *,MAGIC *)) {
+static void _swig_create_magic(SV *sv, const char *name, int (*set)(SV *, MAGIC *), int (*get)(SV *,MAGIC *)) {
#else
#define swig_create_magic(s,a,b,c) _swig_create_magic(pPerl,s,a,b,c)
-static void _swig_create_magic(CPerlObj *pPerl, SV *sv, char *name, int (CPerlObj::*set)(SV *, MAGIC *), int (CPerlObj::*get)(SV *, MAGIC *)) {
+static void _swig_create_magic(CPerlObj *pPerl, SV *sv, const char *name, int (CPerlObj::*set)(SV *, MAGIC *), int (CPerlObj::*get)(SV *, MAGIC *)) {
#endif
MAGIC *mg;
- sv_magic(sv,sv,'U',name,strlen(name));
+ sv_magic(sv,sv,'U',(char *) name,strlen(name));
mg = mg_find(sv,'U');
mg->mg_virtual = (MGVTBL *) malloc(sizeof(MGVTBL));
mg->mg_virtual->svt_get = get;
diff --git a/SWIG/Lib/perl5/ptrlang.i b/SWIG/Lib/perl5/ptrlang.i
index e0cee9cf4..56cfe5b14 100644
--- a/SWIG/Lib/perl5/ptrlang.i
+++ b/SWIG/Lib/perl5/ptrlang.i
@@ -50,10 +50,10 @@ static swig_type_info *SWIG_POINTER_void_p = 0;
------------------------------------------------------------------ */
#ifdef PERL_OBJECT
-static SV *_ptrvalue(CPerlObj *pPerl,SV *_PTRVALUE, int index, char *type) {
+static SV *_ptrvalue(CPerlObj *pPerl,SV *_PTRVALUE, int index, const char *type) {
#define ptrvalue(a,b,c) _ptrvalue(pPerl,a,b,c)
#else
-static SV *_ptrvalue(SV *_PTRVALUE, int index, char *type) {
+static SV *_ptrvalue(SV *_PTRVALUE, int index, const char *type) {
#define ptrvalue(a,b,c) _ptrvalue(a,b,c)
#endif
@@ -258,10 +258,10 @@ static SV *_ptrcreate(char *type, SV *value, int numelements) {
------------------------------------------------------------------ */
#ifdef PERL_OBJECT
-static void _ptrset(CPerlObj *pPerl,SV *_PTRVALUE, SV *value, int index, char *type) {
+static void _ptrset(CPerlObj *pPerl,SV *_PTRVALUE, SV *value, int index, const char *type) {
#define ptrset(a,b,c,d) _ptrset(pPerl,a,b,c,d)
#else
-static void _ptrset(SV *_PTRVALUE, SV *value, int index, char *type) {
+static void _ptrset(SV *_PTRVALUE, SV *value, int index, const char *type) {
#define ptrset(a,b,c,d) _ptrset(a,b,c,d)
#endif
void *ptr;
diff --git a/SWIG/Lib/ruby/rubydec.swg b/SWIG/Lib/ruby/rubydec.swg
index fe1fc2780..8f3a3d08a 100644
--- a/SWIG/Lib/ruby/rubydec.swg
+++ b/SWIG/Lib/ruby/rubydec.swg
@@ -3,7 +3,7 @@
extern "C" {
#endif
-SWIGEXPORT(void) SWIG_define_class(VALUE, swig_type_info *)
+SWIGEXPORT(void) SWIG_define_class(swig_type_info *);
SWIGEXPORT(VALUE) SWIG_NewPointerObj(void *, swig_type_info *);
SWIGEXPORT(char *) SWIG_MangleStr(VALUE);
SWIGEXPORT(void *) SWIG_ConvertPtr(VALUE, swig_type_info *);
diff --git a/SWIG/Lib/tcl/object.swg b/SWIG/Lib/tcl/object.swg
index 7e806c65d..b087f36c6 100644
--- a/SWIG/Lib/tcl/object.swg
+++ b/SWIG/Lib/tcl/object.swg
@@ -57,7 +57,7 @@ SwigMethodCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONS
objv = (Tcl_Obj **) _objv;
if (objc < 2) {
- Tcl_SetResult(interp,"wrong # args.", TCL_STATIC);
+ Tcl_SetResult(interp, (char *) "wrong # args.", TCL_STATIC);
return TCL_ERROR;
}
meth = inst->classptr->methods;
@@ -79,7 +79,7 @@ SwigMethodCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONS
/* Check class methods for a match */
if (strcmp(method,"cget") == 0) {
if (objc < 3) {
- Tcl_SetResult(interp,"wrong # args.", TCL_STATIC);
+ Tcl_SetResult(interp, (char *) "wrong # args.", TCL_STATIC);
return TCL_ERROR;
}
attrname = Tcl_GetStringFromObj(objv[2],NULL);
@@ -100,12 +100,12 @@ SwigMethodCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONS
Tcl_SetObjResult(interp, Tcl_DuplicateObj(inst->thisptr));
return TCL_OK;
}
- Tcl_SetResult(interp,"Invalid attribute.", TCL_STATIC);
+ Tcl_SetResult(interp, (char *) "Invalid attribute.", TCL_STATIC);
return TCL_ERROR;
} else if (strcmp(method, "configure") == 0) {
int i;
if (objc < 4) {
- Tcl_SetResult(interp,"wrong # args.", TCL_STATIC);
+ Tcl_SetResult(interp, (char *) "wrong # args.", TCL_STATIC);
return TCL_ERROR;
}
i = 2;
@@ -127,16 +127,16 @@ SwigMethodCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONS
attr++;
}
if (inst->classptr->attributes && !(attr->name)) {
- Tcl_SetResult(interp,"Invalid attribute name.", TCL_STATIC);
+ Tcl_SetResult(interp, (char *) "Invalid attribute name.", TCL_STATIC);
return TCL_ERROR;
}
}
return TCL_OK;
} else {
- Tcl_SetResult(interp,"Invalid method. Must be one of: configure cget ", TCL_STATIC);
+ Tcl_SetResult(interp, (char *) "Invalid method. Must be one of: configure cget ", TCL_STATIC);
meth = inst->classptr->methods;
while (meth && meth->name) {
- Tcl_AppendElement(interp, meth->name);
+ Tcl_AppendElement(interp, (char *) meth->name);
meth++;
}
return TCL_ERROR;
@@ -161,7 +161,7 @@ SwigObjectCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONS
Tcl_CmdInfo ci;
if (!classptr) {
- Tcl_SetResult(interp,"swig: internal runtime error. No class object defined.", TCL_STATIC);
+ Tcl_SetResult(interp, (char *) "swig: internal runtime error. No class object defined.", TCL_STATIC);
return TCL_ERROR;
}
cons = classptr->constructor;
@@ -201,11 +201,11 @@ SwigObjectCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONS
newObj = Tcl_DuplicateObj(objv[thisarg]);
if (!name) name = Tcl_GetStringFromObj(newObj,NULL);
} else {
- Tcl_SetResult(interp,"wrong # args.", TCL_STATIC);
+ Tcl_SetResult(interp, (char *) "wrong # args.", TCL_STATIC);
return TCL_ERROR;
}
} else {
- Tcl_SetResult(interp,"No constructor available.", TCL_STATIC);
+ Tcl_SetResult(interp, (char *) "No constructor available.", TCL_STATIC);
return TCL_ERROR;
}
if (!Tcl_GetCommandInfo(interp,name,&ci)) {
@@ -222,7 +222,7 @@ SwigObjectCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONS
Tcl_CreateObjCommand(interp,name, SwigMethodCmd, (ClientData) newinst, SwigObjectDelete);
return TCL_OK;
} else {
- Tcl_SetResult(interp,"Object name already exists!", TCL_STATIC);
+ Tcl_SetResult(interp, (char *) "Object name already exists!", TCL_STATIC);
return TCL_ERROR;
}
}
diff --git a/SWIG/Lib/tcl/swigtcl8.swg b/SWIG/Lib/tcl/swigtcl8.swg
index 44087256d..13828588d 100644
--- a/SWIG/Lib/tcl/swigtcl8.swg
+++ b/SWIG/Lib/tcl/swigtcl8.swg
@@ -33,7 +33,7 @@ SWIG_ConvertPtrFromString(Tcl_Interp *interp, char *c, void **ptr, swig_type_inf
if (*c != '_') {
*ptr = (void *) 0;
if (strcmp(c,"NULL") == 0) return TCL_OK;
- Tcl_SetResult(interp,"Type error. Expected a pointer", TCL_STATIC);
+ Tcl_SetResult(interp, (char *) "Type error. Expected a pointer", TCL_STATIC);
return TCL_ERROR;
}
c++;
@@ -51,8 +51,8 @@ SWIG_ConvertPtrFromString(Tcl_Interp *interp, char *c, void **ptr, swig_type_inf
if (ty) {
tc = SWIG_TypeCheck(c,ty);
if (!tc) {
- Tcl_SetResult(interp,"Type error. Expected ", TCL_STATIC);
- Tcl_AppendElement(interp, ty->name);
+ Tcl_SetResult(interp, (char *) "Type error. Expected ", TCL_STATIC);
+ Tcl_AppendElement(interp, (char *) ty->name);
return TCL_ERROR;
}
*ptr = SWIG_TypeCast(tc,(void *)p);
@@ -139,7 +139,7 @@ SWIG_GetArgs(Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[], const char *fm
}
if (argno >= (objc-1)) {
if (!opt) {
- Tcl_SetResult(interp,"Wrong # args. ", TCL_STATIC);
+ Tcl_SetResult(interp, (char *) "Wrong # args. ", TCL_STATIC);
goto argerror;
} else {
va_end(ap);
@@ -195,7 +195,7 @@ SWIG_GetArgs(Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[], const char *fm
}
}
if ((objc-1) > argno) {
- Tcl_SetResult(interp,"Wrong # args.", TCL_STATIC);
+ Tcl_SetResult(interp, (char *) "Wrong # args.", TCL_STATIC);
goto argerror;
}
va_end(ap);
diff --git a/SWIG/Lib/tcl/tclsh.i b/SWIG/Lib/tcl/tclsh.i
index 839de3be9..6301b2024 100644
--- a/SWIG/Lib/tcl/tclsh.i
+++ b/SWIG/Lib/tcl/tclsh.i
@@ -48,12 +48,12 @@ int Tcl_AppInit(Tcl_Interp *interp){
if (SWIG_init(interp) == TCL_ERROR)
return TCL_ERROR;
#if TCL_MAJOR_VERSION > 7 || TCL_MAJOR_VERSION == 7 && TCL_MINOR_VERSION >= 5
- Tcl_SetVar(interp,"tcl_rcFileName",SWIG_RcFileName,TCL_GLOBAL_ONLY);
+ Tcl_SetVar(interp, (char *) "tcl_rcFileName",SWIG_RcFileName,TCL_GLOBAL_ONLY);
#else
tcl_RcFileName = SWIG_RcFileName;
#endif
#ifdef SWIG_RcRsrcName
- Tcl_SetVar(interp,"tcl_rcRsrcName",SWIG_RcRsrcName,TCL_GLOBAL);
+ Tcl_SetVar(interp, (char *) "tcl_rcRsrcName",SWIG_RcRsrcName,TCL_GLOBAL);
#endif
return TCL_OK;
diff --git a/SWIG/Lib/tcl/wish.i b/SWIG/Lib/tcl/wish.i
index 201a438b9..6bef3ba7c 100644
--- a/SWIG/Lib/tcl/wish.i
+++ b/SWIG/Lib/tcl/wish.i
@@ -7,6 +7,9 @@
//
/* Revision History
* $Log$
+ * Revision 1.1.2.1 2001/06/20 11:47:29 mkoeppe
+ * Portability fixes
+ *
* Revision 1.1 2000/01/11 21:15:54 beazley
* Added files
*
@@ -122,7 +125,7 @@ int Tcl_AppInit(Tcl_Interp *interp)
*/
#if TCL_MAJOR_VERSION >= 8 || TCL_MAJOR_VERSION == 7 && TCL_MINOR_VERSION >= 5
- Tcl_SetVar(interp,"tcl_rcFileName",SWIG_RcFileName,TCL_GLOBAL_ONLY);
+ Tcl_SetVar(interp, (char *) "tcl_rcFileName",SWIG_RcFileName,TCL_GLOBAL_ONLY);
#else
tcl_RcFileName = SWIG_RcFileName;
#endif
@@ -131,7 +134,7 @@ int Tcl_AppInit(Tcl_Interp *interp)
#ifdef MAC_TCL
#ifdef SWIG_RcRsrcName
- Tcl_SetVar(interp,"tcl_rcRsrcName",SWIG_RcRsrcName,TCL_GLOBAL_ONLY);
+ Tcl_SetVar(interp, (char *) "tcl_rcRsrcName",SWIG_RcRsrcName,TCL_GLOBAL_ONLY);
#endif
#endif
return TCL_OK;
diff --git a/SWIG/Makefile.in b/SWIG/Makefile.in
index 7e097277f..02bfcee85 100644
--- a/SWIG/Makefile.in
+++ b/SWIG/Makefile.in
@@ -20,9 +20,10 @@ RANLIB = @RANLIB@
# Note: Files in `SWIG_LIB' are machine independent so we use `prefix'
# instead of `exec_prefix' or, derivatively, `libdir'.
-SWIG_LIB = $(prefix)/lib/swig1.3
+SWIG_LIB = @swig_lib@
BIN_DIR = @bindir@
-TARGET = swig
+RELEASESUFFIX = @release_suffix@
+TARGET = swig$(RELEASESUFFIX)
SOURCE = Source
SOURCEDIRS = `ls $(SOURCE)`
@@ -35,7 +36,7 @@ swig: SWIG1.1 Modules1.1 Swig Preprocessor DOH
$(SOURCE)/DOH/libdoh.a \
$(LIBS)
-experiment: Swig Preprocessor LParse Experiment DOH Modules
+experiment: Swig Preprocessor LParse DOH Modules
$(CXX) -o $(TARGET) \
$(SOURCE)/Experiment/libexp.a \
$(SOURCE)/LParse/liblparse.a \
@@ -45,33 +46,37 @@ experiment: Swig Preprocessor LParse Experiment DOH Modules
$(SOURCE)/DOH/libdoh.a \
$(LIBS)
-SWIG1.1:
+SWIG1.1: Source/Include/swigconfig.h
@cd $(SOURCE)/SWIG1.1; $(MAKE)
-Modules1.1:
+Modules1.1: Source/Include/swigconfig.h
@cd $(SOURCE)/Modules1.1; $(MAKE)
-Swig:
+Swig: Source/Include/swigconfig.h
@cd $(SOURCE)/Swig; $(MAKE)
-Preprocessor:
+Preprocessor: Source/Include/swigconfig.h
@cd $(SOURCE)/Preprocessor; $(MAKE)
-LParse:
+LParse: Source/Include/swigconfig.h
@cd $(SOURCE)/LParse; $(MAKE)
-Experiment:
- @cd $(SOURCE)/Experiment; $(MAKE)
-
-DOH:
+DOH: Source/Include/swigconfig.h
@cd $(SOURCE)/DOH; $(MAKE)
-Modules:
+Modules: Source/Include/swigconfig.h
@cd $(SOURCE)/Modules; $(MAKE)
.PHONY: SWIG1.1 Modules1.1 Swig Preprocessor LParse \
Experiment Swim SWILL DOH Swithe
+# Config file must be generated at make time, rather than at configure
+# time because it paths need to be substituted.
+
+Source/Include/swigconfig.h: Source/Include/swigconfig.h.in Makefile.in config.status
+ sed 's|@-swig_lib-@|$(SWIG_LIB)|g;s|@-exec_prefix-@|$(exec_prefix)|g;s|@-release_suffix-@|$(RELEASESUFFIX)|g' Source/Include/swigconfig.h.in > $@
+
+
#####################################################################
# Runtime libraries
#####################################################################
@@ -92,56 +97,122 @@ skip-mzscheme = [ -z "@MZC@" ]
skip-ruby = [ -z "@RUBY@" -o -z "@RUBYINCLUDE@" -o -z "@RUBYLIB@" ]
chk-swiglib = @ROOT_DIR@/Lib
-chk = $(MAKE) SWIG_LIB=$(chk-swiglib) check
+chk = $(MAKE) -k -s SWIG_LIB=$(chk-swiglib) SWIG=@ROOT_DIR@/$(TARGET) check
check-aliveness:
- test -x ./swig
- ./swig -version
- ./swig -help
- $(skip-tcl) || ./swig -tcl -help
- $(skip-perl) || ./swig -perl -help
- $(skip-python) || ./swig -python -help
- $(skip-java) || ./swig -java -help
- $(skip-guile) || ./swig -guile -help
- $(skip-mzscheme) || ./swig -mzscheme -help
- $(skip-ruby) || ./swig -ruby -help
-
-check-examples:
- $(skip-tcl) || (cd Examples/tcl/class && $(chk))
- $(skip-tcl) || (cd Examples/tcl/constants && $(chk))
- $(skip-tcl) || (cd Examples/tcl/pointer && $(chk))
- $(skip-tcl) || (cd Examples/tcl/reference && $(chk))
- $(skip-tcl) || (cd Examples/tcl/simple && $(chk))
- $(skip-tcl) || (cd Examples/tcl/value && $(chk))
- $(skip-tcl) || (cd Examples/tcl/variables && $(chk))
- $(skip-perl) || (cd Examples/perl5/class && $(chk))
- $(skip-perl) || (cd Examples/perl5/constants && $(chk))
- $(skip-perl) || (cd Examples/perl5/pointer && $(chk))
- $(skip-perl) || (cd Examples/perl5/reference && $(chk))
- $(skip-perl) || (cd Examples/perl5/simple && $(chk))
- $(skip-perl) || (cd Examples/perl5/value && $(chk))
- $(skip-perl) || (cd Examples/perl5/variables && $(chk))
- $(skip-python) || (cd Examples/python/class && $(chk))
- $(skip-python) || (cd Examples/python/constants && $(chk))
- $(skip-python) || (cd Examples/python/pointer && $(chk))
- $(skip-python) || (cd Examples/python/reference && $(chk))
- $(skip-python) || (cd Examples/python/simple && $(chk))
- $(skip-python) || (cd Examples/python/value && $(chk))
- $(skip-python) || (cd Examples/python/variables && $(chk))
- $(skip-java) || (cd Examples/java/native && $(chk))
- $(skip-java) || (cd Examples/java/simple && $(chk))
- $(skip-java) || (cd Examples/java/typemap && $(chk))
- $(skip-guile) || (cd Examples/guile/matrix && $(chk))
- $(skip-guile) || (cd Examples/guile/simple && $(chk))
- $(skip-guile) || (cd Examples/guile/port && $(chk))
- $(skip-mzscheme) || (cd Examples/mzscheme/simple && $(chk))
- $(skip-ruby) || (cd Examples/ruby/class && $(chk))
- $(skip-ruby) || (cd Examples/ruby/constants && $(chk))
- $(skip-ruby) || (cd Examples/ruby/pointer && $(chk))
- $(skip-ruby) || (cd Examples/ruby/reference && $(chk))
- $(skip-ruby) || (cd Examples/ruby/simple && $(chk))
- $(skip-ruby) || (cd Examples/ruby/value && $(chk))
- $(skip-ruby) || (cd Examples/ruby/variables && $(chk))
+ test -x ./$(TARGET)
+ ./$(TARGET) -version
+ ./$(TARGET) -help
+ $(skip-tcl) || ./$(TARGET) -tcl -help
+ $(skip-perl) || ./$(TARGET) -perl -help
+ $(skip-python) || ./$(TARGET) -python -help
+ $(skip-java) || ./$(TARGET) -java -help
+ $(skip-guile) || ./$(TARGET) -guile -help
+ $(skip-mzscheme) || ./$(TARGET) -mzscheme -help
+ $(skip-ruby) || ./$(TARGET) -ruby -help
+
+TCL_EXAMPLES = class constants enum funcptr pointer reference simple value variables
+PERL5_EXAMPLES = class constants funcptr pointer reference simple value variables pointer-cxx
+PYTHON_EXAMPLES = class constants enum funcptr pointer reference shadow simple value variables
+JAVA_EXAMPLES = class constants enum native reference simple typemap
+GUILE_EXAMPLES = matrix simple port test-suite
+MZSCHEME_EXAMPLES = simple
+RUBY_EXAMPLES = class constants enum funcptr pointer reference simple value variables
+
+check-examples: check-tcl-examples check-perl5-examples check-python-examples \
+ check-java-examples check-guile-examples check-mzscheme-examples \
+ check-ruby-examples
+
+check-tcl-examples:
+ @if $(skip-tcl); then \
+ echo Skipping Tcl tests; \
+ else \
+ passed=true; \
+ for a in $(TCL_EXAMPLES); do \
+ echo Checking Examples/tcl/$$a; \
+ (cd Examples/tcl/$$a && $(chk)) \
+ || passed=false; \
+ done; \
+ test $$passed = true; \
+ fi
+
+check-perl5-examples:
+ @if $(skip-perl); then \
+ echo Skipping Perl tests; \
+ else \
+ passed=true; \
+ for a in $(PERL5_EXAMPLES); do \
+ echo Checking Examples/perl5/$$a; \
+ (cd Examples/perl5/$$a && $(chk)) \
+ || passed=false; \
+ done; \
+ test $$passed = true; \
+ fi
+
+check-python-examples:
+ @if $(skip-python); then \
+ echo Skipping Python tests; \
+ else \
+ passed=true; \
+ for a in $(PYTHON_EXAMPLES); do \
+ echo Checking Examples/python/$$a; \
+ (cd Examples/python/$$a && $(chk)) \
+ || passed=false; \
+ done; \
+ test $$passed = true; \
+ fi
+
+check-java-examples:
+ @if $(skip-java); then \
+ echo Skipping Java tests; \
+ else \
+ passed=true; \
+ for a in $(JAVA_EXAMPLES); do \
+ echo Checking Examples/java/$$a; \
+ (cd Examples/java/$$a && $(chk)) \
+ || passed=false; \
+ done; \
+ test $$passed = true; \
+ fi
+
+check-guile-examples:
+ @if $(skip-guile); then \
+ echo Skipping Guile tests; \
+ else \
+ passed=true; \
+ for a in $(GUILE_EXAMPLES); do \
+ echo Checking Examples/guile/$$a; \
+ (cd Examples/guile/$$a && $(chk)) \
+ || passed=false; \
+ done; \
+ test $$passed = true; \
+ fi
+
+check-mzscheme-examples:
+ @if $(skip-mzscheme); then \
+ echo Skipping MzScheme tests; \
+ else \
+ passed=true; \
+ for a in $(MZSCHEME_EXAMPLES); do \
+ echo Checking Examples/mzscheme/$$a; \
+ (cd Examples/mzscheme/$$a && $(chk)) \
+ || passed=false; \
+ done; \
+ test $$passed = true; \
+ fi
+
+check-ruby-examples:
+ @if $(skip-ruby); then \
+ echo Skipping Ruby tests; \
+ else \
+ passed=true; \
+ for a in $(RUBY_EXAMPLES); do \
+ echo Checking Examples/ruby/$$a; \
+ (cd Examples/ruby/$$a && $(chk)) \
+ || passed=false; \
+ done; \
+ test $$passed = true; \
+ fi
Examples/GIFPlot/libgifplot.a:
cd Examples/GIFPlot/Lib ; $(MAKE)
@@ -151,12 +222,14 @@ check-gifplot-example: Examples/GIFPlot/libgifplot.a
$(skip-perl) || (cd Examples/GIFPlot/Perl/simple && $(chk))
$(skip-perl) || (cd Examples/GIFPlot/Perl/shadow && $(chk))
$(skip-python) || (cd Examples/GIFPlot/Python/full && $(chk))
+ $(skip-python) || (cd Examples/GIFPlot/Python/shadow && $(chk))
$(skip-python) || (cd Examples/GIFPlot/Python/simple && $(chk))
$(skip-tcl) || (cd Examples/GIFPlot/Tcl/full && $(chk))
$(skip-tcl) || (cd Examples/GIFPlot/Tcl/mandel && $(chk))
$(skip-tcl) || (cd Examples/GIFPlot/Tcl/simple && $(chk))
$(skip-guile) || (cd Examples/GIFPlot/Guile/full && $(chk))
$(skip-guile) || (cd Examples/GIFPlot/Guile/simple && $(chk))
+ $(skip-java) || (cd Examples/GIFPlot/Java && $(chk))
$(skip-ruby) || (cd Examples/GIFPlot/Ruby/full && $(chk))
$(skip-ruby) || (cd Examples/GIFPlot/Ruby/simple && $(chk))
$(skip-ruby) || (cd Examples/GIFPlot/Ruby/shadow && $(chk))
@@ -179,7 +252,7 @@ clean:
fi \
done;
@cd Runtime; $(MAKE) clean
- rm -f swig
+ rm -f $(TARGET)
distclean-dead = config.status config.log config.cache \
@configure_substituted_files@
@@ -202,64 +275,64 @@ install: install-main install-lib install-runtime
install-main:
@echo "Installing $(BIN_DIR)/swig"
- @$(MKINSTDIRS) $(BIN_DIR)
- @if [ -f swig.exe ]; then \
- $(INSTALL_PROGRAM) swig.exe $(BIN_DIR)/swig.exe; \
- else \
- $(INSTALL_PROGRAM) swig $(BIN_DIR)/swig; \
+ @$(MKINSTDIRS) $(DESTDIR)$(BIN_DIR)
+ @if [ -f swig.exe ]; then \
+ $(INSTALL_PROGRAM) swig.exe $(DESTDIR)$(BIN_DIR)/swig.exe; \
+ else \
+ $(INSTALL_PROGRAM) $(TARGET) $(DESTDIR)$(BIN_DIR)/$(TARGET); \
fi
install-lib:
@echo "Installing the SWIG library"
- @$(MKINSTDIRS) $(SWIG_LIB)
+ @$(MKINSTDIRS) $(DESTDIR)$(SWIG_LIB)
# cd $(SWIG_LIB); rm -rf *
# The following line has `*.swg' removed -- add it back if needed.
@cd $(srcdir)/Lib; for i in *.i *.swg; \
do \
echo "Installing Lib/$$i"; \
- ../$(INSTALL_DATA) $$i $(SWIG_LIB)/$$i; \
+ ../$(INSTALL_DATA) $$i $(DESTDIR)$(SWIG_LIB)/$$i; \
done;
- @$(MKINSTDIRS) $(SWIG_LIB)/tcl
+ @$(MKINSTDIRS) $(DESTDIR)$(SWIG_LIB)/tcl
@cd $(srcdir)/Lib/tcl; for i in *.i *.swg; \
do \
echo "Installing Lib/tcl/$$i"; \
- ../../$(INSTALL_DATA) $$i $(SWIG_LIB)/tcl/$$i; \
+ ../../$(INSTALL_DATA) $$i $(DESTDIR)$(SWIG_LIB)/tcl/$$i; \
done;
- @$(MKINSTDIRS) $(SWIG_LIB)/perl5
+ @$(MKINSTDIRS) $(DESTDIR)$(SWIG_LIB)/perl5
@cd $(srcdir)/Lib/perl5; for i in *.i *.swg Makefile.pl; \
do \
echo "Installing Lib/perl5/$$i"; \
- ../../$(INSTALL_DATA) $$i $(SWIG_LIB)/perl5/$$i; \
+ ../../$(INSTALL_DATA) $$i $(DESTDIR)$(SWIG_LIB)/perl5/$$i; \
done;
- @$(MKINSTDIRS) $(SWIG_LIB)/python
+ @$(MKINSTDIRS) $(DESTDIR)$(SWIG_LIB)/python
@cd $(srcdir)/Lib/python; for i in *.i *.swg; \
do \
echo "Installing Lib/python/$$i"; \
- ../../$(INSTALL_DATA) $$i $(SWIG_LIB)/python/$$i; \
+ ../../$(INSTALL_DATA) $$i $(DESTDIR)$(SWIG_LIB)/python/$$i; \
done;
- @$(MKINSTDIRS) $(SWIG_LIB)/guile
+ @$(MKINSTDIRS) $(DESTDIR)$(SWIG_LIB)/guile
@cd $(srcdir)/Lib/guile; for i in *.i *.swg; \
do \
echo "Installing Lib/guile/$$i"; \
- ../../$(INSTALL_DATA) $$i $(SWIG_LIB)/guile/$$i; \
+ ../../$(INSTALL_DATA) $$i $(DESTDIR)$(SWIG_LIB)/guile/$$i; \
done;
- @$(MKINSTDIRS) $(SWIG_LIB)/java
+ @$(MKINSTDIRS) $(DESTDIR)$(SWIG_LIB)/java
@cd $(srcdir)/Lib/java; for i in *.i *.swg; \
do \
echo "Installing Lib/java/$$i"; \
- ../../$(INSTALL_DATA) $$i $(SWIG_LIB)/java/$$i; \
+ ../../$(INSTALL_DATA) $$i $(DESTDIR)$(SWIG_LIB)/java/$$i; \
done;
- @$(MKINSTDIRS) $(SWIG_LIB)/mzscheme
+ @$(MKINSTDIRS) $(DESTDIR)$(SWIG_LIB)/mzscheme
@cd $(srcdir)/Lib/mzscheme; for i in *.i *.swg; \
do \
echo "Installing Lib/mzscheme/$$i"; \
- ../../$(INSTALL_DATA) $$i $(SWIG_LIB)/mzscheme/$$i; \
+ ../../$(INSTALL_DATA) $$i $(DESTDIR)$(SWIG_LIB)/mzscheme/$$i; \
done;
- @$(MKINSTDIRS) $(SWIG_LIB)/ruby
+ @$(MKINSTDIRS) $(DESTDIR)$(SWIG_LIB)/ruby
@cd $(srcdir)/Lib/ruby; for i in *.i *.swg Makefile.swig extconf.rb; \
do \
echo "Installing Lib/ruby/$$i"; \
- ../../$(INSTALL_DATA) $$i $(SWIG_LIB)/ruby/$$i; \
+ ../../$(INSTALL_DATA) $$i $(DESTDIR)$(SWIG_LIB)/ruby/$$i; \
done;
install-runtime:
diff --git a/SWIG/NEW b/SWIG/NEW
index 2fb195d18..760c61387 100644
--- a/SWIG/NEW
+++ b/SWIG/NEW
@@ -187,7 +187,7 @@ and it is simpler to implement than the old string based approach.
6. New Features
---------------
-6.1 Java module added (although broken in SWIG1.3a4)
+6.1 Java module added
6.2 Ruby module added
diff --git a/SWIG/README b/SWIG/README
index e84918f89..8f1340f70 100644
--- a/SWIG/README
+++ b/SWIG/README
@@ -1,67 +1,37 @@
SWIG (Simplified Wrapper and Interface Generator)
-Version: 1.3 (alpha)
+Version: 1.3.6 (July 9, 2001)
$Header$
-Tagline: SWIG is a compiler that integrates C and C++ with scripting
+Tagline: SWIG is a compiler that integrates C and C++ with
languages including Perl, Python, Tcl, Guile, Mzscheme,
- and Ruby.
+ Java and Ruby.
-This distribution represents work in progress towards building a new
-SWIG release. The guilty parties working on this are:
+SWIG reads annotated C/C++ header files and creates wrapper code (glue
+code) in order to make the corresponding C/C++ libraries available to
+the listed languages, or to extend C/C++ programs with a scripting
+language.
+
+This distribution represents the new stable release of SWIG, aiming to
+replace versions 1.1p5 and 1.1-883. The guilty parties working on this
+are:
Dave Beazley (beazley@cs.uchicago.edu) (SWIG core)
Loic Dachary (loic@ceic.com) (Perl5)
- Harco de Hilster (Harco.de.Hilster@ATComputing.nl) (Java)
+ William Fulton (wfulton1@motorola.com) (Java)
Thien-Thi Nguyen (ttn@glug.org) (Testing/Misc)
Masaki Fukushima (fukusima@goto.info.waseda.ac.jp) (Ruby)
- Matthias Köppe (mkoeppe@saturn.Math.Uni-Magdeburg.DE) (Guile)
- Oleg Tolmatcev (o.t@altavista.net) (Mzscheme)
-
-Past contributors (currently incomplete):
-
-Dustin Mitchell, Ian Cooke, Catalin Dumitrescu, Baran Kovuk, Gary Holt,
-David Fletcher.
+ Matthias Köppe (mkoeppe@mail.math.uni-magdeburg.de) (Guile/MzScheme)
-***********************************************************************
-***** IMPORTANT NOTICE -- READ THIS NOW (OR ELSE) *****
-***********************************************************************
+Past contributors (see the CHANGES file for a complete list):
-If you downloaded SWIG as a prepackaged release such as SWIG1.3a4, be
-advised that this distribution represents a snapshot of the most
-"stable" part of the SWIG CVS repository. As this is an unstable
-release, there is a pretty good chance that a number of features are
-broken or under repair. Currently, SWIG is undergoing a large
-redevelopment effort in which it is being converted from C++ to ANSI C
-and restructured to be more extensible. As a result, the source code
-is very disorganized at the moment. The SWIG1.3 series of releases
-should be viewed as transitional releases leading to the eventual
-release of SWIG2.0. First-time users should probably start with
-SWIG1.1p5 which is significantly more stable (and includes a wider
-range of documentation and examples).
+Clark McGrew, Dustin Mitchell, Ian Cooke, Catalin Dumitrescu, Baran
+Kovuk, Gary Holt, David Fletcher, Oleg Tolmatcev, Harco de Hilster.
-*** WE NEED YOUR HELP! ***
+Up-to-date SWIG related information can be found at
-Please report any errors and submit patches (if possible)! Not only
-are we making radical changes to the system, we only have access to a
-limited variety of hardware (Linux, Solaris, and Windows). All
-contributions help.
-
-*** Backwards Compatibility ***
-
-Although we are making every attempt preserve backwards compatibility
-with interfaces written for SWIG1.1, SWIG1.3 incorporates a number of
-very substantial modifications to things such as type handling,
-typemaps, and wrapper code generation. Therefore, if you are making
-extensive use of advanced SWIG features, interfaces written for
-SWIG1.1 may not work. We apologize for the inconvenience, but these
-changes are needed in order to remove a variety of annoying "features"
-of SWIG1.1.
-
-In addition, SWIG1.3 makes no attempt to be compatible with SWIG1.1 at
-the C++ API level so language modules written for SWIG1.1 will most
-definitely not work with this release.
+ http://www.swig.org
What's New?
===========
@@ -73,18 +43,18 @@ Here are the most notable changes (so far):
substantially improved both in terms of size and runtime
efficiency (Perl5 is coming along too).
- - Java module is now included.
-
- The Guile module is stable. It represents C pointers as smobs and
supports the Guile module system and exceptions.
- - Ruby and mzscheme modules added.
+ - Java, Ruby, and MzScheme modules added.
- Testing framework part of the distribution ("make check" support).
- A lot of minor bug fixes and cleanup.
-Here are a few missing features
+ - SWIG requires an ANSI C compiler.
+
+Here are a few missing features:
- The SWIG1.1 documentation system is gone and hasn't been
replaced yet. This is on the long-term to-do list.
@@ -95,24 +65,25 @@ Here are a few missing features
- A wide variety of old SWIG command-line options and
obscure features are gone.
-What's Broken?
-==============
-
- - The Java module is broken and temporarily unavailable (SWIG1.3a4).
-
- Objective C support doesn't work right now. No ETA as to
when it will return.
- - SWIG requires an ANSI C compiler.
+Although we are making every attempt preserve backwards compatibility
+with interfaces written for SWIG1.1, SWIG1.3 incorporates a number of
+very substantial modifications to things such as type handling,
+typemaps, and wrapper code generation. Therefore, if you are making
+extensive use of advanced SWIG features, interfaces written for
+SWIG1.1 may not work. We apologize for the inconvenience, but these
+changes are needed in order to remove a variety of annoying "features"
+of SWIG1.1.
- - A number of low-level data structures have been converted
- to C. Since things haven't yet been fully tested, there's
- a chance that unusual corner cases might cause SWIG to crash.
- If so, please send us a debugger traceback if possible.
+In addition, SWIG1.3 makes no attempt to be compatible with SWIG1.1 at
+the C++ API level so language modules written for SWIG1.1 will most
+definitely not work with this release.
- - The CHANGES file describes in some detail all of the important
- changes that have been made to the system. Experienced
- users would be advised to read this.
+The files NEW and CHANGES describe in some detail all of the important
+changes that have been made to the system. Experienced users would be
+advised to read this.
Installation
============
@@ -131,12 +102,21 @@ the following before doing the 'make install' step above.
If you don't know what the runtime libraries are, don't worry
about this step.
-The Examples directory contains a few examples of using SWIG.
+The file INSTALL details more about using configure. Also try
+
+ % ./configure --help.
+
+The configure script will attempt to locate various packages on your
+machine, including Tcl, Perl5, Python and other target languages that SWIG
+uses. Don't panic if you get 'not found' messages--SWIG does not need these
+packages to compile or run. The configure script is actually looking for
+these packages so that you can try out the SWIG examples contained
+in the 'Examples' directory without having to hack Makefiles.
Notes:
-(1) If you checked the code out via CVS, you will have to run autoconf
- before typing 'configure.' In addition, a full build of SWIG requires
+(1) If you checked the code out via CVS, you will have to run ./autogen.sh
+ before typing 'configure'. In addition, a full build of SWIG requires
the use of bison.
(2) If you are using Windows, the easiest way to install and build
@@ -146,38 +126,36 @@ Notes:
The SWIG1.1p5 distribution also contains a number of examples configured
to work with Visual C++ (most of which should also work with SWIG1.3).
-(3) 'make check' is a new feature that requires all of the target languages
- to be installed and which performs compile/link level testing
- of the examples. If it fails, it may mean that you have an uninstalled
- language module or that the file 'Examples/Makefile' has been
- incorrectly configured. It may also fail due to compiler issues
- such as broken C++ compiler. Even if 'make check' fails, there is a
- pretty good chance SWIG still works correctly---you will just have
- to mess around with one of the examples and some makefiles first.
+(3) 'make check' is a new feature that requires at least one of the target
+ languages to be installed and which performs compile/link level testing
+ of the examples. If it fails, it may mean that you have an uninstalled
+ language module or that the file 'Examples/Makefile' has been
+ incorrectly configured. It may also fail due to compiler issues
+ such as broken C++ compiler. Even if 'make check' fails, there is a
+ pretty good chance SWIG still works correctly---you will just have
+ to mess around with one of the examples and some makefiles first.
Examples
========
-The Examples directory contains a variety of new examples and it has some
-browsable documentation. Simply point your browser to the file
-"Example/index.html".
+The Examples directory contains a variety of examples of using SWIG
+and it has some browsable documentation. Simply point your browser to
+the file "Example/index.html".
Documentation
=============
-No documentation is currently included in this release. However, most
-of the documentation for SWIG1.1 still applies. This can be obtained
-on http://www.swig.org.
+No user documentation is currently included in this release. However,
+most of the documentation for SWIG1.1 still applies. This can be
+obtained on http://www.swig.org.
+
+There is some technical documentation available in the Doc subdirectory.
Participate!
============
-We are looking for people who want to join the effort of getting this
-next release off the ground. Please send me email for details.
--- Dave (beazley@cs.uchicago.edu)
+Please report any errors and submit patches (if possible)! We only
+have access to a limited variety of hardware (Linux, Solaris, and
+Windows). All contributions help.
+Contributions of new language modules will also be accepted.
-Developer Information
-=====================
-The primary goal of future development is to make SWIG more modular,
-extensible, and easier to maintain. To this end, the source code has
-been consolidated and reorganized with the Source directory. For more
-information, please see Doc/internals.html.
+ -- The SWIG Maintainers
diff --git a/SWIG/Runtime/.cvsignore b/SWIG/Runtime/.cvsignore
new file mode 100644
index 000000000..cda4e782d
--- /dev/null
+++ b/SWIG/Runtime/.cvsignore
@@ -0,0 +1,7 @@
+.libs
+Makefile
+lib*.c
+lib*.lo
+lib*.la
+swigtcl8.c
+swigtcl8.lo
diff --git a/SWIG/Runtime/Makefile.in b/SWIG/Runtime/Makefile.in
index 6b6031c62..6f9cef39f 100644
--- a/SWIG/Runtime/Makefile.in
+++ b/SWIG/Runtime/Makefile.in
@@ -13,19 +13,26 @@ VPATH = @srcdir@
CC = @CC@
LIBTOOL = ../Tools/libtool
SWIGLIB = ../Lib
-LIBS = libswigpl.la libswigpy.la libswigtcl8.la libswigrb.la
+RELEASESUFFIX = @release_suffix@
+LIBS = libswigpl$(RELEASESUFFIX).la libswigpy$(RELEASESUFFIX).la \
+ libswigtcl8$(RELEASESUFFIX).la libswigrb$(RELEASESUFFIX).la \
+ libswigguile$(RELEASESUFFIX).la
LIB_DIR = $(exec_prefix)/lib
all:
- @sh $(srcdir)/make.sh
-
+ -$(MAKE) perl5
+ -$(MAKE) python
+ -$(MAKE) tcl
+ -$(MAKE) ruby
+ -$(MAKE) guile
install:
@echo "Installing runtime libraries"
@for i in $(LIBS); \
do \
if [ -f $$i ]; then \
- $(LIBTOOL) install -c $$i $(LIB_DIR)/$$i; \
+ echo $(LIBTOOL) install -c $$i $(DESTDIR)$(LIB_DIR)/$$i; \
+ $(LIBTOOL) install -c $$i $(DESTDIR)$(LIB_DIR)/$$i; \
fi; \
done;
@@ -42,14 +49,14 @@ TCL_INCLUDE = @TCLINCLUDE@
TCL_RUNTIME = $(SWIGLIB)/tcl/swigtcl8.swg
# Tcl 8.x
-tcl: libswigtcl8.la
+tcl: libswigtcl8$(RELEASESUFFIX).la
-libswigtcl8.la:
+libswigtcl8$(RELEASESUFFIX).la:
rm -f swigtcl8.c
cat $(srcdir)/$(SWIG_TYPECHECK) $(srcdir)/$(TCL_RUNTIME) >> swigtcl8.c
# -cp $(srcdir)/$(TCL_RUNTIME) swigtcl8.c
$(LIBTOOL) $(CC) -c $(TCL_INCLUDE) -DSWIG_GLOBAL swigtcl8.c
- $(LIBTOOL) $(CC) -o libswigtcl8.la swigtcl8.lo -rpath $(LIB_DIR) -avoid-version
+ $(LIBTOOL) $(CC) -o libswigtcl8$(RELEASESUFFIX).la swigtcl8.lo -rpath $(LIB_DIR) -avoid-version
# ----------------------------------------------------------------------
# Python run-time library
@@ -60,14 +67,14 @@ PYTHON_RUNTIME = $(SWIGLIB)/python/python.swg
# Python shared
-python: libswigpy.la
+python: libswigpy$(RELEASESUFFIX).la
-libswigpy.la:
+libswigpy$(RELEASESUFFIX).la:
rm -f libpy.c
cat $(srcdir)/$(SWIG_TYPECHECK) $(srcdir)/$(PYTHON_RUNTIME) >> libpy.c
# -cp $(srcdir)/$(PYTHON_RUNTIME) libpy.c
$(LIBTOOL) $(CC) -c $(PYTHON_INCLUDE) -DSWIG_GLOBAL libpy.c
- $(LIBTOOL) $(CC) -o libswigpy.la libpy.lo -rpath $(LIB_DIR) -avoid-version
+ $(LIBTOOL) $(CC) -o libswigpy$(RELEASESUFFIX).la libpy.lo -rpath $(LIB_DIR) -avoid-version
# ----------------------------------------------------------------------
# Perl run-time library
@@ -78,14 +85,14 @@ PERL5_RUNTIME = $(SWIGLIB)/perl5/perl5.swg
# Perl shared
-perl5: libswigpl.la
+perl5: libswigpl$(RELEASESUFFIX).la
-libswigpl.la:
+libswigpl$(RELEASESUFFIX).la:
@rm -f libperl.c
# cat $(srcdir)/perlrun.h >> libperl.c
cat $(srcdir)/$(SWIG_TYPECHECK) $(srcdir)/$(PERL5_RUNTIME) >> libperl.c
$(LIBTOOL) $(CC) -c $(PERL5_INCLUDE) -DSWIG_GLOBAL -Dbool=char -Dexplicit= libperl.c
- $(LIBTOOL) $(CC) -o libswigpl.la libperl.lo -rpath $(LIB_DIR) -avoid-version
+ $(LIBTOOL) $(CC) -o libswigpl$(RELEASESUFFIX).la libperl.lo -rpath $(LIB_DIR) -avoid-version
# ----------------------------------------------------------------------
# Ruby run-time library
@@ -96,11 +103,29 @@ RUBY_RUNTIME = $(SWIGLIB)/ruby/ruby.swg
# Ruby shared
-ruby: libswigrb.la
+ruby: libswigrb$(RELEASESUFFIX).la
-libswigrb.la:
+libswigrb$(RELEASESUFFIX).la:
rm -f librb.c
# cp $(srcdir)/$(RUBY_RUNTIME) librb.c
cat $(srcdir)/$(SWIG_TYPECHECK) $(srcdir)/$(RUBY_RUNTIME) $(SWIGLIB)/ruby/rubydef.swg >> librb.c
$(LIBTOOL) $(CC) -c $(RUBY_INCLUDE) -DSWIG_GLOBAL librb.c
- $(LIBTOOL) $(CC) -o libswigrb.la librb.lo -rpath $(LIB_DIR) -avoid-version
+ $(LIBTOOL) $(CC) -o libswigrb$(RELEASESUFFIX).la librb.lo -rpath $(LIB_DIR) -avoid-version
+
+# ----------------------------------------------------------------------
+# Guile run-time library
+# ----------------------------------------------------------------------
+
+GUILE_INCLUDE = @GUILEINCLUDE@
+GUILE_RUNTIME = $(SWIGLIB)/guile/guiledec.swg $(SWIGLIB)/guile/guile.swg
+
+# Guile shared
+
+guile: libswigguile$(RELEASESUFFIX).la
+
+libswigguile$(RELEASESUFFIX).la:
+ rm -f libguile.c
+ cat $(srcdir)/$(GUILE_RUNTIME) >> libguile.c
+ $(LIBTOOL) $(CC) -c $(GUILE_INCLUDE) -DSWIG_GLOBAL libguile.c
+ $(LIBTOOL) $(CC) -o libswigguile$(RELEASESUFFIX).la libguile.lo -rpath $(LIB_DIR) -avoid-version
+
diff --git a/SWIG/Source/DOH/Doh/Makefile b/SWIG/Source/DOH/Doh/Makefile
deleted file mode 100644
index 0908946e0..000000000
--- a/SWIG/Source/DOH/Doh/Makefile
+++ /dev/null
@@ -1,50 +0,0 @@
-# Generated automatically from Makefile.in by configure.
-#######################################################################
-# $Header$
-# DOH
-#######################################################################
-
-#.KEEP_STATE:
-
-# Set your C++ compiler here. g++ works on most machines,
-# but you might have to change it depending on your installation.
-#
-CC = cc
-prefix = /r0/beazley/Projects
-
-# Comment out the following line if you're on an SGI or don't have ranlib!
-RANLIB = ranlib
-AR = ar
-
-########################################################################
-# Normally, you shouldn't have to change anything below this point #
-########################################################################
-
-LIBOBJS = callable.o void.o fio.o memory.o base.o file.o list.o hash.o string.o
-
-LIBSRCS = callable.c void.c fio.c memory.c base.c file.c list.c hash.c string.c
-
-LIBHEADERS = ../Include/doh.h
-LIB = ../libdoh.a
-INCLUDE = -I../Include
-CFLAGS = -DDOH_STRING_UPDATE_LINES
-SHELL = /bin/sh
-
-#
-# Rules for creation of a .o file from .cxx
-.SUFFIXES: .c
-.c.o:
- $(CC) $(INCLUDE) $(CFLAGS) -c -o $*.o $<
-
-all: $(LIB)
-
-$(LIB): $(LIBOBJS)
- @echo "Building library"
- $(AR) cr $(LIB) $(LIBOBJS)
- $(RANLIB) $(LIB)
-
-clean::
- rm -f *.o ../libdoh.a
-nuke::
- rm -f Makefile *~ #* core a.out
-
diff --git a/SWIG/Source/DOH/configure.in b/SWIG/Source/DOH/configure.in
index 0c114907c..6fd2e4642 100644
--- a/SWIG/Source/DOH/configure.in
+++ b/SWIG/Source/DOH/configure.in
@@ -41,4 +41,4 @@ dnl Checks for header files.
AC_HEADER_STDC
dnl Checks for library functions.
-AC_OUTPUT(Makefile Doh/Makefile Test/Makefile)
+AC_OUTPUT(Makefile Doh/Makefile)
diff --git a/SWIG/Source/Include/.cvsignore b/SWIG/Source/Include/.cvsignore
new file mode 100644
index 000000000..c451252ce
--- /dev/null
+++ b/SWIG/Source/Include/.cvsignore
@@ -0,0 +1 @@
+swigconfig.h
diff --git a/SWIG/Source/Include/swigconfig.h.in b/SWIG/Source/Include/swigconfig.h.in
index 7a02d27fb..6c672b56a 100644
--- a/SWIG/Source/Include/swigconfig.h.in
+++ b/SWIG/Source/Include/swigconfig.h.in
@@ -1,6 +1,18 @@
-/* This file contains SWIG specific configuration data for those modules
+/* This -*-c-*- file contains SWIG specific configuration data for those modules
that care */
-#define SWIG_LIB "@prefix@/lib/swig1.3"
+/* Directory where to find the machine-independent SWIG files */
+
+#define SWIG_LIB "@-swig_lib-@"
+
+/* Default language */
+
#define SWIG_LANG TCL8
+/* Values returned by swig when invoked with the -ldflags option */
+
+#define SWIG_PERL_RUNTIME "-L@-exec_prefix-@/lib -lswigpl@-release_suffix-@"
+#define SWIG_PYTHON_RUNTIME "-L@-exec_prefix-@/lib -lswigpy@-release_suffix-@"
+#define SWIG_TCL_RUNTIME "-L@-exec_prefix-@/lib -lswigtcl@-release_suffix-@"
+#define SWIG_RUBY_RUNTIME "-L@-exec_prefix-@/lib -lswigrb@-release_suffix-@"
+#define SWIG_GUILE_RUNTIME "-L@-exec_prefix-@/lib -lswigguile@-release_suffix-@"
diff --git a/SWIG/Source/Include/swigver.h b/SWIG/Source/Include/swigver.h
index 9da439bbd..7bdb7e412 100644
--- a/SWIG/Source/Include/swigver.h
+++ b/SWIG/Source/Include/swigver.h
@@ -2,9 +2,9 @@
/* SWIG version information */
#ifndef SWIG_VERSION
-#define SWIG_VERSION "1.3u-20000712-1502"
+#define SWIG_VERSION "1.3u-20010628-1103"
#endif
#ifndef SWIG_SPIN
-#define SWIG_SPIN "(Alpha 3)"
+#define SWIG_SPIN "(Alpha 5)"
#endif
diff --git a/SWIG/Source/Modules/.cvsignore b/SWIG/Source/Modules/.cvsignore
new file mode 100644
index 000000000..f3c7a7c5d
--- /dev/null
+++ b/SWIG/Source/Modules/.cvsignore
@@ -0,0 +1 @@
+Makefile
diff --git a/SWIG/Source/Modules1.1/Makefile.in b/SWIG/Source/Modules1.1/Makefile.in
index b9f686a2f..88859a0b7 100644
--- a/SWIG/Source/Modules1.1/Makefile.in
+++ b/SWIG/Source/Modules1.1/Makefile.in
@@ -13,8 +13,8 @@ AR = @AR@
RANLIB = @RANLIB@
TARGET = libmodules11.a
-OBJS = swigmain.o tcl8.o python.o perl5.o guile.o ruby.o mzscheme.o #java.o
-SRCS = swigmain.cxx tcl8.cxx python.cxx perl5.cxx guile.cxx ruby.cxx mzscheme.cxx #java.cxx
+OBJS = swigmain.o tcl8.o python.o perl5.o guile.o ruby.o mzscheme.o java.o
+SRCS = swigmain.cxx tcl8.cxx python.cxx perl5.cxx guile.cxx ruby.cxx mzscheme.cxx java.cxx
INCLUDE = -I$(srcdir)/../Include \
-I$(srcdir)/../SWIG1.1 \
diff --git a/SWIG/Source/Modules1.1/guile.cxx b/SWIG/Source/Modules1.1/guile.cxx
index 837693176..fa4b5136f 100644
--- a/SWIG/Source/Modules1.1/guile.cxx
+++ b/SWIG/Source/Modules1.1/guile.cxx
@@ -25,21 +25,28 @@ static char cvsroot[] = "$Header$";
#include "mod11.h"
#include "guile.h"
+#include "swigconfig.h"
static char *guile_usage = (char*)"\
Guile Options (available with -guile)\n\
- -module name - Set base name of module\n\
+ -ldflags - Print runtime libraries to link with\n\
+ -module name - Set name of module [default \"swig\"]\n\
-prefix name - Use NAME as prefix [default \"gswig_\"]\n\
-package name - Set the path of the module [default NULL]\n\
- -Linkage lstyle - Use linkage protocol LSTYLE [default `ltdlmod']\n\
- -procdoc file - Output procedure documentation to file\n\
+ -linkage lstyle - Use linkage protocol LSTYLE [default `module']\n\
+ -procdoc file - Output procedure documentation to FILE\n\
\n\
+ -procdocformat format - Output procedure documentation in FORMAT;\n\
+ one of `guile-1.4', `plain', `texinfo'\n\
The module option does not create a guile module with a separate name\n\
space. It specifies the name of the initialization function and is\n\
called a module here so that it is compadible with the rest of SWIG.\n\
\n\
- When unspecified, the default LSTYLE is `ltdlmod' for libtool ltdl\n\
- modules. Other LSTYLE values are: `hobbit' for hobbit modules.\n\
+ When unspecified, the default LSTYLE is `simple'. For native Guile\n\
+ module linking (for Guile versions >=1.5.0), use `module'. Other\n\
+ LSTYLE values are: `passive' for passive linking (no module-handling\n\
+ code), `ltdlmod' for Guile's old dynamic module convention\n\
+ (versions <= 1.4), or `hobbit' for hobbit modules.\n\
\n";
// ---------------------------------------------------------------------
@@ -59,8 +66,11 @@ GUILE::GUILE ()
package = NULL;
linkage = GUILE_LSTYLE_SIMPLE;
procdoc = NULL;
+ docformat = GUILE_1_4;
emit_setters = 0;
struct_member = 0;
+ before_return = NULL;
+ exported_symbols = NewString("");
}
// ---------------------------------------------------------------------
@@ -115,15 +125,24 @@ GUILE::parse_args (int argc, char *argv[])
Swig_arg_error();
}
}
- /* Bogus upcase requirement due to top-level parsing not respecting
- language specification. Top-level should stop when it sees "-guile"
- or other languages. */
- else if (strcmp (argv[i], "-Linkage") == 0) {
+ else if (strcmp (argv[i], "-ldflags") == 0) {
+ printf("%s\n", SWIG_GUILE_RUNTIME);
+ SWIG_exit (EXIT_SUCCESS);
+ }
+ /* The upcase variant is a historic artefact. */
+ else if (strcmp (argv[i], "-Linkage") == 0
+ || strcmp (argv[i], "-linkage") == 0) {
if (argv[i + 1]) {
if (0 == strcmp (argv[i + 1], "ltdlmod"))
- linkage = GUILE_LSTYLE_LTDLMOD;
+ linkage = GUILE_LSTYLE_LTDLMOD_1_4;
else if (0 == strcmp (argv[i + 1], "hobbit"))
linkage = GUILE_LSTYLE_HOBBIT;
+ else if (0 == strcmp (argv[i + 1], "simple"))
+ linkage = GUILE_LSTYLE_SIMPLE;
+ else if (0 == strcmp (argv[i + 1], "passive"))
+ linkage = GUILE_LSTYLE_PASSIVE;
+ else if (0 == strcmp (argv[i + 1], "module"))
+ linkage = GUILE_LSTYLE_MODULE;
else
Swig_arg_error ();
Swig_mark_arg (i);
@@ -143,6 +162,18 @@ GUILE::parse_args (int argc, char *argv[])
Swig_arg_error();
}
}
+ else if (strcmp (argv[i], "-procdocformat") == 0) {
+ if (strcmp(argv[i+1], "guile-1.4") == 0)
+ docformat = GUILE_1_4;
+ else if (strcmp(argv[i+1], "plain") == 0)
+ docformat = PLAIN;
+ else if (strcmp(argv[i+1], "texinfo") == 0)
+ docformat = TEXINFO;
+ else Swig_arg_error();
+ Swig_mark_arg(i);
+ Swig_mark_arg(i+1);
+ i++;
+ }
else if (strcmp (argv[i], "-emit-setters") == 0) {
emit_setters = 1;
Swig_mark_arg (i);
@@ -174,8 +205,6 @@ GUILE::parse_args (int argc, char *argv[])
void
GUILE::parse ()
{
- printf ("Generating wrappers for Guile\n");
-
// Print out GUILE specific headers
headers();
@@ -197,10 +226,7 @@ GUILE::parse ()
void
GUILE::set_module (char *mod_name)
{
- if (module) {
- printf ("module already set (%s), returning\n", module);
- return;
- }
+ if (module) return;
module = new char [strlen (mod_name) + 1];
strcpy (module, mod_name);
@@ -252,6 +278,9 @@ GUILE::headers (void)
void
GUILE::initialize (void)
{
+ if (CPlusPlus) {
+ Printf(f_runtime, "extern \"C\" {\n\n");
+ }
switch (linkage) {
case GUILE_LSTYLE_SIMPLE:
/* Simple linkage; we have to export the SWIG_init function. The user can
@@ -266,6 +295,9 @@ GUILE::initialize (void)
break;
}
Printf (f_init, "\tSWIG_Guile_Init();\n");
+ if (CPlusPlus) {
+ Printf(f_runtime, "\n}\n");
+ }
}
void
@@ -273,6 +305,10 @@ GUILE::emit_linkage (char *module_name)
{
DOHString *module_func = NewString("");
+ if (CPlusPlus) {
+ Printf(f_init, "extern \"C\" {\n\n");
+ }
+
Printv(module_func,module_name,0);
Replace(module_func,"-", "_", DOH_REPLACE_ANY);
@@ -280,7 +316,18 @@ GUILE::emit_linkage (char *module_name)
case GUILE_LSTYLE_SIMPLE:
Printf (f_init, "\n/* Linkage: simple */\n");
break;
- case GUILE_LSTYLE_LTDLMOD:
+ case GUILE_LSTYLE_PASSIVE:
+ Printf (f_init, "\n/* Linkage: passive */\n");
+ Replace(module_func,"/", "_", DOH_REPLACE_ANY);
+ Insert(module_func,0, "scm_init_");
+ Append(module_func,"_module");
+
+ Printf (f_init, "SCM\n%s (void)\n{\n", module_func);
+ Printf (f_init, " SWIG_init();\n");
+ Printf (f_init, " return SCM_UNSPECIFIED;\n");
+ Printf (f_init, "}\n");
+ break;
+ case GUILE_LSTYLE_LTDLMOD_1_4:
Printf (f_init, "\n/* Linkage: ltdlmod */\n");
Replace(module_func,"/", "_", DOH_REPLACE_ANY);
Insert(module_func,0, "scm_init_");
@@ -296,6 +343,29 @@ GUILE::emit_linkage (char *module_name)
}
Printf (f_init, "}\n");
break;
+ case GUILE_LSTYLE_MODULE:
+ Printf (f_init, "\n/* Linkage: module */\n");
+ Replace(module_func,"/", "_", DOH_REPLACE_ANY);
+ Insert(module_func,0, "scm_init_");
+ Append(module_func,"_module");
+
+ Printf (f_init, "static void SWIG_init_helper(void *data)\n");
+ Printf (f_init, "{\n SWIG_init();\n");
+ if (Len(exported_symbols) > 0)
+ Printf (f_init, " scm_c_export(%sNULL);",
+ exported_symbols);
+ Printf (f_init, "\n}\n\n");
+
+ Printf (f_init, "SCM\n%s (void)\n{\n", module_func);
+ {
+ DOHString *mod = NewString(module_name);
+ Replace(mod,"/", " ", DOH_REPLACE_ANY);
+ Printf(f_init, " SCM module = scm_c_define_module(\"%s\",\n", mod);
+ Printf(f_init, " SWIG_init_helper, NULL);\n");
+ Printf(f_init, " return SCM_UNSPECIFIED;\n");
+ }
+ Printf (f_init, "}\n");
+ break;
case GUILE_LSTYLE_HOBBIT:
Printf (f_init, "\n/* Linkage: hobbit */\n");
Replace(module_func,"/", "_slash_", DOH_REPLACE_ANY);
@@ -315,6 +385,9 @@ GUILE::emit_linkage (char *module_name)
abort(); // for now
}
Delete(module_func);
+ if (CPlusPlus) {
+ Printf(f_init, "\n}\n");
+ }
}
// ---------------------------------------------------------------------
@@ -328,7 +401,7 @@ GUILE::close (void)
{
SwigType_emit_type_table (f_runtime, f_wrappers);
- Printf (f_init, "SWIG_Guile_RegisterTypes(swig_types);\n");
+ Printf (f_init, "SWIG_Guile_RegisterTypes(swig_types, swig_types_initial);\n");
Printf (f_init, "}\n\n");
char module_name[256];
@@ -341,42 +414,13 @@ GUILE::close (void)
strcpy(module_name,module);
}
emit_linkage (module_name);
-
+
if (procdoc) {
Delete(procdoc);
procdoc = NULL;
}
}
-// ----------------------------------------------------------------------
-// get_pointer()
-//
-// Emits code to get a pointer from a parameter and do type checking.
-// parm is the parameter number. This function is only used
-// in create_function().
-// ----------------------------------------------------------------------
-
-static void
-get_pointer (char *iname, int parm, SwigType *t,
- Wrapper *f, DOHString_or_char *proc_name,
- int num_scheme_parm)
-{
- SwigType_remember(t);
- /* Pointers are smobs */
- Printf(f->code, " if (SWIG_Guile_GetPtr(s_%d,(void **) &arg%d", parm, parm);
- if (SwigType_type(t) == T_VOID)
- Printf(f->code, ", NULL)) {\n");
- else
- Printv(f->code, ", SWIGTYPE", SwigType_manglestr(t), ")) {\n", 0);
- /* Raise exception */
- Printv(f->code,
- tab8,
- "scm_wrong_type_arg(\"",proc_name, "\", ",
- 0);
- Printf(f->code,"%d, s_%d);\n", num_scheme_parm, parm);
- Printv(f->code, tab4, "}\n", 0);
-}
-
/* Return true iff T is a pointer type */
static int
@@ -417,11 +461,42 @@ guile_do_typemap(DOHFile *file, const char *op,
if ((tm = guile_typemap_lookup(op, type, arg,
source, target, f))) {
String *s = NewString(tm);
+ String *descriptor = NewString("");
+ String *basedescriptor = NewString("");
+ String *stardescriptor = NewString("");
char argnum_s[10];
+ SwigType *startype = NULL;
+
+ if (SwigType_ispointer(type)) {
+ startype = Copy(type);
+ SwigType_del_pointer(startype);
+ Printf(stardescriptor, "SWIGTYPE%s",
+ SwigType_manglestr(startype));
+ }
+ else Printf(stardescriptor, "SWIGTYPE_BAD");
+ Printf(descriptor, "SWIGTYPE%s",
+ SwigType_manglestr(type));
+ Printf(basedescriptor, "SWIGTYPE%s",
+ SwigType_manglestr(SwigType_base(type)));
sprintf(argnum_s, "%d", argnum);
Replace(s,"$argnum", argnum_s, DOH_REPLACE_ANY);
Replace(s,"$arg", arg, DOH_REPLACE_ANY);
Replace(s,"$name", name, DOH_REPLACE_ANY);
+ if (Replace(s, "$descriptor",
+ descriptor, DOH_REPLACE_ANY))
+ SwigType_remember(type);
+ if (Replace(s, "$basedescriptor",
+ basedescriptor, DOH_REPLACE_ANY))
+ SwigType_remember(SwigType_base(type));
+ if (Replace(s, "$*descriptor", stardescriptor,
+ DOH_REPLACE_ANY)) {
+ if (!startype) {
+ Printf (stderr, "%s : Line %d. $*descriptor is meaningless for non-pointer types.\n",
+ input_file, line_number);
+ error_count++;
+ }
+ else SwigType_remember(startype);
+ }
if (nonewline_p)
Printv(file, s, 0);
else Printv(file, s, "\n", 0);
@@ -460,6 +535,35 @@ throw_unhandled_guile_type_error (SwigType *d)
error_count++;
}
+
+/* Write out procedure documentation */
+
+void
+GUILE::write_doc(const String *proc_name,
+ const String *signature,
+ const String *doc)
+{
+ switch (docformat) {
+ case GUILE_1_4:
+ Printv(procdoc, "\f\n", 0);
+ Printv(procdoc, "(", signature, ")\n", 0);
+ Printv(procdoc, doc, "\n", 0);
+ break;
+ case PLAIN:
+ Printv(procdoc, "\f", proc_name, "\n\n", 0);
+ Printv(procdoc, "(", signature, ")\n", 0);
+ Printv(procdoc, doc, "\n\n", 0);
+ break;
+ case TEXINFO:
+ Printv(procdoc, "\f", proc_name, "\n", 0);
+ Printv(procdoc, "@deffn primitive ", signature, "\n", 0);
+ Printv(procdoc, doc, "\n", 0);
+ Printv(procdoc, "@end deffn\n\n", 0);
+ break;
+ }
+}
+
+
// ----------------------------------------------------------------------
// GUILE::create_function(char *name, char *iname, SwigType *d,
// ParmList *l)
@@ -472,7 +576,7 @@ GUILE::create_function (char *name, char *iname, SwigType *d, ParmList *l)
{
Parm *p;
DOHString *proc_name = 0;
- char source[256], target[256];
+ char source[256], target[256], wname[256];
Wrapper *f = NewWrapper();;
String *cleanup = NewString("");
String *outarg = NewString("");
@@ -485,8 +589,7 @@ GUILE::create_function (char *name, char *iname, SwigType *d, ParmList *l)
int numopt = 0;
// Make a wrapper name for this
- char * wname = new char [strlen (prefix) + strlen (iname) + 2];
- sprintf (wname, "%s%s", prefix, iname);
+ strcpy(wname, Char(Swig_name_wrapper(name)));
// Build the name for scheme.
proc_name = NewString(iname);
@@ -498,6 +601,7 @@ GUILE::create_function (char *name, char *iname, SwigType *d, ParmList *l)
/* Declare return variable */
Wrapper_add_local (f,"gswig_result", "SCM gswig_result");
+ Wrapper_add_local (f,"gswig_list_p", "int gswig_list_p = 0");
if (procdoc)
guile_do_doc_typemap(returns, "outdoc", d, NULL,
@@ -506,7 +610,7 @@ GUILE::create_function (char *name, char *iname, SwigType *d, ParmList *l)
/* Open prototype and signature */
Printv(f->def, "static SCM\n", wname," (", 0);
- Printv(signature, "(", proc_name, 0);
+ Printv(signature, proc_name, 0);
/* Now write code to extract the parameters */
@@ -536,9 +640,6 @@ GUILE::create_function (char *name, char *iname, SwigType *d, ParmList *l)
source, target, numargs, proc_name, f, 0)) {
/* nothing to do */
}
- else if (is_a_pointer(pt)) {
- get_pointer (iname, i, pt, f, proc_name, numargs);
- }
else {
throw_unhandled_guile_type_error (pt);
}
@@ -583,9 +684,8 @@ GUILE::create_function (char *name, char *iname, SwigType *d, ParmList *l)
source, target, numargs, proc_name, f, 0);
}
- /* Close prototype and signature */
+ /* Close prototype */
- Printv(signature, ")\n", 0);
Printf(f->def, ")\n{\n");
/* Define the scheme name in C. This define is used by several Guile
@@ -604,15 +704,6 @@ GUILE::create_function (char *name, char *iname, SwigType *d, ParmList *l)
0, proc_name, f, 0)) {
/* nothing */
}
- else if (is_a_pointer(d)) {
- SwigType_remember(d);
- Printv(f->code, tab4,
- "gswig_result = SWIG_Guile_MakePtr (",
- "result, ",
- "SWIGTYPE", SwigType_manglestr(d),
- ");\n",
- 0);
- }
else {
throw_unhandled_guile_type_error (d);
}
@@ -637,6 +728,8 @@ GUILE::create_function (char *name, char *iname, SwigType *d, ParmList *l)
// Wrap things up (in a manner of speaking)
+ if (before_return)
+ Printv(f->code, before_return, "\n", 0);
Printv(f->code, "return gswig_result;\n", 0);
// Undefine the scheme name
@@ -662,7 +755,7 @@ GUILE::create_function (char *name, char *iname, SwigType *d, ParmList *l)
Printv(f_wrappers, ");\n", 0);
Printv(f_wrappers, "}\n", 0);
/* Register it */
- Printf (f_init, "gh_new_procedure(\"%s\", %s_rest, 0, 0, 1);\n",
+ Printf (f_init, "gh_new_procedure(\"%s\", (SCM (*) ()) %s_rest, 0, 0, 1);\n",
proc_name, wname, numargs-numopt, numopt);
}
else if (emit_setters && struct_member && strlen(Char(proc_name))>3) {
@@ -675,7 +768,7 @@ GUILE::create_function (char *name, char *iname, SwigType *d, ParmList *l)
struct_member = 2; /* have a setter */
}
else Printf(f_init, "SCM getter = ");
- Printf (f_init, "gh_new_procedure(\"%s\", %s, %d, %d, 0);\n",
+ Printf (f_init, "gh_new_procedure(\"%s\", (SCM (*) ()) %s, %d, %d, 0);\n",
proc_name, wname, numargs-numopt, numopt);
if (!is_setter) {
/* Strip off "-get" */
@@ -693,22 +786,24 @@ GUILE::create_function (char *name, char *iname, SwigType *d, ParmList *l)
Printf (f_init, "gh_define(\"%s\", getter);\n",
pws_name);
}
+ Printf (exported_symbols, "\"%s\", ", pws_name);
free(pws_name);
}
}
else {
/* Register the function */
- Printf (f_init, "gh_new_procedure(\"%s\", %s, %d, %d, 0);\n",
+ Printf (f_init, "gh_new_procedure(\"%s\", (SCM (*) ()) %s, %d, %d, 0);\n",
proc_name, wname, numargs-numopt, numopt);
}
+ Printf (exported_symbols, "\"%s\", ", proc_name);
if (procdoc) {
- /* Write out procedure documentation */
- Printv(signature, "Returns ", 0);
- if (Len(returns)==0) Printv(signature, "unspecified", 0);
- else if (returns_list) Printv(signature, "list (", returns, ")", 0);
- else Printv(signature, returns, 0);
- Printv(signature, "\n", 0);
- Printv(procdoc, "\f\n", signature, 0);
+ String *returns_text = NewString("");
+ Printv(returns_text, "Returns ", 0);
+ if (Len(returns)==0) Printv(returns_text, "unspecified", 0);
+ else if (returns_list) Printv(returns_text, "list (", returns, ")", 0);
+ else Printv(returns_text, returns, 0);
+ write_doc(proc_name, signature, returns_text);
+ Delete(returns_text);
}
Delete(proc_name);
@@ -718,7 +813,6 @@ GUILE::create_function (char *name, char *iname, SwigType *d, ParmList *l)
Delete(returns);
Delete(tmp);
DelWrapper(f);
- delete[] wname;
}
// -----------------------------------------------------------------------
@@ -743,7 +837,7 @@ GUILE::link_variable (char *name, char *iname, SwigType *t)
f = NewWrapper();
// evaluation function names
- sprintf (var_name, "%svar_%s", prefix, iname);
+ strcpy(var_name, Char(Swig_name_wrapper(name)));
// Build the name for scheme.
proc_name = NewString(iname);
@@ -751,7 +845,11 @@ GUILE::link_variable (char *name, char *iname, SwigType *t)
if ((SwigType_type(t) != T_USER) || (is_a_pointer(t))) {
- Printf (f_wrappers, "SCM %s(SCM s_0) {\n", var_name);
+ Printf (f_wrappers, "static SCM %s(SCM s_0)\n{\n", var_name);
+
+ /* Define the scheme name in C. This define is used by several Guile
+ macros. */
+ Printv(f_wrappers, "#define FUNC_NAME \"", proc_name, "\"\n", 0);
if (!(Status & STAT_READONLY) && SwigType_type(t) == T_STRING) {
Printf (f_wrappers, "\t char *_temp;\n");
@@ -770,31 +868,9 @@ GUILE::link_variable (char *name, char *iname, SwigType *t)
"\"Unable to set %s. Variable is read only.\", SCM_EOL);\n",
proc_name, proc_name);
}
- else if ((tm = guile_typemap_lookup ("varin",
- t, name, (char*)"s_0", name, f))) {
- Printf (f_wrappers, "%s\n", tm);
- }
- else if (is_a_pointer(t)) {
- if (SwigType_type(t) == T_STRING) {
- Printf (f_wrappers, "\t\t _temp = gh_scm2newstr(s_0, &_len);\n");
- Printf (f_wrappers, "\t\t if (%s) { free(%s);}\n", name, name);
- Printf (f_wrappers, "\t\t %s = (char *) "
- "malloc((_len+1)*sizeof(char));\n", name);
- Printf (f_wrappers, "\t\t strncpy(%s,_temp,_len);\n", name);
- Printf (f_wrappers, "\t\t %s[_len] = 0;\n", name);
- } else {
- // Set the value of a pointer
- Printf (f_wrappers, "\t if (SWIG_Guile_GetPtr(s_0, "
- "(void **) &%s, ", name);
- if (SwigType_type(t) == T_VOID)
- Printf (f_wrappers, "NULL)) {\n");
- else
- Printf (f_wrappers, "SWIGTYPE%s)) {\n", SwigType_manglestr(t));
- /* Raise exception */
- Printf(f_wrappers, "\tscm_wrong_type_arg(\"%s\", "
- "%d, s_0);\n", proc_name, 1);
- Printf (f_wrappers, "\t}\n");
- }
+ else if (guile_do_typemap(f_wrappers, "varin",
+ t, name, (char*) "s_0", name, 1, name, f, 0)) {
+ /* nothing */
}
else {
throw_unhandled_guile_type_error (t);
@@ -804,24 +880,17 @@ GUILE::link_variable (char *name, char *iname, SwigType *t)
// Now return the value of the variable (regardless
// of evaluating or setting)
- if ((tm = guile_typemap_lookup ("varout",
- t, name, name, (char*)"gswig_result", f))) {
- Printf (f_wrappers, "%s\n", tm);
- }
- else if (is_a_pointer(t)) {
- if (SwigType_type(t) == T_STRING) {
- Printf (f_wrappers, "\t gswig_result = gh_str02scm(%s);\n", name);
- } else {
- // Is an ordinary pointer type.
- Printf (f_wrappers, "\t gswig_result = SWIG_Guile_MakePtr ("
- "%s, SWIGTYPE%s);\n", name, SwigType_manglestr(t));
- }
+ if (guile_do_typemap (f_wrappers, "varout",
+ t, name, name, (char*)"gswig_result",
+ 0, name, f, 1)) {
+ /* nothing */
}
else {
throw_unhandled_guile_type_error (t);
}
Printf (f_wrappers, "\t return gswig_result;\n");
- Printf (f_wrappers, "}\n");
+ Printf (f_wrappers, "#undef FUNC_NAME\n");
+ Printf (f_wrappers, "}\n\n");
// Now add symbol to the Guile interpreter
@@ -829,44 +898,44 @@ GUILE::link_variable (char *name, char *iname, SwigType *t)
|| Status & STAT_READONLY) {
/* Read-only variables become a simple procedure returning the
value. */
- Printf (f_init, "\t gh_new_procedure(\"%s\", %s, 0, 1, 0);\n",
+ Printf (f_init, "\t gh_new_procedure(\"%s\", (SCM (*) ()) %s, 0, 1, 0);\n",
proc_name, var_name);
}
else {
/* Read/write variables become a procedure with setter. */
- Printf (f_init, "\t{ SCM p = gh_new_procedure(\"%s\", %s, 0, 1, 0);\n",
+ Printf (f_init, "\t{ SCM p = gh_new_procedure(\"%s\", (SCM (*) ()) %s, 0, 1, 0);\n",
proc_name, var_name);
Printf (f_init, "\t gh_define(\"%s\", "
"scm_make_procedure_with_setter(p, p)); }\n",
proc_name);
}
+ Printf (exported_symbols, "\"%s\", ", proc_name);
if (procdoc) {
/* Compute documentation */
String *signature = NewString("");
+ String *doc = NewString("");
if (Status & STAT_READONLY) {
- Printv(signature, "(", proc_name, ")\n", 0);
- Printv(signature, "Returns constant ", 0);
- guile_do_doc_typemap(signature, "varoutdoc", t, NULL,
+ Printv(signature, proc_name, 0);
+ Printv(doc, "Returns constant ", 0);
+ guile_do_doc_typemap(doc, "varoutdoc", t, NULL,
0, proc_name, f);
- Printv(signature, "\n", 0);
}
else {
- Printv(signature, "(", proc_name,
+ Printv(signature, proc_name,
" #:optional ", 0);
guile_do_doc_typemap(signature, "varindoc", t, "new-value",
1, proc_name, f);
- Printv(signature, ")\n", 0);
- Printv(signature, "If NEW-VALUE is provided, "
+ Printv(doc, "If NEW-VALUE is provided, "
"set C variable to this value.\n", 0);
- Printv(signature, "Returns variable value ", 0);
- guile_do_doc_typemap(signature, "varoutdoc", t, NULL,
+ Printv(doc, "Returns variable value ", 0);
+ guile_do_doc_typemap(doc, "varoutdoc", t, NULL,
0, proc_name, f);
- Printv(signature, "\n", 0);
}
- Printv(procdoc, "\f\n", signature, 0);
+ write_doc(proc_name, signature, doc);
Delete(signature);
+ Delete(doc);
}
} else {
@@ -881,12 +950,11 @@ GUILE::link_variable (char *name, char *iname, SwigType *t)
// -----------------------------------------------------------------------
// GUILE::declare_const(char *name, char *iname, SwigType *type, char *value)
//
-// Makes a constant. Not sure how this is really supposed to work.
-// I'm going to fake out SWIG and create a variable instead.
+// We create a read-only variable.
// ------------------------------------------------------------------------
void
-GUILE::declare_const (char *name, char *, SwigType *type, char *value)
+GUILE::declare_const (char *name, char *iname, SwigType *type, char *value)
{
int OldStatus = Status; // Save old status flags
DOHString *proc_name;
@@ -903,7 +971,7 @@ GUILE::declare_const (char *name, char *, SwigType *type, char *value)
sprintf (var_name, "%sconst_%s", prefix, name);
// Build the name for scheme.
- proc_name = NewString(name);
+ proc_name = NewString(iname);
Replace(proc_name,"_", "-", DOH_REPLACE_ANY);
if ((SwigType_type(type) == T_USER) && (!is_a_pointer(type))) {
@@ -921,25 +989,17 @@ GUILE::declare_const (char *name, char *, SwigType *type, char *value)
} else {
rvalue = NewString(value);
}
- if ((tm = guile_typemap_lookup ("const", type, name,
- Char(rvalue), name, f))) {
- Printf (f_init, "%s\n", tm);
+ if (guile_do_typemap(f_header, "const", type, name,
+ Char(rvalue), name, 0, name, f, 0)) {
+ /* nothing */
} else {
// Create variable and assign it a value
-
- Printf (f_header, "static %s %s = ", SwigType_lstr(type,0), var_name);
- if (SwigType_type(type) == T_STRING) {
- Printf (f_header, "\"%s\";\n", value);
- } else if (SwigType_type(type) == T_CHAR) {
- Printf (f_header, "\'%s\';\n", value);
- } else {
- Printf (f_header, "%s;\n", value);
- }
- // Now create a variable declaration
-
- link_variable (var_name, name, type);
- Status = OldStatus;
+ Printf (f_header, "static %s %s = %s;\n", SwigType_lstr(type,0),
+ var_name, rvalue);
}
+ // Now create a variable declaration
+ link_variable (var_name, iname, type);
+ Status = OldStatus;
Delete(proc_name);
Delete(rvalue);
DelWrapper(f);
@@ -959,3 +1019,14 @@ void GUILE::cpp_variable(char *name, char *iname, SwigType *t)
Language::cpp_variable(name, iname, t);
}
}
+
+void GUILE::pragma(char *lang, char *cmd, char *value)
+{
+ if (strcmp(lang,(char*)"guile") == 0) {
+ if (strcmp(cmd, (char*)"beforereturn")==0) {
+ if (before_return)
+ Delete(before_return);
+ before_return = NewString(value);
+ }
+ }
+}
diff --git a/SWIG/Source/Modules1.1/guile.h b/SWIG/Source/Modules1.1/guile.h
index bdfc5f75b..093107bf2 100644
--- a/SWIG/Source/Modules1.1/guile.h
+++ b/SWIG/Source/Modules1.1/guile.h
@@ -32,14 +32,26 @@ private:
char *package;
enum {
GUILE_LSTYLE_SIMPLE, // call `SWIG_init()'
- GUILE_LSTYLE_LTDLMOD, // "native" guile?
+ GUILE_LSTYLE_PASSIVE, // passive linking (no module code)
+ GUILE_LSTYLE_MODULE, // native guile module linking (Guile >= 1.4.1)
+ GUILE_LSTYLE_LTDLMOD_1_4, // old (Guile <= 1.4) dynamic module convention
GUILE_LSTYLE_HOBBIT // use (hobbit4d link)
} linkage;
File *procdoc;
+ enum {
+ GUILE_1_4,
+ PLAIN,
+ TEXINFO
+ } docformat;
int emit_setters;
int struct_member;
+ String *before_return;
+ String *pragma_name;
+ String *exported_symbols;
void emit_linkage(char *module_name);
-
+ void write_doc(const String *proc_name,
+ const String *signature,
+ const String *doc);
public :
GUILE ();
void parse_args (int, char *argv[]);
@@ -54,6 +66,7 @@ public :
void set_init (char *);
void create_command (char *, char *) { };
void cpp_variable(char *name, char *iname, SwigType *t);
+ void pragma(char *lang, char *cmd, char *value);
};
/* guile.h ends here */
diff --git a/SWIG/Source/Modules1.1/java.cxx b/SWIG/Source/Modules1.1/java.cxx
index 18b7011d5..e44abca91 100644
--- a/SWIG/Source/Modules1.1/java.cxx
+++ b/SWIG/Source/Modules1.1/java.cxx
@@ -1,32 +1,11 @@
-/*******************************************************************************
- * SWIG Java module
- * Author: Harco de Hilster
- * AT Consultancy
- * Toernooiveld 104
- * P.O. Box 1428
- * 6501 BK Nijmegen
- * +31 24 3527282
- * harcoh@ATConsultancy.nl
+/* -----------------------------------------------------------------------------
+ * java.cxx
*
- * thanks to the following persons for submitting bug-reports:
+ * Java wrapper module.
*
- * James Hicks <jamey@crl.dec.com>
- * Lars Schmidt-Thieme <lschmidt@ix.urz.uni-heidelberg.de>
- * Per OEyvind Hvidsten Per-Oyvind.Hvidsten@ffi.no
- * Geoff Dillon <gdillon@pervasive.com>
- * Michael Haller <haller@lionbio.co.uk>
- * "Simon J. Julier" <sjulier@erols.com>
- * "Pritam Kamat" <pritam@alier.com>
- * Marc Hadley <marc_hadley@chrystal.co.uk>
- *******************************************************************************
-*/
-
-/* !!!!!!!
- * DB 7/24/00: Is there any way to clean up the implementation of this module?
- * I've tried to bring it as far as I can with core changes, but it's getting
- * to be a little rough.
- * !!!!!!!
- */
+ * Copyright (C) 1999-2000. The University of Chicago
+ * See the file LICENSE for information on usage and redistribution.
+ * ----------------------------------------------------------------------------- */
#include <ctype.h>
@@ -37,204 +16,266 @@ char bigbuf[1024];
static char *usage = (char*)"\
Java Options\n\
- -jnic - use c syntax for jni calls\n\
- -jnicpp - use c++ syntax for jni calls\n\
- -module name - set name of module\n\
- -package name - set name of package\n\
- -shadow - enable shadow classes\n\
- -finalize - generate finalize methods\n\
+ -jnic - use c syntax for JNI calls\n\
+ -jnicpp - use c++ syntax for JNI calls\n\
+ -module <name> - set name of the module\n\
+ -package <name> - set name of the package\n\
+ -shadow - generate shadow classes\n\
+ -nofinalize - do not generate finalize methods in shadow classes\n\
-rn - generate register natives code\n\n";
-static char *module = 0; // Name of the module
-static char *java_path = (char*)"java";
-static char *package = 0; // Name of the package
-static char *c_pkgstr; // Name of the package
-static char *jni_pkgstr; // Name of the package
-static char *shadow_classname;
-static char *jimport = 0;
-static char *method_modifiers = (char*)"public final static";
-static FILE *f_java = 0;
-static FILE *f_shadow = 0;
-static int shadow = 0;
-static DOHHash *shadow_classes;
-static DOHString *shadow_classdef;
-static char *shadow_name = 0;
-static char *shadow_baseclass = 0;
-static int classdef_emitted = 0;
-static int shadow_classdef_emitted = 0;
-static int have_default_constructor = 0;
-static int native_func = 0; // Set to 1 when wrapping a native function
-static int member_func = 0; // Set to 1 when wrapping a member function
-static int jnic = -1; // 1: use c syntax jni; 0: use c++ syntax jni
-static int finalize = 0; // generate finalize methods
-static int useRegisterNatives = 0; // Set to 1 when doing stuff with register natives
-static DOHString *registerNativesList = 0;
-
-char *JAVA::SwigTcToJniType(DataType *t, int ret) {
- if(DataType_is_pointer(t) == 1) {
- switch(DataType_Gettypecode(t)) {
- case T_INT: return (char*)"jintArray";
- case T_SHORT: return (char*)"jshortArray";
- case T_LONG: return (char*)"jlongArray";
- case T_CHAR: return (char*)"jstring";
- case T_FLOAT: return (char*)"jfloatArray";
- case T_DOUBLE: return (char*)"jdoubleArray";
- case T_UINT: return (char*)"jintArray";
- case T_USHORT: return (char*)"jshortArray";
- case T_ULONG: return (char*)"jlongArray";
- case T_UCHAR: return (char*)"jbyteArray";
- case T_SCHAR: return (char*)"jbyteArray";
- case T_BOOL: return (char*)"jbooleanArray";
- case T_VOID:
- case T_USER: return (char*)"jlong";
- }
- } else if(DataType_is_pointer(t) > 1) {
- if(ret)
- return (char*)"jlong";
- else return (char*)"jlongArray";
- } else {
- switch(DataType_Gettypecode(t)) {
- case T_INT: return (char*)"jint";
- case T_SHORT: return (char*)"jshort";
- case T_LONG: return (char*)"jlong";
- case T_CHAR: return (char*)"jbyte";
- case T_FLOAT: return (char*)"jfloat";
- case T_DOUBLE: return (char*)"jdouble";
- case T_UINT: return (char*)"jint";
- case T_USHORT: return (char*)"jshort";
- case T_ULONG: return (char*)"jlong";
- case T_UCHAR: return (char*)"jbyte";
- case T_SCHAR: return (char*)"jbyte";
- case T_BOOL: return (char*)"jboolean";
- case T_VOID: return (char*)"void";
- case T_USER: return (char*)"jlong";
- }
+static char *module = 0; // Name of the module
+static char *java_path = (char*)"java";
+static char *package = 0; // Name of the package
+static char *c_pkgstr; // Name of the package
+static char *jni_pkgstr; // Name of the package
+static char *shadow_classname;
+static FILE *f_java = 0;
+static FILE *f_shadow = 0;
+static int shadow = 0;
+static Hash *shadow_classes;
+static String *shadow_classdef;
+static char *shadow_variable_name = 0; //Name of a c struct variable or c++ public member variable (may or may not be const)
+static int classdef_emitted = 0;
+static int shadow_classdef_emitted = 0;
+static int have_default_constructor = 0;
+static int native_func = 0; // Set to 1 when wrapping a native function
+static int enum_flag = 0; // Set to 1 when wrapping an enum
+static int static_flag = 0; // Set to 1 when wrapping a static functions or member variables
+static int variable_wrapper_flag = 0; // Set to 1 when wrapping a member variable
+static int wrapping_member = 0; // Set to 1 when wrapping a member variable/enum/const
+static int jnic = -1; // 1: use c syntax jni; 0: use c++ syntax jni
+static int nofinalize = 0; // for generating finalize methods
+static int useRegisterNatives = 0; // Set to 1 when doing stuff with register natives
+static String *registerNativesList = 0;
+static String *shadow_enum_code = 0;
+static String *java_enum_code = 0;
+static String *module_extra_code = 0; // Extra code for the module class from %pragma
+static String *all_shadow_extra_code = 0; // Extra code for all shadow classes from %pragma
+static String *this_shadow_extra_code = 0; // Extra code for current single shadow class from %pragma
+static String *module_import = 0; //module import from %pragma
+static String *all_shadow_import = 0; //import for all shadow classes from %pragma
+static String *this_shadow_import = 0; //import for current shadow classes from %pragma
+static String *module_baseclass = 0; //inheritance for module class from %pragma
+static String *all_shadow_baseclass = 0; //inheritance for all shadow classes from %pragma
+static String *this_shadow_baseclass = 0; //inheritance for shadow class from %pragma and cpp_inherit
+static String *module_interfaces = 0; //interfaces for module class from %pragma
+static String *all_shadow_interfaces = 0; //interfaces for all shadow classes from %pragma
+static String *this_shadow_interfaces = 0; //interfaces for shadow class from %pragma
+static String *module_class_modifiers = 0; //class modifiers for module class overriden by %pragma
+static String *all_shadow_class_modifiers = 0; //class modifiers for all shadow classes overriden by %pragma
+static String *this_shadow_class_modifiers = 0; //class modifiers for shadow class overriden by %pragma
+static String *module_method_modifiers = 0; //native method modifiers overridden by %pragma
+
+/* Test to see if a type corresponds to something wrapped with a shadow class */
+/* Return NULL if not otherwise the shadow name */
+static String *is_shadow(SwigType *t) {
+ String *r;
+ SwigType *lt = Swig_clocal_type(t);
+ r = Getattr(shadow_classes,lt);
+ Delete(lt);
+ return r;
+}
+
+// Return the type of the c array
+static SwigType *get_array_type(SwigType *t) {
+ SwigType *ta = 0;
+ if (SwigType_type(t) == T_ARRAY) {
+ SwigType *aop;
+ ta = Copy(t);
+ aop = SwigType_pop(ta);
}
- Printf(stderr, "SwigTcToJniType: unhandled SWIG type %s\n", DataType_str(t,0));
- return NULL;
+ return ta;
}
-char *JAVA::SwigTcToJavaType(DataType *t, int ret, int inShadow) {
- if(DataType_is_pointer(t) == 1) {
- switch(DataType_Gettypecode(t)) {
- case T_INT: return (char*)"int []";
- case T_SHORT: return (char*)"short []";
- case T_LONG: return (char*)"long []";
- case T_CHAR: return (char*)"String";
- case T_FLOAT: return (char*)"float []";
- case T_DOUBLE: return (char*)"double []";
- case T_UINT: return (char*)"int []";
- case T_USHORT: return (char*)"short []";
- case T_ULONG: return (char*)"long []";
- case T_UCHAR: return (char*)"byte []";
- case T_SCHAR: return (char*)"byte []";
- case T_BOOL: return (char*)"boolean []";
- case T_VOID:
- case T_USER: if(inShadow && Getattr(shadow_classes,DataType_Getname(t)))
- return GetChar(shadow_classes,DataType_Getname(t));
- else return (char*)"long";
- }
- } else if(DataType_is_pointer(t) > 1) {
- if(ret)
- return (char*)"long";
- else return (char*)"long []";
- } else {
- switch(DataType_Gettypecode(t)) {
- case T_INT: return (char*)"int";
- case T_SHORT: return (char*)"short";
- case T_LONG: return (char*)"long";
- case T_CHAR: return (char*)"byte";
- case T_FLOAT: return (char*)"float";
- case T_DOUBLE: return (char*)"double";
- case T_UINT: return (char*)"int";
- case T_USHORT: return (char*)"short";
- case T_ULONG: return (char*)"long";
- case T_UCHAR: return (char*)"byte";
- case T_SCHAR: return (char*)"byte";
- case T_BOOL: return (char*)"boolean";
- case T_VOID: return (char*)"void";
- case T_USER: return (char*)"long";
- }
+/*
+Return java type in java_type.
+The type returned is the java type when shadow_flag=0.
+The type returned is the java shadow type when shadow_flag=1.
+*/
+void JAVA::SwigToJavaType(SwigType *t, String_or_char *pname, String* java_type, int shadow_flag) {
+ char *jtype = 0;
+ if (shadow_flag)
+ jtype = JavaTypeFromTypemap((char*)"jstype", t, pname);
+ if (!jtype)
+ jtype = JavaTypeFromTypemap((char*)"jtype", t, pname);
+
+ if(jtype) {
+ Printf(java_type, jtype);
+ }
+ else {
+ /* Map type here */
+ switch(SwigType_type(t)) {
+ case T_CHAR: Printf(java_type, "byte"); break;
+ case T_SCHAR: Printf(java_type, "byte"); break;
+ case T_UCHAR: Printf(java_type, "short"); break;
+ case T_SHORT: Printf(java_type, "short"); break;
+ case T_USHORT: Printf(java_type, "int"); break;
+ case T_INT: Printf(java_type, "int"); break;
+ case T_UINT: Printf(java_type, "long"); break;
+ case T_LONG: Printf(java_type, "long"); break;
+ case T_ULONG: Printf(java_type, "long"); break;
+ case T_FLOAT: Printf(java_type, "float"); break;
+ case T_DOUBLE: Printf(java_type, "double"); break;
+ case T_BOOL: Printf(java_type, "boolean"); break;
+ case T_STRING: Printf(java_type, "String"); break;
+ case T_VOID: Printf(java_type, "void"); break;
+ case T_POINTER:
+ case T_REFERENCE:
+ case T_USER:
+ if(shadow_flag && is_shadow(t))
+ Printf(java_type, Char(is_shadow(t)));
+ else
+ Printf(java_type, "long");
+ break;
+ case T_ARRAY:
+ if(shadow_flag && is_shadow(t))
+ Printf(java_type, "%s[]", Char(is_shadow(t)));
+ else {
+ SwigType* array_type = get_array_type(t);
+ /* Arrays of arrays not shadowed properly yet */
+ if (SwigType_type(array_type) != T_ARRAY)
+ SwigToJavaType(array_type, pname, java_type, shadow_flag);
+ else
+ Printf(java_type, "long");
+ Printv(java_type, "[]", 0);
+ }
+ break;
+ default:
+ Printf(stderr, "SwigToJavaType: unhandled data type: %s\n", SwigType_str(t,0));
+ break;
+ }
+// printf("SwigToJavaType %d [%s]\n", SwigType_type(t), Char(java_type));
}
- Printf(stderr, "SwigTcToJavaType: unhandled SWIG type %s\n", DataType_str(t,0));
- return NULL;
}
-char *JAVA::SwigTcToJniScalarType(DataType *t) {
- if(DataType_is_pointer(t) == 1) {
- switch(DataType_Gettypecode(t)) {
- case T_INT: return (char*)"Int";
- case T_SHORT: return (char*)"Short";
- case T_LONG: return (char*)"Long";
- case T_CHAR: return (char*)"Byte";
- case T_FLOAT: return (char*)"Float";
- case T_DOUBLE: return (char*)"Double";
- case T_UINT: return (char*)"Int";
- case T_USHORT: return (char*)"Short";
- case T_ULONG: return (char*)"Long";
- case T_UCHAR: return (char*)"Byte";
- case T_SCHAR: return (char*)"Byte";
- case T_BOOL: return (char*)"Boolean";
- case T_VOID:
- case T_USER: return (char*)"Long";
- }
- } else {
- return (char*)"Long";
+/* Return JNI type in jni_type. */
+void JAVA::SwigToJNIType(SwigType *t, String_or_char *pname, String* jni_type) {
+ char *jtype = JavaTypeFromTypemap((char*)"jni", t, pname);
+
+ if(jtype) {
+ Printf(jni_type, jtype);
}
+ else {
+ /* Map type here */
+ switch(SwigType_type(t)) {
+ case T_CHAR: Printf(jni_type, "jbyte"); break;
+ case T_SCHAR: Printf(jni_type, "jbyte"); break;
+ case T_UCHAR: Printf(jni_type, "jshort"); break;
+ case T_SHORT: Printf(jni_type, "jshort"); break;
+ case T_USHORT: Printf(jni_type, "jint"); break;
+ case T_INT: Printf(jni_type, "jint"); break;
+ case T_UINT: Printf(jni_type, "jlong"); break;
+ case T_LONG: Printf(jni_type, "jlong"); break;
+ case T_ULONG: Printf(jni_type, "jlong"); break;
+ case T_FLOAT: Printf(jni_type, "jfloat"); break;
+ case T_DOUBLE: Printf(jni_type, "jdouble"); break;
+ case T_BOOL: Printf(jni_type, "jboolean"); break;
+ case T_STRING: Printf(jni_type, "jstring"); break;
+ case T_VOID: Printf(jni_type, "void"); break;
+ case T_POINTER:
+ case T_REFERENCE:
+ case T_USER: Printf(jni_type, "jlong"); break;
+ case T_ARRAY:
+ {
+ SwigType* array_type = get_array_type(t);
+ if (SwigType_type(array_type) != T_ARRAY)
+ SwigToJNIType(array_type, pname, jni_type);
+ else
+ Printf(jni_type, "jlong"); // Arrays of arrays not implemented
+ Printv(jni_type, "Array", 0);
+ }
+ break;
+ default:
+ Printf(stderr, "SwigToJNIType: unhandled data type: %s\n", SwigType_str(t,0));
+ break;
+ }
+// printf("SwigToJNIType %d [%s]\n", SwigType_type(t), Char(jni_type));
+ }
+}
- Printf(stderr, "SwigTcToJniScalarType: unhandled SWIG type %s\n", DataType_str(t,0));
- return NULL;
+char *JAVA::SwigToJavaArrayType(SwigType *t) {
+ switch(SwigType_type(t)) {
+ case T_CHAR: return (char*)"Byte";
+ case T_SCHAR: return (char*)"Byte";
+ case T_UCHAR: return (char*)"Short";
+ case T_SHORT: return (char*)"Short";
+ case T_USHORT: return (char*)"Int";
+ case T_INT: return (char*)"Int";
+ case T_UINT: return (char*)"Long";
+ case T_LONG: return (char*)"Long";
+ case T_ULONG: return (char*)"Long";
+ case T_FLOAT: return (char*)"Float";
+ case T_DOUBLE: return (char*)"Double";
+ case T_BOOL: return (char*)"Boolean";
+ case T_STRING: return (char*)"String";
+ case T_POINTER:
+ case T_REFERENCE:
+ case T_ARRAY:
+ case T_VOID:
+ case T_USER:
+ default : return (char*)"Long"; // Treat as a pointer
+ }
}
-char *JAVA::JavaMethodSignature(DataType *t, int ret, int inShadow) {
- if(DataType_is_pointer(t) == 1) {
- switch(DataType_Gettypecode(t)) {
- case T_INT: return (char*)"[I";
+/* JavaMethodSignature still needs updating for changes from SWIG1.3a3 to SWIG1.3a5 */
+char *JAVA::JavaMethodSignature(SwigType *t, int ret, int inShadow) {
+ if(SwigType_ispointer(t) == 1) {
+ switch(SwigType_type(t)) {
+ case T_CHAR: return (char*)"Ljava/lang/String;";
+ case T_SCHAR: return (char*)"[B";
+ case T_UCHAR: return (char*)"[S";
case T_SHORT: return (char*)"[S";
+ case T_USHORT: return (char*)"[I";
+ case T_INT: return (char*)"[I";
+ case T_UINT: return (char*)"[J";
case T_LONG: return (char*)"[J";
- case T_CHAR: return (char*)"Ljava/lang/String;";
+ case T_ULONG: return (char*)"[J";
case T_FLOAT: return (char*)"[F";
case T_DOUBLE: return (char*)"[D";
- case T_UINT: return (char*)"[I";
- case T_USHORT: return (char*)"[S";
- case T_ULONG: return (char*)"[J";
- case T_UCHAR: return (char*)"[B";
- case T_SCHAR: return (char*)"[B";
case T_BOOL: return (char*)"[Z";
+ case T_STRING: return (char*)"Ljava/lang/String;";
+ case T_POINTER: return (char*)"[J";
+ case T_REFERENCE: return (char*)"[J";
+ case T_ARRAY: return (char*)"???";
case T_VOID:
- case T_USER: if(inShadow && Getattr(shadow_classes,DataType_Getname(t)))
- return GetChar(shadow_classes,DataType_Getname(t));
+ case T_USER: if(inShadow && is_shadow(t))
+ return Char(is_shadow(t));
else return (char*)"J";
}
- } else if(DataType_is_pointer(t) > 1) {
+ } else if(SwigType_ispointer(t) > 1) {
if(ret) return (char*)"J";
else return (char*)"[J";
} else {
- switch(DataType_Gettypecode(t)) {
- case T_INT: return (char*)"I";
+ switch(SwigType_type(t)) {
+ case T_CHAR: return (char*)"B";
+ case T_SCHAR: return (char*)"B";
+ case T_UCHAR: return (char*)"S";
case T_SHORT: return (char*)"S";
+ case T_USHORT: return (char*)"I";
+ case T_INT: return (char*)"I";
+ case T_UINT: return (char*)"J";
case T_LONG: return (char*)"J";
- case T_CHAR: return (char*)"B";
+ case T_ULONG: return (char*)"J";
case T_FLOAT: return (char*)"F";
case T_DOUBLE: return (char*)"D";
- case T_UINT: return (char*)"I";
- case T_USHORT: return (char*)"S";
- case T_ULONG: return (char*)"J";
- case T_UCHAR: return (char*)"B";
- case T_SCHAR: return (char*)"B";
case T_BOOL: return (char*)"Z";
+ case T_STRING: return (char*)"Ljava/lang/String;";
+ case T_POINTER: return (char*)"J";
+ case T_REFERENCE: return (char*)"J";
+ case T_ARRAY: return (char*)"???";
case T_VOID: return (char*)"V";
case T_USER: return (char*)"J";
}
}
- Printf(stderr, "JavaMethodSignature: unhandled SWIG type %s\n", DataType_str(t,0));
+ Printf(stderr, "JavaMethodSignature: unhandled SWIG type [%d] %s\n", SwigType_type(t), SwigType_str(t,0));
return NULL;
}
-char *JAVA::JavaTypeFromTypemap(char *op, char *lang, DataType *t, char *pname) {
+char *JAVA::JavaTypeFromTypemap(char *op, SwigType *t, String_or_char *pname) {
char *tm;
char *c = bigbuf;
- if(!(tm = typemap_lookup(op, lang, t, pname, (char*)"", (char*)""))) return NULL;
+ if(!(tm = Swig_typemap_lookup(op, t, pname, (char*)"", (char*)"", NULL))) return NULL;
while(*tm && (isspace(*tm) || *tm == '{')) tm++;
while(*tm && *tm != '}') *c++ = *tm++;
*c='\0';
@@ -248,7 +289,8 @@ char *JAVA::makeValidJniName(char *name) {
while(*c) {
*b++ = *c;
- if(*c == '_') *b++ = '1';
+ if(*c == '_')
+ *b++ = '1';
c++;
}
*b = '\0';
@@ -257,7 +299,7 @@ char *JAVA::makeValidJniName(char *name) {
}
// !! this approach fails for functions without arguments
-char *JAVA::JNICALL(DOHString_or_char *func) {
+char *JAVA::JNICALL(String_or_char *func) {
if(jnic)
sprintf(bigbuf, "(*jenv)->%s(jenv, ", Char(func));
else
@@ -327,7 +369,7 @@ void JAVA::parse_args(int argc, char *argv[]) {
if (argv[i]) {
if (strcmp(argv[i],"-module") == 0) {
if (argv[i+1]) {
- set_module(argv[i+1],0);
+ set_module(argv[i+1]);
Swig_mark_arg(i);
Swig_mark_arg(i+1);
i++;
@@ -350,9 +392,9 @@ void JAVA::parse_args(int argc, char *argv[]) {
} else if (strcmp(argv[i],"-jnic") == 0) {
Swig_mark_arg(i);
jnic = 1;
- } else if (strcmp(argv[i],"-finalize") == 0) {
+ } else if (strcmp(argv[i],"-nofinalize") == 0) {
Swig_mark_arg(i);
- finalize = 1;
+ nofinalize = 1;
} else if (strcmp(argv[i],"-rn") == 0) {
Swig_mark_arg(i);
useRegisterNatives = 1;
@@ -386,28 +428,35 @@ void JAVA::parse_args(int argc, char *argv[]) {
// ---------------------------------------------------------------------
void JAVA::parse() {
-
- Printf(stderr,"Generating wrappers for Java\n");
-
shadow_classes = NewHash();
shadow_classdef = NewString("");
registerNativesList = NewString("");
+ java_enum_code = NewString("");
+ module_extra_code = NewString("");
+ module_baseclass = NewString("");
+ module_interfaces = NewString("");
+ module_class_modifiers = NewString("");
+ all_shadow_extra_code = NewString("");
+ all_shadow_import = NewString("");
+ all_shadow_baseclass = NewString("");
+ all_shadow_interfaces = NewString("");
+ all_shadow_class_modifiers = NewString("");
+ module_import = NewString("");
+ module_method_modifiers = NewString("public final static");
headers(); // Emit header files and other supporting code
yyparse(); // Run the SWIG parser
}
// ---------------------------------------------------------------------
-// JAVA::set_module(char *mod_name,char **mod_list)
+// JAVA::set_module(char *mod_name)
//
// Sets the module name. Does nothing if it's already set (so it can
// be overriddent as a command line option).
//
-// mod_list is a NULL-terminated list of additional modules. This
-// is really only useful when building static executables.
//----------------------------------------------------------------------
-void JAVA::set_module(char *mod_name, char **mod_list) {
+void JAVA::set_module(char *mod_name) {
if (module) return;
module = new char[strlen(mod_name)+1];
strcpy(module,mod_name);
@@ -447,13 +496,13 @@ void JAVA::initialize()
}
if(package) {
- DOHString *s = NewString(package);
+ String *s = NewString(package);
Replace(s,".","_", DOH_REPLACE_ANY);
Append(s,"_");
c_pkgstr = Swig_copy_string(Char(s));
Delete(s);
- DOHString *s2 = NewString(package);
+ String *s2 = NewString(package);
Replace(s2,".","/", DOH_REPLACE_ANY);
Append(s2,"/");
jni_pkgstr = Swig_copy_string(Char(s2));
@@ -464,7 +513,12 @@ void JAVA::initialize()
sprintf(bigbuf, "Java_%s%s", c_pkgstr, module);
c_pkgstr = Swig_copy_string(bigbuf);
- sprintf(bigbuf, "%s_%%f", c_pkgstr);
+
+ if (strchr(module + strlen(module)-1, '_')) //if module has a '_' as last character
+ sprintf(bigbuf, "%s1_%%f", c_pkgstr); //separate double underscore with 1
+ else
+ sprintf(bigbuf, "%s_%%f", c_pkgstr);
+
Swig_name_register((char*)"wrapper", Swig_copy_string(bigbuf));
Swig_name_register((char*)"set", (char*)"set_%v");
Swig_name_register((char*)"get", (char*)"get_%v");
@@ -486,9 +540,36 @@ void JAVA::initialize()
}
}
+void emit_banner(FILE *f) {
+ Printf(f, "/* ----------------------------------------------------------------------------\n");
+ Printf(f, " * This file was automatically generated by SWIG (http://www.swig.org).\n");
+ Printf(f, " * Version: %s\n", SWIG_VERSION);
+ Printf(f, " *\n");
+ Printf(f, " * Do not make changes to this file unless you know what you are doing--modify\n");
+ Printf(f, " * the SWIG interface file instead.\n");
+ Printf(f, " * ----------------------------------------------------------------------------- */\n\n");
+}
+
void JAVA::emit_classdef() {
- if(!classdef_emitted)
- Printf(f_java, "public class %s {\n", module);
+ if(!classdef_emitted) {
+ emit_banner(f_java);
+ if(module_import)
+ Printf(f_java, "%s\n", module_import);
+
+ if (module_class_modifiers && *Char(module_class_modifiers))
+ Printf(f_java, "%s", module_class_modifiers);
+ else
+ Printf(f_java, "public");
+ Printf(f_java, " class %s ", module);
+
+ if (module_baseclass)
+ Printv(f_java, module_baseclass, 0);
+ if (module_interfaces)
+ Printv(f_java, module_interfaces, " ", 0);
+ Printf(f_java, "{\n", module);
+ if (module_extra_code)
+ Printv(f_java, module_extra_code, 0);
+ }
classdef_emitted = 1;
}
@@ -502,12 +583,33 @@ void JAVA::close(void)
{
if(!classdef_emitted) emit_classdef();
+ // Write the enum initialisation code in a static block.
+ // These are all the enums defined in the global c context.
+ if (strlen(Char(java_enum_code)) != 0 )
+ Printv(f_java, " static {\n // Initialise java constants from c/c++ enums\n", java_enum_code, " }\n",0);
+
// Finish off the java class
Printf(f_java, "}\n");
fclose(f_java);
if(useRegisterNatives)
writeRegisterNatives();
+
+ Delete(shadow_classes); shadow_classes = NULL;
+ Delete(shadow_classdef); shadow_classdef = NULL;
+ Delete(registerNativesList); registerNativesList = NULL;
+ Delete(java_enum_code); java_enum_code = NULL;
+ Delete(module_extra_code); module_extra_code = NULL;
+ Delete(module_baseclass); module_baseclass = NULL;
+ Delete(module_interfaces); module_interfaces = NULL;
+ Delete(module_class_modifiers); module_class_modifiers = NULL;
+ Delete(all_shadow_extra_code); all_shadow_extra_code = NULL;
+ Delete(all_shadow_import); all_shadow_import = NULL;
+ Delete(all_shadow_baseclass); all_shadow_baseclass = NULL;
+ Delete(all_shadow_interfaces); all_shadow_interfaces = NULL;
+ Delete(all_shadow_class_modifiers); all_shadow_class_modifiers = NULL;
+ Delete(module_import); module_import = NULL;
+ Delete(module_method_modifiers); module_method_modifiers = NULL;
}
// ----------------------------------------------------------------------
@@ -519,31 +621,54 @@ void JAVA::close(void)
void JAVA::create_command(char *cname, char *iname) {
}
-void JAVA::add_native(char *name, char *iname, DataType *t, ParmList *l) {
+void JAVA::add_native(char *name, char *iname, SwigType *t, ParmList *l) {
native_func = 1;
create_function(name, iname, t, l);
native_func = 0;
}
// ----------------------------------------------------------------------
-// JAVA::create_function(char *name, char *iname, DataType *d, ParmList *l)
+// JAVA::create_function(char *name, char *iname, SwigType *d, ParmList *l)
//
// Create a function declaration and register it with the interpreter.
// ----------------------------------------------------------------------
-void JAVA::create_function(char *name, char *iname, DataType *t, ParmList *l)
+void JAVA::create_function(char *name, char *iname, SwigType *t, ParmList *l)
{
- char source[256], target[256];
+ char source[256], target[256];
char *tm;
- DOHString *cleanup, *outarg, *body;
char *javaReturnSignature = 0;
- DOHString *javaParameterSignature;
- Parm *p;
+ String *jnirettype = NewString("");
+ String *javarettype = NewString("");
+ String *cleanup = NewString("");
+ String *outarg = NewString("");
+ String *body = NewString("");
+ String *javaParameterSignature = NewString("");
+
+ /*
+ Generate the java class wrapper function ie the java shadow class. Only done for public
+ member variables. That is this generates the getters/setters for member variables.
+ */
+ if(shadow && wrapping_member && !enum_flag) {
+ String *member_function_name = NewString("");
+ String *java_function_name = NewString(iname);
+ if(strcmp(iname, Char(Swig_name_set(Swig_name_member(shadow_classname, shadow_variable_name)))) == 0)
+ Printf(member_function_name,"set");
+ else Printf(member_function_name,"get");
+ Putc(toupper((int) *shadow_variable_name), member_function_name);
+ Printf(member_function_name, "%s", shadow_variable_name+1);
+
+ cpp_func(Char(member_function_name), t, l, java_function_name);
+
+ Delete(java_function_name);
+ Delete(member_function_name);
+ }
- cleanup = NewString("");
- outarg = NewString("");
- body = NewString("");
- javaParameterSignature = NewString("");
+ /*
+ The rest of create_function deals with generating the java wrapper function (that wraps
+ a c/c++ function) and generating the JNI c code. Each java wrapper function has a
+ matching JNI c function call.
+ */
// A new wrapper function object
Wrapper *f = NewWrapper();
@@ -551,15 +676,14 @@ void JAVA::create_function(char *name, char *iname, DataType *t, ParmList *l)
if(!classdef_emitted) emit_classdef();
// Make a wrapper name for this function
-
char *jniname = makeValidJniName(iname);
- char *wname = Swig_name_wrapper(jniname);
+ String *wname = Swig_name_wrapper(jniname);
+
free(jniname);
- char *jnirettype = JavaTypeFromTypemap((char*)"jni", typemap_lang, t, iname);
- if(!jnirettype) jnirettype = SwigTcToJniType(t, 1);
- char *javarettype = JavaTypeFromTypemap((char*)"jtype", typemap_lang, t, iname);
- if(!javarettype) javarettype = SwigTcToJavaType(t, 1, 0);
+ /* Get the java and jni types of the return */
+ SwigToJNIType(t, iname, jnirettype);
+ SwigToJavaType(t, iname, javarettype, 0);
// If dumping the registerNative outputs, store the method return type
// signature
@@ -567,25 +691,15 @@ void JAVA::create_function(char *name, char *iname, DataType *t, ParmList *l)
javaReturnSignature = JavaMethodSignature(t, 1, 0);
}
- if (DataType_type(t) != T_VOID) {
- Wrapper_add_localv(f,"_jresult", jnirettype, "_jresult = 0",0);
+ if (SwigType_type(t) != T_VOID) {
+ Wrapper_add_localv(f,"jresult", jnirettype, "jresult = 0",0);
}
- Printf(f_java, " %s ", method_modifiers);
+ Printf(f_java, " %s ", module_method_modifiers);
Printf(f_java, "native %s %s(", javarettype, iname);
- if(shadow && member_func) {
- DOHString *member_name = NewString("");
- if(strcmp(iname, Swig_name_set(Swig_name_member(shadow_classname, shadow_name))) == 0)
- Printf(member_name,"set");
- else Printf(member_name,"get");
- Putc(toupper((int) *shadow_name), member_name);
- Printf(member_name, "%s", shadow_name+1);
- Printf(f_shadow, " public %s %s(", javarettype, member_name);
- Printv(body, tab4, "return ", module, ".", iname, "(_self", 0);
- Delete(member_name);
- }
- if(!jnic) Printf(f->def,"extern \"C\"\n");
+ if(!jnic)
+ Printv(f->def, "extern \"C\"{\n", 0);
Printv(f->def, "JNIEXPORT ", jnirettype, " JNICALL ", wname, "(JNIEnv *jenv, jclass jcls", 0);
// Emit all of the local variables for holding arguments.
@@ -594,198 +708,288 @@ void JAVA::create_function(char *name, char *iname, DataType *t, ParmList *l)
int gencomma = 0;
// Now walk the function parameter list and generate code to get arguments
- p = l;
+ Parm *p = l;
for (int i = 0; i < pcount ; i++, p = Getnext(p)) {
- DataType *pt = Gettype(p);
- char *pn = Getname(p);
- char *target_copy = NULL;
- char *target_length = NULL;
- char *local_i = NULL;
+ SwigType *pt = Gettype(p);
+ String *pn = Getname(p);
+ String *javaparamtype = NewString("");
+ String *jni_param_type = NewString("");
// Produce string representation of source and target arguments
- sprintf(source,"jarg%d",i);
- sprintf(target,"%s", Getlname(p));
+ sprintf(target,"%s", Char(Getlname(p)));
+ sprintf(source,"j%s", target);
- char *jnitype = JavaTypeFromTypemap((char*)"jni", typemap_lang, pt, pn);
- if(!jnitype) jnitype = SwigTcToJniType(pt, 0);
- char *jtype = JavaTypeFromTypemap((char*)"jtype", typemap_lang, pt, pn);
- if(!jtype) jtype = SwigTcToJavaType(pt, 0, 0);
if (useRegisterNatives) {
Printv(javaParameterSignature, JavaMethodSignature(pt, 0, 0), 0);
}
if(Getignore(p)) continue;
- // Add to java function header
- if(shadow && member_func) {
- if(i > 0) {
- if(i>1) Printf(f_shadow, ", ");
- Printf(f_shadow, "%s %s", jtype, source);
- Printv(body,", ", source, 0);
- }
- }
+ /* Get the java and jni types of the parameter */
+ SwigToJNIType(pt, pn, jni_param_type);
+ SwigToJavaType(pt, pn, javaparamtype, 0);
+ /* Add to java function header */
if(gencomma) Printf(f_java, ", ");
- Printf(f_java, "%s %s", jtype, source);
+ Printf(f_java, "%s %s", javaparamtype, source);
gencomma = 1;
// Add to Jni function header
- Printv(f->def, ", ", jnitype, " ", source, 0);
+ Printv(f->def, ", ", jni_param_type, " ", source, 0);
// Get typemap for this argument
- tm = typemap_lookup((char*)"in",typemap_lang,pt,pn,source,target,f);
+ tm = Swig_typemap_lookup((char*)"in",pt,pn,source,target,f);
if (tm) {
- Printf(f->code,"%s\n", tm);
- Replace(f->code,"$arg",source, DOH_REPLACE_ANY);
+ Printf(f->code,"%s\n", tm);
+ Replace(f->code,"$arg",source, DOH_REPLACE_ANY);
} else {
- if(!DataType_is_pointer(pt))
- Printv(f->code, tab4, target, " = (", DataType_lstr(pt,0), ") ", source, ";\n", 0);
- else if((DataType_Gettypecode(pt) == T_VOID && (DataType_is_pointer(pt) == 1)) ||
- (DataType_Gettypecode(pt) == T_USER && (DataType_is_pointer(pt) == 1))) {
- DataType_add_pointer(pt);
- Printv(f->code, tab4, target, " = *(", DataType_lstr(pt,0), ")&", source, ";\n", 0);
- DataType_del_pointer(pt);
- } else {
- if(DataType_type(pt) == T_STRING) {
- Printv(f->code, tab4, target, " = (", source, ") ? (char *)", JNICALL((char*)"GetStringUTFChars"), source, ", 0) : NULL;\n", 0);
- } else {
- char *scalarType = SwigTcToJniScalarType(pt);
-
- DataType_del_pointer(pt);
- const char *basic_jnitype = (DataType_is_pointer(pt) > 0) ? "jlong" : SwigTcToJniType(pt, 0);
- char *ctype = DataType_lstr(pt,0);
- if(scalarType == NULL || basic_jnitype == NULL) {
- Printf(stderr, "\'%s\' does not have a in/jni typemap, and is not a basic type.\n", ctype);
- SWIG_exit(1);
- };
- DataType_add_pointer(pt);
-
- DOHString *basic_jniptrtype = NewStringf("%s*",basic_jnitype);
- DOHString *source_length = NewStringf("%s%s)", JNICALL((char*)"GetArrayLength"), source);
-
- target_copy = Swig_copy_string(Wrapper_new_localv(f,target,Char(basic_jniptrtype), target, 0));
- target_length = Swig_copy_string(Wrapper_new_localv(f,target,"jsize", target, "=", Char(source_length),0));
- if(local_i == NULL) local_i = Swig_copy_string(Wrapper_new_local(f,"i","int i"));
-
- DOHString *scalarFunc = NewStringf("Get%sArrayElements",scalarType);
-
- Printv(f->code, tab4, target_copy, " = ", JNICALL(scalarFunc), source, ", 0);\n", 0);
- Printv(f->code, tab4, target, " = (", DataType_lstr(pt,0), ") malloc(", target_length, " * sizeof(", ctype, "));\n", 0);
- Printv(f->code, tab4, "for(i=0; i<", target_length, "; i++)\n", 0);
- if(DataType_is_pointer(pt) > 1) {
- Printv(f->code, tab8, target, "[i] = *(", DataType_lstr(pt,0), ")&", target_copy, "[i];\n", 0);
- } else {
- DataType_del_pointer(pt);
- Printv(f->code, tab8, target, "[i] = (", DataType_lstr(pt,0), ")", target_copy, "[i];\n", 0);
- DataType_add_pointer(pt);
- }
- Delete(scalarFunc);
- Delete(source_length);
- Delete(basic_jniptrtype);
+ switch(SwigType_type(pt)) {
+ case T_BOOL:
+ 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:
+ Printv(f->code, tab4, target, " = (", SwigType_lstr(pt,0), ") ", source, ";\n", 0);
+ break;
+ case T_STRING:
+ Printv(f->code, tab4, target, " = (", source, ") ? (char *)", JNICALL((char*)"GetStringUTFChars"), source, ", 0) : NULL;\n", 0);
+ break;
+ case T_VOID:
+ break;
+ case T_USER:
+ Printv(f->code, tab4, target, " = *(", SwigType_lstr(pt,0), "**)&", source, ";\n", 0);
+ break;
+ case T_POINTER:
+ case T_REFERENCE:
+ Printv(f->code, tab4, target, " = *(", SwigType_lstr(pt,0), "*)&", source, ";\n", 0);
+ break;
+ case T_ARRAY:
+ {
+ String *jni_array_type = NewString("");
+ SwigType *array_type = get_array_type(pt);
+ char *java_array_type = SwigToJavaArrayType(array_type);
+ SwigToJNIType(array_type, pn, jni_array_type);
+
+ String *ctype = SwigType_lstr(array_type, 0);
+
+ String *basic_jniptrtype = NewStringf("%s*", jni_array_type);
+ String *source_length = NewStringf("%s%s)", JNICALL((char*)"GetArrayLength"), source);
+ String *c_array = NewStringf("%s_carray", source);
+ String *array_len = NewStringf("%s_len", source);
+ String *get_array_func = NewStringf("Get%sArrayElements", java_array_type);
+
+ Wrapper_add_localv(f, "i", "int", "i", 0); // Only gets added once if called more than once
+ Wrapper_add_localv(f, c_array, basic_jniptrtype, c_array, 0);
+ Wrapper_add_localv(f, array_len, "jsize", array_len, "= ", source_length, 0);
+
+ Printv(f->code, tab4, c_array, " = ", JNICALL(get_array_func), source, ", 0);\n", 0);
+ Printv(f->code, tab4, target, " = (", SwigType_lstr(pt, 0), ") malloc(", array_len, " * sizeof(", ctype, "));\n", 0);
+ Printv(f->code, tab4, "for(i=0; i<", array_len, "; i++)\n", 0);
+
+ switch(SwigType_type(array_type)) {
+ case T_USER:
+ Printv(f->code, tab8, target, "[i] = **(", ctype, "**)&", c_array, "[i];\n", 0);
+ break;
+ case T_POINTER:
+ Printv(f->code, tab8, target, "[i] = *(", ctype, "*)&", c_array, "[i];\n", 0);
+ break;
+ default:
+ Printv(f->code, tab8, target, "[i] = (", ctype, ")", c_array, "[i];\n", 0);
+ break;
+ }
+
+ Delete(jni_array_type);
+ Delete(basic_jniptrtype);
+ Delete(source_length);
+ Delete(c_array);
+ Delete(array_len);
+ Delete(get_array_func);
}
+ break;
+ default:
+ Printf(stderr,"%s : Line %d. Error: Unknown typecode for type %s\n", input_file,line_number,SwigType_str(pt,0));
+ break;
}
}
// Check to see if there was any sort of a constaint typemap
- if ((tm = typemap_lookup((char*)"check",typemap_lang,pt,pn,source,target))) {
+ if ((tm = Swig_typemap_lookup((char*)"check",pt,pn,source,target,NULL))) {
// Yep. Use it instead of the default
Printf(f->code,"%s\n", tm);
Replace(f->code,"$arg",source, DOH_REPLACE_ANY);
}
// Check if there was any cleanup code (save it for later)
- if ((tm = typemap_lookup((char*)"freearg",typemap_lang,pt,pn,source,target))) {
+ if ((tm = Swig_typemap_lookup((char*)"freearg",pt,pn,source,target,NULL))) {
// Yep. Use it instead of the default
Printf(cleanup,"%s\n", tm);
Replace(cleanup,"$arg",source, DOH_REPLACE_ANY);
}
- if ((tm = typemap_lookup((char*)"argout",typemap_lang,pt,pn,source,target))) {
+ if ((tm = Swig_typemap_lookup((char*)"argout",pt,pn,source,target,NULL))) {
// Yep. Use it instead of the default
Printf(outarg,"%s\n", tm);
Replace(outarg,"$arg",source, DOH_REPLACE_ANY);
} else {
- // if(pt->is_pointer && pt->type != T_USER && pt->type != T_VOID) {
- if(DataType_is_pointer(pt)) {
- if(DataType_type(pt) == T_STRING) {
- Printv(outarg, tab4, "if(", target,") ", JNICALL((char*)"ReleaseStringUTFChars"), source, ", ", target, ");\n", 0);
- } else if(((DataType_Gettypecode(pt) == T_VOID) && DataType_is_pointer(pt) == 1) ||
- ((DataType_Gettypecode(pt) == T_USER) && DataType_is_pointer(pt) == 1)) {
- // nothing to do
- } else {
- char *scalarType = SwigTcToJniScalarType(pt);
-
- DataType_del_pointer(pt);
- const char *basic_jnitype = (DataType_is_pointer(pt) > 0) ? "jlong" : SwigTcToJniType(pt, 0);
- char *ctype = DataType_lstr(pt,0);
- if(scalarType == NULL || basic_jnitype == NULL) {
- Printf(stderr, "\'%s\' does not have a argout/jni typemap, and is not a basic type.\n", ctype);
- SWIG_exit(1);
- };
- DataType_add_pointer(pt);
- Printf(outarg, " for(i=0; i< %d; i++)\n", target_length);
- if(DataType_is_pointer(pt) > 1) {
- Printv(outarg, tab8, "*(", DataType_lstr(pt,0), ")&", target_copy, "[i] = ", target, "[i];\n", 0);
- } else {
- Printv(outarg, tab8, target_copy, "[i] = (", basic_jnitype, ") ", target, "[i];\n", 0);
- }
- DOHString *scalarFunc = NewStringf("Release%sArrayElements",scalarType);
- Printv(outarg, tab4, JNICALL(scalarFunc), source, ", ", target_copy, ", 0);\n", 0);
- Printv(outarg, tab4, "free(", target, ");\n", 0);
- Delete(scalarFunc);
- free(target_copy);
- free(target_length);
- free(local_i);
- }
- }
+ switch(SwigType_type(pt)) {
+ case T_BOOL:
+ 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:
+ // nothing to do
+ break;
+ case T_STRING:
+ Printv(outarg, tab4, "if(", target,") ", JNICALL((char*)"ReleaseStringUTFChars"), source, ", ", target, ");\n", 0);
+ break;
+ case T_VOID:
+ case T_USER:
+ case T_POINTER:
+ case T_REFERENCE:
+ // nothing to do
+ break;
+ case T_ARRAY:
+ {
+ String *jni_array_type = NewString("");
+ SwigType *array_type = get_array_type(pt);
+ char *java_array_type = SwigToJavaArrayType(array_type);
+ SwigToJNIType(array_type, pn, jni_array_type);
+
+ String *c_array = NewStringf("%s_carray", source);
+ String *release_array_func = NewStringf("Release%sArrayElements", java_array_type);
+
+ Printv(outarg, tab4, JNICALL(release_array_func), source, ", ", c_array, ", 0);\n", 0);
+ Printv(outarg, tab4, "free(", target, ");\n", 0);
+
+ Delete(jni_array_type);
+ Delete(c_array);
+ Delete(release_array_func);
+ }
+ break;
+ default:
+ Printf(stderr,"%s : Line %d. Error: Unknown typecode for type %s\n", input_file,line_number,SwigType_str(pt,0));
+ break;
+ }
+ }
+ Delete(javaparamtype);
+ Delete(jni_param_type);
}
- }
Printf(f_java, ");\n");
- if(shadow && member_func) {
- Printf(f_shadow, ") {\n");
- Printf(body,")");
- Printf(f_shadow, "%s;\n }\n\n",body);
- }
Printf(f->def,") {");
// Now write code to make the function call
if(!native_func)
emit_func_call(name,t,l,f);
-
// Return value if necessary
- if((DataType_type(t) != T_VOID) && !native_func) {
- if ((tm = typemap_lookup((char*)"out",typemap_lang,t,iname,(char*)"result",(char*)"_jresult"))) {
+ if((SwigType_type(t) != T_VOID) && !native_func) {
+ if ((tm = Swig_typemap_lookup((char*)"out",t,iname,(char*)"result",(char*)"jresult",NULL))) {
Printf(f->code,"%s\n", tm);
} else {
- if(DataType_type(t) == T_USER) { /* return by value */
- DataType_add_pointer(t);
- DataType_add_pointer(t);
- Printv(f->code, tab4, "*(", DataType_lstr(t,0), ")&_jresult = result;\n", 0);
- DataType_del_pointer(t);
- DataType_del_pointer(t);
- } else if(DataType_is_pointer(t) == 0 && (DataType_Gettypecode(t) != T_USER)) {
- Printv(f->code, tab4, "_jresult = (", jnirettype, ") result;\n", 0);
- } else if(((DataType_Gettypecode(t) == T_VOID) && DataType_is_pointer(t) == 1) ||
- ((DataType_Gettypecode(t) == T_USER) && DataType_is_pointer(t) == 1)) {
- DataType_add_pointer(t);
- Printv(f->code, tab4, "*(", DataType_lstr(t,0), ")&_jresult = result;\n", 0);
- DataType_del_pointer(t);
- } else {
- if(DataType_type(t) == T_STRING) {
- Printv(f->code, tab4, "if(result != NULL)\n", 0);
- Printv(f->code, tab8, "_jresult = (jstring)", JNICALL((char*)"NewStringUTF"), "result);\n", 0);
- } else {
- Printf(stderr,"%s : Line %d. Warning: no return typemap for datatype %s\n", input_file,line_number,DataType_str(t,0));
- DataType_add_pointer(t);
- Printv(f->code, tab4, "*(", DataType_lstr(t,0), ")&_jresult = result;\n", 0);
- DataType_del_pointer(t);
+ switch(SwigType_type(t)) {
+ case T_BOOL:
+ 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:
+ Printv(f->code, tab4, "jresult = (", jnirettype, ") result;\n", 0);
+ break;
+ case T_STRING:
+ Printv(f->code, tab4, "if(result != NULL)\n", 0);
+ Printv(f->code, tab8, "jresult = (jstring)", JNICALL((char*)"NewStringUTF"), "result);\n", 0);
+ break;
+ case T_VOID:
+ break;
+ case T_USER:
+ Printv(f->code, tab4, "*(", SwigType_lstr(t,0), "**)&jresult = result;\n", 0);
+ break;
+ case T_POINTER:
+ case T_REFERENCE:
+ Printv(f->code, tab4, "*(", SwigType_lstr(t,0), "*)&jresult = result;\n", 0);
+ break;
+ case T_ARRAY:
+ {
+ // Handle return values that are one dimension arrays
+ // Todo: What about void pointers?
+ // Todo: Check on array size - check user has passed correct size in
+
+ const int dim_no = 0; // Dimension number (0 == 1st ) - currently only 1 supported
+ String *jnitype_ptr = NewString("");
+ String *jnicall_new = NewString("");
+ String *jnicall_get = NewString("");
+ String *jnicall_release = NewString("");
+ String *jni_array_type = NewString("");
+ SwigType *array_type = get_array_type(t);
+ char *java_array_type = SwigToJavaArrayType(array_type);
+ SwigToJNIType(array_type, iname, jni_array_type);
+
+ Printv(jnitype_ptr, jni_array_type, "*", 0);
+ Wrapper_add_localv(f, "jnitype_ptr", jnitype_ptr, "jnitype_ptr", "= 0", 0);
+ Wrapper_add_localv(f, "k", "int", "k", 0);
+
+ // Create a java array for return to Java subsystem, eg for int array
+ // String jresult = (*jenv)->NewIntArray(jenv, array_size);
+ Printv(jnicall_new, "New", java_array_type, "Array", 0);
+ Printv(f->code, tab4, "jresult = ", JNICALL((char*)jnicall_new), SwigType_array_getdim(t, dim_no), ");\n", 0);
+
+ // Get the c memory pointer to the java array, eg for int array
+ // jnitype_ptr = (*jenv)->GetIntArrayElements(jenv, jresult, 0);
+ Printv(jnicall_get, "Get", java_array_type, "ArrayElements", 0);
+ Printv(f->code, tab4, "jnitype_ptr = ", JNICALL((char*)jnicall_get), "jresult, 0);\n", 0);
+
+ // Populate the java array from the c array
+ Printv(f->code, tab4, "for (k=0; k<", SwigType_array_getdim(t, dim_no), "; k++)\n", 0);
+ switch(SwigType_type(array_type)) {
+ case T_USER:
+ Printv(f->code, tab8, "*(", SwigType_lstr(array_type, 0), "**)&jnitype_ptr[k] = &result[k];\n", 0);
+ break;
+ case T_POINTER:
+ Printv(f->code, tab8, "*(", SwigType_lstr(array_type, 0), "*)&jnitype_ptr[k] = result[k];\n", 0);
+ break;
+ default:
+ Printv(f->code, tab8, "jnitype_ptr[k] = (", jni_array_type, ")result[k];\n", 0);
+ break;
+ }
+ // Release reference to the array so that it may be garbage collected in the future
+ // (*jenv)->ReleaseIntArrayElements(jenv, jresult, _arg00, 0);
+ Printv(jnicall_release, "Release", java_array_type, "ArrayElements", 0);
+ Printv(f->code, tab4, JNICALL((char*)jnicall_release), "jresult, ", "jnitype_ptr", ", 0);\n", 0);
+ Delete(jnitype_ptr);
+ Delete(jnicall_new);
+ Delete(jnicall_get);
+ Delete(jnicall_release);
+ Delete(jni_array_type);
+ }
+ break;
+ default:
+ Printf(stderr,"%s : Line %d. Error: Unknown typecode for type %s\n", input_file,line_number,SwigType_str(t,0));
+ break;
}
}
- }
}
// Dump argument output code;
@@ -797,20 +1001,22 @@ void JAVA::create_function(char *name, char *iname, DataType *t, ParmList *l)
// Look for any remaining cleanup
if (NewObject) {
- if ((tm = typemap_lookup((char*)"newfree",typemap_lang,t,iname,(char*)"result",(char*)""))) {
+ if ((tm = Swig_typemap_lookup((char*)"newfree",t,iname,(char*)"result",(char*)"",NULL))) {
Printf(f->code,"%s\n", tm);
}
}
- if((DataType_type(t) != T_VOID) && !native_func) {
- if ((tm = typemap_lookup((char*)"ret",typemap_lang,t,iname,(char*)"result",(char*)"_jresult", NULL))) {
+ if((SwigType_type(t) != T_VOID) && !native_func) {
+ if ((tm = Swig_typemap_lookup((char*)"ret",t,iname,(char*)"result",(char*)"jresult", NULL))) {
Printf(f->code,"%s\n", tm);
}
}
// Wrap things up (in a manner of speaking)
- if(DataType_type(t) != T_VOID)
- Printv(f->code, tab4, "return _jresult;\n", 0);
+ if(SwigType_type(t) != T_VOID)
+ Printv(f->code, tab4, "return jresult;\n", 0);
+ if(!jnic)
+ Printf(f->code, "}");
Printf(f->code, "}\n");
// Substitute the cleanup code (some exception handlers like to have this)
@@ -831,6 +1037,8 @@ void JAVA::create_function(char *name, char *iname, DataType *t, ParmList *l)
}
+ Delete(jnirettype);
+ Delete(javarettype);
Delete(cleanup);
Delete(outarg);
Delete(body);
@@ -839,103 +1047,163 @@ void JAVA::create_function(char *name, char *iname, DataType *t, ParmList *l)
}
// -----------------------------------------------------------------------
-// JAVA::link_variable(char *name, char *iname, DataType *t)
+// JAVA::link_variable(char *name, char *iname, SwigType *t)
//
// Create a JAVA link to a C variable.
// -----------------------------------------------------------------------
-void JAVA::link_variable(char *name, char *iname, DataType *t)
+void JAVA::link_variable(char *name, char *iname, SwigType *t)
{
emit_set_get(name,iname, t);
}
// -----------------------------------------------------------------------
-// JAVA::declare_const(char *name, char *iname, DataType *type, char *value)
+// JAVA::declare_const(char *name, char *iname, SwigType *type, char *value)
// ------------------------------------------------------------------------
-void JAVA::declare_const(char *name, char *iname, DataType *type, char *value) {
+void JAVA::declare_const(char *name, char *iname, SwigType *type, char *value) {
+ int OldStatus = Status;
char *tm;
FILE *jfile;
char *jname;
+ Status = STAT_READONLY;
+ String *java_type = NewString("");
if(!classdef_emitted) emit_classdef();
- if(shadow && member_func) {
+ if(shadow && wrapping_member) {
+ if(!shadow_classdef_emitted) emit_shadow_classdef();
jfile = f_shadow;
- jname = shadow_name;
+ jname = shadow_variable_name;
} else {
jfile = f_java;
jname = name;
}
- if ((tm = typemap_lookup((char*)"const",typemap_lang,type,name,name,iname))) {
- DOHString *str = NewString(tm);
+ if ((tm = Swig_typemap_lookup((char*)"const",type,name,name,iname,NULL))) {
+ String *str = NewString(tm);
Replace(str,"$value",value, DOH_REPLACE_ANY);
Printf(jfile," %s\n\n", str);
Delete(str);
} else {
- if((DataType_is_pointer(type) == 0)) {
- char *jtype = typemap_lookup((char*)"jtype", typemap_lang, type, name, name, iname);
- if(!jtype) jtype = SwigTcToJavaType(type, 0, 0);
- if(strcmp(jname, value) == 0 || strstr(value,"::") != NULL) {
- Printf(stderr, "ignoring enum constant: %s\n", jname);
- } else
- Printf(jfile, " public final static %s %s = %s;\n\n", jtype, jname, value);
- } else {
- if(DataType_type(type) == T_STRING) {
- Printf(jfile, " public final static String %s = \"%s\";\n\n", jname, value);
- } else {
- emit_set_get(name,iname, type);
+ SwigToJavaType(type, iname, java_type, shadow && wrapping_member);
+ if(strcmp(jname, value) == 0 || strstr(value,"::") != NULL) {
+ /*
+ We have found an enum.
+ The enum implementation is done using a public final static int
+ in Java. They are then initialised through a JNI call to c in a Java static block.
+ */
+ Printf(jfile, " public final static %s %s;\n", java_type, jname, value);
+
+ if(shadow && wrapping_member) {
+ Printv(shadow_enum_code, tab4, jname, " = ", module, ".", Swig_name_get(iname), "();\n", 0);
+ /*
+ The following is a work around for an apparent bug in the swig core.
+ When an enum is defined in a c++ class the emit_func_call() should
+ output ClassName::EnumName, but instead it outputs ClassName_EnumName.
+ */
+ Printv(f_header, "#define ", iname, " ", value, "\n", 0);
+ }
+ else {
+ Printv(java_enum_code, tab4, jname, " = ", Swig_name_get(iname), "();\n", 0);
}
+ enum_flag = 1;
+ emit_set_get(name,iname, type);
+ enum_flag = 0;
+ } else {
+ if(SwigType_type(type) == T_STRING)
+ Printf(jfile, " public final static %s %s = \"%s\";\n", java_type, jname, value);
+ else
+ Printf(jfile, " public final static %s %s = %s;\n", java_type, jname, value);
}
}
+ Delete(java_type);
+ Status = OldStatus;
}
-
-void emit_shadow_banner(FILE *f) {
- Printf(f, "/*\n");
- Printf(f, " *\n");
- Printf(f, " * This file was automatically generated by :\n");
- Printf(f, " * Simplified Wrapper and Interface Generator (SWIG)\n");
- Printf(f, " * Version: %s\n", SWIG_VERSION);
- Printf(f, " *\n");
- Printf(f, " * Portions Copyright (c) 1995-1997\n");
- Printf(f, " * The University of Utah and The Regents of the University of California.\n");
- Printf(f, " * Permission is granted to distribute this file in any manner provided\n");
- Printf(f, " * this notice remains intact.\n");
- Printf(f, " *\n");
- Printf(f, " * Portions Copyright (c) 1997-1999\n");
- Printf(f, " * Harco de Hilster, Harco.de.Hilster@ATConsultancy.nl\n");
- Printf(f, " *\n");
- Printf(f, " * Do not make changes to this file--changes will be lost!\n");
- Printf(f, " *\n");
- Printf(f, " */\n\n\n");
-}
-
+/*
+Valid Pragmas:
+These pragmas start with 'allshadow' or 'module'
+ modulebase - base (extends) for the java module class
+ allshadowbase - base (extends) for all java shadow classes
+ modulecode - text (java code) is copied verbatim to the java module class
+ allshadowcode - text (java code) is copied verbatim to all java shadow classes
+ moduleclassmodifiers - class modifiers for the module class
+ allshadowclassmodifiers - class modifiers for all shadow classes
+ moduleimport - import statement generation for the java module class
+ allshadowimport - import statement generation for all java shadow classes
+ moduleinterface - interface (implements) for the module class
+ allshadowinterface - interface (implements) for all shadow classes
+ modulemethodmodifiers - replaces the generated native calls' default modifiers
+*/
void JAVA::pragma(char *lang, char *code, char *value) {
if(strcmp(lang, "java") != 0) return;
- DOHString *s = NewString(value);
- Replace(s,"\\\"", "\"", DOH_REPLACE_ANY);
- if(strcmp(code, "import") == 0) {
- jimport = Swig_copy_string(Char(s));
- Printf(f_java, "// pragma\nimport %s;\n\n", jimport);
- } else if(strcmp(code, "module") == 0) {
- if(!classdef_emitted) emit_classdef();
- Printf(f_java, "// pragma\n");
- Printf(f_java, "%s", s);
- Printf(f_java, "\n\n");
- } else if(strcmp(code, "shadow") == 0) {
- if(shadow && f_shadow) {
- Printf(f_shadow, "// pragma\n");
- Printf(f_shadow, "%s", s);
- Printf(f_shadow, "\n\n");
+ String *strvalue = NewString(value);
+ Replace(strvalue,"\\\"", "\"", DOH_REPLACE_ANY);
+
+ if(strcmp(code, "moduleimport") == 0) {
+ Printf(module_import, "import %s;\n", strvalue);
+ }
+ else if(strcmp(code, "allshadowimport") == 0) {
+ if(shadow && all_shadow_import)
+ Printf(all_shadow_import, "import %s;\n", strvalue);
+ }
+ else if(strcmp(code, "import") == 0) {
+ Printf(stderr,"%s : Line %d. Ignored: Deprecated pragma. Please replace with moduleimport, shadowimport and/or allshadowimport pragmas.\n", input_file, line_number);
+ }
+ else if(strcmp(code, "modulecode") == 0 || strcmp(code, "module") == 0) {
+ if(strcmp(code, "module") == 0)
+ Printf(stderr,"%s : Line %d. Soon to be deprecated pragma. Please replace with modulecode pragma.\n", input_file, line_number);
+ Printf(module_extra_code, "%s\n", strvalue);
+ }
+ else if(strcmp(code, "allshadowcode") == 0 || strcmp(code, "shadow") == 0) {
+ if(shadow && all_shadow_extra_code) {
+ if(strcmp(code, "shadow") == 0)
+ Printf(stderr,"%s : Line %d. Soon to be deprecated pragma. Please replace with allshadowcode pragma.\n", input_file, line_number);
+ Printf(all_shadow_extra_code, "%s\n", strvalue);
}
- } else if(strcmp(code, "modifiers") == 0) {
- method_modifiers = Swig_copy_string(value);
- } else {
- Printf(stderr,"%s : Line %d. Unrecognized pragma.\n", input_file,line_number);
+ }
+ else if(strcmp(code, "modulebase") == 0) {
+ if(shadow && module_baseclass)
+ Printf(module_baseclass, "extends %s ", strvalue);
+ }
+ else if(strcmp(code, "allshadowbase") == 0) {
+ if(shadow && all_shadow_baseclass)
+ Printf(all_shadow_baseclass, "extends %s ", strvalue);
+ }
+ else if(strcmp(code, "moduleinterface") == 0) {
+ if(shadow && module_interfaces)
+ if (!*Char(module_interfaces))
+ Printf(module_interfaces, "implements %s", strvalue);
+ else
+ Printf(module_interfaces, ", %s", strvalue);
+ }
+ else if(strcmp(code, "allshadowinterface") == 0) {
+ if(shadow && all_shadow_interfaces) {
+ if (!*Char(all_shadow_interfaces))
+ Printf(all_shadow_interfaces, "implements %s", strvalue);
+ else
+ Printf(all_shadow_interfaces, ", %s", strvalue);
+ }
+ }
+ else if(strcmp(code, "allshadowclassmodifiers") == 0) {
+ if(shadow && all_shadow_class_modifiers)
+ Printv(all_shadow_class_modifiers, strvalue, 0);
+ }
+ else if(strcmp(code, "moduleclassmodifiers") == 0) {
+ if(shadow && module_class_modifiers)
+ Printv(module_class_modifiers, strvalue, 0);
+ }
+ else if(strcmp(code, "modulemethodmodifiers") == 0 || strcmp(code, "modifiers") == 0) {
+ if(strcmp(code, "modifiers") == 0)
+ Printf(stderr,"%s : Line %d. Soon to be deprecated pragma. Please replace with modulemethodmodifiers pragma.\n", input_file, line_number);
+ Clear(module_method_modifiers);
+ Printv(module_method_modifiers, strvalue, 0);
+ }
+ else {
+ Printf(stderr,"%s : Line %d. Unrecognized pragma.\n", input_file, line_number);
}
- Delete(s);
+ Delete(strvalue);
}
// ---------------------------------------------------------------------
@@ -945,22 +1213,60 @@ void JAVA::pragma(char *lang, char *code, char *value) {
// C structs.
// ---------------------------------------------------------------------
-void JAVA::add_typedef(DataType *t, char *name) {
- if(!shadow) return;
-
- // First check to see if there aren't too many pointers
-
- if (DataType_is_pointer(t) > 1) return;
-
- if(Getattr(shadow_classes,name)) return; // Already added
-
- // Now look up the datatype in our shadow class hash table
+/*
+C++ pragmas: pragmas declared within a class or c struct for the shadow class.
+These pragmas start with 'shadow'
+Valid pragmas:
+ shadowbase - base (extends) for all java shadow classes
+ shadowcode - text (java code) is copied verbatim to the shadow class
+ shadowclassmodifiers - class modifiers for the shadow class
+ shadowimport - import statement generation for the shadow class
+ shadowinterface - interfaces (extends) for the shadow class
+*/
+void JAVA::cpp_pragma(Pragma* plist) {
+ while (plist) {
+ if ( (strcmp(Char(plist->lang),(char*)"java") == 0) && shadow) {
+ String* strvalue = NewString(plist->value);
+ Replace(strvalue,"\\\"", "\"", DOH_REPLACE_ANY);
+
+ if (strcmp(Char(plist->name),"shadowcode") == 0) {
+ if (this_shadow_extra_code)
+ Printf(this_shadow_extra_code, "%s\n", strvalue);
+ }
+ else if (strcmp(Char(plist->name),"shadowimport") == 0) {
+ if (this_shadow_import)
+ Printf(this_shadow_import, "import %s;\n", strvalue);
+ }
+ else if (strcmp(Char(plist->name),"shadowbase") == 0) {
+ if (this_shadow_baseclass)
+ Printf(this_shadow_baseclass, "extends %s ", strvalue);
+ }
+ else if (strcmp(Char(plist->name),"shadowinterface") == 0) {
+ if (this_shadow_interfaces) {
+ if (!*Char(this_shadow_interfaces))
+ Printf(this_shadow_interfaces, "implements %s", strvalue);
+ else
+ Printf(this_shadow_interfaces, ", %s", strvalue);
+ }
+ }
+ else if (strcmp(Char(plist->name),"shadowclassmodifiers") == 0) {
+ if (this_shadow_class_modifiers)
+ Printv(this_shadow_class_modifiers, strvalue, 0);
+ }
+ else {
+ Printf(stderr,"%s : Line %d. Unrecognized pragma for shadow class.\n", plist->filename, plist->lineno);
+ }
- if (Getattr(shadow_classes,DataType_Getname(t))) {
+ Delete(strvalue);
+ }
+ plist = plist->next;
+ }
+}
- // Yep. This datatype is in the hash
- // Put this types 'new' name into the hash
- Setattr(shadow_classes,name,GetChar(shadow_classes,DataType_Getname(t)));
+void JAVA::add_typedef(SwigType *t, char *name) {
+ if(!shadow) return;
+ if (is_shadow(t)) {
+ cpp_class_decl(name,Char(is_shadow(t)), (char*) "");
}
}
@@ -990,44 +1296,86 @@ void JAVA::cpp_open_class(char *classname, char *rename, char *ctype, int strip)
Printf(stderr, "Unable to create shadow class file: %s\n", bigbuf);
}
- emit_shadow_banner(f_shadow);
+ emit_banner(f_shadow);
if(*package)
- Printf(f_shadow, "package %s;\n\n", package);
- else Printf(f_shadow, "import %s;\n\n", module);
- if(jimport != NULL)
- Printf(f_shadow, "import %s;\n\n", jimport);
+ Printf(f_shadow, "package %s;\n\n", package);
+ else
+ Printf(f_shadow, "import %s;\n", module);
+ if(all_shadow_import)
+ Printf(f_shadow, "%s", all_shadow_import);
Clear(shadow_classdef);
- Printv(shadow_classdef, "public class ", shadow_classname, " %BASECLASS% ", "{\n", 0);
+ Printv(shadow_classdef, "$classmodifiers class ", shadow_classname, " $bases", "{\n", 0);
- shadow_baseclass = (char*) "";
shadow_classdef_emitted = 0;
have_default_constructor = 0;
+ shadow_enum_code = NewString("");
+ this_shadow_baseclass = NewString("");
+ this_shadow_extra_code = NewString("");
+ this_shadow_interfaces = NewString("");
+ this_shadow_import = NewString("");
+ this_shadow_class_modifiers = NewString("");
+
+ if(all_shadow_interfaces)
+ Printv(this_shadow_interfaces, all_shadow_interfaces, 0);
}
void JAVA::emit_shadow_classdef() {
- if(*shadow_baseclass) {
- sprintf(bigbuf, "extends %s", shadow_baseclass);
- Replace(shadow_classdef,"%BASECLASS%", bigbuf, DOH_REPLACE_ANY);
- Printv(shadow_classdef, " public ", shadow_classname, "(java.lang.Long obj) {\n", tab4, "_self = obj.longValue();\n }\n\n", 0);
- } else {
- Replace(shadow_classdef,"%BASECLASS%", "",DOH_REPLACE_ANY);
-
- Printv(shadow_classdef,
- " public long _self = 0;\n",
- " public boolean _selfown = false;\n\n",
- " public static Object newInstance(long p) {\n",
- " return new ", shadow_classname, "(new Long(p));\n",
- " };\n\n",
-
- " public ", shadow_classname, "(java.lang.Long obj) {\n", tab4, "_self = obj.longValue();\n }\n\n",
- 0);
+ String* temp_str = NewString("");
+ if(this_shadow_baseclass)
+ Printv(temp_str, this_shadow_baseclass, 0);
+ if(all_shadow_baseclass)
+ Printv(temp_str, all_shadow_baseclass, 0);
+ if(this_shadow_interfaces && *Char(this_shadow_interfaces))
+ Printv(temp_str, this_shadow_interfaces, " ", 0);
+ Replace(shadow_classdef,"$bases", temp_str, DOH_REPLACE_ANY);
+
+ //Display warning on attempt to use multiple inheritance
+ char* search_str = Char(temp_str);
+ int count = 0;
+ while(search_str = strstr(search_str, "extends")) {
+ search_str += strlen("extends");
+ count++;
}
- Printv(shadow_classdef, " public Class _selfClass() {\n", tab4, "return ", shadow_classname, ".class;\n", " };\n\n", 0);
+ if (count > 1)
+ Printf(stderr, "Warning for shadow class %s: Multiple inheritance is not supported in Java.\n", shadow_classname);
+
+ if (this_shadow_class_modifiers && *Char(this_shadow_class_modifiers))
+ Replace(shadow_classdef, "$classmodifiers", this_shadow_class_modifiers, DOH_REPLACE_ANY);
+ else if (all_shadow_class_modifiers && *Char(all_shadow_class_modifiers))
+ Replace(shadow_classdef, "$classmodifiers", all_shadow_class_modifiers, DOH_REPLACE_ANY);
+ else
+ Replace(shadow_classdef, "$classmodifiers", "public", DOH_REPLACE_ANY);
+
+ Printv(shadow_classdef,
+ " private long _cPtr = 0;\n",
+ " private boolean _cMemOwn = false;\n",
+ "\n",
+ " public $class(long cPointer, boolean cMemoryOwn) {\n",
+ " _cPtr = cPointer;\n",
+ " _cMemOwn = cMemoryOwn;\n",
+ " }\n",
+ "\n",
+ " public long getCPtr() {\n",
+ " return _cPtr;\n",
+ " };\n",
+ "\n", 0);
+ Replace(shadow_classdef, "$class", shadow_classname, DOH_REPLACE_ANY);
+
+ if (all_shadow_extra_code)
+ Printv(shadow_classdef, all_shadow_extra_code, 0);
+
+ if (this_shadow_extra_code)
+ Printv(shadow_classdef, this_shadow_extra_code, 0);
+
+ if(this_shadow_import)
+ Printf(f_shadow, "%s", this_shadow_import);
+ Printf(f_shadow, "\n");
Printv(f_shadow, shadow_classdef,0);
shadow_classdef_emitted = 1;
+ Delete(temp_str);
}
void JAVA::cpp_close_class() {
@@ -1036,270 +1384,305 @@ void JAVA::cpp_close_class() {
if(!shadow_classdef_emitted) emit_shadow_classdef();
+ // No default constructor implies class is abstract.
+ // Note that abstract in cplus.cxx has this information - it ought to be passed to each
+ // module when the class is opened.
if(have_default_constructor == 0) {
- Printf(f_shadow, " public %s() {}\n\n", shadow_classname);
+ Printf(f_shadow, " protected %s() {}\n\n", shadow_classname);
}
+ // Write the enum initialisation code in a static block.
+ // These are all the enums defined within the c++ class.
+ if (strlen(Char(shadow_enum_code)) != 0 )
+ Printv(f_shadow, " static {\n // Initialise java constants from c++ enums\n", shadow_enum_code, " }\n",0);
+
Printf(f_shadow, "}\n");
fclose(f_shadow);
f_shadow = NULL;
free(shadow_classname);
shadow_classname = NULL;
-}
-void JAVA::cpp_member_func(char *name, char *iname, DataType *t, ParmList *l) {
- char arg[256];
- DOHString *nativecall;
-
- nativecall = NewString("");
+ Delete(shadow_enum_code); shadow_enum_code = NULL;
+ Delete(this_shadow_baseclass); this_shadow_baseclass = NULL;
+ Delete(this_shadow_extra_code); this_shadow_extra_code = NULL;
+ Delete(this_shadow_interfaces); this_shadow_interfaces = NULL;
+ Delete(this_shadow_import); this_shadow_import = NULL;
+ Delete(this_shadow_class_modifiers); this_shadow_class_modifiers = NULL;
+}
+void JAVA::cpp_member_func(char *name, char *iname, SwigType *t, ParmList *l) {
this->Language::cpp_member_func(name,iname,t,l);
- if(!shadow) return;
- if(!shadow_classdef_emitted) emit_shadow_classdef();
-
- char *javarettype = JavaTypeFromTypemap((char*)"jtype", typemap_lang, t, iname);
- if(!javarettype) javarettype = SwigTcToJavaType(t, 1, 0);
- char *shadowrettype = JavaTypeFromTypemap((char*)"jstype", typemap_lang, t, iname);
- if(!shadowrettype && (DataType_Gettypecode(t) == T_USER) && DataType_is_pointer(t) <= 1) {
- shadowrettype = GetChar(shadow_classes,DataType_Getname(t));
+/*
+// TODO: modify output so that pure virtual functions are declared abstract and
+// have no body. Also make the class declaration abstract. Make other constructor protected.
+extern int IsVirtual;
+ printf("IsVirtual: %d [%s] %s\n", IsVirtual, name, shadow_classname);
+ if (IsVirtual == PURE_VIRTUAL) {
}
+*/
+ if (shadow && !is_multiple_definition()) {
+ char* realname = iname ? iname : name;
+ String* java_function_name = Swig_name_member(shadow_classname, realname);
- Printf(f_shadow, " public %s %s(", (shadowrettype) ? shadowrettype : javarettype, iname);
-
- if(DataType_type(t) != T_VOID) {
- Printf(nativecall,"return ");
- if(shadowrettype) {
- Printv(nativecall, "new ", shadowrettype, "(new Long(", 0);
- }
+ cpp_func(iname, t, l, java_function_name);
}
- Printv(nativecall, module, ".", Swig_name_member(shadow_classname,iname), "(_self", 0);
-
- int pcount = ParmList_len(l);
-
- Parm *p = l;
- for (int i = 0; i < pcount ; i++, p = Getnext(p)) {
- DataType *pt = Gettype(p);
- char *pn = Getname(p);
-
- // Produce string representation of source and target arguments
- if(pn && *(pn))
- strcpy(arg,pn);
- else {
- sprintf(arg,"arg%d",i);
- }
-
- if((DataType_Gettypecode(pt) == T_USER) && (DataType_is_pointer(pt) <= 1) && Getattr(shadow_classes,DataType_Getname(pt))) {
- Printv(nativecall, ", ", arg, "._self", 0);
- } else Printv(nativecall, ", ", arg, 0);
+}
- char *jtype = JavaTypeFromTypemap((char*)"jtype", typemap_lang, pt, pn);
- if(!jtype) jtype = SwigTcToJavaType(pt, 0, 0);
+void JAVA::cpp_static_func(char *name, char *iname, SwigType *t, ParmList *l) {
+ this->Language::cpp_static_func(name,iname,t,l);
- char *jstype = JavaTypeFromTypemap((char*)"jstype", typemap_lang, pt, pn);
- if(!jstype && (DataType_Gettypecode(pt) == T_USER) && (DataType_is_pointer(pt) <= 1)) {
- jstype = GetChar(shadow_classes,DataType_Getname(pt));
- }
+ if (shadow && !is_multiple_definition()) {
+ char* realname = iname ? iname : name;
+ String* java_function_name = Swig_name_member(shadow_classname, realname);
- // Add to java function header
- Printf(f_shadow, "%s %s", (jstype) ? jstype : jtype, arg);
- if(i != pcount-1) {
- Printf(f_shadow, ", ");
- }
+ static_flag = 1;
+ cpp_func(iname, t, l, java_function_name);
+ static_flag = 0;
}
-
- if((DataType_Gettypecode(t) != T_VOID) && shadowrettype)
- Printf(nativecall, "))");
-
- Printf(nativecall,");\n");
-
- Printf(f_shadow, ") {\n");
- Printf(f_shadow, "\t%s\n", nativecall);
- Printf(f_shadow, " }\n\n");
- Delete(nativecall);
-
}
-void JAVA::cpp_static_func(char *name, char *iname, DataType *t, ParmList *l) {
- char arg[256];
- DOHString *nativecall;
-
- this->Language::cpp_static_func(name,iname,t,l);
+/*
+Function called for creating a java class wrapper function around a c++ function in the
+java wrapper class. Used for both static and non static functions.
+C++ static functions map to java static functions.
+iname is the name of the java class wrapper function, which in turn will call
+java_function_name, the java function which wraps the c++ function.
+*/
+void JAVA::cpp_func(char *iname, SwigType *t, ParmList *l, String* java_function_name) {
+ char arg[256];
+ String *nativecall = NewString("");
+ String *shadowrettype = NewString("");
+ String *user_arrays = NewString("");
if(!shadow) return;
- nativecall = NewString("");
if(!shadow_classdef_emitted) emit_shadow_classdef();
- char *javarettype = JavaTypeFromTypemap((char*)"jtype", typemap_lang, t, iname);
- if(!javarettype) javarettype = SwigTcToJavaType(t, 1, 0);
- char *shadowrettype = JavaTypeFromTypemap((char*)"jstype", typemap_lang, t, iname);
- if(!shadowrettype && (DataType_Gettypecode(t) == T_USER) && (DataType_is_pointer(t) <= 1)) {
- shadowrettype = GetChar(shadow_classes,DataType_Getname(t));
- }
+ /* Get the java return type */
+ SwigToJavaType(t, iname, shadowrettype, shadow);
- Printf(f_shadow, " public static %s %s(", (shadowrettype) ? shadowrettype : javarettype, iname);
+ Printf(f_shadow, " public %s %s %s(", (static_flag ? "static":""), shadowrettype, iname);
- if(DataType_type(t) != T_VOID) {
- Printf(nativecall, "return ");
- if(shadowrettype) {
- Printv(nativecall, "new ", shadowrettype, "(new Long(", 0);
+ if(SwigType_type(t) == T_ARRAY && is_shadow(get_array_type(t))) {
+ Printf(nativecall, "long[] cArray = ");
+ }
+ else {
+ if(SwigType_type(t) != T_VOID) {
+ Printf(nativecall,"return ");
+ }
+ if(is_shadow(t)) {
+ Printv(nativecall, "new ", shadowrettype, "(", 0);
}
}
- Printv(nativecall, module, ".", Swig_name_member(shadow_classname,iname), "(", 0);
+ Printv(nativecall, module, ".", java_function_name, "(", 0);
+ if (!static_flag)
+ Printv(nativecall, "getCPtr()", 0);
+
+ int gencomma = !static_flag;
int pcount = ParmList_len(l);
- int gencomma = 0;
+ /* Output each parameter */
Parm *p = l;
- for (int i = 0; i < pcount ; i++, p = Getnext(p)) {
- DataType *pt = Gettype(p);
- char *pn = Getname(p);
-
- // Produce string representation of source and target arguments
- if(pn && *(pn))
- strcpy(arg,pn);
- else {
- sprintf(arg,"arg%d",i);
- }
-
- if(gencomma) Printf(nativecall,", ");
- if((DataType_Gettypecode(pt) == T_USER) && (DataType_is_pointer(pt) <= 1) && Getattr(shadow_classes,DataType_Getname(pt))) {
- Printv(nativecall, arg, "._self", 0);
- } else Printv(nativecall,arg,0);
+/* Workaround to overcome Getignore(p) not working - p does not always have the Getignore
+attribute set. Noticeable when cpp_func is called from cpp_member_func() */
+Wrapper* f = NewWrapper();
+emit_args(NULL, l, f);
+DelWrapper(f);
+/* Workaround end */
- gencomma = 1;
+ for (int i = 0; i < pcount ; i++, p = Getnext(p)) {
+ if(Getignore(p)) continue;
- char *jtype = JavaTypeFromTypemap((char*)"jtype", typemap_lang, pt, pn);
- if(!jtype) jtype = SwigTcToJavaType(pt, 0, 0);
+ /* Ignore the 'this' argument for variable wrappers */
+ if (!(variable_wrapper_flag && i==0))
+ {
+ SwigType *pt = Gettype(p);
+ String *pn = Getname(p);
+ String *javaparamtype = NewString("");
+
+ /* Produce string representation of source and target arguments */
+ if(pn && *(Char(pn)))
+ strcpy(arg,Char(pn));
+ else {
+ sprintf(arg,"arg%d",i);
+ }
+
+ if (gencomma)
+ Printf(nativecall, ", ");
+
+ if(SwigType_type(pt) == T_ARRAY && is_shadow(get_array_type(pt))) {
+ Printv(user_arrays, tab4, "long[] $arg_cArray = new long[$arg.length];\n", 0);
+ Printv(user_arrays, tab4, "for (int i=0; i<$arg.length; i++)\n", 0);
+ Printv(user_arrays, tab4, " $arg_cArray[i] = $arg[i].getCPtr();\n", 0);
+ Replace(user_arrays, "$arg", pn, DOH_REPLACE_ANY);
+
+ Printv(nativecall, arg, "_cArray", 0);
+ } else if (is_shadow(pt)) {
+ Printv(nativecall, arg, ".getCPtr()", 0);
+ } else Printv(nativecall, arg, 0);
+
+ /* Get the java type of the parameter */
+ SwigToJavaType(pt, pn, javaparamtype, shadow);
+
+ /* Add to java shadow function header */
+ if (gencomma >= 2)
+ Printf(f_shadow, ", ");
+ gencomma = 2;
+ Printf(f_shadow, "%s %s", javaparamtype, arg);
- char *jstype = JavaTypeFromTypemap((char*)"jstype", typemap_lang, pt, pn);
- if(!jstype && (DataType_Gettypecode(pt) == T_USER) && (DataType_is_pointer(pt) <= 1)) {
- jstype = GetChar(shadow_classes, DataType_Getname(pt));
+ Delete(javaparamtype);
}
+ }
- // Add to java function header
- Printf(f_shadow, "%s %s", (jstype) ? jstype : jtype, arg);
- if(i != pcount-1) {
- Printf(f_shadow, ", ");
+ if(SwigType_type(t) == T_ARRAY && is_shadow(get_array_type(t))) {
+ String* array_ret = NewString("");
+ String* user_return_type = NewString("");
+ SwigType *array_type = get_array_type(t);
+ Printf(array_ret,");\n");
+ Printv(array_ret, tab4, "$type[] arrayWrapper = new $type[cArray.length];\n", 0);
+ Printv(array_ret, tab4, "for (int i=0; i<cArray.length; i++)\n", 0);
+ Printv(array_ret, tab4, " arrayWrapper[i] = new $type(cArray[i], false);\n", 0);
+ Printv(array_ret, tab4, "return arrayWrapper;\n", 0);
+
+ SwigToJavaType(array_type, iname, user_return_type, shadow);
+ Replace(array_ret, "$type", user_return_type, DOH_REPLACE_ANY);
+ Printv(nativecall, array_ret, 0);
+ Delete(array_ret);
+ Delete(user_return_type);
+ }
+ else {
+ if(is_shadow(t)) {
+ switch(SwigType_type(t)) {
+ case T_USER:
+ Printf(nativecall, "), true");
+ break;
+ case T_REFERENCE:
+ case T_POINTER:
+ Printf(nativecall, "), false");
+ break;
+ default:
+ Printf(stderr, "Internal Error: unknown shadow type: %s\n", SwigType_str(t,0));
+ break;
+ }
}
+ Printf(nativecall,");\n");
}
-
- if((DataType_type(t) != T_VOID) && shadowrettype)
- Printf(nativecall,"))");
-
- Printf(nativecall,");\n");
-
Printf(f_shadow, ") {\n");
- Printf(f_shadow, "\t%s\n", nativecall);
+ Printv(f_shadow, user_arrays, 0);
+ Printf(f_shadow, "\t%s", nativecall);
Printf(f_shadow, " }\n\n");
+ Delete(shadowrettype);
Delete(nativecall);
+ Delete(user_arrays);
}
void JAVA::cpp_constructor(char *name, char *iname, ParmList *l) {
this->Language::cpp_constructor(name,iname,l);
- if(!shadow) return;
- if(!shadow_classdef_emitted) emit_shadow_classdef();
-
- DOHString *nativecall = NewString("");
- char arg[256];
-
- Printf(f_shadow, " public %s(", shadow_classname);
-
- Printv(nativecall, " if(_self == 0 && ", shadow_classname, ".class == _selfClass()) {\n", 0);
- if (iname != NULL)
- Printv(nativecall, tab8, " _self = ", module, ".", Swig_name_construct(iname), "(", 0);
- else
- Printv(nativecall, tab8, " _self = ", module, ".", Swig_name_construct(shadow_classname), "(", 0);
-
- int pcount = ParmList_len(l);
- if(pcount == 0) // We must have a default constructor
- have_default_constructor = 1;
-
- Parm *p = l;
- for (int i = 0; i < pcount ; i++, p = Getnext(p)) {
- DataType *pt = Gettype(p);
- char *pn = Getname(p);
-
- // Produce string representation of source and target arguments
- if(pn && *(pn))
- strcpy(arg,pn);
- else {
- sprintf(arg,"arg%d",i);
- }
-
- char *jtype = JavaTypeFromTypemap((char*)"jtype", typemap_lang, pt, pn);
- if(!jtype) jtype = SwigTcToJavaType(pt, 0, 0);
-
- char *jstype = JavaTypeFromTypemap((char*)"jstype", typemap_lang, pt, pn);
- if(!jstype && (DataType_Gettypecode(pt) == T_USER) && (DataType_is_pointer(pt) <= 1)) {
- jstype = GetChar(shadow_classes, DataType_Getname(pt));
- }
-
- // Add to java function header
- Printf(f_shadow, "%s %s", (jstype) ? jstype : jtype, arg);
-
- if((DataType_Gettypecode(pt) == T_USER) && (DataType_is_pointer(pt) <= 1) && Getattr(shadow_classes,DataType_Getname(pt))) {
- Printv(nativecall,arg, "._self", 0);
- } else Printv(nativecall, arg, 0);
-
- if(i != pcount-1) {
- Printf(nativecall, ", ");
- Printf(f_shadow, ", ");
+ if(shadow && !is_multiple_definition()) {
+ if(!shadow_classdef_emitted) emit_shadow_classdef();
+
+ String *nativecall = NewString("");
+ char arg[256];
+
+ Printf(f_shadow, " public %s(", shadow_classname);
+
+ Printv(nativecall, " if(getCPtr() == 0) {\n", 0);
+ if (iname != NULL)
+ Printv(nativecall, tab8, " _cPtr = ", module, ".", Swig_name_construct(iname), "(", 0);
+ else
+ Printv(nativecall, tab8, " _cPtr = ", module, ".", Swig_name_construct(shadow_classname), "(", 0);
+
+ int pcount = ParmList_len(l);
+ if(pcount == 0) // We must have a default constructor
+ have_default_constructor = 1;
+
+ /* Output each parameter */
+ Parm *p = l;
+ for (int i = 0; i < pcount ; i++, p = Getnext(p)) {
+ SwigType *pt = Gettype(p);
+ String *pn = Getname(p);
+ String *javaparamtype = NewString("");
+
+ /* Produce string representation of source and target arguments */
+ if(pn && *(Char(pn)))
+ strcpy(arg,Char(pn));
+ else {
+ sprintf(arg,"arg%d",i);
+ }
+
+ if(is_shadow(pt)) {
+ Printv(nativecall, arg, ".getCPtr()", 0);
+ } else Printv(nativecall, arg, 0);
+
+ /* Get the java type of the parameter */
+ SwigToJavaType(pt, pn, javaparamtype, shadow);
+
+ /* Add to java shadow function header */
+ Printf(f_shadow, "%s %s", javaparamtype, arg);
+
+ if(i != pcount-1) {
+ Printf(nativecall, ", ");
+ Printf(f_shadow, ", ");
+ }
+ Delete(javaparamtype);
}
+
+
+ Printf(f_shadow, ") {\n");
+ Printv(nativecall,
+ ");\n",
+ tab8, " _cMemOwn = true;\n",
+ " }\n",
+ 0);
+
+ Printf(f_shadow, "%s", nativecall);
+ Printf(f_shadow, " }\n\n");
+ Delete(nativecall);
}
-
-
- Printf(f_shadow, ") {\n");
- Printv(nativecall,
- ");\n",
- tab8, " _selfown = true;\n",
- " }\n",
- 0);
-
- Printf(f_shadow, "%s", nativecall);
- Printf(f_shadow, " }\n\n");
- Delete(nativecall);
}
void JAVA::cpp_destructor(char *name, char *newname) {
this->Language::cpp_destructor(name,newname);
- if(!shadow) return;
- if(!shadow_classdef_emitted) emit_shadow_classdef();
-
- char *realname = (newname) ? newname : name;
-
- if(finalize) {
- Printf(f_shadow, " protected void finalize() {\n");
- Printf(f_shadow, " if(_selfown) {\n");
- Printf(f_shadow, " _delete();\n");
+ if(shadow && !is_multiple_definition()) {
+ if(!shadow_classdef_emitted) emit_shadow_classdef();
+
+ char *realname = (newname) ? newname : name;
+
+ if(!nofinalize) {
+ Printf(f_shadow, " protected void finalize() {\n");
+ Printf(f_shadow, " _delete();\n");
+ Printf(f_shadow, " };\n\n");
+ }
+
+ Printf(f_shadow, " public void _delete() {\n");
+ Printf(f_shadow, " if(getCPtr() != 0 && _cMemOwn) {\n");
+ Printf(f_shadow, "\t%s.%s(_cPtr);\n", module, Swig_name_destroy(shadow_classname));
+ Printf(f_shadow, "\t_cPtr = 0;\n");
Printf(f_shadow, " }\n");
- Printf(f_shadow, " };\n\n");
+ Printf(f_shadow, " }\n\n");
}
-
- Printf(f_shadow, " public void _delete() {\n");
- Printf(f_shadow, " if(_self != 0 && %s.class == _selfClass()) {\n", shadow_classname);
- Printf(f_shadow, "\t%s.%s(_self);\n", module, Swig_name_destroy(realname));
- Printf(f_shadow, "\t_self = 0;\n");
- Printf(f_shadow, " }\n");
- Printf(f_shadow, " }\n\n");
}
void JAVA::cpp_class_decl(char *name, char *rename, char *type) {
- this->Language::cpp_class_decl(name,rename, type);
-
- if(!shadow) return;
-
- char *realname = (rename) ? rename : name;
-
- Setattr(shadow_classes,name, realname);
- if(type && strcmp(type, "struct") == 0) {
- sprintf(bigbuf, "struct %s", name);
- Setattr(shadow_classes, bigbuf, rename);
+ String *stype;
+/* Register the class as one for which there will be a java shadow class */
+ if (shadow) {
+ stype = NewString(name);
+ SwigType_add_pointer(stype);
+ Setattr(shadow_classes,stype,rename);
+ Delete(stype);
+ if (strlen(type) > 0) {
+ stype = NewStringf("%s %s",type,name);
+ SwigType_add_pointer(stype);
+ Setattr(shadow_classes,stype,rename);
+ Delete(stype);
+ }
}
}
@@ -1308,39 +1691,55 @@ void JAVA::cpp_inherit(char **baseclass, int) {
if(!shadow) return;
- int cnt = 0;
- char **bc = baseclass;
- while(*bc++) cnt++;
+ int i = 0;
+ while(baseclass[i]) i++;
- if(cnt > 1)
+ if(i > 1)
Printf(stderr, "Warning: %s inherits from multiple base classes. Multiple inheritance is not supported.\n", shadow_classname);
- shadow_baseclass = Swig_copy_string(*baseclass);
+ i=0;
+ char *bc;
+ if (baseclass[i]) {
+ /* See if this is a class we know about */
+ String *b = NewString(baseclass[i]);
+ bc = Char(is_shadow(b));
+ if (bc && this_shadow_baseclass)
+ Printf(this_shadow_baseclass, "extends %s ", bc);
+ Delete(b);
+ }
}
-void JAVA::cpp_variable(char *name, char *iname, DataType *t) {
- if(shadow && !shadow_classdef_emitted) emit_shadow_classdef();
+void JAVA::cpp_variable(char *name, char *iname, SwigType *t) {
+ shadow_variable_name = Swig_copy_string((iname) ? iname : name);
- if(shadow) member_func = 1;
- shadow_name = Swig_copy_string((iname) ? iname : name);
+ wrapping_member = 1;
+ variable_wrapper_flag = 1;
this->Language::cpp_variable(name, iname, t);
- member_func = 0;
+ wrapping_member = 0;
+ variable_wrapper_flag = 0;
}
-void JAVA::cpp_static_var(char *name, char *iname, DataType *t) {
- if(shadow) member_func = 1;
- shadow_name = Swig_copy_string((iname) ? iname : name);
+void JAVA::cpp_static_var(char *name, char *iname, SwigType *t) {
+ shadow_variable_name = Swig_copy_string((iname) ? iname : name);
+
+/*
+ wrapping_member = 1;
+ static_flag = 1;
+ variable_wrapper_flag = 1;
this->Language::cpp_static_var(name, iname, t);
- member_func = 0;
+ wrapping_member = 0;
+ static_flag = 0;
+ variable_wrapper_flag = 0;
+*/
+ Printf(stderr, "Ignoring %s::%s. Static member variables are broken in SWIG!\n", shadow_classname, shadow_variable_name);
}
-void JAVA::cpp_declare_const(char *name, char *iname, DataType *type, char *value) {
- if(shadow && !shadow_classdef_emitted) emit_shadow_classdef();
+void JAVA::cpp_declare_const(char *name, char *iname, SwigType *type, char *value) {
+ shadow_variable_name = Swig_copy_string((iname) ? iname : name);
- if(shadow) member_func = 1;
- shadow_name = Swig_copy_string((iname) ? iname : name);
+ wrapping_member = 1;
this->Language::cpp_declare_const(name, iname, type, value);
- member_func = 0;
+ wrapping_member = 0;
}
diff --git a/SWIG/Source/Modules1.1/java.h b/SWIG/Source/Modules1.1/java.h
index 6c86b452e..d5b1edb10 100644
--- a/SWIG/Source/Modules1.1/java.h
+++ b/SWIG/Source/Modules1.1/java.h
@@ -18,11 +18,12 @@ public :
void initialize(void);
void headers(void);
void close(void);
- void set_module(char *,char **);
+ void set_module(char *);
void create_command(char *, char *);
void pragma(char *lang, char *code, char *value);
void add_typedef(SwigType *t, char *name);
+ void cpp_pragma(Pragma *plist);
void cpp_open_class(char *classname, char *rename, char *ctype, int strip);
void cpp_close_class();
void cpp_member_func(char *name, char *iname, SwigType *t, ParmList *l);
@@ -39,11 +40,12 @@ public :
void emit_classdef();
void emit_shadow_classdef();
char *JNICALL(DOHString_or_char *func);
- char *SwigTcToJniType(SwigType *t, int ret);
- char *SwigTcToJavaType(SwigType *t, int ret, int inShadow);
- char *SwigTcToJniScalarType(SwigType *t);
- char *JavaTypeFromTypemap(char *op, char *lang, SwigType *t, char *pname);
+ void SwigToJNIType(SwigType *t, String_or_char *pname, String* jni_type);
+ void SwigToJavaType(SwigType *t, String_or_char *pname, String* java_type, int shadow_flag);
+ char *SwigToJavaArrayType(SwigType *t);
+ char *JavaTypeFromTypemap(char *op, SwigType *t, String_or_char *pname);
char *makeValidJniName(char *name);
char *JavaMethodSignature(SwigType *t, int ret, int inShadow);
void writeRegisterNatives();
+ void cpp_func(char *iname, SwigType *t, ParmList *l, String* java_function_name);
};
diff --git a/SWIG/Source/Modules1.1/mzscheme.cxx b/SWIG/Source/Modules1.1/mzscheme.cxx
index 7414ba859..eb3cc258f 100644
--- a/SWIG/Source/Modules1.1/mzscheme.cxx
+++ b/SWIG/Source/Modules1.1/mzscheme.cxx
@@ -101,6 +101,9 @@ MZSCHEME::parse_args (int argc, char *argv[])
// Set name of typemaps
typemap_lang = (char*)"mzscheme";
+
+ // Read in default typemaps */
+ SWIG_config_file("mzscheme.i");
}
// --------------------------------------------------------------------
@@ -113,9 +116,6 @@ void
MZSCHEME::parse ()
{
init_func_def = NewString("");
- printf ("Generating wrappers for Mzscheme\n");
-
- init_func_def = NewString("");
// Print out MZSCHEME specific headers
@@ -172,21 +172,11 @@ MZSCHEME::set_init (char *iname)
void
MZSCHEME::headers (void)
{
- Swig_banner (f_header);
-
- Printf (f_header, "/* Implementation : MZSCHEME */\n\n");
- Printf (f_header, "#include <stdio.h>\n");
- Printf (f_header, "#include <string.h>\n");
- Printf (f_header, "#include <stdlib.h>\n");
+ Printf(f_runtime, "/* -*- buffer-read-only: t -*- vi: set ro: */\n");
+ Swig_banner (f_runtime);
- // insert mzscheme.swg
-
- if (!NoInclude) {
- if (Swig_insert_file ("mzscheme.swg", f_header) == -1) {
- Printf (stderr, "SWIG : Fatal error. ");
- Printf (stderr, "Unable to locate 'mzscheme.swg' in SWIG library.\n");
- SWIG_exit (1);
- }
+ if (NoInclude) {
+ Printf(f_runtime, "#define SWIG_NOINCLUDE\n");
}
}
@@ -257,13 +247,34 @@ mreplace (String *s, String *argnum, String *arg, String *proc_name)
static void
throw_unhandled_mzscheme_type_error (SwigType *d)
{
- fflush (stdout);
- fprintf (stderr, "ERROR: Unhandled MZSCHEME type error.\n");
- fprintf (stderr, "str: %s\n", Char(SwigType_str(d,0)));
- fprintf (stderr, "lstr: %s\n", Char(SwigType_lstr(d,0)));
- fprintf (stderr, "manglestr: %s\n", Char(SwigType_manglestr(d)));
- Printf (stderr, "\n\nBAILING...\n"); // for now -ttn
- abort(); // for now -ttn
+ Printf (stderr, "%s : Line %d. Unable to handle type %s.\n", input_file, line_number, SwigType_str(d,0));
+ error_count++;
+}
+
+/* Return true iff T is a pointer type */
+
+static int
+is_a_pointer (SwigType *t)
+{
+ return SwigType_ispointer(SwigType_typedef_resolve_all(t));
+}
+
+/* Same as Swig_typemap_lookup but fall back to `int' when `enum' is
+ requested -- enum handling is somewhat broken in the 1.1 parser.
+ But we don't want to change it now since it is deprecated. */
+
+static char *
+mzscheme_typemap_lookup(const char *op, SwigType *type, const String_or_char *pname, String_or_char *source,
+ String_or_char *target, Wrapper *f)
+{
+ char *tm;
+ tm = Swig_typemap_lookup((char*) op, type, (char*)pname, source, target, f);
+ if (!tm) {
+ SwigType *base = SwigType_typedef_resolve_all(type);
+ if (strncmp(Char(base), "enum ", 5)==0)
+ tm = Swig_typemap_lookup((char*) op, (char*) "int", (char*)pname, source, target, f);
+ }
+ return tm;
}
void
@@ -281,9 +292,6 @@ MZSCHEME::create_function (char *name, char *iname, SwigType *d, ParmList *l)
String *build = NewString("");
SwigType *t;
char *tm;
- int need_len = 0;
- int need_tempc = 0;
- int have_build = 0;
int argout_set = 0;
int i = 0;
@@ -304,9 +312,8 @@ MZSCHEME::create_function (char *name, char *iname, SwigType *d, ParmList *l)
// they are called arg0, arg1, ...
// the return value is called result
- int pcount = emit_args(d, l, f);
+ /* pcount = */ emit_args(d, l, f);
int numargs = 0;
- int numopt = 0;
// adds local variables
Wrapper_add_local(f, "_tempc", "char *_tempc");
@@ -332,7 +339,7 @@ MZSCHEME::create_function (char *name, char *iname, SwigType *d, ParmList *l)
Printv(f->code, "/* ", Char(Getname(p)), " ignored... */\n", 0);
else {
++numargs;
- if ((tm = Swig_typemap_lookup ((char*)"in",
+ if ((tm = mzscheme_typemap_lookup ("in",
Gettype(p), Getname(p), source, target, f))) {
Printv(f->code, tm, "\n", 0);
mreplace (f->code, argnum, arg, proc_name);
@@ -343,7 +350,7 @@ MZSCHEME::create_function (char *name, char *iname, SwigType *d, ParmList *l)
t = SwigType_typedef_resolve(Gettype(p));
// if a pointer then get it
- if (SwigType_ispointer(t)) {
+ if (is_a_pointer(t)) {
get_pointer (proc_name, i, t, f);
}
// not a pointer
@@ -353,7 +360,7 @@ MZSCHEME::create_function (char *name, char *iname, SwigType *d, ParmList *l)
// Check if there are any constraints.
- if ((tm = Swig_typemap_lookup ((char*)"check",
+ if ((tm = mzscheme_typemap_lookup ("check",
Gettype(p), Getname(p), source, target, f))) {
// Yep. Use it instead of the default
Printv(f->code, tm, "\n", 0);
@@ -362,7 +369,7 @@ MZSCHEME::create_function (char *name, char *iname, SwigType *d, ParmList *l)
// Pass output arguments back to the caller.
- if ((tm = Swig_typemap_lookup ((char*)"argout",
+ if ((tm = mzscheme_typemap_lookup ("argout",
Gettype(p), Getname(p), source, target, f))) {
// Yep. Use it instead of the default
Printv(outarg, tm, "\n",0);
@@ -371,7 +378,7 @@ MZSCHEME::create_function (char *name, char *iname, SwigType *d, ParmList *l)
}
// Free up any memory allocated for the arguments.
- if ((tm = Swig_typemap_lookup ((char*)"freearg",
+ if ((tm = mzscheme_typemap_lookup ("freearg",
Gettype(p), Getname(p), source, target, f))) {
// Yep. Use it instead of the default
Printv(cleanup, tm, "\n",0);
@@ -391,14 +398,14 @@ MZSCHEME::create_function (char *name, char *iname, SwigType *d, ParmList *l)
Printv(f->code, tab4, "swig_result = scheme_void;\n",0);
}
- else if ((tm = Swig_typemap_lookup ((char*)"out",
+ else if ((tm = mzscheme_typemap_lookup ("out",
d, name, (char*)"result", (char*)"swig_result", f))) {
Printv(f->code, tm, "\n",0);
mreplace (f->code, argnum, arg, proc_name);
}
// no typemap found and not void then create a Scheme_Object holding
// the C pointer and return it
- else if (SwigType_ispointer(d)) {
+ else if (is_a_pointer(d)) {
Printv(f->code, tab4,
"swig_result = swig_make_c_pointer(",
"result, \"",
@@ -418,7 +425,7 @@ MZSCHEME::create_function (char *name, char *iname, SwigType *d, ParmList *l)
// Look for any remaining cleanup
if (NewObject) {
- if ((tm = Swig_typemap_lookup ((char*)"newfree",
+ if ((tm = mzscheme_typemap_lookup ("newfree",
d, iname, (char*)"result", (char*)"", f))) {
Printv(f->code, tm, "\n",0);
mreplace (f->code, argnum, arg, proc_name);
@@ -427,7 +434,7 @@ MZSCHEME::create_function (char *name, char *iname, SwigType *d, ParmList *l)
// Free any memory allocated by the function being wrapped..
- if ((tm = Swig_typemap_lookup ((char*)"ret",
+ if ((tm = mzscheme_typemap_lookup ("ret",
d, name, (char*)"result", (char*)"", f))) {
// Yep. Use it instead of the default
Printv(f->code, tm, "\n",0);
@@ -504,11 +511,11 @@ MZSCHEME::link_variable (char *name, char *iname, SwigType *t)
Printv(proc_name, iname,0);
Replace(proc_name, "_", "-", DOH_REPLACE_ANY);
- if ((SwigType_type(t) != T_USER) || (SwigType_ispointer(t))) {
+ if ((SwigType_type(t) != T_USER) || (is_a_pointer(t))) {
Printf (f_wrappers, "static Scheme_Object *%s(int argc, Scheme_Object** argv) {\n", var_name);
- if ((SwigType_type(t) == T_CHAR) || (SwigType_ispointer(t))){
+ if ((SwigType_type(t) == T_CHAR) || (is_a_pointer(t))){
Printf (f_wrappers, "\t char *_temp, _ptemp[128];\n");
Printf (f_wrappers, "\t int _len;\n");
}
@@ -528,14 +535,14 @@ MZSCHEME::link_variable (char *name, char *iname, SwigType *t)
Printf (f_wrappers, "\t\t scheme_signal_error(\"Unable to set %s. "
"Variable is read only.\");\n", iname);
}
- else if ((tm = Swig_typemap_lookup ((char*)"varin",
+ else if ((tm = mzscheme_typemap_lookup ("varin",
t, name, (char*)"argv[0]", name,0))) {
Printv(tm2, tm,0);
mreplace(tm2, argnum, arg, proc_name);
Printv(f_wrappers, tm2, "\n",0);
}
- else if (SwigType_ispointer(t)) {
- if ((SwigType_type(t) == T_CHAR) && (SwigType_ispointer(t) == 1)) {
+ else if (is_a_pointer(t)) {
+ if ((SwigType_type(t) == T_CHAR) && (is_a_pointer(t) == 1)) {
Printf (f_wrappers, "\t\t _temp = SCHEME_STR_VAL(argv[0]);\n");
Printf (f_wrappers, "\t\t _len = SCHEME_STRLEN_VAL(argv[0]);\n");
Printf (f_wrappers, "\t\t if (%s) { free(%s);}\n", name, name);
@@ -544,9 +551,9 @@ MZSCHEME::link_variable (char *name, char *iname, SwigType *t)
Printf (f_wrappers, "\t\t strncpy(%s,_temp,_len);\n", name);
} else {
// Set the value of a pointer
- Printf(f_wrappers, "\t\tif (!swig_get_c_pointer(argv[0], \"%s\", (void **) &arg0))\n",
- SwigType_manglestr(t));
- Printf(f_wrappers, "\t\t\tscheme_wrong_type(\"%s\", %s, 0, argc, argv", \
+ Printf(f_wrappers, "\t\tif (!swig_get_c_pointer(argv[0], \"%s\", (void **) &%s))\n",
+ SwigType_manglestr(t), name);
+ Printf(f_wrappers, "\t\t\tscheme_wrong_type(\"%s\", \"%s\", 0, argc, argv);", \
var_name, SwigType_manglestr(t));
}
}
@@ -558,12 +565,12 @@ MZSCHEME::link_variable (char *name, char *iname, SwigType *t)
// Now return the value of the variable (regardless
// of evaluating or setting)
- if ((tm = Swig_typemap_lookup ((char*)"varout",
+ if ((tm = mzscheme_typemap_lookup ("varout",
t, name, name, (char*)"swig_result",0))) {
Printf (f_wrappers, "%s\n", tm);
}
- else if (SwigType_ispointer(t)) {
- if ((SwigType_type(t) == T_CHAR) && (SwigType_ispointer(t) == 1)) {
+ else if (is_a_pointer(t)) {
+ if ((SwigType_type(t) == T_CHAR) && (is_a_pointer(t) == 1)) {
Printf (f_wrappers, "\t swig_result = scheme_make_string(%s);\n", name);
} else {
// Is an ordinary pointer type.
@@ -630,7 +637,7 @@ MZSCHEME::declare_const (char *name, char *, SwigType *type, char *value)
Printv(proc_name, name,0);
Replace(proc_name, "_", "-", DOH_REPLACE_ANY);
- if ((SwigType_type(type) == T_USER) && (!SwigType_ispointer(type))) {
+ if ((SwigType_type(type) == T_USER) && (!is_a_pointer(type))) {
fprintf (stderr, "%s : Line %d. Unsupported constant value.\n",
input_file, line_number);
return;
@@ -639,18 +646,18 @@ MZSCHEME::declare_const (char *name, char *, SwigType *type, char *value)
// See if there's a typemap
Printv(rvalue, value,0);
- if ((SwigType_type(type) == T_CHAR) && (SwigType_ispointer(type) == 1)) {
+ if ((SwigType_type(type) == T_CHAR) && (is_a_pointer(type) == 1)) {
temp = Copy(rvalue);
Clear(rvalue);
Printv(rvalue, "\"", temp, "\"",0);
}
- if ((SwigType_type(type) == T_CHAR) && (SwigType_ispointer(type) == 0)) {
+ if ((SwigType_type(type) == T_CHAR) && (is_a_pointer(type) == 0)) {
Delete(temp);
temp = Copy(rvalue);
Clear(rvalue);
Printv(rvalue, "'", temp, "'",0);
}
- if ((tm = Swig_typemap_lookup ((char*)"const", type, name,
+ if ((tm = mzscheme_typemap_lookup ("const", type, name,
rvalue, name,0))) {
// Yep. Use it instead of the default
Printf (f_init, "%s\n", tm);
@@ -658,8 +665,10 @@ MZSCHEME::declare_const (char *name, char *, SwigType *type, char *value)
// Create variable and assign it a value
Printf (f_header, "static %s %s = ", SwigType_str(type,0), var_name);
- if ((SwigType_type(type) == T_CHAR) && (SwigType_ispointer(type) <= 1)) {
+ if ((SwigType_type(type) == T_STRING)) {
Printf (f_header, "\"%s\";\n", value);
+ } else if (SwigType_type(type) == T_CHAR) {
+ Printf (f_header, "\'%s\';\n", value);
} else {
Printf (f_header, "%s;\n", value);
}
@@ -721,8 +730,8 @@ MZSCHEME::usage_func (char *iname, SwigType *d, ParmList *l, DOHString *usage)
// Print the type.
Printv(usage," <", Getname(pt), 0);
- if (SwigType_ispointer(pt)) {
- for (int j = 0; j < SwigType_ispointer(pt); j++) {
+ if (is_a_pointer(pt)) {
+ for (int j = 0; j < is_a_pointer(pt); j++) {
Putc('*', usage);
}
}
@@ -773,8 +782,8 @@ MZSCHEME::usage_returns (char *iname, SwigType *d, ParmList *l, DOHString *usage
// Print the type.
Printv(param," $", Getname(pt), 0);
- if (SwigType_ispointer(pt)) {
- for (j = 0; j < SwigType_ispointer(pt) - 1; j++) {
+ if (is_a_pointer(pt)) {
+ for (j = 0; j < is_a_pointer(pt) - 1; j++) {
Putc('*',param);
}
}
diff --git a/SWIG/Source/Modules1.1/perl5.cxx b/SWIG/Source/Modules1.1/perl5.cxx
index c17173de4..8bceb61db 100644
--- a/SWIG/Source/Modules1.1/perl5.cxx
+++ b/SWIG/Source/Modules1.1/perl5.cxx
@@ -19,9 +19,11 @@ static char cvsroot[] = "$Header$";
#include "mod11.h"
#include "perl5.h"
+#include "swigconfig.h"
static char *usage = (char*)"\
Perl5 Options (available with -perl5)\n\
+ -ldflags - Print runtime libraries to link with\n\
-module name - Set module name\n\
-interface name - Set interface name\n\
-package name - Set package prefix\n\
@@ -49,7 +51,6 @@ static int is_static = 0;
static int blessed = 0; /* Enable object oriented features */
static Hash *classes = 0; /* A hash table for storing the classes we've seen so far */
-static Hash *symbols = 0;
static int have_constructor = 0;
static int have_destructor= 0;
static int have_data_members = 0;
@@ -134,6 +135,9 @@ PERL5::parse_args(int argc, char *argv[]) {
Swig_mark_arg(i);
} else if (strcmp(argv[i],"-help") == 0) {
fputs(usage,stderr);
+ } else if (strcmp (argv[i], "-ldflags") == 0) {
+ printf("%s\n", SWIG_PERL_RUNTIME);
+ SWIG_exit (EXIT_SUCCESS);
}
}
}
@@ -150,7 +154,6 @@ void
PERL5::parse() {
classes = NewHash();
- symbols = NewHash();
vinit = NewString("");
pm = NewString("");
@@ -282,12 +285,12 @@ PERL5::initialize()
Printf(f_init,"XS(SWIG_init) {\n");
Printf(f_init,"\t dXSARGS;\n");
Printf(f_init,"\t int i;\n");
- Printf(f_init,"\t char *file = __FILE__;\n");
+ Printf(f_init,"\t char *file = (char *) __FILE__;\n");
Printv(f_init,
"for (i = 0; swig_types_initial[i]; i++) {\n",
"swig_types[i] = SWIG_TypeRegister(swig_types_initial[i]);\n",
"}\n", 0);
- Printf(f_init,"\t newXS(\"%s::var_%s_init\", _wrap_perl5_%s_var_init, file);\n",package,cmodule, cmodule);
+ Printf(f_init,"\t newXS((char *) \"%s::var_%s_init\", _wrap_perl5_%s_var_init, file);\n",package,cmodule, cmodule);
Printv(vinit,
"XS(_wrap_perl5_", cmodule, "_var_init) {\n",
@@ -488,7 +491,7 @@ get_pointer(char *iname, char *srcname, char *src, char *dest,
* ----------------------------------------------------------------------------- */
void
PERL5::create_command(char *cname, char *iname) {
- Printf(f_init,"\t newXS(\"%s::%s\", %s, file);\n", package, iname, Swig_name_wrapper(cname));
+ Printf(f_init,"\t newXS((char *) \"%s::%s\", %s, file);\n", package, iname, Swig_name_wrapper(cname));
if (export_all) {
Printf(exported,"%s ",iname);
}
@@ -727,7 +730,7 @@ PERL5::create_function(char *name, char *iname, SwigType *d, ParmList *l)
/* Now register the function */
- Printf(f_init,"\t newXS(\"%s::%s\", %s, file);\n", package, iname, Swig_name_wrapper(iname));
+ Printf(f_init,"\t newXS((char *) \"%s::%s\", %s, file);\n", package, iname, Swig_name_wrapper(iname));
if (export_all) {
Printf(exported,"%s ", iname);
@@ -1259,7 +1262,7 @@ PERL5::usage_func(char *iname, SwigType *, ParmList *l) {
* ----------------------------------------------------------------------------- */
void
PERL5::add_native(char *name, char *funcname, SwigType *, ParmList *) {
- Printf(f_init,"\t newXS(\"%s::%s\", %s, file);\n", package,name, funcname);
+ Printf(f_init,"\t newXS((char *) \"%s::%s\", %s, file);\n", package,name, funcname);
if (export_all)
Printf(exported,"%s ",name);
if (blessed) {
@@ -1489,110 +1492,105 @@ PERL5::cpp_member_func(char *name, char *iname, SwigType *t, ParmList *l) {
this->Language::cpp_member_func(name,iname,t,l);
member_func = 0;
- if (!blessed) return;
-
- func = NewString("");
- cname = NewString("perl5:");
-
- /* Now emit a Perl wrapper function around our member function, we might need
- to patch up some arguments along the way */
-
- if (!iname)
- realname = name;
- else
- realname = iname;
-
- Printf(cname,"%s::%s",class_name,realname);
- if (Getattr(symbols,cname)) {
- return; /* Forget it, we saw this already */
- }
- Setattr(symbols,cname,cname);
-
- Printv(func,
- "sub ", realname, " {\n",
- tab4, "my @args = @_;\n",
- 0);
-
- /* Now we have to go through and patch up the argument list. If any
- arguments to our function correspond to other Perl objects, we
- need to extract them from a tied-hash table object. */
-
- p = l;
- pcount = ParmList_len(l);
- numopt = check_numopt(l);
- i = 1;
- while(p) {
- SwigType *pt = Gettype(p);
- if (!Getignore(p)) {
- char sourceNtarget[512];
- sprintf(sourceNtarget, "$args[%d]", i);
-
- if ((tm = Swig_typemap_lookup((char*)"perl5in",pt,(char*)"",sourceNtarget,sourceNtarget,0))) {
- Printf(func,"%s\n",tm);
- need_wrapper = 1;
+ if (blessed && !is_multiple_definition()) {
+ func = NewString("");
+ cname = NewString("perl5:");
+
+ /* Now emit a Perl wrapper function around our member function, we might need
+ to patch up some arguments along the way */
+
+ if (!iname)
+ realname = name;
+ else
+ realname = iname;
+
+ Printf(cname,"%s::%s",class_name,realname);
+ Printv(func,
+ "sub ", realname, " {\n",
+ tab4, "my @args = @_;\n",
+ 0);
+
+ /* Now we have to go through and patch up the argument list. If any
+ arguments to our function correspond to other Perl objects, we
+ need to extract them from a tied-hash table object. */
+
+ p = l;
+ pcount = ParmList_len(l);
+ numopt = check_numopt(l);
+ i = 1;
+ while(p) {
+ SwigType *pt = Gettype(p);
+ if (!Getignore(p)) {
+ char sourceNtarget[512];
+ sprintf(sourceNtarget, "$args[%d]", i);
+
+ if ((tm = Swig_typemap_lookup((char*)"perl5in",pt,(char*)"",sourceNtarget,sourceNtarget,0))) {
+ Printf(func,"%s\n",tm);
+ need_wrapper = 1;
+ }
+ i++;
}
- i++;
+ p = Getnext(p);
}
- p = Getnext(p);
- }
-
- /* Okay. We've made argument adjustments, now call into the package */
-
- Printv(func,
- tab4, "my $result = ", package, "::", Swig_name_member(class_name,realname),
- "(@args);\n",
- 0);
-
- /* Now check to see what kind of return result was found.
- * If this function is returning a result by 'value', SWIG did an
- * implicit malloc/new. We'll mark the object like it was created
- * in Perl so we can garbage collect it. */
-
- if ((tm = Swig_typemap_lookup((char*)"perl5out",t,(char*)"",name,(char*)"sv",0))) {
+
+ /* Okay. We've made argument adjustments, now call into the package */
+
Printv(func,
- tm, "\n",
- tab4,"return $result;\n",
- "}\n",
- 0);
- need_wrapper = 1;
-
- } else if (is_shadow(t)) {
-
- Printv(func,tab4, "return undef if (!defined($result));\n", 0);
-
- /* If we're returning an object by value, put it's reference
- into our local hash table */
-
- if (!SwigType_ispointer(t) || NewObject) {
- Printv(func, tab4, "$", is_shadow(t), "::OWNER{$result} = 1; \n", 0);
+ tab4, "my $result = ", package, "::", Swig_name_member(class_name,realname),
+ "(@args);\n",
+ 0);
+
+ /* Now check to see what kind of return result was found.
+ * If this function is returning a result by 'value', SWIG did an
+ * implicit malloc/new. We'll mark the object like it was created
+ * in Perl so we can garbage collect it. */
+
+ if ((tm = Swig_typemap_lookup((char*)"perl5out",t,(char*)"",name,(char*)"sv",0))) {
+ Printv(func,
+ tm, "\n",
+ tab4,"return $result;\n",
+ "}\n",
+ 0);
+ need_wrapper = 1;
+
+ } else if (is_shadow(t)) {
+
+ Printv(func,tab4, "return undef if (!defined($result));\n", 0);
+
+ /* If we're returning an object by value, put it's reference
+ into our local hash table */
+
+ if (!SwigType_ispointer(t) || NewObject) {
+ Printv(func, tab4, "$", is_shadow(t), "::OWNER{$result} = 1; \n", 0);
+ }
+
+ /* We're returning a Perl "object" of some kind. Turn it into
+ a tied hash */
+
+ Printv(func,
+ tab4, "my %resulthash;\n",
+ tab4, "tie %resulthash, ref($result), $result;\n",
+ tab4, "return bless \\%resulthash, ref($result);\n",
+ "}\n",
+ 0);
+
+ need_wrapper = 1;
+ } else {
+
+ /* Hmmm. This doesn't appear to be anything I know about so just
+ return it unmodified */
+
+ Printv(func, tab4,"return $result;\n", "}\n", 0);
}
-
- /* We're returning a Perl "object" of some kind. Turn it into
- a tied hash */
-
- Printv(func,
- tab4, "my %resulthash;\n",
- tab4, "tie %resulthash, ref($result), $result;\n",
- tab4, "return bless \\%resulthash, ref($result);\n",
- "}\n",
- 0);
-
- need_wrapper = 1;
- } else {
-
- /* Hmmm. This doesn't appear to be anything I know about so just
- return it unmodified */
-
- Printv(func, tab4,"return $result;\n", "}\n", 0);
- }
-
- if (need_wrapper) {
- Printv(pcode,func,0);
- } else {
- Printv(pcode,"*",realname," = *", package, "::", Swig_name_member(class_name,realname), ";\n", 0);
+
+ if (need_wrapper) {
+ Printv(pcode,func,0);
+ } else {
+ Printv(pcode,"*",realname," = *", package, "::", Swig_name_member(class_name,realname), ";\n", 0);
+ }
+ Delete(func);
+ Delete(cname);
}
- Delete(func);
- Delete(cname);
}
/* -----------------------------------------------------------------------------
@@ -1615,9 +1613,6 @@ PERL5::cpp_member_func(char *name, char *iname, SwigType *t, ParmList *l) {
void PERL5::cpp_variable(char *name, char *iname, SwigType *t) {
char *realname;
- String *cname;
-
- cname = NewString("perl5:");
/* Emit a pair of get/set functions for the variable */
@@ -1625,16 +1620,9 @@ void PERL5::cpp_variable(char *name, char *iname, SwigType *t) {
this->Language::cpp_variable(name, iname, t);
member_func = 0;
- if (iname) realname = iname;
- else realname = name;
-
- if (blessed) {
- Printf(cname,"%s::%s", class_name, realname);
- if (Getattr(symbols,cname)) {
- Delete(cname);
- return;
- }
- Setattr(symbols,cname,cname);
+ if (blessed && !is_multiple_definition()) {
+ if (iname) realname = iname;
+ else realname = name;
/* Store name of key for future reference */
Printf(member_keys,"'%s', ", realname);
@@ -1652,7 +1640,6 @@ void PERL5::cpp_variable(char *name, char *iname, SwigType *t) {
}
}
have_data_members++;
- Delete(cname);
}
/* -----------------------------------------------------------------------------
@@ -1668,16 +1655,13 @@ PERL5::cpp_constructor(char *name, char *iname, ParmList *l) {
Parm *p;
int i;
String *realname;
- String *cname;
-
- cname = NewString("perl5:constructor:");
/* Emit an old-style constructor for this class */
member_func = 1;
this->Language::cpp_constructor(name, iname, l);
- if (blessed) {
+ if (blessed && !is_multiple_definition()) {
if (iname)
realname = iname;
@@ -1686,12 +1670,6 @@ PERL5::cpp_constructor(char *name, char *iname, ParmList *l) {
else realname = class_name;
}
- Printf(cname,"%s::%s", class_name, realname);
- if (Getattr(symbols,cname)) {
- Delete(cname);
- return;
- }
- Setattr(symbols,cname, cname);
if ((Cmp(realname,class_name) == 0) || ((!iname) && (ObjCClass)) ){
/* Emit a blessed constructor */
@@ -1741,7 +1719,6 @@ PERL5::cpp_constructor(char *name, char *iname, ParmList *l) {
have_constructor = 1;
}
- Delete(cname);
member_func = 0;
}
@@ -1754,7 +1731,7 @@ PERL5::cpp_destructor(char *name, char *newname) {
member_func = 1;
this->Language::cpp_destructor(name, newname);
- if (blessed) {
+ if (blessed && !is_multiple_definition()) {
if (newname) realname = newname;
else {
if (class_renamed) realname = class_name;
@@ -1786,11 +1763,12 @@ PERL5::cpp_destructor(char *name, char *newname) {
void
PERL5::cpp_static_func(char *name, char *iname, SwigType *t, ParmList *l) {
this->Language::cpp_static_func(name,iname,t,l);
- char *realname;
- if (iname) realname = name;
- else realname = iname;
- if (blessed) {
+ if (blessed && !is_multiple_definition()) {
+ char *realname;
+ if (iname) realname = name;
+ else realname = iname;
+
Printv(pcode, "*", realname, " = *", realpackage, "::", Swig_name_member(class_name,realname), ";\n", 0);
}
}
@@ -1840,25 +1818,18 @@ void
PERL5::cpp_declare_const(char *name, char *iname, SwigType *type, char *value) {
String *realname;
int oldblessed = blessed;
- char cname[256];
/* Create a normal constant */
blessed = 0;
this->Language::cpp_declare_const(name, iname, type, value);
blessed = oldblessed;
- if (blessed) {
+ if (blessed && !is_multiple_definition()) {
if (!iname)
realname = name;
else
realname = iname;
- sprintf(cname,"%s::%s",Char(class_name),Char(realname));
- if (Getattr(symbols, cname)) {
- return;
- }
- Setattr(symbols, cname,cname);
-
/* Create a symbol table entry for it */
Printv(pcode, "*", realname, " = *", package, "::", Swig_name_member(class_name,realname), ";\n", 0);
}
diff --git a/SWIG/Source/Modules1.1/python.cxx b/SWIG/Source/Modules1.1/python.cxx
index 140668e93..23a8e8562 100644
--- a/SWIG/Source/Modules1.1/python.cxx
+++ b/SWIG/Source/Modules1.1/python.cxx
@@ -13,6 +13,7 @@ static char cvsroot[] = "$Header$";
#include "mod11.h"
#include "python.h"
+#include "swigconfig.h"
static String *const_code = 0;
static String *shadow_methods = 0;
@@ -26,7 +27,6 @@ static int use_kw = 0;
static int noopt = 1;
static FILE *f_shadow;
static Hash *hash;
-static Hash *symbols;
static String *classes;
static String *func;
static String *vars;
@@ -37,6 +37,7 @@ static char *class_name;
static char *usage = (char *)"\
Python Options (available with -python)\n\
+ -ldflags - Print runtime libraries to link with\n\
-globals name - Set name used to access C global variable ('cvar' by default).\n\
-module name - Set module name\n\
-interface name - Set the lib name\n\
@@ -108,6 +109,9 @@ PYTHON::parse_args(int argc, char *argv[]) {
Swig_mark_arg(i);
} else if (strcmp(argv[i],"-help") == 0) {
fputs(usage,stderr);
+ } else if (strcmp (argv[i], "-ldflags") == 0) {
+ printf("%s\n", SWIG_PYTHON_RUNTIME);
+ SWIG_exit (EXIT_SUCCESS);
}
}
}
@@ -123,7 +127,6 @@ void
PYTHON::parse() {
hash = NewHash();
- symbols = NewHash();
const_code = NewString("");
shadow_methods = NewString("");
classes = NewString("");
@@ -1227,20 +1230,15 @@ void
PYTHON::cpp_member_func(char *name, char *iname, SwigType *t, ParmList *l) {
char *realname;
int oldshadow;
- char cname[1024];
/* Create the default member function */
oldshadow = shadow; /* Disable shadowing when wrapping member functions */
if (shadow) shadow = shadow | PYSHADOW_MEMBER;
this->Language::cpp_member_func(name,iname,t,l);
shadow = oldshadow;
- if (shadow) {
- realname = iname ? iname : name;
- /* Check to see if we've already seen this */
- sprintf(cname,"python:%s::%s",class_name,realname);
- if (Getattr(symbols,cname)) return;
- Setattr(symbols,cname,cname);
+ if (shadow && !is_multiple_definition()) {
+ realname = iname ? iname : name;
if (strcmp(realname,"__repr__") == 0)
have_repr = 1;
@@ -1287,20 +1285,14 @@ void
PYTHON::cpp_constructor(char *name, char *iname, ParmList *l) {
char *realname;
int oldshadow = shadow;
- char cname[1024];
if (shadow) shadow = shadow | PYSHADOW_MEMBER;
this->Language::cpp_constructor(name,iname,l);
shadow = oldshadow;
- if (shadow) {
+ if (shadow && !is_multiple_definition()) {
realname = iname ? iname : class_name;
- /* Check to see if we've already seen this */
- sprintf(cname,":python:constructor:%s::%s",class_name,realname);
- if (Getattr(symbols,cname)) return;
- Setattr(symbols,cname,cname);
-
if (!have_constructor) {
if (use_kw)
Printv(construct, tab4, "def __init__(self,*args,**kwargs):\n", 0);
@@ -1345,13 +1337,13 @@ PYTHON::cpp_destructor(char *name, char *newname) {
if (shadow) shadow = shadow | PYSHADOW_MEMBER;
this->Language::cpp_destructor(name,newname);
shadow = oldshadow;
- if (shadow) {
+ if (shadow && !is_multiple_definition()) {
if (newname) realname = newname;
else realname = class_renamed ? class_name : name;
Printv(pyclass, tab4, "def __del__(self,", module, "=", module, "):\n", 0);
emitAddPragmas(pyclass,(char*)"__del__",(char*)tab8);
- Printv(pyclass, tab8, "if self.thisown == 1 :\n",
+ Printv(pyclass, tab8, "if getattr(self,'thisown',0):\n",
tab8, tab4, module, ".", Swig_name_destroy(realname), "(self)\n", 0);
have_destructor = 1;
@@ -1478,23 +1470,16 @@ PYTHON::cpp_variable(char *name, char *iname, SwigType *t) {
char *realname;
int inhash = 0;
int oldshadow = shadow;
- char cname[512];
if (shadow) shadow = shadow | PYSHADOW_MEMBER;
this->Language::cpp_variable(name,iname,t);
shadow = oldshadow;
- if (shadow) {
+ if (shadow && !is_multiple_definition()) {
have_getattr = 1;
have_setattr = 1;
realname = iname ? iname : name;
- /* Check to see if we've already seen this */
- sprintf(cname,"python:%s::%s:",class_name,realname);
- if (Getattr(symbols,cname)) return;
-
- Setattr(symbols,cname,cname);
-
/* Figure out if we've seen this datatype before */
if (is_shadow(t)) inhash = 1;
@@ -1518,19 +1503,13 @@ void
PYTHON::cpp_declare_const(char *name, char *iname, SwigType *type, char *value) {
char *realname;
int oldshadow = shadow;
- char cname[512];
if (shadow) shadow = shadow | PYSHADOW_MEMBER;
this->Language::cpp_declare_const(name,iname,type,value);
shadow = oldshadow;
- if (shadow) {
+ if (shadow && !is_multiple_definition()) {
realname = iname ? iname : name;
-
- /* Check to see if we've already seen this */
- sprintf(cname,"python:%s::%s", class_name, realname);
- if (Getattr(symbols,cname)) return;
- Setattr(symbols,cname,cname);
Printv(cinit, tab4, realname, " = ", module, ".", Swig_name_member(class_name,realname), "\n", 0);
}
}
diff --git a/SWIG/Source/Modules1.1/ruby.cxx b/SWIG/Source/Modules1.1/ruby.cxx
index 84a2ee3e3..6b401520d 100644
--- a/SWIG/Source/Modules1.1/ruby.cxx
+++ b/SWIG/Source/Modules1.1/ruby.cxx
@@ -14,6 +14,7 @@ static char cvsroot[] = "$Header$";
#include "mod11.h"
#include "ruby.h"
+#include "swigconfig.h"
#include <ctype.h>
#include <string.h>
@@ -92,6 +93,7 @@ class RClass {
static char *usage = (char*)"\
Ruby Options (available with -ruby)\n\
+ -ldflags - Print runtime libraries to link with\n\
-module name - Set module name\n\
-feature name - Set feature name (used by `require')\n";
@@ -155,6 +157,9 @@ void RUBY::parse_args(int argc, char *argv[]) {
}
} else if (strcmp(argv[i],"-help") == 0) {
Printf(stderr,"%s\n", usage);
+ } else if (strcmp (argv[i], "-ldflags") == 0) {
+ printf("%s\n", SWIG_RUBY_RUNTIME);
+ SWIG_exit (EXIT_SUCCESS);
}
}
}
@@ -1309,39 +1314,41 @@ void RUBY::cpp_destructor(char *name, char *newname) {
current = DESTRUCTOR;
this->Language::cpp_destructor(name, newname);
- String *freefunc = NewString("");
- String *freeproto = NewString("");
- String *freebody = NewString("");
-
- Printv(freefunc, "free_", klass->cname, 0);
- Printv(freeproto, "static void ", freefunc, "(", klass->type, " *);\n", 0);
- Printv(freebody, "static void\n",
- freefunc, "(", klass->type, " *", Swig_cparm_name(0,0), ") {\n",
- tab4, 0);
- if (AddMethods) {
- Printv(freebody, Swig_name_destroy(name), "(", Swig_cparm_name(0,0), ")", 0);
- } else {
- /* When no addmethods mode, swig emits no destroy function. */
- if (CPlusPlus)
- Printv(freebody, Swig_cppdestructor_call(), 0);
- else
- Printv(freebody, Swig_cdestructor_call(), 0);
- }
- Printv(freebody, ";\n}\n", 0);
- if (CPlusPlus) {
- Insert(freefunc,0,"VOIDFUNC(");
- Append(freefunc,")");
+ if (!is_multiple_definition()) {
+ String *freefunc = NewString("");
+ String *freeproto = NewString("");
+ String *freebody = NewString("");
+
+ Printv(freefunc, "free_", klass->cname, 0);
+ Printv(freeproto, "static void ", freefunc, "(", klass->type, " *);\n", 0);
+ Printv(freebody, "static void\n",
+ freefunc, "(", klass->type, " *", Swig_cparm_name(0,0), ") {\n",
+ tab4, 0);
+ if (AddMethods) {
+ Printv(freebody, Swig_name_destroy(name), "(", Swig_cparm_name(0,0), ")", 0);
+ } else {
+ /* When no addmethods mode, swig emits no destroy function. */
+ if (CPlusPlus)
+ Printv(freebody, Swig_cppdestructor_call(), 0);
+ else
+ Printv(freebody, Swig_cdestructor_call(), 0);
+ }
+ Printv(freebody, ";\n}\n", 0);
+ if (CPlusPlus) {
+ Insert(freefunc,0,"VOIDFUNC(");
+ Append(freefunc,")");
+ }
+
+ Replace(klass->header,"$freefunc", freefunc, DOH_REPLACE_ANY);
+ Replace(klass->header,"$freeproto", freeproto, DOH_REPLACE_ANY);
+ Printv(f_wrappers, freebody, 0);
+
+ klass->destructor_defined = 1;
+ current = NO_CPP;
+ Delete(freefunc);
+ Delete(freeproto);
+ Delete(freebody);
}
-
- Replace(klass->header,"$freefunc", freefunc, DOH_REPLACE_ANY);
- Replace(klass->header,"$freeproto", freeproto, DOH_REPLACE_ANY);
- Printv(f_wrappers, freebody, 0);
-
- klass->destructor_defined = 1;
- current = NO_CPP;
- Delete(freefunc);
- Delete(freeproto);
- Delete(freebody);
}
/* ---------------------------------------------------------------------
diff --git a/SWIG/Source/Modules1.1/swigmain.cxx b/SWIG/Source/Modules1.1/swigmain.cxx
index 50f775268..86e8a2f45 100644
--- a/SWIG/Source/Modules1.1/swigmain.cxx
+++ b/SWIG/Source/Modules1.1/swigmain.cxx
@@ -32,9 +32,7 @@ static char cvsroot[] = "$Header$";
#include "perl5.h"
#include "guile.h"
-#ifdef OLD
#include "java.h"
-#endif
#include "mzscheme.h"
#include "ruby.h"
@@ -88,11 +86,9 @@ int main(int argc, char **argv) {
} else if (strcmp(argv[i],"-guile") == 0) {
dl = new GUILE;
Swig_mark_arg(i);
-#ifdef OLD
} else if (strcmp(argv[i],"-java") == 0) {
dl = new JAVA;
Swig_mark_arg(i);
-#endif
} else if (strcmp(argv[i],"-mzscheme") == 0) {
dl = new MZSCHEME;
Swig_mark_arg(i);
diff --git a/SWIG/Source/Modules1.1/tcl8.cxx b/SWIG/Source/Modules1.1/tcl8.cxx
index 8ed1ed4fc..105808cb8 100644
--- a/SWIG/Source/Modules1.1/tcl8.cxx
+++ b/SWIG/Source/Modules1.1/tcl8.cxx
@@ -14,9 +14,11 @@ static char cvsroot[] = "$Header$";
#include "mod11.h"
#include "tcl8.h"
#include <ctype.h>
+#include "swigconfig.h"
static char *usage = (char*)"\
Tcl 8.0 Options (available with -tcl)\n\
+ -ldflags - Print runtime libraries to link with\n\
-module name - Set name of module\n\
-prefix name - Set a prefix to be appended to all names\n\
-namespace - Build module into a Tcl 8 namespace. \n\
@@ -76,6 +78,9 @@ TCL8::parse_args(int argc, char *argv[]) {
Swig_mark_arg(i);
} else if (strcmp(argv[i],"-help") == 0) {
fputs(usage,stderr);
+ } else if (strcmp (argv[i], "-ldflags") == 0) {
+ printf("%s\n", SWIG_TCL_RUNTIME);
+ SWIG_exit (EXIT_SUCCESS);
}
}
}
@@ -230,7 +235,7 @@ TCL8::close(void) {
Printf(f_init,"}\n");
Printf(f_init,"for (i = 0; swig_variables[i].name; i++) {\n");
- Printf(f_init,"Tcl_SetVar(interp, (char *) swig_variables[i].name, \"\", TCL_GLOBAL_ONLY);\n");
+ Printf(f_init,"Tcl_SetVar(interp, (char *) swig_variables[i].name, (char *) \"\", TCL_GLOBAL_ONLY);\n");
Printf(f_init,"Tcl_TraceVar(interp, (char *) swig_variables[i].name, TCL_TRACE_READS | TCL_GLOBAL_ONLY, swig_variables[i].get, (ClientData) swig_variables[i].addr);\n");
Printf(f_init,"Tcl_TraceVar(interp, (char *) swig_variables[i].name, TCL_TRACE_WRITES | TCL_GLOBAL_ONLY, swig_variables[i].set, (ClientData) swig_variables[i].addr);\n");
Printf(f_init,"}\n");
@@ -1014,7 +1019,7 @@ void TCL8::cpp_member_func(char *name, char *iname, SwigType *t, ParmList *l) {
String *rname;
this->Language::cpp_member_func(name,iname,t,l);
- if (shadow) {
+ if (shadow && !is_multiple_definition()) {
realname = iname ? iname : name;
/* Add stubs for this member to our class handler function */
@@ -1033,7 +1038,7 @@ void TCL8::cpp_variable(char *name, char *iname, SwigType *t) {
this->Language::cpp_variable(name, iname, t);
- if (shadow) {
+ if (shadow && !is_multiple_definition()) {
realname = iname ? iname : name;
Printv(attributes, tab4, "{ \"-", realname, "\",", 0);
diff --git a/SWIG/Source/Preprocessor/cpp.c b/SWIG/Source/Preprocessor/cpp.c
index e72e6550b..7fe5f59f8 100644
--- a/SWIG/Source/Preprocessor/cpp.c
+++ b/SWIG/Source/Preprocessor/cpp.c
@@ -173,7 +173,7 @@ DOHHash *Preprocessor_define(DOHString_or_char *str, int swigmacro)
goto macro_error;
}
break;
- } else if (isidchar(c)) {
+ } else if (isidchar(c) || (c == '%')) {
Putc(c,macroname);
} else if (isspace(c)) {
break;
@@ -283,19 +283,21 @@ find_args(DOHString *s)
DOHList *args;
DOHString *str;
int c, level;
+ long pos;
/* Create a new list */
args = NewList();
copy_location(s,args);
/* First look for a '(' */
+ pos = Tell(s);
skip_whitespace(s,0);
/* Now see if the next character is a '(' */
c = Getc(s);
if (c != '(') {
/* Not a macro, bail out now! */
- cpp_error(Getfile(s),Getline(s),"Missing macro arguments\n");
+ Seek(s,pos, SEEK_SET);
return args;
}
c = Getc(s);
@@ -401,12 +403,14 @@ expand_macro(DOHString_or_char *name, DOHList *args)
ns = NewString("");
Printf(ns,"%s",name);
if (args) {
- Putc('(',ns);
+ if (Len(args))
+ Putc('(',ns);
for (i = 0; i < Len(args); i++) {
Printf(ns,"%s",Getitem(args,i));
if (i < (Len(args) -1)) Putc(',',ns);
}
- Putc(')',ns);
+ if (i)
+ Putc(')',ns);
}
return ns;
}
@@ -456,6 +460,26 @@ expand_macro(DOHString_or_char *name, DOHList *args)
Printf(tempa,"\"%s\"",arg);
Replace(ns, temp, tempa, DOH_REPLACE_ANY);
}
+
+ /* Non-standard macro expansion. The value `x` is replaced by a quoted
+ version of the argument except that if the argument is already quoted
+ nothing happens */
+
+ if (strstr(Char(ns),"`")) {
+ String *rep;
+ char *c;
+ Clear(temp);
+ Printf(temp,"`%s`",aname);
+ c = Char(arg);
+ if (*c == '\"') {
+ rep = arg;
+ } else {
+ Clear(tempa);
+ Printf(tempa,"\"%s\"",arg);
+ rep = tempa;
+ }
+ Replace(ns,temp,rep, DOH_REPLACE_ANY);
+ }
Replace(ns, aname, arg, DOH_REPLACE_ID);
}
}
@@ -513,7 +537,7 @@ Preprocessor_replace(DOH *s)
while ((c = Getc(s)) != EOF) {
switch (state) {
case 0:
- if (isidentifier(c)) {
+ if (isidentifier(c) || (c == '%')) {
Clear(id);
copy_location(s,id);
Putc(c,id);
@@ -675,19 +699,28 @@ static int
check_id(DOH *s)
{
int c, state = 0;
+ int hasvalue = 0;
Seek(s,0,SEEK_SET);
while ((c = Getc(s)) != EOF) {
switch(state) {
case 0:
- if (isdigit(c)) state = 1;
+ if (isdigit(c)) {
+ hasvalue =1;
+ state = 1;
+ }
else if (isidentifier(c)) return 1;
- else if (c == '\"') skip_tochar(s,'\"',0);
- else if (c == '\'') skip_tochar(s,'\'',0);
- else if (c == '/') state = 3;
+ else if (c == '\"') {
+ skip_tochar(s,'\"',0);
+ hasvalue = 1;
+ } else if (c == '\'') {
+ skip_tochar(s,'\'',0);
+ hasvalue = 1;
+ } else if (c == '/') state = 3;
break;
case 1:
if (isspace(c)) state = 0;
+ hasvalue = 1;
break;
case 3:
if (c == '*') state = 10;
@@ -709,6 +742,7 @@ check_id(DOH *s)
break;
}
}
+ if (!hasvalue) return 1;
return 0;
}
@@ -906,7 +940,12 @@ Preprocessor_parse(DOH *s)
case 45:
if (c == '/') state = 46;
else if (c == '*') state = 47;
- else {
+ else if (c == '\n') {
+ Putc('/',value);
+ Ungetc(c,s);
+ cpp_lines++;
+ state = 50;
+ } else {
Putc('/',value);
Putc(c,value);
state = 43;
@@ -946,6 +985,7 @@ Preprocessor_parse(DOH *s)
silent_errors = 1;
v1 = Preprocessor_replace(v);
silent_errors = 0;
+ /* Printf(stdout,"checking '%s'\n", v1); */
if (!check_id(v1)) {
if (Len(comment) == 0)
Printf(ns,"%%constant %s %s;\n", Getattr(m,"name"), v1);
diff --git a/SWIG/Source/SWIG1.1/.cvsignore b/SWIG/Source/SWIG1.1/.cvsignore
index 1c4954aef..8905680c7 100644
--- a/SWIG/Source/SWIG1.1/.cvsignore
+++ b/SWIG/Source/SWIG1.1/.cvsignore
@@ -1,6 +1,8 @@
-Makefile
*.flc
.deps
-swig
-parser.h
+Makefile
parser.cxx
+parser.h
+swig
+y.tab.c
+y.tab.h
diff --git a/SWIG/Source/SWIG1.1/cplus.cxx b/SWIG/Source/SWIG1.1/cplus.cxx
index 906c81ac2..c77047525 100644
--- a/SWIG/Source/SWIG1.1/cplus.cxx
+++ b/SWIG/Source/SWIG1.1/cplus.cxx
@@ -699,6 +699,16 @@ void CPP_class::create_all() {
c->emit_decls();
lang->cpp_close_class();
}
+ // Force brute patch to produce the proper casting code
+ // between "local" classes and "external" ones when
+ // %import is used.
+ else if ( (c->wextern) && (c->classtype) ) {
+ SwigType *t;
+ t = NewString(c->classname);
+ SwigType_add_pointer(t);
+ SwigType_remember(t);
+ Delete(t);
+ }
}
c = c->next;
}
diff --git a/SWIG/Source/SWIG1.1/lang.cxx b/SWIG/Source/SWIG1.1/lang.cxx
index 70a808f9d..b60f7a2e5 100644
--- a/SWIG/Source/SWIG1.1/lang.cxx
+++ b/SWIG/Source/SWIG1.1/lang.cxx
@@ -44,6 +44,7 @@ Language::add_native(char *, char *iname, SwigType *, ParmList *) {
static char *ClassName = 0; /* This is the real name of the current class */
static char *ClassRename = 0; /* This is non-NULL if the class has been renamed */
static char *ClassType = 0; /* Type of class (ie. union, struct, class) */
+static int multiple_definition = 0; /* Defines whether a function has been multiply defined*/
/* -----------------------------------------------------------------------------
* Language::cpp_open_class()
@@ -90,6 +91,7 @@ void Language::cpp_close_class() {
void Language::cpp_member_func(char *name, char *iname, SwigType *t, ParmList *l) {
char new_name[256];
char *prefix;
+ multiple_definition = 0;
/* Generate the C wrapper function name and interpreter name of this function*/
@@ -110,8 +112,9 @@ void Language::cpp_member_func(char *name, char *iname, SwigType *t, ParmList *l
/* Now do a symbol table lookup on it : */
if (add_symbol(new_name)) {
- Printf(stderr,"%s : Line %d. Function %s (member %s) multiply defined (2nd definition ignored).\n",
+ Printf(stderr,"%s : Line %d. Function %s (member %s) multiply defined (multiple definition ignored).\n",
input_file, line_number, iname, name);
+ multiple_definition = 1;
return;
}
cplus_emit_member_func(ClassName, ClassType, ClassRename, name, iname, t, l, AddMethods);
@@ -124,6 +127,7 @@ void Language::cpp_member_func(char *name, char *iname, SwigType *t, ParmList *l
void Language::cpp_constructor(char *name, char *iname, ParmList *l) {
char *prefix, *cname;
+ multiple_definition = 0;
if ((strcmp(name,ClassName)) && (!ObjCClass)) {
Printf(stderr,"%s : Line %d. Function %s must have a return type.\n",
@@ -146,8 +150,9 @@ void Language::cpp_constructor(char *name, char *iname, ParmList *l) {
/* Add this function to the SWIG symbol table */
if (add_symbol(cname)) {
- Printf(stderr,"%s : Line %d. Constructor %s multiply defined (2nd definition ignored).\n",
+ Printf(stderr,"%s : Line %d. Constructor %s multiply defined (multiple definition ignored).\n",
input_file, line_number, cname);
+ multiple_definition = 1;
return;
}
@@ -164,6 +169,7 @@ void Language::cpp_constructor(char *name, char *iname, ParmList *l) {
void Language::cpp_destructor(char *name, char *iname) {
char *cname;
+ multiple_definition = 0;
if (ClassRename)
cname = Char(Swig_name_destroy(ClassRename));
@@ -173,8 +179,9 @@ void Language::cpp_destructor(char *name, char *iname) {
/* Add this function to the SWIG symbol table */
if (add_symbol(cname)) {
- Printf(stderr,"%s : Line %d. Destructor %s multiply defined (2nd definition ignored).\n",
+ Printf(stderr,"%s : Line %d. Destructor %s multiply defined (multiple definition ignored).\n",
input_file, line_number, cname);
+ multiple_definition = 1;
return;
}
@@ -217,6 +224,7 @@ void Language::cpp_inherit(char **baseclass, int mode) {
void Language::cpp_variable(char *name, char *iname, SwigType *t) {
char *prefix, *cname;
+ multiple_definition = 0;
/* Set the class prefix */
@@ -234,7 +242,8 @@ void Language::cpp_variable(char *name, char *iname, SwigType *t) {
/* Check the symbol table */
if (add_symbol(cname)) {
- Printf(stderr,"%s : Line %d. Variable %s multiply defined (2nd definition ignored).\n", input_file, line_number, cname);
+ Printf(stderr,"%s : Line %d. Variable %s multiply defined (multiple definition ignored).\n", input_file, line_number, cname);
+ multiple_definition = 1;
return;
}
@@ -259,6 +268,7 @@ void Language::cpp_static_func(char *name, char *iname, SwigType *t, ParmList *l
char *prefix;
char *mname;
char *cname;
+ multiple_definition = 0;
/* Set the classname prefix */
@@ -280,11 +290,12 @@ void Language::cpp_static_func(char *name, char *iname, SwigType *t, ParmList *l
if (add_symbol(cname)) {
if (ObjCClass)
- Printf(stderr,"%s : Line %d. class function %s multiply defined (2nd definition ignored).\n",
+ Printf(stderr,"%s : Line %d. class function %s multiply defined (multiple definition ignored).\n",
input_file, line_number, cname);
else
- Printf(stderr,"%s : Line %d. static function %s multiply defined (2nd definition ignored).\n",
+ Printf(stderr,"%s : Line %d. static function %s multiply defined (multiple definition ignored).\n",
input_file, line_number, cname);
+ multiple_definition = 1;
return;
}
cplus_emit_static_func(ClassName,ClassType, ClassRename, name, iname, t, l, AddMethods);
@@ -302,6 +313,7 @@ void Language::cpp_declare_const(char *name, char *iname, SwigType *type, char *
char mname[256];
char *new_value;
char *prefix;
+ multiple_definition = 0;
/* Set the classname prefix */
@@ -321,8 +333,9 @@ void Language::cpp_declare_const(char *name, char *iname, SwigType *type, char *
/* Now do a symbol table lookup on it : */
if (add_symbol(cname)) {
- Printf(stderr,"%s : Line %d. Constant %s (member %s) multiply defined (2nd definition ignored).\n",
+ Printf(stderr,"%s : Line %d. Constant %s (member %s) multiply defined (multiple definition ignored).\n",
input_file, line_number, cname, name);
+ multiple_definition = 1;
return;
}
@@ -354,6 +367,7 @@ void Language::cpp_static_var(char *name, char *iname, SwigType *t) {
char *cname;
char mname[256];
char *prefix;
+ multiple_definition = 0;
/* Set the classname prefix */
@@ -373,8 +387,9 @@ void Language::cpp_static_var(char *name, char *iname, SwigType *t) {
/* Now do a symbol table lookup on it : */
if (add_symbol(cname)) {
- Printf(stderr,"%s : Line %d. Variable %s (member %s) multiply defined (2nd definition ignored).\n",
+ Printf(stderr,"%s : Line %d. Variable %s (member %s) multiply defined (multiple definition ignored).\n",
input_file, line_number, cname, name);
+ multiple_definition = 1;
return;
}
@@ -426,3 +441,11 @@ void Language::pragma(char *, char *, char *) {
void Language::import(char *) {
/* Does nothing by default */
}
+
+/* -----------------------------------------------------------------------------
+ * Language::is_multiple_definition()
+ * ----------------------------------------------------------------------------- */
+
+int Language::is_multiple_definition() {
+ return multiple_definition;
+}
diff --git a/SWIG/Source/SWIG1.1/main.cxx b/SWIG/Source/SWIG1.1/main.cxx
index 0e6dd26e5..f042c4ae7 100644
--- a/SWIG/Source/SWIG1.1/main.cxx
+++ b/SWIG/Source/SWIG1.1/main.cxx
@@ -245,10 +245,12 @@ int SWIG_main(int argc, char *argv[], Language *l) {
Swig_arg_error();
}
} else if (strcmp(argv[i],"-version") == 0) {
- fprintf(stderr,"\nSWIG Version %s %s\n",
- SWIG_VERSION, SWIG_SPIN);
- fprintf(stderr,"Copyright (c) 1995-98\n");
+ fprintf(stderr,"\nSWIG Version %s\n",
+ SWIG_VERSION);
+ fprintf(stderr,"Copyright (c) 1995-1998\n");
fprintf(stderr,"University of Utah and the Regents of the University of California\n");
+ fprintf(stderr,"Copyright (c) 1998-2001\n");
+ fprintf(stderr,"University of Chicago\n");
fprintf(stderr,"\nCompiled with %s\n", SWIG_CC);
SWIG_exit (EXIT_SUCCESS);
} else if (strncmp(argv[i],"-l",2) == 0) {
@@ -393,18 +395,16 @@ int SWIG_main(int argc, char *argv[], Language *l) {
DOH *cpps;
int i;
String *fs = NewString("");
- String *ds = Swig_include(input_file);
- if (!ds) {
+ FILE *df = Swig_open(input_file);
+ if (!df) {
Printf(stderr,"Unable to find '%s'\n", input_file);
SWIG_exit (EXIT_FAILURE);
}
+ fclose(df);
if (lang_config) {
Printf(fs,"\n%%include \"%s\"\n", lang_config);
}
- Printf(fs,"\n%%includefile \"%s\" {\n", Swig_last_file());
- Append(fs, ds);
- Append(fs,"\n}\n");
- Delete(ds);
+ Printf(fs,"%%include \"%s\"\n", Swig_last_file());
for (i = 0; i < Len(libfiles); i++) {
Printf(fs,"\n%%include \"%s\"\n", Getitem(libfiles,i));
}
diff --git a/SWIG/Source/SWIG1.1/parser.yxx b/SWIG/Source/SWIG1.1/parser.yxx
index f77a80963..dbbf04abf 100644
--- a/SWIG/Source/SWIG1.1/parser.yxx
+++ b/SWIG/Source/SWIG1.1/parser.yxx
@@ -514,7 +514,7 @@ static void dump_nested(char *parent) {
%type <id> pname cpptype base_specifier access_specifier typemap_name tm_method;
%type <type> type opt_signed opt_unsigned strict_type;
%type <decl> declaration nested_decl;
-%type <ivalue> stars cpp_vend;
+%type <ivalue> stars maybestars cpp_vend;
%type <ilist> initlist base_list inherit;
%type <dtype> definetype def_args;
%type <dtype> etype;
@@ -752,12 +752,26 @@ statement : INCLUDE STRING LBRACE {
Rename_true = 1;
}
+/* and its string version */
+
+ | NAME LPAREN STRING RPAREN {
+ strcpy(yy_rename,$3);
+ Rename_true = 1;
+ }
+
/* %rename directive */
| RENAME ID ID SEMI {
if (!name_hash) name_hash = NewHash();
Setattr(name_hash,$2,$3);
}
+/* and its string version */
+
+ | RENAME ID STRING SEMI {
+ if (!name_hash) name_hash = NewHash();
+ Setattr(name_hash,$2,$3);
+ }
+
/* %new directive */
| NEW {
@@ -1487,17 +1501,28 @@ parm_type : type pname {
free($3);
}
- | type AND pname {
- $$ = NewParm($1,$3);
+ | type maybestars CONST pname {
+ $$ = NewParm($1,$4);
+ add_pointers(Gettype($$), $2);
+ SwigType_add_qualifier($$,(char*)"const");
+ Setvalue($$,DefArg);
+ Delete($1);
+ free($4);
+ }
+
+ | type maybestars AND pname {
+ $$ = NewParm($1,$4);
SwigType *pt = Gettype($$);
+ add_pointers(Gettype($$), $2);
SwigType_add_reference(pt);
Setvalue($$,DefArg);
if (!CPlusPlus) {
Printf(stderr,"%s : Line %d. Warning. Use of C++ Reference detected. Use the -c++ option.\n", input_file, line_number);
}
Delete($1);
- free($3);
+ free($4);
}
+
| type LPAREN stars pname RPAREN LPAREN parms RPAREN {
$$ = NewParm($1,$4);
SwigType *pt = Gettype($$);
@@ -1585,6 +1610,9 @@ stars : STAR empty { $$ = 1; }
| STAR stars { $$ = $2 + 1;}
;
+maybestars : empty { $$ = 0; }
+ | stars { $$ = $1; }
+ ;
array : LBRACKET RBRACKET array2 {
$$ = $3 + 1;
@@ -1616,6 +1644,9 @@ type : TYPE_INT {
| TYPE_LONG opt_int {
$$ = $1;
}
+ | TYPE_LONG TYPE_LONG opt_int {
+ $$ = NewString("long long");
+ }
| TYPE_CHAR {
$$ = $1;
}
@@ -1683,6 +1714,9 @@ strict_type : TYPE_INT {
| TYPE_LONG opt_int {
$$ = $1;
}
+ | TYPE_LONG TYPE_LONG opt_int {
+ $$ = NewString("long long");
+ }
| TYPE_CHAR {
$$ = $1;
}
@@ -1735,6 +1769,9 @@ opt_signed : empty {
| TYPE_LONG opt_int {
$$ = $1;
}
+ | TYPE_LONG TYPE_LONG opt_int {
+ $$ = NewString("long long");
+ }
| TYPE_CHAR {
$$ = NewString("signed char");
}
@@ -1754,6 +1791,9 @@ opt_unsigned : empty {
| TYPE_LONG opt_int {
$$ = NewString("unsigned long");
}
+ | TYPE_LONG TYPE_LONG opt_int {
+ $$ = NewString("unsigned long long");
+ }
| TYPE_CHAR {
$$ = NewString("unsigned char");
}
@@ -2802,6 +2842,7 @@ cpptype : CLASS { $$ = (char*)"class"; }
cpp_const : CONST {}
| THROW LPAREN parms RPAREN { Delete($3);}
+ | CONST THROW LPAREN parms RPAREN { Delete($4);}
| empty {}
;
@@ -3212,17 +3253,18 @@ typemap_parm : type typemap_name {
free($3);
}
- | type AND typemap_name {
+ | type maybestars AND typemap_name {
$$ = NewTMParm();
- $$->p = NewParm($1,$3);
+ $$->p = NewParm($1,$4);
SwigType *pt = Gettype($$->p);
+ add_pointers(pt,$2);
SwigType_add_reference(pt);
if (!CPlusPlus) {
Printf(stderr,"%s : Line %d. Warning. Use of C++ Reference detected. Use the -c++ option.\n", input_file, line_number);
}
$$->args = tm_parm;
Delete($1);
- free($3);
+ free($4);
}
| type LPAREN stars typemap_name RPAREN LPAREN parms RPAREN {
Printf(stderr,"%s : Line %d. Error. Function pointer not allowed (remap with typedef).\n", input_file, line_number);
diff --git a/SWIG/Source/SWIG1.1/scanner.cxx b/SWIG/Source/SWIG1.1/scanner.cxx
index 58c69ff8f..6e4f135a5 100644
--- a/SWIG/Source/SWIG1.1/scanner.cxx
+++ b/SWIG/Source/SWIG1.1/scanner.cxx
@@ -83,6 +83,7 @@ void scanner_file(DOHFile *f) {
in->extern_mode = WrapExtern;
in->force_extern = ForceExtern;
in->inline_mode = 0;
+ in->line_number = 1;
if (!in_head) in->prev = 0;
else in->prev = in_head;
in_head = in;
diff --git a/SWIG/Source/SWIG1.1/swig11.h b/SWIG/Source/SWIG1.1/swig11.h
index 9b0fe8870..af1c7d007 100644
--- a/SWIG/Source/SWIG1.1/swig11.h
+++ b/SWIG/Source/SWIG1.1/swig11.h
@@ -214,6 +214,8 @@ public:
virtual void import(char *filename);
+protected:
+ int is_multiple_definition(); // indicates whether the function has already been defined
};
/* Emit functions */
diff --git a/SWIG/Source/Swig/cwrap.c b/SWIG/Source/Swig/cwrap.c
index 33af4c955..56e25884e 100644
--- a/SWIG/Source/Swig/cwrap.c
+++ b/SWIG/Source/Swig/cwrap.c
@@ -74,7 +74,7 @@ Swig_clocal(SwigType *t, String_or_char *name, String_or_char *value) {
* Swig_clocal_type()
*
* Creates a string that declares a C local variable type. Converts references
- * and user defined types to pointers.
+ * and user defined types and arrays to pointers.
* ----------------------------------------------------------------------------- */
SwigType *
@@ -94,6 +94,27 @@ Swig_clocal_type(SwigType *t) {
}
/* -----------------------------------------------------------------------------
+ * Swig_wrapped_var_convert()
+ *
+ * Converts a member variable for use in the get and set wrapper methods.
+ * This function only converts user defined types to pointers.
+ * ----------------------------------------------------------------------------- */
+
+SwigType *
+Swig_wrapped_var_type(SwigType *t) {
+ SwigType *ty;
+ ty = Copy(t);
+ switch(SwigType_type(t)) {
+ case T_USER:
+ SwigType_add_pointer(ty);
+ break;
+ default:
+ break;
+ }
+ return ty;
+}
+
+/* -----------------------------------------------------------------------------
* Swig_clocal_deref()
*
* Creates a string that can be used to deref a local variable wrapped with
@@ -253,7 +274,7 @@ void Swig_cppresult(Wrapper *w, SwigType *t, String_or_char *name, String_or_cha
switch(SwigType_type(t)) {
case T_USER:
- Printf(fcall,");");
+ Printf(fcall,");\n");
break;
case T_REFERENCE:
Printf(fcall,";\n");
@@ -797,6 +818,7 @@ Swig_cmemberset_wrapper(String_or_char *classname,
Parm *p;
SwigType *t;
SwigType *lt;
+ SwigType *ty;
w = NewWrapper();
@@ -810,7 +832,9 @@ Swig_cmemberset_wrapper(String_or_char *classname,
Delete(t);
lt = Swig_clocal_type(type);
- p = NewParm(lt,"value");
+ ty = Swig_wrapped_var_type(type);
+ p = NewParm(ty,"value");
+
Setnext(l,p);
/* Printf(w->def,"%s %s(%s) {", SwigType_str(lt,0), Wrapper_Getname(w), ParmList_str(l)); */
@@ -829,6 +853,7 @@ Swig_cmemberset_wrapper(String_or_char *classname,
Wrapper_Setparms(w,l);
Delete(l);
Delete(lt);
+ Delete(ty);
return w;
}
@@ -850,6 +875,7 @@ Swig_cmemberget_wrapper(String_or_char *classname,
Parm *p;
SwigType *t;
SwigType *lt;
+ SwigType *ty;
w = NewWrapper();
@@ -872,10 +898,13 @@ Swig_cmemberget_wrapper(String_or_char *classname,
Printv(w->code, code, "\n", 0);
}
Printf(w->code,"}\n");
- Wrapper_Settype(w,lt);
+ ty = Swig_wrapped_var_type(type);
+ Wrapper_Settype(w,ty);
+
Wrapper_Setparms(w,l);
Delete(l);
Delete(lt);
+ Delete(ty);
return w;
}
@@ -894,6 +923,7 @@ Swig_cvarset_wrapper(String_or_char *varname,
ParmList *l;
Parm *p;
SwigType *lt;
+ SwigType *ty;
w = NewWrapper();
@@ -901,15 +931,16 @@ Swig_cvarset_wrapper(String_or_char *varname,
Wrapper_Setname(w,Swig_name_set(varname));
lt = Swig_clocal_type(type);
- p = NewParm(lt,"value");
+ ty = Swig_wrapped_var_type(type);
+ p = NewParm(ty,"value");
l = p;
- Printf(w->def,"%s %s(%s) {", SwigType_str(lt,0), Wrapper_Getname(w), ParmList_str(l));
+/* Printf(w->def,"%s %s(%s) {", SwigType_str(lt,0), Wrapper_Getname(w), ParmList_str(l));*/
+ Printf(w->def,"void %s(%s) {", Wrapper_Getname(w), ParmList_str(l));
if (!code) {
/* No code supplied. Write a function manually */
- Printf(w->code,"%s = %s;\n", varname, Swig_clocal_deref(lt,"value"));
- Printf(w->code,"return %s;\n", Swig_clocal_assign(lt,varname));
+ Printf(w->code,"%s = %s;\n", varname, Swig_clocal_deref(type,"value"));
} else {
Printv(w->code, code, "\n", 0);
Replace(w->code,"$target",varname, DOH_REPLACE_ANY);
@@ -918,10 +949,11 @@ Swig_cvarset_wrapper(String_or_char *varname,
Replace(w->code,"$rtype", SwigType_str(type,""), DOH_REPLACE_ANY);
}
Printf(w->code,"}\n");
- Wrapper_Settype(w,lt);
+ Wrapper_Settype(w,"void");
Wrapper_Setparms(w,l);
Delete(l);
Delete(lt);
+ Delete(ty);
return w;
}
@@ -939,6 +971,7 @@ Swig_cvarget_wrapper(String_or_char *varname,
Wrapper *w;
ParmList *l = 0;
SwigType *lt;
+ SwigType *ty;
w = NewWrapper();
@@ -956,10 +989,12 @@ Swig_cvarget_wrapper(String_or_char *varname,
Printv(w->code, code, "\n", 0);
}
Printf(w->code,"}\n");
- Wrapper_Settype(w,lt);
+ ty = Swig_wrapped_var_type(type);
+ Wrapper_Settype(w,ty);
Wrapper_Setparms(w,l);
Delete(l);
Delete(lt);
+ Delete(ty);
return w;
}
diff --git a/SWIG/Source/Swig/misc.c b/SWIG/Source/Swig/misc.c
index bd4de2e82..74899a5d3 100644
--- a/SWIG/Source/Swig/misc.c
+++ b/SWIG/Source/Swig/misc.c
@@ -42,13 +42,13 @@ Swig_banner(File *f) {
Printf(f,
"/* ----------------------------------------------------------------------------\n\
* This file was automatically generated by SWIG (http://www.swig.org).\n\
- * Version %s %s\n\
+ * Version %s\n\
* \n\
* This file is not intended to be easily readable and contains a number of \n\
* coding conventions designed to improve portability and efficiency. Do not make\n\
* changes to this file unless you know what you are doing--modify the SWIG \n\
* interface file instead. \n\
- * ----------------------------------------------------------------------------- */\n\n", SWIG_VERSION, SWIG_SPIN);
+ * ----------------------------------------------------------------------------- */\n\n", SWIG_VERSION);
}
diff --git a/SWIG/Source/Swig/stype.c b/SWIG/Source/Swig/stype.c
index 6618ea7a6..8047cd1c1 100644
--- a/SWIG/Source/Swig/stype.c
+++ b/SWIG/Source/Swig/stype.c
@@ -812,6 +812,8 @@ SwigType_lstr(SwigType *s, const String_or_char *id)
Append(result,")");
Delete(parms);
} else if (SwigType_isqualifier(element)) {
+ } else if (SwigType_isenum(element)) {
+ Insert(result,0," int ");
} else {
Insert(result,0," ");
Insert(result,0,element);
@@ -1329,6 +1331,8 @@ int SwigType_type(SwigType *t)
if (strcmp(c,"double") == 0) return T_DOUBLE;
if (strcmp(c,"void") == 0) return T_VOID;
if (strcmp(c,"bool") == 0) return T_BOOL;
+ if (strcmp(c,"long long") == 0) return T_LONGLONG;
+ if (strcmp(c,"unsigned long long") == 0) return T_ULONGLONG;
if (strncmp(c,"enum ",5) == 0) return T_INT;
/* Hmmm. Unknown type */
if (SwigType_istypedef(t)) {
diff --git a/SWIG/Source/Swig/swig.h b/SWIG/Source/Swig/swig.h
index 30ceae6c2..d32eb2125 100644
--- a/SWIG/Source/Swig/swig.h
+++ b/SWIG/Source/Swig/swig.h
@@ -47,6 +47,8 @@ typedef DOH File;
#define T_CHAR 12
#define T_USER 13
#define T_VOID 14
+#define T_LONGLONG 15
+#define T_ULONGLONG 16
#define T_STRING 20
#define T_POINTER 21
#define T_REFERENCE 22
diff --git a/SWIG/Source/Swig/typemap.c b/SWIG/Source/Swig/typemap.c
index d71d37a00..2a6af339e 100644
--- a/SWIG/Source/Swig/typemap.c
+++ b/SWIG/Source/Swig/typemap.c
@@ -329,7 +329,14 @@ Swig_typemap_search(char *op, SwigType *type, String_or_char *name) {
if (!primitive)
primitive = SwigType_default(type);
tm = Getattr(typemaps[ts],primitive);
- if (tm) {
+ if (tm && cname) {
+ tm1 = Getattr(tm,cname);
+ if (tm1) {
+ result = Getattr(tm1,op); /* See if there is a type-name match */
+ if (result) goto ret_result;
+ }
+ }
+ if (tm) { /* See if there is simply a type match */
result = Getattr(tm,op);
if (result) goto ret_result;
}
diff --git a/SWIG/TODO b/SWIG/TODO
index d05e675e1..d18bb9baf 100644
--- a/SWIG/TODO
+++ b/SWIG/TODO
@@ -1,25 +1,84 @@
-*- outline -*-
-* for 1.3a4 release
+* for release 1.3.6
-** [ttn] add test-suite based on Examples
+** Testing
-[open] The behavior of SWIG with respect to call/return-by-value needs
- to be verified for all language modules. Previously, the
+* for release 1.3.7
+
+** Discuss the %pragma directive syntax change from CVS head.
+ Why is the syntax changing all the time? Can't we just stick to
+ the syntax in 1.3a5?
+
+** Maybe port other parser-related stuff from CVS head
+
+** Maybe get the 10/14/00 changes from CVS head
+
+** Fix all the bugs on SourceForge
+
+** Incorporate all the patches on SourceForge
+
+** Make a proper test suite with both language-independent and language-dependent tests.
+ The directories Examples/guile/test-suite, Examples/perl5/pointer-cxx, Examples/C++
+ contain some material that can be used.
+
+* eventually
+
+** Revive the documentation
+
+** Maybe use libtool rather than all the home-grown compile/link stuff
+
+** The behavior of SWIG with respect to call/return-by-value needs
+ to be verified for all language modules. Previously, the
parser automatically performed the conversion of pass-by-value
to pass-by-reference. Unfortunately, this confused typemap
handling and other aspects of the system. I have removed
this behavior. However, in doing so, the handling of user
defined types is passed on to the language modules.
-[open] All of the SWIG 1.1p5 examples need to be verified. Changes
+** All of the SWIG 1.1p5 examples need to be verified. Changes
in type handling and internal data structures may have broken
a variety of things.
-* for 1.3a5 release
+** [Guile] New %pragma "documentation", which allows to attach documentation
+ strings to a procedure.
+
+** [Guile] Maybe support keyword args
+
+** [Guile] Maybe support GOOPS shadow classes
+
+** [Guile] Support garbage collection.
+
+*** %new annotation decides whether a pointer smob can be gc'ed.
+
+*** New smob type `swig-gc'; instances created with
+ SWIG_Guile_MakeCollectablePtr. %new versions of the pointer
+ typemaps use this function rather than SWIG_Guile_MakePtr.
+
+*** New typemaps "destructor", "gcmarker". Their values are taken as
+ identifiers for functions taking one argument: a pointer to the
+ object to be destroyed, or whose SCM-valued subobjects are to be
+ marked. After creating the pointer equivalence table, we iterate
+ again over the remembered pointer types, emitting code that puts
+ the functions into our type table. No additional functions are
+ generated.
+
+*** The default for all pointer types would be:
+ %typemap(destructor) SWIGPOINTER * "free";
+
+*** A special annotation, e.g. FREED, can be attached to the arguments
+ of destructor functions, so that explicitly freed structs won't be
+ collected by the GC again. Like this:
-* for 1.3b1 release
+ %typemap(argout) SWIGPOINTER *FREED {
+ smob-tag($source) = swig; /* non-gc */
+ smob-data($source) = NULL;
+ }
+ void free_foo(struct foo *FREED);
+
+** Make a tricky header file defining annotations invisible to the C compiler.
+ The idea is to prepare one file that serves both as a C header file
+ and a SWIG interface file.
-* for 1.3b2 release
+ void add(SWIG_OUTPUT(int) *z, int x, int y)
-* for 2.x release
diff --git a/SWIG/Tools/.cvsignore b/SWIG/Tools/.cvsignore
new file mode 100644
index 000000000..343f52205
--- /dev/null
+++ b/SWIG/Tools/.cvsignore
@@ -0,0 +1,4 @@
+config.log
+config.status
+configure
+libtool
diff --git a/SWIG/VERSION b/SWIG/VERSION
index d16435bb6..4b20c77c9 100644
--- a/SWIG/VERSION
+++ b/SWIG/VERSION
@@ -14,10 +14,10 @@
devrelease_today=u-`date +%Y%m%d-%H%M`
SWIG_MAJOR_VERSION=1
-SWIG_MINOR_VERSION=3$devrelease_today
+SWIG_MINOR_VERSION=3
+SWIG_SPIN=6
-SWIG_VERSION=$SWIG_MAJOR_VERSION.$SWIG_MINOR_VERSION
-SWIG_SPIN='(Alpha 5)'
+SWIG_VERSION=$SWIG_MAJOR_VERSION.$SWIG_MINOR_VERSION.$SWIG_SPIN$devrelease_today
# For autoconf.
VERSION=$SWIG_VERSION
diff --git a/SWIG/autogen.sh b/SWIG/autogen.sh
new file mode 100755
index 000000000..65baeb520
--- /dev/null
+++ b/SWIG/autogen.sh
@@ -0,0 +1,6 @@
+#! /bin/sh
+# Bootstrap the development environment
+autoconf
+(cd Source/DOH; autoconf)
+(cd Tools; autoconf)
+(cd Examples/GIFPlot; autoconf)
diff --git a/SWIG/configure.in b/SWIG/configure.in
index a4b3342b5..faca60444 100644
--- a/SWIG/configure.in
+++ b/SWIG/configure.in
@@ -61,6 +61,8 @@ dnl Checks for library functions.
AC_SUBST(SO)
AC_SUBST(LDSHARED)
AC_SUBST(CCSHARED)
+AC_SUBST(CXXSHARED)
+AC_SUBST(TRYLINKINGWITHCXX)
AC_SUBST(LINKFORSHARED)
# SO is the extension of shared libraries `(including the dot!)
@@ -83,6 +85,8 @@ if test -z "$LDSHARED"
then
case $ac_sys_system/$ac_sys_release in
AIX*) LDSHARED="\$(srcdir)/ld_so_aix \$(CC)";;
+ # cygwin uses dllwrap to create shared libraries
+ CYGWIN*) LDSHARED="dllwrap --target=cygwin --as=as --dlltool-name=dlltool --driver-name=$CC --export-all -s ";;
IRIX/5*) LDSHARED="ld -shared";;
IRIX*/6*) LDSHARED="ld ${SGI_ABI} -shared -all";;
SunOS/4*) LDSHARED="ld";;
@@ -114,6 +118,32 @@ then
esac
fi
AC_MSG_RESULT($LDSHARED)
+# CXXSHARED is the ld *command* used to create C++ shared library
+# -- "ld" on SunOS 4.x.x, "ld -G" on SunOS 5.x, "ld -shared" on IRIX 5
+# (Shared libraries in this instance are shared modules to be loaded into
+# Python, as opposed to building Python itself as a shared library.)
+AC_MSG_CHECKING(CXXSHARED)
+if test -z "$CXXSHARED"
+then
+ case $ac_sys_system/$ac_sys_release in
+ # cygwin uses dllwrap to create shared libraries
+ CYGWIN*) CXXSHARED="dllwrap --target=cygwin --as=as --dlltool-name=dlltool --driver-name=$CXX --export-all -s ";;
+ # all other platforms make no distinction between C and C++ shared libraries
+ *) CXXSHARED="$LDSHARED";;
+ esac
+fi
+AC_MSG_RESULT($CXXSHARED)
+#
+AC_MSG_CHECKING(TRYLINKINGWITHCXX)
+if test -z "$TRYLINKINGWITHCXX"
+then
+ case $ac_sys_system/$ac_sys_release in
+ # cygwin uses dllwrap to create shared libraries
+ CYGWIN*) TRYLINKINGWITHCXX="# Not for CYGWIN: CXXSHARED= $CXX -shared ";;
+ *) TRYLINKINGWITHCXX="CXXSHARED= $CXX -shared ";;
+ esac
+fi
+AC_MSG_RESULT($TRYLINKINGWITHCXX)
# CCSHARED are the C *flags* used to create objects to go into a shared
# library (module) -- this is only needed for a few systems
AC_MSG_CHECKING(CCSHARED)
@@ -145,10 +175,10 @@ AC_MSG_CHECKING(RPATH)
if test -z "$RPATH"
then
case $ac_sys_system/$ac_sys_release in
- SunOS/5*) RPATH="-R. -R$(exec_prefix)/lib";;
- IRIX*) RPATH="-rpath .:$(exec_prefix)/lib";;
- Linux*) RPATH="-Xlinker -rpath $(exec_prefix)/lib -Xlinker -rpath .";;
- *) RPATH="";;
+ SunOS/5*) RPATH='-R. -R$(exec_prefix)/lib';;
+ IRIX*) RPATH='-rpath .:$(exec_prefix)/lib';;
+ Linux*) RPATH='-Xlinker -rpath $(exec_prefix)/lib -Xlinker -rpath .';;
+ *) RPATH='';;
esac
fi
AC_MSG_RESULT($RPATH)
@@ -298,6 +328,8 @@ TCLINCLUDE=
TCLLIB=
TCLPACKAGE=
+AC_ARG_WITH(tclconfig,[ --with-tclconfig=path Set location of tclConfig.sh],
+ with_tclconfig="$withval")
AC_ARG_WITH(tcl,[ --with-tcl=path Set location of Tcl package],[
TCLPACKAGE="$withval"], [TCLPACKAGE=])
AC_ARG_WITH(tclincl,[ --with-tclincl=path Set location of Tcl include directory],[
@@ -305,6 +337,35 @@ AC_ARG_WITH(tclincl,[ --with-tclincl=path Set location of Tcl include direc
AC_ARG_WITH(tcllib,[ --with-tcllib=path Set location of Tcl library directory],[
TCLLIB="-L$withval"], [TCLLIB=])
+AC_MSG_CHECKING([for Tcl configuration])
+# First check to see if --with-tclconfig was specified.
+if test x"${with_tclconfig}" != x ; then
+ if test -f "${with_tclconfig}/tclConfig.sh" ; then
+ TCLCONFIG=`(cd ${with_tclconfig}; pwd)`
+ else
+ AC_MSG_ERROR([${with_tcl} directory doesn't contain tclConfig.sh])
+ fi
+fi
+# check in a few common install locations
+if test x"${TCLCONFIG}" = x ; then
+ for i in `ls -d /usr/lib 2>/dev/null` \
+ `ls -d ${prefix}/lib 2>/dev/null` \
+ `ls -d /usr/local/lib 2>/dev/null` ; do
+ if test -f "$i/tclConfig.sh" ; then
+ TCLCONFIG=`(cd $i; pwd)`
+ break
+ fi
+ done
+fi
+if test x"${TCLCONFIG}" = x ; then
+ AC_MSG_RESULT(no)
+else
+ AC_MSG_RESULT(found $TCLCONFIG/tclConfig.sh)
+ . $TCLCONFIG/tclConfig.sh
+ TCLINCLUDE=-I$TCL_PREFIX/include
+ TCLLIB=$TCL_LIB_SPEC
+fi
+
if test -z "$TCLINCLUDE"; then
if test -n "$TCLPACKAGE"; then
TCLINCLUDE="-I$TCLPACKAGE/include"
@@ -313,7 +374,7 @@ fi
if test -z "$TCLLIB"; then
if test -n "$TCLPACKAGE"; then
- TCLLIB="-L$TCLPACKAGE/lib"
+ TCLLIB="-L$TCLPACKAGE/lib -ltcl"
fi
fi
@@ -331,7 +392,7 @@ if test -z "$TCLINCLUDE"; then
done
fi
if test -z "$TCLINCLUDE"; then
- TCLINCLUDE="-I/usr/local/include"
+# TCLINCLUDE="-I/usr/local/include"
AC_MSG_RESULT(not found)
fi
else
@@ -344,13 +405,13 @@ dirs="$prefix/lib /usr/local/lib /usr/lib /opt/local/lib /home/sci/local/lib"
for i in $dirs ; do
if test -r $i/libtcl.a; then
AC_MSG_RESULT($i)
- TCLLIB="-L$i"
+ TCLLIB="-L$i -ltcl"
break
fi
done
if test -z "$TCLLIB"; then
AC_MSG_RESULT(not found)
- TCLLIB="-L/usr/local/lib"
+# TCLLIB="-L/usr/local/lib"
fi
else
AC_MSG_RESULT($TCLLIB)
@@ -390,7 +451,7 @@ fi
AC_MSG_CHECKING(for Python header files)
-dirs="$PYINCLUDE $PYINCLUDE/python1.6 $PYINCLUDE/python1.5 $PYINCLUDE/python1.4 $PYINCLUDE/Py $prefix=/include/python1.6 $prefix/include/python1.5 $prefix/include/python1.4 /usr/local/include/python1.6 /usr/local/include/python1.5 /usr/include/python1.5 /usr/local/include/python1.4 /usr/include/python1.4 $prefix/include/Py /usr/local/include/Py /usr/include/Py"
+dirs="$PYINCLUDE $PYINCLUDE/python2.1 $PYINCLUDE/python2.0 $PYINCLUDE/python1.6 $PYINCLUDE/python1.5 $PYINCLUDE/python1.4 $PYINCLUDE/Py $prefix/include/python2.1 $prefix/include/python2.0 $prefix/include/python1.6 $prefix/include/python1.5 $prefix/include/python1.4 /usr/local/include/python2.1 /usr/local/include/python2.0 /usr/local/include/python1.6 /usr/local/include/python1.5 /usr/include/python1.5 /usr/local/include/python1.4 /usr/include/python1.4 $prefix/include/Py /usr/local/include/Py /usr/include/Py"
for i in $dirs ; do
if test -r $i/Python.h; then
AC_MSG_RESULT($i)
@@ -399,14 +460,28 @@ for i in $dirs ; do
fi
done
if test -z "$PYINCLUDE"; then
- PYINCLUDE="-I/usr/local/include/Py"
+# PYINCLUDE="-I/usr/local/include/Py"
AC_MSG_RESULT(not found)
fi
AC_MSG_CHECKING(for Python library)
-dirs="$PYLIB $PYLIB/config $PYLIB/lib $PYLIB/python1.6/config $PYLIB/python1.5/config $PYLIB/python1.4/config $PYLIB/python/lib $prefix/lib/python1.6/config $prefix/lib/python1.5/config $prefix/lib/python1.4/config /usr/local/lib/python1.6/config /usr/local/lib/python1.5/config /usr/lib/python1.5 /usr/local/lib/python1.4/config /usr/lib/python1.4 $prefix/lib/python/lib /usr/local/lib/python/lib /usr/lib/python/lib /home/sci/local/lib/python"
+dirs="$PYLIB $PYLIB/config $PYLIB/lib $PYLIB/python2.1/config $PYLIB/python2.0/config $PYLIB/python1.6/config $PYLIB/python1.5/config $PYLIB/python1.4/config $PYLIB/python/lib $prefix/lib/python2.1/config $prefix/lib/python2.0/config $prefix/lib/python1.6/config $prefix/lib/python1.5/config $prefix/lib/python1.4/config /usr/local/lib/python2.1/config /usr/local/lib/python2.0/config /usr/local/lib/python1.6/config /usr/local/lib/python1.5/config /usr/lib/python1.5/config /usr/lib/python1.5 /usr/local/lib/python1.4/config /usr/lib/python1.4/config /usr/lib/python1.4 $prefix/lib/python/lib /usr/local/lib/python/lib /usr/lib/python/lib /home/sci/local/lib/python"
for i in $dirs ; do
+ if test -r $i/libpython2.1.a; then
+ AC_MSG_RESULT($i)
+ PYLIB="$i"
+ PYINCLUDE="$PYINCLUDE -I$i"
+ PYLINK="-lpython2.1"
+ break
+ fi
+ if test -r $i/libpython2.0.a; then
+ AC_MSG_RESULT($i)
+ PYLIB="$i"
+ PYINCLUDE="$PYINCLUDE -I$i"
+ PYLINK="-lpython2.0"
+ break
+ fi
if test -r $i/libpython1.6.a; then
AC_MSG_RESULT($i)
PYLIB="$i"
@@ -430,8 +505,8 @@ for i in $dirs ; do
done
if test -z "$PYLIB"; then
AC_MSG_RESULT(not found)
- PYLIB="/usr/local/lib/python/lib"
- PYINCLUDE="$PYINCLUDE -I$PYLIB"
+# PYLIB="/usr/local/lib/python/lib"
+# PYINCLUDE="$PYINCLUDE -I$PYLIB"
fi
AC_SUBST(PYINCLUDE)
@@ -449,7 +524,7 @@ AC_ARG_WITH(perl5,[ --with-perl5=path Set location of Perl5 executable],[
# First figure out what the name of Perl5 is
if test -z "$PERLBIN"; then
-AC_CHECK_PROGS(PERL, perl5.004 perl5.003 perl5.002 perl5.001 perl5 perl)
+AC_CHECK_PROGS(PERL, perl5.6.1 perl5.6.0 perl5.004 perl5.003 perl5.002 perl5.001 perl5 perl)
else
PERL="$PERLBIN"
fi
@@ -476,7 +551,7 @@ if test -n "$PERL"; then
fi
else
AC_MSG_RESULT(could not figure out how to run perl5)
- PERL5EXT="/usr/local/lib/perl/archname/5.003/CORE"
+# PERL5EXT="/usr/local/lib/perl/archname/5.003/CORE"
fi
AC_SUBST(PERL5EXT)
@@ -582,7 +657,7 @@ if test -n "$GUILE_CONFIG" ; then
fi
done
if test -z "$GUILEINCLUDE"; then
- GUILEINCLUDE="-I/usr/local/include"
+# GUILEINCLUDE="-I/usr/local/include"
AC_MSG_RESULT(not found)
fi
@@ -597,7 +672,7 @@ if test -n "$GUILE_CONFIG" ; then
done
if test -z "$GUILELIB"; then
AC_MSG_RESULT(not found)
- GUILELIB="/usr/local/lib"
+# GUILELIB="/usr/local/lib"
fi
GUILELINK="`guile-config link`"
@@ -630,8 +705,9 @@ else
RUBY="$RUBYBIN"
fi
AC_MSG_CHECKING(for Ruby header files)
+RUBYLIBRUBYARG=""
if test -n "$RUBY"; then
- RUBYDIR=`($RUBY -rmkmf -e 'print $archdir') 2>/dev/null`
+ RUBYDIR=`($RUBY -rmkmf -e 'print Config::CONFIG[["archdir"]] || $archdir') 2>/dev/null`
if test "$RUBYDIR" != ""; then
dirs="$RUBYDIR"
RUBYINCLUDE=none
@@ -650,7 +726,8 @@ if test -n "$RUBY"; then
AC_MSG_CHECKING(for Ruby library)
RUBYLIB=none
for i in $dirs; do
- if test -r $i/libruby.a; then
+ # cygwin produces "librubys.a" instead of "libruby.a"
+ if ((test -r $i/libruby.a;) || (test -r $i/librubys.a;)) then
AC_MSG_RESULT($i)
RUBYLIB="$i"
break;
@@ -668,6 +745,12 @@ if test -n "$RUBY"; then
RUBYLINK=`($RUBY -rrbconfig -e 'print Config::CONFIG[["RUBY_INSTALL_NAME"]]') 2>/dev/null`
RUBYLINK="-l$RUBYLINK"
RUBYLINK="$RUBYLINK `($RUBY -rrbconfig -e 'print Config::CONFIG[["LIBS"]]') 2>/dev/null`"
+ RUBYCCDLFLAGS=`($RUBY -rrbconfig -e 'print Config::CONFIG[["CCDLFLAGS"]]') 2>/dev/null`
+ # At least for cygwin the following arguments can be extracted from the CONFIG-hash
+ case $ac_sys_system/$ac_sys_release in
+ CYGWIN*) RUBYLIBRUBYARG=`($RUBY -rrbconfig -e 'print Config::CONFIG[["LIBRUBYARG"]]') 2>/dev/null`;;
+ *) RUBYLIBRUBYARG="";;
+ esac
else
AC_MSG_RESULT(could not figure out how to run ruby)
RUBYINCLUDE="-I/usr/local/lib/ruby/1.4/arch"
@@ -678,7 +761,21 @@ fi
AC_SUBST(RUBYINCLUDE)
AC_SUBST(RUBYLIB)
AC_SUBST(RUBYLINK)
+AC_SUBST(RUBYCCDLFLAGS)
+AC_SUBST(RUBYLIBRUBYARG)
+
+# Configure SWIG_LIB path
+AC_ARG_WITH(swiglibdir,[ --with-swiglibdir=DIR Put SWIG system-independent libraries into DIR.],
+ [swig_lib="$withval"], [swig_lib="\$(prefix)/lib/swig1.3"])
+AC_SUBST(swig_lib)
+
+# Configure RELEASESUFFIX (for setups having both SWIG 1.1 and 1.3 on a system...)
+
+AC_ARG_WITH(release-suffix,
+ [ --with-release-suffix=SUFFIX Attach SUFFIX to the binary and the runtime libs. ],
+ [release_suffix="$withval"], [release_suffix=""])
+AC_SUBST(release_suffix)
#----------------------------------------------------------------
# Miscellaneous
@@ -705,12 +802,16 @@ if test ! -r $srcdir/Tools/configure ; then
(cd $srcdir/Tools ; autoconf)
fi
+if test ! -r $srcdir/Examples/GIFPlot/configure ; then
+ (cd $srcdir/Examples/GIFPlot ; autoconf)
+fi
+
#
#AC_OUTPUT_COMMANDS(test -f Examples/install-sh || cp install-sh Examples)
# DB: Maybe I'm missings something, but why is it necessary to put
# an 'install-sh' script in the Examples directory?
-AC_CONFIG_SUBDIRS(Source/DOH Tools)
+AC_CONFIG_SUBDIRS(Source/DOH Tools Examples/GIFPlot)
# NOTE: The following ref to `Source' should NOT be prefixed w/ `$srcdir/'.
# We can remove it if `Source' ever has a generated file but not before.
@@ -721,10 +822,9 @@ configure_substituted_files=`echo \
Examples/Makefile \
Examples/C++/test_conf.py \
Examples/guile/Makefile \
+ Examples/guile/test-suite/Makefile \
Makefile \
Runtime/Makefile \
- Source/Experiment/Makefile \
- Source/Include/swigconfig.h \
Source/Include/swigver.h \
Source/LParse/Makefile \
Source/Modules/Makefile \
diff --git a/SWIG/debian/.cvsignore b/SWIG/debian/.cvsignore
new file mode 100644
index 000000000..62abe9f21
--- /dev/null
+++ b/SWIG/debian/.cvsignore
@@ -0,0 +1 @@
+*.debhelper
diff --git a/SWIG/debian/README b/SWIG/debian/README
new file mode 100644
index 000000000..9cbe96a3c
--- /dev/null
+++ b/SWIG/debian/README
@@ -0,0 +1,20 @@
+The Debian Package swig1.3
+--------------------------
+
+This is SWIG 1.3 (Simplified Wrapper and Interface Generator)
+packaged for Debian GNU/Linux.
+
+SWIG 1.3 is not fully compatible with SWIG 1.1. It is a re-development
+effort of SWIG 1.1 (which was written in C++) in ANSI C. The 1.3
+series is in "alpha" state. Release 1.3a5 was rather stable, and it
+should be used for new projects rather than the ancient release
+1.1p5. See the file `NEW' for information on the new features of the
+1.3 series.
+
+This Debian package derives from the release 1.3a5 and corresponds to
+the "mkoeppe-1-3-a5-patches" branch of the SWIG CVS repository. It
+fixes several bugs and enhances several language backends. See the
+top of the file `CHANGES' for details.
+
+
+Matthias Koeppe <mkoeppe@mail.math.uni-magdeburg.de>, Mon, 28 May 2001 15:08:55 +0200
diff --git a/SWIG/debian/changelog b/SWIG/debian/changelog
new file mode 100644
index 000000000..0caee090a
--- /dev/null
+++ b/SWIG/debian/changelog
@@ -0,0 +1,60 @@
+swig1.3 (1.3.a5+patches-9) unstable; urgency=low
+
+ * New upstream version
+
+ -- Matthias Koeppe <mkoeppe@rotehorn.math.uni-magdeburg.de> Wed, 6 Jun 2001 16:11:41 +0200
+
+swig1.3 (1.3.a5+patches-8) unstable; urgency=low
+
+ * New upstream version
+
+ -- Matthias Koeppe <mkoeppe@rotehorn.math.uni-magdeburg.de> Wed, 6 Jun 2001 14:06:51 +0200
+
+swig1.3 (1.3.a5+patches-7) unstable; urgency=low
+
+ * New upstream version
+
+ -- Matthias Koeppe <mkoeppe@rotehorn.math.uni-magdeburg.de> Wed, 6 Jun 2001 13:34:44 +0200
+
+swig1.3 (1.3.a5+patches-6) unstable; urgency=low
+
+ * New upstream version
+
+ -- Matthias Koeppe <mkoeppe@rotehorn.math.uni-magdeburg.de> Tue, 5 Jun 2001 14:11:52 +0200
+
+swig1.3 (1.3.a5+patches-5) unstable; urgency=low
+
+ * New upstream version.
+
+ -- Matthias Koeppe <mkoeppe@rotehorn.math.uni-magdeburg.de> Fri, 1 Jun 2001 18:48:59 +0200
+
+swig1.3 (1.3.a5+patches-4) unstable; urgency=low
+
+ * Fix hard-coded location of swig library. Added build-dependency on
+ tcl-dev.
+
+ -- Matthias Koeppe <mkoeppe@rotehorn.math.uni-magdeburg.de> Fri, 1 Jun 2001 13:32:34 +0200
+
+swig1.3 (1.3.a5+patches-3) unstable; urgency=low
+
+ * New upstream version
+
+ -- Matthias Koeppe <mkoeppe@rotehorn.math.uni-magdeburg.de> Thu, 31 May 2001 13:15:20 +0200
+
+swig1.3 (1.3.a5+patches-2) unstable; urgency=low
+
+ * Binary and manpage now include version number, to improve
+ cooperation with the "swig" package.
+
+ -- Matthias Koeppe <mkoeppe@rotehorn.math.uni-magdeburg.de> Tue, 29 May 2001 15:15:07 +0200
+
+swig1.3 (1.3.a5+patches-1) unstable; urgency=low
+
+ * First release.
+
+ -- Matthias Koeppe <mkoeppe@mail.math.uni-magdeburg.de> Sat, 20 Nov 1999 01:09:11 +0100
+
+Local variables:
+mode: debian-changelog
+add-log-mailing-address: "mkoeppe@mail.math.uni-magdeburg.de"
+End: \ No newline at end of file
diff --git a/SWIG/debian/control b/SWIG/debian/control
new file mode 100644
index 000000000..80e0a7017
--- /dev/null
+++ b/SWIG/debian/control
@@ -0,0 +1,18 @@
+Source: swig1.3
+Section: interpreters
+Priority: optional
+Maintainer: Matthias Koeppe <mkoeppe@mail.math.uni-magdeburg.de>
+Build-Depends: debhelper (>> 3.0.0), libguile-dev, python-dev, perl,
+ ruby-dev, ruby, tcl8.0-dev
+Standards-Version: 3.5.2
+
+Package: swig1.3
+Architecture: any
+Depends: ${shlibs:Depends}
+Description: Generate scripting interfaces to C/C++ code
+ SWIG (Simplified Wrapper and Interface Generator) is a system for
+ automatically generating wrapper/glue code for several languages
+ (Tcl, Python, Perl, Ruby, MzScheme, Guile, Java) from annotated C or
+ C++ header files.
+ This package represents some point in the SWIG 1.3 development
+ series. It is not fully compatible with the SWIG 1.1 release.
diff --git a/SWIG/debian/copyright b/SWIG/debian/copyright
new file mode 100644
index 000000000..8cb86922e
--- /dev/null
+++ b/SWIG/debian/copyright
@@ -0,0 +1,83 @@
+This is SWIG, written and maintained by:
+
+ Dave Beazley (beazley@cs.uchicago.edu) (SWIG core)
+ Loic Dachary (loic@ceic.com) (Perl5)
+ Harco de Hilster (Harco.de.Hilster@ATComputing.nl) (Java)
+ Thien-Thi Nguyen (ttn@glug.org) (Testing/Misc)
+ Masaki Fukushima (fukusima@goto.info.waseda.ac.jp) (Ruby)
+ Matthias Koeppe (mkoeppe@mail.math.uni-magdeburg.de) (Guile/MzScheme)
+
+Past contributors:
+
+ Dustin Mitchell, Ian Cooke, Catalin Dumitrescu, Baran Kovuk, Gary Holt,
+ David Fletcher, Oleg Tolmatcev.
+
+SWIG can be obtained by anonymous CVS:
+
+ cvs -d :pserver:cvs@swig.cs.uchicago.edu:/cvsroot co SWIG
+
+SWIG is distributed under the following terms:
+
+I.
+
+Copyright (C) 1998-2000
+The University of Chicago
+
+Permission is hereby granted, without written agreement and without
+license or royalty fees, to use, copy, modify, and distribute this
+software and its documentation for any purpose, provided that
+(1) The above copyright notice and the following two paragraphs
+appear in all copies of the source code and (2) redistributions
+including binaries reproduces these notices in the supporting
+documentation. Substantial modifications to this software may be
+copyrighted by their authors and need not follow the licensing terms
+described here, provided that the new terms are clearly indicated in
+all files where they apply.
+
+IN NO EVENT SHALL THE AUTHOR, THE UNIVERSITY OF CHICAGO, OR
+DISTRIBUTORS OF THIS SOFTWARE BE LIABLE TO ANY PARTY FOR DIRECT,
+INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
+THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE AUTHORS OR
+ANY OF THE ABOVE PARTIES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGE.
+
+THE AUTHOR AND THE UNIVERSITY OF CHICAGO SPECIFICALLY DISCLAIM ANY
+WARRANTIES,INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
+PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE AUTHORS AND
+DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT,
+UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+
+
+II.
+
+Copyright (c) 1995-1998
+The University of Utah and the Regents of the University of California
+All Rights Reserved
+
+Permission is hereby granted, without written agreement and without
+license or royalty fees, to use, copy, modify, and distribute this
+software and its documentation for any purpose, provided that
+(1) The above copyright notice and the following two paragraphs
+appear in all copies of the source code and (2) redistributions
+including binaries reproduces these notices in the supporting
+documentation. Substantial modifications to this software may be
+copyrighted by their authors and need not follow the licensing terms
+described here, provided that the new terms are clearly indicated in
+all files where they apply.
+
+IN NO EVENT SHALL THE AUTHOR, THE UNIVERSITY OF CALIFORNIA, THE
+UNIVERSITY OF UTAH OR DISTRIBUTORS OF THIS SOFTWARE BE LIABLE TO ANY
+PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION,
+EVEN IF THE AUTHORS OR ANY OF THE ABOVE PARTIES HAVE BEEN ADVISED OF
+THE POSSIBILITY OF SUCH DAMAGE.
+
+THE AUTHOR, THE UNIVERSITY OF CALIFORNIA, AND THE UNIVERSITY OF UTAH
+SPECIFICALLY DISCLAIM ANY WARRANTIES,INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND
+THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE MAINTENANCE,
+SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+
+
diff --git a/SWIG/debian/dirs b/SWIG/debian/dirs
new file mode 100644
index 000000000..45b1a7422
--- /dev/null
+++ b/SWIG/debian/dirs
@@ -0,0 +1,4 @@
+usr/bin
+usr/lib
+usr/share/swig1.3
+usr/share/doc/swig1.3
diff --git a/SWIG/debian/docs b/SWIG/debian/docs
new file mode 100644
index 000000000..b6059c0f6
--- /dev/null
+++ b/SWIG/debian/docs
@@ -0,0 +1,10 @@
+README
+TODO
+ANNOUNCE
+CHANGES
+NEW
+Doc/engineering.html
+Doc/index.html
+Doc/internals.html
+Doc/migrate.txt
+Doc/whitepaper.html
diff --git a/SWIG/debian/postinst b/SWIG/debian/postinst
new file mode 100644
index 000000000..164b5ff1a
--- /dev/null
+++ b/SWIG/debian/postinst
@@ -0,0 +1,45 @@
+#! /bin/sh
+# postinst script for swig1.3
+#
+# see: dh_installdeb(1)
+
+set -e
+
+# summary of how this script can be called:
+# * <postinst> `configure' <most-recently-configured-version>
+# * <old-postinst> `abort-upgrade' <new version>
+# * <conflictor's-postinst> `abort-remove' `in-favour' <package>
+# <new-version>
+# * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
+# <failed-install-package> <version> `removing'
+# <conflicting-package> <version>
+# for details, see /usr/share/doc/packaging-manual/
+#
+# quoting from the policy:
+# Any necessary prompting should almost always be confined to the
+# post-installation script, and should be protected with a conditional
+# so that unnecessary prompting doesn't happen if a package's
+# installation fails and the `postinst' is called with `abort-upgrade',
+# `abort-remove' or `abort-deconfigure'.
+
+case "$1" in
+ configure)
+
+ ;;
+
+ abort-upgrade|abort-remove|abort-deconfigure)
+
+ ;;
+
+ *)
+ echo "postinst called with unknown argument \`$1'" >&2
+ exit 0
+ ;;
+esac
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+#DEBHELPER#
+
+exit 0
diff --git a/SWIG/debian/rules b/SWIG/debian/rules
new file mode 100755
index 000000000..b4df2d096
--- /dev/null
+++ b/SWIG/debian/rules
@@ -0,0 +1,76 @@
+#!/usr/bin/make -f
+# Sample debian/rules that uses debhelper.
+# GNU copyright 1997 to 1999 by Joey Hess.
+
+# Uncomment this to turn on verbose mode.
+export DH_VERBOSE=1
+
+# This is the debhelper compatability version to use.
+export DH_COMPAT=3
+
+configure: configure-stamp
+configure-stamp:
+ dh_testdir
+ ./autogen.sh
+ ./configure --prefix=/usr --mandir=/usr/share/man --with-swiglibdir=/usr/share/swig1.3 --with-release-suffix=-1.3
+ touch configure-stamp
+
+build: configure-stamp build-stamp
+build-stamp:
+ dh_testdir
+ $(MAKE)
+ $(MAKE) runtime
+ touch build-stamp
+
+clean:
+ dh_testdir
+ dh_testroot
+ rm -f build-stamp configure-stamp
+
+ -$(MAKE) clean
+
+ dh_clean
+
+install: build
+ dh_testdir
+ dh_testroot
+ dh_clean -k
+ dh_installdirs
+ $(MAKE) install DESTDIR=$(CURDIR)/debian/swig1.3
+
+# Build architecture-independent files here.
+binary-indep: build install
+# We have nothing to do by default.
+
+# Build architecture-dependent files here.
+binary-arch: build install
+ dh_testdir
+ dh_testroot
+# dh_installdebconf
+ dh_installdocs
+ dh_installexamples
+ dh_installmenu
+# dh_installlogrotate
+# dh_installemacsen
+# dh_installpam
+# dh_installmime
+# dh_installinit
+# dh_installcron
+ dh_installman
+ dh_installinfo
+ dh_undocumented swig-1.3.1
+ dh_installchangelogs CHANGES
+ dh_link
+ dh_strip
+ dh_compress
+ dh_fixperms
+ dh_makeshlibs
+ dh_installdeb
+# dh_perl
+ dh_shlibdeps
+ dh_gencontrol
+ dh_md5sums
+ dh_builddeb
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary install configure
diff --git a/SWIG/debian/substvars b/SWIG/debian/substvars
new file mode 100644
index 000000000..c9df68ba1
--- /dev/null
+++ b/SWIG/debian/substvars
@@ -0,0 +1 @@
+shlibs:Depends=libc6 (>= 2.2.3-1), libstdc++2.10-glibc2.2