From bafcafb27071fad976c9807f24bc801e3dfbfaa2 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Tue, 3 Jun 1997 21:49:52 +0000 Subject: * struct.c (scm_struct_ref, scm_struct_set_x): Use scm_struct_i_n_words to get the number of fields, not -scm_struct_n_extra_words. On the route to fancier struct printing: * struct.c (scm_print_struct): New function to print a structure. Include "genio.h" to support it. This function doesn't do anything interesting right now, but I think it should be here anyway. * struct.h: Include "print.h" and add prototype for scm_print_struct. * print.c (scm_iprin1): Call scm_print_struct instead of trying to print structures ourself. --- libguile/struct.c | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) (limited to 'libguile/struct.c') diff --git a/libguile/struct.c b/libguile/struct.c index 525df2638..6f2261ec5 100644 --- a/libguile/struct.c +++ b/libguile/struct.c @@ -43,6 +43,7 @@ #include #include "_scm.h" #include "chars.h" +#include "genio.h" #include "struct.h" @@ -434,7 +435,7 @@ scm_struct_ref (handle, pos) p = SCM_INUM (pos); fields_desc = (unsigned char *)SCM_CHARS (layout); - n_fields = data[- scm_struct_n_extra_words] - scm_struct_n_extra_words; + n_fields = data[scm_struct_i_n_words] - scm_struct_n_extra_words; SCM_ASSERT (p < n_fields, pos, SCM_OUTOFRANGE, s_struct_ref); @@ -516,7 +517,7 @@ scm_struct_set_x (handle, pos, val) p = SCM_INUM (pos); fields_desc = (unsigned char *)SCM_CHARS (layout); - n_fields = data[- scm_struct_n_extra_words] - scm_struct_n_extra_words; + n_fields = data[scm_struct_i_n_words] - scm_struct_n_extra_words; SCM_ASSERT (p < n_fields, pos, SCM_OUTOFRANGE, s_struct_set_x); @@ -595,6 +596,41 @@ scm_struct_vtable_tag (handle) +void +scm_print_struct (exp, port, pstate) + SCM exp; + SCM port; + scm_print_state *pstate; +{ +#if 0 /* XXX - too verbose */ + SCM * data; + SCM layout; + int p; + int n_fields; + unsigned char * fields_desc; + unsigned char field_type; + + layout = SCM_STRUCT_LAYOUT (exp); + data = SCM_STRUCT_DATA (exp); + + fields_desc = (unsigned char *)SCM_CHARS (layout); + n_fields = data[scm_struct_i_n_words] - scm_struct_n_extra_words; + + scm_gen_write (scm_regular_string, "#', port); +#else + scm_gen_write (scm_regular_string, "#', port); +#endif +} void scm_init_struct () -- cgit v1.2.3