Next: , Up: Scheme

13.1 Scheme kernel data types

Files: scheme/glt_kernel.c, scheme/glt_kernel.h

For accessing VRR objects from Scheme, it is needed to create Scheme objects for VRR objects. We call these Scheme objects proxies. Proxy data types are defined during kernel initialization, in the function glt_kernel_init(). There are three types of proxies: o, anchor and hanger proxies. From the user's point of view there a is different division based on the object kinds – in this division o proxies are in two categories: obj and go proxies, but their implementation is the same. Proxies are implemented using the GUILE's mechanism of smobs - small objects with type information and one pointer. This pointer is used to store a pointer on the target structure. So, having a proxy, it is simple to get the VRR structure (functions scm2o(), scm2anchor(), scm2hanger()). We wanted not to have more different proxies for one kernel structure, so we use a hash table to convert pointers to kernel structures to their proxies (functions o2scm(), anchor2scm(), hanger2scm()). If anyone wants a proxy to a kernel structure, it is taken from the hash table or created (and put to the hash table). A proxy increases the reference counter of the appropriate kernel structure. If garbage collector finds a proxy as unusable, then the reference is freed and the proxy is removed from the hash table.