(to_stencil): use Book::process().
* lily/include/my-lily-parser.hh (class My_lily_parser): remove
header_ field. Store in $globalheader
* lily/parser.yy (book_body): book header is initted to
$globalheader.
+2004-05-29 Han-Wen Nienhuys <hanwen@xs4all.nl>
+
+ * lily/book.cc (process): return Paper_book
+ (to_stencil): use Book::process().
+
+ * lily/include/my-lily-parser.hh (class My_lily_parser): remove
+ header_ field. Store in $globalheader
+
+ * lily/parser.yy (book_body): book header is initted to
+ $globalheader.
+
+
2004-05-28 Han-Wen Nienhuys <hanwen@xs4all.nl>
+ * input/test/fill-a4.ly: removed.
+
* lily/parser.yy (output_def): push scope of parent_ Output_def
too.
return 1;
}
-void
-Book::process (String outname, Output_def *default_def, SCM header)
+/*
+ This function does not dump the output; outname is required eg. for
+ dumping header fields.
+ */
+Paper_book *
+Book::process (String outname, Output_def *default_def)
{
Paper_book *paper_book = new Paper_book ();
-
Real scale = ly_scm2double (bookpaper_->c_variable ("outputscale"));
Output_def * scaled_bookdef = scale_output_def (bookpaper_, scale);
paper_book->bookpaper_ = scaled_bookdef;
+ scm_gc_unprotect_object (scaled_bookdef->self_scm());
+
+ paper_book->header_ = header_;
+
int score_count = scores_.size ();
for (int i = 0; i < score_count; i++)
{
{
Score_lines sc;
sc.lines_ = systems;
- sc.header_ = header;
+ sc.header_ = header_;
paper_book->score_lines_.push (sc);
}
}
- paper_book->output (outname);
-
- scm_gc_unprotect_object (paper_book->bookpaper_->self_scm ());
- scm_gc_unprotect_object (paper_book->self_scm ());
+ return paper_book;
}
/* FIXME: WIP, this is a hack. Return first page as stencil. */
SCM
-Book::to_stencil (Output_def *default_def, SCM header)
+Book::to_stencil (Output_def *default_def)
{
- Paper_book *paper_book = new Paper_book ();
- Real scale = ly_scm2double (bookpaper_->c_variable ("outputscale"));
-
- Output_def * scaled_bookdef = scale_output_def (bookpaper_, scale);
-
- paper_book->bookpaper_ = scaled_bookdef;
-
- int score_count = scores_.size ();
- for (int i = 0; i < score_count; i++)
- {
- SCM systems = scores_[i]->book_rendering ("<markup>",
- bookpaper_,
- default_def);
-
- if (systems != SCM_UNDEFINED)
- {
- Score_lines sc;
- sc.lines_ = systems;
- sc.header_ =header;
-
- paper_book->score_lines_.push (sc);
-
- // wtf: code dup.
- }
- }
+ Paper_book *paper_book = process ("<markup>", default_def);
SCM pages = paper_book->pages ();
- paper_book = 0;
+ scm_gc_unprotect_object (paper_book->self_scm ());
+
if (pages != SCM_EOL)
{
progress_indication (_f ("paper output to `%s'...", "<markup>"));
Link_array<Score> scores_;
Book ();
- void process (String outname, Output_def*, SCM header);
- SCM to_stencil (Output_def*, SCM header);
+ Paper_book* process (String, Output_def*);
+ SCM to_stencil (Output_def*);
};
DECLARE_UNSMOB (Book, book);
void start_main_input ();
SCM lookup_identifier (String s);
+ SCM lookup_identifier_symbol (SCM s);
void push_chord_state (SCM tab);
void push_figuredbass_state ();
void push_lyric_state ();
#include "input.hh"
#include "parray.hh"
#include "pitch.hh"
-#include "protected-scm.hh"
#include "smobs.hh"
#include "string.hh"
Sources *sources_;
Duration default_duration_;
String output_basename_;
- Protected_scm header_;
+ // Protected_scm header_;
int score_count_;
int book_count_;
int fatal_error_;
Real height_;
SCM copyright_;
SCM tagline_;
- SCM global_header_;
public:
+ SCM header_;
Array<Score_lines> score_lines_;
Output_def *bookpaper_;
}
SCM
-My_lily_lexer::lookup_identifier (String name)
+My_lily_lexer::lookup_identifier_symbol (SCM sym)
{
- SCM sym = ly_symbol2scm (name.to_str0 ());
for (SCM s = scopes_; ly_c_pair_p (s); s = ly_cdr (s))
{
SCM var = ly_module_lookup (ly_car (s), sym);
return SCM_UNDEFINED;
}
+SCM
+My_lily_lexer::lookup_identifier (String name)
+{
+ return lookup_identifier_symbol ( ly_symbol2scm (name.to_str0 ()));
+}
+
void
My_lily_lexer::start_main_input ()
{
#include "file-path.hh"
#include "lily-version.hh"
#include "ly-module.hh"
-#include "ly-smobs.icc"
#include "main.hh"
#include "my-lily-lexer.hh"
#include "my-lily-parser.hh"
#include "output-def.hh"
-#include "parray.hh"
+#include "paper-book.hh"
#include "parser.hh"
-#include "scm-hash.hh"
#include "score.hh"
#include "source.hh"
-#include "string.hh"
#include "warn.hh"
+#include "ly-smobs.icc"
+
+
My_lily_parser::My_lily_parser (Sources *sources)
{
book_count_ = 0;
default_duration_ = Duration (2,0);
error_level_ = 0;
last_beam_start_ = SCM_EOL;
- header_ = SCM_EOL;
- header_ = ly_make_anonymous_module (false);
smobify_self ();
}
default_duration_ = src.default_duration_;
error_level_ = src.error_level_;
last_beam_start_ = src.last_beam_start_;
- header_ = src.header_;
smobify_self ();
lexer_ = new My_lily_lexer (*src.lexer_);
My_lily_parser::mark_smob (SCM s)
{
My_lily_parser *parser = (My_lily_parser*) ly_cdr (s);
- return parser->header_;
+ return SCM_EOL;
}
int
SCM_ASSERT_TYPE (score, score_smob, SCM_ARG2, __FUNCTION__, "score");
SCM header = ly_c_module_p (score->header_) ? score->header_
- : parser->header_.to_SCM ();
+ : parser->lexer_->lookup_identifier ("$globalheader");
File_name outname (parser->output_basename_);
int *c = &parser->book_count_;
/* ugh. changing argument.*/
book->bookpaper_ = bp;
- SCM header = parser->header_;
File_name outname (parser->output_basename_);
int *c = &parser->book_count_;
if (*c)
Output_def *paper = get_paper (parser);
- book->process (outname.to_string (), paper, header);
+ Paper_book* pb = book->process (outname.to_string (), paper);
+ pb->output (outname.to_string ());
+
scm_gc_unprotect_object (paper->self_scm ());
+ scm_gc_unprotect_object (pb->self_scm ());
+
return SCM_UNDEFINED;
}
{
copyright_ = SCM_EOL;
tagline_ = SCM_EOL;
- global_header_ = SCM_EOL;
+ header_ = SCM_EOL;
bookpaper_ = 0;
smobify_self ();
scm_gc_mark (b->copyright_);
if (b->bookpaper_)
scm_gc_mark (b->bookpaper_->self_scm ());
- scm_gc_mark (b->global_header_);
+ scm_gc_mark (b->header_);
return b->tagline_;
}
Paper_outputter *out = get_paper_outputter (outname);
int page_count = scm_ilength (pages);
- out->output_header (bookpaper_, global_header_, page_count, false);
+ out->output_header (bookpaper_, scm_list_1 (header_), page_count, false);
for (SCM s = pages; s != SCM_EOL; s = ly_cdr (s))
{
// ugh code dup
SCM scopes = SCM_EOL;
- if (ly_c_module_p (global_header_))
- scopes = scm_cons (global_header_, scopes);
+ if (ly_c_module_p (header_))
+ scopes = scm_cons (header_, scopes);
if (ly_c_module_p (score_lines_[i].header_))
scopes = scm_cons (score_lines_[i].header_, scopes);
// ugh code dup
SCM scopes = SCM_EOL;
- if (ly_c_module_p (global_header_))
- scopes = scm_cons (global_header_, scopes);
+ if (ly_c_module_p (header_))
+ scopes = scm_cons (header_, scopes);
if (ly_c_module_p (score_lines_[0].header_))
scopes = scm_cons (score_lines_[0].header_, scopes);
//end ugh
- out->output_header (p, global_header_, 0, true);
+ out->output_header (p, header_, 0, true);
SCM top_lines = score_lines_.top ().lines_;
Paper_line *first = unsmob_paper_line (scm_vector_ref (top_lines,
Output_def *paper = bookpaper_;
SCM scopes = SCM_EOL;
- if (ly_c_module_p (global_header_))
- scopes = scm_cons (global_header_, scopes);
+ if (ly_c_module_p (header_))
+ scopes = scm_cons (header_, scopes);
SCM make_tagline = paper->c_variable ("make-tagline");
tagline_ = scm_call_2 (make_tagline, paper->self_scm (), scopes);
toplevel_expression:
lilypond_header {
- THIS->header_ = $1;
+ THIS->lexer_->set_identifier (ly_symbol2scm ("$globalheader"), $1);
}
| add_quote {
$$->set_spot (THIS->here_input ());
$$->bookpaper_ = dynamic_cast<Output_def*> (unsmob_output_def (THIS->lexer_->lookup_identifier ("$defaultbookpaper"))->clone ());
scm_gc_unprotect_object ($$->bookpaper_->self_scm ());
+ $$->header_ = THIS->lexer_->lookup_identifier ("$globalheader");
}
| book_body book_paper_block {
$$->bookpaper_ = $2;
scm_gc_unprotect_object (music->self_scm ());
}
| lilypond_header {
- THIS->header_ = $1;
+ $$->header_ = $1;
}
| book_body error {
THIS->lexer_->pop_state ();
Score *score = $2;
Book *book = new Book;
+ book->header_ = THIS->lexer_->lookup_identifier ("$globalheader");
book->scores_.push (score);
Output_def *paper = get_paper (THIS);
book->bookpaper_ = get_bookpaper (THIS);
- SCM s = book->to_stencil (paper, THIS->header_);
+ SCM s = book->to_stencil (paper);
scm_gc_unprotect_object (score->self_scm ());
scm_gc_unprotect_object (book->self_scm ());
$$ = scm_list_2 (ly_scheme_function ("stencil-markup"), s);
Music_output *output = g->get_output ();
if (systems != SCM_UNDEFINED)
{
+ /*
+ ugh, this is strange, Paper_book without a Book object.
+ */
Paper_book *paper_book = new Paper_book ();
paper_book->bookpaper_ = unsmob_output_def (scaled_bookdef);
}
LY_DEFINE (ly_score_bookify, "ly:score-bookify",
- 1, 0, 0,
- (SCM score_smob),
- "Return SCORE encapsulated in a BOOK.")
+ 2, 0, 0,
+ (SCM score_smob, SCM header),
+ "Return @var{score_smob} encapsulated in a Book object. Set "
+ "@var{header} as book level header.")
{
SCM_ASSERT_TYPE (unsmob_score (score_smob), score_smob, SCM_ARG1, __FUNCTION__, "score_smob");
Score *score = unsmob_score (score_smob);
Book *book = new Book;
book->scores_.push (score);
+ book->header_ = header;
scm_gc_unprotect_object (book->self_scm ());
return book->self_scm ();
}
(define-public (print-score-as-book parser score)
(let
- ((book (ly:score-bookify score))
- )
+ ((book (ly:score-bookify score (ly:parser-lookup parser '$globalheader))))
(ly:parser-print-book parser book)))