2 book.cc -- implement Book
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
13 #include "lilypond-key.hh"
14 #include "global-context.hh"
16 #include "music-iterator.hh"
17 #include "music-output.hh"
19 #include "output-def.hh"
20 #include "paper-book.hh"
25 #include "ly-smobs.icc"
32 assert (!scores_.size ());
40 IMPLEMENT_SMOBS (Book);
41 IMPLEMENT_DEFAULT_EQUAL_P (Book);
44 Book::mark_smob (SCM s)
46 Book *book = (Book*) SCM_CELL_WORD_1 (s);
47 int score_count = book->scores_.size ();
48 for (int i = 0; i < score_count; i++)
49 scm_gc_mark (book->scores_[i]->self_scm ());
53 scm_gc_mark (book->key_->self_scm());
56 scm_gc_mark (book->paper_->self_scm ());
61 Book::print_smob (SCM, SCM p, scm_print_state*)
63 scm_puts ("#<Book>", p);
67 /* This function does not dump the output; outname is required eg. for
68 dumping header fields. */
70 Book::process (String outname, Output_def *default_def)
73 for (int i = 0; i < scores_.size(); i++)
74 error = error || scores_[i]->error_found_;
79 Paper_book *paper_book = new Paper_book ();
80 Real scale = scm_to_double (paper_->c_variable ("outputscale"));
81 Output_def * scaled_bookdef = scale_output_def (paper_, scale);
84 Object_key * key = new Lilypond_general_key (0, user_key_, 0);
85 SCM scm_key = key->self_scm();
86 scm_gc_unprotect_object (scm_key);
88 paper_book->paper_ = scaled_bookdef;
89 scm_gc_unprotect_object (scaled_bookdef->self_scm());
91 paper_book->header_ = header_;
92 int score_count = scores_.size ();
93 for (int i = 0; i < score_count; i++)
95 SCM systems = scores_[i]->book_rendering (outname,
102 If the score is empty, generate no output. Should we
105 if (SCM_NFALSEP(scm_vector_p (systems)))
108 sc.systems_ = systems;
109 sc.header_ = scores_[i]->header_;
110 paper_book->score_systems_.push (sc);
115 scm_remember_upto_here_1 (scm_key);
123 Book::add_score (Score *s)
126 scm_gc_unprotect_object (s->self_scm ());