]> git.donarmstrong.com Git - lilypond.git/blob - lily/book.cc
* lily/my-lily-parser.cc: remove paper_description function
[lilypond.git] / lily / book.cc
1 /*
2   book.cc -- implement Book
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8
9 #include <stdio.h>
10
11 #include "ly-smobs.icc"
12
13 #include "book.hh"
14 #include "global-context.hh"
15 #include "ly-module.hh"
16 #include "input-file-results.hh"
17 #include "main.hh"
18 #include "music-iterator.hh"
19 #include "music-output-def.hh"
20 #include "music-output.hh"
21 #include "music.hh"
22 #include "paper-book.hh"
23 #include "paper-def.hh"
24 #include "score.hh"
25 #include "warn.hh"
26
27 Book::Book ()
28   : Input ()
29 {
30   header_ = SCM_EOL;
31   smobify_self ();
32 }
33
34 #if 0
35 Book::Book (Book const &src)
36   : Input (src)
37 {
38   header_ = SCM_EOL;
39   smobify_self ();
40
41   int score_count = src.scores_.size ();
42   for (int i = 0; i < score_count; i++)
43     scores_.push (src.scores_[i]->clone ());
44
45 #if 0
46   header_ = ly_make_anonymous_module ();
47   if (is_module (src.header_))
48     ly_import_module (header_, src.header_);
49 #endif
50 }
51 #endif
52
53 Book::~Book ()
54 {
55 }
56
57 IMPLEMENT_SMOBS (Book);
58 IMPLEMENT_DEFAULT_EQUAL_P (Book);
59
60 SCM
61 Book::mark_smob (SCM s)
62 {
63   Book *book = (Book*) SCM_CELL_WORD_1 (s);
64   int score_count = book->scores_.size ();
65   for (int i = 0; i < score_count; i++)
66     scm_gc_mark (book->scores_[i]->self_scm ());
67   return book->header_;
68 }
69
70 int
71 Book::print_smob (SCM, SCM p, scm_print_state*)
72 {
73   scm_puts ("#<Book>", p);
74   return 1;
75 }
76
77 void
78 Book::process (String outname, Music_output_def *default_def, SCM header)
79 {
80   Paper_book *paper_book = new Paper_book ();
81   int score_count = scores_.size ();
82   for (int i = 0; i < score_count; i++)
83     {
84       Paper_def *paper = 0;
85       SCM systems = scores_[i]->book_rendering (outname, default_def, &paper);
86       if (systems != SCM_UNDEFINED)
87         {
88           if (paper)
89             paper_book->papers_.push (paper);
90           paper_book->scores_.push (systems);
91
92           // fixme.
93           //paper_book->global_headers_.push (global_input_file->header_);
94           //paper_book->headers_.push (scores_[i]->header_);
95           paper_book->headers_.push (header);
96         }
97     }
98   paper_book->output (outname);
99   scm_gc_unprotect_object (paper_book->self_scm ());
100 }