X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=doc%2Fref.sgml;h=99234c410e200a23bb2ee9a97bd182e5436f3849;hb=7612015bdcfa851374a4e8c6f3ff68a8dd8b9a9a;hp=cbf5336613c678cbf354dee67f10c2463dac9c63;hpb=77fd04d570b9ae1fd40c1f7b0134af826576210b;p=uffi.git diff --git a/doc/ref.sgml b/doc/ref.sgml index cbf5336..99234c4 100644 --- a/doc/ref.sgml +++ b/doc/ref.sgml @@ -1515,7 +1515,7 @@ if a cstring returned by a function is &null;. Syntax - with-cast-pointer binding-name ptr type & body body => value + with-cast-pointer (binding-name ptr type) & body body => value @@ -1547,11 +1547,11 @@ if a cstring returned by a function is &null;. Description - Executes BODY with POINTER casted to be a pointer to type TYPE. If - BINDING-NAME is provided the casted pointer will be bound to this + Executes BODY with POINTER cast to be a pointer to type TYPE. If + BINDING-NAME is provided the cast pointer will be bound to this name during the execution of BODY. If BINDING-NAME is not provided POINTER must be a name bound to the pointer which should be - casted. This name will be bound to the casted pointer during the + cast. This name will be bound to the cast pointer during the execution of BODY. This is a no-op in AllegroCL but will wrap BODY in a LET form if @@ -1562,6 +1562,21 @@ if a cstring returned by a function is &null;. DEREF-POINTER or DEREF-ARRAY. + + Examples + +(with-foreign-object (size :int) + ;; FOO is a foreign function returning a :POINTER-VOID + (let ((memory (foo size))) + (when (mumble) + ;; at this point we know for some reason that MEMORY points + ;; to an array of unsigned bytes + (with-cast-pointer (memory :unsigned-byte) + (dotimes (i (deref-pointer size :int)) + (do-something-with + (deref-array memory '(:array :unsigned-byte) i))))))) + + Side Effects None.