1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 11:50:28 +02:00
Commit graph

21 commits

Author SHA1 Message Date
Andy Wingo
9db57a19e1 Merge commit '9b5da400dd'
Conflicts:
	libguile/vectors.c
	test-suite/tests/weaks.test
2014-02-07 15:36:06 +01:00
Andy Wingo
9b5da400dd Deprecate vector-ref, vector-length, vector-set! on weak vectors
* libguile/vectors.c (scm_vector_length, scm_c_vector_length):
  (scm_c_vector_ref, scm_c_vector_set_x): Deprecate the use of these
  procedures on weak vectors.

* test-suite/tests/guardians.test:
* test-suite/tests/weaks.test: Adapt test suites.
2014-02-07 12:42:44 +01:00
Andy Wingo
07e69928fc hash-set! on weak tables returns the value
* libguile/weak-table.h:
* libguile/weak-table.c (scm_weak_table_putq_x)
  (scm_weak_table_remq_x, scm_weak_table_clear_x)
  (scm_weak_table_for_each): Declare these as returning void instead of
  SCM.
* libguile/hashtab.c (scm_hashq_set_x, scm_hashq_remove_x)
  (scm_hashv_set_x, scm_hashv_remove_x)
  (scm_hash_set_x, scm_hash_remove_x)
  (scm_hashx_set_x, scm_hashx_remove_x):
  (scm_hash_for_each): For weak tables, have the set! functions return
  the values, as they used to do.  Have remove! functions return #f,
  indicating the lack of a handle.  Shim around for-each to return
  unspecified, even though that wasn't yet a problem.

* test-suite/tests/weaks.test: Add a test.
2012-03-02 18:26:56 +01:00
Andy Wingo
a141db8604 remove weak pairs, rewrite weak vectors
* libguile/weak-vector.c:
* libguile/weak-vector.h: Renamed from weaks.[ch].  Remove weak pairs.
  They were not safe to access with `car' and `cdr'.  Remove weak alist
  vectors, as we have weak tables and sets.  Reimplement weak vectors,
  moving the implementation here.

* libguile/vectors.c:
* libguile/vectors.h: Remove the extra header word.  Use
  scm_c_weak_vector_ref / scm_c_weak_vector_set_x to access weak
  vectors.

* libguile/snarf.h: Remove the extra header word in vectors.

* libguile/threads.c (do_thread_exit, fat_mutex_lock, fat_mutex_unlock):
  Instead of weak pairs, store thread-owned mutexes in a list of
  one-element weak vectors.

* libguile/guardians.c (finalize_guarded): Similarly, store object
  guardians in a list of one-element weak vectors.

* libguile/modules.c (scm_module_reverse_lookup): We no longer need to
  handle the case of weak references.

* libguile/print.c (iprin1): Use the standard vector accessor to print
  vectors.

* libguile.h:
* libguile/Makefile.am:
* libguile/gc-malloc.c:
* libguile/gc.c:
* libguile/goops.c:
* libguile/init.c:
* libguile/objprop.c:
* libguile/struct.c: Update includes.

* module/ice-9/weak-vector.scm: Load weak vector definitions using an
  extension instead of %init-weaks-builtins.

* test-suite/tests/weaks.test: Use the make-...-hash-table names instead
  of the old alist vector names.
2011-10-24 12:54:14 +02:00
Andy Wingo
636c99d42d fix hash-set! on weak tables
* test-suite/tests/weaks.test: Add tests.
* libguile/hashtab.c (scm_hash_fn_set_x): Fix updates to weak-value hash
  tables to not deadlock inside the alloc lock.
