PageRenderTime 40ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 0ms

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

#
Swig | 132 lines | 99 code | 33 blank | 0 comment | 0 complexity | ad15052487490a668cd58d44713ae72f MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. %module smart_pointer_extend
  2. %warnfilter(SWIGWARN_RUBY_WRONG_NAME) hi::CBase::z; /* Ruby, wrong const name */
  3. %inline %{
  4. namespace hi
  5. {
  6. struct CBase
  7. {
  8. static int hello()
  9. {
  10. return 1;
  11. }
  12. int x;
  13. static const int z = 1;
  14. };
  15. class CDerived : public CBase
  16. {
  17. };
  18. class CPtr
  19. {
  20. public:
  21. CDerived* operator->(void) {return 0;}
  22. };
  23. int get_hello(CPtr ptr)
  24. {
  25. return ptr->hello();
  26. }
  27. class CPtrConst
  28. {
  29. public:
  30. const CDerived* operator->() const {return 0;};
  31. };
  32. }
  33. %}
  34. %extend hi::CBase {
  35. int foo(void) {return 1;};
  36. int bar(void) {return 2;};
  37. int boo(int i) {return i;};
  38. }
  39. %extend hi::CDerived {
  40. int foo(void) {return 1;};
  41. }
  42. %extend Foo
  43. {
  44. int extension(int i, int j) { return i; }
  45. int extension(int i) { return i; }
  46. int extension() { return 1; }
  47. }
  48. %inline %{
  49. struct Foo {
  50. };
  51. class Bar {
  52. Foo *f;
  53. public:
  54. Bar(Foo *f) : f(f) { }
  55. Foo *operator->() {
  56. return f;
  57. }
  58. };
  59. %}
  60. %extend CFoo
  61. {
  62. public:
  63. static void StatFun() {};
  64. static void StatFun(int i) {};
  65. static void HoHoHo(int i, int j) {};
  66. }
  67. %inline %{
  68. class CFoo
  69. {
  70. };
  71. class CPtrFoo
  72. {
  73. public:
  74. CFoo* operator->(void) {return 0;};
  75. };
  76. %}
  77. %inline %{
  78. namespace foo {
  79. class DFoo;
  80. class DPtrFoo
  81. {
  82. DFoo *p;
  83. public:
  84. DPtrFoo(DFoo *ptr) : p(ptr)
  85. {
  86. }
  87. DFoo* operator->(void) {return p;};
  88. };
  89. class DFoo
  90. {
  91. public:
  92. void F(void) {};
  93. };
  94. }
  95. %}
  96. %extend foo::DFoo {
  97. static int SExt(int i = 1) {return i;};
  98. int Ext(int i = 2) {return i;};
  99. }