import source from 1.3.40
[external/swig.git] / Examples / test-suite / overload_extend.i
1 %module overload_extend
2
3 #ifndef __cplusplus
4 %{
5 #include <stdlib.h>
6 %}
7
8 %typemap(default) double y "$1=1000;";
9 #endif
10
11 #ifdef SWIGLUA  // lua only has one numeric type, so some overloads shadow each other creating warnings
12 %warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) test;
13 #endif
14
15 %warnfilter(SWIGWARN_PARSE_REDEFINED) Foo::test; 
16
17
18
19 %extend Foo {
20     int test() { return 0; }
21     int test(int x) { x = 0; return 1; }
22     int test(char *s) { s = 0; return 2; }
23 #ifdef __cplusplus
24     double test(double x, double y = 1000) { return x + y; }
25 #else
26     double test(double x, double y) { return x + y; }
27 #endif
28 };
29
30
31 %inline %{
32 struct Foo {
33   int variable;
34 #ifdef __cplusplus
35     int test() { return -1; }
36 #endif
37 };
38 %}
39
40
41 %extend Bar {
42 #ifdef __cplusplus
43   Bar() {
44     return new Bar();
45   }
46   ~Bar() {
47     delete $self;
48   }
49 #else
50   Bar() {
51     return (Bar *) malloc(sizeof(Bar));
52   }
53   ~Bar() {
54     free($self);
55   }
56 #endif
57 }
58
59 %inline %{
60 typedef struct {
61   int variable;
62 } Bar;
63 %}
64        
65