Add more regex function usage examples in %rename section.
Mention the examples from the test suite and the change log file in the manual as well. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12188 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
024ed6ce2a
commit
9b09784715
1 changed files with 22 additions and 0 deletions
|
|
@ -1904,6 +1904,28 @@ and a more descriptive one, but the two functions are otherwise equivalent:
|
|||
</tr>
|
||||
</table>
|
||||
|
||||
<p>
|
||||
The most general function of all of the above ones (not counting
|
||||
<tt>command</tt> which is even more powerful in principle but which should
|
||||
generally be avoided because of performance considerations) is the
|
||||
<tt>regex</tt> one. Here are some more examples of its use:
|
||||
<div class="code">
|
||||
<pre>
|
||||
// Strip the wx prefix from all identifiers except those starting with wxEVT
|
||||
%rename("%(regex:/wx(?!EVT)(.*)/\\1/)s") ""; // wxSomeWidget -> SomeWidget
|
||||
// wxEVT_PAINT -> wxEVT_PAINT
|
||||
|
||||
// Apply a rule for renaming the enum elements to avoid the common prefixes
|
||||
// which are redundant in C#/Java
|
||||
%rename("%(regex:/^([A-Z][a-z]+)+_(.*)/\\2/)s", %$isenumitem) ""; // Colour_Red -> Red
|
||||
|
||||
// Remove all "Set/Get" prefixes.
|
||||
%rename("%(regex:/^(Set|Get)(.*)/\\2/)s") ""; // SetValue -> Value
|
||||
// GetValue -> Value
|
||||
</pre>
|
||||
</div>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
As before, everything that was said above about <tt>%rename</tt> also applies to
|
||||
<tt>%ignore</tt>. In fact, the latter is just a special case of the former and
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue