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
On 2006-maj-19, at 23:43, Ken Tilton wrote:
The allocate ended up with CFFI being passed ':float, which really made CFFI unhappy.
Strange, it works for me.
UFFI> (allocate-foreign-object :float 16) #<A Mac Pointer #x302E30>
Also, ':float shouldn't be a problem:
CFFI> (foreign-alloc ':float) #<A Mac Pointer #x3019F0>
But a similar hack on deref-array did not fly [...]
If I understand the UFFI docs correctly, I think your code is not correct UFFI, since deref-array expects an array type, not the type of the array's elements. So, def-array-pointer would be necessary to define the array type.
cffi-uffi-compat seems to be a great way to find bugs in UFFI code, heh.
On 5/19/06, Luís Oliveira luismbo@gmail.com wrote:
On 2006-maj-19, at 23:43, Ken Tilton wrote:
The allocate ended up with CFFI being passed ':float, which really made CFFI unhappy.
Strange, it works for me.
UFFI> (allocate-foreign-object :float 16) #<A Mac Pointer #x302E30>
Also, ':float shouldn't be a problem:
CFFI> (foreign-alloc ':float) #<A Mac Pointer #x3019F0>
But a similar hack on deref-array did not fly [...]
If I understand the UFFI docs correctly, I think your code is not correct UFFI, since deref-array expects an array type,...
OK, that is probably it. We have been thrashing around with old UFFI code half transitioned half not etc etc. Probably flipped some stuff over to CFFI then tried ... well, you get the idea.
thx, kt