Previous: , Up: The SCM Type in Guile   [Contents][Index]


9.2.5.6 Accessing Heap Object Fields

For a non-immediate Scheme object x, the object type can be determined by using the SCM_CELL_TYPE macro described in the previous section. For each different type of heap object it is known which fields hold tagged Scheme objects and which fields hold untagged raw data. To access the different fields appropriately, the following macros are provided.

Macro: scm_t_bits SCM_CELL_WORD (SCM x, unsigned int n)
Macro: scm_t_bits SCM_CELL_WORD_0 (x)
Macro: scm_t_bits SCM_CELL_WORD_1 (x)
Macro: scm_t_bits SCM_CELL_WORD_2 (x)
Macro: scm_t_bits SCM_CELL_WORD_3 (x)

Deliver the field n of the heap object referenced by the non-immediate Scheme object x as raw untagged data. Only use this macro for fields containing untagged data; don’t use it for fields containing tagged SCM objects.

Macro: SCM SCM_CELL_OBJECT (SCM x, unsigned int n)
Macro: SCM SCM_CELL_OBJECT_0 (SCM x)
Macro: SCM SCM_CELL_OBJECT_1 (SCM x)
Macro: SCM SCM_CELL_OBJECT_2 (SCM x)
Macro: SCM SCM_CELL_OBJECT_3 (SCM x)

Deliver the field n of the heap object referenced by the non-immediate Scheme object x as a Scheme object. Only use this macro for fields containing tagged SCM objects; don’t use it for fields containing untagged data.

Macro: void SCM_SET_CELL_WORD (SCM x, unsigned int n, scm_t_bits w)
Macro: void SCM_SET_CELL_WORD_0 (x, w)
Macro: void SCM_SET_CELL_WORD_1 (x, w)
Macro: void SCM_SET_CELL_WORD_2 (x, w)
Macro: void SCM_SET_CELL_WORD_3 (x, w)

Write the raw value w into field number n of the heap object referenced by the non-immediate Scheme value x. Values that are written into heap objects as raw values should only be read later using the SCM_CELL_WORD macros.

Macro: void SCM_SET_CELL_OBJECT (SCM x, unsigned int n, SCM o)
Macro: void SCM_SET_CELL_OBJECT_0 (SCM x, SCM o)
Macro: void SCM_SET_CELL_OBJECT_1 (SCM x, SCM o)
Macro: void SCM_SET_CELL_OBJECT_2 (SCM x, SCM o)
Macro: void SCM_SET_CELL_OBJECT_3 (SCM x, SCM o)

Write the Scheme object o into field number n of the heap object referenced by the non-immediate Scheme value x. Values that are written into heap objects as objects should only be read using the SCM_CELL_OBJECT macros.

Summary:


Previous: , Up: The SCM Type in Guile   [Contents][Index]