r1526: *** empty log message ***
authorKevin M. Rosenberg <kevin@rosenberg.net>
Sun, 10 Mar 2002 05:13:09 +0000 (05:13 +0000)
committerKevin M. Rosenberg <kevin@rosenberg.net>
Sun, 10 Mar 2002 05:13:09 +0000 (05:13 +0000)
ChangeLog
doc/uffi.pdf
examples/compress.cl
examples/getenv.cl
examples/strtol.cl
src/immediates.cl
src/strings.cl
tests/compress.cl
tests/getenv.cl
tests/strtol.cl

index 1000077e66274844cd8903f3a08128f9afb594e4..0be07ab017b100f236a71d1c86313fe7bd6df233 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,7 +3,9 @@
        - Fixed bug in def-function for Lispworks
        - Fixed error in +null-c-string-pointer+ name
        - Fixed error in (make-null-pointer) for Lispworks
-       - Fixed error in strtol example
+       - Reworked Lispwork c-strings to be (* :char) rather than
+       the implementation default of (* (:unsigned :char)) to be
+       consistent with CMUCL
        
 8 Mar 2002
        - Added ZIP file output with LF->CRLF translations to distribution
index f100f7076d05ee9d91ee0251097203ca48bcaee3..7236b52e304892f4bea8c439e2cc2112984accf8 100644 (file)
Binary files a/doc/uffi.pdf and b/doc/uffi.pdf differ
index 1ef513db8adde6bf4ae8d5ff595159db9a56fe52..640ce26ab2f63aa18f2302cb8ef86bff8b454543 100644 (file)
@@ -9,7 +9,7 @@
 ;;;;
 ;;;; Copyright (c) 2002 Kevin M. Rosenberg
 ;;;;
-;;;; $Id: compress.cl,v 1.3 2002/03/10 04:15:33 kevin Exp $
+;;;; $Id: compress.cl,v 1.4 2002/03/10 05:09:00 kevin Exp $
 ;;;;
 ;;;; This file is part of UFFI. 
 ;;;;
@@ -45,7 +45,7 @@
  and the numbe of compressed bytes"
   (let* ((sourcelen (length source))
         (destsize (+ 12 (ceiling (* sourcelen 1.01))))
-        (dest (uffi:allocate-foreign-string destsize))
+        (dest (uffi:allocate-foreign-string destsize :unsigned t))
         (destlen (uffi:allocate-foreign-object :long)))
     (setf (uffi:deref-pointer destlen :long) destsize)
     (uffi:with-c-string (source-native source)
index 347a22f81b12c461c7ce0836d293c160caa7b4b8..2f83426f11885b49601999ad5ba3904a3d41ace9 100644 (file)
@@ -9,7 +9,7 @@
 ;;;;
 ;;;; Copyright (c) 2002 Kevin M. Rosenberg
 ;;;;
-;;;; $Id: getenv.cl,v 1.3 2002/03/10 04:15:33 kevin Exp $
+;;;; $Id: getenv.cl,v 1.4 2002/03/10 05:13:09 kevin Exp $
 ;;;;
 ;;;; This file is part of UFFI. 
 ;;;;
     ((name :c-string))
   :returning :c-string)
 
-(defun getenv (key)
+(defun my-getenv (key)
   "Returns an environment variable, or NIL if it does not exist"
   (check-type key string)
   (uffi:with-c-string (key-native key)
     (let ((value-c-string (c-getenv key-native)))
       (uffi:convert-from-c-string value-c-string))))
     
-(format t "~&Environment value for USER key: ~A" (getenv "USER"))
-(format t "~&Environment value for _FOO_ key: ~A" (getenv "_FOO_"))
-
 #+test-uffi
 (progn
   (flet ((print-results (str)
-          (format t "~&(getenv ~S) => ~S" str (getenv str))))
+          (format t "~&(getenv ~S) => ~S" str (my-getenv str))))
     (print-results "USER")
     (print-results "_FOO_")))
 
index 387d23b26b639b4a8fbf7705d1ecc1a20ccf0b14..98131602bc57d65629c8d1e479011af10d08c905 100644 (file)
@@ -9,7 +9,7 @@
 ;;;;
 ;;;; Copyright (c) 2002 Kevin M. Rosenberg
 ;;;;
