2006-04-17 00:05:42 +00:00
|
|
|
|
/* Copyright (C) 1995,1996,1998,1999,2000,2001, 2003, 2004, 2006 Free Software Foundation, Inc.
|
1996-07-25 22:56:11 +00:00
|
|
|
|
*
|
2003-04-05 19:15:35 +00:00
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
1996-07-25 22:56:11 +00:00
|
|
|
|
*
|
2003-04-05 19:15:35 +00:00
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
|
* Lesser General Public License for more details.
|
1996-07-25 22:56:11 +00:00
|
|
|
|
*
|
2003-04-05 19:15:35 +00:00
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2005-05-23 19:57:22 +00:00
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2003-04-05 19:15:35 +00:00
|
|
|
|
*/
|
1999-12-12 02:36:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
* gc-mark.c (scm_mark_all): Do not rely on hooks to run the weak
hashtable and guardian machinery but call the relevant functions
directly.
* guardians.h, guardians.c, deprecated.h,
deprecated.c (scm_destroy_guardian_x, scm_guardian_greedy_p,
scm_guardian_destroyed_p, scm_guard, scm_get_one_zombie):
Deprecated and moved into deprecated.[ch].
* guardians.h, guardians.c: Mostly rewritten.
(scm_i_init_guardians_for_gc,
scm_i_identify_inaccessible_guardeds,
scm_i_mark_inaccessible_guardeds): New.
* weaks.h, weaks.c (SCM_I_WVECT_TYPE, SCM_I_SET_WVECT_TYPE): New.
(SCM_I_WVECT_N_ITEMS, SCM_I_SET_WVECT_N_ITEMS): New.
(SCM_WVECTF_NOSCAN, SCM_WVECT_NOSCAN_P): Removed.
(scm_weaks_prehistory): Removed.
(scm_i_init_weak_vectors_for_gc, scm_i_mark_weak_vector,
scm_i_mark_weak_vectors_non_weaks,
scm_i_remove_weaks_from_weak_vectors, scm_i_remove_weaks): New.
(scm_weak_vector_gc_init, scm_mark_weak_vector_spines,
scm_scan_weak_vectors): Removed.
* hashtab.h (scm_i_scan_weak_hashtables): New.
* hashtab.c (make_hash_table, scm_i_rehash): Do not use
SCM_WVECTF_NOSCAN.
(hashtable_print): Use SCM_HASHTABLE_N_ITEMS instead of
t->n_items.
(scan_weak_hashtables, scm_i_scan_weak_hashtables): Renamed former
to latter. Do not scan the alists themselves, this is done by the
weak vector code now. Just update the element count.
* vectors.h (SCM_I_WVECT_TYPE, SCM_I_WVECT_EXTRA): Renamed former
to latter. The type is now only part of the cell word.
(SCM_I_SET_WVECT_TYPE, SCM_I_SET_WVECT_EXTRA): Likewise.
* init.c (scm_i_init_guile): Do not call scm_weaks_prehistory.
2005-07-31 23:04:36 +00:00
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
2000-04-21 14:16:44 +00:00
|
|
|
|
#include "libguile/_scm.h"
|
|
|
|
|
|
#include "libguile/alist.h"
|
|
|
|
|
|
#include "libguile/hash.h"
|
|
|
|
|
|
#include "libguile/eval.h"
|
2001-06-26 15:46:40 +00:00
|
|
|
|
#include "libguile/root.h"
|
2000-04-21 14:16:44 +00:00
|
|
|
|
#include "libguile/vectors.h"
|
2003-02-11 13:49:32 +00:00
|
|
|
|
#include "libguile/ports.h"
|
2000-04-21 14:16:44 +00:00
|
|
|
|
|
|
|
|
|
|
#include "libguile/validate.h"
|
|
|
|
|
|
#include "libguile/hashtab.h"
|
2006-04-09 16:13:01 +00:00
|
|
|
|
|
|
|
|
|
|
#include <gc/gc.h>
|
|
|
|
|
|
#include <gc/gc_typed.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
* hooks.c (scm_c_hook_add): Fixed bug in append mode.
* environments.c (obarray_enter, obarray_retrieve, obarray_remove,
leaf_environment_fold, obarray_remove_all): Use hashtable
accessors.
* gc.c (scm_init_storage): Moved hook initialization to
scm_storage_prehistory.
(scm_storage_prehistory): New function.
(scm_igc): Added commentary about placement of
scm_after_sweep_c_hook.
* gc-mark.c (scm_mark_all): Use hashtable accessors.
(scm_gc_mark_dependencies): Use SCM_WVECT_WEAK_KEY_P and
SCM_WVECT_WEAK_VALUE_P.
* hashtab.c, hashtab.h (scm_hash_for_each, scm_hash_map): New
functions.
(scm_vector_to_hash_table, scm_c_make_resizing_hash_table):
Removed.
(scm_make_weak_key_hash_table, scm_make_weak_value_hash_table,
scm_make_doubly_weak_hash_table): Moved here from weaks.c.
* init.c (scm_init_guile_1): Removed call to scm_init_weaks; Added
calls to scm_storage_prehistory and scm_hashtab_prehistory.
* modules.c (module-reverse-lookup): Use hashtable accessors.
* symbols.c, symbols.h (scm_i_hash_symbol): New function.
* weaks.c, weaks.h (scm_make_weak_key_alist_vector,
scm_make_weak_value_alist_vector,
scm_make_doubly_weak_alist_vector): New functions.
* weaks.c (scm_init_weaks_builtins): New function.
* weaks.h (SCM_WVECTF_WEAK_KEY, SCM_WVECTF_WEAK_VALUE,
SCM_WVECTF_NOSCAN, SCM_WVECT_WEAK_KEY_P, SCM_WVECT_WEAK_VALUE_P,
SCM_WVECT_NOSCAN_P): New macros.
* weaks.c (scm_scan_weak_vectors): Use SCM_WVECT_WEAK_KEY_P
and SCM_WVECT_WEAK_VALUE_P.
* weaks.c, weaks.h (scm_i_allocate_weak_vector): Renamed from
allocate_weak_vector and exported.
* Makefile.am (ice9_sources): Added weak-vector.scm.
* weak-vector.scm: New file.
* boot-9.scm (module-clear!): Use hash-clear!.
(module-for-each): Use hash-for-each.
(module-map): Use hash-map.
2003-02-19 15:04:51 +00:00
|
|
|
|
/* NOTES
|
|
|
|
|
|
*
|
|
|
|
|
|
* 1. The current hash table implementation uses weak alist vectors
|
|
|
|
|
|
* (implementation in weaks.c) internally, but we do the scanning
|
|
|
|
|
|
* ourselves (in scan_weak_hashtables) because we need to update the
|
|
|
|
|
|
* hash table structure when items are dropped during GC.
|
|
|
|
|
|
*
|
|
|
|
|
|
* 2. All hash table operations still work on alist vectors.
|
|
|
|
|
|
*
|
2003-02-11 13:49:32 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
* hooks.c (scm_c_hook_add): Fixed bug in append mode.
* environments.c (obarray_enter, obarray_retrieve, obarray_remove,
leaf_environment_fold, obarray_remove_all): Use hashtable
accessors.
* gc.c (scm_init_storage): Moved hook initialization to
scm_storage_prehistory.
(scm_storage_prehistory): New function.
(scm_igc): Added commentary about placement of
scm_after_sweep_c_hook.
* gc-mark.c (scm_mark_all): Use hashtable accessors.
(scm_gc_mark_dependencies): Use SCM_WVECT_WEAK_KEY_P and
SCM_WVECT_WEAK_VALUE_P.
* hashtab.c, hashtab.h (scm_hash_for_each, scm_hash_map): New
functions.
(scm_vector_to_hash_table, scm_c_make_resizing_hash_table):
Removed.
(scm_make_weak_key_hash_table, scm_make_weak_value_hash_table,
scm_make_doubly_weak_hash_table): Moved here from weaks.c.
* init.c (scm_init_guile_1): Removed call to scm_init_weaks; Added
calls to scm_storage_prehistory and scm_hashtab_prehistory.
* modules.c (module-reverse-lookup): Use hashtable accessors.
* symbols.c, symbols.h (scm_i_hash_symbol): New function.
* weaks.c, weaks.h (scm_make_weak_key_alist_vector,
scm_make_weak_value_alist_vector,
scm_make_doubly_weak_alist_vector): New functions.
* weaks.c (scm_init_weaks_builtins): New function.
* weaks.h (SCM_WVECTF_WEAK_KEY, SCM_WVECTF_WEAK_VALUE,
SCM_WVECTF_NOSCAN, SCM_WVECT_WEAK_KEY_P, SCM_WVECT_WEAK_VALUE_P,
SCM_WVECT_NOSCAN_P): New macros.
* weaks.c (scm_scan_weak_vectors): Use SCM_WVECT_WEAK_KEY_P
and SCM_WVECT_WEAK_VALUE_P.
* weaks.c, weaks.h (scm_i_allocate_weak_vector): Renamed from
allocate_weak_vector and exported.
* Makefile.am (ice9_sources): Added weak-vector.scm.
* weak-vector.scm: New file.
* boot-9.scm (module-clear!): Use hash-clear!.
(module-for-each): Use hash-for-each.
(module-map): Use hash-map.
2003-02-19 15:04:51 +00:00
|
|
|
|
/* Hash tables are either vectors of association lists or smobs
|
|
|
|
|
|
* containing such vectors. Currently, the vector version represents
|
|
|
|
|
|
* constant size tables while those wrapped in a smob represents
|
|
|
|
|
|
* resizing tables.
|
|
|
|
|
|
*
|
|
|
|
|
|
* Growing or shrinking, with following rehashing, is triggered when
|
|
|
|
|
|
* the load factor
|
|
|
|
|
|
*
|
|
|
|
|
|
* L = N / S (N: number of items in table, S: bucket vector length)
|
|
|
|
|
|
*
|
|
|
|
|
|
* passes an upper limit of 0.9 or a lower limit of 0.25.
|
|
|
|
|
|
*
|
|
|
|
|
|
* The implementation stores the upper and lower number of items which
|
|
|
|
|
|
* trigger a resize in the hashtable object.
|
|
|
|
|
|
*
|
|
|
|
|
|
* Possible hash table sizes (primes) are stored in the array
|
|
|
|
|
|
* hashtable_size.
|
2003-02-11 13:49:32 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
scm_t_bits scm_tc16_hashtable;
|
|
|
|
|
|
|
2003-02-13 10:42:59 +00:00
|
|
|
|
static unsigned long hashtable_size[] = {
|
|
|
|
|
|
31, 61, 113, 223, 443, 883, 1759, 3517, 7027, 14051, 28099, 56197, 112363,
|
2005-01-20 14:39:49 +00:00
|
|
|
|
224717, 449419, 898823, 1797641, 3595271, 7190537, 14381041
|
|
|
|
|
|
#if 0
|
|
|
|
|
|
/* vectors are currently restricted to 2^24-1 = 16777215 elements. */
|
|
|
|
|
|
28762081, 57524111, 115048217, 230096423, 460192829
|
|
|
|
|
|
/* larger values can't be represented as INUMs */
|
|
|
|
|
|
#endif
|
2003-02-11 13:49:32 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
2005-01-20 14:39:49 +00:00
|
|
|
|
#define HASHTABLE_SIZE_N (sizeof(hashtable_size)/sizeof(unsigned long))
|
|
|
|
|
|
|
2003-02-11 13:49:32 +00:00
|
|
|
|
static char *s_hashtable = "hashtable";
|
|
|
|
|
|
|
* hooks.c (scm_c_hook_add): Fixed bug in append mode.
* environments.c (obarray_enter, obarray_retrieve, obarray_remove,
leaf_environment_fold, obarray_remove_all): Use hashtable
accessors.
* gc.c (scm_init_storage): Moved hook initialization to
scm_storage_prehistory.
(scm_storage_prehistory): New function.
(scm_igc): Added commentary about placement of
scm_after_sweep_c_hook.
* gc-mark.c (scm_mark_all): Use hashtable accessors.
(scm_gc_mark_dependencies): Use SCM_WVECT_WEAK_KEY_P and
SCM_WVECT_WEAK_VALUE_P.
* hashtab.c, hashtab.h (scm_hash_for_each, scm_hash_map): New
functions.
(scm_vector_to_hash_table, scm_c_make_resizing_hash_table):
Removed.
(scm_make_weak_key_hash_table, scm_make_weak_value_hash_table,
scm_make_doubly_weak_hash_table): Moved here from weaks.c.
* init.c (scm_init_guile_1): Removed call to scm_init_weaks; Added
calls to scm_storage_prehistory and scm_hashtab_prehistory.
* modules.c (module-reverse-lookup): Use hashtable accessors.
* symbols.c, symbols.h (scm_i_hash_symbol): New function.
* weaks.c, weaks.h (scm_make_weak_key_alist_vector,
scm_make_weak_value_alist_vector,
scm_make_doubly_weak_alist_vector): New functions.
* weaks.c (scm_init_weaks_builtins): New function.
* weaks.h (SCM_WVECTF_WEAK_KEY, SCM_WVECTF_WEAK_VALUE,
SCM_WVECTF_NOSCAN, SCM_WVECT_WEAK_KEY_P, SCM_WVECT_WEAK_VALUE_P,
SCM_WVECT_NOSCAN_P): New macros.
* weaks.c (scm_scan_weak_vectors): Use SCM_WVECT_WEAK_KEY_P
and SCM_WVECT_WEAK_VALUE_P.
* weaks.c, weaks.h (scm_i_allocate_weak_vector): Renamed from
allocate_weak_vector and exported.
* Makefile.am (ice9_sources): Added weak-vector.scm.
* weak-vector.scm: New file.
* boot-9.scm (module-clear!): Use hash-clear!.
(module-for-each): Use hash-for-each.
(module-map): Use hash-map.
2003-02-19 15:04:51 +00:00
|
|
|
|
SCM weak_hashtables = SCM_EOL;
|
|
|
|
|
|
|
2006-04-09 16:13:01 +00:00
|
|
|
|
|
2006-04-04 21:28:13 +00:00
|
|
|
|
|
2006-04-09 16:13:01 +00:00
|
|
|
|
/* Weak cells for use in weak alist vectors (aka. weak hash tables).
|
|
|
|
|
|
|
|
|
|
|
|
We have weal-car cells, weak-cdr cells, and doubly weak cells. In weak
|
|
|
|
|
|
cells, the weak component(s) are not scanned for pointers and are
|
|
|
|
|
|
registered as disapperaring links; therefore, the weak component may be
|
|
|
|
|
|
set to NULL by the garbage collector when no other reference to that word
|
|
|
|
|
|
exist. Thus, we use `scm_fixup_weak_alist ()' to check for nullified weak
|
|
|
|
|
|
cells and remove them. */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Type descriptors for weak-c[ad]r cells. */
|
|
|
|
|
|
static GC_descr wcar_cell_descr, wcdr_cell_descr;
|
|
|
|
|
|
|
2006-04-04 21:28:13 +00:00
|
|
|
|
|
|
|
|
|
|
static SCM
|
|
|
|
|
|
scm_weak_car_cell (SCM car, SCM cdr)
|
|
|
|
|
|
{
|
2006-04-09 16:13:01 +00:00
|
|
|
|
scm_t_cell *cell;
|
|
|
|
|
|
|
|
|
|
|
|
cell = (scm_t_cell *)GC_malloc_explicitly_typed (sizeof (*cell),
|
|
|
|
|
|
wcar_cell_descr);
|
2006-04-04 21:28:13 +00:00
|
|
|
|
|
|
|
|
|
|
cell->word_0 = car;
|
|
|
|
|
|
cell->word_1 = cdr;
|
|
|
|
|
|
|
|
|
|
|
|
if (SCM_NIMP (car))
|
|
|
|
|
|
{
|
|
|
|
|
|
/* Weak car cells make sense iff the car is non-immediate. */
|
|
|
|
|
|
GC_GENERAL_REGISTER_DISAPPEARING_LINK ((GC_PTR)&cell->word_0,
|
|
|
|
|
|
(GC_PTR)SCM_UNPACK (car));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return (SCM_PACK (cell));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static SCM
|
|
|
|
|
|
scm_weak_cdr_cell (SCM car, SCM cdr)
|
|
|
|
|
|
{
|
2006-04-09 16:13:01 +00:00
|
|
|
|
scm_t_cell *cell;
|
|
|
|
|
|
|
|
|
|
|
|
cell = (scm_t_cell *)GC_malloc_explicitly_typed (sizeof (*cell),
|
|
|
|
|
|
wcdr_cell_descr);
|
2006-04-04 21:28:13 +00:00
|
|
|
|
|
|
|
|
|
|
cell->word_0 = car;
|
|
|
|
|
|
cell->word_1 = cdr;
|
|
|
|
|
|
|
|
|
|
|
|
if (SCM_NIMP (cdr))
|
|
|
|
|
|
{
|
|
|
|
|
|
/* Weak cdr cells make sense iff the cdr is non-immediate. */
|
|
|
|
|
|
GC_GENERAL_REGISTER_DISAPPEARING_LINK ((GC_PTR)&cell->word_1,
|
|
|
|
|
|
(GC_PTR)SCM_UNPACK (cdr));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return (SCM_PACK (cell));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static SCM
|
|
|
|
|
|
scm_doubly_weak_cell (SCM car, SCM cdr)
|
|
|
|
|
|
{
|
2006-04-09 16:13:01 +00:00
|
|
|
|
/* Doubly weak cells shall not be scanned at all for pointers. */
|
2006-04-04 21:28:13 +00:00
|
|
|
|
scm_t_cell *cell = (scm_t_cell *)scm_gc_malloc_pointerless (sizeof (*cell),
|
|
|
|
|
|
"weak cell");
|
|
|
|
|
|
|
|
|
|
|
|
cell->word_0 = car;
|
|
|
|
|
|
cell->word_1 = cdr;
|
|
|
|
|
|
|
|
|
|
|
|
if (SCM_NIMP (car))
|
|
|
|
|
|
{
|
|
|
|
|
|
GC_GENERAL_REGISTER_DISAPPEARING_LINK ((GC_PTR)&cell->word_0,
|
|
|
|
|
|
(GC_PTR)SCM_UNPACK (car));
|
|
|
|
|
|
}
|
|
|
|
|
|
if (SCM_NIMP (cdr))
|
|
|
|
|
|
{
|
|
|
|
|
|
GC_GENERAL_REGISTER_DISAPPEARING_LINK ((GC_PTR)&cell->word_1,
|
|
|
|
|
|
(GC_PTR)SCM_UNPACK (cdr));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return (SCM_PACK (cell));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Testing the weak component(s) of a cell for reachability. */
|
|
|
|
|
|
#define SCM_WEAK_CELL_WORD_DELETED_P(_cell, _word) \
|
2006-04-09 16:13:01 +00:00
|
|
|
|
(SCM_CELL_OBJECT ((_cell), (_word)) == SCM_PACK (NULL))
|
2006-04-04 21:28:13 +00:00
|
|
|
|
#define SCM_WEAK_CELL_CAR_DELETED_P(_cell) \
|
|
|
|
|
|
(SCM_WEAK_CELL_WORD_DELETED_P ((_cell), 0))
|
|
|
|
|
|
#define SCM_WEAK_CELL_CDR_DELETED_P(_cell) \
|
|
|
|
|
|
(SCM_WEAK_CELL_WORD_DELETED_P ((_cell), 1))
|
|
|
|
|
|
|
|
|
|
|
|
/* Accessing the components of a weak cell. */
|
|
|
|
|
|
#define SCM_WEAK_CELL_WORD(_cell, _word) \
|
|
|
|
|
|
((SCM_WEAK_CELL_WORD_DELETED_P ((_cell), (_word))) \
|
|
|
|
|
|
? SCM_BOOL_F : SCM_CAR (pair))
|
|
|
|
|
|
#define SCM_WEAK_CELL_CAR(_cell) (SCM_WEAK_CELL_WORD ((_cell), 0))
|
|
|
|
|
|
#define SCM_WEAK_CELL_CDR(_cell) (SCM_WEAK_CELL_WORD ((_cell), 1))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Return a ``usable'' version of ALIST, an alist of weak pairs. By
|
|
|
|
|
|
``usable'', we mean that it contains only valid Scheme objects. */
|
|
|
|
|
|
static SCM
|
|
|
|
|
|
scm_fixup_weak_alist (SCM alist)
|
|
|
|
|
|
{
|
|
|
|
|
|
SCM result;
|
|
|
|
|
|
SCM prev = SCM_EOL;
|
|
|
|
|
|
|
|
|
|
|
|
for (result = alist;
|
|
|
|
|
|
scm_is_pair (alist);
|
|
|
|
|
|
prev = alist, alist = SCM_CDR (alist))
|
|
|
|
|
|
{
|
|
|
|
|
|
SCM pair = SCM_CAR (alist);
|
|
|
|
|
|
|
|
|
|
|
|
if (scm_is_pair (pair))
|
|
|
|
|
|
{
|
|
|
|
|
|
if ((SCM_WEAK_CELL_CAR_DELETED_P (pair))
|
|
|
|
|
|
|| (SCM_WEAK_CELL_CDR_DELETED_P (pair)))
|
|
|
|
|
|
{
|
|
|
|
|
|
/* Remove from ALIST weak pair PAIR whose car/cdr has been
|
|
|
|
|
|
nullified by the GC. */
|
|
|
|
|
|
if (prev == SCM_EOL)
|
|
|
|
|
|
result = alist;
|
|
|
|
|
|
else
|
|
|
|
|
|
SCM_SETCDR (prev, SCM_CDR (alist));
|
|
|
|
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
* hooks.c (scm_c_hook_add): Fixed bug in append mode.
* environments.c (obarray_enter, obarray_retrieve, obarray_remove,
leaf_environment_fold, obarray_remove_all): Use hashtable
accessors.
* gc.c (scm_init_storage): Moved hook initialization to
scm_storage_prehistory.
(scm_storage_prehistory): New function.
(scm_igc): Added commentary about placement of
scm_after_sweep_c_hook.
* gc-mark.c (scm_mark_all): Use hashtable accessors.
(scm_gc_mark_dependencies): Use SCM_WVECT_WEAK_KEY_P and
SCM_WVECT_WEAK_VALUE_P.
* hashtab.c, hashtab.h (scm_hash_for_each, scm_hash_map): New
functions.
(scm_vector_to_hash_table, scm_c_make_resizing_hash_table):
Removed.
(scm_make_weak_key_hash_table, scm_make_weak_value_hash_table,
scm_make_doubly_weak_hash_table): Moved here from weaks.c.
* init.c (scm_init_guile_1): Removed call to scm_init_weaks; Added
calls to scm_storage_prehistory and scm_hashtab_prehistory.
* modules.c (module-reverse-lookup): Use hashtable accessors.
* symbols.c, symbols.h (scm_i_hash_symbol): New function.
* weaks.c, weaks.h (scm_make_weak_key_alist_vector,
scm_make_weak_value_alist_vector,
scm_make_doubly_weak_alist_vector): New functions.
* weaks.c (scm_init_weaks_builtins): New function.
* weaks.h (SCM_WVECTF_WEAK_KEY, SCM_WVECTF_WEAK_VALUE,
SCM_WVECTF_NOSCAN, SCM_WVECT_WEAK_KEY_P, SCM_WVECT_WEAK_VALUE_P,
SCM_WVECT_NOSCAN_P): New macros.
* weaks.c (scm_scan_weak_vectors): Use SCM_WVECT_WEAK_KEY_P
and SCM_WVECT_WEAK_VALUE_P.
* weaks.c, weaks.h (scm_i_allocate_weak_vector): Renamed from
allocate_weak_vector and exported.
* Makefile.am (ice9_sources): Added weak-vector.scm.
* weak-vector.scm: New file.
* boot-9.scm (module-clear!): Use hash-clear!.
(module-for-each): Use hash-for-each.
(module-map): Use hash-map.
2003-02-19 15:04:51 +00:00
|
|
|
|
static SCM
|
2005-03-29 17:47:39 +00:00
|
|
|
|
make_hash_table (int flags, unsigned long k, const char *func_name)
|
|
|
|
|
|
{
|
* hooks.c (scm_c_hook_add): Fixed bug in append mode.
* environments.c (obarray_enter, obarray_retrieve, obarray_remove,
leaf_environment_fold, obarray_remove_all): Use hashtable
accessors.
* gc.c (scm_init_storage): Moved hook initialization to
scm_storage_prehistory.
(scm_storage_prehistory): New function.
(scm_igc): Added commentary about placement of
scm_after_sweep_c_hook.
* gc-mark.c (scm_mark_all): Use hashtable accessors.
(scm_gc_mark_dependencies): Use SCM_WVECT_WEAK_KEY_P and
SCM_WVECT_WEAK_VALUE_P.
* hashtab.c, hashtab.h (scm_hash_for_each, scm_hash_map): New
functions.
(scm_vector_to_hash_table, scm_c_make_resizing_hash_table):
Removed.
(scm_make_weak_key_hash_table, scm_make_weak_value_hash_table,
scm_make_doubly_weak_hash_table): Moved here from weaks.c.
* init.c (scm_init_guile_1): Removed call to scm_init_weaks; Added
calls to scm_storage_prehistory and scm_hashtab_prehistory.
* modules.c (module-reverse-lookup): Use hashtable accessors.
* symbols.c, symbols.h (scm_i_hash_symbol): New function.
* weaks.c, weaks.h (scm_make_weak_key_alist_vector,
scm_make_weak_value_alist_vector,
scm_make_doubly_weak_alist_vector): New functions.
* weaks.c (scm_init_weaks_builtins): New function.
* weaks.h (SCM_WVECTF_WEAK_KEY, SCM_WVECTF_WEAK_VALUE,
SCM_WVECTF_NOSCAN, SCM_WVECT_WEAK_KEY_P, SCM_WVECT_WEAK_VALUE_P,
SCM_WVECT_NOSCAN_P): New macros.
* weaks.c (scm_scan_weak_vectors): Use SCM_WVECT_WEAK_KEY_P
and SCM_WVECT_WEAK_VALUE_P.
* weaks.c, weaks.h (scm_i_allocate_weak_vector): Renamed from
allocate_weak_vector and exported.
* Makefile.am (ice9_sources): Added weak-vector.scm.
* weak-vector.scm: New file.
* boot-9.scm (module-clear!): Use hash-clear!.
(module-for-each): Use hash-for-each.
(module-map): Use hash-map.
2003-02-19 15:04:51 +00:00
|
|
|
|
SCM table, vector;
|
2003-02-19 17:57:01 +00:00
|
|
|
|
scm_t_hashtable *t;
|
2003-02-19 15:43:00 +00:00
|
|
|
|
int i = 0, n = k ? k : 31;
|
|
|
|
|
|
while (i < HASHTABLE_SIZE_N && n > hashtable_size[i])
|
|
|
|
|
|
++i;
|
|
|
|
|
|
n = hashtable_size[i];
|
2006-04-04 21:28:13 +00:00
|
|
|
|
|
|
|
|
|
|
/* In both cases, i.e., regardless of whether we are creating a weak hash
|
|
|
|
|
|
table, we return a non-weak vector. This is because the vector itself
|
|
|
|
|
|
is not weak in the case of a weak hash table: the alist pairs are. */
|
|
|
|
|
|
vector = scm_c_make_vector (n, SCM_EOL);
|
|
|
|
|
|
|
|
|
|
|
|
t = scm_gc_malloc_pointerless (sizeof (*t), s_hashtable);
|
* hooks.c (scm_c_hook_add): Fixed bug in append mode.
* environments.c (obarray_enter, obarray_retrieve, obarray_remove,
leaf_environment_fold, obarray_remove_all): Use hashtable
accessors.
* gc.c (scm_init_storage): Moved hook initialization to
scm_storage_prehistory.
(scm_storage_prehistory): New function.
(scm_igc): Added commentary about placement of
scm_after_sweep_c_hook.
* gc-mark.c (scm_mark_all): Use hashtable accessors.
(scm_gc_mark_dependencies): Use SCM_WVECT_WEAK_KEY_P and
SCM_WVECT_WEAK_VALUE_P.
* hashtab.c, hashtab.h (scm_hash_for_each, scm_hash_map): New
functions.
(scm_vector_to_hash_table, scm_c_make_resizing_hash_table):
Removed.
(scm_make_weak_key_hash_table, scm_make_weak_value_hash_table,
scm_make_doubly_weak_hash_table): Moved here from weaks.c.
* init.c (scm_init_guile_1): Removed call to scm_init_weaks; Added
calls to scm_storage_prehistory and scm_hashtab_prehistory.
* modules.c (module-reverse-lookup): Use hashtable accessors.
* symbols.c, symbols.h (scm_i_hash_symbol): New function.
* weaks.c, weaks.h (scm_make_weak_key_alist_vector,
scm_make_weak_value_alist_vector,
scm_make_doubly_weak_alist_vector): New functions.
* weaks.c (scm_init_weaks_builtins): New function.
* weaks.h (SCM_WVECTF_WEAK_KEY, SCM_WVECTF_WEAK_VALUE,
SCM_WVECTF_NOSCAN, SCM_WVECT_WEAK_KEY_P, SCM_WVECT_WEAK_VALUE_P,
SCM_WVECT_NOSCAN_P): New macros.
* weaks.c (scm_scan_weak_vectors): Use SCM_WVECT_WEAK_KEY_P
and SCM_WVECT_WEAK_VALUE_P.
* weaks.c, weaks.h (scm_i_allocate_weak_vector): Renamed from
allocate_weak_vector and exported.
* Makefile.am (ice9_sources): Added weak-vector.scm.
* weak-vector.scm: New file.
* boot-9.scm (module-clear!): Use hash-clear!.
(module-for-each): Use hash-for-each.
(module-map): Use hash-map.
2003-02-19 15:04:51 +00:00
|
|
|
|
t->min_size_index = t->size_index = i;
|
2003-02-11 13:49:32 +00:00
|
|
|
|
t->n_items = 0;
|
* hooks.c (scm_c_hook_add): Fixed bug in append mode.
* environments.c (obarray_enter, obarray_retrieve, obarray_remove,
leaf_environment_fold, obarray_remove_all): Use hashtable
accessors.
* gc.c (scm_init_storage): Moved hook initialization to
scm_storage_prehistory.
(scm_storage_prehistory): New function.
(scm_igc): Added commentary about placement of
scm_after_sweep_c_hook.
* gc-mark.c (scm_mark_all): Use hashtable accessors.
(scm_gc_mark_dependencies): Use SCM_WVECT_WEAK_KEY_P and
SCM_WVECT_WEAK_VALUE_P.
* hashtab.c, hashtab.h (scm_hash_for_each, scm_hash_map): New
functions.
(scm_vector_to_hash_table, scm_c_make_resizing_hash_table):
Removed.
(scm_make_weak_key_hash_table, scm_make_weak_value_hash_table,
scm_make_doubly_weak_hash_table): Moved here from weaks.c.
* init.c (scm_init_guile_1): Removed call to scm_init_weaks; Added
calls to scm_storage_prehistory and scm_hashtab_prehistory.
* modules.c (module-reverse-lookup): Use hashtable accessors.
* symbols.c, symbols.h (scm_i_hash_symbol): New function.
* weaks.c, weaks.h (scm_make_weak_key_alist_vector,
scm_make_weak_value_alist_vector,
scm_make_doubly_weak_alist_vector): New functions.
* weaks.c (scm_init_weaks_builtins): New function.
* weaks.h (SCM_WVECTF_WEAK_KEY, SCM_WVECTF_WEAK_VALUE,
SCM_WVECTF_NOSCAN, SCM_WVECT_WEAK_KEY_P, SCM_WVECT_WEAK_VALUE_P,
SCM_WVECT_NOSCAN_P): New macros.
* weaks.c (scm_scan_weak_vectors): Use SCM_WVECT_WEAK_KEY_P
and SCM_WVECT_WEAK_VALUE_P.
* weaks.c, weaks.h (scm_i_allocate_weak_vector): Renamed from
allocate_weak_vector and exported.
* Makefile.am (ice9_sources): Added weak-vector.scm.
* weak-vector.scm: New file.
* boot-9.scm (module-clear!): Use hash-clear!.
(module-for-each): Use hash-for-each.
(module-map): Use hash-map.
2003-02-19 15:04:51 +00:00
|
|
|
|
t->lower = 0;
|
2003-02-19 15:43:00 +00:00
|
|
|
|
t->upper = 9 * n / 10;
|
* hooks.c (scm_c_hook_add): Fixed bug in append mode.
* environments.c (obarray_enter, obarray_retrieve, obarray_remove,
leaf_environment_fold, obarray_remove_all): Use hashtable
accessors.
* gc.c (scm_init_storage): Moved hook initialization to
scm_storage_prehistory.
(scm_storage_prehistory): New function.
(scm_igc): Added commentary about placement of
scm_after_sweep_c_hook.
* gc-mark.c (scm_mark_all): Use hashtable accessors.
(scm_gc_mark_dependencies): Use SCM_WVECT_WEAK_KEY_P and
SCM_WVECT_WEAK_VALUE_P.
* hashtab.c, hashtab.h (scm_hash_for_each, scm_hash_map): New
functions.
(scm_vector_to_hash_table, scm_c_make_resizing_hash_table):
Removed.
(scm_make_weak_key_hash_table, scm_make_weak_value_hash_table,
scm_make_doubly_weak_hash_table): Moved here from weaks.c.
* init.c (scm_init_guile_1): Removed call to scm_init_weaks; Added
calls to scm_storage_prehistory and scm_hashtab_prehistory.
* modules.c (module-reverse-lookup): Use hashtable accessors.
* symbols.c, symbols.h (scm_i_hash_symbol): New function.
* weaks.c, weaks.h (scm_make_weak_key_alist_vector,
scm_make_weak_value_alist_vector,
scm_make_doubly_weak_alist_vector): New functions.
* weaks.c (scm_init_weaks_builtins): New function.
* weaks.h (SCM_WVECTF_WEAK_KEY, SCM_WVECTF_WEAK_VALUE,
SCM_WVECTF_NOSCAN, SCM_WVECT_WEAK_KEY_P, SCM_WVECT_WEAK_VALUE_P,
SCM_WVECT_NOSCAN_P): New macros.
* weaks.c (scm_scan_weak_vectors): Use SCM_WVECT_WEAK_KEY_P
and SCM_WVECT_WEAK_VALUE_P.
* weaks.c, weaks.h (scm_i_allocate_weak_vector): Renamed from
allocate_weak_vector and exported.
* Makefile.am (ice9_sources): Added weak-vector.scm.
* weak-vector.scm: New file.
* boot-9.scm (module-clear!): Use hash-clear!.
(module-for-each): Use hash-for-each.
(module-map): Use hash-map.
2003-02-19 15:04:51 +00:00
|
|
|
|
t->flags = flags;
|
2005-04-04 14:53:27 +00:00
|
|
|
|
t->hash_fn = NULL;
|
* hooks.c (scm_c_hook_add): Fixed bug in append mode.
* environments.c (obarray_enter, obarray_retrieve, obarray_remove,
leaf_environment_fold, obarray_remove_all): Use hashtable
accessors.
* gc.c (scm_init_storage): Moved hook initialization to
scm_storage_prehistory.
(scm_storage_prehistory): New function.
(scm_igc): Added commentary about placement of
scm_after_sweep_c_hook.
* gc-mark.c (scm_mark_all): Use hashtable accessors.
(scm_gc_mark_dependencies): Use SCM_WVECT_WEAK_KEY_P and
SCM_WVECT_WEAK_VALUE_P.
* hashtab.c, hashtab.h (scm_hash_for_each, scm_hash_map): New
functions.
(scm_vector_to_hash_table, scm_c_make_resizing_hash_table):
Removed.
(scm_make_weak_key_hash_table, scm_make_weak_value_hash_table,
scm_make_doubly_weak_hash_table): Moved here from weaks.c.
* init.c (scm_init_guile_1): Removed call to scm_init_weaks; Added
calls to scm_storage_prehistory and scm_hashtab_prehistory.
* modules.c (module-reverse-lookup): Use hashtable accessors.
* symbols.c, symbols.h (scm_i_hash_symbol): New function.
* weaks.c, weaks.h (scm_make_weak_key_alist_vector,
scm_make_weak_value_alist_vector,
scm_make_doubly_weak_alist_vector): New functions.
* weaks.c (scm_init_weaks_builtins): New function.
* weaks.h (SCM_WVECTF_WEAK_KEY, SCM_WVECTF_WEAK_VALUE,
SCM_WVECTF_NOSCAN, SCM_WVECT_WEAK_KEY_P, SCM_WVECT_WEAK_VALUE_P,
SCM_WVECT_NOSCAN_P): New macros.
* weaks.c (scm_scan_weak_vectors): Use SCM_WVECT_WEAK_KEY_P
and SCM_WVECT_WEAK_VALUE_P.
* weaks.c, weaks.h (scm_i_allocate_weak_vector): Renamed from
allocate_weak_vector and exported.
* Makefile.am (ice9_sources): Added weak-vector.scm.
* weak-vector.scm: New file.
* boot-9.scm (module-clear!): Use hash-clear!.
(module-for-each): Use hash-for-each.
(module-map): Use hash-map.
2003-02-19 15:04:51 +00:00
|
|
|
|
if (flags)
|
|
|
|
|
|
{
|
2006-04-04 21:28:13 +00:00
|
|
|
|
/* FIXME: We should eventually remove WEAK_HASHTABLES. */
|
* hooks.c (scm_c_hook_add): Fixed bug in append mode.
* environments.c (obarray_enter, obarray_retrieve, obarray_remove,
leaf_environment_fold, obarray_remove_all): Use hashtable
accessors.
* gc.c (scm_init_storage): Moved hook initialization to
scm_storage_prehistory.
(scm_storage_prehistory): New function.
(scm_igc): Added commentary about placement of
scm_after_sweep_c_hook.
* gc-mark.c (scm_mark_all): Use hashtable accessors.
(scm_gc_mark_dependencies): Use SCM_WVECT_WEAK_KEY_P and
SCM_WVECT_WEAK_VALUE_P.
* hashtab.c, hashtab.h (scm_hash_for_each, scm_hash_map): New
functions.
(scm_vector_to_hash_table, scm_c_make_resizing_hash_table):
Removed.
(scm_make_weak_key_hash_table, scm_make_weak_value_hash_table,
scm_make_doubly_weak_hash_table): Moved here from weaks.c.
* init.c (scm_init_guile_1): Removed call to scm_init_weaks; Added
calls to scm_storage_prehistory and scm_hashtab_prehistory.
* modules.c (module-reverse-lookup): Use hashtable accessors.
* symbols.c, symbols.h (scm_i_hash_symbol): New function.
* weaks.c, weaks.h (scm_make_weak_key_alist_vector,
scm_make_weak_value_alist_vector,
scm_make_doubly_weak_alist_vector): New functions.
* weaks.c (scm_init_weaks_builtins): New function.
* weaks.h (SCM_WVECTF_WEAK_KEY, SCM_WVECTF_WEAK_VALUE,
SCM_WVECTF_NOSCAN, SCM_WVECT_WEAK_KEY_P, SCM_WVECT_WEAK_VALUE_P,
SCM_WVECT_NOSCAN_P): New macros.
* weaks.c (scm_scan_weak_vectors): Use SCM_WVECT_WEAK_KEY_P
and SCM_WVECT_WEAK_VALUE_P.
* weaks.c, weaks.h (scm_i_allocate_weak_vector): Renamed from
allocate_weak_vector and exported.
* Makefile.am (ice9_sources): Added weak-vector.scm.
* weak-vector.scm: New file.
* boot-9.scm (module-clear!): Use hash-clear!.
(module-for-each): Use hash-for-each.
(module-map): Use hash-map.
2003-02-19 15:04:51 +00:00
|
|
|
|
SCM_NEWSMOB3 (table, scm_tc16_hashtable, vector, t, weak_hashtables);
|
|
|
|
|
|
weak_hashtables = table;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
SCM_NEWSMOB3 (table, scm_tc16_hashtable, vector, t, SCM_EOL);
|
2003-02-11 13:49:32 +00:00
|
|
|
|
return table;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
* hooks.c (scm_c_hook_add): Fixed bug in append mode.
* environments.c (obarray_enter, obarray_retrieve, obarray_remove,
leaf_environment_fold, obarray_remove_all): Use hashtable
accessors.
* gc.c (scm_init_storage): Moved hook initialization to
scm_storage_prehistory.
(scm_storage_prehistory): New function.
(scm_igc): Added commentary about placement of
scm_after_sweep_c_hook.
* gc-mark.c (scm_mark_all): Use hashtable accessors.
(scm_gc_mark_dependencies): Use SCM_WVECT_WEAK_KEY_P and
SCM_WVECT_WEAK_VALUE_P.
* hashtab.c, hashtab.h (scm_hash_for_each, scm_hash_map): New
functions.
(scm_vector_to_hash_table, scm_c_make_resizing_hash_table):
Removed.
(scm_make_weak_key_hash_table, scm_make_weak_value_hash_table,
scm_make_doubly_weak_hash_table): Moved here from weaks.c.
* init.c (scm_init_guile_1): Removed call to scm_init_weaks; Added
calls to scm_storage_prehistory and scm_hashtab_prehistory.
* modules.c (module-reverse-lookup): Use hashtable accessors.
* symbols.c, symbols.h (scm_i_hash_symbol): New function.
* weaks.c, weaks.h (scm_make_weak_key_alist_vector,
scm_make_weak_value_alist_vector,
scm_make_doubly_weak_alist_vector): New functions.
* weaks.c (scm_init_weaks_builtins): New function.
* weaks.h (SCM_WVECTF_WEAK_KEY, SCM_WVECTF_WEAK_VALUE,
SCM_WVECTF_NOSCAN, SCM_WVECT_WEAK_KEY_P, SCM_WVECT_WEAK_VALUE_P,
SCM_WVECT_NOSCAN_P): New macros.
* weaks.c (scm_scan_weak_vectors): Use SCM_WVECT_WEAK_KEY_P
and SCM_WVECT_WEAK_VALUE_P.
* weaks.c, weaks.h (scm_i_allocate_weak_vector): Renamed from
allocate_weak_vector and exported.
* Makefile.am (ice9_sources): Added weak-vector.scm.
* weak-vector.scm: New file.
* boot-9.scm (module-clear!): Use hash-clear!.
(module-for-each): Use hash-for-each.
(module-map): Use hash-map.
2003-02-19 15:04:51 +00:00
|
|
|
|
void
|
|
|
|
|
|
scm_i_rehash (SCM table,
|
|
|
|
|
|
unsigned long (*hash_fn)(),
|
|
|
|
|
|
void *closure,
|
|
|
|
|
|
const char* func_name)
|
|
|
|
|
|
{
|
|
|
|
|
|
SCM buckets, new_buckets;
|
|
|
|
|
|
int i;
|
|
|
|
|
|
unsigned long old_size;
|
|
|
|
|
|
unsigned long new_size;
|
|
|
|
|
|
|
|
|
|
|
|
if (SCM_HASHTABLE_N_ITEMS (table) < SCM_HASHTABLE_LOWER (table))
|
|
|
|
|
|
{
|
|
|
|
|
|
/* rehashing is not triggered when i <= min_size */
|
|
|
|
|
|
i = SCM_HASHTABLE (table)->size_index;
|
|
|
|
|
|
do
|
|
|
|
|
|
--i;
|
|
|
|
|
|
while (i > SCM_HASHTABLE (table)->min_size_index
|
|
|
|
|
|
&& SCM_HASHTABLE_N_ITEMS (table) < hashtable_size[i] / 4);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
i = SCM_HASHTABLE (table)->size_index + 1;
|
|
|
|
|
|
if (i >= HASHTABLE_SIZE_N)
|
|
|
|
|
|
/* don't rehash */
|
|
|
|
|
|
return;
|
2005-04-04 14:53:27 +00:00
|
|
|
|
|
|
|
|
|
|
/* Remember HASH_FN for rehash_after_gc, but only when CLOSURE
|
|
|
|
|
|
is not needed since CLOSURE can not be guaranteed to be valid
|
|
|
|
|
|
after this function returns.
|
|
|
|
|
|
*/
|
|
|
|
|
|
if (closure == NULL)
|
|
|
|
|
|
SCM_HASHTABLE (table)->hash_fn = hash_fn;
|
* hooks.c (scm_c_hook_add): Fixed bug in append mode.
* environments.c (obarray_enter, obarray_retrieve, obarray_remove,
leaf_environment_fold, obarray_remove_all): Use hashtable
accessors.
* gc.c (scm_init_storage): Moved hook initialization to
scm_storage_prehistory.
(scm_storage_prehistory): New function.
(scm_igc): Added commentary about placement of
scm_after_sweep_c_hook.
* gc-mark.c (scm_mark_all): Use hashtable accessors.
(scm_gc_mark_dependencies): Use SCM_WVECT_WEAK_KEY_P and
SCM_WVECT_WEAK_VALUE_P.
* hashtab.c, hashtab.h (scm_hash_for_each, scm_hash_map): New
functions.
(scm_vector_to_hash_table, scm_c_make_resizing_hash_table):
Removed.
(scm_make_weak_key_hash_table, scm_make_weak_value_hash_table,
scm_make_doubly_weak_hash_table): Moved here from weaks.c.
* init.c (scm_init_guile_1): Removed call to scm_init_weaks; Added
calls to scm_storage_prehistory and scm_hashtab_prehistory.
* modules.c (module-reverse-lookup): Use hashtable accessors.
* symbols.c, symbols.h (scm_i_hash_symbol): New function.
* weaks.c, weaks.h (scm_make_weak_key_alist_vector,
scm_make_weak_value_alist_vector,
scm_make_doubly_weak_alist_vector): New functions.
* weaks.c (scm_init_weaks_builtins): New function.
* weaks.h (SCM_WVECTF_WEAK_KEY, SCM_WVECTF_WEAK_VALUE,
SCM_WVECTF_NOSCAN, SCM_WVECT_WEAK_KEY_P, SCM_WVECT_WEAK_VALUE_P,
SCM_WVECT_NOSCAN_P): New macros.
* weaks.c (scm_scan_weak_vectors): Use SCM_WVECT_WEAK_KEY_P
and SCM_WVECT_WEAK_VALUE_P.
* weaks.c, weaks.h (scm_i_allocate_weak_vector): Renamed from
allocate_weak_vector and exported.
* Makefile.am (ice9_sources): Added weak-vector.scm.
* weak-vector.scm: New file.
* boot-9.scm (module-clear!): Use hash-clear!.
(module-for-each): Use hash-for-each.
(module-map): Use hash-map.
2003-02-19 15:04:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
SCM_HASHTABLE (table)->size_index = i;
|
2005-01-24 23:41:14 +00:00
|
|
|
|
|
* hooks.c (scm_c_hook_add): Fixed bug in append mode.
* environments.c (obarray_enter, obarray_retrieve, obarray_remove,
leaf_environment_fold, obarray_remove_all): Use hashtable
accessors.
* gc.c (scm_init_storage): Moved hook initialization to
scm_storage_prehistory.
(scm_storage_prehistory): New function.
(scm_igc): Added commentary about placement of
scm_after_sweep_c_hook.
* gc-mark.c (scm_mark_all): Use hashtable accessors.
(scm_gc_mark_dependencies): Use SCM_WVECT_WEAK_KEY_P and
SCM_WVECT_WEAK_VALUE_P.
* hashtab.c, hashtab.h (scm_hash_for_each, scm_hash_map): New
functions.
(scm_vector_to_hash_table, scm_c_make_resizing_hash_table):
Removed.
(scm_make_weak_key_hash_table, scm_make_weak_value_hash_table,
scm_make_doubly_weak_hash_table): Moved here from weaks.c.
* init.c (scm_init_guile_1): Removed call to scm_init_weaks; Added
calls to scm_storage_prehistory and scm_hashtab_prehistory.
* modules.c (module-reverse-lookup): Use hashtable accessors.
* symbols.c, symbols.h (scm_i_hash_symbol): New function.
* weaks.c, weaks.h (scm_make_weak_key_alist_vector,
scm_make_weak_value_alist_vector,
scm_make_doubly_weak_alist_vector): New functions.
* weaks.c (scm_init_weaks_builtins): New function.
* weaks.h (SCM_WVECTF_WEAK_KEY, SCM_WVECTF_WEAK_VALUE,
SCM_WVECTF_NOSCAN, SCM_WVECT_WEAK_KEY_P, SCM_WVECT_WEAK_VALUE_P,
SCM_WVECT_NOSCAN_P): New macros.
* weaks.c (scm_scan_weak_vectors): Use SCM_WVECT_WEAK_KEY_P
and SCM_WVECT_WEAK_VALUE_P.
* weaks.c, weaks.h (scm_i_allocate_weak_vector): Renamed from
allocate_weak_vector and exported.
* Makefile.am (ice9_sources): Added weak-vector.scm.
* weak-vector.scm: New file.
* boot-9.scm (module-clear!): Use hash-clear!.
(module-for-each): Use hash-for-each.
(module-map): Use hash-map.
2003-02-19 15:04:51 +00:00
|
|
|
|
new_size = hashtable_size[i];
|
|
|
|
|
|
if (i <= SCM_HASHTABLE (table)->min_size_index)
|
|
|
|
|
|
SCM_HASHTABLE (table)->lower = 0;
|
|
|
|
|
|
else
|
|
|
|
|
|
SCM_HASHTABLE (table)->lower = new_size / 4;
|
|
|
|
|
|
SCM_HASHTABLE (table)->upper = 9 * new_size / 10;
|
|
|
|
|
|
buckets = SCM_HASHTABLE_VECTOR (table);
|
2006-04-04 21:28:13 +00:00
|
|
|
|
|
|
|
|
|
|
new_buckets = scm_c_make_vector (new_size, SCM_EOL);
|
* hooks.c (scm_c_hook_add): Fixed bug in append mode.
* environments.c (obarray_enter, obarray_retrieve, obarray_remove,
leaf_environment_fold, obarray_remove_all): Use hashtable
accessors.
* gc.c (scm_init_storage): Moved hook initialization to
scm_storage_prehistory.
(scm_storage_prehistory): New function.
(scm_igc): Added commentary about placement of
scm_after_sweep_c_hook.
* gc-mark.c (scm_mark_all): Use hashtable accessors.
(scm_gc_mark_dependencies): Use SCM_WVECT_WEAK_KEY_P and
SCM_WVECT_WEAK_VALUE_P.
* hashtab.c, hashtab.h (scm_hash_for_each, scm_hash_map): New
functions.
(scm_vector_to_hash_table, scm_c_make_resizing_hash_table):
Removed.
(scm_make_weak_key_hash_table, scm_make_weak_value_hash_table,
scm_make_doubly_weak_hash_table): Moved here from weaks.c.
* init.c (scm_init_guile_1): Removed call to scm_init_weaks; Added
calls to scm_storage_prehistory and scm_hashtab_prehistory.
* modules.c (module-reverse-lookup): Use hashtable accessors.
* symbols.c, symbols.h (scm_i_hash_symbol): New function.
* weaks.c, weaks.h (scm_make_weak_key_alist_vector,
scm_make_weak_value_alist_vector,
scm_make_doubly_weak_alist_vector): New functions.
* weaks.c (scm_init_weaks_builtins): New function.
* weaks.h (SCM_WVECTF_WEAK_KEY, SCM_WVECTF_WEAK_VALUE,
SCM_WVECTF_NOSCAN, SCM_WVECT_WEAK_KEY_P, SCM_WVECT_WEAK_VALUE_P,
SCM_WVECT_NOSCAN_P): New macros.
* weaks.c (scm_scan_weak_vectors): Use SCM_WVECT_WEAK_KEY_P
and SCM_WVECT_WEAK_VALUE_P.
* weaks.c, weaks.h (scm_i_allocate_weak_vector): Renamed from
allocate_weak_vector and exported.
* Makefile.am (ice9_sources): Added weak-vector.scm.
* weak-vector.scm: New file.
* boot-9.scm (module-clear!): Use hash-clear!.
(module-for-each): Use hash-for-each.
(module-map): Use hash-map.
2003-02-19 15:04:51 +00:00
|
|
|
|
|
2005-02-23 17:24:19 +00:00
|
|
|
|
/* When this is a weak hashtable, running the GC might change it.
|
|
|
|
|
|
We need to cope with this while rehashing its elements. We do
|
* gc-mark.c (scm_mark_all): Do not rely on hooks to run the weak
hashtable and guardian machinery but call the relevant functions
directly.
* guardians.h, guardians.c, deprecated.h,
deprecated.c (scm_destroy_guardian_x, scm_guardian_greedy_p,
scm_guardian_destroyed_p, scm_guard, scm_get_one_zombie):
Deprecated and moved into deprecated.[ch].
* guardians.h, guardians.c: Mostly rewritten.
(scm_i_init_guardians_for_gc,
scm_i_identify_inaccessible_guardeds,
scm_i_mark_inaccessible_guardeds): New.
* weaks.h, weaks.c (SCM_I_WVECT_TYPE, SCM_I_SET_WVECT_TYPE): New.
(SCM_I_WVECT_N_ITEMS, SCM_I_SET_WVECT_N_ITEMS): New.
(SCM_WVECTF_NOSCAN, SCM_WVECT_NOSCAN_P): Removed.
(scm_weaks_prehistory): Removed.
(scm_i_init_weak_vectors_for_gc, scm_i_mark_weak_vector,
scm_i_mark_weak_vectors_non_weaks,
scm_i_remove_weaks_from_weak_vectors, scm_i_remove_weaks): New.
(scm_weak_vector_gc_init, scm_mark_weak_vector_spines,
scm_scan_weak_vectors): Removed.
* hashtab.h (scm_i_scan_weak_hashtables): New.
* hashtab.c (make_hash_table, scm_i_rehash): Do not use
SCM_WVECTF_NOSCAN.
(hashtable_print): Use SCM_HASHTABLE_N_ITEMS instead of
t->n_items.
(scan_weak_hashtables, scm_i_scan_weak_hashtables): Renamed former
to latter. Do not scan the alists themselves, this is done by the
weak vector code now. Just update the element count.
* vectors.h (SCM_I_WVECT_TYPE, SCM_I_WVECT_EXTRA): Renamed former
to latter. The type is now only part of the cell word.
(SCM_I_SET_WVECT_TYPE, SCM_I_SET_WVECT_EXTRA): Likewise.
* init.c (scm_i_init_guile): Do not call scm_weaks_prehistory.
2005-07-31 23:04:36 +00:00
|
|
|
|
this by first installing the new, empty bucket vector. Then we
|
|
|
|
|
|
remove the elements from the old bucket vector and insert them
|
|
|
|
|
|
into the new one.
|
2005-02-23 17:24:19 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
SCM_SET_HASHTABLE_VECTOR (table, new_buckets);
|
|
|
|
|
|
SCM_SET_HASHTABLE_N_ITEMS (table, 0);
|
|
|
|
|
|
|
2005-01-02 20:11:15 +00:00
|
|
|
|
old_size = SCM_SIMPLE_VECTOR_LENGTH (buckets);
|
* hooks.c (scm_c_hook_add): Fixed bug in append mode.
* environments.c (obarray_enter, obarray_retrieve, obarray_remove,
leaf_environment_fold, obarray_remove_all): Use hashtable
accessors.
* gc.c (scm_init_storage): Moved hook initialization to
scm_storage_prehistory.
(scm_storage_prehistory): New function.
(scm_igc): Added commentary about placement of
scm_after_sweep_c_hook.
* gc-mark.c (scm_mark_all): Use hashtable accessors.
(scm_gc_mark_dependencies): Use SCM_WVECT_WEAK_KEY_P and
SCM_WVECT_WEAK_VALUE_P.
* hashtab.c, hashtab.h (scm_hash_for_each, scm_hash_map): New
functions.
(scm_vector_to_hash_table, scm_c_make_resizing_hash_table):
Removed.
(scm_make_weak_key_hash_table, scm_make_weak_value_hash_table,
scm_make_doubly_weak_hash_table): Moved here from weaks.c.
* init.c (scm_init_guile_1): Removed call to scm_init_weaks; Added
calls to scm_storage_prehistory and scm_hashtab_prehistory.
* modules.c (module-reverse-lookup): Use hashtable accessors.
* symbols.c, symbols.h (scm_i_hash_symbol): New function.
* weaks.c, weaks.h (scm_make_weak_key_alist_vector,
scm_make_weak_value_alist_vector,
scm_make_doubly_weak_alist_vector): New functions.
* weaks.c (scm_init_weaks_builtins): New function.
* weaks.h (SCM_WVECTF_WEAK_KEY, SCM_WVECTF_WEAK_VALUE,
SCM_WVECTF_NOSCAN, SCM_WVECT_WEAK_KEY_P, SCM_WVECT_WEAK_VALUE_P,
SCM_WVECT_NOSCAN_P): New macros.
* weaks.c (scm_scan_weak_vectors): Use SCM_WVECT_WEAK_KEY_P
and SCM_WVECT_WEAK_VALUE_P.
* weaks.c, weaks.h (scm_i_allocate_weak_vector): Renamed from
allocate_weak_vector and exported.
* Makefile.am (ice9_sources): Added weak-vector.scm.
* weak-vector.scm: New file.
* boot-9.scm (module-clear!): Use hash-clear!.
(module-for-each): Use hash-for-each.
(module-map): Use hash-map.
2003-02-19 15:04:51 +00:00
|
|
|
|
for (i = 0; i < old_size; ++i)
|
|
|
|
|
|
{
|
2005-02-23 17:24:19 +00:00
|
|
|
|
SCM ls, cell, handle;
|
|
|
|
|
|
|
|
|
|
|
|
ls = SCM_SIMPLE_VECTOR_REF (buckets, i);
|
2005-02-25 21:22:44 +00:00
|
|
|
|
SCM_SIMPLE_VECTOR_SET (buckets, i, SCM_EOL);
|
|
|
|
|
|
|
2005-02-23 17:24:19 +00:00
|
|
|
|
while (scm_is_pair (ls))
|
* hooks.c (scm_c_hook_add): Fixed bug in append mode.
* environments.c (obarray_enter, obarray_retrieve, obarray_remove,
leaf_environment_fold, obarray_remove_all): Use hashtable
accessors.
* gc.c (scm_init_storage): Moved hook initialization to
scm_storage_prehistory.
(scm_storage_prehistory): New function.
(scm_igc): Added commentary about placement of
scm_after_sweep_c_hook.
* gc-mark.c (scm_mark_all): Use hashtable accessors.
(scm_gc_mark_dependencies): Use SCM_WVECT_WEAK_KEY_P and
SCM_WVECT_WEAK_VALUE_P.
* hashtab.c, hashtab.h (scm_hash_for_each, scm_hash_map): New
functions.
(scm_vector_to_hash_table, scm_c_make_resizing_hash_table):
Removed.
(scm_make_weak_key_hash_table, scm_make_weak_value_hash_table,
scm_make_doubly_weak_hash_table): Moved here from weaks.c.
* init.c (scm_init_guile_1): Removed call to scm_init_weaks; Added
calls to scm_storage_prehistory and scm_hashtab_prehistory.
* modules.c (module-reverse-lookup): Use hashtable accessors.
* symbols.c, symbols.h (scm_i_hash_symbol): New function.
* weaks.c, weaks.h (scm_make_weak_key_alist_vector,
scm_make_weak_value_alist_vector,
scm_make_doubly_weak_alist_vector): New functions.
* weaks.c (scm_init_weaks_builtins): New function.
* weaks.h (SCM_WVECTF_WEAK_KEY, SCM_WVECTF_WEAK_VALUE,
SCM_WVECTF_NOSCAN, SCM_WVECT_WEAK_KEY_P, SCM_WVECT_WEAK_VALUE_P,
SCM_WVECT_NOSCAN_P): New macros.
* weaks.c (scm_scan_weak_vectors): Use SCM_WVECT_WEAK_KEY_P
and SCM_WVECT_WEAK_VALUE_P.
* weaks.c, weaks.h (scm_i_allocate_weak_vector): Renamed from
allocate_weak_vector and exported.
* Makefile.am (ice9_sources): Added weak-vector.scm.
* weak-vector.scm: New file.
* boot-9.scm (module-clear!): Use hash-clear!.
(module-for-each): Use hash-for-each.
(module-map): Use hash-map.
2003-02-19 15:04:51 +00:00
|
|
|
|
{
|
|
|
|
|
|
unsigned long h;
|
2005-02-23 17:24:19 +00:00
|
|
|
|
cell = ls;
|
|
|
|
|
|
handle = SCM_CAR (cell);
|
|
|
|
|
|
ls = SCM_CDR (ls);
|
* hooks.c (scm_c_hook_add): Fixed bug in append mode.
* environments.c (obarray_enter, obarray_retrieve, obarray_remove,
leaf_environment_fold, obarray_remove_all): Use hashtable
accessors.
* gc.c (scm_init_storage): Moved hook initialization to
scm_storage_prehistory.
(scm_storage_prehistory): New function.
(scm_igc): Added commentary about placement of
scm_after_sweep_c_hook.
* gc-mark.c (scm_mark_all): Use hashtable accessors.
(scm_gc_mark_dependencies): Use SCM_WVECT_WEAK_KEY_P and
SCM_WVECT_WEAK_VALUE_P.
* hashtab.c, hashtab.h (scm_hash_for_each, scm_hash_map): New
functions.
(scm_vector_to_hash_table, scm_c_make_resizing_hash_table):
Removed.
(scm_make_weak_key_hash_table, scm_make_weak_value_hash_table,
scm_make_doubly_weak_hash_table): Moved here from weaks.c.
* init.c (scm_init_guile_1): Removed call to scm_init_weaks; Added
calls to scm_storage_prehistory and scm_hashtab_prehistory.
* modules.c (module-reverse-lookup): Use hashtable accessors.
* symbols.c, symbols.h (scm_i_hash_symbol): New function.
* weaks.c, weaks.h (scm_make_weak_key_alist_vector,
scm_make_weak_value_alist_vector,
scm_make_doubly_weak_alist_vector): New functions.
* weaks.c (scm_init_weaks_builtins): New function.
* weaks.h (SCM_WVECTF_WEAK_KEY, SCM_WVECTF_WEAK_VALUE,
SCM_WVECTF_NOSCAN, SCM_WVECT_WEAK_KEY_P, SCM_WVECT_WEAK_VALUE_P,
SCM_WVECT_NOSCAN_P): New macros.
* weaks.c (scm_scan_weak_vectors): Use SCM_WVECT_WEAK_KEY_P
and SCM_WVECT_WEAK_VALUE_P.
* weaks.c, weaks.h (scm_i_allocate_weak_vector): Renamed from
allocate_weak_vector and exported.
* Makefile.am (ice9_sources): Added weak-vector.scm.
* weak-vector.scm: New file.
* boot-9.scm (module-clear!): Use hash-clear!.
(module-for-each): Use hash-for-each.
(module-map): Use hash-map.
2003-02-19 15:04:51 +00:00
|
|
|
|
h = hash_fn (SCM_CAR (handle), new_size, closure);
|
|
|
|
|
|
if (h >= new_size)
|
* numbers.h, numbers.c, discouraged.h, discouraged.c (scm_short2num,
scm_ushort2num, scm_int2num, scm_uint2num, scm_long2num,
scm_ulong2num, scm_size2num, scm_ptrdiff2num, scm_num2short,
scm_num2ushort, scm_num2int, scm_num2uint, scm_num2long,
scm_num2ulong, scm_num2size, scm_num2ptrdiff, scm_long_long2num,
scm_ulong_long2num, scm_num2long_long, scm_num2ulong_long):
Discouraged by moving to discouraged.h and discouraged.c and
reimplementing in terms of scm_from_* and scm_to_*. Changed all uses
to the new scm_from_* and scm_to_* functions.
2004-08-02 16:14:04 +00:00
|
|
|
|
scm_out_of_range (func_name, scm_from_ulong (h));
|
2005-02-23 17:24:19 +00:00
|
|
|
|
SCM_SETCDR (cell, SCM_SIMPLE_VECTOR_REF (new_buckets, h));
|
|
|
|
|
|
SCM_SIMPLE_VECTOR_SET (new_buckets, h, cell);
|
|
|
|
|
|
SCM_HASHTABLE_INCREMENT (table);
|
* hooks.c (scm_c_hook_add): Fixed bug in append mode.
* environments.c (obarray_enter, obarray_retrieve, obarray_remove,
leaf_environment_fold, obarray_remove_all): Use hashtable
accessors.
* gc.c (scm_init_storage): Moved hook initialization to
scm_storage_prehistory.
(scm_storage_prehistory): New function.
(scm_igc): Added commentary about placement of
scm_after_sweep_c_hook.
* gc-mark.c (scm_mark_all): Use hashtable accessors.
(scm_gc_mark_dependencies): Use SCM_WVECT_WEAK_KEY_P and
SCM_WVECT_WEAK_VALUE_P.
* hashtab.c, hashtab.h (scm_hash_for_each, scm_hash_map): New
functions.
(scm_vector_to_hash_table, scm_c_make_resizing_hash_table):
Removed.
(scm_make_weak_key_hash_table, scm_make_weak_value_hash_table,
scm_make_doubly_weak_hash_table): Moved here from weaks.c.
* init.c (scm_init_guile_1): Removed call to scm_init_weaks; Added
calls to scm_storage_prehistory and scm_hashtab_prehistory.
* modules.c (module-reverse-lookup): Use hashtable accessors.
* symbols.c, symbols.h (scm_i_hash_symbol): New function.
* weaks.c, weaks.h (scm_make_weak_key_alist_vector,
scm_make_weak_value_alist_vector,
scm_make_doubly_weak_alist_vector): New functions.
* weaks.c (scm_init_weaks_builtins): New function.
* weaks.h (SCM_WVECTF_WEAK_KEY, SCM_WVECTF_WEAK_VALUE,
SCM_WVECTF_NOSCAN, SCM_WVECT_WEAK_KEY_P, SCM_WVECT_WEAK_VALUE_P,
SCM_WVECT_NOSCAN_P): New macros.
* weaks.c (scm_scan_weak_vectors): Use SCM_WVECT_WEAK_KEY_P
and SCM_WVECT_WEAK_VALUE_P.
* weaks.c, weaks.h (scm_i_allocate_weak_vector): Renamed from
allocate_weak_vector and exported.
* Makefile.am (ice9_sources): Added weak-vector.scm.
* weak-vector.scm: New file.
* boot-9.scm (module-clear!): Use hash-clear!.
(module-for-each): Use hash-for-each.
(module-map): Use hash-map.
2003-02-19 15:04:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2003-02-11 13:49:32 +00:00
|
|
|
|
static int
|
|
|
|
|
|
hashtable_print (SCM exp, SCM port, scm_print_state *pstate SCM_UNUSED)
|
|
|
|
|
|
{
|
* hooks.c (scm_c_hook_add): Fixed bug in append mode.
* environments.c (obarray_enter, obarray_retrieve, obarray_remove,
leaf_environment_fold, obarray_remove_all): Use hashtable
accessors.
* gc.c (scm_init_storage): Moved hook initialization to
scm_storage_prehistory.
(scm_storage_prehistory): New function.
(scm_igc): Added commentary about placement of
scm_after_sweep_c_hook.
* gc-mark.c (scm_mark_all): Use hashtable accessors.
(scm_gc_mark_dependencies): Use SCM_WVECT_WEAK_KEY_P and
SCM_WVECT_WEAK_VALUE_P.
* hashtab.c, hashtab.h (scm_hash_for_each, scm_hash_map): New
functions.
(scm_vector_to_hash_table, scm_c_make_resizing_hash_table):
Removed.
(scm_make_weak_key_hash_table, scm_make_weak_value_hash_table,
scm_make_doubly_weak_hash_table): Moved here from weaks.c.
* init.c (scm_init_guile_1): Removed call to scm_init_weaks; Added
calls to scm_storage_prehistory and scm_hashtab_prehistory.
* modules.c (module-reverse-lookup): Use hashtable accessors.
* symbols.c, symbols.h (scm_i_hash_symbol): New function.
* weaks.c, weaks.h (scm_make_weak_key_alist_vector,
scm_make_weak_value_alist_vector,
scm_make_doubly_weak_alist_vector): New functions.
* weaks.c (scm_init_weaks_builtins): New function.
* weaks.h (SCM_WVECTF_WEAK_KEY, SCM_WVECTF_WEAK_VALUE,
SCM_WVECTF_NOSCAN, SCM_WVECT_WEAK_KEY_P, SCM_WVECT_WEAK_VALUE_P,
SCM_WVECT_NOSCAN_P): New macros.
* weaks.c (scm_scan_weak_vectors): Use SCM_WVECT_WEAK_KEY_P
and SCM_WVECT_WEAK_VALUE_P.
* weaks.c, weaks.h (scm_i_allocate_weak_vector): Renamed from
allocate_weak_vector and exported.
* Makefile.am (ice9_sources): Added weak-vector.scm.
* weak-vector.scm: New file.
* boot-9.scm (module-clear!): Use hash-clear!.
(module-for-each): Use hash-for-each.
(module-map): Use hash-map.
2003-02-19 15:04:51 +00:00
|
|
|
|
scm_puts ("#<", port);
|
|
|
|
|
|
if (SCM_HASHTABLE_WEAK_KEY_P (exp))
|
|
|
|
|
|
scm_puts ("weak-key-", port);
|
|
|
|
|
|
else if (SCM_HASHTABLE_WEAK_VALUE_P (exp))
|
|
|
|
|
|
scm_puts ("weak-value-", port);
|
|
|
|
|
|
else if (SCM_HASHTABLE_DOUBLY_WEAK_P (exp))
|
|
|
|
|
|
scm_puts ("doubly-weak-", port);
|
|
|
|
|
|
scm_puts ("hash-table ", port);
|
* gc-mark.c (scm_mark_all): Do not rely on hooks to run the weak
hashtable and guardian machinery but call the relevant functions
directly.
* guardians.h, guardians.c, deprecated.h,
deprecated.c (scm_destroy_guardian_x, scm_guardian_greedy_p,
scm_guardian_destroyed_p, scm_guard, scm_get_one_zombie):
Deprecated and moved into deprecated.[ch].
* guardians.h, guardians.c: Mostly rewritten.
(scm_i_init_guardians_for_gc,
scm_i_identify_inaccessible_guardeds,
scm_i_mark_inaccessible_guardeds): New.
* weaks.h, weaks.c (SCM_I_WVECT_TYPE, SCM_I_SET_WVECT_TYPE): New.
(SCM_I_WVECT_N_ITEMS, SCM_I_SET_WVECT_N_ITEMS): New.
(SCM_WVECTF_NOSCAN, SCM_WVECT_NOSCAN_P): Removed.
(scm_weaks_prehistory): Removed.
(scm_i_init_weak_vectors_for_gc, scm_i_mark_weak_vector,
scm_i_mark_weak_vectors_non_weaks,
scm_i_remove_weaks_from_weak_vectors, scm_i_remove_weaks): New.
(scm_weak_vector_gc_init, scm_mark_weak_vector_spines,
scm_scan_weak_vectors): Removed.
* hashtab.h (scm_i_scan_weak_hashtables): New.
* hashtab.c (make_hash_table, scm_i_rehash): Do not use
SCM_WVECTF_NOSCAN.
(hashtable_print): Use SCM_HASHTABLE_N_ITEMS instead of
t->n_items.
(scan_weak_hashtables, scm_i_scan_weak_hashtables): Renamed former
to latter. Do not scan the alists themselves, this is done by the
weak vector code now. Just update the element count.
* vectors.h (SCM_I_WVECT_TYPE, SCM_I_WVECT_EXTRA): Renamed former
to latter. The type is now only part of the cell word.
(SCM_I_SET_WVECT_TYPE, SCM_I_SET_WVECT_EXTRA): Likewise.
* init.c (scm_i_init_guile): Do not call scm_weaks_prehistory.
2005-07-31 23:04:36 +00:00
|
|
|
|
scm_uintprint (SCM_HASHTABLE_N_ITEMS (exp), 10, port);
|
2003-02-11 13:49:32 +00:00
|
|
|
|
scm_putc ('/', port);
|
2005-01-02 20:11:15 +00:00
|
|
|
|
scm_uintprint (SCM_SIMPLE_VECTOR_LENGTH (SCM_HASHTABLE_VECTOR (exp)),
|
|
|
|
|
|
10, port);
|
2003-02-11 13:49:32 +00:00
|
|
|
|
scm_puts (">", port);
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2006-03-21 22:16:33 +00:00
|
|
|
|
/* FIXME */
|
|
|
|
|
|
#define UNMARKED_CELL_P(x) 0 /* (SCM_NIMP(x) && !SCM_GC_MARK_P (x)) */
|
* hooks.c (scm_c_hook_add): Fixed bug in append mode.
* environments.c (obarray_enter, obarray_retrieve, obarray_remove,
leaf_environment_fold, obarray_remove_all): Use hashtable
accessors.
* gc.c (scm_init_storage): Moved hook initialization to
scm_storage_prehistory.
(scm_storage_prehistory): New function.
(scm_igc): Added commentary about placement of
scm_after_sweep_c_hook.
* gc-mark.c (scm_mark_all): Use hashtable accessors.
(scm_gc_mark_dependencies): Use SCM_WVECT_WEAK_KEY_P and
SCM_WVECT_WEAK_VALUE_P.
* hashtab.c, hashtab.h (scm_hash_for_each, scm_hash_map): New
functions.
(scm_vector_to_hash_table, scm_c_make_resizing_hash_table):
Removed.
(scm_make_weak_key_hash_table, scm_make_weak_value_hash_table,
scm_make_doubly_weak_hash_table): Moved here from weaks.c.
* init.c (scm_init_guile_1): Removed call to scm_init_weaks; Added
calls to scm_storage_prehistory and scm_hashtab_prehistory.
* modules.c (module-reverse-lookup): Use hashtable accessors.
* symbols.c, symbols.h (scm_i_hash_symbol): New function.
* weaks.c, weaks.h (scm_make_weak_key_alist_vector,
scm_make_weak_value_alist_vector,
scm_make_doubly_weak_alist_vector): New functions.
* weaks.c (scm_init_weaks_builtins): New function.
* weaks.h (SCM_WVECTF_WEAK_KEY, SCM_WVECTF_WEAK_VALUE,
SCM_WVECTF_NOSCAN, SCM_WVECT_WEAK_KEY_P, SCM_WVECT_WEAK_VALUE_P,
SCM_WVECT_NOSCAN_P): New macros.
* weaks.c (scm_scan_weak_vectors): Use SCM_WVECT_WEAK_KEY_P
and SCM_WVECT_WEAK_VALUE_P.
* weaks.c, weaks.h (scm_i_allocate_weak_vector): Renamed from
allocate_weak_vector and exported.
* Makefile.am (ice9_sources): Added weak-vector.scm.
* weak-vector.scm: New file.
* boot-9.scm (module-clear!): Use hash-clear!.
(module-for-each): Use hash-for-each.
(module-map): Use hash-map.
2003-02-19 15:04:51 +00:00
|
|
|
|
|
|
|
|
|
|
/* keep track of hash tables that need to shrink after scan */
|
|
|
|
|
|
static SCM to_rehash = SCM_EOL;
|
|
|
|
|
|
|
* gc-mark.c (scm_mark_all): Do not rely on hooks to run the weak
hashtable and guardian machinery but call the relevant functions
directly.
* guardians.h, guardians.c, deprecated.h,
deprecated.c (scm_destroy_guardian_x, scm_guardian_greedy_p,
scm_guardian_destroyed_p, scm_guard, scm_get_one_zombie):
Deprecated and moved into deprecated.[ch].
* guardians.h, guardians.c: Mostly rewritten.
(scm_i_init_guardians_for_gc,
scm_i_identify_inaccessible_guardeds,
scm_i_mark_inaccessible_guardeds): New.
* weaks.h, weaks.c (SCM_I_WVECT_TYPE, SCM_I_SET_WVECT_TYPE): New.
(SCM_I_WVECT_N_ITEMS, SCM_I_SET_WVECT_N_ITEMS): New.
(SCM_WVECTF_NOSCAN, SCM_WVECT_NOSCAN_P): Removed.
(scm_weaks_prehistory): Removed.
(scm_i_init_weak_vectors_for_gc, scm_i_mark_weak_vector,
scm_i_mark_weak_vectors_non_weaks,
scm_i_remove_weaks_from_weak_vectors, scm_i_remove_weaks): New.
(scm_weak_vector_gc_init, scm_mark_weak_vector_spines,
scm_scan_weak_vectors): Removed.
* hashtab.h (scm_i_scan_weak_hashtables): New.
* hashtab.c (make_hash_table, scm_i_rehash): Do not use
SCM_WVECTF_NOSCAN.
(hashtable_print): Use SCM_HASHTABLE_N_ITEMS instead of
t->n_items.
(scan_weak_hashtables, scm_i_scan_weak_hashtables): Renamed former
to latter. Do not scan the alists themselves, this is done by the
weak vector code now. Just update the element count.
* vectors.h (SCM_I_WVECT_TYPE, SCM_I_WVECT_EXTRA): Renamed former
to latter. The type is now only part of the cell word.
(SCM_I_SET_WVECT_TYPE, SCM_I_SET_WVECT_EXTRA): Likewise.
* init.c (scm_i_init_guile): Do not call scm_weaks_prehistory.
2005-07-31 23:04:36 +00:00
|
|
|
|
/* scan hash tables and update hash tables item count */
|
|
|
|
|
|
void
|
|
|
|
|
|
scm_i_scan_weak_hashtables ()
|
* hooks.c (scm_c_hook_add): Fixed bug in append mode.
* environments.c (obarray_enter, obarray_retrieve, obarray_remove,
leaf_environment_fold, obarray_remove_all): Use hashtable
accessors.
* gc.c (scm_init_storage): Moved hook initialization to
scm_storage_prehistory.
(scm_storage_prehistory): New function.
(scm_igc): Added commentary about placement of
scm_after_sweep_c_hook.
* gc-mark.c (scm_mark_all): Use hashtable accessors.
(scm_gc_mark_dependencies): Use SCM_WVECT_WEAK_KEY_P and
SCM_WVECT_WEAK_VALUE_P.
* hashtab.c, hashtab.h (scm_hash_for_each, scm_hash_map): New
functions.
(scm_vector_to_hash_table, scm_c_make_resizing_hash_table):
Removed.
(scm_make_weak_key_hash_table, scm_make_weak_value_hash_table,
scm_make_doubly_weak_hash_table): Moved here from weaks.c.
* init.c (scm_init_guile_1): Removed call to scm_init_weaks; Added
calls to scm_storage_prehistory and scm_hashtab_prehistory.
* modules.c (module-reverse-lookup): Use hashtable accessors.
* symbols.c, symbols.h (scm_i_hash_symbol): New function.
* weaks.c, weaks.h (scm_make_weak_key_alist_vector,
scm_make_weak_value_alist_vector,
scm_make_doubly_weak_alist_vector): New functions.
* weaks.c (scm_init_weaks_builtins): New function.
* weaks.h (SCM_WVECTF_WEAK_KEY, SCM_WVECTF_WEAK_VALUE,
SCM_WVECTF_NOSCAN, SCM_WVECT_WEAK_KEY_P, SCM_WVECT_WEAK_VALUE_P,
SCM_WVECT_NOSCAN_P): New macros.
* weaks.c (scm_scan_weak_vectors): Use SCM_WVECT_WEAK_KEY_P
and SCM_WVECT_WEAK_VALUE_P.
* weaks.c, weaks.h (scm_i_allocate_weak_vector): Renamed from
allocate_weak_vector and exported.
* Makefile.am (ice9_sources): Added weak-vector.scm.
* weak-vector.scm: New file.
* boot-9.scm (module-clear!): Use hash-clear!.
(module-for-each): Use hash-for-each.
(module-map): Use hash-map.
2003-02-19 15:04:51 +00:00
|
|
|
|
{
|
2006-03-21 22:16:33 +00:00
|
|
|
|
#if 0 /* FIXME */
|
* hooks.c (scm_c_hook_add): Fixed bug in append mode.
* environments.c (obarray_enter, obarray_retrieve, obarray_remove,
leaf_environment_fold, obarray_remove_all): Use hashtable
accessors.
* gc.c (scm_init_storage): Moved hook initialization to
scm_storage_prehistory.
(scm_storage_prehistory): New function.
(scm_igc): Added commentary about placement of
scm_after_sweep_c_hook.
* gc-mark.c (scm_mark_all): Use hashtable accessors.
(scm_gc_mark_dependencies): Use SCM_WVECT_WEAK_KEY_P and
SCM_WVECT_WEAK_VALUE_P.
* hashtab.c, hashtab.h (scm_hash_for_each, scm_hash_map): New
functions.
(scm_vector_to_hash_table, scm_c_make_resizing_hash_table):
Removed.
(scm_make_weak_key_hash_table, scm_make_weak_value_hash_table,
scm_make_doubly_weak_hash_table): Moved here from weaks.c.
* init.c (scm_init_guile_1): Removed call to scm_init_weaks; Added
calls to scm_storage_prehistory and scm_hashtab_prehistory.
* modules.c (module-reverse-lookup): Use hashtable accessors.
* symbols.c, symbols.h (scm_i_hash_symbol): New function.
* weaks.c, weaks.h (scm_make_weak_key_alist_vector,
scm_make_weak_value_alist_vector,
scm_make_doubly_weak_alist_vector): New functions.
* weaks.c (scm_init_weaks_builtins): New function.
* weaks.h (SCM_WVECTF_WEAK_KEY, SCM_WVECTF_WEAK_VALUE,
SCM_WVECTF_NOSCAN, SCM_WVECT_WEAK_KEY_P, SCM_WVECT_WEAK_VALUE_P,
SCM_WVECT_NOSCAN_P): New macros.
* weaks.c (scm_scan_weak_vectors): Use SCM_WVECT_WEAK_KEY_P
and SCM_WVECT_WEAK_VALUE_P.
* weaks.c, weaks.h (scm_i_allocate_weak_vector): Renamed from
allocate_weak_vector and exported.
* Makefile.am (ice9_sources): Added weak-vector.scm.
* weak-vector.scm: New file.
* boot-9.scm (module-clear!): Use hash-clear!.
(module-for-each): Use hash-for-each.
(module-map): Use hash-map.
2003-02-19 15:04:51 +00:00
|
|
|
|
SCM *next = &weak_hashtables;
|
|
|
|
|
|
SCM h = *next;
|
2004-09-22 17:41:37 +00:00
|
|
|
|
while (!scm_is_null (h))
|
* hooks.c (scm_c_hook_add): Fixed bug in append mode.
* environments.c (obarray_enter, obarray_retrieve, obarray_remove,
leaf_environment_fold, obarray_remove_all): Use hashtable
accessors.
* gc.c (scm_init_storage): Moved hook initialization to
scm_storage_prehistory.
(scm_storage_prehistory): New function.
(scm_igc): Added commentary about placement of
scm_after_sweep_c_hook.
* gc-mark.c (scm_mark_all): Use hashtable accessors.
(scm_gc_mark_dependencies): Use SCM_WVECT_WEAK_KEY_P and
SCM_WVECT_WEAK_VALUE_P.
* hashtab.c, hashtab.h (scm_hash_for_each, scm_hash_map): New
functions.
(scm_vector_to_hash_table, scm_c_make_resizing_hash_table):
Removed.
(scm_make_weak_key_hash_table, scm_make_weak_value_hash_table,
scm_make_doubly_weak_hash_table): Moved here from weaks.c.
* init.c (scm_init_guile_1): Removed call to scm_init_weaks; Added
calls to scm_storage_prehistory and scm_hashtab_prehistory.
* modules.c (module-reverse-lookup): Use hashtable accessors.
* symbols.c, symbols.h (scm_i_hash_symbol): New function.
* weaks.c, weaks.h (scm_make_weak_key_alist_vector,
scm_make_weak_value_alist_vector,
scm_make_doubly_weak_alist_vector): New functions.
* weaks.c (scm_init_weaks_builtins): New function.
* weaks.h (SCM_WVECTF_WEAK_KEY, SCM_WVECTF_WEAK_VALUE,
SCM_WVECTF_NOSCAN, SCM_WVECT_WEAK_KEY_P, SCM_WVECT_WEAK_VALUE_P,
SCM_WVECT_NOSCAN_P): New macros.
* weaks.c (scm_scan_weak_vectors): Use SCM_WVECT_WEAK_KEY_P
and SCM_WVECT_WEAK_VALUE_P.
* weaks.c, weaks.h (scm_i_allocate_weak_vector): Renamed from
allocate_weak_vector and exported.
* Makefile.am (ice9_sources): Added weak-vector.scm.
* weak-vector.scm: New file.
* boot-9.scm (module-clear!): Use hash-clear!.
(module-for-each): Use hash-for-each.
(module-map): Use hash-map.
2003-02-19 15:04:51 +00:00
|
|
|
|
{
|
|
|
|
|
|
if (!SCM_GC_MARK_P (h))
|
|
|
|
|
|
*next = h = SCM_HASHTABLE_NEXT (h);
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
* gc-mark.c (scm_mark_all): Do not rely on hooks to run the weak
hashtable and guardian machinery but call the relevant functions
directly.
* guardians.h, guardians.c, deprecated.h,
deprecated.c (scm_destroy_guardian_x, scm_guardian_greedy_p,
scm_guardian_destroyed_p, scm_guard, scm_get_one_zombie):
Deprecated and moved into deprecated.[ch].
* guardians.h, guardians.c: Mostly rewritten.
(scm_i_init_guardians_for_gc,
scm_i_identify_inaccessible_guardeds,
scm_i_mark_inaccessible_guardeds): New.
* weaks.h, weaks.c (SCM_I_WVECT_TYPE, SCM_I_SET_WVECT_TYPE): New.
(SCM_I_WVECT_N_ITEMS, SCM_I_SET_WVECT_N_ITEMS): New.
(SCM_WVECTF_NOSCAN, SCM_WVECT_NOSCAN_P): Removed.
(scm_weaks_prehistory): Removed.
(scm_i_init_weak_vectors_for_gc, scm_i_mark_weak_vector,
scm_i_mark_weak_vectors_non_weaks,
scm_i_remove_weaks_from_weak_vectors, scm_i_remove_weaks): New.
(scm_weak_vector_gc_init, scm_mark_weak_vector_spines,
scm_scan_weak_vectors): Removed.
* hashtab.h (scm_i_scan_weak_hashtables): New.
* hashtab.c (make_hash_table, scm_i_rehash): Do not use
SCM_WVECTF_NOSCAN.
(hashtable_print): Use SCM_HASHTABLE_N_ITEMS instead of
t->n_items.
(scan_weak_hashtables, scm_i_scan_weak_hashtables): Renamed former
to latter. Do not scan the alists themselves, this is done by the
weak vector code now. Just update the element count.
* vectors.h (SCM_I_WVECT_TYPE, SCM_I_WVECT_EXTRA): Renamed former
to latter. The type is now only part of the cell word.
(SCM_I_SET_WVECT_TYPE, SCM_I_SET_WVECT_EXTRA): Likewise.
* init.c (scm_i_init_guile): Do not call scm_weaks_prehistory.
2005-07-31 23:04:36 +00:00
|
|
|
|
SCM vec = SCM_HASHTABLE_VECTOR (h);
|
|
|
|
|
|
size_t delta = SCM_I_WVECT_DELTA (vec);
|
|
|
|
|
|
SCM_I_SET_WVECT_DELTA (vec, 0);
|
|
|
|
|
|
SCM_SET_HASHTABLE_N_ITEMS (h, SCM_HASHTABLE_N_ITEMS (h) - delta);
|
|
|
|
|
|
|
|
|
|
|
|
if (SCM_HASHTABLE_N_ITEMS (h) < SCM_HASHTABLE_LOWER (h))
|
* hooks.c (scm_c_hook_add): Fixed bug in append mode.
* environments.c (obarray_enter, obarray_retrieve, obarray_remove,
leaf_environment_fold, obarray_remove_all): Use hashtable
accessors.
* gc.c (scm_init_storage): Moved hook initialization to
scm_storage_prehistory.
(scm_storage_prehistory): New function.
(scm_igc): Added commentary about placement of
scm_after_sweep_c_hook.
* gc-mark.c (scm_mark_all): Use hashtable accessors.
(scm_gc_mark_dependencies): Use SCM_WVECT_WEAK_KEY_P and
SCM_WVECT_WEAK_VALUE_P.
* hashtab.c, hashtab.h (scm_hash_for_each, scm_hash_map): New
functions.
(scm_vector_to_hash_table, scm_c_make_resizing_hash_table):
Removed.
(scm_make_weak_key_hash_table, scm_make_weak_value_hash_table,
scm_make_doubly_weak_hash_table): Moved here from weaks.c.
* init.c (scm_init_guile_1): Removed call to scm_init_weaks; Added
calls to scm_storage_prehistory and scm_hashtab_prehistory.
* modules.c (module-reverse-lookup): Use hashtable accessors.
* symbols.c, symbols.h (scm_i_hash_symbol): New function.
* weaks.c, weaks.h (scm_make_weak_key_alist_vector,
scm_make_weak_value_alist_vector,
scm_make_doubly_weak_alist_vector): New functions.
* weaks.c (scm_init_weaks_builtins): New function.
* weaks.h (SCM_WVECTF_WEAK_KEY, SCM_WVECTF_WEAK_VALUE,
SCM_WVECTF_NOSCAN, SCM_WVECT_WEAK_KEY_P, SCM_WVECT_WEAK_VALUE_P,
SCM_WVECT_NOSCAN_P): New macros.
* weaks.c (scm_scan_weak_vectors): Use SCM_WVECT_WEAK_KEY_P
and SCM_WVECT_WEAK_VALUE_P.
* weaks.c, weaks.h (scm_i_allocate_weak_vector): Renamed from
allocate_weak_vector and exported.
* Makefile.am (ice9_sources): Added weak-vector.scm.
* weak-vector.scm: New file.
* boot-9.scm (module-clear!): Use hash-clear!.
(module-for-each): Use hash-for-each.
(module-map): Use hash-map.
2003-02-19 15:04:51 +00:00
|
|
|
|
{
|
|
|
|
|
|
SCM tmp = SCM_HASHTABLE_NEXT (h);
|
|
|
|
|
|
/* temporarily move table from weak_hashtables to to_rehash */
|
|
|
|
|
|
SCM_SET_HASHTABLE_NEXT (h, to_rehash);
|
|
|
|
|
|
to_rehash = h;
|
|
|
|
|
|
*next = h = tmp;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
next = SCM_HASHTABLE_NEXTLOC (h);
|
|
|
|
|
|
h = SCM_HASHTABLE_NEXT (h);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2006-03-21 22:16:33 +00:00
|
|
|
|
#endif
|
* hooks.c (scm_c_hook_add): Fixed bug in append mode.
* environments.c (obarray_enter, obarray_retrieve, obarray_remove,
leaf_environment_fold, obarray_remove_all): Use hashtable
accessors.
* gc.c (scm_init_storage): Moved hook initialization to
scm_storage_prehistory.
(scm_storage_prehistory): New function.
(scm_igc): Added commentary about placement of
scm_after_sweep_c_hook.
* gc-mark.c (scm_mark_all): Use hashtable accessors.
(scm_gc_mark_dependencies): Use SCM_WVECT_WEAK_KEY_P and
SCM_WVECT_WEAK_VALUE_P.
* hashtab.c, hashtab.h (scm_hash_for_each, scm_hash_map): New
functions.
(scm_vector_to_hash_table, scm_c_make_resizing_hash_table):
Removed.
(scm_make_weak_key_hash_table, scm_make_weak_value_hash_table,
scm_make_doubly_weak_hash_table): Moved here from weaks.c.
* init.c (scm_init_guile_1): Removed call to scm_init_weaks; Added
calls to scm_storage_prehistory and scm_hashtab_prehistory.
* modules.c (module-reverse-lookup): Use hashtable accessors.
* symbols.c, symbols.h (scm_i_hash_symbol): New function.
* weaks.c, weaks.h (scm_make_weak_key_alist_vector,
scm_make_weak_value_alist_vector,
scm_make_doubly_weak_alist_vector): New functions.
* weaks.c (scm_init_weaks_builtins): New function.
* weaks.h (SCM_WVECTF_WEAK_KEY, SCM_WVECTF_WEAK_VALUE,
SCM_WVECTF_NOSCAN, SCM_WVECT_WEAK_KEY_P, SCM_WVECT_WEAK_VALUE_P,
SCM_WVECT_NOSCAN_P): New macros.
* weaks.c (scm_scan_weak_vectors): Use SCM_WVECT_WEAK_KEY_P
and SCM_WVECT_WEAK_VALUE_P.
* weaks.c, weaks.h (scm_i_allocate_weak_vector): Renamed from
allocate_weak_vector and exported.
* Makefile.am (ice9_sources): Added weak-vector.scm.
* weak-vector.scm: New file.
* boot-9.scm (module-clear!): Use hash-clear!.
(module-for-each): Use hash-for-each.
(module-map): Use hash-map.
2003-02-19 15:04:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void *
|
|
|
|
|
|
rehash_after_gc (void *dummy1 SCM_UNUSED,
|
|
|
|
|
|
void *dummy2 SCM_UNUSED,
|
|
|
|
|
|
void *dummy3 SCM_UNUSED)
|
|
|
|
|
|
{
|
2004-09-22 17:41:37 +00:00
|
|
|
|
if (!scm_is_null (to_rehash))
|
* hooks.c (scm_c_hook_add): Fixed bug in append mode.
* environments.c (obarray_enter, obarray_retrieve, obarray_remove,
leaf_environment_fold, obarray_remove_all): Use hashtable
accessors.
* gc.c (scm_init_storage): Moved hook initialization to
scm_storage_prehistory.
(scm_storage_prehistory): New function.
(scm_igc): Added commentary about placement of
scm_after_sweep_c_hook.
* gc-mark.c (scm_mark_all): Use hashtable accessors.
(scm_gc_mark_dependencies): Use SCM_WVECT_WEAK_KEY_P and
SCM_WVECT_WEAK_VALUE_P.
* hashtab.c, hashtab.h (scm_hash_for_each, scm_hash_map): New
functions.
(scm_vector_to_hash_table, scm_c_make_resizing_hash_table):
Removed.
(scm_make_weak_key_hash_table, scm_make_weak_value_hash_table,
scm_make_doubly_weak_hash_table): Moved here from weaks.c.
* init.c (scm_init_guile_1): Removed call to scm_init_weaks; Added
calls to scm_storage_prehistory and scm_hashtab_prehistory.
* modules.c (module-reverse-lookup): Use hashtable accessors.
* symbols.c, symbols.h (scm_i_hash_symbol): New function.
* weaks.c, weaks.h (scm_make_weak_key_alist_vector,
scm_make_weak_value_alist_vector,
scm_make_doubly_weak_alist_vector): New functions.
* weaks.c (scm_init_weaks_builtins): New function.
* weaks.h (SCM_WVECTF_WEAK_KEY, SCM_WVECTF_WEAK_VALUE,
SCM_WVECTF_NOSCAN, SCM_WVECT_WEAK_KEY_P, SCM_WVECT_WEAK_VALUE_P,
SCM_WVECT_NOSCAN_P): New macros.
* weaks.c (scm_scan_weak_vectors): Use SCM_WVECT_WEAK_KEY_P
and SCM_WVECT_WEAK_VALUE_P.
* weaks.c, weaks.h (scm_i_allocate_weak_vector): Renamed from
allocate_weak_vector and exported.
* Makefile.am (ice9_sources): Added weak-vector.scm.
* weak-vector.scm: New file.
* boot-9.scm (module-clear!): Use hash-clear!.
(module-for-each): Use hash-for-each.
(module-map): Use hash-map.
2003-02-19 15:04:51 +00:00
|
|
|
|
{
|
2004-05-18 21:29:38 +00:00
|
|
|
|
SCM first = to_rehash, last, h;
|
2003-04-05 20:45:17 +00:00
|
|
|
|
/* important to clear to_rehash here so that we don't get stuck
|
|
|
|
|
|
in an infinite loop if scm_i_rehash causes GC */
|
|
|
|
|
|
to_rehash = SCM_EOL;
|
2004-05-18 21:29:38 +00:00
|
|
|
|
h = first;
|
* hooks.c (scm_c_hook_add): Fixed bug in append mode.
* environments.c (obarray_enter, obarray_retrieve, obarray_remove,
leaf_environment_fold, obarray_remove_all): Use hashtable
accessors.
* gc.c (scm_init_storage): Moved hook initialization to
scm_storage_prehistory.
(scm_storage_prehistory): New function.
(scm_igc): Added commentary about placement of
scm_after_sweep_c_hook.
* gc-mark.c (scm_mark_all): Use hashtable accessors.
(scm_gc_mark_dependencies): Use SCM_WVECT_WEAK_KEY_P and
SCM_WVECT_WEAK_VALUE_P.
* hashtab.c, hashtab.h (scm_hash_for_each, scm_hash_map): New
functions.
(scm_vector_to_hash_table, scm_c_make_resizing_hash_table):
Removed.
(scm_make_weak_key_hash_table, scm_make_weak_value_hash_table,
scm_make_doubly_weak_hash_table): Moved here from weaks.c.
* init.c (scm_init_guile_1): Removed call to scm_init_weaks; Added
calls to scm_storage_prehistory and scm_hashtab_prehistory.
* modules.c (module-reverse-lookup): Use hashtable accessors.
* symbols.c, symbols.h (scm_i_hash_symbol): New function.
* weaks.c, weaks.h (scm_make_weak_key_alist_vector,
scm_make_weak_value_alist_vector,
scm_make_doubly_weak_alist_vector): New functions.
* weaks.c (scm_init_weaks_builtins): New function.
* weaks.h (SCM_WVECTF_WEAK_KEY, SCM_WVECTF_WEAK_VALUE,
SCM_WVECTF_NOSCAN, SCM_WVECT_WEAK_KEY_P, SCM_WVECT_WEAK_VALUE_P,
SCM_WVECT_NOSCAN_P): New macros.
* weaks.c (scm_scan_weak_vectors): Use SCM_WVECT_WEAK_KEY_P
and SCM_WVECT_WEAK_VALUE_P.
* weaks.c, weaks.h (scm_i_allocate_weak_vector): Renamed from
allocate_weak_vector and exported.
* Makefile.am (ice9_sources): Added weak-vector.scm.
* weak-vector.scm: New file.
* boot-9.scm (module-clear!): Use hash-clear!.
(module-for-each): Use hash-for-each.
(module-map): Use hash-map.
2003-02-19 15:04:51 +00:00
|
|
|
|
do
|
|
|
|
|
|
{
|
2005-04-04 14:53:27 +00:00
|
|
|
|
/* Rehash only when we have a hash_fn.
|
|
|
|
|
|
*/
|
|
|
|
|
|
if (SCM_HASHTABLE (h)->hash_fn)
|
|
|
|
|
|
scm_i_rehash (h, SCM_HASHTABLE (h)->hash_fn, NULL,
|
|
|
|
|
|
"rehash_after_gc");
|
* hooks.c (scm_c_hook_add): Fixed bug in append mode.
* environments.c (obarray_enter, obarray_retrieve, obarray_remove,
leaf_environment_fold, obarray_remove_all): Use hashtable
accessors.
* gc.c (scm_init_storage): Moved hook initialization to
scm_storage_prehistory.
(scm_storage_prehistory): New function.
(scm_igc): Added commentary about placement of
scm_after_sweep_c_hook.
* gc-mark.c (scm_mark_all): Use hashtable accessors.
(scm_gc_mark_dependencies): Use SCM_WVECT_WEAK_KEY_P and
SCM_WVECT_WEAK_VALUE_P.
* hashtab.c, hashtab.h (scm_hash_for_each, scm_hash_map): New
functions.
(scm_vector_to_hash_table, scm_c_make_resizing_hash_table):
Removed.
(scm_make_weak_key_hash_table, scm_make_weak_value_hash_table,
scm_make_doubly_weak_hash_table): Moved here from weaks.c.
* init.c (scm_init_guile_1): Removed call to scm_init_weaks; Added
calls to scm_storage_prehistory and scm_hashtab_prehistory.
* modules.c (module-reverse-lookup): Use hashtable accessors.
* symbols.c, symbols.h (scm_i_hash_symbol): New function.
* weaks.c, weaks.h (scm_make_weak_key_alist_vector,
scm_make_weak_value_alist_vector,
scm_make_doubly_weak_alist_vector): New functions.
* weaks.c (scm_init_weaks_builtins): New function.
* weaks.h (SCM_WVECTF_WEAK_KEY, SCM_WVECTF_WEAK_VALUE,
SCM_WVECTF_NOSCAN, SCM_WVECT_WEAK_KEY_P, SCM_WVECT_WEAK_VALUE_P,
SCM_WVECT_NOSCAN_P): New macros.
* weaks.c (scm_scan_weak_vectors): Use SCM_WVECT_WEAK_KEY_P
and SCM_WVECT_WEAK_VALUE_P.
* weaks.c, weaks.h (scm_i_allocate_weak_vector): Renamed from
allocate_weak_vector and exported.
* Makefile.am (ice9_sources): Added weak-vector.scm.
* weak-vector.scm: New file.
* boot-9.scm (module-clear!): Use hash-clear!.
(module-for-each): Use hash-for-each.
(module-map): Use hash-map.
2003-02-19 15:04:51 +00:00
|
|
|
|
last = h;
|
|
|
|
|
|
h = SCM_HASHTABLE_NEXT (h);
|
2004-09-22 17:41:37 +00:00
|
|
|
|
} while (!scm_is_null (h));
|
* hooks.c (scm_c_hook_add): Fixed bug in append mode.
* environments.c (obarray_enter, obarray_retrieve, obarray_remove,
leaf_environment_fold, obarray_remove_all): Use hashtable
accessors.
* gc.c (scm_init_storage): Moved hook initialization to
scm_storage_prehistory.
(scm_storage_prehistory): New function.
(scm_igc): Added commentary about placement of
scm_after_sweep_c_hook.
* gc-mark.c (scm_mark_all): Use hashtable accessors.
(scm_gc_mark_dependencies): Use SCM_WVECT_WEAK_KEY_P and
SCM_WVECT_WEAK_VALUE_P.
* hashtab.c, hashtab.h (scm_hash_for_each, scm_hash_map): New
functions.
(scm_vector_to_hash_table, scm_c_make_resizing_hash_table):
Removed.
(scm_make_weak_key_hash_table, scm_make_weak_value_hash_table,
scm_make_doubly_weak_hash_table): Moved here from weaks.c.
* init.c (scm_init_guile_1): Removed call to scm_init_weaks; Added
calls to scm_storage_prehistory and scm_hashtab_prehistory.
* modules.c (module-reverse-lookup): Use hashtable accessors.
* symbols.c, symbols.h (scm_i_hash_symbol): New function.
* weaks.c, weaks.h (scm_make_weak_key_alist_vector,
scm_make_weak_value_alist_vector,
scm_make_doubly_weak_alist_vector): New functions.
* weaks.c (scm_init_weaks_builtins): New function.
* weaks.h (SCM_WVECTF_WEAK_KEY, SCM_WVECTF_WEAK_VALUE,
SCM_WVECTF_NOSCAN, SCM_WVECT_WEAK_KEY_P, SCM_WVECT_WEAK_VALUE_P,
SCM_WVECT_NOSCAN_P): New macros.
* weaks.c (scm_scan_weak_vectors): Use SCM_WVECT_WEAK_KEY_P
and SCM_WVECT_WEAK_VALUE_P.
* weaks.c, weaks.h (scm_i_allocate_weak_vector): Renamed from
allocate_weak_vector and exported.
* Makefile.am (ice9_sources): Added weak-vector.scm.
* weak-vector.scm: New file.
* boot-9.scm (module-clear!): Use hash-clear!.
(module-for-each): Use hash-for-each.
(module-map): Use hash-map.
2003-02-19 15:04:51 +00:00
|
|
|
|
/* move tables back to weak_hashtables */
|
|
|
|
|
|
SCM_SET_HASHTABLE_NEXT (last, weak_hashtables);
|
2004-05-18 21:29:38 +00:00
|
|
|
|
weak_hashtables = first;
|
* hooks.c (scm_c_hook_add): Fixed bug in append mode.
* environments.c (obarray_enter, obarray_retrieve, obarray_remove,
leaf_environment_fold, obarray_remove_all): Use hashtable
accessors.
* gc.c (scm_init_storage): Moved hook initialization to
scm_storage_prehistory.
(scm_storage_prehistory): New function.
(scm_igc): Added commentary about placement of
scm_after_sweep_c_hook.
* gc-mark.c (scm_mark_all): Use hashtable accessors.
(scm_gc_mark_dependencies): Use SCM_WVECT_WEAK_KEY_P and
SCM_WVECT_WEAK_VALUE_P.
* hashtab.c, hashtab.h (scm_hash_for_each, scm_hash_map): New
functions.
(scm_vector_to_hash_table, scm_c_make_resizing_hash_table):
Removed.
(scm_make_weak_key_hash_table, scm_make_weak_value_hash_table,
scm_make_doubly_weak_hash_table): Moved here from weaks.c.
* init.c (scm_init_guile_1): Removed call to scm_init_weaks; Added
calls to scm_storage_prehistory and scm_hashtab_prehistory.
* modules.c (module-reverse-lookup): Use hashtable accessors.
* symbols.c, symbols.h (scm_i_hash_symbol): New function.
* weaks.c, weaks.h (scm_make_weak_key_alist_vector,
scm_make_weak_value_alist_vector,
scm_make_doubly_weak_alist_vector): New functions.
* weaks.c (scm_init_weaks_builtins): New function.
* weaks.h (SCM_WVECTF_WEAK_KEY, SCM_WVECTF_WEAK_VALUE,
SCM_WVECTF_NOSCAN, SCM_WVECT_WEAK_KEY_P, SCM_WVECT_WEAK_VALUE_P,
SCM_WVECT_NOSCAN_P): New macros.
* weaks.c (scm_scan_weak_vectors): Use SCM_WVECT_WEAK_KEY_P
and SCM_WVECT_WEAK_VALUE_P.
* weaks.c, weaks.h (scm_i_allocate_weak_vector): Renamed from
allocate_weak_vector and exported.
* Makefile.am (ice9_sources): Added weak-vector.scm.
* weak-vector.scm: New file.
* boot-9.scm (module-clear!): Use hash-clear!.
(module-for-each): Use hash-for-each.
(module-map): Use hash-map.
2003-02-19 15:04:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2003-02-11 13:49:32 +00:00
|
|
|
|
static size_t
|
|
|
|
|
|
hashtable_free (SCM obj)
|
|
|
|
|
|
{
|
|
|
|
|
|
scm_gc_free (SCM_HASHTABLE (obj), sizeof (scm_t_hashtable), s_hashtable);
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2001-02-02 04:56:25 +00:00
|
|
|
|
SCM
|
2001-05-26 20:51:22 +00:00
|
|
|
|
scm_c_make_hash_table (unsigned long k)
|
2001-02-02 04:56:25 +00:00
|
|
|
|
{
|
* hooks.c (scm_c_hook_add): Fixed bug in append mode.
* environments.c (obarray_enter, obarray_retrieve, obarray_remove,
leaf_environment_fold, obarray_remove_all): Use hashtable
accessors.
* gc.c (scm_init_storage): Moved hook initialization to
scm_storage_prehistory.
(scm_storage_prehistory): New function.
(scm_igc): Added commentary about placement of
scm_after_sweep_c_hook.
* gc-mark.c (scm_mark_all): Use hashtable accessors.
(scm_gc_mark_dependencies): Use SCM_WVECT_WEAK_KEY_P and
SCM_WVECT_WEAK_VALUE_P.
* hashtab.c, hashtab.h (scm_hash_for_each, scm_hash_map): New
functions.
(scm_vector_to_hash_table, scm_c_make_resizing_hash_table):
Removed.
(scm_make_weak_key_hash_table, scm_make_weak_value_hash_table,
scm_make_doubly_weak_hash_table): Moved here from weaks.c.
* init.c (scm_init_guile_1): Removed call to scm_init_weaks; Added
calls to scm_storage_prehistory and scm_hashtab_prehistory.
* modules.c (module-reverse-lookup): Use hashtable accessors.
* symbols.c, symbols.h (scm_i_hash_symbol): New function.
* weaks.c, weaks.h (scm_make_weak_key_alist_vector,
scm_make_weak_value_alist_vector,
scm_make_doubly_weak_alist_vector): New functions.
* weaks.c (scm_init_weaks_builtins): New function.
* weaks.h (SCM_WVECTF_WEAK_KEY, SCM_WVECTF_WEAK_VALUE,
SCM_WVECTF_NOSCAN, SCM_WVECT_WEAK_KEY_P, SCM_WVECT_WEAK_VALUE_P,
SCM_WVECT_NOSCAN_P): New macros.
* weaks.c (scm_scan_weak_vectors): Use SCM_WVECT_WEAK_KEY_P
and SCM_WVECT_WEAK_VALUE_P.
* weaks.c, weaks.h (scm_i_allocate_weak_vector): Renamed from
allocate_weak_vector and exported.
* Makefile.am (ice9_sources): Added weak-vector.scm.
* weak-vector.scm: New file.
* boot-9.scm (module-clear!): Use hash-clear!.
(module-for-each): Use hash-for-each.
(module-map): Use hash-map.
2003-02-19 15:04:51 +00:00
|
|
|
|
return make_hash_table (0, k, "scm_c_make_hash_table");
|
2003-02-11 13:49:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SCM_DEFINE (scm_make_hash_table, "make-hash-table", 0, 1, 0,
|
|
|
|
|
|
(SCM n),
|
2005-03-29 17:47:39 +00:00
|
|
|
|
"Make a new abstract hash table object with minimum number of buckets @var{n}\n")
|
2003-02-11 13:49:32 +00:00
|
|
|
|
#define FUNC_NAME s_scm_make_hash_table
|
|
|
|
|
|
{
|
|
|
|
|
|
if (SCM_UNBNDP (n))
|
* hooks.c (scm_c_hook_add): Fixed bug in append mode.
* environments.c (obarray_enter, obarray_retrieve, obarray_remove,
leaf_environment_fold, obarray_remove_all): Use hashtable
accessors.
* gc.c (scm_init_storage): Moved hook initialization to
scm_storage_prehistory.
(scm_storage_prehistory): New function.
(scm_igc): Added commentary about placement of
scm_after_sweep_c_hook.
* gc-mark.c (scm_mark_all): Use hashtable accessors.
(scm_gc_mark_dependencies): Use SCM_WVECT_WEAK_KEY_P and
SCM_WVECT_WEAK_VALUE_P.
* hashtab.c, hashtab.h (scm_hash_for_each, scm_hash_map): New
functions.
(scm_vector_to_hash_table, scm_c_make_resizing_hash_table):
Removed.
(scm_make_weak_key_hash_table, scm_make_weak_value_hash_table,
scm_make_doubly_weak_hash_table): Moved here from weaks.c.
* init.c (scm_init_guile_1): Removed call to scm_init_weaks; Added
calls to scm_storage_prehistory and scm_hashtab_prehistory.
* modules.c (module-reverse-lookup): Use hashtable accessors.
* symbols.c, symbols.h (scm_i_hash_symbol): New function.
* weaks.c, weaks.h (scm_make_weak_key_alist_vector,
scm_make_weak_value_alist_vector,
scm_make_doubly_weak_alist_vector): New functions.
* weaks.c (scm_init_weaks_builtins): New function.
* weaks.h (SCM_WVECTF_WEAK_KEY, SCM_WVECTF_WEAK_VALUE,
SCM_WVECTF_NOSCAN, SCM_WVECT_WEAK_KEY_P, SCM_WVECT_WEAK_VALUE_P,
SCM_WVECT_NOSCAN_P): New macros.
* weaks.c (scm_scan_weak_vectors): Use SCM_WVECT_WEAK_KEY_P
and SCM_WVECT_WEAK_VALUE_P.
* weaks.c, weaks.h (scm_i_allocate_weak_vector): Renamed from
allocate_weak_vector and exported.
* Makefile.am (ice9_sources): Added weak-vector.scm.
* weak-vector.scm: New file.
* boot-9.scm (module-clear!): Use hash-clear!.
(module-for-each): Use hash-for-each.
(module-map): Use hash-map.
2003-02-19 15:04:51 +00:00
|
|
|
|
return make_hash_table (0, 0, FUNC_NAME);
|
2003-02-11 13:49:32 +00:00
|
|
|
|
else
|
* validate.h, deprecated.h (SCM_VALIDATE_INUM, SCM_VALIDATE_INUM_COPY,
SCM_VALIDATE_BIGINT, SCM_VALIDATE_INUM_MIN,
SCM_VALIDATE_INUM_MIN_COPY,
SCM_VALIDATE_INUM_MIN_DEF_COPY,SCM_VALIDATE_INUM_DEF,
SCM_VALIDATE_INUM_DEF_COPY, SCM_VALIDATE_INUM_RANGE,
SCM_VALIDATE_INUM_RANGE_COPY): Deprecated because they make the
fixnum/bignum distinction visible. Changed all uses to scm_to_size_t
or similar.
2004-07-10 14:35:36 +00:00
|
|
|
|
return make_hash_table (0, scm_to_ulong (n), FUNC_NAME);
|
2003-02-11 13:49:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
#undef FUNC_NAME
|
|
|
|
|
|
|
* hooks.c (scm_c_hook_add): Fixed bug in append mode.
* environments.c (obarray_enter, obarray_retrieve, obarray_remove,
leaf_environment_fold, obarray_remove_all): Use hashtable
accessors.
* gc.c (scm_init_storage): Moved hook initialization to
scm_storage_prehistory.
(scm_storage_prehistory): New function.
(scm_igc): Added commentary about placement of
scm_after_sweep_c_hook.
* gc-mark.c (scm_mark_all): Use hashtable accessors.
(scm_gc_mark_dependencies): Use SCM_WVECT_WEAK_KEY_P and
SCM_WVECT_WEAK_VALUE_P.
* hashtab.c, hashtab.h (scm_hash_for_each, scm_hash_map): New
functions.
(scm_vector_to_hash_table, scm_c_make_resizing_hash_table):
Removed.
(scm_make_weak_key_hash_table, scm_make_weak_value_hash_table,
scm_make_doubly_weak_hash_table): Moved here from weaks.c.
* init.c (scm_init_guile_1): Removed call to scm_init_weaks; Added
calls to scm_storage_prehistory and scm_hashtab_prehistory.
* modules.c (module-reverse-lookup): Use hashtable accessors.
* symbols.c, symbols.h (scm_i_hash_symbol): New function.
* weaks.c, weaks.h (scm_make_weak_key_alist_vector,
scm_make_weak_value_alist_vector,
scm_make_doubly_weak_alist_vector): New functions.
* weaks.c (scm_init_weaks_builtins): New function.
* weaks.h (SCM_WVECTF_WEAK_KEY, SCM_WVECTF_WEAK_VALUE,
SCM_WVECTF_NOSCAN, SCM_WVECT_WEAK_KEY_P, SCM_WVECT_WEAK_VALUE_P,
SCM_WVECT_NOSCAN_P): New macros.
* weaks.c (scm_scan_weak_vectors): Use SCM_WVECT_WEAK_KEY_P
and SCM_WVECT_WEAK_VALUE_P.
* weaks.c, weaks.h (scm_i_allocate_weak_vector): Renamed from
allocate_weak_vector and exported.
* Makefile.am (ice9_sources): Added weak-vector.scm.
* weak-vector.scm: New file.
* boot-9.scm (module-clear!): Use hash-clear!.
(module-for-each): Use hash-for-each.
(module-map): Use hash-map.
2003-02-19 15:04:51 +00:00
|
|
|
|
SCM_DEFINE (scm_make_weak_key_hash_table, "make-weak-key-hash-table", 0, 1, 0,
|
|
|
|
|
|
(SCM n),
|
|
|
|
|
|
"@deffnx {Scheme Procedure} make-weak-value-hash-table size\n"
|
|
|
|
|
|
"@deffnx {Scheme Procedure} make-doubly-weak-hash-table size\n"
|
2005-03-29 17:47:39 +00:00
|
|
|
|
"Return a weak hash table with @var{size} buckets.\n"
|
* hooks.c (scm_c_hook_add): Fixed bug in append mode.
* environments.c (obarray_enter, obarray_retrieve, obarray_remove,
leaf_environment_fold, obarray_remove_all): Use hashtable
accessors.
* gc.c (scm_init_storage): Moved hook initialization to
scm_storage_prehistory.
(scm_storage_prehistory): New function.
(scm_igc): Added commentary about placement of
scm_after_sweep_c_hook.
* gc-mark.c (scm_mark_all): Use hashtable accessors.
(scm_gc_mark_dependencies): Use SCM_WVECT_WEAK_KEY_P and
SCM_WVECT_WEAK_VALUE_P.
* hashtab.c, hashtab.h (scm_hash_for_each, scm_hash_map): New
functions.
(scm_vector_to_hash_table, scm_c_make_resizing_hash_table):
Removed.
(scm_make_weak_key_hash_table, scm_make_weak_value_hash_table,
scm_make_doubly_weak_hash_table): Moved here from weaks.c.
* init.c (scm_init_guile_1): Removed call to scm_init_weaks; Added
calls to scm_storage_prehistory and scm_hashtab_prehistory.
* modules.c (module-reverse-lookup): Use hashtable accessors.
* symbols.c, symbols.h (scm_i_hash_symbol): New function.
* weaks.c, weaks.h (scm_make_weak_key_alist_vector,
scm_make_weak_value_alist_vector,
scm_make_doubly_weak_alist_vector): New functions.
* weaks.c (scm_init_weaks_builtins): New function.
* weaks.h (SCM_WVECTF_WEAK_KEY, SCM_WVECTF_WEAK_VALUE,
SCM_WVECTF_NOSCAN, SCM_WVECT_WEAK_KEY_P, SCM_WVECT_WEAK_VALUE_P,
SCM_WVECT_NOSCAN_P): New macros.
* weaks.c (scm_scan_weak_vectors): Use SCM_WVECT_WEAK_KEY_P
and SCM_WVECT_WEAK_VALUE_P.
* weaks.c, weaks.h (scm_i_allocate_weak_vector): Renamed from
allocate_weak_vector and exported.
* Makefile.am (ice9_sources): Added weak-vector.scm.
* weak-vector.scm: New file.
* boot-9.scm (module-clear!): Use hash-clear!.
(module-for-each): Use hash-for-each.
(module-map): Use hash-map.
2003-02-19 15:04:51 +00:00
|
|
|
|
"\n"
|
|
|
|
|
|
"You can modify weak hash tables in exactly the same way you\n"
|
|
|
|
|
|
"would modify regular hash tables. (@pxref{Hash Tables})")
|
|
|
|
|
|
#define FUNC_NAME s_scm_make_weak_key_hash_table
|
2003-02-11 13:49:32 +00:00
|
|
|
|
{
|
* hooks.c (scm_c_hook_add): Fixed bug in append mode.
* environments.c (obarray_enter, obarray_retrieve, obarray_remove,
leaf_environment_fold, obarray_remove_all): Use hashtable
accessors.
* gc.c (scm_init_storage): Moved hook initialization to
scm_storage_prehistory.
(scm_storage_prehistory): New function.
(scm_igc): Added commentary about placement of
scm_after_sweep_c_hook.
* gc-mark.c (scm_mark_all): Use hashtable accessors.
(scm_gc_mark_dependencies): Use SCM_WVECT_WEAK_KEY_P and
SCM_WVECT_WEAK_VALUE_P.
* hashtab.c, hashtab.h (scm_hash_for_each, scm_hash_map): New
functions.
(scm_vector_to_hash_table, scm_c_make_resizing_hash_table):
Removed.
(scm_make_weak_key_hash_table, scm_make_weak_value_hash_table,
scm_make_doubly_weak_hash_table): Moved here from weaks.c.
* init.c (scm_init_guile_1): Removed call to scm_init_weaks; Added
calls to scm_storage_prehistory and scm_hashtab_prehistory.
* modules.c (module-reverse-lookup): Use hashtable accessors.
* symbols.c, symbols.h (scm_i_hash_symbol): New function.
* weaks.c, weaks.h (scm_make_weak_key_alist_vector,
scm_make_weak_value_alist_vector,
scm_make_doubly_weak_alist_vector): New functions.
* weaks.c (scm_init_weaks_builtins): New function.
* weaks.h (SCM_WVECTF_WEAK_KEY, SCM_WVECTF_WEAK_VALUE,
SCM_WVECTF_NOSCAN, SCM_WVECT_WEAK_KEY_P, SCM_WVECT_WEAK_VALUE_P,
SCM_WVECT_NOSCAN_P): New macros.
* weaks.c (scm_scan_weak_vectors): Use SCM_WVECT_WEAK_KEY_P
and SCM_WVECT_WEAK_VALUE_P.
* weaks.c, weaks.h (scm_i_allocate_weak_vector): Renamed from
allocate_weak_vector and exported.
* Makefile.am (ice9_sources): Added weak-vector.scm.
* weak-vector.scm: New file.
* boot-9.scm (module-clear!): Use hash-clear!.
(module-for-each): Use hash-for-each.
(module-map): Use hash-map.
2003-02-19 15:04:51 +00:00
|
|
|
|
if (SCM_UNBNDP (n))
|
|
|
|
|
|
return make_hash_table (SCM_HASHTABLEF_WEAK_CAR, 0, FUNC_NAME);
|
2003-02-11 13:49:32 +00:00
|
|
|
|
else
|
* validate.h, deprecated.h (SCM_VALIDATE_INUM, SCM_VALIDATE_INUM_COPY,
SCM_VALIDATE_BIGINT, SCM_VALIDATE_INUM_MIN,
SCM_VALIDATE_INUM_MIN_COPY,
SCM_VALIDATE_INUM_MIN_DEF_COPY,SCM_VALIDATE_INUM_DEF,
SCM_VALIDATE_INUM_DEF_COPY, SCM_VALIDATE_INUM_RANGE,
SCM_VALIDATE_INUM_RANGE_COPY): Deprecated because they make the
fixnum/bignum distinction visible. Changed all uses to scm_to_size_t
or similar.
2004-07-10 14:35:36 +00:00
|
|
|
|
return make_hash_table (SCM_HASHTABLEF_WEAK_CAR,
|
|
|
|
|
|
scm_to_ulong (n), FUNC_NAME);
|
* hooks.c (scm_c_hook_add): Fixed bug in append mode.
* environments.c (obarray_enter, obarray_retrieve, obarray_remove,
leaf_environment_fold, obarray_remove_all): Use hashtable
accessors.
* gc.c (scm_init_storage): Moved hook initialization to
scm_storage_prehistory.
(scm_storage_prehistory): New function.
(scm_igc): Added commentary about placement of
scm_after_sweep_c_hook.
* gc-mark.c (scm_mark_all): Use hashtable accessors.
(scm_gc_mark_dependencies): Use SCM_WVECT_WEAK_KEY_P and
SCM_WVECT_WEAK_VALUE_P.
* hashtab.c, hashtab.h (scm_hash_for_each, scm_hash_map): New
functions.
(scm_vector_to_hash_table, scm_c_make_resizing_hash_table):
Removed.
(scm_make_weak_key_hash_table, scm_make_weak_value_hash_table,
scm_make_doubly_weak_hash_table): Moved here from weaks.c.
* init.c (scm_init_guile_1): Removed call to scm_init_weaks; Added
calls to scm_storage_prehistory and scm_hashtab_prehistory.
* modules.c (module-reverse-lookup): Use hashtable accessors.
* symbols.c, symbols.h (scm_i_hash_symbol): New function.
* weaks.c, weaks.h (scm_make_weak_key_alist_vector,
scm_make_weak_value_alist_vector,
scm_make_doubly_weak_alist_vector): New functions.
* weaks.c (scm_init_weaks_builtins): New function.
* weaks.h (SCM_WVECTF_WEAK_KEY, SCM_WVECTF_WEAK_VALUE,
SCM_WVECTF_NOSCAN, SCM_WVECT_WEAK_KEY_P, SCM_WVECT_WEAK_VALUE_P,
SCM_WVECT_NOSCAN_P): New macros.
* weaks.c (scm_scan_weak_vectors): Use SCM_WVECT_WEAK_KEY_P
and SCM_WVECT_WEAK_VALUE_P.
* weaks.c, weaks.h (scm_i_allocate_weak_vector): Renamed from
allocate_weak_vector and exported.
* Makefile.am (ice9_sources): Added weak-vector.scm.
* weak-vector.scm: New file.
* boot-9.scm (module-clear!): Use hash-clear!.
(module-for-each): Use hash-for-each.
(module-map): Use hash-map.
2003-02-19 15:04:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
#undef FUNC_NAME
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SCM_DEFINE (scm_make_weak_value_hash_table, "make-weak-value-hash-table", 0, 1, 0,
|
|
|
|
|
|
(SCM n),
|
|
|
|
|
|
"Return a hash table with weak values with @var{size} buckets.\n"
|
|
|
|
|
|
"(@pxref{Hash Tables})")
|
|
|
|
|
|
#define FUNC_NAME s_scm_make_weak_value_hash_table
|
|
|
|
|
|
{
|
|
|
|
|
|
if (SCM_UNBNDP (n))
|
|
|
|
|
|
return make_hash_table (SCM_HASHTABLEF_WEAK_CDR, 0, FUNC_NAME);
|
2003-02-11 13:49:32 +00:00
|
|
|
|
else
|
* hooks.c (scm_c_hook_add): Fixed bug in append mode.
* environments.c (obarray_enter, obarray_retrieve, obarray_remove,
leaf_environment_fold, obarray_remove_all): Use hashtable
accessors.
* gc.c (scm_init_storage): Moved hook initialization to
scm_storage_prehistory.
(scm_storage_prehistory): New function.
(scm_igc): Added commentary about placement of
scm_after_sweep_c_hook.
* gc-mark.c (scm_mark_all): Use hashtable accessors.
(scm_gc_mark_dependencies): Use SCM_WVECT_WEAK_KEY_P and
SCM_WVECT_WEAK_VALUE_P.
* hashtab.c, hashtab.h (scm_hash_for_each, scm_hash_map): New
functions.
(scm_vector_to_hash_table, scm_c_make_resizing_hash_table):
Removed.
(scm_make_weak_key_hash_table, scm_make_weak_value_hash_table,
scm_make_doubly_weak_hash_table): Moved here from weaks.c.
* init.c (scm_init_guile_1): Removed call to scm_init_weaks; Added
calls to scm_storage_prehistory and scm_hashtab_prehistory.
* modules.c (module-reverse-lookup): Use hashtable accessors.
* symbols.c, symbols.h (scm_i_hash_symbol): New function.
* weaks.c, weaks.h (scm_make_weak_key_alist_vector,
scm_make_weak_value_alist_vector,
scm_make_doubly_weak_alist_vector): New functions.
* weaks.c (scm_init_weaks_builtins): New function.
* weaks.h (SCM_WVECTF_WEAK_KEY, SCM_WVECTF_WEAK_VALUE,
SCM_WVECTF_NOSCAN, SCM_WVECT_WEAK_KEY_P, SCM_WVECT_WEAK_VALUE_P,
SCM_WVECT_NOSCAN_P): New macros.
* weaks.c (scm_scan_weak_vectors): Use SCM_WVECT_WEAK_KEY_P
and SCM_WVECT_WEAK_VALUE_P.
* weaks.c, weaks.h (scm_i_allocate_weak_vector): Renamed from
allocate_weak_vector and exported.
* Makefile.am (ice9_sources): Added weak-vector.scm.
* weak-vector.scm: New file.
* boot-9.scm (module-clear!): Use hash-clear!.
(module-for-each): Use hash-for-each.
(module-map): Use hash-map.
2003-02-19 15:04:51 +00:00
|
|
|
|
{
|
* validate.h, deprecated.h (SCM_VALIDATE_INUM, SCM_VALIDATE_INUM_COPY,
SCM_VALIDATE_BIGINT, SCM_VALIDATE_INUM_MIN,
SCM_VALIDATE_INUM_MIN_COPY,
SCM_VALIDATE_INUM_MIN_DEF_COPY,SCM_VALIDATE_INUM_DEF,
SCM_VALIDATE_INUM_DEF_COPY, SCM_VALIDATE_INUM_RANGE,
SCM_VALIDATE_INUM_RANGE_COPY): Deprecated because they make the
fixnum/bignum distinction visible. Changed all uses to scm_to_size_t
or similar.
2004-07-10 14:35:36 +00:00
|
|
|
|
return make_hash_table (SCM_HASHTABLEF_WEAK_CDR,
|
|
|
|
|
|
scm_to_ulong (n), FUNC_NAME);
|
2003-02-11 13:49:32 +00:00
|
|
|
|
}
|
* hooks.c (scm_c_hook_add): Fixed bug in append mode.
* environments.c (obarray_enter, obarray_retrieve, obarray_remove,
leaf_environment_fold, obarray_remove_all): Use hashtable
accessors.
* gc.c (scm_init_storage): Moved hook initialization to
scm_storage_prehistory.
(scm_storage_prehistory): New function.
(scm_igc): Added commentary about placement of
scm_after_sweep_c_hook.
* gc-mark.c (scm_mark_all): Use hashtable accessors.
(scm_gc_mark_dependencies): Use SCM_WVECT_WEAK_KEY_P and
SCM_WVECT_WEAK_VALUE_P.
* hashtab.c, hashtab.h (scm_hash_for_each, scm_hash_map): New
functions.
(scm_vector_to_hash_table, scm_c_make_resizing_hash_table):
Removed.
(scm_make_weak_key_hash_table, scm_make_weak_value_hash_table,
scm_make_doubly_weak_hash_table): Moved here from weaks.c.
* init.c (scm_init_guile_1): Removed call to scm_init_weaks; Added
calls to scm_storage_prehistory and scm_hashtab_prehistory.
* modules.c (module-reverse-lookup): Use hashtable accessors.
* symbols.c, symbols.h (scm_i_hash_symbol): New function.
* weaks.c, weaks.h (scm_make_weak_key_alist_vector,
scm_make_weak_value_alist_vector,
scm_make_doubly_weak_alist_vector): New functions.
* weaks.c (scm_init_weaks_builtins): New function.
* weaks.h (SCM_WVECTF_WEAK_KEY, SCM_WVECTF_WEAK_VALUE,
SCM_WVECTF_NOSCAN, SCM_WVECT_WEAK_KEY_P, SCM_WVECT_WEAK_VALUE_P,
SCM_WVECT_NOSCAN_P): New macros.
* weaks.c (scm_scan_weak_vectors): Use SCM_WVECT_WEAK_KEY_P
and SCM_WVECT_WEAK_VALUE_P.
* weaks.c, weaks.h (scm_i_allocate_weak_vector): Renamed from
allocate_weak_vector and exported.
* Makefile.am (ice9_sources): Added weak-vector.scm.
* weak-vector.scm: New file.
* boot-9.scm (module-clear!): Use hash-clear!.
(module-for-each): Use hash-for-each.
(module-map): Use hash-map.
2003-02-19 15:04:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
#undef FUNC_NAME
|
2003-02-11 13:49:32 +00:00
|
|
|
|
|
* hooks.c (scm_c_hook_add): Fixed bug in append mode.
* environments.c (obarray_enter, obarray_retrieve, obarray_remove,
leaf_environment_fold, obarray_remove_all): Use hashtable
accessors.
* gc.c (scm_init_storage): Moved hook initialization to
scm_storage_prehistory.
(scm_storage_prehistory): New function.
(scm_igc): Added commentary about placement of
scm_after_sweep_c_hook.
* gc-mark.c (scm_mark_all): Use hashtable accessors.
(scm_gc_mark_dependencies): Use SCM_WVECT_WEAK_KEY_P and
SCM_WVECT_WEAK_VALUE_P.
* hashtab.c, hashtab.h (scm_hash_for_each, scm_hash_map): New
functions.
(scm_vector_to_hash_table, scm_c_make_resizing_hash_table):
Removed.
(scm_make_weak_key_hash_table, scm_make_weak_value_hash_table,
scm_make_doubly_weak_hash_table): Moved here from weaks.c.
* init.c (scm_init_guile_1): Removed call to scm_init_weaks; Added
calls to scm_storage_prehistory and scm_hashtab_prehistory.
* modules.c (module-reverse-lookup): Use hashtable accessors.
* symbols.c, symbols.h (scm_i_hash_symbol): New function.
* weaks.c, weaks.h (scm_make_weak_key_alist_vector,
scm_make_weak_value_alist_vector,
scm_make_doubly_weak_alist_vector): New functions.
* weaks.c (scm_init_weaks_builtins): New function.
* weaks.h (SCM_WVECTF_WEAK_KEY, SCM_WVECTF_WEAK_VALUE,
SCM_WVECTF_NOSCAN, SCM_WVECT_WEAK_KEY_P, SCM_WVECT_WEAK_VALUE_P,
SCM_WVECT_NOSCAN_P): New macros.
* weaks.c (scm_scan_weak_vectors): Use SCM_WVECT_WEAK_KEY_P
and SCM_WVECT_WEAK_VALUE_P.
* weaks.c, weaks.h (scm_i_allocate_weak_vector): Renamed from
allocate_weak_vector and exported.
* Makefile.am (ice9_sources): Added weak-vector.scm.
* weak-vector.scm: New file.
* boot-9.scm (module-clear!): Use hash-clear!.
(module-for-each): Use hash-for-each.
(module-map): Use hash-map.
2003-02-19 15:04:51 +00:00
|
|
|
|
|
|
|
|
|
|
SCM_DEFINE (scm_make_doubly_weak_hash_table, "make-doubly-weak-hash-table", 1, 0, 0,
|
|
|
|
|
|
(SCM n),
|
|
|
|
|
|
"Return a hash table with weak keys and values with @var{size}\n"
|
|
|
|
|
|
"buckets. (@pxref{Hash Tables})")
|
|
|
|
|
|
#define FUNC_NAME s_scm_make_doubly_weak_hash_table
|
|
|
|
|
|
{
|
|
|
|
|
|
if (SCM_UNBNDP (n))
|
|
|
|
|
|
return make_hash_table (SCM_HASHTABLEF_WEAK_CAR | SCM_HASHTABLEF_WEAK_CDR,
|
|
|
|
|
|
0,
|
|
|
|
|
|
FUNC_NAME);
|
|
|
|
|
|
else
|
2003-02-11 13:49:32 +00:00
|
|
|
|
{
|
* hooks.c (scm_c_hook_add): Fixed bug in append mode.
* environments.c (obarray_enter, obarray_retrieve, obarray_remove,
leaf_environment_fold, obarray_remove_all): Use hashtable
accessors.
* gc.c (scm_init_storage): Moved hook initialization to
scm_storage_prehistory.
(scm_storage_prehistory): New function.
(scm_igc): Added commentary about placement of
scm_after_sweep_c_hook.
* gc-mark.c (scm_mark_all): Use hashtable accessors.
(scm_gc_mark_dependencies): Use SCM_WVECT_WEAK_KEY_P and
SCM_WVECT_WEAK_VALUE_P.
* hashtab.c, hashtab.h (scm_hash_for_each, scm_hash_map): New
functions.
(scm_vector_to_hash_table, scm_c_make_resizing_hash_table):
Removed.
(scm_make_weak_key_hash_table, scm_make_weak_value_hash_table,
scm_make_doubly_weak_hash_table): Moved here from weaks.c.
* init.c (scm_init_guile_1): Removed call to scm_init_weaks; Added
calls to scm_storage_prehistory and scm_hashtab_prehistory.
* modules.c (module-reverse-lookup): Use hashtable accessors.
* symbols.c, symbols.h (scm_i_hash_symbol): New function.
* weaks.c, weaks.h (scm_make_weak_key_alist_vector,
scm_make_weak_value_alist_vector,
scm_make_doubly_weak_alist_vector): New functions.
* weaks.c (scm_init_weaks_builtins): New function.
* weaks.h (SCM_WVECTF_WEAK_KEY, SCM_WVECTF_WEAK_VALUE,
SCM_WVECTF_NOSCAN, SCM_WVECT_WEAK_KEY_P, SCM_WVECT_WEAK_VALUE_P,
SCM_WVECT_NOSCAN_P): New macros.
* weaks.c (scm_scan_weak_vectors): Use SCM_WVECT_WEAK_KEY_P
and SCM_WVECT_WEAK_VALUE_P.
* weaks.c, weaks.h (scm_i_allocate_weak_vector): Renamed from
allocate_weak_vector and exported.
* Makefile.am (ice9_sources): Added weak-vector.scm.
* weak-vector.scm: New file.
* boot-9.scm (module-clear!): Use hash-clear!.
(module-for-each): Use hash-for-each.
(module-map): Use hash-map.
2003-02-19 15:04:51 +00:00
|
|
|
|
return make_hash_table (SCM_HASHTABLEF_WEAK_CAR | SCM_HASHTABLEF_WEAK_CDR,
|
* validate.h, deprecated.h (SCM_VALIDATE_INUM, SCM_VALIDATE_INUM_COPY,
SCM_VALIDATE_BIGINT, SCM_VALIDATE_INUM_MIN,
SCM_VALIDATE_INUM_MIN_COPY,
SCM_VALIDATE_INUM_MIN_DEF_COPY,SCM_VALIDATE_INUM_DEF,
SCM_VALIDATE_INUM_DEF_COPY, SCM_VALIDATE_INUM_RANGE,
SCM_VALIDATE_INUM_RANGE_COPY): Deprecated because they make the
fixnum/bignum distinction visible. Changed all uses to scm_to_size_t
or similar.
2004-07-10 14:35:36 +00:00
|
|
|
|
scm_to_ulong (n),
|
* hooks.c (scm_c_hook_add): Fixed bug in append mode.
* environments.c (obarray_enter, obarray_retrieve, obarray_remove,
leaf_environment_fold, obarray_remove_all): Use hashtable
accessors.
* gc.c (scm_init_storage): Moved hook initialization to
scm_storage_prehistory.
(scm_storage_prehistory): New function.
(scm_igc): Added commentary about placement of
scm_after_sweep_c_hook.
* gc-mark.c (scm_mark_all): Use hashtable accessors.
(scm_gc_mark_dependencies): Use SCM_WVECT_WEAK_KEY_P and
SCM_WVECT_WEAK_VALUE_P.
* hashtab.c, hashtab.h (scm_hash_for_each, scm_hash_map): New
functions.
(scm_vector_to_hash_table, scm_c_make_resizing_hash_table):
Removed.
(scm_make_weak_key_hash_table, scm_make_weak_value_hash_table,
scm_make_doubly_weak_hash_table): Moved here from weaks.c.
* init.c (scm_init_guile_1): Removed call to scm_init_weaks; Added
calls to scm_storage_prehistory and scm_hashtab_prehistory.
* modules.c (module-reverse-lookup): Use hashtable accessors.
* symbols.c, symbols.h (scm_i_hash_symbol): New function.
* weaks.c, weaks.h (scm_make_weak_key_alist_vector,
scm_make_weak_value_alist_vector,
scm_make_doubly_weak_alist_vector): New functions.
* weaks.c (scm_init_weaks_builtins): New function.
* weaks.h (SCM_WVECTF_WEAK_KEY, SCM_WVECTF_WEAK_VALUE,
SCM_WVECTF_NOSCAN, SCM_WVECT_WEAK_KEY_P, SCM_WVECT_WEAK_VALUE_P,
SCM_WVECT_NOSCAN_P): New macros.
* weaks.c (scm_scan_weak_vectors): Use SCM_WVECT_WEAK_KEY_P
and SCM_WVECT_WEAK_VALUE_P.
* weaks.c, weaks.h (scm_i_allocate_weak_vector): Renamed from
allocate_weak_vector and exported.
* Makefile.am (ice9_sources): Added weak-vector.scm.
* weak-vector.scm: New file.
* boot-9.scm (module-clear!): Use hash-clear!.
(module-for-each): Use hash-for-each.
(module-map): Use hash-map.
2003-02-19 15:04:51 +00:00
|
|
|
|
FUNC_NAME);
|
2003-02-11 13:49:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
* hooks.c (scm_c_hook_add): Fixed bug in append mode.
* environments.c (obarray_enter, obarray_retrieve, obarray_remove,
leaf_environment_fold, obarray_remove_all): Use hashtable
accessors.
* gc.c (scm_init_storage): Moved hook initialization to
scm_storage_prehistory.
(scm_storage_prehistory): New function.
(scm_igc): Added commentary about placement of
scm_after_sweep_c_hook.
* gc-mark.c (scm_mark_all): Use hashtable accessors.
(scm_gc_mark_dependencies): Use SCM_WVECT_WEAK_KEY_P and
SCM_WVECT_WEAK_VALUE_P.
* hashtab.c, hashtab.h (scm_hash_for_each, scm_hash_map): New
functions.
(scm_vector_to_hash_table, scm_c_make_resizing_hash_table):
Removed.
(scm_make_weak_key_hash_table, scm_make_weak_value_hash_table,
scm_make_doubly_weak_hash_table): Moved here from weaks.c.
* init.c (scm_init_guile_1): Removed call to scm_init_weaks; Added
calls to scm_storage_prehistory and scm_hashtab_prehistory.
* modules.c (module-reverse-lookup): Use hashtable accessors.
* symbols.c, symbols.h (scm_i_hash_symbol): New function.
* weaks.c, weaks.h (scm_make_weak_key_alist_vector,
scm_make_weak_value_alist_vector,
scm_make_doubly_weak_alist_vector): New functions.
* weaks.c (scm_init_weaks_builtins): New function.
* weaks.h (SCM_WVECTF_WEAK_KEY, SCM_WVECTF_WEAK_VALUE,
SCM_WVECTF_NOSCAN, SCM_WVECT_WEAK_KEY_P, SCM_WVECT_WEAK_VALUE_P,
SCM_WVECT_NOSCAN_P): New macros.
* weaks.c (scm_scan_weak_vectors): Use SCM_WVECT_WEAK_KEY_P
and SCM_WVECT_WEAK_VALUE_P.
* weaks.c, weaks.h (scm_i_allocate_weak_vector): Renamed from
allocate_weak_vector and exported.
* Makefile.am (ice9_sources): Added weak-vector.scm.
* weak-vector.scm: New file.
* boot-9.scm (module-clear!): Use hash-clear!.
(module-for-each): Use hash-for-each.
(module-map): Use hash-map.
2003-02-19 15:04:51 +00:00
|
|
|
|
#undef FUNC_NAME
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SCM_DEFINE (scm_hash_table_p, "hash-table?", 1, 0, 0,
|
|
|
|
|
|
(SCM obj),
|
2005-03-29 17:47:39 +00:00
|
|
|
|
"Return @code{#t} if @var{obj} is an abstract hash table object.")
|
* hooks.c (scm_c_hook_add): Fixed bug in append mode.
* environments.c (obarray_enter, obarray_retrieve, obarray_remove,
leaf_environment_fold, obarray_remove_all): Use hashtable
accessors.
* gc.c (scm_init_storage): Moved hook initialization to
scm_storage_prehistory.
(scm_storage_prehistory): New function.
(scm_igc): Added commentary about placement of
scm_after_sweep_c_hook.
* gc-mark.c (scm_mark_all): Use hashtable accessors.
(scm_gc_mark_dependencies): Use SCM_WVECT_WEAK_KEY_P and
SCM_WVECT_WEAK_VALUE_P.
* hashtab.c, hashtab.h (scm_hash_for_each, scm_hash_map): New
functions.
(scm_vector_to_hash_table, scm_c_make_resizing_hash_table):
Removed.
(scm_make_weak_key_hash_table, scm_make_weak_value_hash_table,
scm_make_doubly_weak_hash_table): Moved here from weaks.c.
* init.c (scm_init_guile_1): Removed call to scm_init_weaks; Added
calls to scm_storage_prehistory and scm_hashtab_prehistory.
* modules.c (module-reverse-lookup): Use hashtable accessors.
* symbols.c, symbols.h (scm_i_hash_symbol): New function.
* weaks.c, weaks.h (scm_make_weak_key_alist_vector,
scm_make_weak_value_alist_vector,
scm_make_doubly_weak_alist_vector): New functions.
* weaks.c (scm_init_weaks_builtins): New function.
* weaks.h (SCM_WVECTF_WEAK_KEY, SCM_WVECTF_WEAK_VALUE,
SCM_WVECTF_NOSCAN, SCM_WVECT_WEAK_KEY_P, SCM_WVECT_WEAK_VALUE_P,
SCM_WVECT_NOSCAN_P): New macros.
* weaks.c (scm_scan_weak_vectors): Use SCM_WVECT_WEAK_KEY_P
and SCM_WVECT_WEAK_VALUE_P.
* weaks.c, weaks.h (scm_i_allocate_weak_vector): Renamed from
allocate_weak_vector and exported.
* Makefile.am (ice9_sources): Added weak-vector.scm.
* weak-vector.scm: New file.
* boot-9.scm (module-clear!): Use hash-clear!.
(module-for-each): Use hash-for-each.
(module-map): Use hash-map.
2003-02-19 15:04:51 +00:00
|
|
|
|
#define FUNC_NAME s_scm_hash_table_p
|
|
|
|
|
|
{
|
2004-07-06 10:59:25 +00:00
|
|
|
|
return scm_from_bool (SCM_HASHTABLE_P (obj));
|
* hooks.c (scm_c_hook_add): Fixed bug in append mode.
* environments.c (obarray_enter, obarray_retrieve, obarray_remove,
leaf_environment_fold, obarray_remove_all): Use hashtable
accessors.
* gc.c (scm_init_storage): Moved hook initialization to
scm_storage_prehistory.
(scm_storage_prehistory): New function.
(scm_igc): Added commentary about placement of
scm_after_sweep_c_hook.
* gc-mark.c (scm_mark_all): Use hashtable accessors.
(scm_gc_mark_dependencies): Use SCM_WVECT_WEAK_KEY_P and
SCM_WVECT_WEAK_VALUE_P.
* hashtab.c, hashtab.h (scm_hash_for_each, scm_hash_map): New
functions.
(scm_vector_to_hash_table, scm_c_make_resizing_hash_table):
Removed.
(scm_make_weak_key_hash_table, scm_make_weak_value_hash_table,
scm_make_doubly_weak_hash_table): Moved here from weaks.c.
* init.c (scm_init_guile_1): Removed call to scm_init_weaks; Added
calls to scm_storage_prehistory and scm_hashtab_prehistory.
* modules.c (module-reverse-lookup): Use hashtable accessors.
* symbols.c, symbols.h (scm_i_hash_symbol): New function.
* weaks.c, weaks.h (scm_make_weak_key_alist_vector,
scm_make_weak_value_alist_vector,
scm_make_doubly_weak_alist_vector): New functions.
* weaks.c (scm_init_weaks_builtins): New function.
* weaks.h (SCM_WVECTF_WEAK_KEY, SCM_WVECTF_WEAK_VALUE,
SCM_WVECTF_NOSCAN, SCM_WVECT_WEAK_KEY_P, SCM_WVECT_WEAK_VALUE_P,
SCM_WVECT_NOSCAN_P): New macros.
* weaks.c (scm_scan_weak_vectors): Use SCM_WVECT_WEAK_KEY_P
and SCM_WVECT_WEAK_VALUE_P.
* weaks.c, weaks.h (scm_i_allocate_weak_vector): Renamed from
allocate_weak_vector and exported.
* Makefile.am (ice9_sources): Added weak-vector.scm.
* weak-vector.scm: New file.
* boot-9.scm (module-clear!): Use hash-clear!.
(module-for-each): Use hash-for-each.
(module-map): Use hash-map.
2003-02-19 15:04:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
#undef FUNC_NAME
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SCM_DEFINE (scm_weak_key_hash_table_p, "weak-key-hash-table?", 1, 0, 0,
|
|
|
|
|
|
(SCM obj),
|
|
|
|
|
|
"@deffnx {Scheme Procedure} weak-value-hash-table? obj\n"
|
|
|
|
|
|
"@deffnx {Scheme Procedure} doubly-weak-hash-table? obj\n"
|
|
|
|
|
|
"Return @code{#t} if @var{obj} is the specified weak hash\n"
|
|
|
|
|
|
"table. Note that a doubly weak hash table is neither a weak key\n"
|
|
|
|
|
|
"nor a weak value hash table.")
|
|
|
|
|
|
#define FUNC_NAME s_scm_weak_key_hash_table_p
|
|
|
|
|
|
{
|
2004-07-06 10:59:25 +00:00
|
|
|
|
return scm_from_bool (SCM_HASHTABLE_P (obj) && SCM_HASHTABLE_WEAK_KEY_P (obj));
|
* hooks.c (scm_c_hook_add): Fixed bug in append mode.
* environments.c (obarray_enter, obarray_retrieve, obarray_remove,
leaf_environment_fold, obarray_remove_all): Use hashtable
accessors.
* gc.c (scm_init_storage): Moved hook initialization to
scm_storage_prehistory.
(scm_storage_prehistory): New function.
(scm_igc): Added commentary about placement of
scm_after_sweep_c_hook.
* gc-mark.c (scm_mark_all): Use hashtable accessors.
(scm_gc_mark_dependencies): Use SCM_WVECT_WEAK_KEY_P and
SCM_WVECT_WEAK_VALUE_P.
* hashtab.c, hashtab.h (scm_hash_for_each, scm_hash_map): New
functions.
(scm_vector_to_hash_table, scm_c_make_resizing_hash_table):
Removed.
(scm_make_weak_key_hash_table, scm_make_weak_value_hash_table,
scm_make_doubly_weak_hash_table): Moved here from weaks.c.
* init.c (scm_init_guile_1): Removed call to scm_init_weaks; Added
calls to scm_storage_prehistory and scm_hashtab_prehistory.
* modules.c (module-reverse-lookup): Use hashtable accessors.
* symbols.c, symbols.h (scm_i_hash_symbol): New function.
* weaks.c, weaks.h (scm_make_weak_key_alist_vector,
scm_make_weak_value_alist_vector,
scm_make_doubly_weak_alist_vector): New functions.
* weaks.c (scm_init_weaks_builtins): New function.
* weaks.h (SCM_WVECTF_WEAK_KEY, SCM_WVECTF_WEAK_VALUE,
SCM_WVECTF_NOSCAN, SCM_WVECT_WEAK_KEY_P, SCM_WVECT_WEAK_VALUE_P,
SCM_WVECT_NOSCAN_P): New macros.
* weaks.c (scm_scan_weak_vectors): Use SCM_WVECT_WEAK_KEY_P
and SCM_WVECT_WEAK_VALUE_P.
* weaks.c, weaks.h (scm_i_allocate_weak_vector): Renamed from
allocate_weak_vector and exported.
* Makefile.am (ice9_sources): Added weak-vector.scm.
* weak-vector.scm: New file.
* boot-9.scm (module-clear!): Use hash-clear!.
(module-for-each): Use hash-for-each.
(module-map): Use hash-map.
2003-02-19 15:04:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
#undef FUNC_NAME
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SCM_DEFINE (scm_weak_value_hash_table_p, "weak-value-hash-table?", 1, 0, 0,
|
|
|
|
|
|
(SCM obj),
|
|
|
|
|
|
"Return @code{#t} if @var{obj} is a weak value hash table.")
|
|
|
|
|
|
#define FUNC_NAME s_scm_weak_value_hash_table_p
|
|
|
|
|
|
{
|
2004-07-06 10:59:25 +00:00
|
|
|
|
return scm_from_bool (SCM_HASHTABLE_P (obj) && SCM_HASHTABLE_WEAK_VALUE_P (obj));
|
* hooks.c (scm_c_hook_add): Fixed bug in append mode.
* environments.c (obarray_enter, obarray_retrieve, obarray_remove,
leaf_environment_fold, obarray_remove_all): Use hashtable
accessors.
* gc.c (scm_init_storage): Moved hook initialization to
scm_storage_prehistory.
(scm_storage_prehistory): New function.
(scm_igc): Added commentary about placement of
scm_after_sweep_c_hook.
* gc-mark.c (scm_mark_all): Use hashtable accessors.
(scm_gc_mark_dependencies): Use SCM_WVECT_WEAK_KEY_P and
SCM_WVECT_WEAK_VALUE_P.
* hashtab.c, hashtab.h (scm_hash_for_each, scm_hash_map): New
functions.
(scm_vector_to_hash_table, scm_c_make_resizing_hash_table):
Removed.
(scm_make_weak_key_hash_table, scm_make_weak_value_hash_table,
scm_make_doubly_weak_hash_table): Moved here from weaks.c.
* init.c (scm_init_guile_1): Removed call to scm_init_weaks; Added
calls to scm_storage_prehistory and scm_hashtab_prehistory.
* modules.c (module-reverse-lookup): Use hashtable accessors.
* symbols.c, symbols.h (scm_i_hash_symbol): New function.
* weaks.c, weaks.h (scm_make_weak_key_alist_vector,
scm_make_weak_value_alist_vector,
scm_make_doubly_weak_alist_vector): New functions.
* weaks.c (scm_init_weaks_builtins): New function.
* weaks.h (SCM_WVECTF_WEAK_KEY, SCM_WVECTF_WEAK_VALUE,
SCM_WVECTF_NOSCAN, SCM_WVECT_WEAK_KEY_P, SCM_WVECT_WEAK_VALUE_P,
SCM_WVECT_NOSCAN_P): New macros.
* weaks.c (scm_scan_weak_vectors): Use SCM_WVECT_WEAK_KEY_P
and SCM_WVECT_WEAK_VALUE_P.
* weaks.c, weaks.h (scm_i_allocate_weak_vector): Renamed from
allocate_weak_vector and exported.
* Makefile.am (ice9_sources): Added weak-vector.scm.
* weak-vector.scm: New file.
* boot-9.scm (module-clear!): Use hash-clear!.
(module-for-each): Use hash-for-each.
(module-map): Use hash-map.
2003-02-19 15:04:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
#undef FUNC_NAME
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SCM_DEFINE (scm_doubly_weak_hash_table_p, "doubly-weak-hash-table?", 1, 0, 0,
|
|
|
|
|
|
(SCM obj),
|
|
|
|
|
|
"Return @code{#t} if @var{obj} is a doubly weak hash table.")
|
|
|
|
|
|
#define FUNC_NAME s_scm_doubly_weak_hash_table_p
|
|
|
|
|
|
{
|
2004-07-06 10:59:25 +00:00
|
|
|
|
return scm_from_bool (SCM_HASHTABLE_P (obj) && SCM_HASHTABLE_DOUBLY_WEAK_P (obj));
|
* hooks.c (scm_c_hook_add): Fixed bug in append mode.
* environments.c (obarray_enter, obarray_retrieve, obarray_remove,
leaf_environment_fold, obarray_remove_all): Use hashtable
accessors.
* gc.c (scm_init_storage): Moved hook initialization to
scm_storage_prehistory.
(scm_storage_prehistory): New function.
(scm_igc): Added commentary about placement of
scm_after_sweep_c_hook.
* gc-mark.c (scm_mark_all): Use hashtable accessors.
(scm_gc_mark_dependencies): Use SCM_WVECT_WEAK_KEY_P and
SCM_WVECT_WEAK_VALUE_P.
* hashtab.c, hashtab.h (scm_hash_for_each, scm_hash_map): New
functions.
(scm_vector_to_hash_table, scm_c_make_resizing_hash_table):
Removed.
(scm_make_weak_key_hash_table, scm_make_weak_value_hash_table,
scm_make_doubly_weak_hash_table): Moved here from weaks.c.
* init.c (scm_init_guile_1): Removed call to scm_init_weaks; Added
calls to scm_storage_prehistory and scm_hashtab_prehistory.
* modules.c (module-reverse-lookup): Use hashtable accessors.
* symbols.c, symbols.h (scm_i_hash_symbol): New function.
* weaks.c, weaks.h (scm_make_weak_key_alist_vector,
scm_make_weak_value_alist_vector,
scm_make_doubly_weak_alist_vector): New functions.
* weaks.c (scm_init_weaks_builtins): New function.
* weaks.h (SCM_WVECTF_WEAK_KEY, SCM_WVECTF_WEAK_VALUE,
SCM_WVECTF_NOSCAN, SCM_WVECT_WEAK_KEY_P, SCM_WVECT_WEAK_VALUE_P,
SCM_WVECT_NOSCAN_P): New macros.
* weaks.c (scm_scan_weak_vectors): Use SCM_WVECT_WEAK_KEY_P
and SCM_WVECT_WEAK_VALUE_P.
* weaks.c, weaks.h (scm_i_allocate_weak_vector): Renamed from
allocate_weak_vector and exported.
* Makefile.am (ice9_sources): Added weak-vector.scm.
* weak-vector.scm: New file.
* boot-9.scm (module-clear!): Use hash-clear!.
(module-for-each): Use hash-for-each.
(module-map): Use hash-map.
2003-02-19 15:04:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
#undef FUNC_NAME
|
|
|
|
|
|
|
2001-03-30 15:03:23 +00:00
|
|
|
|
|
1996-07-25 22:56:11 +00:00
|
|
|
|
SCM
|
2002-07-20 14:08:34 +00:00
|
|
|
|
scm_hash_fn_get_handle (SCM table, SCM obj, unsigned long (*hash_fn)(), SCM (*assoc_fn)(), void * closure)
|
2001-03-30 15:03:23 +00:00
|
|
|
|
#define FUNC_NAME "scm_hash_fn_get_handle"
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2006-04-09 16:13:01 +00:00
|
|
|
|
int weak = 0;
|
2001-05-26 20:51:22 +00:00
|
|
|
|
unsigned long k;
|
2006-04-04 21:28:13 +00:00
|
|
|
|
SCM alist, h;
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
2003-02-11 13:49:32 +00:00
|
|
|
|
if (SCM_HASHTABLE_P (table))
|
2003-02-13 10:42:59 +00:00
|
|
|
|
table = SCM_HASHTABLE_VECTOR (table);
|
2003-02-11 13:49:32 +00:00
|
|
|
|
else
|
2003-02-13 10:42:59 +00:00
|
|
|
|
SCM_VALIDATE_VECTOR (1, table);
|
2005-01-02 20:11:15 +00:00
|
|
|
|
if (SCM_SIMPLE_VECTOR_LENGTH (table) == 0)
|
2001-03-30 15:03:23 +00:00
|
|
|
|
return SCM_BOOL_F;
|
2005-01-02 20:11:15 +00:00
|
|
|
|
k = hash_fn (obj, SCM_SIMPLE_VECTOR_LENGTH (table), closure);
|
|
|
|
|
|
if (k >= SCM_SIMPLE_VECTOR_LENGTH (table))
|
* numbers.h, numbers.c, discouraged.h, discouraged.c (scm_short2num,
scm_ushort2num, scm_int2num, scm_uint2num, scm_long2num,
scm_ulong2num, scm_size2num, scm_ptrdiff2num, scm_num2short,
scm_num2ushort, scm_num2int, scm_num2uint, scm_num2long,
scm_num2ulong, scm_num2size, scm_num2ptrdiff, scm_long_long2num,
scm_ulong_long2num, scm_num2long_long, scm_num2ulong_long):
Discouraged by moving to discouraged.h and discouraged.c and
reimplementing in terms of scm_from_* and scm_to_*. Changed all uses
to the new scm_from_* and scm_to_* functions.
2004-08-02 16:14:04 +00:00
|
|
|
|
scm_out_of_range ("hash_fn_get_handle", scm_from_ulong (k));
|
2006-04-04 21:28:13 +00:00
|
|
|
|
|
|
|
|
|
|
alist = SCM_SIMPLE_VECTOR_REF (table, k);
|
|
|
|
|
|
|
|
|
|
|
|
/* XXX: We assume that if TABLE is a vector, then it's a weak vector. */
|
|
|
|
|
|
if ((SCM_HASHTABLE_P (table) && (SCM_HASHTABLE_WEAK_P (table)))
|
|
|
|
|
|
|| (SCM_I_IS_VECTOR (table)))
|
2006-04-09 16:13:01 +00:00
|
|
|
|
{
|
|
|
|
|
|
/* Disable the GC so that ALIST remains valid until ASSOC_FN has
|
|
|
|
|
|
returned. */
|
|
|
|
|
|
/* FIXME: We could maybe trigger a rehash here depending on whether
|
|
|
|
|
|
`scm_fixup_weak_alist ()' noticed some change. */
|
|
|
|
|
|
GC_disable ();
|
|
|
|
|
|
weak = 1;
|
|
|
|
|
|
alist = scm_fixup_weak_alist (alist);
|
|
|
|
|
|
}
|
2006-04-04 21:28:13 +00:00
|
|
|
|
|
|
|
|
|
|
h = assoc_fn (obj, alist, closure);
|
2006-04-09 16:13:01 +00:00
|
|
|
|
if (weak)
|
|
|
|
|
|
GC_enable ();
|
|
|
|
|
|
|
1996-07-25 22:56:11 +00:00
|
|
|
|
return h;
|
|
|
|
|
|
}
|
2001-03-30 15:03:23 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SCM
|
2002-07-20 14:08:34 +00:00
|
|
|
|
scm_hash_fn_create_handle_x (SCM table, SCM obj, SCM init, unsigned long (*hash_fn)(),
|
|
|
|
|
|
SCM (*assoc_fn)(), void * closure)
|
2000-07-07 15:28:56 +00:00
|
|
|
|
#define FUNC_NAME "scm_hash_fn_create_handle_x"
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2006-04-09 16:13:01 +00:00
|
|
|
|
int weak = 0;
|
2001-05-26 20:51:22 +00:00
|
|
|
|
unsigned long k;
|
2006-04-04 21:28:13 +00:00
|
|
|
|
SCM buckets, alist, it;
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
2003-02-11 13:49:32 +00:00
|
|
|
|
if (SCM_HASHTABLE_P (table))
|
2003-02-13 10:42:59 +00:00
|
|
|
|
buckets = SCM_HASHTABLE_VECTOR (table);
|
2003-02-11 13:49:32 +00:00
|
|
|
|
else
|
|
|
|
|
|
{
|
2005-01-02 20:11:15 +00:00
|
|
|
|
SCM_ASSERT (scm_is_simple_vector (table),
|
2003-02-11 13:49:32 +00:00
|
|
|
|
table, SCM_ARG1, "hash_fn_create_handle_x");
|
|
|
|
|
|
buckets = table;
|
|
|
|
|
|
}
|
2005-01-02 20:11:15 +00:00
|
|
|
|
if (SCM_SIMPLE_VECTOR_LENGTH (buckets) == 0)
|
2000-07-07 15:28:56 +00:00
|
|
|
|
SCM_MISC_ERROR ("void hashtable", SCM_EOL);
|
|
|
|
|
|
|
2005-01-02 20:11:15 +00:00
|
|
|
|
k = hash_fn (obj, SCM_SIMPLE_VECTOR_LENGTH (buckets), closure);
|
|
|
|
|
|
if (k >= SCM_SIMPLE_VECTOR_LENGTH (buckets))
|
* numbers.h, numbers.c, discouraged.h, discouraged.c (scm_short2num,
scm_ushort2num, scm_int2num, scm_uint2num, scm_long2num,
scm_ulong2num, scm_size2num, scm_ptrdiff2num, scm_num2short,
scm_num2ushort, scm_num2int, scm_num2uint, scm_num2long,
scm_num2ulong, scm_num2size, scm_num2ptrdiff, scm_long_long2num,
scm_ulong_long2num, scm_num2long_long, scm_num2ulong_long):
Discouraged by moving to discouraged.h and discouraged.c and
reimplementing in terms of scm_from_* and scm_to_*. Changed all uses
to the new scm_from_* and scm_to_* functions.
2004-08-02 16:14:04 +00:00
|
|
|
|
scm_out_of_range ("hash_fn_create_handle_x", scm_from_ulong (k));
|
2006-04-04 21:28:13 +00:00
|
|
|
|
|
|
|
|
|
|
alist = SCM_SIMPLE_VECTOR_REF (buckets, k);
|
|
|
|
|
|
if ((SCM_HASHTABLE_P (table) && (SCM_HASHTABLE_WEAK_P (table)))
|
|
|
|
|
|
|| (SCM_I_IS_VECTOR (table)))
|
2006-04-09 16:13:01 +00:00
|
|
|
|
{
|
|
|
|
|
|
GC_disable ();
|
|
|
|
|
|
weak = 1;
|
|
|
|
|
|
alist = scm_fixup_weak_alist (alist);
|
|
|
|
|
|
}
|
2006-04-04 21:28:13 +00:00
|
|
|
|
|
|
|
|
|
|
it = assoc_fn (obj, alist, closure);
|
2006-04-09 16:13:01 +00:00
|
|
|
|
if (weak)
|
|
|
|
|
|
GC_enable ();
|
|
|
|
|
|
|
2004-07-06 10:59:25 +00:00
|
|
|
|
if (scm_is_true (it))
|
2003-02-13 10:42:59 +00:00
|
|
|
|
return it;
|
2001-10-08 21:23:00 +00:00
|
|
|
|
else
|
|
|
|
|
|
{
|
2005-02-25 22:35:26 +00:00
|
|
|
|
/* When this is a weak hashtable, running the GC can change it.
|
|
|
|
|
|
Thus, we must allocate the new cells first and can only then
|
|
|
|
|
|
access BUCKETS. Also, we need to fetch the bucket vector
|
|
|
|
|
|
again since the hashtable might have been rehashed. This
|
|
|
|
|
|
necessitates a new hash value as well.
|
2005-02-23 17:24:19 +00:00
|
|
|
|
*/
|
2006-04-04 21:28:13 +00:00
|
|
|
|
SCM handle, new_bucket;
|
|
|
|
|
|
|
|
|
|
|
|
if ((SCM_HASHTABLE_P (table) && (SCM_HASHTABLE_WEAK_P (table)))
|
|
|
|
|
|
|| (SCM_I_IS_VECTOR (table)))
|
|
|
|
|
|
{
|
|
|
|
|
|
/* Use a weak cell. */
|
|
|
|
|
|
if (SCM_HASHTABLE_DOUBLY_WEAK_P (table))
|
|
|
|
|
|
handle = scm_doubly_weak_cell (obj, init);
|
|
|
|
|
|
else if (SCM_HASHTABLE_WEAK_KEY_P (table))
|
|
|
|
|
|
handle = scm_weak_car_cell (obj, init);
|
|
|
|
|
|
else
|
|
|
|
|
|
handle = scm_weak_cdr_cell (obj, init);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
/* Use a regular, non-weak cell. */
|
|
|
|
|
|
handle = scm_cons (obj, init);
|
|
|
|
|
|
|
|
|
|
|
|
new_bucket = scm_cons (handle, SCM_EOL);
|
|
|
|
|
|
|
2005-02-25 22:35:26 +00:00
|
|
|
|
if (!scm_is_eq (table, buckets)
|
|
|
|
|
|
&& !scm_is_eq (SCM_HASHTABLE_VECTOR (table), buckets))
|
|
|
|
|
|
{
|
|
|
|
|
|
buckets = SCM_HASHTABLE_VECTOR (table);
|
|
|
|
|
|
k = hash_fn (obj, SCM_SIMPLE_VECTOR_LENGTH (buckets), closure);
|
|
|
|
|
|
if (k >= SCM_SIMPLE_VECTOR_LENGTH (buckets))
|
|
|
|
|
|
scm_out_of_range ("hash_fn_create_handle_x", scm_from_ulong (k));
|
|
|
|
|
|
}
|
2005-02-23 17:24:19 +00:00
|
|
|
|
SCM_SETCDR (new_bucket, SCM_SIMPLE_VECTOR_REF (buckets, k));
|
2005-01-02 20:11:15 +00:00
|
|
|
|
SCM_SIMPLE_VECTOR_SET (buckets, k, new_bucket);
|
2005-03-02 20:05:38 +00:00
|
|
|
|
if (!scm_is_eq (table, buckets))
|
2003-02-11 13:49:32 +00:00
|
|
|
|
{
|
2005-04-04 14:53:27 +00:00
|
|
|
|
/* Update element count and maybe rehash the table. The
|
|
|
|
|
|
table might have too few entries here since weak hash
|
|
|
|
|
|
tables used with the hashx_* functions can not be
|
|
|
|
|
|
rehashed after GC.
|
|
|
|
|
|
*/
|
2003-02-11 13:49:32 +00:00
|
|
|
|
SCM_HASHTABLE_INCREMENT (table);
|
2005-04-04 14:53:27 +00:00
|
|
|
|
if (SCM_HASHTABLE_N_ITEMS (table) < SCM_HASHTABLE_LOWER (table)
|
|
|
|
|
|
|| SCM_HASHTABLE_N_ITEMS (table) > SCM_HASHTABLE_UPPER (table))
|
* hooks.c (scm_c_hook_add): Fixed bug in append mode.
* environments.c (obarray_enter, obarray_retrieve, obarray_remove,
leaf_environment_fold, obarray_remove_all): Use hashtable
accessors.
* gc.c (scm_init_storage): Moved hook initialization to
scm_storage_prehistory.
(scm_storage_prehistory): New function.
(scm_igc): Added commentary about placement of
scm_after_sweep_c_hook.
* gc-mark.c (scm_mark_all): Use hashtable accessors.
(scm_gc_mark_dependencies): Use SCM_WVECT_WEAK_KEY_P and
SCM_WVECT_WEAK_VALUE_P.
* hashtab.c, hashtab.h (scm_hash_for_each, scm_hash_map): New
functions.
(scm_vector_to_hash_table, scm_c_make_resizing_hash_table):
Removed.
(scm_make_weak_key_hash_table, scm_make_weak_value_hash_table,
scm_make_doubly_weak_hash_table): Moved here from weaks.c.
* init.c (scm_init_guile_1): Removed call to scm_init_weaks; Added
calls to scm_storage_prehistory and scm_hashtab_prehistory.
* modules.c (module-reverse-lookup): Use hashtable accessors.
* symbols.c, symbols.h (scm_i_hash_symbol): New function.
* weaks.c, weaks.h (scm_make_weak_key_alist_vector,
scm_make_weak_value_alist_vector,
scm_make_doubly_weak_alist_vector): New functions.
* weaks.c (scm_init_weaks_builtins): New function.
* weaks.h (SCM_WVECTF_WEAK_KEY, SCM_WVECTF_WEAK_VALUE,
SCM_WVECTF_NOSCAN, SCM_WVECT_WEAK_KEY_P, SCM_WVECT_WEAK_VALUE_P,
SCM_WVECT_NOSCAN_P): New macros.
* weaks.c (scm_scan_weak_vectors): Use SCM_WVECT_WEAK_KEY_P
and SCM_WVECT_WEAK_VALUE_P.
* weaks.c, weaks.h (scm_i_allocate_weak_vector): Renamed from
allocate_weak_vector and exported.
* Makefile.am (ice9_sources): Added weak-vector.scm.
* weak-vector.scm: New file.
* boot-9.scm (module-clear!): Use hash-clear!.
(module-for-each): Use hash-for-each.
(module-map): Use hash-map.
2003-02-19 15:04:51 +00:00
|
|
|
|
scm_i_rehash (table, hash_fn, closure, FUNC_NAME);
|
2003-02-11 13:49:32 +00:00
|
|
|
|
}
|
2001-10-08 21:23:00 +00:00
|
|
|
|
return SCM_CAR (new_bucket);
|
|
|
|
|
|
}
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
2000-07-07 15:28:56 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
* __scm.h, alist.c, alist.h, append.c, append.h, appinit.c,
arbiters.c, arbiters.h, async.c, async.h, boolean.c, boolean.h,
chars.c, chars.h, continuations.c, continuations.h, debug.c,
debug.h, dynwind.c, dynwind.h, eq.c, eq.h, error.c, eval.c,
eval.h, extchrs.c, extchrs.h, fdsocket.c, fdsocket.h, filesys.c,
filesys.h, fports.c, fports.h, gc.c, gdb_interface.h, gdbint.c,
gdbint.h, genio.c, genio.h, gscm.c, gscm.h, gsubr.c, gsubr.h,
hash.c, hash.h, hashtab.c, hashtab.h, init.c, ioext.c, ioext.h,
kw.c, kw.h, libguile.h, mallocs.c, mallocs.h, markers.c,
markers.h, mbstrings.c, mbstrings.h, numbers.c, numbers.h,
objprop.c, objprop.h, options.c, options.h, pairs.c, pairs.h,
ports.c, ports.h, posix.c, posix.h, print.c, print.h, procprop.c,
procprop.h, procs.c, procs.h, ramap.c, ramap.h, read.c, read.h,
root.c, scmsigs.c, scmsigs.h, sequences.c, sequences.h, simpos.c,
simpos.h, smob.c, socket.c, socket.h, srcprop.c, srcprop.h,
stackchk.c, stackchk.h, stime.c, stime.h, strings.c, strings.h,
strop.c, strop.h, strorder.c, strorder.h, strports.c, strports.h,
struct.c, struct.h, symbols.c, symbols.h, tag.c, tag.h, unif.c,
unif.h, variable.c, variable.h, vectors.c, vectors.h, version.c,
version.h, vports.c, vports.h, weaks.c, weaks.h: Use SCM_P to
declare functions with prototypes. (Patch thanks to Marius
Vollmer.)
1996-10-14 01:33:50 +00:00
|
|
|
|
|
1996-07-25 22:56:11 +00:00
|
|
|
|
SCM
|
2002-07-20 14:08:34 +00:00
|
|
|
|
scm_hash_fn_ref (SCM table, SCM obj, SCM dflt, unsigned long (*hash_fn)(),
|
|
|
|
|
|
SCM (*assoc_fn)(), void * closure)
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2001-03-30 15:03:23 +00:00
|
|
|
|
SCM it = scm_hash_fn_get_handle (table, obj, hash_fn, assoc_fn, closure);
|
2004-09-22 17:41:37 +00:00
|
|
|
|
if (scm_is_pair (it))
|
1996-07-25 22:56:11 +00:00
|
|
|
|
return SCM_CDR (it);
|
2001-03-30 15:03:23 +00:00
|
|
|
|
else
|
|
|
|
|
|
return dflt;
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
* __scm.h, alist.c, alist.h, append.c, append.h, appinit.c,
arbiters.c, arbiters.h, async.c, async.h, boolean.c, boolean.h,
chars.c, chars.h, continuations.c, continuations.h, debug.c,
debug.h, dynwind.c, dynwind.h, eq.c, eq.h, error.c, eval.c,
eval.h, extchrs.c, extchrs.h, fdsocket.c, fdsocket.h, filesys.c,
filesys.h, fports.c, fports.h, gc.c, gdb_interface.h, gdbint.c,
gdbint.h, genio.c, genio.h, gscm.c, gscm.h, gsubr.c, gsubr.h,
hash.c, hash.h, hashtab.c, hashtab.h, init.c, ioext.c, ioext.h,
kw.c, kw.h, libguile.h, mallocs.c, mallocs.h, markers.c,
markers.h, mbstrings.c, mbstrings.h, numbers.c, numbers.h,
objprop.c, objprop.h, options.c, options.h, pairs.c, pairs.h,
ports.c, ports.h, posix.c, posix.h, print.c, print.h, procprop.c,
procprop.h, procs.c, procs.h, ramap.c, ramap.h, read.c, read.h,
root.c, scmsigs.c, scmsigs.h, sequences.c, sequences.h, simpos.c,
simpos.h, smob.c, socket.c, socket.h, srcprop.c, srcprop.h,
stackchk.c, stackchk.h, stime.c, stime.h, strings.c, strings.h,
strop.c, strop.h, strorder.c, strorder.h, strports.c, strports.h,
struct.c, struct.h, symbols.c, symbols.h, tag.c, tag.h, unif.c,
unif.h, variable.c, variable.h, vectors.c, vectors.h, version.c,
version.h, vports.c, vports.h, weaks.c, weaks.h: Use SCM_P to
declare functions with prototypes. (Patch thanks to Marius
Vollmer.)
1996-10-14 01:33:50 +00:00
|
|
|
|
|
1996-07-25 22:56:11 +00:00
|
|
|
|
SCM
|
2002-07-20 14:08:34 +00:00
|
|
|
|
scm_hash_fn_set_x (SCM table, SCM obj, SCM val, unsigned long (*hash_fn)(),
|
|
|
|
|
|
SCM (*assoc_fn)(), void * closure)
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
|
|
|
|
|
SCM it;
|
|
|
|
|
|
|
|
|
|
|
|
it = scm_hash_fn_create_handle_x (table, obj, SCM_BOOL_F, hash_fn, assoc_fn, closure);
|
|
|
|
|
|
SCM_SETCDR (it, val);
|
|
|
|
|
|
return val;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SCM
|
2005-03-29 17:47:39 +00:00
|
|
|
|
scm_hash_fn_remove_x (SCM table, SCM obj,
|
|
|
|
|
|
unsigned long (*hash_fn)(),
|
|
|
|
|
|
SCM (*assoc_fn)(),
|
|
|
|
|
|
void *closure)
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2006-04-09 16:13:01 +00:00
|
|
|
|
int weak = 0;
|
2001-05-26 20:51:22 +00:00
|
|
|
|
unsigned long k;
|
2006-04-04 21:28:13 +00:00
|
|
|
|
SCM buckets, alist, h;
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
2003-02-12 09:55:10 +00:00
|
|
|
|
if (SCM_HASHTABLE_P (table))
|
2003-02-13 10:42:59 +00:00
|
|
|
|
buckets = SCM_HASHTABLE_VECTOR (table);
|
2003-02-12 09:55:10 +00:00
|
|
|
|
else
|
|
|
|
|
|
{
|
2005-01-02 20:11:15 +00:00
|
|
|
|
SCM_ASSERT (scm_is_simple_vector (table), table,
|
|
|
|
|
|
SCM_ARG1, "hash_fn_remove_x");
|
2003-02-12 09:55:10 +00:00
|
|
|
|
buckets = table;
|
|
|
|
|
|
}
|
2005-01-02 20:11:15 +00:00
|
|
|
|
if (SCM_SIMPLE_VECTOR_LENGTH (table) == 0)
|
1996-07-25 22:56:11 +00:00
|
|
|
|
return SCM_EOL;
|
2003-02-12 09:55:10 +00:00
|
|
|
|
|
2005-01-02 20:11:15 +00:00
|
|
|
|
k = hash_fn (obj, SCM_SIMPLE_VECTOR_LENGTH (buckets), closure);
|
|
|
|
|
|
if (k >= SCM_SIMPLE_VECTOR_LENGTH (buckets))
|
* numbers.h, numbers.c, discouraged.h, discouraged.c (scm_short2num,
scm_ushort2num, scm_int2num, scm_uint2num, scm_long2num,
scm_ulong2num, scm_size2num, scm_ptrdiff2num, scm_num2short,
scm_num2ushort, scm_num2int, scm_num2uint, scm_num2long,
scm_num2ulong, scm_num2size, scm_num2ptrdiff, scm_long_long2num,
scm_ulong_long2num, scm_num2long_long, scm_num2ulong_long):
Discouraged by moving to discouraged.h and discouraged.c and
reimplementing in terms of scm_from_* and scm_to_*. Changed all uses
to the new scm_from_* and scm_to_* functions.
2004-08-02 16:14:04 +00:00
|
|
|
|
scm_out_of_range ("hash_fn_remove_x", scm_from_ulong (k));
|
2006-04-04 21:28:13 +00:00
|
|
|
|
|
|
|
|
|
|
alist = SCM_SIMPLE_VECTOR_REF (buckets, k);
|
|
|
|
|
|
if ((SCM_HASHTABLE_P (table) && (SCM_HASHTABLE_WEAK_P (table)))
|
|
|
|
|
|
|| (SCM_I_IS_VECTOR (table)))
|
2006-04-09 16:13:01 +00:00
|
|
|
|
{
|
|
|
|
|
|
GC_disable ();
|
|
|
|
|
|
weak = 1;
|
|
|
|
|
|
alist = scm_fixup_weak_alist (alist);
|
|
|
|
|
|
}
|
2006-04-04 21:28:13 +00:00
|
|
|
|
|
|
|
|
|
|
h = assoc_fn (obj, alist, closure);
|
2006-04-09 16:13:01 +00:00
|
|
|
|
if (weak)
|
|
|
|
|
|
GC_enable ();
|
|
|
|
|
|
|
2004-07-06 10:59:25 +00:00
|
|
|
|
if (scm_is_true (h))
|
2003-02-12 09:55:10 +00:00
|
|
|
|
{
|
2005-01-02 20:11:15 +00:00
|
|
|
|
SCM_SIMPLE_VECTOR_SET
|
2005-03-29 17:47:39 +00:00
|
|
|
|
(buckets, k, scm_delq_x (h, SCM_SIMPLE_VECTOR_REF (buckets, k)));
|
2005-03-02 20:05:38 +00:00
|
|
|
|
if (!scm_is_eq (table, buckets))
|
2003-02-12 09:55:10 +00:00
|
|
|
|
{
|
|
|
|
|
|
SCM_HASHTABLE_DECREMENT (table);
|
|
|
|
|
|
if (SCM_HASHTABLE_N_ITEMS (table) < SCM_HASHTABLE_LOWER (table))
|
* hooks.c (scm_c_hook_add): Fixed bug in append mode.
* environments.c (obarray_enter, obarray_retrieve, obarray_remove,
leaf_environment_fold, obarray_remove_all): Use hashtable
accessors.
* gc.c (scm_init_storage): Moved hook initialization to
scm_storage_prehistory.
(scm_storage_prehistory): New function.
(scm_igc): Added commentary about placement of
scm_after_sweep_c_hook.
* gc-mark.c (scm_mark_all): Use hashtable accessors.
(scm_gc_mark_dependencies): Use SCM_WVECT_WEAK_KEY_P and
SCM_WVECT_WEAK_VALUE_P.
* hashtab.c, hashtab.h (scm_hash_for_each, scm_hash_map): New
functions.
(scm_vector_to_hash_table, scm_c_make_resizing_hash_table):
Removed.
(scm_make_weak_key_hash_table, scm_make_weak_value_hash_table,
scm_make_doubly_weak_hash_table): Moved here from weaks.c.
* init.c (scm_init_guile_1): Removed call to scm_init_weaks; Added
calls to scm_storage_prehistory and scm_hashtab_prehistory.
* modules.c (module-reverse-lookup): Use hashtable accessors.
* symbols.c, symbols.h (scm_i_hash_symbol): New function.
* weaks.c, weaks.h (scm_make_weak_key_alist_vector,
scm_make_weak_value_alist_vector,
scm_make_doubly_weak_alist_vector): New functions.
* weaks.c (scm_init_weaks_builtins): New function.
* weaks.h (SCM_WVECTF_WEAK_KEY, SCM_WVECTF_WEAK_VALUE,
SCM_WVECTF_NOSCAN, SCM_WVECT_WEAK_KEY_P, SCM_WVECT_WEAK_VALUE_P,
SCM_WVECT_NOSCAN_P): New macros.
* weaks.c (scm_scan_weak_vectors): Use SCM_WVECT_WEAK_KEY_P
and SCM_WVECT_WEAK_VALUE_P.
* weaks.c, weaks.h (scm_i_allocate_weak_vector): Renamed from
allocate_weak_vector and exported.
* Makefile.am (ice9_sources): Added weak-vector.scm.
* weak-vector.scm: New file.
* boot-9.scm (module-clear!): Use hash-clear!.
(module-for-each): Use hash-for-each.
(module-map): Use hash-map.
2003-02-19 15:04:51 +00:00
|
|
|
|
scm_i_rehash (table, hash_fn, closure, "scm_hash_fn_remove_x");
|
2003-02-12 09:55:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
1996-07-25 22:56:11 +00:00
|
|
|
|
return h;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
* hooks.c (scm_c_hook_add): Fixed bug in append mode.
* environments.c (obarray_enter, obarray_retrieve, obarray_remove,
leaf_environment_fold, obarray_remove_all): Use hashtable
accessors.
* gc.c (scm_init_storage): Moved hook initialization to
scm_storage_prehistory.
(scm_storage_prehistory): New function.
(scm_igc): Added commentary about placement of
scm_after_sweep_c_hook.
* gc-mark.c (scm_mark_all): Use hashtable accessors.
(scm_gc_mark_dependencies): Use SCM_WVECT_WEAK_KEY_P and
SCM_WVECT_WEAK_VALUE_P.
* hashtab.c, hashtab.h (scm_hash_for_each, scm_hash_map): New
functions.
(scm_vector_to_hash_table, scm_c_make_resizing_hash_table):
Removed.
(scm_make_weak_key_hash_table, scm_make_weak_value_hash_table,
scm_make_doubly_weak_hash_table): Moved here from weaks.c.
* init.c (scm_init_guile_1): Removed call to scm_init_weaks; Added
calls to scm_storage_prehistory and scm_hashtab_prehistory.
* modules.c (module-reverse-lookup): Use hashtable accessors.
* symbols.c, symbols.h (scm_i_hash_symbol): New function.
* weaks.c, weaks.h (scm_make_weak_key_alist_vector,
scm_make_weak_value_alist_vector,
scm_make_doubly_weak_alist_vector): New functions.
* weaks.c (scm_init_weaks_builtins): New function.
* weaks.h (SCM_WVECTF_WEAK_KEY, SCM_WVECTF_WEAK_VALUE,
SCM_WVECTF_NOSCAN, SCM_WVECT_WEAK_KEY_P, SCM_WVECT_WEAK_VALUE_P,
SCM_WVECT_NOSCAN_P): New macros.
* weaks.c (scm_scan_weak_vectors): Use SCM_WVECT_WEAK_KEY_P
and SCM_WVECT_WEAK_VALUE_P.
* weaks.c, weaks.h (scm_i_allocate_weak_vector): Renamed from
allocate_weak_vector and exported.
* Makefile.am (ice9_sources): Added weak-vector.scm.
* weak-vector.scm: New file.
* boot-9.scm (module-clear!): Use hash-clear!.
(module-for-each): Use hash-for-each.
(module-map): Use hash-map.
2003-02-19 15:04:51 +00:00
|
|
|
|
SCM_DEFINE (scm_hash_clear_x, "hash-clear!", 1, 0, 0,
|
|
|
|
|
|
(SCM table),
|
2005-03-29 17:47:39 +00:00
|
|
|
|
"Remove all items from @var{table} (without triggering a resize).")
|
* hooks.c (scm_c_hook_add): Fixed bug in append mode.
* environments.c (obarray_enter, obarray_retrieve, obarray_remove,
leaf_environment_fold, obarray_remove_all): Use hashtable
accessors.
* gc.c (scm_init_storage): Moved hook initialization to
scm_storage_prehistory.
(scm_storage_prehistory): New function.
(scm_igc): Added commentary about placement of
scm_after_sweep_c_hook.
* gc-mark.c (scm_mark_all): Use hashtable accessors.
(scm_gc_mark_dependencies): Use SCM_WVECT_WEAK_KEY_P and
SCM_WVECT_WEAK_VALUE_P.
* hashtab.c, hashtab.h (scm_hash_for_each, scm_hash_map): New
functions.
(scm_vector_to_hash_table, scm_c_make_resizing_hash_table):
Removed.
(scm_make_weak_key_hash_table, scm_make_weak_value_hash_table,
scm_make_doubly_weak_hash_table): Moved here from weaks.c.
* init.c (scm_init_guile_1): Removed call to scm_init_weaks; Added
calls to scm_storage_prehistory and scm_hashtab_prehistory.
* modules.c (module-reverse-lookup): Use hashtable accessors.
* symbols.c, symbols.h (scm_i_hash_symbol): New function.
* weaks.c, weaks.h (scm_make_weak_key_alist_vector,
scm_make_weak_value_alist_vector,
scm_make_doubly_weak_alist_vector): New functions.
* weaks.c (scm_init_weaks_builtins): New function.
* weaks.h (SCM_WVECTF_WEAK_KEY, SCM_WVECTF_WEAK_VALUE,
SCM_WVECTF_NOSCAN, SCM_WVECT_WEAK_KEY_P, SCM_WVECT_WEAK_VALUE_P,
SCM_WVECT_NOSCAN_P): New macros.
* weaks.c (scm_scan_weak_vectors): Use SCM_WVECT_WEAK_KEY_P
and SCM_WVECT_WEAK_VALUE_P.
* weaks.c, weaks.h (scm_i_allocate_weak_vector): Renamed from
allocate_weak_vector and exported.
* Makefile.am (ice9_sources): Added weak-vector.scm.
* weak-vector.scm: New file.
* boot-9.scm (module-clear!): Use hash-clear!.
(module-for-each): Use hash-for-each.
(module-map): Use hash-map.
2003-02-19 15:04:51 +00:00
|
|
|
|
#define FUNC_NAME s_scm_hash_clear_x
|
|
|
|
|
|
{
|
2005-03-29 17:47:39 +00:00
|
|
|
|
if (SCM_HASHTABLE_P (table))
|
|
|
|
|
|
{
|
|
|
|
|
|
scm_vector_fill_x (SCM_HASHTABLE_VECTOR (table), SCM_EOL);
|
|
|
|
|
|
SCM_SET_HASHTABLE_N_ITEMS (table, 0);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
scm_vector_fill_x (table, SCM_EOL);
|
* hooks.c (scm_c_hook_add): Fixed bug in append mode.
* environments.c (obarray_enter, obarray_retrieve, obarray_remove,
leaf_environment_fold, obarray_remove_all): Use hashtable
accessors.
* gc.c (scm_init_storage): Moved hook initialization to
scm_storage_prehistory.
(scm_storage_prehistory): New function.
(scm_igc): Added commentary about placement of
scm_after_sweep_c_hook.
* gc-mark.c (scm_mark_all): Use hashtable accessors.
(scm_gc_mark_dependencies): Use SCM_WVECT_WEAK_KEY_P and
SCM_WVECT_WEAK_VALUE_P.
* hashtab.c, hashtab.h (scm_hash_for_each, scm_hash_map): New
functions.
(scm_vector_to_hash_table, scm_c_make_resizing_hash_table):
Removed.
(scm_make_weak_key_hash_table, scm_make_weak_value_hash_table,
scm_make_doubly_weak_hash_table): Moved here from weaks.c.
* init.c (scm_init_guile_1): Removed call to scm_init_weaks; Added
calls to scm_storage_prehistory and scm_hashtab_prehistory.
* modules.c (module-reverse-lookup): Use hashtable accessors.
* symbols.c, symbols.h (scm_i_hash_symbol): New function.
* weaks.c, weaks.h (scm_make_weak_key_alist_vector,
scm_make_weak_value_alist_vector,
scm_make_doubly_weak_alist_vector): New functions.
* weaks.c (scm_init_weaks_builtins): New function.
* weaks.h (SCM_WVECTF_WEAK_KEY, SCM_WVECTF_WEAK_VALUE,
SCM_WVECTF_NOSCAN, SCM_WVECT_WEAK_KEY_P, SCM_WVECT_WEAK_VALUE_P,
SCM_WVECT_NOSCAN_P): New macros.
* weaks.c (scm_scan_weak_vectors): Use SCM_WVECT_WEAK_KEY_P
and SCM_WVECT_WEAK_VALUE_P.
* weaks.c, weaks.h (scm_i_allocate_weak_vector): Renamed from
allocate_weak_vector and exported.
* Makefile.am (ice9_sources): Added weak-vector.scm.
* weak-vector.scm: New file.
* boot-9.scm (module-clear!): Use hash-clear!.
(module-for-each): Use hash-for-each.
(module-map): Use hash-map.
2003-02-19 15:04:51 +00:00
|
|
|
|
return SCM_UNSPECIFIED;
|
|
|
|
|
|
}
|
|
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2000-01-05 19:05:23 +00:00
|
|
|
|
SCM_DEFINE (scm_hashq_get_handle, "hashq-get-handle", 2, 0, 0,
|
2001-03-30 15:03:23 +00:00
|
|
|
|
(SCM table, SCM key),
|
|
|
|
|
|
"This procedure returns the @code{(key . value)} pair from the\n"
|
|
|
|
|
|
"hash table @var{table}. If @var{table} does not hold an\n"
|
|
|
|
|
|
"associated value for @var{key}, @code{#f} is returned.\n"
|
|
|
|
|
|
"Uses @code{eq?} for equality testing.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_hashq_get_handle
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2001-03-30 15:03:23 +00:00
|
|
|
|
return scm_hash_fn_get_handle (table, key, scm_ihashq, scm_sloppy_assq, 0);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
2000-01-05 19:05:23 +00:00
|
|
|
|
SCM_DEFINE (scm_hashq_create_handle_x, "hashq-create-handle!", 3, 0, 0,
|
2000-03-02 23:41:22 +00:00
|
|
|
|
(SCM table, SCM key, SCM init),
|
|
|
|
|
|
"This function looks up @var{key} in @var{table} and returns its handle.\n"
|
* alist.c, chars.c, debug.c, dynl.c, dynwind.c, error.c, eval.c,
evalext.c, filesys.c, gc.c, hash.c, hashtab.c, ioext.c,
keywords.c, list.c, load.c, macros.c, net_db.c, numbers.c,
objprop.c, ports.c, posix.c, print.c, procprop.c, procs.c,
ramap.c, regex-posix.c, root.c, scmsigs.c, simpos.c, socket.c,
stacks.c, stime.c, strings.c, strop.c, strports.c, struct.c,
symbols.c, throw.c, unif.c, vectors.c, version.c, vports.c,
weaks.c: Converted docstrings to ANSI C format.
2000-01-18 11:24:03 +00:00
|
|
|
|
"If @var{key} is not already present, a new handle is created which\n"
|
|
|
|
|
|
"associates @var{key} with @var{init}.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_hashq_create_handle_x
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2000-03-02 23:41:22 +00:00
|
|
|
|
return scm_hash_fn_create_handle_x (table, key, init, scm_ihashq, scm_sloppy_assq, 0);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
2000-01-05 19:05:23 +00:00
|
|
|
|
SCM_DEFINE (scm_hashq_ref, "hashq-ref", 2, 1, 0,
|
2001-04-03 13:19:05 +00:00
|
|
|
|
(SCM table, SCM key, SCM dflt),
|
* alist.c, chars.c, debug.c, dynl.c, dynwind.c, error.c, eval.c,
evalext.c, filesys.c, gc.c, hash.c, hashtab.c, ioext.c,
keywords.c, list.c, load.c, macros.c, net_db.c, numbers.c,
objprop.c, ports.c, posix.c, print.c, procprop.c, procs.c,
ramap.c, regex-posix.c, root.c, scmsigs.c, simpos.c, socket.c,
stacks.c, stime.c, strings.c, strop.c, strports.c, struct.c,
symbols.c, throw.c, unif.c, vectors.c, version.c, vports.c,
weaks.c: Converted docstrings to ANSI C format.
2000-01-18 11:24:03 +00:00
|
|
|
|
"Look up @var{key} in the hash table @var{table}, and return the\n"
|
|
|
|
|
|
"value (if any) associated with it. If @var{key} is not found,\n"
|
* list.c (scm_list, scm_cons_star, scm_null_p, scm_list_p),
(scm_length, scm_append, scm_reverse, scm_list_ref),
(scm_memq, scm_memv, scm_member, scm_delv_x, scm_delete_x),
(scm_delq, scm_delv, scm_delete, scm_delq1_x, scm_delv1_x),
(scm_delete1_x), gc.c (scm_map_free_list),
(scm_free_list_length), hash.c (scm_hashq, scm_hashv),
(scm_hash), hashtab.c (scm_hashq_ref, scm_hashq_set_x),
(scm_hashq_remove_x, scm_hashv_ref, scm_hashv_set_x),
(scm_hashv_remove_x, scm_hash_ref, scm_hash_set_x),
(scm_hash_remove_x), ports.c (scm_pt_size, scm_pt_member), print.c
(scm_current_pstate), scmsigs.c (scm_usleep), goops.c
(scm_get_keyword, scm_sys_compute_slots): Added texinfo markup.
* weaks.c (scm_weak_vector_p, scm_weak_key_hash_table_p),
(scm_weak_value_hash_table_p, scm_doubly_weak_hash_table_p),
rdelim.c (scm_read_delimited_x), strop.c (scm_string_index),
symbols.c (scm_symbol_interned_p), numbers.c
(scm_string_to_number), ports.c (scm_port_p): Corrected texinfo
markup.
2001-03-16 10:00:17 +00:00
|
|
|
|
"return @var{default} (or @code{#f} if no @var{default} argument\n"
|
|
|
|
|
|
"is supplied). Uses @code{eq?} for equality testing.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_hashq_ref
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2000-04-03 08:47:51 +00:00
|
|
|
|
if (SCM_UNBNDP (dflt))
|
1996-07-25 22:56:11 +00:00
|
|
|
|
dflt = SCM_BOOL_F;
|
2001-04-03 13:19:05 +00:00
|
|
|
|
return scm_hash_fn_ref (table, key, dflt, scm_ihashq, scm_sloppy_assq, 0);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2000-01-05 19:05:23 +00:00
|
|
|
|
SCM_DEFINE (scm_hashq_set_x, "hashq-set!", 3, 0, 0,
|
2001-04-03 13:19:05 +00:00
|
|
|
|
(SCM table, SCM key, SCM val),
|
* list.c (scm_list, scm_cons_star, scm_null_p, scm_list_p),
(scm_length, scm_append, scm_reverse, scm_list_ref),
(scm_memq, scm_memv, scm_member, scm_delv_x, scm_delete_x),
(scm_delq, scm_delv, scm_delete, scm_delq1_x, scm_delv1_x),
(scm_delete1_x), gc.c (scm_map_free_list),
(scm_free_list_length), hash.c (scm_hashq, scm_hashv),
(scm_hash), hashtab.c (scm_hashq_ref, scm_hashq_set_x),
(scm_hashq_remove_x, scm_hashv_ref, scm_hashv_set_x),
(scm_hashv_remove_x, scm_hash_ref, scm_hash_set_x),
(scm_hash_remove_x), ports.c (scm_pt_size, scm_pt_member), print.c
(scm_current_pstate), scmsigs.c (scm_usleep), goops.c
(scm_get_keyword, scm_sys_compute_slots): Added texinfo markup.
* weaks.c (scm_weak_vector_p, scm_weak_key_hash_table_p),
(scm_weak_value_hash_table_p, scm_doubly_weak_hash_table_p),
rdelim.c (scm_read_delimited_x), strop.c (scm_string_index),
symbols.c (scm_symbol_interned_p), numbers.c
(scm_string_to_number), ports.c (scm_port_p): Corrected texinfo
markup.
2001-03-16 10:00:17 +00:00
|
|
|
|
"Find the entry in @var{table} associated with @var{key}, and\n"
|
|
|
|
|
|
"store @var{value} there. Uses @code{eq?} for equality testing.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_hashq_set_x
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2001-04-03 13:19:05 +00:00
|
|
|
|
return scm_hash_fn_set_x (table, key, val, scm_ihashq, scm_sloppy_assq, 0);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2000-01-05 19:05:23 +00:00
|
|
|
|
SCM_DEFINE (scm_hashq_remove_x, "hashq-remove!", 2, 0, 0,
|
2001-04-03 13:19:05 +00:00
|
|
|
|
(SCM table, SCM key),
|
* list.c (scm_list, scm_cons_star, scm_null_p, scm_list_p),
(scm_length, scm_append, scm_reverse, scm_list_ref),
(scm_memq, scm_memv, scm_member, scm_delv_x, scm_delete_x),
(scm_delq, scm_delv, scm_delete, scm_delq1_x, scm_delv1_x),
(scm_delete1_x), gc.c (scm_map_free_list),
(scm_free_list_length), hash.c (scm_hashq, scm_hashv),
(scm_hash), hashtab.c (scm_hashq_ref, scm_hashq_set_x),
(scm_hashq_remove_x, scm_hashv_ref, scm_hashv_set_x),
(scm_hashv_remove_x, scm_hash_ref, scm_hash_set_x),
(scm_hash_remove_x), ports.c (scm_pt_size, scm_pt_member), print.c
(scm_current_pstate), scmsigs.c (scm_usleep), goops.c
(scm_get_keyword, scm_sys_compute_slots): Added texinfo markup.
* weaks.c (scm_weak_vector_p, scm_weak_key_hash_table_p),
(scm_weak_value_hash_table_p, scm_doubly_weak_hash_table_p),
rdelim.c (scm_read_delimited_x), strop.c (scm_string_index),
symbols.c (scm_symbol_interned_p), numbers.c
(scm_string_to_number), ports.c (scm_port_p): Corrected texinfo
markup.
2001-03-16 10:00:17 +00:00
|
|
|
|
"Remove @var{key} (and any value associated with it) from\n"
|
|
|
|
|
|
"@var{table}. Uses @code{eq?} for equality tests.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_hashq_remove_x
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2005-03-29 17:47:39 +00:00
|
|
|
|
return scm_hash_fn_remove_x (table, key, scm_ihashq, scm_sloppy_assq, 0);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2000-01-05 19:05:23 +00:00
|
|
|
|
SCM_DEFINE (scm_hashv_get_handle, "hashv-get-handle", 2, 0, 0,
|
2001-03-30 15:03:23 +00:00
|
|
|
|
(SCM table, SCM key),
|
|
|
|
|
|
"This procedure returns the @code{(key . value)} pair from the\n"
|
|
|
|
|
|
"hash table @var{table}. If @var{table} does not hold an\n"
|
|
|
|
|
|
"associated value for @var{key}, @code{#f} is returned.\n"
|
|
|
|
|
|
"Uses @code{eqv?} for equality testing.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_hashv_get_handle
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2001-03-30 15:03:23 +00:00
|
|
|
|
return scm_hash_fn_get_handle (table, key, scm_ihashv, scm_sloppy_assv, 0);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
2000-01-05 19:05:23 +00:00
|
|
|
|
SCM_DEFINE (scm_hashv_create_handle_x, "hashv-create-handle!", 3, 0, 0,
|
2000-03-02 23:41:22 +00:00
|
|
|
|
(SCM table, SCM key, SCM init),
|
|
|
|
|
|
"This function looks up @var{key} in @var{table} and returns its handle.\n"
|
|
|
|
|
|
"If @var{key} is not already present, a new handle is created which\n"
|
|
|
|
|
|
"associates @var{key} with @var{init}.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_hashv_create_handle_x
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2001-04-03 13:19:05 +00:00
|
|
|
|
return scm_hash_fn_create_handle_x (table, key, init, scm_ihashv,
|
|
|
|
|
|
scm_sloppy_assv, 0);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
2000-01-05 19:05:23 +00:00
|
|
|
|
SCM_DEFINE (scm_hashv_ref, "hashv-ref", 2, 1, 0,
|
2001-04-03 13:19:05 +00:00
|
|
|
|
(SCM table, SCM key, SCM dflt),
|
2000-03-02 23:41:22 +00:00
|
|
|
|
"Look up @var{key} in the hash table @var{table}, and return the\n"
|
|
|
|
|
|
"value (if any) associated with it. If @var{key} is not found,\n"
|
* list.c (scm_list, scm_cons_star, scm_null_p, scm_list_p),
(scm_length, scm_append, scm_reverse, scm_list_ref),
(scm_memq, scm_memv, scm_member, scm_delv_x, scm_delete_x),
(scm_delq, scm_delv, scm_delete, scm_delq1_x, scm_delv1_x),
(scm_delete1_x), gc.c (scm_map_free_list),
(scm_free_list_length), hash.c (scm_hashq, scm_hashv),
(scm_hash), hashtab.c (scm_hashq_ref, scm_hashq_set_x),
(scm_hashq_remove_x, scm_hashv_ref, scm_hashv_set_x),
(scm_hashv_remove_x, scm_hash_ref, scm_hash_set_x),
(scm_hash_remove_x), ports.c (scm_pt_size, scm_pt_member), print.c
(scm_current_pstate), scmsigs.c (scm_usleep), goops.c
(scm_get_keyword, scm_sys_compute_slots): Added texinfo markup.
* weaks.c (scm_weak_vector_p, scm_weak_key_hash_table_p),
(scm_weak_value_hash_table_p, scm_doubly_weak_hash_table_p),
rdelim.c (scm_read_delimited_x), strop.c (scm_string_index),
symbols.c (scm_symbol_interned_p), numbers.c
(scm_string_to_number), ports.c (scm_port_p): Corrected texinfo
markup.
2001-03-16 10:00:17 +00:00
|
|
|
|
"return @var{default} (or @code{#f} if no @var{default} argument\n"
|
|
|
|
|
|
"is supplied). Uses @code{eqv?} for equality testing.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_hashv_ref
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2000-04-03 08:47:51 +00:00
|
|
|
|
if (SCM_UNBNDP (dflt))
|
1996-07-25 22:56:11 +00:00
|
|
|
|
dflt = SCM_BOOL_F;
|
2001-04-03 13:19:05 +00:00
|
|
|
|
return scm_hash_fn_ref (table, key, dflt, scm_ihashv, scm_sloppy_assv, 0);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2000-01-05 19:05:23 +00:00
|
|
|
|
SCM_DEFINE (scm_hashv_set_x, "hashv-set!", 3, 0, 0,
|
2001-04-03 13:19:05 +00:00
|
|
|
|
(SCM table, SCM key, SCM val),
|
* list.c (scm_list, scm_cons_star, scm_null_p, scm_list_p),
(scm_length, scm_append, scm_reverse, scm_list_ref),
(scm_memq, scm_memv, scm_member, scm_delv_x, scm_delete_x),
(scm_delq, scm_delv, scm_delete, scm_delq1_x, scm_delv1_x),
(scm_delete1_x), gc.c (scm_map_free_list),
(scm_free_list_length), hash.c (scm_hashq, scm_hashv),
(scm_hash), hashtab.c (scm_hashq_ref, scm_hashq_set_x),
(scm_hashq_remove_x, scm_hashv_ref, scm_hashv_set_x),
(scm_hashv_remove_x, scm_hash_ref, scm_hash_set_x),
(scm_hash_remove_x), ports.c (scm_pt_size, scm_pt_member), print.c
(scm_current_pstate), scmsigs.c (scm_usleep), goops.c
(scm_get_keyword, scm_sys_compute_slots): Added texinfo markup.
* weaks.c (scm_weak_vector_p, scm_weak_key_hash_table_p),
(scm_weak_value_hash_table_p, scm_doubly_weak_hash_table_p),
rdelim.c (scm_read_delimited_x), strop.c (scm_string_index),
symbols.c (scm_symbol_interned_p), numbers.c
(scm_string_to_number), ports.c (scm_port_p): Corrected texinfo
markup.
2001-03-16 10:00:17 +00:00
|
|
|
|
"Find the entry in @var{table} associated with @var{key}, and\n"
|
|
|
|
|
|
"store @var{value} there. Uses @code{eqv?} for equality testing.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_hashv_set_x
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2001-04-03 13:19:05 +00:00
|
|
|
|
return scm_hash_fn_set_x (table, key, val, scm_ihashv, scm_sloppy_assv, 0);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
2000-01-05 19:05:23 +00:00
|
|
|
|
SCM_DEFINE (scm_hashv_remove_x, "hashv-remove!", 2, 0, 0,
|
2001-04-03 13:19:05 +00:00
|
|
|
|
(SCM table, SCM key),
|
* list.c (scm_list, scm_cons_star, scm_null_p, scm_list_p),
(scm_length, scm_append, scm_reverse, scm_list_ref),
(scm_memq, scm_memv, scm_member, scm_delv_x, scm_delete_x),
(scm_delq, scm_delv, scm_delete, scm_delq1_x, scm_delv1_x),
(scm_delete1_x), gc.c (scm_map_free_list),
(scm_free_list_length), hash.c (scm_hashq, scm_hashv),
(scm_hash), hashtab.c (scm_hashq_ref, scm_hashq_set_x),
(scm_hashq_remove_x, scm_hashv_ref, scm_hashv_set_x),
(scm_hashv_remove_x, scm_hash_ref, scm_hash_set_x),
(scm_hash_remove_x), ports.c (scm_pt_size, scm_pt_member), print.c
(scm_current_pstate), scmsigs.c (scm_usleep), goops.c
(scm_get_keyword, scm_sys_compute_slots): Added texinfo markup.
* weaks.c (scm_weak_vector_p, scm_weak_key_hash_table_p),
(scm_weak_value_hash_table_p, scm_doubly_weak_hash_table_p),
rdelim.c (scm_read_delimited_x), strop.c (scm_string_index),
symbols.c (scm_symbol_interned_p), numbers.c
(scm_string_to_number), ports.c (scm_port_p): Corrected texinfo
markup.
2001-03-16 10:00:17 +00:00
|
|
|
|
"Remove @var{key} (and any value associated with it) from\n"
|
|
|
|
|
|
"@var{table}. Uses @code{eqv?} for equality tests.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_hashv_remove_x
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2005-03-29 17:47:39 +00:00
|
|
|
|
return scm_hash_fn_remove_x (table, key, scm_ihashv, scm_sloppy_assv, 0);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2000-01-05 19:05:23 +00:00
|
|
|
|
SCM_DEFINE (scm_hash_get_handle, "hash-get-handle", 2, 0, 0,
|
2001-03-30 15:03:23 +00:00
|
|
|
|
(SCM table, SCM key),
|
|
|
|
|
|
"This procedure returns the @code{(key . value)} pair from the\n"
|
|
|
|
|
|
"hash table @var{table}. If @var{table} does not hold an\n"
|
|
|
|
|
|
"associated value for @var{key}, @code{#f} is returned.\n"
|
|
|
|
|
|
"Uses @code{equal?} for equality testing.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_hash_get_handle
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2001-03-30 15:03:23 +00:00
|
|
|
|
return scm_hash_fn_get_handle (table, key, scm_ihash, scm_sloppy_assoc, 0);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
2000-01-05 19:05:23 +00:00
|
|
|
|
SCM_DEFINE (scm_hash_create_handle_x, "hash-create-handle!", 3, 0, 0,
|
2000-03-02 23:41:22 +00:00
|
|
|
|
(SCM table, SCM key, SCM init),
|
|
|
|
|
|
"This function looks up @var{key} in @var{table} and returns its handle.\n"
|
|
|
|
|
|
"If @var{key} is not already present, a new handle is created which\n"
|
|
|
|
|
|
"associates @var{key} with @var{init}.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_hash_create_handle_x
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2000-03-02 23:41:22 +00:00
|
|
|
|
return scm_hash_fn_create_handle_x (table, key, init, scm_ihash, scm_sloppy_assoc, 0);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
2000-01-05 19:05:23 +00:00
|
|
|
|
SCM_DEFINE (scm_hash_ref, "hash-ref", 2, 1, 0,
|
2001-04-03 13:19:05 +00:00
|
|
|
|
(SCM table, SCM key, SCM dflt),
|
2000-03-02 23:41:22 +00:00
|
|
|
|
"Look up @var{key} in the hash table @var{table}, and return the\n"
|
|
|
|
|
|
"value (if any) associated with it. If @var{key} is not found,\n"
|
* list.c (scm_list, scm_cons_star, scm_null_p, scm_list_p),
(scm_length, scm_append, scm_reverse, scm_list_ref),
(scm_memq, scm_memv, scm_member, scm_delv_x, scm_delete_x),
(scm_delq, scm_delv, scm_delete, scm_delq1_x, scm_delv1_x),
(scm_delete1_x), gc.c (scm_map_free_list),
(scm_free_list_length), hash.c (scm_hashq, scm_hashv),
(scm_hash), hashtab.c (scm_hashq_ref, scm_hashq_set_x),
(scm_hashq_remove_x, scm_hashv_ref, scm_hashv_set_x),
(scm_hashv_remove_x, scm_hash_ref, scm_hash_set_x),
(scm_hash_remove_x), ports.c (scm_pt_size, scm_pt_member), print.c
(scm_current_pstate), scmsigs.c (scm_usleep), goops.c
(scm_get_keyword, scm_sys_compute_slots): Added texinfo markup.
* weaks.c (scm_weak_vector_p, scm_weak_key_hash_table_p),
(scm_weak_value_hash_table_p, scm_doubly_weak_hash_table_p),
rdelim.c (scm_read_delimited_x), strop.c (scm_string_index),
symbols.c (scm_symbol_interned_p), numbers.c
(scm_string_to_number), ports.c (scm_port_p): Corrected texinfo
markup.
2001-03-16 10:00:17 +00:00
|
|
|
|
"return @var{default} (or @code{#f} if no @var{default} argument\n"
|
|
|
|
|
|
"is supplied). Uses @code{equal?} for equality testing.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_hash_ref
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2000-04-03 08:47:51 +00:00
|
|
|
|
if (SCM_UNBNDP (dflt))
|
1996-07-25 22:56:11 +00:00
|
|
|
|
dflt = SCM_BOOL_F;
|
2001-04-03 13:19:05 +00:00
|
|
|
|
return scm_hash_fn_ref (table, key, dflt, scm_ihash, scm_sloppy_assoc, 0);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2000-01-05 19:05:23 +00:00
|
|
|
|
SCM_DEFINE (scm_hash_set_x, "hash-set!", 3, 0, 0,
|
2001-04-03 13:19:05 +00:00
|
|
|
|
(SCM table, SCM key, SCM val),
|
* list.c (scm_list, scm_cons_star, scm_null_p, scm_list_p),
(scm_length, scm_append, scm_reverse, scm_list_ref),
(scm_memq, scm_memv, scm_member, scm_delv_x, scm_delete_x),
(scm_delq, scm_delv, scm_delete, scm_delq1_x, scm_delv1_x),
(scm_delete1_x), gc.c (scm_map_free_list),
(scm_free_list_length), hash.c (scm_hashq, scm_hashv),
(scm_hash), hashtab.c (scm_hashq_ref, scm_hashq_set_x),
(scm_hashq_remove_x, scm_hashv_ref, scm_hashv_set_x),
(scm_hashv_remove_x, scm_hash_ref, scm_hash_set_x),
(scm_hash_remove_x), ports.c (scm_pt_size, scm_pt_member), print.c
(scm_current_pstate), scmsigs.c (scm_usleep), goops.c
(scm_get_keyword, scm_sys_compute_slots): Added texinfo markup.
* weaks.c (scm_weak_vector_p, scm_weak_key_hash_table_p),
(scm_weak_value_hash_table_p, scm_doubly_weak_hash_table_p),
rdelim.c (scm_read_delimited_x), strop.c (scm_string_index),
symbols.c (scm_symbol_interned_p), numbers.c
(scm_string_to_number), ports.c (scm_port_p): Corrected texinfo
markup.
2001-03-16 10:00:17 +00:00
|
|
|
|
"Find the entry in @var{table} associated with @var{key}, and\n"
|
|
|
|
|
|
"store @var{value} there. Uses @code{equal?} for equality\n"
|
|
|
|
|
|
"testing.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_hash_set_x
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2001-04-03 13:19:05 +00:00
|
|
|
|
return scm_hash_fn_set_x (table, key, val, scm_ihash, scm_sloppy_assoc, 0);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2000-01-05 19:05:23 +00:00
|
|
|
|
SCM_DEFINE (scm_hash_remove_x, "hash-remove!", 2, 0, 0,
|
2001-04-03 13:19:05 +00:00
|
|
|
|
(SCM table, SCM key),
|
* list.c (scm_list, scm_cons_star, scm_null_p, scm_list_p),
(scm_length, scm_append, scm_reverse, scm_list_ref),
(scm_memq, scm_memv, scm_member, scm_delv_x, scm_delete_x),
(scm_delq, scm_delv, scm_delete, scm_delq1_x, scm_delv1_x),
(scm_delete1_x), gc.c (scm_map_free_list),
(scm_free_list_length), hash.c (scm_hashq, scm_hashv),
(scm_hash), hashtab.c (scm_hashq_ref, scm_hashq_set_x),
(scm_hashq_remove_x, scm_hashv_ref, scm_hashv_set_x),
(scm_hashv_remove_x, scm_hash_ref, scm_hash_set_x),
(scm_hash_remove_x), ports.c (scm_pt_size, scm_pt_member), print.c
(scm_current_pstate), scmsigs.c (scm_usleep), goops.c
(scm_get_keyword, scm_sys_compute_slots): Added texinfo markup.
* weaks.c (scm_weak_vector_p, scm_weak_key_hash_table_p),
(scm_weak_value_hash_table_p, scm_doubly_weak_hash_table_p),
rdelim.c (scm_read_delimited_x), strop.c (scm_string_index),
symbols.c (scm_symbol_interned_p), numbers.c
(scm_string_to_number), ports.c (scm_port_p): Corrected texinfo
markup.
2001-03-16 10:00:17 +00:00
|
|
|
|
"Remove @var{key} (and any value associated with it) from\n"
|
|
|
|
|
|
"@var{table}. Uses @code{equal?} for equality tests.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_hash_remove_x
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2005-03-29 17:47:39 +00:00
|
|
|
|
return scm_hash_fn_remove_x (table, key, scm_ihash, scm_sloppy_assoc, 0);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2001-06-14 19:50:43 +00:00
|
|
|
|
typedef struct scm_t_ihashx_closure
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
|
|
|
|
|
SCM hash;
|
|
|
|
|
|
SCM assoc;
|
2001-06-14 19:50:43 +00:00
|
|
|
|
} scm_t_ihashx_closure;
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
* __scm.h, alist.c, alist.h, append.c, append.h, appinit.c,
arbiters.c, arbiters.h, async.c, async.h, boolean.c, boolean.h,
chars.c, chars.h, continuations.c, continuations.h, debug.c,
debug.h, dynwind.c, dynwind.h, eq.c, eq.h, error.c, eval.c,
eval.h, extchrs.c, extchrs.h, fdsocket.c, fdsocket.h, filesys.c,
filesys.h, fports.c, fports.h, gc.c, gdb_interface.h, gdbint.c,
gdbint.h, genio.c, genio.h, gscm.c, gscm.h, gsubr.c, gsubr.h,
hash.c, hash.h, hashtab.c, hashtab.h, init.c, ioext.c, ioext.h,
kw.c, kw.h, libguile.h, mallocs.c, mallocs.h, markers.c,
markers.h, mbstrings.c, mbstrings.h, numbers.c, numbers.h,
objprop.c, objprop.h, options.c, options.h, pairs.c, pairs.h,
ports.c, ports.h, posix.c, posix.h, print.c, print.h, procprop.c,
procprop.h, procs.c, procs.h, ramap.c, ramap.h, read.c, read.h,
root.c, scmsigs.c, scmsigs.h, sequences.c, sequences.h, simpos.c,
simpos.h, smob.c, socket.c, socket.h, srcprop.c, srcprop.h,
stackchk.c, stackchk.h, stime.c, stime.h, strings.c, strings.h,
strop.c, strop.h, strorder.c, strorder.h, strports.c, strports.h,
struct.c, struct.h, symbols.c, symbols.h, tag.c, tag.h, unif.c,
unif.h, variable.c, variable.h, vectors.c, vectors.h, version.c,
version.h, vports.c, vports.h, weaks.c, weaks.h: Use SCM_P to
declare functions with prototypes. (Patch thanks to Marius
Vollmer.)
1996-10-14 01:33:50 +00:00
|
|
|
|
|
2001-05-26 20:51:22 +00:00
|
|
|
|
static unsigned long
|
2001-06-14 19:50:43 +00:00
|
|
|
|
scm_ihashx (SCM obj, unsigned long n, scm_t_ihashx_closure *closure)
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
* numbers.h, numbers.c, discouraged.h, discouraged.c (scm_short2num,
scm_ushort2num, scm_int2num, scm_uint2num, scm_long2num,
scm_ulong2num, scm_size2num, scm_ptrdiff2num, scm_num2short,
scm_num2ushort, scm_num2int, scm_num2uint, scm_num2long,
scm_num2ulong, scm_num2size, scm_num2ptrdiff, scm_long_long2num,
scm_ulong_long2num, scm_num2long_long, scm_num2ulong_long):
Discouraged by moving to discouraged.h and discouraged.c and
reimplementing in terms of scm_from_* and scm_to_*. Changed all uses
to the new scm_from_* and scm_to_* functions.
2004-08-02 16:14:04 +00:00
|
|
|
|
SCM answer = scm_call_2 (closure->hash, obj, scm_from_ulong (n));
|
* validate.h, deprecated.h (SCM_VALIDATE_INUM, SCM_VALIDATE_INUM_COPY,
SCM_VALIDATE_BIGINT, SCM_VALIDATE_INUM_MIN,
SCM_VALIDATE_INUM_MIN_COPY,
SCM_VALIDATE_INUM_MIN_DEF_COPY,SCM_VALIDATE_INUM_DEF,
SCM_VALIDATE_INUM_DEF_COPY, SCM_VALIDATE_INUM_RANGE,
SCM_VALIDATE_INUM_RANGE_COPY): Deprecated because they make the
fixnum/bignum distinction visible. Changed all uses to scm_to_size_t
or similar.
2004-07-10 14:35:36 +00:00
|
|
|
|
return scm_to_ulong (answer);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
* __scm.h, alist.c, alist.h, append.c, append.h, appinit.c,
arbiters.c, arbiters.h, async.c, async.h, boolean.c, boolean.h,
chars.c, chars.h, continuations.c, continuations.h, debug.c,
debug.h, dynwind.c, dynwind.h, eq.c, eq.h, error.c, eval.c,
eval.h, extchrs.c, extchrs.h, fdsocket.c, fdsocket.h, filesys.c,
filesys.h, fports.c, fports.h, gc.c, gdb_interface.h, gdbint.c,
gdbint.h, genio.c, genio.h, gscm.c, gscm.h, gsubr.c, gsubr.h,
hash.c, hash.h, hashtab.c, hashtab.h, init.c, ioext.c, ioext.h,
kw.c, kw.h, libguile.h, mallocs.c, mallocs.h, markers.c,
markers.h, mbstrings.c, mbstrings.h, numbers.c, numbers.h,
objprop.c, objprop.h, options.c, options.h, pairs.c, pairs.h,
ports.c, ports.h, posix.c, posix.h, print.c, print.h, procprop.c,
procprop.h, procs.c, procs.h, ramap.c, ramap.h, read.c, read.h,
root.c, scmsigs.c, scmsigs.h, sequences.c, sequences.h, simpos.c,
simpos.h, smob.c, socket.c, socket.h, srcprop.c, srcprop.h,
stackchk.c, stackchk.h, stime.c, stime.h, strings.c, strings.h,
strop.c, strop.h, strorder.c, strorder.h, strports.c, strports.h,
struct.c, struct.h, symbols.c, symbols.h, tag.c, tag.h, unif.c,
unif.h, variable.c, variable.h, vectors.c, vectors.h, version.c,
version.h, vports.c, vports.h, weaks.c, weaks.h: Use SCM_P to
declare functions with prototypes. (Patch thanks to Marius
Vollmer.)
1996-10-14 01:33:50 +00:00
|
|
|
|
|
1996-07-25 22:56:11 +00:00
|
|
|
|
static SCM
|
2001-06-14 19:50:43 +00:00
|
|
|
|
scm_sloppy_assx (SCM obj, SCM alist, scm_t_ihashx_closure *closure)
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2003-02-12 09:55:10 +00:00
|
|
|
|
return scm_call_2 (closure->assoc, obj, alist);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2000-01-05 19:05:23 +00:00
|
|
|
|
SCM_DEFINE (scm_hashx_get_handle, "hashx-get-handle", 4, 0, 0,
|
2001-04-03 13:19:05 +00:00
|
|
|
|
(SCM hash, SCM assoc, SCM table, SCM key),
|
|
|
|
|
|
"This behaves the same way as the corresponding\n"
|
|
|
|
|
|
"@code{-get-handle} function, but uses @var{hash} as a hash\n"
|
|
|
|
|
|
"function and @var{assoc} to compare keys. @code{hash} must be\n"
|
|
|
|
|
|
"a function that takes two arguments, a key to be hashed and a\n"
|
2000-03-02 23:41:22 +00:00
|
|
|
|
"table size. @code{assoc} must be an associator function, like\n"
|
|
|
|
|
|
"@code{assoc}, @code{assq} or @code{assv}.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_hashx_get_handle
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2001-06-14 19:50:43 +00:00
|
|
|
|
scm_t_ihashx_closure closure;
|
1996-07-25 22:56:11 +00:00
|
|
|
|
closure.hash = hash;
|
|
|
|
|
|
closure.assoc = assoc;
|
2001-04-03 13:19:05 +00:00
|
|
|
|
return scm_hash_fn_get_handle (table, key, scm_ihashx, scm_sloppy_assx,
|
2003-02-12 09:55:10 +00:00
|
|
|
|
(void *) &closure);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
2000-01-05 19:05:23 +00:00
|
|
|
|
SCM_DEFINE (scm_hashx_create_handle_x, "hashx-create-handle!", 5, 0, 0,
|
2001-04-03 13:19:05 +00:00
|
|
|
|
(SCM hash, SCM assoc, SCM table, SCM key, SCM init),
|
|
|
|
|
|
"This behaves the same way as the corresponding\n"
|
|
|
|
|
|
"@code{-create-handle} function, but uses @var{hash} as a hash\n"
|
|
|
|
|
|
"function and @var{assoc} to compare keys. @code{hash} must be\n"
|
|
|
|
|
|
"a function that takes two arguments, a key to be hashed and a\n"
|
2000-03-02 23:41:22 +00:00
|
|
|
|
"table size. @code{assoc} must be an associator function, like\n"
|
|
|
|
|
|
"@code{assoc}, @code{assq} or @code{assv}.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_hashx_create_handle_x
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2001-06-14 19:50:43 +00:00
|
|
|
|
scm_t_ihashx_closure closure;
|
1996-07-25 22:56:11 +00:00
|
|
|
|
closure.hash = hash;
|
|
|
|
|
|
closure.assoc = assoc;
|
2001-04-03 13:19:05 +00:00
|
|
|
|
return scm_hash_fn_create_handle_x (table, key, init, scm_ihashx,
|
|
|
|
|
|
scm_sloppy_assx, (void *)&closure);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2000-01-05 19:05:23 +00:00
|
|
|
|
SCM_DEFINE (scm_hashx_ref, "hashx-ref", 4, 1, 0,
|
2001-04-03 13:19:05 +00:00
|
|
|
|
(SCM hash, SCM assoc, SCM table, SCM key, SCM dflt),
|
2000-03-02 23:41:22 +00:00
|
|
|
|
"This behaves the same way as the corresponding @code{ref}\n"
|
2001-04-03 13:19:05 +00:00
|
|
|
|
"function, but uses @var{hash} as a hash function and\n"
|
|
|
|
|
|
"@var{assoc} to compare keys. @code{hash} must be a function\n"
|
|
|
|
|
|
"that takes two arguments, a key to be hashed and a table size.\n"
|
|
|
|
|
|
"@code{assoc} must be an associator function, like @code{assoc},\n"
|
|
|
|
|
|
"@code{assq} or @code{assv}.\n"
|
|
|
|
|
|
"\n"
|
|
|
|
|
|
"By way of illustration, @code{hashq-ref table key} is\n"
|
|
|
|
|
|
"equivalent to @code{hashx-ref hashq assq table key}.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_hashx_ref
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2001-06-14 19:50:43 +00:00
|
|
|
|
scm_t_ihashx_closure closure;
|
2000-04-03 08:47:51 +00:00
|
|
|
|
if (SCM_UNBNDP (dflt))
|
1996-07-25 22:56:11 +00:00
|
|
|
|
dflt = SCM_BOOL_F;
|
|
|
|
|
|
closure.hash = hash;
|
|
|
|
|
|
closure.assoc = assoc;
|
2001-04-03 13:19:05 +00:00
|
|
|
|
return scm_hash_fn_ref (table, key, dflt, scm_ihashx, scm_sloppy_assx,
|
|
|
|
|
|
(void *)&closure);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2000-01-05 19:05:23 +00:00
|
|
|
|
SCM_DEFINE (scm_hashx_set_x, "hashx-set!", 5, 0, 0,
|
2001-04-03 13:19:05 +00:00
|
|
|
|
(SCM hash, SCM assoc, SCM table, SCM key, SCM val),
|
2000-03-02 23:41:22 +00:00
|
|
|
|
"This behaves the same way as the corresponding @code{set!}\n"
|
2001-04-03 13:19:05 +00:00
|
|
|
|
"function, but uses @var{hash} as a hash function and\n"
|
|
|
|
|
|
"@var{assoc} to compare keys. @code{hash} must be a function\n"
|
|
|
|
|
|
"that takes two arguments, a key to be hashed and a table size.\n"
|
|
|
|
|
|
"@code{assoc} must be an associator function, like @code{assoc},\n"
|
|
|
|
|
|
"@code{assq} or @code{assv}.\n"
|
|
|
|
|
|
"\n"
|
|
|
|
|
|
" By way of illustration, @code{hashq-set! table key} is\n"
|
|
|
|
|
|
"equivalent to @code{hashx-set! hashq assq table key}.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_hashx_set_x
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2001-06-14 19:50:43 +00:00
|
|
|
|
scm_t_ihashx_closure closure;
|
1996-07-25 22:56:11 +00:00
|
|
|
|
closure.hash = hash;
|
|
|
|
|
|
closure.assoc = assoc;
|
2001-04-03 13:19:05 +00:00
|
|
|
|
return scm_hash_fn_set_x (table, key, val, scm_ihashx, scm_sloppy_assx,
|
|
|
|
|
|
(void *)&closure);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
2005-03-29 17:47:39 +00:00
|
|
|
|
SCM_DEFINE (scm_hashx_remove_x, "hashx-remove!", 4, 0, 0,
|
|
|
|
|
|
(SCM hash, SCM assoc, SCM table, SCM obj),
|
|
|
|
|
|
"This behaves the same way as the corresponding @code{remove!}\n"
|
|
|
|
|
|
"function, but uses @var{hash} as a hash function and\n"
|
|
|
|
|
|
"@var{assoc} to compare keys. @code{hash} must be a function\n"
|
|
|
|
|
|
"that takes two arguments, a key to be hashed and a table size.\n"
|
|
|
|
|
|
"@code{assoc} must be an associator function, like @code{assoc},\n"
|
|
|
|
|
|
"@code{assq} or @code{assv}.\n"
|
|
|
|
|
|
"\n"
|
|
|
|
|
|
" By way of illustration, @code{hashq-remove! table key} is\n"
|
|
|
|
|
|
"equivalent to @code{hashx-remove! hashq assq #f table key}.")
|
|
|
|
|
|
#define FUNC_NAME s_scm_hashx_remove_x
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2001-06-14 19:50:43 +00:00
|
|
|
|
scm_t_ihashx_closure closure;
|
1996-07-25 22:56:11 +00:00
|
|
|
|
closure.hash = hash;
|
|
|
|
|
|
closure.assoc = assoc;
|
2005-04-22 23:33:15 +00:00
|
|
|
|
return scm_hash_fn_remove_x (table, obj, scm_ihashx, scm_sloppy_assx,
|
|
|
|
|
|
(void *) &closure);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
2005-03-29 17:47:39 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
2004-02-13 23:15:37 +00:00
|
|
|
|
/* Hash table iterators */
|
1999-07-31 09:04:46 +00:00
|
|
|
|
|
2004-02-13 23:15:37 +00:00
|
|
|
|
static const char s_scm_hash_fold[];
|
1999-03-14 16:48:50 +00:00
|
|
|
|
|
|
|
|
|
|
SCM
|
1999-03-21 05:02:42 +00:00
|
|
|
|
scm_internal_hash_fold (SCM (*fn) (), void *closure, SCM init, SCM table)
|
1999-03-14 16:48:50 +00:00
|
|
|
|
{
|
2003-02-12 09:55:10 +00:00
|
|
|
|
long i, n;
|
|
|
|
|
|
SCM buckets, result = init;
|
|
|
|
|
|
|
|
|
|
|
|
if (SCM_HASHTABLE_P (table))
|
2003-02-13 10:42:59 +00:00
|
|
|
|
buckets = SCM_HASHTABLE_VECTOR (table);
|
2003-02-12 09:55:10 +00:00
|
|
|
|
else
|
2003-02-13 10:42:59 +00:00
|
|
|
|
buckets = table;
|
|
|
|
|
|
|
2005-01-02 20:11:15 +00:00
|
|
|
|
n = SCM_SIMPLE_VECTOR_LENGTH (buckets);
|
1999-03-14 16:48:50 +00:00
|
|
|
|
for (i = 0; i < n; ++i)
|
|
|
|
|
|
{
|
2005-01-02 20:11:15 +00:00
|
|
|
|
SCM ls = SCM_SIMPLE_VECTOR_REF (buckets, i), handle;
|
2004-09-22 17:41:37 +00:00
|
|
|
|
while (!scm_is_null (ls))
|
1999-03-14 16:48:50 +00:00
|
|
|
|
{
|
2004-09-22 17:41:37 +00:00
|
|
|
|
if (!scm_is_pair (ls))
|
2003-02-13 10:42:59 +00:00
|
|
|
|
scm_wrong_type_arg (s_scm_hash_fold, SCM_ARG3, buckets);
|
1999-03-14 16:48:50 +00:00
|
|
|
|
handle = SCM_CAR (ls);
|
2004-09-22 17:41:37 +00:00
|
|
|
|
if (!scm_is_pair (handle))
|
2003-02-13 10:42:59 +00:00
|
|
|
|
scm_wrong_type_arg (s_scm_hash_fold, SCM_ARG3, buckets);
|
1999-03-14 16:48:50 +00:00
|
|
|
|
result = fn (closure, SCM_CAR (handle), SCM_CDR (handle), result);
|
|
|
|
|
|
ls = SCM_CDR (ls);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2003-02-12 09:55:10 +00:00
|
|
|
|
|
1999-03-14 16:48:50 +00:00
|
|
|
|
return result;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2004-02-13 23:15:37 +00:00
|
|
|
|
/* The following redundant code is here in order to be able to support
|
|
|
|
|
|
hash-for-each-handle. An alternative would have been to replace
|
|
|
|
|
|
this code and scm_internal_hash_fold above with a single
|
|
|
|
|
|
scm_internal_hash_fold_handles, but we don't want to promote such
|
|
|
|
|
|
an API. */
|
|
|
|
|
|
|
|
|
|
|
|
static const char s_scm_hash_for_each[];
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
|
scm_internal_hash_for_each_handle (SCM (*fn) (), void *closure, SCM table)
|
|
|
|
|
|
{
|
|
|
|
|
|
long i, n;
|
|
|
|
|
|
SCM buckets;
|
|
|
|
|
|
|
|
|
|
|
|
if (SCM_HASHTABLE_P (table))
|
|
|
|
|
|
buckets = SCM_HASHTABLE_VECTOR (table);
|
|
|
|
|
|
else
|
|
|
|
|
|
buckets = table;
|
|
|
|
|
|
|
2005-01-02 20:11:15 +00:00
|
|
|
|
n = SCM_SIMPLE_VECTOR_LENGTH (buckets);
|
2004-02-13 23:15:37 +00:00
|
|
|
|
for (i = 0; i < n; ++i)
|
|
|
|
|
|
{
|
2005-01-02 20:11:15 +00:00
|
|
|
|
SCM ls = SCM_SIMPLE_VECTOR_REF (buckets, i), handle;
|
2004-09-22 17:41:37 +00:00
|
|
|
|
while (!scm_is_null (ls))
|
2004-02-13 23:15:37 +00:00
|
|
|
|
{
|
2004-09-22 17:41:37 +00:00
|
|
|
|
if (!scm_is_pair (ls))
|
2004-02-13 23:15:37 +00:00
|
|
|
|
scm_wrong_type_arg (s_scm_hash_for_each, SCM_ARG3, buckets);
|
|
|
|
|
|
handle = SCM_CAR (ls);
|
2004-09-22 17:41:37 +00:00
|
|
|
|
if (!scm_is_pair (handle))
|
2004-02-13 23:15:37 +00:00
|
|
|
|
scm_wrong_type_arg (s_scm_hash_for_each, SCM_ARG3, buckets);
|
|
|
|
|
|
fn (closure, handle);
|
|
|
|
|
|
ls = SCM_CDR (ls);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SCM_DEFINE (scm_hash_fold, "hash-fold", 3, 0, 0,
|
|
|
|
|
|
(SCM proc, SCM init, SCM table),
|
|
|
|
|
|
"An iterator over hash-table elements.\n"
|
|
|
|
|
|
"Accumulates and returns a result by applying PROC successively.\n"
|
|
|
|
|
|
"The arguments to PROC are \"(key value prior-result)\" where key\n"
|
|
|
|
|
|
"and value are successive pairs from the hash table TABLE, and\n"
|
|
|
|
|
|
"prior-result is either INIT (for the first application of PROC)\n"
|
|
|
|
|
|
"or the return value of the previous application of PROC.\n"
|
|
|
|
|
|
"For example, @code{(hash-fold acons '() tab)} will convert a hash\n"
|
|
|
|
|
|
"table into an a-list of key-value pairs.")
|
|
|
|
|
|
#define FUNC_NAME s_scm_hash_fold
|
|
|
|
|
|
{
|
|
|
|
|
|
SCM_VALIDATE_PROC (1, proc);
|
|
|
|
|
|
if (!SCM_HASHTABLE_P (table))
|
|
|
|
|
|
SCM_VALIDATE_VECTOR (3, table);
|
|
|
|
|
|
return scm_internal_hash_fold (scm_call_3, (void *) SCM_UNPACK (proc), init, table);
|
|
|
|
|
|
}
|
|
|
|
|
|
#undef FUNC_NAME
|
|
|
|
|
|
|
* hooks.c (scm_c_hook_add): Fixed bug in append mode.
* environments.c (obarray_enter, obarray_retrieve, obarray_remove,
leaf_environment_fold, obarray_remove_all): Use hashtable
accessors.
* gc.c (scm_init_storage): Moved hook initialization to
scm_storage_prehistory.
(scm_storage_prehistory): New function.
(scm_igc): Added commentary about placement of
scm_after_sweep_c_hook.
* gc-mark.c (scm_mark_all): Use hashtable accessors.
(scm_gc_mark_dependencies): Use SCM_WVECT_WEAK_KEY_P and
SCM_WVECT_WEAK_VALUE_P.
* hashtab.c, hashtab.h (scm_hash_for_each, scm_hash_map): New
functions.
(scm_vector_to_hash_table, scm_c_make_resizing_hash_table):
Removed.
(scm_make_weak_key_hash_table, scm_make_weak_value_hash_table,
scm_make_doubly_weak_hash_table): Moved here from weaks.c.
* init.c (scm_init_guile_1): Removed call to scm_init_weaks; Added
calls to scm_storage_prehistory and scm_hashtab_prehistory.
* modules.c (module-reverse-lookup): Use hashtable accessors.
* symbols.c, symbols.h (scm_i_hash_symbol): New function.
* weaks.c, weaks.h (scm_make_weak_key_alist_vector,
scm_make_weak_value_alist_vector,
scm_make_doubly_weak_alist_vector): New functions.
* weaks.c (scm_init_weaks_builtins): New function.
* weaks.h (SCM_WVECTF_WEAK_KEY, SCM_WVECTF_WEAK_VALUE,
SCM_WVECTF_NOSCAN, SCM_WVECT_WEAK_KEY_P, SCM_WVECT_WEAK_VALUE_P,
SCM_WVECT_NOSCAN_P): New macros.
* weaks.c (scm_scan_weak_vectors): Use SCM_WVECT_WEAK_KEY_P
and SCM_WVECT_WEAK_VALUE_P.
* weaks.c, weaks.h (scm_i_allocate_weak_vector): Renamed from
allocate_weak_vector and exported.
* Makefile.am (ice9_sources): Added weak-vector.scm.
* weak-vector.scm: New file.
* boot-9.scm (module-clear!): Use hash-clear!.
(module-for-each): Use hash-for-each.
(module-map): Use hash-map.
2003-02-19 15:04:51 +00:00
|
|
|
|
static SCM
|
2004-02-13 23:15:37 +00:00
|
|
|
|
for_each_proc (void *proc, SCM handle)
|
* hooks.c (scm_c_hook_add): Fixed bug in append mode.
* environments.c (obarray_enter, obarray_retrieve, obarray_remove,
leaf_environment_fold, obarray_remove_all): Use hashtable
accessors.
* gc.c (scm_init_storage): Moved hook initialization to
scm_storage_prehistory.
(scm_storage_prehistory): New function.
(scm_igc): Added commentary about placement of
scm_after_sweep_c_hook.
* gc-mark.c (scm_mark_all): Use hashtable accessors.
(scm_gc_mark_dependencies): Use SCM_WVECT_WEAK_KEY_P and
SCM_WVECT_WEAK_VALUE_P.
* hashtab.c, hashtab.h (scm_hash_for_each, scm_hash_map): New
functions.
(scm_vector_to_hash_table, scm_c_make_resizing_hash_table):
Removed.
(scm_make_weak_key_hash_table, scm_make_weak_value_hash_table,
scm_make_doubly_weak_hash_table): Moved here from weaks.c.
* init.c (scm_init_guile_1): Removed call to scm_init_weaks; Added
calls to scm_storage_prehistory and scm_hashtab_prehistory.
* modules.c (module-reverse-lookup): Use hashtable accessors.
* symbols.c, symbols.h (scm_i_hash_symbol): New function.
* weaks.c, weaks.h (scm_make_weak_key_alist_vector,
scm_make_weak_value_alist_vector,
scm_make_doubly_weak_alist_vector): New functions.
* weaks.c (scm_init_weaks_builtins): New function.
* weaks.h (SCM_WVECTF_WEAK_KEY, SCM_WVECTF_WEAK_VALUE,
SCM_WVECTF_NOSCAN, SCM_WVECT_WEAK_KEY_P, SCM_WVECT_WEAK_VALUE_P,
SCM_WVECT_NOSCAN_P): New macros.
* weaks.c (scm_scan_weak_vectors): Use SCM_WVECT_WEAK_KEY_P
and SCM_WVECT_WEAK_VALUE_P.
* weaks.c, weaks.h (scm_i_allocate_weak_vector): Renamed from
allocate_weak_vector and exported.
* Makefile.am (ice9_sources): Added weak-vector.scm.
* weak-vector.scm: New file.
* boot-9.scm (module-clear!): Use hash-clear!.
(module-for-each): Use hash-for-each.
(module-map): Use hash-map.
2003-02-19 15:04:51 +00:00
|
|
|
|
{
|
2004-02-13 23:15:37 +00:00
|
|
|
|
return scm_call_2 (SCM_PACK (proc), SCM_CAR (handle), SCM_CDR (handle));
|
* hooks.c (scm_c_hook_add): Fixed bug in append mode.
* environments.c (obarray_enter, obarray_retrieve, obarray_remove,
leaf_environment_fold, obarray_remove_all): Use hashtable
accessors.
* gc.c (scm_init_storage): Moved hook initialization to
scm_storage_prehistory.
(scm_storage_prehistory): New function.
(scm_igc): Added commentary about placement of
scm_after_sweep_c_hook.
* gc-mark.c (scm_mark_all): Use hashtable accessors.
(scm_gc_mark_dependencies): Use SCM_WVECT_WEAK_KEY_P and
SCM_WVECT_WEAK_VALUE_P.
* hashtab.c, hashtab.h (scm_hash_for_each, scm_hash_map): New
functions.
(scm_vector_to_hash_table, scm_c_make_resizing_hash_table):
Removed.
(scm_make_weak_key_hash_table, scm_make_weak_value_hash_table,
scm_make_doubly_weak_hash_table): Moved here from weaks.c.
* init.c (scm_init_guile_1): Removed call to scm_init_weaks; Added
calls to scm_storage_prehistory and scm_hashtab_prehistory.
* modules.c (module-reverse-lookup): Use hashtable accessors.
* symbols.c, symbols.h (scm_i_hash_symbol): New function.
* weaks.c, weaks.h (scm_make_weak_key_alist_vector,
scm_make_weak_value_alist_vector,
scm_make_doubly_weak_alist_vector): New functions.
* weaks.c (scm_init_weaks_builtins): New function.
* weaks.h (SCM_WVECTF_WEAK_KEY, SCM_WVECTF_WEAK_VALUE,
SCM_WVECTF_NOSCAN, SCM_WVECT_WEAK_KEY_P, SCM_WVECT_WEAK_VALUE_P,
SCM_WVECT_NOSCAN_P): New macros.
* weaks.c (scm_scan_weak_vectors): Use SCM_WVECT_WEAK_KEY_P
and SCM_WVECT_WEAK_VALUE_P.
* weaks.c, weaks.h (scm_i_allocate_weak_vector): Renamed from
allocate_weak_vector and exported.
* Makefile.am (ice9_sources): Added weak-vector.scm.
* weak-vector.scm: New file.
* boot-9.scm (module-clear!): Use hash-clear!.
(module-for-each): Use hash-for-each.
(module-map): Use hash-map.
2003-02-19 15:04:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SCM_DEFINE (scm_hash_for_each, "hash-for-each", 2, 0, 0,
|
|
|
|
|
|
(SCM proc, SCM table),
|
|
|
|
|
|
"An iterator over hash-table elements.\n"
|
|
|
|
|
|
"Applies PROC successively on all hash table items.\n"
|
|
|
|
|
|
"The arguments to PROC are \"(key value)\" where key\n"
|
|
|
|
|
|
"and value are successive pairs from the hash table TABLE.")
|
|
|
|
|
|
#define FUNC_NAME s_scm_hash_for_each
|
|
|
|
|
|
{
|
|
|
|
|
|
SCM_VALIDATE_PROC (1, proc);
|
|
|
|
|
|
if (!SCM_HASHTABLE_P (table))
|
|
|
|
|
|
SCM_VALIDATE_VECTOR (2, table);
|
2004-02-13 23:15:37 +00:00
|
|
|
|
|
|
|
|
|
|
scm_internal_hash_for_each_handle (for_each_proc,
|
|
|
|
|
|
(void *) SCM_UNPACK (proc),
|
|
|
|
|
|
table);
|
|
|
|
|
|
return SCM_UNSPECIFIED;
|
|
|
|
|
|
}
|
|
|
|
|
|
#undef FUNC_NAME
|
|
|
|
|
|
|
|
|
|
|
|
SCM_DEFINE (scm_hash_for_each_handle, "hash-for-each-handle", 2, 0, 0,
|
|
|
|
|
|
(SCM proc, SCM table),
|
|
|
|
|
|
"An iterator over hash-table elements.\n"
|
|
|
|
|
|
"Applies PROC successively on all hash table handles.")
|
|
|
|
|
|
#define FUNC_NAME s_scm_hash_for_each_handle
|
|
|
|
|
|
{
|
|
|
|
|
|
scm_t_trampoline_1 call = scm_trampoline_1 (proc);
|
|
|
|
|
|
SCM_ASSERT (call, proc, 1, FUNC_NAME);
|
|
|
|
|
|
if (!SCM_HASHTABLE_P (table))
|
|
|
|
|
|
SCM_VALIDATE_VECTOR (2, table);
|
|
|
|
|
|
|
|
|
|
|
|
scm_internal_hash_for_each_handle (call,
|
|
|
|
|
|
(void *) SCM_UNPACK (proc),
|
|
|
|
|
|
table);
|
* hooks.c (scm_c_hook_add): Fixed bug in append mode.
* environments.c (obarray_enter, obarray_retrieve, obarray_remove,
leaf_environment_fold, obarray_remove_all): Use hashtable
accessors.
* gc.c (scm_init_storage): Moved hook initialization to
scm_storage_prehistory.
(scm_storage_prehistory): New function.
(scm_igc): Added commentary about placement of
scm_after_sweep_c_hook.
* gc-mark.c (scm_mark_all): Use hashtable accessors.
(scm_gc_mark_dependencies): Use SCM_WVECT_WEAK_KEY_P and
SCM_WVECT_WEAK_VALUE_P.
* hashtab.c, hashtab.h (scm_hash_for_each, scm_hash_map): New
functions.
(scm_vector_to_hash_table, scm_c_make_resizing_hash_table):
Removed.
(scm_make_weak_key_hash_table, scm_make_weak_value_hash_table,
scm_make_doubly_weak_hash_table): Moved here from weaks.c.
* init.c (scm_init_guile_1): Removed call to scm_init_weaks; Added
calls to scm_storage_prehistory and scm_hashtab_prehistory.
* modules.c (module-reverse-lookup): Use hashtable accessors.
* symbols.c, symbols.h (scm_i_hash_symbol): New function.
* weaks.c, weaks.h (scm_make_weak_key_alist_vector,
scm_make_weak_value_alist_vector,
scm_make_doubly_weak_alist_vector): New functions.
* weaks.c (scm_init_weaks_builtins): New function.
* weaks.h (SCM_WVECTF_WEAK_KEY, SCM_WVECTF_WEAK_VALUE,
SCM_WVECTF_NOSCAN, SCM_WVECT_WEAK_KEY_P, SCM_WVECT_WEAK_VALUE_P,
SCM_WVECT_NOSCAN_P): New macros.
* weaks.c (scm_scan_weak_vectors): Use SCM_WVECT_WEAK_KEY_P
and SCM_WVECT_WEAK_VALUE_P.
* weaks.c, weaks.h (scm_i_allocate_weak_vector): Renamed from
allocate_weak_vector and exported.
* Makefile.am (ice9_sources): Added weak-vector.scm.
* weak-vector.scm: New file.
* boot-9.scm (module-clear!): Use hash-clear!.
(module-for-each): Use hash-for-each.
(module-map): Use hash-map.
2003-02-19 15:04:51 +00:00
|
|
|
|
return SCM_UNSPECIFIED;
|
|
|
|
|
|
}
|
|
|
|
|
|
#undef FUNC_NAME
|
|
|
|
|
|
|
|
|
|
|
|
static SCM
|
|
|
|
|
|
map_proc (void *proc, SCM key, SCM data, SCM value)
|
|
|
|
|
|
{
|
|
|
|
|
|
return scm_cons (scm_call_2 (SCM_PACK (proc), key, data), value);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2004-02-13 23:15:37 +00:00
|
|
|
|
SCM_DEFINE (scm_hash_map_to_list, "hash-map->list", 2, 0, 0,
|
* hooks.c (scm_c_hook_add): Fixed bug in append mode.
* environments.c (obarray_enter, obarray_retrieve, obarray_remove,
leaf_environment_fold, obarray_remove_all): Use hashtable
accessors.
* gc.c (scm_init_storage): Moved hook initialization to
scm_storage_prehistory.
(scm_storage_prehistory): New function.
(scm_igc): Added commentary about placement of
scm_after_sweep_c_hook.
* gc-mark.c (scm_mark_all): Use hashtable accessors.
(scm_gc_mark_dependencies): Use SCM_WVECT_WEAK_KEY_P and
SCM_WVECT_WEAK_VALUE_P.
* hashtab.c, hashtab.h (scm_hash_for_each, scm_hash_map): New
functions.
(scm_vector_to_hash_table, scm_c_make_resizing_hash_table):
Removed.
(scm_make_weak_key_hash_table, scm_make_weak_value_hash_table,
scm_make_doubly_weak_hash_table): Moved here from weaks.c.
* init.c (scm_init_guile_1): Removed call to scm_init_weaks; Added
calls to scm_storage_prehistory and scm_hashtab_prehistory.
* modules.c (module-reverse-lookup): Use hashtable accessors.
* symbols.c, symbols.h (scm_i_hash_symbol): New function.
* weaks.c, weaks.h (scm_make_weak_key_alist_vector,
scm_make_weak_value_alist_vector,
scm_make_doubly_weak_alist_vector): New functions.
* weaks.c (scm_init_weaks_builtins): New function.
* weaks.h (SCM_WVECTF_WEAK_KEY, SCM_WVECTF_WEAK_VALUE,
SCM_WVECTF_NOSCAN, SCM_WVECT_WEAK_KEY_P, SCM_WVECT_WEAK_VALUE_P,
SCM_WVECT_NOSCAN_P): New macros.
* weaks.c (scm_scan_weak_vectors): Use SCM_WVECT_WEAK_KEY_P
and SCM_WVECT_WEAK_VALUE_P.
* weaks.c, weaks.h (scm_i_allocate_weak_vector): Renamed from
allocate_weak_vector and exported.
* Makefile.am (ice9_sources): Added weak-vector.scm.
* weak-vector.scm: New file.
* boot-9.scm (module-clear!): Use hash-clear!.
(module-for-each): Use hash-for-each.
(module-map): Use hash-map.
2003-02-19 15:04:51 +00:00
|
|
|
|
(SCM proc, SCM table),
|
|
|
|
|
|
"An iterator over hash-table elements.\n"
|
|
|
|
|
|
"Accumulates and returns as a list the results of applying PROC successively.\n"
|
|
|
|
|
|
"The arguments to PROC are \"(key value)\" where key\n"
|
|
|
|
|
|
"and value are successive pairs from the hash table TABLE.")
|
2004-02-13 23:15:37 +00:00
|
|
|
|
#define FUNC_NAME s_scm_hash_map_to_list
|
* hooks.c (scm_c_hook_add): Fixed bug in append mode.
* environments.c (obarray_enter, obarray_retrieve, obarray_remove,
leaf_environment_fold, obarray_remove_all): Use hashtable
accessors.
* gc.c (scm_init_storage): Moved hook initialization to
scm_storage_prehistory.
(scm_storage_prehistory): New function.
(scm_igc): Added commentary about placement of
scm_after_sweep_c_hook.
* gc-mark.c (scm_mark_all): Use hashtable accessors.
(scm_gc_mark_dependencies): Use SCM_WVECT_WEAK_KEY_P and
SCM_WVECT_WEAK_VALUE_P.
* hashtab.c, hashtab.h (scm_hash_for_each, scm_hash_map): New
functions.
(scm_vector_to_hash_table, scm_c_make_resizing_hash_table):
Removed.
(scm_make_weak_key_hash_table, scm_make_weak_value_hash_table,
scm_make_doubly_weak_hash_table): Moved here from weaks.c.
* init.c (scm_init_guile_1): Removed call to scm_init_weaks; Added
calls to scm_storage_prehistory and scm_hashtab_prehistory.
* modules.c (module-reverse-lookup): Use hashtable accessors.
* symbols.c, symbols.h (scm_i_hash_symbol): New function.
* weaks.c, weaks.h (scm_make_weak_key_alist_vector,
scm_make_weak_value_alist_vector,
scm_make_doubly_weak_alist_vector): New functions.
* weaks.c (scm_init_weaks_builtins): New function.
* weaks.h (SCM_WVECTF_WEAK_KEY, SCM_WVECTF_WEAK_VALUE,
SCM_WVECTF_NOSCAN, SCM_WVECT_WEAK_KEY_P, SCM_WVECT_WEAK_VALUE_P,
SCM_WVECT_NOSCAN_P): New macros.
* weaks.c (scm_scan_weak_vectors): Use SCM_WVECT_WEAK_KEY_P
and SCM_WVECT_WEAK_VALUE_P.
* weaks.c, weaks.h (scm_i_allocate_weak_vector): Renamed from
allocate_weak_vector and exported.
* Makefile.am (ice9_sources): Added weak-vector.scm.
* weak-vector.scm: New file.
* boot-9.scm (module-clear!): Use hash-clear!.
(module-for-each): Use hash-for-each.
(module-map): Use hash-map.
2003-02-19 15:04:51 +00:00
|
|
|
|
{
|
|
|
|
|
|
SCM_VALIDATE_PROC (1, proc);
|
|
|
|
|
|
if (!SCM_HASHTABLE_P (table))
|
|
|
|
|
|
SCM_VALIDATE_VECTOR (2, table);
|
|
|
|
|
|
return scm_internal_hash_fold (map_proc,
|
|
|
|
|
|
(void *) SCM_UNPACK (proc),
|
|
|
|
|
|
SCM_EOL,
|
|
|
|
|
|
table);
|
|
|
|
|
|
}
|
|
|
|
|
|
#undef FUNC_NAME
|
|
|
|
|
|
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
* __scm.h, alist.c, alist.h, append.c, append.h, appinit.c,
arbiters.c, arbiters.h, async.c, async.h, boolean.c, boolean.h,
chars.c, chars.h, continuations.c, continuations.h, debug.c,
debug.h, dynwind.c, dynwind.h, eq.c, eq.h, error.c, eval.c,
eval.h, extchrs.c, extchrs.h, fdsocket.c, fdsocket.h, filesys.c,
filesys.h, fports.c, fports.h, gc.c, gdb_interface.h, gdbint.c,
gdbint.h, genio.c, genio.h, gscm.c, gscm.h, gsubr.c, gsubr.h,
hash.c, hash.h, hashtab.c, hashtab.h, init.c, ioext.c, ioext.h,
kw.c, kw.h, libguile.h, mallocs.c, mallocs.h, markers.c,
markers.h, mbstrings.c, mbstrings.h, numbers.c, numbers.h,
objprop.c, objprop.h, options.c, options.h, pairs.c, pairs.h,
ports.c, ports.h, posix.c, posix.h, print.c, print.h, procprop.c,
procprop.h, procs.c, procs.h, ramap.c, ramap.h, read.c, read.h,
root.c, scmsigs.c, scmsigs.h, sequences.c, sequences.h, simpos.c,
simpos.h, smob.c, socket.c, socket.h, srcprop.c, srcprop.h,
stackchk.c, stackchk.h, stime.c, stime.h, strings.c, strings.h,
strop.c, strop.h, strorder.c, strorder.h, strports.c, strports.h,
struct.c, struct.h, symbols.c, symbols.h, tag.c, tag.h, unif.c,
unif.h, variable.c, variable.h, vectors.c, vectors.h, version.c,
version.h, vports.c, vports.h, weaks.c, weaks.h: Use SCM_P to
declare functions with prototypes. (Patch thanks to Marius
Vollmer.)
1996-10-14 01:33:50 +00:00
|
|
|
|
|
1996-07-25 22:56:11 +00:00
|
|
|
|
void
|
* hooks.c (scm_c_hook_add): Fixed bug in append mode.
* environments.c (obarray_enter, obarray_retrieve, obarray_remove,
leaf_environment_fold, obarray_remove_all): Use hashtable
accessors.
* gc.c (scm_init_storage): Moved hook initialization to
scm_storage_prehistory.
(scm_storage_prehistory): New function.
(scm_igc): Added commentary about placement of
scm_after_sweep_c_hook.
* gc-mark.c (scm_mark_all): Use hashtable accessors.
(scm_gc_mark_dependencies): Use SCM_WVECT_WEAK_KEY_P and
SCM_WVECT_WEAK_VALUE_P.
* hashtab.c, hashtab.h (scm_hash_for_each, scm_hash_map): New
functions.
(scm_vector_to_hash_table, scm_c_make_resizing_hash_table):
Removed.
(scm_make_weak_key_hash_table, scm_make_weak_value_hash_table,
scm_make_doubly_weak_hash_table): Moved here from weaks.c.
* init.c (scm_init_guile_1): Removed call to scm_init_weaks; Added
calls to scm_storage_prehistory and scm_hashtab_prehistory.
* modules.c (module-reverse-lookup): Use hashtable accessors.
* symbols.c, symbols.h (scm_i_hash_symbol): New function.
* weaks.c, weaks.h (scm_make_weak_key_alist_vector,
scm_make_weak_value_alist_vector,
scm_make_doubly_weak_alist_vector): New functions.
* weaks.c (scm_init_weaks_builtins): New function.
* weaks.h (SCM_WVECTF_WEAK_KEY, SCM_WVECTF_WEAK_VALUE,
SCM_WVECTF_NOSCAN, SCM_WVECT_WEAK_KEY_P, SCM_WVECT_WEAK_VALUE_P,
SCM_WVECT_NOSCAN_P): New macros.
* weaks.c (scm_scan_weak_vectors): Use SCM_WVECT_WEAK_KEY_P
and SCM_WVECT_WEAK_VALUE_P.
* weaks.c, weaks.h (scm_i_allocate_weak_vector): Renamed from
allocate_weak_vector and exported.
* Makefile.am (ice9_sources): Added weak-vector.scm.
* weak-vector.scm: New file.
* boot-9.scm (module-clear!): Use hash-clear!.
(module-for-each): Use hash-for-each.
(module-map): Use hash-map.
2003-02-19 15:04:51 +00:00
|
|
|
|
scm_hashtab_prehistory ()
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2006-04-09 16:13:01 +00:00
|
|
|
|
/* Initialize weak cells. */
|
|
|
|
|
|
GC_word wcar_cell_bitmap[GC_BITMAP_SIZE (scm_t_cell)] = { 0 };
|
|
|
|
|
|
GC_word wcdr_cell_bitmap[GC_BITMAP_SIZE (scm_t_cell)] = { 0 };
|
|
|
|
|
|
|
|
|
|
|
|
/* In a weak-car cell, only the second word must be scanned for
|
|
|
|
|
|
pointers. */
|
|
|
|
|
|
GC_set_bit (wcar_cell_bitmap, GC_WORD_OFFSET (scm_t_cell, word_1));
|
|
|
|
|
|
wcar_cell_descr = GC_make_descriptor (wcar_cell_bitmap,
|
|
|
|
|
|
GC_WORD_LEN (scm_t_cell));
|
|
|
|
|
|
|
|
|
|
|
|
/* Conversely, in a weak-cdr cell, only the first word must be scanned for
|
|
|
|
|
|
pointers. */
|
|
|
|
|
|
GC_set_bit (wcdr_cell_bitmap, GC_WORD_OFFSET (scm_t_cell, word_0));
|
|
|
|
|
|
wcdr_cell_descr = GC_make_descriptor (wcdr_cell_bitmap,
|
|
|
|
|
|
GC_WORD_LEN (scm_t_cell));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Initialize the hashtab SMOB type. */
|
2003-02-11 13:49:32 +00:00
|
|
|
|
scm_tc16_hashtable = scm_make_smob_type (s_hashtable, 0);
|
|
|
|
|
|
scm_set_smob_mark (scm_tc16_hashtable, scm_markcdr);
|
|
|
|
|
|
scm_set_smob_print (scm_tc16_hashtable, hashtable_print);
|
|
|
|
|
|
scm_set_smob_free (scm_tc16_hashtable, hashtable_free);
|
* hooks.c (scm_c_hook_add): Fixed bug in append mode.
* environments.c (obarray_enter, obarray_retrieve, obarray_remove,
leaf_environment_fold, obarray_remove_all): Use hashtable
accessors.
* gc.c (scm_init_storage): Moved hook initialization to
scm_storage_prehistory.
(scm_storage_prehistory): New function.
(scm_igc): Added commentary about placement of
scm_after_sweep_c_hook.
* gc-mark.c (scm_mark_all): Use hashtable accessors.
(scm_gc_mark_dependencies): Use SCM_WVECT_WEAK_KEY_P and
SCM_WVECT_WEAK_VALUE_P.
* hashtab.c, hashtab.h (scm_hash_for_each, scm_hash_map): New
functions.
(scm_vector_to_hash_table, scm_c_make_resizing_hash_table):
Removed.
(scm_make_weak_key_hash_table, scm_make_weak_value_hash_table,
scm_make_doubly_weak_hash_table): Moved here from weaks.c.
* init.c (scm_init_guile_1): Removed call to scm_init_weaks; Added
calls to scm_storage_prehistory and scm_hashtab_prehistory.
* modules.c (module-reverse-lookup): Use hashtable accessors.
* symbols.c, symbols.h (scm_i_hash_symbol): New function.
* weaks.c, weaks.h (scm_make_weak_key_alist_vector,
scm_make_weak_value_alist_vector,
scm_make_doubly_weak_alist_vector): New functions.
* weaks.c (scm_init_weaks_builtins): New function.
* weaks.h (SCM_WVECTF_WEAK_KEY, SCM_WVECTF_WEAK_VALUE,
SCM_WVECTF_NOSCAN, SCM_WVECT_WEAK_KEY_P, SCM_WVECT_WEAK_VALUE_P,
SCM_WVECT_NOSCAN_P): New macros.
* weaks.c (scm_scan_weak_vectors): Use SCM_WVECT_WEAK_KEY_P
and SCM_WVECT_WEAK_VALUE_P.
* weaks.c, weaks.h (scm_i_allocate_weak_vector): Renamed from
allocate_weak_vector and exported.
* Makefile.am (ice9_sources): Added weak-vector.scm.
* weak-vector.scm: New file.
* boot-9.scm (module-clear!): Use hash-clear!.
(module-for-each): Use hash-for-each.
(module-map): Use hash-map.
2003-02-19 15:04:51 +00:00
|
|
|
|
scm_c_hook_add (&scm_after_gc_c_hook, rehash_after_gc, 0, 0);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
|
scm_init_hashtab ()
|
|
|
|
|
|
{
|
2000-04-21 14:16:44 +00:00
|
|
|
|
#include "libguile/hashtab.x"
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
2000-03-19 19:01:16 +00:00
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
Local Variables:
|
|
|
|
|
|
c-file-style: "gnu"
|
|
|
|
|
|
End:
|
|
|
|
|
|
*/
|