Index: lily/break-substitution.cc |
diff --git a/lily/break-substitution.cc b/lily/break-substitution.cc |
index 4f59b946987a8f4f2e08d260e2bed3f36e960228..7f48fa75a27a478a13f1d2dfe482d10bdd954ab9 100644 |
--- a/lily/break-substitution.cc |
+++ b/lily/break-substitution.cc |
@@ -35,47 +35,10 @@ typedef Interval_t<int> System_range; |
Perform the substitution for a single grob. |
*/ |
Grob * |
-substitute_grob (SCM break_criterion, Grob *sc) |
+substitute_grob (Break_criterion break_criterion, Grob *sc) |
{ |
- if (scm_is_integer (break_criterion)) |
- { |
- Item *i = dynamic_cast<Item *> (sc); |
- Direction d = to_dir (break_criterion); |
- if (i && i->break_status_dir () != d) |
- { |
- Item *br = i->find_prebroken_piece (d); |
- return br; |
- } |
- } |
- else |
- { |
- System *line |
- = unsmob<System> (break_criterion); |
- if (sc->get_system () != line) |
- sc = sc->find_broken_piece (line); |
- |
- /* now: !sc || (sc && sc->get_system () == line) */ |
- if (!sc) |
- return 0; |
- |
- /* now: sc && sc->get_system () == line */ |
- if (!line) |
- return sc; |
- |
- /* |
- We don't return SCM_UNDEFINED for |
- suicided grobs, for two reasons |
- |
- - it doesn't work (strange disappearing objects) |
- |
- - it forces us to mark the parents of a grob, leading to |
- a huge recursion in the GC routine. |
- */ |
- |
- return sc; |
- } |
- |
- return sc; |
+ return break_criterion.root_system_->get_break_substitution ( |
+ sc, break_criterion.break_dir_, break_criterion.break_system_); |
} |
/* |
@@ -93,7 +56,7 @@ substitute_grob (SCM break_criterion, Grob *sc) |
generate a lot of garbage. |
*/ |
SCM |
-do_break_substitution (SCM break_criterion, SCM src) |
+do_break_substitution (Break_criterion break_criterion, SCM src) |
{ |
again: |
@@ -295,7 +258,7 @@ struct Substitution_entry |
}; |
bool |
-Spanner::fast_substitute_grob_array (SCM sym, |
+Spanner::fast_substitute_grob_array (System *root_system, SCM sym, |
Grob_array *grob_array) |
{ |
int len = grob_array->size (); |
@@ -382,8 +345,9 @@ Spanner::fast_substitute_grob_array (SCM sym, |
for (vsize i = 0; i < broken_intos_.size (); i++) |
{ |
Grob *sc = broken_intos_[i]; |
- System *l = sc->get_system (); |
- |
+ Break_criterion bc; |
+ bc.root_system_ = root_system; |
+ bc.break_system_ = sc->get_system (); |
SCM newval = sc->internal_get_object (sym); |
if (!unsmob<Grob_array> (newval)) |
{ |
@@ -395,7 +359,7 @@ Spanner::fast_substitute_grob_array (SCM sym, |
for (int k = 0; k < 2; k++) |
for (int j = (*arrs[k])[i][LEFT]; j <= (*arrs[k])[i][RIGHT]; j++) |
{ |
- Grob *substituted = substitute_grob (l->self_scm (), vec[j].grob_); |
+ Grob *substituted = substitute_grob (bc, vec[j].grob_); |
if (substituted) |
new_array->add (substituted); |
} |
@@ -429,7 +393,7 @@ Spanner::fast_substitute_grob_array (SCM sym, |
pthreads. pthreads impose small limits on the stack size. |
*/ |
void |
-substitute_object_alist (SCM break_criterion, SCM alist, SCM *dest) |
+substitute_object_alist (Break_criterion break_criterion, SCM alist, SCM *dest) |
{ |
SCM old = *dest; |
*dest = SCM_EOL; |
@@ -468,17 +432,20 @@ substitute_object_alist (SCM break_criterion, SCM alist, SCM *dest) |
} |
void |
-Spanner::substitute_one_mutable_property (SCM sym, SCM val) |
+Spanner::substitute_one_mutable_property (System *root, SCM sym, SCM val) |
{ |
Grob_array *grob_array = unsmob<Grob_array> (val); |
- if (grob_array && fast_substitute_grob_array (sym, grob_array)) |
+ if (grob_array && fast_substitute_grob_array (root, sym, grob_array)) |
return; |
for (vsize i = 0; i < broken_intos_.size (); i++) |
{ |
Grob *sc = broken_intos_[i]; |
System *l = sc->get_system (); |
- SCM break_criterion = l->self_scm (); |
+ |
+ Break_criterion bc; |
+ bc.root_system_ = root; |
+ bc.break_system_ = l; |
if (grob_array) |
{ |
@@ -489,19 +456,18 @@ Spanner::substitute_one_mutable_property (SCM sym, SCM val) |
set_object (sc, sym, newval); |
} |
Grob_array *new_arr = unsmob<Grob_array> (newval); |
- new_arr->filter_map_assign2 (*grob_array, substitute_grob, |
- break_criterion); |
+ new_arr->filter_map_assign2 (*grob_array, substitute_grob, bc); |
} |
else |
{ |
- SCM newval = do_break_substitution (break_criterion, val); |
+ SCM newval = do_break_substitution (bc, val); |
set_object (sc, sym, newval); |
} |
} |
} |
void |
-Grob::substitute_object_links (SCM crit, SCM orig) |
+Grob::substitute_object_links (Break_criterion crit, SCM orig) |
{ |
substitute_object_alist (crit, orig, &object_alist_); |
} |