X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=doc%2Fref_object.xml;h=ed76892089168cf6c95f8d66003b8b605dce86c2;hb=895cdddc64ad069c4d8173a21d0d5ce47b79e919;hp=ef6b1215dc2b1c0a6132e6b8c6726e076d798c37;hpb=6be0cb84dd1fc6a0ae9410f7ccdc34ac21ae4377;p=uffi.git diff --git a/doc/ref_object.xml b/doc/ref_object.xml index ef6b121..ed76892 100644 --- a/doc/ref_object.xml +++ b/doc/ref_object.xml @@ -1,7 +1,7 @@ - + + "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" [ + %myents; ]> @@ -64,11 +64,11 @@ array of type that is size members Examples - + (def-struct ab (a :int) (b :double)) (allocate-foreign-object 'ab) => #<ptr> - + Side Effects @@ -181,14 +181,14 @@ much better with static allocation. Examples - + (defun gethostname2 () "Returns the hostname" (uffi:with-foreign-object (name '(:array :unsigned-char 256)) (if (zerop (c-gethostname (uffi:char-array-to-pointer name) 256)) (uffi:convert-from-foreign-string name) (error "gethostname() failed.")))) - + Side Effects @@ -238,12 +238,12 @@ much better with static allocation. Examples - + (size-of-foreign-object :unsigned-byte) => 1 (size-of-foreign-object 'my-100-byte-vector-type) => 100 - + @@ -360,14 +360,14 @@ much better with static allocation. Examples - + (let ((intp (allocate-foreign-object :int))) (setf (deref-pointer intp :int) 10) (prog1 (deref-pointer intp :int) (free-foreign-object intp))) => 10 - + @@ -436,13 +436,13 @@ pointers are a lisp character. Examples - + (let ((fs (convert-to-foreign-string "a"))) (prog1 (ensure-char-character (deref-pointer fs :char)) (free-foreign-object fs))) => #\a - + @@ -504,13 +504,13 @@ an integer. Examples - + (let ((fs (convert-to-foreign-string "a"))) (prog1 (ensure-char-integer (deref-pointer fs :char)) (free-foreign-object fs))) => 96 - + @@ -667,6 +667,13 @@ if a cstring returned by a function is &null;. Arguments and Values + + binding-name + + A symbol which will be bound to the casted object. + + + ptr @@ -693,12 +700,9 @@ if a cstring returned by a function is &null;. Description - 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 - cast. This name will be bound to the cast pointer during the - execution of BODY. + Executes BODY with POINTER cast to be a pointer to type TYPE. + BINDING-NAME is will be bound to this value during the execution of + BODY. This is a no-op in AllegroCL but will wrap BODY in a LET form if BINDING-NAME is provided. @@ -710,7 +714,7 @@ if a cstring returned by a function is &null;. Examples - + (with-foreign-object (size :int) ;; FOO is a foreign function returning a :POINTER-VOID (let ((memory (foo size))) @@ -721,7 +725,7 @@ if a cstring returned by a function is &null;. (dotimes (i (deref-pointer size :int)) (do-something-with (deref-array memory '(:array :unsigned-byte) i))))))) - + Side Effects @@ -796,7 +800,7 @@ value of a variable in foreign code. Examples C code - + int baz = 3; typedef struct { @@ -809,11 +813,11 @@ value of a variable in foreign code. int foo () { return baz; } - + Lisp code - + (uffi:def-struct foo-struct (x :int) (y :double)) @@ -835,7 +839,7 @@ value of a variable in foreign code. (foo) => 4 - +