Next Previous Up Top Contents Index

2 FLI Types

2.3 Parameterized types

The define-foreign-type anddefine-foreign-converter types allow the definition of parameterized types. For example, assume you want to create a foreign type that matches the Lisp typeunsigned-byte when supplied with an argument of one of 8, 16, or 32. The following code achieves this:

(fli:define-foreign-type unsigned-byte (&optional (bitsize '*))
  (case bitsize
    (8 '(:unsigned :byte))
    (16 '(:unsigned :short))
    (32 '(:unsigned :int))
    (otherwise (error "Illegal foreign type (~s ~s)"
                'unsigned-byte bitsize))))

This defines the new foreign typeunsigned-byte that can be used anywhere within the FLI as one of

Specifying anything else returns an error.


LispWorks Foreign Language Interface - 12 Oct 1998

Next Previous Up Top Contents Index

Generated with Harlequin WebMaker