0.8.16.14:
[sbcl.git] / src / code / host-c-call.lisp
index b7730f1..4ad089a 100644 (file)
      ((alien (* char)) (alien-sap ,value))
      (simple-base-string (vector-sap ,value))))
 
+(/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")