X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;ds=sidebyside;f=doc%2Fref.sgml;h=732204a47c7f6de8fd3eb8c686a1592333db5681;hb=f73eb94e15649aba5fcfbe3a900aa72f31f46a96;hp=fcb08ebf8af2ca1e2e2e45629fcfe73eee1a7eef;hpb=ca7e9a2299773cfbc927d71e6289549601438b24;p=uffi.git
diff --git a/doc/ref.sgml b/doc/ref.sgml
index fcb08eb..732204a 100644
--- a/doc/ref.sgml
+++ b/doc/ref.sgml
@@ -877,7 +877,7 @@ can be freed.
type
- A unevaluated type of foreign object to allocate.
+ The type of foreign object to allocate. This parameter is evaluated.
@@ -908,7 +908,7 @@ array of type that is size members
Examples
(def-struct ab (a :int) (b :double))
-(allocate-foreign-object ab)
+(allocate-foreign-object 'ab)
=> #<ptr>
@@ -973,6 +973,79 @@ array of type that is size members
+
+
+ with-foreign-object
+ Wraps the allocation of a foreign object around a body of code.
+
+ Macro
+
+
+ Syntax
+
+ with-foreign-object (var type) &body body => form-return
+
+
+
+ Arguments and Values
+
+
+ var
+
+ The variable name to bind.
+
+
+
+
+ type
+
+ The type of foreign object to allocate. This parameter is evaluated.
+
+
+
+
+ form-return
+
+ The result of evaluating the body.
+
+
+
+
+
+
+ Description
+
+This function wraps the allocation, binding, and destruction of a foreign object.
+On &cmucl; and
+&lw; platforms the object is stack allocated for efficiency. Benchmarks show that &acl; performs
+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
+ None.
+
+
+ Affected by
+ None.
+
+
+ Exceptional Situations
+ None.
+
+
+
pointer-address