Sorry Phil - corrected inheritance tree: PUDPSocket <- PIPDataGramSocket <- PIPSocket <- PSocket (ABC) PTCPSocket <- PIPSocket <- PSocket (ABC)
PUDPSocket does not have a 'Listen' function in it, instead it just inherits it from PIPSocket, who overrides PSocket. PTCPSocket DOES include a 'Listen' function in it, and overrides it from PIPSocket and PSocket. I've attached the corresponding sip files and the generated .cpp files from sip. Below I've also included a snippet of the generated code for both classes. The weird thing is that SIP wraps the PIPSocket Listen function, along with the one from PSocket. http://old.nabble.com/file/p29056623/ptlib.rar ptlib.rar class sipPUDPSocket : public PUDPSocket { public: .... /* * There is a protected method for every virtual method visible from * this class. */ protected: ... PBoolean Listen(unsigned,WORD,PIPSocket::Reusability); PBoolean Listen(const PIPSocket::Address&,unsigned,WORD,PIPSocket::Reusability); ... PBoolean Listen(unsigned,WORD,PSocket::Reusability); } class sipPTCPSocket : public PTCPSocket { public: ... /* * There is a protected method for every virtual method visible from * this class. */ protected: PBoolean Listen(unsigned,WORD,PIPSocket::Reusability); PBoolean Listen(const PIPSocket::Address&,unsigned,WORD,PIPSocket::Reusability); ... PBoolean Listen(unsigned,WORD,PSocket::Reusability); }; Both classes share the same exact inheritance bug when wrapped: Phil Thompson-5 wrote: > > On Thu, 1 Jul 2010 17:53:23 -0700 (PDT), Demetrius Cassidy > <dcassid...@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 >>> <dcassid...@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@riverbankcomputing.com >>> http://www.riverbankcomputing.com/mailman/listinfo/pyqt >>> >>> > _______________________________________________ > PyQt mailing list PyQt@riverbankcomputing.com > http://www.riverbankcomputing.com/mailman/listinfo/pyqt > > -- View this message in context: http://old.nabble.com/SIP-Bug%3A-virtual-function-wrapped-twice-due-to-deep-inheritance-from-base-class-and-ABC-tp28936011p29056623.html Sent from the PyQt mailing list archive at Nabble.com. _______________________________________________ PyQt mailing list PyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt