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