X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;ds=sidebyside;f=doc%2Fref.sgml;h=dd0e05a3e1cfaa9e366f3b3ab49c4c1dd6f57e76;hb=6dfe1d55f312dd6b802004705bcaf0509f7d5414;hp=510dd4ca3a64351ce68ad4c22e25e95db7680d9a;hpb=2ba109a5fd136bbef29b618a1d60e63fae971187;p=uffi.git
diff --git a/doc/ref.sgml b/doc/ref.sgml
index 510dd4c..dd0e05a 100644
--- a/doc/ref.sgml
+++ b/doc/ref.sgml
@@ -759,7 +759,7 @@ the array.
Examples
-(def-array ca :char)
+(def-array-pointer ca :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))))
@@ -767,6 +767,14 @@ the array.
&t;
+
+ Notes
+
+ The TYPE argument is ignored for CL implementations other than
+ AllegroCL. If you want to cast a pointer to another type use
+ WITH-CAST-POINTER together with DEREF-POINTER/DEREF-ARRAY.
+
+
Side Effects
None.
@@ -1216,6 +1224,14 @@ much better with static allocation.
+
+ Notes
+
+ The TYPE argument is ignored for CL implementations other than
+ AllegroCL. If you want to cast a pointer to another type use
+ WITH-CAST-POINTER together with DEREF-POINTER/DEREF-ARRAY.
+
+
Side Effects
None.
@@ -1266,8 +1282,9 @@ a character.
Description
- Ensures that an object obtained by dereferencing a
-:char pointer is a character.
+ Ensures that an objects obtained by dereferencing
+:char and :unsigned-char
+pointers are a lisp character.
@@ -1488,6 +1505,207 @@ if a cstring returned by a function is &null;.
+
+
+ with-cast-pointer
+ Wraps a body of code with a pointer cast to a new type.
+
+ Macro
+
+
+ Syntax
+
+ with-cast-pointer (binding-name ptr type) & body body => value
+
+
+
+ Arguments and Values
+
+
+ ptr
+
+ A pointer to a foreign object.
+
+
+
+
+ type
+
+ A foreign type of the object being pointed to.
+
+
+
+
+ value
+
+ The value of the object where the pointer points.
+
+
+
+
+
+
+ Description
+
+ Executes BODY with POINTER cast to be a pointer to type TYPE. If
+ BINDING-NAME is provided the cast pointer will be bound to this
+ name during the execution of BODY. If BINDING-NAME is not provided
+ POINTER must be a name bound to the pointer which should be
+ cast. This name will be bound to the cast pointer during the
+ execution of BODY.
+
+ This is a no-op in AllegroCL but will wrap BODY in a LET form if
+ BINDING-NAME is provided.
+
+ This macro is meant to be used in conjunction with DEREF-POINTER or
+ DEREF-ARRAY. In Allegro CL the "cast" will actually take place in
+ DEREF-POINTER or DEREF-ARRAY.
+
+
+
+ Examples
+
+(with-foreign-object (size :int)
+ ;; FOO is a foreign function returning a :POINTER-VOID
+ (let ((memory (foo size)))
+ (when (mumble)
+ ;; at this point we know for some reason that MEMORY points
+ ;; to an array of unsigned bytes
+ (with-cast-pointer (memory :unsigned-byte)
+ (dotimes (i (deref-pointer size :int))
+ (do-something-with
+ (deref-array memory '(:array :unsigned-byte) i)))))))
+
+
+
+ Side Effects
+ None.
+
+
+ Affected by
+ None.
+
+
+ Exceptional Situations
+ None.
+
+
+
+
+
+ def-foreign-var
+
+Defines a symbol macro to access a variable in foreign code
+
+ Macro
+
+
+ Syntax
+
+ def-foreign-var name type module
+
+
+
+ Arguments and Values
+
+
+ name
+
+
+A string or list specificying the symbol macro's name. If it is a
+ string, that names the foreign variable. A Lisp name is created
+ by translating #\_ to #\- and by converting to upper-case in
+ case-insensitive Lisp implementations. If it is a list, the first
+ item is a string specifying the foreign variable name and the
+ second it is a symbol stating the Lisp name.
+
+
+
+
+ type
+
+ A foreign type of the foreign variable.
+
+
+
+
+ module
+
+
+ A string specifying the module (or library) the foreign variable
+ resides in. (Required by Lispworks)
+
+
+
+
+
+
+ Description
+
+Defines a symbol macro which can be used to access (get and set) the
+value of a variable in foreign code.
+
+
+
+ Examples
+
+ C code
+
+ int baz = 3;
+
+ typedef struct {
+ int x;
+ double y;
+ } foo_struct;
+
+ foo_struct the_struct = { 42, 3.2 };
+
+ int foo () {
+ return baz;
+ }
+
+
+
+Lisp code
+
+ (uffi:def-struct foo-struct
+ (x :int)
+ (y :double))
+
+ (uffi:def-function ("foo" foo)
+ ()
+ :returning :int
+ :module "foo")
+
+ (uffi:def-foreign-var ("baz" *baz*) :int "foo")
+ (uffi:def-foreign-var ("the_struct" *the-struct*) foo-struct "foo")
+
+
+*baz*
+ => 3
+
+(incf *baz*)
+ => 4
+
+(foo)
+ => 4
+
+
+
+
+ Side Effects
+ None.
+
+
+ Affected by
+ None.
+
+
+ Exceptional Situations
+ None.
+
+
+
@@ -2074,7 +2292,7 @@ foreign function. If :void indicates module does not return
Syntax
- load-foreign-library filename &key module supporting-libraries => success
+ load-foreign-library filename &key module supporting-libraries force-load => success
@@ -2105,6 +2323,13 @@ link the foreign library. (Required by CMUCL)
+
+ force-load
+
+ Forces the loading of the library if it has been previously loaded.
+
+
+
success
@@ -2120,7 +2345,7 @@ otherwise &nil;.
Description
Loads a foreign library. Applies a module name to functions
within the library. Ensures that a library is only loaded once during
-a session.
+a session. A library can be reloaded by using the :force-load key.