1 %module(docstring="hello.") autodoc
2
3 %warnfilter(SWIGWARN_PARSE_KEYWORD) inout;
4
5 %feature("autodoc");
6
7 // special typemap and its docs
8 %typemap(in) (int c, int d) "$1 = 0; $2 = 0;";
9 %typemap(doc,name="hello",type="Tuple") (int c, int d) "hello: int tuple[2]";
10
11 // testing for different documentation levels
12 %feature("autodoc","0") A::func0; // names
13 %feature("autodoc","1") A::func1; // names + types
14 %feature("autodoc","2") A::func2; // extended
15 %feature("autodoc","3") A::func3; // extended + types
16
17 %feature("autodoc","0") A::func0default; // names
18 %feature("autodoc","1") A::func1default; // names + types
19 %feature("autodoc","2") A::func2default; // extended
20 %feature("autodoc","3") A::func3default; // extended + types
21
22 %feature("autodoc","0") A::func0static; // names
23 %feature("autodoc","1") A::func1static; // names + types
24 %feature("autodoc","2") A::func2static; // extended
25 %feature("autodoc","3") A::func3static; // extended + types
26
27 %feature("autodoc","0") A::variable_a; // names
28 %feature("autodoc","1") A::variable_b; // names + types
29 %feature("autodoc","2") A::variable_c; // extended
30 %feature("autodoc","3") A::variable_d; // extended + types
31
32 %feature("autodoc","just a string.") A::funk; // names
33
34 %inline {
35
36 enum Hola {
37 hi, hello
38 };
39
40 struct A {
AA41 A(int a, short b, Hola h) {}
funkA42 int funk(int a) { return a; }
43
func0A44 int func0(short, int c, int d) { return c; }
func1A45 int func1(short, int c, int d) { return c; }
func2A46 int func2(short, int c, int d) { return c; }
func3A47 int func3(short, int c, int d) { return c; }
48
49 int func0default(A *e, short, int c, int d, double f = 2) { return 0; }
50 int func1default(A *e, short, int c, int d, double f = 2) { return 0; }
51 int func2default(A *e, short, int c, int d, double f = 2) { return 0; }
52 int func3default(A *e, short, int c, int d, double f = 2) { return 0; }
53
54 static int func0static(A *e, short, int c, int d, double f = 2) { return 0; }
55 static int func1static(A *e, short, int c, int d, double f = 2) { return 0; }
56 static int func2static(A *e, short, int c, int d, double f = 2) { return 0; }
57 static int func3static(A *e, short, int c, int d, double f = 2) { return 0; }
58
59 int variable_a;
60 int variable_b;
61 int variable_c;
62 int variable_d;
63 };
64 }
65
66
67 // deleting typemaps and docs
68 %typemap(in) (int c, int d) ;
69 %typemap(doc) (int c, int d);
70
71 // docs for some parameters
72 %typemap(doc) int a "a: special comment for parameter a";
73 %typemap(doc) int b "b: another special comment for parameter b";
74
75 %feature("autodoc","0") C::C(int a, int b, Hola h); // names
76 %feature("autodoc","1") D::D(int a, int b, Hola h); // names + types
77 %feature("autodoc","2") E::E(int a, int b, Hola h); // extended
78 %feature("autodoc","3") F::F(int a, int b, Hola h); // extended + types
79 %feature("autodoc","0") C::~C(); // names
80 %feature("autodoc","1") D::~D(); // names + types
81 %feature("autodoc","2") E::~E(); // extended
82 %feature("autodoc","3") F::~F(); // extended + types
83
84 %inline {
85
86 struct B {
BB87 B(int a, int b, Hola h) {}
funkB88 int funk(int c, int d) { return c; }
89 };
90
91 struct C {
CC92 C(int a, int b, Hola h) {}
93 };
94 struct D {
DD95 D(int a, int b, Hola h) {}
96 };
97 struct E {
EE98 E(int a, int b, Hola h) {}
99 };
100 struct F {
FF101 F(int a, int b, Hola h) {}
102 };
103
funk(A * e,short,int c,int d)104 int funk(A *e, short, int c, int d) { return c; }
105 int funkdefaults(A *e, short, int c, int d, double f = 2) { return c; }
106 }
107
108 %include <typemaps.i>
109 %inline %{
func_input(int * INPUT)110 int func_input(int *INPUT) {
111 return 1;
112 }
func_output(int * OUTPUT)113 int func_output(int *OUTPUT) {
114 *OUTPUT = 2;
115 return 1;
116 }
func_inout(int * INOUT)117 int func_inout(int *INOUT) {
118 *INOUT += 1;
119 return 1;
120 }
121 %}
122
123 %callback("%(uppercase)s_CALLBACK") func_cb;
124
125 %inline {
func_cb(int c,int d)126 int func_cb(int c, int d) { return c; }
127 }
128
129 // Bug 3310528
130 %feature("autodoc","1") banana; // names + types
131 %inline %{
132 typedef struct tagS {
133 int a;
134 char b;
135 } S;
136
137 typedef int Integer;
138
banana(S * a,const struct tagS * b,int c,Integer d)139 void banana(S *a, const struct tagS *b, int c, Integer d) {}
140 %}
141
142 // Check docs for a template type
143 %inline %{
144 template<typename X> struct T {
inoutT145 T inout(T t) { return t; }
146 };
147 %}
148 %template(TInteger) T<int>;
149
150 %inline %{
151 #ifdef SWIGPYTHON_BUILTIN
is_python_builtin()152 bool is_python_builtin() { return true; }
153 #else
154 bool is_python_builtin() { return false; }
155 #endif
156 %}
157
158 // Autodoc language keywords
159 %feature(autodoc,1) process;
160 %feature(autodoc,1) process2;
161 %feature("compactdefaultargs") process;
162 %feature("compactdefaultargs") process2;
163 %inline %{
process(int from,int in,int var)164 int process(int from, int in, int var) { return from; }
165 int process2(int from = 0, int _in = 1, int var = 2) { return from; }
166 %}
167
168 %feature(autodoc,1) process3;
169 %feature(autodoc,1) process4;
170 %feature("kwargs") process3;
171 %feature("kwargs") process4;
172 %inline %{
process3(int from,int _in,int var)173 int process3(int from, int _in, int var) { return from; }
174 int process4(int from = 0, int _in = 1, int var = 2) { return from; }
175 %}
176
177 // Autodoc for methods with default arguments not directly representable in
178 // target language.
179 %feature(autodoc,0) process_complex_defval;
180 %feature("compactdefaultargs") process_complex_defval;
181 %inline %{
182 const int PROCESS_DEFAULT_VALUE = 17;
183 typedef long int some_type;
184 int process_complex_defval(int val = PROCESS_DEFAULT_VALUE, int factor = some_type(-1)) { return val*factor; }
185 %}
186
187 // Test for empty docstring, which should be ignored.
188 %feature("docstring") ""
189
190 %inline %{
191 struct a_structure{
192 char my_array[1];
193 };
194 %}
195