[PyQt] SIP: overloaded functions with the same Python signature

Andreas Pakulat apaku at gmx.de
Thu Jul 8 11:54:10 BST 2010


On 08.07.10 11:16:34, Phil Thompson wrote:
> On Mon, 05 Jul 2010 23:36:57 +0200, GOO Creations <goocreations at gmail.com>
> wrote:
> > Hello
> > 
> > This may sound like a really stupid question, but I can't find proper 
> > documentation/examples online:
> > 
> > I'm using SIP for my C++ - Python bindings. My C++ class has 2 functions 
> > with the same name.
> > 
> > ----------------------------------------------------------
> > The C++ class:
> > 
> > class MyHasher
> > {
> > public:
> > 
> >      enum HashAlgorithm
> >      {
> >          Md4,
> >          Md5,
> >          Sha1
> >      };
> > 
> >      MyHasher();
> >      QString getFileHash(QString data, HashAlgorithm hash = Md5);
> >      QString getFileHash(QString data, HashAlgorithm hash = Md5, int 
> > numberOfBytes = 2048);
> > };
> > ----------------------------------------------------------
> > 
> > The sip file:
> > 
> > class MyHasher
> > {
> > 
> > %TypeHeaderCode
> > #include <myhasher.h>
> > %End
> > 
> > public:
> > 
> >      enum HashAlgorithm
> >      {
> >          Md4,
> >          Md5,
> >          Sha1
> >      };
> > 
> >      MyHasher();
> >      QString getFileHash(QString data, HashAlgorithm hash = Md5);
> >      QString getFileHash(QString data, HashAlgorithm hash = Md5, int 
> > numberOfBytes = 2048);
> > };
> > ----------------------------------------------------------
> > 
> > 
> > 
> > When I compile it, I'm getting the error:
> > sip: MyHasher::getFileHash() has overloaded functions with the same 
> > Python signature
> > 
> > When I remove one of the getFileHash functions, everything is working 
> > fine, but the problem seems to be with 2 functions with the same name at 
> > the same time.
> > 
> > How can I correct this in SIP?
> 
> I'm not a C++ expert, but I'm surprised that it allows those overloads.

It doesn't. At least not if one actually calls the function with less than
3 arguments.

Andreas

-- 
Today is what happened to yesterday.


More information about the PyQt mailing list