Upstream version 1.3.40
[profile/ivi/swig.git] / Examples / test-suite / minherit.i
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(ruby_minherit="1") minherit
8
9 #if defined(SWIGPYTHON) || defined(SWIGRUBY) || defined(SWIGOCAML) || defined(SWIGOCTAVE) || defined(SWIGPERL)
10
11 %inline %{
12
13 class Foo {
14 private:
15     int x;
16 public:
17     Foo() { x = 1; }
18     virtual ~Foo() {}
19     virtual int  xget() {  return x; };
20 };
21 typedef Foo *FooPtr;
22
23 FooPtr toFooPtr(Foo *f) { return f; }
24
25 class Bar {
26 private:
27     int y;
28 public:
29     Bar() { y = 2; }
30     virtual ~Bar() {}
31     virtual int yget() { return y; }
32 };
33
34 typedef Bar *BarPtr;
35 BarPtr toBarPtr(Bar *f) { return f; }
36
37 class FooBar : public Foo, public Bar {
38 private:
39     int z;
40 public:
41     FooBar() { z = 3; }
42     virtual int zget() { return z; }
43 };
44
45 typedef FooBar *FooBarPtr;
46 FooBarPtr toFooBarPtr(FooBar *f) { return f; }
47
48 class Spam: public FooBar {
49 private:
50     int w;
51 public:
52     Spam() { w = 4; }
53     virtual int wget() { return w; }
54 };
55
56 typedef Spam *SpamPtr;
57 SpamPtr toSpamPtr(Spam *f) { return f; }
58
59 int xget(FooPtr f) {
60    return f->xget();
61 }
62
63 int yget(BarPtr f) {
64    return f->yget();
65 }
66
67 int zget(FooBarPtr f) {
68    return f->zget();
69 }
70
71 int wget(SpamPtr f) {
72    return f->wget();
73 }
74 %}
75
76 #endif
77