2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 2005--2014 Han-Wen Nienhuys <hanwen@xs4all.nl>
6 LilyPond is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 LilyPond is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
20 #include "grob-array.hh"
26 Grob_array::item (vsize i)
28 return dynamic_cast<Item *> (grobs_.at (i));
32 Grob_array::spanner (vsize i)
34 return dynamic_cast<Spanner *> (grobs_.at (i));
37 Grob_array::Grob_array ()
43 Grob_array::array_reference ()
48 vector<Grob *> const &
49 Grob_array::array () const
55 Grob_array::mark_smob ()
57 #if 0 /* see System::derived_mark () const */
58 Grob_array *ga = Grob_array::unsmob (s);
59 for (vsize i = 0; i < ga->grobs_.size (); i++)
60 scm_gc_mark (ga->grobs_[i]->self_scm ());
66 Grob_array::print_smob (SCM arr, SCM port, scm_print_state *)
68 scm_puts ("#<Grob_array", port);
70 Grob_array *grob_arr = unsmob (arr);
71 for (vsize i = 0; i < grob_arr->size (); i++)
73 scm_display (grob_arr->grob (i)->self_scm (), port);
81 Grob_array::make_array ()
84 return ga.smobbed_copy ();
94 Grob_array::remove_duplicates ()
102 Grob_array::empty () const
104 return grobs_.empty ();
108 Grob_array::set_array (vector<Grob *> const &src)
113 const char Grob_array::type_p_name_[] = "ly:grob-array?";
117 grob_list_to_grob_array (SCM lst)
119 SCM arr_scm = Grob_array::make_array ();
120 Grob_array *ga = Grob_array::unsmob (arr_scm);
121 for (SCM s = lst; scm_is_pair (s); s = scm_cdr (s))
122 ga->add (Grob::unsmob (scm_car (s)));
127 grob_array_to_list (Grob_array *array)
132 for (vsize i = 0; i < array->size (); i++)
134 *tail = scm_cons (array->grob (i)->self_scm (), SCM_EOL);
135 tail = SCM_CDRLOC (*tail);