Add %rename matching docs and improvements
Add in %$isusing macro for %rename. Improve docs for %$not and notmatch.
This commit is contained in:
parent
79a1bbee8b
commit
546062fdf1
2 changed files with 26 additions and 1 deletions
|
|
@ -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
|
restricts it to the enum elements. SWIG also provides convenience macros for
|
||||||
such match expressions, for example
|
such match expressions, for example
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div class="code">
|
<div class="code">
|
||||||
<pre>
|
<pre>
|
||||||
%rename("%(title)s", %$isenumitem) "";
|
%rename("%(title)s", %$isenumitem) "";
|
||||||
|
// same as:
|
||||||
|
%rename("%(title)s", match="enumitem") "";
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
will capitalize the names of all the enum elements but not change the case of
|
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>,
|
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.
|
<tt>swig.swg</tt> for the full list of supported match expressions.
|
||||||
</p>
|
</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>
|
<p>
|
||||||
In addition to literally matching some string with <tt>match</tt> you can
|
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
|
also use <tt>regexmatch</tt> or <tt>notregexmatch</tt> to match a string
|
||||||
|
|
|
||||||
|
|
@ -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 %$isenum "match"="enum" %enddef
|
||||||
%define %$isenumitem "match"="enumitem" %enddef
|
%define %$isenumitem "match"="enumitem" %enddef
|
||||||
%define %$isaccess "match"="access" %enddef
|
%define %$isaccess "match"="access" %enddef
|
||||||
|
|
@ -279,6 +281,7 @@ static int NAME(TYPE x) {
|
||||||
%define %$isnamespace "match"="namespace" %enddef
|
%define %$isnamespace "match"="namespace" %enddef
|
||||||
%define %$istemplate "match"="template" %enddef
|
%define %$istemplate "match"="template" %enddef
|
||||||
%define %$isconstant "match"="constant" %enddef /* %constant definition */
|
%define %$isconstant "match"="constant" %enddef /* %constant definition */
|
||||||
|
%define %$isusing "match"="using" %enddef
|
||||||
|
|
||||||
%define %$isunion "match$kind"="union" %enddef
|
%define %$isunion "match$kind"="union" %enddef
|
||||||
%define %$isfunction "match$kind"="function" %enddef
|
%define %$isfunction "match$kind"="function" %enddef
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue