From: William S F. <ws...@fu...> - 2006-02-21 22:34:17
|
William S Fulton wrote: > Gabe Plank wrote: >> Hello- >> >> I have two base classes that contain the same virtual method. My >> wrapper is complaining about multiple inheritance when I compile. >> >> As I understand, one can use %csmethodmodifiers to work around this by >> renaming and/or re-scoping the method on one of the (less important) >> base objects. Is this the correct tack in general, to change the >> interface? Is there any sample code that addresses this issue? >> > > Can't think of any examples, but try searching through the > Examples/test-suite directory. Otherwise here is one which makes the > second derived class' method2() available to the derived class. > > %inline %{ > struct Base1 { > virtual ~Base1() {} > virtual void method1() {} > }; > struct Base2 { > virtual ~Base2() {} > virtual void method2() {} > }; > struct Derived : public Base1, public Base2 {}; > %} > > %csmethodmodifiers Derived::method2() "public virtual"; > %extend Derived { > void method2() { return self->method2(); } > }; > I was just thinking about this enquiry and improving matters for the target languages that only support single inheritance. I was hoping that the following %extend would work instead of the above %extend: %csmethodmodifiers Derived::method2() "public virtual"; %extend Derived { using Base2::method2; }; But only the following is generated for the %extend (and the %csmethodmodifiers feature is ignored): SWIGINTERN void Derived_method2(Derived *self){} If a 'using' is declared in %extend it would be nice if the following was automatically generated: SWIGINTERN void Derived_method2(Derived *self){ return self->Base2::method2(); } Then as a further step we could create a feature that would then add in %extend 'using' methods for for all the methods in all the base classes that would have been ignored. Any thoughts? William |