FLI type descriptor
fli
:one-of &rest types
A list of types sharing the same underlying type.
:one-of
type is used to allocate an object which can be one of a number of types. The types must have the same underlying structure, which means they must have the same size and must be referenced in the same manner. The FLI:one-of
type is useful when a foreign function returns a value whose underlying type is known, but whose exact type is not.
:one-of
type is allocated. (setq thing (fli:allocate-foreign-object :type '(:one-of :ptr :int :unsigned)))
thing
is set to be 100 usingdereference
, it is taken to be an object of type:int
, as this is the first element in the sequence of types defined by:one-of
which matches the type of the number 100. (setf (fli:dereference thing) 100)
thing
is now dereferenced, it is returned as a pointer to the address 100 (Or hex address 64), as there is no method for determining the type ofthing
, and therefore the first element in the list of:one-of
is used. (fli:dereference thing)
:union