PageRenderTime 30ms CodeModel.GetById 24ms app.highlight 2ms RepoModel.GetById 2ms app.codeStats 0ms

/trunk/Examples/test-suite/li_typemaps_apply.i

#
Swig | 46 lines | 38 code | 8 blank | 0 comment | 0 complexity | d1ba3d024d0162a66991858bb55d4f19 MD5 | raw file
 1%module li_typemaps_apply
 2
 3// Test %apply to global primitive type references/pointers to make sure the return types are still okay... mainly for the strongly typed languages.
 4
 5%include "typemaps.i"
 6
 7#if !defined(SWIGJAVA) // Needs asymmetric type marshalling support for this testcase to work
 8
 9%define TMAPS(PRIMTYPE, NAME)
10%apply PRIMTYPE *INPUT { PRIMTYPE * }
11%apply PRIMTYPE &INPUT { PRIMTYPE & }
12%inline %{
13PRIMTYPE *input_ptr_##NAME(PRIMTYPE *v) { static PRIMTYPE stat; stat = *v; return &stat; }
14PRIMTYPE &input_ref_##NAME(PRIMTYPE &v) { static PRIMTYPE stat; stat = v; return stat; }
15%}
16
17%apply PRIMTYPE *OUTPUT { PRIMTYPE * }
18%apply PRIMTYPE &OUTPUT { PRIMTYPE & }
19%inline %{
20PRIMTYPE *output_ptr_##NAME(PRIMTYPE x, PRIMTYPE *v) { static PRIMTYPE stat; stat = x; *v = x; return &stat; }
21PRIMTYPE &output_ref_##NAME(PRIMTYPE x, PRIMTYPE &v) { static PRIMTYPE stat; stat = x; v = x; return stat; }
22%}
23
24%apply PRIMTYPE *INOUT { PRIMTYPE * }
25%apply PRIMTYPE &INOUT { PRIMTYPE & }
26%inline %{
27PRIMTYPE *inout_ptr_##NAME(PRIMTYPE *v) { static PRIMTYPE stat; stat = *v; *v = *v; return &stat; }
28PRIMTYPE &inout_ref_##NAME(PRIMTYPE &v) { static PRIMTYPE stat; stat = v; v = v; return stat; }
29%}
30%enddef
31
32TMAPS(bool,               bool)
33TMAPS(int,                int)
34TMAPS(short,              short)
35TMAPS(long,               long)
36TMAPS(unsigned int,       uint)
37TMAPS(unsigned short,     ushort)
38TMAPS(unsigned long,      ulong)
39TMAPS(unsigned char,      uchar)
40TMAPS(signed char,        schar)
41TMAPS(float,              float)
42TMAPS(double,             double)
43TMAPS(long long,          longlong)
44TMAPS(unsigned long long, ulonglong)
45
46#endif