[PyQt] Literals as template parameters

Shaheed Haque srhaque at theiet.org
Sat Jul 8 16:58:56 BST 2017


Hi Phil,

On 23 June 2017 at 08:55, Phil Thompson <phil at riverbankcomputing.com> wrote:
> On 22 Jun 2017, at 5:59 pm, Shaheed Haque <srhaque at theiet.org> wrote:
>>
>> Hi Phil,
>>
>> SIP 4.19.3.dev1706161918 does not seem to like literals (or at least
>> literal numbers) as template paramters. The "16" here:
>>
>>        static int parseParenthesizedList(const QByteArray &data,
>> QVarLengthArray<QByteArray, 16> &result, int start = 0)
>>            [int (const QByteArray &data, QVarLengthArray<QByteArray,
>> 16> &result, int start = 0)];
>>
>> results in a syntax error. Temporarily changing the "16" to "a16"
>> suppresses the error. (i've not been able to think of a way to use
>> this as a workaround though).
>
> The workaround is to define a C++ typedef in the %ModuleHeaderCode or %TypeHeaderCode and use that typedef in the declaration (and the mapped type definition that will be needed).

I tried replacing this SIP code with:

        WTF::Vector<unsigned char, 0> &codeBlock();

with:

        typedef WTF::Vector<unsigned char, 0> foo;
        foo &codeBlock();

but the result is still a syntax error. (I also added the
corresponding C++ typedef in %TypeHeaderCode to check if that made any
difference). Did I perhaps misinterpret the suggested workaround?

Thanks, Shaheed

P.S. I did look at parser.y, and AFAICS anything template-related
seemed to involve cpptypelist, and that seems to disallow a literal.


>
> Phil


More information about the PyQt mailing list