r1538: *** empty log message ***
authorKevin M. Rosenberg <kevin@rosenberg.net>
Sun, 10 Mar 2002 17:43:56 +0000 (17:43 +0000)
committerKevin M. Rosenberg <kevin@rosenberg.net>
Sun, 10 Mar 2002 17:43:56 +0000 (17:43 +0000)
doc/Makefile
doc/ref.sgml
examples/getenv.cl
src/immediates.cl
tests/getenv.cl

index 63e83e02d11daa86d8b4f26272df8345f251c800..baccb857f5b8657c33072e79986a75fc0139d32c 100644 (file)
@@ -5,7 +5,7 @@
 #  Programer:    Kevin M. Rosenberg
 #  Date Started: Mar 2002
 #
-#  CVS Id:   $Id: Makefile,v 1.3 2002/03/10 12:54:01 kevin Exp $
+#  CVS Id:   $Id: Makefile,v 1.4 2002/03/10 17:43:56 kevin Exp $
 #
 #  Copyright (c) 2002 by Kevin M. Rosenberg
 #
 DSSSL_HTML=/usr/share/sgml/docbook/dsssl-stylesheets-1.76/html/docbook.dsl 
 DSSSL_PRINT=/usr/share/sgml/docbook/dsssl-stylesheets-1.76/print/docbook.dsl
 
+# Custom version
+#DSSSL_HTML=/home/kevin/lisp/docbook/html/lisp.dsl
+#DSSSL_PRINT=/home/kevin/lisp/docbook/print/lisp.dsl
+
 # Nothing to configure beyond this point
 
 DOCFILE_BASE_DEFAULT=uffi
index 6b794780a597b65a281d9797d9656b44053be9bc..103363a2a6624cd62b2fd5e3d8ec1c340a7d8ed5 100644 (file)
@@ -70,9 +70,6 @@
          the keyword package.
        </para>
        <itemizedlist>
-         <listitem>
-           <para><constant>:byte</constant> - Unsigned 8-bit</para>
-         </listitem>
          <listitem>
            <para><constant>:char</constant> - Signed 8-bits</para>
          </listitem>
            <para><constant>:unsigned-long</constant> - Unsigned 32-bits</para>
          </listitem>
          <listitem>
-           <para><constant>:single-float</constant> - 32-bit floating point</para>
+           <para><constant>:float</constant> - 32-bit floating point</para>
          </listitem>
          <listitem>
-           <para><constant>:double-float</constant> - 64-bit floating point</para>
+           <para><constant>:double</constant> - 64-bit floating point</para>
          </listitem>
          <listitem>
-           <para>
-             <constant>
-               :cstring
-             </constant> 
-             - A null-terminated string used for passing and returning with a function.
-             </para>
+           <para><constant>:cstring</constant> - 
+A null-terminated string used for passing and returning with a function.
+           </para>
          </listitem>
          <listitem>
-           <para>
-             <constant>
-               :void
-             </constant> 
-             - An absence of a value. Used in generic pointers and in
-             return types from functions.</para>
+           <para><constant>:void</constant> - 
+The absence of a value. Used in generic pointers and in return types from functions.</para>
          </listitem>
          <listitem>
            <para><constant>*</constant> - Used to declare a pointer to an object</para>
 
     <sect1>
       <title>Objects</title>
+      <sect2>
+       <title>Overview</title>
+       <para>
+         Objects are entities that can allocated and freed.
+       </para>
+      </sect2>
       <sect2>
        <title>allocate-foreign-object</title>
        <para>
@@ -277,8 +273,8 @@ always need to have memory for them.
        <title>convert-to-cstring</title>
        <para>
          Converts a Lisp string to a
-         <varname>cstring</varname>. These
-         <varname>cstring's</varname> should be freed with
+         <varname>cstring</varname>. The
+         <varname>cstring</varname> should be freed with
          <function>free-cstring</function>.
        </para>
       </sect2>
@@ -294,6 +290,22 @@ always need to have memory for them.
        <para>
          Binds a lexical variable to a newly allocated <varname>cstring</varname>. Automatically frees <varname>cstring</varname>.
        </para>
+       <sect3>
+         <title>Examples</title>
+         <para>
+           <programlisting>
+(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))))
+         </programlisting>
+       </para>
+      </sect3>
       </sect2>
       <sect2>
        <title>covert-from-foreign-string</title>
@@ -320,12 +332,79 @@ always need to have memory for them.
 
     <sect1>
       <title>Functions</title>
-      <sect2>
-       <title>def-function</title>
-       <para>
-         This macro generates a &c; function definition.
+      <refentry id="def-function">
+       <refnamediv>
+         <refname>def-function</refname>
+       <refpurpose>Declares a function. 
+       </refpurpose>
+       <refclass>Macro</refclass>
+      </refnamediv>
+      <refsect1>
+       <title>Syntax</title>
+<synopsis>
+         <function>def-function</function> <replaceable>name args &amp;key module returning</replaceable>
+</synopsis>
+      </refsect1>
+      <refsect1>
+       <title>Arguments and Values</title>
+       <variablelist>
+         <varlistentry>
+           <term><parameter>name</parameter></term>
+           <listitem>
+             <para>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.
+             </para>
+           </listitem>
+         </varlistentry>
+         <varlistentry>
+           <term><parameter>args</parameter></term>
+           <listitem>
+             <para>A list of argument declarations. Use &nil; to specify no arguments.
+             </para>
+           </listitem>
+         </varlistentry>
+         <varlistentry>
+           <term><parameter>module</parameter></term>
+           <listitem>
+             <para>A string specifying which module (or library) that the foreign function resides. (Required by Lispworks)</para>
+           </listitem>
+         </varlistentry>
+         <varlistentry>
+           <term><returnvalue>returning</returnvalue></term>
+           <listitem>
+             <para>A declaration specifying the result type of the
+foreign function.
+             </para>
+           </listitem>
+         </varlistentry>
+       </variablelist>
+      </refsect1>
+      <refsect1>
+       <title>Description</title>
+       <para>Declares a foreign function.
        </para>
