summaryrefslogtreecommitdiff
path: root/Examples/test-suite/director_simple.i
blob: 0883cae128dcc3f1556c716d56cef85e2e8b196e (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
%module(directors="1") director_simple

%feature("director") IntBase;
%feature("director") BoolBase;

%inline %{
class IntBase {
 public:
  virtual ~IntBase() {}
  IntBase(int i = 3) { (void)i; }
  virtual int apply(int x) const { return x * 2; }
};

class IntDerived : public IntBase {
 public:
  virtual int apply(int x) const { return x * 3; }
};

int apply(const IntBase& b, int x)
{
  return b.apply(x);
}

class BoolBase {
 public:
  virtual ~BoolBase() {}
  BoolBase() {}
  virtual bool apply(bool a, bool b) const = 0;
};

class BoolDerived : public BoolBase {
 public:
  virtual bool apply(bool a, bool b) const { return a != b; }
};

bool apply(const BoolBase& base, bool a, bool b)
{
  return base.apply(a, b);
}

%}