Hi there.<br><br>Your current implementation of "parse-args-and-types" in src/function.lisp use destructuring clause in "loop" and tests the end(as i understood) of the arguments list by comparing second value with nil<br>
<br>(defun parse-args-and-types (args)<br> "Returns 4 values. Types, canonicalized types, args and return type."<br> (let ((return-type :void))<br> (loop for (type arg) on args by #'cddr<br> if arg collect type into types<br>
and collect (canonicalize-foreign-type type) into ctypes<br> and collect arg into fargs<br> else do (setf return-type type)<br> finally (return (values types ctypes fargs return-type)))))<br>
<br>but it also causes foreign-funcall to skip argument if it's value is NIL:<br>(define-foreign-type ptr-type () ()<br> (:actual-type :pointer)<br> (:simple-parser some-type))<br>(defmethod translate-to-foreign (val (type ptr-type))<br>
(if (null val) (null-pointer) val))<br><br>(foreign-funcall "f" :uint x some-type nil :uint y :void)<br>==><br>(LET ((#:G13879 X)) <br> (LET ((#:G13880 Y))<br> (CFFI-SYS:%FOREIGN-FUNCALL "f"<br>
(:UNSIGNED-INT #:G13879 :UNSIGNED-INT #:G13880 :VOID) :CALLING-CONVENTION<br> :CDECL :LIBRARY :DEFAULT)))<br><br>Shouldn't that function be written like this(for example)?<br><br>(defun parse-args-and-types (args)<br>
"Returns 4 values. Types, canonicalized types, args and return type."<br> (let* ((len (length args))<br> (return-type (if (oddp len) (car (last args)) :void)))<br> (loop repeat (floor len 2)<br> for (type arg) on args by #'cddr<br>
collect type into types<br> collect (canonicalize-foreign-type type) into ctypes<br> collect arg into fargs <br> finally (return (values types ctypes fargs return-type)))))<br>
<br>p.s. sorry for my bad english :)<br>