[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 08/21: Make file/line/column fields of ports private
From: |
Andy Wingo |
Subject: |
[Guile-commits] 08/21: Make file/line/column fields of ports private |
Date: |
Mon, 16 May 2016 07:39:34 +0000 (UTC) |
wingo pushed a commit to branch wip-port-refactor
in repository guile.
commit 8af64975be43a5055e6a74e9eef89a9c9955af7d
Author: Andy Wingo <address@hidden>
Date: Fri May 13 10:31:01 2016 +0200
Make file/line/column fields of ports private
* libguile/ports-internal.h (scm_t_port_internal): Move file_name,
line_number, and column_number here.
(SCM_FILENAME, SCM_SET_FILENAME, SCM_LINUM, SCM_COL, SCM_INCLINE):
(SCM_ZEROCOL, SCM_INCCOL, SCM_DECCOL, SCM_TABCOL): Make internal.
* libguile/ports.c (scm_c_make_port_with_encoding)
(scm_set_port_line_x, scm_set_port_column_x): Adapt to change.
---
libguile/ports-internal.h | 17 +++++++++++++++++
libguile/ports.c | 6 +++---
libguile/ports.h | 16 ----------------
3 files changed, 20 insertions(+), 19 deletions(-)
diff --git a/libguile/ports-internal.h b/libguile/ports-internal.h
index a7d61d4..28b9c5f 100644
--- a/libguile/ports-internal.h
+++ b/libguile/ports-internal.h
@@ -227,6 +227,12 @@ typedef struct scm_iconv_descriptors
scm_t_iconv_descriptors;
struct scm_port_internal
{
scm_t_port pt;
+
+ /* Source location information. */
+ SCM file_name;
+ long line_number;
+ int column_number;
+
unsigned at_stream_start_for_bom_read : 1;
unsigned at_stream_start_for_bom_write : 1;
scm_t_iconv_descriptors *iconv_descriptors;
@@ -239,6 +245,17 @@ typedef struct scm_port_internal scm_t_port_internal;
#define SCM_PORT_GET_INTERNAL(x) ((scm_t_port_internal*) SCM_PTAB_ENTRY(x))
+#define SCM_FILENAME(x) (SCM_PORT_GET_INTERNAL(x)->file_name)
+#define SCM_SET_FILENAME(x, n) (SCM_PORT_GET_INTERNAL(x)->file_name = (n))
+#define SCM_LINUM(x) (SCM_PORT_GET_INTERNAL(x)->line_number)
+#define SCM_COL(x) (SCM_PORT_GET_INTERNAL(x)->column_number)
+
+#define SCM_INCLINE(port) do {SCM_LINUM (port) += 1; SCM_COL (port) = 0;}
while (0)
+#define SCM_ZEROCOL(port) do {SCM_COL (port) = 0;} while (0)
+#define SCM_INCCOL(port) do {SCM_COL (port) += 1;} while (0)
+#define SCM_DECCOL(port) do {if (SCM_COL (port) > 0) SCM_COL (port) -=
1;} while (0)
+#define SCM_TABCOL(port) do {SCM_COL (port) += 8 - SCM_COL (port) % 8;}
while (0)
+
typedef enum scm_t_port_rw_active {
SCM_PORT_NEITHER = 0,
SCM_PORT_READ = 1,
diff --git a/libguile/ports.c b/libguile/ports.c
index c3d5f5e..fe877ac 100644
--- a/libguile/ports.c
+++ b/libguile/ports.c
@@ -727,10 +727,10 @@ scm_c_make_port_with_encoding (scm_t_bits tag, unsigned
long mode_bits,
SCM_SET_CELL_WORD_1 (ret, (scm_t_bits) entry);
SCM_SET_CELL_WORD_2 (ret, (scm_t_bits) ptob);
- entry->file_name = SCM_BOOL_F;
entry->stream = stream;
entry->encoding = encoding;
entry->conversion_strategy = conversion_strategy;
+ pti->file_name = SCM_BOOL_F;
pti->iconv_descriptors = NULL;
pti->at_stream_start_for_bom_read = 1;
@@ -3017,7 +3017,7 @@ SCM_DEFINE (scm_set_port_line_x, "set-port-line!", 2, 0,
0,
{
port = SCM_COERCE_OUTPORT (port);
SCM_VALIDATE_OPENPORT (1, port);
- SCM_PTAB_ENTRY (port)->line_number = scm_to_long (line);
+ SCM_PORT_GET_INTERNAL (port)->line_number = scm_to_long (line);
return SCM_UNSPECIFIED;
}
#undef FUNC_NAME
@@ -3048,7 +3048,7 @@ SCM_DEFINE (scm_set_port_column_x, "set-port-column!", 2,
0, 0,
{
port = SCM_COERCE_OUTPORT (port);
SCM_VALIDATE_OPENPORT (1, port);
- SCM_PTAB_ENTRY (port)->column_number = scm_to_int (column);
+ SCM_PORT_GET_INTERNAL (port)->column_number = scm_to_int (column);
return SCM_UNSPECIFIED;
}
#undef FUNC_NAME
diff --git a/libguile/ports.h b/libguile/ports.h
index 793523b..efaa765 100644
--- a/libguile/ports.h
+++ b/libguile/ports.h
@@ -84,11 +84,6 @@ typedef struct
/* Data for the underlying port implementation as a raw C value. */
scm_t_bits stream;
- /* Source location information. */
- SCM file_name;
- long line_number;
- int column_number;
-
/* Port buffers. */
SCM read_buf;
SCM write_buf;
@@ -147,17 +142,6 @@ SCM_INTERNAL SCM scm_i_port_weak_set;
#define SCM_SETPTAB_ENTRY(x, ent) (SCM_SET_CELL_WORD_1 ((x), (scm_t_bits)
(ent)))
#define SCM_STREAM(x) (SCM_PTAB_ENTRY(x)->stream)
#define SCM_SETSTREAM(x, s) (SCM_PTAB_ENTRY(x)->stream = (scm_t_bits)
(s))
-#define SCM_FILENAME(x) (SCM_PTAB_ENTRY(x)->file_name)
-#define SCM_SET_FILENAME(x, n) (SCM_PTAB_ENTRY(x)->file_name = (n))
-#define SCM_LINUM(x) (SCM_PTAB_ENTRY(x)->line_number)
-#define SCM_COL(x) (SCM_PTAB_ENTRY(x)->column_number)
-
-#define SCM_INCLINE(port) do {SCM_LINUM (port) += 1; SCM_COL (port) = 0;}
while (0)
-#define SCM_ZEROCOL(port) do {SCM_COL (port) = 0;} while (0)
-#define SCM_INCCOL(port) do {SCM_COL (port) += 1;} while (0)
-#define SCM_DECCOL(port) do {if (SCM_COL (port) > 0) SCM_COL (port) -=
1;} while (0)
-#define SCM_TABCOL(port) do {SCM_COL (port) += 8 - SCM_COL (port) % 8;}
while (0)
-
/* Maximum number of port types. */
#define SCM_I_MAX_PORT_TYPE_COUNT 256
- [Guile-commits] branch wip-port-refactor updated (d28d1a5 -> da456d2), Andy Wingo, 2016/05/16
- [Guile-commits] 07/21: Embed scm_t_port in scm_t_port_internal, Andy Wingo, 2016/05/16
- [Guile-commits] 21/21: Bump objcode version, Andy Wingo, 2016/05/16
- [Guile-commits] 02/21: Implement lookahead-u8, get-u8 in Scheme, Andy Wingo, 2016/05/16
- [Guile-commits] 10/21: Make scm_t_port private, Andy Wingo, 2016/05/16
- [Guile-commits] 17/21: Update port mode bits documentation., Andy Wingo, 2016/05/16
- [Guile-commits] 08/21: Make file/line/column fields of ports private,
Andy Wingo <=
- [Guile-commits] 20/21: Update NEWS for release, Andy Wingo, 2016/05/16
- [Guile-commits] 18/21: Document scm_c_make_port and friends, Andy Wingo, 2016/05/16
- [Guile-commits] 01/21: %read-char speedup, Andy Wingo, 2016/05/16
- [Guile-commits] 12/21: Update port documentation, Andy Wingo, 2016/05/16
- [Guile-commits] 04/21: Add (ice-9 sports) module, Andy Wingo, 2016/05/16
- [Guile-commits] 13/21: Make scm_t_ptob_descriptor private., Andy Wingo, 2016/05/16
- [Guile-commits] 15/21: Update port type documentation, Andy Wingo, 2016/05/16
- [Guile-commits] 09/21: Make port buffering fields private, Andy Wingo, 2016/05/16
- [Guile-commits] 16/21: Add SCM_OPN to mode bits when making ports, Andy Wingo, 2016/05/16
- [Guile-commits] 03/21: Beginnings of shunting ports-in-scheme off to a module, Andy Wingo, 2016/05/16