FLI type descriptor
:wrapper fli-type &key lisp-to-fli fli-to-lisp
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.
:wrappertype allows for an extra level of conversion between Lisp and a foreign language through the FLI. With the
:wrappertype 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
:wrapperto pass values to an
:intas strings, and to receive them back as strings when the pointer to the
:intis allocated with a wrapper to allow the
:intto be accessed as a string.
(setq wrap (fli:allocate-foreign-object :type '(:wrapper :int :lisp-to-foreign read-from-string :foreign-to-lisp prin1-to-string)))
wrap, although consisting of an underlying
:int, is set with
dereferenceby passing a string, which is automatically converted using the Lisp function
read-from-string. Similarly, when
wrapis dereferenced, the value stored as an
:intis converted using
prin1-to-stringto a Lisp string, which is the returned. The following two commands demonstrate this.
(setf (fli:dereference wrap) "#x100") (fli:dereference wrap)
wrapto be 256 (100 in hex), by passing a string to it. The second command dereferences the value at
wrap, but returns it as a string. The pointer
wrapcan be coerced to return the value as an actual
Generated with Harlequin WebMaker