Hello, I'm extending an application that supports customization using the C language. I am able to write standalone python applications that use the C API's using cffi. This is good, but only a first step.
This application allows me to register code that will run on various events but it has to be C code. I'd like to write Python code instead. So basically, my C code will use the Python C API to get a handle to the module and function (like how they do it here http://docs.python.org/2/extending/embedding.html#pure-embedding) What would be the proper way to pass a pointer to a C structure from C to Python so that I can use ffi.cast and be able to use it from within Python? I have got this to work but I'm not certain that it is correct, fool-proof, or portable. This is how I got it to work from the C side.... PyObject* pArgs = Py_BuildValue("(k)", &some_structure); PyObject_CallObject(pFunc, pArgs) ... and from the Python side... def my_function(struct_ptr): struct = ffi.cast("mystruct_t *", struct_ptr) Like I said, this works fine. I am able to manipulate the structure from within Python. I just want to know the correct way to to this. Thanks, ~Eric
-- https://mail.python.org/mailman/listinfo/python-list