Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | /* ----------------------------------------------------------------------------- |
2 | * perl5.swg | |
3 | * | |
4 | * Perl 5 configuration file | |
5 | * ----------------------------------------------------------------------------- */ | |
6 | ||
7 | %runtime "swigrun.swg" // Common C API type-checking code | |
8 | %runtime "perlrun.swg" // Perl runtime functions | |
9 | %runtime "noembed.h" // undefine Perl5 macros | |
10 | ||
11 | #define %perlcode %insert("perl") | |
12 | ||
13 | /* Typemaps for input parameters */ | |
14 | ||
15 | %typemap(in) int, short, long, signed char, enum SWIGTYPE | |
16 | "$1 = ($1_ltype) SvIV($input);"; | |
17 | ||
18 | %typemap(in) bool | |
19 | "$1 = SvIV($input) ? true : false;"; | |
20 | ||
21 | %typemap(in) unsigned int, unsigned short, unsigned long, unsigned char | |
22 | "$1 = ($1_ltype) SvUV($input);"; | |
23 | ||
24 | %typemap(in) char | |
25 | "$1 = ($1_ltype) *SvPV($input,PL_na);"; | |
26 | ||
27 | %typemap(in) float, double | |
28 | "$1 = ($1_ltype) SvNV($input);\n"; | |
29 | ||
30 | %typemap(in) long long "$1 = ($1_ltype) strtoll(SvPV($input, PL_na), 0, 0);"; | |
31 | %typemap(in) unsigned long long "$1 = ($1_ltype) strtoull(SvPV($input, PL_na), 0, 0);"; | |
32 | ||
33 | %typemap(in) char * | |
34 | "if (!SvOK((SV*) $input)) $1 = 0; | |
35 | else $1 = ($1_ltype) SvPV($input, PL_na);"; | |
36 | ||
37 | %typemap(in) char [ANY] | |
38 | "$1 = SvPV($input,PL_na);\n"; | |
39 | ||
40 | %typemap(in) SWIGTYPE *, SWIGTYPE [], SWIGTYPE & { | |
41 | if (SWIG_ConvertPtr($input, (void **) &$1, $1_descriptor,0) < 0) { | |
42 | SWIG_croak("Type error in argument $argnum of $symname. Expected $1_mangle"); | |
43 | } | |
44 | } | |
45 | ||
46 | %typemap(in) void * { | |
47 | if (SWIG_ConvertPtr($input, (void **) &$1, 0,0) < 0) { | |
48 | SWIG_croak("Type error in argument $argnum of $symname. Expected $1_mangle"); | |
49 | } | |
50 | } | |
51 | ||
52 | /* Object passed by value. Convert to a pointer */ | |
53 | %typemap(in) SWIGTYPE { | |
54 | $&1_ltype argp; | |
55 | if (SWIG_ConvertPtr($input,(void **) &argp, $&1_descriptor,0) < 0) { | |
56 | SWIG_croak("Type error in argument $argnum of $symname. Expected $&1_mangle"); | |
57 | } | |
58 | $1 = *argp; | |
59 | } | |
60 | ||
61 | /* Pointer to a class member */ | |
62 | %typemap(in) SWIGTYPE (CLASS::*) { | |
63 | if ((SWIG_ConvertPacked($input, (void *) &$1, sizeof($1_type), $1_descriptor,0)) < 0) { | |
64 | SWIG_croak("Type error in argument $argnum of $symname. Expected $&1_mangle"); | |
65 | } | |
66 | } | |
67 | ||
68 | /* Const primitive references. Passed by value */ | |
69 | ||
70 | %typemap(in) const int & (int temp), | |
71 | const short & (short temp), | |
72 | const long & (long temp), | |
73 | const signed char & (signed char temp), | |
74 | const enum SWIGTYPE & ($*1_ltype temp) | |
75 | "temp = ($*1_ltype) SvIV($input); | |
76 | $1 = &temp;"; | |
77 | ||
78 | %typemap(in) const bool & (bool temp) | |
79 | "temp = SvIV($input) ? true : false; | |
80 | $1 = &temp;"; | |
81 | ||
82 | %typemap(in) const unsigned int & (unsigned int temp), | |
83 | const unsigned short & (unsigned short temp), | |
84 | const unsigned long & (unsigned long temp), | |
85 | const unsigned char & (unsigned char temp) | |
86 | "temp = ($*1_ltype) SvUV($input); | |
87 | $1 = &temp;"; | |
88 | ||
89 | %typemap(in) const float & (float temp), | |
90 | const double & (double temp) | |
91 | "temp = ($*1_ltype) SvNV($input); | |
92 | $1 = &temp;"; | |
93 | ||
94 | %typemap(in) const long long & ($*1_ltype temp) | |
95 | "temp = ($*1_ltype) strtoll(SvPV($input,PL_na),0,0); | |
96 | $1 = &temp;"; | |
97 | ||
98 | %typemap(in) const unsigned long long & ($*1_ltype temp) | |
99 | "temp = ($*1_ltype) strtoull(SvPV($input, PL_na),0,0); | |
100 | $1 = &temp;"; | |
101 | ||
102 | %typemap(in) const char &(char temp) { | |
103 | temp = *SvPV($input,PL_na); | |
104 | $1 = &temp; | |
105 | } | |
106 | ||
107 | /* Typemap for output values */ | |
108 | ||
109 | %typemap(out) int, short, long, signed char, bool, enum SWIGTYPE | |
110 | "ST(argvi) = sv_newmortal(); | |
111 | sv_setiv(ST(argvi++), (IV) $1);"; | |
112 | ||
113 | %typemap(out) unsigned int, unsigned short, unsigned long, unsigned char | |
114 | "ST(argvi) = sv_newmortal(); | |
115 | sv_setuv(ST(argvi++), (UV) $1);"; | |
116 | ||
117 | %typemap(out) float, double | |
118 | "ST(argvi) = sv_newmortal(); | |
119 | sv_setnv(ST(argvi++), (double) $1);"; | |
120 | ||
121 | %typemap(out) char | |
122 | "ST(argvi) = sv_newmortal(); | |
123 | sv_setpvn((SV*)ST(argvi++), &$1, 1);"; | |
124 | ||
125 | %typemap(out) char * | |
126 | "ST(argvi) = sv_newmortal(); | |
127 | if ($1) { | |
128 | sv_setpv((SV*)ST(argvi++), (char *) $1); | |
129 | } else { | |
130 | sv_setsv((SV*)ST(argvi++), &PL_sv_undef); | |
131 | }"; | |
132 | ||
133 | %typemap(out) long long { | |
134 | char temp[256]; | |
135 | sprintf(temp,"%lld", (long long) $1); | |
136 | ST(argvi) = sv_newmortal(); | |
137 | sv_setpv((SV*)ST(argvi++), temp); | |
138 | } | |
139 | ||
140 | %typemap(out) unsigned long long { | |
141 | char temp[256]; | |
142 | sprintf(temp,"%llu", (unsigned long long) $1); | |
143 | ST(argvi) = sv_newmortal(); | |
144 | sv_setpv((SV*)ST(argvi++), temp); | |
145 | } | |
146 | ||
147 | %typemap(out) SWIGTYPE *, SWIGTYPE [], SWIGTYPE & | |
148 | "ST(argvi) = sv_newmortal(); | |
149 | SWIG_MakePtr(ST(argvi++), (void *) $1, $1_descriptor, $shadow|$owner);"; | |
150 | ||
151 | ||
152 | %typemap(out) SWIGTYPE | |
153 | #ifdef __cplusplus | |
154 | { | |
155 | $&1_ltype resultobj = new $1_ltype(($1_ltype &)$1); | |
156 | ST(argvi) = sv_newmortal(); | |
157 | SWIG_MakePtr(ST(argvi++), (void *) resultobj, $&1_descriptor, $shadow|SWIG_OWNER); | |
158 | } | |
159 | #else | |
160 | { | |
161 | $&1_ltype resultobj = ($&1_ltype) malloc(sizeof($1_type)); | |
162 | memmove(resultobj, &$1, sizeof($1_type)); | |
163 | ST(argvi) = sv_newmortal(); | |
164 | SWIG_MakePtr(ST(argvi++), (void *) resultobj, $&1_descriptor, $shadow|SWIG_OWNER); | |
165 | } | |
166 | #endif | |
167 | ||
168 | /* Dynamic casts */ | |
169 | ||
170 | %typemap(out) SWIGTYPE *DYNAMIC, SWIGTYPE &DYNAMIC { | |
171 | swig_type_info *ty = SWIG_TypeDynamicCast($1_descriptor, (void **) &$1); | |
172 | ST(argvi) = sv_newmortal(); | |
173 | SWIG_MakePtr(ST(argvi++), (void *) $1, ty, $shadow|$owner); | |
174 | } | |
175 | ||
176 | /* Member pointer */ | |
177 | %typemap(out) SWIGTYPE (CLASS::*) { | |
178 | ST(argvi) = sv_newmortal(); | |
179 | SWIG_MakePackedObj(ST(argvi), (void *) &$1, sizeof($1_type), $1_descriptor); | |
180 | argvi++; | |
181 | } | |
182 | ||
183 | %typemap(out) void ""; | |
184 | ||
185 | /* Typemap for character array returns */ | |
186 | ||
187 | %typemap(out) char [ANY] | |
188 | "ST(argvi) = sv_newmortal(); | |
189 | sv_setpv((SV*)ST(argvi++),(char *) $1);"; | |
190 | ||
191 | ||
192 | ||
193 | /* References to primitive types. Return by value */ | |
194 | ||
195 | %typemap(out) const int &, | |
196 | const short &, | |
197 | const long &, | |
198 | const signed char &, | |
199 | const bool &, | |
200 | const enum SWIGTYPE & | |
201 | "ST(argvi) = sv_newmortal(); | |
202 | sv_setiv(ST(argvi++), (IV) *($1));"; | |
203 | ||
204 | %typemap(out) const unsigned int &, | |
205 | const unsigned short &, | |
206 | const unsigned long &, | |
207 | const unsigned char & | |
208 | "ST(argvi) = sv_newmortal(); | |
209 | sv_setuv(ST(argvi++), (UV) *($1));"; | |
210 | ||
211 | %typemap(out) const float &, const double & | |
212 | "ST(argvi) = sv_newmortal(); | |
213 | sv_setnv(ST(argvi++), (double) *($1));"; | |
214 | ||
215 | %typemap(out) const long long & { | |
216 | char temp[256]; | |
217 | sprintf(temp,"%lld", (long long)*($1)); | |
218 | ST(argvi) = sv_newmortal(); | |
219 | sv_setpv((SV*)ST(argvi++), temp); | |
220 | } | |
221 | ||
222 | %typemap(out) const unsigned long long & { | |
223 | char temp[256]; | |
224 | sprintf(temp,"%llu", (unsigned long long)*($1)); | |
225 | ST(argvi) = sv_newmortal(); | |
226 | sv_setpv((SV*)ST(argvi++), temp); | |
227 | } | |
228 | ||
229 | %typemap(out) const char & | |
230 | "ST(argvi) = sv_newmortal(); | |
231 | sv_setpvn((SV*)ST(argvi++), $1, 1);"; | |
232 | ||
233 | ||
234 | /* Variable input */ | |
235 | ||
236 | %typemap(varin) int, short, long, signed char | |
237 | "$1 = ($1_ltype) SvIV($input);"; | |
238 | ||
239 | %typemap(varin) bool | |
240 | "$1 = SvIV($input) ? true : false;"; | |
241 | ||
242 | %typemap(varin) unsigned int, unsigned short, unsigned long, unsigned char | |
243 | "$1 = ($1_ltype) SvUV($input);"; | |
244 | ||
245 | %typemap(varin) char | |
246 | "$1 = ($1_ltype) *SvPV($input,PL_na);"; | |
247 | ||
248 | %typemap(varin) float, double | |
249 | "$1 = ($1_ltype) SvNV($input);\n"; | |
250 | ||
251 | %typemap(varin) long long "$1 = ($1_ltype) strtoll(SvPV($input, PL_na), 0, 0);"; | |
252 | %typemap(varin) unsigned long long "$1 = ($1_ltype) strtoull(SvPV($input, PL_na), 0, 0);"; | |
253 | ||
254 | %typemap(varin) SWIGTYPE * { | |
255 | void *temp; | |
256 | if (SWIG_ConvertPtr($input, &temp, $1_descriptor,0) < 0) { | |
257 | croak("Type error in argument $argnum of $symname. Expected $1_mangle"); | |
258 | } | |
259 | $1 = ($1_ltype) temp; | |
260 | } | |
261 | ||
262 | %typemap(varin) SWIGTYPE [ANY] { | |
263 | int i; | |
264 | $1_basetype *temp; | |
265 | $1_basetype *b = ($1_basetype *) $1; | |
266 | if (SWIG_ConvertPtr($input, (void **) &temp, $1_descriptor,0) < 0) { | |
267 | croak("Type error in argument $argnum of $symname. Expected $1_mangle"); | |
268 | } | |
269 | for (i = 0; i < $1_size; i++) b[i] = temp[i]; | |
270 | } | |
271 | ||
272 | %typemap(varin,warning="462:Unable to set dimensionless array variable") SWIGTYPE [] | |
273 | { | |
274 | croak("C/C++ variable '$name' is read-only"); | |
275 | } | |
276 | ||
277 | %typemap(varin) SWIGTYPE & { | |
278 | void *temp; | |
279 | if (SWIG_ConvertPtr($input, &temp, $1_descriptor,0) < 0) { | |
280 | croak("Type error in argument $argnum of $symname. Expected $1_mangle"); | |
281 | } | |
282 | $1 = *($1_ltype) temp; | |
283 | } | |
284 | ||
285 | %typemap(varin) void * { | |
286 | void *temp; | |
287 | if (SWIG_ConvertPtr($input, &temp, 0,0) < 0) { | |
288 | croak("Type error in argument $argnum of $symname. Expected $1_mangle"); | |
289 | } | |
290 | $1 = temp; | |
291 | } | |
292 | ||
293 | /* Object passed by value. Convert to a pointer */ | |
294 | %typemap(varin) SWIGTYPE { | |
295 | $&1_ltype temp; | |
296 | if (SWIG_ConvertPtr($input,(void **) &temp, $&1_descriptor,0) < 0) { | |
297 | croak("Type error in argument $argnum of $symname. Expected $&1_mangle"); | |
298 | } | |
299 | $1 = *temp; | |
300 | } | |
301 | ||
302 | /* Member pointer */ | |
303 | %typemap(varin) SWIGTYPE (CLASS::*) { | |
304 | char temp[sizeof($1_type)]; | |
305 | if (SWIG_ConvertPacked($input, (void *) temp, sizeof($1_type), $1_descriptor, 0) < 0) { | |
306 | croak("Type error in argument $argnum of $symname. Expected $&1_mangle"); | |
307 | } | |
308 | memmove((void *) &$1, temp, sizeof($1_type)); | |
309 | } | |
310 | ||
311 | /* Const primitive references. Passed by value */ | |
312 | ||
313 | %typemap(varin) const int & (int temp), | |
314 | const short & (short temp), | |
315 | const long & (long temp), | |
316 | const signed char & (signed char temp), | |
317 | const enum SWIGTYPE & ($*1_ltype temp) | |
318 | "temp = ($*1_ltype) SvIV($input); | |
319 | $1 = &temp;"; | |
320 | ||
321 | %typemap(varin) const bool & (bool temp) | |
322 | "temp = SvIV($input) ? true : false; | |
323 | $1 = &temp;"; | |
324 | ||
325 | %typemap(varin) const unsigned int & (unsigned int temp), | |
326 | const unsigned short & (unsigned short temp), | |
327 | const unsigned long & (unsigned long temp), | |
328 | const unsigned char & (unsigned char temp) | |
329 | "temp = ($*1_ltype) SvUV($input); | |
330 | $1 = &temp;"; | |
331 | ||
332 | %typemap(varin) const float & (float temp), | |
333 | const double & (double temp) | |
334 | "temp = ($*1_ltype) SvNV($input); | |
335 | $1 = &temp;"; | |
336 | ||
337 | %typemap(varin) const long long & ($*1_ltype temp) | |
338 | "temp = ($1_ltype) strtoll(SvPV($input,PL_na),0,0); | |
339 | $1 = &temp;"; | |
340 | ||
341 | %typemap(varin) const unsigned long long & ($*1_ltype temp) | |
342 | "temp = ($1_ltype) strtoull(SvPV($input, PL_na),0,0); | |
343 | $1 = &temp;"; | |
344 | ||
345 | %typemap(varin) const char &(char temp) { | |
346 | temp = *SvPV($input,PL_na); | |
347 | $1 = &temp; | |
348 | } | |
349 | ||
350 | %typemap(varin) char * | |
351 | #ifdef __cplusplus | |
352 | { | |
353 | char *_a = (char *) SvPV(sv,PL_na); | |
354 | if ($1) delete [] $1; | |
355 | $1 = new char[strlen(_a)+1]; | |
356 | strcpy((char *)$1,_a); | |
357 | } | |
358 | #else | |
359 | { | |
360 | char *_a = (char *) SvPV(sv,PL_na); | |
361 | if ($1) free((char *) $1); | |
362 | $1 = (char *) malloc(strlen(_a)+1); | |
363 | strcpy((char *)$1,_a); | |
364 | } | |
365 | #endif | |
366 | ||
367 | %typemap(varin,warning="451:Setting const char * variable may leak memory") const char * | |
368 | #ifdef __cplusplus | |
369 | { | |
370 | char *_a = (char *) SvPV(sv,PL_na); | |
371 | $1 = new char[strlen(_a)+1]; | |
372 | strcpy((char *)$1,_a); | |
373 | } | |
374 | #else | |
375 | { | |
376 | char *_a = (char *) SvPV(sv,PL_na); | |
377 | $1 = (char *) malloc(strlen(_a)+1); | |
378 | strcpy((char *)$1,_a); | |
379 | } | |
380 | #endif | |
381 | ||
382 | %typemap(varin) char [ANY] | |
383 | "strncpy($1, (char *) SvPV(sv,PL_na), $1_dim0);"; | |
384 | ||
385 | %typemap(varin,warning="462: Unable to set variable of type char []") char [] | |
386 | { croak("Variable $symname is read-only."); } | |
387 | ||
388 | %typemap(varin) enum SWIGTYPE { | |
389 | if (sizeof(int) != sizeof($1)) { | |
390 | croak("enum variable '$name' can not be set."); | |
391 | } | |
392 | *(int *)(void *)&($1) = SvIV($input); | |
393 | } | |
394 | ||
395 | /* --- Typemaps for variable output --- */ | |
396 | ||
397 | %typemap(varout) int, short, long, signed char, bool, enum SWIGTYPE | |
398 | "sv_setiv($result, (IV) $1);"; | |
399 | ||
400 | %typemap(varout) unsigned int, unsigned short, unsigned long, unsigned char | |
401 | "sv_setuv($result, (UV) $1);"; | |
402 | ||
403 | %typemap(varout) float, double | |
404 | "sv_setnv($result, (double) $1);"; | |
405 | ||
406 | %typemap(varout) char | |
407 | "sv_setpvn((SV *) $result, &$1, 1);"; | |
408 | ||
409 | %typemap(varout) long long { | |
410 | char temp[256]; | |
411 | sprintf(temp,"%lld",(long long)$1); | |
412 | sv_setpv((SV *) $result, temp); | |
413 | } | |
414 | ||
415 | %typemap(varout) unsigned long long { | |
416 | char temp[256]; | |
417 | sprintf(temp,"%llu",(unsigned long long)$1); | |
418 | sv_setpv((SV *) $result, temp); | |
419 | } | |
420 | ||
421 | %typemap(varout) char *, char [ANY] | |
422 | "if ($1) { | |
423 | sv_setpv((SV*)$result, (char *) $1); | |
424 | } else { | |
425 | sv_setsv((SV*)$result, &PL_sv_undef); | |
426 | }"; | |
427 | ||
428 | //%typemap(varout) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] | |
429 | // "SWIG_MakePtr($result, (void *) $1, $1_descriptor);"; | |
430 | ||
431 | %typemap(varout,type="$1_descriptor") SWIGTYPE *, SWIGTYPE [] | |
432 | "sv_setiv(SvRV($result),(IV) $1);"; | |
433 | ||
434 | %typemap(varout,type="$1_descriptor") SWIGTYPE & | |
435 | "sv_setiv(SvRV($result),(IV) &$1);"; | |
436 | ||
437 | //%typemap(varout) SWIGTYPE | |
438 | // "SWIG_MakePtr($result, (void *) &$1, $&1_descriptor);"; | |
439 | ||
440 | %typemap(varout,type="$&1_descriptor") SWIGTYPE | |
441 | "sv_setiv(SvRV($result), (IV) &$1);"; | |
442 | ||
443 | %typemap(varout,type="$1_descriptor") SWIGTYPE (CLASS::*) { | |
444 | SWIG_MakePackedObj($result, (void *) &$1, sizeof($1_type), $1_descriptor); | |
445 | } | |
446 | ||
447 | /* --- Typemaps for constants --- * | |
448 | ||
449 | /* --- Constants --- */ | |
450 | ||
451 | %typemap(consttab) int, unsigned int, short, unsigned short, long, unsigned long, unsigned char, signed char, bool, enum SWIGTYPE | |
452 | { SWIG_INT, (char *) SWIG_prefix "$symname", (long) $value, 0, 0, 0} | |
453 | ||
454 | %typemap(consttab) float, double | |
455 | { SWIG_FLOAT, (char *) SWIG_prefix "$symname", 0, (double) $value, 0, 0} | |
456 | ||
457 | %typemap(consttab) char, char * | |
458 | { SWIG_STRING, (char *) SWIG_prefix "$symname", 0, 0, (void *)$value, 0} | |
459 | ||
460 | %typemap(consttab) long long, unsigned long long | |
461 | { SWIG_STRING, (char *) SWIG_prefix "$symname", 0, 0, (void *) "$value", 0} | |
462 | ||
463 | %typemap(consttab) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] | |
464 | { SWIG_POINTER, (char *) SWIG_prefix "$symname", 0, 0, (void *)$value, &$1_descriptor} | |
465 | ||
466 | %typemap(consttab) SWIGTYPE (CLASS::*) | |
467 | { SWIG_BINARY, (char *) SWIG_prefix "$symname", sizeof($type), 0, (void *)&$value, &$1_descriptor} | |
468 | ||
469 | ||
470 | /* ------------------------------------------------------------ | |
471 | * String & length | |
472 | * ------------------------------------------------------------ */ | |
473 | ||
474 | %typemap(in) (char *STRING, int LENGTH) { | |
475 | STRLEN temp; | |
476 | $1 = ($1_ltype) SvPV($input,temp); | |
477 | $2 = ($2_ltype) temp; | |
478 | } | |
479 | ||
480 | /* ------------------------------------------------------------ | |
481 | * ANSI C typemaps | |
482 | * ------------------------------------------------------------ */ | |
483 | ||
484 | %apply unsigned long { size_t }; | |
485 | ||
486 | /* ------------------------------------------------------------ | |
487 | * Typechecking rules | |
488 | * ------------------------------------------------------------ */ | |
489 | ||
490 | %typecheck(SWIG_TYPECHECK_INTEGER) | |
491 | int, short, long, | |
492 | unsigned int, unsigned short, unsigned long, | |
493 | signed char, unsigned char, | |
494 | long long, unsigned long long, | |
495 | const int &, const short &, const long &, | |
496 | const unsigned int &, const unsigned short &, const unsigned long &, | |
497 | const long long &, const unsigned long long &, | |
498 | enum SWIGTYPE, const enum SWIGTYPE &, | |
499 | bool, const bool & | |
500 | { | |
501 | $1 = SvIOK($input) ? 1 : 0; | |
502 | } | |
503 | ||
504 | %typecheck(SWIG_TYPECHECK_DOUBLE) | |
505 | float, double, | |
506 | const float &, const double & | |
507 | { | |
508 | $1 = SvNIOK($input) ? 1 : 0; | |
509 | } | |
510 | ||
511 | %typecheck(SWIG_TYPECHECK_CHAR) char { | |
512 | $1 = SvPOK($input) ? 1 : 0; | |
513 | } | |
514 | ||
515 | %typecheck(SWIG_TYPECHECK_STRING) char * { | |
516 | $1 = SvPOK($input) ? 1 : 0; | |
517 | } | |
518 | ||
519 | %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] { | |
520 | void *tmp; | |
521 | if (SWIG_ConvertPtr($input, (void **) &tmp, $1_descriptor, 0) == -1) { | |
522 | $1 = 0; | |
523 | } else { | |
524 | $1 = 1; | |
525 | } | |
526 | } | |
527 | ||
528 | %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE { | |
529 | void *tmp; | |
530 | if (SWIG_ConvertPtr($input, (void **) &tmp, $&1_descriptor, 0) == -1) { | |
531 | $1 = 0; | |
532 | } else { | |
533 | $1 = 1; | |
534 | } | |
535 | } | |
536 | ||
537 | %typecheck(SWIG_TYPECHECK_VOIDPTR) void * { | |
538 | void *tmp; | |
539 | if (SWIG_ConvertPtr($input, (void **) &tmp, 0, 0) == -1) { | |
540 | $1 = 0; | |
541 | } else { | |
542 | $1 = 1; | |
543 | } | |
544 | } | |
545 | ||
546 | /* ------------------------------------------------------------ | |
547 | * Exception handling | |
548 | * ------------------------------------------------------------ */ | |
549 | ||
550 | %typemap(throws) int, | |
551 | long, | |
552 | short, | |
553 | unsigned int, | |
554 | unsigned long, | |
555 | unsigned short { | |
556 | SWIG_SetErrorf("%d", $1); SWIG_fail; | |
557 | } | |
558 | ||
559 | /* throws real objects */ | |
560 | %typemap(throws) SWIGTYPE | |
561 | { | |
562 | SV *esv=sv_newmortal(); | |
563 | $&1_ltype copy = new $1_ltype(($1_ltype &)$1); | |
564 | SWIG_MakePtr(esv, (void *) copy, | |
565 | $&1_descriptor, SWIG_OWNER); | |
566 | SWIG_croakSV(esv); | |
567 | } | |
568 | ||
569 | %typemap(throws) SWIGTYPE, SWIGTYPE &, SWIGTYPE *, SWIGTYPE [ANY] %{ | |
570 | (void)$1; | |
571 | SWIG_croak("C++ $1_type exception thrown"); | |
572 | %} | |
573 | ||
574 | %typemap(throws) enum SWIGTYPE %{ | |
575 | (void)$1; | |
576 | SWIG_croak("C++ $1_type exception thrown"); | |
577 | %} | |
578 | ||
579 | %typemap(throws) char * { | |
580 | SWIG_croak($1); | |
581 | } | |
582 | ||
583 | %include "perlinit.swg" |