From 1c8ae9fb4170bb2566c2acb1a11155c23c12cfdc Mon Sep 17 00:00:00 2001 From: Ian Hulin Date: Tue, 8 Nov 2011 12:29:23 +0000 Subject: [PATCH] Tracker 2025 - move safe utility to separate module to aid Guile V2 migration lily.scm (define safe-objects) and (define-macro define-safe-public) moved to new scm/safe-utility-defs.scm new file scm/safe-utility-defs.scm All other scm files using define-safe-public now have (use-modules (scm safe-utility-defs)) call added. scm/chord-entry.scm scm/define-music-types.scm scm/lily-library.scm scm/music-functions.scm scm/paper.scm --- scm/chord-entry.scm | 3 +++ scm/define-music-types.scm | 3 +++ scm/lily-library.scm | 3 +++ scm/lily.scm | 24 ++---------------- scm/music-functions.scm | 3 +++ scm/paper.scm | 3 +++ scm/safe-utility-defs.scm | 51 ++++++++++++++++++++++++++++++++++++++ 7 files changed, 68 insertions(+), 22 deletions(-) create mode 100644 scm/safe-utility-defs.scm diff --git a/scm/chord-entry.scm b/scm/chord-entry.scm index 06cc077ce4..dc0bb85a8c 100644 --- a/scm/chord-entry.scm +++ b/scm/chord-entry.scm @@ -15,6 +15,9 @@ ;;;; You should have received a copy of the GNU General Public License ;;;; along with LilyPond. If not, see . +; for define-safe-public when byte-compiling using Guile V2 +(use-modules (scm safe-utility-defs)) + (define-public (construct-chord-elements root duration modifications) "Build a chord on root using modifiers in @var{modifications}. @code{NoteEvents} have duration @var{duration}. diff --git a/scm/define-music-types.scm b/scm/define-music-types.scm index 4085957e03..015a628c53 100644 --- a/scm/define-music-types.scm +++ b/scm/define-music-types.scm @@ -16,6 +16,9 @@ ;;;; You should have received a copy of the GNU General Public License ;;;; along with LilyPond. If not, see . +; for define-safe-public when byte-compiling using Guile V2 +(use-modules (scm safe-utility-defs)) + ;; TODO: should link back into user manual. (define-public music-descriptions diff --git a/scm/lily-library.scm b/scm/lily-library.scm index 5b990e7604..97a96d1d3e 100644 --- a/scm/lily-library.scm +++ b/scm/lily-library.scm @@ -19,6 +19,9 @@ ; for take, drop, take-while, list-index, and find-tail: (use-modules (srfi srfi-1)) +; for define-safe-public when byte-compiling using Guile V2 +(use-modules (scm safe-utility-defs)) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; constants. diff --git a/scm/lily.scm b/scm/lily.scm index 4ab0164850..78a7197fcd 100644 --- a/scm/lily.scm +++ b/scm/lily.scm @@ -219,7 +219,8 @@ messages into errors.") (srfi srfi-14) (scm clip-region) (scm memory-trace) - (scm coverage)) + (scm coverage) + (scm safe-utility-defs)) (define-public _ gettext) ;;; There are new modules defined in Guile V2.0 which we need to use. @@ -344,27 +345,6 @@ messages into errors.") (fresh-interface!)))) (set-module-obarray! iface (module-obarray mod)))))) -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; Safe definitions utility - -(define safe-objects - (list)) - -(define-macro (define-safe-public arglist . body) - "Define a variable, export it, and mark it as safe, i.e. usable in -LilyPond safe mode. The syntax is the same as `define*-public'." - (define (get-symbol arg) - (if (pair? arg) - (get-symbol (car arg)) - arg)) - - (let ((safe-symbol (get-symbol arglist))) - `(begin - (define*-public ,arglist - ,@body) - (set! safe-objects (cons (cons ',safe-symbol ,safe-symbol) - safe-objects)) - ,safe-symbol))) (define-safe-public (lilypond-version) (string-join diff --git a/scm/music-functions.scm b/scm/music-functions.scm index 5f73038d91..f18a6507fd 100644 --- a/scm/music-functions.scm +++ b/scm/music-functions.scm @@ -16,6 +16,9 @@ ;;;; You should have received a copy of the GNU General Public License ;;;; along with LilyPond. If not, see . +; for define-safe-public when byte-compiling using Guile V2 +(use-modules (scm safe-utility-defs)) + ;; (use-modules (ice-9 optargs)) ;;; ly:music-property with setter diff --git a/scm/paper.scm b/scm/paper.scm index 3208f4b82a..3230c65087 100644 --- a/scm/paper.scm +++ b/scm/paper.scm @@ -15,6 +15,9 @@ ;;;; You should have received a copy of the GNU General Public License ;;;; along with LilyPond. If not, see . +; for define-safe-public when byte-compiling using Guile V2 +(use-modules (scm safe-utility-defs)) + (define-public (set-paper-dimension-variables mod) (module-define! mod 'dimension-variables '(blot-diameter diff --git a/scm/safe-utility-defs.scm b/scm/safe-utility-defs.scm new file mode 100644 index 0000000000..7600c39f5a --- /dev/null +++ b/scm/safe-utility-defs.scm @@ -0,0 +1,51 @@ +;;;; This file is part of LilyPond, the GNU music typesetter. +;;;; +;;;; Copyright (C) 1998--2011 Jan Nieuwenhuizen +;;;; Han-Wen Nienhuys +;;;; +;;;; LilyPond is free software: you can redistribute it and/or modify +;;;; it under the terms of the GNU General Public License as published by +;;;; the Free Software Foundation, either version 3 of the License, or +;;;; (at your option) any later version. +;;;; +;;;; LilyPond 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 General Public License for more details. +;;;; +;;;; You should have received a copy of the GNU General Public License +;;;; along with LilyPond. If not, see . +;;; +;;; Author Ian Hulin +;;; Date 16 October 2011 +;;; + +(define-module (scm safe-utility-defs) +#:use-module (ice-9 optargs) +#:export (safe-objects) +#:export-syntax (define-safe-public) +#:re-export-syntax (define*-public)) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Safe definitions utility + +(define safe-objects + (list)) + +(define (get-symbol arg) + (if (pair? arg) + (get-symbol (car arg)) + arg)) + + +(define-macro (define-safe-public arglist . body) + "Define a variable, export it, and mark it as safe, i.e. usable in +LilyPond safe mode. The syntax is the same as `define*-public'." + + (let ((safe-symbol (get-symbol arglist))) + `(begin + (define*-public ,arglist + ,@body) + (set! safe-objects (cons (cons ',safe-symbol ,safe-symbol) + safe-objects)) + ,safe-symbol))) -- 2.39.2