Improve %rename(match) documentation.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12172 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
0b2561f300
commit
409ae85a74
1 changed files with 35 additions and 3 deletions
|
|
@ -1931,14 +1931,30 @@ As explained in the previous sections, it is possible to either rename
|
||||||
individual declarations or apply a rename rule to all of them at once. In
|
individual declarations or apply a rename rule to all of them at once. In
|
||||||
practice, the latter is however rarely appropriate as there are always some
|
practice, the latter is however rarely appropriate as there are always some
|
||||||
exceptions to the general rules. To deal with them, the scope of an unnamed
|
exceptions to the general rules. To deal with them, the scope of an unnamed
|
||||||
<tt>%rename</tt> can be limited using a second parameter.
|
<tt>%rename</tt> can be limited using subsequent <tt>match</tt> parameters.
|
||||||
|
They can be applied to any of the attributes associated by SWIG with the
|
||||||
|
declarations appearing in its input. One of them is the declaration name and
|
||||||
</p>
|
</p>
|
||||||
|
<div class="code">
|
||||||
|
<pre>
|
||||||
|
%rename("foo", match$name="bar") "";
|
||||||
|
</pre>
|
||||||
|
</div>
|
||||||
<p>
|
<p>
|
||||||
The simplest possibility is to match the declaration type, for example:
|
can be used to achieve the same effect as the simpler
|
||||||
</p>
|
</p>
|
||||||
<div class="code">
|
<div class="code">
|
||||||
<pre>
|
<pre>
|
||||||
|
%rename("foo") bar;
|
||||||
|
</pre>
|
||||||
|
</div>
|
||||||
|
<p>
|
||||||
|
However <tt>match</tt> can also be applied to the declaration type, for
|
||||||
|
example <tt>match="class"</tt> restricts the match to class declarations only
|
||||||
|
(in C++) and <tt>match="enumitem"</tt> restricts it to the enum elements. SWIG
|
||||||
|
also provides convenience macros for such match expressions, for example
|
||||||
|
<div class="code">
|
||||||
|
<pre>
|
||||||
%rename("%(title)s", %$isenumitem) "";
|
%rename("%(title)s", %$isenumitem) "";
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -1950,6 +1966,22 @@ documentation is not exhaustive, see "%rename predicates" section of
|
||||||
<tt>Lib/swig.swg</tt> for the full list of supported match expressions.
|
<tt>Lib/swig.swg</tt> for the full list of supported match expressions.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Another important feature of <tt>match</tt> is that it can be applied not
|
||||||
|
only to the declaration itself but also to its enclosing declaration. So
|
||||||
|
<tt>match$parentNode$name="SomeClass"</tt> would be true only for members of
|
||||||
|
the C++ class with the specified name. This can, of course, be combined with
|
||||||
|
more complicated matches making it possible to write
|
||||||
|
</p>
|
||||||
|
<div class="code">
|
||||||
|
<pre>
|
||||||
|
%rename("%(lower)s", match$parentNode$name="SomeClass", %$isenum) "";
|
||||||
|
</pre>
|
||||||
|
</div>
|
||||||
|
<p>
|
||||||
|
to rename all enums nested in the given class to lower case.
|
||||||
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Finally, even more powerful variants of <tt>%rename</tt> and <tt>%ignore</tt> directives can be used to help
|
Finally, even more powerful variants of <tt>%rename</tt> and <tt>%ignore</tt> directives can be used to help
|
||||||
wrap C++ overloaded functions and methods or C++ methods which use default arguments. This is described in the
|
wrap C++ overloaded functions and methods or C++ methods which use default arguments. This is described in the
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue