PageRenderTime 42ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

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

#
Swig | 86 lines | 65 code | 21 blank | 0 comment | 0 complexity | 19413c38e7dad4ad2436f4cd5be97b5a MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. %module(directors="1",dirprot="1") director_nested
  2. #pragma SWIG nowarn=SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR
  3. %{
  4. #include <string>
  5. #include <iostream>
  6. %}
  7. %include "std_string.i"
  8. %feature("director") Bar;
  9. %feature("director") Foo<int>;
  10. %feature("director") FooBar<int>;
  11. %newobject *::create();
  12. %inline {
  13. template <class C>
  14. class Foo {
  15. public:
  16. virtual ~Foo() {}
  17. std::string advance()
  18. {
  19. return "Foo::advance;" + do_advance();
  20. }
  21. protected:
  22. virtual std::string do_advance() = 0;
  23. };
  24. }
  25. %template(Foo_int) Foo<int>;
  26. %inline {
  27. class Bar : public Foo<int>
  28. {
  29. public:
  30. std::string step()
  31. {
  32. return "Bar::step;" + advance();
  33. }
  34. protected:
  35. std::string do_advance()
  36. {
  37. return "Bar::do_advance;" + do_step();
  38. }
  39. #if defined(SWIGPYTHON) || defined(SWIGRUBY) || \
  40. defined(SWIGJAVA) || defined(SWIGOCAML) || defined(SWIGCSHARP)
  41. virtual std::string do_step() const = 0;
  42. #else
  43. virtual std::string do_step() const {return "";};
  44. #endif
  45. };
  46. template <class C>
  47. class FooBar : public Bar
  48. {
  49. public:
  50. virtual C get_value() const = 0;
  51. virtual const char * get_name()
  52. {
  53. return "FooBar::get_name";
  54. }
  55. const char *name()
  56. {
  57. return get_name();
  58. }
  59. static FooBar *get_self(FooBar *a)
  60. {
  61. return a;
  62. }
  63. };
  64. }
  65. %template(FooBar_int) FooBar<int>;