Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | /* ----------------------------------------------------------------------------- |
2 | * --- Input arguments --- | |
3 | * ----------------------------------------------------------------------------- */ | |
4 | ||
5 | /* Pointers, references, and arrays */ | |
6 | ||
7 | %typemap(in) SWIGTYPE *, SWIGTYPE [] | |
8 | "SWIG_Python_ConvertPtr($input, (void **)&$1, $descriptor, SWIG_POINTER_EXCEPTION | $disown); | |
9 | if (SWIG_arg_fail($argnum)) SWIG_fail;"; | |
10 | ||
11 | %typemap(in) SWIGTYPE* const& ($*ltype temp) | |
12 | "SWIG_Python_ConvertPtr($input, (void **)&temp, $*descriptor, SWIG_POINTER_EXCEPTION | $disown); | |
13 | if (SWIG_arg_fail($argnum)) SWIG_fail; | |
14 | $1 = &temp; | |
15 | "; | |
16 | ||
17 | %typemap(in) SWIGTYPE *DISOWN | |
18 | "SWIG_Python_ConvertPtr($input, (void **)&$1, $descriptor, SWIG_POINTER_EXCEPTION | SWIG_POINTER_DISOWN); | |
19 | if (SWIG_arg_fail($argnum)) SWIG_fail;"; | |
20 | ||
21 | /* Additional check for null references */ | |
22 | %typemap(in) SWIGTYPE & { | |
23 | SWIG_Python_ConvertPtr($input, (void **)&$1, $descriptor, SWIG_POINTER_EXCEPTION | $disown); | |
24 | if (SWIG_arg_fail($argnum)) SWIG_fail; | |
25 | if ($1 == NULL) { | |
26 | SWIG_null_ref("$basetype"); | |
27 | } | |
28 | if (SWIG_arg_fail($argnum)) SWIG_fail; | |
29 | } | |
30 | ||
31 | /* Object passed by value. Convert to a pointer */ | |
32 | %typemap(in) SWIGTYPE { | |
33 | $<ype argp; | |
34 | SWIG_Python_ConvertPtr($input, (void **)&argp, $&descriptor, SWIG_POINTER_EXCEPTION); | |
35 | if (SWIG_arg_fail($argnum)) SWIG_fail; | |
36 | if (argp == NULL) { | |
37 | SWIG_null_ref("$basetype"); | |
38 | } | |
39 | if (SWIG_arg_fail($argnum)) SWIG_fail; | |
40 | $1 = *argp; | |
41 | } | |
42 | ||
43 | /* Pointer to a class member */ | |
44 | %typemap(in) SWIGTYPE (CLASS::*) { | |
45 | if ((SWIG_ConvertPacked($input,(void *)(&$1),sizeof($type),$descriptor,0)) == -1) { | |
46 | SWIG_type_error("$type",$input); | |
47 | } | |
48 | if (SWIG_arg_fail($argnum)) SWIG_fail; | |
49 | } | |
50 | ||
51 | /* ----------------------------------------------------------------------------- | |
52 | * --- Output arguments --- | |
53 | * ----------------------------------------------------------------------------- */ | |
54 | ||
55 | /* Pointers, references, and arrays */ | |
56 | %typemap(out) SWIGTYPE *, SWIGTYPE & | |
57 | "$result = SWIG_NewPointerObj((void*)($1), $descriptor, $owner);"; | |
58 | ||
59 | ||
60 | %typemap(out) SWIGTYPE* const& | |
61 | "$result = SWIG_NewPointerObj((void*)(*$1), $*descriptor, $owner);"; | |
62 | ||
63 | /* Dynamic casts */ | |
64 | ||
65 | %typemap(out) SWIGTYPE *DYNAMIC, SWIGTYPE &DYNAMIC { | |
66 | swig_type_info *ty = SWIG_TypeDynamicCast($descriptor, (void **) &$1); | |
67 | $result = SWIG_NewPointerObj((void *) $1, ty, $owner); | |
68 | } | |
69 | ||
70 | /* Member pointer */ | |
71 | %typemap(out) SWIGTYPE (CLASS::*) | |
72 | "$result = SWIG_NewPackedObj((void*)(&$1), sizeof($type), $descriptor);"; | |
73 | ||
74 | /* Primitive types--return by value */ | |
75 | #ifdef __cplusplus | |
76 | %typemap(out) SWIGTYPE | |
77 | { | |
78 | $<ype resultptr; | |
79 | resultptr = new $ltype(SWIG_static_cast($1,$type &)); | |
80 | $result = SWIG_NewPointerObj((void *)(resultptr), $&descriptor, 1); | |
81 | } | |
82 | #else | |
83 | %typemap(out /* warning="452:Default return typemap could be unsafe" */) SWIGTYPE | |
84 | { | |
85 | $<ype resultptr; | |
86 | resultptr = ($<ype) malloc(sizeof($type)); | |
87 | if (resultptr) memcpy(resultptr, &$1, sizeof($type)); | |
88 | $result = SWIG_NewPointerObj((void *)(resultptr), $&descriptor, 1); | |
89 | } | |
90 | #endif | |
91 | ||
92 | ||
93 | /* ----------------------------------------------------------------------------- | |
94 | * --- Variable input --- | |
95 | * ----------------------------------------------------------------------------- */ | |
96 | ||
97 | /* memberin/globalin/varin, for fix arrays. */ | |
98 | ||
99 | %typemap(memberin) SWIGTYPE [ANY] { | |
100 | $basetype *inp = SWIG_static_cast($input, $basetype *); | |
101 | if (inp) { | |
102 | $basetype *dest = SWIG_static_cast($1, $basetype *); | |
103 | size_t ii = 0; | |
104 | for (; ii < $dim0; ++ii) dest[ii] = inp[ii]; | |
105 | } else { | |
106 | SWIG_null_ref("$basetype"); | |
107 | } | |
108 | } | |
109 | ||
110 | %typemap(globalin) SWIGTYPE [ANY] { | |
111 | $basetype *inp = SWIG_static_cast($input, $basetype *); | |
112 | if (inp) { | |
113 | $basetype *dest = SWIG_static_cast($1, $basetype *); | |
114 | size_t ii = 0; | |
115 | for (; ii < $dim0; ++ii) dest[ii] = inp[ii]; | |
116 | } else { | |
117 | SWIG_null_ref("$basetype"); | |
118 | } | |
119 | } | |
120 | ||
121 | %typemap(varin) SWIGTYPE [ANY] { | |
122 | $basetype *inp = 0; | |
123 | if ((SWIG_ConvertPtr($input, (void **)&inp, $descriptor, SWIG_POINTER_EXCEPTION)) == -1) { | |
124 | SWIG_append_errmsg("C/C++ variable '$name'"); | |
125 | return 1; | |
126 | } else if (inp) { | |
127 | size_t ii = 0; | |
128 | $basetype *dest = SWIG_static_cast($1, $basetype *); | |
129 | for (; ii < $dim0; ++ii) dest[ii] = inp[ii]; | |
130 | } else { | |
131 | SWIG_null_ref("$basetype"); | |
132 | return 1; | |
133 | } | |
134 | } | |
135 | ||
136 | /* memberin/globalin/varin, for fix double arrays. */ | |
137 | ||
138 | %typemap(memberin) SWIGTYPE [ANY][ANY] { | |
139 | $basetype (*inp)[$dim1] = SWIG_static_cast($input, $basetype (*)[$dim1]); | |
140 | if (inp) { | |
141 | $basetype (*dest)[$dim1] = SWIG_static_cast($1, $basetype (*)[$dim1]); | |
142 | size_t ii = 0; | |
143 | for (; ii < $dim0; ++ii) { | |
144 | $basetype *ip = inp[ii]; | |
145 | if (ip) { | |
146 | $basetype *dp = dest[ii]; | |
147 | size_t jj = 0; | |
148 | for (; jj < $dim1; ++jj) dp[jj] = ip[jj]; | |
149 | } else { | |
150 | SWIG_null_ref("$basetype"); | |
151 | } | |
152 | } | |
153 | } else { | |
154 | SWIG_null_ref("$basetype[$dim1]"); | |
155 | } | |
156 | } | |
157 | ||
158 | %typemap(globalin) SWIGTYPE [ANY][ANY] { | |
159 | $basetype (*inp)[$dim1] = SWIG_static_cast($input, $basetype (*)[$dim1]); | |
160 | if (inp) { | |
161 | $basetype (*dest)[$dim1] = SWIG_static_cast($1, $basetype (*)[$dim1]); | |
162 | size_t ii = 0; | |
163 | for (; ii < $dim0; ++ii) { | |
164 | $basetype *ip = inp[ii]; | |
165 | if (ip) { | |
166 | $basetype *dp = dest[ii]; | |
167 | size_t jj = 0; | |
168 | for (; jj < $dim1; ++jj) dp[jj] = ip[jj]; | |
169 | } else { | |
170 | SWIG_null_ref("$basetype"); | |
171 | } | |
172 | } | |
173 | } else { | |
174 | SWIG_null_ref("$basetype[$dim1]"); | |
175 | } | |
176 | } | |
177 | ||
178 | %typemap(varin) SWIGTYPE [ANY][ANY] { | |
179 | $basetype (*inp)[$dim1] = 0; | |
180 | if ((SWIG_ConvertPtr($input, (void **)&inp, $descriptor, SWIG_POINTER_EXCEPTION)) == -1) { | |
181 | SWIG_append_errmsg("C/C++ variable '$name'"); | |
182 | return 1; | |
183 | } else if (inp) { | |
184 | $basetype (*dest)[$dim1] = SWIG_static_cast($1, $basetype (*)[$dim1]); | |
185 | size_t ii = 0; | |
186 | for (; ii < $dim0; ++ii) { | |
187 | $basetype *ip = inp[ii]; | |
188 | if (ip) { | |
189 | $basetype *dp = dest[ii]; | |
190 | size_t jj = 0; | |
191 | for (; jj < $dim1; ++jj) dp[jj] = ip[jj]; | |
192 | } else { | |
193 | SWIG_null_ref("$basetype"); | |
194 | return 1; | |
195 | } | |
196 | } | |
197 | } else { | |
198 | SWIG_null_ref("$basetype[$dim1]"); | |
199 | return 1; | |
200 | } | |
201 | } | |
202 | ||
203 | /* Pointers, references, and variable size arrays */ | |
204 | ||
205 | %typemap(varin) SWIGTYPE * { | |
206 | void *temp; | |
207 | if ((SWIG_ConvertPtr($input, &temp, $descriptor, SWIG_POINTER_EXCEPTION | SWIG_POINTER_DISOWN)) == -1) { | |
208 | SWIG_append_errmsg("C/C++ variable '$name'"); | |
209 | return 1; | |
210 | } | |
211 | $1 = ($ltype) temp; | |
212 | } | |
213 | ||
214 | %typemap(varin,warning="462:Unable to set dimensionless array variable") SWIGTYPE [] | |
215 | { | |
216 | PyErr_SetString(PyExc_AttributeError, "C/C++ variable '$name' is read-only"); | |
217 | return 1; | |
218 | } | |
219 | ||
220 | %typemap(varin) SWIGTYPE & { | |
221 | void *temp; | |
222 | if ((SWIG_ConvertPtr($input, &temp, $descriptor, SWIG_POINTER_EXCEPTION)) == -1 || temp == NULL) { | |
223 | SWIG_append_errmsg("C/C++ variable '$name'"); | |
224 | return 1; | |
225 | } | |
226 | $1 = *($ltype) temp; | |
227 | } | |
228 | ||
229 | %typemap(varin) SWIGTYPE (CLASS::*) { | |
230 | char temp[sizeof($type)]; | |
231 | if ((SWIG_ConvertPacked($input,(void *) temp, sizeof($type), $descriptor, SWIG_POINTER_EXCEPTION)) == -1) { | |
232 | SWIG_append_errmsg("C/C++ variable '$name'"); | |
233 | return 1; | |
234 | } | |
235 | memmove((void *) &$1,temp,sizeof($type)); | |
236 | } | |
237 | ||
238 | %typemap(varin) SWIGTYPE { | |
239 | $<ype temp; | |
240 | if ((SWIG_ConvertPtr($input, (void **)(&temp), $&descriptor, SWIG_POINTER_EXCEPTION)) == -1) { | |
241 | SWIG_append_errmsg("C/C++ variable '$name'"); | |
242 | return 1; | |
243 | } | |
244 | $1 = *(($&type) temp); | |
245 | } | |
246 | ||
247 | /* ----------------------------------------------------------------------------- | |
248 | * --- Variable output --- | |
249 | * ----------------------------------------------------------------------------- */ | |
250 | ||
251 | /* Pointers and arrays */ | |
252 | %typemap(varout) SWIGTYPE *, SWIGTYPE [] | |
253 | "$result = SWIG_NewPointerObj((void *)($1), $descriptor, 0);"; | |
254 | ||
255 | /* References */ | |
256 | %typemap(varout) SWIGTYPE & | |
257 | "$result = SWIG_NewPointerObj((void *)(&$1), $descriptor, 0);"; | |
258 | ||
259 | /* Member pointer */ | |
260 | %typemap(varout) SWIGTYPE (CLASS::*) | |
261 | "$result = SWIG_NewPackedObj((void *)(&$1), sizeof($type), $descriptor);"; | |
262 | ||
263 | %typemap(varout) SWIGTYPE | |
264 | "$result = SWIG_NewPointerObj((void *)(&$1), $&descriptor, 0);"; | |
265 | ||
266 | /* ----------------------------------------------------------------------------- | |
267 | * --- Constants --- * | |
268 | * ----------------------------------------------------------------------------- */ | |
269 | ||
270 | ||
271 | /* Pointers, arrays, objects */ | |
272 | ||
273 | %typemap(consttab) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] | |
274 | { SWIG_PY_POINTER, (char*)"$symname", 0, 0, (void *)$value, &$descriptor} | |
275 | ||
276 | %typemap(consttab) SWIGTYPE (CLASS::*) | |
277 | { SWIG_PY_BINARY, (char *)"$symname", sizeof($type), 0, (void *)&$value, &$descriptor} | |
278 | ||
279 | ||
280 | /* ----------------------------------------------------------------------------- | |
281 | * --- Director typemaps --- * | |
282 | * ----------------------------------------------------------------------------- */ | |
283 | ||
284 | /* directorin */ | |
285 | ||
286 | %typemap(directorin) SWIGTYPE* { | |
287 | $input = SWIG_NewPointerObj(SWIG_static_cast(SWIG_static_cast($1_name, $1_ltype), void*), $descriptor, 0); | |
288 | } | |
289 | ||
290 | %typemap(directorin) SWIGTYPE { | |
291 | $input = SWIG_NewPointerObj(SWIG_static_cast(SWIG_static_cast(&$1_name, $&1_ltype), void*), $&descriptor, 0); | |
292 | } | |
293 | ||
294 | %typemap(directorin) SWIGTYPE& { | |
295 | $input = SWIG_NewPointerObj(SWIG_static_cast(SWIG_static_cast(&$1_name, $1_ltype), void*), $descriptor, 0); | |
296 | } | |
297 | ||
298 | /* the const cases */ | |
299 | %typemap(directorin) SWIGTYPE const& { | |
300 | $input = SWIG_NewPointerObj(SWIG_static_cast(SWIG_const_cast(&$1_name, $1_ltype), void*), $descriptor, 0); | |
301 | } | |
302 | ||
303 | %typemap(directorin) SWIGTYPE const* { | |
304 | $input = SWIG_NewPointerObj(SWIG_static_cast(SWIG_const_cast($1_name, $1_ltype), void*), $descriptor, 0); | |
305 | } | |
306 | ||
307 | ||
308 | /* directorout */ | |
309 | ||
310 | %typemap(directorout) SWIGTYPE ($<ype argp) | |
311 | "if (!$input || (SWIG_ConvertPtr($input, (void **)(&argp), | |
312 | $&descriptor, SWIG_POINTER_EXCEPTION | $disown)) == -1) | |
313 | Swig::DirectorTypeMismatchException::raise(\"Pointer conversion failed.\"); | |
314 | $result = *argp;"; | |
315 | ||
316 | %typemap(directorout) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] | |
317 | "if (!$input || (SWIG_ConvertPtr($input,(void **)(&$result), | |
318 | $descriptor,SWIG_POINTER_EXCEPTION | $disown )) == -1) | |
319 | Swig::DirectorTypeMismatchException::raise(\"Pointer conversion failed.\");"; | |
320 | ||
321 | ||
322 | /* ------------------------------------------------------------ | |
323 | * --- Typechecking rules --- | |
324 | * ------------------------------------------------------------ */ | |
325 | ||
326 | %typecheck(SWIG_TYPECHECK_POINTER) | |
327 | SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] | |
328 | { | |
329 | void *ptr; | |
330 | if (SWIG_ConvertPtr($input, &ptr, $descriptor, 0) == -1) { | |
331 | $1 = 0; | |
332 | PyErr_Clear(); | |
333 | } else { | |
334 | $1 = 1; | |
335 | } | |
336 | } | |
337 | ||
338 | %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE & | |
339 | { | |
340 | void *ptr = 0; | |
341 | if (SWIG_ConvertPtr($input, &ptr, $descriptor, 0) == -1) { | |
342 | $1 = 0; | |
343 | PyErr_Clear(); | |
344 | } else { | |
345 | $1 = (ptr != 0); | |
346 | } | |
347 | } | |
348 | ||
349 | %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE | |
350 | { | |
351 | void *ptr = 0; | |
352 | if (SWIG_ConvertPtr($input, &ptr, $&descriptor, 0) == -1) { | |
353 | $1 = 0; | |
354 | PyErr_Clear(); | |
355 | } else { | |
356 | $1 = (ptr != 0); | |
357 | } | |
358 | } | |
359 | ||
360 | ||
361 | /* ------------------------------------------------------------ | |
362 | * --- Exception handling --- | |
363 | * ------------------------------------------------------------ */ | |
364 | ||
365 | %typemap(throws) SWIGTYPE { | |
366 | $<ype temp = new $ltype($1); | |
367 | if ($&descriptor->clientdata) { | |
368 | PyErr_SetObject((PyObject *) ($&descriptor->clientdata), SWIG_NewPointerObj(temp,$&descriptor,1)); | |
369 | } else { | |
370 | PyErr_SetString(PyExc_RuntimeError,"$type"); | |
371 | } | |
372 | SWIG_fail; | |
373 | } | |
374 | ||
375 | ||
376 | %typemap(throws) SWIGTYPE * { | |
377 | if ($descriptor->clientdata) { | |
378 | PyErr_SetObject((PyObject *) ($descriptor->clientdata), | |
379 | SWIG_NewPointerObj((void *) $1,$descriptor,1)); | |
380 | } else { | |
381 | PyErr_SetString(PyExc_RuntimeError,"$type"); | |
382 | } | |
383 | SWIG_fail; | |
384 | } | |
385 | ||
386 | ||
387 | %typemap(throws) SWIGTYPE [ANY] { | |
388 | if ($descriptor->clientdata) { | |
389 | PyErr_SetObject((PyObject *) ($descriptor->clientdata), | |
390 | SWIG_NewPointerObj((void *)$1,$descriptor,1)); | |
391 | } else { | |
392 | PyErr_SetString(PyExc_RuntimeError,"$type"); | |
393 | } | |
394 | SWIG_fail; | |
395 | } | |
396 | ||
397 | %typemap(throws) SWIGTYPE & { | |
398 | if ($descriptor->clientdata) { | |
399 | PyErr_SetObject((PyObject *) ($descriptor->clientdata), | |
400 | SWIG_NewPointerObj((void *)&($1),$descriptor,1)); | |
401 | } else { | |
402 | PyErr_SetString(PyExc_RuntimeError,"$type"); | |
403 | } | |
404 | SWIG_fail; | |
405 | } |