~ubuntu-branches/ubuntu/oneiric/swig1.3/oneiric

« back to all changes in this revision

Viewing changes to Examples/test-suite/std_containers.i

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2007-12-06 10:27:08 UTC
  • mfrom: (1.2.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20071206102708-t37t62i45n595w0e
Tags: 1.3.33-2ubuntu1
* Merge with Debian; remaining changes:
  - Drop support for pike.
  - Use python2.5 instead of python2.4.
  - Clean Runtime/ as well.
  - Force a few environment variables.
* debian/Rules (clean): Remove Lib/ocaml/swigp4.ml.

Show diffs side-by-side

added added

removed removed

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