diff options
author | William S Fulton <wsf@fultondesigns.co.uk> | 2015-09-12 17:23:48 +0100 |
---|---|---|
committer | William S Fulton <wsf@fultondesigns.co.uk> | 2015-09-13 14:53:25 +0100 |
commit | 37e60f450f9d492ec90b55883ddb2a174877a66d (patch) | |
tree | 7357b996ab66777441e51c61a8cfadec6dfac277 /Doc/Manual | |
parent | 0ee304188c1317fdaf5aaaa19d98bad96fc14e3c (diff) | |
download | swig-37e60f450f9d492ec90b55883ddb2a174877a66d.tar.gz |
Ruby tracking doc fixes
Diffstat (limited to 'Doc/Manual')
-rw-r--r-- | Doc/Manual/Ruby.html | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/Doc/Manual/Ruby.html b/Doc/Manual/Ruby.html index 6590a133b..d5faeb7b8 100644 --- a/Doc/Manual/Ruby.html +++ b/Doc/Manual/Ruby.html @@ -4941,7 +4941,8 @@ class-by-class basis if needed. To fix the example above:</p> <b>/* Tell SWIG that create_animal creates a new object */</b> <b>%newobject Zoo::create_animal;</b> -<b>/* Tell SWIG to keep track of mappings between C/C++ structs/classes. */</b><b>%trackobjects;</b> +<b>/* Tell SWIG to keep track of mappings between C/C++ structs/classes. */</b> +<b>%trackobjects;</b> %include "example.h"</pre> </div> @@ -5101,7 +5102,7 @@ static void mark_Zoo(void* ptr) { <p> Note the <tt>mark</tt> function is dependent on the <tt>SWIG_RUBY_InstanceFor</tt> method, and thus requires that <tt>%trackobjects</tt> is enabled. For more -information, please refer to the track_object.i test case in the SWIG +information, please refer to the ruby_track_objects.i test case in the SWIG test suite.</p> <p>When this code is compiled we now see:</p> @@ -5168,21 +5169,23 @@ above. </p> <p>To show how to use the <tt>%freefunc</tt> directive, let's slightly change our example. Assume that the zoo -object is responsible for freeing animal that it contains. This means +object is responsible for freeing any animal that it contains. This means that the <tt>Zoo::add_animal</tt> function should be marked with a <tt>DISOWN</tt> typemap and the destructor should be updated as below:</p> <div class="code"> -<pre>Zoo::~Zoo() { - IterType iter = this->animals.begin(); - IterType end = this->animals.end(); - - for(iter; iter != end; ++iter) { - Animal* animal = *iter; - delete animal; - } -}</pre> +<pre> +Zoo::~Zoo() { + IterType iter = this->animals.begin(); + IterType end = this->animals.end(); + + for(iter; iter != end; ++iter) { + Animal* animal = *iter; + delete animal; + } +} +</pre> </div> <p>When we use these objects in IRB we see:</p> |