]> git.donarmstrong.com Git - lilypond.git/commitdiff
Removes pure-print-callbacks list.
authorMike Solomon <mike@apollinemike.com>
Wed, 20 Feb 2013 05:58:02 +0000 (06:58 +0100)
committerMike Solomon <mike@apollinemike.com>
Wed, 20 Feb 2013 05:58:02 +0000 (06:58 +0100)
LilyPond currently hardcodes certain print functions as being able
to be evaluated as 'pure', meaning that they should not result in calls
to set_property, set_object, translate_axis or suicide.  This means that,
for example, if one uses a custom stencil function, the Y-extent function
for the grob must be wrapped in an unpure-pure-container in order
to return a non-empty pure_height.

The reading of these hardcoded lists results in difficult-to-maintain code.
For example, several (but not all) flag modification functions are part of
this list, causing spacing inconsistencies in certain regtests.
Using unpure-pure-containers to signify all relationships between unpure and
pure functions and eliminating the lists of pure functions in
define-grobs.scm allows the code base to be more extensible, demanding the
elaboration of unpure-pure relationships in the property-setting phase
(either in define-grobs.scm or in an override) and not using hardcoded lists.

Inversely, this also prevents deep that can creep up when a function
signified as pure turns out not to be.  For example, ly:note-head::print,
marked as pure, can be made unpure if its lookup of the style,
duration-log or glyph-name properties trigger vertical alignment
(which results in a call to translate_axis). Thus, users who wish to use
this function as an unpure function now can because it is no longer
hardcoded as pure.

scm/define-grobs.scm
scm/output-lib.scm

index cc4a9c76e935f7ba965f2904aedcfce460856724..915a51ca72c4619e9b8c25977a16221ccbf25b08 100644 (file)
        (glyph-name . ,note-head::calc-glyph-name)
        (stencil . ,ly:note-head::print)
        (Y-offset . ,ly:staff-symbol-referencer::callback)
