X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=doc%2Fref.sgml;h=103363a2a6624cd62b2fd5e3d8ec1c340a7d8ed5;hb=4d0afb9bedcc103e882dce47d0cdc57a0b79e433;hp=6b794780a597b65a281d9797d9656b44053be9bc;hpb=b130d8ce7ea8f259f1f6c037693dee789f86570a;p=uffi.git diff --git a/doc/ref.sgml b/doc/ref.sgml index 6b79478..103363a 100644 --- a/doc/ref.sgml +++ b/doc/ref.sgml @@ -70,9 +70,6 @@ the keyword package. - - :byte - Unsigned 8-bit - :char - Signed 8-bits @@ -98,26 +95,19 @@ :unsigned-long - Unsigned 32-bits - :single-float - 32-bit floating point + :float - 32-bit floating point - :double-float - 64-bit floating point + :double - 64-bit floating point - - - :cstring - - - A null-terminated string used for passing and returning with a function. - + :cstring - +A null-terminated string used for passing and returning with a function. + - - - :void - - - An absence of a value. Used in generic pointers and in - return types from functions. + :void - +The absence of a value. Used in generic pointers and in return types from functions. * - Used to declare a pointer to an object @@ -210,6 +200,12 @@ Objects + + Overview + + Objects are entities that can allocated and freed. + + allocate-foreign-object @@ -277,8 +273,8 @@ always need to have memory for them. convert-to-cstring Converts a Lisp string to a - cstring. These - cstring's should be freed with + cstring. The + cstring should be freed with free-cstring. @@ -294,6 +290,22 @@ always need to have memory for them. Binds a lexical variable to a newly allocated cstring. Automatically frees cstring. + + Examples + + +(def-function ("getenv" c-getenv) + ((name :cstring)) + :returning :cstring) + +(defun getenv (key) + "Returns an environment variable, or NIL if it does not exist" + (check-type key string) + (with-cstring (key-cstring key) + (convert-from-cstring (c-getenv key-cstring)))) + + + covert-from-foreign-string @@ -320,12 +332,79 @@ always need to have memory for them. Functions - - def-function - - This macro generates a &c; function definition. + + + def-function + Declares a function. + + Macro + + + Syntax + + def-function name args &key module returning + + + + Arguments and Values + + + name + + A string or list specificying the function name. If it is a string, that names the foreign function. 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 function name and the second it is a symbol stating the Lisp name. + + + + + args + + A list of argument declarations. Use &nil; to specify no arguments. + + + + + module + + A string specifying which module (or library) that the foreign function resides. (Required by Lispworks) + + + + returning + + A declaration specifying the result type of the +foreign function. + + + + + + + Description + Declares a foreign function. - + + + Examples + +(def-function "gethostname" + ((name :cstring) + (len :int)) + :returning :int) + + + + Side Effects + None. + + + Affected by + None. + + + Exceptional Situations + None. + +