aboutsummaryrefslogtreecommitdiff
path: root/Examples/test-suite/overload_arrays.i
blob: e6bd09adf05cc96464fb6589131d0e53b23db91c (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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
// Tests of overloaded functions of arrays
// Based on overload_simple testcase
%module overload_arrays

#ifdef SWIGLUA
// lua only has one numeric type, so most of the overloads shadow each other creating warnings
%warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) foo;
%warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) bar;
%warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) Spam;
#endif

#ifdef SWIGGO
%warnfilter(SWIGWARN_PARSE_KEYWORD) type; // 'type' is a Go keyword, renamed as 'Xtype'
%rename(Foos) Foo;
#endif

#ifdef SWIGOCAML
%warnfilter(SWIGWARN_PARSE_KEYWORD) type;
#endif

%immutable Spam::type;

%inline %{

#define SIZE 3

struct Foo {
};

class Bar {
public:
  Bar(int i = 0) { num = i; }

  static int foo(int a=0, int b=0) {return 0;}

  int num;
};

char *foo() {
   return (char *) "foo:";
}
char *foo(int[SIZE]) {
   return (char*) "foo:int[SIZE]";
}

char *foo(double[SIZE]) {
   return (char*) "foo:double[SIZE]";
}

char *foo(char *[SIZE]) {
   return (char*) "foo:char *[SIZE]";
}

char *foo(Foo *[SIZE]) {
   return (char*) "foo:Foo *[SIZE]";
}
char *foo(Bar *[SIZE]) {
   return (char *) "foo:Bar *[SIZE]";
}
char *foo(void *[SIZE]) {
   return (char *) "foo:void *[SIZE]";
}
char *foo(Foo *[SIZE], int[SIZE]) {
   return (char *) "foo:Foo *[SIZE],int[SIZE]";
}
char *foo(double[SIZE], Bar *[SIZE]) {
   return (char *) "foo:double[SIZE],Bar *[SIZE]";
}

char *blah(double[SIZE]) {
   return (char *) "blah:double[SIZE]";
}

char *blah(char *[SIZE]) {
   return (char *) "blah:char *[SIZE]";
}

class Spam {
public:
    Spam() { type = "none"; }
    Spam(int[SIZE]) { type = "int[SIZE]"; }
    Spam(double[SIZE]) { type = "double[SIZE]"; }
    Spam(char *[SIZE]) { type = "char *[SIZE]"; }
    Spam(Foo *[SIZE]) { type = "Foo *[SIZE]"; }
    Spam(Bar *[SIZE]) { type = "Bar *[SIZE]"; }
    Spam(void *[SIZE]) { type = "void *[SIZE]"; }
    const char *type;

char *foo(int[SIZE]) {
   return (char*) "foo:int[SIZE]";
}
char *foo(double[SIZE]) {
   return (char*) "foo:double[SIZE]";
}
char *foo(char *[SIZE]) {
   return (char*) "foo:char *[SIZE]";
}
char *foo(Foo *[SIZE]) {
   return (char*) "foo:Foo *[SIZE]";
}
char *foo(Bar *[SIZE]) {
   return (char *) "foo:Bar *[SIZE]";
}
char *foo(void *[SIZE]) {
   return (char *) "foo:void *[SIZE]";
}

static char *bar(int[SIZE]) {
   return (char*) "bar:int[SIZE]";
}
static char *bar(double[SIZE]) {
   return (char*) "bar:double[SIZE]";
}
static char *bar(char *[SIZE]) {
   return (char*) "bar:char *[SIZE]";
}
static char *bar(Foo *[SIZE]) {
   return (char*) "bar:Foo *[SIZE]";
}
static char *bar(Bar *[SIZE]) {
   return (char *) "bar:Bar *[SIZE]";
}
static char *bar(void *[SIZE]) {
   return (char *) "bar:void *[SIZE]";
}
};

%}


%inline {
  class ClassA
  {
  public:
    ClassA() {}
    int method1( ) {return 0;}
    int method1( int arg1[SIZE] ) {return arg1[0];}
  protected:
    int method1( int arg1[SIZE], int arg2[SIZE] ) {return arg1[0] + arg2[0];}

  };
}