manpagez: man pages & more
info guile
Home | html | info | man
[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.5.7 Double Smobs

Smobs are called smob because they are small: they normally have only room for one void* or SCM value plus 16 bits. The reason for this is that smobs are directly implemented by using the low-level, two-word cells of Guile that are also used to implement pairs, for example. (see section Data Representation for the details.) One word of the two-word cells is used for SCM_SMOB_DATA (or SCM_SMOB_OBJECT), the other contains the 16-bit type tag and the 16 extra bits.

In addition to the fundamental two-word cells, Guile also has four-word cells, which are appropriately called double cells. You can use them for double smobs and get two more immediate words of type scm_t_bits.

A double smob is created with scm_new_double_smob. Its immediate words can be retrieved as scm_t_bits with SCM_SMOB_DATA_2 and SCM_SMOB_DATA_3 in addition to SCM_SMOB_DATA. Unsurprisingly, the words can be set to scm_t_bits values with SCM_SET_SMOB_DATA_2 and SCM_SET_SMOB_DATA_3.

Of course there are also SCM_SMOB_OBJECT_2, SCM_SMOB_OBJECT_3, SCM_SET_SMOB_OBJECT_2, and SCM_SET_SMOB_OBJECT_3.


This document was generated on April 20, 2013 using texi2html 5.0.

© manpagez.com 2000-2019
Individual documents may contain additional copyright information.