X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=src%2Fstrings.cl;h=0e1e20de513da50e414010a83c03e8768f46dad6;hb=8ea47cc46f02b47a7c1e0c302d1004c4b94d8abc;hp=0cbf721d9e739534a3b740cf24d01ef5d1f4b184;hpb=40314c219af7f3c1117836a66f4028a52704437d;p=uffi.git diff --git a/src/strings.cl b/src/strings.cl index 0cbf721..0e1e20d 100644 --- a/src/strings.cl +++ b/src/strings.cl @@ -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) )