PageRenderTime 38ms CodeModel.GetById 16ms RepoModel.GetById 1ms app.codeStats 0ms

/tags/rel-1.3.35/Examples/test-suite/python/std_containers.i

#
Swig | 199 lines | 153 code | 46 blank | 0 comment | 0 complexity | a19f4c6057b14f3c89d3dfac15ac1b6c MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. %module std_containers
  2. %{
  3. #include <set>
  4. %}
  5. %include std_vector.i
  6. %include std_string.i
  7. %include std_deque.i
  8. %include std_list.i
  9. %include std_set.i
  10. %include std_multiset.i
  11. %include std_pair.i
  12. %include std_map.i
  13. %include std_multimap.i
  14. %include std_complex.i
  15. %template() std::vector<double>;
  16. %template() std::pair<std::string, int>;
  17. %template() std::pair<int,double>;
  18. %template() std::vector< std::vector<double > > ;
  19. %template(ccube) std::vector< std::vector< std::vector<double > > >;
  20. %inline
  21. {
  22. typedef
  23. std::vector<std::vector<std::vector<double > > >
  24. ccube;
  25. ccube cident(const ccube& c)
  26. {
  27. return c;
  28. }
  29. struct C
  30. {
  31. };
  32. }
  33. %template(map_si) std::map<std::string, int>;
  34. %template(pair_iC) std::pair<int, C*>;
  35. %template(map_iC) std::map<int, C*>;
  36. %template(mmap_si) std::multimap<std::string, int>;
  37. %template(set_i) std::set<int>;
  38. %template(multiset_i) std::multiset<int>;
  39. %template(list_i) std::list<int>;
  40. %template(deque_i) std::deque<int>;
  41. %template(vector_b) std::vector<bool>;
  42. %template(vector_i) std::vector<int>;
  43. %template(vector_c) std::vector<std::complex<double> >;
  44. %template(vector_ui) std::vector<unsigned int>;
  45. %template(bmatrix) std::vector<std::vector<bool> >;
  46. %template(imatrix) std::vector<std::vector<int> >;
  47. %template(cmatrix) std::vector<std::vector<std::complex<double> > >;
  48. %apply std::vector<int> *INOUT {std::vector<int> *INOUT2};
  49. %inline
  50. {
  51. typedef std::vector<std::vector<int> > imatrix;
  52. imatrix midenti(const imatrix& v)
  53. {
  54. return v;
  55. }
  56. typedef std::vector<std::vector<bool> > bmatrix;
  57. bmatrix midentb(const bmatrix& v)
  58. {
  59. return v;
  60. }
  61. std::map<int,C*> mapidentc(const std::map<int,C*>& v)
  62. {
  63. return v;
  64. }
  65. std::map<int,int> mapidenti(const std::map<int,int>& v)
  66. {
  67. return v;
  68. }
  69. std::map<std::string,int> mapident(const std::map<std::string,int>& v)
  70. {
  71. return v;
  72. }
  73. std::multimap<std::string,int> mapident(const std::multimap<std::string,int>& v)
  74. {
  75. return v;
  76. }
  77. std::vector<int> vident(const std::vector<int>& v)
  78. {
  79. return v;
  80. }
  81. std::set<int> sident(const std::set<int>& v)
  82. {
  83. return v;
  84. }
  85. std::vector<unsigned int> videntu(const std::vector<unsigned int>& v)
  86. {
  87. return v;
  88. }
  89. int get_elem(const std::vector<int>& v, int index)
  90. {
  91. return v[index];
  92. }
  93. std::pair<int,double> pident(const std::pair<int,double>& p)
  94. {
  95. return p;
  96. }
  97. void
  98. v_inout(std::vector<int> *INOUT) {
  99. *INOUT = *INOUT;
  100. }
  101. void
  102. v_inout2(std::vector<int> *INOUT, std::vector<int> *INOUT2) {
  103. std::swap(*INOUT, *INOUT2);
  104. }
  105. }
  106. %{
  107. template <class C> struct Param
  108. {
  109. };
  110. %}
  111. template <class C> struct Param
  112. {
  113. };
  114. %template(Param_c) Param<std::complex<double> >;
  115. %inline
  116. {
  117. int hello(Param<std::complex<double> > c)
  118. {
  119. return 0;
  120. }
  121. }
  122. %inline
  123. {
  124. struct A
  125. {
  126. A(int aa = 0) : a(aa)
  127. {
  128. }
  129. int a;
  130. };
  131. }
  132. %template() std::pair<A,int>;
  133. %template(pair_iA) std::pair<int,A>;
  134. %template(vector_piA) std::vector<std::pair<int,A> >;
  135. %inline {
  136. std::pair<A,int> ident(std::pair<int,A> a, const std::pair<int,int>& b)
  137. {
  138. return std::pair<A,int>();
  139. }
  140. std::vector<std::pair<int,A> > pia_vident(std::vector<std::pair<int,A> > a )
  141. {
  142. return a;
  143. }
  144. struct Foo
  145. {
  146. Foo(int i) {
  147. }
  148. };
  149. }
  150. %std_nodefconst_type(Foo);
  151. %template(vector_Foo) std::vector<Foo>;
  152. %template(deque_Foo) std::deque<Foo>;
  153. %template(list_Foo) std::list<Foo>;