Thousands of changes to correct incorrect HTML. HTML is now valid (transitional 4.01).

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@6074 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2004-08-04 21:28:14 +00:00
commit aa4d1d907d
31 changed files with 6754 additions and 4801 deletions

View file

@ -7,31 +7,31 @@
<body bgcolor="#ffffff">
<a name="n1"></a><H1>25 SWIG and Chicken</H1>
<H1><a name="Chicken"></a>17 SWIG and Chicken</H1>
<!-- INDEX -->
<ul>
<li><a href="#n2">Preliminaries</a>
<li><a href="#Chicken_nn2">Preliminaries</a>
<ul>
<li><a href="#n3">Running SWIG in C mode</a>
<li><a href="#n4">Running SWIG in C++ mode</a>
<li><a href="#Chicken_nn3">Running SWIG in C mode</a>
<li><a href="#Chicken_nn4">Running SWIG in C++ mode</a>
</ul>
<li><a href="#n5">Code Generation</a>
<li><a href="#Chicken_nn5">Code Generation</a>
<ul>
<li><a href="#n6">Naming Conventions</a>
<li><a href="#n7">Modules and Prefixes</a>
<li><a href="#n8">Constants and Variables</a>
<li><a href="#n9">Functions</a>
<li><a href="#Chicken_nn6">Naming Conventions</a>
<li><a href="#Chicken_nn7">Modules and Prefixes</a>
<li><a href="#Chicken_nn8">Constants and Variables</a>
<li><a href="#Chicken_nn9">Functions</a>
</ul>
<li><a href="#n10">TinyCLOS</a>
<li><a href="#n11">Compilation</a>
<li><a href="#n12">Linkage</a>
<li><a href="#Chicken_nn10">TinyCLOS</a>
<li><a href="#Chicken_nn11">Compilation</a>
<li><a href="#Chicken_nn12">Linkage</a>
<ul>
<li><a href="#n13">Shared library</a>
<li><a href="#n14">Static binary</a>
<li><a href="#Chicken_nn13">Shared library</a>
<li><a href="#Chicken_nn14">Static binary</a>
</ul>
<li><a href="#n15">Typemaps</a>
<li><a href="#n16">Pointers</a>
<li><a href="#n17">Unsupported features</a>
<li><a href="#Chicken_nn15">Typemaps</a>
<li><a href="#Chicken_nn16">Pointers</a>
<li><a href="#Chicken_nn17">Unsupported features</a>
</ul>
<!-- INDEX -->
@ -61,7 +61,7 @@
</p>
<a name="n2"></a><H2>25.1 Preliminaries</H2>
<H2><a name="Chicken_nn2"></a>17.1 Preliminaries</H2>
<p>
@ -82,61 +82,77 @@
</p>
<a name="n3"></a><H3>25.1.1 Running SWIG in C mode</H3>
<H3><a name="Chicken_nn3"></a>17.1.1 Running SWIG in C mode</H3>
<p>
<p>
To run SWIG CHICKEN in C mode, use
the -chicken option.
</p>
<blockquote>
<pre>% swig -chicken example.i</pre>
</blockquote>
<p>
To allow the wrapper to take advantage of future CHICKEN code
generation improvements, part of the wrapper is direct CHICKEN
function calls (<tt>example_wrap.c</tt>) and part is CHICKEN
Scheme (<tt>example.scm</tt>). The basic Scheme code must
be compiled to C using your system's CHICKEN compiler.
</p>
<blockquote>
<pre>% chicken example.scm -output-file oexample.c</pre>
</blockquote>
<p>
So for the C mode of SWIG CHICKEN, <tt>example_wrap.c</tt> and
<tt>oexample.c</tt> are the files that must be compiled to
object files and linked into your project.
</p>
</p>
<a name="n4"></a><H3>25.1.2 Running SWIG in C++ mode</H3>
<H3><a name="Chicken_nn4"></a>17.1.2 Running SWIG in C++ mode</H3>
<p>
<p>
To run SWIG CHICKEN in C++ mode, use
the -chicken -c++ option.
</p>
<blockquote>
<pre>% swig -chicken -c++ example.i</pre>
</blockquote>
<p>
This will generate <tt>example_wrap.cxx</tt>,
<tt>example.scm</tt>, <tt>example-generic.scm</tt> and
<tt>example-clos.scm</tt>. The basic Scheme code must be
compiled to C using your system's CHICKEN compiler.
</p>
<blockquote>
<pre>% chicken example.scm -output-file oexample.c</pre>
</blockquote>
<p>
So for the C++ mode of SWIG CHICKEN, <tt>example_wrap.cxx</tt>
and <tt>oexample.c</tt> are the files that must be compiled to
object files and linked into your project.
</p>
</p>
<a name="n5"></a><H2>25.2 Code Generation</H2>
<H2><a name="Chicken_nn5"></a>17.2 Code Generation</H2>
<a name="n6"></a><H3>25.2.1 Naming Conventions</H3>
<H3><a name="Chicken_nn6"></a>17.2.1 Naming Conventions</H3>
<p>
Given a C variable, function or constant declaration named
<tt>Foo_Bar_to_Foo_Baz</tt>, the declaration will be available
in CHICKEN as an identifier ending with
<tt>Foo-Bar->Foo-Baz</tt>. That is, an underscore is converted
<tt>Foo-Bar-&gt;Foo-Baz</tt>. That is, an underscore is converted
to a dash and '_to_' is converted to an arrow.
<br>
@ -156,7 +172,7 @@
<tt>%rename</tt> SWIG directive in the SWIG interface file.
</p>
<a name="n7"></a><H3>25.2.2 Modules and Prefixes</H3>
<H3><a name="Chicken_nn7"></a>17.2.2 Modules and Prefixes</H3>
<p>
@ -192,7 +208,7 @@
</p>
<a name="n8"></a><H3>25.2.3 Constants and Variables</H3>
<H3><a name="Chicken_nn8"></a>17.2.3 Constants and Variables</H3>
<p>
@ -219,7 +235,7 @@
use <tt>(my-variable)</tt>.
</p>
<a name="n9"></a><H3>25.2.4 Functions</H3>
<H3><a name="Chicken_nn9"></a>17.2.4 Functions</H3>
<p>
@ -238,11 +254,12 @@
parameters).
</p>
<a name="n10"></a><H2>25.3 TinyCLOS</H2>
<H2><a name="Chicken_nn10"></a>17.3 TinyCLOS</H2>
<p>
<p>
The author of TinyCLOS, Gregor Kiczales, describes TinyCLOS as:
</p>
<blockquote>
Tiny CLOS is a Scheme implementation of a `kernelized' CLOS, with a
metaobject protocol. The implementation is even simpler than
@ -250,12 +267,15 @@
weighing in at around 850 lines of code, including (some)
comments and documentation.
</blockquote>
<p>
Almost all good Scheme books describe how to use metaobjects and
generic procedures to implement an object-oriented Scheme
system. Please consult a Scheme book if you are unfamiliar
with the concept.
</p>
<br>
<p>
CHICKEN has a modified version of TinyCLOS, which SWIG CHICKEN
uses in C++ mode. SWIG CHICKEN generates a
@ -265,8 +285,9 @@
program needs, and <strong>then</strong> <tt>(include
"xxx-clos")</tt> all the metaobject (class) macros your program
needs.
</p>
<br>
<p>
SWIG CHICKEN will call the destructor for all TinyCLOS objects
that are garbage-collected by CHICKEN. It also allows access to
@ -274,9 +295,9 @@
of any TinyCLOS parameters. It is best to learn the TinyCLOS
system by running the <tt>Examples/chicken/class/</tt> example.
</p>
</p>
<a name="n11"></a><H2>25.4 Compilation</H2>
<H2><a name="Chicken_nn11"></a>17.4 Compilation</H2>
<p>
@ -290,7 +311,7 @@
much simpler <tt>csc</tt> or <tt>csc.bat</tt>.
</p>
<a name="n12"></a><H2>25.5 Linkage</H2>
<H2><a name="Chicken_nn12"></a>17.5 Linkage</H2>
<p>
@ -304,7 +325,7 @@
loadable module.
</p>
<a name="n13"></a><H3>25.5.1 Shared library</H3>
<H3><a name="Chicken_nn13"></a>17.5.1 Shared library</H3>
<p>
@ -313,42 +334,47 @@
in example.i and the C functions being wrapped are in example_impl.c.
</p>
<pre><blockquote>
<blockquote>
<pre>
$ swig -chicken example.i
$ csc -svk example.scm example_impl.c example_wrap.c
$ csi example.so test_script.scm
</blockquote></pre>
</pre>
</blockquote>
<p>
You must be careful not to name the example_impl.c file example.c because
when compiling example.scm, csc compiles that into example.c!
</p>
<a name="n14"></a><H3>25.5.2 Static binary</H3>
<H3><a name="Chicken_nn14"></a>17.5.2 Static binary</H3>
<p>Again, we can easily use csc to build a binary.</p>
<pre><blockquote>
<blockquote>
<pre>
$ swig -chicken example.i
$ csc -vk example.scm example_impl.c example_wrap.c test_script.scm -o example
$ ./example
</blockquote></pre>
</pre>
</blockquote>
<a name="n15"></a><H2>25.6 Typemaps</H2>
<H2><a name="Chicken_nn15"></a>17.6 Typemaps</H2>
<p>
The Chicken module handles all types via typemaps. This information is
read from <code>Lib/chicken/typemaps.i</code> and
<code>Lib/chicken/chicken.swg</code>.
</p>
<br>
<p>
Two Chicken-specific typemaps are supported:
<code>clos_in</code> and <code>clos_out</code>. They are for
converting TinyCLOS to and from low-level CHICKEN SWIG. Here is
a quick example:
</p>
<blockquote>
<pre>
@ -365,7 +391,7 @@
<blockquote>
<pre>
/* TinyCLOS <--> Low-level CHICKEN */
/* TinyCLOS &lt;--&gt; Low-level CHICKEN */
%typemap("clos_in") SIMPLE_CLOS_OBJECT * "(slot-ref $input (quote this))"
%typemap("clos_out") SIMPLE_CLOS_OBJECT * "(make $class (quote this) $1)"
@ -457,6 +483,7 @@
</pre>
</blockquote>
<p>
After SWIG processes <code>vtkObject.h</code> (from the
<tt>%include "vtkObject.h"</tt> line), SWIG will have the complete
definition of the <code>vtkObject</code> class because
@ -475,7 +502,7 @@
</p>
<a name="n16"></a><H2>25.7 Pointers</H2>
<H2><a name="Chicken_nn16"></a>17.7 Pointers</H2>
<p>
@ -508,7 +535,7 @@
type.
</p>
<a name="n17"></a><H2>25.8 Unsupported features</H2>
<H2><a name="Chicken_nn17"></a>17.8 Unsupported features</H2>
<ul>