Ruby tracking doc fixes
This commit is contained in:
parent
0ee304188c
commit
37e60f450f
1 changed files with 15 additions and 12 deletions
|
|
@ -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>/* Tell SWIG that create_animal creates a new object */</b>
|
||||||
<b>%newobject Zoo::create_animal;</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>
|
%include "example.h"</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -5101,7 +5102,7 @@ static void mark_Zoo(void* ptr) {
|
||||||
<p> Note the <tt>mark</tt> function is dependent on
|
<p> Note the <tt>mark</tt> function is dependent on
|
||||||
the <tt>SWIG_RUBY_InstanceFor</tt> method, and thus
|
the <tt>SWIG_RUBY_InstanceFor</tt> method, and thus
|
||||||
requires that <tt>%trackobjects</tt> is enabled. For more
|
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>
|
test suite.</p>
|
||||||
|
|
||||||
<p>When this code is compiled we now see:</p>
|
<p>When this code is compiled we now see:</p>
|
||||||
|
|
@ -5168,13 +5169,14 @@ above. </p>
|
||||||
|
|
||||||
<p>To show how to use the <tt>%freefunc</tt>
|
<p>To show how to use the <tt>%freefunc</tt>
|
||||||
directive, let's slightly change our example. Assume that the zoo
|
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>
|
that the <tt>Zoo::add_animal</tt>
|
||||||
function should be marked with a <tt>DISOWN</tt> typemap
|
function should be marked with a <tt>DISOWN</tt> typemap
|
||||||
and the destructor should be updated as below:</p>
|
and the destructor should be updated as below:</p>
|
||||||
|
|
||||||
<div class="code">
|
<div class="code">
|
||||||
<pre>Zoo::~Zoo() {
|
<pre>
|
||||||
|
Zoo::~Zoo() {
|
||||||
IterType iter = this->animals.begin();
|
IterType iter = this->animals.begin();
|
||||||
IterType end = this->animals.end();
|
IterType end = this->animals.end();
|
||||||
|
|
||||||
|
|
@ -5182,7 +5184,8 @@ and the destructor should be updated as below:</p>
|
||||||
Animal* animal = *iter;
|
Animal* animal = *iter;
|
||||||
delete animal;
|
delete animal;
|
||||||
}
|
}
|
||||||
}</pre>
|
}
|
||||||
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p>When we use these objects in IRB we see:</p>
|
<p>When we use these objects in IRB we see:</p>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue