print.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /* classes: h_files */
  2. #ifndef PRINTH
  3. #define PRINTH
  4. /* Copyright (C) 1995,1996,1998, 2000, 2002 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., 59 Temple Place, Suite 330,
  19. * Boston, MA 02111-1307 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_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_NIMP(p) && (SCM_TYP16 (p) == scm_tc16_port_with_ps))
  64. #define SCM_PORT_WITH_PS_PORT(p) SCM_CADR (p)
  65. #define SCM_PORT_WITH_PS_PS(p) SCM_CDDR (p)
  66. #define SCM_COERCE_OUTPORT(p) (SCM_NIMP (p) && SCM_PORT_WITH_PS_P (p) \
  67. ? SCM_PORT_WITH_PS_PORT (p) \
  68. : p)
  69. #define SCM_PRINT_STATE_LAYOUT "sruwuwuwuwuwpwuwuwuruopr"
  70. typedef struct scm_print_state {
  71. SCM handle; /* Struct handle */
  72. int revealed; /* Has the state escaped to Scheme? */
  73. unsigned long writingp; /* Writing? */
  74. unsigned long fancyp; /* Fancy printing? */
  75. unsigned long level; /* Max level */
  76. unsigned long length; /* Max number of objects per level */
  77. SCM hot_ref; /* Hot reference */
  78. unsigned long list_offset;
  79. unsigned long top; /* Top of reference stack */
  80. unsigned long ceiling; /* Max size of reference stack */
  81. SCM *ref_stack; /* Stack of references used during
  82. circular reference detection */
  83. SCM ref_vect;
  84. } scm_print_state;
  85. extern SCM scm_print_state_vtable;
  86. /* ? scm or long? print.h and print.c disagree */
  87. extern long scm_tc16_port_with_ps;
  88. extern SCM scm_print_options (SCM setting);
  89. SCM scm_make_print_state (void);
  90. void scm_free_print_state (SCM print_state);
  91. extern void scm_intprint (long n, int radix, SCM port);
  92. extern void scm_ipruk (char *hdr, SCM ptr, SCM port);
  93. extern void scm_iprlist (char *hdr, SCM exp, int tlr, SCM port, scm_print_state *pstate);
  94. extern void scm_prin1 (SCM exp, SCM port, int writingp);
  95. extern void scm_iprin1 (SCM exp, SCM port, scm_print_state *pstate);
  96. extern SCM scm_write (SCM obj, SCM port);
  97. extern SCM scm_display (SCM obj, SCM port);
  98. extern SCM scm_simple_format (SCM port, SCM message, SCM args);
  99. extern SCM scm_newline (SCM port);
  100. extern SCM scm_write_char (SCM chr, SCM port);
  101. extern SCM scm_printer_apply (SCM proc, SCM exp, SCM port,
  102. scm_print_state *);
  103. extern SCM scm_port_with_print_state (SCM port, SCM pstate);
  104. extern SCM scm_get_print_state (SCM port);
  105. extern int scm_valid_oport_value_p (SCM val);
  106. extern void scm_init_print (void);
  107. #ifdef GUILE_DEBUG
  108. extern SCM scm_current_pstate (void);
  109. #endif
  110. #endif /* PRINTH */
  111. /*
  112. Local Variables:
  113. c-file-style: "gnu"
  114. End:
  115. */