[prev in list] [next in list] [prev in thread] [next in thread]
List: pykde
Subject: Re: [PyQt] SIP newbie question (%MethodCode oddity)
From: Phil Thompson <phil () riverbankcomputing ! co ! uk>
Date: 2008-01-10 12:00:30
Message-ID: 200801101200.31005.phil () riverbankcomputing ! co ! uk
[Download RAW message or body]
On Tuesday 08 January 2008, Jim Crowell wrote:
> Hi all,
>
> I'm fiddling with SIP 4.7.3 on XP for a non-Qt-related project. As a
> learning exercise I tried porting the Fraction example at
> <http://www.panix.com/~elflord/unix/siptute/> to SIP 4. Got it working
> to a first approximation, but there's a bit that puzzles me: sipCpp
> doesn't always get defined in %MethodCode blocks where it looks like it
> should.
>
> Here's the working .sip code for two methods:
>
> float __float__();
> %MethodCode
> sipRes = (double)sipCpp->numerator() / sipCpp->denominator();
> %End
>
> Fraction __add__( Fraction );
> %MethodCode
> sipRes = new Fraction(*a0 + *a1);
> %End
>
> i.e. in the latter case sipCpp is not defined, but that same
> self-as-c++-object pointer resides in a0. Can anyone tell me why?
It's an artifact of the way global operators (eg. operator+()) are
implemented. I've fixed the documentation to describe the inconsistency.
Phil
_______________________________________________
PyQt mailing list PyQt@riverbankcomputing.com
http://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