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>
11 #include "output-def.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
;
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 ();
37 LY_DEFINE (ly_book_process
, "ly:book-process",
38 4, 0, 0, (SCM book_smob
,
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
));
60 return SCM_UNSPECIFIED
;
64 LY_DEFINE (ly_book_process_to_systems
, "ly:book-process-to-systems",
65 4, 0, 0, (SCM book_smob
,
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
));
83 pb
->classic_output (output
);
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
;