From cddd91863740e560ae95ccdd2be5aa0e128713ed Mon Sep 17 00:00:00 2001
From: Kaz Kylheku <kaz@kylheku.com>
Date: Thu, 22 Jul 2021 07:18:58 -0700
Subject: hash: change make_hash interface.

The make_hash function now takes the hash_weak_opt_t
enumeration instead of a pair of flags.

* hash.c (do_make_hash): Take enum argument instead of pair of
flags. Just store the option; nothing to calculate.
(weak_opt_from_flags): New static function.
(tweak_hash): Function removed.
(make_seeded_hash): Adjust to new do_make_hash interface with
help from weak_opt_from_flags.
(make_hash, make_eq_hash): Take enum argument instead of pair
of flags.
(hashv): Calculate hash_weak_opt_t enum from the extracted
flags, pass down to make_eq_hash or make_hash.

* hash.h (tweak_hash): Declration removed.
(make_hash, make_eq_hash): Declarations updated.

* eval.c (me_case, expand_switch): Update make_hash
calls to new style.
(eval_init): Update make_hash calls and get rid of tweak_hash
calls. This renders the tweak_hash function unused.

* ffi.c (make_ffi_type_enum, ffi_init): Update make_hash calls
to new style.

* filter.c (make_trie, trie_add, filter_init): Likewise.

* lib.c (make_package_common, obj_init, obj_print): Likewise.

* lisplib.c (lisplib_init): Likewise.

* match.c (dir_tables_init): Likewise.

* parser.c (parser_circ_def, repl, parse_init): Likewise.

* parser.l (parser_l_init): Likewise.

* struct.c (struct_init, get_slot_syms): Likewise.

* sysif.c (get_env_hash): Likewise.

* lex.yy.c.shipped, y.tab.c.shipped: Updated.
---
 lib.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

(limited to 'lib.c')

diff --git a/lib.c b/lib.c
index 53db3ac0..399ffb71 100644
--- a/lib.c
+++ b/lib.c
@@ -6379,9 +6379,10 @@ val gensym(val prefix)
 
 static val make_package_common(val name, val weak)
 {
-  val weak_vals = default_null_arg(weak);
-  val sh = make_hash(nil, weak_vals, t);
-  val hh = make_hash(nil, weak_vals, t);
+  hash_weak_opt_t wkopt = if3(default_null_arg(weak),
+                              hash_weak_vals, hash_weak_none);
+  val sh = make_hash(wkopt, t);
+  val hh = make_hash(wkopt, t);
   val obj = make_obj();
   obj->pk.type = PKG;
   obj->pk.name = name;
@@ -12782,7 +12783,7 @@ static void obj_init(void)
   greater_f = func_n2(greater);
   prog_string = string(progname);
 
-  cobj_hash = make_hash(nil, nil, nil);
+  cobj_hash = make_hash(hash_weak_none, nil);
 }
 
 static val simple_qref_args_p(val args, val pos)
@@ -13866,7 +13867,7 @@ val obj_print(val obj, val out, val pretty)
   if (ctx) {
     if (cdr(lookup_var(nil, print_circle_s))) {
       ctx->obj_hash_prev = ctx->obj_hash;
-      ctx->obj_hash = make_eq_hash(nil, nil);
+      ctx->obj_hash = make_eq_hash(hash_weak_none);
       populate_obj_hash(obj, ctx);
       obj_hash_merge(ctx->obj_hash_prev, ctx->obj_hash);
       ctx->obj_hash = ctx->obj_hash_prev;
@@ -13881,7 +13882,7 @@ val obj_print(val obj, val out, val pretty)
     ctx->obj_hash_prev = nil;
     ctx->obj_hash = if2(print_circle_s &&
                         cdr(lookup_var(nil, print_circle_s)),
-                        make_eq_hash(nil, nil));
+                        make_eq_hash(hash_weak_none));
     ctx->depth = 0;
     get_set_ctx(out, ctx);
     if (ctx->obj_hash)
-- 
cgit v1.2.3