]> git.donarmstrong.com Git - lilypond.git/blob - lily/book-scheme.cc
Merge with master
[lilypond.git] / lily / book-scheme.cc
1 /*
2   book-scheme.cc -- implement Book bindings
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 2004--2007 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 */
8
9 #include "book.hh"
10
11 #include "output-def.hh"
12 #include "score.hh"
13 #include "paper-book.hh"
14 #include "ly-module.hh"
15
16 LY_DEFINE (ly_make_book, "ly:make-book",
17            2, 0, 1, (SCM paper, SCM header, SCM scores),
18            "Make a \\book of @var{paper} and @var{header} (which may be #f as well)  "
19            "containing @code{\\scores}.")
20 {
21   Output_def *odef = unsmob_output_def (paper);
22   LY_ASSERT_SMOB (Output_def, paper, 1);
23
24   Book *book = new Book;
25   book->paper_ = odef;
26
27   if (ly_is_module (header))
28     book->header_ = header;
29
30   book->scores_ = scm_append (scm_list_2 (scores, book->scores_));
31
32   SCM x = book->self_scm ();
33   book->unprotect ();
34   return x;
35 }
36
37 LY_DEFINE (ly_book_process, "ly:book-process",
38            4, 0, 0, (SCM book_smob,
39                      SCM default_paper,
40                      SCM default_layout,
41                      SCM output),
42            "Print book. @var{output} is passed to the backend unchanged. "
43            "Eg. it may be "
44            "a string (for file based outputs) or a socket (for network based "
45            "output).")
46 {
47   Book *book = unsmob_book (book_smob);
48
49   LY_ASSERT_SMOB(Book, book_smob, 1);
50   LY_ASSERT_SMOB(Output_def, default_paper, 2);
51   LY_ASSERT_SMOB(Output_def, default_layout, 3);
52
53   Paper_book *pb = book->process (unsmob_output_def (default_paper),
54                                   unsmob_output_def (default_layout));
55   if (pb)
56     {
57       pb->output (output);
58       pb->unprotect ();
59     }
60
61   return SCM_UNSPECIFIED;
62 }
63
64
65 LY_DEFINE (ly_book_process_to_systems, "ly:book-process-to-systems",
66            4, 0, 0, (SCM book_smob,
67                      SCM default_paper,
68                      SCM default_layout,
69                      SCM output),
70            "Print book. @var{output} is passed to the backend unchanged. "
71            "Eg. it may be "
72            "a string (for file based outputs) or a socket (for network based "
73            "output).")
74 {
75   LY_ASSERT_SMOB (Book, book_smob, 1);
76   LY_ASSERT_SMOB(Output_def, default_paper, 2);
77   LY_ASSERT_SMOB(Output_def, default_layout, 3);
78
79   Book *book = unsmob_book (book_smob); 
80
81   Paper_book *pb = book->process (unsmob_output_def (default_paper),
82                                   unsmob_output_def (default_layout));
83   if (pb)
84     {
85       pb->classic_output (output);
86       pb->unprotect ();
87     }
88
89   return SCM_UNSPECIFIED;
90 }
91