Use scalar instead of embedded_scm for context mod overrides.
[lilypond/mpolesky.git] / lily / book-scheme.cc
blob0c0896668fbe07f11bdf0c32a2820e2d27263e2e
1 /*
2 book-scheme.cc -- implement Book bindings
4 source file of the GNU LilyPond music typesetter
6 (c) 2004--2009 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_make_book_part, "ly:make-book-part",
38 1, 0, 0, (SCM scores),
39 "Make a @code{\\bookpart} containing @code{\\scores}.")
41 Book *book = new Book;
42 book->scores_ = scm_append (scm_list_2 (scores, book->scores_));
44 SCM x = book->self_scm ();
45 book->unprotect ();
46 return x;
49 LY_DEFINE (ly_book_process, "ly:book-process",
50 4, 0, 0, (SCM book_smob,
51 SCM default_paper,
52 SCM default_layout,
53 SCM output),
54 "Print book. @var{output} is passed to the backend unchanged."
55 " For example, it may be a string (for file based outputs)"
56 " or a socket (for network based output).")
58 Book *book = unsmob_book (book_smob);
60 LY_ASSERT_SMOB (Book, book_smob, 1);
61 LY_ASSERT_SMOB (Output_def, default_paper, 2);
62 LY_ASSERT_SMOB (Output_def, default_layout, 3);
64 Paper_book *pb = book->process (unsmob_output_def (default_paper),
65 unsmob_output_def (default_layout));
66 if (pb)
68 pb->output (output);
69 pb->unprotect ();
72 return SCM_UNSPECIFIED;
76 LY_DEFINE (ly_book_process_to_systems, "ly:book-process-to-systems",
77 4, 0, 0, (SCM book_smob,
78 SCM default_paper,
79 SCM default_layout,
80 SCM output),
81 "Print book. @var{output} is passed to the backend unchanged."
82 " For example, it may be a string (for file based outputs)"
83 " or a socket (for network based output).")
85 LY_ASSERT_SMOB (Book, book_smob, 1);
86 LY_ASSERT_SMOB (Output_def, default_paper, 2);
87 LY_ASSERT_SMOB (Output_def, default_layout, 3);
89 Book *book = unsmob_book (book_smob);
91 Paper_book *pb = book->process (unsmob_output_def (default_paper),
92 unsmob_output_def (default_layout));
93 if (pb)
95 pb->classic_output (output);
96 pb->unprotect ();
99 return SCM_UNSPECIFIED;
102 LY_DEFINE (ly_book_add_score_x, "ly:book-add-score!",
103 2, 0, 0, (SCM book_smob, SCM score),
104 "Add @var{score} to @var{book-smob} score list.")
106 LY_ASSERT_SMOB (Book, book_smob, 1);
107 Book *book = unsmob_book (book_smob);
108 book->add_score (score);
109 return SCM_UNSPECIFIED;
112 LY_DEFINE (ly_book_add_bookpart_x, "ly:book-add-bookpart!",
113 2, 0, 0, (SCM book_smob, SCM book_part),
114 "Add @var{book_part} to @var{book-smob} book part list.")
116 LY_ASSERT_SMOB (Book, book_smob, 1);
117 Book *book = unsmob_book (book_smob);
118 book->add_bookpart (book_part);
119 return SCM_UNSPECIFIED;