[cffi-devel] cffi-uffi-compat vs :float
Ken Tilton
kentilton at gmail.com
Fri May 19 22:43:34 UTC 2006
I think this kind of code does not like cffi-uffi-compat:
(defun gl-apply-matrix (a b c d x y)
(let ((m (allocate-foreign-object :float 16))
(l (list a c 0 0 b d 0 0 0 0 1 0 x y 0 1)))
(loop for i from 0 to 15 and j in l do
(setf (deref-array m :float i) (coerce j 'float)))
(gl-mult-matrixf m)
(free-foreign-object m)))
The allocate ended up with CFFI being passed ':float, which really made CFFI
unhappy. I beat on things a little and got past that with the dubious:
(defmacro allocate-foreign-object (type &optional (size 1))
"Allocate one or more instance of a foreign type."
`(cffi:foreign-alloc ,(cond
((keywordp type) `,(convert-uffi-type type))
((constantp type) `',(convert-uffi-type (eval
type)))
(t `(convert-uffi-type ,type)))
:count ,size))
But a similar hack on deref-array did not fly and when I saw why I decided
to port the code to native CFFI since there is not that much of it.
Are those easily fixable? There is a lot of UFFI code out there that might
like CFFI's portability. (I know you know that. <g>)
kenny
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/cffi-devel/attachments/20060519/61f523ba/attachment.html>
More information about the cffi-devel
mailing list