Node:Accessing Cell Entries, Next:, Previous:Heap Cell Type Information, Up:Unpacking the SCM type



18.2.7.5 Accessing Cell Entries

For a non-immediate Scheme object x, the object type can be determined by reading the cell type entry using the SCM_CELL_TYPE macro. For each different type of cell it is known which cell entries hold Scheme objects and which cell entries hold raw C data. To access the different cell entries appropriately, the following macros are provided.

scm_t_bits SCM_CELL_WORD (SCM x, unsigned int n) Macro
Deliver the cell entry n of the heap cell referenced by the non-immediate Scheme object x as raw data. It is illegal, to access cell entries that hold Scheme objects by using these macros. For convenience, the following macros are also provided.
  • SCM_CELL_WORD_0 (x) => SCM_CELL_WORD (x, 0)
  • SCM_CELL_WORD_1 (x) => SCM_CELL_WORD (x, 1)
  • ...
  • SCM_CELL_WORD_n (x) => SCM_CELL_WORD (x, n)

SCM SCM_CELL_OBJECT (SCM x, unsigned int n) Macro
Deliver the cell entry n of the heap cell referenced by the non-immediate Scheme object x as a Scheme object. It is illegal, to access cell entries that do not hold Scheme objects by using these macros. For convenience, the following macros are also provided.
  • SCM_CELL_OBJECT_0 (x) => SCM_CELL_OBJECT (x, 0)
  • SCM_CELL_OBJECT_1 (x) => SCM_CELL_OBJECT (x, 1)
  • ...
  • SCM_CELL_OBJECT_n (x) => SCM_CELL_OBJECT (x, n)

void SCM_SET_CELL_WORD (SCM x, unsigned int n, scm_t_bits w) Macro
Write the raw C value w into entry number n of the heap cell referenced by the non-immediate Scheme value x. Values that are written into cells this way may only be read from the cells using the SCM_CELL_WORD macros or, in case cell entry 0 is written, using the SCM_CELL_TYPE macro. For the special case of cell entry 0 it has to be made sure that w contains a cell type information which does not describe a Scheme object. For convenience, the following macros are also provided.
  • SCM_SET_CELL_WORD_0 (x, w) => SCM_SET_CELL_WORD (x, 0, w)
  • SCM_SET_CELL_WORD_1 (x, w) => SCM_SET_CELL_WORD (x, 1, w)
  • ...
  • SCM_SET_CELL_WORD_n (x, w) => SCM_SET_CELL_WORD (x, n, w)

void SCM_SET_CELL_OBJECT (SCM x, unsigned int n, SCM o) Macro
Write the Scheme object o into entry number n of the heap cell referenced by the non-immediate Scheme value x. Values that are written into cells this way may only be read from the cells using the SCM_CELL_OBJECT macros or, in case cell entry 0 is written, using the SCM_CELL_TYPE macro. For the special case of cell entry 0 the writing of a Scheme object into this cell is only allowed if the cell forms a Scheme pair. For convenience, the following macros are also provided.
  • SCM_SET_CELL_OBJECT_0 (x, o) => SCM_SET_CELL_OBJECT (x, 0, o)
  • SCM_SET_CELL_OBJECT_1 (x, o) => SCM_SET_CELL_OBJECT (x, 1, o)
  • ...
  • SCM_SET_CELL_OBJECT_n (x, o) => SCM_SET_CELL_OBJECT (x, n, o)

Summary: