[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: SIP: Virtual pure method with std::function
From:       Julien Cabieces <julien.cabieces () oslandia ! com>
Date:       2021-04-12 6:56:05
Message-ID: 87h7kcdm9m.fsf () julien-laptop ! home
[Download RAW message or body]


Hi,

Thank you for your reponse, I'm gonna considering doing it an other way.

Regards,
Julien


> On 06/04/2021 13:24, Julien Cabieces wrote:
>> Hi,
>> 
>>> You need to provide the C++ signature in [] after the Python 
>>> signature.
>>> See the example in this section...
>> 
>> I change the signature in the sip file like this
>> 
>> virtual MyObject *doThings( const QString &filePath, const QUrl &url,
>> SIP_PYCALLABLE / AllowNone / ) = 0 [MyObject * ( const QString &, const
>> QUrl &, const ErrorCallback & )];
>> 
>> and define the ErrorCallback this way in my header
>> 
>> typedef std::function< void ( const QString & ) > ErrorCallback;
>> 
>> It fails later with this error
>> 
>> sip_corepart0.cpp:21379:193: error: unknown type name 'ErrorCallback'
>> 
>> my header file is included later (line 49811) in cpp file produced by
>> sip, so it's normal it doesn't know yet the ErrorCallback type.
>> 
>> If I get rid of the typedef definition and put the std::function
>> directly in the sip signature, sip fails with a syntax error. It looks
>> like it comes from the parenthesis around "const QString &".
>> 
>> Any idea?
>
> SIP doesn't implement a full C++ parser and there will be some 
> constructs that it can't handle, in this case the arguments to the 
> std::function template. (Maybe putting a dummy name after the void would 
> work.)
>
> A separate issue might be that SIP is being too aggressive when parsing 
> the C++ signature and maybe it could/should not try to resolve 
> ErrorCallback and leave it to the C++ compiler to determine if it has a 
> proper definition.
>
> For the moment I can't suggest anything other than not using 
> std::function.
>
> Phil

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic