[PyQt] SIP Bug: virtual function wrapped twice due to deep inheritance from base class and ABC

Phil Thompson phil at riverbankcomputing.com
Thu Jul 1 15:28:28 BST 2010


On Sat, 19 Jun 2010 10:27:55 -0700 (PDT), Demetrius Cassidy
<dcassidy36 at mass.rr.com> wrote:
> Basically I have a Listen() function in a derived class, that is also in
> the 
> base and ABC. For some reason sip ends up wrapping the same function
twice
> (it 
> has a body in the ABC), even though it's a virtual function in all of the

> derived classes. If I comment out this function in the ABC, everything
> works 
> fine, but otherwise I get a C2535 compiler error with Visual C++. 
>  
> Here is what sip comes up with: 
>  
> class sipPUDPSocket : public PUDPSocket 
> { 
>  
>     /* 
>      * There is a protected method for every virtual method visible from 
>      * this class. 
>      */ 
>  protected: 
>     PBoolean Listen(unsigned,WORD,PIPSocket::Reusability); 
>     /*more wrapped functions*/ 
>     PBoolean Listen(unsigned,WORD,PIPSocket::Reusability); // <--
duplicate
> function 
> }; 
>  
> C++ nmake errors: 
>  
> sippyptlibPTCPSocket.cpp 
> .\sippyptlibPTCPSocket.cpp(121) : error C2535: 'PBoolean 
> sipPTCPSocket::Listen(unsigned int,WORD,PSocket::Reusability)' 
> : member function already defined or declared 
>         .\sippyptlibPTCPSocket.cpp(102) : see declaration of 
> 'sipPTCPSocket::Listen' 
>  
>  
> .\sippyptlibPTCPSocket.cpp(506) : error C2084: function 'PBoolean
> sipPTCPSocket: 
> :Listen(unsigned int,WORD,PSocket::Reusability)' already has a body 
>         .\sippyptlibPTCPSocket.cpp(102) : see previous definition of
> 'Listen' 
>  
>  
> Basic code structure based on what I am wrapping - note that I only
> included
> the 
> offending function here, as it would be too much code to include
> everything. 

But you at least need to include the definition of PUDPSocket.

> typedef bool PBoolean; 
>  
> class PTCPSocket : PIPDataGramSocket 
> { 
>  public: 
>   virtual PBoolean Listen(unsigned int, WORD, PSocket::Reusability); 
> } 
>  
> class PIPDataGramSocket : PIPSocket 
> { 
>   protected: 
>     PIPDataGramSocket(); 
> } 
>  
> class PIPSocket : PSocket 
> { 
>  public: 
>   virtual PBoolean Listen(unsigned int, WORD, PSocket::Reusability); 
> } 
>  
> class PSocket /Abstract/ 
> { 
>   public: 
>     /// Flags to reuse of port numbers in Listen() function. 
>     enum Reusability { 
>       CanReuseAddress, 
>       AddressIsExclusive 
>     }; 
>  
>   virtual PBoolean Listen(unsigned int, WORD, PSocket::Reusability); // 
> commenting this function out fixes this problem 
>  
>  protected: 
>     /*This function calls os_socket() with the correct parameters for the

>        socket protocol type. 
>      */ 
>     virtual PBoolean OpenSocket() = 0; 
>  
> }; 

Phil


More information about the PyQt mailing list