Next: define-parse-method, Previous: defcenum, Up: Foreign Types [Contents][Index]
options ::= (:actual-type
type) | (:simple-parser
symbol) | regular defclass option
A symbol naming the new foreign type class.
A list of symbols naming the super classes.
A list of slot definitions, passed to defclass
.
The macro define-foreign-type
defines a new class
class-name. It is a thin wrapper around defclass
. Among
other things, it ensures that class-name becomes a subclass of
foreign-type, what you need to know about that is that there’s
an initarg :actual-type
which serves the same purpose as
defctype
’s base-type argument.
Taken from CFFI’s :boolean
type definition:
(define-foreign-type :boolean (&optional (base-type :int)) "Boolean type. Maps to an :int by default. Only accepts integer types." (ecase base-type ((:char :unsigned-char :int :unsigned-int :long :unsigned-long) base-type))) CFFI> (canonicalize-foreign-type :boolean) ⇒ :INT CFFI> (canonicalize-foreign-type '(:boolean :long)) ⇒ :LONG CFFI> (canonicalize-foreign-type '(:boolean :float)) ;; error→ signalled by ECASE.