rpav / cl-autowrap

(c-include "file.h") => complete FFI wrapper
BSD 2-Clause "Simplified" License
210 stars 41 forks source link

Fix handling of function pointers in function parameters #90

Open sdilts opened 5 years ago

sdilts commented 5 years ago

Function pointers are just that; pointers. Therefore they should be marked as a pointer in cffi-sys:%foreign-funcall instead of as a :function. Another solution is to mark the parameter types as a pointer when initializing the function object, but having a parameter's type being a pointer is not as informative as it being a function.

This removes an error that looks something like:

; --> PROGN EVAL-WHEN AUTOWRAP:DEFINE-CFUN PROGN DEFUN PROGN
; --> SB-IMPL::%DEFUN SB-IMPL::%DEFUN SB-INT:NAMED-LAMBDA FUNCTION
; --> BLOCK LET LET LET
; ==>
;   (CFFI-SYS:%FOREIGN-FUNCALL "wlr_list_find"
;                              (:POINTER #:LIST13159 :FUNCTION #:COMPARE13160
;                               :POINTER #:CMP-TO13161 :LONG)
;                              :CONVENTION :CDECL)
;
; caught ERROR:
;   during macroexpansion of
;   (CFFI-SYS:%FOREIGN-FUNCALL "wlr_list_find" (:POINTER #:LIST13159 :FUNCTION ...)
;                              ...).
;   Use *BREAK-ON-SIGNALS* to intercept.
;
;    :FUNCTION fell through ECASE expression.
;    Wanted one of (:CHAR :UNSIGNED-CHAR :SHORT :UNSIGNED-SHORT :INT :UNSIGNED-INT
;                   :LONG :UNSIGNED-LONG :LONG-LONG :UNSIGNED-LONG-LONG :FLOAT
;                   :DOUBLE :POINTER :VOID).