Next: , Previous: , Up: Pointers   [Contents][Index]


with-foreign-object

with-foreign-object, with-foreign-objects

Syntax

Macro: with-foreign-object (var type &optional count) &body body
Macro: with-foreign-objects (bindings) &body body

bindings ::= {(var type &optional count)}*

Arguments and Values

var

A symbol.

type

A foreign type, evaluated.

count

An integer.

Description

The macros with-foreign-object and with-foreign-objects bind var to a pointer to count newly allocated objects of type type during body. The buffer has dynamic extent and may be stack allocated if supported by the host Lisp.

Examples

  CFFI> (with-foreign-object (array :int 10)
          (dotimes (i 10)
            (setf (mem-aref array :int i) (random 100)))
          (loop for i below 10
                collect (mem-aref array :int i)))(22 7 22 52 69 1 46 93 90 65)

See Also

foreign-alloc