X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcode%2Fhost-c-call.lisp;h=409fd9fa8013890c280afa886cc0695429a15d13;hb=731d5dd65a7b94b5d49d1663d9b60c3a406ce38c;hp=b0b143b428c407156d75a7a56f83727269a95bc5;hpb=e33fb894f991b2926d8f3bace9058e4c0b2c3a37;p=sbcl.git diff --git a/src/code/host-c-call.lisp b/src/code/host-c-call.lisp index b0b143b..409fd9f 100644 --- a/src/code/host-c-call.lisp +++ b/src/code/host-c-call.lisp @@ -7,16 +7,15 @@ ;;;; provided with absolutely no warranty. See the COPYING and CREDITS ;;;; files for more information. -(in-package "SB!C-CALL") +(in-package "SB!ALIEN") (/show0 "host-c-call.lisp 12") (define-alien-type-class (c-string :include pointer :include-args (to))) (define-alien-type-translator c-string () - (make-alien-c-string-type :to - (parse-alien-type 'char - (sb!kernel::make-null-lexenv)))) + (make-alien-c-string-type + :to (parse-alien-type 'char (sb!kernel:make-null-lexenv)))) (define-alien-type-method (c-string :unparse) (type) (declare (ignore type)) @@ -24,7 +23,7 @@ (define-alien-type-method (c-string :lisp-rep) (type) (declare (ignore type)) - '(or simple-base-string null (alien (* char)))) + '(or simple-string null (alien (* char)))) (define-alien-type-method (c-string :naturalize-gen) (type alien) (declare (ignore type)) @@ -37,6 +36,37 @@ `(etypecase ,value (null (int-sap 0)) ((alien (* char)) (alien-sap ,value)) - (simple-base-string (vector-sap ,value)))) + (simple-base-string (vector-sap ,value)) + (simple-string (vector-sap (coerce ,value 'simple-base-string))))) + +(/show0 "host-c-call.lisp 42") + +(define-alien-type-class (utf8-string :include pointer :include-args (to))) + +(define-alien-type-translator utf8-string () + (make-alien-utf8-string-type + :to (parse-alien-type 'char (sb!kernel:make-null-lexenv)))) + +(define-alien-type-method (utf8-string :unparse) (type) + (declare (ignore type)) + 'utf8-string) + +(define-alien-type-method (utf8-string :lisp-rep) (type) + (declare (ignore type)) + '(or simple-string null (alien (* char)))) + +(define-alien-type-method (utf8-string :naturalize-gen) (type alien) + (declare (ignore type)) + `(if (zerop (sap-int ,alien)) + nil + (%naturalize-utf8-string ,alien))) + +(define-alien-type-method (utf8-string :deport-gen) (type value) + (declare (ignore type)) + `(etypecase ,value + (null (int-sap 0)) + ((alien (* char)) (alien-sap ,value)) + (simple-base-string (vector-sap ,value)) + (simple-string (vector-sap (%deport-utf8-string ,value))))) (/show0 "host-c-call.lisp end of file")