/tags/rel-1.3.35/Examples/test-suite/rename_scope.i
Swig | 68 lines | 58 code | 10 blank | 0 comment | 0 complexity | 4e81574f3e184421e548a467f5c4c3aa MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
1%module rename_scope
2
3%inline
4%{
5 namespace oss
6 {
7 enum Polarization { UnaryPolarization, BinaryPolarization };
8
9 template <Polarization P>
10 struct Interface
11 {
12 };
13 }
14%}
15
16namespace oss
17{
18 // Interface
19 %template(Interface_UP) Interface<UnaryPolarization>;
20 %template(Interface_BP) Interface<BinaryPolarization>;
21
22}
23%inline
24%{
25 namespace oss
26 {
27 namespace interfaces
28 {
29 template <Polarization P>
30 struct Natural : Interface<P>
31 {
32 int test(void) { return 1; }
33 };
34 }
35 }
36%}
37
38namespace oss
39{
40 namespace interfaces
41 {
42 %rename(rtest) Natural<UnaryPolarization>::test;
43 %rename(rtest) Natural<oss::BinaryPolarization>::test;
44
45 // Natural
46 %template(Natural_UP) Natural<UnaryPolarization>;
47 %template(Natural_BP) Natural<BinaryPolarization>;
48 }
49}
50
51%rename("equals") operator==;
52
53%inline %{
54
55 namespace Utilities {
56 class Bucket
57 {
58 public:
59 Bucket() : m_left(0) {}
60 friend bool operator==(const Bucket& lhs, const Bucket& rhs){
61 return ( rhs.m_left == lhs.m_left );
62 }
63 private:
64 int m_left;
65 };
66 }
67
68%}