| Allegro CL version 6.2 Unrevised from 6.1 |
Arguments: type allocation object &rest slot-names
Access a slot from an object. The type argument declares the type of the object being accessed. It may be:
The allocation declares the storage class of the
object being accessed. allocation must be one of
:foreign
, :foreign-static-gc
,
:lisp
, :c
or nil
. If the allocation is nil
then the allocation type will be computed from
the object argument.
The object argument identifies the object being accessed. The following table shows what object should be given the value of allocation:
Allocation argument | Object argument |
:foreign |
A foreign object allocated in the Lisp heap |
:foreign-static-gc |
A foreign object allocated in the Lisp static memory |
:lisp |
A Lisp array of type (unsigned-byte 8) of sufficient size to hold the foreign object. |
:c |
A Lisp integer representing the address of the object in memory. |
nil |
One of the above types - the computed allocation type will be the corresponding value in the first column of the table. |
The slot-names are symbols or integers. Symbols name the slots to access. Integers are used to specify array indices.
The symbol naming a slot can either be the exact symbol used when the type was defined, or it can be a keyword package symbol with the same symbol-name as the one used to define the slot.
When the accessed slot is a primitive type, then the value of the slot is returned. When the accessed slot is a composite type such as a sub-structure or an array, then the address of the sub-structure or array is returned as a Lisp integer. Please see the caution in the description of fslot-address-typed about using the returned address value.
The special slot-name asterisk *' is used to denote dereferencing a pointer. If a slot has the type (* foo) then you use the * slot name to indicate that you want to follow the pointer to the foo-typed object. If the object is an array, then the asterisk will access the first element of the array (the element at index zero).
When the allocation argument is given (i.e. not
nil), and the slot names are all constants, then this
function will be open coded by the compiler if the optimize-fslot-value-switch
is true.
(def-foreign-type sub-rec (:struct (a :int) (b :int))) (def-foreign-type record (:struct (num1 :int) (num2 :int) (nums (:array :int 17)) (floats (:array :float 11 12)) (internal sub-rec) (pointer (* record)) (sarray (:array sub-rec 7)) )) (fslot-value-typed 'record nil x 'num1) RETURNS the integer value of slot num1 (fslot-value-typed 'record nil x 'nums 3) RETURNS the integer value of element 3 of the array at slot nums (fslot-value-typed 'record nil x 'floats 5 7) RETURNS the float indexed with 5 and 7 in the array at slot floats (fslot-value-typed 'record nil x 'internal) RETURNS an integer that represents the address of the sub-structure. (fslot-value-typed 'record nil x 'internal 'a) RETURNS the integer value of slot a of the sub-structure of type sub-rec at slot internal (fslot-value-typed 'record nil x 'pointer) RETURNS the address in slot pointer This address is an integer that can be used with the allocation type :c to access data stored at the pointer location (fslot-value-typed 'record nil x 'pointer '* 'num2) RETURNS the integer value of slot num2 in the instance of type record stored at the address in slot pointer (fslot-value-typed 'record nil x 'sarray 3 'b) RETURNS the integer value of slot b in the structure of type sub-rec that is stored as element 3 of the array at slot sarray
See ftype.htm for information on foreign types in Allegro CL and foreign-functions.htm for general information on foreign functions in Allegro CL.
Copyright (c) 1998-2002, Franz Inc. Oakland, CA., USA. All rights reserved.
Documentation for Allegro CL version 6.2. This page was not revised from the 6.1 page.
Created 2002.2.26.
| Allegro CL version 6.2 Unrevised from 6.1 |