-;;;; $Id: strtol.cl,v 1.4 2002/03/10 04:36:04 kevin Exp $
+;;;; $Id: strtol.cl,v 1.5 2002/03/10 05:09:00 kevin Exp $
 ;;;;
 ;;;; This file is part of UFFI. 
 ;;;;
 
 (in-package :cl-user)
 
-(uffi:def-type char-ptr (* :unsigned-char))
+(uffi:def-type char-ptr (* :char))
   
 ;; This example does not use :c-string to pass the input string since
 ;; the routine needs to do pointer arithmetic to see how many characters
 ;; were parsed
 
 (uffi:def-function ("strtol" c-strtol) 
-    ((nptr (* :unsigned-char))
+    ((nptr (* :char))
      (endptr (* char-ptr))
      (base :int))
   :returning :long)
index b22a47b029f9c648d08344b9b984f14a2e2dc56f..62e216f1c1fc5382fe5fd03aa43889d751655e81 100644 (file)
@@ -9,7 +9,7 @@
 ;;;;
 ;;;; Copyright (c) 2002 Kevin M. Rosenberg
 ;;;;
-;;;; $Id: immediates.cl,v 1.1 2002/03/09 19:55:33 kevin Exp $
+;;;; $Id: immediates.cl,v 1.2 2002/03/10 05:09:00 kevin Exp $
 ;;;;
 ;;;; This file is part of the UFFI. 
 ;;;;
@@ -111,7 +111,7 @@ supports this."
     '((* . :pointer) (:void . :void) 
       (:short . :short)
       (:pointer-void . (:pointer :void))
-      (:c-string . (:pointer (:unsigned :char))) 
+      (:c-string . (:pointer :char))
       (:char . :char) (:unsigned-char . (:unsigned :char))
       (:int . :int) (:unsigned-int . (:unsigned :int))
       (:long . :long) (:unsigned-long . (:unsigned :long))
index 0cbf721d9e739534a3b740cf24d01ef5d1f4b184..0e1e20de513da50e414010a83c03e8768f46dad6 100644 (file)
@@ -9,7 +9,7 @@
 ;;;;
 ;;;; Copyright (c) 2002 Kevin M. Rosenberg
 ;;;;
-;;;; $Id: strings.cl,v 1.2 2002/03/10 00:11:47 kevin Exp $
+;;;; $Id: strings.cl,v 1.3 2002/03/10 05:09:00 kevin Exp $
 ;;;;
 ;;;; This file is part of the UFFI. 
 ;;;;
@@ -53,7 +53,9 @@ that CMU automatically converts strings from c-calls."
   #+lispworks
   `(if (null ,obj)
        +null-c-string-pointer+
-     (fli:convert-to-foreign-string ,obj))
+     (fli:make-pointer
+      :address (fli:pointer-address (fli:convert-to-foreign-string ,obj))
+      :type :char))
   #+allegro
   `(if (null ,obj)
        0
@@ -102,7 +104,9 @@ that CMU automatically converts strings from c-calls."
   #+lispworks
   `(if (null ,obj)
        +null-c-string-pointer+
-     (fli:convert-to-foreign-string ,obj))
+     (fli:make-pointer
+      :address (fli:pointer-address (fli:convert-to-foreign-string ,obj))
+      :type :char))
   #+allegro
   `(if (null ,obj)
        0
@@ -124,13 +128,22 @@ that CMU automatically converts strings from c-calls."
   )
 
 
-(defmacro allocate-foreign-string (size)
+(defmacro allocate-foreign-string (size &key (unsigned nil))
   #+cmu
   (let ((array-def (gensym)))
     `(let ((,array-def (list 'alien:array 'c-call:char ,size)))
-       (eval `(alien:cast (alien:make-alien ,,array-def) (* (alien:unsigned 8))))))
+       (eval `(alien:cast (alien:make-alien ,,array-def) 
+                         ,(if ,unsigned 
+                              '(* (alien:unsigned 8))
+                            '(* (alien:signed 8)))))))
   #+lispworks
-  `(fli:allocate-foreign-object :type '(:unsigned :char) :nelems ,size)
+  `(fli:allocate-foreign-object :type 
+                               ,(if unsigned 
+                                    ''(:unsigned :char) 
+                                  :char)
+                               :nelems ,size)
+  #+allegro
+  (declare (ignore unsigned))
   #+allegro
   `(ff:allocate-fobject :char :c ,size)
   )
index 1ef513db8adde6bf4ae8d5ff595159db9a56fe52..640ce26ab2f63aa18f2302cb8ef86bff8b454543 100644 (file)
@@ -9,7 +9,7 @@
 ;;;;
 ;;;; Copyright (c) 2002 Kevin M. Rosenberg
 ;;;;
-;;;; $Id: compress.cl,v 1.3 2002/03/10 04:15:33 kevin Exp $
+;;;; $Id: compress.cl,v 1.4 2002/03/10 05:09:00 kevin Exp $
 ;;;;
 ;;;; This file is part of UFFI. 
 ;;;;
@@ -45,7 +45,7 @@
  and the numbe of compressed bytes"
   (let* ((sourcelen (length source))
         (destsize (+ 12 (ceiling (* sourcelen 1.01))))
-        (dest (uffi:allocate-foreign-string destsize))
+        (dest (uffi:allocate-foreign-string destsize :unsigned t))
         (destlen (uffi:allocate-foreign-object :long)))
     (setf (uffi:deref-pointer destlen :long) destsize)
     (uffi:with-c-string (source-native source)
index 347a22f81b12c461c7ce0836d293c160caa7b4b8..2f83426f11885b49601999ad5ba3904a3d41ace9 100644 (file)
@@ -9,7 +9,7 @@
 ;;;;
 ;;;; Copyright (c) 2002 Kevin M. Rosenberg
 ;;;;
-;;;; $Id: getenv.cl,v 1.3 2002/03/10 04:15:33 kevin Exp $
+;;;; $Id: getenv.cl,v 1.4 2002/03/10 05:13:09 kevin Exp $
 ;;;;
 ;;;; This file is part of UFFI. 
 ;;;;
     ((name :c-string))
   :returning :c-string)
 
-(defun getenv (key)
+(defun my-getenv (key)
   "Returns an environment variable, or NIL if it does not exist"
   (check-type key string)
   (uffi:with-c-string (key-native key)
     (let ((value-c-string (c-getenv key-native)))
       (uffi:convert-from-c-string value-c-string))))
     
-(format t "~&Environment value for USER key: ~A" (getenv "USER"))
-(format t "~&Environment value for _FOO_ key: ~A" (getenv "_FOO_"))
-
 #+test-uffi
 (progn
   (flet ((print-results (str)
-          (format t "~&(getenv ~S) => ~S" str (getenv str))))
+          (format t "~&(getenv ~S) => ~S" str (my-getenv str))))
     (print-results "USER")
     (print-results "_FOO_")))
 
index 387d23b26b639b4a8fbf7705d1ecc1a20ccf0b14..98131602bc57d65629c8d1e479011af10d08c905 100644 (file)
@@ -9,7 +9,7 @@
 ;;;;
 ;;;; Copyright (c) 2002 Kevin M. Rosenberg
 ;;;;
-;;;; $Id: strtol.cl,v 1.4 2002/03/10 04:36:04 kevin Exp $
+;;;; $Id: strtol.cl,v 1.5 2002/03/10 05:09:00 kevin Exp $
 ;;;;
 ;;;; This file is part of UFFI. 
 ;;;;
 
 (in-package :cl-user)
 
-(uffi:def-type char-ptr (* :unsigned-char))
+(uffi:def-type char-ptr (* :char))
   
 ;; This example does not use :c-string to pass the input string since
 ;; the routine needs to do pointer arithmetic to see how many characters
 ;; were parsed
 
 (uffi:def-function ("strtol" c-strtol) 
-    ((nptr (* :unsigned-char))
+    ((nptr (* :char))
      (endptr (* char-ptr))
      (base :int))
   :returning :long)