+       (Y-extent . ,grob::all-heights-from-stencil)
        (meta . ((class . Item)
                 (interfaces . (ambitus-interface
                                font-interface
                        (next-note . (semi-fixed-space . 0.9))
                        (right-edge . (extra-space . 0.0))))
        (stencil . ,ly:bar-line::print)
+       (Y-extent . ,grob::all-heights-from-stencil)
        (meta . ((class . Item)
                  (object-callbacks . ((pure-Y-common . ,ly:axis-group-interface::calc-pure-y-common)
                                       (pure-relevant-grobs . ,ly:pure-from-neighbor-interface::calc-pure-relevant-grobs)))
                        ,(ly:make-simple-closure
                          (list ly:self-alignment-interface::x-aligned-on-self)))))
        (Y-offset . ,ly:side-position-interface::y-aligned-side)
+       (Y-extent . ,grob::all-heights-from-stencil)
        (meta .
              ((class . Item)
               (interfaces . (break-alignable-interface
     (BassFigure
      . (
        (stencil . ,ly:text-interface::print)
+       (Y-extent . ,grob::all-heights-from-stencil)
        (meta . ((class . Item)
                 (interfaces . (bass-figure-interface
                                font-interface
        (stencil . ,ly:text-interface::print)
        (text . ,(make-musicglyph-markup "scripts.rcomma"))
        (Y-offset . ,ly:breathing-sign::offset-callback)
+       (Y-extent . ,grob::all-heights-from-stencil)
        (meta . ((class . Item)
                 (interfaces . (break-aligned-interface
                                breathing-sign-interface
        (extra-spacing-height . (0.2 . -0.2))
        (extra-spacing-width . (-0.5 . 0.5))
        (word-space . 0.0)
+       (Y-extent . ,grob::all-heights-from-stencil)
        (meta . ((class . Item)
                 (interfaces . (chord-name-interface
                                font-interface
                        (next-note . (extra-space . 1.0))
                        (right-edge . (extra-space . 0.5))))
        (stencil . ,ly:clef::print)
+       (Y-extent . ,grob::all-heights-from-stencil)
        (vertical-skylines . ,ly:grob::vertical-skylines-from-stencil)
        (Y-offset . ,ly:staff-symbol-referencer::callback)
        (meta . ((class . Item)
        (stencil . ,ly:text-interface::print)
        (X-offset . ,ly:self-alignment-interface::x-aligned-on-self)
        (Y-offset . ,ly:side-position-interface::y-aligned-side)
+       (Y-extent . ,grob::all-heights-from-stencil)
        (meta . ((class . Item)
                 (interfaces . (font-interface
                                side-position-interface
                        (right-edge . (extra-space . 0.5))))
        (stencil . ,ly:clef::print)
        (vertical-skylines . ,ly:grob::vertical-skylines-from-stencil)
+       (Y-extent . ,grob::all-heights-from-stencil)
        (Y-offset . ,ly:staff-symbol-referencer::callback)
        (meta . ((class . Item)
                  (object-callbacks . ((pure-Y-common . ,ly:axis-group-interface::calc-pure-y-common)
                        (next-note . (extra-space . 1.0))
                        (right-edge . (extra-space . 0.5))))
        (stencil . ,ly:clef::print)
+       (Y-extent . ,grob::all-heights-from-stencil)
        (Y-offset . ,ly:staff-symbol-referencer::callback)
        (meta . ((class . Item)
                  (object-callbacks . ((pure-Y-common . ,ly:axis-group-interface::calc-pure-y-common)
        (dot-count . ,dots::calc-dot-count)
        (staff-position . ,dots::calc-staff-position)
        (stencil . ,ly:dots::print)
+       (Y-extent . ,grob::all-heights-from-stencil)
        (extra-spacing-height . (-0.5 . 0.5))
        (meta . ((class . Item)
                 (interfaces . (dots-interface
        (slash-negative-kern . 1.6)
        (slope . 1.0)
        (stencil . ,ly:percent-repeat-item-interface::double-percent)
+       (Y-extent . ,grob::all-heights-from-stencil)
        (thickness . 0.48)
        (meta . ((class . Item)
                 (interfaces . (break-aligned-interface
                          (list ly:self-alignment-interface::centered-on-y-parent))
                        ,(ly:make-simple-closure
                          (list ly:self-alignment-interface::x-aligned-on-self)))))
+       (Y-extent . ,grob::all-heights-from-stencil)
        (Y-offset . ,ly:side-position-interface::y-aligned-side)
        (meta . ((class . Item)
                 (interfaces . (font-interface
        (slash-negative-kern . 1.6)
        (slope . 1.0)
        (stencil . ,ly:percent-repeat-item-interface::beat-slash)
+       (Y-extent . ,grob::all-heights-from-stencil)
        (thickness . 0.48)
        (meta . ((class . Item)
                 (interfaces . (font-interface
        (self-alignment-Y . ,CENTER)
        (stencil . ,ly:text-interface::print)
        (vertical-skylines . ,ly:grob::vertical-skylines-from-stencil)
+       (Y-extent . ,grob::all-heights-from-stencil)
        (X-offset . ,ly:self-alignment-interface::x-aligned-on-self)
        (Y-offset . ,ly:self-alignment-interface::y-aligned-on-self)
        (meta . ((class . Item)
        (staff-padding . 0.5)
        (stencil . ,ly:text-interface::print)
        (text . ,fingering::calc-text)
+       (Y-extent . ,grob::all-heights-from-stencil)
        (meta . ((class . Item)
                 (interfaces . (finger-interface
                                font-interface
        (X-offset . ,ly:flag::calc-x-offset)
        (Y-offset . ,ly:flag::calc-y-offset)
        (vertical-skylines . ,ly:grob::vertical-skylines-from-stencil)
+       (Y-extent . ,grob::all-heights-from-stencil)
        (meta . ((class . Item)
                 (interfaces . (flag-interface
                                 font-interface))))))
        (stencil . ,fret-board::calc-stencil)
        (extra-spacing-height . (0.2 . -0.2))
        (extra-spacing-width . (-0.5 . 0.5))
+       (Y-extent . ,grob::all-heights-from-stencil)
        (meta . ((class . Item)
                 (interfaces . (chord-name-interface
                                font-interface
        (side-axis . ,Y)
        (staff-padding . 0.5)
        (stencil . ,ly:text-interface::print)
+       (Y-extent . ,grob::all-heights-from-stencil)
        (X-offset . ,ly:self-alignment-interface::x-aligned-on-self)
        (Y-offset . ,ly:side-position-interface::y-aligned-side)
        (meta . ((class . Item)
                        (right-edge . (extra-space . 0.5))
                        (first-note . (fixed-space . 2.5))))
        (stencil . ,ly:key-signature-interface::print)
+       (Y-extent . ,grob::all-heights-from-stencil)
        (vertical-skylines . ,ly:grob::vertical-skylines-from-stencil)
        (extra-spacing-width . (0.0 . 1.0))
        (extra-spacing-height . ,pure-from-neighbor-interface::extra-spacing-height-including-staff)
                        (right-edge . (extra-space . 0.5))
                        (first-note . (fixed-space . 2.5))))
        (stencil . ,ly:key-signature-interface::print)
+       (Y-extent . ,grob::all-heights-from-stencil)
        (extra-spacing-width . (0.0 . 1.0))
        (extra-spacing-height . ,pure-from-neighbor-interface::extra-spacing-height-including-staff)
        (vertical-skylines . ,ly:grob::vertical-skylines-from-stencil)
        (thickness . 1.0)
        (extra-spacing-height . (-0.5 . 0.5))
        (vertical-skylines . ,ly:grob::vertical-skylines-from-stencil)
+       (Y-extent . ,grob::all-heights-from-stencil)
        (meta . ((class . Item)
                 (interfaces . (semi-tie-interface))))))
 
        (skyline-horizontal-padding . 0.1)
        (vertical-skylines . ,ly:grob::vertical-skylines-from-stencil)
        (X-offset . ,ly:self-alignment-interface::aligned-on-x-parent)
+       (Y-extent . ,grob::all-heights-from-stencil)
        (meta . ((class . Item)
                 (interfaces . (font-interface
                                lyric-syllable-interface
        (self-alignment-X . ,LEFT)
        (break-align-symbols . (time-signature))
        (non-break-align-symbols . (multi-measure-rest-interface))
+       (Y-extent . ,grob::all-heights-from-stencil)
        (meta . ((class . Item)
                 (interfaces . (break-alignable-interface
                                font-interface
                          (list ly:self-alignment-interface::x-centered-on-y-parent)))))
        (Y-offset . ,ly:side-position-interface::y-aligned-side)
        (vertical-skylines . ,ly:grob::vertical-skylines-from-stencil)
+       (Y-extent . ,grob::all-heights-from-stencil)
        (meta . ((class . Spanner)
                 (interfaces . (font-interface
                                multi-measure-interface
                          (list ly:self-alignment-interface::x-aligned-on-self)))))
        (Y-offset . ,ly:side-position-interface::y-aligned-side)
        (vertical-skylines . ,ly:grob::vertical-skylines-from-stencil)
+       (Y-extent . ,grob::all-heights-from-stencil)
        (meta . ((class . Spanner)
                 (interfaces . (font-interface
                                multi-measure-interface
        (stencil . ,ly:note-head::print)
        (X-offset . ,ly:note-head::stem-x-shift)
        (Y-offset . ,ly:staff-symbol-referencer::callback)
+       (Y-extent . ,grob::all-heights-from-stencil)
        (meta . ((class . Item)
                 (interfaces . (font-interface
                                gregorian-ligature-interface
     (NoteName
      . (
        (stencil . ,ly:text-interface::print)
+       (Y-extent . ,grob::all-heights-from-stencil)
        (meta . ((class . Item)
                 (interfaces . (font-interface
                                note-name-interface
                          (list ly:self-alignment-interface::centered-on-x-parent)))))
        (Y-offset . ,ly:side-position-interface::y-aligned-side)
        (vertical-skylines . ,ly:grob::vertical-skylines-from-stencil)
+       (Y-extent . ,grob::all-heights-from-stencil)
        (meta . ((class . Item)
                 (interfaces . (font-interface
                                octavate-eight-interface
                        ,(ly:make-simple-closure
                          (list ly:self-alignment-interface::x-aligned-on-self)))))
        (Y-offset . ,ly:side-position-interface::y-aligned-side)
+       (Y-extent . ,grob::all-heights-from-stencil)
        (meta . ((class . Spanner)
                 (interfaces . (font-interface
                                percent-repeat-interface
                        ,(ly:make-simple-closure
                          (list ly:self-alignment-interface::x-aligned-on-self)))))
        (Y-offset . ,ly:side-position-interface::y-aligned-side)
+       (Y-extent . ,grob::all-heights-from-stencil)
        (meta . ((class . Item)
                 (interfaces . (break-alignable-interface
                                font-interface
        (slash-negative-kern . 0.85)
        (slope . 1.7)
        (stencil . ,ly:percent-repeat-item-interface::beat-slash)
+       (Y-extent . ,grob::all-heights-from-stencil)
        (thickness . 0.48)
        (meta . ((class . Item)
                 (interfaces . (percent-repeat-interface
 
        (stencil . ,ly:script-interface::print)
        (vertical-skylines . ,ly:grob::vertical-skylines-from-stencil)
+       (Y-extent . ,grob::all-heights-from-stencil)
        (X-offset . ,script-interface::calc-x-offset)
        (Y-offset . ,ly:side-position-interface::y-aligned-side)
        (meta . ((class . Item)
        (stencil . ,ly:text-interface::print)
        (vertical-skylines . ,ly:grob::vertical-skylines-from-stencil)
        (X-offset . ,ly:self-alignment-interface::x-aligned-on-self)
+       (Y-extent . ,grob::all-heights-from-stencil)
        (meta . ((class . Item)
                 (interfaces . (font-interface
                                piano-pedal-script-interface
        (side-axis . ,X)
        (stencil . ,ly:text-interface::print)
        (X-offset . ,ly:side-position-interface::x-aligned-side)
+       (Y-extent . ,grob::all-heights-from-stencil)
        (meta . ((class . Item)
                 (interfaces . (font-interface
                                side-position-interface
        (staff-padding . 0.5)
        (stencil . ,print-circled-text-callback)
        (text . ,string-number::calc-text)
+       (Y-extent . ,grob::all-heights-from-stencil)
        (meta . ((class . Item)
                 (interfaces . (font-interface
                                self-alignment-interface
        (staff-padding . 0.5)
        (stencil . ,ly:text-interface::print)
        (text . ,stroke-finger::calc-text)
+       (Y-extent . ,grob::all-heights-from-stencil)
        (meta . ((class . Item)
                 (interfaces . (font-interface
                                self-alignment-interface
        (stencil . ,ly:sustain-pedal::print)
        (vertical-skylines . ,ly:grob::vertical-skylines-from-stencil)
        (X-offset . ,ly:self-alignment-interface::x-aligned-on-self)
+       (Y-extent . ,grob::all-heights-from-stencil)
        (meta . ((class . Item)
                 (interfaces . (font-interface
                                piano-pedal-interface
        (whiteout . #t)
        (X-offset . ,ly:self-alignment-interface::x-aligned-on-self)
        (Y-offset . ,ly:staff-symbol-referencer::callback)
+       (Y-extent . ,grob::all-heights-from-stencil)
        (meta . ((class . Item)
                 (interfaces  . (font-interface
                                 note-head-interface
        (stencil . ,ly:text-interface::print)
        (vertical-skylines . ,ly:grob::vertical-skylines-from-stencil)
        ;; todo: add X self alignment?
+       (Y-extent . ,grob::all-heights-from-stencil)
        (X-offset . ,ly:self-alignment-interface::x-aligned-on-self)
        (Y-offset . ,ly:side-position-interface::y-aligned-side)
        (meta . ((class . Item)
                        (right-edge . (extra-space . 0.5))
                        (staff-bar . (minimum-space . 2.0))))
        (stencil . ,ly:time-signature::print)
+       (Y-extent . ,grob::all-heights-from-stencil)
        (style . C)
        (meta . ((class . Item)
                  (object-callbacks . ((pure-Y-common . ,ly:axis-group-interface::calc-pure-y-common)
        (stencil . ,parenthesize-elements)
        (stencils . ,parentheses-item::calc-parenthesis-stencils)
        (X-offset . ,ly:side-position-interface::x-aligned-side)
+       (Y-extent . ,grob::all-heights-from-stencil)
        (meta . ((class . Item)
                 (interfaces . (axis-group-interface
                                font-interface
        (font-size . -4)
        (stencil . ,ly:note-head::print)
        (Y-offset . ,ly:staff-symbol-referencer::callback)
+       (Y-extent . ,grob::all-heights-from-stencil)
        (meta . ((class . Item)
                 (interfaces . (font-interface
                                ledgered-interface
        (self-alignment-X . ,CENTER)
        (stencil . ,ly:text-interface::print)
        (vertical-skylines . ,ly:grob::vertical-skylines-from-stencil)
+       (Y-extent . ,grob::all-heights-from-stencil)
        (X-offset . ,ly:self-alignment-interface::x-aligned-on-self)
        (meta . ((class . Item)
                 (interfaces . (font-interface
          (interval-union '(0 . 0) (cons smaller larger)))
        '(0 . 0))))
 
-(define pure-print-callbacks
-  (list
-   fret-board::calc-stencil
-   note-head::brew-ez-stencil
-   print-circled-text-callback
-   laissez-vibrer::print
-   lyric-text::print
-   ly:bar-line::print
-   ly:mensural-ligature::brew-ligature-primitive
-   ly:note-head::print
-   ly:dots::print
-   ly:clef::print
-   ly:flag::print
-   ly:time-signature::print
-   default-flag
-   normal-flag
-   mensural-flag
-   no-flag
-   modern-straight-flag
-   old-straight-flag
-   ly:key-signature-interface::print
-   ly:percent-repeat-item-interface::beat-slash
-   ly:text-interface::print
-   ly:script-interface::print
-   ly:sustain-pedal::print))
-
 ;; Sometimes we have grobs with (Y-extent . ,ly:grob::stencil-height)
 ;; and the print function is not pure, but there is a easy way to
 ;; figure out the Y-extent from the print function.
 (define (pure-stencil-height grob start stop)
   (let* ((sten (ly:grob-property-data grob 'stencil))
         (pure-height-callback (assoc-get sten pure-print-to-height-conversions)))
-    (cond ((or
-           (ly:stencil? sten)
-           (memq sten pure-print-callbacks))
+    (cond ((ly:stencil? sten)
           (ly:grob::stencil-height grob))
          ((procedure? pure-height-callback)
           (pure-height-callback grob start stop))
                (let ((stencil (ly:grob-property-data grob 'stencil)))
                  (or
                   (not (eq? extent-callback ly:grob::stencil-height))
-                  (memq stencil pure-print-callbacks)
                   (assq stencil pure-print-to-height-conversions)
                   (ly:stencil? stencil)))))))))
 
index 641ca7ce50abaf01162bd5881507b9229a8e3078..6c43b0aab1dccb695a0c0c032b1424203944ce14 100644 (file)
 
     (ly:text-interface::interpret-markup layout props text)))
 
+;; Using this as a callback for a grob's Y-extent promises
+;; that the grob's stencil does not depend on line-spacing.
+;; We use this promise to figure the space required by Clefs
+;; and such at the note-spacing stage.
+
+(define-public grob::all-heights-from-stencil
+  (ly:make-unpure-pure-container
+    ly:grob::stencil-height
+    (lambda (grob start end) (ly:grob::stencil-height grob))))
+
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; beam slope