mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-07 18:30:25 +02:00
This will replace an internal interface in (system foreign-objects). * module/system/finalizers.scm: New file. * am/bootstrap.am (SOURCES): Add new file. * libguile/foreign-object.h: * libguile/foreign-object.c (invoke_finalizer): (sys_add_finalizer_x): (scm_init_foreign_object): (scm_register_foreign_object): Remove. * libguile/init.c (scm_i_init_guile): Register finalizers instead of foreign-object. * module/system/foreign-object.scm (allocate-instance): Use finalizers module. * libguile/finalizers.c (invoke_finalizer): (scm_sys_add_finalizer): New helper.
34 lines
1.3 KiB
Scheme
34 lines
1.3 KiB
Scheme
;;; 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/>.
|
||
|
||
|
||
(define-module (system finalizers)
|
||
#:export (add-finalizer!
|
||
%guardian-finalizer-priority
|
||
%default-finalizer-priority))
|
||
|
||
(eval-when (expand load eval)
|
||
(load-extension (string-append "libguile-" (effective-version))
|
||
"scm_init_finalizers_module"))
|
||
|
||
(define %guardian-finalizer-priority 1)
|
||
(define %default-finalizer-priority 0)
|
||
|
||
(define* (add-finalizer! obj proc
|
||
#:optional (priority %default-finalizer-priority))
|
||
"Add a finalizer @var{proc} to object @var{obj}, with priority
|
||
@var{priority}. Return the finalizer object."
|
||
(%add-finalizer! obj proc priority))
|