[PyKDE] function overload with different type using SIP

Phil Thompson phil at riverbankcomputing.co.uk
Fri Nov 18 18:10:10 GMT 2005


On Friday 18 November 2005 5:56 pm, Zilin Du wrote:
> Hi, I got some problem for using overload functions using SIP (4.3.2),
> here is my example:
>
> class A {
> public:
>   A(long)
>   A(unsigned long)
>   A(double)
>   int cmp(long)
>   int cmp(unsigned long)
>   int cmp(double)
> };
>
> when I run sip, sip complains:
>
> A constructor with the same Python signature has already been defined
> A function with the same Python signature has already been defined
>
> if I remove:
>   A(double)
>   int cmp(double)
> then no error.
>
> so I don't know how we can define two overloaded function which can
> take long or double. Can anyone can share me his experience using sip?

It's warning you that Python will not be able distinguish between all the 
types because it does automatic type conversion. Use the /Constrained/ 
annotation on the double variants and make sure they appear first, eg.

    int cmp(double /Constrained/);
    int cmp(unsigned long);
    int cmp(long);

Phil




More information about the PyQt mailing list