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