2 score.cc -- implement Score
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
11 #include "ly-smobs.icc"
15 #include "music-output-def.hh"
16 #include "music-output.hh"
17 #include "music-iterator.hh"
19 #include "global-translator.hh"
20 #include "scm-hash.hh"
21 #include "cpu-timer.hh"
23 #include "paper-def.hh"
40 store point & click locations.
41 Global to save some time. (Sue us!)
43 bool store_locations_global_b;
45 Score::Score (Score const &s)
52 Music * m =unsmob_music (s.music_);
53 music_ = m?m->clone ()->self_scm () : SCM_EOL;
54 scm_gc_unprotect_object (music_);
56 for (int i=0; i < s.def_p_arr_.size (); i++)
57 def_p_arr_.push (s.def_p_arr_[i]->clone ());
58 errorlevel_i_ = s.errorlevel_i_;
61 header_p_ = (s.header_p_) ? new Scheme_hash_table (*s.header_p_): 0;
63 scm_gc_unprotect_object (header_p_->self_scm ());
74 should enable this to find weird mistakes?
79 #include <sys/resource.h>
83 Score::run_translator (Music_output_def *odef_l)
92 getrlimit (RLIMIT_STACK, &rls);
93 progress_indication (_f("stack size cur %d, max %d\n" ,rls.rlim_cur, rls.rlim_max));
98 We want to know if we want to store locations, since they take a
101 store_locations_global_b = (gh_eval_str ("point-and-click") != SCM_BOOL_F);
104 Global_translator * trans_p = odef_l->get_global_translator_p ();
107 programming_error ("no toplevel translator");
110 progress_indication (_ ("Interpreting music..."));
111 Music * music = unsmob_music (music_);
113 trans_p->final_mom_ = music->length_mom ();
115 Music_iterator * iter = Music_iterator::static_get_iterator_p (music);
116 iter->init_translator (music, trans_p);
118 iter->construct_children ();
123 warning (_ ("Need music in a score"));
129 trans_p->run_iterator_on_me (iter);
135 // should we? hampers debugging.
136 warning (_ ("Errors found/*, not processing score*/"));
139 Music_output * output = trans_p->get_output_p ();
140 scm_gc_unprotect_object (trans_p->self_scm ());
142 if (verbose_global_b)
143 progress_indication (_f ("elapsed time: %.2f seconds", timer.read ()));
146 header_p_ = new Scheme_hash_table; // ugh
148 output->header_l_ = header_p_;
149 output->origin_str_ = location_str ();
151 progress_indication ("\n");
156 force GC. At this point, GUILE may give back mallocated area to
166 if (!unsmob_music (music_))
170 for (int i=0; i < def_p_arr_.size (); i++)
172 if (no_paper_global_b
173 && dynamic_cast<Paper_def*> (def_p_arr_[i]))
175 run_translator (def_p_arr_[i]);
183 Score::add_output (Music_output_def *pap_p)
185 def_p_arr_.push (pap_p);
188 IMPLEMENT_SMOBS (Score);
189 IMPLEMENT_DEFAULT_EQUAL_P (Score);
193 Score::mark_smob (SCM s)
195 Score * sc = (Score*) SCM_CELL_WORD_1 (s);
197 scm_gc_mark (sc->header_p_->self_scm ());
198 for (int i = sc->def_p_arr_.size (); i--;)
199 scm_gc_mark (sc->def_p_arr_[i]->self_scm ());
205 Score::print_smob (SCM , SCM p, scm_print_state*)
207 scm_puts ("#<Score>", p);