From 61bba8a98a53e424054b26d63ead26b0696ea29d Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Mon, 14 Jun 2004 13:39:41 +0000 Subject: [PATCH] * lily/paper-score.cc (process): Do not show progress newline. * lily/paper-book.cc (output, classic_output): Show progess newline after score. --- ChangeLog | 12 ++ lily/book-paper-def.cc | 67 ++++------ lily/book.cc | 24 ++-- lily/context-def.cc | 221 ++++++++++++++------------------- lily/duration.cc | 15 ++- lily/grob-scheme.cc | 60 +++++---- lily/identifier-smob.cc | 21 ++-- lily/include/ly-module.hh | 2 +- lily/lily-guile.cc | 23 ++-- lily/ly-module.cc | 31 +++-- lily/moment.cc | 139 ++++++++++----------- lily/my-lily-parser.cc | 62 ++++----- lily/output-def.cc | 70 ++++------- lily/paper-book.cc | 98 +++++---------- lily/paper-outputter.cc | 1 - lily/paper-score.cc | 30 ++--- lily/pitch.cc | 17 ++- lily/score.cc | 80 ++++-------- lily/script-column.cc | 4 +- lily/stencil-scheme.cc | 2 +- lily/system.cc | 7 +- scm/define-markup-commands.scm | 4 +- 22 files changed, 419 insertions(+), 571 deletions(-) diff --git a/ChangeLog b/ChangeLog index fdc7a9797d..4c94a60dca 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,9 +1,21 @@ +2004-06-14 Jan Nieuwenhuizen + + * lily/paper-score.cc (process): Do not show progress newline. + + * lily/paper-book.cc (output, classic_output): Show progess + newline after score. + 2004-06-14 Heikki Junes * buildscripts/lilypond-words.py: add ly/vlaams.ly 2004-06-14 Jan Nieuwenhuizen + * lily/score.cc (ly:run-translator): Do not crash on empty music + list. + + * lily/book.cc (process): Do not render score when systems is empty. + * input/simple-song.ly: Down one octave. * scm/output-gnome.scm: Remove script again; re-add modules fix diff --git a/lily/book-paper-def.cc b/lily/book-paper-def.cc index 517887939e..95d7114dc2 100644 --- a/lily/book-paper-def.cc +++ b/lily/book-paper-def.cc @@ -1,38 +1,31 @@ /* book-paper-def.cc -- implement Output_def - + source file of the GNU LilyPond music typesetter - + (c) 2004 Han-Wen Nienhuys - */ -#include "ly-module.hh" -#include "output-def.hh" #include "dimensions.hh" -#include "ly-smobs.icc" #include "font-metric.hh" -#include "virtual-font-metric.hh" +#include "ly-module.hh" +#include "output-def.hh" #include "scaled-font-metric.hh" +#include "virtual-font-metric.hh" Real -output_scale (Output_def * od) +output_scale (Output_def *od) { return ly_scm2double (od->lookup_variable (ly_symbol2scm ("outputscale"))); } -/* - TODO: should add nesting for Output_def here too. - */ -Font_metric* -find_scaled_font (Output_def * mod, +/* TODO: should add nesting for Output_def here too. */ +Font_metric * +find_scaled_font (Output_def *mod, Font_metric *f, Real m, SCM input_enc_name) { if (mod->parent_) - { - return find_scaled_font (mod->parent_, - f, m, input_enc_name); - } + return find_scaled_font (mod->parent_, f, m, input_enc_name); Real lookup_mag = m; if (!dynamic_cast (f)) @@ -61,18 +54,14 @@ find_scaled_font (Output_def * mod, SCM val = SCM_EOL; if (Virtual_font_metric * vf = dynamic_cast (f)) { - /* - For fontify_atom (), the magnification and name must be known - at the same time. That's impossible for - - Scaled (Virtual_font (Font1,Font2)) - - so we replace by - - Virtual_font (Scaled (Font1), Scaled (Font2)) - - */ - + /* For fontify_atom (), the magnification and name must be known + at the same time. That's impossible for + + Scaled (Virtual_font (Font1,Font2)) + + so we replace by + + Virtual_font (Scaled (Font1), Scaled (Font2)) */ SCM lst = SCM_EOL; SCM *t = &lst; for (SCM s = vf->get_font_list (); ly_c_pair_p (s); s = ly_cdr (s)) @@ -91,7 +80,8 @@ find_scaled_font (Output_def * mod, { if (!ly_c_symbol_p (input_enc_name)) { - SCM var = ly_module_lookup (mod->scope_, ly_symbol2scm ("inputencoding")); + SCM var = ly_module_lookup (mod->scope_, + ly_symbol2scm ("inputencoding")); if (var != SCM_BOOL_F) input_enc_name = scm_variable_ref (var); if (!ly_c_symbol_p (input_enc_name)) @@ -108,17 +98,14 @@ find_scaled_font (Output_def * mod, return unsmob_metrics (val); } -/* - TODO: this is a nasty interface. During formatting, - the Output_def should be scaled to the output_scale_ - specified in the toplevel Output_def. - */ -Output_def* -scale_output_def (Output_def * o, Real amount) +/* TODO: this is a nasty interface. During formatting, + the Output_def should be scaled to the output_scale_ + specified in the toplevel Output_def. */ +Output_def * +scale_output_def (Output_def *o, Real amount) { SCM proc = ly_scheme_function ("scale-paper"); - SCM new_pap = scm_call_2 (proc, o->self_scm (), - scm_double2num (amount)); + SCM new_pap = scm_call_2 (proc, o->self_scm (), scm_double2num (amount)); scm_gc_protect_object (new_pap); return unsmob_output_def (new_pap); @@ -144,7 +131,7 @@ LY_DEFINE (ly_bookpaper_fonts, "ly:bookpaper-fonts", s = ly_cdr (s)) { SCM entry = ly_car (s); - for (SCM t = ly_cdr (entry); ly_c_pair_p (t); t = ly_cdr (t)) + for (SCM t = ly_cdr (entry); ly_c_pair_p (t); t = ly_cdr (t)) { Font_metric *fm = unsmob_metrics (ly_cdar (t)); diff --git a/lily/book.cc b/lily/book.cc index 4a26b47a73..5159c117b4 100644 --- a/lily/book.cc +++ b/lily/book.cc @@ -8,20 +8,17 @@ #include - -#include "ly-smobs.icc" -#include "stencil.hh" #include "book.hh" #include "global-context.hh" #include "ly-module.hh" #include "main.hh" #include "music-iterator.hh" -#include "output-def.hh" #include "music-output.hh" #include "music.hh" -#include "paper-book.hh" #include "output-def.hh" +#include "paper-book.hh" #include "score.hh" +#include "stencil.hh" #include "warn.hh" Book::Book () @@ -37,6 +34,7 @@ Book::~Book () { } +#include "ly-smobs.icc" IMPLEMENT_SMOBS (Book); IMPLEMENT_DEFAULT_EQUAL_P (Book); @@ -60,10 +58,8 @@ Book::print_smob (SCM, SCM p, scm_print_state*) return 1; } -/* - This function does not dump the output; outname is required eg. for - dumping header fields. - */ +/* 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) { @@ -83,12 +79,18 @@ Book::process (String outname, Output_def *default_def) SCM systems = scores_[i]->book_rendering (outname, paper_book->bookpaper_, default_def); - if (systems != SCM_UNDEFINED) + + /* If the score is empty, generate no output. Should we + do titling? */ + if (systems != SCM_EOL + /* FIXME: can systems be SCM_UNDEFINED at all? + it seesm to be initialise with SCM_EOL and only gets assigned + non-SCM_UNDEFINED values -- jcn */ + && systems != SCM_UNDEFINED) { Score_lines sc; sc.lines_ = systems; sc.header_ = header_; - paper_book->score_lines_.push (sc); } } diff --git a/lily/context-def.cc b/lily/context-def.cc index 42ea516f91..e9c7f4da3c 100644 --- a/lily/context-def.cc +++ b/lily/context-def.cc @@ -1,55 +1,22 @@ /* translator-def.cc -- implement Context_def - + source file of the GNU LilyPond music typesetter - + (c) 2000--2004 Han-Wen Nienhuys - - */ +*/ -/* - TODO: should junk this class an replace by - a single list of context modifications? - */ +/* TODO: should junk this class an replace by + a single list of context modifications? */ -#include "lily-proto.hh" #include "context-def.hh" -#include "translator-group.hh" -#include "warn.hh" +#include "engraver.hh" +#include "lily-proto.hh" #include "output-def.hh" -#include "ly-smobs.icc" -#include "score-context.hh" - #include "performer.hh" -#include "engraver.hh" - -int -Context_def::print_smob (SCM smob, SCM port, scm_print_state*) -{ - Context_def* me = (Context_def*) SCM_CELL_WORD_1 (smob); - - scm_puts ("#context_name_, port); - scm_puts (">", port); - return 1; -} - - -SCM -Context_def::mark_smob (SCM smob) -{ - Context_def* me = (Context_def*) SCM_CELL_WORD_1 (smob); - - scm_gc_mark (me->description_); - scm_gc_mark (me->context_aliases_); - scm_gc_mark (me->accept_mods_); - scm_gc_mark (me->translator_mods_); - scm_gc_mark (me->property_ops_); - scm_gc_mark (me->translator_group_type_); - - return me->context_name_; -} - +#include "score-context.hh" +#include "translator-group.hh" +#include "warn.hh" Context_def::Context_def () { @@ -66,10 +33,6 @@ Context_def::Context_def () context_name_ = ly_symbol2scm (""); } -Context_def::~Context_def () -{ -} - Context_def::Context_def (Context_def const & s) : Input (s) { @@ -92,15 +55,48 @@ Context_def::Context_def (Context_def const & s) context_name_ = s.context_name_; } +Context_def::~Context_def () +{ +} + +#include "ly-smobs.icc" +IMPLEMENT_SMOBS (Context_def); +IMPLEMENT_DEFAULT_EQUAL_P (Context_def); + +int +Context_def::print_smob (SCM smob, SCM port, scm_print_state*) +{ + Context_def* me = (Context_def*) SCM_CELL_WORD_1 (smob); + + scm_puts ("#context_name_, port); + scm_puts (">", port); + return 1; +} + +SCM +Context_def::mark_smob (SCM smob) +{ + Context_def* me = (Context_def*) SCM_CELL_WORD_1 (smob); + + scm_gc_mark (me->description_); + scm_gc_mark (me->context_aliases_); + scm_gc_mark (me->accept_mods_); + scm_gc_mark (me->translator_mods_); + scm_gc_mark (me->property_ops_); + scm_gc_mark (me->translator_group_type_); + + return me->context_name_; +} void Context_def::add_context_mod (SCM mod) { - SCM tag = ly_car (mod); - if (ly_symbol2scm ("description") == tag) + SCM tag = ly_car (mod); + if (ly_symbol2scm ("description") == tag) { description_ = ly_cadr (mod); - return ; + return; } SCM sym = ly_cadr (mod); @@ -112,43 +108,30 @@ Context_def::add_context_mod (SCM mod) || ly_symbol2scm ("remove") == tag) { if (!get_translator (sym)) - error (_f ("Program has no such type: `%s'", ly_symbol2string (sym).to_str0 ())); + error (_f ("Program has no such type: `%s'", + ly_symbol2string (sym).to_str0 ())); else - translator_mods_ = scm_cons (scm_list_2 (tag, sym), translator_mods_ ); + translator_mods_ = scm_cons (scm_list_2 (tag, sym), translator_mods_); } else if (ly_symbol2scm ("accepts") == tag || ly_symbol2scm ("denies") == tag) - { - accept_mods_ = scm_cons (scm_list_2 (tag, sym), accept_mods_); - } + accept_mods_ = scm_cons (scm_list_2 (tag, sym), accept_mods_); else if (ly_symbol2scm ("poppush") == tag || ly_symbol2scm ("pop") == tag || ly_symbol2scm ("push") == tag || ly_symbol2scm ("assign") == tag || ly_symbol2scm ("unset") == tag) - { - property_ops_ = scm_cons (mod, property_ops_); - } + property_ops_ = scm_cons (mod, property_ops_); else if (ly_symbol2scm ("alias") == tag) - { - context_aliases_ = scm_cons (sym, context_aliases_); - } + context_aliases_ = scm_cons (sym, context_aliases_); else if (ly_symbol2scm ("translator-type") == tag) - { - translator_group_type_ = sym; - } + translator_group_type_ = sym; else if (ly_symbol2scm ("context-name") == tag) - { - context_name_ = sym; - } + context_name_ = sym; else - { - programming_error ("Unknown context mod tag."); - } + programming_error ("Unknown context mod tag."); } - - SCM Context_def::get_context_name () const { @@ -158,8 +141,7 @@ Context_def::get_context_name () const SCM Context_def::get_accepted (SCM user_mod) const { - SCM mods = scm_reverse_x (scm_list_copy (accept_mods_), - user_mod); + SCM mods = scm_reverse_x (scm_list_copy (accept_mods_), user_mod); SCM acc = SCM_EOL; for (SCM s = mods; ly_c_pair_p (s); s = ly_cdr (s)) { @@ -173,9 +155,8 @@ Context_def::get_accepted (SCM user_mod) const return acc; } - Link_array -Context_def::path_to_acceptable_context (SCM type_sym, Output_def* odef) const +Context_def::path_to_acceptable_context (SCM type_sym, Output_def *odef) const { assert (ly_c_symbol_p (type_sym)); @@ -183,26 +164,22 @@ Context_def::path_to_acceptable_context (SCM type_sym, Output_def* odef) const Link_array accepteds; for (SCM s = accepted; ly_c_pair_p (s); s = ly_cdr (s)) - { - Context_def *t = unsmob_context_def (find_context_def (odef, ly_car (s))); - if (!t) - continue; + if (Context_def *t = unsmob_context_def (find_context_def (odef, + ly_car (s)))) accepteds.push (t); - } Link_array best_result; for (int i=0; i < accepteds.size (); i++) { - /* - don't check aliases, because \context Staff should not create RhythmicStaff. - */ + /* do not check aliases, because \context Staff should not + create RhythmicStaff. */ if (ly_c_equal_p (accepteds[i]->get_context_name (), type_sym)) { best_result.push (accepteds[i]); return best_result; } } - + int best_depth= INT_MAX; for (int i=0; i < accepteds.size (); i++) { @@ -215,10 +192,8 @@ Context_def::path_to_acceptable_context (SCM type_sym, Output_def* odef) const result.insert (g,0); best_result = result; - /* - this following line was added in 1.9.3, but hsould've been - there all along... Let's hope it doesn't cause nightmares. - */ + /* this following line was added in 1.9.3, but hsould've been + there all along... Let's hope it doesn't cause nightmares. */ best_depth = result.size (); } } @@ -226,18 +201,13 @@ Context_def::path_to_acceptable_context (SCM type_sym, Output_def* odef) const return best_result; } -IMPLEMENT_SMOBS (Context_def); -IMPLEMENT_DEFAULT_EQUAL_P (Context_def); - - SCM Context_def::get_translator_names (SCM user_mod) const { SCM l1 = SCM_EOL; SCM l2 = SCM_EOL; - SCM mods = scm_reverse_x (scm_list_copy (translator_mods_), - user_mod); + SCM mods = scm_reverse_x (scm_list_copy (translator_mods_), user_mod); for (SCM s = mods; ly_c_pair_p (s); s = ly_cdr (s)) { @@ -257,15 +227,13 @@ Context_def::get_translator_names (SCM user_mod) const l2 = scm_delete_x (arg, l2); } } - return scm_append_x (scm_list_2 (l1, l2)); } - SCM -filter_performers (SCM l) +filter_performers (SCM ell) { - for (SCM *tail = &l; ly_c_pair_p (*tail); tail = SCM_CDRLOC (*tail)) + for (SCM *tail = ℓ ly_c_pair_p (*tail); tail = SCM_CDRLOC (*tail)) { if (dynamic_cast (unsmob_translator (ly_car (*tail)))) { @@ -274,14 +242,13 @@ filter_performers (SCM l) break ; } } - return l; + return ell; } - SCM -filter_engravers (SCM l) +filter_engravers (SCM ell) { - SCM *tail = &l; + SCM *tail = ℓ for (; ly_c_pair_p (*tail) ; tail = SCM_CDRLOC (*tail)) { if (dynamic_cast (unsmob_translator (ly_car (*tail)))) @@ -291,14 +258,14 @@ filter_engravers (SCM l) break ; } } - return l; + return ell; } Context * Context_def::instantiate (SCM ops) { - Context * tg = 0; + Context *tg = 0; if (context_name_ == ly_symbol2scm ("Score")) tg = new Score_context (); @@ -309,27 +276,25 @@ Context_def::instantiate (SCM ops) SCM trans_names = get_translator_names (ops); - Translator * g = get_translator (translator_group_type_); + Translator *g = get_translator (translator_group_type_); g = g->clone (); - g->simple_trans_list_ = SCM_EOL; + g->simple_trans_list_ = SCM_EOL; for (SCM s = trans_names; ly_c_pair_p (s) ; s = ly_cdr (s)) { - Translator * t = get_translator (ly_car (s)); + Translator *t = get_translator (ly_car (s)); if (!t) warning (_f ("can't find: `%s'", s)); else { - Translator * tr = t->clone (); + Translator *tr = t->clone (); SCM str = tr->self_scm (); g->simple_trans_list_ = scm_cons (str, g->simple_trans_list_); tr->daddy_context_ = tg; scm_gc_unprotect_object (str); } } - - tg->implementation_ = g->self_scm (); if (dynamic_cast (g)) @@ -347,12 +312,10 @@ Context_def::instantiate (SCM ops) return tg; } - SCM Context_def::clone_scm () const { Context_def * t = new Context_def (*this); - SCM x = t->self_scm (); scm_gc_unprotect_object (x); return x; @@ -362,8 +325,7 @@ SCM Context_def::make_scm () { Context_def* t = new Context_def; - - SCM x =t->self_scm (); + SCM x = t->self_scm (); scm_gc_unprotect_object (x); return x; } @@ -371,25 +333,28 @@ Context_def::make_scm () void Context_def::apply_default_property_operations (Context *tg) { - apply_property_operations (tg , property_ops_); + apply_property_operations (tg, property_ops_); } SCM Context_def::to_alist () const { - SCM l = SCM_EOL; - - l = scm_cons (scm_cons (ly_symbol2scm ("consists"), - get_translator_names (SCM_EOL)), l); - l = scm_cons (scm_cons (ly_symbol2scm ("description"), description_), l); - l = scm_cons (scm_cons (ly_symbol2scm ("aliases"), context_aliases_), l); - l = scm_cons (scm_cons (ly_symbol2scm ("accepts"), get_accepted (SCM_EOL)), l); - l = scm_cons (scm_cons (ly_symbol2scm ("property-ops"), property_ops_), l); - l = scm_cons (scm_cons (ly_symbol2scm ("context-name"), context_name_), l); + SCM ell = SCM_EOL; + + ell = scm_cons (scm_cons (ly_symbol2scm ("consists"), + get_translator_names (SCM_EOL)), ell); + ell = scm_cons (scm_cons (ly_symbol2scm ("description"), description_), ell); + ell = scm_cons (scm_cons (ly_symbol2scm ("aliases"), context_aliases_), ell); + ell = scm_cons (scm_cons (ly_symbol2scm ("accepts"), get_accepted (SCM_EOL)), + ell); + ell = scm_cons (scm_cons (ly_symbol2scm ("property-ops"), property_ops_), + ell); + ell = scm_cons (scm_cons (ly_symbol2scm ("context-name"), context_name_), + ell); if (ly_c_symbol_p (translator_group_type_)) - l = scm_cons (scm_cons (ly_symbol2scm ("group-type"), translator_group_type_), l); - - return l; + ell = scm_cons (scm_cons (ly_symbol2scm ("group-type"), + translator_group_type_), ell); + return ell; } diff --git a/lily/duration.cc b/lily/duration.cc index 3740b09f9a..82f5a506c2 100644 --- a/lily/duration.cc +++ b/lily/duration.cc @@ -128,7 +128,7 @@ Duration::less_p (SCM p1, SCM p2) return SCM_BOOL_F; } -LY_DEFINE (duration_less, "ly:durationduration_log ()); } -LY_DEFINE (dot_count_log, "ly:duration-dot-count", 1, 0, 0, (SCM dur), - "Extract the dot count from @var{dur}" -) +LY_DEFINE (ly_duration_dot_count, "ly:duration-dot-count", + 1, 0, 0, (SCM dur), + "Extract the dot count from @var{dur}") { SCM_ASSERT_TYPE (unsmob_duration (dur), dur, SCM_ARG1, __FUNCTION__, "duration"); return scm_int2num (unsmob_duration (dur)->dot_count ()); } - LY_DEFINE (ly_intlog2, "ly:intlog2", 1, 0, 0, (SCM d), "The 2-logarithm of 1/@var{d}.") @@ -219,7 +218,7 @@ LY_DEFINE (ly_intlog2, "ly:intlog2", return scm_int2num (log); } -LY_DEFINE (compression_factor, "ly:duration-factor", +LY_DEFINE (ly_duration_factor, "ly:duration-factor", 1, 0, 0, (SCM dur), "Extract the compression factor from @var{dur}. Return as a pair.") { diff --git a/lily/grob-scheme.cc b/lily/grob-scheme.cc index 740491f52a..05eedf6512 100644 --- a/lily/grob-scheme.cc +++ b/lily/grob-scheme.cc @@ -15,11 +15,11 @@ #include "system.hh" -LY_DEFINE (ly_grob_set_property,"ly:grob-set-property!", 3, 0, 0, - (SCM grob, SCM sym, SCM val), - "Set @var{sym} in grob @var{grob} to value @var{val}") +LY_DEFINE (ly_grob_set_property_x, "ly:grob-set-property!", + 3, 0, 0, (SCM grob, SCM sym, SCM val), + "Set @var{sym} in grob @var{grob} to value @var{val}") { - Grob * sc = unsmob_grob (grob); + Grob *sc = unsmob_grob (grob); SCM_ASSERT_TYPE (sc, grob, SCM_ARG1, __FUNCTION__, "grob"); SCM_ASSERT_TYPE (ly_c_symbol_p (sym), sym, SCM_ARG2, __FUNCTION__, "symbol"); @@ -30,7 +30,7 @@ LY_DEFINE (ly_grob_set_property,"ly:grob-set-property!", 3, 0, 0, return SCM_UNSPECIFIED; } -LY_DEFINE (ly_get_property, "ly:grob-property", +LY_DEFINE (ly_grob_property, "ly:grob-property", 2, 0, 0, (SCM grob, SCM sym), "Return the value of a value in grob @var{g} of property @var{sym}. " "It will return @code{' ()} (end-of-list) " @@ -45,8 +45,8 @@ LY_DEFINE (ly_get_property, "ly:grob-property", return sc->internal_get_property (sym); } -LY_DEFINE (spanner_get_bound, "ly:spanner-get-bound", 2 , 0, 0, - (SCM slur, SCM dir), +LY_DEFINE (ly_spanner_get_bound, "ly:spanner-get-bound", + 2, 0, 0, (SCM slur, SCM dir), "Get one of the bounds of @var{spanner}. @var{dir} is @code{-1} " "for left, and @code{1} for right.") { @@ -58,9 +58,9 @@ LY_DEFINE (spanner_get_bound, "ly:spanner-get-bound", 2 , 0, 0, /* TODO: make difference between scaled and unscalead variable in calling (i.e different funcs.) */ -LY_DEFINE (ly_grob_paper,"ly:grob-paper", 1, 0, 0, - (SCM g), - "Get @code{\\paper} definition from grob @var{g}.") +LY_DEFINE (ly_grob_paper, "ly:grob-paper", + 1, 0, 0, (SCM g), + "Get @code{\\paper} definition from grob @var{g}.") { Grob * sc = unsmob_grob (g); SCM_ASSERT_TYPE (sc, g, SCM_ARG1, __FUNCTION__, "grob"); @@ -68,45 +68,42 @@ LY_DEFINE (ly_grob_paper,"ly:grob-paper", 1, 0, 0, return sc->get_paper ()->self_scm (); } - -LY_DEFINE(ly_grob_alist_chain, "ly:grob-alist-chain", - 1, 1, 0, - (SCM g, SCM global), - "Get an alist chain for grob @var{g}, with @var{global} as the " - "global default. If unspecified, @code{font-defaults} " - "from the paper block is taken. " - ) +LY_DEFINE (ly_grob_alist_chain, "ly:grob-alist-chain", + 1, 1, 0, (SCM g, SCM global), + "Get an alist chain for grob @var{g}, with @var{global} as the " + "global default. If unspecified, @code{font-defaults} " + "from the paper block is taken. ") { - Grob * sc = unsmob_grob (g); + Grob *sc = unsmob_grob (g); SCM_ASSERT_TYPE (sc, g, SCM_ARG1, __FUNCTION__, "grob"); if (global == SCM_UNDEFINED) - global = sc->get_paper ()->lookup_variable (ly_symbol2scm ("font-defaults")); + global + = sc->get_paper ()->lookup_variable (ly_symbol2scm ("font-defaults")); return sc->get_property_alist_chain (global); } - -LY_DEFINE (ly_get_extent, "ly:grob-extent", 3, 0, 0, - (SCM grob, SCM refp, SCM axis), +LY_DEFINE (ly_get_extent, "ly:grob-extent", + 3, 0, 0, (SCM grob, SCM refp, SCM axis), "Get the extent in @var{axis} direction of @var{grob} relative to " "the grob @var{refp}") { - Grob * sc = unsmob_grob (grob); - Grob * ref = unsmob_grob (refp); + Grob *sc = unsmob_grob (grob); + Grob *ref = unsmob_grob (refp); SCM_ASSERT_TYPE (sc, grob, SCM_ARG1, __FUNCTION__, "grob"); SCM_ASSERT_TYPE (ref, refp, SCM_ARG2, __FUNCTION__, "grob"); - SCM_ASSERT_TYPE (is_axis (axis), axis, SCM_ARG3, __FUNCTION__, "axis"); return ly_interval2scm ( sc->extent (ref, Axis (ly_scm2int (axis)))); } -LY_DEFINE (ly_get_parent, "ly:grob-parent", 2, 0, 0, (SCM grob, SCM axis), +LY_DEFINE (ly_grob_parent, "ly:grob-parent", + 2, 0, 0, (SCM grob, SCM axis), "Get the parent of @var{grob}. @var{axis} is 0 for the X-axis, " "1 for the Y-axis.") { - Grob * sc = unsmob_grob (grob); + Grob *sc = unsmob_grob (grob); SCM_ASSERT_TYPE (sc, grob, SCM_ARG1, __FUNCTION__, "grob"); SCM_ASSERT_TYPE (is_axis (axis), axis, SCM_ARG2, __FUNCTION__, "axis"); @@ -114,7 +111,7 @@ LY_DEFINE (ly_get_parent, "ly:grob-parent", 2, 0, 0, (SCM grob, SCM axis), return par ? par->self_scm () : SCM_EOL; } -LY_DEFINE (ly_get_system, "ly:grob-system", +LY_DEFINE (ly_grob_system, "ly:grob-system", 1, 0, 0, (SCM g), "Return the System Grob of @var{g}.") { @@ -127,7 +124,7 @@ LY_DEFINE (ly_get_system, "ly:grob-system", return SCM_EOL; } -LY_DEFINE (ly_get_original, "ly:grob-original", +LY_DEFINE (ly_grob_original, "ly:grob-original", 1, 0, 0, (SCM grob), "Return the unbroken original Grob of @var{grob}.") { @@ -136,10 +133,9 @@ LY_DEFINE (ly_get_original, "ly:grob-original", return me->original_ ? me->original_->self_scm () : me->self_scm (); } -/* FIXME: ly prefix? spanner in name? */ /* TODO: maybe we should return a vector -- random access is more logical for this list? */ -LY_DEFINE (get_broken_into, "ly:spanner-broken-into", +LY_DEFINE (ly_spanner_broken_into, "ly:spanner-broken-into", 1, 0, 0, (SCM spanner), "Return broken-into list for @var{spanner}.") { diff --git a/lily/identifier-smob.cc b/lily/identifier-smob.cc index 3696cf4954..7846df2666 100644 --- a/lily/identifier-smob.cc +++ b/lily/identifier-smob.cc @@ -1,12 +1,12 @@ -/* -identifier-smob.cc -- implement glue to pass Scheme expressions off as -identifiers. +/* + identifier-smob.cc -- implement glue to pass Scheme expressions off as + identifiers. -source file of the GNU LilyPond music typesetter - -(c) 2002--2004 Han-Wen Nienhuys + source file of the GNU LilyPond music typesetter + (c) 2002--2004 Han-Wen Nienhuys */ + #include "identifier-smob.hh" @@ -25,16 +25,16 @@ print_box (SCM b, SCM port, scm_print_state *) return 1; } - /* This defines the primitve `make-box', which returns a new smob of type `box', initialized to `#f'. */ -LY_DEFINE (package_identifier, "ly:export", 1,0,0, (SCM arg), - "Export a Scheme object to the parser, so it is treated as an identifier.") +LY_DEFINE (ly_export, "ly:export", + 1, 0, 0, (SCM arg), + "Export a Scheme object to the parser, " + "so it is treated as an identifier.") { SCM_RETURN_NEWSMOB (package_tag, arg); } - SCM unpack_identifier (SCM box) { @@ -51,4 +51,5 @@ init_box_type (void) scm_set_smob_mark (package_tag, scm_markcdr); scm_set_smob_print (package_tag, print_box); } + ADD_SCM_INIT_FUNC (package, init_box_type); diff --git a/lily/include/ly-module.hh b/lily/include/ly-module.hh index 89d13eb8a6..9d2e54095e 100644 --- a/lily/include/ly-module.hh +++ b/lily/include/ly-module.hh @@ -14,7 +14,7 @@ SCM ly_make_anonymous_module (bool safe); void ly_import_module (SCM dest, SCM src); -SCM ly_module_to_alist (SCM mod); +SCM ly_module2alist (SCM mod); SCM ly_module_lookup (SCM module, SCM sym); SCM ly_modules_lookup (SCM modules, SCM sym, SCM); SCM ly_module_symbols (SCM mod); diff --git a/lily/lily-guile.cc b/lily/lily-guile.cc index 1c03bf92cb..c21e7e7a43 100644 --- a/lily/lily-guile.cc +++ b/lily/lily-guile.cc @@ -4,8 +4,7 @@ source file of the GNU LilyPond music typesetter (c) 1998--2004 Jan Nieuwenhuizen - - Han-Wen Nienhuys + Han-Wen Nienhuys */ @@ -173,8 +172,9 @@ index_set_cell (SCM s, Direction d, SCM v) return s; } -LY_DEFINE (ly_warning,"ly:warn", 1, 0, 0, - (SCM str), "Scheme callable function to issue the warning @code{msg}.") +LY_DEFINE (ly_warn, "ly:warn", + 1, 0, 0, (SCM str), + "Scheme callable function to issue the warning @code{msg}.") { SCM_ASSERT_TYPE (ly_c_string_p (str), str, SCM_ARG1, __FUNCTION__, "string"); progress_indication ("\n"); @@ -182,7 +182,8 @@ LY_DEFINE (ly_warning,"ly:warn", 1, 0, 0, return SCM_BOOL_T; } -LY_DEFINE (ly_dir_p, "ly:dir?", 1,0, 0, (SCM s), +LY_DEFINE (ly_dir_p, "ly:dir?", + 1, 0, 0, (SCM s), "type predicate. A direction is @code{-1}, @code{0} or " "@code{1}, where @code{-1} represents " "left or down and @code{1} represents right or up.") @@ -198,7 +199,8 @@ LY_DEFINE (ly_dir_p, "ly:dir?", 1,0, 0, (SCM s), bool is_number_pair (SCM p) { - return ly_c_pair_p (p) && ly_c_number_p (ly_car (p)) && ly_c_number_p (ly_cdr (p)); + return ly_c_pair_p (p) + && ly_c_number_p (ly_car (p)) && ly_c_number_p (ly_cdr (p)); } typedef void (*Void_fptr) (); @@ -212,7 +214,6 @@ void add_scm_init_func (void (*f) ()) scm_init_funcs_->push (f); } - void ly_init_ly_module (void *) { @@ -234,13 +235,12 @@ ly_c_init_guile () scm_c_use_module ("lily"); } -unsigned int ly_scm_hash (SCM s) +unsigned int +ly_scm_hash (SCM s) { return scm_ihashv (s, ~1u); } - - bool is_direction (SCM s) { @@ -252,7 +252,6 @@ is_direction (SCM s) return false; } - bool is_axis (SCM s) { @@ -315,7 +314,6 @@ appendable_list_append (SCM l, SCM elt) scm_set_car_x (l, newcons); } - SCM ly_offset2scm (Offset o) { @@ -329,7 +327,6 @@ ly_scm2offset (SCM s) ly_scm2double (ly_cdr (s))); } - LY_DEFINE (ly_number2string, "ly:number->string", 1, 0, 0, (SCM s), "Convert @var{num} to a string without generating many decimals.") diff --git a/lily/ly-module.cc b/lily/ly-module.cc index 6b2317eaad..6e344e6077 100644 --- a/lily/ly-module.cc +++ b/lily/ly-module.cc @@ -104,9 +104,9 @@ entry_to_alist (void *closure, SCM key, SCM val, SCM result) return scm_cons (scm_cons (key, scm_variable_ref (val)), result); } -LY_DEFINE(ly_module_to_alist, "ly:module->alist", - 1,0,0, (SCM mod), - "Dump the contents of module @var{mod} as an alist.") +LY_DEFINE (ly_module2alist, "ly:module->alist", + 1, 0, 0, (SCM mod), + "Dump the contents of module @var{mod} as an alist.") { SCM_VALIDATE_MODULE (1, mod); SCM obarr= SCM_MODULE_OBARRAY (mod); @@ -125,28 +125,27 @@ ly_module_lookup (SCM module, SCM sym) #undef FUNC_NAME } -/* - Lookup SYM in a list of modules, which do not have to be related. - Return the first instance. - */ -LY_DEFINE(ly_modules_lookup, "ly:modules-lookup", - 2, 1, 0, - (SCM modules, SCM sym, SCM def), - "Lookup @var{sym} in the list @var{modules}, returning the " - "first occurence. If not found, return @var{default}, or @code{#f}.") +/* Lookup SYM in a list of modules, which do not have to be related. + Return the first instance. */ +LY_DEFINE (ly_modules_lookup, "ly:modules-lookup", + 2, 1, 0, + (SCM modules, SCM sym, SCM def), + "Lookup @var{sym} in the list @var{modules}, " + "returning the first occurence. " + "If not found, return @var{default}, or @code{#f}.") { for (SCM s = modules; ly_c_pair_p (s); s = ly_cdr (s)) { SCM mod = ly_car (s); - SCM v = scm_sym2var (sym, scm_module_lookup_closure (mod), SCM_UNDEFINED); - if (SCM_VARIABLEP(v) && SCM_VARIABLE_REF(v) != SCM_UNDEFINED) + SCM v = scm_sym2var (sym, scm_module_lookup_closure (mod), + SCM_UNDEFINED); + if (SCM_VARIABLEP(v) && SCM_VARIABLE_REF(v) != SCM_UNDEFINED) return SCM_VARIABLE_REF(v); } if (def != SCM_UNDEFINED) return def; - else - return SCM_BOOL_F; + return SCM_BOOL_F; } void diff --git a/lily/moment.cc b/lily/moment.cc index edd24f8cd6..54ee65c184 100644 --- a/lily/moment.cc +++ b/lily/moment.cc @@ -1,18 +1,39 @@ /* moment.cc -- implement Moment - + source file of the GNU LilyPond music typesetter - - (c) 1999--2004 Han-Wen Nienhuys - - */ + (c) 1999--2004 Han-Wen Nienhuys +*/ #include "lily-guile.hh" #include "moment.hh" #include "warn.hh" -#include "ly-smobs.icc" + +Moment::Moment () +{ +} + +Moment::Moment (int m) +{ + main_part_ = Rational (m); + grace_part_ = Rational ( 0); +} + +Moment::Moment (Rational m, Rational g) +{ + main_part_ = m; + grace_part_ = g; +} + +Moment::Moment (Rational m) +{ + main_part_ = m; + grace_part_ = Rational (0); +} + +#include "ly-smobs.icc" IMPLEMENT_SIMPLE_SMOBS (Moment); IMPLEMENT_TYPE_P (Moment, "ly:moment?"); @@ -22,9 +43,6 @@ Moment::mark_smob (SCM) return SCM_EOL; } - - - int Moment::print_smob (SCM s, SCM port, scm_print_state *) { @@ -38,19 +56,18 @@ Moment::print_smob (SCM s, SCM port, scm_print_state *) return 1; } -/* - TODO: add optional factor argument. -*/ -LY_DEFINE (make_moment,"ly:make-moment", 2,2,0, (SCM n, SCM d, SCM gn, SCM gd), +/* TODO: add optional factor argument. */ +LY_DEFINE (ly_make_moment, "ly:make-moment", + 2, 2, 0, (SCM n, SCM d, SCM gn, SCM gd), "Create the rational number with main timing @var{n}/@var{d}, " "and optional grace timin @var{gn}/@var{gd}.\n" "\n" "\n" - "Moment is a point in musical time. It is consists of a pair of\n" - "rationals (@var{m},@var{g}), where @var{m} is the timing for the main\n" - "notes, and @var{g} the timing for grace notes. In absence of grace\n" - "notes, @var{g} is zero.\n" - ) + "Moment is a point in musical time. " + "It is consists of a pair of rationals (@var{m},@var{g}), " + "where @var{m} is the timing for the main\n" + "notes, and @var{g} the timing for grace notes. " + "In absence of grace notes, @var{g} is zero.\n") { SCM_ASSERT_TYPE (SCM_INUMP (n), n, SCM_ARG1, __FUNCTION__, "integer"); SCM_ASSERT_TYPE (SCM_INUMP (d), d, SCM_ARG2, __FUNCTION__, "integer"); @@ -73,58 +90,50 @@ LY_DEFINE (make_moment,"ly:make-moment", 2,2,0, (SCM n, SCM d, SCM gn, SCM gd), Rational (grace_num, grace_den)).smobbed_copy (); } -LY_DEFINE (add_moment,"ly:add-moment", 2,0,0, (SCM a, SCM b), - "Add two moments." - ) +LY_DEFINE (ly_add_moment, "ly:add-moment", + 2, 0, 0, (SCM a, SCM b), + "Add two moments.") { - Moment * ma = unsmob_moment (a); - Moment * mb = unsmob_moment (b); + Moment *ma = unsmob_moment (a); + Moment *mb = unsmob_moment (b); SCM_ASSERT_TYPE (ma, a, SCM_ARG1, __FUNCTION__, "moment"); SCM_ASSERT_TYPE (mb, b, SCM_ARG2, __FUNCTION__, "moment"); - return (*ma + *mb).smobbed_copy (); } - -LY_DEFINE (mul_moment,"ly:mul-moment", 2,0,0, (SCM a, SCM b), - "Multiply two moments." - ) +LY_DEFINE (ly_mul_moment,"ly:mul-moment", + 2, 0, 0, (SCM a, SCM b), + "Multiply two moments.") { - Moment * ma = unsmob_moment (a); - Moment * mb = unsmob_moment (b); + Moment *ma = unsmob_moment (a); + Moment *mb = unsmob_moment (b); SCM_ASSERT_TYPE (ma, a, SCM_ARG1, __FUNCTION__, "moment"); SCM_ASSERT_TYPE (mb, b, SCM_ARG2, __FUNCTION__, "moment"); - - return (*ma * *mb).smobbed_copy (); + return (*ma * *mb).smobbed_copy (); } - - -LY_DEFINE (div_moment,"ly:div-moment", 2,0,0, (SCM a, SCM b), - "Divide two moments." - ) +LY_DEFINE (ly_div_moment,"ly:div-moment", + 2, 0, 0, (SCM a, SCM b), + "Divide two moments.") { - Moment * ma = unsmob_moment (a); - Moment * mb = unsmob_moment (b); + Moment *ma = unsmob_moment (a); + Moment *mb = unsmob_moment (b); SCM_ASSERT_TYPE (ma, a, SCM_ARG1, __FUNCTION__, "moment"); SCM_ASSERT_TYPE (mb, b, SCM_ARG2, __FUNCTION__, "moment"); - - return (*ma / *mb).smobbed_copy (); + return (*ma / *mb).smobbed_copy (); } -LY_DEFINE (ly_moment_less_p,"ly:momentself_scm ()); } -LY_DEFINE(ly_parser_define, "ly:parser-define", - 3, 0, 0, - (SCM parser_smob, SCM symbol, SCM val), - "Bind SYMBOL to VAL in PARSER_SMOB's module.") +LY_DEFINE (ly_parser_define, "ly:parser-define", + 3, 0, 0, (SCM parser_smob, SCM symbol, SCM val), + "Bind SYMBOL to VAL in PARSER_SMOB's module.") { My_lily_parser *parser = unsmob_my_lily_parser (parser_smob); SCM_ASSERT_TYPE (ly_c_symbol_p (symbol), symbol, SCM_ARG2, __FUNCTION__, "symbol"); @@ -342,10 +336,11 @@ LY_DEFINE(ly_parser_define, "ly:parser-define", parser->lexer_->set_identifier (scm_symbol_to_string (symbol), val); return SCM_UNSPECIFIED; } -LY_DEFINE(ly_parser_lookup, "ly:parser-lookup", - 2, 0, 0, - (SCM parser_smob, SCM symbol), - "Lookup @var{symbol} in @var{parser_smob}'s module. Undefined is '().") + +LY_DEFINE (ly_parser_lookup, "ly:parser-lookup", + 2, 0, 0, (SCM parser_smob, SCM symbol), + "Lookup @var{symbol} in @var{parser_smob}'s module. " + "Undefined is '().") { My_lily_parser *parser = unsmob_my_lily_parser (parser_smob); @@ -360,12 +355,10 @@ LY_DEFINE(ly_parser_lookup, "ly:parser-lookup", } LY_DEFINE (ly_parser_parse_string, "ly:parser-parse-string", - 2, 0, 0, - (SCM parser_smob, SCM ly_code), + 2, 0, 0, (SCM parser_smob, SCM ly_code), "Parse the string LY_CODE with PARSER_SMOB." "Upon failure, throw @code{ly-file-failed} key.") { - My_lily_parser *parser = unsmob_my_lily_parser (parser_smob); SCM_ASSERT_TYPE (parser, parser_smob, SCM_ARG1, __FUNCTION__, "parser"); @@ -412,10 +405,8 @@ get_bookpaper (My_lily_parser *parser) } -/* - TODO: move this to Scheme? Why take the parser arg, and all the back - & forth between scm and c++? - */ +/* TODO: move this to Scheme? Why take the parser arg, and all the back + & forth between scm and c++? */ LY_DEFINE (ly_parser_print_score, "ly:parser-print-score", 2, 0, 0, (SCM parser_smob, SCM score_smob), @@ -455,11 +446,11 @@ LY_DEFINE (ly_parser_print_score, "ly:parser-print-score", } -LY_DEFINE (ly_parser_set_names, "ly:parser-set-note-names", - 2, 0, 0, - (SCM parser, SCM names), - "Replace current note names in @var{parser}. @var{names} is an alist of " - "symbols. This only has effect if the current mode is notes.") +LY_DEFINE (ly_parser_set_note_names, "ly:parser-set-note-names", + 2, 0, 0, (SCM parser, SCM names), + "Replace current note names in @var{parser}. " + "@var{names} is an alist of symbols. " + "This only has effect if the current mode is notes.") { My_lily_parser *p = unsmob_my_lily_parser (parser); SCM_ASSERT_TYPE(p, parser, SCM_ARG1, __FUNCTION__, "Lilypond parser"); @@ -474,8 +465,7 @@ LY_DEFINE (ly_parser_set_names, "ly:parser-set-note-names", } LY_DEFINE (ly_parser_print_book, "ly:parser-print-book", - 2, 0, 0, - (SCM parser_smob, SCM book_smob), + 2, 0, 0, (SCM parser_smob, SCM book_smob), "Print book.") { My_lily_parser *parser = unsmob_my_lily_parser (parser_smob); diff --git a/lily/output-def.cc b/lily/output-def.cc index 0363aef752..10dbc0f783 100644 --- a/lily/output-def.cc +++ b/lily/output-def.cc @@ -6,10 +6,10 @@ (c) 1997--2004 Han-Wen Nienhuys */ - #include "context-def.hh" #include "file-path.hh" #include "global-context.hh" +#include "interval.hh" #include "lily-guile.hh" #include "ly-module.hh" #include "main.hh" @@ -18,8 +18,6 @@ #include "scm-hash.hh" #include "warn.hh" -#include "ly-smobs.icc" - Output_def::Output_def () { scope_ = SCM_EOL; @@ -29,10 +27,6 @@ Output_def::Output_def () scope_ = ly_make_anonymous_module (false); } -Output_def::~Output_def () -{ -} - Output_def::Output_def (Output_def const &s) { scope_ = SCM_EOL; @@ -45,30 +39,32 @@ Output_def::Output_def (Output_def const &s) ly_import_module (scope_, s.scope_); } +Output_def::~Output_def () +{ +} +#include "ly-smobs.icc" IMPLEMENT_SMOBS (Output_def); IMPLEMENT_DEFAULT_EQUAL_P (Output_def); - SCM Output_def::mark_smob (SCM m) { - Output_def * mo = (Output_def*) SCM_CELL_WORD_1 (m); + Output_def *mo = (Output_def*) SCM_CELL_WORD_1 (m); - /* - FIXME: why is this necessary? - all bookpaper_ should be protected by themselves. - */ + /* FIXME: why is this necessary? + all bookpaper_ should be protected by themselves. */ if (mo->parent_) scm_gc_mark (mo->parent_->self_scm ()); - mo->derived_mark (); return mo->scope_; } void -Output_def::derived_mark () {} +Output_def::derived_mark () +{ +} void assign_context_def (Output_def * m, SCM transdef) @@ -83,9 +79,7 @@ assign_context_def (Output_def * m, SCM transdef) } } -/* - find the translator for NAME. NAME must be a symbol. -*/ +/* find the translator for NAME. NAME must be a symbol. */ SCM find_context_def (Output_def const *m, SCM name) { @@ -112,7 +106,6 @@ Output_def::get_dimension (SCM s) const return ly_scm2double (val); } - SCM Output_def::lookup_variable (SCM sym) const { @@ -151,7 +144,7 @@ LY_DEFINE (ly_paper_lookup, "ly:output-def-lookup", } LY_DEFINE (ly_output_def_scope, "ly:output-def-scope", - 1, 0,0, (SCM def), + 1, 0, 0, (SCM def), "Get the variable scope inside @var{def}.") { Output_def *op = unsmob_output_def (def); @@ -159,7 +152,6 @@ LY_DEFINE (ly_output_def_scope, "ly:output-def-scope", return op->scope_; } - LY_DEFINE (ly_output_def_parent, "ly:output-def-parent", 1, 0, 0, (SCM def), "Get the parent output-def of @var{def}.") @@ -169,7 +161,6 @@ LY_DEFINE (ly_output_def_parent, "ly:output-def-parent", return op->parent_ ? op->parent_->self_scm () : SCM_EOL; } - LY_DEFINE (ly_output_def_clone, "ly:output-def-clone", 1, 0, 0, (SCM def), "Clone @var{def}.") @@ -181,41 +172,32 @@ LY_DEFINE (ly_output_def_clone, "ly:output-def-clone", return s; } -LY_DEFINE(ly_output_description, "ly:output-description", - 1,0,0, - (SCM output_def), - "Return the description of translators in @var{output-def}.") +LY_DEFINE (ly_output_description, "ly:output-description", + 1, 0, 0, (SCM output_def), + "Return the description of translators in @var{output-def}.") { Output_def *id = unsmob_output_def (output_def); - SCM al =ly_module_to_alist (id->scope_); + SCM al = ly_module2alist (id->scope_); - SCM l = SCM_EOL; - for (SCM s = al ; ly_c_pair_p (s); s = ly_cdr (s)) + SCM ell = SCM_EOL; + for (SCM s = al; ly_c_pair_p (s); s = ly_cdr (s)) { Context_def * td = unsmob_context_def (ly_cdar (s)); SCM key = ly_caar (s); if (td && key == td->get_context_name ()) - { - - l = scm_cons (scm_cons (key, td->to_alist ()), l); - } + ell = scm_cons (scm_cons (key, td->to_alist ()), ell); } - return l; + return ell; } - - -#include "interval.hh" - /* FIXME. This is broken until we have a generic way of putting lists inside the \paper block. */ Interval line_dimensions_int (Output_def *def, int n) { - Real lw = def->get_dimension (ly_symbol2scm ("linewidth")); + Real lw = def->get_dimension (ly_symbol2scm ("linewidth")); Real ind = n ? 0.0 : def->get_dimension (ly_symbol2scm ("indent")); - return Interval (ind, lw); } @@ -226,11 +208,8 @@ LY_DEFINE (ly_paper_def_p, "ly:paper-def?", return ly_bool2scm (unsmob_output_def (def)); } - - LY_DEFINE (ly_bookpaper_outputscale, "ly:bookpaper-outputscale", - 1, 0, 0, - (SCM bp), + 1, 0, 0, (SCM bp), "Get outputscale for BP.") { Output_def *b = unsmob_output_def (bp); @@ -238,8 +217,6 @@ LY_DEFINE (ly_bookpaper_outputscale, "ly:bookpaper-outputscale", return scm_make_real (output_scale (b)); } - - LY_DEFINE (ly_make_output_def, "ly:make-output-def", 0, 0, 0, (), "Make a output def.") @@ -248,3 +225,4 @@ LY_DEFINE (ly_make_output_def, "ly:make-output-def", return scm_gc_unprotect_object (bp->self_scm ()); } + diff --git a/lily/paper-book.cc b/lily/paper-book.cc index f4ab0c0d91..a25c0dedab 100644 --- a/lily/paper-book.cc +++ b/lily/paper-book.cc @@ -106,7 +106,8 @@ LY_DEFINE (ly_output_formats, "ly:output-formats", Array output_formats = split_string (output_format_global, ','); SCM lst = SCM_EOL; - for (int i = 0; i < output_formats.size (); i ++) + int output_formats_count = output_formats.size (); + for (int i = 0; i < output_formats_count; i ++) lst = scm_cons (scm_makfrom0str (output_formats[i].to_str0 ()), lst); return lst; @@ -118,17 +119,15 @@ Paper_book::output (String outname) if (!score_lines_.size ()) return; - /* Generate all stencils to trigger font loads. */ pages (); - SCM formats = ly_output_formats(); for (SCM s = formats; ly_c_pair_p (s); s = ly_cdr (s)) { String format = ly_scm2string (ly_car (s)); - - Paper_outputter *out = get_paper_outputter (outname + "." + format, format); + Paper_outputter *out = get_paper_outputter (outname + "." + format, + format); SCM scopes = SCM_EOL; if (ly_c_module_p (header_)) @@ -143,22 +142,19 @@ Paper_book::output (String outname) scopes, dump_fields (), scm_makfrom0str (outname.to_str0 ()), - SCM_UNDEFINED - )) ; + SCM_UNDEFINED)); scm_gc_unprotect_object (out->self_scm ()); + progress_indication ("\n"); } } - void Paper_book::classic_output (String outname) { - /* Generate all stencils to trigger font loads. */ lines (); - // ugh code dup SCM scopes = SCM_EOL; if (ly_c_module_p (header_)) @@ -168,7 +164,6 @@ Paper_book::classic_output (String outname) scopes = scm_cons (score_lines_[0].header_, scopes); //end ugh - Array output_formats = split_string (output_format_global, ','); for (int i = 0; i < output_formats.size (); i++) @@ -178,41 +173,30 @@ Paper_book::classic_output (String outname) func_nm = "output-classic-framework-" + func_nm; SCM func = ly_scheme_function (func_nm.to_str0 ()); + Paper_outputter *out = get_paper_outputter (outname + "." + format, + format); - Paper_outputter *out = get_paper_outputter (outname + "." + format, format); - - scm_apply_0 (func, scm_list_n (out->self_scm (), - self_scm (), - scopes, + scm_apply_0 (func, scm_list_5 (out->self_scm (), self_scm (), scopes, dump_fields (), - scm_makfrom0str (outname.to_str0 ()), - SCM_UNDEFINED - )) ; + scm_makfrom0str (outname.to_str0 ()))); scm_gc_unprotect_object (out->self_scm ()); + progress_indication ("\n"); } - - progress_indication ("\n"); } - - - -LY_DEFINE(ly_paper_book_pages, "ly:paper-book-pages", - 1,0,0, - (SCM pb), +LY_DEFINE (ly_paper_book_pages, "ly:paper-book-pages", + 1, 0, 0, (SCM pb), "Return pages in book PB.") { return unsmob_paper_book(pb)->pages (); } - -LY_DEFINE(ly_paper_book_scopes, "ly:paper-book-scopes", - 1,0,0, - (SCM book), +LY_DEFINE (ly_paper_book_scopes, "ly:paper-book-scopes", + 1, 0, 0, (SCM book), "Return pages in paper book @var{book}.") { - Paper_book * pb = unsmob_paper_book(book); + Paper_book *pb = unsmob_paper_book(book); SCM_ASSERT_TYPE(pb, book, SCM_ARG1, __FUNCTION__, "Paper_book"); SCM scopes = SCM_EOL; @@ -222,29 +206,21 @@ LY_DEFINE(ly_paper_book_scopes, "ly:paper-book-scopes", return scopes; } - -LY_DEFINE(ly_paper_book_lines, "ly:paper-book-lines", - 1,0,0, - (SCM pb), - "Return lines in book PB.") +LY_DEFINE (ly_paper_book_lines, "ly:paper-book-lines", + 1, 0, 0, (SCM pb), + "Return lines in book PB.") { return unsmob_paper_book (pb)->lines (); } - -LY_DEFINE(ly_paper_book_book_paper, "ly:paper-book-book-paper", - 1,0,0, - (SCM pb), +LY_DEFINE (ly_paper_book_book_paper, "ly:paper-book-book-paper", + 1, 0, 0, (SCM pb), "Return pages in book PB.") { - return unsmob_paper_book(pb)->bookpaper_->self_scm (); + return unsmob_paper_book (pb)->bookpaper_->self_scm (); } -/* - -TODO: resurrect more complex user-tweaks for titling? - -*/ +/* TODO: resurrect more complex user-tweaks for titling? */ Stencil Paper_book::book_title () { @@ -271,8 +247,6 @@ Paper_book::book_title () return title; } - - Stencil Paper_book::score_title (int i) { @@ -298,18 +272,16 @@ Paper_book::score_title (int i) if (unsmob_stencil (tit)) title = *unsmob_stencil (tit); - if (!title.is_empty ()) title.align_to (Y_AXIS, UP); return title; } - SCM Paper_book::lines () { - if (SCM_BOOL_F != lines_) + if (lines_ != SCM_BOOL_F) return lines_; lines_ = SCM_EOL; @@ -318,7 +290,6 @@ Paper_book::lines () if (!title.is_empty ()) { Paper_system *pl = new Paper_system (title, true); - lines_ = scm_cons (pl->self_scm (), lines_); scm_gc_unprotect_object (pl->self_scm ()); } @@ -336,7 +307,8 @@ Paper_book::lines () if (scm_vector_p (score_lines_[i].lines_) == SCM_BOOL_T) { - SCM line_list = scm_vector_to_list (score_lines_[i].lines_); // guh. + // guh. + SCM line_list = scm_vector_to_list (score_lines_[i].lines_); line_list = scm_reverse (line_list); lines_ = scm_append (scm_list_2 (line_list, lines_)); @@ -346,24 +318,21 @@ Paper_book::lines () lines_ = scm_reverse (lines_); int i = 0; - Paper_system * last = 0; + Paper_system *last = 0; for (SCM s = lines_; s != SCM_EOL; s = ly_cdr (s)) { Paper_system * p = unsmob_paper_line (ly_car (s)); p->number_ = ++i; if (last && last->is_title ()) - { - p->penalty_ = 10000; // ugh, hardcoded. - } + // ugh, hardcoded. + p->penalty_ = 10000; last = p; } - return lines_; } - SCM Paper_book::pages () { @@ -371,20 +340,13 @@ Paper_book::pages () return pages_; pages_ = SCM_EOL; - Output_def *paper = bookpaper_; - SCM proc = paper->c_variable ("page-breaking"); - pages_ = scm_apply_0 (proc, scm_list_n (lines (), - self_scm (), - SCM_UNDEFINED)); - + pages_ = scm_apply_0 (proc, scm_list_2 (lines (), self_scm ())); return pages_; } - - /****************************************************************/ Score_lines::Score_lines () diff --git a/lily/paper-outputter.cc b/lily/paper-outputter.cc index c384996375..809b8dbd78 100644 --- a/lily/paper-outputter.cc +++ b/lily/paper-outputter.cc @@ -112,7 +112,6 @@ get_paper_outputter (String outname, String f) progress_indication (_f ("paper output to `%s'...", outname == "-" ? String ("") : outname)); return new Paper_outputter (outname, f); - } /* FIXME: why is output_* wrapper called dump? */ diff --git a/lily/paper-score.cc b/lily/paper-score.cc index 9d4024b18a..9d58682b0c 100644 --- a/lily/paper-score.cc +++ b/lily/paper-score.cc @@ -6,25 +6,22 @@ (c) 1996--2004 Han-Wen Nienhuys */ -#include "score.hh" -#include "main.hh" -#include "warn.hh" +#include "all-font-metrics.hh" #include "font-metric.hh" -#include "spanner.hh" +#include "gourlay-breaking.hh" +#include "ly-module.hh" +#include "main.hh" +#include "misc.hh" #include "output-def.hh" -#include "system.hh" +#include "paper-book.hh" #include "paper-column.hh" #include "paper-score.hh" -#include "paper-column.hh" #include "scm-hash.hh" -#include "gourlay-breaking.hh" -//#include "paper-outputter.hh" -#include "misc.hh" -#include "all-font-metrics.hh" - +#include "score.hh" +#include "spanner.hh" #include "stencil.hh" -#include "paper-book.hh" -#include "ly-module.hh" +#include "system.hh" +#include "warn.hh" Paper_score::Paper_score () { @@ -53,7 +50,7 @@ Paper_score::typeset_line (System *system) Array Paper_score::calc_breaking () { - Break_algorithm *algorithm=0; + Break_algorithm *algorithm = 0; Array sol; algorithm = new Gourlay_breaking ; @@ -87,8 +84,11 @@ Paper_score::process (String) Array breaking = calc_breaking (); system_->break_into_pieces (breaking); SCM lines = system_->get_lines (); +#if 0 + /* gourlay:do_solve also prints newline. */ progress_indication ("\n"); - +#endif + /* Only keep result stencils in lines_, *title_; delete all grobs. */ systems_ = SCM_EOL; diff --git a/lily/pitch.cc b/lily/pitch.cc index 8004d2fe65..4f1b17a5c1 100644 --- a/lily/pitch.cc +++ b/lily/pitch.cc @@ -291,7 +291,7 @@ Pitch::less_p (SCM p1, SCM p2) } /* Should add optional args. */ -LY_DEFINE (make_pitch, "ly:make-pitch", +LY_DEFINE (ly_make_pitch, "ly:make-pitch", 3, 0, 0, (SCM octave, SCM note, SCM alter), "@var{octave} is specified by an integer, " "zero for the octave containing middle C. " @@ -308,7 +308,7 @@ LY_DEFINE (make_pitch, "ly:make-pitch", return p.smobbed_copy (); } -LY_DEFINE (pitch_steps, "ly:pitch-steps", 1, 0, 0, +LY_DEFINE (ly_pitch_steps, "ly:pitch-steps", 1, 0, 0, (SCM p), "Number of steps counted from middle C of the pitch @var{p}.") { @@ -317,7 +317,7 @@ LY_DEFINE (pitch_steps, "ly:pitch-steps", 1, 0, 0, return scm_int2num (pp->steps ()); } -LY_DEFINE (pitch_octave, "ly:pitch-octave", +LY_DEFINE (ly_pitch_octave, "ly:pitch-octave", 1, 0, 0, (SCM pp), "Extract the octave from pitch @var{p}.") { @@ -327,7 +327,7 @@ LY_DEFINE (pitch_octave, "ly:pitch-octave", return scm_int2num (q); } -LY_DEFINE (pitch_alteration, "ly:pitch-alteration", +LY_DEFINE (ly_pitch_alteration, "ly:pitch-alteration", 1, 0, 0, (SCM pp), "Extract the alteration from pitch @var{p}.") { @@ -348,7 +348,7 @@ LY_DEFINE (pitch_notename, "ly:pitch-notename", return scm_int2num (q); } -LY_DEFINE (ly_pitch_quartertones, "ly:pitch-quartertones", +LY_DEFINE (ly_pitch_quartertones, "ly:pitch-quartertones", 1, 0, 0, (SCM pp), "Calculate the number of quarter tones of @var{p} from middle C.") { @@ -358,7 +358,7 @@ LY_DEFINE (ly_pitch_quartertones, "ly:pitch-quartertones", return scm_int2num (q); } -LY_DEFINE (ly_pitch_semitones, "ly:pitch-semitones", +LY_DEFINE (ly_pitch_semitones, "ly:pitch-semitones", 1, 0, 0, (SCM pp), "calculate the number of semitones of @var{p} from middle C.") { @@ -368,7 +368,7 @@ LY_DEFINE (ly_pitch_semitones, "ly:pitch-semitones", return scm_int2num (q); } -LY_DEFINE (pitch_less, "ly:pitchget_length ()); + Global_context *trans = new Global_context (odef, music->get_length ()); if (!trans) { @@ -151,7 +146,7 @@ LY_DEFINE (ly_format_output, "ly:format-output", Music_output *output = g->get_output (); progress_indication ("\n"); - // ugh, midi still wants outname + /* ugh, midi still wants outname */ return output->process (ly_scm2string (outname)); } @@ -165,25 +160,23 @@ default_rendering (SCM music, SCM outdef, Output_def *bpd = unsmob_output_def (book_outputdef); - /* - ugh. - */ + /* ugh. */ if (bpd->c_variable ("is-bookpaper") == SCM_BOOL_T) { Real scale = ly_scm2double (bpd->c_variable ("outputscale")); - Output_def * def = scale_output_def (unsmob_output_def (outdef), scale); + Output_def *def = scale_output_def (unsmob_output_def (outdef), scale); scaled_def = def->self_scm (); scaled_bookdef = scale_output_def (bpd, scale)->self_scm (); - unsmob_output_def (scaled_def)->parent_ = unsmob_output_def (scaled_bookdef); + unsmob_output_def (scaled_def)->parent_ + = unsmob_output_def (scaled_bookdef); scm_gc_unprotect_object (scaled_bookdef); scm_gc_unprotect_object (scaled_def); } SCM context = ly_run_translator (music, scaled_def); - if (Global_context *g = dynamic_cast (unsmob_context (context))) { @@ -191,9 +184,7 @@ default_rendering (SCM music, SCM outdef, Music_output *output = g->get_output (); if (systems != SCM_UNDEFINED) { - /* - ugh, this is strange, Paper_book without a Book object. - */ + /* ugh, this is strange, Paper_book without a Book object. */ Paper_book *paper_book = new Paper_book (); paper_book->header_ = header; paper_book->bookpaper_ = unsmob_output_def (scaled_bookdef); @@ -214,9 +205,7 @@ default_rendering (SCM music, SCM outdef, scm_remember_upto_here_1 (scaled_bookdef); } -/* - PAPERBOOK should be scaled already. - */ +/* PAPERBOOK should be scaled already. */ SCM Score::book_rendering (String outname, Output_def *paperbook, @@ -226,9 +215,7 @@ Score::book_rendering (String outname, Real scale = 1.0; if (paperbook && paperbook->c_variable ("is-bookpaper") == SCM_BOOL_T) - { - scale = ly_scm2double (paperbook->c_variable ("outputscale")); - } + scale = ly_scm2double (paperbook->c_variable ("outputscale")); SCM out = scm_makfrom0str (outname.to_str0 ()); SCM systems = SCM_EOL; @@ -245,18 +232,13 @@ Score::book_rendering (String outname, scm_gc_unprotect_object (scaled); } - /* - TODO: fix or junk --no-paper. - */ - + /* TODO: fix or junk --no-paper. */ SCM context = ly_run_translator (music_, def->self_scm ()); if (dynamic_cast (unsmob_context (context))) { SCM s = ly_format_output (context, out); if (s != SCM_UNDEFINED) - { - systems = s; - } + systems = s; } scm_remember_upto_here_1 (scaled); @@ -285,8 +267,9 @@ LY_DEFINE (ly_score_bookify, "ly:score-bookify", LY_DEFINE (ly_score_embedded_format, "ly:score-embedded-format", 2, 0, 0, (SCM score, SCM paper), - "Run @var{score} through @var{paper}, a output definition, " - " scaled to correct outputscale already, return a list of paper-lines. ") + "Run @var{score} through @var{paper}, an output definition, " + "scaled to correct outputscale already, " + "return a list of paper-lines.") { Score * sc = unsmob_score (score); Output_def *od = unsmob_output_def (paper); @@ -297,32 +280,21 @@ LY_DEFINE (ly_score_embedded_format, "ly:score-embedded-format", SCM lines = SCM_EOL; Output_def * score_def = 0; - /* - UGR, FIXME, these are default \paper blocks once again. They suck. - */ + /* UGR, FIXME, these are default \paper blocks once again. They + suck. */ for (int i = 0; !score_def && i < sc->defs_.size (); i++) - { - if (sc->defs_[i]->c_variable ("is-paper") == SCM_BOOL_T) - { - score_def = sc->defs_[i]; - } - } + if (sc->defs_[i]->c_variable ("is-paper") == SCM_BOOL_T) + score_def = sc->defs_[i]; if (!score_def) return lines; - score_def = score_def->clone (); SCM prot = score_def->self_scm (); scm_gc_unprotect_object (prot); - /* - - TODO: SCORE_DEF should be scaled according to OD->parent_ or OD - itself. - - */ - + /* TODO: SCORE_DEF should be scaled according to OD->parent_ or OD + itself. */ score_def->parent_ = od; SCM context = ly_run_translator (sc->music_, score_def->self_scm ()); diff --git a/lily/script-column.cc b/lily/script-column.cc index b7a70bd462..faddd44efc 100644 --- a/lily/script-column.cc +++ b/lily/script-column.cc @@ -23,7 +23,7 @@ Script_column::add_staff_sided (Grob *me, Item *i) me->add_dependency (i); } -LY_DEFINE (grob_script_priority_less, "ly:grob-script-priority-less", +LY_DEFINE (ly_grob_script_priority_less, "ly:grob-script-priority-less", 2, 0, 0, (SCM a, SCM b), "Compare two grobs by script priority. For internal use.") { @@ -74,7 +74,7 @@ Script_column::before_line_breaking (SCM smob) do { SCM ss = scm_reverse_x (scripts[d], SCM_EOL); - ss = scm_stable_sort_x (ss, grob_script_priority_less_proc); + ss = scm_stable_sort_x (ss, ly_grob_script_priority_less_proc); Grob * last = 0; for (SCM s = ss; ly_c_pair_p (s); s = ly_cdr (s)) diff --git a/lily/stencil-scheme.cc b/lily/stencil-scheme.cc index da4d81c0cb..8f069bba45 100644 --- a/lily/stencil-scheme.cc +++ b/lily/stencil-scheme.cc @@ -216,7 +216,7 @@ LY_DEFINE (ly_make_stencil, "ly:make-stencil", } -LY_DEFINE (ly_align_to_x, "ly:stencil-align-to!", +LY_DEFINE (ly_stencil_align_to_x, "ly:stencil-align-to!", 3, 0, 0, (SCM stil, SCM axis, SCM dir), "Align @var{stil} using its own extents. " "@var{dir} is a number -1, 1 are left and right respectively. " diff --git a/lily/system.cc b/lily/system.cc index f8af69c80d..0d2ce87b9d 100644 --- a/lily/system.cc +++ b/lily/system.cc @@ -269,7 +269,6 @@ System::pre_processing () if (verbose_global_b) progress_indication (_f ("Grob count %d", element_count ())); - for (SCM s = get_property ("all-elements"); ly_c_pair_p (s); s = ly_cdr (s)) unsmob_grob (ly_car (s))->handle_prebroken_dependencies (); @@ -278,11 +277,13 @@ System::pre_processing () for (SCM s = get_property ("all-elements"); ly_c_pair_p (s); s = ly_cdr (s)) { - Grob* sc = unsmob_grob (ly_car (s)); + Grob *sc = unsmob_grob (ly_car (s)); sc->calculate_dependencies (PRECALCED, PRECALCING, ly_symbol2scm ("before-line-breaking-callback")); } - progress_indication ("\n" + _ ("Calculating line breaks...") + " "); + progress_indication ("\n"); + progress_indication (_ ("Calculating line breaks...")); + progress_indication (" "); for (SCM s = get_property ("all-elements"); ly_c_pair_p (s); s = ly_cdr (s)) { Grob *e = unsmob_grob (ly_car (s)); diff --git a/scm/define-markup-commands.scm b/scm/define-markup-commands.scm index 8de6a818a1..1acf6f7e8b 100644 --- a/scm/define-markup-commands.scm +++ b/scm/define-markup-commands.scm @@ -91,8 +91,8 @@ determines the space between each markup in @var{args}." (def-markup-command (combine paper props m1 m2) (markup? markup?) "Print two markups on top of each other." (let* - ((s1 (interpret-markup paper props m1)) - (s2 (interpret-markup paper props m2))) + ((s1 (interpret-markup paper props m1)) + (s2 (interpret-markup paper props m2))) (ly:stencil-add s1 s2))) -- 2.39.2