;;;;
;;;; Copyright (c) 2002 Kevin M. Rosenberg
;;;;
-;;;; $Id: strings.cl,v 1.1 2002/03/09 19:55:33 kevin Exp $
+;;;; $Id: strings.cl,v 1.3 2002/03/10 05:09:00 kevin Exp $
;;;;
;;;; This file is part of the UFFI.
;;;;
(defmacro convert-to-c-string (obj)
#+lispworks
`(if (null ,obj)
- +null-c-string-ptr+
- (fli:convert-to-foreign-string ,obj))
+ +null-c-string-pointer+
+ (fli:make-pointer
+ :address (fli:pointer-address (fli:convert-to-foreign-string ,obj))
+ :type :char))
#+allegro
`(if (null ,obj)
0
(defmacro convert-to-foreign-string (obj)
#+lispworks
`(if (null ,obj)
- +null-c-string-ptr+
- (fli:convert-to-foreign-string ,obj))
+ +null-c-string-pointer+
+ (fli:make-pointer
+ :address (fli:pointer-address (fli:convert-to-foreign-string ,obj))
+ :type :char))
#+allegro
`(if (null ,obj)
0
)
-(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)
)