summaryrefslogtreecommitdiff
path: root/Examples/test-suite/minherit.i
blob: 82d1f3cce0d72575dc4b052f455cebea1cd6ce63 (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
// This module tests multiple inheritance, typedef handling, and some
// truly horrible parts of the SWIG type system.   This is only tested
// for Python since not all language modules support multiple-inheritance.
// However, if it works for Python, things should be working for other
// modules.

%module(ruby_minherit="1") minherit

#if defined(SWIGPYTHON) || defined(SWIGRUBY) || defined(SWIGOCAML) || defined(SWIGOCTAVE) || defined(SWIGPERL) || defined(SWIGGO)

%inline %{

class Foo {
private:
    int x;
public:
    Foo() { x = 1; }
    virtual ~Foo() {}
    virtual int  xget() {  return x; };
};
typedef Foo *FooPtr;

FooPtr toFooPtr(Foo *f) { return f; }

class Bar {
private:
    int y;
public:
    Bar() { y = 2; }
    virtual ~Bar() {}
    virtual int yget() { return y; }
};

typedef Bar *BarPtr;
BarPtr toBarPtr(Bar *f) { return f; }

class FooBar : public Foo, public Bar {
private:
    int z;
public:
    FooBar() { z = 3; }
    virtual int zget() { return z; }
};

typedef FooBar *FooBarPtr;
FooBarPtr toFooBarPtr(FooBar *f) { return f; }

class Spam: public FooBar {
private:
    int w;
public:
    Spam() { w = 4; }
    virtual int wget() { return w; }
};

typedef Spam *SpamPtr;
SpamPtr toSpamPtr(Spam *f) { return f; }

int xget(FooPtr f) {
   return f->xget();
}

int yget(BarPtr f) {
   return f->yget();
}

int zget(FooBarPtr f) {
   return f->zget();
}

int wget(SpamPtr f) {
   return f->wget();
}
%}

#endif


// Was causing runtime error in Ruby
%include <std_vector.i>
%template(IntVector) std::vector<int>;