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.
On 2005-dec-11, at 13:27, Леонид Новиков wrote:
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)
привет Леонид!
The type should be (:array g-value) not (:array (quote g-value))
(cffi-uffi-compat::convert-uffi-type '(:array g-value)) => (CFFI-UFFI-COMPAT::UFFI-ARRAY G-VALUE NIL)
cffi-uffi-compat:size-of-foreign-type on that type wouldn't work, but UFFI users wouldn't notice that since the real uffi:size-of-foreign- type is broken anyway. This is fixed now anyway.
Thanks,
The type should be (:array g-value) not (:array (quote g-value))
(:array 'g-value) was received as follows:
(defmacro ff-elt (v type n) `(uffi:deref-array ,v '(:array ,type) ,n))
(setq gva (ffx:fgn-alloc 'g-value 1 :with-g-value))
(ff-elt gva 'g-value 0)
This part of code cells-gtk. I try to start current version under clisp using cffi-uffi-compat. With my correction this was got. I expected that uffi and cffi-uffi-comapt under alike parameter must return alike results :)
If (:array g-value) will run on uffi that I shall try to change ff-elt that this run on cffi-uffi-compat
On 2005-dec-12, at 13:06, Леонид Новиков wrote:
The type should be (:array g-value) not (:array (quote g-value))
(:array 'g-value) was received as follows:
(defmacro ff-elt (v type n) `(uffi:deref-array ,v '(:array ,type) ,n))
(setq gva (ffx:fgn-alloc 'g-value 1 :with-g-value))
(ff-elt gva 'g-value 0)
This part of code cells-gtk. I try to start current version under clisp using cffi-uffi-compat. With my correction this was got. I expected that uffi and cffi-uffi-comapt under alike parameter must return alike results :)
Hmm... to tell you the truth, I've investigated this issue and I don't quite understand how the :array type is supposed to behave:
CL-USER(2): (uffi:def-struct g-value (g-type (:array :int 16))) #<FOREIGN-FUNCTIONS::FOREIGN-STRUCTURE G-VALUE> CL-USER(3): (uffi::convert-from-uffi-type '(:array 'g-value) :type) (:ARRAY G-VALUE) CL-USER(4): (uffi::convert-from-uffi-type '(:array g-value) :type) (:ARRAY G-VALUE)
On 2005-dec-12, at 13:06, Леонид Новиков wrote:
I expected that uffi and cffi-uffi-comapt under alike parameter must return alike results :)
Well, you are absolutely right. :-) I think this is fixed now.
Thanks for your bug report.