Next Previous Up Top Contents Index

5 Function and Macro Reference

foreign-slot-value

Function

Summary

Returns the value of a slot in a foreign object.
Package

fli

Signature

foreign-slot-value object slot-name &key type copy-foreign-object => value
Arguments

object

Either an instance of or a pointer to an FLI structure.

slot-name

The name of the slot of object to be accessed.

type

The type of object. Specifying type makes accessing the object faster. If the specified type is different to the actual type,foreign-slot-value returns the value of the object in the format of type where possible.

copy-foreign-object

This option is only important when dealing with slots which are aggregate FLI types, and cannot be returned by value.

If set tot,foreign-slot-value makes a copy of the aggregate slot of the object pointed to by pointer and returns the copy.

If set tonil,foreign-slot-value returns the aggregate slot of the object directly.

If set toerror thenforeign-slot-value signals an error. This is the default value for copy-foreign-object.

Value

value

The value of the slot slot-name in the FLI object object is returned.

Description

The functionforeign-slot-value returns the value of a slot in a specified object. An error is signaled if the slot is an aggregate type and copy-foreign-object is not set accordingly
The functionforeign-slot-value can be used withsetf to set the value of a slot in a structure, as shown in the example below.
Example

In the following example a foreign structure is defined, an instance of the structure is made withmy-pos pointing to the instance, andforeign-slot-value is used to set they slot of the object to 10.
(fli:define-c-struct POS
  (x :int)
  (y :int)
  (z :int))

(setq my-pos (fli:allocate-foreign-object :type 'POS))

(setf (fli:foreign-slot-value my-pos 'y) 10)

The next line returns the value of they slot atmy-pos, which is 10.
(fli:foreign-slot-value my-pos 'y)

See Also

dereference

LispWorks Foreign Language Interface - 12 Oct 1998

Next Previous Up Top Contents Index

Generated with Harlequin WebMaker