1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-10 14:00:21 +02:00

module-public-interface is a field in the module record

* module/ice-9/boot-9.scm (module-public-interface)
  (set-module-public-interface!): Instead of using
  '%module-public-interface, use a field in the module instead.
  (make-module, make-autoload-interface): Adapt.

* module/ice-9/deprecated.scm (module-public-interface):
  (set-module-public-interface!): Add shims so that manually munging
  %module-public-interface should continue to work.
This commit is contained in:
Andy Wingo 2010-04-23 17:16:56 +02:00
parent 69928c8a32
commit 4e48b4950e
2 changed files with 28 additions and 8 deletions

View file

@ -1551,6 +1551,7 @@ If there is no handler at all, Guile prints an error and then exits."
;; NOTE: The getter `module-eval-closure' is used in libguile/modules.c.
;; NOTE: The getter `module-transfomer' is defined libguile/modules.c.
;; NOTE: The getter `module-name' is defined later, due to boot reasons.
;; NOTE: The getter `module-public-interface' is used in libguile/modules.c.
;;
(define-record-type module
(lambda (obj port) (%print-module obj port))
@ -1567,7 +1568,8 @@ If there is no handler at all, Guile prints an error and then exits."
(weak-observers #:no-setter)
version
submodules
submodule-binder)))
submodule-binder
public-interface)))
;; make-module &opt size uses binder
@ -1609,7 +1611,7 @@ If there is no handler at all, Guile prints an error and then exits."
(make-hash-table %default-import-size)
'()
(make-weak-key-hash-table 31) #f
(make-hash-table 7) #f)))
(make-hash-table 7) #f #f)))
;; We can't pass this as an argument to module-constructor,
;; because we need it to close over a pointer to the module
@ -2218,11 +2220,6 @@ If there is no handler at all, Guile prints an error and then exits."
;;; better thought of as a root.
;;;
(define (module-public-interface m)
(let ((var (module-local-variable m '%module-public-interface)))
(and var (variable-ref var))))
(define (set-module-public-interface! m i)
(module-define! m '%module-public-interface i))
(define (set-system-module! m s)
(set-procedure-property! (module-eval-closure m) 'system-module s))
(define the-root-module (make-root-module))
@ -2686,7 +2683,7 @@ If there is no handler at all, Guile prints an error and then exits."
(module-local-variable i sym))))))
(module-constructor (make-hash-table 0) '() b #f #f name 'autoload #f
(make-hash-table 0) '() (make-weak-value-hash-table 31) #f
(make-hash-table 0) #f)))
(make-hash-table 0) #f #f)))
(define (module-autoload! module . args)
"Have @var{module} automatically load the module named @var{name} when one

View file

@ -327,3 +327,26 @@
(module-define-submodule! the-root-module '%app %app)
(module-define-submodule! the-root-module 'app %app)
(module-define-submodule! %app 'modules (resolve-module '() #f)))
;; Allow code that poked %module-public-interface to keep on working.
;;
(set! module-public-interface
(let ((getter module-public-interface))
(lambda (mod)
(or (getter mod)
(cond
((and=> (module-local-variable mod '%module-public-interface)
variable-ref)
=> (lambda (iface)
(issue-deprecation-warning
"Setting a module's public interface via munging %module-public-interface is
deprecated. Use set-module-public-interface! instead.")
(set-module-public-interface! mod iface)
iface))
(else #f))))))
(set! set-module-public-interface!
(let ((setter set-module-public-interface!))
(lambda (mod iface)
(setter mod iface)
(module-define! mod '%module-public-interface iface))))