[cffi-devel] small bag in cffi-uffi-compat

Леонид Новиков ln at bk.ru
Sun Dec 11 13:27:29 UTC 2005


I have found small mistake in cffi-uffi-compat:

CL-USER> (cffi-uffi-compat:def-struct g-value
    (g-type (:array :int 16)))
G-VALUE

CL-USER> (cffi-uffi-compat::convert-uffi-type 'g-value)
G-VALUE

CL-USER> (cffi-uffi-compat::convert-uffi-type '(:array 'g-value))
(CFFI-UFFI-COMPAT::UFFI-ARRAY NIL NIL)

Last call was to return: (CFFI-UFFI-COMPAT::UFFI-ARRAY G-VALUE NIL)

For correct work I have corrected convert-uffi-type as follows:

(defun convert-uffi-type (uffi-type)
  "Convert a UFFI primitive type to a CFFI type."
  ;; Many CFFI types are the same as UFFI.  This list handles the
  ;; exceptions only.
  (case uffi-type
    (:cstring :pointer)
    (:pointer-void :pointer)
    (:pointer-self :pointer)
    (:char '(uffi-char :char))
    (:unsigned-char '(uffi-char :unsigned-char))
    (:byte :char)
    (:unsigned-byte :unsigned-char)
    (t
     (if (listp uffi-type)
         (case (car uffi-type)
           (* :pointer)
           (:array `(uffi-array ,(convert-uffi-type (second uffi-type))
                                ,(third uffi-type)))
           (:union (second uffi-type))
           (:struct (convert-uffi-type (second uffi-type)))
           (:struct-pointer :pointer)
           
	   ;My correction
	   (t (eval uffi-type))
     )
         uffi-type))))

I bad know lisp so probably this not best variant of the decision of this mistake.




More information about the cffi-devel mailing list