[Pyrex] Assign C object to a cdeffed variable of a class
Stefano Esposito
stefano.esposito87 at gmail.com
Sat Sep 8 13:17:07 CEST 2007
Hi all,
i'm trying to write a python bindings to a library in pyrex (this is my first try in usin pyrex).
I hava a C function declared (in the .h file) as this:
int alpm_pkg_load (const char *filename, pmpkg_t **pkg);
and which i've declared to pyrex as follows:
ing alpm_pkg_load (char *filname, pmpkg_t **pkg);
the pmpkg_t is an exter struct and i've declared it as:
ctypedef struct pmpkg_t
i have defined a class like follows:
cdef class Package:
cdef pmpkg_t *pkg
[...]
what i'd like to do is to call the alpm_pkg_load from a module function like:
def package_new_from_file (filename):
cdef pmpkg_t *pkg
alpm_pkg_load (filename, &pkg)
and then assing the pkg variable to the pkg member of Package class. I've tried with simply:
pypkg = Package()
pypkg.pkg = pkg
but pyrexc complains to cannot convert pmpkg_t (*) to a Python object. Is there a way to do something similar or a work around?
--
Stefano Esposito <stefano.esposito87 at gmail.com>
More information about the Pyrex
mailing list