Ability to query function signatures
I am writing a code generator that creates binding modules from parsed and mangled C headers, all using CFFI's parsing and verifying facilities.
I would like the generator to be able to tag functions which require additional wrapping (such as functions taking or returning pointers) and output warnings for those. This makes it necessary to query a function for its C signature.
At the moment this is possible via an undocumented feature, using ffi._backend._getfields(ffi.typeof(callable)) when applied to a callable retrieved from a function returned by ffi.dlopen(), but only with the CPython backend.
It would be great to get an official interface for this feature that worked with both PyPy and CPython. This could work in one of two possible ways (whatever is more convenient to implement):
- with callables retrieved through either ffi.verify() or ffi.dlopen():
{{{print(ffi.signatureof(ffi.dlopen().some_function))}}}
- with names known to ffi after a call to cdef(): {{{ ffi.cdef('void some_function(int,float,cheese);') print(ffi.signatureof('some_function')) }}}
Comments (2)
-
-
- changed status to resolved
Changed in d63ceb231d7c, now probably final: add read-only attributes to <ctype> objects.
- Log in to comment
Added in bde32d4f45e8: ffi.inspecttype().