r1546: *** empty log message ***
authorKevin M. Rosenberg <kevin@rosenberg.net>
Mon, 11 Mar 2002 18:00:57 +0000 (18:00 +0000)
committerKevin M. Rosenberg <kevin@rosenberg.net>
Mon, 11 Mar 2002 18:00:57 +0000 (18:00 +0000)
ChangeLog
Makefile
doc/notes.sgml
doc/ref.sgml
examples/gettime.cl
examples/strtol.cl
set-logical.cl [new file with mode: 0644]
src/primitives.cl
tests/gettime.cl
tests/strtol.cl
uffi.system

index 3f0291b06f67dace65a45d5c36ae606f38e16fbd..fddee6331a47487cc232c4419057701ff4285ea2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+11 Mar 2002
+
+       * Changed def-type to def-foreign-type
+
+       * Created new macro def-type to generate cl:deftype forms. Removed
+       uffi-declare and uffi-slot-type as they are no longer necessary.
+        
 10 Mar 2002
 
        * Modified input parameters to load-foreign-library
index 51dd113b549308ce2c41073403ccedfc8ad9c8cf..41ac5b3b8d7d4fd88716c1024acdad2db353b6fa 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -5,7 +5,7 @@
 #  Programer:    Kevin M. Rosenberg, M.D.
 #  Date Started: Mar 2002
 #
-#  CVS Id:   $Id: Makefile,v 1.10 2002/03/10 21:48:50 kevin Exp $
+#  CVS Id:   $Id: Makefile,v 1.11 2002/03/11 18:00:57 kevin Exp $
 #
 #  Copyright (c) 2002 by Kevin M. Rosenberg
 #
@@ -41,12 +41,12 @@ realclean: clean
 docs:
        @(cd doc; make dist-doc)
 
-VERSION=0.2.2
+VERSION=0.2.3
 DISTDIR=uffi-${VERSION}
 DIST_TARBALL=${DISTDIR}.tar.gz
 DIST_ZIP=${DISTDIR}.zip
 SOURCE_FILES=src doc examples Makefile COPYING COPYRIGHT README \
-        INSTALL uffi.lsm ChangeLog NEWS test-examples.cl
+        INSTALL uffi.lsm ChangeLog NEWS test-examples.cl set-logical.cl
 
 dist: realclean docs
        @rm -fr ${DISTDIR} ${DIST_TARBALL} ${DIST_ZIP}
index cdb5f6d8788a7e81bf3a5ecdd28392874f1f461d..c4e86036a66c38184e5fd0ef2df771bf2dcbd997 100644 (file)
@@ -77,8 +77,9 @@
        Here is an example that should both methods being used for
        maximum cross-implementation optimization:
        <programlisting>
