From e904008e0f0b56f7cacd330a72c2b56ec6906a93 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Mon, 18 Apr 2005 13:27:48 +0000 Subject: [PATCH] * lily/paper-score-scheme.cc (LY_DEFINE): new file. (LY_DEFINE): ly:paper-score-paper-systems: new function * lily/score-scheme.cc (LY_DEFINE): require music argument. * lily/score.cc (default_rendering): use Music_output too. * lily/paper-score.cc (process): run get_paper_systems() only once. --- ChangeLog | 5 +++++ lily/music-output.cc | 2 +- lily/paper-score-scheme.cc | 21 +++++++++++++++++++++ lily/paper-score.cc | 4 ++-- lily/score-scheme.cc | 20 +++++++++++--------- scm/define-markup-commands.scm | 10 +++++----- 6 files changed, 45 insertions(+), 17 deletions(-) create mode 100644 lily/paper-score-scheme.cc diff --git a/ChangeLog b/ChangeLog index 43bd3a5a3c..d9816a68ca 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2005-04-18 Han-Wen Nienhuys + * lily/paper-score-scheme.cc (LY_DEFINE): new file. + (LY_DEFINE): ly:paper-score-paper-systems: new function + + * lily/score-scheme.cc (LY_DEFINE): require music argument. + * lily/score.cc (default_rendering): use Music_output too. * input/test/chord-names-languages.ly (Module): rename file. diff --git a/lily/music-output.cc b/lily/music-output.cc index 958a78a887..5330e864eb 100644 --- a/lily/music-output.cc +++ b/lily/music-output.cc @@ -32,7 +32,7 @@ Music_output::derived_mark () const IMPLEMENT_SMOBS (Music_output); IMPLEMENT_DEFAULT_EQUAL_P (Music_output); -IMPLEMENT_TYPE_P (Music_output, "ly:score?"); +IMPLEMENT_TYPE_P (Music_output, "ly:music-output?"); SCM Music_output::mark_smob (SCM s) diff --git a/lily/paper-score-scheme.cc b/lily/paper-score-scheme.cc new file mode 100644 index 0000000000..031c76b84c --- /dev/null +++ b/lily/paper-score-scheme.cc @@ -0,0 +1,21 @@ +/* + paper-score-scheme.cc -- implement Paper_score bindings + + source file of the GNU LilyPond music typesetter + + (c) 2005 Han-Wen Nienhuys + +*/ + +#include "paper-score.hh" + +LY_DEFINE (ly_paper_score_paper_systems, "ly:paper-score-paper-systems", + 1, 0, 0, + (SCM paper_score), + "Return vector of Paper_system objects from @var{paper-score}.") +{ + Paper_score *pscore = dynamic_cast (unsmob_music_output (paper_score)); + SCM_ASSERT_TYPE (pscore, paper_score, SCM_ARG1, __FUNCTION__, "Paper score (Music output)"); + + return pscore->get_paper_systems (); +} diff --git a/lily/paper-score.cc b/lily/paper-score.cc index 2c1f0797d0..b756841679 100644 --- a/lily/paper-score.cc +++ b/lily/paper-score.cc @@ -74,8 +74,8 @@ Paper_score::process () { if (be_verbose_global) message (_f ("Element count %d (spanners %d) ", - system_->element_count (), - system_->spanner_count ())); + system_->element_count (), + system_->spanner_count ())); message (_ ("Preprocessing graphical objects...") + " "); diff --git a/lily/score-scheme.cc b/lily/score-scheme.cc index 56a175149e..fce8296dc9 100644 --- a/lily/score-scheme.cc +++ b/lily/score-scheme.cc @@ -14,15 +14,17 @@ LY_DEFINE (ly_music_scorify, "ly:music-scorify", 2, 0, 0, (SCM music, SCM parser), - "Return MUSIC with TEXTS encapsulated in SCORE.") + "Return @var{music} with @var{texts} encapsulated in @var{score}.") { -#if 0 - SCM_ASSERT_TYPE (ly_c_music_p (music), music, SCM_ARG1, __FUNCTION__, "music"); -#endif + Music *mus = unsmob_music (music); + SCM_ASSERT_TYPE (mus, music, SCM_ARG1, __FUNCTION__, "music"); + Score *score = new Score; score->set_music (music, parser); - scm_gc_unprotect_object (score->self_scm ()); - return score->self_scm (); + + SCM self = score->self_scm (); + scm_gc_unprotect_object (self); + return self; } LY_DEFINE (ly_score_embedded_format, "ly:score-embedded-format", @@ -50,7 +52,7 @@ LY_DEFINE (ly_score_embedded_format, "ly:score-embedded-format", score_def = sc->defs_[i]; if (!score_def) - return scm_c_make_vector (0, SCM_EOL); + return SCM_BOOL_F; score_def = score_def->clone (); SCM prot = score_def->self_scm (); @@ -62,8 +64,8 @@ LY_DEFINE (ly_score_embedded_format, "ly:score-embedded-format", SCM context = ly_run_translator (sc->get_music (), score_def->self_scm (), key); - SCM lines = ly_format_output (context); + SCM output = ly_format_output (context); scm_remember_upto_here_1 (prot); - return lines; + return output; } diff --git a/scm/define-markup-commands.scm b/scm/define-markup-commands.scm index 33cb29a993..8c0d58cb62 100644 --- a/scm/define-markup-commands.scm +++ b/scm/define-markup-commands.scm @@ -103,14 +103,14 @@ one staff-space." (def-markup-command (score layout props score) (ly:score?) "Inline an image of music." - (let* ((systems (ly:score-embedded-format score layout))) + (let* ((output (ly:score-embedded-format score layout))) - (if (= (vector-length systems) 0) + (if (ly:music-output? output) + (ly:paper-system-stencil + (vector-ref (ly:paper-score-paper-systems output) 0)) (begin (ly:warning (_"no systems found in \\score markup, does it have a \\layout block?")) - empty-markup) - (let* ((stencil (ly:paper-system-stencil (vector-ref systems 0)))) - (ly:stencil-aligned-to stencil Y CENTER))))) + empty-stencil)))) (def-markup-command (simple layout props str) (string?) "A simple text string; @code{\\markup @{ foo @}} is equivalent with -- 2.39.5