/trunk/Examples/test-suite/template_inherit_abstract.i
Swig | 68 lines | 55 code | 13 blank | 0 comment | 0 complexity | 96b12a83d4bd90ddfc140eb9bda6cc68 MD5 | raw file
1%module(ruby_minherit="1") template_inherit_abstract 2 3%warnfilter(SWIGWARN_RUBY_WRONG_NAME) oss::test; /* Ruby, wrong class name */ 4 5%warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE, 6 SWIGWARN_CSHARP_MULTIPLE_INHERITANCE, 7 SWIGWARN_D_MULTIPLE_INHERITANCE, 8 SWIGWARN_PHP_MULTIPLE_INHERITANCE) oss::Module; /* C#, D, Java, PHP multiple inheritance */ 9 10%inline %{ 11 12 namespace oss 13 { 14 template <class C> 15 struct Wrap 16 { 17 }; 18 19 struct ModuleBase 20 { 21 virtual ~ModuleBase() {} 22 virtual int get() = 0; 23 }; 24 25 template <class C> 26 struct Module : C, ModuleBase 27 { 28 virtual ~Module() {} 29 30 protected: 31 Module() {} 32 }; 33 34 template <class C> 35 struct HModule : Module<Wrap<C> > 36 { 37 // virtual int get(); // declaration here works 38 39 protected: 40 HModule() {} 41 }; 42 } 43 44 struct B 45 { 46 }; 47 48%} 49 50namespace oss 51{ 52 %template(Wrap_B) Wrap<B>; 53 %template(Module_B) Module<Wrap<B> >; 54 %template(HModule_B) HModule<B>; 55} 56 57%inline %{ 58 namespace oss 59 { 60#if defined(SWIG) && (defined(SWIGCSHARP) || defined(SWIGD)) 61%ignore HModule<B>::get(); // Work around for lack of multiple inheritance support - base ModuleBase is ignored. 62#endif 63 struct test : HModule<B> 64 { 65 virtual int get() {return 0;} // declaration here breaks swig 66 }; 67 } 68%}