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 */
122 scm_option scm_print_opts
[] = {
123 { SCM_OPTION_SCM
, "closure-hook", SCM_BOOL_F
,
124 "Hook for printing closures." },
125 { SCM_OPTION_BOOLEAN
, "source", 0,
126 "Print closures with source." }
129 GUILE_PROC (scm_print_options
, "print-options-interface", 0, 1, 0,
132 #define FUNC_NAME s_scm_print_options
134 SCM ans
= scm_options (setting
,
143 /* {Printing of Scheme Objects}
146 /* Detection of circular references.
148 * Due to other constraints in the implementation, this code has bad
149 * time complexity (O (depth * N)), The printer code will be
150 * completely rewritten before next release of Guile. The new code
153 #define PUSH_REF(pstate, obj) \
155 pstate->ref_stack[pstate->top++] = (obj); \
156 if (pstate->top == pstate->ceiling) \
157 grow_ref_stack (pstate); \
160 #define ENTER_NESTED_DATA(pstate, obj, label) \
162 register unsigned long i; \
163 for (i = 0; i < pstate->top; ++i) \
164 if (pstate->ref_stack[i] == (obj)) \
166 if (pstate->fancyp) \
168 if (pstate->top - pstate->list_offset >= pstate->level) \
170 scm_putc ('#', port); \
174 PUSH_REF(pstate, obj); \
177 #define EXIT_NESTED_DATA(pstate) { --pstate->top; }
179 SCM scm_print_state_vtable
;
181 static SCM print_state_pool
;
183 #ifdef GUILE_DEBUG /* Used for debugging purposes */
185 GUILE_PROC(scm_current_pstate
, "current-pstate", 0, 0, 0,
188 #define FUNC_NAME s_scm_current_pstate
190 return SCM_CADR (print_state_pool
);
196 #define PSTATE_SIZE 50L
199 make_print_state (void)
201 SCM print_state
= scm_make_struct (SCM_CAR (print_state_pool
), /* pstate type */
204 scm_print_state
*pstate
= SCM_PRINT_STATE (print_state
);
205 pstate
->ref_vect
= scm_make_vector (SCM_MAKINUM (PSTATE_SIZE
),
207 pstate
->ref_stack
= SCM_VELTS (pstate
->ref_vect
);
208 pstate
->ceiling
= SCM_LENGTH (pstate
->ref_vect
);
213 scm_make_print_state ()
217 /* First try to allocate a print state from the pool */
219 if (SCM_NNULLP (SCM_CDR (print_state_pool
)))
221 answer
= SCM_CADR (print_state_pool
);
222 SCM_SETCDR (print_state_pool
, SCM_CDDR (print_state_pool
));
226 return answer
? answer
: make_print_state ();
230 scm_free_print_state (SCM print_state
)
233 scm_print_state
*pstate
= SCM_PRINT_STATE (print_state
);
234 /* Cleanup before returning print state to pool.
235 * It is better to do it here. Doing it in scm_prin1
236 * would cost more since that function is called much more
240 pstate
->revealed
= 0;
241 SCM_NEWCELL (handle
);
243 SCM_SETCAR (handle
, print_state
);
244 SCM_SETCDR (handle
, SCM_CDR (print_state_pool
));
245 SCM_SETCDR (print_state_pool
, handle
);
250 grow_ref_stack (scm_print_state
*pstate
)
252 int new_size
= 2 * pstate
->ceiling
;
253 scm_vector_set_length_x (pstate
->ref_vect
, SCM_MAKINUM (new_size
));
254 pstate
->ref_stack
= SCM_VELTS (pstate
->ref_vect
);
255 pstate
->ceiling
= new_size
;
260 print_circref (SCM port
,scm_print_state
*pstate
,SCM ref
)
263 int self
= pstate
->top
- 1;
265 if (SCM_CONSP (pstate
->ref_stack
[i
]))
269 if (SCM_NCONSP (pstate
->ref_stack
[i
- 1])
270 || SCM_CDR (pstate
->ref_stack
[i
- 1]) != pstate
->ref_stack
[i
])
276 for (i
= pstate
->top
- 1; 1; --i
)
277 if (pstate
->ref_stack
[i
] == ref
)
279 scm_putc ('#', port
);
280 scm_intprint (i
- self
, 10, port
);
281 scm_putc ('#', port
);
284 /* Print generally. Handles both write and display according to PSTATE.
286 SCM_GPROC(s_write
, "write", 1, 1, 0, scm_write
, g_write
);
287 SCM_GPROC(s_display
, "display", 1, 1, 0, scm_display
, g_display
);
290 scm_iprin1 (SCM exp
, SCM port
, scm_print_state
*pstate
)
293 switch (7 & (int) exp
)
297 scm_intprint (SCM_INUM (exp
), 10, port
);
305 if (SCM_WRITINGP (pstate
))
307 scm_puts ("#\\", port
);
308 if ((i
>= 0) && (i
<= ' ') && scm_charnames
[i
])
309 scm_puts (scm_charnames
[i
], port
);
310 else if (i
< 0 || i
> '\177')
311 scm_intprint (i
, 8, port
);
318 else if (SCM_IFLAGP (exp
)
319 && ((size_t) SCM_ISYMNUM (exp
) < (sizeof scm_isymnames
/ sizeof (char *))))
320 scm_puts (SCM_ISYMCHARS (exp
), port
);
321 else if (SCM_ILOCP (exp
))
323 scm_puts ("#@", port
);
324 scm_intprint ((long) SCM_IFRAME (exp
), 10, port
);
325 scm_putc (SCM_ICDRP (exp
) ? '-' : '+', port
);
326 scm_intprint ((long) SCM_IDIST (exp
), 10, port
);
333 scm_puts ("#@", port
);
334 exp
= SCM_CAR (exp
- 1);
338 scm_ipruk ("immediate", exp
, port
);
341 switch (SCM_TYP7 (exp
))
343 case scm_tcs_cons_gloc
:
345 if (SCM_CDR (SCM_CAR (exp
) - 1L) == 0)
347 ENTER_NESTED_DATA (pstate
, exp
, circref
);
348 if (SCM_OBJ_CLASS_FLAGS (exp
) & SCM_CLASSF_GOOPS
)
350 SCM pwps
, print
= pstate
->writingp
? g_write
: g_display
;
354 scm_tc16_port_with_ps
,
355 scm_cons (port
, pstate
->handle
));
356 scm_call_generic_2 (print
, exp
, pwps
);
361 scm_print_struct (exp
, port
, pstate
);
363 EXIT_NESTED_DATA (pstate
);
367 case scm_tcs_cons_imcar
:
368 case scm_tcs_cons_nimcar
:
369 ENTER_NESTED_DATA (pstate
, exp
, circref
);
370 scm_iprlist ("(", exp
, ')', port
, pstate
);
371 EXIT_NESTED_DATA (pstate
);
374 print_circref (port
, pstate
, exp
);
377 if (!SCM_CLOSUREP (SCM_CDR (exp
)))
379 case scm_tcs_closures
:
380 /* The user supplied print closure procedure must handle
381 macro closures as well. */
382 if (SCM_FALSEP (scm_procedure_p (SCM_PRINT_CLOSURE
))
383 || SCM_FALSEP (scm_printer_apply (SCM_PRINT_CLOSURE
,
387 if (SCM_TYP16 (exp
) == scm_tc16_macro
)
389 /* Printing a macro. */
391 name
= scm_macro_name (exp
);
392 if (!SCM_CLOSUREP (SCM_CDR (exp
)))
395 scm_puts ("#<primitive-", port
);
399 code
= SCM_CODE (SCM_CDR (exp
));
400 env
= SCM_ENV (SCM_CDR (exp
));
401 scm_puts ("#<", port
);
403 if (SCM_CAR (exp
) & (3L << 16))
404 scm_puts ("macro", port
);
406 scm_puts ("syntax", port
);
407 if (SCM_CAR (exp
) & (2L << 16))
408 scm_putc ('!', port
);
412 /* Printing a closure. */
413 name
= scm_procedure_name (exp
);
414 code
= SCM_CODE (exp
);
416 scm_puts ("#<procedure", port
);
418 if (SCM_NIMP (name
) && SCM_ROSTRINGP (name
))
420 scm_putc (' ', port
);
421 scm_puts (SCM_ROCHARS (name
), port
);
425 if (SCM_PRINT_SOURCE_P
)
427 code
= scm_unmemocopy (code
,
428 SCM_EXTEND_ENV (SCM_CAR (code
),
431 ENTER_NESTED_DATA (pstate
, exp
, circref
);
432 scm_iprlist (" ", code
, '>', port
, pstate
);
433 EXIT_NESTED_DATA (pstate
);
437 if (SCM_TYP16 (exp
) != scm_tc16_macro
)
439 scm_putc (' ', port
);
440 scm_iprin1 (SCM_CAR (code
), port
, pstate
);
442 scm_putc ('>', port
);
446 scm_putc ('>', port
);
449 case scm_tc7_substring
:
451 if (SCM_WRITINGP (pstate
))
455 scm_putc ('"', port
);
456 for (i
= 0; i
< SCM_ROLENGTH (exp
); ++i
)
457 switch (SCM_ROCHARS (exp
)[i
])
461 scm_putc ('\\', port
);
463 scm_putc (SCM_ROCHARS (exp
)[i
], port
);
465 scm_putc ('"', port
);
469 scm_lfwrite (SCM_ROCHARS (exp
), (scm_sizet
) SCM_ROLENGTH (exp
),
472 case scm_tcs_symbols
:
482 len
= SCM_LENGTH (exp
);
483 str
= SCM_CHARS (exp
);
490 scm_lfwrite ("#{}#", 4, port
);
492 for (end
= pos
; end
< len
; ++end
)
495 #ifdef BRACKETS_AS_PARENS
503 case SCM_WHITE_SPACES
:
504 case SCM_LINE_INCREMENTORS
:
513 scm_lfwrite ("#{", 2, port
);
518 scm_lfwrite (str
+ pos
, end
- pos
, port
);
524 scm_lfwrite (buf
, 2, port
);
546 scm_lfwrite (str
+ pos
, end
- pos
, port
);
548 scm_lfwrite ("}#", 2, port
);
552 ENTER_NESTED_DATA (pstate
, exp
, circref
);
553 if (SCM_IS_WHVEC (exp
))
554 scm_puts ("#wh(", port
);
556 scm_puts ("#w(", port
);
557 goto common_vector_printer
;
560 ENTER_NESTED_DATA (pstate
, exp
, circref
);
561 scm_puts ("#(", port
);
562 common_vector_printer
:
565 int last
= SCM_LENGTH (exp
) - 1;
567 if (pstate
->fancyp
&& SCM_LENGTH (exp
) > pstate
->length
)
569 last
= pstate
->length
- 1;
572 for (i
= 0; i
< last
; ++i
)
575 scm_iprin1 (SCM_VELTS (exp
)[i
], port
, pstate
);
576 scm_putc (' ', port
);
581 scm_iprin1 (SCM_VELTS (exp
)[i
], port
, pstate
);
584 scm_puts (" ...", port
);
585 scm_putc (')', port
);
587 EXIT_NESTED_DATA (pstate
);
598 #ifdef HAVE_LONG_LONGS
601 scm_raprin1 (exp
, port
, pstate
);
605 scm_puts (SCM_SUBR_GENERIC (exp
) && *SCM_SUBR_GENERIC (exp
)
606 ? "#<primitive-generic "
607 : "#<primitive-procedure ",
609 scm_puts (SCM_CHARS (SCM_SNAME (exp
)), port
);
610 scm_putc ('>', port
);
615 SCM proc
= SCM_CCLO_SUBR (exp
);
616 if (proc
== scm_f_gsubr_apply
)
618 /* Print gsubrs as primitives */
619 SCM name
= scm_procedure_name (exp
);
620 scm_puts ("#<primitive-procedure", port
);
621 if (SCM_NFALSEP (name
))
623 scm_putc (' ', port
);
624 scm_puts (SCM_CHARS (name
), port
);
629 scm_puts ("#<compiled-closure ", port
);
630 scm_iprin1 (proc
, port
, pstate
);
632 scm_putc ('>', port
);
637 scm_puts ("#<procedure-with-setter", port
);
639 SCM name
= scm_procedure_name (exp
);
640 if (SCM_NFALSEP (name
))
642 scm_putc (' ', port
);
643 scm_puts (SCM_ROCHARS (name
), port
);
646 scm_putc ('>', port
);
649 scm_puts ("#<continuation ", port
);
650 scm_intprint (SCM_LENGTH (exp
), 10, port
);
651 scm_puts (" @ ", port
);
652 scm_intprint ((long) SCM_CHARS (exp
), 16, port
);
653 scm_putc ('>', port
);
657 register long i
= SCM_PTOBNUM (exp
);
659 && scm_ptobs
[i
].print
660 && (scm_ptobs
[i
].print
) (exp
, port
, pstate
))
667 ENTER_NESTED_DATA (pstate
, exp
, circref
);
668 i
= SCM_SMOBNUM (exp
);
669 if (i
< scm_numsmob
&& scm_smobs
[i
].print
670 && (scm_smobs
[i
].print
) (exp
, port
, pstate
))
672 EXIT_NESTED_DATA (pstate
);
675 EXIT_NESTED_DATA (pstate
);
676 /* Macros have their print field set to NULL. They are
677 handled at the same place as closures in order to achieve
678 non-redundancy. Placing the condition here won't slow
679 down printing of other smobs. */
680 if (SCM_TYP16 (exp
) == scm_tc16_macro
)
685 scm_ipruk ("type", exp
, port
);
690 /* Print states are necessary for circular reference safe printing.
691 * They are also expensive to allocate. Therefore print states are
692 * kept in a pool so that they can be reused.
695 /* The PORT argument can also be a print-state/port pair, which will
696 * then be used instead of allocating a new print state. This is
697 * useful for continuing a chain of print calls from Scheme. */
700 scm_prin1 (SCM exp
, SCM port
, int writingp
)
702 SCM handle
= SCM_BOOL_F
; /* Will GC protect the handle whilst unlinked */
704 scm_print_state
*pstate
;
706 /* If PORT is a print-state/port pair, use that. Else create a new
709 if (SCM_NIMP (port
) && SCM_PORT_WITH_PS_P (port
))
711 pstate_scm
= SCM_PORT_WITH_PS_PS (port
);
712 port
= SCM_PORT_WITH_PS_PORT (port
);
716 /* First try to allocate a print state from the pool */
718 if (SCM_NNULLP (SCM_CDR (print_state_pool
)))
720 handle
= SCM_CDR (print_state_pool
);
721 SCM_SETCDR (print_state_pool
, SCM_CDDR (print_state_pool
));
724 if (handle
== SCM_BOOL_F
)
725 handle
= scm_cons (make_print_state (), SCM_EOL
);
726 pstate_scm
= SCM_CAR (handle
);
729 pstate
= SCM_PRINT_STATE (pstate_scm
);
730 pstate
->writingp
= writingp
;
731 scm_iprin1 (exp
, port
, pstate
);
733 /* Return print state to pool if it has been created above and
734 hasn't escaped to Scheme. */
736 if (handle
!= SCM_BOOL_F
&& !pstate
->revealed
)
739 SCM_SETCDR (handle
, SCM_CDR (print_state_pool
));
740 SCM_SETCDR (print_state_pool
, handle
);
750 scm_intprint (long n
, int radix
, SCM port
)
752 char num_buf
[SCM_INTBUFLEN
];
753 scm_lfwrite (num_buf
, scm_iint2str (n
, radix
, num_buf
), port
);
756 /* Print an object of unrecognized type.
760 scm_ipruk (char *hdr
, SCM ptr
, SCM port
)
762 scm_puts ("#<unknown-", port
);
763 scm_puts (hdr
, port
);
766 scm_puts (" (0x", port
);
767 scm_intprint (SCM_CAR (ptr
), 16, port
);
768 scm_puts (" . 0x", port
);
769 scm_intprint (SCM_CDR (ptr
), 16, port
);
770 scm_puts (") @", port
);
772 scm_puts (" 0x", port
);
773 scm_intprint (ptr
, 16, port
);
774 scm_putc ('>', port
);
782 scm_iprlist (char *hdr
,SCM exp
,int tlr
,SCM port
,scm_print_state
*pstate
)
784 register SCM hare
, tortoise
;
785 int floor
= pstate
->top
- 2;
786 scm_puts (hdr
, port
);
791 /* Run a hare and tortoise so that total time complexity will be
792 O(depth * N) instead of O(N^2). */
793 hare
= SCM_CDR (exp
);
795 while (SCM_NIMP (hare
) && SCM_ECONSP (hare
))
797 if (hare
== tortoise
)
799 hare
= SCM_CDR (hare
);
800 if (SCM_IMP (hare
) || SCM_NECONSP (hare
))
802 hare
= SCM_CDR (hare
);
803 tortoise
= SCM_CDR (tortoise
);
806 /* No cdr cycles intrinsic to this list */
807 scm_iprin1 (SCM_CAR (exp
), port
, pstate
);
809 for (; SCM_NIMP (exp
); exp
= SCM_CDR (exp
))
813 if (SCM_NECONSP (exp
))
815 for (i
= floor
; i
>= 0; --i
)
816 if (pstate
->ref_stack
[i
] == exp
)
818 PUSH_REF (pstate
, exp
);
819 scm_putc (' ', port
);
821 scm_iprin1 (SCM_CAR (exp
), port
, pstate
);
823 if (SCM_NNULLP (exp
))
825 scm_puts (" . ", port
);
826 scm_iprin1 (exp
, port
, pstate
);
830 scm_putc (tlr
, port
);
831 pstate
->top
= floor
+ 2;
836 int n
= pstate
->length
;
838 scm_iprin1 (SCM_CAR (exp
), port
, pstate
);
839 exp
= SCM_CDR (exp
); --n
;
840 for (; SCM_NIMP (exp
); exp
= SCM_CDR (exp
))
842 register unsigned long i
;
844 if (SCM_NECONSP (exp
))
846 for (i
= 0; i
< pstate
->top
; ++i
)
847 if (pstate
->ref_stack
[i
] == exp
)
853 scm_puts (" ...", port
);
859 PUSH_REF(pstate
, exp
);
860 ++pstate
->list_offset
;
861 scm_putc (' ', port
);
863 scm_iprin1 (SCM_CAR (exp
), port
, pstate
);
866 if (SCM_NNULLP (exp
))
868 scm_puts (" . ", port
);
869 scm_iprin1 (exp
, port
, pstate
);
872 pstate
->list_offset
-= pstate
->top
- floor
- 2;
876 pstate
->list_offset
-= pstate
->top
- floor
- 2;
879 scm_puts (" . ", port
);
880 print_circref (port
, pstate
, exp
);
887 scm_valid_oport_value_p (SCM val
)
889 return (SCM_NIMP (val
)
890 && (SCM_OPOUTPORTP (val
)
891 || (SCM_PORT_WITH_PS_P (val
)
892 && SCM_OPOUTPORTP (SCM_PORT_WITH_PS_PORT (val
)))));
895 /* SCM_GPROC(s_write, "write", 1, 1, 0, scm_write, g_write); */
898 scm_write (SCM obj
, SCM port
)
900 if (SCM_UNBNDP (port
))
903 SCM_ASSERT (scm_valid_oport_value_p (port
), port
, SCM_ARG2
, s_write
);
905 scm_prin1 (obj
, port
, 1);
909 scm_close_port (port
);
912 return SCM_UNSPECIFIED
;
916 /* SCM_GPROC(s_display, "display", 1, 1, 0, scm_display, g_display); */
919 scm_display (SCM obj
, SCM port
)
921 if (SCM_UNBNDP (port
))
924 SCM_ASSERT (scm_valid_oport_value_p (port
), port
, SCM_ARG2
, s_display
);
926 scm_prin1 (obj
, port
, 0);
930 scm_close_port (port
);
933 return SCM_UNSPECIFIED
;
936 GUILE_PROC(scm_newline
, "newline", 0, 1, 0,
939 #define FUNC_NAME s_scm_newline
941 if (SCM_UNBNDP (port
))
944 SCM_VALIDATE_OPORT_VALUE(1,port
);
946 scm_putc ('\n', SCM_COERCE_OUTPORT (port
));
947 return SCM_UNSPECIFIED
;
951 GUILE_PROC(scm_write_char
, "write-char", 1, 1, 0,
954 #define FUNC_NAME s_scm_write_char
956 if (SCM_UNBNDP (port
))
959 SCM_VALIDATE_CHAR(1,chr
);
960 SCM_VALIDATE_OPORT_VALUE(2,port
);
962 scm_putc ((int) SCM_ICHR (chr
), SCM_COERCE_OUTPORT (port
));
966 scm_close_port (port
);
969 return SCM_UNSPECIFIED
;
975 /* Call back to Scheme code to do the printing of special objects
976 * (like structs). SCM_PRINTER_APPLY applies PROC to EXP and a smob
977 * containing PORT and PSTATE. This object can be used as the port for
978 * display/write etc to continue the current print chain. The REVEALED
979 * field of PSTATE is set to true to indicate that the print state has
980 * escaped to Scheme and thus has to be freed by the GC.
983 long scm_tc16_port_with_ps
;
985 /* Print exactly as the port itself would */
988 print_port_with_ps (SCM obj
, SCM port
, scm_print_state
*pstate
)
990 obj
= SCM_PORT_WITH_PS_PORT (obj
);
991 return scm_ptobs
[SCM_PTOBNUM (obj
)].print (obj
, port
, pstate
);
995 scm_printer_apply (SCM proc
, SCM exp
, SCM port
, scm_print_state
*pstate
)
998 SCM pair
= scm_cons (port
, pstate
->handle
);
999 SCM_NEWSMOB (pwps
, scm_tc16_port_with_ps
, pair
);
1000 pstate
->revealed
= 1;
1001 return scm_apply (proc
, exp
, scm_cons (pwps
, scm_listofnull
));
1004 GUILE_PROC (scm_port_with_print_state
, "port-with-print-state", 2, 0, 0,
1005 (SCM port
, SCM pstate
),
1007 #define FUNC_NAME s_scm_port_with_print_state
1010 SCM_VALIDATE_OPORT_VALUE(1,port
);
1011 SCM_VALIDATE_PRINTSTATE(2,pstate
);
1012 port
= SCM_COERCE_OUTPORT (port
);
1013 SCM_NEWSMOB (pwps
, scm_tc16_port_with_ps
, scm_cons (port
, pstate
));
1018 GUILE_PROC (scm_get_print_state
, "get-print-state", 1, 0, 0,
1021 #define FUNC_NAME s_scm_get_print_state
1023 if (SCM_NIMP (port
))
1025 if (SCM_PORT_WITH_PS_P (port
))
1026 return SCM_PORT_WITH_PS_PS (port
);
1027 if (SCM_OUTPORTP (port
))
1030 RETURN_SCM_WTA (1,port
);
1039 SCM vtable
, layout
, type
;
1041 scm_init_opts (scm_print_options
, scm_print_opts
, SCM_N_PRINT_OPTIONS
);
1042 vtable
= scm_make_vtable_vtable (scm_make_struct_layout (scm_nullstr
),
1045 layout
= scm_make_struct_layout (scm_makfrom0str (SCM_PRINT_STATE_LAYOUT
));
1046 type
= scm_make_struct (vtable
, SCM_INUM0
, SCM_LIST1 (layout
));
1047 scm_set_struct_vtable_name_x (type
, SCM_CAR (scm_intern0 ("print-state")));
1048 print_state_pool
= scm_permanent_object (scm_cons (type
, SCM_EOL
));
1050 scm_print_state_vtable
= type
;
1052 /* Don't want to bind a wrapper class in GOOPS, so pass 0 as arg1. */
1053 scm_tc16_port_with_ps
= scm_make_smob_type (0, 0);
1054 scm_set_smob_mark (scm_tc16_port_with_ps
, scm_markcdr
);
1055 scm_set_smob_print (scm_tc16_port_with_ps
, print_port_with_ps
);