Alternative to copy-in/copy-out?
"Liam M. Healy" <[email protected]> Wed, 23 Oct 2002 10:34:54 -0400
| Newsgroups | gmane.lisp.uffi.general |
|---|---|
| Message-ID | <[email protected]> |
I am just starting out with UFFI, and it looks very useful. I have
ported a small amount of ACL-specific foreign interface code, mostly
to Fortran, to UFFI.
When using the ACL interface I could directly pass CL objects to and
from foreign code. I am looking for the analogue in UFFI.
In c-test-fns.lisp there is a function
(defun t2 ()
(let ((vec (make-array +double-vec-length+ :element-type 'double-float)))
(dotimes (i +double-vec-length+)
(setf (aref vec i) (coerce i 'double-float)))
(half-double-vector +double-vec-length+ vec)
vec))
which seems like it should do what
(defun test-half-double-vector ()
(let ((vec (uffi:allocate-foreign-object :double +double-vec-length+))
results)
(dotimes (i +double-vec-length+)
(setf (uffi:deref-array vec '(:array :double) i)
(coerce i 'double-float)))
(half-double-vector +double-vec-length+ vec)
(dotimes (i +double-vec-length+)
(push (uffi:deref-array vec '(:array :double) i) results))
(uffi:free-foreign-object vec)
(nreverse results)))
does, and is much simpler, and should be more efficient. However,
it doesn't work for me.
Is there a way to avoid copy-in and copy-out when making foreign
calls through UFFI?
Thanks for ideas.
Liam