summaryrefslogtreecommitdiff
path: root/libguile
diff options
context:
space:
mode:
authorAndy Wingo <wingo@unquote.local>2008-04-10 01:32:14 +0200
committerLudovic Courtès <ludo@gnu.org>2008-04-10 23:21:30 +0200
commit4650d115020924e8da5547d4c346cbe5cd01029e (patch)
tree656c5c7e30d6552636722c52cbf455ff2a2ae40c /libguile
parent4125c767611836b984749045d4566d3d1c9ed393 (diff)
downloadguile-4650d115020924e8da5547d4c346cbe5cd01029e.tar.gz
fix struct-ref and struct-set! on "light" structs
* libguile/struct.c (scm_struct_ref, scm_struct_set_x): "Light" structs have no hidden words (members of the SCM_STRUCT_DATA(x) array accessed with negative indices). In that case, determine the number of fields from the length of the struct layout descriptor. (Most GOOPS instances are light structs.)
Diffstat (limited to 'libguile')
-rw-r--r--libguile/ChangeLog6
-rw-r--r--libguile/struct.c12
2 files changed, 16 insertions, 2 deletions
diff --git a/libguile/ChangeLog b/libguile/ChangeLog
index cce8dbb3b..0d91c6b56 100644
--- a/libguile/ChangeLog
+++ b/libguile/ChangeLog
@@ -1,5 +1,11 @@
2008-04-10 Andy Wingo <wingo@pobox.com>
+ * struct.c (scm_struct_ref, scm_struct_set_x): "Light" structs
+ have no hidden words (members of the SCM_STRUCT_DATA(x) array
+ accessed with negative indices). In that case, determine the
+ number of fields from the length of the struct layout
+ descriptor. (Most GOOPS instances are light structs.)
+
* goops.c (wrap_init): Initialize 'u' slots to 0, not some random
SCM value.
diff --git a/libguile/struct.c b/libguile/struct.c
index c8d34a4db..2d36303b4 100644
--- a/libguile/struct.c
+++ b/libguile/struct.c
@@ -659,7 +659,11 @@ SCM_DEFINE (scm_struct_ref, "struct-ref", 2, 0, 0,
fields_desc = scm_i_symbol_chars (layout);
layout_len = scm_i_symbol_length (layout);
- n_fields = data[scm_struct_i_n_words];
+ if (SCM_STRUCT_VTABLE_FLAGS (handle) & SCM_STRUCTF_LIGHT)
+ /* no extra words */
+ n_fields = layout_len / 2;
+ else
+ n_fields = data[scm_struct_i_n_words];
SCM_ASSERT_RANGE(1, pos, p < n_fields);
@@ -736,7 +740,11 @@ SCM_DEFINE (scm_struct_set_x, "struct-set!", 3, 0, 0,
fields_desc = scm_i_symbol_chars (layout);
layout_len = scm_i_symbol_length (layout);
- n_fields = data[scm_struct_i_n_words];
+ if (SCM_STRUCT_VTABLE_FLAGS (handle) & SCM_STRUCTF_LIGHT)
+ /* no extra words */
+ n_fields = layout_len / 2;
+ else
+ n_fields = data[scm_struct_i_n_words];
SCM_ASSERT_RANGE (1, pos, p < n_fields);