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

List:       pykde
Subject:    Re: [PyQt] SIP: exposing C++ shift operators
From:       Phil Thompson <phil () riverbankcomputing ! co ! uk>
Date:       2009-07-09 20:49:02
Message-ID: f9d0827983d52587833636f6cff37a58 () localhost
[Download RAW message or body]

On Thu, 09 Jul 2009 20:14:07 +0200, Giovanni Bajo <rasky@develer.com>
wrote:
> Hi Phil,
> 
> I'm trying to expose a global operator function through SIP. The first 
> argument is not an object wrapped by SIP, but I don't really care: it 
> would be sufficient if it was possible to call it from Python as a 
> normal function call. I tried this:
> 
> void operator<<(A& a, B& b) /PyName=foobar/;
> 
> but it doesn't work because SIP generates this code:
> 
>    __lshift__(*a0, *a1);

Actually it should display an error message.

> It would work if it generated this:
> 
>    operator<<(*a0, *a1);
> 
> Does this make sense? Is it a simple fix that I can do myself?

Global operators are supported but only if the first argument is a wrapped
class.

Instead just define...

void foobar(A& a, B& b);
%MethodCode
    operator<<(*a0, *a1);
%End

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