Next Previous Up Top Contents Index

6 Type Reference

:union

FLI type descriptor

Summary

Converts between a Lisp object and a Cunion type.
Package

fli

Syntax

:union &rest slots

slots ::= {symbol | (symbol type)}*

Arguments

slots

A sequence of one or more slots making up the union.

symbol

A symbol naming the slot.

type

The slot type. If no type is given, it defaults to an:int.

Description

The FLI:union type is an aggregate type, and converts between a Lisp object and a Cunion type. The FLI union consists of a collection of one or more slots, only one of which can be active at any one time. The size of the whole union structure is therefore equal to the size of the largest slot. Each slot has a name and a type.
The foreign-slot-names, foreign-slot-type, and foreign-slot-value functions can be used to access and change the slots of the union. The convenience FLI function define-c-union is provided to simplify the definition of unions.
Example

In the following example a union type with two slots is defined.
(fli:define-c-union my-number 
                    (small :byte) (large :int))

An instance of the union is allocated and bound to the Lisp variablelength.
(setq length
      (fli:allocate-foreign-object :type 'my-number))

Finally, thesmall slot of the union is set equal to24.
(setf (fli:foreign-slot-value length 'small))

See Also

define-c-union
foreign-slot-names
foreign-slot-offset
foreign-slot-pointer
foreign-slot-type
foreign-slot-value

LispWorks Foreign Language Interface - 12 Oct 1998

Next Previous Up Top Contents Index

Generated with Harlequin WebMaker