scm_gc_unprotect_object (music_);
for (int i = 0, n = s.defs_.size (); i < n; i++)
- defs_.push (s.defs_[i]->clone ());
-
+ {
+ Output_def * copy = s.defs_[i]->clone ();
+ defs_.push (copy);
+ scm_gc_unprotect_object (copy->self_scm ());
+ }
header_ = ly_make_anonymous_module (false);
if (ly_c_module_p (s.header_))
ly_module_copy (header_, s.header_);
}
SCM context = ly_run_translator (music, scaled_def, key);
- if (Global_context *g = dynamic_cast<Global_context *>
- (unsmob_context (context)))
+
+ SCM output_as_scm = ly_format_output (context);
+ Music_output *output = unsmob_music_output (output_as_scm);
+
+ if (Paper_score *pscore = dynamic_cast<Paper_score*> (output))
{
- SCM systems = ly_format_output (context, outname);
- 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->header_ = header;
- paper_book->paper_ = unsmob_output_def (scaled_bookdef);
+ /* ugh, this is strange, Paper_book without a Book object. */
+ Paper_book *paper_book = new Paper_book ();
+ paper_book->header_ = header;
+ paper_book->paper_ = unsmob_output_def (scaled_bookdef);
- if (ly_c_module_p (header))
- paper_book->add_score (header);
- paper_book->add_score (systems);
+ if (ly_c_module_p (header))
+ paper_book->add_score (header);
- paper_book->classic_output (ly_scm2string (outname));
- scm_gc_unprotect_object (paper_book->self_scm ());
- }
- delete output;
+ SCM systems = pscore->get_paper_systems ();
+ paper_book->add_score (systems);
+
+ paper_book->classic_output (ly_scm2string (outname));
+ scm_gc_unprotect_object (paper_book->self_scm ());
}
scm_remember_upto_here_1 (scaled_def);
+ scm_remember_upto_here_1 (output_as_scm);
scm_remember_upto_here_1 (scaled_bookdef);
}
/*
- Format score, return systems. OUTNAME is still passed to create a midi
- file.
+ Format score, return list of Music_output objects.
LAYOUTBOOK should be scaled already.
*/
SCM
-Score::book_rendering (String outname,
- Output_def *layoutbook,
+Score::book_rendering (Output_def *layoutbook,
Output_def *default_def,
Object_key *book_key)
{
if (layoutbook && layoutbook->c_variable ("is-paper") == SCM_BOOL_T)
scale = scm_to_double (layoutbook->c_variable ("outputscale"));
- SCM out = scm_makfrom0str (outname.to_str0 ());
- SCM systems = SCM_EOL;
+ SCM outputs = SCM_EOL;
+ SCM *tail = &outputs;
+
int outdef_count = defs_.size ();
Object_key *key = new Lilypond_general_key (book_key, user_key_, 0);
{
Output_def *def = outdef_count ? defs_[i] : default_def;
SCM scaled = SCM_EOL;
+
if (def->c_variable ("is-layout") == SCM_BOOL_T)
{
def = scale_output_def (def, scale);
SCM context = ly_run_translator (music_, def->self_scm (), scm_key);
if (dynamic_cast<Global_context *> (unsmob_context (context)))
{
- SCM s = ly_format_output (context, out);
- if (s != SCM_UNDEFINED)
- systems = s;
+ SCM s = ly_format_output (context);
+
+ *tail = scm_cons (s, SCM_EOL);
+ tail = SCM_CDRLOC(*tail);
}
scm_remember_upto_here_1 (scaled);
scm_remember_upto_here_1 (scm_key);
scm_remember_upto_here_1 (scaled_bookdef);
- return systems;
+ return outputs;
}
void