Function
fli
foreign-slot-pointer object slot-name &key type => pointer
A foreign object, or a pointer to a foreign object.
The name of a slot in object.
The type of the slot slot-name.
A pointer to slot-name.
foreign-slot-pointer
takes a foreign object, a slot within the object, and optionally the type of the slot, and returns a pointer to the slot.
COMPASS
is defined. An instance of the structure is allocated usingallocate-foreign-object
, pointed to bypoint1
. Thenforeign-slot-pointer
is used to get a pointer, calledpoint2
, to the second slot of the foreign object. (fli:define-c-struct COMPASS (west :int) (east :int)) (setq point1 (fli:allocate-foreign-object :type 'COMPASS)) (setq point2 (fli:foreign-slot-pointer point1 'east :type :int))
:type
keyword can be used to return the value stored in the slot as a different type, providing the type is compatible. In the next example,point3
is set to be a pointer to the same address aspoint2
, but it expects the value stored there to be a boolean. (setq point3 (fli:foreign-slot-pointer point1 'east :type '(:boolean :int)))
dereference
the value can be set as an integer usingpoint2
and read as a boolean usingpoint3
. (setf (fli:dereference point2) 0) (fli:dereference point3) (setf (fli:dereference point2) 1) (fli:dereference point3)
decf-pointer
incf-pointer
make-pointer