summaryrefslogtreecommitdiff
path: root/libguile/print.h
diff options
context:
space:
mode:
authorMarius Vollmer <mvo@zagadka.de>1997-10-02 14:55:02 +0000
committerMarius Vollmer <mvo@zagadka.de>1997-10-02 14:55:02 +0000
commitbb35f3151b168022db4d3a04376182f9604371d5 (patch)
tree7861980c03f5628eda106cf5e09195b864898930 /libguile/print.h
parentc68296f8fd1787572f24930ebd9b9ca5a28b29fa (diff)
downloadguile-bb35f3151b168022db4d3a04376182f9604371d5.tar.gz
* print.h (SCM_PRINT_STATE_P, SCM_COERCE_OPORT): New macros.
(struct scm_print_state) [revealed]: New field. (scm_print_state_vtable): Make visible to the outside world for type checking purposes. (scm_valid_oport_value_p): New prototype. * print.c (scm_valid_oport_value_p): New function to check whether a certain value is acceptable as a port argument. (scm_print_state_vtable): New variable. (scm_free_print_state): Set `revealed' field to false. (scm_iprin1): Call user supplied closure printer with scm_printer_apply. Print in the traditional way when there isn't one or when it returns #f. (scm_prin1, scm_display, scm_write, scm_newline, scm_write_char): Accept a port/print-state pair in addition to just a port. (scm_prin1): Don't return the print_state to the pool when it has been `revealed'. (scm_printer_apply): Set `revealed' field of print_state to true. (scm_init_print): Set scm_print_state_vtable. (print_state_fluid, print_state_fluid_num): Removed.
Diffstat (limited to 'libguile/print.h')
-rw-r--r--libguile/print.h15
1 files changed, 13 insertions, 2 deletions
diff --git a/libguile/print.h b/libguile/print.h
index 592c82b1d..2025c8f89 100644
--- a/libguile/print.h
+++ b/libguile/print.h
@@ -56,6 +56,9 @@ extern scm_option scm_print_opts[];
/* State information passed around during printing.
*/
+#define SCM_PRINT_STATE_P(obj) (SCM_NIMP(obj) && SCM_STRUCTP(obj) && \
+ SCM_STRUCT_VTABLE(obj) == \
+ scm_print_state_vtable)
#define SCM_PRINT_STATE(obj) ((scm_print_state *) SCM_STRUCT_DATA (obj))
#define RESET_PRINT_STATE(pstate) \
@@ -67,9 +70,13 @@ extern scm_option scm_print_opts[];
#define SCM_WRITINGP(pstate) ((pstate)->writingp)
#define SCM_SET_WRITINGP(pstate, x) { (pstate)->writingp = (x); }
-#define SCM_PRINT_STATE_LAYOUT "sruwuwuwuwpwuwuwuruopr"
+#define SCM_COERCE_OPORT(p) ((SCM_NIMP(p) && SCM_PRINT_STATE_P(SCM_CDR (p)))? \
+ SCM_CAR(p) : p)
+
+#define SCM_PRINT_STATE_LAYOUT "sruwuwuwuwuwpwuwuwuruopr"
typedef struct scm_print_state {
SCM handle; /* Struct handle */
+ int revealed; /* Has the state escaped to Scheme? */
unsigned long writingp; /* Writing? */
unsigned long fancyp; /* Fancy printing? */
unsigned long level; /* Max level */
@@ -83,6 +90,8 @@ typedef struct scm_print_state {
SCM ref_vect;
} scm_print_state;
+extern SCM scm_print_state_vtable;
+
extern SCM scm_print_options SCM_P ((SCM setting));
SCM scm_make_print_state SCM_P ((void));
void scm_free_print_state SCM_P ((SCM print_state));
@@ -95,7 +104,9 @@ extern SCM scm_write SCM_P ((SCM obj, SCM port));
extern SCM scm_display SCM_P ((SCM obj, SCM port));
extern SCM scm_newline SCM_P ((SCM port));
extern SCM scm_write_char SCM_P ((SCM chr, SCM port));
-extern SCM scm_printer_apply SCM_P ((SCM proc, SCM exp, SCM port, scm_print_state *));
+extern SCM scm_printer_apply SCM_P ((SCM proc, SCM exp, SCM port,
+ scm_print_state *));
+extern int scm_valid_oport_value_p SCM_P ((SCM val));
extern void scm_init_print SCM_P ((void));
#endif /* PRINTH */