1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208
|
%module std_containers
//
// STL containers test suite.
// Tests:
// std::complex, std::string, std::vector, std::set, std::deque,
// std::pair, std::map, std::multiset, std::multimap and IN/OUT functions
// for them, with C++ types.
//
%{
#include <set>
%}
%include std_vector.i
%include std_string.i
%include std_deque.i
%include std_list.i
%include std_set.i
%include std_multiset.i
%include std_pair.i
%include std_map.i
%include std_multimap.i
%include std_complex.i
%template() std::vector<double>;
%template() std::pair<std::string, int>;
%template() std::pair<int,double>;
%template() std::vector< std::vector<double > > ;
%template(ccube) std::vector< std::vector< std::vector<double > > >;
%inline
{
typedef
std::vector<std::vector<std::vector<double > > >
ccube;
ccube cident(const ccube& c)
{
return c;
}
struct C
{
};
}
%template(map_si) std::map<std::string, int>;
%template(pair_iC) std::pair<int, C*>;
%template(map_iC) std::map<int, C*>;
%template(mmap_si) std::multimap<std::string, int>;
%template(set_i) std::set<int>;
%template(multiset_i) std::multiset<int>;
%template(list_i) std::list<int>;
%template(deque_i) std::deque<int>;
%template(vector_b) std::vector<bool>;
%template(vector_i) std::vector<int>;
%template(vector_c) std::vector<std::complex<double> >;
%template(vector_ui) std::vector<unsigned int>;
%template(bmatrix) std::vector<std::vector<bool> >;
%template(imatrix) std::vector<std::vector<int> >;
%template(cmatrix) std::vector<std::vector<std::complex<double> > >;
%apply std::vector<int> *INOUT {std::vector<int> *INOUT2};
%inline
{
typedef std::vector<std::vector<int> > imatrix;
imatrix midenti(const imatrix& v)
{
return v;
}
typedef std::vector<std::vector<bool> > bmatrix;
bmatrix midentb(const bmatrix& v)
{
return v;
}
std::map<int,C*> mapidentc(const std::map<int,C*>& v)
{
return v;
}
std::map<int,int> mapidenti(const std::map<int,int>& v)
{
return v;
}
std::map<std::string,int> mapident(const std::map<std::string,int>& v)
{
return v;
}
std::multimap<std::string,int> mapident(const std::multimap<std::string,int>& v)
{
return v;
}
std::vector<int> vident(const std::vector<int>& v)
{
return v;
}
std::set<int> sident(const std::set<int>& v)
{
return v;
}
std::vector<unsigned int> videntu(const std::vector<unsigned int>& v)
{
return v;
}
int get_elem(const std::vector<int>& v, int index)
{
return v[index];
}
std::pair<int,double> pident(const std::pair<int,double>& p)
{
return p;
}
void
v_inout(std::vector<int> *INOUT) {
*INOUT = *INOUT;
}
void
v_inout2(std::vector<int> *INOUT, std::vector<int> *INOUT2) {
std::swap(*INOUT, *INOUT2);
}
}
%{
template <class C> struct Param
{
};
%}
template <class C> struct Param
{
};
%template(Param_c) Param<std::complex<double> >;
%inline
{
int hello(Param<std::complex<double> > c)
{
return 0;
}
}
%inline
{
struct A
{
A(int aa = 0) : a(aa)
{
}
int a;
};
}
%template() std::pair<A,int>;
%template(pair_iA) std::pair<int,A>;
%template(vector_piA) std::vector<std::pair<int,A> >;
%inline {
std::pair<A,int> ident(std::pair<int,A> a, const std::pair<int,int>& b)
{
return std::pair<A,int>();
}
std::vector<std::pair<int,A> > pia_vident(std::vector<std::pair<int,A> > a )
{
return a;
}
struct Foo
{
int x;
Foo(int i) : x(i) {
}
};
}
%std_nodefconst_type(Foo);
%template(vector_Foo) std::vector<Foo>;
%template(deque_Foo) std::deque<Foo>;
%template(list_Foo) std::list<Foo>;
|