diff options
author | Vadim Zeitlin <vz-swig@zeitlins.org> | 2013-08-30 17:01:01 +0200 |
---|---|---|
committer | William S Fulton <wsf@fultondesigns.co.uk> | 2013-10-15 07:17:56 +0100 |
commit | 72afb74f470841d9af504a8f85617c6a70aa837d (patch) | |
tree | 7738345ee23ac538eb81deace43782261f2c5ca5 /Examples/test-suite/rename_pcre_encoder.i | |
parent | 669a27bb7b9d2da9c1758a5126d1db1f56299f08 (diff) | |
download | swig-72afb74f470841d9af504a8f85617c6a70aa837d.tar.gz |
Add support for case conversion characters in regex substitutions.
Allow using Perl-like \l, \L, \u, \U and \E escape sequences in the
substitution string used with %rename("%(regex:/pattern/subst/)s").
This is useful for e.g. title casing all string after removing some prefix.
Closes #82
Diffstat (limited to 'Examples/test-suite/rename_pcre_encoder.i')
-rw-r--r-- | Examples/test-suite/rename_pcre_encoder.i | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/Examples/test-suite/rename_pcre_encoder.i b/Examples/test-suite/rename_pcre_encoder.i index 66f30c7bc..b29b2a056 100644 --- a/Examples/test-suite/rename_pcre_encoder.i +++ b/Examples/test-suite/rename_pcre_encoder.i @@ -3,9 +3,14 @@ // strip the wx prefix from all identifiers except those starting with wxEVT %rename("%(regex:/wx(?!EVT)(.*)/\\1/)s") ""; -// Replace "Set" and "Get" prefixes with "put" and "get" respectively. -%rename("%(regex:/^Set(.*)/put\\1/)s", %$isfunction) ""; -%rename("%(regex:/^Get(.*)/get\\1/)s", %$isfunction) ""; +// Change "{Set,Get}Foo" naming convention to "{put,get}_foo" one. +%rename("%(regex:/^Set(.*)/put_\\l\\1/)s", %$isfunction) ""; +%rename("%(regex:/^Get(.*)/get_\\l\\1/)s", %$isfunction) ""; + +// Make some words stand out (unfortunately we don't have "global" flag): we +// use \U to capitalize the second capture group and then \E to preserve the +// case of the rest. +%rename("%(regex:/(.*?)(nsa)(.*?)\\2(.*?)\\2(.*?)\\2(.*)/\\1\\U\\2\\E\\3\\U\\2\\E\\4\\U\\2\\E\\5\\U\\2\\E\\6/)s") ""; %inline %{ @@ -28,4 +33,6 @@ class wxEVTSomeEvent { class xUnchangedName { }; +inline int StartInsaneAndUnsavoryTransatlanticRansack() { return 42; } + %} |