[cffi-devel] Mutable Pointers

Stephen Compall s11 at member.fsf.org
Fri Jul 14 16:01:27 UTC 2006


On Fri, 2006-07-14 at 13:30 +0100, Luís Oliveira wrote:
> See inc-pointer.
> <http://common-lisp.net/project/cffi/manual/html_node/ 
> inc_002dpointer.html>
> 
> (setf *stack-pointer* (inc-pointer *stack-pointer* 1)) should work.  
> You can abstract that with a simple macro:
> 
>    (defmacro incf-pointer (place &optional (offset 1))
>      `(setf ,place (inc-pointer ,place ,offset)))
> 
> Any objections to adding this macro to CFFI?

This evaluates the PLACE forms twice.  If I follow correctly, this can
be more generally solved with a cross-platform setf-expander for
POINTER-ADDRESS that requires its PTR arg to be a place, whereupon
things like (incf (pointer-address *ptr*)) and any other place-modifier
should work.

-- 
Stephen Compall
http://scompall.nocandysw.com/blog
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 191 bytes
Desc: This is a digitally signed message part
URL: <https://mailman.common-lisp.net/pipermail/cffi-devel/attachments/20060714/72bc8451/attachment.sig>


More information about the cffi-devel mailing list