]> git.donarmstrong.com Git - lilypond.git/blob - lily/book.cc
(LY_DEFINE): move parse-file 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 "main.hh"
17 #include "music-iterator.hh"
18 #include "music-output-def.hh"
19 #include "music-output.hh"
20 #include "music.hh"
21 #include "paper-book.hh"
22 #include "paper-def.hh"
23 #include "score.hh"
24 #include "warn.hh"
25
26 Book::Book ()
27   : Input ()
28 {
29   header_ = SCM_EOL;
30   smobify_self ();
31 }
32
33 #if 0
34 Book::Book (Book const &src)
35   : Input (src)
36 {
37   header_ = SCM_EOL;
38   smobify_self ();
39
40   int score_count = src.scores_.size ();
41   for (int i = 0; i < score_count; i++)
42     scores_.push (src.scores_[i]->clone ());
43
44 #if 0
45   header_ = ly_make_anonymous_module ();
46   if (is_module (src.header_))
47     ly_import_module (header_, src.header_);
48 #endif
49 }
50 #endif
51
52 Book::~Book ()
53 {
54 }
55
56 IMPLEMENT_SMOBS (Book);
57 IMPLEMENT_DEFAULT_EQUAL_P (Book);
58
59 SCM
60 Book::mark_smob (SCM s)
61 {
62   Book *book = (Book*) SCM_CELL_WORD_1 (s);
63   int score_count = book->scores_.size ();
64   for (int i = 0; i < score_count; i++)
65     scm_gc_mark (book->scores_[i]->self_scm ());
66   return book->header_;
67 }
68
69 int
70 Book::print_smob (SCM, SCM p, scm_print_state*)
71 {
72   scm_puts ("#<Book>", p);
73   return 1;
74 }
75
76 void
77 Book::process (String outname, Music_output_def *default_def, SCM header)
78 {
79   Paper_book *paper_book = new Paper_book ();
80   int score_count = scores_.size ();
81   for (int i = 0; i < score_count; i++)
82     {
83       Paper_def *paper = 0;
84       SCM systems = scores_[i]->book_rendering (outname, default_def, &paper);
85       if (systems != SCM_UNDEFINED)
86         {
87           if (paper)
88             paper_book->papers_.push (paper);
89           paper_book->scores_.push (systems);
90
91           // fixme.
92           //paper_book->global_headers_.push (global_input_file->header_);
93           //paper_book->headers_.push (scores_[i]->header_);
94           paper_book->headers_.push (header);
95         }
96     }
97   paper_book->output (outname);
98   scm_gc_unprotect_object (paper_book->self_scm ());
99 }