X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;ds=inline;f=doc%2Fref.sgml;h=827ac079f6e3e39f5102540b8a8964bc3d1c2c59;hb=d2cba79718785eaf10ee11d661aca3f4ebb20929;hp=82ee66a5df717e7d9ed15cbbfa5e3d8d607c39f1;hpb=d3f9b63d9227cc2fb7b978e4b40b9592c04852ab;p=uffi.git
diff --git a/doc/ref.sgml b/doc/ref.sgml
index 82ee66a..827ac07 100644
--- a/doc/ref.sgml
+++ b/doc/ref.sgml
@@ -96,8 +96,12 @@ dereferenced :char pointer returns an character.
pointer returns an character.
- :byte - Unsigned 8-bits. A
+ :byte - Signed 8-bits. A
dereferenced :byte pointer returns an integer.
+
+
+ :unsigned-byte - Unsigned 8-bits. A
+dereferenced :unsigned-byte pointer returns an integer.
:short - Signed 16-bits.
@@ -315,7 +319,7 @@ abstracts the difference in implementations where some return a
Examples
-(def-array ca :char)
+(def-array-pointer ca :unsigned-char)
(let ((fs (convert-to-foreign-string "ab")))
(values (null-char-p (deref-array fs 'ca 0))
(null-char-p (deref-array fs 'ca 2))))
@@ -640,17 +644,17 @@ structure. It's type is :pointer-self.
-
+
- def-array
- Defines a foreign array type.
+ def-array-pointer
+ Defines a pointer to a array of type.
Macro
Syntax
- def-array name type
+ def-array-pointer name type
@@ -675,13 +679,13 @@ structure. It's type is :pointer-self.
Description
- Defines a foreign array type.
+ Defines a type tat is a pointer to an array of type.
Examples
-(def-array byte-array :unsigned-char)
+(def-array-pointer byte-array-pointer :unsigned-char)
@@ -868,7 +872,7 @@ can be freed.
Syntax
- allocate-foreign-object type => ptr
+ allocate-foreign-object type &optional size => ptr
@@ -877,7 +881,15 @@ can be freed.
type
- A type of foreign object to allocate.
+ The type of foreign object to allocate. This parameter is evaluated.
+
+
+
+
+ size
+
+ An optional size parameter that is evaluated. If specified, allocates and returns an
+array of type that is size members long. This parameter is evaluated.
@@ -900,7 +912,7 @@ can be freed.
Examples
(def-struct ab (a :int) (b :double))
-(allocate-foreign-object ab)
+(allocate-foreign-object 'ab)
=> #<ptr>
@@ -965,6 +977,134 @@ can be freed.
+
+
+ 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.
+
+
+
+
+
+ size-of-foreign-type
+ Returns the number of data bytes used by a foreign object type.
+
+ Macro
+
+
+ Syntax
+
+ size-of-foreign-type ftype
+
+
+
+ Arguments and Values
+
+
+ ftype
+
+ A foreign type specifier. This parameter is evaluated.
+
+
+
+
+
+
+ Description
+
+ Returns the number of data bytes used by a foreign object type. This does not include any Lisp storage overhead.
+
+
+
+ Examples
+
+
+(size-of-foreign-object :unsigned-byte)
+=> 1
+(size-of-foreign-object 'my-100-byte-vector-type)
+=> 100
+
+
+
+
+ Side Effects
+ None.
+
+ Affected by
+ None.
+
+
+ Exceptional Situations
+ None.
+
+
+
pointer-address
@@ -1093,7 +1233,7 @@ can be freed.
ensure-char-character
- Ensures that a dereferenced :char pointer is
+ Ensures that a dereferenced :char pointer is
a character.
Macro
@@ -1161,7 +1301,7 @@ integer.
ensure-char-integer
- Ensures that a dereferenced :char pointer is
+ Ensures that a dereferenced :char pointer is
an integer.
Macro
@@ -1947,6 +2087,91 @@ a session.
+
+
+ find-foreign-library
+ Finds a foreign library file.
+
+ Function
+
+
+ Syntax
+
+ find-foreign-library names directories & drive-letters types => path
+
+
+
+ Arguments and Values
+
+
+ names
+
+ A string or list of strings containing the base name of the library file.
+
+
+
+
+ directories
+
+ A string or list of strings containing the directory the library file.
+
+
+
+
+ drive-letters
+
+ A string or list of strings containing the drive letters for the library file.
+
+
+
+
+ types
+
+ A string or list of strings containing the file type of the library file. Default
+is &nil;. If &nil;, will use a default type based on the currently running implementation.
+
+
+
+
+ path
+
+ A path containing the path found, or &nil; if the library file was not found.
+
+
+
+
+
+
+ Description
+ Finds a foreign library by searching through a number of possible locations. Returns
+the path of the first found file.
+
+
+
+ Examples
+
+(find-foreign-library '("libmysqlclient" "libmysql")
+ '("/opt/mysql/lib/mysql/" "/usr/local/lib/" "/usr/lib/" "/mysql/lib/opt/")
+ :types '("so" "dll")
+ :drive-letters '("C" "D" "E"))
+=> #P"D:\\mysql\\lib\\opt\\libmysql.dll"
+
+
+
+ Side Effects
+ None.
+
+
+
+ Affected by
+ None.
+
+
+ Exceptional Situations
+ None.
+
+
+