projects
/
uffi.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
r9439: Automated commit for Debian build of uffi upstream-version-1.4.20
[uffi.git]
/
src
/
strings.lisp
diff --git
a/src/strings.lisp
b/src/strings.lisp
index 4671925661c8b67298d5879a233524e08e9619f7..f935e1bd479db0b479068a6e812432dbfebe44d9 100644
(file)
--- a/
src/strings.lisp
+++ b/
src/strings.lisp
@@
-157,10
+157,11
@@
that LW/CMU automatically converts strings from c-calls."
nil
(if (eq ,locale :none)
(fast-native-to-string ,obj ,length)
nil
(if (eq ,locale :none)
(fast-native-to-string ,obj ,length)
- (excl:native-to-string
- ,obj
- ,@(when length (list :length length))
- :truncate (not ,null-terminated-p))))
+ (values
+ (excl:native-to-string
+ ,obj
+ ,@(when length (list :length length))
+ :truncate (not ,null-terminated-p)))))
#+lispworks
`(if (fli:null-pointer-p ,obj)
nil
#+lispworks
`(if (fli:null-pointer-p ,obj)
nil
@@
-188,25
+189,33
@@
that LW/CMU automatically converts strings from c-calls."
#+mcl
`(if (ccl:%null-ptr-p ,obj)
nil
#+mcl
`(if (ccl:%null-ptr-p ,obj)
nil
- (ccl:%get-cstring ,obj 0 ,@(if length (list length) nil)))
+ #+(and mcl (not openmcl)) (ccl:%get-cstring ,obj 0 ,@(if length (list length) nil))
+ #+openmcl (let ((str (ccl:%get-cstring ,obj)))
+ ,(if length '(subseq str 0 length) 'str)))
)
(defmacro allocate-foreign-string (size &key (unsigned t))
)
(defmacro allocate-foreign-string (size &key (unsigned t))
- #+
(or cmu scl)
+ #+
ignore
(let ((array-def (gensym)))
`(let ((,array-def (list 'alien:array 'c-call:char ,size)))
(eval `(alien:cast (alien:make-alien ,,array-def)
,(if ,unsigned
'(* (alien:unsigned 8))
'(* (alien:signed 8)))))))
(let ((array-def (gensym)))
`(let ((,array-def (list 'alien:array 'c-call:char ,size)))
(eval `(alien:cast (alien:make-alien ,,array-def)
,(if ,unsigned
'(* (alien:unsigned 8))
'(* (alien:signed 8)))))))
+
+ #+(or cmu scl)
+ `(alien:make-alien ,(if unsigned
+ '(alien:unsigned 8)
+ '(alien:signed 8))
+ ,size)
+
#+sbcl
#+sbcl
- (let ((array-def (gensym)))
- `(let ((,array-def (list 'sb-alien:array 'char ,size)))
- (eval `(sb-alien:cast (sb-alien:make-alien ,,array-def)
- ,(if ,unsigned
- '(* (sb-alien:unsigned 8))
- '(* (sb-alien:signed 8)))))))
+ `(sb-alien:make-alien ,(if unsigned
+ '(sb-alien:unsigned 8)
+ '(sb-alien:signed 8))
+ ,size)
+
#+lispworks
`(fli:allocate-foreign-object :type
,(if unsigned
#+lispworks
`(fli:allocate-foreign-object :type
,(if unsigned
@@
-227,7
+236,7
@@
that LW/CMU automatically converts strings from c-calls."
#+allegro `(ff:foreign-strlen ,foreign-string)
#-allegro
`(loop with size = 0
#+allegro `(ff:foreign-strlen ,foreign-string)
#-allegro
`(loop with size = 0
- until (char= (deref-array ,
ptr
'(:array :unsigned-char) size) #\Null)
+ until (char= (deref-array ,
foreign-string
'(:array :unsigned-char) size) #\Null)
do (incf size)
finally return size))
do (incf size)
finally return size))
@@
-312,10
+321,10
@@
that LW/CMU automatically converts strings from c-calls."
(* length sb-vm:n-byte-bits))
result)))
(* length sb-vm:n-byte-bits))
result)))
-
-(def-function "strlen"
- ((str (* :unsigned-char)))
-
:returning :unsigned-int
)
+(eval-when (:compile-toplevel :load-toplevel :execute)
+
(def-function "strlen"
+
((str (* :unsigned-char)))
+
:returning :unsigned-int)
)
(def-type char-ptr-def (* :unsigned-char))
(def-type char-ptr-def (* :unsigned-char))
@@
-338,4
+347,4
@@
that LW/CMU automatically converts strings from c-calls."
(let* ((len (or len (strlen s)))
(str (make-string len)))
(dotimes (i len str)
(let* ((len (or len (strlen s)))
(str (make-string len)))
(dotimes (i len str)
- (setf (schar str i) (code-char (uffi:deref-array s '(:array :byte) i))))))
+ (setf (schar str i) (code-char (uffi:deref-array s '(:array :
unsigned-
byte) i))))))