2001-03-30 15:03:23 +00:00
|
|
|
|
/* Copyright (C) 1995,1996,1998,2000,2001 Free Software Foundation, Inc.
|
1996-07-25 22:56:11 +00:00
|
|
|
|
*
|
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
|
* the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
|
|
* any later version.
|
|
|
|
|
|
*
|
|
|
|
|
|
* This program 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 General Public License for more details.
|
|
|
|
|
|
*
|
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
|
* along with this software; see the file COPYING. If not, write to
|
1997-05-26 22:34:48 +00:00
|
|
|
|
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
|
|
|
|
|
* Boston, MA 02111-1307 USA
|
1996-07-25 22:56:11 +00:00
|
|
|
|
*
|
|
|
|
|
|
* As a special exception, Free Software Foundation gives permission
|
|
|
|
|
|
* for additional uses of the text contained in its release of this library.
|
|
|
|
|
|
*
|
|
|
|
|
|
* The exception is that, if you link this library with other files
|
|
|
|
|
|
* to produce an executable, this does not by itself cause the
|
|
|
|
|
|
* resulting executable to be covered by the GNU General Public License.
|
|
|
|
|
|
* Your use of that executable is in no way restricted on account of
|
|
|
|
|
|
* linking this library code into it.
|
|
|
|
|
|
*
|
|
|
|
|
|
* This exception does not however invalidate any other reasons why
|
|
|
|
|
|
* the executable file might be covered by the GNU General Public License.
|
|
|
|
|
|
*
|
|
|
|
|
|
* This exception applies only to the code released by
|
|
|
|
|
|
* Free Software Foundation as part of this library. If you copy
|
|
|
|
|
|
* code from other releases distributed under the terms of the GPL into a copy of
|
|
|
|
|
|
* this library, as the General Public License permits, the exception does
|
|
|
|
|
|
* not apply to the code that you add in this way. To avoid misleading
|
|
|
|
|
|
* anyone as to the status of such modified files, you must delete
|
|
|
|
|
|
* this exception notice from such code.
|
|
|
|
|
|
*
|
|
|
|
|
|
* If you write modifications of your own for this library, it is your choice
|
|
|
|
|
|
* whether to permit this exception to apply to your modifications.
|
1997-05-26 22:34:48 +00:00
|
|
|
|
* If you do not wish that, delete this exception notice. */
|
1999-12-12 02:36:16 +00:00
|
|
|
|
|
|
|
|
|
|
/* Software engineering face-lift by Greg J. Badros, 11-Dec-1999,
|
|
|
|
|
|
gjb@cs.washington.edu, http://www.cs.washington.edu/homes/gjb */
|
|
|
|
|
|
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
2000-04-21 14:16:44 +00:00
|
|
|
|
#include "libguile/_scm.h"
|
|
|
|
|
|
#include "libguile/vectors.h"
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
2000-04-21 14:16:44 +00:00
|
|
|
|
#include "libguile/validate.h"
|
|
|
|
|
|
#include "libguile/weaks.h"
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* {Weak Vectors}
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
2000-01-05 19:25:37 +00:00
|
|
|
|
SCM_DEFINE (scm_make_weak_vector, "make-weak-vector", 1, 1, 0,
|
2001-04-03 13:19:05 +00:00
|
|
|
|
(SCM size, SCM fill),
|
* 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
|
|
|
|
"Return a weak vector with @var{size} elements. If the optional\n"
|
2001-04-03 13:19:05 +00:00
|
|
|
|
"argument @var{fill} is given, all entries in the vector will be\n"
|
|
|
|
|
|
"set to @var{fill}. The default value for @var{fill} is the\n"
|
|
|
|
|
|
"empty list.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_make_weak_vector
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2000-11-22 14:45:41 +00:00
|
|
|
|
/* Dirk:FIXME:: We should probably rather use a double cell for weak vectors. */
|
1996-07-25 22:56:11 +00:00
|
|
|
|
SCM v;
|
2001-04-03 13:19:05 +00:00
|
|
|
|
v = scm_make_vector (scm_sum (size, SCM_MAKINUM (2)), fill);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
SCM_DEFER_INTS;
|
2001-04-03 13:19:05 +00:00
|
|
|
|
SCM_SET_VECTOR_LENGTH (v, SCM_INUM (size), scm_tc7_wvect);
|
1999-06-15 14:00:11 +00:00
|
|
|
|
SCM_SETVELTS(v, SCM_VELTS(v) + 2);
|
2000-04-19 11:32:05 +00:00
|
|
|
|
SCM_VELTS(v)[-2] = SCM_EOL;
|
2001-06-07 23:10:33 +00:00
|
|
|
|
SCM_VECTOR_BASE (v) [-1] = 0;
|
1996-07-25 22:56:11 +00:00
|
|
|
|
SCM_ALLOW_INTS;
|
|
|
|
|
|
return v;
|
|
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
1999-12-12 02:36:16 +00:00
|
|
|
|
SCM_REGISTER_PROC(s_list_to_weak_vector, "list->weak-vector", 1, 0, 0, scm_weak_vector);
|
* __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
|
|
|
|
|
2000-01-05 19:25:37 +00:00
|
|
|
|
SCM_DEFINE (scm_weak_vector, "weak-vector", 0, 0, 1,
|
1999-12-12 02:36:16 +00:00
|
|
|
|
(SCM l),
|
* 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
|
|
|
|
"@deffnx primitive list->weak-vector l\n"
|
2001-04-03 13:19:05 +00:00
|
|
|
|
"Construct a weak vector from a list: @code{weak-vector} uses\n"
|
|
|
|
|
|
"the list of its arguments while @code{list->weak-vector} uses\n"
|
|
|
|
|
|
"its only argument @var{l} (a list) to construct a weak vector\n"
|
|
|
|
|
|
"the same way @code{list->vector} would.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_weak_vector
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
|
|
|
|
|
SCM res;
|
2001-03-30 15:03:23 +00:00
|
|
|
|
SCM *data;
|
2001-05-26 20:51:22 +00:00
|
|
|
|
long i;
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
2001-03-30 15:03:23 +00:00
|
|
|
|
/* Dirk:FIXME:: In case of multiple threads, the list might get corrupted
|
|
|
|
|
|
while the vector is being created. */
|
1996-07-25 22:56:11 +00:00
|
|
|
|
i = scm_ilength (l);
|
1999-12-12 02:36:16 +00:00
|
|
|
|
SCM_ASSERT (i >= 0, l, SCM_ARG1, FUNC_NAME);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
res = scm_make_weak_vector (SCM_MAKINUM (i), SCM_UNSPECIFIED);
|
|
|
|
|
|
data = SCM_VELTS (res);
|
2001-03-30 15:03:23 +00:00
|
|
|
|
|
|
|
|
|
|
while (!SCM_NULLP (l))
|
|
|
|
|
|
{
|
|
|
|
|
|
*data++ = SCM_CAR (l);
|
|
|
|
|
|
l = SCM_CDR (l);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
1996-07-25 22:56:11 +00:00
|
|
|
|
return res;
|
|
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
2000-01-05 19:25:37 +00:00
|
|
|
|
SCM_DEFINE (scm_weak_vector_p, "weak-vector?", 1, 0, 0,
|
2001-04-03 13:19:05 +00:00
|
|
|
|
(SCM obj),
|
* 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 @code{#t} if @var{obj} is a weak vector. Note that all\n"
|
|
|
|
|
|
"weak hashes are also weak vectors.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_weak_vector_p
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2001-04-03 13:19:05 +00:00
|
|
|
|
return SCM_BOOL(SCM_WVECTP (obj) && !SCM_IS_WHVEC (obj));
|
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:25:37 +00:00
|
|
|
|
SCM_DEFINE (scm_make_weak_key_hash_table, "make-weak-key-hash-table", 1, 0, 0,
|
2001-04-03 13:19:05 +00:00
|
|
|
|
(SCM size),
|
* 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
|
|
|
|
"@deffnx primitive make-weak-value-hash-table size\n"
|
|
|
|
|
|
"@deffnx primitive make-doubly-weak-hash-table size\n"
|
2001-04-03 13:19:05 +00:00
|
|
|
|
"Return a weak hash table with @var{size} buckets. As with any\n"
|
|
|
|
|
|
"hash table, choosing a good size for the table requires some\n"
|
|
|
|
|
|
"caution.\n"
|
|
|
|
|
|
"\n"
|
|
|
|
|
|
"You can modify weak hash tables in exactly the same way you\n"
|
|
|
|
|
|
"would modify regular hash tables. (@pxref{Hash Tables})")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_make_weak_key_hash_table
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
|
|
|
|
|
SCM v;
|
2001-04-03 13:19:05 +00:00
|
|
|
|
SCM_VALIDATE_INUM (1, size);
|
|
|
|
|
|
v = scm_make_weak_vector (size, SCM_EOL);
|
2000-05-05 11:10:57 +00:00
|
|
|
|
SCM_DEFER_INTS;
|
2001-06-07 23:10:33 +00:00
|
|
|
|
SCM_VECTOR_BASE (v) [-1] = 1;
|
1996-07-25 22:56:11 +00:00
|
|
|
|
SCM_ALLOW_INTS;
|
|
|
|
|
|
return v;
|
|
|
|
|
|
}
|
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_make_weak_value_hash_table, "make-weak-value-hash-table", 1, 0, 0,
|
2001-04-03 13:19:05 +00:00
|
|
|
|
(SCM size),
|
2001-01-30 14:53:20 +00:00
|
|
|
|
"Return a hash table with weak values with @var{size} buckets.\n"
|
|
|
|
|
|
"(@pxref{Hash Tables})")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_make_weak_value_hash_table
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
|
|
|
|
|
SCM v;
|
2001-04-03 13:19:05 +00:00
|
|
|
|
SCM_VALIDATE_INUM (1, size);
|
|
|
|
|
|
v = scm_make_weak_vector (size, SCM_EOL);
|
2000-05-05 11:10:57 +00:00
|
|
|
|
SCM_DEFER_INTS;
|
2001-06-07 23:10:33 +00:00
|
|
|
|
SCM_VECTOR_BASE (v) [-1] = 2;
|
1996-07-25 22:56:11 +00:00
|
|
|
|
SCM_ALLOW_INTS;
|
|
|
|
|
|
return v;
|
|
|
|
|
|
}
|
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_make_doubly_weak_hash_table, "make-doubly-weak-hash-table", 1, 0, 0,
|
2001-04-03 13:19:05 +00:00
|
|
|
|
(SCM size),
|
2001-01-30 14:53:20 +00:00
|
|
|
|
"Return a hash table with weak keys and values with @var{size}\n"
|
|
|
|
|
|
"buckets. (@pxref{Hash Tables})")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_make_doubly_weak_hash_table
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
|
|
|
|
|
SCM v;
|
2001-04-03 13:19:05 +00:00
|
|
|
|
SCM_VALIDATE_INUM (1, size);
|
|
|
|
|
|
v = scm_make_weak_vector (size, SCM_EOL);
|
2000-05-05 11:10:57 +00:00
|
|
|
|
SCM_DEFER_INTS;
|
2001-06-07 23:10:33 +00:00
|
|
|
|
SCM_VECTOR_BASE (v) [-1] = 3;
|
1996-07-25 22:56:11 +00:00
|
|
|
|
SCM_ALLOW_INTS;
|
|
|
|
|
|
return v;
|
|
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
2000-01-05 19:25:37 +00:00
|
|
|
|
SCM_DEFINE (scm_weak_key_hash_table_p, "weak-key-hash-table?", 1, 0, 0,
|
2001-04-03 13:19:05 +00:00
|
|
|
|
(SCM obj),
|
* 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
|
|
|
|
"@deffnx primitive weak-value-hash-table? obj\n"
|
|
|
|
|
|
"@deffnx primitive doubly-weak-hash-table? obj\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 @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.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_weak_key_hash_table_p
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2001-04-03 13:19:05 +00:00
|
|
|
|
return SCM_BOOL(SCM_WVECTP (obj) && SCM_IS_WHVEC(obj));
|
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_weak_value_hash_table_p, "weak-value-hash-table?", 1, 0, 0,
|
2001-04-03 13:19:05 +00:00
|
|
|
|
(SCM obj),
|
|
|
|
|
|
"Return @code{#t} if @var{obj} is a weak value hash table.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_weak_value_hash_table_p
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2001-04-03 13:19:05 +00:00
|
|
|
|
return SCM_BOOL(SCM_WVECTP (obj) && SCM_IS_WHVEC_V(obj));
|
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_doubly_weak_hash_table_p, "doubly-weak-hash-table?", 1, 0, 0,
|
2001-04-03 13:19:05 +00:00
|
|
|
|
(SCM obj),
|
|
|
|
|
|
"Return @code{#t} if @var{obj} is a doubly weak hash table.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_doubly_weak_hash_table_p
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2001-04-03 13:19:05 +00:00
|
|
|
|
return SCM_BOOL(SCM_WVECTP (obj) && SCM_IS_WHVEC_B (obj));
|
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-04-21 23:14:06 +00:00
|
|
|
|
static void *
|
2001-06-07 21:12:19 +00:00
|
|
|
|
scm_weak_vector_gc_init (void *dummy1 SCM_UNUSED,
|
|
|
|
|
|
void *dummy2 SCM_UNUSED,
|
|
|
|
|
|
void *dummy3 SCM_UNUSED)
|
2000-04-21 23:14:06 +00:00
|
|
|
|
{
|
|
|
|
|
|
scm_weak_vectors = SCM_EOL;
|
|
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void *
|
2001-06-07 21:12:19 +00:00
|
|
|
|
scm_mark_weak_vector_spines (void *dummy1 SCM_UNUSED,
|
|
|
|
|
|
void *dummy2 SCM_UNUSED,
|
|
|
|
|
|
void *dummy3 SCM_UNUSED)
|
2000-04-21 23:14:06 +00:00
|
|
|
|
{
|
|
|
|
|
|
SCM w;
|
|
|
|
|
|
|
|
|
|
|
|
for (w = scm_weak_vectors; !SCM_NULLP (w); w = SCM_WVECT_GC_CHAIN (w))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (SCM_IS_WHVEC_ANY (w))
|
|
|
|
|
|
{
|
|
|
|
|
|
SCM *ptr;
|
|
|
|
|
|
SCM obj;
|
2001-05-26 20:51:22 +00:00
|
|
|
|
long j;
|
|
|
|
|
|
long n;
|
2000-04-21 23:14:06 +00:00
|
|
|
|
|
|
|
|
|
|
obj = w;
|
|
|
|
|
|
ptr = SCM_VELTS (w);
|
2000-10-09 14:37:36 +00:00
|
|
|
|
n = SCM_VECTOR_LENGTH (w);
|
2000-04-21 23:14:06 +00:00
|
|
|
|
for (j = 0; j < n; ++j)
|
|
|
|
|
|
{
|
|
|
|
|
|
SCM alist;
|
|
|
|
|
|
|
|
|
|
|
|
alist = ptr[j];
|
|
|
|
|
|
while ( SCM_CONSP (alist)
|
|
|
|
|
|
&& !SCM_GCMARKP (alist)
|
|
|
|
|
|
&& SCM_CONSP (SCM_CAR (alist)))
|
|
|
|
|
|
{
|
|
|
|
|
|
SCM_SETGCMARK (alist);
|
|
|
|
|
|
SCM_SETGCMARK (SCM_CAR (alist));
|
2000-12-06 15:16:59 +00:00
|
|
|
|
alist = SCM_CDR (alist);
|
2000-04-21 23:14:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void *
|
2001-06-07 21:12:19 +00:00
|
|
|
|
scm_scan_weak_vectors (void *dummy1 SCM_UNUSED,
|
|
|
|
|
|
void *dummy2 SCM_UNUSED,
|
|
|
|
|
|
void *dummy3 SCM_UNUSED)
|
2000-04-21 23:14:06 +00:00
|
|
|
|
{
|
|
|
|
|
|
SCM *ptr, w;
|
|
|
|
|
|
for (w = scm_weak_vectors; !SCM_NULLP (w); w = SCM_WVECT_GC_CHAIN (w))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!SCM_IS_WHVEC_ANY (w))
|
|
|
|
|
|
{
|
|
|
|
|
|
register long j, n;
|
|
|
|
|
|
|
|
|
|
|
|
ptr = SCM_VELTS (w);
|
2000-10-09 14:37:36 +00:00
|
|
|
|
n = SCM_VECTOR_LENGTH (w);
|
2000-04-21 23:14:06 +00:00
|
|
|
|
for (j = 0; j < n; ++j)
|
2000-07-13 15:00:58 +00:00
|
|
|
|
if (SCM_FREE_CELL_P (ptr[j]))
|
2000-04-21 23:14:06 +00:00
|
|
|
|
ptr[j] = SCM_BOOL_F;
|
|
|
|
|
|
}
|
|
|
|
|
|
else /* if (SCM_IS_WHVEC_ANY (scm_weak_vectors[i])) */
|
|
|
|
|
|
{
|
|
|
|
|
|
SCM obj = w;
|
2001-05-26 20:51:22 +00:00
|
|
|
|
register long n = SCM_VECTOR_LENGTH (w);
|
|
|
|
|
|
register long j;
|
2000-12-29 22:18:06 +00:00
|
|
|
|
int weak_keys = SCM_IS_WHVEC (obj) || SCM_IS_WHVEC_B (obj);
|
|
|
|
|
|
int weak_values = SCM_IS_WHVEC_V (obj) || SCM_IS_WHVEC_B (obj);
|
2000-04-21 23:14:06 +00:00
|
|
|
|
|
|
|
|
|
|
ptr = SCM_VELTS (w);
|
|
|
|
|
|
|
|
|
|
|
|
for (j = 0; j < n; ++j)
|
|
|
|
|
|
{
|
|
|
|
|
|
SCM * fixup;
|
|
|
|
|
|
SCM alist;
|
|
|
|
|
|
|
|
|
|
|
|
fixup = ptr + j;
|
|
|
|
|
|
alist = *fixup;
|
|
|
|
|
|
|
|
|
|
|
|
while ( SCM_CONSP (alist)
|
|
|
|
|
|
&& SCM_CONSP (SCM_CAR (alist)))
|
|
|
|
|
|
{
|
|
|
|
|
|
SCM key;
|
|
|
|
|
|
SCM value;
|
|
|
|
|
|
|
|
|
|
|
|
key = SCM_CAAR (alist);
|
|
|
|
|
|
value = SCM_CDAR (alist);
|
2000-07-13 15:00:58 +00:00
|
|
|
|
if ( (weak_keys && SCM_FREE_CELL_P (key))
|
|
|
|
|
|
|| (weak_values && SCM_FREE_CELL_P (value)))
|
2000-04-21 23:14:06 +00:00
|
|
|
|
{
|
|
|
|
|
|
*fixup = SCM_CDR (alist);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
fixup = SCM_CDRLOC (alist);
|
|
|
|
|
|
alist = SCM_CDR (alist);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
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
|
|
|
|
|
2000-04-21 23:14:06 +00:00
|
|
|
|
void
|
|
|
|
|
|
scm_weaks_prehistory ()
|
|
|
|
|
|
{
|
|
|
|
|
|
scm_c_hook_add (&scm_before_mark_c_hook, scm_weak_vector_gc_init, 0, 0);
|
|
|
|
|
|
scm_c_hook_add (&scm_before_sweep_c_hook, scm_mark_weak_vector_spines, 0, 0);
|
|
|
|
|
|
scm_c_hook_add (&scm_after_sweep_c_hook, scm_scan_weak_vectors, 0, 0);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
1996-07-25 22:56:11 +00:00
|
|
|
|
void
|
|
|
|
|
|
scm_init_weaks ()
|
|
|
|
|
|
{
|
* alist.c, arbiters.c, async.c, backtrace.c, boolean.c, chars.c,
continuations.c, debug-malloc.c, debug.c, dynl.c, dynwind.c,
environments.c, eq.c, error.c, eval.c, evalext.c, feature.c,
filesys.c, fluids.c, fports.c, gc.c, goops.c, guardians.c, hash.c,
hashtab.c, hooks.c, ioext.c, iselect.c, keywords.c, lang.c,
list.c, load.c, macros.c, modules.c, net_db.c, numbers.c,
objects.c, objprop.c, options.c, pairs.c, ports.c, posix.c,
print.c, procprop.c, procs.c, properties.c, ramap.c, random.c,
read.c, regex-posix.c, root.c, scmsigs.c, script.c, simpos.c,
socket.c, sort.c, srcprop.c, stackchk.c, stacks.c, stime.c,
strings.c, strop.c, strorder.c, strports.c, struct.c, symbols.c,
tag.c, threads.c, throw.c, unif.c, variable.c, vectors.c,
version.c, vports.c, weaks.c: Makes sure the snarfer output
inclusion is disabled when the snarfer is run on the file. Thanks
to Lars J. Aas!
* Makefile.am: Install guile-procedures.txt in version-specific
directory to enable multiple installed guile versions. Suggested
by Karl M. Hegbloom <karlheg@debian.org, patch by Matthias Koeppe.
2000-11-17 16:25:05 +00:00
|
|
|
|
#ifndef SCM_MAGIC_SNARFER
|
2000-04-21 14:16:44 +00:00
|
|
|
|
#include "libguile/weaks.x"
|
* alist.c, arbiters.c, async.c, backtrace.c, boolean.c, chars.c,
continuations.c, debug-malloc.c, debug.c, dynl.c, dynwind.c,
environments.c, eq.c, error.c, eval.c, evalext.c, feature.c,
filesys.c, fluids.c, fports.c, gc.c, goops.c, guardians.c, hash.c,
hashtab.c, hooks.c, ioext.c, iselect.c, keywords.c, lang.c,
list.c, load.c, macros.c, modules.c, net_db.c, numbers.c,
objects.c, objprop.c, options.c, pairs.c, ports.c, posix.c,
print.c, procprop.c, procs.c, properties.c, ramap.c, random.c,
read.c, regex-posix.c, root.c, scmsigs.c, script.c, simpos.c,
socket.c, sort.c, srcprop.c, stackchk.c, stacks.c, stime.c,
strings.c, strop.c, strorder.c, strports.c, struct.c, symbols.c,
tag.c, threads.c, throw.c, unif.c, variable.c, vectors.c,
version.c, vports.c, weaks.c: Makes sure the snarfer output
inclusion is disabled when the snarfer is run on the file. Thanks
to Lars J. Aas!
* Makefile.am: Install guile-procedures.txt in version-specific
directory to enable multiple installed guile versions. Suggested
by Karl M. Hegbloom <karlheg@debian.org, patch by Matthias Koeppe.
2000-11-17 16:25:05 +00:00
|
|
|
|
#endif
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2000-03-19 19:01:16 +00:00
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
Local Variables:
|
|
|
|
|
|
c-file-style: "gnu"
|
|
|
|
|
|
End:
|
|
|
|
|
|
*/
|