+(uffi:def-type the-struct-type-def the-struct-type)
 (let ((a-foreign-struct (allocate-foreign-object 'the-struct-type)))
-  (uffi-declare 'the-struct-type a-foreign-struct)
+  (declare 'the-struct-type-def a-foreign-struct)
   (get-slot-value a-foreign-struct 'the-struct-type 'field-name))
        </programlisting>
       </para>
index 33f8a568d7e317d990aade3ca42ee60cf8efaa09..aaf1feac499abe4fde3a6c841017de27e7a7328e 100644 (file)
        </para>
       </sect2>
 
-      <sect2 id="uffi-declare">
-       <title>uffi-declare</title>
-       <para>
-         This is used wherever a <function>declare</function>
-         expression can be placed. For example:
-       </para>
-       <para>
-         <programlisting>
-(let ((my-structure (uffi:allocate-foreign-object 'a-struct)))
-   (uffi:uffi-declare a-struct my-structure))
-         </programlisting>
-       </para>
-      </sect2>
-
-      <sect2 id="slot-type">
-       <title>slot-type</title>
+      <sect2 id="def-type">
+       <title>def-type</title>
        <para>
-         This is used inside of <function>defclass</function> and
-         <function>defstruct</function> expressions to set the type
-         for a field. Because the type identifier is not evaluated in
-         &cl;, the expression must be backquoted for effect. For
-         example:
-       </para>
+         This is used wherever a &cl; <function>deftype</function>
+         expression can be placed. Used to declare types to
+the compiler for optimization. Currently, on &cmucl; takes advantage
+of this.       </para>
        <para>
          <programlisting>
-(eval 
-  `(defclass a-class ()
-     ((char-ptr :type ,(uffi:slot-type (* :char))))))
+(uffi:def-type my-struct-def my-struct-foreign-type)
          </programlisting>
        </para>
       </sect2>
index a0933066ff32b500401cf2c29e92764607318959..1c644217ed56c226882e81d96026eb157c7dd31e 100644 (file)
@@ -9,7 +9,7 @@
 ;;;;
 ;;;; Copyright (c) 2002 Kevin M. Rosenberg
 ;;;;
-;;;; $Id: gettime.cl,v 1.4 2002/03/10 22:29:47 kevin Exp $
+;;;; $Id: gettime.cl,v 1.5 2002/03/11 18:00:57 kevin Exp $
 ;;;;
 ;;;; This file is part of UFFI. 
 ;;;;
@@ -29,7 +29,7 @@
 
 (in-package :cl-user)
 
-(uffi:def-type time-t :unsigned-long)
+(uffi:def-foreign-type time-t :unsigned-long)
 
 (uffi:def-struct tm
     (sec :int)
     ((time (* time-t)))
   :returning (* tm))
 
+(uffi:def-type time-t :unsigned-long)
+(uffi:def-type tm-pointer (* tm))
+
 (defun gettime ()
-  "Returns the local time"
-  (let* ((time (uffi:allocate-foreign-object time-t)))
-;;    (uffi:uffi-declare time-t time)
-    (c-time time)
-    (let ((tm-ptr (c-localtime time)))
-;;      (uffi:uffi-declare (* tm) tm-ptr)
-      (let ((time-string (format nil "~2d/~2,'0d/~d ~2d:~2,'0d:~2,'0d" 
-                                (1+ (uffi:get-slot-value tm-ptr 'tm 'mon))
-                                (uffi:get-slot-value tm-ptr 'tm 'mday)
-                                (+ 1900 (uffi:get-slot-value tm-ptr 'tm 'year))
-                                (uffi:get-slot-value tm-ptr 'tm 'hour)
-                                (uffi:get-slot-value tm-ptr 'tm 'min)
-                                (uffi:get-slot-value tm-ptr 'tm 'sec)
-                                )))
-       (uffi:free-foreign-object time)
-       time-string))
-    ))
+   "Returns the local time"
+   (let* ((time (uffi:allocate-foreign-object time-t)))
+     (declare (type time-t time))
+     (c-time time)
+     (let ((tm-ptr (the tm-pointer (c-localtime time))))
+       (declare (type tm-pointer tm-ptr))
+       (let ((time-string (format nil "~2d/~2,'0d/~d ~2d:~2,'0d:~2,'0d" 
+                                 (1+ (uffi:get-slot-value tm-ptr 'tm 'mon))
+                                 (uffi:get-slot-value tm-ptr 'tm 'mday)
+                                 (+ 1900 (uffi:get-slot-value tm-ptr 'tm 'year))
+                                 (uffi:get-slot-value tm-ptr 'tm 'hour)
+                                 (uffi:get-slot-value tm-ptr 'tm 'min)
+                                 (uffi:get-slot-value tm-ptr 'tm 'sec)
+                                 )))
+        (uffi:free-foreign-object time)
+        time-string))
+     ))
+
+
+
 
 #+test-uffi
 (format t "~&~A" (gettime))
index 518eb2909fa102b95ef93f48a3e7136199d98bd3..57d2b45b37166bd207d8e6a2223aed439e479e1b 100644 (file)
@@ -9,7 +9,7 @@
 ;;;;
 ;;;; Copyright (c) 2002 Kevin M. Rosenberg
 ;;;;
-;;;; $Id: strtol.cl,v 1.6 2002/03/10 11:13:07 kevin Exp $
+;;;; $Id: strtol.cl,v 1.7 2002/03/11 18:00:57 kevin Exp $
 ;;;;
 ;;;; This file is part of UFFI. 
 ;;;;
@@ -29,7 +29,7 @@
 
 (in-package :cl-user)
 
-(uffi:def-type char-ptr (* :char))
+(uffi:def-foreign-type char-ptr (* :char))
   
 ;; This example does not use :cstring to pass the input string since
 ;; the routine needs to do pointer arithmetic to see how many characters
diff --git a/set-logical.cl b/set-logical.cl
new file mode 100644 (file)
index 0000000..228023a
--- /dev/null
@@ -0,0 +1,75 @@
+;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*-
+;;;; *************************************************************************
+;;;; FILE IDENTIFICATION
+;;;;
+;;;; Name:          set-logical.cl
+;;;; Purpose:       Sets a logical host for src/binaries based on a pathname.
+;;;; Programmer:    Kevin M. Rosenberg
+;;;; Date Started:  Feb 2002
+;;;;
+;;;; Copyright (c) 2002 Kevin M. Rosenberg
+;;;;
+;;;; $Id: set-logical.cl,v 1.1 2002/03/11 18:00:57 kevin Exp $
+;;;;
+;;;; This file is part of UFFI. 
+;;;;
+;;;; UFFI is free software; you can redistribute it and/or modify
+;;;; it under the terms of the GNU General Public License (version 2) as
+;;;; published by the Free Software Foundation.
+;;;;
+;;;; UFFI is distributed in the hope that it will be useful,
+;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;;; GNU General Public License for more details.
+;;;;
+;;;; You should have received a copy of the GNU General Public License
+;;;; along with UFFI; if not, write to the Free Software Foundation, Inc.,
+;;;; 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+;;;; *************************************************************************
+
+
+;;; Setup logical pathname translaton with separate binary directories
+;;; for each implementation
+
+;; push allegro case sensitivity on *features*
+#+allegro
+(eval-when (:compile-toplevel :load-toplevel :execute)
+  (if (or (eq excl:*current-case-mode* :case-sensitive-lower)
+         (eq excl:*current-case-mode* :case-sensitive-upper))
+      (pushnew :case-sensitive cl:*features*)
+    (pushnew :case-insensitive cl:*features*)))
+
+(defconstant +set-logical-compiler-name+
+    #+(and allegro ics case-sensitive) "acl-modern"
+    #+(and allegro (not ics) case-sensitive) "acl-modern8"
+    #+(and allegro ics (not case-sensitive)) "acl-ansi"
+    #+(and allegro (not ics) (not case-sensitive)) "acl-ansi8"
+    #+lispworks "lispworks"
+    #+clisp "clisp"
+    #+cmu "cmucl"
+    #+sbcl "sbcl"
+    #+corman "corman"
+    #+mcl "mcl"
+    #-(or allegro lispworks clisp cmu sbcl corman mcl) "unknown")
+
+(defun set-logical-host-for-pathname (host base-pathname)
+  (setf (logical-pathname-translations host)
+    `(("ROOT;" ,(make-pathname
+               :host (pathname-host base-pathname)
+               :device (pathname-device base-pathname)
+               :directory (pathname-directory base-pathname)))
+      ("**;bin;*.*.*" ,(merge-pathnames
+                       (make-pathname 
+                        :name :wild
+                        :type :wild
+                        :directory 
+                        (append '(:relative :wild-inferiors
+                                  ".bin" #.+set-logical-compiler-name+)))
+                       base-pathname))
+      ("**;*.*.*" ,(merge-pathnames
+                   (make-pathname
+                    :name :wild
+                    :type :wild
+                    :directory '(:relative :wild-inferiors))
+                   base-pathname))))
+  )
index a0bcae74361768916e7d066a5478042d07e90830..1df69e1cbdf5ecb3c4ba3288d2ee073518df62ca 100644 (file)
@@ -9,7 +9,7 @@
 ;;;;
 ;;;; Copyright (c) 2002 Kevin M. Rosenberg
 ;;;;
-;;;; $Id: primitives.cl,v 1.2 2002/03/10 22:29:47 kevin Exp $
+;;;; $Id: primitives.cl,v 1.3 2002/03/11 18:00:57 kevin Exp $
 ;;;;
 ;;;; This file is part of the UFFI. 
 ;;;;
      (defconstant ,name ,value)
      (export ',name)))
 
-(defmacro uffi-declare (type name)
-  "Generates a declare statement for CL. Currently, only CMUCL
-supports this."
+(defmacro def-type (name type)
+  "Generates a (deftype) statement for CL. Currently, only CMUCL
+supports takes advantage of this optimization."
   #+(or lispworks allegro)
-  (declare (ignore type name))
+  `(deftype ,name () t)
   #+cmu
-  `(declare (type (alien:alien ,type)) ,name)
+  `(deftype ,name () '(alien:alien ,(convert-from-uffi-type type :declare)))
   )
 
-(defmacro slot-type (type)
-  #+(or lispworks allegro)
-  (declare (ignore type))
-  #+(or lispworks allegro)
-  t
-  #+cmu `'(alien:alien ,type))
-
 (defmacro null-char-p (val)
   `(if (or (eql ,val 0)
           (eq ,val #\Null))
@@ -59,7 +52,7 @@ supports this."
     nil))
 
       
-(defmacro def-type (name type)
+(defmacro def-foreign-type (name type)
   #+lispworks `(fli:define-c-typedef ,name ,(convert-from-uffi-type type :type))
   #+allegro `(ff:def-foreign-type ,name ,(convert-from-uffi-type type :type))
   #+cmu `(alien:def-alien-type ,name ,(convert-from-uffi-type type :type))
@@ -131,7 +124,7 @@ supports this."
 (dolist (type +cmu-def-type-list+)
   (setf (gethash (car type) +cmu-def-type-hash+) (cdr type)))
 
-(defun ph (&optional (os *standard-output*))
+(defmethod ph (&optional (os *standard-output*))
   (maphash #'(lambda (k v) (format os "~&~S => ~S" k v)) +type-conversion-hash+))
 
 (defun convert-from-uffi-type (type context)
index a0933066ff32b500401cf2c29e92764607318959..1c644217ed56c226882e81d96026eb157c7dd31e 100644 (file)
@@ -9,7 +9,7 @@
 ;;;;
 ;;;; Copyright (c) 2002 Kevin M. Rosenberg
 ;;;;
-;;;; $Id: gettime.cl,v 1.4 2002/03/10 22:29:47 kevin Exp $
+;;;; $Id: gettime.cl,v 1.5 2002/03/11 18:00:57 kevin Exp $
 ;;;;
 ;;;; This file is part of UFFI. 
 ;;;;
@@ -29,7 +29,7 @@
 
 (in-package :cl-user)
 
-(uffi:def-type time-t :unsigned-long)
+(uffi:def-foreign-type time-t :unsigned-long)
 
 (uffi:def-struct tm
     (sec :int)
     ((time (* time-t)))
   :returning (* tm))
 
+(uffi:def-type time-t :unsigned-long)
+(uffi:def-type tm-pointer (* tm))
+
 (defun gettime ()
-  "Returns the local time"
-  (let* ((time (uffi:allocate-foreign-object time-t)))
-;;    (uffi:uffi-declare time-t time)
-    (c-time time)
-    (let ((tm-ptr (c-localtime time)))
-;;      (uffi:uffi-declare (* tm) tm-ptr)
-      (let ((time-string (format nil "~2d/~2,'0d/~d ~2d:~2,'0d:~2,'0d" 
-                                (1+ (uffi:get-slot-value tm-ptr 'tm 'mon))
-                                (uffi:get-slot-value tm-ptr 'tm 'mday)
-                                (+ 1900 (uffi:get-slot-value tm-ptr 'tm 'year))
-                                (uffi:get-slot-value tm-ptr 'tm 'hour)
-                                (uffi:get-slot-value tm-ptr 'tm 'min)
-                                (uffi:get-slot-value tm-ptr 'tm 'sec)
-                                )))
-       (uffi:free-foreign-object time)
-       time-string))
-    ))
+   "Returns the local time"
+   (let* ((time (uffi:allocate-foreign-object time-t)))
+     (declare (type time-t time))
+     (c-time time)
+     (let ((tm-ptr (the tm-pointer (c-localtime time))))
+       (declare (type tm-pointer tm-ptr))
+       (let ((time-string (format nil "~2d/~2,'0d/~d ~2d:~2,'0d:~2,'0d" 
+                                 (1+ (uffi:get-slot-value tm-ptr 'tm 'mon))
+                                 (uffi:get-slot-value tm-ptr 'tm 'mday)
+                                 (+ 1900 (uffi:get-slot-value tm-ptr 'tm 'year))
+                                 (uffi:get-slot-value tm-ptr 'tm 'hour)
+                                 (uffi:get-slot-value tm-ptr 'tm 'min)
+                                 (uffi:get-slot-value tm-ptr 'tm 'sec)
+                                 )))
+        (uffi:free-foreign-object time)
+        time-string))
+     ))
+
+
+
 
 #+test-uffi
 (format t "~&~A" (gettime))
index 518eb2909fa102b95ef93f48a3e7136199d98bd3..57d2b45b37166bd207d8e6a2223aed439e479e1b 100644 (file)
@@ -9,7 +9,7 @@
 ;;;;
 ;;;; Copyright (c) 2002 Kevin M. Rosenberg
 ;;;;
-;;;; $Id: strtol.cl,v 1.6 2002/03/10 11:13:07 kevin Exp $
+;;;; $Id: strtol.cl,v 1.7 2002/03/11 18:00:57 kevin Exp $
 ;;;;
 ;;;; This file is part of UFFI. 
 ;;;;
@@ -29,7 +29,7 @@
 
 (in-package :cl-user)
 
-(uffi:def-type char-ptr (* :char))
+(uffi:def-foreign-type char-ptr (* :char))
   
 ;; This example does not use :cstring to pass the input string since
 ;; the routine needs to do pointer arithmetic to see how many characters
index 312f9befeed19dce7a6ad4c42f22640e37bd48b8..7491d639f4522ab9594a4e8f66cdb57a44dc3ba2 100644 (file)
@@ -9,7 +9,7 @@
 ;;;;
 ;;;; Copyright (c) 2002 Kevin M. Rosenberg
 ;;;;
-;;;; $Id: uffi.system,v 1.3 2002/03/10 21:48:50 kevin Exp $
+;;;; $Id: uffi.system,v 1.4 2002/03/11 18:00:57 kevin Exp $
 ;;;;
 ;;;; This file is part of UFFI. 
 ;;;;
 (declaim (optimize (debug 3) (speed 3) (safety 1) (compilation-speed 0)))
 (in-package :cl-user)
 
-;;; Setup logical pathname translaton with separate binary directories
-;;; for each implementation
-
-;; push allegro case sensitivity on *features*
-#+allegro
-(eval-when (:compile-toplevel :load-toplevel :execute)
-  (if (or (eq excl:*current-case-mode* :case-sensitive-lower)
-         (eq excl:*current-case-mode* :case-sensitive-upper))
-      (pushnew :case-sensitive cl:*features*)
-    (pushnew :case-insensitive cl:*features*)))
-
-(defconstant +uffi-compiler-name+
-    #+(and allegro ics case-sensitive) "acl-modern"
-    #+(and allegro (not ics) case-sensitive) "acl-modern8"
-    #+(and allegro ics (not case-sensitive)) "acl-ansi"
-    #+(and allegro (not ics) (not case-sensitive)) "acl-ansi8"
-    #+lispworks "lispworks"
-    #+clisp "clisp"
-    #+cmu "cmucl"
-    #+sbcl "sbcl"
-    #+corman "corman"
-    #+mcl "mcl"
-    #-(or allegro lispworks clisp cmu sbcl corman mcl) "unknown")
-
-(setf (logical-pathname-translations "UFFI")
-  `(("**;bin;*.*.*" ,(merge-pathnames
-                     (make-pathname 
-                      :name :wild
-                      :type :wild
-                      :directory 
-                      (append '(:relative :wild-inferiors
-                                ".bin" #.+uffi-compiler-name+)))
-                     *load-truename*))
-    ("**;*.*.*" ,(merge-pathnames
-                 (make-pathname
-                  :name :wild
-                  :type :wild
-                  :directory '(:relative :wild-inferiors))
-                 *load-truename*))))
+(load (make-pathname :name "set-logical" :type "cl"
+                    :defaults *load-truename*))
+(set-logical-host-for-pathname "UFFI" *load-truename*)
 
 ;;; UFFI system definition