]> git.donarmstrong.com Git - lilypond.git/blob - lily/book-scheme.cc
5a975041608ca85178fe3302e8ae48021deef014
[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_FIRST_SMOB (Output_def, paper)
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_FUNC_NOTE_FIRST_ARG(book_smob);
50   LY_ASSERT_SMOB(Book,1);
51   LY_ASSERT_SMOB(Output_def, 2);
52   LY_ASSERT_SMOB(Output_def, 3);
53
54   Paper_book *pb = book->process (unsmob_output_def (default_paper),
55                                   unsmob_output_def (default_layout));
56   if (pb)
57     {
58       pb->output (output);
59       pb->unprotect ();
60     }
61
62   return SCM_UNSPECIFIED;
63 }
64
65
66 LY_DEFINE (ly_book_process_to_systems, "ly:book-process-to-systems",
67            4, 0, 0, (SCM book_smob,
68                      SCM default_paper,
69                      SCM default_layout,
70                      SCM output),
71            "Print book. @var{output} is passed to the backend unchanged. "
72            "Eg. it may be "
73            "a string (for file based outputs) or a socket (for network based "
74            "output).")
75 {
76   Book *book = unsmob_book (book_smob);
77
78   LY_FUNC_NOTE_FIRST_ARG(book_smob);
79   
80   LY_ASSERT_SMOB(Book,1);
81   LY_ASSERT_SMOB(Output_def, 2);
82   LY_ASSERT_SMOB(Output_def, 3);
83
84   Paper_book *pb = book->process (unsmob_output_def (default_paper),
85                                   unsmob_output_def (default_layout));
86   if (pb)
87     {
88       pb->classic_output (output);
89       pb->unprotect ();
90     }
91
92   return SCM_UNSPECIFIED;
93 }
94