]> git.donarmstrong.com Git - lilypond.git/commitdiff
* lily/include/lily-lexer.hh (class Lily_lexer): lose hungarian _b
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Mon, 10 Jan 2005 22:33:33 +0000 (22:33 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Mon, 10 Jan 2005 22:33:33 +0000 (22:33 +0000)
suffix for main_input_b_.

* scm/music-functions.scm (toplevel-music-functions):
precompute music lengths for music expressions.

ChangeLog
lily/include/lily-lexer.hh
lily/lexer.ll
lily/lily-lexer.cc
lily/lily-parser.cc
lily/music.cc
scm/define-grobs.scm
scm/define-music-properties.scm
scm/define-music-types.scm
scm/music-functions.scm

index 99b7d155b834305461f94a53575da916959143f1..cff57e8791eb4fa708a471ba9300c2dd90cd6461 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2005-01-10  Han-Wen Nienhuys  <hanwen@xs4all.nl>
+
+       * lily/include/lily-lexer.hh (class Lily_lexer): lose hungarian _b
+       suffix for main_input_b_.
+
+       * scm/music-functions.scm (toplevel-music-functions):
+       precompute music lengths for music expressions.  
+
 2005-01-11  Nicolas Sceaux  <nicolas.sceaux@free.fr>
 
        * lily/include/input.hh (class Input): new `end_' slot for end of
index 0e42719912c893717dac5e0e3e8d24ea63e0f3b1..0cd081cd520287e786a42a91fa49b65cfb7221b0 100644 (file)
@@ -39,7 +39,7 @@ public:
   String main_input_name_;
   void *lexval;
   Input *lexloc;
-  bool main_input_b_;
+  bool is_main_input_;
   
   Sources *sources_; 
 
index 2e4d96401ef029c1881a2e09e8d3f9713d4ff53f..a56385cd2a82600530f398d8f5cfa13d0b6afefc 100644 (file)
@@ -216,7 +216,7 @@ HYPHEN              --
        }
        <<EOF>>         {
                LexerError (_ ("EOF found inside a comment").to_str0 ());
-               main_input_b_ = false;
+               is_main_input_ = false;
                if (! close_input ()) 
                  yyterminate (); // can't move this, since it actually rets a YY_NULL
        }
@@ -224,10 +224,10 @@ HYPHEN            --
 
 
 <INITIAL,chords,lyrics,notes,figures>\\maininput           {
-       if (!main_input_b_)
+       if (!is_main_input_)
        {
                start_main_input ();
-               main_input_b_ = true;
+               is_main_input_ = true;
        }
        else
                error (_ ("\\maininput not allowed outside init files"));
@@ -279,7 +279,7 @@ HYPHEN              --
        Input hi = here_input();
        hi.step_forward ();
        SCM sval = ly_parse_scm (hi.start_, &n, hi,
-               be_safe_global && main_input_b_);
+               be_safe_global && is_main_input_);
 
        if (sval == SCM_UNDEFINED)
        {
@@ -536,9 +536,9 @@ HYPHEN              --
 }
 
 <<EOF>> {
-       if (main_input_b_)
+       if (is_main_input_)
        {
-               main_input_b_ = false;
+               is_main_input_ = false;
                if (!close_input ())
                /* Returns YY_NULL */
                        yyterminate ();
index de95f11f44375b05181e885af8fd5d028df0c509..559d5340a3af0ef9117fcc00e242d863018c71d1 100644 (file)
@@ -91,7 +91,7 @@ Lily_lexer::Lily_lexer (Sources *sources)
   sources_ = sources;
   scopes_ = SCM_EOL;
   error_level_ = 0; 
-  main_input_b_ = false;
+  is_main_input_ = false;
 
   smobify_self ();
   
@@ -109,7 +109,7 @@ Lily_lexer::Lily_lexer (Lily_lexer const &src)
   sources_ = src.sources_;
   
   error_level_ = src.error_level_; 
-  main_input_b_ = src.main_input_b_;
+  is_main_input_ = src.is_main_input_;
 
   scopes_ = SCM_EOL;
   
index 3eb14cd13e13d27c40882d845159eb4a3eb656d8..534352be3042434dc079dcdbc426ada60c609903 100644 (file)
@@ -142,7 +142,7 @@ Lily_parser::parse_string (String ly_code)
                          self_scm ());
   
   lexer_->main_input_name_ = "<string>";
-  lexer_->main_input_b_ = true;
+  lexer_->is_main_input_ = true;
 
   set_yydebug (0);
   lexer_->new_input (lexer_->main_input_name_, ly_code, sources_);
index 5183763f8ded12f58ec7a3bc73d6360763cfcff2..3ce9c302ce7b6331693784a170cd686c674c2a11 100644 (file)
@@ -88,7 +88,9 @@ Music::get_length () const
   SCM lst = get_property ("length");
   if (unsmob_moment (lst))
     return *unsmob_moment (lst);
-  else if (ly_c_procedure_p (lst))
+
+  lst = get_property ("length-callback");
+  if (ly_c_procedure_p (lst))
     {
       SCM res = scm_call_1 (lst, self_scm ());
       return *unsmob_moment (res);
index ad4a6fa6584171a1517d369a90a795c792cc564d..8c477e6e61dc317c4adf742875693c6e998b1e71 100644 (file)
                                      break-aligned-interface item-interface ))))
        ))
 
-
     (DotColumn
      . (
        (axes . (0))
        (staff-padding . 0.25)
        (meta . ((interfaces . (side-position-interface multi-measure-interface self-alignment-interface font-interface spanner-interface text-interface))))
        ))
- (NoteCollision
+
+    (NoteCollision
      . (
        (axes . (0 1))
        (X-extent-callback . ,Axis_group_interface::group_extent_callback)
index c3c6eadac5d260781160dea8b86d744c7b190396..b8aba452ff8364dfb4d67fd5649ee71c9be4a8af 100644 (file)
@@ -65,7 +65,8 @@ e.g. @code{\\tag #'part ...} could tag a piece of music as only being active in
      (inversion ,boolean? "If set, this chord note is inverted.")
      (label ,markup? "label of a mark.")
      (last-pitch ,ly:pitch? "The last pitch after relativization.")
-     (length ,procedure? "How to compute the duration of this music")
+     (length ,ly:moment? "The duration of this music")
+     (length-callback ,procedure? "How to compute the duration of this music")
      (internal-class-name ,string? "C++ class to use for this Music object") 
      (name ,symbol? "Name of this music object")
      (numerator ,integer? "numerator of a time signature")
index 5784760d328878357ef9592a0cc688f720357a14..57d4acf8dde7f157d05835c0f75966d211f7c17b 100644 (file)
@@ -615,7 +615,7 @@ does not create staffs or voices implicitly.
 
 Syntax: @code{\\skip }@var{duration}.")
        (internal-class-name . "Music")
-       (length . ,ly:music-duration-length)
+       (length-callback . ,ly:music-duration-length)
        (iterator-ctor . ,Simple_music_iterator::constructor)
        (types . (general-music event rhythmic-event skip-event))
        ))
@@ -712,7 +712,7 @@ Syntax: @code{\\\\}")
        (internal-class-name . "Repeated_music")
        (description . "")
        (start-moment-function .  ,Repeated_music::first_start)
-       (length . ,Repeated_music::volta_music_length)
+       (length-callback . ,Repeated_music::volta_music_length)
        (types . (general-music repeated-music volta-repeated-music))
        ))
     
@@ -723,7 +723,7 @@ Syntax: @code{\\\\}")
        (start-moment-function .  ,Repeated_music::first_start)
        (internal-class-name . "Repeated_music")
        (types . (general-music repeated-music unfolded-repeated-music))
-       (length . ,Repeated_music::unfolded_music_length)
+       (length-callback . ,Repeated_music::unfolded_music_length)
        ))
     (PercentRepeatedMusic
      . (
@@ -731,7 +731,7 @@ Syntax: @code{\\\\}")
        (description .  "Repeats encoded by percents.")
        (iterator-ctor . ,Percent_repeat_iterator::constructor)
        (start-moment-function .  ,Repeated_music::first_start)
-       (length . ,Repeated_music::unfolded_music_length)
+       (length-callback . ,Repeated_music::unfolded_music_length)
        (types . (general-music repeated-music percent-repeated-music))
        ))
     
@@ -743,7 +743,7 @@ Syntax: @code{\\\\}")
        (start-moment-function .  ,Repeated_music::first_start)
 
        ;; the length of the repeat is handled by shifting the note logs
-       (length . ,Repeated_music::folded_music_length)
+       (length-callback . ,Repeated_music::folded_music_length)
        (types . (general-music repeated-music tremolo-repeated-music))
        
        ))
@@ -754,7 +754,7 @@ Syntax: @code{\\\\}")
        (description .  "Repeats with alternatives placed in parallel. ")
        (iterator-ctor  . ,Folded_repeat_iterator::constructor)
        (start-moment-function .  ,Repeated_music::minimum_start)
-       (length . ,Repeated_music::folded_music_length)
+       (length-callback . ,Repeated_music::folded_music_length)
        (types . (general-music repeated-music folded-repeated-music))
        ))
     ))
index f4bee703a25d16f7c42edcf812c7dce2d8e60a3a..b19cc5cf88315e3ce73e7208714809dd6493726c 100644 (file)
                              ly:grob-set-property!))
 
 (define-public (music-map function music)
-  "Apply @var{function} to @var{music} and all of the music it contains. "
+  "Apply @var{function} to @var{music} and all of the music it contains.
+
+First it recurses over the children, then the function is applied to MUSIC.
+"
   (let ((es (ly:music-property music 'elements))
        (e (ly:music-property music 'element)))
     (set! (ly:music-property music 'elements) 
@@ -635,12 +638,18 @@ Syntax:
       (set! (ly:music-property music 'error-found) #t))
   music)
 
+(define (precompute-music-length music)
+  (set! (ly:music-property music 'length)
+       (ly:music-length music))
+  music)
+
 (define-public toplevel-music-functions
   (list
    ;; check-start-chords ; ; no longer needed with chord syntax. 
    (lambda (music parser) (voicify-music music))
    (lambda (x parser) (music-map glue-mm-rest-texts x))
    (lambda (x parser) (music-map music-check-error x))
+   (lambda (x parser) (music-map precompute-music-length x))
    (lambda (music parser)
 
      (music-map (quote-substitute (ly:parser-lookup parser 'musicQuotes))  music))