>From 07249825a5f9485c554b2df10d9b443b770eec3d Mon Sep 17 00:00:00 2001 From: Ian Hulin Date: Tue, 31 Aug 2010 18:42:42 +0100 Subject: [PATCH] T1224: Avoid using deprecated %module-public-interface in guile initialisation. 1. ly-module.cc:ly_make_module Replace call using %module-public-interface with shim supplied by guile developers. Also replace reference to "the-scm-module" with "the-root-module" to ensure compatibility with Guile V2.0. 2. ly_module.cc:ly_use_module Reorganise and comment routine to aid maintenance. 3. lily.scm Add in module-export-all! shim for Guile V1.8.7 and test for Guile version. Add in shim to use (ice-9 curried-definitions) if running Guile V2.0 4. Remove stray dots in ergonomic-simple-format etc. 5. Make success and warning messages in ly:exit translatable. 6. Move public definitions of make-rhythmic-location etc. from clip-region.scm to output-lib.scm. --- lily/ly-module.cc | 46 +++++++++++++++++++++++++---------- scm/clip-region.scm | 66 ++++++++++++++------------------------------------- scm/lily.scm | 45 +++++++++++++++++++++++++++++++---- scm/output-lib.scm | 50 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 141 insertions(+), 66 deletions(-) diff --git a/lily/ly-module.cc b/lily/ly-module.cc index 42ff2f8..ff365b8 100644 --- a/lily/ly-module.cc +++ b/lily/ly-module.cc @@ -24,25 +24,34 @@ #include "protected-scm.hh" + SCM ly_make_module (bool safe) { SCM mod = SCM_EOL; if (!safe) { - SCM maker = ly_lily_module_constant ("make-module"); - - SCM scm_module = ly_lily_module_constant ("the-scm-module"); + /* Look up (evaluate) Scheme make-module function and call it */ + SCM maker = ly_lily_module_constant("make-module"); mod = scm_call_0 (maker); - scm_module_define (mod, ly_symbol2scm ("%module-public-interface"), - mod); - + /* Look up and call Guile module-export-all! or Lilypond-defined + compatible version when using Guile V1.8 */ + SCM module_export_all_x = ly_lily_module_constant ("module-export-all!"); + scm_call_1 (module_export_all_x, mod); + + /* Evaluate Guile module "the-root-module", + and ensure we inherit definitions from it and the "lily" module + N.B. this used to be "the-scm-module" and is deprecated in + Guile V1.9/2.0 + */ + SCM scm_module = ly_lily_module_constant ("the-root-module"); ly_use_module (mod, scm_module); ly_use_module (mod, global_lily_module); } else { + /* Evaluate and call make-safe-lilypond-module */ SCM proc = ly_lily_module_constant ("make-safe-lilypond-module"); mod = scm_call_0 (proc); } @@ -54,19 +63,30 @@ ly_make_module (bool safe) SCM ly_use_module (SCM mod, SCM used) { - SCM expr - = scm_list_3 (ly_symbol2scm ("module-use!"), - mod, - scm_list_2 (ly_symbol2scm ("module-public-interface"), - used)); - + SCM expr = SCM_EOL; + /* + Pick up the module's interface definition. + TODO - Replace inline evaluations (interpreted) + with guile API calls if these become available. + */ + SCM scm_module_use = ly_symbol2scm ("module-use!"); + SCM scm_module_public_interface = ly_symbol2scm ("module-public-interface"); + SCM iface = scm_list_2 (scm_module_public_interface, used); + /* + Set up to interpret + '(module_use! (module-public-interface ) )' + */ + expr = scm_list_3 (scm_module_use, mod, iface); + /* + Now return SCM value, this is the result of interpreting + '(eval (module_use! (module-public-interface )) "lily")' + */ return scm_eval (expr, global_lily_module); } #define FUNC_NAME __FUNCTION__ - SCM ly_module_symbols (SCM mod) { diff --git a/scm/clip-region.scm b/scm/clip-region.scm index 14f593a..1c0a640 100644 --- a/scm/clip-region.scm +++ b/scm/clip-region.scm @@ -19,55 +19,25 @@ (use-modules (lily)) +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;; The procedures shown in this list have been moved to +;; scm/output-lib.scm +;; +;; +;; (define-public (make-rhythmic-location bar-num num den) +;: (define-public (rhythmic-location? a) +;; (define-public (make-graceless-rhythmic-location loc) +;; (define-public rhythmic-location-measure-position cdr) +;; (define-public rhythmic-location-bar-number car) +;; (define-public (rhythmic-location=? a b) +;; (define-public (rhythmic-location>? a b) +;: (define-public (rhythmic-location=? a b) +;; (define-public (rhythmic-location->file-string a) +;; (define-public (rhythmic-location->string a) -(define-public (make-rhythmic-location bar-num num den) - (cons - bar-num (ly:make-moment num den))) - -(define-public (rhythmic-location? a) - (and (pair? a) - (integer? (car a)) - (ly:moment? (cdr a)))) - -(define-public (make-graceless-rhythmic-location loc) - (make-rhythmic-location - (car loc) - (ly:moment-main-numerator (rhythmic-location-measure-position loc)) - (ly:moment-main-denominator (rhythmic-location-measure-position loc)))) - - -(define-public rhythmic-location-measure-position cdr) -(define-public rhythmic-location-bar-number car) - -(define-public (rhythmic-location (car a) (car b)) #f) - (else - (ly:moment=? a b) - (rhythmic-location? a b) - (rhythmic-locationfile-string a) - (ly:format "~a.~a.~a" - (car a) - (ly:moment-main-numerator (cdr a)) - (ly:moment-main-denominator (cdr a)))) - -(define-public (rhythmic-location->string a) - (ly:format "bar ~a ~a" - (car a) - (ly:moment->string (cdr a)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Actual clipping logic. diff --git a/scm/lily.scm b/scm/lily.scm index 4a00ab6..e049aa3 100644 --- a/scm/lily.scm +++ b/scm/lily.scm @@ -196,6 +196,10 @@ messages into errors.") ;(set-debug-cell-accesses! 1000) +;;; Boolean thunk - are we integrating Guile V2.0 or higher with Lilypond? +(define-public (guile-v2 ) + (string>? (version) "1.9.10")) + (use-modules (ice-9 regex) (ice-9 safe) (ice-9 format) @@ -209,6 +213,22 @@ messages into errors.") (scm memory-trace) (scm coverage)) +(define-public _ gettext) +;;; Modules and scheme files loaded by lily.scm use currying +;; in Guile V2 this needs a module which is not present in Guile V1.8 +;; +;; TODO add in modules for V1.8,7 deprecated in V2.0 and integrated +;; into Guile base code, like (ice-9 syncase). +;; +(cond-expand + ((or guile-v2) + (if (ly:get-option 'verbose) + (ly:progress (_ "Using (ice-9 curried-definitions) module\n")) + (use-modules (ice-9 curried-definitions)))) + (else + (if (ly:get-option 'verbose) + (ly:progress (_ "module (ice-9 curried-definitions) not in Guile 1.8\n"))))) + (define-public fancy-format format) @@ -250,6 +270,7 @@ messages into errors.") (if (ly:get-option 'trace-scheme-coverage) (coverage:enable)) + (define-public parser #f) (define music-string-to-path-backends @@ -258,14 +279,13 @@ messages into errors.") (if (memq (ly:get-option 'backend) music-string-to-path-backends) (ly:set-option 'music-strings-to-paths #t)) -(define-public _ gettext) (define-public (ly:load x) (let* ((file-name (%search-load-path x))) (if (ly:get-option 'verbose) (ly:progress "[~A" file-name)) (if (not file-name) - (ly:error (_ "cannot find: ~A") x)) + (ly:error(_"cannot find: ~A") x)) (primitive-load file-name) (if (ly:get-option 'verbose) (ly:progress "]\n")))) @@ -299,7 +319,22 @@ messages into errors.") (eq? (string-ref file-name 2) #\/)))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; If necessary, emulate Guile V2 module_export_all! for Guile V1.8.n +(cond-expand + ((not guile-v2) + (define (module-export-all! mod) + (define (fresh-interface!) + (let ((iface (make-module))) + (set-module-name! iface (module-name mod)) + ;; for guile 2: (set-module-version! iface (module-version mod)) + (set-module-kind! iface 'interface) + (set-module-public-interface! mod iface) + iface)) + (let ((iface (or (module-public-interface mod) + (fresh-interface!)))) + (set-module-obarray! iface (module-obarray mod)))))) +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (define (type-check-list location signature arguments) "Typecheck a list of arguments against a list of type predicates. Print a message at LOCATION if any predicate failed." @@ -671,8 +706,8 @@ PIDs or the number of the process." "Exit function for lilypond" (if (not silently) (case status - ((0) (ly:success "Compilation successfully completed")) - ((1) (ly:warning "Compilation completed with warnings or errors")) + ((0) (ly:success (_ "Compilation successfully completed"))) + ((1) (ly:warning (_ "Compilation completed with warnings or errors"))) (else (ly:message ""))) ) (exit status) @@ -808,7 +843,7 @@ PIDs or the number of the process." (ly:reset-all-fonts)))) files) - ;; we want the failed-files notice in the aggregrate logfile. + ;; we want the failed-files noticed in the aggregrate logfile. (if ping-log (format ping-log "Failed files: ~a\n" failed)) (if (ly:get-option 'dump-profile) diff --git a/scm/output-lib.scm b/scm/output-lib.scm index 409e8c1..f9dbbf4 100644 --- a/scm/output-lib.scm +++ b/scm/output-lib.scm @@ -173,6 +173,56 @@ and duration-log @var{log}." letter))) radius X))) +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; clipping +(define-public (make-rhythmic-location bar-num num den) + (cons + bar-num (ly:make-moment num den))) + +(define-public (rhythmic-location? a) + (and (pair? a) + (integer? (car a)) + (ly:moment? (cdr a)))) + +(define-public (make-graceless-rhythmic-location loc) + (make-rhythmic-location + (car loc) + (ly:moment-main-numerator (rhythmic-location-measure-position loc)) + (ly:moment-main-denominator (rhythmic-location-measure-position loc)))) + + +(define-public rhythmic-location-measure-position cdr) +(define-public rhythmic-location-bar-number car) + +(define-public (rhythmic-location (car a) (car b)) #f) + (else + (ly:moment=? a b) + (rhythmic-location? a b) + (rhythmic-locationfile-string a) + (ly:format "~a.~a.~a" + (car a) + (ly:moment-main-numerator (cdr a)) + (ly:moment-main-denominator (cdr a)))) + +(define-public (rhythmic-location->string a) + (ly:format "bar ~a ~a" + (car a) + (ly:moment->string (cdr a)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; break visibility -- 1.7.0.4