[Pyrex] creating and populating Python/C structs
Simon Burton
simon at arrowtheory.com
Sun Sep 4 17:30:02 CEST 2005
On Sun, 4 Sep 2005 16:12:26 +1000
Christopher Armstrong <radeex at gmail.com> wrote:
>
> On 9/5/05, Simon Burton <simon at arrowtheory.com> wrote:
> >
> > It seems you need to include compile.h before frameobject.h (see attached).
> >
> > Simon.
>
> Thanks, I figured Python.h had all that stuff already included. That
> got my module to compile, but newframe is just returning a string of
> bytes instead of a PyFrameObject now. If I've got a cdef PyFrameObject
> *frame in a 'def' python function, how do I return that as a PyObject,
> i.e., an instance of types.FrameType?
>
You need to actually malloc the object using eg. PyFrame_New which
should be cdef declared to return object (so that pyrex handles increfs for you).
And: keep an eye on the generated c code, to make sure it's doing what you expect. (!!)
Simon.
PS. yes this is tricky, and i don't know all the details of what you will have to do.
--
Simon Burton, B.Sc.
Licensed PO Box 8066
ANU Canberra 2601
Australia
Ph. 61 02 6249 6940
http://arrowtheory.com
More information about the Pyrex
mailing list