]> git.donarmstrong.com Git - lilypond.git/commitdiff
(ordered_elements): we cannot
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Mon, 22 Mar 2004 22:33:57 +0000 (22:33 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Mon, 22 Mar 2004 22:33:57 +0000 (22:33 +0000)
modify the #'elements property, so return reordered array.

ChangeLog
lily/axis-group-interface.cc
lily/box.cc
lily/break-align-interface.cc
lily/include/break-align-interface.hh
lily/multi-measure-rest.cc
lily/property-iterator.cc
lily/separating-line-group-engraver.cc
lily/translator-property.cc

index d1cc15defb07a02191cf839cfe0b545b51ced032..eccd595f384e9d2d8b13c8613ac041a28e737cb9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2004-03-22  Han-Wen Nienhuys   <hanwen@xs4all.nl>
+
+       * lily/break-align-interface.cc (ordered_elements): we cannot
+       modify the #'elements property, so return reordered array.
+
 2004-03-23  Heikki Junes  <hjunes@cc.hut.fi>
 
        * buildscripts/lilypond.words.py: remove.
index 40ea7ca721184950bd5f298a98b2ef09cceed876..1f628a458c2d7fcf8b8d8f924a788ee4f7047214 100644 (file)
@@ -62,7 +62,7 @@ Axis_group_interface::group_extent_callback (SCM element_smob, SCM scm_axis)
   Grob * common = common_refpoint_of_list (elts, me, a);
 
   Real my_coord = me->relative_coordinate (common, a);
-  Interval r (relative_group_extent (a, common,elts));
+  Interval r (relative_group_extent (a, common, elts));
 
   return ly_interval2scm (r - my_coord);
 }
index a61a8abf08f4284594d8eb49e0442d54271e5190..5ec4a9f03949234f7ce87d003b2f6f157b8a0eb9 100644 (file)
@@ -80,5 +80,4 @@ Box::widen (Real x, Real y)
 {
   interval_a_[X_AXIS].widen (x);
   interval_a_[Y_AXIS].widen (y);
-  
 }
index aadb89a9987fb977833f67032b98d3389c63daf2..3e5f9d38b5ea39bebf027465ea02176aac9896a9 100644 (file)
@@ -63,49 +63,46 @@ Break_align_interface::self_align_callback (SCM element_smob, SCM axis)
 }
 
 
-void
-Break_align_interface::order_elements (Grob *grob)
+/*
+  This is tricky: we cannot modify 'elements, since callers are
+  iterating the same list. Reordering the list in-place, or resetting
+  'elements will skip elements in the loops of callers.
+  
+  So we return the correct order as an array.
+ */
+Link_array<Grob>
+Break_align_interface::ordered_elements (Grob *grob)
 {
   Item *me  = dynamic_cast<Item*> (grob);
   SCM elts = me->get_property ("elements");
   SCM order_vec = me->get_property ("break-align-orders");
   if (!gh_vector_p (order_vec)
       || gh_vector_length (order_vec) < 3)
-    return ;
-
+    return  Pointer_group_interface__extract_grobs (me, (Grob*)0,
+                                                   "elements");
   SCM order = scm_vector_ref (order_vec,
                              gh_int2scm (me->break_status_dir() + 1));
 
+
   /*
-    Copy in order specified in BREAK-ALIGN-ORDER. We use
-    Pointer_group_interface__extract_grobs (which reverses the list)
-    down the line, so it's ok to prepend onto newlist.
-   */
-  SCM new_list = SCM_EOL;
+    Copy in order specified in BREAK-ALIGN-ORDER.
+  */
+  Link_array<Grob> new_elts;
   for (; gh_pair_p (order); order = ly_cdr (order))
     {
       SCM sym = gh_car (order);
-
-      SCM *tail = &elts;
-      for (; gh_pair_p (*tail); tail = SCM_CDRLOC(*tail))
+      
+      for (SCM s =elts; gh_pair_p (s); s = gh_cdr (s))
        {
-         Grob * g = unsmob_grob (gh_car (*tail));
-         if (sym == g->get_property ("break-align-symbol"))
+         Grob *g = unsmob_grob (gh_car (s));
+         if (g && sym == g->get_property ("break-align-symbol"))
            {
-             SCM new_pair = *tail;
-             *tail = gh_cdr (*tail);
-             if (gh_pair_p (*tail))
-               tail = SCM_CDRLOC(*tail);
-
-             gh_set_cdr_x (new_pair, new_list);
-             new_list = new_pair;
-             break;
+             new_elts.push (g);
+             elts = scm_delq (g->self_scm (), elts); 
            }
        }
     }
-
-  new_list = scm_reverse_x (elts, new_list);
-  me->set_property ("elements", new_list);
+  return new_elts;
 }
 
 void
