PageRenderTime 44ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/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. %module minherit
  7. #ifdef SWIGPYTHON
  8. %inline %{
  9. class Foo {
  10. private:
  11. int x;
  12. public:
  13. Foo() { x = 1; }
  14. virtual int xget() { return x; };
  15. };
  16. typedef Foo *FooPtr;
  17. FooPtr toFooPtr(Foo *f) { return f; }
  18. class Bar {
  19. private:
  20. int y;
  21. public:
  22. Bar() { y = 2; }
  23. virtual int yget() { return y; }
  24. };
  25. typedef Bar *BarPtr;
  26. BarPtr toBarPtr(Bar *f) { return f; }
  27. class FooBar : public Foo, public Bar {
  28. private:
  29. int z;
  30. public:
  31. FooBar() { z = 3; }
  32. virtual int zget() { return z; }
  33. };
  34. typedef FooBar *FooBarPtr;
  35. FooBarPtr toFooBarPtr(FooBar *f) { return f; }
  36. class Spam: public FooBar {
  37. private:
  38. int w;
  39. public:
  40. Spam() { w = 4; }
  41. virtual int wget() { return w; }
  42. };
  43. typedef Spam *SpamPtr;
  44. SpamPtr toSpamPtr(Spam *f) { return f; }
  45. int xget(FooPtr f) {
  46. return f->xget();
  47. }
  48. int yget(BarPtr f) {
  49. return f->yget();
  50. }
  51. int zget(FooBarPtr f) {
  52. return f->zget();
  53. }
  54. int wget(SpamPtr f) {
  55. return f->wget();
  56. }
  57. %}
  58. #endif