* lexer-gcc-3.1.sh: Remove.
[lilypond/patrick.git] / lily / book-scheme.cc
blob750917187f65a86612d86fe0d21b2959010be73e
1 /*
2 book-scheme.cc -- implement Book bindings
4 source file of the GNU LilyPond music typesetter
6 (c) 2004--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 */
9 #include "book.hh"
11 #include "output-def.hh"
12 #include "score.hh"
13 #include "paper-book.hh"
14 #include "ly-module.hh"
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}.")
21 Output_def *odef = unsmob_output_def (paper);
22 SCM_ASSERT_TYPE (odef, paper,
23 SCM_ARG1, __FUNCTION__, "Output_def");
25 Book *book = new Book;
26 book->paper_ = odef;
28 if (ly_is_module (header))
29 book->header_ = header;
31 book->scores_ = scm_append (scm_list_2 (scores, book->scores_));
33 SCM x = book->self_scm ();
34 book->unprotect ();
35 return x;
38 LY_DEFINE (ly_parser_print_book, "ly:book-process",
39 4, 0, 0, (SCM book_smob,
40 SCM default_paper,
41 SCM default_layout,
42 SCM output),
43 "Print book. @var{output} is passed to the backend unchanged. "
44 "Eg. it may be "
45 "a string (for file based outputs) or a socket (for network based "
46 "output).")
48 Book *book = unsmob_book (book_smob);
50 SCM_ASSERT_TYPE (book, book_smob, SCM_ARG1, __FUNCTION__, "Book");
51 SCM_ASSERT_TYPE (unsmob_output_def (default_paper),
52 default_layout, SCM_ARG2, __FUNCTION__, "\\paper block");
53 SCM_ASSERT_TYPE (unsmob_output_def (default_layout),
54 default_layout, SCM_ARG3, __FUNCTION__, "\\layout block");
56 Paper_book *pb = book->process (unsmob_output_def (default_paper),
57 unsmob_output_def (default_layout));
58 if (pb)
60 pb->output (output);
61 pb->unprotect ();
64 return SCM_UNSPECIFIED;