PageRenderTime 4ms CodeModel.GetById 2ms app.highlight 0ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/Examples/test-suite/director_alternating.i

#
Swig | 36 lines | 30 code | 6 blank | 0 comment | 0 complexity | 506d269c0ee2a1b77d517398d80c8a19 MD5 | raw file
 1// Checks if calls to a method being defined in the base class, not
 2// overridden in the subclass, but again overridden in a class derived from
 3// the first subclass are dispatched correctly.
 4%module(directors="1") director_alternating;
 5
 6%feature("director") Foo;
 7
 8%inline %{
 9struct Foo {
10  virtual ~Foo() {}
11  virtual int id() {
12    return 0;
13  }
14};
15
16struct Bar : Foo {};
17
18struct Baz : Bar {
19  virtual int id() {
20    return 2;
21  }
22};
23
24// Note that even though the return value is of type Bar*, it really points to
25// an instance of Baz (in which id() has been overridden).
26Bar *getBar() {
27  static Baz baz;
28  return &baz;
29}
30
31// idFromGetBar() obviously is equivalent to getBar()->id() in C++ รข€“ this
32// should be true from the target language as well.
33int idFromGetBar() {
34  return getBar()->id();
35}
36%}