X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=doc%2Fref_object.xml;h=6ee2efd4925dce87f58f7a80d080832a55e50e81;hb=7177cf1ffcd71227b04934ae09188dd708ae3bb9;hp=d5dfdee8edb69a1528868253535ba7d308357a3e;hpb=c5115898210dbfa357c208c1bfe58049f7d6ff6d;p=uffi.git diff --git a/doc/ref_object.xml b/doc/ref_object.xml index d5dfdee..6ee2efd 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 - + @@ -710,7 +710,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 +721,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 +796,7 @@ value of a variable in foreign code. Examples C code - + int baz = 3; typedef struct { @@ -809,11 +809,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 +835,7 @@ value of a variable in foreign code. (foo) => 4 - +