[Commit] nickle/builtin builtin.c,1.11,1.12 toplevel.c,1.18,1.19

Keith Packard commit at keithp.com
Mon Jul 21 22:32:38 PDT 2003


Committed by: keithp

Update of /local/src/CVS/nickle/builtin
In directory home.keithp.com:/tmp/cvs-serv9757/builtin

Modified Files:
	builtin.c toplevel.c 
Log Message:
Eliminate bogus function layer in Hash API.
Switch hash initializes from colon to double arrow (=>)
Fix hash printing to produce re-parsable output
Make HashHash compute reasonable hash values
Add hash_key builtin


Index: builtin.c
===================================================================
RCS file: /local/src/CVS/nickle/builtin/builtin.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- builtin.c	11 Jun 2003 05:01:55 -0000	1.11
+++ builtin.c	22 Jul 2003 04:32:36 -0000	1.12
@@ -118,7 +118,9 @@
     Type   *t;
     Bool    ref = False;
     Bool    array = False;
+    Bool    hash = False;
     Expr    *dims = 0;
+    Type    *k;
     
     ref = False;
     if (*format == '*')
@@ -136,6 +138,11 @@
 	    format++;
 	}
     }
+    if (*format == 'H')
+    {
+	hash = True;
+	format = BuiltinType (format + 1, &k);
+    }
     switch (*format++) {
     case 'p': t = typePoly; break;
     case 'n': t = typeGroup; break;
@@ -161,6 +168,8 @@
 	t = NewTypeRef (t, False);
     if (array)
 	t = NewTypeArray (t, dims);
+    if (hash)
+	t = NewTypeHash (t, k);
     *type = t;
     return format;
 }

Index: toplevel.c
===================================================================
RCS file: /local/src/CVS/nickle/builtin/toplevel.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- toplevel.c	21 Jul 2003 22:22:11 -0000	1.18
+++ toplevel.c	22 Jul 2003 04:32:36 -0000	1.19
@@ -24,7 +24,7 @@
     static const struct fbuiltin_0 funcs_0[] = {
         { do_getbyte, "getbyte", "i", "" },
         { do_time, "time", "i", "" },
-	{ do_hash_new, "hash_new", "p", "" },
+	{ do_hash_new, "hash_new", "Hpp", "" },
         { 0 }
     };
 
@@ -63,6 +63,7 @@
         { do_sleep, "sleep", "v", "i" },
         { do_string_to_real, "string_to_real", "R", "s" },
 	{ do_hash, "hash", "i", "p" },
+	{ do_hash_keys, "hash_keys", "Ap", "Hpp" },
         { 0 }
     };
 
@@ -72,9 +73,9 @@
         { do_xor, "xor", "i", "ii" },
 	{ do_setdims, "setdims", "v", "ApAi" },
 	{ do_setdim, "setdim", "v", "Api" },
-	{ do_hash_get, "hash_get", "p", "pp" },
-	{ do_hash_del, "hash_del", "v", "pp" },
-	{ do_hash_test, "hash_test", "b", "pp" },
+	{ do_hash_get, "hash_get", "p", "Hppp" },
+	{ do_hash_del, "hash_del", "v", "Hppp" },
+	{ do_hash_test, "hash_test", "b", "Hppp" },
         { 0 }
     };
 
@@ -84,7 +85,7 @@
     };
 
     static const struct fbuiltin_3 funcs_3[] = {
-	{ do_hash_set, "hash_set", "v", "ppp" },
+	{ do_hash_set, "hash_set", "v", "Hpppp" },
 	{ 0 }
     };
 
@@ -773,6 +774,11 @@
     return HashTest (hv, key);
 }
    
+Value	do_hash_keys (Value hv)
+{
+    return HashKeys (hv);
+}
+
 Value	do_hash_set (Value hv, Value key, Value value)
 {
     HashSet (hv, key, value);




More information about the Commit mailing list