Fix typo in convert-ly.
[lilypond.git] / lily / book-scheme.cc
blobe00f1ded496965f1882390f31976f613b26debb7
1 /*
2 book-scheme.cc -- implement Book bindings
4 source file of the GNU LilyPond music typesetter
6 (c) 2004--2007 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 @code{\\book} of @var{paper} and @var{header}"
19 " (which may be @code{#f} as well) containing @code{\\scores}.")
21 Output_def *odef = unsmob_output_def (paper);
22 LY_ASSERT_SMOB (Output_def, paper, 1);
24 Book *book = new Book;
25 book->paper_ = odef;
27 if (ly_is_module (header))
28 book->header_ = header;
30 book->scores_ = scm_append (scm_list_2 (scores, book->scores_));
32 SCM x = book->self_scm ();
33 book->unprotect ();
34 return x;
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 " For example, it may be a string (for file based outputs)"
44 " or a socket (for network based output).")
46 Book *book = unsmob_book (book_smob);
48 LY_ASSERT_SMOB (Book, book_smob, 1);
49 LY_ASSERT_SMOB (Output_def, default_paper, 2);
50 LY_ASSERT_SMOB (Output_def, default_layout, 3);
52 Paper_book *pb = book->process (unsmob_output_def (default_paper),
53 unsmob_output_def (default_layout));
54 if (pb)
56 pb->output (output);
57 pb->unprotect ();
60 return SCM_UNSPECIFIED;
64 LY_DEFINE (ly_book_process_to_systems, "ly:book-process-to-systems",
65 4, 0, 0, (SCM book_smob,
66 SCM default_paper,
67 SCM default_layout,
68 SCM output),
69 "Print book. @var{output} is passed to the backend unchanged."
70 " For example, it may be a string (for file based outputs)"
71 " or a socket (for network based output).")
73 LY_ASSERT_SMOB (Book, book_smob, 1);
74 LY_ASSERT_SMOB (Output_def, default_paper, 2);
75 LY_ASSERT_SMOB (Output_def, default_layout, 3);
77 Book *book = unsmob_book (book_smob);
79 Paper_book *pb = book->process (unsmob_output_def (default_paper),
80 unsmob_output_def (default_layout));
81 if (pb)
83 pb->classic_output (output);
84 pb->unprotect ();
87 return SCM_UNSPECIFIED;
90 LY_DEFINE (ly_book_add_score_x, "ly:book-add-score!",
91 2, 0, 0, (SCM book_smob, SCM score),
92 "Add @var{score} to @var{book-smob} score list.")
94 LY_ASSERT_SMOB (Book, book_smob, 1);
95 Book *book = unsmob_book (book_smob);
96 book->add_score (score);
97 return SCM_UNSPECIFIED;