This is the mail archive of the
guile@sourceware.cygnus.com
mailing list for the Guile project.
struct interface
- To: Guile Mailing List <guile at sourceware dot cygnus dot com>
- Subject: struct interface
- From: Dirk Herrmann <dirk at ida dot ing dot tu-bs dot de>
- Date: Thu, 6 Apr 2000 10:01:44 +0200 (MEST)
Hi!
Similar as with cells, struct data memory can also hold raw data and
scheme objects. I am currently changing the data part from SCM[] to
scm_bits_t, thus following the paradigm that SCM should only be used if
we are sure that the content is a valid scheme object.
However, as with cells, it would make sense to provide low-level macros to
read struct slots as raw data as well as scheme objects in order to reduce
the amount of packing/unpacking on the user side.
Thus, I suggest the following macros:
SCM_STRUCT_WORD(s,n)
--> deliver the user field number n of struct s as raw data
This will translate into:
SCM_STRUCT_DATA(s)[n]
SCM_STRUCT_OBJECT(s,n)
--> deliver the user field number n of struct s as a scheme object
This will translate into:
SCM_PACK (SCM_STRUCT_DATA(s)[n])
SCM_SET_STRUCT_WORD(s,n,v)
--> set the user field number n of struct s as raw data
This will translate into:
(SCM_STRUCT_DATA(s)[n] = v)
SCM_SET_STRUCT_OBJECT(s,n,v)
--> set the user field number n of struct s as a scheme object
This will translate into:
(SCM_STRUCT_DATA(s)[n] = SCM_UNPACK (v))
We could also provide the corresponding macros a la SCM_STRUCT_WORD_0, but
I'm not sure if this is necessary.
Best regards
Dirk Herrmann