The underlying type to wrap.
Code specifying how to convert between Lisp and the FLI.
Code specifying how to convert between the FLI and Lisp.
type allows for an extra level of conversion between Lisp and a foreign language through the FLI. With the
type you can specify conversion functions from and to an instance of another type. Whenever data is passed to the object, or received from the object it is passed through the conversion function. See below for an example of a use of
to pass values to an :int as strings, and to receive them back as strings when the pointer to the :int is dereferenced.
The object pointed to by
, although consisting of an underlying :int, is set with dereference by passing a string, which is automatically converted using the Lisp function
. Similarly, when
is dereferenced, the value stored as an :int is converted using
to a Lisp string, which is the returned. The following two commands demonstrate this.
(setf (fli:dereference wrap) "#x100")
The first command sets the value stored at
to be 256 (100 in hex), by passing a string to it. The second command dereferences the value at
, but returns it as a string. The pointer
can be coerced to return the value as an actual :int as follows:
(fli:dereference wrap :type :int)