diff options
author | Andy Wingo <wingo@pobox.com> | 2016-05-13 11:21:41 +0200 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2016-05-13 11:27:37 +0200 |
commit | e5d2f4e566586f768bda99c28a74fd2303ecace1 (patch) | |
tree | 71fead353c58b0a42e7c3dbf71bd4e9d884297b4 /libguile/ports-internal.h | |
parent | 9a9e0cceae8433ba45e2ab9b37c02dd3b3c71d9a (diff) |
Make scm_t_port private
* libguile/ports-internal.h (enum scm_port_encoding_mode): Remove unused
enum.
(scm_t_port_internal, scm_t_port): Make encoding and
conversion_strategy private. Instead of scm_t_port_internal containing
scm_t_port, now that all members are private, we can store the user's
"stream" in a word in the port object itself and make the whole of
scm_t_port private. The next commit will remove scm_t_port_internal.
(SCM_PTAB_ENTRY, SCM_PORT_DESCRIPTOR): Make private.
* libguile/ports.c (scm_c_make_port_with_encoding): Adapt to new port
layout.
(scm_port_print): Use SCM_PTAB_ENTRY when printing.
* libguile/ports.h: Remove scm_t_port definition.
* libguile/ioext.c (get_matching_port): Simplify.
* libguile/fports.c (scm_i_evict_port): Simplify.
Diffstat (limited to 'libguile/ports-internal.h')
-rw-r--r-- | libguile/ports-internal.h | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/libguile/ports-internal.h b/libguile/ports-internal.h index 948c27bcb..e2a672d8b 100644 --- a/libguile/ports-internal.h +++ b/libguile/ports-internal.h @@ -231,14 +231,6 @@ scm_port_buffer_putback (SCM buf, const scm_t_uint8 *src, size_t count) src, count); } -enum scm_port_encoding_mode { - SCM_PORT_ENCODING_MODE_UTF8, - SCM_PORT_ENCODING_MODE_LATIN1, - SCM_PORT_ENCODING_MODE_ICONV -}; - -typedef enum scm_port_encoding_mode scm_t_port_encoding_mode; - /* This is a separate object so that only those ports that use iconv cause finalizers to be registered. */ struct scm_iconv_descriptors @@ -257,10 +249,8 @@ struct scm_iconv_descriptors typedef struct scm_iconv_descriptors scm_t_iconv_descriptors; -struct scm_port_internal +struct scm_port { - scm_t_port pt; - /* Source location information. */ SCM file_name; long line_number; @@ -284,13 +274,21 @@ struct scm_port_internal and so on. */ int rw_random; + /* Character encoding support. */ + SCM encoding; /* A symbol of upper-case ASCII. */ + SCM conversion_strategy; /* A symbol; either substitute, error, or escape. */ + unsigned at_stream_start_for_bom_read : 1; unsigned at_stream_start_for_bom_write : 1; scm_t_iconv_descriptors *iconv_descriptors; SCM alist; }; -typedef struct scm_port_internal scm_t_port_internal; +typedef struct scm_port scm_t_port; +typedef scm_t_port scm_t_port_internal; + +#define SCM_PTAB_ENTRY(x) ((scm_t_port *) SCM_CELL_WORD_2 (x)) +#define SCM_PORT_DESCRIPTOR(port) ((scm_t_ptob_descriptor *) SCM_CELL_WORD_3 (port)) #define SCM_UNICODE_BOM 0xFEFFUL /* Unicode byte-order mark */ |