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) || defined(SWIGLUA) || defined(SWIGJAVASCRIPT)
6 
7 #if defined(SWIGJAVA)
8 SWIG_JAVABODY_PROXY(public, public, SWIGTYPE)
9 #endif
10 
11 %nspace;
12 %nonspace Outer::Inner2::NoNSpacePlease;
13 %nonspace Outer::Inner2::NoNSpacePlease::ReallyNoNSpaceEnum;
14 
15 %copyctor;
16 %ignore Outer::Inner2::Color::Color();
17 
18 #define CONSTANT100 100
19 
20 %inline %{
21 
22 namespace Outer {
23   class namespce {
24   };
25   namespace Inner1 {
26     enum Channel { Diffuse, Specular = 0x10, Transmission1 };
27     enum { ColorEnumVal1, ColorEnumVal2 = 0x11, ColorEnumVal3 };
28 
29     struct Color {
createColor30       static Color* create() { return new Color(); }
31 
32       enum Channel { Diffuse, Specular = 0x20, Transmission };
33       enum { ColorEnumVal1, ColorEnumVal2 = 0x22, ColorEnumVal3 };
34 
35       int instanceMemberVariable;
36       static int staticMemberVariable;
37       static const int staticConstMemberVariable = 222;
38       static const Channel staticConstEnumMemberVariable = Transmission;
colorInstanceMethodColor39       void colorInstanceMethod(double d) {}
colorStaticMethodColor40       static void colorStaticMethod(double d) {}
41     }; // Color
42     int Color::staticMemberVariable = 0;
43 
namespaceFunction(Color k)44     Color namespaceFunction(Color k) { return k; }
45     int namespaceVar = 0;
46   } // Inner1
47 
48   namespace Inner2 {
49     enum Channel { Diffuse, Specular = 0x30, Transmission2 };
50 
51     struct Color {
ColorColor52       Color() : instanceMemberVariable(0) {}
createColor53       static Color* create() { return new Color(); }
54 
55       enum Channel { Diffuse, Specular = 0x40, Transmission };
56       enum { ColorEnumVal1, ColorEnumVal2 = 0x33, ColorEnumVal3 };
57 
58       int instanceMemberVariable;
59       static int staticMemberVariable;
60       static const int staticConstMemberVariable = 333;
61       static const Channel staticConstEnumMemberVariable = Transmission;
colorInstanceMethodColor62       void colorInstanceMethod(double d) {}
colorStaticMethodColor63       static void colorStaticMethod(double d) {}
colorsColor64       void colors(const Inner1::Color& col1a,
65                   const Outer::Inner1::Color& col1b,
66                   const Color &col2a,
67                   const Inner2::Color& col2b,
68                   const Outer::Inner2::Color& col2c) {}
69     }; // Color
70     int Color::staticMemberVariable = 0;
71     class NoNSpacePlease {
72       public:
73         enum NoNSpaceEnum { NoNspace1 = 1, NoNspace2 = 10 };
74         enum ReallyNoNSpaceEnum { ReallyNoNspace1 = 1, ReallyNoNspace2 = 10 };
noNspaceStaticFunc()75         static int noNspaceStaticFunc() { return 10; }
76     };
77   } // Inner2
78 
79   // Derived class
80   namespace Inner3 {
81     struct Blue : Inner2::Color {
blueInstanceMethodBlue82       void blueInstanceMethod() {}
83     };
84   }
85   namespace Inner4 {
86     struct Blue : Inner2::Color {
blueInstanceMethodBlue87       void blueInstanceMethod() {}
88     };
89   }
90 
91   class SomeClass {
92   public:
GetInner1ColorChannel()93     Inner1::Color::Channel GetInner1ColorChannel() { return Inner1::Color::Transmission; }
GetInner2ColorChannel()94     Inner2::Color::Channel GetInner2ColorChannel() { return Inner2::Color::Transmission; }
GetInner1Channel()95     Inner1::Channel GetInner1Channel() { return Inner1::Transmission1; }
GetInner2Channel()96     Inner2::Channel GetInner2Channel() { return Inner2::Transmission2; }
97   }; // SomeClass
98 
99 } // Outer
100 
101 namespace Outer {
102   struct MyWorldPart2 {};
103 }
104 
105 struct GlobalClass {
gmethodGlobalClass106   void gmethod() {}
107 };
108 
test_classes(Outer::SomeClass c,Outer::Inner2::Color cc)109 void test_classes(Outer::SomeClass c, Outer::Inner2::Color cc) {}
110 %}
111 
112 #else
113 //#warning nspace feature not yet supported in this target language
114 #endif
115 
116