[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: [PyQt] sip: Problem with inheritance and function overloads
From:       Phil Thompson <phil () riverbankcomputing ! com>
Date:       2010-07-25 11:10:48
Message-ID: c0aff5739b1aa0213deea515002ed55e () localhost
[Download RAW message or body]

On Fri, 23 Jul 2010 10:53:37 +0200, Daniel Stöckel
<dstoeckel@bioinf.uni-sb.de> wrote:
> Hi,
> 
> I seem to have noticed a bug in sip concerning function overloads that
> occur 
> because of inheritance:
> 
> I have a C++ project in which I have classes like this (I used this
actual
> toy 
> example to reproduce the problem):
> 
>   class A
>   {
>       public:
>           void do_sth(DummyA&);
>   };
> 
>   class B : public A
>   {
>       public:
>           void do_sth(DummyB&);
>   };
> 
> The sip wrapper code is also straight forward:
> 
>   class A
>   {
>   %TypeHeaderCode
>       #include "bla.h"
>   %End
>       public:
>           void do_sth(DummyA&);
>   };
> 
>   class B : A 
>   {
>   %TypeHeaderCode
>       #include "bla.h"
>   %End
>       public:
>           void do_sth(DummyB&);
>   };
> 
> In C++ it is now possible to call do_sth on class B with both: DummyA
and 
> DummyB due to function overloading.

No you can't. You can only do that if both implementations of do_sth() are
in the same class. Otherwise there would be no reason for C++'s "using"
directive when applied to methods.

> In the generated sip wrapper however 
> calling do_sth on an object of type B with an object of type DummyA
causes
> the 
> following error:
> 	"TypeError: B.do_sth(): argument 1 has unexpected type 'DummyA'"
> Note that regular overloading, so if both do_sth() methods were defined
> and 
> wrapped in class B, works just fine. It seems to me as if sip does not 
> propagate information about function overloads down the inheritance
tree.
> 
> Am I doing something wrong or is this indeed a bug/limitation in sip?
> 
> Greetings,
> Daniel

Phil
_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic