NextPrevUpTopContentsIndex

with-foreign-slots

Macro
Summary

Allows convenient access to the slots of a foreign structure.

Package

fli

Signature

with-foreign-slots slots object &body body => last

slots ::= { slot-name *}

Arguments

slots

A list of foreign slot names slot-name for object .

object

A foreign structure or a pointer to a foreign structure.

body

A list of forms to be executed.

Values

last

The value of the last form in body .

Description

The macro with-foreign-slots is analogous to the Common Lisp macro with-slots . Within body , each slot-name evaluates to the result of foreign-slot-value, and setf can be used to set the foreign-slot-value.

Example
(fli:define-c-struct abc 
  (a :int)
  (b :int)
  (c :int))
=>
(:STRUCT ABC)
 
(setf abc (fli:allocate-foreign-object :type 'abc))
=>
#<Pointer to type (:STRUCT ABC) = #x007F3BE0>
 
(fli:with-foreign-slots (a b c) abc
  (setf a 6 b 7 c (* a b)))
=> 
42
 
(fli:foreign-slot-value abc 'c)
=> 
42
See also

foreign-slot-value


LispWorks Foreign Language Interface User Guide and Reference Manual - 27 Mar 2005

NextPrevUpTopContentsIndex