summaryrefslogtreecommitdiffstats
path: root/hash.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2016-10-20 21:36:33 -0700
committerKaz Kylheku <kaz@kylheku.com>2016-10-20 21:36:33 -0700
commit6d8df2a98bae323078951e4d4268a30b4743e31e (patch)
treefeae27bbcc443512d1ade58098c71bb79baa7727 /hash.c
parenteb6b20a502f7c20b6a5cfc9155dcbf2cb06c895e (diff)
downloadtxr-6d8df2a98bae323078951e4d4268a30b4743e31e.tar.gz
txr-6d8df2a98bae323078951e4d4268a30b4743e31e.tar.bz2
txr-6d8df2a98bae323078951e4d4268a30b4743e31e.zip
Changes to the printing framework.
The print function now takes an optional boolean for pretty printing. The print method is also called with a third argument; hence structures can customize both standard printing and pretty printing. * lib.c (obj_print): Take pretty argument, and pass it down to obj_print_impl. This makes obj_pprint redundant. (obj_pprint): Function removed: it was identical to obj_print except for passing t down to obj_print_impl for the pretty argument. These two wrappers had started small and got bigger with identical changes done in parallel. (pprint): New function. (tostring, dump): Pass nil for pretty argument of obj_print. (tostringp): Use pprint instead of obj_pprint. * lib.h (obj_print): Declaration updated. (obj_pprint): Declaration removed. (print, pprint): Declared. * eval.c (prinl): Pass nil for pretty_p argument of obj_print. Do the stream defaulting here; obj_print doesn't do it. (pprinl): Pass t for pretty_p argument of obj_print, and do stream argument defaulting. (eval_init): Register print to new print function rather than directly to obj_print. Register pprint to new pprint function rather than obj_pprint. * hash.c (hash_print_op): Call obj_print_impl to print the :equal-based keyword, rather than obj_print. Pass down the pretty flag. All the other keywords are treated this way; this fixes an inconsistency. * match.c (dump_var): Call pprint instead of obj_pprint. * stream.c (formatv): Call obj_print, with a calculated pretty argument instead of switching between obj_pprint and obj_print. * struct.c (struct_inst_print): Except when in backward compatibility mode, call the object's print method in both pretty and regular printing mode, passing the mode as a third argument. * tests/012/oop.tl (defstruct animal): Support third argument in print method. Make it optional because there are some explicit calls which don't pass the argument. * txr.1: Documentation updated for print method and the print function. Revised text for some of the related functions. Added compat notes.
Diffstat (limited to 'hash.c')
-rw-r--r--hash.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/hash.c b/hash.c
index cd49db16..bb270de9 100644
--- a/hash.c
+++ b/hash.c
@@ -389,7 +389,7 @@ static void hash_print_op(val hash, val out, val pretty, struct strm_ctx *ctx)
put_char(chr('('), out);
if (h->hash_fun == equal_hash) {
- obj_print(equal_based_k, out);
+ obj_print_impl(equal_based_k, out, pretty, ctx);
need_space = 1;
}
if (h->flags != hash_weak_none) {