Huge update to the Allegrocl module. Better C support. C++ support

added. Documentation! Makes use of typemaps for better interface
tuning. Improved type support. Wrapping of foreign pointers in
CLOS objects; hopefully a step toward being able to extend C++
classes from Lisp.


git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7828 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Ahmon Dancy 2005-11-09 20:44:22 +00:00
commit 4098a01b68
22 changed files with 3703 additions and 882 deletions

View file

@ -5,7 +5,7 @@
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body style="background-color: rgb(255, 255, 255);">
<H1><a name="Ruby"></a>27 SWIG and Ruby</H1>
<H1><a name="Ruby"></a>29 SWIG and Ruby</H1>
<!-- INDEX -->
<div class="sectiontoc">
<ul>
@ -223,7 +223,7 @@
</ul>
</div> <!-- INDEX -->
<p>This chapter describes SWIG's support of Ruby.</p>
<H2><a name="Ruby_nn2"></a>27.1 Preliminaries</H2>
<H2><a name="Ruby_nn2"></a>29.1 Preliminaries</H2>
<p>
@ -237,7 +237,7 @@
Basics</a>" chapter. It is also assumed that the reader has a basic
understanding of Ruby.
</p>
<H3><a name="Ruby_nn3"></a>27.1.1 Running SWIG</H3>
<H3><a name="Ruby_nn3"></a>29.1.1 Running SWIG</H3>
<p>
@ -259,7 +259,7 @@
extension module. To finish building the module, you need to compile this file
and link it with the rest of your program.
</p>
<H3><a name="Ruby_nn4"></a>27.1.2 Getting the right header files</H3>
<H3><a name="Ruby_nn4"></a>29.1.2 Getting the right header files</H3>
<p>
@ -280,7 +280,7 @@ $ <b>ruby -e 'puts $:.join("\n")'</b><br>/usr/local/lib/ruby/site_ruby/1.6 /usr/
/usr/local/lib/ruby/site_ruby /usr/local/lib/ruby/1.6 /usr/local/lib/ruby/1.6/i686-linux .
</pre>
</div>
<H3><a name="Ruby_nn5"></a>27.1.3 Compiling a dynamic module</H3>
<H3><a name="Ruby_nn5"></a>29.1.3 Compiling a dynamic module</H3>
<p>
@ -332,7 +332,7 @@ $ <b>ruby -e 'puts $:.join("\n")'</b><br>/usr/local/lib/ruby/site_ruby/1.6 /usr/
<p>
<a name="n6"></a>
</p>
<H3><a name="Ruby_nn6"></a>27.1.4 Using your module</H3>
<H3><a name="Ruby_nn6"></a>29.1.4 Using your module</H3>
<p>
@ -356,7 +356,7 @@ $ <b>ruby -e 'puts $:.join("\n")'</b><br>/usr/local/lib/ruby/site_ruby/1.6 /usr/
will result in an extension module using the feature name "example" and Ruby
module name "Example".
</p>
<H3><a name="Ruby_nn7"></a>27.1.5 Static linking</H3>
<H3><a name="Ruby_nn7"></a>29.1.5 Static linking</H3>
<p>
@ -372,7 +372,7 @@ $ <b>ruby -e 'puts $:.join("\n")'</b><br>/usr/local/lib/ruby/site_ruby/1.6 /usr/
to the list of extensions in the file, and finally rebuilding Ruby.
</p>
<p><a name="n8"></a></p>
<H3><a name="Ruby_nn8"></a>27.1.6 Compilation of C++ extensions</H3>
<H3><a name="Ruby_nn8"></a>29.1.6 Compilation of C++ extensions</H3>
<p>
@ -396,7 +396,7 @@ $ <b>ruby -e 'puts $:.join("\n")'</b><br>/usr/local/lib/ruby/site_ruby/1.6 /usr/
<div class="code">
<pre>require 'mkmf'<br>$libs = append_library($libs, "supc++")<br>create_makefile('example')<br></pre>
</div>
<H2><a name="Ruby_nn9"></a>27.2 Building Ruby Extensions under Windows 95/NT</H2>
<H2><a name="Ruby_nn9"></a>29.2 Building Ruby Extensions under Windows 95/NT</H2>
<p>
@ -419,7 +419,7 @@ $ <b>ruby -e 'puts $:.join("\n")'</b><br>/usr/local/lib/ruby/site_ruby/1.6 /usr/
will need the Ruby header files.
</p>
<p><a name="n10"></a></p>
<H3><a name="Ruby_nn10"></a>27.2.1 Running SWIG from Developer Studio</H3>
<H3><a name="Ruby_nn10"></a>29.2.1 Running SWIG from Developer Studio</H3>
<p>
@ -487,14 +487,14 @@ $ <b>ruby -e 'puts $:.join("\n")'</b><br>/usr/local/lib/ruby/site_ruby/1.6 /usr/
<div class="code">
<pre>C:\swigtest&gt; <b>ruby run.rb</b><br>Foo = 3.0<br></pre>
</div>
<H2><a name="Ruby_nn11"></a>27.3 The Ruby-to-C/C++ Mapping</H2>
<H2><a name="Ruby_nn11"></a>29.3 The Ruby-to-C/C++ Mapping</H2>
<p>
This section describes the basics of how SWIG maps C or C++ declarations in
your SWIG interface files to Ruby constructs.
</p>
<H3><a name="Ruby_nn12"></a>27.3.1 Modules</H3>
<H3><a name="Ruby_nn12"></a>29.3.1 Modules</H3>
<p>
@ -561,7 +561,7 @@ $ <b>ruby -e 'puts $:.join("\n")'</b><br>/usr/local/lib/ruby/site_ruby/1.6 /usr/
global module, take care that the names of your constants, classes and methods
don't conflict with any of Ruby's built-in names.
</p>
<H3><a name="Ruby_nn13"></a>27.3.2 Functions</H3>
<H3><a name="Ruby_nn13"></a>29.3.2 Functions</H3>
<p>
@ -584,7 +584,7 @@ $ <b>ruby -e 'puts $:.join("\n")'</b><br>/usr/local/lib/ruby/site_ruby/1.6 /usr/
<div class="code">
<pre>$ <b>irb</b><br>irb(main):001:0&gt; <b>require 'example'</b><br>true<br>irb(main):002:0&gt; <b>Example.fact(4)</b><br>24<br></pre>
</div>
<H3><a name="Ruby_nn14"></a>27.3.3 Variable Linking</H3>
<H3><a name="Ruby_nn14"></a>29.3.3 Variable Linking</H3>
<p>
@ -621,7 +621,7 @@ $ <b>ruby -e 'puts $:.join("\n")'</b><br>/usr/local/lib/ruby/site_ruby/1.6 /usr/
The <tt>%immutable</tt> directive stays in effect until it is explicitly
disabled using <tt>%mutable</tt>.
</p>
<H3><a name="Ruby_nn15"></a>27.3.4 Constants</H3>
<H3><a name="Ruby_nn15"></a>29.3.4 Constants</H3>
<p>
@ -638,7 +638,7 @@ $ <b>ruby -e 'puts $:.join("\n")'</b><br>/usr/local/lib/ruby/site_ruby/1.6 /usr/
<div class="code">
<pre>$ <b>irb</b><br>irb(main):001:0&gt; <b>require 'Example'</b><br>true<br>irb(main):002:0&gt; <b>Example::PI</b><br>3.14159<br></pre>
</div>
<H3><a name="Ruby_nn16"></a>27.3.5 Pointers</H3>
<H3><a name="Ruby_nn16"></a>29.3.5 Pointers</H3>
<p>
@ -659,7 +659,7 @@ $ <b>ruby -e 'puts $:.join("\n")'</b><br>/usr/local/lib/ruby/site_ruby/1.6 /usr/
<p>
A <tt>NULL</tt> pointer is always represented by the Ruby <tt>nil</tt> object.
</p>
<H3><a name="Ruby_nn17"></a>27.3.6 Structures</H3>
<H3><a name="Ruby_nn17"></a>29.3.6 Structures</H3>
<p>
@ -724,7 +724,7 @@ $ <b>ruby -e 'puts $:.join("\n")'</b><br>/usr/local/lib/ruby/site_ruby/1.6 /usr/
<div class="code">
<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>
</div>
<H3><a name="Ruby_nn18"></a>27.3.7 C++ classes</H3>
<H3><a name="Ruby_nn18"></a>29.3.7 C++ classes</H3>
<p>
@ -758,7 +758,7 @@ $ <b>ruby -e 'puts $:.join("\n")'</b><br>/usr/local/lib/ruby/site_ruby/1.6 /usr/
<div class="code">
<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>
</div>
<H3><a name="Ruby_nn19"></a>27.3.8 C++ Inheritance</H3>
<H3><a name="Ruby_nn19"></a>29.3.8 C++ Inheritance</H3>
<p>
@ -851,7 +851,7 @@ $ <b>ruby -e 'puts $:.join("\n")'</b><br>/usr/local/lib/ruby/site_ruby/1.6 /usr/
will otherwise behave as though they inherit from both <tt>Base1</tt> and <tt>Base2</tt>
(i.e. they exhibit <a href="http://c2.com/cgi/wiki?DuckTyping">"Duck Typing"</a>).
</p>
<H3><a name="Ruby_nn20"></a>27.3.9 C++ Overloaded Functions</H3>
<H3><a name="Ruby_nn20"></a>29.3.9 C++ Overloaded Functions</H3>
<p>
@ -913,7 +913,7 @@ $ <b>ruby -e 'puts $:.join("\n")'</b><br>/usr/local/lib/ruby/site_ruby/1.6 /usr/
<p>Please refer to the <a href="SWIGPlus.html#SWIGPlus">"SWIG and C++"</a> chapter
for more information about overloading. <a name="n21"></a>
</p>
<H3><a name="Ruby_nn21"></a>27.3.10 C++ Operators</H3>
<H3><a name="Ruby_nn21"></a>29.3.10 C++ Operators</H3>
<p>
@ -943,7 +943,7 @@ $ <b>ruby -e 'puts $:.join("\n")'</b><br>/usr/local/lib/ruby/site_ruby/1.6 /usr/
More details about wrapping C++ operators into Ruby operators is discussed in
the <a href="#ruby_operator_overloading">section on operator overloading</a>.
</p>
<H3><a name="Ruby_nn22"></a>27.3.11 C++ namespaces</H3>
<H3><a name="Ruby_nn22"></a>29.3.11 C++ namespaces</H3>
<p>
@ -973,7 +973,7 @@ $ <b>ruby -e 'puts $:.join("\n")'</b><br>/usr/local/lib/ruby/site_ruby/1.6 /usr/
namespaces each with identical symbol names, well, then you get what you
deserve.
</p>
<H3><a name="Ruby_nn23"></a>27.3.12 C++ templates</H3>
<H3><a name="Ruby_nn23"></a>29.3.12 C++ templates</H3>
<p>
@ -1014,7 +1014,7 @@ $ <b>ruby -e 'puts $:.join("\n")'</b><br>/usr/local/lib/ruby/site_ruby/1.6 /usr/
examples. More details can be found in the <a href="SWIGPlus.html#SWIGPlus">SWIG
and C++</a> chapter.
</p>
<H3><a name="ruby_cpp_smart_pointers"></a>27.3.13 C++ Smart Pointers</H3>
<H3><a name="ruby_cpp_smart_pointers"></a>29.3.13 C++ Smart Pointers</H3>
<p>
@ -1052,7 +1052,7 @@ $ <b>ruby -e 'puts $:.join("\n")'</b><br>/usr/local/lib/ruby/site_ruby/1.6 /usr/
<div class="code">
<pre>irb(main):004:0&gt; <b>f = p.__deref__()</b> # Returns underlying Foo *<br></pre>
</div>
<H3><a name="Ruby_nn25"></a>27.3.14 Cross-Language Polymorphism</H3>
<H3><a name="Ruby_nn25"></a>29.3.14 Cross-Language Polymorphism</H3>
<p>
@ -1062,7 +1062,7 @@ $ <b>ruby -e 'puts $:.join("\n")'</b><br>/usr/local/lib/ruby/site_ruby/1.6 /usr/
this section just notes the differences that you need to be aware of when using
this feature with Ruby.
</p>
<H4><a name="Ruby_nn26"></a>27.3.14.1 Exception Unrolling</H4>
<H4><a name="Ruby_nn26"></a>29.3.14.1 Exception Unrolling</H4>
<p>
@ -1083,7 +1083,7 @@ $ <b>ruby -e 'puts $:.join("\n")'</b><br>/usr/local/lib/ruby/site_ruby/1.6 /usr/
Ruby exception is raised, it will be caught here and a C++ exception is raised
in its place.
</p>
<H2><a name="Ruby_nn27"></a>27.4 Input and output parameters</H2>
<H2><a name="Ruby_nn27"></a>29.4 Input and output parameters</H2>
<p>
@ -1209,7 +1209,7 @@ $ <b>ruby -e 'puts $:.join("\n")'</b><br>/usr/local/lib/ruby/site_ruby/1.6 /usr/
the standard Ruby exception classes, consult a Ruby reference such as <a href="http://www.rubycentral.com/book">
<em>Programming Ruby</em></a>.
</p>
<H2><a name="Ruby_nn29"></a>27.5 Typemaps</H2>
<H2><a name="Ruby_nn29"></a>29.5 Typemaps</H2>
<p>
@ -1222,7 +1222,7 @@ $ <b>ruby -e 'puts $:.join("\n")'</b><br>/usr/local/lib/ruby/site_ruby/1.6 /usr/
of using SWIG---the default wrapping behavior is enough in most cases. Typemaps
are only used if you want to change some aspect of the primitive C-Ruby
interface.</p>
<H3><a name="Ruby_nn30"></a>27.5.1 What is a typemap?</H3>
<H3><a name="Ruby_nn30"></a>29.5.1 What is a typemap?</H3>
<p>
@ -1289,7 +1289,7 @@ $ <b>ruby -e 'puts $:.join("\n")'</b><br>/usr/local/lib/ruby/site_ruby/1.6 /usr/
<div class="code">
<pre>puts Example.count('o','Hello World')<br>2<br></pre>
</div>
<H3><a name="Ruby_nn31"></a>27.5.2 Ruby typemaps</H3>
<H3><a name="Ruby_nn31"></a>29.5.2 Ruby typemaps</H3>
<p>
@ -1346,7 +1346,7 @@ $ <b>ruby -e 'puts $:.join("\n")'</b><br>/usr/local/lib/ruby/site_ruby/1.6 /usr/
Examples of these typemaps appears in the <a href="#ruby_typemap_examples">section
on typemap examples</a>
</p>
<H3><a name="Ruby_nn32"></a>27.5.3 Typemap variables</H3>
<H3><a name="Ruby_nn32"></a>29.5.3 Typemap variables</H3>
Within a typemap, a number of special variables prefaced with a <tt>$</tt> may
@ -1382,7 +1382,7 @@ $ <b>ruby -e 'puts $:.join("\n")'</b><br>/usr/local/lib/ruby/site_ruby/1.6 /usr/
<p><tt>$symname</tt></p>
<div class="indent">The Ruby name of the wrapper function being created.
</div>
<H3><a name="Ruby_nn33"></a>27.5.4 Useful Functions</H3>
<H3><a name="Ruby_nn33"></a>29.5.4 Useful Functions</H3>
<p>
@ -1392,19 +1392,19 @@ $ <b>ruby -e 'puts $:.join("\n")'</b><br>/usr/local/lib/ruby/site_ruby/1.6 /usr/
by David Thomas and Andrew Hunt.)
</p>
<p><a name="n34"></a></p>
<H4><a name="Ruby_nn34"></a>27.5.4.1 C Datatypes to Ruby Objects</H4>
<H4><a name="Ruby_nn34"></a>29.5.4.1 C Datatypes to Ruby Objects</H4>
<div class="code">
<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>
</div>
<H4><a name="Ruby_nn35"></a>27.5.4.2 Ruby Objects to C Datatypes</H4>
<H4><a name="Ruby_nn35"></a>29.5.4.2 Ruby Objects to C Datatypes</H4>
<div class="code">
<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>
</div>
<H4><a name="Ruby_nn36"></a>27.5.4.3 Macros for VALUE</H4>
<H4><a name="Ruby_nn36"></a>29.5.4.3 Macros for VALUE</H4>
<p>
@ -1419,7 +1419,7 @@ $ <b>ruby -e 'puts $:.join("\n")'</b><br>/usr/local/lib/ruby/site_ruby/1.6 /usr/
<div class="indent">capacity of the Ruby array</div>
<p><tt>RARRAY(arr)-&gt;ptr</tt></p>
<div class="indent">pointer to array storage</div>
<H4><a name="Ruby_nn37"></a>27.5.4.4 Exceptions</H4>
<H4><a name="Ruby_nn37"></a>29.5.4.4 Exceptions</H4>
<p>
@ -1486,7 +1486,7 @@ $ <b>ruby -e 'puts $:.join("\n")'</b><br>/usr/local/lib/ruby/site_ruby/1.6 /usr/
with the <tt>-w</tt> flag. The given format string <i>fmt</i> and remaining
arguments are interpreted as with <tt>printf()</tt>.
</div>
<H4><a name="Ruby_nn38"></a>27.5.4.5 Iterators</H4>
<H4><a name="Ruby_nn38"></a>29.5.4.5 Iterators</H4>
<p>
@ -1525,14 +1525,14 @@ $ <b>ruby -e 'puts $:.join("\n")'</b><br>/usr/local/lib/ruby/site_ruby/1.6 /usr/
<div class="indent">
Equivalent to Ruby's <tt>throw</tt>.
</div>
<H3><a name="ruby_typemap_examples"></a>27.5.5 Typemap Examples</H3>
<H3><a name="ruby_typemap_examples"></a>29.5.5 Typemap Examples</H3>
<p>
This section includes a few examples of typemaps. For more examples, you might
look at the examples in the <tt>Example/ruby</tt> directory.
</p>
<H3><a name="Ruby_nn40"></a>27.5.6 Converting a Ruby array to a char **</H3>
<H3><a name="Ruby_nn40"></a>29.5.6 Converting a Ruby array to a char **</H3>
<p>
@ -1556,7 +1556,7 @@ $ <b>ruby -e 'puts $:.join("\n")'</b><br>/usr/local/lib/ruby/site_ruby/1.6 /usr/
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.
</p>
<H3><a name="Ruby_nn41"></a>27.5.7 Collecting arguments in a hash</H3>
<H3><a name="Ruby_nn41"></a>29.5.7 Collecting arguments in a hash</H3>
<p>
@ -1669,7 +1669,7 @@ $ <b>ruby -e 'puts $:.join("\n")'</b><br>/usr/local/lib/ruby/site_ruby/1.6 /usr/
the extension, can be found in the <tt>Examples/ruby/hashargs</tt> directory of
the SWIG distribution.
</p>
<H3><a name="Ruby_nn42"></a>27.5.8 Pointer handling</H3>
<H3><a name="Ruby_nn42"></a>29.5.8 Pointer handling</H3>
<p>
@ -1716,7 +1716,7 @@ $ <b>ruby -e 'puts $:.join("\n")'</b><br>/usr/local/lib/ruby/site_ruby/1.6 /usr/
<div class="indent">
<pre>%typemap(in) Foo * {<br> SWIG_ConvertPtr($input, (void **) &amp;$1, $1_descriptor, 1);<br>}<br></pre>
</div>
<H4><a name="Ruby_nn43"></a>27.5.8.1 Ruby Datatype Wrapping</H4>
<H4><a name="Ruby_nn43"></a>29.5.8.1 Ruby Datatype Wrapping</H4>
<p>
@ -1737,7 +1737,7 @@ $ <b>ruby -e 'puts $:.join("\n")'</b><br>/usr/local/lib/ruby/site_ruby/1.6 /usr/
<div class="indent">Retrieves the original C pointer of type <i>c-type</i> from the
data object <i>obj</i> and assigns that pointer to <i>ptr</i>.
</div>
<H2><a name="ruby_operator_overloading"></a>27.6 Operator overloading</H2>
<H2><a name="ruby_operator_overloading"></a>29.6 Operator overloading</H2>
<p>
@ -1752,7 +1752,7 @@ $ <b>ruby -e 'puts $:.join("\n")'</b><br>/usr/local/lib/ruby/site_ruby/1.6 /usr/
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>.
</p>
<H3><a name="Ruby_nn45"></a>27.6.1 Example: STL Vector to Ruby Array</H3>
<H3><a name="Ruby_nn45"></a>29.6.1 Example: STL Vector to Ruby Array</H3>
<p>
@ -1789,10 +1789,10 @@ $ <b>ruby -e 'puts $:.join("\n")'</b><br>/usr/local/lib/ruby/site_ruby/1.6 /usr/
<div class="code">
<pre>%define VECTOR_TO_RUBY_ARRAY(vectorclassname, classname)<br>%typemap(ruby, out) vectorclassname &amp;, const vectorclassname &amp; {<br> VALUE arr = rb_ary_new2($1-&gt;size()); <br> vectorclassname::iterator i = $1-&gt;begin(), iend = $1-&gt;end();<br> for ( ; i!=iend; i++ )<br> rb_ary_push(arr, Data_Wrap_Struct(c ## classname.klass, 0, 0, &amp;(*i)));<br> $result = arr;<br>}<br>%typemap(ruby, out) vectorclassname, const vectorclassname {<br> VALUE arr = rb_ary_new2($1.size()); <br> vectorclassname::iterator i = $1.begin(), iend = $1.end();<br> for ( ; i!=iend; i++ )<br> rb_ary_push(arr, Data_Wrap_Struct(c ## classname.klass, 0, 0, &amp;(*i)));<br> $result = arr;<br>}<br>%enddef<br></pre>
</div>
<H2><a name="Ruby_nn46"></a>27.7 Advanced Topics</H2>
<H2><a name="Ruby_nn46"></a>29.7 Advanced Topics</H2>
<H3><a name="Ruby_nn47"></a>27.7.1 Creating Multi-Module Packages</H3>
<H3><a name="Ruby_nn47"></a>29.7.1 Creating Multi-Module Packages</H3>
<p>
@ -1863,7 +1863,7 @@ $ <b>ruby -e 'puts $:.join("\n")'</b><br>/usr/local/lib/ruby/site_ruby/1.6 /usr/
<div class="code">
<pre>$ <b>irb</b><br>irb(main):001:0&gt; <b>require 'shape'</b><br>true<br>irb(main):002:0&gt; <b>require 'circle'</b><br>true<br>irb(main):003:0&gt; <b>c = Circle::Circle.new(5, 5, 20)</b><br>#&lt;Circle::Circle:0xa097208&gt;<br>irb(main):004:0&gt; <b>c.kind_of? Shape::Shape</b><br>true<br>irb(main):005:0&gt; <b>c.getX()</b><br>5.0<br></pre>
</div>
<H3><a name="Ruby_nn48"></a>27.7.2 Defining Aliases</H3>
<H3><a name="Ruby_nn48"></a>29.7.2 Defining Aliases</H3>
<p>
@ -1902,7 +1902,7 @@ $ <b>ruby -e 'puts $:.join("\n")'</b><br>/usr/local/lib/ruby/site_ruby/1.6 /usr/
mechanism and so the same name matching rules used for other kinds of features
apply (see the chapter on <a href="Customization.html#Customization">"Customization
Features"</a>) for more details).</p>
<H3><a name="Ruby_nn49"></a>27.7.3 Predicate Methods</H3>
<H3><a name="Ruby_nn49"></a>29.7.3 Predicate Methods</H3>
<p>
@ -1939,7 +1939,7 @@ $ <b>ruby -e 'puts $:.join("\n")'</b><br>/usr/local/lib/ruby/site_ruby/1.6 /usr/
of features apply (see the chapter on <a href="Customization.html#Customization">"Customization
Features"</a>) for more details).
</p>
<H3><a name="Ruby_nn50"></a>27.7.4 Specifying Mixin Modules</H3>
<H3><a name="Ruby_nn50"></a>29.7.4 Specifying Mixin Modules</H3>
<p>
@ -1980,7 +1980,7 @@ $ <b>ruby -e 'puts $:.join("\n")'</b><br>/usr/local/lib/ruby/site_ruby/1.6 /usr/
apply (see the chapter on <a href="Customization.html#Customization">"Customization
Features"</a>) for more details).
</p>
<H2><a name="Ruby_nn51"></a>27.8 Memory Management</H2>
<H2><a name="Ruby_nn51"></a>29.8 Memory Management</H2>
<p>One of the most common issues in generating SWIG bindings for Ruby is proper
@ -2024,7 +2024,7 @@ $ <b>ruby -e 'puts $:.join("\n")'</b><br>/usr/local/lib/ruby/site_ruby/1.6 /usr/
allocated in creating the underlying C struct or C++ struct, then a "free"
function must be defined that deallocates this memory.
</p>
<H3><a name="Ruby_nn53"></a>27.8.1 Object Ownership</H3>
<H3><a name="Ruby_nn53"></a>29.8.1 Object Ownership</H3>
<p>As described above, memory management depends on clearly defining who is
@ -2099,7 +2099,7 @@ $ <b>ruby -e 'puts $:.join("\n")'</b><br>/usr/local/lib/ruby/site_ruby/1.6 /usr/
<p>
This code can be seen in swig/examples/ruby/tracking.</p>
<br>
<H3><a name="Ruby_nn54"></a>27.8.2 Object Tracking</H3>
<H3><a name="Ruby_nn54"></a>29.8.2 Object Tracking</H3>
<p>The remaining parts of this section will use the class library shown below to
@ -2168,7 +2168,7 @@ $ <b>ruby -e 'puts $:.join("\n")'</b><br>/usr/local/lib/ruby/site_ruby/1.6 /usr/
implement your own free functions (see below) you may also have to call the<tt>SWIG_RubyRemoveTracking</tt>
and <tt>RubyUnlinkObjects</tt> methods.</p>
<H3><a name="Ruby_nn55"></a>27.8.3 Mark Functions</H3>
<H3><a name="Ruby_nn55"></a>29.8.3 Mark Functions</H3>
<p>With a bit more testing, we see that our class library still has problems. For
@ -2210,7 +2210,7 @@ $ <b>ruby -e 'puts $:.join("\n")'</b><br>/usr/local/lib/ruby/site_ruby/1.6 /usr/
</div>
<br>
<p>This code can be seen in swig/examples/ruby/mark_function.</p>
<H3><a name="Ruby_nn56"></a>27.8.4 Free Functions</H3>
<H3><a name="Ruby_nn56"></a>29.8.4 Free Functions</H3>
<p>By default, SWIG creates a "free" function that is called when a Ruby object is