X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=doc%2Fref.sgml;h=82ee66a5df717e7d9ed15cbbfa5e3d8d607c39f1;hb=d3f9b63d9227cc2fb7b978e4b40b9592c04852ab;hp=e8c45fd222e31318faaf6f6f8f921d368fa21bda;hpb=7cb20f3bc266ede16dfcd449986136c43c4a2d57;p=uffi.git
diff --git a/doc/ref.sgml b/doc/ref.sgml
index e8c45fd..82ee66a 100644
--- a/doc/ref.sgml
+++ b/doc/ref.sgml
@@ -776,6 +776,75 @@ the array.
None.
+
+
+
+ def-union
+ Defines a foreign union type.
+
+ Macro
+
+
+ Syntax
+
+ def-union name &rest fields
+
+
+
+ Arguments and Values
+
+
+ name
+
+ A name of the new union type.
+
+
+
+
+ fields
+
+ A list of fields of the union.
+
+
+
+
+
+
+ Description
+
+ Defines a foreign union type.
+
+
+
+ Examples
+
+(def-union test-union
+ (a-char :char)
+ (an-int :int))
+
+(let ((u (allocate-foreign-object 'test-union))
+ (setf (get-slot-value u 'test-union 'an-int) (+ 65 (* 66 256)))
+ (prog1
+ (ensure-char-character (get-slot-value u 'test-union 'a-char))
+ (free-foreign-object u)))
+=> #\A
+
+
+
+ Side Effects
+ Defines a new foreign type.
+
+
+ Affected by
+ None.
+
+
+ Exceptional Situations
+ None.
+
+
+
+
@@ -783,7 +852,8 @@ the array.
Overview
- Objects are entities that can allocated and freed.
+ Objects are entities that can allocated, referred to by pointers, and
+can be freed.
@@ -979,7 +1049,7 @@ the array.
- value
+ value
The value of the object where the pointer points.
@@ -997,9 +1067,76 @@ the array.
Examples
+(let ((intp (allocate-foreign-object :int)))
+ (setf (deref-pointer intp :int) 10)
+ (prog1
+ (deref-pointer intp :int)
+ (free-foreign-object intp)))
+=> 10
+
+
+
+
+ Side Effects
+ None.
+
+
+ Affected by
+ None.
+
+
+ Exceptional Situations
+ None.
+
+
+
+
+
+ ensure-char-character
+ Ensures that a dereferenced :char pointer is
+a character.
+
+ Macro
+
+
+ Syntax
+
+ ensure-char-character object => char
+
+
+
+ Arguments and Values
+
+
+ object
+
+ Either a character or a integer specifying a character code.
+
+
+
+
+ char
+
+ A character.
+
+
+
+
+
+
+ Description
+
+ Ensures that an object obtained by dereferencing a
+:char pointer is a character.
+
+
+
+ Examples
+
+
(let ((fs (convert-to-foreign-string "a")))
(prog1
- (ensure-char (deref-pointer fs :char))
+ (ensure-char-character (deref-pointer fs :char))
(free-foreign-object fs)))
=> #\a
@@ -1015,8 +1152,78 @@ the array.
Exceptional Situations
+ Depending upon the implementation and what &uffi; expects, this
+macro may signal an error if the object is not a character or
+integer.
+
+
+
+
+
+ ensure-char-integer
+ Ensures that a dereferenced :char pointer is
+an integer.
+
+ Macro
+
+
+ Syntax
+
+ ensure-char-integer object => int
+
+
+
+ Arguments and Values
+
+
+ object
+
+ Either a character or a integer specifying a character code.
+
+
+
+
+ int
+
+ An integer.
+
+
+
+
+
+
+ Description
+
+ Ensures that an object obtained by dereferencing a
+:char pointer is an integer.
+
+
+
+ Examples
+
+
+(let ((fs (convert-to-foreign-string "a")))
+ (prog1
+ (ensure-char-integer (deref-pointer fs :char))
+ (free-foreign-object fs)))
+=> 96
+
+
+
+
+ Side Effects
None.
+
+ Affected by
+ None.
+
+
+ Exceptional Situations
+ Depending upon the implementation and what &uffi; expects, this
+macro may signal an error if the object is not a character or
+integer.
+
@@ -1638,7 +1845,7 @@ foreign function. If :void indicates module does not return
Examples
(def-function "gethostname"
- ((name :cstring)
+ ((name (* :unsigned-char))
(len :int))
:returning :int)