PageRenderTime 13ms CodeModel.GetById 1ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 1ms

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

#
Swig | 307 lines | 234 code | 71 blank | 2 comment | 0 complexity | cfa3cdede8f572cd6ee94fe7165cfc0d MD5 | raw file
  1%module namespace_class
  2
  3%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Ala::Ola;
  4
  5#ifdef SWIGD
  6%warnfilter(SWIGWARN_IGNORE_OPERATOR_LT);
  7#endif
  8
  9%inline %{
 10  template<class T> void foobar(T t) {}
 11  namespace test {
 12    template<class T> void barfoo(T t) {}
 13  }  
 14%}
 15
 16%template(FooBarInt) ::foobar<int>;
 17%template(BarFooInt) test::barfoo<int>;
 18
 19
 20%inline %{
 21  template <class C>
 22  struct Bar_T
 23  {
 24  };
 25  
 26  
 27
 28  namespace test {
 29    enum Hello {
 30      Hi
 31    };    
 32    
 33    struct Test;
 34
 35    struct Bar  {
 36      Hello foo(Hello h) {
 37	return h;
 38      }
 39    };
 40
 41    namespace hola {
 42      struct Bor;
 43      struct Foo;
 44      struct Foobar;
 45      template <class T> struct BarT {
 46      };
 47
 48      template <class T> class FooT;
 49    }
 50
 51    template <class T>
 52    class hola::FooT {
 53    public:
 54      Hello foo(Hello h) {
 55	return h;
 56      }
 57      
 58      T bar(T h) {
 59	return h;
 60      }
 61    };
 62
 63    namespace hola {
 64      template <> class FooT<double>;
 65      template <> class FooT<int>;
 66    }
 67    
 68    template <>
 69    class hola::FooT<double> {
 70    public:
 71      double moo(double h) {
 72	return h;
 73      }
 74    };
 75
 76    int a;
 77
 78    struct hola::Foo : Bar {
 79      Hello bar(Hello h) {
 80	return h;
 81      }    
 82    };
 83  }
 84  
 85  struct test::Test {
 86    Hello foo(Hello h) {
 87      return h;
 88    }
 89  };
 90
 91  struct test::hola::Bor {
 92    Hello foo(Hello h) {
 93      return h;
 94    }    
 95  };
 96
 97  namespace test {
 98    struct hola::Foobar : Bar {
 99      Hello bar(Hello h) {
100	return h;
101      }    
102    };
103  }
104
105  template <>
106  class test::hola::FooT<int> {
107  public:
108    int quack(int h) {
109      return h;
110    }
111  };
112
113%}
114
115
116namespace test
117{
118  namespace hola {
119    %template(FooT_i) FooT<int>;
120  }
121
122  %template(FooT_H) hola::FooT<Hello>;
123}
124
125%template(FooT_d) ::test::hola::FooT<double>;
126%template(BarT_H) test::hola::BarT<test::Hello>;
127
128%inline %{
129
130  namespace hi {
131    namespace hello {
132      template <class T> struct PooT;
133    }
134
135    namespace hello {
136      template <class T> struct PooT
137      {
138      }; 
139    }
140  }
141%}
142
143%template(Poo_i) hi::hello::PooT<int>;
144
145%inline %{
146
147  template <class T> struct BooT {
148  };
149
150  namespace test {
151    
152    typedef ::BooT<Hello> BooT_H;
153  }
154
155%}
156
157namespace test {
158  
159  %template(BooT_H) ::BooT<Hello>;
160}
161%template(BooT_i) ::BooT<int>;
162
163
164%inline %{
165
166namespace jafar {
167  namespace jmath {
168    class EulerT3D {
169    public:
170      static void hello(){}
171      
172      template<class VecFrame, class Vec, class VecRes>
173      static void toFrame(const VecFrame& frame_, const Vec&v_,const VecRes& vRes){}
174      
175      template<class T>
176      void operator ()(T& x){}
177
178      template<class T>
179      void operator < (T& x){}
180      
181      template<class T>
182      operator Bar_T<T> () {}
183
184    };
185  }
186}
187%}
188
189%template(toFrame) jafar::jmath::EulerT3D::toFrame<int,int,int>;
190%template(callint) jafar::jmath::EulerT3D::operator()<int>;
191%template(lessint) jafar::jmath::EulerT3D::operator < <int>;
192%template(callfooi) jafar::jmath::EulerT3D::operator() <test::hola::FooT<int> >;
193%template(lessfooi) jafar::jmath::EulerT3D::operator < < test::hola::FooT<int> >;
194
195
196%inline %{
197
198namespace {
199  /* the unnamed namespace is 'private', so, the following
200     declarations shouldn't be wrapped */
201  class Private1
202  {
203  };
204
205}
206
207namespace a
208{
209  namespace 
210  {
211    class Private2
212    {
213    };
214  }
215}
216 
217%}
218
219// %copyctor doesn't work with nested class workaround
220%nocopyctor;
221
222%inline %{
223  class Ala {
224  public : 
225    Ala() {}
226    class Ola {
227    public:
228      Ola() {}
229      void eek() {}
230    };
231    
232    template <class T>
233    static void hi() 
234    {
235    }
236  };
237%}
238
239%rename(Ala__Ola) Ala::Ola;
240class Ala::Ola {
241public:
242  Ola() {}
243  void eek() {}
244};
245
246%template(hi) Ala::hi<int>;
247
248%extend jafar::jmath::EulerT3D 
249{
250  
251}
252
253%rename(FLACFile) TagLib::FLAC::File;
254
255%inline {
256namespace TagLib
257{
258  class File {
259  public:
260    File() {}
261  };
262
263  class AudioProperties {
264  };
265
266  class AudioPropertiesFile {
267  public:
268    typedef TagLib::File File;
269  };
270  
271  namespace FLAC
272  {
273    class File;
274    class Properties : public AudioProperties  {
275    public:
276      Properties(File *) {}
277    };
278
279    class PropertiesFile : public AudioPropertiesFile  {
280    public:
281      PropertiesFile(File * = 0) {}
282    };
283
284    namespace bar {
285      class PropertiesFree  : public AudioProperties  {
286      public:
287	PropertiesFree(File *) {}
288      };
289    }
290
291    class FooFilePrivate : private PropertiesFile  {
292    public:
293      FooFilePrivate(File *) {}
294    };
295
296    class FooFile : public PropertiesFile  {
297    public:
298      FooFile(File *) {}
299    };
300
301    class File {
302    public:
303      File() {}
304    };
305  }
306}
307}