On Sun, 2007-05-13 at 10:00 -0400, Tamas K Papp wrote: > (cffi:defcfun ("cairo_line_to" cairo_line_to) :void > (cr :pointer) > (x :double) > (y :double)) > > I would like to generate wrapper functions that would take the first > argument from a global variable and apply conversions for the rest. > The problem is that there are many functions, and I want to automate > this as much as possible. > > Is there any way to get the signature of a function defined with > cffi:defcfun? In this case, I need something like (:void cr :pointer > x :double y: double) (of course the syntax and the ordering can vary). > With this, I could automate the generation of wrappers.
Sorry, this information is used in the macroexpansion, but not saved. See src/functions.lisp. If you're using SWIG's output unedited, there should be a pattern of output. In that case, you could pretty easily postprocess the output. (defun wanted-signature-p (form) (and (eq (first form) 'cffi:defcfun) (cdddr form) (eq (second (fourth form)) :pointer))) (defun save-signature (form) "Save CFFI:DEFCFUN signature in FORM." (destructuring-bind (macro-name (c-name lisp-name) &rest rettype-args) form (declare (ignore macro-name c-name)) (put lisp-name 'defcfun-signature rettype-args))) Alternatively, you could wipe out the cffi: prefix and wrap defcfun at the top of that file. -- ;;; Stephen Compall ** http://scompall.nocandysw.com/blog ** Failure to imagine vast possibilities usually stems from a lack of imagination, not a lack of possibility.
signature.asc
Description: This is a digitally signed message part
_______________________________________________ cffi-devel mailing list cffi-devel@common-lisp.net http://common-lisp.net/cgi-bin/mailman/listinfo/cffi-devel