Btrieve/C-extension question

vincent wehren v.wehren at home.nl
Thu Jun 19 11:53:40 EDT 2003


"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:

pos = PyCObject_FromVoidPtr(pos_blk; NULL) ;
return Py_BuildValue("N", pos);

Passing is back in where I was getting trouble:
( passed back in via PyArg_ParseTuple(args, "O", pos) )
pos_blk = PyCObjectAsVoidPtr(pos);
doesn't seem to work...

I think I need to check to C side of things once more.
Maybe there's some other Btrieve mystery that needs unravelling!

Vincent Wehren

But
> http://www.python.org/doc/current/api/cObjects.html
>
> <quote from page above>
>        This subtype of PyObject represents an opaque value, useful for
> C extension modules who need to pass an opaque value (as a void*
> pointer) through Python code to other C code.
> <end quote>
>
> It seems like this is meant for function pointers and the like, but it
> works well for pieces of memory that need to be passed through Python
> but not processed.
>
> HTH,
> Paul Simmonds
>
> >
> > Any pointers would be much appreciated.
> >
> > Regards,
> > Vincent Wehren






More information about the Python-list mailing list