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"
23 #include "text-item.hh"
26 #include "ly-smobs.icc"
41 IMPLEMENT_SMOBS (Book);
42 IMPLEMENT_DEFAULT_EQUAL_P (Book);
45 Book::mark_smob (SCM s)
47 Book *book = (Book*) SCM_CELL_WORD_1 (s);
51 scm_gc_mark (book->key_->self_scm());
55 scm_gc_mark (book->paper_->self_scm ());
56 scm_gc_mark (book->scores_);
62 Book::print_smob (SCM, SCM p, scm_print_state*)
64 scm_puts ("#<Book>", p);
69 Book::add_score (SCM s)
71 scores_ = scm_cons (s, scores_);
74 /* This function does not dump the output; outname is required eg. for
75 dumping header fields. */
77 Book::process (String outname, Output_def *default_def)
79 for (SCM s = scores_; s != SCM_EOL; s = scm_cdr (s))
80 if (Score *score = unsmob_score (scm_car (s)))
81 if (score->error_found_)
84 Paper_book *paper_book = new Paper_book ();
85 Real scale = scm_to_double (paper_->c_variable ("outputscale"));
86 Output_def * scaled_bookdef = scale_output_def (paper_, scale);
88 Object_key * key = new Lilypond_general_key (0, user_key_, 0);
89 SCM scm_key = key->self_scm();
90 scm_gc_unprotect_object (scm_key);
92 paper_book->paper_ = scaled_bookdef;
93 scm_gc_unprotect_object (scaled_bookdef->self_scm());
95 paper_book->header_ = header_;
97 /* Render in order of parsing. */
98 for (SCM s = scm_reverse (scores_); s != SCM_EOL; s = scm_cdr (s))
100 if (Score *score = unsmob_score (scm_car (s)))
103 ->book_rendering (outname, paper_book->paper_, default_def, key);
105 /* If the score is empty, generate no output. Should we do
107 if (scm_is_vector (systems))
109 if (ly_c_module_p (header_))
110 paper_book->add_score (header_);
111 paper_book->add_score (systems);
114 else if (Text_interface::markup_p (scm_car (s)))
115 paper_book->add_score (scm_car (s));
120 scm_remember_upto_here_1 (scm_key);