[cffi-devel] shareable-byte-vectors for Allegro

John Fremlin jf at msi.co.jp
Tue Jan 13 08:50:20 UTC 2009


After some internal discussion, we have come up with this patch, which
brings back the foreign-address keyword. The keyword is not a
foreign-type and is not used as one.

Pointers passed to or returned from foreign functions use
:foreign-address, and there is no second Lisp type. (The original
unpatched CFFI incorrectly uses nil as the foreign-type and
:foreign-address as the Lisp type.)

This means that you can pass either and address or a Lisp array directly
as the pointer.

Note that there cannot be a second type in the pair after the
foreign-address keyword, if we want to use this functionality,

It should be safer than the ff:allocate-object method and it looks nicer
too.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: bring-back-foreign-address.patch
Type: text/x-diff
Size: 1623 bytes
Desc: not available
URL: <https://mailman.common-lisp.net/pipermail/cffi-devel/attachments/20090113/3c3dd614/attachment.patch>
-------------- next part --------------



John Fremlin <jf at msi.co.jp> writes:

> Any idea how safe or not this is? I am going to ask support at Franz.
>
> (defun make-shareable-byte-vector (size)
>   "Create a Lisp vector of SIZE bytes can passed to
> ;WITH-POINTER-TO-VECTOR-DATA."
>   (ff:allocate-fobject :unsigned-char :lisp size))
> ;
> (defmacro with-pointer-to-vector-data ((ptr-var vector) &body body)
>   "Bind PTR-VAR to a foreign pointer to the data in VECTOR."
>   `(let ((,ptr-var (ff:fslot-address-typed :unsigned-char :lisp ,vector)))
>      , at body))
>
> _______________________________________________
> cffi-devel mailing list
> cffi-devel at common-lisp.net
> http://common-lisp.net/cgi-bin/mailman/listinfo/cffi-devel


More information about the cffi-devel mailing list