mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-07-01 07:20:20 +02:00
The goal was that, as part of a print operation, all nested prints of contained data would be able to use the same parameters (e.g. write or not), and also detect cycles, highlight objects, etc. The mechanism was a heap-allocated data structure. However, given that: 1. Nobody accessed print states from Scheme 2. `write` and `display` should move to Scheme anyway, in order to be suspendable 3. The "fancyp" and "highlight" options were unused 4. A simple stack-allocated data structure with a per-thread key could do the trick just as well, without needing the weird freelist structure 5. Ports-with-print-states were a source of bugs In the end we switch print states to be something completely internal to print.c. There are no more SCM print-state objects, and no more ports-with-print-state. * libguile/print.h: Remove print state from API. * libguile/print.c (struct scm_print_state): Move definition here. (scm_print_opts): Remove "highlight-prefix" and "highlight-suffix" options, as they were not used. (ENTER_NESTED_DATA): Remove "fancyp" case. (init_print_state_key, get_print_state, push_print_state) (maybe_push_print_state, pop_print_state): New facility to manage stack of active print states. (scm_iprin1, print_vector): No more fancyp. (iprin1): Access "writingp" member directly. Don't make ports with print states. (scm_prin1): Manage print state stack. (scm_iprlist): No more fancyp. (scm_valid_oport_value_p): Remove; valid outports are SCM_OPOUTPORTP. * libguile/backtrace.c: * libguile/filesys.c: * libguile/fports.c: * libguile/goops.c: * libguile/ioext.c: * libguile/ports.c: * libguile/posix.c: * libguile/promises.c: * libguile/socket.c: * libguile/struct.c: Remove cases that dealt with ports-with-print-states. * libguile/private-options.h: Remove highlight options. * module/ice-9/ports.scm (inherit-print-state): Deprecate. * libguile/deprecated.c: * libguile/deprecated.h: Add deprecation shims for print states, as far as that is possible.
50 lines
1.8 KiB
C
50 lines
1.8 KiB
C
#ifndef SCM_PRINT_H
|
||
#define SCM_PRINT_H
|
||
|
||
/* Copyright 1995-1996,1998,2000-2001,2003-2004,2006,2008,2010,2012,2017-2018,2025
|
||
Free Software Foundation, Inc.
|
||
|
||
This file is part of Guile.
|
||
|
||
Guile is free software: you can redistribute it and/or modify it
|
||
under the terms of the GNU Lesser General Public License as published
|
||
by the Free Software Foundation, either version 3 of the License, or
|
||
(at your option) any later version.
|
||
|
||
Guile is distributed in the hope that it will be useful, but WITHOUT
|
||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||
License for more details.
|
||
|
||
You should have received a copy of the GNU Lesser General Public
|
||
License along with Guile. If not, see
|
||
<https://www.gnu.org/licenses/>. */
|
||
|
||
|
||
|
||
#include "libguile/chars.h"
|
||
#include <libguile/error.h>
|
||
#include <libguile/gc.h>
|
||
#include "libguile/options.h"
|
||
|
||
|
||
|
||
struct scm_print_state;
|
||
typedef struct scm_print_state scm_print_state;
|
||
|
||
SCM_API SCM scm_print_options (SCM setting);
|
||
SCM_API void scm_intprint (intmax_t n, int radix, SCM port);
|
||
SCM_API void scm_uintprint (uintmax_t n, int radix, SCM port);
|
||
SCM_API void scm_ipruk (char *hdr, SCM ptr, SCM port);
|
||
SCM_API void scm_iprlist (char *hdr, SCM exp, int tlr, SCM port, scm_print_state *pstate);
|
||
SCM_API void scm_print_symbol_name (const char *str, size_t len, SCM port);
|
||
SCM_API void scm_prin1 (SCM exp, SCM port, int writingp);
|
||
SCM_API void scm_iprin1 (SCM exp, SCM port, scm_print_state *pstate);
|
||
SCM_API SCM scm_write (SCM obj, SCM port);
|
||
SCM_API SCM scm_display (SCM obj, SCM port);
|
||
SCM_API SCM scm_simple_format (SCM port, SCM message, SCM args);
|
||
SCM_API SCM scm_newline (SCM port);
|
||
SCM_API SCM scm_write_char (SCM chr, SCM port);
|
||
SCM_INTERNAL void scm_init_print (void);
|
||
|
||
#endif /* SCM_PRINT_H */
|