X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;ds=sidebyside;f=doc%2Fref.sgml;h=dd0e05a3e1cfaa9e366f3b3ab49c4c1dd6f57e76;hb=6dfe1d55f312dd6b802004705bcaf0509f7d5414;hp=cbf5336613c678cbf354dee67f10c2463dac9c63;hpb=77fd04d570b9ae1fd40c1f7b0134af826576210b;p=uffi.git
diff --git a/doc/ref.sgml b/doc/ref.sgml
index cbf5336..dd0e05a 100644
--- a/doc/ref.sgml
+++ b/doc/ref.sgml
@@ -1515,7 +1515,7 @@ if a cstring returned by a function is &null;.
Syntax
- with-cast-pointer binding-name ptr type & body body => value
+ with-cast-pointer (binding-name ptr type) & body body => value
@@ -1547,11 +1547,11 @@ if a cstring returned by a function is &null;.
Description
- Executes BODY with POINTER casted to be a pointer to type TYPE. If
- BINDING-NAME is provided the casted pointer will be bound to this
+ 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
- casted. This name will be bound to the casted pointer during the
+ 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
@@ -1562,6 +1562,136 @@ if a cstring returned by a function is &null;.
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.