Apply small documentation fix - patch #2579863
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11165 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
2c71ee47fb
commit
65f79a952c
2 changed files with 3 additions and 3 deletions
|
|
@ -10567,7 +10567,7 @@ existing Ruby object to the destroyed C++ object and raise an exception.<br>
|
|||
|
||||
|
||||
<div class="code">
|
||||
<pre>%module example<br><br>%{<br>#include "example.h"<br>%}<br><br>/* Specify that ownership is transferred to the zoo<br> when calling add_animal */<br>%apply SWIGTYPE *DISOWN { Animal* animal };<br><br>/* Track objects */<br>%trackobjects;<br><br>/* Specify the mark function */<br>%freefunc Zoo "free_Zoo";<br><br>%include "example.h"<br><br>%header %{<br> static void free_Zoo(void* ptr) {<br> Zoo* zoo = (Zoo*) ptr;<br><br> /* Loop over each animal */<br> int count = zoo->get_num_animals();<br><br> for(int i = 0; i < count; ++i) {<br> /* Get an animal */<br> Animal* animal = zoo->get_animal(i);<br><br> /* Unlink the Ruby object from the C++ object */<br> SWIG_RubyUnlinkObjects(animal);<br><br> /* Now remove the tracking for this animal */<br> SWIG_RubyRemoveTracking(animal);<br> }<br><br> /* Now call SWIG_RemoveMapping for the zoo */<br> SWIG_RemoveMapping(ptr);<br> <br> /* Now free the zoo which will free the animals it contains */<br> delete zoo;<br> }<br>%} </pre>
|
||||
<pre>%module example<br><br>%{<br>#include "example.h"<br>%}<br><br>/* Specify that ownership is transferred to the zoo<br> when calling add_animal */<br>%apply SWIGTYPE *DISOWN { Animal* animal };<br><br>/* Track objects */<br>%trackobjects;<br><br>/* Specify the mark function */<br>%freefunc Zoo "free_Zoo";<br><br>%include "example.h"<br><br>%header %{<br> static void free_Zoo(void* ptr) {<br> Zoo* zoo = (Zoo*) ptr;<br><br> /* Loop over each animal */<br> int count = zoo->get_num_animals();<br><br> for(int i = 0; i < count; ++i) {<br> /* Get an animal */<br> Animal* animal = zoo->get_animal(i);<br><br> /* Unlink the Ruby object from the C++ object */<br> SWIG_RubyUnlinkObjects(animal);<br><br> /* Now remove the tracking for this animal */<br> SWIG_RubyRemoveTracking(animal);<br> }<br><br> /* Now call SWIG_RubyRemoveTracking for the zoo */<br> SWIG_RubyRemoveTracking(ptr);<br> <br> /* Now free the zoo which will free the animals it contains */<br> delete zoo;<br> }<br>%} </pre>
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
static void free_Zoo(void* ptr) {
|
||||
Zoo* zoo = (Zoo*) ptr;
|
||||
|
||||
/* Loop over each object and call SWIG_RemoveMapping */
|
||||
/* Loop over each object and call SWIG_RubyRemoveTracking */
|
||||
int count = zoo->get_num_animals();
|
||||
|
||||
for(int i = 0; i < count; ++i) {
|
||||
|
|
@ -32,7 +32,7 @@
|
|||
SWIG_RubyRemoveTracking(animal);
|
||||
}
|
||||
|
||||
/* Now call SWIG_RemoveMapping for the zoo */
|
||||
/* Now call SWIG_RubyRemoveTracking for the zoo */
|
||||
SWIG_RubyRemoveTracking(ptr);
|
||||
|
||||
/* Now free the zoo which will free the animals it contains */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue