[PyQt] How does sipParseArgs skip arguments?

Shaheed Haque srhaque at theiet.org
Sun Apr 16 12:55:55 BST 2017


When using %MethodCode, the SIP-generated part of the output generally
includes a call to sipParseArgs. Now, the documentation for
%MethodCode explains the use of sipArgs as a tuple, so it is clear
that handwritten code for argument N should extract the N'th entry in
sipArgs and proceed as required.

What I'd like to understand is how sipParseArgs knows to skip an
argument which is to be handled manually? For example (using SIP 4.18)
and these two similar functions:

    KEmoticonsTheme newTheme(const QString &name, KService &service,
bool dummy);
    KEmoticonsTheme newTheme2(const QString &name, const
QExplicitlySharedDataPointer<KService> &service, bool dummy)
    [KEmoticonsTheme(const QString &name, const
QExplicitlySharedDataPointer<KService> &service, bool dummy)];
%MethodCode
// TBD
%End

The first function gets its arguments like this:

=====================
       const QString* a0;
        int a0State = 0;
        KService* a1;
        bool a2;
        KEmoticons *sipCpp;

        if (sipParseArgs(&sipParseErr, sipArgs, "BJ1J9b", &sipSelf,
sipType_KEmoticons, &sipCpp, sipType_QString,&a0, &a0State,
sipType_KService, &a1, &a2))
=====================

whereas the second version skips a1 like this:

=====================
        const QString* a0;
        int a0State = 0;
        QExplicitlySharedDataPointer<KService> a1;
        bool a2;
        KEmoticons *sipCpp;

        if (sipParseArgs(&sipParseErr, sipArgs, "BJ1b", &sipSelf,
sipType_KEmoticons, &sipCpp, sipType_QString,&a0, &a0State, &a2))
=====================

I need to generate the code to extract a1 from sipArgs, but in
general, what are the rules that govern whether sipParseArgs will or
will not extract arguments? And in the second case, how does it know
to extract a0 and then a2, but not a1?

Thanks, Shaheed


More information about the PyQt mailing list