2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 2004--2012 Han-Wen Nienhuys <hanwen@xs4all.nl>
6 LilyPond is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 LilyPond is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
22 #include "output-def.hh"
24 #include "paper-book.hh"
25 #include "ly-module.hh"
27 LY_DEFINE (ly_make_book, "ly:make-book",
28 2, 0, 1, (SCM paper, SCM header, SCM scores),
29 "Make a @code{\\book} of @var{paper} and @var{header}"
30 " (which may be @code{#f} as well) containing @code{\\scores}.")
32 Output_def *odef = unsmob_output_def (paper);
33 LY_ASSERT_SMOB (Output_def, paper, 1);
35 Book *book = new Book;
38 if (ly_is_module (header))
39 book->header_ = header;
41 book->scores_ = scm_append (scm_list_2 (scores, book->scores_));
43 SCM x = book->self_scm ();
48 LY_DEFINE (ly_make_book_part, "ly:make-book-part",
49 1, 0, 0, (SCM scores),
50 "Make a @code{\\bookpart} containing @code{\\scores}.")
52 Book *book = new Book;
53 book->scores_ = scm_append (scm_list_2 (scores, book->scores_));
55 SCM x = book->self_scm ();
60 LY_DEFINE (ly_book_process, "ly:book-process",
61 4, 0, 0, (SCM book_smob,
65 "Print book. @var{output} is passed to the backend unchanged."
66 " For example, it may be a string (for file based outputs)"
67 " or a socket (for network based output).")
69 Book *book = unsmob_book (book_smob);
71 LY_ASSERT_SMOB (Book, book_smob, 1);
72 LY_ASSERT_SMOB (Output_def, default_paper, 2);
73 LY_ASSERT_SMOB (Output_def, default_layout, 3);
75 Paper_book *pb = book->process (unsmob_output_def (default_paper),
76 unsmob_output_def (default_layout));
83 return SCM_UNSPECIFIED;
86 LY_DEFINE (ly_book_process_to_systems, "ly:book-process-to-systems",
87 4, 0, 0, (SCM book_smob,
91 "Print book. @var{output} is passed to the backend unchanged."
92 " For example, it may be a string (for file based outputs)"
93 " or a socket (for network based output).")
95 LY_ASSERT_SMOB (Book, book_smob, 1);
96 LY_ASSERT_SMOB (Output_def, default_paper, 2);
97 LY_ASSERT_SMOB (Output_def, default_layout, 3);
99 Book *book = unsmob_book (book_smob);
101 Paper_book *pb = book->process (unsmob_output_def (default_paper),
102 unsmob_output_def (default_layout));
105 pb->classic_output (output);
109 return SCM_UNSPECIFIED;
112 LY_DEFINE (ly_book_add_score_x, "ly:book-add-score!",
113 2, 0, 0, (SCM book_smob, SCM score),
114 "Add @var{score} to @var{book-smob} score list.")
116 LY_ASSERT_SMOB (Book, book_smob, 1);
117 Book *book = unsmob_book (book_smob);
118 book->add_score (score);
119 return SCM_UNSPECIFIED;
122 LY_DEFINE (ly_book_add_bookpart_x, "ly:book-add-bookpart!",
123 2, 0, 0, (SCM book_smob, SCM book_part),
124 "Add @var{book-part} to @var{book-smob} book part list.")
126 LY_ASSERT_SMOB (Book, book_smob, 1);
127 Book *book = unsmob_book (book_smob);
128 book->add_bookpart (book_part);
129 return SCM_UNSPECIFIED;
132 LY_DEFINE (ly_book_book_parts, "ly:book-book-parts",
134 "Return book parts in @var{book}.")
136 LY_ASSERT_SMOB (Book, book, 1);
137 Book *b = unsmob_book (book);
138 return b->bookparts_;
141 LY_DEFINE (ly_book_paper, "ly:book-paper",
143 "Return paper in @var{book}.")
145 LY_ASSERT_SMOB (Book, book, 1);
146 Book *b = unsmob_book (book);
147 return b->paper_ ? b->paper_->self_scm () : SCM_BOOL_F;
150 LY_DEFINE (ly_book_header, "ly:book-header",
152 "Return header in @var{book}.")
154 LY_ASSERT_SMOB (Book, book, 1);
155 Book *b = unsmob_book (book);
156 return b->header_ ? b->header_ : SCM_BOOL_F;
159 LY_DEFINE (ly_book_set_header_x, "ly:book-set-header!",
160 2, 0, 0, (SCM book, SCM module),
161 "Set the book header.")
163 LY_ASSERT_SMOB (Book, book, 1);
164 SCM_ASSERT_TYPE (ly_is_module (module), module, SCM_ARG2, __FUNCTION__,
167 Book *b = unsmob_book (book);
168 b->header_ = (module);
169 return SCM_UNSPECIFIED;
172 LY_DEFINE (ly_book_scores, "ly:book-scores",
174 "Return scores in @var{book}.")
176 LY_ASSERT_SMOB (Book, book, 1);
177 Book *b = unsmob_book (book);
181 #include "ly-smobs.icc"
183 IMPLEMENT_TYPE_P (Book, "ly:book?");