r1526: *** empty log message ***
[uffi.git] / src / strings.cl
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)
   )