2 score.cc -- implement Score
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2001 Han-Wen Nienhuys <hanwen@cs.uu.nl>
9 #include "ly-smobs.icc"
11 #include "scm-hash.hh"
14 #include "music-output-def.hh"
15 #include "music-output.hh"
16 #include "music-iterator.hh"
18 #include "global-translator.hh"
20 #include "cpu-timer.hh"
22 #include "paper-def.hh"
39 store point & click locations.
40 Global to save some time. (Sue us!)
42 bool store_locations_global_b;
44 Score::Score (Score const &s)
52 TODO: this is not very elegant....
54 store_locations_global_b = (gh_eval_str ("point-and-click") != SCM_BOOL_F);
56 Music * m =unsmob_music (s.music_);
57 music_ = m?m->clone ()->self_scm () : SCM_EOL;
58 scm_gc_unprotect_object (music_);
60 for (int i=0; i < s.def_p_arr_.size (); i++)
61 def_p_arr_.push (s.def_p_arr_[i]->clone ());
62 errorlevel_i_ = s.errorlevel_i_;
65 header_p_ = (s.header_p_) ? new Scheme_hash_table (*s.header_p_): 0;
67 scm_gc_unprotect_object (header_p_->self_scm ());
77 Score::run_translator (Music_output_def *odef_l)
82 Global_translator * trans_p = odef_l->get_global_translator_p ();
85 programming_error ("no toplevel translator");
88 progress_indication (_ ("Interpreting music..."));
89 Music * music = unsmob_music (music_);
91 trans_p->final_mom_ = music->length_mom ();
94 Music_iterator * iter = Music_iterator::static_get_iterator_p (music);
95 iter->init_translator (music, trans_p);
97 iter->construct_children ();
102 warning (_ ("Need music in a score"));
108 trans_p->run_iterator_on_me (iter);
114 // should we? hampers debugging.
115 warning (_ ("Errors found/*, not processing score*/"));
118 Music_output * output = trans_p->get_output_p ();
119 scm_gc_unprotect_object (trans_p->self_scm ());
121 if (verbose_global_b)
122 progress_indication (_f ("elapsed time: %.2f seconds", timer.read ()));
125 header_p_ = new Scheme_hash_table; // ugh
126 Scope bla (header_p_);
127 output->header_l_ = &bla;
128 output->origin_str_ = location_str ();
130 progress_indication ("\n");
135 force GC. At this point, GUILE may give back mallocated area to
145 if (!unsmob_music (music_))
149 for (int i=0; i < def_p_arr_.size (); i++)
151 if (no_paper_global_b
152 && dynamic_cast<Paper_def*> (def_p_arr_[i]))
154 run_translator (def_p_arr_[i]);
162 Score::add_output (Music_output_def *pap_p)
164 def_p_arr_.push (pap_p);
167 IMPLEMENT_SMOBS (Score);
168 IMPLEMENT_DEFAULT_EQUAL_P (Score);
172 Score::mark_smob (SCM s)
174 Score * sc = (Score*) SCM_CELL_WORD_1 (s);
176 scm_gc_mark (sc->header_p_->self_scm ());
177 for (int i = sc->def_p_arr_.size (); i--;)
178 scm_gc_mark (sc->def_p_arr_[i]->self_scm ());
184 Score::print_smob (SCM , SCM p, scm_print_state*)
186 scm_puts ("#<Score>", p);