1 /* Copyright (C) 1995-1999 Free Software Foundation, Inc.
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2, or (at your option)
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this software; see the file COPYING. If not, write to
15 * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
16 * Boston, MA 02111-1307 USA
18 * As a special exception, the Free Software Foundation gives permission
19 * for additional uses of the text contained in its release of GUILE.
21 * The exception is that, if you link the GUILE library with other files
22 * to produce an executable, this does not by itself cause the
23 * resulting executable to be covered by the GNU General Public License.
24 * Your use of that executable is in no way restricted on account of
25 * linking the GUILE library code into it.
27 * This exception does not however invalidate any other reasons why
28 * the executable file might be covered by the GNU General Public License.
30 * This exception applies only to the code released by the
31 * Free Software Foundation under the name GUILE. If you copy
32 * code from other Free Software Foundation releases into a copy of
33 * GUILE, as the General Public License permits, the exception does
34 * not apply to the code that you add in this way. To avoid misleading
35 * anyone as to the status of such modified files, you must delete
36 * this exception notice from them.
38 * If you write modifications of your own for GUILE, it is your choice
39 * whether to permit this exception to apply to your modifications.
40 * If you do not wish that, delete this exception notice. */
42 /* Software engineering face-lift by Greg J. Badros, 11-Dec-1999,
43 gjb@cs.washington.edu, http://www.cs.washington.edu/homes/gjb */
62 #include "scm_validate.h"
66 /* {Names of immediate symbols}
68 * This table must agree with the declarations in scm.h: {Immediate Symbols}.
71 char *scm_isymnames
[] =
73 /* This table must agree with the declarations */
89 "#@literal-variable-ref",
90 "#@literal-variable-set!",
93 "#@call-with-current-continuation",
95 /* user visible ISYMS */
109 /* Multi-language support */
124 scm_option scm_print_opts
[] = {
125 { SCM_OPTION_SCM
, "closure-hook", SCM_BOOL_F
,
126 "Hook for printing closures." },
127 { SCM_OPTION_BOOLEAN
, "source", 0,
128 "Print closures with source." }
131 SCM_DEFINE (scm_print_options
, "print-options-interface", 0, 1, 0,
134 #define FUNC_NAME s_scm_print_options
136 SCM ans
= scm_options (setting
,
145 /* {Printing of Scheme Objects}
148 /* Detection of circular references.
150 * Due to other constraints in the implementation, this code has bad
151 * time complexity (O (depth * N)), The printer code will be
152 * completely rewritten before next release of Guile. The new code
155 #define PUSH_REF(pstate, obj) \
157 pstate->ref_stack[pstate->top++] = (obj); \
158 if (pstate->top == pstate->ceiling) \
159 grow_ref_stack (pstate); \
162 #define ENTER_NESTED_DATA(pstate, obj, label) \
164 register unsigned long i; \
165 for (i = 0; i < pstate->top; ++i) \
166 if (pstate->ref_stack[i] == (obj)) \
168 if (pstate->fancyp) \
170 if (pstate->top - pstate->list_offset >= pstate->level) \
172 scm_putc ('#', port); \
176 PUSH_REF(pstate, obj); \
179 #define EXIT_NESTED_DATA(pstate) { --pstate->top; }
181 SCM scm_print_state_vtable
;
183 static SCM print_state_pool
;
185 #ifdef GUILE_DEBUG /* Used for debugging purposes */
187 SCM_DEFINE (scm_current_pstate
, "current-pstate", 0, 0, 0,
190 #define FUNC_NAME s_scm_current_pstate
192 return SCM_CADR (print_state_pool
);
198 #define PSTATE_SIZE 50L
201 make_print_state (void)
203 SCM print_state
= scm_make_struct (SCM_CAR (print_state_pool
), /* pstate type */
206 scm_print_state
*pstate
= SCM_PRINT_STATE (print_state
);
207 pstate
->ref_vect
= scm_make_vector (SCM_MAKINUM (PSTATE_SIZE
),
209 pstate
->ref_stack
= SCM_VELTS (pstate
->ref_vect
);
210 pstate
->ceiling
= SCM_LENGTH (pstate
->ref_vect
);
215 scm_make_print_state ()
219 /* First try to allocate a print state from the pool */
221 if (SCM_NNULLP (SCM_CDR (print_state_pool
)))
223 answer
= SCM_CADR (print_state_pool
);
224 SCM_SETCDR (print_state_pool
, SCM_CDDR (print_state_pool
));
228 return answer
? answer
: make_print_state ();
232 scm_free_print_state (SCM print_state
)
235 scm_print_state
*pstate
= SCM_PRINT_STATE (print_state
);
236 /* Cleanup before returning print state to pool.
237 * It is better to do it here. Doing it in scm_prin1
238 * would cost more since that function is called much more
242 pstate
->revealed
= 0;
243 SCM_NEWCELL (handle
);
245 SCM_SETCAR (handle
, print_state
);
246 SCM_SETCDR (handle
, SCM_CDR (print_state_pool
));
247 SCM_SETCDR (print_state_pool
, handle
);
252 grow_ref_stack (scm_print_state
*pstate
)
254 int new_size
= 2 * pstate
->ceiling
;
255 scm_vector_set_length_x (pstate
->ref_vect
, SCM_MAKINUM (new_size
));
256 pstate
->ref_stack
= SCM_VELTS (pstate
->ref_vect
);
257 pstate
->ceiling
= new_size
;
262 print_circref (SCM port
,scm_print_state
*pstate
,SCM ref
)
265 int self
= pstate
->top
- 1;
267 if (SCM_CONSP (pstate
->ref_stack
[i
]))
271 if (SCM_NCONSP (pstate
->ref_stack
[i
- 1])
272 || SCM_CDR (pstate
->ref_stack
[i
- 1]) != pstate
->ref_stack
[i
])
278 for (i
= pstate
->top
- 1; 1; --i
)
279 if (pstate
->ref_stack
[i
] == ref
)
281 scm_putc ('#', port
);
282 scm_intprint (i
- self
, 10, port
);
283 scm_putc ('#', port
);
286 /* Print generally. Handles both write and display according to PSTATE.
288 SCM_GPROC(s_write
, "write", 1, 1, 0, scm_write
, g_write
);
289 SCM_GPROC(s_display
, "display", 1, 1, 0, scm_display
, g_display
);
292 scm_iprin1 (SCM exp
, SCM port
, scm_print_state
*pstate
)
295 switch (7 & (int) exp
)
299 scm_intprint (SCM_INUM (exp
), 10, port
);
307 if (SCM_WRITINGP (pstate
))
309 scm_puts ("#\\", port
);
310 if ((i
>= 0) && (i
<= ' ') && scm_charnames
[i
])
311 scm_puts (scm_charnames
[i
], port
);
312 else if (i
< 0 || i
> '\177')
313 scm_intprint (i
, 8, port
);
320 else if (SCM_IFLAGP (exp
)
321 && ((size_t) SCM_ISYMNUM (exp
) < (sizeof scm_isymnames
/ sizeof (char *))))
322 scm_puts (SCM_ISYMCHARS (exp
), port
);
323 else if (SCM_ILOCP (exp
))
325 scm_puts ("#@", port
);
326 scm_intprint ((long) SCM_IFRAME (exp
), 10, port
);
327 scm_putc (SCM_ICDRP (exp
) ? '-' : '+', port
);
328 scm_intprint ((long) SCM_IDIST (exp
), 10, port
);
335 scm_puts ("#@", port
);
336 exp
= SCM_CAR (exp
- 1);
340 scm_ipruk ("immediate", exp
, port
);
343 switch (SCM_TYP7 (exp
))
345 case scm_tcs_cons_gloc
:
347 if (SCM_CDR (SCM_CAR (exp
) - 1L) == 0)
349 ENTER_NESTED_DATA (pstate
, exp
, circref
);
350 if (SCM_OBJ_CLASS_FLAGS (exp
) & SCM_CLASSF_GOOPS
)
352 SCM pwps
, print
= pstate
->writingp
? g_write
: g_display
;
356 scm_tc16_port_with_ps
,
357 scm_cons (port
, pstate
->handle
));
358 scm_call_generic_2 (print
, exp
, pwps
);
363 scm_print_struct (exp
, port
, pstate
);
365 EXIT_NESTED_DATA (pstate
);
369 case scm_tcs_cons_imcar
:
370 case scm_tcs_cons_nimcar
:
371 ENTER_NESTED_DATA (pstate
, exp
, circref
);
372 scm_iprlist ("(", exp
, ')', port
, pstate
);
373 EXIT_NESTED_DATA (pstate
);
376 print_circref (port
, pstate
, exp
);
379 if (!SCM_CLOSUREP (SCM_CDR (exp
)))
381 case scm_tcs_closures
:
382 /* The user supplied print closure procedure must handle
383 macro closures as well. */
384 if (SCM_FALSEP (scm_procedure_p (SCM_PRINT_CLOSURE
))
385 || SCM_FALSEP (scm_printer_apply (SCM_PRINT_CLOSURE
,
389 if (SCM_TYP16 (exp
) == scm_tc16_macro
)
391 /* Printing a macro. */
393 name
= scm_macro_name (exp
);
394 if (!SCM_CLOSUREP (SCM_CDR (exp
)))
397 scm_puts ("#<primitive-", port
);
401 code
= SCM_CODE (SCM_CDR (exp
));
402 env
= SCM_ENV (SCM_CDR (exp
));
403 scm_puts ("#<", port
);
405 if (SCM_CAR (exp
) & (3L << 16))
406 scm_puts ("macro", port
);
408 scm_puts ("syntax", port
);
409 if (SCM_CAR (exp
) & (2L << 16))
410 scm_putc ('!', port
);
414 /* Printing a closure. */
415 name
= scm_procedure_name (exp
);
416 code
= SCM_CODE (exp
);
418 scm_puts ("#<procedure", port
);
420 if (SCM_ROSTRINGP (name
))
422 scm_putc (' ', port
);
423 scm_puts (SCM_ROCHARS (name
), port
);
427 if (SCM_PRINT_SOURCE_P
)
429 code
= scm_unmemocopy (code
,
430 SCM_EXTEND_ENV (SCM_CAR (code
),
433 ENTER_NESTED_DATA (pstate
, exp
, circref
);
434 scm_iprlist (" ", code
, '>', port
, pstate
);
435 EXIT_NESTED_DATA (pstate
);
439 if (SCM_TYP16 (exp
) != scm_tc16_macro
)
441 scm_putc (' ', port
);
442 scm_iprin1 (SCM_CAR (code
), port
, pstate
);
444 scm_putc ('>', port
);
448 scm_putc ('>', port
);
451 case scm_tc7_substring
:
453 if (SCM_WRITINGP (pstate
))
457 scm_putc ('"', port
);
458 for (i
= 0; i
< SCM_ROLENGTH (exp
); ++i
)
459 switch (SCM_ROCHARS (exp
)[i
])
463 scm_putc ('\\', port
);
465 scm_putc (SCM_ROCHARS (exp
)[i
], port
);
467 scm_putc ('"', port
);
471 scm_lfwrite (SCM_ROCHARS (exp
), (scm_sizet
) SCM_ROLENGTH (exp
),
474 case scm_tcs_symbols
:
484 len
= SCM_LENGTH (exp
);
485 str
= SCM_CHARS (exp
);
492 scm_lfwrite ("#{}#", 4, port
);
494 for (end
= pos
; end
< len
; ++end
)
497 #ifdef BRACKETS_AS_PARENS
505 case SCM_WHITE_SPACES
:
506 case SCM_LINE_INCREMENTORS
:
515 scm_lfwrite ("#{", 2, port
);
520 scm_lfwrite (str
+ pos
, end
- pos
, port
);
526 scm_lfwrite (buf
, 2, port
);
548 scm_lfwrite (str
+ pos
, end
- pos
, port
);
550 scm_lfwrite ("}#", 2, port
);
554 ENTER_NESTED_DATA (pstate
, exp
, circref
);
555 if (SCM_IS_WHVEC (exp
))
556 scm_puts ("#wh(", port
);
558 scm_puts ("#w(", port
);
559 goto common_vector_printer
;
562 ENTER_NESTED_DATA (pstate
, exp
, circref
);
563 scm_puts ("#(", port
);
564 common_vector_printer
:
567 int last
= SCM_LENGTH (exp
) - 1;
569 if (pstate
->fancyp
&& SCM_LENGTH (exp
) > pstate
->length
)
571 last
= pstate
->length
- 1;
574 for (i
= 0; i
< last
; ++i
)
577 scm_iprin1 (SCM_VELTS (exp
)[i
], port
, pstate
);
578 scm_putc (' ', port
);
583 scm_iprin1 (SCM_VELTS (exp
)[i
], port
, pstate
);
586 scm_puts (" ...", port
);
587 scm_putc (')', port
);
589 EXIT_NESTED_DATA (pstate
);
600 #ifdef HAVE_LONG_LONGS
603 scm_raprin1 (exp
, port
, pstate
);
607 scm_puts (SCM_SUBR_GENERIC (exp
) && *SCM_SUBR_GENERIC (exp
)
608 ? "#<primitive-generic "
609 : "#<primitive-procedure ",
611 scm_puts (SCM_CHARS (SCM_SNAME (exp
)), port
);
612 scm_putc ('>', port
);
617 SCM proc
= SCM_CCLO_SUBR (exp
);
618 if (proc
== scm_f_gsubr_apply
)
620 /* Print gsubrs as primitives */
621 SCM name
= scm_procedure_name (exp
);
622 scm_puts ("#<primitive-procedure", port
);
623 if (SCM_NFALSEP (name
))
625 scm_putc (' ', port
);
626 scm_puts (SCM_CHARS (name
), port
);
631 scm_puts ("#<compiled-closure ", port
);
632 scm_iprin1 (proc
, port
, pstate
);
634 scm_putc ('>', port
);
639 scm_puts ("#<procedure-with-setter", port
);
641 SCM name
= scm_procedure_name (exp
);
642 if (SCM_NFALSEP (name
))
644 scm_putc (' ', port
);
645 scm_puts (SCM_ROCHARS (name
), port
);
648 scm_putc ('>', port
);
651 scm_puts ("#<continuation ", port
);
652 scm_intprint (SCM_LENGTH (exp
), 10, port
);
653 scm_puts (" @ ", port
);
654 scm_intprint ((long) SCM_CHARS (exp
), 16, port
);
655 scm_putc ('>', port
);
659 register long i
= SCM_PTOBNUM (exp
);
661 && scm_ptobs
[i
].print
662 && (scm_ptobs
[i
].print
) (exp
, port
, pstate
))
669 ENTER_NESTED_DATA (pstate
, exp
, circref
);
670 i
= SCM_SMOBNUM (exp
);
671 if (i
< scm_numsmob
&& scm_smobs
[i
].print
672 && (scm_smobs
[i
].print
) (exp
, port
, pstate
))
674 EXIT_NESTED_DATA (pstate
);
677 EXIT_NESTED_DATA (pstate
);
678 /* Macros have their print field set to NULL. They are
679 handled at the same place as closures in order to achieve
680 non-redundancy. Placing the condition here won't slow
681 down printing of other smobs. */
682 if (SCM_TYP16 (exp
) == scm_tc16_macro
)
687 scm_ipruk ("type", exp
, port
);
692 /* Print states are necessary for circular reference safe printing.
693 * They are also expensive to allocate. Therefore print states are
694 * kept in a pool so that they can be reused.
697 /* The PORT argument can also be a print-state/port pair, which will
698 * then be used instead of allocating a new print state. This is
699 * useful for continuing a chain of print calls from Scheme. */
702 scm_prin1 (SCM exp
, SCM port
, int writingp
)
704 SCM handle
= SCM_BOOL_F
; /* Will GC protect the handle whilst unlinked */
706 scm_print_state
*pstate
;
708 /* If PORT is a print-state/port pair, use that. Else create a new
711 if (SCM_PORT_WITH_PS_P (port
))
713 pstate_scm
= SCM_PORT_WITH_PS_PS (port
);
714 port
= SCM_PORT_WITH_PS_PORT (port
);
718 /* First try to allocate a print state from the pool */
720 if (SCM_NNULLP (SCM_CDR (print_state_pool
)))
722 handle
= SCM_CDR (print_state_pool
);
723 SCM_SETCDR (print_state_pool
, SCM_CDDR (print_state_pool
));
726 if (handle
== SCM_BOOL_F
)
727 handle
= scm_cons (make_print_state (), SCM_EOL
);
728 pstate_scm
= SCM_CAR (handle
);
731 pstate
= SCM_PRINT_STATE (pstate_scm
);
732 pstate
->writingp
= writingp
;
733 scm_iprin1 (exp
, port
, pstate
);
735 /* Return print state to pool if it has been created above and
736 hasn't escaped to Scheme. */
738 if (handle
!= SCM_BOOL_F
&& !pstate
->revealed
)
741 SCM_SETCDR (handle
, SCM_CDR (print_state_pool
));
742 SCM_SETCDR (print_state_pool
, handle
);
752 scm_intprint (long n
, int radix
, SCM port
)
754 char num_buf
[SCM_INTBUFLEN
];
755 scm_lfwrite (num_buf
, scm_iint2str (n
, radix
, num_buf
), port
);
758 /* Print an object of unrecognized type.
762 scm_ipruk (char *hdr
, SCM ptr
, SCM port
)
764 scm_puts ("#<unknown-", port
);
765 scm_puts (hdr
, port
);
768 scm_puts (" (0x", port
);
769 scm_intprint (SCM_CAR (ptr
), 16, port
);
770 scm_puts (" . 0x", port
);
771 scm_intprint (SCM_CDR (ptr
), 16, port
);
772 scm_puts (") @", port
);
774 scm_puts (" 0x", port
);
775 scm_intprint (ptr
, 16, port
);
776 scm_putc ('>', port
);
784 scm_iprlist (char *hdr
,SCM exp
,int tlr
,SCM port
,scm_print_state
*pstate
)
786 register SCM hare
, tortoise
;
787 int floor
= pstate
->top
- 2;
788 scm_puts (hdr
, port
);
793 /* Run a hare and tortoise so that total time complexity will be
794 O(depth * N) instead of O(N^2). */
795 hare
= SCM_CDR (exp
);
797 while (SCM_ECONSP (hare
))
799 if (hare
== tortoise
)
801 hare
= SCM_CDR (hare
);
802 if (SCM_IMP (hare
) || SCM_NECONSP (hare
))
804 hare
= SCM_CDR (hare
);
805 tortoise
= SCM_CDR (tortoise
);
808 /* No cdr cycles intrinsic to this list */
809 scm_iprin1 (SCM_CAR (exp
), port
, pstate
);
811 for (; SCM_NIMP (exp
); exp
= SCM_CDR (exp
))
815 if (SCM_NECONSP (exp
))
817 for (i
= floor
; i
>= 0; --i
)
818 if (pstate
->ref_stack
[i
] == exp
)
820 PUSH_REF (pstate
, exp
);
821 scm_putc (' ', port
);
823 scm_iprin1 (SCM_CAR (exp
), port
, pstate
);
825 if (SCM_NNULLP (exp
))
827 scm_puts (" . ", port
);
828 scm_iprin1 (exp
, port
, pstate
);
832 scm_putc (tlr
, port
);
833 pstate
->top
= floor
+ 2;
838 int n
= pstate
->length
;
840 scm_iprin1 (SCM_CAR (exp
), port
, pstate
);
841 exp
= SCM_CDR (exp
); --n
;
842 for (; SCM_NIMP (exp
); exp
= SCM_CDR (exp
))
844 register unsigned long i
;
846 if (SCM_NECONSP (exp
))
848 for (i
= 0; i
< pstate
->top
; ++i
)
849 if (pstate
->ref_stack
[i
] == exp
)
855 scm_puts (" ...", port
);
861 PUSH_REF(pstate
, exp
);
862 ++pstate
->list_offset
;
863 scm_putc (' ', port
);
865 scm_iprin1 (SCM_CAR (exp
), port
, pstate
);
868 if (SCM_NNULLP (exp
))
870 scm_puts (" . ", port
);
871 scm_iprin1 (exp
, port
, pstate
);
874 pstate
->list_offset
-= pstate
->top
- floor
- 2;
878 pstate
->list_offset
-= pstate
->top
- floor
- 2;
881 scm_puts (" . ", port
);
882 print_circref (port
, pstate
, exp
);
889 scm_valid_oport_value_p (SCM val
)
891 return (SCM_OPOUTPORTP (val
)
892 || (SCM_PORT_WITH_PS_P (val
)
893 && SCM_OPOUTPORTP (SCM_PORT_WITH_PS_PORT (val
))));
896 /* SCM_GPROC(s_write, "write", 1, 1, 0, scm_write, g_write); */
899 scm_write (SCM obj
, SCM port
)
901 if (SCM_UNBNDP (port
))
904 SCM_ASSERT (scm_valid_oport_value_p (port
), port
, SCM_ARG2
, s_write
);
906 scm_prin1 (obj
, port
, 1);
910 scm_close_port (port
);
913 return SCM_UNSPECIFIED
;
917 /* SCM_GPROC(s_display, "display", 1, 1, 0, scm_display, g_display); */
920 scm_display (SCM obj
, SCM port
)
922 if (SCM_UNBNDP (port
))
925 SCM_ASSERT (scm_valid_oport_value_p (port
), port
, SCM_ARG2
, s_display
);
927 scm_prin1 (obj
, port
, 0);
931 scm_close_port (port
);
934 return SCM_UNSPECIFIED
;
937 SCM_DEFINE (scm_newline
, "newline", 0, 1, 0,
940 #define FUNC_NAME s_scm_newline
942 if (SCM_UNBNDP (port
))
945 SCM_VALIDATE_OPORT_VALUE (1,port
);
947 scm_putc ('\n', SCM_COERCE_OUTPORT (port
));
948 return SCM_UNSPECIFIED
;
952 SCM_DEFINE (scm_write_char
, "write-char", 1, 1, 0,
955 #define FUNC_NAME s_scm_write_char
957 if (SCM_UNBNDP (port
))
960 SCM_VALIDATE_CHAR (1,chr
);
961 SCM_VALIDATE_OPORT_VALUE (2,port
);
963 scm_putc ((int) SCM_ICHR (chr
), SCM_COERCE_OUTPORT (port
));
967 scm_close_port (port
);
970 return SCM_UNSPECIFIED
;
976 /* Call back to Scheme code to do the printing of special objects
977 * (like structs). SCM_PRINTER_APPLY applies PROC to EXP and a smob
978 * containing PORT and PSTATE. This object can be used as the port for
979 * display/write etc to continue the current print chain. The REVEALED
980 * field of PSTATE is set to true to indicate that the print state has
981 * escaped to Scheme and thus has to be freed by the GC.
984 long scm_tc16_port_with_ps
;
986 /* Print exactly as the port itself would */
989 print_port_with_ps (SCM obj
, SCM port
, scm_print_state
*pstate
)
991 obj
= SCM_PORT_WITH_PS_PORT (obj
);
992 return scm_ptobs
[SCM_PTOBNUM (obj
)].print (obj
, port
, pstate
);
996 scm_printer_apply (SCM proc
, SCM exp
, SCM port
, scm_print_state
*pstate
)
999 SCM pair
= scm_cons (port
, pstate
->handle
);
1000 SCM_NEWSMOB (pwps
, scm_tc16_port_with_ps
, pair
);
1001 pstate
->revealed
= 1;
1002 return scm_apply (proc
, exp
, scm_cons (pwps
, scm_listofnull
));
1005 SCM_DEFINE (scm_port_with_print_state
, "port-with-print-state", 2, 0, 0,
1006 (SCM port
, SCM pstate
),
1008 #define FUNC_NAME s_scm_port_with_print_state
1011 SCM_VALIDATE_OPORT_VALUE (1,port
);
1012 SCM_VALIDATE_PRINTSTATE (2,pstate
);
1013 port
= SCM_COERCE_OUTPORT (port
);
1014 SCM_NEWSMOB (pwps
, scm_tc16_port_with_ps
, scm_cons (port
, pstate
));
1019 SCM_DEFINE (scm_get_print_state
, "get-print-state", 1, 0, 0,
1022 #define FUNC_NAME s_scm_get_print_state
1024 if (SCM_PORT_WITH_PS_P (port
))
1025 return SCM_PORT_WITH_PS_PS (port
);
1026 if (SCM_OUTPORTP (port
))
1028 RETURN_SCM_WTA (1,port
);
1037 SCM vtable
, layout
, type
;
1039 scm_init_opts (scm_print_options
, scm_print_opts
, SCM_N_PRINT_OPTIONS
);
1040 vtable
= scm_make_vtable_vtable (scm_make_struct_layout (scm_nullstr
),
1043 layout
= scm_make_struct_layout (scm_makfrom0str (SCM_PRINT_STATE_LAYOUT
));
1044 type
= scm_make_struct (vtable
, SCM_INUM0
, SCM_LIST1 (layout
));
1045 scm_set_struct_vtable_name_x (type
, SCM_CAR (scm_intern0 ("print-state")));
1046 print_state_pool
= scm_permanent_object (scm_cons (type
, SCM_EOL
));
1048 scm_print_state_vtable
= type
;
1050 /* Don't want to bind a wrapper class in GOOPS, so pass 0 as arg1. */
1051 scm_tc16_port_with_ps
= scm_make_smob_type (0, 0);
1052 scm_set_smob_mark (scm_tc16_port_with_ps
, scm_markcdr
);
1053 scm_set_smob_print (scm_tc16_port_with_ps
, print_port_with_ps
);