PageRenderTime 54ms CodeModel.GetById 28ms RepoModel.GetById 0ms app.codeStats 0ms

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

#
Swig | 107 lines | 84 code | 23 blank | 0 comment | 0 complexity | 7282a58d32a7076fba1781d3880afc9d MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. // Test the nspace feature
  2. %module nspace
  3. // nspace feature only supported by these languages
  4. #if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGD)
  5. #if defined(SWIGJAVA)
  6. SWIG_JAVABODY_PROXY(public, public, SWIGTYPE)
  7. #endif
  8. %nspace;
  9. %nonspace Outer::Inner2::NoNSpacePlease;
  10. %copyctor;
  11. %ignore Outer::Inner2::Color::Color();
  12. #define CONSTANT100 100
  13. %inline %{
  14. namespace Outer {
  15. class namespce {
  16. };
  17. namespace Inner1 {
  18. enum Channel { Diffuse, Specular = 0x10, Transmission1 };
  19. enum { ColorEnumVal1, ColorEnumVal2 = 0x11, ColorEnumVal3 };
  20. struct Color {
  21. static Color* create() { return new Color(); }
  22. enum Channel { Diffuse, Specular = 0x20, Transmission };
  23. enum { ColorEnumVal1, ColorEnumVal2 = 0x22, ColorEnumVal3 };
  24. int instanceMemberVariable;
  25. static int staticMemberVariable;
  26. static const int staticConstMemberVariable = 222;
  27. static const Channel staticConstEnumMemberVariable = Transmission;
  28. void colorInstanceMethod(double d) {}
  29. static void colorStaticMethod(double d) {}
  30. }; // Color
  31. int Color::staticMemberVariable = 0;
  32. Color namespaceFunction(Color k) { return k; }
  33. int namespaceVar = 0;
  34. } // Inner1
  35. namespace Inner2 {
  36. enum Channel { Diffuse, Specular = 0x30, Transmission2 };
  37. struct Color {
  38. Color() : instanceMemberVariable(0) {}
  39. static Color* create() { return new Color(); }
  40. enum Channel { Diffuse, Specular = 0x40, Transmission };
  41. enum { ColorEnumVal1, ColorEnumVal2 = 0x33, ColorEnumVal3 };
  42. int instanceMemberVariable;
  43. static int staticMemberVariable;
  44. static const int staticConstMemberVariable = 333;
  45. static const Channel staticConstEnumMemberVariable = Transmission;
  46. void colorInstanceMethod(double d) {}
  47. static void colorStaticMethod(double d) {}
  48. void colors(const Inner1::Color& col1a,
  49. const Outer::Inner1::Color& col1b,
  50. const Color &col2a,
  51. const Inner2::Color& col2b,
  52. const Outer::Inner2::Color& col2c) {}
  53. }; // Color
  54. int Color::staticMemberVariable = 0;
  55. class NoNSpacePlease {};
  56. } // Inner2
  57. // Derived class
  58. namespace Inner3 {
  59. struct Blue : Inner2::Color {
  60. void blueInstanceMethod() {}
  61. };
  62. }
  63. namespace Inner4 {
  64. struct Blue : Inner2::Color {
  65. void blueInstanceMethod() {}
  66. };
  67. }
  68. class SomeClass {
  69. public:
  70. Inner1::Color::Channel GetInner1ColorChannel() { return Inner1::Color::Transmission; }
  71. Inner2::Color::Channel GetInner2ColorChannel() { return Inner2::Color::Transmission; }
  72. Inner1::Channel GetInner1Channel() { return Inner1::Transmission1; }
  73. Inner2::Channel GetInner2Channel() { return Inner2::Transmission2; }
  74. }; // SomeClass
  75. } // Outer
  76. namespace Outer {
  77. struct MyWorldPart2 {};
  78. }
  79. struct GlobalClass {
  80. void gmethod() {}
  81. };
  82. void test_classes(Outer::SomeClass c, Outer::Inner2::Color cc) {}
  83. %}
  84. #endif