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

GOO Creations goocreations at gmail.com
Thu Jul 8 13:01:21 BST 2010


With getFileHash(QString()) the first overload is being called.
If I understand you correct, SIP doesn't allow this?

Christoph



On 2010/07/08 12:16 PM, 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.
> According to the standard, with...
>
> getFileHash(QString());
>
> ...which overload gets called?
>
> Phil
>
>    



More information about the PyQt mailing list