]> git.donarmstrong.com Git - lilypond.git/blob - lily/book-scheme.cc
Minor documentation improvements for Scheme functions.
[lilypond.git] / lily / book-scheme.cc
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 2004--2010 Han-Wen Nienhuys <hanwen@xs4all.nl>
5
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.
10
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.
15
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/>.
18 */
19
20 #include "book.hh"
21
22 #include "output-def.hh"
23 #include "score.hh"
24 #include "paper-book.hh"
25 #include "ly-module.hh"
26
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}.")
31 {
32   Output_def *odef = unsmob_output_def (paper);
33   LY_ASSERT_SMOB (Output_def, paper, 1);
34
35   Book *book = new Book;
36   book->paper_ = odef;
37
38   if (ly_is_module (header))
39     book->header_ = header;
40
41   book->scores_ = scm_append (scm_list_2 (scores, book->scores_));
42
43   SCM x = book->self_scm ();
44   book->unprotect ();
45   return x;
46 }
47
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}.")
51 {
52   Book *book = new Book;
53   book->scores_ = scm_append (scm_list_2 (scores, book->scores_));
54
55   SCM x = book->self_scm ();
56   book->unprotect ();
57   return x;
58 }
59
60 LY_DEFINE (ly_book_process, "ly:book-process",
61            4, 0, 0, (SCM book_smob,
62                      SCM default_paper,
63                      SCM default_layout,
64                      SCM output),
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).")
68 {
69   Book *book = unsmob_book (book_smob);
70
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);
74
75   Paper_book *pb = book->process (unsmob_output_def (default_paper),
76                                   unsmob_output_def (default_layout));
77   if (pb)
78     {
79       pb->output (output);
80       pb->unprotect ();
81     }
82
83   return SCM_UNSPECIFIED;
84 }
85
86
87 LY_DEFINE (ly_book_process_to_systems, "ly:book-process-to-systems",
88            4, 0, 0, (SCM book_smob,
89                      SCM default_paper,
90                      SCM default_layout,
91                      SCM output),
92            "Print book.  @var{output} is passed to the backend unchanged."
93            "  For example, it may be a string (for file based outputs)"
94            " or a socket (for network based output).")
95 {
96   LY_ASSERT_SMOB (Book, book_smob, 1);
97   LY_ASSERT_SMOB (Output_def, default_paper, 2);
98   LY_ASSERT_SMOB (Output_def, default_layout, 3);
99
100   Book *book = unsmob_book (book_smob); 
101
102   Paper_book *pb = book->process (unsmob_output_def (default_paper),
103                                   unsmob_output_def (default_layout));
104   if (pb)
105     {
106       pb->classic_output (output);
107       pb->unprotect ();
108     }
109
110   return SCM_UNSPECIFIED;
111 }
112
113 LY_DEFINE (ly_book_add_score_x, "ly:book-add-score!",
114            2, 0, 0, (SCM book_smob, SCM score),
115            "Add @var{score} to @var{book-smob} score list.")
116 {
117   LY_ASSERT_SMOB (Book, book_smob, 1);
118   Book *book = unsmob_book (book_smob); 
119   book->add_score (score);
120   return SCM_UNSPECIFIED;
121 }
122
123 LY_DEFINE (ly_book_add_bookpart_x, "ly:book-add-bookpart!",
124            2, 0, 0, (SCM book_smob, SCM book_part),
125            "Add @var{book-part} to @var{book-smob} book part list.")
126 {
127   LY_ASSERT_SMOB (Book, book_smob, 1);
128   Book *book = unsmob_book (book_smob); 
129   book->add_bookpart (book_part);
130   return SCM_UNSPECIFIED;
131 }
132
133 LY_DEFINE (ly_book_book_parts, "ly:book-book-parts",
134            1, 0, 0, (SCM book),
135            "Return book parts in @var{book}.")
136 {
137   LY_ASSERT_SMOB (Book, book, 1);
138   Book *b = unsmob_book (book);
139   return b->bookparts_;
140 }
141
142 LY_DEFINE (ly_book_paper, "ly:book-paper",
143            1, 0, 0, (SCM book),
144            "Return paper in @var{book}.")
145 {
146   LY_ASSERT_SMOB (Book, book, 1);
147   Book *b = unsmob_book (book);
148   return b->paper_ ? b->paper_->self_scm () : SCM_BOOL_F;
149 }
150
151 LY_DEFINE (ly_book_scores, "ly:book-scores",
152            1, 0, 0, (SCM book),
153            "Return scores in @var{book}.")
154 {
155   LY_ASSERT_SMOB (Book, book, 1);
156   Book *b = unsmob_book (book);
157   return b->scores_;
158 }