changes after maketoc.py was run

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@6039 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2004-07-12 19:59:40 +00:00
commit 07b2b75836
22 changed files with 436 additions and 362 deletions

View file

@ -424,4 +424,4 @@ constraint, the <tt>%clear</tt> directive can be used :<p>
<address>SWIG 1.3 - Last Modified : October 13, 2002</address>
</body>
</html>
</html>

View file

@ -24,7 +24,7 @@
</ul>
<li><a href="#n10">TinyCLOS</a>
<li><a href="#n11">Compilation</a>
<li><a href="#n12">Linking</a>
<li><a href="#n12">Linkage</a>
<ul>
<li><a href="#n13">Shared library</a>
<li><a href="#n14">Static binary</a>
@ -300,6 +300,7 @@
<a name="n13"></a><H3>25.5.1 Shared library</H3>
<p>
The easiest way to use SWIG and CHICKEN is to use the csc compiler
wrapper provided by CHICKEN. Assume you have a SWIG interface file
@ -319,6 +320,7 @@
<a name="n14"></a><H3>25.5.2 Static binary</H3>
<p>Again, we can easily use csc to build a binary.</p>
<pre><blockquote>
@ -507,4 +509,4 @@
<li>No exception handling.</li>
</ul>
</body>
</html>
</html>

View file

@ -53,30 +53,29 @@
<li><a href="Windows.html#n2">Installation on Windows</a>
<ul>
<li><a href="Windows.html#n3">Windows Executable</a>
<li><a href="Windows.html#n4">Runtime Libraries</a>
</ul>
<li><a href="Windows.html#n5">SWIG Windows Examples</a>
<li><a href="Windows.html#n4">SWIG Windows Examples</a>
<ul>
<li><a href="Windows.html#n6">Instructions for using the Examples with Visual Studio</a>
<li><a href="Windows.html#n5">Instructions for using the Examples with Visual Studio</a>
<ul>
<li><a href="Windows.html#n7">Python</a>
<li><a href="Windows.html#n8">TCL</a>
<li><a href="Windows.html#n9">Perl</a>
<li><a href="Windows.html#n10">Java</a>
<li><a href="Windows.html#n11">Ruby</a>
<li><a href="Windows.html#n12">C#</a>
<li><a href="Windows.html#n6">Python</a>
<li><a href="Windows.html#n7">TCL</a>
<li><a href="Windows.html#n8">Perl</a>
<li><a href="Windows.html#n9">Java</a>
<li><a href="Windows.html#n10">Ruby</a>
<li><a href="Windows.html#n11">C#</a>
</ul>
<li><a href="Windows.html#n13">Instructions for using the Examples with other compilers</a>
<li><a href="Windows.html#n12">Instructions for using the Examples with other compilers</a>
</ul>
<li><a href="Windows.html#n14">SWIG on Cygwin and MinGW</a>
<li><a href="Windows.html#n13">SWIG on Cygwin and MinGW</a>
<ul>
<li><a href="Windows.html#n15">Building swig.exe on Windows</a>
<li><a href="Windows.html#n14">Building swig.exe on Windows</a>
<ul>
<li><a href="Windows.html#n16">Building swig.exe using MinGW and MSYS</a>
<li><a href="Windows.html#n17">Building swig.exe using Cygwin</a>
<li><a href="Windows.html#n18">Building swig.exe alternatives</a>
<li><a href="Windows.html#n15">Building swig.exe using MinGW and MSYS</a>
<li><a href="Windows.html#n16">Building swig.exe using Cygwin</a>
<li><a href="Windows.html#n17">Building swig.exe alternatives</a>
</ul>
<li><a href="Windows.html#n19">Running the examples on Windows using Cygwin</a>
<li><a href="Windows.html#n18">Running the examples on Windows using Cygwin</a>
</ul>
</ul>
<!-- INDEX -->
@ -312,19 +311,20 @@
<li><a href="Typemaps.html#n35">"memberin" typemap</a>
<li><a href="Typemaps.html#n36">"varin" typemap</a>
<li><a href="Typemaps.html#n37">"varout" typemap</a>
<li><a href="Typemaps.html#n38">"throws" typemap</a>
</ul>
<li><a href="Typemaps.html#n38">Some typemap examples</a>
<li><a href="Typemaps.html#n39">Some typemap examples</a>
<ul>
<li><a href="Typemaps.html#n39">Typemaps for arrays</a>
<li><a href="Typemaps.html#n40">Implementing constraints with typemaps</a>
<li><a href="Typemaps.html#n40">Typemaps for arrays</a>
<li><a href="Typemaps.html#n41">Implementing constraints with typemaps</a>
</ul>
<li><a href="Typemaps.html#n41">Multi-argument typemaps</a>
<li><a href="Typemaps.html#n42">The run-time type checker</a>
<li><a href="Typemaps.html#n43">Typemaps and overloading</a>
<li><a href="Typemaps.html#n44">More about <tt>%apply</tt> and <tt>%clear</tt></a>
<li><a href="Typemaps.html#n45">Reducing wrapper code size</a>
<li><a href="Typemaps.html#n46">Passing data between typemaps</a>
<li><a href="Typemaps.html#n47">Where to go for more information?</a>
<li><a href="Typemaps.html#n42">Multi-argument typemaps</a>
<li><a href="Typemaps.html#n43">The run-time type checker</a>
<li><a href="Typemaps.html#n44">Typemaps and overloading</a>
<li><a href="Typemaps.html#n45">More about <tt>%apply</tt> and <tt>%clear</tt></a>
<li><a href="Typemaps.html#n46">Reducing wrapper code size</a>
<li><a href="Typemaps.html#n47">Passing data between typemaps</a>
<li><a href="Typemaps.html#n48">Where to go for more information?</a>
</ul>
<!-- INDEX -->
@ -381,18 +381,19 @@
<li><a href="Warnings.html#n4">Enabling additional warnings</a>
<li><a href="Warnings.html#n5">Issuing a warning message</a>
<li><a href="Warnings.html#n6">Commentary</a>
<li><a href="Warnings.html#n7">Message output format</a>
<li><a href="Warnings.html#n8">Warning number reference</a>
<li><a href="Warnings.html#n7">Warnings as errors</a>
<li><a href="Warnings.html#n8">Message output format</a>
<li><a href="Warnings.html#n9">Warning number reference</a>
<ul>
<li><a href="Warnings.html#n9">Deprecated features (100-199)</a>
<li><a href="Warnings.html#n10">Preprocessor (200-299)</a>
<li><a href="Warnings.html#n11">C/C++ Parser (300-399)</a>
<li><a href="Warnings.html#n12">Types and typemaps (400-499) </a>
<li><a href="Warnings.html#n13">Code generation (500-599)</a>
<li><a href="Warnings.html#n14">Language module specific (800-899) </a>
<li><a href="Warnings.html#n15">User defined (900-999)</a>
<li><a href="Warnings.html#n10">Deprecated features (100-199)</a>
<li><a href="Warnings.html#n11">Preprocessor (200-299)</a>
<li><a href="Warnings.html#n12">C/C++ Parser (300-399)</a>
<li><a href="Warnings.html#n13">Types and typemaps (400-499) </a>
<li><a href="Warnings.html#n14">Code generation (500-599)</a>
<li><a href="Warnings.html#n15">Language module specific (800-899) </a>
<li><a href="Warnings.html#n16">User defined (900-999)</a>
</ul>
<li><a href="Warnings.html#n16">History</a>
<li><a href="Warnings.html#n17">History</a>
</ul>
<!-- INDEX -->
@ -576,7 +577,7 @@
<ul>
<li><a href="Java.html#n55">C/C++ helper functions</a>
<li><a href="Java.html#n56">Class extension with %extend</a>
<li><a href="Java.html#n57">Exception handling with %exception</a>
<li><a href="Java.html#n57">Exception handling with %exception and %javaexception</a>
<li><a href="Java.html#n58">Method access with %javamethodmodifiers</a>
</ul>
<li><a href="Java.html#n59">Tips and techniques</a>
@ -592,30 +593,33 @@
<li><a href="Java.html#n66">Sixty four bit JVMs</a>
<li><a href="Java.html#n67">What is a typemap?</a>
<li><a href="Java.html#n68">Typemaps for mapping C/C++ types to Java types</a>
<li><a href="Java.html#n69">Java special variables</a>
<li><a href="Java.html#n70">Typemaps for both C and C++ compilation</a>
<li><a href="Java.html#n71">Java code typemaps</a>
<li><a href="Java.html#n72">Director specific typemaps</a>
<li><a href="Java.html#n69">Java typemap attributes</a>
<li><a href="Java.html#n70">Java special variables</a>
<li><a href="Java.html#n71">Typemaps for both C and C++ compilation</a>
<li><a href="Java.html#n72">Java code typemaps</a>
<li><a href="Java.html#n73">Director specific typemaps</a>
</ul>
<li><a href="Java.html#n73">Typemap Examples</a>
<li><a href="Java.html#n74">Typemap Examples</a>
<ul>
<li><a href="Java.html#n74">Simpler Java enums for enums without initializers</a>
<li><a href="Java.html#n75">Converting Java String arrays to char ** </a>
<li><a href="Java.html#n76">Expanding a Java object to multiple arguments</a>
<li><a href="Java.html#n77">Using typemaps to return arguments</a>
<li><a href="Java.html#n78">Adding Java downcasts to polymorphic return types</a>
<li><a href="Java.html#n79">Adding an equals method to the Java classes</a>
<li><a href="Java.html#n80">Void pointers and a common Java base class</a>
<li><a href="Java.html#n75">Simpler Java enums for enums without initializers</a>
<li><a href="Java.html#n76">Handling C++ exception specifications as Java exceptions</a>
<li><a href="Java.html#n77">NaN Exception - exception handling for a particular type</a>
<li><a href="Java.html#n78">Converting Java String arrays to char ** </a>
<li><a href="Java.html#n79">Expanding a Java object to multiple arguments</a>
<li><a href="Java.html#n80">Using typemaps to return arguments</a>
<li><a href="Java.html#n81">Adding Java downcasts to polymorphic return types</a>
<li><a href="Java.html#n82">Adding an equals method to the Java classes</a>
<li><a href="Java.html#n83">Void pointers and a common Java base class</a>
</ul>
<li><a href="Java.html#n81">Living with Java Directors</a>
<li><a href="Java.html#n82">Odds and ends</a>
<li><a href="Java.html#n84">Living with Java Directors</a>
<li><a href="Java.html#n85">Odds and ends</a>
<ul>
<li><a href="Java.html#n83">JavaDoc comments</a>
<li><a href="Java.html#n84">Functional interface without proxy classes</a>
<li><a href="Java.html#n85">Using your own JNI functions</a>
<li><a href="Java.html#n86">Performance concerns and hints</a>
<li><a href="Java.html#n86">JavaDoc comments</a>
<li><a href="Java.html#n87">Functional interface without proxy classes</a>
<li><a href="Java.html#n88">Using your own JNI functions</a>
<li><a href="Java.html#n89">Performance concerns and hints</a>
</ul>
<li><a href="Java.html#n87">Examples</a>
<li><a href="Java.html#n90">Examples</a>
</ul>
<!-- INDEX -->

