mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-07 20:50:17 +02:00
Move weak tables out to a module
* module/ice-9/weak-tables.scm: New file. * am/bootstrap.am (SOURCES): Wire it up. * module/ice-9/deprecated.scm: Add deprecation shims. * libguile/init.c (scm_i_init_guile): Don't add weak bindings to default module. * libguile/weak-table.h: * libguile/weak-table.c (scm_init_weak_tables): (scm_weak_table_prehistory): Arrange to load bindings from the weaks module. * module/ice-9/hcons.scm: * module/ice-9/object-properties.scm: * module/ice-9/poe.scm: * module/ice-9/popen.scm: * module/ice-9/sandbox.scm: * module/language/ecmascript/function.scm: * module/oop/goops/save.scm: * module/srfi/srfi-18.scm: * module/srfi/srfi-69.scm: * module/system/foreign.scm: * test-suite/tests/gc.test: * test-suite/tests/hash.test: * test-suite/tests/types.test: * test-suite/tests/weaks.test: Adapt to use the new module.
This commit is contained in:
parent
3a9c0939a0
commit
67dca3a1f5
20 changed files with 124 additions and 27 deletions
|
@ -201,6 +201,7 @@ SOURCES = \
|
|||
ice-9/top-repl.scm \
|
||||
ice-9/unicode.scm \
|
||||
ice-9/vlist.scm \
|
||||
ice-9/weak-tables.scm \
|
||||
ice-9/weak-vector.scm \
|
||||
\
|
||||
language/brainfuck/parse.scm \
|
||||
|
|
|
@ -458,7 +458,6 @@ scm_i_init_guile (struct gc_stack_addr base)
|
|||
scm_init_throw (); /* Requires smob_prehistory */
|
||||
scm_init_version ();
|
||||
scm_init_weak_set ();
|
||||
scm_init_weak_table ();
|
||||
scm_init_standard_ports (); /* Requires fports */
|
||||
scm_init_expand (); /* Requires structs */
|
||||
scm_init_memoize (); /* Requires smob_prehistory */
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "alist.h"
|
||||
#include "bdw-gc.h"
|
||||
#include "eval.h"
|
||||
#include "extensions.h"
|
||||
#include "finalizers.h"
|
||||
#include "gsubr.h"
|
||||
#include "hash.h"
|
||||
|
@ -37,6 +38,7 @@
|
|||
#include "ports.h"
|
||||
#include "procs.h"
|
||||
#include "threads.h"
|
||||
#include "version.h"
|
||||
|
||||
#include "weak-table.h"
|
||||
|
||||
|
@ -772,6 +774,12 @@ SCM_DEFINE (scm_doubly_weak_hash_table_p, "doubly-weak-hash-table?", 1, 0, 0,
|
|||
|
||||
|
||||
|
||||
static void
|
||||
scm_init_weak_tables (void*)
|
||||
{
|
||||
#include "weak-table.x"
|
||||
}
|
||||
|
||||
void
|
||||
scm_weak_table_prehistory (void)
|
||||
{
|
||||
|
@ -792,10 +800,8 @@ scm_weak_table_prehistory (void)
|
|||
GC_WORD_LEN (scm_t_weak_entry));
|
||||
doubly_weak_descr = GC_make_descriptor (doubly_weak_bitmap,
|
||||
GC_WORD_LEN (scm_t_weak_entry));
|
||||
|
||||
scm_c_register_extension ("libguile-" SCM_EFFECTIVE_VERSION,
|
||||
"scm_init_weak_tables", scm_init_weak_tables, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
scm_init_weak_table ()
|
||||
{
|
||||
#include "weak-table.x"
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef SCM_WEAK_TABLE_H
|
||||
#define SCM_WEAK_TABLE_H
|
||||
|
||||
/* Copyright 2011-2012,2018
|
||||
/* Copyright 2011-2012,2018,2025
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
This file is part of Guile.
|
||||
|
@ -82,6 +82,5 @@ SCM_API SCM scm_doubly_weak_hash_table_p (SCM h);
|
|||
|
||||
SCM_INTERNAL void scm_i_weak_table_print (SCM exp, SCM port, scm_print_state *pstate);
|
||||
SCM_INTERNAL void scm_weak_table_prehistory (void);
|
||||
SCM_INTERNAL void scm_init_weak_table (void);
|
||||
|
||||
#endif /* SCM_WEAK_TABLE_H */
|
||||
|
|
|
@ -18,9 +18,16 @@
|
|||
(define-module (ice-9 deprecated)
|
||||
#:use-module (ice-9 guardians)
|
||||
#:use-module (ice-9 object-properties)
|
||||
#:use-module (ice-9 weak-tables)
|
||||
#:export ((make-guardian* . make-guardian)
|
||||
module-observe-weak
|
||||
(make-object-property* . make-object-property)))
|
||||
(make-object-property* . make-object-property)
|
||||
(make-weak-key-hash-table* . make-weak-key-hash-table)
|
||||
(make-weak-value-hash-table* . make-weak-value-hash-table)
|
||||
(make-doubly-weak-hash-table* . make-doubly-weak-hash-table)
|
||||
(weak-key-hash-table?* . weak-key-hash-table?)
|
||||
(weak-value-hash-table?* . weak-value-hash-table?)
|
||||
(doubly-weak-hash-table?* . doubly-weak-hash-table?)))
|
||||
|
||||
#;
|
||||
(define-syntax-rule (define-deprecated name message exp)
|
||||
|
@ -48,3 +55,39 @@ from (ice-9 guardians) instead.")
|
|||
"make-object-property in the default environment is deprecated. Import
|
||||
it from (ice-9 object-properties) instead.")
|
||||
(make-object-property))
|
||||
|
||||
(define* (make-weak-key-hash-table* #:optional (n 0))
|
||||
(issue-deprecation-warning
|
||||
"make-weak-key-hash-table in the default environment is deprecated.
|
||||
Import it from (ice-9 weak-tables) instead.")
|
||||
(make-weak-key-hash-table))
|
||||
|
||||
(define* (make-weak-value-hash-table* #:optional (n 0))
|
||||
(issue-deprecation-warning
|
||||
"make-weak-value-hash-table in the default environment is deprecated.
|
||||
Import it from (ice-9 weak-tables) instead.")
|
||||
(make-weak-value-hash-table))
|
||||
|
||||
(define* (make-doubly-weak-hash-table* #:optional (n 0))
|
||||
(issue-deprecation-warning
|
||||
"make-weak-key-hash-table in the default environment is deprecated.
|
||||
Import it from (ice-9 weak-tables) instead.")
|
||||
(make-doubly-weak-hash-table))
|
||||
|
||||
(define (weak-key-hash-table?* x)
|
||||
(issue-deprecation-warning
|
||||
"weak-key-hash-table? in the default environment is deprecated.
|
||||
Import it from (ice-9 weak-tables) instead.")
|
||||
(weak-key-hash-table? x))
|
||||
|
||||
(define (weak-value-hash-table?* x)
|
||||
(issue-deprecation-warning
|
||||
"weak-value-hash-table? in the default environment is deprecated.
|
||||
Import it from (ice-9 weak-tables) instead.")
|
||||
(weak-value-hash-table? x))
|
||||
|
||||
(define (doubly-weak-hash-table?* x)
|
||||
(issue-deprecation-warning
|
||||
"doubly-weak-hash-table? in the default environment is deprecated.
|
||||
Import it from (ice-9 weak-tables) instead.")
|
||||
(doubly-weak-hash-table? x))
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
;;; installed-scm-file
|
||||
|
||||
;;;; Copyright (C) 1995, 1996, 1998, 2001, 2003, 2006 Free Software Foundation, Inc.
|
||||
;;;; Copyright (C) 1995, 1996, 1998, 2001, 2003, 2006, 2025 Free Software Foundation, Inc.
|
||||
;;;;
|
||||
;;;; This library is free software; you can redistribute it and/or
|
||||
;;;; modify it under the terms of the GNU Lesser General Public
|
||||
|
@ -19,7 +19,8 @@
|
|||
|
||||
|
||||
(define-module (ice-9 hcons)
|
||||
:export (hashq-cons-hash hashq-cons-assoc hashq-cons-get-handle
|
||||
#:use-module (ice-9 weak-tables)
|
||||
#:export (hashq-cons-hash hashq-cons-assoc hashq-cons-get-handle
|
||||
hashq-cons-create-handle! hashq-cons-ref hashq-cons-set! hashq-cons
|
||||
hashq-conser make-gc-buffer))
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
|
||||
|
||||
(define-module (ice-9 object-properties)
|
||||
#:use-module (ice-9 weak-tables)
|
||||
;; FIXME: Change to #:export when deprecated bindings removed.
|
||||
#:replace (make-object-property))
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
;;; installed-scm-file
|
||||
|
||||
;;;; Copyright (C) 1996, 2001, 2006, 2011 Free Software Foundation, Inc.
|
||||
;;;; Copyright (C) 1996, 2001, 2006, 2011, 2025 Free Software Foundation, Inc.
|
||||
;;;;
|
||||
;;;; This library is free software; you can redistribute it and/or
|
||||
;;;; modify it under the terms of the GNU Lesser General Public
|
||||
|
@ -19,8 +19,9 @@
|
|||
|
||||
|
||||
(define-module (ice-9 poe)
|
||||
:use-module (ice-9 hcons)
|
||||
:export (pure-funcq perfect-funcq))
|
||||
#:use-module (ice-9 hcons)
|
||||
#:use-module (ice-9 weak-tables)
|
||||
#:export (pure-funcq perfect-funcq))
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#:use-module (ice-9 binary-ports)
|
||||
#:use-module (ice-9 guardians)
|
||||
#:use-module (ice-9 threads)
|
||||
#:use-module (ice-9 weak-tables)
|
||||
#:use-module (srfi srfi-1)
|
||||
#:use-module (srfi srfi-9)
|
||||
#:export (port/pid-table open-pipe* open-pipe close-pipe open-input-pipe
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
;;; Sandboxed evaluation of Scheme code
|
||||
|
||||
;;; Copyright (C) 2017, 2018 Free Software Foundation, Inc.
|
||||
;;; Copyright (C) 2017, 2018, 2025 Free Software Foundation, Inc.
|
||||
|
||||
;;;; This library is free software; you can redistribute it and/or
|
||||
;;;; modify it under the terms of the GNU Lesser General Public
|
||||
|
@ -845,7 +845,6 @@ allocation limit is exceeded, an exception will be thrown to the
|
|||
|
||||
(define hash-bindings
|
||||
'(((guile)
|
||||
doubly-weak-hash-table?
|
||||
hash
|
||||
hash-count
|
||||
hash-fold
|
||||
|
@ -863,8 +862,10 @@ allocation limit is exceeded, an exception will be thrown to the
|
|||
hashv-ref
|
||||
hashx-get-handle
|
||||
hashx-ref
|
||||
make-hash-table)
|
||||
((ice-9 weak-tables)
|
||||
doubly-weak-hash-table?
|
||||
make-doubly-weak-hash-table
|
||||
make-hash-table
|
||||
make-weak-key-hash-table
|
||||
make-weak-value-hash-table
|
||||
weak-key-hash-table?
|
||||
|
|
35
module/ice-9/weak-tables.scm
Normal file
35
module/ice-9/weak-tables.scm
Normal file
|
@ -0,0 +1,35 @@
|
|||
;;; Copyright (C) 2025 Free Software Foundation, Inc.
|
||||
;;;
|
||||
;;; 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 3 of the
|
||||
;;; License, or (at your option) any later version.
|
||||
;;;
|
||||
;;; 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.
|
||||
;;;
|
||||
;;; You should have received a copy of the GNU Lesser General Public
|
||||
;;; License along with this program. If not, see
|
||||
;;; <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
;;;
|
||||
;;;
|
||||
;;; Code:
|
||||
|
||||
|
||||
(define-module (ice-9 weak-tables)
|
||||
;; FIXME: Change to #:export when deprecated code removed.
|
||||
#:replace (make-weak-key-hash-table
|
||||
make-weak-value-hash-table
|
||||
make-doubly-weak-hash-table
|
||||
|
||||
weak-key-hash-table?
|
||||
weak-value-hash-table?
|
||||
doubly-weak-hash-table?))
|
||||
|
||||
(eval-when (expand load eval)
|
||||
(load-extension (string-append "libguile-" (effective-version))
|
||||
"scm_init_weak_tables"))
|
|
@ -1,6 +1,6 @@
|
|||
;;; ECMAScript for Guile
|
||||
|
||||
;; Copyright (C) 2009 Free Software Foundation, Inc.
|
||||
;; Copyright (C) 2009, 2025 Free Software Foundation, Inc.
|
||||
|
||||
;;;; This library is free software; you can redistribute it and/or
|
||||
;;;; modify it under the terms of the GNU Lesser General Public
|
||||
|
@ -19,6 +19,7 @@
|
|||
;;; Code:
|
||||
|
||||
(define-module (language ecmascript function)
|
||||
#:use-module (ice-9 weak-tables)
|
||||
#:use-module (oop goops)
|
||||
#:use-module (language ecmascript base)
|
||||
#:export (*function-prototype* *program-wrappers*))
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
;;; installed-scm-file
|
||||
|
||||
;;;; Copyright (C) 2000,2001,2002, 2006, 2009, 2010, 2013, 2015, 2020 Free Software Foundation, Inc.
|
||||
;;;; Copyright (C) 2000,2001,2002, 2006, 2009, 2010, 2013, 2015, 2020, 2025, 2025 Free Software Foundation, Inc.
|
||||
;;;;
|
||||
;;;; This library is free software; you can redistribute it and/or
|
||||
;;;; modify it under the terms of the GNU Lesser General Public
|
||||
|
@ -20,6 +20,7 @@
|
|||
|
||||
(define-module (oop goops save)
|
||||
#:use-module (ice-9 copy-tree)
|
||||
#:use-module (ice-9 weak-tables)
|
||||
#:use-module (oop goops internal)
|
||||
#:export (make-unbound save-objects load-objects restore
|
||||
enumerate! enumerate-component!
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
;;; srfi-18.scm --- Multithreading support
|
||||
|
||||
;; Copyright (C) 2008, 2009, 2010, 2012, 2014, 2018 Free Software Foundation, Inc.
|
||||
;; Copyright (C) 2008, 2009, 2010, 2012, 2014, 2018, 2025, 2025 Free Software Foundation, Inc.
|
||||
;;
|
||||
;; This library is free software; you can redistribute it and/or
|
||||
;; modify it under the terms of the GNU Lesser General Public
|
||||
|
@ -34,6 +34,7 @@
|
|||
#:use-module (ice-9 exceptions)
|
||||
#:use-module ((ice-9 threads) #:prefix threads:)
|
||||
#:use-module (ice-9 match)
|
||||
#:use-module (ice-9 weak-tables)
|
||||
#:use-module (srfi srfi-9)
|
||||
#:export (;; Threads
|
||||
make-thread
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
;;; srfi-69.scm --- Basic hash tables
|
||||
|
||||
;; Copyright (C) 2007 Free Software Foundation, Inc.
|
||||
;; Copyright (C) 2007, 2025 Free Software Foundation, Inc.
|
||||
;;
|
||||
;; This library is free software; you can redistribute it and/or
|
||||
;; modify it under the terms of the GNU Lesser General Public
|
||||
|
@ -71,6 +71,7 @@
|
|||
#:use-module (srfi srfi-9)
|
||||
#:use-module (srfi srfi-13) ;string-hash,string-hash-ci
|
||||
#:use-module (ice-9 optargs)
|
||||
#:use-module (ice-9 weak-tables)
|
||||
#:export (;; Type constructors & predicate
|
||||
make-hash-table hash-table? alist->hash-table
|
||||
;; Reflective queries
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
;;; Copyright (C) 2010-2011,2013-2014,2024 Free Software Foundation, Inc.
|
||||
;;; Copyright (C) 2010-2011,2013-2014,2024,2025,2025 Free Software Foundation, Inc.
|
||||
;;;
|
||||
;;; This library is free software: you can redistribute it and/or modify
|
||||
;;; it under the terms of the GNU Lesser General Public License as
|
||||
|
@ -17,6 +17,7 @@
|
|||
|
||||
(define-module (system foreign)
|
||||
#:use-module (ice-9 match)
|
||||
#:use-module (ice-9 weak-tables)
|
||||
#:use-module (rnrs bytevectors)
|
||||
#:use-module (srfi srfi-1)
|
||||
#:use-module (srfi srfi-9)
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
(define-module (tests gc)
|
||||
#:use-module (ice-9 documentation)
|
||||
#:use-module (ice-9 guardians)
|
||||
#:use-module (ice-9 weak-tables)
|
||||
#:use-module (test-suite lib)
|
||||
#:use-module ((system base compile) #:select (compile)))
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
;;;; hash.test --- test guile hashing -*- scheme -*-
|
||||
;;;;
|
||||
;;;; Copyright (C) 2004, 2005, 2006, 2008, 2011, 2012,
|
||||
;;;; 2014, 2020 Free Software Foundation, Inc.
|
||||
;;;; 2014, 2020, 2025 Free Software Foundation, Inc.
|
||||
;;;;
|
||||
;;;; This library is free software; you can redistribute it and/or
|
||||
;;;; modify it under the terms of the GNU Lesser General Public
|
||||
|
@ -20,7 +20,8 @@
|
|||
(define-module (test-suite test-numbers)
|
||||
#:use-module (test-suite lib)
|
||||
#:use-module (ice-9 documentation)
|
||||
#:use-module (ice-9 hash-table))
|
||||
#:use-module (ice-9 hash-table)
|
||||
#:use-module (ice-9 weak-tables))
|
||||
|
||||
;;;
|
||||
;;; hash
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#:use-module (rnrs io ports)
|
||||
#:use-module (ice-9 match)
|
||||
#:use-module (ice-9 regex)
|
||||
#:use-module (ice-9 weak-tables)
|
||||
#:use-module (srfi srfi-1)
|
||||
#:use-module (srfi srfi-9)
|
||||
#:use-module (system foreign)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
;;;; weaks.test --- tests guile's weaks -*- scheme -*-
|
||||
;;;; Copyright (C) 1999, 2001, 2003, 2006, 2009, 2010, 2011, 2012, 2014
|
||||
;;;; Copyright (C) 1999, 2001, 2003, 2006, 2009, 2010, 2011, 2012, 2014, 2025
|
||||
;;;; Free Software Foundation, Inc.
|
||||
;;;;
|
||||
;;;; This library is free software; you can redistribute it and/or
|
||||
|
@ -37,6 +37,7 @@
|
|||
(define-module (test-weaks)
|
||||
#:use-module (test-suite lib)
|
||||
#:use-module (ice-9 weak-vector)
|
||||
#:use-module (ice-9 weak-tables)
|
||||
#:use-module (srfi srfi-1)
|
||||
#:use-module (srfi srfi-26))
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue