[prev in list] [next in list] [prev in thread] [next in thread]
List: pykde
Subject: Re: [PyQt] Function pointers and SIP
From: Phil Thompson <phil () riverbankcomputing ! co ! uk>
Date: 2009-06-18 18:01:31
Message-ID: dd512bd44cfe7365ce4b535a0b2e484e () localhost
[Download RAW message or body]
On Thu, 18 Jun 2009 19:40:08 +0200, Giovanni Bajo <rasky@develer.com>
wrote:
> Hi Phil,
>
> given a C++ object where you can register callbacks such as:
>
> void registerCallback(void (*cb)(void*), void* user_data);
>
> or
>
> void registerCallback(std::tr1::function<void (void)> cb);
>
> how would you wrap them in SIP? Is there some code in PyQt that I can
> look at?
I think you answered this yourself a couple of weeks back.
You'll tell SIP that the arguments are...
void registerCallback(SIP_PYCALLABLE cb, SIP_PYOBJECT user_data);
You'll need to provide %MethodCode. How well you wrap it depends on how
well the API is designed. You can wrap it properly if the API provides
enough context information to the callback to allow a single callback to
handle all calls.
The nearest example in PyQt is probably qInstallMsgHandler().
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