[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: [PyQt] Possible bug in the handling of sipTypeInstanceDef for const data
From:       Shaheed Haque <srhaque () theiet ! org>
Date:       2017-09-05 16:42:55
Message-ID: CAHAc2jc7xxEd_OKKcMcrUF7-k90m2H8jij9_DxmJowVw2EzhiQ () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


On 5 Sep 2017 16:50, "Phil Thompson" <phil@riverbankcomputing.com> wrote:

On 30 Aug 2017, at 8:44 pm, Shaheed Haque <srhaque@theiet.org> wrote:
>
> Hi Phil,
>
> I have a bit of C++ like this:
>
> ========
> typedef struct prob {
>    int p_range;
>    int p_offset;
> } Prob;
>
> static const Prob freqs[16] = {
>    {0, 0},   ...
> };
> ========
>
> (all this is at global scope). The SIP I create for this is:
>
> ========
> struct prob
> {
> %TypeHeaderCode
> #include <MessageViewer/KXFace>
> %End
>    int p_range;
>    int p_offset;
> };
>
> const prob *freqs /NoSetter/;
> ========
>
> In response, SIP creates this code which does not compile, complaining
> "error: invalid conversion from ‘const void*' to ‘void*'":
>
> ========
> /* Define the class and enum instances to be added to this module
dictionary. */
> static sipTypeInstanceDef typeInstances[] = {
>    {sipName_freqs, & ::freqs, &sipType_prob, SIP_INDIRECT},
>    {0, 0, 0, 0}
> };
> ========
>
> Inserting a cast to make the second filed look like "(void *)&
> ::freqs" suppresses the error. Now, I could probably cook up a patch
> to do this, but I'm not sure if the correct fix is actually to change
> the definition of the field to "const void *ti_ptr"?
>
> Any thoughts?

Tonight's snapshot has the cast.


Thanks for the quick turnaround as usual! I'll add the patch to my Python 2
code as Clang has still not released Python 3 support...

Shaheed


Phil

[Attachment #5 (text/html)]

<div dir="auto"><div><br><div class="gmail_extra"><br><div class="gmail_quote">On 5 \
Sep 2017 16:50, &quot;Phil Thompson&quot; &lt;<a \
href="mailto:phil@riverbankcomputing.com">phil@riverbankcomputing.com</a>&gt; \
wrote:<br type="attribution"><blockquote class="quote" style="margin:0 0 0 \
.8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="elided-text">On 30 Aug \
2017, at 8:44 pm, Shaheed Haque &lt;<a \
href="mailto:srhaque@theiet.org">srhaque@theiet.org</a>&gt; wrote:<br> &gt;<br>
&gt; Hi Phil,<br>
&gt;<br>
&gt; I have a bit of C++ like this:<br>
&gt;<br>
&gt; ========<br>
&gt; typedef struct prob {<br>
&gt;      int p_range;<br>
&gt;      int p_offset;<br>
&gt; } Prob;<br>
&gt;<br>
&gt; static const Prob freqs[16] = {<br>
&gt;      {0, 0},     ...<br>
&gt; };<br>
&gt; ========<br>
&gt;<br>
&gt; (all this is at global scope). The SIP I create for this is:<br>
&gt;<br>
&gt; ========<br>
&gt; struct prob<br>
&gt; {<br>
&gt; %TypeHeaderCode<br>
&gt; #include &lt;MessageViewer/KXFace&gt;<br>
&gt; %End<br>
&gt;      int p_range;<br>
&gt;      int p_offset;<br>
&gt; };<br>
&gt;<br>
&gt; const prob *freqs /NoSetter/;<br>
&gt; ========<br>
&gt;<br>
&gt; In response, SIP creates this code which does not compile, complaining<br>
&gt; &quot;error: invalid conversion from ‘const void*' to ‘void*'&quot;:<br>
&gt;<br>
&gt; ========<br>
&gt; /* Define the class and enum instances to be added to this module dictionary. \
*/<br> &gt; static sipTypeInstanceDef typeInstances[] = {<br>
&gt;      {sipName_freqs, &amp; ::freqs, &amp;sipType_prob, SIP_INDIRECT},<br>
&gt;      {0, 0, 0, 0}<br>
&gt; };<br>
&gt; ========<br>
&gt;<br>
&gt; Inserting a cast to make the second filed look like &quot;(void *)&amp;<br>
&gt; ::freqs&quot; suppresses the error. Now, I could probably cook up a patch<br>
&gt; to do this, but I&#39;m not sure if the correct fix is actually to change<br>
&gt; the definition of the field to &quot;const void *ti_ptr&quot;?<br>
&gt;<br>
&gt; Any thoughts?<br>
<br>
</div>Tonight&#39;s snapshot has the cast.<br></blockquote></div></div></div><div \
dir="auto"><br></div><div dir="auto">Thanks for the quick turnaround as usual! \
I&#39;ll add the patch to my Python 2 code as Clang has still not released Python 3 \
support...</div><div dir="auto"><br></div><div dir="auto">Shaheed</div><div \
dir="auto"><br></div><div dir="auto"><div class="gmail_extra"><div \
class="gmail_quote"><blockquote class="quote" style="margin:0 0 0 \
.8ex;border-left:1px #ccc solid;padding-left:1ex"> <font color="#888888"><br>
Phil</font></blockquote></div><br></div></div></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