Defines a FLI union type corresponding to the C union
type.
fli
define-c-union name-and-options &rest slot-descriptions => list
name-and-options ::= name | (name option*)
option ::= (:foreign-name foreign-name) | (:forward-reference-p forward-reference-p)
slot-descriptions ::= {slot-description}*
slot-description ::= (slot-name slot-type)
name⇩ |
A symbol naming the new union type descriptor. |
foreign-name⇩ |
A string specifying the foreign name of the type. |
forward-reference-p⇩ |
A boolean. |
slot-name⇩ |
A symbol naming the slot. |
slot-type⇩ |
The FLI type of the slot. |
list |
The list (:union name) . |
The macro define-c-union
is used to define a FLI union type specifier, which corresponds to the C union
type. It is a convenience function, as a union type could also be defined using define-foreign-type.
A union is an aggregate type, or collection, of other FLI types. The types contained in a union are referred to as slots, and can be accessed using the foreign-slot-type and foreign-slot-value functions.
The FLI type specifier is named by name, with optional foreign name foreign-name.
Each slot-description is a list of a symbol slot-name and a corresponding FLI type descriptor slot-type which is the type of the slot named by slot-name.
When forward-reference-p is true, the new type specifier is defined as a forward reference type and descriptions can be empty. See define-foreign-forward-reference-type.
foreign-name, specifying the foreign name, is supported only for documentation purposes.
In the following example a union is defined using define-c-union
, and the corresponding C code is given.
(fli:define-c-union a-point (x :int) (color :byte) (ident :char))
union a-point { int x; byte color; char ident; };
define-c-enum
define-c-struct
define-c-typedef
define-foreign-type
2 FLI Types
Foreign Language Interface User Guide and Reference Manual - 01 Dec 2021 19:34:58