/tags/ttn-post-libtool-1-4-3-upgrade/SWIG/Examples/test-suite/minherit.i
Swig | 80 lines | 58 code | 22 blank | 0 comment | 0 complexity | f5d4a4542ec72d8d76b14835d739fbaf MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
1// This module tests multiple inheritance, typedef handling, and some
2// truly horrible parts of the SWIG type system. This is only tested
3// for Python since not all language modules support multiple-inheritance.
4// However, if it works for Python, things should be working for other
5// modules.
6
7%module minherit
8
9#ifdef SWIGPYTHON
10
11%inline %{
12
13class Foo {
14private:
15 int x;
16public:
17 Foo() { x = 1; }
18 virtual int xget() { return x; };
19};
20typedef Foo *FooPtr;
21
22FooPtr toFooPtr(Foo *f) { return f; }
23
24class Bar {
25private:
26 int y;
27public:
28 Bar() { y = 2; }
29 virtual int yget() { return y; }
30};
31
32typedef Bar *BarPtr;
33BarPtr toBarPtr(Bar *f) { return f; }
34
35class FooBar : public Foo, public Bar {
36private:
37 int z;
38public:
39 FooBar() { z = 3; }
40 virtual int zget() { return z; }
41};
42
43typedef FooBar *FooBarPtr;
44FooBarPtr toFooBarPtr(FooBar *f) { return f; }
45
46class Spam: public FooBar {
47private:
48 int w;
49public:
50 Spam() { w = 4; }
51 virtual int wget() { return w; }
52};
53
54typedef Spam *SpamPtr;
55SpamPtr toSpamPtr(Spam *f) { return f; }
56
57int xget(FooPtr f) {
58 return f->xget();
59}
60
61int yget(BarPtr f) {
62 return f->yget();
63}
64
65int zget(FooBarPtr f) {
66 return f->zget();
67}
68
69int wget(SpamPtr f) {
70 return f->wget();
71}
72%}
73
74#endif
75
76
77
78
79
80