[PyQt] Rules for how SIP handles arguments?

Shaheed Haque srhaque at theiet.org
Sun Jun 4 00:34:46 BST 2017


This turned out to be due to the type of the argument not being known.
More precisely, the type in question was QFlags<something> where the
"something" was not known.

Unfortunately, there was no useful error message until I temporarily
hacked the argument passing, at which point the C++ compiler whined...

On 27 May 2017 at 16:20, Shaheed Haque <srhaque at theiet.org> wrote:
> Hi,
>
> I'm looking into some corner cases in my test suite, and came across
> some differences in how SIP handles similar-looking QFlags<xyz>
> arguments in these two cases:
>
> ========
>         virtual KIO::RenameDialog_Result askSkip(KJob*job,
> QFlags<KIO::SkipDialog_Option>options, const QString &error_text) = 0
>             [KIO::RenameDialog_Result (KJob* job,
> QFlags<KIO::SkipDialog_Option> options, const QString &error_text)];
> ========
>
> versus:
>
> ========
>        virtual void copy(const QUrl &src, const QUrl &dest, int
> permissions, QFlags<KIO::JobFlag>flags)
>             [void (const QUrl &src, const QUrl &dest, int permissions,
> QFlags<KIO::JobFlag> flags)];
> ========
>
> In the askSkip case, the generated code has a1 as a pointer, and
> initialises it using sipParseArgs like this:
>
> ========
>         ::KJob* a0;
>          ::KIO::SkipDialog_Options* a1;
>         int a1State = 0;
>         const  ::QString* a2;
>         int a2State = 0;
>          ::KIO::JobUiDelegateExtension *sipCpp;
>
>         if (sipParseArgs(&sipParseErr, sipArgs, "BJ8J1J1", &sipSelf,
> sipType_KIO_JobUiDelegateExtension, &sipCpp, sipType_KJob, &a0,
> sipType_KIO_SkipDialog_Options, &a1, &a1State, sipType_QString,&a2,
> &a2State))
> =========
>
> whereas in the copy case, a2 is NOT a pointer, and is not initialised
> by sipParseArgs:
>
> =========
>         const  ::QString* a0;
>         int a0State = 0;
>         const  ::QUrl* a1;
>         QFlags<KIO::JobFlag> a2;
>          ::KIO::ForwardingSlaveBase *sipCpp;
>
>         if (sipParseArgs(&sipParseErr, sipArgs, "BJ1J9", &sipSelf,
> sipType_KIO_ForwardingSlaveBase, &sipCpp, sipType_QString,&a0,
> &a0State, sipType_QUrl, &a1))
>
> =========
>
> How does SIP decide whether to use a pointer or not? I *think* that
> because a2 is not initialised, SIP somehow thinks that a2 is an output
> variable...either way, it would be good to know what rules SIP uses,
> so the generated code can do the right thing.
>
> Thanks, Shaheed


More information about the PyQt mailing list