[prev in list] [next in list] [prev in thread] [next in thread]
List: pykde
Subject: [PyQt] /In,Out/ annotation for "const char *&"
From: Shaheed Haque <srhaque () theiet ! org>
Date: 2017-05-08 17:59:51
Message-ID: CAHAc2jdY3c55YjXjnTtC+5oChro97uL8sNm6W_xpdXKq6w0cZg () mail ! gmail ! com
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
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.
[Attachment #5 (text/html)]
<div dir="auto">Hi,<br><br>I have the following method in C++:<br><br> bool \
parseAtom(const char *&scursor, const char* send, QString &result, bool \
allow8Bit = false);<br><br>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:<br><br> bool parseAtom(const char *&scursor \
/In,Out/, const char* send, QString &result, bool allow8Bit = false);<br><br>The \
generated docstring looks plausible:<br><br> parseAtom(str, str, str, bool = \
False) -> Tuple[bool, str]<br><br>but the generated code does not compile because \
it is passed using "&" when I think it should not be:<br><br> \
const char* a0;<br>...<br> if (sipParseArgs(&sipParseErr, sipArgs, \
"csJ1|b", &a0, &a1, sipType_QString,&a2, &a2State, \
&a3))<br> {<br>...<br> sipRes = \
::KMime::HeaderParsing::parseAtom(&a0,a1,*a2,a3);<br><br>The compilation error \
is:<br><br>========<br>tmp2/tmp/PyKF5/KMime/KMime/sipKMimeKMimeHeaderParsing.cpp: In \
function ‘PyObject* meth_KMime_HeaderParsing_parseAtom(PyObject*, \
PyObject*)':<br>tmp2/tmp/PyKF5/KMime/KMime/sipKMimeKMimeHeaderParsing.cpp:1385:70: \
error: no matching function for call to ‘parseAtom(const char**, const char*&, \
QString&, bool&)'<br>In file included from \
/usr/include/KF5/KMime/kmime/kmime_headers.h:44:0,<br> from \
/usr/include/KF5/KMime/kmime/kmime_util.h:27,<br> from \
/usr/include/KF5/KMime/kmime/kmime_content.h:53,<br> from \
/usr/include/KF5/KMime/KMime/Content:1,<br> from \
tmp/KMime/KMime/Content.sip:27,<br> from \
unifiedKMime.cpp:1:<br>/usr/include/KF5/KMime/kmime/kmime_header_parsing.h:91:19: \
note: candidate: bool KMime::HeaderParsing::parseAtom(const char*&, const char*, \
QString&, bool)<br> KMIME_EXPORT bool parseAtom(const char *&scursor, const \
char *const send,<br> \
^~~~~~~~~<br>/usr/include/KF5/KMime/kmime/kmime_header_parsing.h:91:19: note: no \
known conversion for argument 1 from ‘const char**' to ‘const \
char*&'<br>========<br><br>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").<br><br>Am I using the annotations \
incorrectly, or is this a bug in SIP?<br><br>Thanks, Shaheed<br><br>[1] Without any \
of the needed annotations, the SIP generated docstring looks as expected:<br><br> \
parseAtom(str, str, str, bool = False) -> bool<br><br>and the generated code for \
the first argument:<br><br> const char* a0;<br>...<br> if \
(sipParseArgs(&sipParseErr, sipArgs, "ssJ1|b", &a0, &a1, \
sipType_QString,&a2, &a2State, &a3))<br> {<br> sipRes = \
::KMime::HeaderParsing::parseAtom(a0,a1,*a2,a3);<br><br>Also, AFAICS, adding the \
needed /Out/ to argument 3 emits plausible looking code.</div>
[Attachment #6 (text/plain)]
_______________________________________________
PyQt mailing list PyQt@riverbankcomputing.com
https://www.riverbankcomputing.com/mailman/listinfo/pyqt
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic