From 47d79a4dc7d1a9ae8161dfd02a75a869169da73f Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Thu, 8 Oct 2015 20:04:19 -0700 Subject: Various stream-related with- macros introduced. * lisplib.c (with_stream_set_entries, with_stream_instantiate): New static functions. (lisplib_init): Register new functions in dl_table. * share/txr/stdlib/with-stream.tl: New file. * txr.1: Documented new macros. --- lisplib.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'lisplib.c') diff --git a/lisplib.c b/lisplib.c index dc90a377..122256f3 100644 --- a/lisplib.c +++ b/lisplib.c @@ -189,6 +189,27 @@ static val struct_instantiate(val set_fun) return nil; } +static val with_stream_set_entries(val dlt, val fun) +{ + val name[] = { + lit("with-out-string-stream"), + lit("with-out-strlist-stream"), + lit("with-in-string-stream"), + lit("with-in-string-byte-stream"), + lit("with-stream"), + nil + }; + set_dlt_entries(dlt, name, fun); + return nil; +} + +static val with_stream_instantiate(val set_fun) +{ + funcall1(set_fun, nil); + load(format(nil, lit("~a/with-stream.tl"), stdlib_path, nao)); + return nil; +} + val dlt_register(val dlt, val (*instantiate)(val), val (*set_entries)(val, val)) @@ -207,6 +228,7 @@ void lisplib_init(void) dlt_register(dl_table, with_resources_instantiate, with_resources_set_entries); dlt_register(dl_table, path_test_instantiate, path_test_set_entries); dlt_register(dl_table, struct_instantiate, struct_set_entries); + dlt_register(dl_table, with_stream_instantiate, with_stream_set_entries); } val lisplib_try_load(val sym) -- cgit v1.2.3