Add %rename matching docs and improvements

Add in %$isusing macro for %rename.
Improve docs for %$not and notmatch.
This commit is contained in:
William S Fulton 2022-02-23 19:38:23 +00:00
commit 546062fdf1
2 changed files with 26 additions and 1 deletions

View file

@ -2147,11 +2147,15 @@ 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
</p>
<div class="code">
<pre>
%rename("%(title)s", %$isenumitem) "";
// same as:
%rename("%(title)s", match="enumitem") "";
</pre>
</div>
<p>
will capitalize the names of all the enum elements but not change the case of
the other declarations. Similarly, <tt>%$isclass</tt>, <tt>%$isfunction</tt>,
@ -2161,6 +2165,24 @@ documentation is not exhaustive, see the "%rename predicates" section in
<tt>swig.swg</tt> for the full list of supported match expressions.
</p>
<p>
A logical not is also possible by using <tt>notmatch</tt>.
For example, <tt>notmatch="enumitem"</tt> will restrict the
match to all items that are not enum elements.
There is also a <tt>%$not</tt> macro which simply expands to "not".
Be careful using this as some of the other macros in <tt>swig.swg</tt>
are complex expressions and so it will only "notmatch" the first part
of the expression.
</p>
<div class="code">
<pre>
%rename("%(title)s", %$not %$isenumitem) "";
// same as:
%rename("%(title)s", notmatch="enumitem") "";
</pre>
</div>
<p>
In addition to literally matching some string with <tt>match</tt> you can
also use <tt>regexmatch</tt> or <tt>notregexmatch</tt> to match a string

View file

@ -268,7 +268,9 @@ static int NAME(TYPE x) {
*/
%define %$not "not" %enddef
/* Note that when %$not is used with another macro, say %enum as follows: %$not %$enum, the result is "notmatch=enum" */
%define %$not "not" %enddef
%define %$isenum "match"="enum" %enddef
%define %$isenumitem "match"="enumitem" %enddef
%define %$isaccess "match"="access" %enddef
@ -279,6 +281,7 @@ static int NAME(TYPE x) {
%define %$isnamespace "match"="namespace" %enddef
%define %$istemplate "match"="template" %enddef
%define %$isconstant "match"="constant" %enddef /* %constant definition */
%define %$isusing "match"="using" %enddef
%define %$isunion "match$kind"="union" %enddef
%define %$isfunction "match$kind"="function" %enddef