summaryrefslogtreecommitdiff
path: root/Examples/test-suite/long_long_apply.i
blob: 0280994d2b64be1b484f0d407fcda4dc38e848b7 (plain)
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
/* This interface file tests whether SWIG handles the Microsoft __int64 type through the use of 
applying the long long typemaps. The generated code should not have any instances of long long. */

%module long_long_apply

%{
#ifdef _MSC_VER /* Visual C++ */
    typedef __int64 LongLong;
    typedef unsigned __int64 UnsignedLongLong;
#else
    typedef long long LongLong;
    typedef unsigned long long UnsignedLongLong;
#endif
%}

%apply long long { LongLong };
%apply unsigned long long { UnsignedLongLong };

%apply const long long & { const LongLong & };
%apply const unsigned long long & { const UnsignedLongLong & };

%inline %{
// pass by value
LongLong value1(LongLong x) { return x; }
UnsignedLongLong value2(UnsignedLongLong x) { return x; }

// pass by reference
const LongLong &ref1(const LongLong &x) { return x; }
const UnsignedLongLong &ref2(const UnsignedLongLong &x) { return x; }

// global variables
LongLong global1;
UnsignedLongLong global2;

// global reference variables
const LongLong& global_ref1 = global1;
const UnsignedLongLong& global_ref2 = global2;
%}


// typemaps library
%include "typemaps.i"
%apply long long *INPUT { LongLong *INPUT };
%apply unsigned long long *INPUT { UnsignedLongLong *INPUT };

%apply long long *OUTPUT { LongLong *OUTPUT };
%apply unsigned long long *OUTPUT { UnsignedLongLong *OUTPUT };

%apply long long *INOUT { LongLong *INOUT };
%apply unsigned long long *INOUT { UnsignedLongLong *INOUT };

%apply long long &INPUT { LongLong &INPUT };
%apply unsigned long long &INPUT { UnsignedLongLong &INPUT };

%apply long long &OUTPUT { LongLong &OUTPUT };
%apply unsigned long long &OUTPUT { UnsignedLongLong &OUTPUT };

%apply long long &INOUT { LongLong &INOUT };
%apply unsigned long long &INOUT { UnsignedLongLong &INOUT };

%inline %{
LongLong in_longlong(LongLong *INPUT) { return *INPUT; }
UnsignedLongLong in_ulonglong(UnsignedLongLong *INPUT) { return *INPUT; }
LongLong inr_longlong(LongLong &INPUT) { return INPUT; }
UnsignedLongLong inr_ulonglong(UnsignedLongLong &INPUT) { return INPUT; }

void out_longlong(LongLong x, LongLong *OUTPUT) {  *OUTPUT = x; }
void out_ulonglong(UnsignedLongLong x, UnsignedLongLong *OUTPUT) {  *OUTPUT = x; }
void outr_longlong(LongLong x, LongLong &OUTPUT) {  OUTPUT = x; }
void outr_ulonglong(UnsignedLongLong x, UnsignedLongLong &OUTPUT) {  OUTPUT = x; }

void inout_longlong(LongLong *INOUT) {  *INOUT = *INOUT; }
void inout_ulonglong(UnsignedLongLong *INOUT) {  *INOUT = *INOUT; }
void inoutr_longlong(LongLong &INOUT) {  INOUT = INOUT; }
void inoutr_ulonglong(UnsignedLongLong &INOUT) {  INOUT = INOUT; }
%}