• Philipp Stephani's avatar
    Implement finalizers for module functions (Bug#30373) · 48ffef5e
    Philipp Stephani authored
    * src/module-env-28.h: Add new module environment functions to
    module environment for Emacs 28.
    * src/emacs-module.h.in: Document that 'emacs_finalizer' also works
    for function finalizers.
    * src/emacs-module.c (CHECK_MODULE_FUNCTION): New function.
    (struct Lisp_Module_Function): Add finalizer data member.
    (module_make_function): Initialize finalizer.
    (module_set_function_finalizer): New module environment functions.
    (module_finalize_function): New function.
    (initialize_environment): Initialize new environment functions.
    * src/alloc.c (cleanup_vector): Call potential module function
    finalizer during garbage collection.
    * test/data/emacs-module/mod-test.c (signal_error): New helper
    (memory_full): Use it.
    (finalizer): New example function finalizer.
    (Fmod_test_function_finalizer_calls): New test module functions.
    (emacs_module_init): Define them.
    * test/src/emacs-module-tests.el (module/function-finalizer): New unit
    * doc/lispref/internals.texi (Module Functions): Document new
    (Module Misc): Move description of 'emacs_finalizer' type to 'Module
    Functions' node, and add a reference to it.
    * etc/NEWS: Mention new functionality.
emacs-module-tests.el 15.7 KB