Next Previous Up Top Contents Index

5 Function and Macro Reference

with-dynamic-foreign-objects

Macro

Summary

Allocates memory for a list of foreign objects, executes a list of forms which may use the objects across the scope of the macro, and then deallocates the foreign objects.
Package

fli

Signature

with-dynamic-foreign-objects bindings &body body => last

bindings ::= ((var foreign-type)*)

body ::= form*

Arguments

bindings

A list of variable bindings.

var

A symbol to be bound to a foreign type.

foreign-type

A foreign type descriptor to be bound to the variable var.

body

A list of forms to be executed with bindings in effect.

form

A form to be executed.

Values

last

The value of the last form in body.

Description

The functionwith-dynamic-foreign-objects binds variables according to the list bindings, and then executes body. Each element of bindings is a list which binds a symbol to a pointer which points to a locally allocated instance of a foreign type. The lifetime of the bound foreign objects, and hence the allocation of the memory they take up, is within the scope of thewith-dynamic-foreign-objects function.
Any object created withallocate-dynamic-foreign-object within body will automatically be deallocated once the scope of thewith-dynamic-foreign-objects function has been left.
Only standard foreign types can be bound using bindings. Foreign pointer types should be allocated usingallocate-dynamic-foreign-object.
Example

An example usingwith-dynamic-foreign-objects andallocate-dynamic-foreign-object is given in "An example of dynamic memory allocation" on page 6.
See Also

allocate-dynamic-foreign-object
free-foreign-object
with-coerced-pointer

LispWorks Foreign Language Interface - 12 Oct 1998

Next Previous Up Top Contents Index

Generated with Harlequin WebMaker