Btrieve/C-extension question

vincent wehren v.wehren at home.nl
Fri Jun 20 12:47:29 EDT 2003


"Paul Simmonds" <psimmo60 at hotmail.com> schrieb im Newsbeitrag
news:94974e1a.0306200124.4dee6542 at posting.google.com...
> "vincent wehren" <v.wehren at home.nl> wrote in message
news:<bcslog$70p$1 at news4.tilbu1.nb.home.nl>...
> > "Paul Simmonds" <psimmo60 at hotmail.com> schrieb im Newsbeitrag
> > news:94974e1a.0306190653.3a829cb6 at posting.google.com...
> > > "vincent wehren" <v.wehren at home.nl> wrote in message
> >  news:<bcrua6$120$1 at news4.tilbu1.nb.home.nl>...
> > > <Problem description snipped>
> > > > Is it sensible to pass such a block of memory to Python and back?
> > > > If so, what is the best way to go about this, I.O.W, how do I pass
such
> >  a
> > > > block of memory
> > > > to Python and back (unchanged).
> > >
> > > I think you need a PyCObject.
> >
> > Thanks
> > Yes, that was my guess too...
> > So I did someting along the lines of:
(...)
> For example (untested):
>
> PyObject *VoidPtr_ParseMe(PyObject *self, PyObject *args)
> {   int flag;
>     PyObject *file;
>     if(!PyArg_ParseTuple(args,"Oi",&file,&flag)) return NULL;
>     /* This could be your problem  /\
>      * Then this should work...*/
>     your_function(PyCObject_AsVoidPtr(file), flag);
> etc...
> }
>
> Of course, if the mistake in your ParseTuple line was just a typo,

Yes this was just a typo. The problem I had was the scope of the pos_blk in
the legacy
C code. After some redesign of the wrapper passing PyCObjects around now
works like a charm!!
Amazing feature!

Cheers,
Vincent Wehren














> maybe you should take a look at exactly what gets put into the
> CObject.
>
> HTH,
> Paul
> >
> > Vincent Wehren
> >






More information about the Python-list mailing list