/trunk/Examples/test-suite/template_inherit_abstract.i
Swig | 68 lines | 55 code | 13 blank | 0 comment | 0 complexity | 96b12a83d4bd90ddfc140eb9bda6cc68 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
- %module(ruby_minherit="1") template_inherit_abstract
- %warnfilter(SWIGWARN_RUBY_WRONG_NAME) oss::test; /* Ruby, wrong class name */
- %warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
- SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
- SWIGWARN_D_MULTIPLE_INHERITANCE,
- SWIGWARN_PHP_MULTIPLE_INHERITANCE) oss::Module; /* C#, D, Java, PHP multiple inheritance */
- %inline %{
-
- namespace oss
- {
- template <class C>
- struct Wrap
- {
- };
-
- struct ModuleBase
- {
- virtual ~ModuleBase() {}
- virtual int get() = 0;
- };
-
- template <class C>
- struct Module : C, ModuleBase
- {
- virtual ~Module() {}
- protected:
- Module() {}
- };
-
- template <class C>
- struct HModule : Module<Wrap<C> >
- {
- // virtual int get(); // declaration here works
-
- protected:
- HModule() {}
- };
- }
-
- struct B
- {
- };
-
- %}
-
- namespace oss
- {
- %template(Wrap_B) Wrap<B>;
- %template(Module_B) Module<Wrap<B> >;
- %template(HModule_B) HModule<B>;
- }
-
- %inline %{
- namespace oss
- {
- #if defined(SWIG) && (defined(SWIGCSHARP) || defined(SWIGD))
- %ignore HModule<B>::get(); // Work around for lack of multiple inheritance support - base ModuleBase is ignored.
- #endif
- struct test : HModule<B>
- {
- virtual int get() {return 0;} // declaration here breaks swig
- };
- }
- %}