2011-06-16 12:09:13 +02:00
Ludovic Courtès
e9bac3be61 Allow arbitrary code in ASSOC procedures for weak hash tables (bug #29616).
* libguile/hashtab.c (struct t_assoc_args, do_weak_bucket_assoc):
  Remove.
  (struct t_fixup_args): New type.
  (do_weak_bucket_fixup): New function.
  (weak_bucket_assoc): Use it.  Keep strong references to BUCKET's
  entries in STRONG_REFS.  Call ASSOC once the alloc lock has been
  released.  This fixes bug #29616.

* test-suite/tests/weaks.test ("assoc can do anything"): New test.
2010-10-11 15:38:06 +02:00
Ludovic Courtès
3b60001f1e Fix typo in `weaks.test'.
* test-suite/tests/weaks.test (valid?): Check for `value', not `val'.
2010-09-24 09:24:35 +02:00
Ludovic Courtès
b88a954c7a Strengthen the weak hash table tests.
* test-suite/tests/weaks.test: Enclose in a module.
  (valid?): New procedure.
  ("weak-hash")["weak-key dies, "weak-value dies", "double-weak dies"]:
  Check that all the values are `valid?', in addition to checking that
  at least one of them is #f.
2010-09-23 22:02:14 +02:00
Ludovic Courtès
5a99a574e4 Fix weak-value hash tables.
* libguile/hashtab.c (scm_hash_fn_set_x): Register a disappearing link
  to VAL when TABLE is weak-value.

* test-suite/tests/weaks.test ("weak-hash")["weak-key dies", "weak-value
  dies", "doubly-weak dies"]: Use `hash-set!' and `hash-ref', not
  `hashq-set!' and `hashq-ref', otherwise these tests would always
  succeed because (eq? "this" "this") => #f.
  ["lives"]: Use `hash-ref' and `hash-set!' too for consistency.
2010-09-23 22:02:11 +02:00
Ludovic Courtès
43b03fbbdc Make `weaks.test' slightly more robust.
* test-suite/tests/weaks.test (global-weak): Use `string-copy' on all
  the keys, in case one of them is retained in `scm_source_whash' or
  similar.
2009-09-28 23:32:34 +02:00
Neil Jerram
53befeb700 Change Guile license to LGPLv3+
(Not quite finished, the following will be done tomorrow.
   module/srfi/*.scm
   module/rnrs/*.scm
   module/scripts/*.scm
   testsuite/*.scm
   guile-readline/*
)
2009-06-17 00:22:09 +01:00
Kevin Ryde
6e7d5622ee merge from 1.8 branch 2006-04-16 23:37:40 +00:00
Marius Vollmer
eb074bfc5a Do not fail when the GC does not collect an object, report it as
'unresolved'.
2005-07-31 23:16:51 +00:00
Marius Vollmer
92205699d0 The FSF has a new address. 2005-05-23 19:57:22 +00:00
Marius Vollmer
73be1d9e8e Changed license terms to the plain LGPL thru-out. 2003-04-05 19:15:35 +00:00
Mikael Djurfeldt
cbbeea6603 * tests/elisp.test: Use module (ice-9 weak-vector).
* tests/weaks.test: Use module (ice-9 weak-vector).
2003-02-19 15:31:30 +00:00
Martin Grabmüller
96e30d2ab2 * tests/alist.test, tests/bit-operations.test,
tests/common-list.test, tests/environments.test, tests/eval.test,
	tests/gc.test, tests/hooks.test, tests/import.test,
	tests/interp.test, tests/list.test, tests/load.test,
	tests/numbers.test, tests/ports.test, tests/r4rs.test,
	tests/version.test, tests/weaks.test, lib.scm, guile-test: Updated
	copyright notice.
2001-07-19 20:30:37 +00:00
Dirk Herrmann
6b4113afc5 * Provide and use new convenience macros to test for exceptions. 2001-02-28 11:25:40 +00:00
Dirk Herrmann
5c96bc39a4 * Make sure that tests return a boolean value. 2001-02-28 08:41:06 +00:00
Dirk Herrmann
57e7f27001 Adopted a couple of nice ideas from Greg. 2000-05-08 17:42:03 +00:00
Mikael Djurfeldt
f70d746879 * tests/weaks.test: Added. 1999-12-22 10:13:49 +00:00