[PyKDE] SIP: Newbie and char buffers

Doyon, Jean-Francois jdoyon at NRCan.gc.ca
Fri Feb 2 21:12:32 GMT 2007


Perfect, just what I needed.  Thanks!

J.F. 

-----Original Message-----
From: Phil Thompson [mailto:phil at riverbankcomputing.co.uk] 
Sent: February 2, 2007 1:33 PM
To: pykde at mats.imk.fraunhofer.de
Cc: Doyon, Jean-Francois
Subject: Re: [PyKDE] SIP: Newbie and char buffers

On Friday 02 February 2007 6:06 pm, Doyon, Jean-Francois wrote:
> Hello,
>
> I've been wrapping a free but not open-source C++ SDK on Linux using
SIP.
>
> I've achieved all that I wanted so far using fairly simple techniques,

> but now I've run into a problem ...
>
> Admitedly, I don't know much about C++ (Which is why I'm wrapping it).
>
> I have a method that looks like this:
>
> virtual lt_uint32 read( lt_uint8 *pDest, lt_uint32 numBytes );
>
> Where "lt_uint8 *pDest" is actually an "unsigned char *buffer" ...
>
> (The class is an in-memory stream).
>
> Although the compile steps work fine, When I come to use it, strange 
> things happen ...
>
> data = ''
> stream.read(data, 512)
>
> This does not work ... Data is still empty after the call.  Also, when

> I use this method, when the python interpreter stops running, it
segfaults!
>
> I tried experimenting with buffer('') for example, but that didn't
work.
>
> I suspect I'm going to have to write some custom code in the SIP file 
> now ... But I'm not sure where to start.
>
> This is the last bit of functionality I need! I'm so close!
>
> Any help would be much appreciated ...

For an example get a copy of PyQt3 and look at the implementation of
readBlock() in qiodevice.sip - both the %MethodCode and the
%VirtualCatcherCode.

Phil




More information about the PyQt mailing list