Next: The C-Call Package, Previous: Alien Types and Lisp Types, Up: Alien Types [Contents][Index]
Some Alien type names are Common Lisp symbols, but the names are
still exported from the alien
package, so it is legal to say
alien:single-float
. These are the basic Alien type specifiers:
A pointer to an object of the specified type. If type
is t
, then it means a pointer to anything, similar to
“void *
” in ANSI C. Currently, the only way to detect a
null pointer is:
(zerop (sap-int (alien-sap ptr)))
An array of the specified dimensions, holding elements of type
type. Note that (* int)
and (array int)
are
considered to be different types when type checking is done; pointer
and array types must be explicitly coerced using cast
.
Arrays are accessed using deref
, passing the indices as
additional arguments. Elements are stored in column-major order (as
in C), so the first dimension determines only the size of the memory
block, and not the layout of the higher dimensions. An array whose
first dimension is variable may be specified by using nil
as the
first dimension. Fixed-size arrays can be allocated as array
elements, structure slots or with-alien
variables. Dynamic
arrays can only be allocated using make-alien
.
A structure type with the specified name and fields.
Fields are allocated at the same positions used by the
implementation’s C compiler. bits is intended for C-like bit
field support, but is currently unused. If name is nil
,
then the type is anonymous.
If a named Alien struct
specifier is passed to
def-alien-type
or with-alien
, then this defines,
respectively, a new global or local Alien structure type. If no
fields are specified, then the fields are taken from the
current (local or global) Alien structure type definition of
name.
Similar to struct
, but defines a union type. All fields are
allocated at the same offset, and the size of the union is the size
of the largest field. The programmer must determine which field is
active from context.
An enumeration type that maps between integer values and keywords.
If name is nil
, then the type is anonymous. Each
spec is either a keyword, or a list (keyword
value)
. If integer is not supplied, then it defaults
to one greater than the value for the preceding spec (or to zero if
it is the first spec.)
A signed integer with the specified number of bits precision. The upper limit on integer precision is determined by the machine’s word size. If no size is specified, the maximum size will be used.
Identical to signed
—the distinction between signed
and integer
is purely stylistic.
Like signed
, but specifies an unsigned integer.
Similar to an enumeration type that maps 0
to nil
and
all other values to t
. bits determines the amount of
storage allocated to hold the truth value.
A floating-point number in IEEE single format.
A floating-point number in IEEE double format.
A Alien function that takes arguments of the specified
arg-types and returns a result of type result-type.
Note that the only context where a function
type is directly
specified is in the argument to alien-funcall
(see section
alien-funcall
.) In all other contexts, functions are
represented by function pointer types: (* (function ...))
.
A pointer which is represented in Lisp as a
system-area-pointer
object (see system-area-pointers.)
Next: The C-Call Package, Previous: Alien Types and Lisp Types, Up: Alien Types [Contents][Index]