Issue #22 resolved

Ability to query function signatures

Leonard Ritter
created an issue

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

  1. with callables retrieved through either ffi.verify() or ffi.dlopen():

{{{print(ffi.signatureof(ffi.dlopen().some_function))}}}

  1. 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)

  1. Log in to comment