PageRenderTime 46ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 1ms

/tags/rel-1.3.35/Examples/test-suite/smart_pointer_namespace2.i

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