X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;ds=sidebyside;f=doc%2Fref.sgml;h=58ac773cac341a8ec6f7a275f640b487a902f1f6;hb=c97f28462cb9499b4687b9d0fd969b3e9fbd6ca2;hp=ad3bbffa11d63b9a2d79c896c901d3cd03ced756;hpb=cdd366616d5a526546a26adbded8c562dfce743f;p=uffi.git
diff --git a/doc/ref.sgml b/doc/ref.sgml
index ad3bbff..58ac773 100644
--- a/doc/ref.sgml
+++ b/doc/ref.sgml
@@ -95,7 +95,6 @@ dereferenced :char pointer returns an character.
:unsigned-char - Unsigned 8-bits. A dereferenced :unsigned-char
pointer returns an character.
-
:byte - Unsigned 8-bits. A
dereferenced :byte pointer returns an integer.
@@ -497,7 +496,7 @@ structure. It's type is :pointer-self.
- def-slot-value
+ get-slot-value
Retrieves a value from a slot of a structure.
Macro
@@ -777,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.
+
+
+
+
@@ -784,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.
@@ -799,7 +868,7 @@ the array.
Syntax
- allocate-foreign-object type => ptr
+ allocate-foreign-object type &optional size => ptr
@@ -808,7 +877,15 @@ the array.
type
- A type of foreign object to allocate.
+ A unevaluated type of foreign object to allocate.
+
+
+
+
+ size
+
+ An optional size parameter. If specified, allocates and returns an
+array of type that is size members long.
@@ -831,7 +908,7 @@ the array.
Examples
(def-struct ab (a :int) (b :double))
-(allocate-foreign-object 'ab)
+(allocate-foreign-object ab)
=> #<ptr>
@@ -959,7 +1036,7 @@ the array.
Syntax
- def-pointer ptr type => value
+ deref-pointer ptr type => value
@@ -980,7 +1057,7 @@ the array.
- value
+ value
The value of the object where the pointer points.
@@ -998,9 +1075,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
@@ -1016,8 +1160,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.
+
@@ -1639,7 +1853,7 @@ foreign function. If :void indicates module does not return
Examples
(def-function "gethostname"
- ((name :cstring)
+ ((name (* :unsigned-char))
(len :int))
:returning :int)