-      </sect2>
+      </refsect1>
+      <refsect1>
+       <title>Examples</title>
+       <programlisting>
+(def-function "gethostname" 
+  ((name :cstring)
+   (len :int))
+  :returning :int)
+       </programlisting>
+      </refsect1>
+      <refsect1>
+       <title>Side Effects</title>
+       <para>None.</para>
+      </refsect1>
+      <refsect1>
+       <title>Affected by</title>
+       <para>None.</para>
+      </refsect1>
+      <refsect1>
+       <title>Exceptional Situations</title>
+       <para>None.</para>
+      </refsect1>
+    </refentry>
     </sect1>
 
     <sect1>
index c6da2a0c9bff1cefaaa8014f708f7e920feae498..043e7fca72ed6b93d0704d344f0c0dff05ec1e5f 100644 (file)
@@ -9,7 +9,7 @@
 ;;;;
 ;;;; Copyright (c) 2002 Kevin M. Rosenberg
 ;;;;
-;;;; $Id: getenv.cl,v 1.5 2002/03/10 11:13:07 kevin Exp $
+;;;; $Id: getenv.cl,v 1.6 2002/03/10 17:42:35 kevin Exp $
 ;;;;
 ;;;; This file is part of UFFI. 
 ;;;;
@@ -38,8 +38,7 @@
   "Returns an environment variable, or NIL if it does not exist"
   (check-type key string)
   (uffi:with-cstring (key-native key)
-    (let ((value-cstring (c-getenv key-native)))
-      (uffi:convert-from-cstring value-cstring))))
+    (uffi:convert-from-cstring (c-getenv key-native))))
     
 #+test-uffi
 (progn
index ae1013cf412a90ae758bf9d02485ecf9f983648e..4dcfec6de6d4ecf84c15d222bee22c50712b36fc 100644 (file)
@@ -9,7 +9,7 @@
 ;;;;
 ;;;; Copyright (c) 2002 Kevin M. Rosenberg
 ;;;;
-;;;; $Id: immediates.cl,v 1.3 2002/03/10 11:13:07 kevin Exp $
+;;;; $Id: immediates.cl,v 1.4 2002/03/10 17:42:35 kevin Exp $
 ;;;;
 ;;;; This file is part of the UFFI. 
 ;;;;
@@ -74,6 +74,7 @@ supports this."
 (defconstant +cmu-def-type-list+
     '((:char . (alien:signed 8))
       (:unsigned-char . (alien:unsigned 8))
+      (:byte . (alien:unsigned 8))
       (:short . (alien:signed 16))
       (:unsigned-short . (alien:unsigned 16))
       (:int . (alien:signed 32))
@@ -90,7 +91,9 @@ supports this."
       (:short . c-call:short)
       (:pointer-void . (* t))
       (:cstring . c-call:cstring)
-      (:char . c-call:char) (:unsigned-char . (alien:unsigned 8))
+      (:char . c-call:char) 
+      (:unsigned-char . (alien:unsigned 8))
+      (:byte . (alien:unsigned 8))
       (:int . alien:integer) (:unsigned-int . c-call:unsigned-int) 
       (:long . c-call:long) (:unsigned-long . c-call:unsigned-long)
       (:float . c-call:float) (:double . c-call:double)
@@ -101,7 +104,9 @@ supports this."
       (:short . :short)
       (:pointer-void . (* :void))
       (:cstring . (* :char))
-      (:char . :char) (:unsigned-char . :unsigned-char)
+      (:char . :char)
+      (:unsigned-char . :unsigned-char)
+      (:byte . :byte)
       (:int . :int) (:unsigned-int . :unsigned-int) 
       (:long . :long) (:unsigned-long . :unsigned-long)
       (:float . :float) (:double . :double)
@@ -112,7 +117,8 @@ supports this."
       (:short . :short)
       (:pointer-void . (:pointer :void))
       (:cstring . (:pointer :char))
-      (:char . :char) (:unsigned-char . (:unsigned :char))
+      (:char . :char) 
+      (:unsigned-char . (:unsigned :char))
       (:int . :int) (:unsigned-int . (:unsigned :int))
       (:long . :long) (:unsigned-long . (:unsigned :long))
       (:float . :float) (:double . :double)
index c6da2a0c9bff1cefaaa8014f708f7e920feae498..043e7fca72ed6b93d0704d344f0c0dff05ec1e5f 100644 (file)
@@ -9,7 +9,7 @@
 ;;;;
 ;;;; Copyright (c) 2002 Kevin M. Rosenberg
 ;;;;
-;;;; $Id: getenv.cl,v 1.5 2002/03/10 11:13:07 kevin Exp $
+;;;; $Id: getenv.cl,v 1.6 2002/03/10 17:42:35 kevin Exp $
 ;;;;
 ;;;; This file is part of UFFI. 
 ;;;;
@@ -38,8 +38,7 @@
   "Returns an environment variable, or NIL if it does not exist"
   (check-type key string)
   (uffi:with-cstring (key-native key)
-    (let ((value-cstring (c-getenv key-native)))
-      (uffi:convert-from-cstring value-cstring))))
+    (uffi:convert-from-cstring (c-getenv key-native))))
     
 #+test-uffi
 (progn