/trunk/Examples/test-suite/smart_pointer_namespace2.i
Swig | 80 lines | 71 code | 9 blank | 0 comment | 0 complexity | ff3e9ce9f899fa10d6a8395585ff5243 MD5 | raw file
1 2%module smart_pointer_namespace2 3%{ 4namespace one 5{ 6 template <typename T> 7 class Ptr 8 { 9 T* p; 10 public: 11 Ptr(T *tp) : p(tp) {} 12 ~Ptr() { }; 13 T* operator->() { return p; } 14 }; 15} 16namespace one 17{ 18 class Obj1 19 { 20 public: 21 Obj1() {} 22 void donothing() {} 23 }; 24 typedef one::Ptr<Obj1> Obj1_ptr; 25} 26 27namespace two 28{ 29 class Obj2 30 { 31 public: 32 Obj2() {} 33 void donothing() {} 34 }; 35 typedef one::Ptr<Obj2> Obj2_ptr; 36} 37%} 38 39namespace one 40{ 41 template <typename T> 42 class Ptr 43 { 44 T* p; 45 public: 46 Ptr(T *tp) : p(tp) {} 47 ~Ptr() { }; 48 T* operator->() { return p; } 49 }; 50} 51 52%define PTR_DEF(o) 53typedef one::Ptr<o> o ## _ptr; 54%template(o ## _ptr) one::Ptr<o>; 55%enddef 56 57namespace one 58{ 59 class Obj1 60 { 61 public: 62 Obj1() {} 63 void donothing() {} 64 }; 65 66 PTR_DEF(Obj1) 67} 68 69namespace two 70{ 71 class Obj2 72 { 73 public: 74 Obj2() {} 75 void donothing() {} 76 }; 77 78 PTR_DEF(Obj2) 79} 80