summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2022-05-27 07:38:11 -0700
committerKaz Kylheku <kaz@kylheku.com>2022-05-27 07:38:11 -0700
commit88ad50aef5d3676c0c963c46c3da21e4b9973004 (patch)
treebab1a803953fc6038f62e28d15b3e5f3cd81293f
parentb8aad5164c87d160cbdaa4f7090fa8145a252ab0 (diff)
downloadtxr-88ad50aef5d3676c0c963c46c3da21e4b9973004.tar.gz
txr-88ad50aef5d3676c0c963c46c3da21e4b9973004.tar.bz2
txr-88ad50aef5d3676c0c963c46c3da21e4b9973004.zip
gzio: include type in printed representation of stream.
* gzio.c (gzio_stream_print): New static function. (gzio_ops_rd, gzio_ops_wr): Wire in function instead of stream_print_op.
-rw-r--r--gzio.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/gzio.c b/gzio.c
index 06f3a6ec..a1948a48 100644
--- a/gzio.c
+++ b/gzio.c
@@ -63,6 +63,20 @@ struct gzio_handle {
struct cobj_class *gzio_stream_cls;
+static void gzio_stream_print(val stream, val out, val pretty,
+ struct strm_ctx *ctx)
+{
+ struct gzio_handle *h = coerce(struct gzio_handle *, stream->co.handle);
+ struct strm_ops *ops = coerce(struct strm_ops *, stream->co.ops);
+ val name = static_str(ops->name);
+ val descr = ops->get_prop(stream, name_k);
+
+ (void) pretty;
+ (void) ctx;
+
+ format(out, lit("#<~a ~a ~p>"), name, descr, stream, nao);
+}
+
static void gzio_stream_destroy(val stream)
{
struct gzio_handle *h = coerce(struct gzio_handle *, stream->co.handle);
@@ -410,7 +424,7 @@ static val gzio_set_prop(val stream, val ind, val prop)
static struct strm_ops gzio_ops_rd =
strm_ops_init(cobj_ops_init(eq,
- stream_print_op,
+ gzio_stream_print,
gzio_stream_destroy,
gzio_stream_mark,
cobj_eq_hash_op),
@@ -438,7 +452,7 @@ static struct strm_ops gzio_ops_rd =
static struct strm_ops gzio_ops_wr =
strm_ops_init(cobj_ops_init(eq,
- stream_print_op,
+ gzio_stream_print,
gzio_stream_destroy,
gzio_stream_mark,
cobj_eq_hash_op),