PageRenderTime 14ms CodeModel.GetById 8ms app.highlight 2ms RepoModel.GetById 2ms app.codeStats 0ms

/trunk/Examples/test-suite/rename_pcre_enum.i

#
Swig | 49 lines | 39 code | 10 blank | 0 comment | 0 complexity | dc24e6a75e73f524a8cc380f916d7189 MD5 | raw file
 1%module rename_pcre_enum
 2
 3// This file is needed for proper enum support in C#/Java backends
 4#if defined(SWIGCSHARP) || defined(SWIGJAVA)
 5%include "enums.swg"
 6#endif
 7
 8// Apply a rule for renaming the enum elements to avoid the common prefixes
 9// redundant in C#/Java
10%rename("%(regex:/([A-Z][a-z]+)+_(.*)/\\2/)s",%$isenumitem) "";
11
12// Also don't export special end of enum markers which are often used in C++
13// code to just have a symbolic name for the number of enum elements but are
14// not needed in target language.
15%rename("$ignore", regexmatch$name="([A-Z][a-z]+)+_Max$",%$isenumitem) "";
16
17// Test another way of doing the same thing with regextarget:
18%rename("$ignore", %$isenumitem, regextarget=1) "([A-Z][a-z]+)+_Internal$";
19
20// Apply this renaming rule to all enum elements that don't contain more than
21// one capital letter.
22%rename("%(lower)s", notregexmatch$name="[A-Z]\\w*[A-Z]", %$isenumitem) "";
23
24%inline %{
25
26// Foo_Internal and Foo_Max won't be exported.
27enum Foo {
28    Foo_Internal = -1,
29    Foo_First,
30    Foo_Second,
31    Foo_Max
32};
33
34// All elements of this enum will be exported because they do not match the
35// excluding regex.
36enum BoundaryCondition {
37    BoundaryCondition_MinMax,
38    BoundaryCondition_MaxMin,
39    BoundaryCondition_MaxMax
40};
41
42// The elements of this enum will have lower-case names.
43enum Colour {
44    Red,
45    Blue,
46    Green
47};
48
49%}