[Pyrex] Python/C API or void * problems...
Scott Robinson
scott_pyrex at scott.tranzoa.net
Sat Nov 1 07:41:08 CET 2003
I have a function I'm interfacing similar to the following:
int process_data (void *data, int data_length)
How would I pass a Python string to that? I'm trying something like:
cdef char *data
cdef int data_length
data = PyString_AsString (data)
data_length = PyString_Size (data)
process_data (data, data_length)
However, there are obviously multiple problems with thus. Furthermore, I
can't seem to properly define access to the PyString accessors:
cdef extern from "Python.h" :
char * PyString_AsString (object string)
int PyString_Size (object string)
Is this correct, or should "object" be "PyObject *"? Pyrex complains with
the original definition.
Scott.
--
http://quadhome.com/ - Personal webpage
http://tranzoa.net/ - Corporate webpage
-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GAT dpu s: a--- C++ UL+++ P++ L+++ E- W++ N++ o+ K++ w++
O M V(-) PS+ PE Y+ PGP+++ t@ 5 X- R- tv(-) b++++ DI++++ D+
G e* h! r* y
------END GEEK CODE BLOCK------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature
Url : http://lists.copyleft.no/pipermail/pyrex/attachments/20031031/045e8744/attachment.bin
More information about the Pyrex
mailing list