View file

@ -239,4 +239,4 @@ in SWIG-1.3.20.
<address>SWIG 1.3 - Last Modified : November 12, 2003</address>
</body>
</html>
</html>

View file

@ -2817,4 +2817,4 @@ extern "X" { ... } declaration.
<address>SWIG 1.3 - Last Modified : January 22, 2002</address>
</body>
</html>
</html>

View file

@ -375,4 +375,4 @@ non-portable or unreliable programming features.
<address>SWIG 1.3 - Last Modified : August 10, 2002</address>
</body>
</html>
</html>

View file

@ -101,32 +101,33 @@
<li><a href="#n66">Sixty four bit JVMs</a>
<li><a href="#n67">What is a typemap?</a>
<li><a href="#n68">Typemaps for mapping C/C++ types to Java types</a>
<li><a href="#n681">Additional Java typemap attributes</a>
<li><a href="#n69">Java special variables</a>
<li><a href="#n70">Typemaps for both C and C++ compilation</a>
<li><a href="#n71">Java code typemaps</a>
<li><a href="#n72">Director specific typemaps</a>
<li><a href="#n69">Java typemap attributes</a>
<li><a href="#n70">Java special variables</a>
<li><a href="#n71">Typemaps for both C and C++ compilation</a>
<li><a href="#n72">Java code typemaps</a>
<li><a href="#n73">Director specific typemaps</a>
</ul>
<li><a href="#n73">Typemap Examples</a>
<li><a href="#n74">Typemap Examples</a>
<ul>
<li><a href="#n74">Simpler Java enums for enums without initializers</a>
<li><a href="#n741">Handling C++ exception specifications as Java exceptions</a>
<li><a href="#n75">Converting Java String arrays to char ** </a>
<li><a href="#n76">Expanding a Java object to multiple arguments</a>
<li><a href="#n77">Using typemaps to return arguments</a>
<li><a href="#n78">Adding Java downcasts to polymorphic return types</a>
<li><a href="#n79">Adding an equals method to the Java classes</a>
<li><a href="#n80">Void pointers and a common Java base class</a>
<li><a href="#n75">Simpler Java enums for enums without initializers</a>
<li><a href="#n76">Handling C++ exception specifications as Java exceptions</a>
<li><a href="#n77">NaN Exception - exception handling for a particular type</a>
<li><a href="#n78">Converting Java String arrays to char ** </a>
<li><a href="#n79">Expanding a Java object to multiple arguments</a>
<li><a href="#n80">Using typemaps to return arguments</a>
<li><a href="#n81">Adding Java downcasts to polymorphic return types</a>
<li><a href="#n82">Adding an equals method to the Java classes</a>
<li><a href="#n83">Void pointers and a common Java base class</a>
</ul>
<li><a href="#n81">Living with Java Directors</a>
<li><a href="#n82">Odds and ends</a>
<li><a href="#n84">Living with Java Directors</a>
<li><a href="#n85">Odds and ends</a>
<ul>
<li><a href="#n83">JavaDoc comments</a>
<li><a href="#n84">Functional interface without proxy classes</a>
<li><a href="#n85">Using your own JNI functions</a>
<li><a href="#n86">Performance concerns and hints</a>
<li><a href="#n86">JavaDoc comments</a>
<li><a href="#n87">Functional interface without proxy classes</a>
<li><a href="#n88">Using your own JNI functions</a>
<li><a href="#n89">Performance concerns and hints</a>
</ul>
<li><a href="#n87">Examples</a>
<li><a href="#n90">Examples</a>
</ul>
<!-- INDEX -->
@ -3900,7 +3901,9 @@ These are listed below:
</table>
<a name="typemap_attributes"></a>
<a name="n681"></a><H3>17.8.5 Java typemap attributes</H3>
<a name="n69"></a><H3>17.8.5 Java typemap attributes</H3>
There is an additional typemap attribute that the Java module supports.
This is the 'throws' attribute.
The throws attribute is optional and specified after the typemap name and contains one or more comma separated classes for adding to the throws clause for any methods that use that typemap.
@ -3925,7 +3928,7 @@ the union of the exception classes is added to the throws clause ensuring there
See the <a href="#nan_exception_typemap">NaN exception example</a> for further usage.
<a name="special_variables"></a>
<a name="n69"></a><H3>17.8.5 Java special variables</H3>
<a name="n70"></a><H3>17.8.6 Java special variables</H3>
The standard SWIG special variables are available for use within typemaps as described in the <a href=Typemaps.html>Typemaps documentation</a>, for example <tt>$1</tt>, <tt>$input</tt>,<tt>$result</tt> etc.
@ -4043,7 +4046,7 @@ This special variable expands to the module name, as specified by <tt>%module</t
Useful for constructing the intermediary classname, which is just <tt>$moduleJNI</tt>.
<a name="typemaps_for_c_and_c++"></a>
<a name="n70"></a><H3>17.8.6 Typemaps for both C and C++ compilation</H3>
<a name="n71"></a><H3>17.8.7 Typemaps for both C and C++ compilation</H3>
JNI calls must be written differently depending on whether the code is being compiled as C or C++.
@ -4074,7 +4077,7 @@ If you do not intend your code to be targeting both C and C++ then your typemaps
<a name="java_code_typemaps"></a>
<a name="n71"></a><H3>17.8.7 Java code typemaps</H3>
<a name="n72"></a><H3>17.8.8 Java code typemaps</H3>
Most of SWIG's typemaps are used for the generation of C/C++ code.
@ -4249,7 +4252,7 @@ For the typemap to be used in all type wrapper classes, all the different types
Again this is the same that is in "<tt>java.swg</tt>", barring the method modifier for <tt>getCPtr</tt>.
<a name="java_directors_typemaps"></a>
<a name="n72"></a><H3>17.8.8 Director specific typemaps</H3>
<a name="n73"></a><H3>17.8.9 Director specific typemaps</H3>
The Java directors feature requires the "javadirectorin", "javadirectorout" and the "directorin" typemaps in order to work properly.
@ -4402,7 +4405,7 @@ The basic strategy here is to provide a default package typemap for the majority
</blockquote>
<a name="typemap_examples"></a>
<a name="n73"></a><H2>17.9 Typemap Examples</H2>
<a name="n74"></a><H2>17.9 Typemap Examples</H2>
This section includes a few examples of typemaps. For more examples, you
@ -4411,7 +4414,7 @@ the SWIG library.
<a name="simpler_enum_classes"></a>
<a name="n74"></a><H3>17.9.1 Simpler Java enums for enums without initializers</H3>
<a name="n75"></a><H3>17.9.1 Simpler Java enums for enums without initializers</H3>
The default <a href="#proper_enums_classes">Proper Java enums</a> approach to wrapping enums is somewhat verbose.
@ -4481,7 +4484,8 @@ This would be done by using the original versions of these typemaps in "enums.sw
<a name="exception_typemap"></a>
<a name="n741"></a><H3>17.9.2 Handling C++ exception specifications as Java exceptions</H3>
<a name="n76"></a><H3>17.9.2 Handling C++ exception specifications as Java exceptions</H3>
This example demonstrates various ways in which C++ exceptions can be tailored and converted into Java exceptions.
Let's consider a simple file class <tt>SimpleFile</tt> and an exception class <tt>FileException</tt> which it may throw on error:
@ -4590,7 +4594,9 @@ We could alternatively have used <tt>%rename</tt> to rename <tt>what()</tt> into
<a name="nan_exception_typemap"></a>
<a name="n75"></a><H3>17.9.2 NaN Exception - exception handling for a particular type</H3>
<a name="n77"></a><H3>17.9.3 NaN Exception - exception handling for a particular type</H3>
A Java exception can be thrown from any Java or JNI code.
Therefore, as most typemaps contain either Java or JNI code, just about any typemap could throw an exception.
The following example demonstrates exception handling on a type by type basis by checking for 'Not a number' (NaN) whenever a parameter of type <tt>float</tt> is wrapped.
@ -4689,7 +4695,7 @@ If we were a martyr to the JNI cause, we could replace the succinct code within
If we had, we would have put it in the "in" typemap which, like all JNI and Java typemaps, also supports the 'throws' attribute.
<a name="converting_java_string_arrays"></a>
<a name="n75"></a><H3>17.9.2 Converting Java String arrays to char ** </H3>
<a name="n78"></a><H3>17.9.4 Converting Java String arrays to char ** </H3>
A common problem in many C programs is the processing of command line arguments, which are usually passed in an array of NULL terminated strings.
@ -4822,7 +4828,7 @@ Lastly the "jni", "jtype" and "jstype" typemaps are also required to specify
what Java types to use.
<a name="expanding_java_object"></a>
<a name="n76"></a><H3>17.9.3 Expanding a Java object to multiple arguments</H3>
<a name="n79"></a><H3>17.9.5 Expanding a Java object to multiple arguments</H3>
Suppose that you had a collection of C functions with arguments
@ -4896,7 +4902,7 @@ example.foo(new String[]{"red", "green", "blue", "white"});
<a name="using_typemaps_return_arguments"></a>
<a name="n77"></a><H3>17.9.4 Using typemaps to return arguments</H3>
<a name="n80"></a><H3>17.9.6 Using typemaps to return arguments</H3>
A common problem in some C programs is that values may be returned in function parameters rather than in the return value of a function.
@ -4997,7 +5003,7 @@ $ java main
</pre></blockquote>
<a name="adding_downcasts"></a>
<a name="n78"></a><H3>17.9.5 Adding Java downcasts to polymorphic return types</H3>
<a name="n81"></a><H3>17.9.7 Adding Java downcasts to polymorphic return types</H3>
SWIG support for polymorphism works in that the appropriate virtual function is called. However, the default generated code does not allow for downcasting.
@ -5181,7 +5187,7 @@ SWIG usually generates code which constructs the proxy classes using Java code a
Note that the JNI code above uses a number of string lookups to call a constructor, whereas this would not occur using byte compiled Java code.
<a name="adding_equals_method"></a>
<a name="n79"></a><H3>17.9.6 Adding an equals method to the Java classes</H3>
<a name="n82"></a><H3>17.9.8 Adding an equals method to the Java classes</H3>
When a pointer is returned from a JNI function, it is wrapped using a new Java proxy class or type wrapper class.
@ -5217,7 +5223,7 @@ System.out.println("foo1? " + foo1.equals(foo2));
<a name="void_pointers"></a>
<a name="n80"></a><H3>17.9.7 Void pointers and a common Java base class</H3>
<a name="n83"></a><H3>17.9.9 Void pointers and a common Java base class</H3>
One might wonder why the common code that SWIG emits for the proxy and type wrapper classes is not pushed into a base class.
@ -5269,7 +5275,7 @@ This example contains some useful functionality which you may want in your code.
</ul>
<a name="java_directors_faq"></a>
<a name="n81"></a><H2>17.10 Living with Java Directors</H2>
<a name="n84"></a><H2>17.10 Living with Java Directors</H2>
<p>
@ -5435,11 +5441,11 @@ public abstract class UserVisibleFoo extends Foo {
</ol>
<a name="odds_ends"></a>
<a name="n82"></a><H2>17.11 Odds and ends</H2>
<a name="n85"></a><H2>17.11 Odds and ends</H2>
<a name="javadoc_comments"></a>
<a name="n83"></a><H3>17.11.1 JavaDoc comments</H3>
<a name="n86"></a><H3>17.11.1 JavaDoc comments</H3>
The SWIG documentation system is currently deprecated.
@ -5491,7 +5497,7 @@ public class Barmy {
<a name="functional_interface"></a>
<a name="n84"></a><H3>17.11.2 Functional interface without proxy classes</H3>
<a name="n87"></a><H3>17.11.2 Functional interface without proxy classes</H3>
It is possible to run SWIG in a mode that does not produce proxy classes by using the -noproxy commandline option.
@ -5543,7 +5549,7 @@ All destructors have to be called manually for example the <tt>delete_Foo(foo)</
<a name="using_own_jni_functions"></a>
<a name="n85"></a><H3>17.11.3 Using your own JNI functions</H3>
<a name="n88"></a><H3>17.11.3 Using your own JNI functions</H3>
You may have some hand written JNI functions that you want to use in addition to the SWIG generated JNI functions.
@ -5584,7 +5590,7 @@ This directive is only really useful if you want to mix your own hand crafted JN
<a name="performance"></a>
<a name="n86"></a><H3>17.11.4 Performance concerns and hints</H3>
<a name="n89"></a><H3>17.11.4 Performance concerns and hints</H3>
If you're directly manipulating huge arrays of complex objects from Java, performance may suffer greatly when using the array functions in <tt>arrays_java.i</tt>.
@ -5602,7 +5608,7 @@ This method calls the C++ destructor or <tt>free()</tt> for C code.
<a name="java_examples"></a>
<a name="n87"></a><H2>17.12 Examples</H2>
<a name="n90"></a><H2>17.12 Examples</H2>
The directory Examples/java has a number of further examples.

View file

@ -1343,4 +1343,4 @@ For example:
<p><hr>
<address>SWIG 1.3 - Last Modified : May 29, 2002</address>
</body>
</html>
</html>

View file

@ -876,4 +876,4 @@ Catching exceptions is now supported using SWIG's %exception feature. A simple
but not too useful example is provided by the throw_exception testcase in
Examples/test-suite. You can provide your own exceptions, too.
</body>
</html>
</html>

View file

@ -2500,4 +2500,4 @@ not even sure if it really works). <p>
<address>SWIG 1.3 - Last Modified : Feb 13, 2003</address>
</body>
</html>
</html>

View file

@ -493,4 +493,4 @@ does not have the 'dl' command as used above.
</body>
</html>
</html>

View file

@ -203,4 +203,4 @@ can only fix bugs if we know about them.
<p><hr>
<address>SWIG 1.3 - Last Modified : March 9, 2003</address>
</body>
</html>
</html>

View file

@ -316,4 +316,4 @@ SWIG will strip the extra <tt>%</tt> and leave the preprocessor directive in the
<address>SWIG 1.3 - Last Modified : March 9, 2003</address>
</body>
</html>
</html>

View file

@ -3646,4 +3646,4 @@ class object (if applicable).
<address>SWIG 1.3 - Last Modified : August 7, 2002</address>
</body>
</html>
</html>

View file

@ -5,132 +5,87 @@
</head>
<body bgcolor="#ffffff">
<a name="n1"></a>
<h1>23 SWIG and Ruby</h1>
<a name="n1"></a><H1>23 SWIG and Ruby</H1>
<!-- INDEX -->
<ul>
<li><a href="#n2">Preliminaries</a>
<ul>
<li><a href="#n3">Running SWIG</a>
</li>
<li><a href="#n4">Getting the right header files</a>
</li>
<li><a href="#n5">Compiling a dynamic module</a>
</li>
<li><a href="#n6">Using your module</a>
</li>
<li><a href="#n7">Static linking</a>
</li>
<li><a href="#n8">Compilation of C++ extensions</a>
</li>
</ul>
</li>
<li><a href="#n9">Building Ruby Extensions under Windows 95/NT</a>
<ul>
<li><a href="#n10">Running SWIG from Developer Studio</a>
</li>
</ul>
</li>
<li><a href="#n11">The Ruby-to-C/C++ Mapping</a>
<ul>
<li><a href="#n12">Modules</a>
</li>
<li><a href="#n13">Functions</a>
</li>
<li><a href="#n14">Variable Linking</a>
</li>
<li><a href="#n15">Constants</a>
</li>
<li><a href="#n16">Pointers</a>
</li>
<li><a href="#n17">Structures</a>
</li>
<li><a href="#n18">C++ classes</a>
</li>
<li><a href="#n19">C++ Inheritance</a>
</li>
<li><a href="#n20">C++ Overloaded Functions</a>
</li>
<li><a href="#n21">C++ Operators</a>
</li>
<li><a href="#n22">C++ namespaces</a>
</li>
<li><a href="#n23">C++ templates</a>
</li>
<li><a href="#n24">C++ Smart Pointers</a>
</li>
<li><a href="#n25">Cross-Language Polymorphism</a>
<ul>
<li><a href="#n26">Exception Unrolling</a>
</li>
</ul>
</li>
</ul>
</li>
<li><a href="#n27">Input and output parameters</a>
</li>
<li><a href="#n28">Simple exception handling </a>
</li>
<li><a href="#n29">Typemaps</a>
<ul>
<li><a href="#n30">What is a typemap?</a>
</li>
<li><a href="#n31">Ruby typemaps</a>
</li>
<li><a href="#n32">Typemap variables</a>
</li>
<li><a href="#n33">Useful Functions</a>
<ul>
<li><a href="#n34">C Datatypes to Ruby Objects</a>
</li>
<li><a href="#n35">Ruby Objects to C Datatypes</a>
</li>
<li><a href="#n36">Macros for VALUE</a>
</li>
<li><a href="#n37">Exceptions</a>
</li>
<li><a href="#n38">Iterators</a>
</li>
</ul>
</li>
<li><a href="#n39">Typemap Examples</a>
</li>
<li><a href="#n40">Converting a Ruby array to a char **</a>
</li>
<li><a href="#n41">Collecting arguments in a hash</a>
</li>
<li><a href="#n42">Pointer handling</a>
<ul>
<li><a href="#n43">Ruby Datatype Wrapping</a>
</li>
</ul>
</li>
</ul>
</li>
<li><a href="#n44">Operator overloading</a>
<ul>
<li><a href="#n45">Example: STL Vector to Ruby Array</a>
</li>
</ul>
</li>
<li><a href="#n46">Advanced Topics</a>
<ul>
<li><a href="#n47">Creating Multi-Module Packages</a>
</li>
<li><a href="#n48">Defining Aliases</a>
</li>
<li><a href="#n49">Predicate Methods</a>
</li>
<li><a href="#n50">Specifying Mixin Modules</a>
</li>
<li><a href="#n51">Interacting with Ruby's Garbage Collector</a>
</li>
</ul>
</li>
<li><a href="#n2">Preliminaries</a>
<ul>
<li><a href="#n3">Running SWIG</a>
<li><a href="#n4">Getting the right header files</a>
<li><a href="#n5">Compiling a dynamic module</a>
<li><a href="#n6">Using your module</a>
<li><a href="#n7">Static linking</a>
<li><a href="#n8">Compilation of C++ extensions</a>
</ul>
<li><a href="#n9">Building Ruby Extensions under Windows 95/NT</a>
<ul>
<li><a href="#n10">Running SWIG from Developer Studio</a>
</ul>
<li><a href="#n11">The Ruby-to-C/C++ Mapping</a>
<ul>
<li><a href="#n12">Modules</a>
<li><a href="#n13">Functions</a>
<li><a href="#n14">Variable Linking</a>
<li><a href="#n15">Constants</a>
<li><a href="#n16">Pointers</a>
<li><a href="#n17">Structures</a>
<li><a href="#n18">C++ classes</a>
<li><a href="#n19">C++ Inheritance</a>
<li><a href="#n20">C++ Overloaded Functions</a>
<li><a href="#n21">C++ Operators</a>
<li><a href="#n22">C++ namespaces</a>
<li><a href="#n23">C++ templates</a>
<li><a href="#n24">C++ Smart Pointers</a>
<li><a href="#n25">Cross-Language Polymorphism</a>
<ul>
<li><a href="#n26">Exception Unrolling</a>
</ul>
</ul>
<li><a href="#n27">Input and output parameters</a>
<li><a href="#n28">Simple exception handling </a>
<li><a href="#n29">Typemaps</a>
<ul>
<li><a href="#n30">What is a typemap?</a>
<li><a href="#n31">Ruby typemaps</a>
<li><a href="#n32">Typemap variables</a>
<li><a href="#n33">Useful Functions</a>
<ul>
<li><a href="#n34">C Datatypes to Ruby Objects</a>
<li><a href="#n35">Ruby Objects to C Datatypes</a>
<li><a href="#n36">Macros for VALUE</a>
<li><a href="#n37">Exceptions</a>
<li><a href="#n38">Iterators</a>
</ul>
<li><a href="#n39">Typemap Examples</a>
<li><a href="#n40">Converting a Ruby array to a char **</a>
<li><a href="#n41">Collecting arguments in a hash</a>
<li><a href="#n42">Pointer handling</a>
<ul>
<li><a href="#n43">Ruby Datatype Wrapping</a>
</ul>
</ul>
<li><a href="#n44">Operator overloading</a>
<ul>
<li><a href="#n45">Example: STL Vector to Ruby Array</a>
</ul>
<li><a href="#n46">Advanced Topics</a>
<ul>
<li><a href="#n47">Creating Multi-Module Packages</a>
<li><a href="#n48">Defining Aliases</a>
<li><a href="#n49">Predicate Methods</a>
<li><a href="#n50">Specifying Mixin Modules</a>
<li><a href="#n51">Interacting with Ruby's Garbage Collector</a>
</ul>
</ul>
<!-- INDEX -->
<p>This chapter describes SWIG's support of Ruby. </p>
<hr><a name="n2"></a>
<h2>23.1 Preliminaries</h2>
<a name="n2"></a><H2>23.1 Preliminaries</H2>
SWIG 1.3 is known to work with Ruby versions 1.6 and later. Given the
choice, you should
use the latest stable version of Ruby. You should also determine if
@ -145,7 +100,9 @@ earlier chapters. At the very least, make sure you also read the "<a
reader
has a basic understanding of Ruby.
<a name="n3"></a></p>
<h3>23.1.1 Running SWIG</h3>
<a name="n3"></a><H3>23.1.1 Running SWIG</H3>
<p>
To build a Ruby module, run SWIG using the <tt>-ruby</tt> option:</p>
<p></p>
@ -169,7 +126,9 @@ Ruby extension module. To finish building the module, you need to
compile this
file and link it with the rest of your program.
<a name="n4"></a></p>
<h3>23.1.2 Getting the right header files</h3>
<a name="n4"></a><H3>23.1.2 Getting the right header files</H3>
In order to compile the wrapper code, the compiler needs the <tt>ruby.h</tt>
header file. This file is usually contained in a directory such as
<p></p>
@ -191,7 +150,9 @@ can run Ruby to find out. For example:
</pre>
</blockquote>
<a name="n5"></a>
<h3>23.1.3 Compiling a dynamic module</h3>
<a name="n5"></a><H3>23.1.3 Compiling a dynamic module</H3>
Ruby extension modules are typically compiled into shared libraries
that the
interpreter loads dynamically at runtime. Since the exact commands for
@ -249,7 +210,9 @@ You might also check the <a
href="http://swig.cs.uchicago.edu/cgi-bin/wiki.pl">
SWIG Wiki</a> for additional information.
<p> <a name="n6"></a></p>
<h3>23.1.4 Using your module</h3>
<a name="n6"></a><H3>23.1.4 Using your module</H3>
Ruby <i>module</i> names must be capitalized, but the convention for
Ruby
<i>feature</i> names is to use lowercase names. So, for example, the <b>Etc</b>
@ -263,7 +226,9 @@ extension. So for example, a SWIG interface file that begins with:
will result in an extension module using the feature name "example" and
Ruby module name "Example".
<a name="n7"></a>
<h3>23.1.5 Static linking</h3>
<a name="n7"></a><H3>23.1.5 Static linking</H3>
An alternative approach to dynamic linking is to rebuild the Ruby
interpreter with your extension module added to it. In the past,
this approach was sometimes necessary due to limitations in dynamic
@ -278,7 +243,9 @@ adding your directory to the list of extensions in the file, and
finally rebuilding Ruby.
</p>
<p><a name="n8"></a></p>
<h3>23.1.6 Compilation of C++ extensions</h3>
<a name="n8"></a><H3>23.1.6 Compilation of C++ extensions</H3>
<p>
On most machines, C++ extension modules should be linked using the C++
compiler. For example:
@ -310,7 +277,9 @@ into your extension, e.g.
</blockquote>
<hr>
<a name="n9"></a>
<h2>23.2 Building Ruby Extensions under Windows 95/NT</h2>
<a name="n9"></a><H2>23.2 Building Ruby Extensions under Windows 95/NT</H2>
Building a SWIG extension to Ruby under Windows 95/NT is roughly
similar to the
process used with Unix. Normally, you will want to produce a DLL that
@ -337,7 +306,9 @@ you may need to download the source distribution to the Ruby package,
as you
will need the Ruby header files.
<p><a name="n10"></a></p>
<h3>23.2.1 Running SWIG from Developer Studio</h3>
<a name="n10"></a><H3>23.2.1 Running SWIG from Developer Studio</H3>
If you are developing your application within Microsoft developer
studio, SWIG
can be invoked as a custom build option. The process roughly follows
@ -426,12 +397,16 @@ Foo = 3.0
<p>
</p>
<hr><a name="n11"></a>
<h2>23.3 The Ruby-to-C/C++ Mapping</h2>
<a name="n11"></a><H2>23.3 The Ruby-to-C/C++ Mapping</H2>
This section describes the basics of how SWIG maps C or C++
declarations
in your SWIG interface files to Ruby constructs.
<a name="n12"></a>
<h3>23.3.1 Modules</h3>
<a name="n12"></a><H3>23.3.1 Modules</H3>
The SWIG <tt>%module</tt> directive specifies the name of the Ruby
module. If
you specify:
@ -489,7 +464,9 @@ take care that the names of your constants, classes and methods don't
conflict
with any of Ruby's built-in names.
<a name="n13"></a></p>
<h3>23.3.2 Functions</h3>
<a name="n13"></a><H3>23.3.2 Functions</H3>
Global functions are wrapped as Ruby module methods. For example, given
the SWIG interface file <tt>example.i</tt>:
<p></p>
@ -513,7 +490,9 @@ irb(main):002:0&gt; <b>Example.fact(4)</b>
</pre>
</blockquote>
<a name="n14"></a>
<h3>23.3.3 Variable Linking</h3>
<a name="n14"></a><H3>23.3.3 Variable Linking</H3>
C/C++ global variables are wrapped as a pair of singleton methods for
the
module: one to get the value of the global variable and one to set it.
@ -565,7 +544,9 @@ The <tt>%immutable</tt> directive stays in effect until it is
explicitly
disabled using <tt>%mutable</tt>.
<a name="n15"></a>
<h3>23.3.4 Constants</h3>
<a name="n15"></a><H3>23.3.4 Constants</H3>
C/C++ constants are wrapped as module constants initialized to the
appropriate value. To create a constant, use <tt>#define</tt> or the
<tt>%constant</tt> directive. For example:
@ -584,7 +565,9 @@ irb(main):002:0&gt; <b>Example::PI</b>
</pre>
</blockquote>
<a name="n16"></a>
<h3>23.3.5 Pointers</h3>
<a name="n16"></a><H3>23.3.5 Pointers</H3>
"Opaque" pointers to arbitrary C/C++ types (i.e. types that aren't
explicitly
declared in your SWIG interface file) are wrapped as data objects. So,
@ -605,7 +588,9 @@ internally generated Ruby class:
A <tt>NULL</tt> pointer is always represented by the Ruby <tt>nil</tt>
object.
<a name="n17"></a>
<h3>23.3.6 Structures</h3>
<a name="n17"></a><H3>23.3.6 Structures</H3>
C/C++ structs are wrapped as Ruby classes, with accessor methods (i.e.
"getters"
and "setters") for all of the struct members. For example, this struct
@ -684,7 +669,9 @@ generates accessor functions such as this:
<pre>Foo *Bar_f_get(Bar *b) {<br> return &amp;b-&gt;f;<br>}<br><br>void Bar_f_set(Bar *b, Foo *val) {<br> b-&gt;f = *val;<br>}<br></pre>
</blockquote>
<a name="n18"></a>
<h3>23.3.7 C++ classes</h3>
<a name="n18"></a><H3>23.3.7 C++ classes</H3>
Like structs, C++ classes are wrapped by creating a new Ruby class of
the same
name with accessor methods for the public class member data.
@ -719,7 +706,9 @@ In Ruby, these functions are used as follows:
<pre>require 'Example'<br><br>l = Example::List.new<br><br>l.insert("Ale")<br>l.insert("Stout")<br>l.insert("Lager")<br>Example.print(l)<br>l.length()<br>----- produces the following output <br>Lager<br>Stout<br>Ale<br>3<br></pre>
</blockquote>
<a name="n19"></a>
<h3>23.3.8 C++ Inheritance</h3>
<a name="n19"></a><H3>23.3.8 C++ Inheritance</H3>
The SWIG type-checker is fully aware of C++ inheritance. Therefore, if
you have
classes like this:
@ -831,7 +820,9 @@ and <tt>Base2</tt>
(i.e. they exhibit <a href="http://c2.com/cgi/wiki?DuckTyping">"Duck
Typing"</a>).
<a name="n20"></a>
<h3>23.3.9 C++ Overloaded Functions</h3>
<a name="n20"></a><H3>23.3.9 C++ Overloaded Functions</H3>
C++ overloaded functions, methods, and constructors are mostly
supported by SWIG. For example,
if you have two functions like this:
@ -883,7 +874,9 @@ arises--in this case, the
first declaration takes precedence.
<p>Please refer to the <a href="SWIGPlus.html">"SWIG and C++"</a>
chapter for more information about overloading. <a name="n21"></a></p>
<h3>23.3.10 C++ Operators</h3>
<a name="n21"></a><H3>23.3.10 C++ Operators</H3>
For the most part, overloaded operators are handled automatically by
SWIG
and do not require any special treatment on your part. So if your class
@ -912,7 +905,9 @@ More details about wrapping C++ operators into Ruby operators is
discussed in
the <a href="#n39">section on operator overloading</a>.
<a name="n22"></a>
<h3>23.3.11 C++ namespaces</h3>
<a name="n22"></a><H3>23.3.11 C++ namespaces</H3>
SWIG is aware of C++ namespaces, but namespace names do not appear in
the module nor do namespaces result in a module that is broken up into
submodules or packages. For example, if you have a file like this,
@ -946,7 +941,9 @@ extension modules for each namespace separately. If your program
utilizes thousands of small deeply nested namespaces each with
identical symbol names, well, then you get what you deserve.
<a name="n23"></a>
<h3>23.3.12 C++ templates</h3>
<a name="n23"></a><H3>23.3.12 C++ templates</H3>
C++ templates don't present a huge problem for SWIG. However, in order
to create wrappers, you have to tell SWIG to create wrappers for a
particular
@ -1000,7 +997,9 @@ examples.
More details can be found in the <a href="SWIGPlus.html">SWIG and C++</a>
chapter.
<a name="n24"></a>
<h3>23.3.13 C++ Smart Pointers</h3>
<a name="n24"></a><H3>23.3.13 C++ Smart Pointers</H3>
In certain C++ programs, it is common to use classes that have been
wrapped by
so-called "smart pointers." Generally, this involves the use of a
@ -1036,7 +1035,9 @@ simply use the <tt>__deref__()</tt> method. For example:
<pre>irb(main):004:0&gt; <b>f = p.__deref__()</b> # Returns underlying Foo *<br></pre>
</blockquote>
<a name="n25"></a>
<h3>23.3.14 Cross-Language Polymorphism</h3>
<a name="n25"></a><H3>23.3.14 Cross-Language Polymorphism</H3>
SWIG's Ruby module supports cross-language polymorphism (a.k.a. the
"directors"
feature) similar to that for SWIG's Python module. Rather than
@ -1047,7 +1048,9 @@ secton just notes the differences that you need to be aware of when
using this
feature with Ruby.
<a name="n26"></a>
<h4>23.3.14.1 Exception Unrolling</h4>
<a name="n26"></a><H4>23.3.14.1 Exception Unrolling</H4>
Whenever a C++ director class routes one of its virtual member function
calls to a
Ruby instance method, there's always the possibility that an exception
@ -1070,7 +1073,9 @@ Ruby exception
is raised, it will be caught here and a C++ exception is raised in its
place.
<hr><a name="n27"></a>
<h2>23.4 Input and output parameters</h2>
<a name="n27"></a><H2>23.4 Input and output parameters</H2>
A common problem in some C programs is handling parameters passed as
simple
pointers. For example:
@ -1144,7 +1149,9 @@ In Ruby:
</blockquote>
<hr>
<a name="n28"></a>
<h2>23.5 Simple exception handling </h2>
<a name="n28"></a><H2>23.5 Simple exception handling </H2>
The SWIG <tt>%exception</tt> directive can be used to define a
user-definable
exception handler that can convert C/C++ errors into Ruby exceptions.
@ -1197,7 +1204,9 @@ Ruby exception classes, consult a Ruby reference such as <a
href="http://www.rubycentral.com/book"><em>Programming Ruby</em></a>.
</p>
<hr><a name="n29"></a>
<h2>23.6 Typemaps</h2>
<a name="n29"></a><H2>23.6 Typemaps</H2>
This section describes how you can modify SWIG's default wrapping
behavior
for various C/C++ datatypes using the <tt>%typemap</tt> directive.
@ -1212,7 +1221,9 @@ Typemaps are only used if you want to change some aspect of the
primitive
C-Ruby interface.
<a name="n30"></a></p>
<h3>23.6.1 What is a typemap?</h3>
<a name="n30"></a><H3>23.6.1 What is a typemap?</H3>
A typemap is nothing more than a code generation rule that is attached
to a specific C datatype. For example, to convert integers from Ruby to
C,
@ -1292,7 +1303,9 @@ follows (notice how the length parameter is omitted):
<pre>puts Example.count('o','Hello World')<br>2<br></pre>
</blockquote>
<a name="n31"></a>
<h3>23.6.2 Ruby typemaps</h3>
<a name="n31"></a><H3>23.6.2 Ruby typemaps</H3>
The previous section illustrated an "in" typemap for converting Ruby
objects to
C. A variety of different typemap methods are defined by the Ruby
@ -1348,7 +1361,9 @@ Examples of these typemaps appears in the <a href="#n34">section on
typemap
examples</a>
<a name="n32"></a>
<h3>23.6.3 Typemap variables</h3>
<a name="n32"></a><H3>23.6.3 Typemap variables</H3>
Within a typemap, a number of special variables prefaced with a <tt>$</tt>
may appear. A full list of variables can be found in the "<a
href="Typemaps.html">Typemaps</a>" chapter. This is a list of the most
@ -1390,7 +1405,9 @@ so that their values can be properly assigned.
<blockquote>The Ruby name of the wrapper function being created.
</blockquote>
<a name="n33"></a>
<h3>23.6.4 Useful Functions</h3>
<a name="n33"></a><H3>23.6.4 Useful Functions</H3>
When you write a typemap, you usually have to work directly with Ruby
objects.
The following functions may prove to be useful. (These functions plus
@ -1399,17 +1416,23 @@ more can be found in <a href="http://www.rubycentral.com/book"><em>Programming
Ruby</em></a>, by David Thomas
and Andrew Hunt.)
<p><a name="n34"></a></p>
<h4>23.6.4.1 C Datatypes to Ruby Objects</h4>
<a name="n34"></a><H4>23.6.4.1 C Datatypes to Ruby Objects</H4>
<blockquote>
<pre>INT2NUM(long or int) - int to Fixnum or Bignum<br>INT2FIX(long or int) - int to Fixnum (faster than INT2NUM)<br>CHR2FIX(char) - char to Fixnum<br>rb_str_new2(char*) - char* to String<br>rb_float_new(double) - double to Float<br></pre>
</blockquote>
<a name="n35"></a>
<h4>23.6.4.2 Ruby Objects to C Datatypes</h4>
<a name="n35"></a><H4>23.6.4.2 Ruby Objects to C Datatypes</H4>
<blockquote>
<pre> int NUM2INT(Numeric)<br> int FIX2INT(Numeric)<br> unsigned int NUM2UINT(Numeric)<br> unsigned int FIX2UINT(Numeric)<br> long NUM2LONG(Numeric)<br> long FIX2LONG(Numeric)<br>unsigned long FIX2ULONG(Numeric)<br> char NUM2CHR(Numeric or String)<br> char * STR2CSTR(String)<br> char * rb_str2cstr(String, int*length)<br> double NUM2DBL(Numeric)<br><br></pre>
</blockquote>
<a name="n36"></a>
<h4>23.6.4.3 Macros for VALUE</h4>
<a name="n36"></a><H4>23.6.4.3 Macros for VALUE</H4>
<p>
<tt>RSTRING(str)-&gt;len</tt>
</p>
@ -1423,7 +1446,9 @@ and Andrew Hunt.)
<tt>RARRAY(arr)-&gt;ptr</tt>
<blockquote>pointer to array storage</blockquote>
<a name="n37"></a>
<h4>23.6.4.4 Exceptions</h4>
<a name="n37"></a><H4>23.6.4.4 Exceptions</H4>
<p>
<tt>void rb_raise(VALUE exception, const char *fmt, ...)</tt>
</p>
@ -1480,7 +1505,9 @@ if Ruby was invoked with the <tt>-w</tt> flag. The given format string
<i>fmt</i> and remaining arguments are interpreted as with <tt>printf()</tt>.
</blockquote>
<a name="n38"></a>
<h4>23.6.4.5 Iterators</h4>
<a name="n38"></a><H4>23.6.4.5 Iterators</H4>
<p>
<tt>void rb_iter_break()</tt>
</p>
@ -1512,12 +1539,16 @@ value)</tt>
<blockquote> Equivalent to Ruby's <tt>throw</tt>.
</blockquote>
<a name="n39"></a>
<h3>23.6.5 Typemap Examples</h3>
<a name="n39"></a><H3>23.6.5 Typemap Examples</H3>
This section includes a few examples of typemaps. For more examples,
you
might look at the examples in the <tt>Example/ruby</tt> directory.
<a name="n40"></a>
<h3>23.6.6 Converting a Ruby array to a char **</h3>
<a name="n40"></a><H3>23.6.6 Converting a Ruby array to a char **</H3>
A common problem in many C programs is the processing of command line
arguments, which are usually passed in an array of <tt>NULL</tt>
terminated
@ -1543,7 +1574,9 @@ allocation is used to allocate memory for the array, the "freearg"
typemap is
used to later release this memory after the execution of the C
function. <a name="n41"></a>
<h3>23.6.7 Collecting arguments in a hash</h3>
<a name="n41"></a><H3>23.6.7 Collecting arguments in a hash</H3>
Ruby's solution to the "keyword arguments" capability of some other
languages is
to allow the programmer to pass in one or more key-value pairs as
@ -1681,7 +1714,9 @@ the extension, can be found in the <tt>Examples/ruby/hashargs</tt>
directory
of the SWIG distribution.
<a name="n42"></a>
<h3>23.6.8 Pointer handling</h3>
<a name="n42"></a><H3>23.6.8 Pointer handling</H3>
Occasionally, it might be necessary to convert pointer values that have
been
stored using the SWIG typed-pointer representation. Since there are
@ -1740,7 +1775,9 @@ typemap variable <tt>$1_descriptor</tt>. For example:
<pre>%typemap(in) Foo * {<br> SWIG_ConvertPtr($input, (void **) &amp;$1, $1_descriptor, 1);<br>}<br></pre>
</blockquote>
<a name="n43"></a>
<h4>23.6.8.1 Ruby Datatype Wrapping</h4>
<a name="n43"></a><H4>23.6.8.1 Ruby Datatype Wrapping</H4>
<p>
<tt>VALUE Data_Wrap_Struct(VALUE class, void (*mark)(void *), void
(*free)(void *), void *ptr)</tt>
@ -1763,7 +1800,9 @@ from the data object
</blockquote>
<hr>
<a name="n44"></a>
<h2>23.7 Operator overloading</h2>
<a name="n44"></a><H2>23.7 Operator overloading</H2>
SWIG allows operator overloading with, by using the <tt>%extend</tt>
or
<tt>%rename</tt> commands in SWIG and the following operator names
@ -1777,7 +1816,9 @@ for defining an equivalence operator, there is no separate method for
handling <i>inequality</i> since Ruby parses the expression <i>a != b</i>
as <i>!(a == b)</i>.
<a name="n45"></a>
<h3>23.7.1 Example: STL Vector to Ruby Array</h3>
<a name="n45"></a><H3>23.7.1 Example: STL Vector to Ruby Array</H3>
<em><b>FIXME: This example is out of place here!</b></em>
<p>Another use for macros and type maps is to create a Ruby array from
a STL
@ -1831,9 +1872,13 @@ types:
%enddef
</blockquote></pre>
<a name="n46"></a>
<h2>23.8 Advanced Topics</h2>
<a name="n46"></a><H2>23.8 Advanced Topics</H2>
<a name="n47"></a>
<h3>23.8.1 Creating Multi-Module Packages</h3>
<a name="n47"></a><H3>23.8.1 Creating Multi-Module Packages</H3>
The chapter on <a href="Advanced.html">Advanced Topics</a> discusses
the basics
of creating multi-module extensions with SWIG, and in particular
@ -1922,7 +1967,9 @@ irb(main):005:0&gt; <b>c.getX()</b>
</pre>
</blockquote>
<a name="n48"></a>
<h3>23.8.2 Defining Aliases</h3>
<a name="n48"></a><H3>23.8.2 Defining Aliases</H3>
It's a fairly common practice in the Ruby built-ins and standard
library to
provide aliases for method names. For example, <em>Array#size</em> is
@ -1966,7 +2013,9 @@ apply (see the chapter on <a href="Customization.html">"Customization
Features"</a>)
for more details).
<a name="n49"></a></p>
<h3>23.8.3 Predicate Methods</h3>
<a name="n49"></a><H3>23.8.3 Predicate Methods</H3>
Predicate methods in Ruby are those which return either <tt>true</tt>
or
<tt>false</tt>. By convention, these methods' names end in a question
@ -2013,7 +2062,9 @@ kinds
of features apply (see the chapter on <a href="Customization.html">"Customization
Features"</a>) for more details).
<a name="n50"></a>
<h3>23.8.4 Specifying Mixin Modules</h3>
<a name="n50"></a><H3>23.8.4 Specifying Mixin Modules</H3>
The Ruby language doesn't support multiple inheritance, but it does
allow you
to mix one or more modules into a class using Ruby's <tt>include</tt>
@ -2062,7 +2113,9 @@ kinds
of features apply (see the chapter on <a href="Customization.html">"Customization
Features"</a>) for more details).
<a name="n51"></a>
<h3>23.8.5 Interacting with Ruby's Garbage Collector</h3>
<a name="n51"></a><H3>23.8.5 Interacting with Ruby's Garbage Collector</H3>
<b>This section is still unfinished!</b>
<p>By default, SWIG ensures that any C++ objects it creates are
destroyed when the

View file

@ -436,4 +436,4 @@ using shared libraries instead.
<address>SWIG 1.3 - Last Modified : July 16, 2001</address>
</body>
</html>
</html>

View file

@ -2927,4 +2927,4 @@ interesting things.<p>
<address>SWIG 1.3 - Last Modified : May 28, 2002</address>
</body>
</html>
</html>

View file

@ -52,20 +52,20 @@
<li><a href="#n35">"memberin" typemap</a>
<li><a href="#n36">"varin" typemap</a>
<li><a href="#n37">"varout" typemap</a>
<li><a href="#n371">"throws" typemap</a>
<li><a href="#n38">"throws" typemap</a>
</ul>
<li><a href="#n38">Some typemap examples</a>
<li><a href="#n39">Some typemap examples</a>
<ul>
<li><a href="#n39">Typemaps for arrays</a>
<li><a href="#n40">Implementing constraints with typemaps</a>
<li><a href="#n40">Typemaps for arrays</a>
<li><a href="#n41">Implementing constraints with typemaps</a>
</ul>
<li><a href="#n41">Multi-argument typemaps</a>
<li><a href="#n42">The run-time type checker</a>
<li><a href="#n43">Typemaps and overloading</a>
<li><a href="#n44">More about <tt>%apply</tt> and <tt>%clear</tt></a>
<li><a href="#n45">Reducing wrapper code size</a>
<li><a href="#n46">Passing data between typemaps</a>
<li><a href="#n47">Where to go for more information?</a>
<li><a href="#n42">Multi-argument typemaps</a>
<li><a href="#n43">The run-time type checker</a>
<li><a href="#n44">Typemaps and overloading</a>
<li><a href="#n45">More about <tt>%apply</tt> and <tt>%clear</tt></a>
<li><a href="#n46">Reducing wrapper code size</a>
<li><a href="#n47">Passing data between typemaps</a>
<li><a href="#n48">Where to go for more information?</a>
</ul>
<!-- INDEX -->
@ -1876,7 +1876,8 @@ The "varout" typemap is used to convert a C/C++ object to an object in the targe
language when reading a C/C++ global variable. This is implementation specific.
<a name="throws_typemap"></a>
<a name="n371"></a><H3>8.5.13 "throws" typemap</H3>
<a name="n38"></a><H3>8.5.13 "throws" typemap</H3>
The "throws" typemap is only used when SWIG parses a C++ method with an exception specification.
It provides a default mechanism for handling C++ methods that have declared the exceptions it will throw.
@ -1915,13 +1916,13 @@ catch(char const *_e) {
Note that if your methods do not have an exception specification yet they do throw exceptions, SWIG cannot know how to deal with them.
For a neat way to handle these, see the <a href="Customization.html#exception">Exception handling with %exception</a> section.
<a name="n38"></a><H2>8.6 Some typemap examples</H2>
<a name="n39"></a><H2>8.6 Some typemap examples</H2>
This section contains a few examples. Consult language module documentation
for more examples.
<a name="n39"></a><H3>8.6.1 Typemaps for arrays</H3>
<a name="n40"></a><H3>8.6.1 Typemaps for arrays</H3>
A common use of typemaps is to provide support for C arrays appearing both as
@ -2151,7 +2152,7 @@ Now, you will find that member access is quite nice:
<b>Compatibility Note:</b> SWIG1.1 used to provide a special "memberout" typemap. However, it was mostly
useless and has since been eliminated. To return structure members, simply use the "out" typemap.
<a name="n40"></a><H3>8.6.2 Implementing constraints with typemaps</H3>
<a name="n41"></a><H3>8.6.2 Implementing constraints with typemaps</H3>
One particularly interesting application of typemaps is the
@ -2197,7 +2198,7 @@ rather than blindly passing values to the underlying C/C++ program.<p>
<p>
Note: A more advanced constraint checking system is in development. Stay tuned.
<a name="n41"></a><H2>8.7 Multi-argument typemaps</H2>
<a name="n42"></a><H2>8.7 Multi-argument typemaps</H2>
So far, the typemaps presented have focused on the problem of dealing with
@ -2433,7 +2434,8 @@ Numeric Python. However, it should also be stressed that some care is in order.
when crossing languages you may need to worry about issues such as row-major vs. column-major
ordering (and perform conversions if needed).
<a name="n42"></a><H2>8.8 The run-time type checker</H2>
<a name="n43"></a><H2>8.8 The run-time type checker</H2>
The run-time type checker is used by many, but not all, of SWIG's supported target languages.
The run-time type checker features
@ -2631,7 +2633,7 @@ type-checking. This code is also included in every generated wrapped file so yo
probably just look at the output of SWIG to get a better sense for how types are
managed.
<a name="n43"></a><H2>8.9 Typemaps and overloading</H2>
<a name="n44"></a><H2>8.9 Typemaps and overloading</H2>
In many target languages, SWIG fully supports C++ overloaded methods and functions. For example,
@ -2915,7 +2917,7 @@ Subsequent "in" typemaps would then perform more extensive type-checking.
<Li>Make sure you read the section on overloading in the "<a href="SWIGPlus.html">SWIG and C++</a>" chapter.
</ul>
<a name="n44"></a><H2>8.10 More about <tt>%apply</tt> and <tt>%clear</tt></H2>
<a name="n45"></a><H2>8.10 More about <tt>%apply</tt> and <tt>%clear</tt></H2>
In order to implement certain kinds of program behavior, it is sometimes necessary to
@ -2988,7 +2990,7 @@ example:
</pre>
</blockquote>
<a name="n45"></a><H2>8.11 Reducing wrapper code size</H2>
<a name="n46"></a><H2>8.11 Reducing wrapper code size</H2>
Since the code supplied to a typemap is inlined directly into wrapper functions, typemaps can result
@ -3064,7 +3066,7 @@ convert_float_array(PyObject *input, int size) {
</pre>
</blockquote>
<a name="n46"></a><H2>8.12 Passing data between typemaps</H2>
<a name="n47"></a><H2>8.12 Passing data between typemaps</H2>
<p>
@ -3098,7 +3100,7 @@ in this manner should probably be avoided. At the very least, you should make
sure that the typemaps sharing information have exactly the same types and names.
<a name="n47"></a><H2>8.13 Where to go for more information?</H2>
<a name="n48"></a><H2>8.13 Where to go for more information?</H2>
The

View file

@ -828,4 +828,4 @@ this will introduce. Good luck.
<address>SWIG 1.3 - Last Modified : March 24, 2002</address>
</body>
</html>
</html>

View file

@ -13,18 +13,19 @@
<li><a href="#n4">Enabling additional warnings</a>
<li><a href="#n5">Issuing a warning message</a>
<li><a href="#n6">Commentary</a>
<li><a href="#n7">Message output format</a>
<li><a href="#n8">Warning number reference</a>
<li><a href="#n7">Warnings as errors</a>
<li><a href="#n8">Message output format</a>
<li><a href="#n9">Warning number reference</a>
<ul>
<li><a href="#n9">Deprecated features (100-199)</a>
<li><a href="#n10">Preprocessor (200-299)</a>
<li><a href="#n11">C/C++ Parser (300-399)</a>
<li><a href="#n12">Types and typemaps (400-499) </a>
<li><a href="#n13">Code generation (500-599)</a>
<li><a href="#n14">Language module specific (800-899) </a>
<li><a href="#n15">User defined (900-999)</a>
<li><a href="#n10">Deprecated features (100-199)</a>
<li><a href="#n11">Preprocessor (200-299)</a>
<li><a href="#n12">C/C++ Parser (300-399)</a>
<li><a href="#n13">Types and typemaps (400-499) </a>
<li><a href="#n14">Code generation (500-599)</a>
<li><a href="#n15">Language module specific (800-899) </a>
<li><a href="#n16">User defined (900-999)</a>
</ul>
<li><a href="#n16">History</a>
<li><a href="#n17">History</a>
</ul>
<!-- INDEX -->
@ -219,10 +220,16 @@ explicitly.
Certain types of SWIG problems are errors. These usually arise due to
parsing errors (bad syntax) or semantic problems for which there is
no obvious recovery. There is no mechanism for suppressing error
messages or handling errors as warnings---you must make changes to
the input file to fix the problem.
messages.
<a name="n7"></a><H2>12.6 Message output format</H2>
<a name="n7"></a><H2>12.6 Warnings as errors</H2>
Warnings can be handled as errors by using the <tt>-Werror</tt> command line
option. This will cause SWIG to exit with a non successful exit code if a
warning is encountered.
<a name="n8"></a><H2>12.7 Message output format</H2>
The output format for both warnings and errors can be selected for
@ -239,10 +246,10 @@ $ swig -python -Fmicrosoft example.i
example.i(4): Syntax error in input.
</pre></blockquote>
<a name="n8"></a><H2>12.7 Warning number reference</H2>
<a name="n9"></a><H2>12.8 Warning number reference</H2>
<a name="n9"></a><H3>12.7.1 Deprecated features (100-199)</H3>
<a name="n10"></a><H3>12.8.1 Deprecated features (100-199)</H3>
<ul>
@ -268,7 +275,7 @@ example.i(4): Syntax error in input.
<li>120. Deprecated command line option (-c).
</ul>
<a name="n10"></a><H3>12.7.2 Preprocessor (200-299)</H3>
<a name="n11"></a><H3>12.8.2 Preprocessor (200-299)</H3>
<ul>
@ -276,7 +283,7 @@ example.i(4): Syntax error in input.
<li>202. Could not evaluate 'expr'.
</ul>
<a name="n11"></a><H3>12.7.3 C/C++ Parser (300-399)</H3>
<a name="n12"></a><H3>12.8.3 C/C++ Parser (300-399)</H3>
<ul>
@ -350,7 +357,7 @@ example.i(4): Syntax error in input.
<li>395. operator delete[] ignored.
</ul>
<a name="n12"></a><H3>12.7.4 Types and typemaps (400-499) </H3>
<a name="n13"></a><H3>12.8.4 Types and typemaps (400-499) </H3>
<ul>
@ -372,7 +379,7 @@ example.i(4): Syntax error in input.
<li>468. No 'throw' typemap defined for exception type 'type'.
</ul>
<a name="n13"></a><H3>12.7.5 Code generation (500-599)</H3>
<a name="n14"></a><H3>12.8.5 Code generation (500-599)</H3>
<ul>
@ -394,7 +401,7 @@ example.i(4): Syntax error in input.
<li>516. Overloaded method <em>declaration</em> ignored. Method <em>declaration</em> at <em>file</em>:<em>line</em> used.
</ul>
<a name="n14"></a><H3>12.7.6 Language module specific (800-899) </H3>
<a name="n15"></a><H3>12.8.6 Language module specific (800-899) </H3>
<ul>
@ -433,12 +440,12 @@ example.i(4): Syntax error in input.
<li>842. Covariant return types not supported in C#. Proxy method will return <em>basetype</em> (C#).
</ul>
<a name="n15"></a><H3>12.7.7 User defined (900-999)</H3>
<a name="n16"></a><H3>12.8.7 User defined (900-999)</H3>
These numbers can be used by your own application.
<a name="n16"></a><H2>12.8 History</H2>
<a name="n17"></a><H2>12.9 History</H2>
The ability to control warning messages was first added to SWIG-1.3.12.
@ -446,4 +453,4 @@ The ability to control warning messages was first added to SWIG-1.3.12.
<p><hr>
<address>SWIG 1.3 - Last Modified : June 28, 2003</address>
</body>
</html>
</html>

View file

@ -12,28 +12,28 @@
<ul>
<li><a href="#n3">Windows Executable</a>
</ul>
<li><a href="#n5">SWIG Windows Examples</a>
<li><a href="#n4">SWIG Windows Examples</a>
<ul>
<li><a href="#n6">Instructions for using the Examples with Visual Studio</a>
<li><a href="#n5">Instructions for using the Examples with Visual Studio</a>
<ul>
<li><a href="#n7">Python</a>
<li><a href="#n8">TCL</a>
<li><a href="#n9">Perl</a>
<li><a href="#n10">Java</a>
<li><a href="#n11">Ruby</a>
<li><a href="#n12">C#</a>
<li><a href="#n6">Python</a>
<li><a href="#n7">TCL</a>
<li><a href="#n8">Perl</a>
<li><a href="#n9">Java</a>
<li><a href="#n10">Ruby</a>
<li><a href="#n11">C#</a>
</ul>
<li><a href="#n13">Instructions for using the Examples with other compilers</a>
<li><a href="#n12">Instructions for using the Examples with other compilers</a>
</ul>
<li><a href="#n14">SWIG on Cygwin and MinGW</a>
<li><a href="#n13">SWIG on Cygwin and MinGW</a>
<ul>
<li><a href="#n15">Building swig.exe on Windows</a>
<li><a href="#n14">Building swig.exe on Windows</a>
<ul>
<li><a href="#n16">Building swig.exe using MinGW and MSYS</a>
<li><a href="#n17">Building swig.exe using Cygwin</a>
<li><a href="#n18">Building swig.exe alternatives</a>
<li><a href="#n15">Building swig.exe using MinGW and MSYS</a>
<li><a href="#n16">Building swig.exe using Cygwin</a>
<li><a href="#n17">Building swig.exe alternatives</a>
</ul>
<li><a href="#n19">Running the examples on Windows using Cygwin</a>
<li><a href="#n18">Running the examples on Windows using Cygwin</a>
</ul>
</ul>
<!-- INDEX -->
@ -63,7 +63,7 @@ If you want to build your own swig.exe have a look at <a href="#swig_exe">Buildi
<a name="examples"></a>
<a name="n5"></a><H2>2.2 SWIG Windows Examples</H2>
<a name="n4"></a><H2>2.2 SWIG Windows Examples</H2>
Using Microsoft Visual C++ is the most common approach to compiling and linking SWIG's output.
@ -77,7 +77,7 @@ Alternatively run the <a href="#examples_cygwin">examples using Cygwin</a>.
More information on each of the examples is available with the examples distributed with SWIG (Examples/index.html).
<a name="n6"></a><H3>2.2.1 Instructions for using the Examples with Visual Studio</H3>
<a name="n5"></a><H3>2.2.1 Instructions for using the Examples with Visual Studio</H3>
Ensure the SWIG executable is as supplied in the SWIG root directory in order for the examples to work.
@ -92,7 +92,7 @@ They are usually set from the Control Panel and System properties, but this depe
If you don't want to use environment variables then change all occurences of the environment variables in the .dsp files with hard coded values.
If you are interested in how the project files are set up there is explanatory information in some of the language module's documentation.
<a name="n7"></a><H4>2.2.1.1 Python</H4>
<a name="n6"></a><H4>2.2.1.1 Python</H4>
<b><tt>PYTHON_INCLUDE</tt></b> : Set this to the directory that contains python.h<br>
@ -103,7 +103,7 @@ PYTHON_INCLUDE: d:\python21\include<br>
PYTHON_LIB: d:\python21\libs\python21.lib<br>
</tt>
<a name="n8"></a><H4>2.2.1.2 TCL</H4>
<a name="n7"></a><H4>2.2.1.2 TCL</H4>
<b><tt>TCL_INCLUDE</tt></b> : Set this to the directory containing tcl.h<br>
@ -114,7 +114,7 @@ TCL_INCLUDE: d:\tcl\include<br>
TCL_LIB: d:\tcl\lib\tcl83.lib<br>
</tt>
<a name="n9"></a><H4>2.2.1.3 Perl</H4>
<a name="n8"></a><H4>2.2.1.3 Perl</H4>
<b><tt>PERL5_INCLUDE</tt></b> : Set this to the directory containing perl.h<br>
@ -125,7 +125,7 @@ PERL5_INCLUDE: D:\nsPerl5.004_04\lib\CORE<br>
PERL5_LIB: D:\nsPerl5.004_04\lib\CORE\perl.lib<br>
</tt>
<a name="n10"></a><H4>2.2.1.4 Java</H4>
<a name="n9"></a><H4>2.2.1.4 Java</H4>
<b><tt>JAVA_INCLUDE</tt></b> : Set this to the directory containing jni.h<br>
@ -136,7 +136,7 @@ JAVA_INCLUDE: d:\jdk1.3\include<br>
JAVA_BIN: d:\jdk1.3\bin<br>
</tt>
<a name="n11"></a><H4>2.2.1.5 Ruby</H4>
<a name="n10"></a><H4>2.2.1.5 Ruby</H4>
<b><tt>RUBY_INCLUDE</tt></b> : Set this to the directory containing ruby.h<br>
@ -147,25 +147,25 @@ RUBY_INCLUDE: D:\ruby\lib\ruby\1.6\i586-mswin32<br>
RUBY_LIB: D:\ruby\lib\mswin32-ruby16.lib<br>
</tt>
<a name="n12"></a><H4>2.2.1.6 C#</H4>
<a name="n11"></a><H4>2.2.1.6 C#</H4>
The C# examples do not require any environment variables to be set as a C# project file is included.
Just open up the .sln solution file in Visual Studio .NET 2003 and do a Rebuild All from the Build menu.
The accompanying C# and C++ project file are automatically used by the solution file.
<a name="n13"></a><H3>2.2.2 Instructions for using the Examples with other compilers</H3>
<a name="n12"></a><H3>2.2.2 Instructions for using the Examples with other compilers</H3>
If you do not have access to Visual C++ you will have to set up project files / Makefiles for your chosen compiler. There is a section in each of the language modules detailing what needs setting up using Visual C++ which may be of some guidance. Alternatively you may want to use Cygwin as described in the following section.
<a name="n14"></a><H2>2.3 SWIG on Cygwin and MinGW</H2>
<a name="n13"></a><H2>2.3 SWIG on Cygwin and MinGW</H2>
SWIG can also be compiled and run using <a href="http://www.cygwin.com">Cygwin</a> or <a href=http://www.mingw.org>MinGW</a> which provides a Unix like front end to Windows and comes free with gcc, an ANSI C/C++ compiler. However, this is not a recommended approach as the prebuilt executable is supplied.
<a name="swig_exe"></a>
<a name="n15"></a><H3>2.3.1 Building swig.exe on Windows</H3>
<a name="n14"></a><H3>2.3.1 Building swig.exe on Windows</H3>
If you want to replicate the build of swig.exe that comes with the download, follow the MinGW instructions below.
@ -173,7 +173,7 @@ This is not necessary to use the supplied swig.exe.
This information is provided for those that want to modify the SWIG source code in a Windows environment.
Normally this is not needed, so most people will want to ignore this section.
<a name="n16"></a><H4>2.3.1.1 Building swig.exe using MinGW and MSYS</H4>
<a name="n15"></a><H4>2.3.1.1 Building swig.exe using MinGW and MSYS</H4>
<ul>
@ -182,7 +182,7 @@ Normally this is not needed, so most people will want to ignore this section.
</ul>
<a name="n17"></a><H4>2.3.1.2 Building swig.exe using Cygwin</H4>
<a name="n16"></a><H4>2.3.1.2 Building swig.exe using Cygwin</H4>
Note that SWIG can also be built using Cygwin.
@ -192,7 +192,7 @@ Note that the Cygwin environment will also allow one to regenerate the autotool
These files are generated using the <tt>autogen.sh</tt> script and will only need regenerating in circumstances such as changing the build system.
<p>
<a name="n18"></a><H4>2.3.1.3 Building swig.exe alternatives</H4>
<a name="n17"></a><H4>2.3.1.3 Building swig.exe alternatives</H4>
If you don't want to install Cygwin or MinGW, use a different compiler to build
@ -201,7 +201,7 @@ file in order to build swig.exe from the Visual C++ IDE.
<a name="examples_cygwin"></a>
<a name="n19"></a><H3>2.3.2 Running the examples on Windows using Cygwin</H3>
<a name="n18"></a><H3>2.3.2 Running the examples on Windows using Cygwin</H3>
The examples and test-suite work as successfully on Cygwin as on any other Unix operating system.

View file

@ -6,7 +6,7 @@
<body bgcolor="#ffffff">
<H1>SWIG1.3 Development Documentation</h1>
Last update : SWIG-1.3.21 (11 January 2004)
Last update : SWIG-1.3.22 (?? ??? 2004)
<p>
<b>Authors:</b>
@ -55,6 +55,8 @@ to help!).
<H3>Language Module Documentation</h3>
<ul>
<li><a href="CSharp.html">C# support</a>
<li><a href="Chicken.html">Chicken support</a>
<li><a href="Guile.html">Guile support</a>
<li><a href="Java.html">Java support</a>
<li><a href="Ocaml.html">Ocaml support</a>
@ -63,8 +65,6 @@ to help!).
<li><a href="Python.html">Python support</a>
<li><a href="Ruby.html">Ruby support</a>
<li><a href="Tcl.html">Tcl support</a>
<li><a href="Chicken.html">Chicken support</a>
<li><a href="CSharp.html">C# support</a>
</ul>
<H3>Developer Documentation</h3>