X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;ds=inline;f=doc%2Fref_object.xml;h=6ee2efd4925dce87f58f7a80d080832a55e50e81;hb=dc12f6625ed6c85ad380525d01c0726100bf7a3d;hp=f6bd71a9987bb70c481888fd933d531016015325;hpb=466148daa2e13a529e7338aeaf83cdc49c47ddbb;p=uffi.git
diff --git a/doc/ref_object.xml b/doc/ref_object.xml
index f6bd71a..6ee2efd 100644
--- a/doc/ref_object.xml
+++ b/doc/ref_object.xml
@@ -1,7 +1,7 @@
-
+
+
%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
-
+