[prev in list] [next in list] [prev in thread] [next in thread]
List: pykde
Subject: Re: [PyQt] SIP template
From: Denis Rouzaud <denis.rouzaud () gmail ! com>
Date: 2017-05-17 4:56:09
Message-ID: CAMtsY+aegh2UjB8Mw8a2kvZSno1-xzYWYVSUdfMtYLkKmrUi7w () mail ! gmail ! com
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
Hi Davod,
Thanks a lot for you reply.
Le mar. 16 mai 2017 à 23:38, David Boddie <david@boddie.org.uk> a écrit :
> On Tue May 16 20:49:57 BST 2017, Denis Rouzaud wrote:
>
> > I am facing an issue with correcty implementing a template (container))
> in
> > SIP.
> >
> > Let's say I have
> >
> > qgsoptional:
> > template<class T>
> > class QgsOptional
> > {
> > public:
> > QgsOptional( const T &data, bool enabled )
> > : mEnabled( enabled )
> > , mData( data )
> > {}
> > private:
> > bool mEnabled;
> > T mData;
> > };
> >
> > qgsoptionalexpression.h:
> >
> > class QgsOptionalExpression : public QgsOptional<QgsExpression>
> > {
> > public:
> > QgsOptionalExpression();
> > }
>
> OK, so you are defining a class called QgsOptionalExpression here. As far
> as
> I can see, this will conflict with what you are doing next:
>
> > Now, I'd like to create the SIP file for QgsOptioalExpression. I tried
> with
> > what I found in another topic [0]:
> >
> > class QgsOptionalExpression
> > {
> > %TypeHeaderCode
> > #include "qgsoptional.h"
> > typedef QgsOptional<QgsExpression> QgsOptionalExpression;
> > %End
> > public:
> > QgsOptionalExpression();
> > }
>
> Here, you define QgsOptionalExpression again using a typedef, resulting in
> the following error:
>
> > But this gives me this error:
> > python/core/qgsoptionalexpression.sip:29:36: error: typedef redefinition
> > with different types ('QgsOptional' vs 'QgsOptionalExpression')
> > typedef QgsOptional QgsOptionalExpression;
> > The error points that the definition is already included in the header
> > qgsoptionalepxression.h while I am actually not including it here (also
> gave
> > it a try with including it).
> >
> > I understand the point, but how shall I tackle this?
>
> Good. :-) Just for others reading this, the reason for the conflict is that
> the typedef is included in the generated C++ code, so the compiler will
> encounter both the class definition and the typedef.
>
> If you don't need the class definition then remove it.
>
> If you do need it then I think you should be able to leave out the typedef
> and include the custom qgsoptionalexpression.h header instead:
>
> class QgsOptionalExpression
> {
> %TypeHeaderCode
> #include "qgsoptionalexpression.h"
> %End
> public:
> QgsOptionalExpression();
> }
>
> Does that help?
>
>
This compiles but I don't have access to enabled() and data() methods in
the template class (QgsOptional), which is a major issue.
With the inheritance written:
class QgsOptionalExpression : public QgOptional<QgsExpression>
I get a "syntax error".
Any idea?
Cheers,
Denis
[Attachment #5 (text/html)]
<div dir="ltr">Hi Davod,<div><br></div><div>Thanks a lot for you reply.<br><br><div \
class="gmail_quote"><div dir="ltr">Le mar. 16 mai 2017 Ã 23:38, David Boddie \
<<a href="mailto:david@boddie.org.uk">david@boddie.org.uk</a>> a écrit \
:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px \
#ccc solid;padding-left:1ex">On Tue May 16 20:49:57 BST 2017, Denis Rouzaud \
wrote:<br> <br>
> I am facing an issue with correcty implementing a template (container)) in<br>
> SIP.<br>
><br>
> Let's say I have<br>
><br>
> qgsoptional:<br>
> template<class T><br>
> class QgsOptional<br>
> {<br>
> public:<br>
> QgsOptional( const T &data, bool enabled )<br>
> : mEnabled( enabled )<br>
> , mData( data )<br>
> {}<br>
> private:<br>
> bool mEnabled;<br>
> T mData;<br>
> };<br>
><br>
> qgsoptionalexpression.h:<br>
><br>
> class QgsOptionalExpression : public QgsOptional<QgsExpression><br>
> {<br>
> public:<br>
> QgsOptionalExpression();<br>
> }<br>
<br>
OK, so you are defining a class called QgsOptionalExpression here. As far as<br>
I can see, this will conflict with what you are doing next:<br>
<br>
> Now, I'd like to create the SIP file for QgsOptioalExpression. I tried with<br>
> what I found in another topic [0]:<br>
><br>
> class QgsOptionalExpression<br>
> {<br>
> %TypeHeaderCode<br>
> #include "qgsoptional.h"<br>
> typedef QgsOptional<QgsExpression> QgsOptionalExpression;<br>
> %End<br>
> public:<br>
> QgsOptionalExpression();<br>
> }<br>
<br>
Here, you define QgsOptionalExpression again using a typedef, resulting in<br>
the following error:<br>
<br>
> But this gives me this error:<br>
> python/core/qgsoptionalexpression.sip:29:36: error: typedef redefinition<br>
> with different types ('QgsOptional' vs \
'QgsOptionalExpression')<br> > typedef QgsOptional \
QgsOptionalExpression;<br> > The error points that the definition is already \
included in the header<br> > qgsoptionalepxression.h while I am actually not \
including it here (also gave<br> > it a try with including it).<br>
><br>
> I understand the point, but how shall I tackle this?<br>
<br>
Good. :-) Just for others reading this, the reason for the conflict is that<br>
the typedef is included in the generated C++ code, so the compiler will<br>
encounter both the class definition and the typedef.<br>
<br>
If you don't need the class definition then remove it.<br>
<br>
If you do need it then I think you should be able to leave out the typedef<br>
and include the custom qgsoptionalexpression.h header instead:<br>
<br>
class QgsOptionalExpression<br>
{<br>
%TypeHeaderCode<br>
#include "qgsoptionalexpression.h"<br>
%End<br>
public:<br>
QgsOptionalExpression();<br>
}<br>
<br>
Does that help?<br><br></blockquote><div><br></div><div>This compiles but I don't \
have access to enabled() and data() methods in the template class (QgsOptional), \
which is a major issue.</div><div><br></div><div>With the inheritance written: \
</div><div>class QgsOptionalExpression : public QgOptional<QgsExpression> \
</div><div>I get a "syntax error".</div><div><br></div><div>Any \
idea?</div><div><br></div><div>Cheers,</div><div>Denis</div><div><br></div><div> \
</div></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