$self special variable for %extend

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9530 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2006-11-08 00:54:28 +00:00
commit ca6b2bfa2b
8 changed files with 62 additions and 30 deletions

View file

@ -989,7 +989,7 @@ $ <b>ruby -e 'puts $:.join("\n")'</b><br>/usr/local/lib/ruby/site_ruby/1.6 /usr/
to add a new method of the aliased name that calls the original function. For
example: </p>
<div class="code">
<pre>class MyArray {<br>public:<br> // Construct an empty array<br> MyArray();<br> <br> // Return the size of this array<br> size_t length() const;<br>};<br><br>%extend MyArray {<br> // MyArray#size is an alias for MyArray#length<br> size_t size() const {<br> return self-&gt;length();<br> }<br>}
<pre>class MyArray {<br>public:<br> // Construct an empty array<br> MyArray();<br> <br> // Return the size of this array<br> size_t length() const;<br>};<br><br>%extend MyArray {<br> // MyArray#size is an alias for MyArray#length<br> size_t size() const {<br> return $self-&gt;length();<br> }<br>}
</pre>
</div>
<p> A better solution is to use the <tt>%alias</tt> directive (unique to