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

Phil Thompson phil at riverbankcomputing.com
Fri Jul 2 08:52:57 BST 2010


On Thu, 1 Jul 2010 17:53:23 -0700 (PDT), Demetrius Cassidy
<dcassidy36 at mass.rr.com> wrote:
> Phil,
> 
> It's not code specific to that class. It's due to the deep inheritance
> tree.
> You should be able to run my test code and get the same results.
> 
> Basically to sum it up:
> 
> PTCPSocket  <- PIPDataGramSocket <- PIPSocket <- PSocket (ABC)
> 
> PTCPSocket, PIPSocket and PSocket all define a virtual function called
> 'Listen'.
> Commenting 'Listen' out from PSocket, and SIP does not include the
function
> twice.
> Listen is NOT a pure virtual function in the ABC, it has a body.
> Listen is fully defined in PTCPSocket, and the other classes except
> PIPDataGramSocket.

The error appears in PUDPSocket but you don't even mention that class.
Where does it fit in the inheritance tree?

Phil


> Phil Thompson-5 wrote:
>> 
>> 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
>> _______________________________________________
>> PyQt mailing list    PyQt at riverbankcomputing.com
>> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>> 
>>


More information about the PyQt mailing list