summaryrefslogtreecommitdiff
path: root/Examples/test-suite/overload_complicated.i
blob: 08abaaed6d52d1e23aac5e30bd4d822d8fa84bb4 (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
// A complicated test of overloaded functions
%module overload_complicated

// Different overloaded warning filters needed for scripting languages (eg Python) and for statically typed languages (eg C#).
%warnfilter(509, 516) Pop::Pop;
%warnfilter(509, 516) Pop::hip;
%warnfilter(509, 516) Pop::hop;
%warnfilter(509, 516) Pop::pop;
%warnfilter(516) Pop::bop;
%warnfilter(516) Pop::bip;
%warnfilter(509, 516) ::muzak;
%warnfilter(509, 516) foo;

%typemap(in, numinputs=0) int l { $1 = 4711; }

%inline %{

int foo(int, int, char *, int) {
    return 15;
}

int foo(int i, int j, double k = 17.4, int l = 18 /* Note numinputs typemap above */, char m = 'P') {
    int sum = i + j + (int)k + l + (int)m;
    return sum;
}

struct Pop {
    Pop(int* i) {}
    Pop(int& i) {}
    Pop(const int* i, bool b) {}
    Pop(const int* i) {}

    // Check overloaded in const only and pointers/references which target languages cannot disambiguate
    int hip(bool b)                 { return 701; }
    int hip(int* i)                 { return 702; }
    int hip(int& i)                 { return 703; }
    int hip(int* i) const           { return 704; }
    int hip(const int* i)           { return 705; }

    // Reverse the order for the above
    int hop(const int* i)           { return 805; }
    int hop(int* i) const           { return 804; }
    int hop(int& i)                 { return 803; }
    int hop(int* i)                 { return 802; }
    int hop(bool b)                 { return 801; }

    // Few more variations and order shuffled
    int pop(bool b)                 { return 901; }
    int pop(int* i) const           { return 902; }
    int pop(int& i)                 { return 903; }
    int pop(int* i)                 { return 904; }
    int pop()                       { return 905; }
    int pop(const int* i)           { return 906; }

    // Overload on const only
    int bop(int* i)                 { return 1001; }
    int bop(int* i) const           { return 1002; }

    int bip(int* i) const           { return 2001; }
    int bip(int* i)                 { return 2002; }
};

// Globals
int muzak(bool b)                 { return 3001; }
int muzak(int* i)                 { return 3002; }
int muzak(int& i)                 { return 3003; }
int muzak(const int* i)           { return 3004; }

%}