print.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /* classes: h_files */
  2. #ifndef SCM_PRINT_H
  3. #define SCM_PRINT_H
  4. /* Copyright (C) 1995,1996,1998,2000,2001 Free Software Foundation, Inc.
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2, or (at your option)
  9. * any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this software; see the file COPYING. If not, write to
  18. * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  19. * Boston, MA 02110-1301 USA
  20. *
  21. * As a special exception, the Free Software Foundation gives permission
  22. * for additional uses of the text contained in its release of GUILE.
  23. *
  24. * The exception is that, if you link the GUILE library with other files
  25. * to produce an executable, this does not by itself cause the
  26. * resulting executable to be covered by the GNU General Public License.
  27. * Your use of that executable is in no way restricted on account of
  28. * linking the GUILE library code into it.
  29. *
  30. * This exception does not however invalidate any other reasons why
  31. * the executable file might be covered by the GNU General Public License.
  32. *
  33. * This exception applies only to the code released by the
  34. * Free Software Foundation under the name GUILE. If you copy
  35. * code from other Free Software Foundation releases into a copy of
  36. * GUILE, as the General Public License permits, the exception does
  37. * not apply to the code that you add in this way. To avoid misleading
  38. * anyone as to the status of such modified files, you must delete
  39. * this exception notice from them.
  40. *
  41. * If you write modifications of your own for GUILE, it is your choice
  42. * whether to permit this exception to apply to your modifications.
  43. * If you do not wish that, delete this exception notice. */
  44. #include "libguile/__scm.h"
  45. #include "libguile/options.h"
  46. extern scm_t_option scm_print_opts[];
  47. #define SCM_PRINT_CLOSURE (SCM_PACK (scm_print_opts[0].val))
  48. #define SCM_PRINT_SOURCE_P ((int) scm_print_opts[1].val)
  49. #define SCM_N_PRINT_OPTIONS 2
  50. /* State information passed around during printing.
  51. */
  52. #define SCM_PRINT_STATE_P(obj) (SCM_STRUCTP(obj) \
  53. && (SCM_EQ_P (SCM_STRUCT_VTABLE(obj), \
  54. scm_print_state_vtable)))
  55. #define SCM_PRINT_STATE(obj) ((scm_print_state *) SCM_STRUCT_DATA (obj))
  56. #define RESET_PRINT_STATE(pstate) \
  57. do { \
  58. pstate->list_offset = 0; \
  59. pstate->top = 0; \
  60. } while (0)
  61. #define SCM_WRITINGP(pstate) ((pstate)->writingp)
  62. #define SCM_SET_WRITINGP(pstate, x) { (pstate)->writingp = (x); }
  63. #define SCM_PORT_WITH_PS_P(p) SCM_TYP16_PREDICATE (scm_tc16_port_with_ps, p)
  64. #define SCM_PORT_WITH_PS_PORT(p) SCM_CAR (SCM_CELL_OBJECT_1 (p))
  65. #define SCM_PORT_WITH_PS_PS(p) SCM_CDR (SCM_CELL_OBJECT_1 (p))
  66. #define SCM_COERCE_OUTPORT(p) \
  67. (SCM_PORT_WITH_PS_P (p) ? SCM_PORT_WITH_PS_PORT (p) : p)
  68. #define SCM_PRINT_STATE_LAYOUT "sruwuwuwuwuwpwuwuwuruopr"
  69. typedef struct scm_print_state {
  70. SCM handle; /* Struct handle */
  71. int revealed; /* Has the state escaped to Scheme? */
  72. unsigned long writingp; /* Writing? */
  73. unsigned long fancyp; /* Fancy printing? */
  74. unsigned long level; /* Max level */
  75. unsigned long length; /* Max number of objects per level */
  76. SCM hot_ref; /* Hot reference */
  77. unsigned long list_offset;
  78. unsigned long top; /* Top of reference stack */
  79. unsigned long ceiling; /* Max size of reference stack */
  80. SCM *ref_stack; /* Stack of references used during
  81. circular reference detection */
  82. SCM ref_vect;
  83. } scm_print_state;
  84. extern SCM scm_print_state_vtable;
  85. extern scm_t_bits scm_tc16_port_with_ps;
  86. extern SCM scm_print_options (SCM setting);
  87. SCM scm_make_print_state (void);
  88. void scm_free_print_state (SCM print_state);
  89. extern void scm_intprint (long n, int radix, SCM port);
  90. extern void scm_ipruk (char *hdr, SCM ptr, SCM port);
  91. extern void scm_iprlist (char *hdr, SCM exp, int tlr, SCM port, scm_print_state *pstate);
  92. extern void scm_print_symbol_name (const char *str, size_t len, SCM port);
  93. extern void scm_prin1 (SCM exp, SCM port, int writingp);
  94. extern void scm_iprin1 (SCM exp, SCM port, scm_print_state *pstate);
  95. extern SCM scm_write (SCM obj, SCM port);
  96. extern SCM scm_display (SCM obj, SCM port);
  97. extern SCM scm_simple_format (SCM port, SCM message, SCM args);
  98. extern SCM scm_newline (SCM port);
  99. extern SCM scm_write_char (SCM chr, SCM port);
  100. extern SCM scm_printer_apply (SCM proc, SCM exp, SCM port, scm_print_state *);
  101. extern SCM scm_port_with_print_state (SCM port, SCM pstate);
  102. extern SCM scm_get_print_state (SCM port);
  103. extern int scm_valid_oport_value_p (SCM val);
  104. extern void scm_init_print (void);
  105. #ifdef GUILE_DEBUG
  106. extern SCM scm_current_pstate (void);
  107. #endif
  108. #endif /* SCM_PRINT_H */
  109. /*
  110. Local Variables:
  111. c-file-style: "gnu"
  112. End:
  113. */