/*
This file is part of LilyPond, the GNU music typesetter.
- Copyright (C) 2001--2011 Han-Wen Nienhuys <hanwen@xs4all.nl>
+ Copyright (C) 2001--2015 Han-Wen Nienhuys <hanwen@xs4all.nl>
LilyPond is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
else
{
System *line
- = dynamic_cast<System *> (unsmob_grob (break_criterion));
+ = unsmob<System> (break_criterion);
if (sc->get_system () != line)
sc = sc->find_broken_piece (line);
{
again:
- if (unsmob_grob (src))
+ if (unsmob<Grob> (src))
{
- Grob *new_ptr = substitute_grob (unsmob_grob (src));
+ Grob *new_ptr = substitute_grob (unsmob<Grob> (src));
return new_ptr ? new_ptr->self_scm () : SCM_UNDEFINED;
}
else if (scm_is_vector (src))
SCM newcar = do_break_substitution (scm_car (src));
SCM oldcdr = scm_cdr (src);
- if (newcar == SCM_UNDEFINED
- && (scm_is_pair (oldcdr) || oldcdr == SCM_EOL))
+ if (SCM_UNBNDP (newcar)
+ && (scm_is_pair (oldcdr) || scm_is_null (oldcdr)))
{
/*
This is tail-recursion, ie.
return src;
}
-/*
- Perform substitution on GROB_LIST using a constant amount of stack.
-*/
-vector<Grob *> temporary_substition_array;
-void
-substitute_grob_array (Grob_array *grob_arr, Grob_array *new_arr)
-{
- vector<Grob *> &old_grobs (grob_arr->array_reference ());
- vector<Grob *> *new_grobs (new_arr == grob_arr
- ? & temporary_substition_array
- : &new_arr->array_reference ());
-
- new_grobs->resize (old_grobs.size ());
- Grob **array = (Grob **) new_grobs->data ();
- Grob **ptr = array;
- for (vsize i = 0; i < old_grobs.size (); i++)
- {
- Grob *orig = old_grobs[i];
- Grob *new_grob = substitute_grob (orig);
- if (new_grob)
- *ptr++ = new_grob;
- }
-
- new_grobs->resize (ptr - array);
- if (new_arr == grob_arr)
- new_arr->set_array (*new_grobs);
-}
-
/*
We don't do
return Slice (st->get_rank (), st->get_rank ());
Slice sr;
- Direction d = LEFT;
- do
+ for (LEFT_and_RIGHT (d))
{
Item *bi = it->find_prebroken_piece (d);
if (bi && bi->get_system ())
sr.add_point (bi->get_system ()->get_rank ());
}
- while (flip (&d) != LEFT);
return sr;
}
set_break_subsititution (l ? l->self_scm () : SCM_UNDEFINED);
SCM newval = sc->internal_get_object (sym);
- if (!unsmob_grob_array (newval))
+ if (!unsmob<Grob_array> (newval))
{
newval = Grob_array::make_array ();
sc->set_object (sym, newval);
}
- Grob_array *new_array = unsmob_grob_array (newval);
+ Grob_array *new_array = unsmob<Grob_array> (newval);
for (int k = 0; k < 2; k++)
for (int j = (*arrs[k])[i][LEFT]; j <= (*arrs[k])[i][RIGHT]; j++)
{
SCM sym = scm_caar (s);
SCM val = scm_cdar (s);
- if (Grob_array *orig = unsmob_grob_array (val))
+ if (Grob_array *orig = unsmob<Grob_array> (val))
{
SCM handle = scm_assq (sym, dest);
SCM newval
? scm_cdr (handle)
: Grob_array::make_array ();
- Grob_array *new_arr = unsmob_grob_array (newval);
-
- substitute_grob_array (orig, new_arr);
+ Grob_array *new_arr = unsmob<Grob_array> (newval);
+ // TODO: What if new_arr is null?
+ new_arr->filter_map_assign (*orig, substitute_grob);
val = newval;
}
else
val = do_break_substitution (val);
- if (val != SCM_UNDEFINED)
+ if (!SCM_UNBNDP (val))
{
/*
for ly:grob? properties, SCM_UNDEFINED could leak out
Spanner *s = this;
bool fast_done = false;
- Grob_array *grob_array = unsmob_grob_array (val);
+ Grob_array *grob_array = unsmob<Grob_array> (val);
if (grob_array)
fast_done = s->fast_substitute_grob_array (sym, grob_array);
if (grob_array)
{
SCM newval = sc->internal_get_object (sym);
- if (!unsmob_grob_array (newval))
+ if (!unsmob<Grob_array> (newval))
{
newval = Grob_array::make_array ();
sc->set_object (sym, newval);
}
- substitute_grob_array (grob_array, unsmob_grob_array (newval));
+ Grob_array *new_arr = unsmob<Grob_array> (newval);
+ new_arr->filter_map_assign (*grob_array, substitute_grob);
}
else
{