mes: hash: Guile interface compliancy.

* mes/module/mes/scm.mes (hashq-get-handle, hashq-ref, hash-ref): New
function.
* src/hash.c (hashq_get_handle_): Rename from hashq_get_handle.
Update users.
(hashq_ref_): Likewise.
(hash_ref_): Likewise.
This commit is contained in:
Jan Nieuwenhuizen 2019-11-10 14:06:57 +01:00 committed by Jan (janneke) Nieuwenhuizen
parent bd7353298e
commit 3afd6044a9
No known key found for this signature in database
GPG Key ID: F3C1A0D9C1D65273
7 changed files with 25 additions and 13 deletions

View File

@ -63,9 +63,9 @@ struct scm *gc ();
/* src/hash.c */ /* src/hash.c */
struct scm *hashq (struct scm *x, struct scm *size); struct scm *hashq (struct scm *x, struct scm *size);
struct scm *hash (struct scm *x, struct scm *size); struct scm *hash (struct scm *x, struct scm *size);
struct scm *hashq_get_handle (struct scm *table, struct scm *key, struct scm *dflt); struct scm *hashq_get_handle_ (struct scm *table, struct scm *key, struct scm *dflt);
struct scm *hashq_ref (struct scm *table, struct scm *key, struct scm *dflt); struct scm *hashq_ref_ (struct scm *table, struct scm *key, struct scm *dflt);
struct scm *hash_ref (struct scm *table, struct scm *key, struct scm *dflt); struct scm *hash_ref_ (struct scm *table, struct scm *key, struct scm *dflt);
struct scm *hashq_set_x (struct scm *table, struct scm *key, struct scm *value); struct scm *hashq_set_x (struct scm *table, struct scm *key, struct scm *value);
struct scm *hash_set_x (struct scm *table, struct scm *key, struct scm *value); struct scm *hash_set_x (struct scm *table, struct scm *key, struct scm *value);
struct scm *hash_table_printer (struct scm *table); struct scm *hash_table_printer (struct scm *table);

View File

@ -190,6 +190,18 @@
(lambda args (lambda args
(proc (apply (apply compose rest) args))))) (proc (apply (apply compose rest) args)))))
;; Hash
(define (hashq-get-handle table key . rest)
(core:hashq-get-handle table key (and (pair? rest) (car rest))))
(define (hashq-ref table key . rest)
(core:hashq-ref table key (and (pair? rest) (car rest))))
(define (hash-ref table key . rest)
(core:hash-ref table key (and (pair? rest) (car rest))))
;; Vector ;; Vector
(define (vector . rest) (list->vector rest)) (define (vector . rest) (list->vector rest))

View File

@ -173,9 +173,9 @@ mes_builtins (struct scm *a) /*:((internal)) */
/* src/hash.c */ /* src/hash.c */
a = init_builtin (builtin_type, "hashq", 2, &hashq, a); a = init_builtin (builtin_type, "hashq", 2, &hashq, a);
a = init_builtin (builtin_type, "hash", 2, &hash, a); a = init_builtin (builtin_type, "hash", 2, &hash, a);
a = init_builtin (builtin_type, "hashq-get-handle", 3, &hashq_get_handle, a); a = init_builtin (builtin_type, "core:hashq-get-handle", 3, &hashq_get_handle_, a);
a = init_builtin (builtin_type, "hashq-ref", 3, &hashq_ref, a); a = init_builtin (builtin_type, "core:hashq-ref", 3, &hashq_ref_, a);
a = init_builtin (builtin_type, "hash-ref", 3, &hash_ref, a); a = init_builtin (builtin_type, "core:hash-ref", 3, &hash_ref_, a);
a = init_builtin (builtin_type, "hashq-set!", 3, &hashq_set_x, a); a = init_builtin (builtin_type, "hashq-set!", 3, &hashq_set_x, a);
a = init_builtin (builtin_type, "hash-set!", 3, &hash_set_x, a); a = init_builtin (builtin_type, "hash-set!", 3, &hash_set_x, a);
a = init_builtin (builtin_type, "hash-table-printer", 1, &hash_table_printer, a); a = init_builtin (builtin_type, "hash-table-printer", 1, &hash_table_printer, a);

View File

@ -158,7 +158,7 @@ struct scm *
macro_get_handle (struct scm *name) /*:((internal)) */ macro_get_handle (struct scm *name) /*:((internal)) */
{ {
if (name->type == TSYMBOL) if (name->type == TSYMBOL)
return hashq_get_handle (g_macros, name, cell_nil); return hashq_get_handle_ (g_macros, name, cell_nil);
return cell_f; return cell_f;
} }

View File

@ -70,7 +70,7 @@ hash (struct scm *x, struct scm *size)
} }
struct scm * struct scm *
hashq_get_handle (struct scm *table, struct scm *key, struct scm *dflt) hashq_get_handle_ (struct scm *table, struct scm *key, struct scm *dflt)
{ {
struct scm *s = struct_ref_ (table, 3); struct scm *s = struct_ref_ (table, 3);
long size = s->value; long size = s->value;
@ -86,16 +86,16 @@ hashq_get_handle (struct scm *table, struct scm *key, struct scm *dflt)
} }
struct scm * struct scm *
hashq_ref (struct scm *table, struct scm *key, struct scm *dflt) hashq_ref_ (struct scm *table, struct scm *key, struct scm *dflt)
{ {
struct scm *x = hashq_get_handle (table, key, dflt); struct scm *x = hashq_get_handle_ (table, key, dflt);
if (x != cell_f) if (x != cell_f)
x = x->cdr; x = x->cdr;
return x; return x;
} }
struct scm * struct scm *
hash_ref (struct scm *table, struct scm *key, struct scm *dflt) hash_ref_ (struct scm *table, struct scm *key, struct scm *dflt)
{ {
struct scm *s = struct_ref_ (table, 3); struct scm *s = struct_ref_ (table, 3);
long size = s->value; long size = s->value;

View File

@ -93,7 +93,7 @@ module_variable (struct scm *module, struct scm *name)
{ {
module = M0; module = M0;
struct scm *globals = struct_ref_ (module, 5); struct scm *globals = struct_ref_ (module, 5);
x = hashq_get_handle (globals, name, cell_f); x = hashq_get_handle_ (globals, name, cell_f);
} }
return x; return x;
} }

View File

@ -114,7 +114,7 @@ keyword_to_string (struct scm *keyword)
struct scm * struct scm *
string_to_symbol (struct scm *string) string_to_symbol (struct scm *string)
{ {
struct scm *x = hash_ref (g_symbols, string, cell_f); struct scm *x = hash_ref_ (g_symbols, string, cell_f);
if (x == cell_f) if (x == cell_f)
x = make_symbol (string); x = make_symbol (string);
return x; return x;