PageRenderTime 31ms CodeModel.GetById 26ms app.highlight 1ms RepoModel.GetById 2ms app.codeStats 0ms

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

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