X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=doc%2Fref.sgml;h=732204a47c7f6de8fd3eb8c686a1592333db5681;hb=8d16d732a80b76c913f4b62b9fe043af39e5bce2;hp=714d8e99ca665e0f9a6500129b380dad5412ae0d;hpb=1796f8c038481234982c983cb0ee611c3ffac4c6;p=uffi.git diff --git a/doc/ref.sgml b/doc/ref.sgml index 714d8e9..732204a 100644 --- a/doc/ref.sgml +++ b/doc/ref.sgml @@ -315,7 +315,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 +640,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 +675,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) @@ -877,7 +877,7 @@ can be freed. type - A unevaluated type of foreign object to allocate. + The type of foreign object to allocate. This parameter is evaluated. @@ -908,7 +908,7 @@ array of type that is size members Examples (def-struct ab (a :int) (b :double)) -(allocate-foreign-object ab) +(allocate-foreign-object 'ab) => #<ptr> @@ -973,6 +973,79 @@ array of type that is size members + + + 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. + + + pointer-address @@ -1101,7 +1174,7 @@ array of type that is size members ensure-char-character - Ensures that a dereferenced :char pointer is + Ensures that a dereferenced :char pointer is a character. Macro @@ -1169,7 +1242,7 @@ integer. ensure-char-integer - Ensures that a dereferenced :char pointer is + Ensures that a dereferenced :char pointer is an integer. Macro