]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/score-scheme.cc
Web-ja: update introduction
[lilypond.git] / lily / score-scheme.cc
index 7a306af442703f7faf35683c048d5863a1605363..1d3e55bc6e31873047eae282ac033a6fe865fcf5 100644 (file)
@@ -1,7 +1,7 @@
 /*
   This file is part of LilyPond, the GNU music typesetter.
 
-  Copyright (C) 2005--2012 Han-Wen Nienhuys <hanwen@xs4all.nl>
+  Copyright (C) 2005--2015 Han-Wen Nienhuys <hanwen@xs4all.nl>
 
   LilyPond is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
@@ -44,7 +44,7 @@ LY_DEFINE (ly_score_output_defs, "ly:score-output-defs",
            "All output definitions in a score.")
 {
   LY_ASSERT_SMOB (Score, score, 1);
-  Score *sc = unsmob_score (score);
+  Score *sc = unsmob<Score> (score);
 
   SCM l = SCM_EOL;
   for (vsize i = 0; i < sc->defs_.size (); i++)
@@ -58,8 +58,8 @@ LY_DEFINE (ly_score_add_output_def_x, "ly:score-add-output-def!",
 {
   LY_ASSERT_SMOB (Score, score, 1);
   LY_ASSERT_SMOB (Output_def, def, 2);
-  Score *sc = unsmob_score (score);
-  Output_def *output_def = unsmob_output_def (def);
+  Score *sc = unsmob<Score> (score);
+  Output_def *output_def = unsmob<Output_def> (def);
   sc->add_output_def (output_def);
   return SCM_UNSPECIFIED;
 }
@@ -69,7 +69,7 @@ LY_DEFINE (ly_score_header, "ly:score-header",
            "Return score header.")
 {
   LY_ASSERT_SMOB (Score, score, 1);
-  Score *sc = unsmob_score (score);
+  Score *sc = unsmob<Score> (score);
   return sc->get_header ();
 }
 
@@ -81,7 +81,7 @@ LY_DEFINE (ly_score_set_header_x, "ly:score-set-header!",
   SCM_ASSERT_TYPE (ly_is_module (module), module, SCM_ARG2, __FUNCTION__,
                    "module");
 
-  Score *sc = unsmob_score (score);
+  Score *sc = unsmob<Score> (score);
   sc->set_header (module);
   return SCM_UNSPECIFIED;
 }
@@ -91,7 +91,7 @@ LY_DEFINE (ly_score_music, "ly:score-music",
            "Return score music.")
 {
   LY_ASSERT_SMOB (Score, score, 1);
-  Score *sc = unsmob_score (score);
+  Score *sc = unsmob<Score> (score);
   return sc->get_music ();
 }
 
@@ -100,7 +100,7 @@ LY_DEFINE (ly_score_error_p, "ly:score-error?",
            "Was there an error in the score?")
 {
   LY_ASSERT_SMOB (Score, score, 1);
-  Score *sc = unsmob_score (score);
+  Score *sc = unsmob<Score> (score);
   return scm_from_bool (sc->error_found_);
 }
 
@@ -113,8 +113,8 @@ LY_DEFINE (ly_score_embedded_format, "ly:score-embedded-format",
   LY_ASSERT_SMOB (Score, score, 1);
   LY_ASSERT_SMOB (Output_def, layout, 2);
 
-  Score *sc = unsmob_score (score);
-  Output_def *od = unsmob_output_def (layout);
+  Score *sc = unsmob<Score> (score);
+  Output_def *od = unsmob<Output_def> (layout);
 
   if (sc->error_found_)
     return SCM_EOL;
@@ -124,22 +124,22 @@ LY_DEFINE (ly_score_embedded_format, "ly:score-embedded-format",
   /* UGR, FIXME, these are default \layout blocks once again.  They
      suck. */
   for (vsize i = 0; !score_def && i < sc->defs_.size (); i++)
-    if (sc->defs_[i]->c_variable ("is-layout") == SCM_BOOL_T)
+    if (to_boolean (sc->defs_[i]->c_variable ("is-layout")))
       score_def = sc->defs_[i];
 
   if (!score_def)
     return SCM_BOOL_F;
 
-  score_def = score_def->clone ();
-  SCM prot = score_def->unprotect ();
+  /* Don't rescale if the layout has already been scaled */
+  if (to_boolean (score_def->c_variable ("cloned")))
+    score_def = score_def->clone ();
+  else
+    score_def = scale_output_def (score_def, output_scale (od));
 
-  /* TODO: SCORE_DEF should be scaled according to OD->parent_ or OD
-     itself. */
   score_def->parent_ = od;
 
-  SCM context = ly_run_translator (sc->get_music (), score_def->self_scm ());
+  SCM context = ly_run_translator (sc->get_music (), score_def->unprotect ());
   SCM output = ly_format_output (context);
 
-  scm_remember_upto_here_1 (prot);
   return output;
 }