@@ -119,11 +116,8 @@ Break_align_interface::do_alignment (Grob *grob)
 {
   Item * me = dynamic_cast<Item*> (grob);
 
-  order_elements (me);
   
-  Link_array<Grob> elems
-    = Pointer_group_interface__extract_grobs (me, (Grob*)0,
-                                                "elements");
+  Link_array<Grob> elems = ordered_elements (me);
   Array<Interval> extents;
 
   int last_nonempty = -1; 
index 123fca1315115612021f51fb855042ba4f8d5909..a79e7e0a39975ce8a373a11721097e82dc2cf210 100644 (file)
@@ -16,8 +16,7 @@ class Break_align_interface
 {
 public:
   static void do_alignment (Grob*);
-  static void new_do_alignment (Grob*);  
-  static void order_elements (Grob *me);
+  static Link_array<Grob> ordered_elements (Grob *me);
   static bool has_interface (Grob*);
   static void add_element (Grob*me, Grob*add);
   DECLARE_SCHEME_CALLBACK (alignment_callback, (SCM element, SCM axis));
index 9436069dd8bdb0746d0d73a0556562c54ed1a209..51101be0e2e6f1995dd9810df505789c5b35d060 100644 (file)
@@ -144,7 +144,7 @@ Multi_measure_rest::symbol_stencil (Grob *me, Real space)
   SCM sml = me->get_property ("use-breve-rest");
   if (measures == 1)
     {
-      if (sml == SCM_BOOL_T)
+      if (to_boolean (sml))
        {
          Stencil s = musfont->find_by_name (Rest::glyph_name (me, -1, ""));
 
@@ -317,13 +317,16 @@ Multi_measure_rest::set_spacing_rods (SCM smob)
   Item * lb = l->find_prebroken_piece (RIGHT);
   Item * rb = r->find_prebroken_piece (LEFT);      
   
-  Item* combinations[4][2]={{l,r}, {lb,r}, {l,rb},{lb,rb}};
+  Item* combinations[4][2] = {{l,r},
+                             {lb,r},
+                             {l,rb},
+                             {lb,rb}};
 
   Real sym_width = symbol_stencil (me, 0.0).extent (X_AXIS).length ();
   
   for (int i=0; i < 4; i++)
     {
-      Item * l =  combinations[i][0];
+      Item *l = combinations[i][0];
       Item *r = combinations[i][1];
 
       if (!l || !r)
index def29de765d6b7a090fd988da1e9a95f1754ed0c..d3007f84330b2b295db725e4d880ecbb7f44ce0f 100644 (file)
@@ -106,8 +106,7 @@ Push_property_iterator::process (Moment m)
       SCM val = get_music ()->get_property ("grob-value");
 
       if (to_boolean (get_music ()->get_property ("pop-first"))
-         && !to_boolean (get_music ()->get_property ("once"))
-         )
+         && !to_boolean (get_music ()->get_property ("once")))
        execute_pushpop_property (get_outlet (), sym, eprop, SCM_UNDEFINED);
 
       execute_pushpop_property (get_outlet (), sym, eprop, val);
index 80b446534b694254d98391a41ca4d1383bbefa46..a2665fad29db7ce8ad90e0627edee950ab747b39 100644 (file)
@@ -163,7 +163,6 @@ Separating_line_group_engraver::acknowledge_grob (Grob_info i)
            }
          else if (last_spacings_.staff_spacing_)
            {
-             
              last_spacings_.staff_spacing_->set_property ("right-items",
                                                                gh_cons (break_item_->self_scm (), SCM_EOL));
            }
index 3b793713d15c56cec51ce4221774a5d8041c2492..4d7a8016d31e4e9aaa6da509452fde5e8c079809 100644 (file)
@@ -44,6 +44,7 @@ execute_pushpop_property (Context * trg,
           */
          if (!where)
            return ;
+         
          if (where != trg)
            {
              SCM base = updated_grob_properties (trg, prop);