mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-27 21:40:34 +02:00
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.
This commit is contained in:
parent
c4e83f74c2
commit
a141db8604
22 changed files with 364 additions and 642 deletions
|
@ -68,28 +68,28 @@
|
|||
exception:wrong-type-arg
|
||||
(list->weak-vector 32)))
|
||||
|
||||
(with-test-prefix "make-weak-key-alist-vector"
|
||||
(with-test-prefix "make-weak-key-hash-table"
|
||||
(pass-if "create"
|
||||
(make-weak-key-alist-vector 17)
|
||||
(make-weak-key-hash-table 17)
|
||||
#t)
|
||||
(pass-if-exception "bad-args"
|
||||
exception:wrong-type-arg
|
||||
(make-weak-key-alist-vector '(bad arg))))
|
||||
(with-test-prefix "make-weak-value-alist-vector"
|
||||
(make-weak-key-hash-table '(bad arg))))
|
||||
(with-test-prefix "make-weak-value-hash-table"
|
||||
(pass-if "create"
|
||||
(make-weak-value-alist-vector 17)
|
||||
(make-weak-value-hash-table 17)
|
||||
#t)
|
||||
(pass-if-exception "bad-args"
|
||||
exception:wrong-type-arg
|
||||
(make-weak-value-alist-vector '(bad arg))))
|
||||
(make-weak-value-hash-table '(bad arg))))
|
||||
|
||||
(with-test-prefix "make-doubly-weak-alist-vector"
|
||||
(with-test-prefix "make-doubly-weak-hash-table"
|
||||
(pass-if "create"
|
||||
(make-doubly-weak-alist-vector 17)
|
||||
(make-doubly-weak-hash-table 17)
|
||||
#t)
|
||||
(pass-if-exception "bad-args"
|
||||
exception:wrong-type-arg
|
||||
(make-doubly-weak-alist-vector '(bad arg)))))
|
||||
(make-doubly-weak-hash-table '(bad arg)))))
|
||||
|
||||
|
||||
|
||||
|
@ -138,9 +138,9 @@
|
|||
(or (not value)
|
||||
(equal? value initial-value)))
|
||||
|
||||
(let ((x (make-weak-key-alist-vector 17))
|
||||
(y (make-weak-value-alist-vector 17))
|
||||
(z (make-doubly-weak-alist-vector 17))
|
||||
(let ((x (make-weak-key-hash-table 17))
|
||||
(y (make-weak-value-hash-table 17))
|
||||
(z (make-doubly-weak-hash-table 17))
|
||||
(test-key "foo")
|
||||
(test-value "bar"))
|
||||
(with-test-prefix
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue