mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-14 23:50:19 +02:00
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.)
This commit is contained in:
parent
4125c76761
commit
4650d11502
2 changed files with 16 additions and 2 deletions
|
@ -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);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue