[PyQt] /In,Out/ annotation for "const char *&"

Shaheed Haque srhaque at theiet.org
Mon May 8 18:59:51 BST 2017


Hi,

I have the following method in C++:

bool parseAtom(const char *&scursor, const char* send, QString &result,
bool allow8Bit = false);

The first argument,scursor, is both input to and output from the method.
(The third is also output, but is not relevant to this note). When I add
the annotations like this:

bool parseAtom(const char *&scursor /In,Out/, const char* send, QString
&result, bool allow8Bit = false);

The generated docstring looks plausible:

parseAtom(str, str, str, bool = False) -> Tuple[bool, str]

but the generated code does not compile because it is passed using "&" when
I think it should not be:

const char* a0;
...
if (sipParseArgs(&sipParseErr, sipArgs, "csJ1|b", &a0, &a1,
sipType_QString,&a2, &a2State, &a3))
{
...
sipRes = ::KMime::HeaderParsing::parseAtom(&a0,a1,*a2,a3);

The compilation error is:

========
tmp2/tmp/PyKF5/KMime/KMime/sipKMimeKMimeHeaderParsing.cpp: In function
‘PyObject* meth_KMime_HeaderParsing_parseAtom(PyObject*, PyObject*)’:
tmp2/tmp/PyKF5/KMime/KMime/sipKMimeKMimeHeaderParsing.cpp:1385:70: error:
no matching function for call to ‘parseAtom(const char**, const char*&,
QString&, bool&)’
In file included from /usr/include/KF5/KMime/kmime/kmime_headers.h:44:0,
from /usr/include/KF5/KMime/kmime/kmime_util.h:27,
from /usr/include/KF5/KMime/kmime/kmime_content.h:53,
from /usr/include/KF5/KMime/KMime/Content:1,
from tmp/KMime/KMime/Content.sip:27,
from unifiedKMime.cpp:1:
/usr/include/KF5/KMime/kmime/kmime_header_parsing.h:91:19: note: candidate:
bool KMime::HeaderParsing::parseAtom(const char*&, const char*, QString&,
bool)
KMIME_EXPORT bool parseAtom(const char *&scursor, const char *const send,
^~~~~~~~~
/usr/include/KF5/KMime/kmime/kmime_header_parsing.h:91:19: note: no known
conversion for argument 1 from ‘const char**’ to ‘const char*&’
========

Notice also the encoding passed to sipParseArgs is "c" (the output without
any annotations is below at [1] for reference, and it emits the encoding as
"s").

Am I using the annotations incorrectly, or is this a bug in SIP?

Thanks, Shaheed

[1] Without any of the needed annotations, the SIP generated docstring
looks as expected:

parseAtom(str, str, str, bool = False) -> bool

and the generated code for the first argument:

const char* a0;
...
if (sipParseArgs(&sipParseErr, sipArgs, "ssJ1|b", &a0, &a1,
sipType_QString,&a2, &a2State, &a3))
{
sipRes = ::KMime::HeaderParsing::parseAtom(a0,a1,*a2,a3);

Also, AFAICS, adding the needed /Out/ to argument 3 emits plausible looking
code.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20170508/1658ffcc/attachment.html>


More information about the PyQt mailing list