1 ;;;; -*- Mode: Lisp; indent-tabs-mode: nil -*-
3 ;;; --- CFFI type designators.
6 (in-package :iolib.syscalls
)
8 ;;;-------------------------------------------------------------------------
9 ;;; CFFI Type Designators
10 ;;;-------------------------------------------------------------------------
12 (defmacro define-designator
(name cffi-type
&body type-clauses
)
13 (let ((type `(quote (or ,@(mapcar #'car type-clauses
))))
14 (ctype (format-symbol t
"~A-~A" (string name
) (string '#:designator
))))
16 (deftype ,name
() ,type
)
20 (define-foreign-type ,ctype
()
22 (:simple-parser
,ctype
)
23 (:actual-type
,cffi-type
))
24 (defmethod expand-to-foreign (value (type ,ctype
))
26 (let ((,',name
,value
))
27 (etypecase ,',name
,@',type-clauses
))
30 (define-designator pointer-or-nil
:pointer
32 (foreign-pointer pointer-or-nil
))
34 (define-designator bool
:int
39 ;;;-------------------------------------------------------------------------
41 ;;;-------------------------------------------------------------------------
43 ;;; FIXME: with fd namespaces on Linux, someday this might be no
45 (deftype fd
() '(integer 0 65535))