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