summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog23
-rw-r--r--hash.c8
-rw-r--r--lib.c8
-rw-r--r--lib.h5
-rw-r--r--regex.c5
-rw-r--r--stream.c11
-rw-r--r--stream.h2
7 files changed, 46 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog
index 0f4d18e9..7a734328 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,28 @@
2015-08-01 Kaz Kylheku <kaz@kylheku.com>
+ Pass pretty flag to cobj print operation.
+
+ * hash.c (hash_print_op): Take third argument,
+ and call cobj_print_impl rather than cobj_print.
+
+ * lib.c (cobj_print_op): Take third argument. The object class is
+ * printed with obj_print_impl.
+ (obj_print_impl): Static function becomes extern. Passes its pretty
+ flag argument to cobj print virtual function.
+
+ * lib.h (cobj_ops): print takes third argument.
+ (cobj_print_op): Declaration updated.
+ (obj_print_impl): Declared.
+
+ * regex.c (regex_print): Takes third argument, and ignores it.
+
+ * stream.c (stream_print_op, stdio_stream_print, cat_stream_print):
+ Take third argument, and ignore it.
+
+ * stream.h (stream_print_op): Declaration updated.
+
+2015-08-01 Kaz Kylheku <kaz@kylheku.com>
+
* eval.c (special_p): Function renamed to special_var_p.
(expand_opt_params_rec, expand_vars): Follow rename of special_p.
(eval_init): Register special-operator-p and special-var-p
diff --git a/hash.c b/hash.c
index 73738b6b..d279ece8 100644
--- a/hash.c
+++ b/hash.c
@@ -347,7 +347,7 @@ static cnum hash_hash_op(val obj)
return out;
}
-static void hash_print_op(val hash, val out)
+static void hash_print_op(val hash, val out, val pretty)
{
struct hash *h = coerce(struct hash *, hash->co.handle);
int need_space = 0;
@@ -370,13 +370,13 @@ static void hash_print_op(val hash, val out)
put_char(chr(' '), out);
switch (h->flags) {
case hash_weak_both:
- obj_print(weak_keys_k, out);
+ obj_print_impl(weak_keys_k, out, pretty);
/* fallthrough */
case hash_weak_vals:
- obj_print(weak_vals_k, out);
+ obj_print_impl(weak_vals_k, out, pretty);
break;
case hash_weak_keys:
- obj_print(weak_keys_k, out);
+ obj_print_impl(weak_keys_k, out, pretty);
break;
default:
break;
diff --git a/lib.c b/lib.c
index 05f94f15..5f2f3aa5 100644
--- a/lib.c
+++ b/lib.c
@@ -5575,10 +5575,10 @@ struct cobj_ops *cobj_ops(val cobj, val cls_sym)
return cobj->co.ops;
}
-void cobj_print_op(val obj, val out)
+void cobj_print_op(val obj, val out, val pretty)
{
put_string(lit("#<"), out);
- obj_print(obj->co.cls, out);
+ obj_print_impl(obj->co.cls, out, pretty);
format(out, lit(": ~p>"), coerce(val, obj->co.handle), nao);
}
@@ -6905,7 +6905,7 @@ static void obj_init(void)
prog_string = string(progname);
}
-static val obj_print_impl(val obj, val out, val pretty)
+val obj_print_impl(val obj, val out, val pretty)
{
val ret = obj;
@@ -7131,7 +7131,7 @@ finish:
obj_print_impl(obj->ls.prefix, out, pretty);
break;
case COBJ:
- obj->co.ops->print(obj, out);
+ obj->co.ops->print(obj, out, pretty);
break;
case ENV:
format(out, lit("#<environment: ~p>"), obj, nao);
diff --git a/lib.h b/lib.h
index caab6b2a..fbdc06a8 100644
--- a/lib.h
+++ b/lib.h
@@ -198,7 +198,7 @@ struct cobj {
struct cobj_ops {
val (*equal)(val self, val other);
- void (*print)(val self, val stream);
+ void (*print)(val self, val stream, val pretty);
void (*destroy)(val self);
void (*mark)(val self);
cnum (*hash)(val self);
@@ -211,7 +211,7 @@ struct cobj_ops {
* Default equal is eq
*/
-void cobj_print_op(val, val);
+void cobj_print_op(val, val, val);
void cobj_destroy_stub_op(val);
void cobj_destroy_free_op(val);
void cobj_mark_op(val);
@@ -855,6 +855,7 @@ val search(val seq, val key, val from, val to);
val where(val func, val seq);
val sel(val seq, val where);
val env(void);
+val obj_print_impl(val obj, val out, val pretty);
val obj_print(val obj, val stream);
val obj_pprint(val obj, val stream);
val tostring(val obj);
diff --git a/regex.c b/regex.c
index 0c6cf363..abc8e1a5 100644
--- a/regex.c
+++ b/regex.c
@@ -1307,7 +1307,7 @@ static void regex_mark(val obj)
gc_mark(regex->source);
}
-static void regex_print(val obj, val stream);
+static void regex_print(val obj, val stream, val pretty);
static struct cobj_ops regex_obj_ops = cobj_ops_init(eq,
regex_print,
@@ -1836,10 +1836,11 @@ static void print_rec(val exp, val stream)
}
}
-static void regex_print(val obj, val stream)
+static void regex_print(val obj, val stream, val pretty)
{
regex_t *regex = coerce(regex_t *, cobj_handle(obj, regex_s));
+ (void) pretty;
put_string(lit("#/"), stream);
print_rec(regex->source, stream);
put_char(chr('/'), stream);
diff --git a/stream.c b/stream.c
index 240db1eb..6e85012f 100644
--- a/stream.c
+++ b/stream.c
@@ -83,9 +83,10 @@ void strm_base_mark(struct strm_base *s)
(void) s;
}
-void stream_print_op(val stream, val out)
+void stream_print_op(val stream, val out, val pretty)
{
val name = stream_get_prop(stream, name_k);
+ (void) pretty;
format(out, lit("#<~a ~p>"), name, stream, nao);
}
@@ -303,12 +304,14 @@ struct stdio_handle {
unsigned is_real_time;
};
-static void stdio_stream_print(val stream, val out)
+static void stdio_stream_print(val stream, val out, val pretty)
{
struct stdio_handle *h = coerce(struct stdio_handle *, stream->co.handle);
struct strm_ops *ops = coerce(struct strm_ops *, stream->co.ops);
val name = static_str(ops->name);
+ (void) pretty;
+
if (h->pid)
format(out, lit("#<~a ~s ~s ~p>"), name, h->descr, num(h->pid), stream, nao);
else
@@ -1693,12 +1696,14 @@ struct cat_strm {
val streams;
};
-static void cat_stream_print(val stream, val out)
+static void cat_stream_print(val stream, val out, val pretty)
{
struct cat_strm *s = coerce(struct cat_strm *, stream->co.handle);
struct strm_ops *ops = coerce(struct strm_ops *, stream->co.ops);
val name = static_str(ops->name);
+ (void) pretty;
+
format(out, lit("#<~a ~s>"), name, s->streams, nao);
}
diff --git a/stream.h b/stream.h
index 04edcda2..862874cd 100644
--- a/stream.h
+++ b/stream.h
@@ -96,7 +96,7 @@ void strm_base_init(struct strm_base *s);
void strm_base_cleanup(struct strm_base *s);
void strm_base_mark(struct strm_base *s);
void fill_stream_ops(struct strm_ops *ops);
-void stream_print_op(val stream, val out);
+void stream_print_op(val stream, val out, val pretty);
void stream_mark_op(val stream);
void stream_destroy_op(val stream);
val make_null_stream(void);