1 ;;;; This software is part of the SBCL system. See the README file for
4 ;;;; This software is derived from the CMU CL system, which was
5 ;;;; written at Carnegie Mellon University and released into the
6 ;;;; public domain. The software is in the public domain and is
7 ;;;; provided with absolutely no warranty. See the COPYING and CREDITS
8 ;;;; files for more information.
10 (in-package "SB!ALIEN")
12 (/show0 "host-c-call.lisp 12")
14 (define-alien-type-class (c-string :include pointer :include-args (to)))
16 (define-alien-type-translator c-string ()
17 (make-alien-c-string-type
18 :to (parse-alien-type 'char (sb!kernel:make-null-lexenv))))
20 (define-alien-type-method (c-string :unparse) (type)
21 (declare (ignore type))
24 (define-alien-type-method (c-string :lisp-rep) (type)
25 (declare (ignore type))
26 '(or simple-string null (alien (* char))))
28 (define-alien-type-method (c-string :naturalize-gen) (type alien)
29 (declare (ignore type))
30 `(if (zerop (sap-int ,alien))
32 (%naturalize-c-string ,alien)))
34 (define-alien-type-method (c-string :deport-gen) (type value)
35 (declare (ignore type))
38 ((alien (* char)) (alien-sap ,value))
39 (simple-base-string (vector-sap ,value))
40 (simple-string (vector-sap (coerce ,value 'simple-base-string)))))
42 (/show0 "host-c-call.lisp 42")
44 (define-alien-type-class (utf8-string :include pointer :include-args (to)))
46 (define-alien-type-translator utf8-string ()
47 (make-alien-utf8-string-type
48 :to (parse-alien-type 'char (sb!kernel:make-null-lexenv))))
50 (define-alien-type-method (utf8-string :unparse) (type)
51 (declare (ignore type))
54 (define-alien-type-method (utf8-string :lisp-rep) (type)
55 (declare (ignore type))
56 '(or simple-string null (alien (* char))))
58 (define-alien-type-method (utf8-string :naturalize-gen) (type alien)
59 (declare (ignore type))
60 `(if (zerop (sap-int ,alien))
62 (%naturalize-utf8-string ,alien)))
64 (define-alien-type-method (utf8-string :deport-gen) (type value)
65 (declare (ignore type))
68 ((alien (* char)) (alien-sap ,value))
69 (simple-base-string (vector-sap ,value))
70 (simple-string (vector-sap (%deport-utf8-string ,value)))))
72 (/show0 "host-c-call.lisp end of file")