From 6817805afca5e84e74479bdd951609b80210095b Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Sun, 7 Mar 2004 13:07:29 +0000 Subject: [PATCH] * lily/stencil-scheme.cc: * lily/staff-symbol-referencer.cc: * lily/script-column.cc: * lily/pitch.cc: * lily/music.cc: * lily/grob-pq-engraver.cc: * lily/font-interface.cc: * lily/music-output-def.cc: * lily/duration.cc: * lily/grob-scheme.cc: * lily/context-scheme.cc: Put scheme name on first line in LY_DEFINE to help etags (multiline regexps are broken). Stray style cleanups. * stepmake/stepmake/scm-vars.make: * stepmake/stepmake/c++-vars.make (TAGS_HEADERS, TAGS_SOURCES): Rename and split TAGS_FILES. * GNUmakefile.in (ALL-TAGS): Remove. * stepmake/stepmake/generic-targets.make (TAGS): Also include deeper TAGS files. Fixes regexp tags in TOP dir. --- ChangeLog | 25 +++ GNUmakefile.in | 5 - lily/GNUmakefile | 3 +- lily/context-scheme.cc | 183 +++++++++----------- lily/duration.cc | 138 +++++++-------- lily/font-interface.cc | 47 ++--- lily/grob-pq-engraver.cc | 4 +- lily/grob-scheme.cc | 111 ++++++------ lily/music-output-def.cc | 41 ++--- lily/music.cc | 230 +++++++++++-------------- lily/pitch.cc | 222 +++++++++++------------- lily/script-column.cc | 61 ++++--- lily/staff-symbol-referencer.cc | 125 ++++++-------- lily/stencil-scheme.cc | 36 ++-- lily/translator-scheme.cc | 33 ++-- stepmake/stepmake/c++-vars.make | 3 +- stepmake/stepmake/c-vars.make | 3 +- stepmake/stepmake/generic-targets.make | 15 +- stepmake/stepmake/generic-vars.make | 5 +- stepmake/stepmake/scm-vars.make | 2 +- 20 files changed, 579 insertions(+), 713 deletions(-) diff --git a/ChangeLog b/ChangeLog index 60ff2d8c16..47518252d1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,28 @@ +2004-03-07 Jan Nieuwenhuizen + + * lily/stencil-scheme.cc: + * lily/staff-symbol-referencer.cc: + * lily/script-column.cc: + * lily/pitch.cc: + * lily/music.cc: + * lily/grob-pq-engraver.cc: + * lily/font-interface.cc: + * lily/music-output-def.cc: + * lily/duration.cc: + * lily/grob-scheme.cc: + * lily/context-scheme.cc: Put scheme name on first line in + LY_DEFINE to help etags (multiline regexps are broken). Stray + style cleanups. + + * stepmake/stepmake/scm-vars.make: + * stepmake/stepmake/c++-vars.make (TAGS_HEADERS, TAGS_SOURCES): + Rename and split TAGS_FILES. + + * GNUmakefile.in (ALL-TAGS): Remove. + + * stepmake/stepmake/generic-targets.make (TAGS): Also include + deeper TAGS files. Fixes regexp tags in TOP dir. + 2004-03-07 Han-Wen Nienhuys * Documentation/user/changing-defaults.itely (Changing defaults): diff --git a/GNUmakefile.in b/GNUmakefile.in index 111e38711e..b977c8558b 100644 --- a/GNUmakefile.in +++ b/GNUmakefile.in @@ -82,11 +82,6 @@ local-WWW-post: src-ext = c cc yy ll hh icc py scm tex ps texi itexi tely itely sh -# FIXME: rename to TAGS; should include deeper TAGS files, see guile-core -ALL-TAGS: - etags $(shell find . $(src-ext:%=-name '*.%' -or) -false \ - | grep -v '/out') - web-clean: $(MAKE) out=www clean $(MAKE) $(builddir)/share/lilypond-force diff --git a/lily/GNUmakefile b/lily/GNUmakefile index 44f2cc0718..a306551671 100644 --- a/lily/GNUmakefile +++ b/lily/GNUmakefile @@ -19,7 +19,8 @@ include $(depth)/make/stepmake.make # USER_LDFLAGS += -static -lltdl -ldl # -ETAGS_FLAGS += -r '/^LY_DEFINE *(\([^,]+\),/\1/' -r '/^LY_DEFINE *([^,]+, *"\([^"]+\)"/\1/' +ETAGS_FLAGS += --regex='{c++}/^LY_DEFINE *(\([^,]+\)/\1/' +ETAGS_FLAGS += --regex='{c++}/^LY_DEFINE *([^"]*"\([^"]+\)"/\1/' default: diff --git a/lily/context-scheme.cc b/lily/context-scheme.cc index 3ae29e339a..b02045e140 100644 --- a/lily/context-scheme.cc +++ b/lily/context-scheme.cc @@ -1,169 +1,148 @@ +/* + context-scheme.cc -- + + source file of the GNU LilyPond music typesetter + + (c) 1998--2004 Jan Nieuwenhuizen + Han-Wen Nienhuys +*/ + #include "context.hh" #include "context-def.hh" - -LY_DEFINE(ly_context_id, - "ly:context-id", 1,0,0, (SCM context), - "Return the id string of @var{context}, i.e. for @code{\\context Voice " -"= one .. } it will return the string @code{one}.") +LY_DEFINE (ly_context_id, "ly:context-id", + 1, 0, 0, (SCM context), + "Return the id string of @var{context}, " + "i.e. for @code{\\context Voice = one .. } " + "return the string @code{one}.") { - Context * tr = (unsmob_context (context)); - SCM_ASSERT_TYPE(tr, context, SCM_ARG1, __FUNCTION__, "Context"); + Context *tr = unsmob_context (context); + SCM_ASSERT_TYPE (tr, context, SCM_ARG1, __FUNCTION__, "Context"); return scm_makfrom0str (tr->id_string_. to_str0 ()); } - -LY_DEFINE(ly_context_name, - "ly:context-name", 1,0,0, (SCM context), - "Return the name of @var{context}, i.e. for @code{\\context Voice " -"= one .. } it will return the symbol @code{Voice}.") +LY_DEFINE (ly_context_name, "ly:context-name", + 1, 0, 0, (SCM context), + "Return the name of @var{context}, " + "i.e. for @code{\\context Voice = one .. } " + "return the symbol @code{Voice}.") { - Context * tr = (unsmob_context (context)); - SCM_ASSERT_TYPE(tr, context, SCM_ARG1, __FUNCTION__, "Context"); - + Context *tr = unsmob_context (context); + SCM_ASSERT_TYPE (tr, context, SCM_ARG1, __FUNCTION__, "Context"); return unsmob_context_def (tr->definition_)->get_context_name (); } - -LY_DEFINE(ly_context_pushpop_property, - "ly:context-pushpop-property", 3, 1, 0, - (SCM context, SCM grob, SCM eltprop, SCM val), - "Do a single @code{\\override} or @code{\\revert} operation " - "in @var{context}. The grob definition @code{grob} is extended with " - "@code{eltprop} (if @var{val} is specified) " - "or reverted (if unspecified).") +LY_DEFINE (ly_context_pushpop_property, "ly:context-pushpop-property", + 3, 1, 0, (SCM context, SCM grob, SCM eltprop, SCM val), + "Do a single @code{\\override} or @code{\\revert} operation " + "in @var{context}. The grob definition @code{grob} is extended " + "with @code{eltprop} (if @var{val} is specified) " + "or reverted (if unspecified).") { - Context *tg = (unsmob_context (context)); - - SCM_ASSERT_TYPE(tg, context, SCM_ARG1, __FUNCTION__, "context"); - SCM_ASSERT_TYPE(gh_symbol_p (grob), grob, SCM_ARG2, __FUNCTION__, "symbol"); - SCM_ASSERT_TYPE(gh_symbol_p (eltprop), eltprop, SCM_ARG3, __FUNCTION__, "symbol"); + Context *tg = unsmob_context (context); + SCM_ASSERT_TYPE (tg, context, SCM_ARG1, __FUNCTION__, "context"); + SCM_ASSERT_TYPE (gh_symbol_p (grob), grob, SCM_ARG2, __FUNCTION__, "symbol"); + SCM_ASSERT_TYPE (gh_symbol_p (eltprop), eltprop, SCM_ARG3, __FUNCTION__, "symbol"); execute_pushpop_property (tg, grob, eltprop, val); return SCM_UNDEFINED; } - -LY_DEFINE(ly_context_property, - "ly:context-property", 2, 0, 0, - (SCM context, SCM name), - "retrieve the value of @var{name} from context @var{context}") +LY_DEFINE (ly_context_property, "ly:context-property", + 2, 0, 0, (SCM context, SCM name), + "Return the value of @var{name} from context @var{context}") { Context *t = unsmob_context (context); - Context * tr= (t); - SCM_ASSERT_TYPE(tr, context, SCM_ARG1, __FUNCTION__, "Translator group"); - SCM_ASSERT_TYPE(gh_symbol_p (name), name, SCM_ARG2, __FUNCTION__, "symbol"); + Context * tr= (t); + SCM_ASSERT_TYPE (tr, context, SCM_ARG1, __FUNCTION__, "Translator group"); + SCM_ASSERT_TYPE (gh_symbol_p (name), name, SCM_ARG2, __FUNCTION__, "symbol"); return tr->internal_get_property (name); - } -LY_DEFINE(ly_context_set_property, - "ly:context-set-property!", 3, 0, 0, - (SCM context, SCM name, SCM val), - "set value of property @var{name} in context @var{context} to @var{val}.") +LY_DEFINE (ly_context_set_property, "ly:context-set-property!", + 3, 0, 0, (SCM context, SCM name, SCM val), + "set value of property @var{name} in context @var{context} " + "to @var{val}.") { - Context *t = unsmob_context (context); - Context * tr= (t); - - SCM_ASSERT_TYPE(tr, context, SCM_ARG1, __FUNCTION__, "Context"); - SCM_ASSERT_TYPE(gh_symbol_p (name), name, SCM_ARG2, __FUNCTION__, "symbol"); + Context *tr = unsmob_context (context); + SCM_ASSERT_TYPE (tr, context, SCM_ARG1, __FUNCTION__, "Context"); + SCM_ASSERT_TYPE (gh_symbol_p (name), name, SCM_ARG2, __FUNCTION__, "symbol"); tr->internal_set_property (name, val); return SCM_UNSPECIFIED; } - -LY_DEFINE(ly_context_property_where_defined, - "ly:context-property-where-defined", 2, 0, 0, - (SCM context, SCM name), - "Return the context above @var{context} where @var{name} is defined.") +LY_DEFINE (ly_context_property_where_defined, "ly:context-property-where-defined", + 2, 0, 0, (SCM context, SCM name), + "Return the context above @var{context} " + "where @var{name} is defined.") { - Context *t = unsmob_context (context); - Context * tr = (t); - SCM_ASSERT_TYPE(tr, context, SCM_ARG1, __FUNCTION__, "Context"); - SCM_ASSERT_TYPE(gh_symbol_p (name), name, SCM_ARG2, __FUNCTION__, "symbol"); - + Context *tr = unsmob_context (context); + SCM_ASSERT_TYPE (tr, context, SCM_ARG1, __FUNCTION__, "Context"); + SCM_ASSERT_TYPE (gh_symbol_p (name), name, SCM_ARG2, __FUNCTION__, "symbol"); tr = tr->where_defined (name); - if (tr) - return tr->self_scm(); + return tr->self_scm (); return SCM_EOL; } -LY_DEFINE(ly_unset_context_property, - "ly:unset-context-property", 2, 0, 0, - (SCM context, SCM name), - "Unset value of property @var{name} in context @var{context}.") +LY_DEFINE (ly_unset_context_property, "ly:unset-context-property", 2, 0, 0, + (SCM context, SCM name), + "Unset value of property @var{name} in context @var{context}.") { - Context *t = unsmob_context (context); - Context * tr = (t); - SCM_ASSERT_TYPE(tr, context, SCM_ARG1, __FUNCTION__, "Context"); - SCM_ASSERT_TYPE(gh_symbol_p (name), name, SCM_ARG2, __FUNCTION__, "symbol"); + Context *tr = unsmob_context (context); + SCM_ASSERT_TYPE (tr, context, SCM_ARG1, __FUNCTION__, "Context"); + SCM_ASSERT_TYPE (gh_symbol_p (name), name, SCM_ARG2, __FUNCTION__, "symbol"); tr->unset_property (name); - return SCM_UNSPECIFIED; } - - -LY_DEFINE(ly_context_parent, - "ly:context-parent", 1, 0, 0, - (SCM context), - "Return the parent of @var{context}, #f if none.") +LY_DEFINE (ly_context_parent, "ly:context-parent", + 1, 0, 0, (SCM context), + "Return the parent of @var{context}, #f if none.") { - Context *t = unsmob_context (context); - Context * tr= (t); - - SCM_ASSERT_TYPE(tr, context, SCM_ARG1, __FUNCTION__, "Context"); + Context *tr = unsmob_context (context); + SCM_ASSERT_TYPE (tr, context, SCM_ARG1, __FUNCTION__, "Context"); - tr = tr->daddy_context_ ; + tr = tr->daddy_context_ ; if (tr) - return tr->self_scm(); + return tr->self_scm (); else return SCM_BOOL_F; } -/* - Todo: should support translator IDs, and creation? - */ -LY_DEFINE(ly_translator_find, - "ly:translator-find", 2, 0,0, - (SCM context, SCM name), - "Find a parent of @var{context} that has name or alias @var{name}. " - "Return @code{#f} if not found." ) +/* FIXME: todo: should support translator IDs, and creation? */ +LY_DEFINE (ly_translator_find, "ly:translator-find", + 2, 0, 0, (SCM context, SCM name), + "Find a parent of @var{context} that has name or alias @var{name}. " + "Return @code{#f} if not found.") { - Context * tr= ( unsmob_context (context)); - - SCM_ASSERT_TYPE(tr, context, SCM_ARG1, __FUNCTION__, "context"); - SCM_ASSERT_TYPE(gh_symbol_p (name), name, SCM_ARG2, __FUNCTION__, "symbol"); + Context *tr = unsmob_context (context); + SCM_ASSERT_TYPE (tr, context, SCM_ARG1, __FUNCTION__, "context"); + SCM_ASSERT_TYPE (gh_symbol_p (name), name, SCM_ARG2, __FUNCTION__, "symbol"); while (tr) { if (tr->is_alias (name)) - return tr->self_scm(); + return tr->self_scm (); tr = tr->daddy_context_ ; } return SCM_BOOL_F; } - -LY_DEFINE(ly_context_properties, - "ly:context-properties", 1, 0, 0, - (SCM context), - "Return all properties of @var{context} in an alist.") +LY_DEFINE (ly_context_properties, "ly:context-properties", + 1, 0, 0, (SCM context), + "Return all properties of @var{context} in an alist.") { - Context *t = unsmob_context (context); - Context * tr= (t); - - SCM_ASSERT_TYPE(tr, context, SCM_ARG1, __FUNCTION__, "Context"); - + Context *tr = unsmob_context (context); + SCM_ASSERT_TYPE (tr, context, SCM_ARG1, __FUNCTION__, "Context"); return tr->properties_as_alist (); } diff --git a/lily/duration.cc b/lily/duration.cc index 6145731b4b..06149d48b6 100644 --- a/lily/duration.cc +++ b/lily/duration.cc @@ -1,10 +1,10 @@ /* duration.cc -- implement Duration - + source file of the LilyPond music typesetter (c) 1997--2004 Jan Nieuwenhuizen - Han-Wen Nienhuys + Han-Wen Nienhuys */ @@ -18,7 +18,6 @@ #include "ly-smobs.icc" - int Duration::compare (Duration const &left, Duration const &right) { @@ -29,14 +28,14 @@ Duration::Duration () { durlog_ = 0; dots_ = 0; - factor_ = Rational (1,1); + factor_ = Rational (1, 1); } -Duration::Duration (int l, int d) +Duration::Duration (int log, int d) { - durlog_ = l; + durlog_ = log; dots_ = d; - factor_ = Rational (1,1); + factor_ = Rational (1, 1); } Duration @@ -53,11 +52,10 @@ Duration::get_length () const Rational mom (1 << abs (durlog_)); if (durlog_> 0) - mom = Rational (1)/mom; + mom = Rational (1) / mom; Rational delta = mom; - - for (int d = dots_; d; d--) + for (int i = 0; i < dots_; i++) { delta /= Rational (2); mom += delta; @@ -66,8 +64,6 @@ Duration::get_length () const return mom * factor_; } - - String Duration::to_string () const { @@ -77,12 +73,10 @@ Duration::to_string () const s = "log = " + ::to_string (durlog_); else s = ::to_string (1 << durlog_); - + s += ::to_string ('.', dots_); - if (factor_ != Moment (Rational (1,1))) - { - s += "*" + factor_.to_string (); - } + if (factor_ != Moment (Rational (1, 1))) + s += "*" + factor_.to_string (); return s; } @@ -100,11 +94,11 @@ int Duration::print_smob (SCM s, SCM port, scm_print_state *) { Duration *r = (Duration *) ly_cdr (s); - + scm_puts ("#to_string ().to_str0 ()), port); scm_puts (" >", port); - + return 1; } @@ -112,7 +106,7 @@ SCM Duration::equal_p (SCM a , SCM b) { Duration *p = (Duration *) ly_cdr (a); - Duration *q = (Duration *) ly_cdr (b); + Duration *q = (Duration *) ly_cdr (b); bool eq = p->dots_ == q->dots_ && p->durlog_ == q->durlog_ @@ -120,7 +114,7 @@ Duration::equal_p (SCM a , SCM b) return eq ? SCM_BOOL_T : SCM_BOOL_F; } - + MAKE_SCHEME_CALLBACK (Duration, less_p, 2); SCM Duration::less_p (SCM p1, SCM p2) @@ -134,14 +128,15 @@ 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), +LY_DEFINE (dot_count_log, "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"); - + SCM_ASSERT_TYPE (unsmob_duration (dur), dur, SCM_ARG1, __FUNCTION__, "duration"); return gh_int2scm (unsmob_duration (dur)->dot_count ()); } -LY_DEFINE(ly_intlog2, - "ly:intlog2", 1, 0, 0, (SCM d), - "The 2-logarithm of 1/@var{d}." -) +LY_DEFINE (ly_intlog2, "ly:intlog2", + 1, 0, 0, (SCM d), + "The 2-logarithm of 1/@var{d}.") { - SCM_ASSERT_TYPE(gh_number_p (d), d, SCM_ARG1, __FUNCTION__, "integer"); - - int l = intlog2 (gh_scm2int (d)); - - return gh_int2scm (l); + SCM_ASSERT_TYPE (gh_number_p (d), d, SCM_ARG1, __FUNCTION__, "integer"); + int log = intlog2 (gh_scm2int (d)); + return gh_int2scm (log); } -LY_DEFINE(compression_factor, - "ly:duration-factor", 1, 0, 0, (SCM dur), - "Extract the compression factor from @var{dur}. Return as a pair." -) +LY_DEFINE (compression_factor, "ly:duration-factor", + 1, 0, 0, (SCM dur), + "Extract the compression factor from @var{dur}. Return as a pair.") { - SCM_ASSERT_TYPE(unsmob_duration(dur), dur, SCM_ARG1, __FUNCTION__, "duration"); - Rational r =unsmob_duration (dur)->factor (); - - return gh_cons(gh_int2scm (r.num()),gh_int2scm (r.den ())); + SCM_ASSERT_TYPE (unsmob_duration (dur), dur, SCM_ARG1, __FUNCTION__, "duration"); + Rational r = unsmob_duration (dur)->factor (); + return gh_cons (gh_int2scm (r.num ()), gh_int2scm (r.den ())); } SCM -Duration::smobbed_copy ()const +Duration::smobbed_copy () const { - Duration * p = new Duration (*this); + Duration *p = new Duration (*this); return p->smobbed_self (); } @@ -259,4 +238,3 @@ Duration::dot_count () const { return dots_; } - diff --git a/lily/font-interface.cc b/lily/font-interface.cc index fc6ce65726..587cc9c155 100644 --- a/lily/font-interface.cc +++ b/lily/font-interface.cc @@ -1,11 +1,10 @@ -/* +/* font-interface.cc -- implement Font_interface source file of the GNU LilyPond music typesetter - + (c) 2000--2004 Han-Wen Nienhuys - - */ +*/ #include "all-font-metrics.hh" #include "font-metric.hh" @@ -15,46 +14,38 @@ #include "warn.hh" -/* - todo: split up this func, reuse in text_item? - */ +/* todo: split up this func, reuse in text_item? */ Font_metric * -Font_interface::get_default_font (Grob*me) +Font_interface::get_default_font (Grob *me) { - Font_metric * fm = unsmob_metrics (me->get_property ("font")); - if (fm) - return fm; - - fm = select_font (me->get_paper (), font_alist_chain (me)); - me->set_property ("font", fm->self_scm ()); + Font_metric *fm = unsmob_metrics (me->get_property ("font")); + if (!fm) + { + fm = select_font (me->get_paper (), font_alist_chain (me)); + me->set_property ("font", fm->self_scm ()); + } return fm; } - -LY_DEFINE(ly_font_interface_get_default_font, - "ly:get-default-font", 1 , 0, 0, - (SCM grob), "Return the default font for grob @var{gr}.") +LY_DEFINE (ly_font_interface_get_default_font, "ly:get-default-font", + 1 , 0, 0, (SCM grob), + "Return the default font for grob @var{gr}.") { - Grob * gr = unsmob_grob (grob); - SCM_ASSERT_TYPE(gr, grob, SCM_ARG1, __FUNCTION__, "grob"); + Grob *gr = unsmob_grob (grob); + SCM_ASSERT_TYPE (gr, grob, SCM_ARG1, __FUNCTION__, "grob"); return Font_interface::get_default_font (gr)->self_scm (); } - SCM -Font_interface::font_alist_chain (Grob*g) +Font_interface::font_alist_chain (Grob *g) { SCM defaults = g->get_paper ()->lookup_variable (ly_symbol2scm ("font-defaults")); - return g->get_property_alist_chain (defaults); } - - - - ADD_INTERFACE (Font_interface, "font-interface", - "Any symbol that is typeset through fixed sets of glyphs (ie. fonts)", + "Any symbol that is typeset through fixed sets of glyphs, " + " (ie. fonts)", "font-magnification font font-series font-shape " "font-family font-name font-size"); diff --git a/lily/grob-pq-engraver.cc b/lily/grob-pq-engraver.cc index 96d93ceec2..db2abd46bd 100644 --- a/lily/grob-pq-engraver.cc +++ b/lily/grob-pq-engraver.cc @@ -33,8 +33,8 @@ Grob_pq_engraver::initialize () daddy_context_->set_property ("busyGrobs", SCM_EOL); } -LY_DEFINE(ly_grob_pq_less_p, - "ly:grob-pq-less?", 2 , 0 ,0, (SCM a, SCM b), +LY_DEFINE(ly_grob_pq_less_p, "ly:grob-pq-less?", + 2, 0 ,0, (SCM a, SCM b), "Compare 2 Grob PQ entries. Internal") { if (Moment::compare (*unsmob_moment (gh_car (a)), diff --git a/lily/grob-scheme.cc b/lily/grob-scheme.cc index f825996bc4..ffee573c79 100644 --- a/lily/grob-scheme.cc +++ b/lily/grob-scheme.cc @@ -1,3 +1,12 @@ +/* + grob-scheme.cc -- + + source file of the GNU LilyPond music typesetter + + (c) 1998--2004 Jan Nieuwenhuizen + Han-Wen Nienhuys +*/ + #include "grob.hh" #include "warn.hh" #include "spanner.hh" @@ -7,33 +16,35 @@ LY_DEFINE (ly_grob_set_property,"ly:grob-set-property!", 3, 0, 0, - (SCM grob, SCM sym, SCM val), + (SCM grob, SCM sym, SCM val), "Set @var{sym} in grob @var{grob} to value @var{val}") { Grob * sc = unsmob_grob (grob); SCM_ASSERT_TYPE (sc, grob, SCM_ARG1, __FUNCTION__, "grob"); - SCM_ASSERT_TYPE (gh_symbol_p (sym), sym, SCM_ARG2, __FUNCTION__, "symbol"); + SCM_ASSERT_TYPE (gh_symbol_p (sym), sym, SCM_ARG2, __FUNCTION__, "symbol"); if (!type_check_assignment (sym, val, ly_symbol2scm ("backend-type?"))) error ("typecheck failed"); - + sc->internal_set_property (sym, val); return SCM_UNSPECIFIED; } -LY_DEFINE (ly_get_property, - "ly:grob-property", 2, 0, 0, (SCM grob, SCM sym), - "Get the value of a value in grob @var{g} of property @var{sym}. It\n" -"will return @code{'()} (end-of-list) if @var{g} doesn't have @var{sym} set.\n" -"\n" -"Grob properties are stored as GUILE association lists, with symbols as\n" -"keys. All lookup functions identify undefined properties with\n" -"end-of-list (i.e. @code{'()} in Scheme or @code{SCM_EOL} in C)\n" -"\n") +LY_DEFINE (ly_get_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) " + "if @var{g} does nott have @var{sym} set." + "\n\n" + "Grob properties are stored as GUILE association lists, " + "with symbols as keys. " + "All lookup functions identify undefined properties " + "with end-of-list (i.e. @code{' ()} in Scheme " + "or @code{SCM_EOL} in C.") { - Grob * sc = unsmob_grob (grob); + Grob *sc = unsmob_grob (grob); SCM_ASSERT_TYPE (sc, grob, SCM_ARG1, __FUNCTION__, "grob"); - SCM_ASSERT_TYPE (gh_symbol_p (sym), sym, SCM_ARG2, __FUNCTION__, "symbol"); + SCM_ASSERT_TYPE (gh_symbol_p (sym), sym, SCM_ARG2, __FUNCTION__, "symbol"); return sc->internal_get_property (sym); } @@ -52,7 +63,7 @@ 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 grob), + (SCM grob), "Get \\paper definition from a grob.") { Grob * sc = unsmob_grob (grob); @@ -61,9 +72,6 @@ LY_DEFINE (ly_grob_paper,"ly:grob-paper", 1, 0, 0, return sc->get_paper ()->self_scm (); } - - - 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 " @@ -73,7 +81,7 @@ LY_DEFINE (ly_get_extent, "ly:grob-extent", 3, 0, 0, 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 (gh_scm2int (axis)))); @@ -87,26 +95,24 @@ LY_DEFINE (ly_get_parent, "ly:grob-parent", 2, 0, 0, (SCM grob, SCM axis), SCM_ASSERT_TYPE (sc, grob, SCM_ARG1, __FUNCTION__, "grob"); SCM_ASSERT_TYPE (is_axis (axis), axis, SCM_ARG2, __FUNCTION__, "axis"); - Grob * par = sc->get_parent (Axis (gh_scm2int (axis))); + Grob *par = sc->get_parent (Axis (gh_scm2int (axis))); return par ? par->self_scm () : SCM_EOL; } -LY_DEFINE (ly_get_system, - "ly:grob-system", +LY_DEFINE (ly_get_system, "ly:grob-system", 1, 0, 0, (SCM grob), "Return the System Grob of @var{grob}.") { Grob *me = unsmob_grob (grob); SCM_ASSERT_TYPE (me, grob, SCM_ARG1, __FUNCTION__, "grob"); - + if (System *g = me->get_system ()) return g->self_scm (); - + return SCM_EOL; } -LY_DEFINE (ly_get_original, - "ly:grob-original", +LY_DEFINE (ly_get_original, "ly:grob-original", 1, 0, 0, (SCM grob), "Return the unbroken original Grob of @var{grob}.") { @@ -115,16 +121,13 @@ LY_DEFINE (ly_get_original, return me->original_ ? me->original_->self_scm () : me->self_scm (); } - -/* ly prefix? spanner in name? */ +/* 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", 1, 0, 0, (SCM spanner), + logical for this list? */ +LY_DEFINE (get_broken_into, "ly:spanner-broken-into", + 1, 0, 0, (SCM spanner), "Return broken-into list for @var{spanner}.") { - /// Spanner *me = unsmob_spanner (spanner); Spanner *me = dynamic_cast (unsmob_grob (spanner)); SCM_ASSERT_TYPE (me, spanner, SCM_ARG1, __FUNCTION__, "spanner"); @@ -134,9 +137,8 @@ LY_DEFINE (get_broken_into, return s; } - -LY_DEFINE (ly_grob_suicide, - "ly:grob-suicide", 1, 0, 0, (SCM g), +LY_DEFINE (ly_grob_suicide, "ly:grob-suicide", + 1, 0, 0, (SCM g), "Kill @var{g}.") { Grob *me = unsmob_grob (g); @@ -146,11 +148,8 @@ LY_DEFINE (ly_grob_suicide, return SCM_UNDEFINED; } - - -LY_DEFINE (ly_grob_translate_axis_x, - "ly:grob-translate-axis!", 3, 0, 0, - (SCM g, SCM d, SCM a), +LY_DEFINE (ly_grob_translate_axis_x, "ly:grob-translate-axis!", + 3, 0, 0, (SCM g, SCM d, SCM a), "Translate @var{g} on axis @var{a} over distance @var{d}.") { Grob *me = unsmob_grob (g); @@ -158,16 +157,12 @@ LY_DEFINE (ly_grob_translate_axis_x, SCM_ASSERT_TYPE (gh_number_p (d), d, SCM_ARG2, __FUNCTION__, "dimension"); SCM_ASSERT_TYPE (is_axis (a), a, SCM_ARG3, __FUNCTION__, "axis"); - me->translate_axis (gh_scm2double (d), - Axis (gh_scm2int (a))); + me->translate_axis (gh_scm2double (d), Axis (gh_scm2int (a))); return SCM_UNDEFINED; } - - -LY_DEFINE (ly_spanner_p, - "ly:spanner?", 1, 0, 0, - (SCM g), +LY_DEFINE (ly_spanner_p, "ly:spanner?", + 1, 0, 0, (SCM g), "Is @var{g} a spanner object?") { Grob *me = unsmob_grob (g); @@ -176,26 +171,20 @@ LY_DEFINE (ly_spanner_p, return gh_bool2scm (b); } -LY_DEFINE (ly_item_p, - "ly:item?", 1, 0, 0, - (SCM g), - "Is @var{g} a item object?") +LY_DEFINE (ly_item_p, "ly:item?", + 1, 0, 0, (SCM g), + "Is @var{g} a item object?") { Grob *me = unsmob_grob (g); bool b = dynamic_cast (me); - return gh_bool2scm (b); } - -LY_DEFINE (ly_item_break_dir, - "ly:item-break-dir", 1, 0, 0, - (SCM it), +LY_DEFINE (ly_item_break_dir, "ly:item-break-dir", + 1, 0, 0, (SCM it), "The break status dir of @var{it}.") { - Item * me = dynamic_cast ( unsmob_grob (it)); + Item *me = dynamic_cast ( unsmob_grob (it)); SCM_ASSERT_TYPE (me, it, SCM_ARG1, __FUNCTION__, "Item"); - - return gh_int2scm (me->break_status_dir ()); + return gh_int2scm (me->break_status_dir ()); } - diff --git a/lily/music-output-def.cc b/lily/music-output-def.cc index b618837323..068b8594cb 100644 --- a/lily/music-output-def.cc +++ b/lily/music-output-def.cc @@ -27,7 +27,7 @@ Music_output_def::Music_output_def () smobify_self (); scm_gc_unprotect_object (translator_tab_->self_scm ()); - scope_ = ly_make_anonymous_module(); + scope_ = ly_make_anonymous_module (); } Music_output_def::~Music_output_def () @@ -77,12 +77,12 @@ Music_output_def::assign_translator (SCM transdef) String nm = ly_symbol2string (tp->get_context_name ()) + "Context"; - scm_module_define (scope_, ly_symbol2scm (nm.to_str0()), transdef); + scm_module_define (scope_, ly_symbol2scm (nm.to_str0 ()), transdef); } /* find the translator for NAME. NAME must be a symbol. - */ +*/ SCM Music_output_def::find_context_def (SCM name) const { @@ -91,7 +91,6 @@ Music_output_def::find_context_def (SCM name) const return val; } - int Music_output_def::print_smob (SCM s, SCM p, scm_print_state *) { @@ -104,14 +103,12 @@ Music_output_def::print_smob (SCM s, SCM p, scm_print_state *) return 1; } - SCM Music_output_def::get_scmvar (String s) const { return lookup_variable (ly_symbol2scm (s.to_str0 ())); } - void Music_output_def::set_variable (SCM sym, SCM val) { @@ -126,13 +123,10 @@ Music_output_def::lookup_variable (SCM sym) const return scm_variable_ref (var); } -LY_DEFINE(ly_paper_lookup, - "ly:paper-lookup", - 2, 0,0, - (SCM pap, SCM sym), - "Lookup @var{sym} in @var{pap}. Return the value " - " or '() if undefined. " - ) +LY_DEFINE (ly_paper_lookup, "ly:paper-lookup", + 2, 0,0, (SCM pap, SCM sym), + "Lookup @var{sym} in @var{pap}. " + "Return the value or ' () if undefined.") { Music_output_def *op = unsmob_music_output_def (pap); SCM_ASSERT_TYPE (op, pap, SCM_ARG1, __FUNCTION__, "Paper"); @@ -145,30 +139,21 @@ LY_DEFINE(ly_paper_lookup, return SCM_EOL; } -LY_DEFINE(ly_output_def_scope, - "ly:output-def-scope", - 1, 0,0, - (SCM def), - "Get the scope inside @var{def}." - ) +LY_DEFINE (ly_output_def_scope, "ly:output-def-scope", + 1, 0,0, (SCM def), + "Get the scope inside @var{def}.") { Music_output_def *op = unsmob_music_output_def (def); SCM_ASSERT_TYPE (op, def, SCM_ARG1, __FUNCTION__, "Output definition"); - return op->scope_; } - -LY_DEFINE(ly_output_def_clone, - "ly:output-def-clone", - 1, 0,0, - (SCM def), - "Clone @var{def}." - ) +LY_DEFINE (ly_output_def_clone, "ly:output-def-clone", + 1, 0, 0, (SCM def), + "Clone @var{def}.") { Music_output_def *op = unsmob_music_output_def (def); SCM_ASSERT_TYPE (op, def, SCM_ARG1, __FUNCTION__, "Output definition"); - SCM s = op->clone ()->self_scm (); scm_gc_unprotect_object (s); return s; diff --git a/lily/music.cc b/lily/music.cc index b5964c87fc..109525bce4 100644 --- a/lily/music.cc +++ b/lily/music.cc @@ -13,11 +13,11 @@ #include "warn.hh" #include "pitch.hh" #include "ly-smobs.icc" - +#include "main.hh" bool -Music::internal_is_music_type (SCM k)const +Music::internal_is_music_type (SCM k) const { SCM ifs = get_property ("types"); @@ -38,7 +38,13 @@ Music::name () const } } - +Music::Music () +{ + self_scm_ = SCM_EOL; + immutable_property_alist_ = SCM_EOL; + mutable_property_alist_ = SCM_EOL; + smobify_self (); +} Music::Music (Music const &m) { @@ -46,24 +52,20 @@ Music::Music (Music const &m) mutable_property_alist_ = SCM_EOL; self_scm_ = SCM_EOL; - /* - First we smobify_self, then we copy over the stuff. If we don't, - stack vars that hold the copy might be optimized away, meaning - that they won't be protected from GC. - */ + /* First we smobify_self, then we copy over the stuff. If we don't, + stack vars that hold the copy might be optimized away, meaning + that they won't be protected from GC. */ smobify_self (); mutable_property_alist_ = ly_deep_mus_copy (m.mutable_property_alist_); set_spot (*m.origin ()); } -Music::Music () +Music::~Music () { - self_scm_ = SCM_EOL; - immutable_property_alist_ = SCM_EOL; - mutable_property_alist_ = SCM_EOL; - smobify_self (); } +ADD_MUSIC (Music); + SCM Music::get_property_alist (bool m) const { @@ -73,7 +75,7 @@ Music::get_property_alist (bool m) const SCM Music::mark_smob (SCM m) { - Music * mus = (Music *)SCM_CELL_WORD_1 (m); + Music *mus = (Music*) SCM_CELL_WORD_1 (m); scm_gc_mark (mus->immutable_property_alist_); scm_gc_mark (mus->mutable_property_alist_); return SCM_EOL; @@ -82,42 +84,40 @@ Music::mark_smob (SCM m) Moment Music::get_length () const { - SCM l = get_property ("length"); - if (unsmob_moment (l)) - return *unsmob_moment (l); - else if (gh_procedure_p (l)) + SCM lst = get_property ("length"); + if (unsmob_moment (lst)) + return *unsmob_moment (lst); + else if (gh_procedure_p (lst)) { - SCM res = gh_call1 (l, self_scm ()); + SCM res = gh_call1 (lst, self_scm ()); return *unsmob_moment (res); } - + return 0; } Moment Music::start_mom () const { - SCM l = get_property ("start-moment-function"); - if (gh_procedure_p (l)) + SCM lst = get_property ("start-moment-function"); + if (gh_procedure_p (lst)) { - SCM res = gh_call1 (l, self_scm ()); + SCM res = gh_call1 (lst, self_scm ()); return *unsmob_moment (res); } - Moment m ; + Moment m; return m; } void print_alist (SCM a, SCM port) { - /* - SCM_EOL -> catch malformed lists. - */ + /* SCM_EOL -> catch malformed lists. */ for (SCM s = a; gh_pair_p (s); s = ly_cdr (s)) { scm_display (ly_caar (s), port); - scm_puts (" = ", port); + scm_puts (" = ", port); scm_write (ly_cdar (s), port); scm_puts ("\n", port); } @@ -131,19 +131,13 @@ Music::print_smob (SCM s, SCM p, scm_print_state*) SCM nm = m->get_property ("name"); if (gh_symbol_p (nm) || gh_string_p (nm)) - { - scm_display (nm, p); - } + scm_display (nm, p); else - { - scm_puts (classname (m),p); - } - - /* - Printing properties takes a lot of time, especially during backtraces. - For inspecting, it is better to explicitly use an inspection - function. - */ + scm_puts (classname (m),p); + + /* Printing properties takes a lot of time, especially during backtraces. + For inspecting, it is better to explicitly use an inspection + function. */ scm_puts (">",p); return 1; @@ -154,11 +148,10 @@ Music::to_relative_octave (Pitch p) { SCM elt = get_property ("element"); - if (Music* m = unsmob_music (elt)) + if (Music *m = unsmob_music (elt)) p = m->to_relative_octave (p); - p = music_list_to_relative (get_property ("elements"), - p, false); + p = music_list_to_relative (get_property ("elements"), p, false); return p; } @@ -167,13 +160,12 @@ Music::compress (Moment factor) { SCM elt = get_property ("element"); - if (Music* m = unsmob_music (elt)) + if (Music *m = unsmob_music (elt)) m->compress (factor); compress_music_list (get_property ("elements"), factor); } - void Music::transpose (Pitch delta) { @@ -185,14 +177,10 @@ Music::transpose (Pitch delta) transpose_music_list (get_property ("elements"), delta); } - IMPLEMENT_TYPE_P (Music, "ly:music?"); - IMPLEMENT_SMOBS (Music); IMPLEMENT_DEFAULT_EQUAL_P (Music); -/****************************/ - SCM Music::internal_get_property (SCM sym) const { @@ -201,7 +189,7 @@ Music::internal_get_property (SCM sym) const return ly_cdr (s); s = scm_sloppy_assq (sym, immutable_property_alist_); - return (s == SCM_BOOL_F) ? SCM_EOL : ly_cdr (s); + return (s == SCM_BOOL_F) ? SCM_EOL : ly_cdr (s); } void @@ -214,8 +202,6 @@ Music::internal_set_property (SCM s, SCM v) mutable_property_alist_ = scm_assq_set_x (mutable_property_alist_, s, v); } -#include "main.hh" - void Music::set_spot (Input ip) { @@ -226,71 +212,61 @@ Input* Music::origin () const { Input *ip = unsmob_input (get_property ("origin")); - return ip ? ip : & dummy_input_global; -} - - -Music::~Music () -{ - + return ip ? ip : & dummy_input_global; } -LY_DEFINE(ly_music_length, - "ly:music-length", 1, 0, 0, (SCM mus), +LY_DEFINE (ly_music_length, "ly:music-length", + 1, 0, 0, (SCM mus), "Get the length (in musical time) of music expression @var{mus}.") { - Music * sc = unsmob_music (mus); - SCM_ASSERT_TYPE(sc, mus, SCM_ARG1, __FUNCTION__, "music"); - return sc->get_length().smobbed_copy(); + Music *sc = unsmob_music (mus); + SCM_ASSERT_TYPE (sc, mus, SCM_ARG1, __FUNCTION__, "music"); + return sc->get_length ().smobbed_copy (); } -LY_DEFINE(ly_music_property, - "ly:music-property", 2, 0, 0, (SCM mus, SCM sym), +LY_DEFINE (ly_music_property, + "ly:music-property", 2, 0, 0, (SCM mus, SCM sym), "Get the property @var{sym} of music expression @var{mus}.\n" - "If @var{sym} is undefined, return @code{'()}.\n" ) + "If @var{sym} is undefined, return @code{' ()}.\n" ) { Music * sc = unsmob_music (mus); - SCM_ASSERT_TYPE(sc, mus, SCM_ARG1, __FUNCTION__, "music"); - SCM_ASSERT_TYPE(gh_symbol_p (sym), sym, SCM_ARG2, __FUNCTION__, "symbol"); + SCM_ASSERT_TYPE (sc, mus, SCM_ARG1, __FUNCTION__, "music"); + SCM_ASSERT_TYPE (gh_symbol_p (sym), sym, SCM_ARG2, __FUNCTION__, "symbol"); return sc->internal_get_property (sym); } -LY_DEFINE(ly_music_set_property, - "ly:music-set-property!", 3, 0, 0, - (SCM mus, SCM sym, SCM val), +LY_DEFINE (ly_music_set_property, "ly:music-set-property!", + 3, 0, 0, (SCM mus, SCM sym, SCM val), "Set property @var{sym} in music expression @var{mus} to @var{val}.") { Music * sc = unsmob_music (mus); - SCM_ASSERT_TYPE(sc, mus, SCM_ARG1, __FUNCTION__, "music"); - SCM_ASSERT_TYPE(gh_symbol_p (sym), sym, SCM_ARG2, __FUNCTION__, "symbol"); + SCM_ASSERT_TYPE (sc, mus, SCM_ARG1, __FUNCTION__, "music"); + SCM_ASSERT_TYPE (gh_symbol_p (sym), sym, SCM_ARG2, __FUNCTION__, "symbol"); bool ok = type_check_assignment (sym, val, ly_symbol2scm ("music-type?")); if (ok) { sc->internal_set_property (sym, val); } - + return SCM_UNSPECIFIED; } - -LY_DEFINE(ly_music_name, "ly:music-name", 1, 0, 0, - (SCM mus), - "Return the name of @var{music}.") +LY_DEFINE (ly_music_name, "ly:music-name", + 1, 0, 0, (SCM mus), + "Return the name of @var{music}.") { - Music * m = unsmob_music (mus); - SCM_ASSERT_TYPE(m, mus, SCM_ARG1, __FUNCTION__ ,"music"); - - const char * nm = classname (m); + Music *m = unsmob_music (mus); + SCM_ASSERT_TYPE (m, mus, SCM_ARG1, __FUNCTION__ ,"music"); + + char const *nm = classname (m); return scm_makfrom0str (nm); } - - -// to do property args -LY_DEFINE(ly_extended_make_music, - "ly:make-bare-music", 2, 0, 0, (SCM type, SCM props), +/* todo: property args */ +LY_DEFINE (ly_extended_make_music, "ly:make-bare-music", + 2, 0, 0, (SCM type, SCM props), "Make a C++ music object of type @var{type}, initialize with\n" "@var{props}. \n\n" "" @@ -299,82 +275,74 @@ LY_DEFINE(ly_extended_make_music, "for creating music objects. " ) { - SCM_ASSERT_TYPE(gh_string_p (type), type, SCM_ARG1, __FUNCTION__, "string"); - + SCM_ASSERT_TYPE (gh_string_p (type), type, SCM_ARG1, __FUNCTION__, "string"); SCM s = make_music (ly_scm2string (type))->self_scm (); unsmob_music (s)->immutable_property_alist_ = props; scm_gc_unprotect_object (s); return s; } -// to do property args -LY_DEFINE(ly_get_mutable_properties, - "ly:get-mutable-properties", 1, 0, 0, (SCM mus), +/* todo: property args */ +LY_DEFINE (ly_get_mutable_properties, "ly:get-mutable-properties", + 1, 0, 0, (SCM mus), "Return an alist containing the mutable properties of @var{mus}.\n" - "The immutable properties are not available; they should be initialized\n" - "by the @code{make-music} function.\n" - ) + "The immutable properties are not available; " + "they should be initialized by the @code{make-music} function.\n") { Music *m = unsmob_music (mus); - SCM_ASSERT_TYPE(m, mus, SCM_ARG1, __FUNCTION__, "music"); - + SCM_ASSERT_TYPE (m, mus, SCM_ARG1, __FUNCTION__, "music"); return m->get_property_alist (true); } -LY_DEFINE(ly_music_list_p,"ly:music-list?", 1, 0, 0, - (SCM l),"Type predicate: return true if @var{l} is a list of music objects.") +LY_DEFINE (ly_music_list_p,"ly:music-list?", + 1, 0, 0, (SCM lst), + "Type predicate: return true if @var{lst} is a list " + "of music objects.") { - if (scm_list_p (l) != SCM_BOOL_T) - return SCM_BOOL_F; + if (scm_list_p (lst) == SCM_BOOL_T) + while (gh_pair_p (lst)) + { + if (!unsmob_music (gh_car (lst))) + return SCM_BOOL_F; + lst = gh_cdr (lst); + } - while (gh_pair_p (l)) - { - if (!unsmob_music (gh_car (l))) - return SCM_BOOL_F; - l =gh_cdr (l); - } return SCM_BOOL_T; } -ADD_MUSIC(Music); - - -LY_DEFINE(ly_deep_mus_copy, - "ly:music-deep-copy", 1,0,0, (SCM m), +LY_DEFINE (ly_deep_mus_copy, "ly:music-deep-copy", + 1, 0, 0, (SCM m), "Copy @var{m} and all sub expressions of @var{m}") { + SCM copy = m; if (unsmob_music (m)) { - SCM ss = unsmob_music (m)->clone ()->self_scm (); - scm_gc_unprotect_object (ss); - return ss; + copy = unsmob_music (m)->clone ()->self_scm (); + scm_gc_unprotect_object (copy); } else if (gh_pair_p (m)) - { - return gh_cons (ly_deep_mus_copy (ly_car (m)), ly_deep_mus_copy (ly_cdr (m))); - } - else - return m; + copy = gh_cons (ly_deep_mus_copy (ly_car (m)), + ly_deep_mus_copy (ly_cdr (m))); + return copy; } -LY_DEFINE(ly_music_transpose, - "ly:music-transpose", 2,0,0, (SCM m, SCM p), +LY_DEFINE (ly_music_transpose, "ly:music-transpose", + 2, 0, 0, (SCM m, SCM p), "Transpose @var{m} such that central C is mapped to @var{p}. " -"Return @var{m}.") + "Return @var{m}.") { Music * sc = unsmob_music (m); Pitch * sp = unsmob_pitch (p); - SCM_ASSERT_TYPE(sc, m, SCM_ARG1, __FUNCTION__, "music"); - SCM_ASSERT_TYPE(sp, p, SCM_ARG2, __FUNCTION__, "pitch"); + SCM_ASSERT_TYPE (sc, m, SCM_ARG1, __FUNCTION__, "music"); + SCM_ASSERT_TYPE (sp, p, SCM_ARG2, __FUNCTION__, "pitch"); sc->transpose (*sp); - return sc->self_scm(); // SCM_UNDEFINED ? + // SCM_UNDEFINED ? + return sc->self_scm (); } - SCM make_music_proc; - Music* make_music_by_name (SCM sym) { @@ -383,9 +351,7 @@ make_music_by_name (SCM sym) SCM rv = scm_call_1 (make_music_proc, sym); - /* - UGH. - */ + /* UGH. */ scm_gc_protect_object (rv); return unsmob_music (rv); } diff --git a/lily/pitch.cc b/lily/pitch.cc index e01026da3d..04d7d6c127 100644 --- a/lily/pitch.cc +++ b/lily/pitch.cc @@ -1,18 +1,17 @@ -/* +/* musical-pitch.cc -- implement Pitch - + source file of the GNU LilyPond music typesetter - + (c) 1998--2004 Han-Wen Nienhuys - - */ +*/ + #include "pitch.hh" #include "warn.hh" #include "main.hh" #include "ly-smobs.icc" - Pitch::Pitch (int o, int n, int a) { notename_ = n; @@ -36,11 +35,11 @@ Pitch::compare (Pitch const &m1, Pitch const &m2) int a = m1.alteration_ - m2.alteration_; if (o) - return o; + return o; if (n) - return n; + return n; if (a) - return a; + return a; return 0; } @@ -50,9 +49,7 @@ Pitch::steps () const return notename_ + octave_*7; } -/* - should be settable from input? - */ +/* Should be settable from input? */ static Byte diatonic_scale_semitones[ ] = { 0, 2, 4, 5, 7, 9, 11 }; @@ -70,12 +67,11 @@ Pitch::semitone_pitch () const } if (alteration_ % 2) - { - programming_error ("Calling semitone_pitch() for quarter tone alterations."); - - } - - return (o + n / 7) * 12 + diatonic_scale_semitones[n % 7] + (alteration_/2); + programming_error ("semitone_pitch () called on quarter tone alteration."); + + return ((o + n / 7) * 12 + + diatonic_scale_semitones[n % 7] + + (alteration_ / 2)); } int @@ -88,8 +84,10 @@ Pitch::quartertone_pitch () const n += 7; o --; } - - return (o + n / 7) * 24 + 2* diatonic_scale_semitones[n % 7] + (alteration_); + + return ((o + n / 7) * 24 + + 2 * diatonic_scale_semitones[n % 7] + + alteration_); } void @@ -121,7 +119,7 @@ Pitch::normalise () alteration_ = 0; alteration_ -= quartertone_pitch () - pitch; } - + while (alteration_ < DOUBLE_FLAT) { if (notename_ == 0) @@ -141,10 +139,10 @@ Pitch::normalise () void Pitch::transpose (Pitch delta) { - int new_semi = quartertone_pitch () +delta.quartertone_pitch(); + int new_semi = quartertone_pitch () +delta.quartertone_pitch (); octave_ += delta.octave_; notename_ += delta.notename_; - alteration_ += new_semi - quartertone_pitch(); + alteration_ += new_semi - quartertone_pitch (); normalise (); } @@ -152,19 +150,18 @@ Pitch::transpose (Pitch delta) Pitch interval (Pitch const & from , Pitch const & to ) { - int sound = to.quartertone_pitch() - from.quartertone_pitch (); + int sound = to.quartertone_pitch () - from.quartertone_pitch (); Pitch pt (to.get_octave () - from.get_octave (), - to.get_notename() - from.get_notename(), + to.get_notename () - from.get_notename (), - to.get_alteration() - from.get_alteration()); + to.get_alteration () - from.get_alteration ()); - return pt.transposed (Pitch(0,0,sound - pt.quartertone_pitch())); + return pt.transposed (Pitch (0,0,sound - pt.quartertone_pitch ())); } /* FIXME - Merge with *pitch->text* funcs in chord-name.scm - */ + Merge with *pitch->text* funcs in chord-name.scm */ char const *accname[] = {"eses", "eseh", "es", "eh", "", "ih", "is" , "isih", "isis"}; @@ -192,20 +189,19 @@ Pitch::to_string () const return s; } -/* - change me to relative, counting from last pitch p - return copy of resulting pitch - */ +/* Change me to relative, counting from last pitch p + return copy of resulting pitch. */ Pitch Pitch::to_relative_octave (Pitch p) const { - int oct_mod = octave_ + 1; // account for c' = octave 1 iso. 0 4 + /* account for c' = octave 1 iso. 0 4 */ + int oct_mod = octave_ + 1; Pitch up_pitch (p); Pitch down_pitch (p); up_pitch.alteration_ = alteration_; down_pitch.alteration_ = alteration_; - + Pitch n = *this; up_pitch.up_to (notename_); down_pitch.down_to (notename_); @@ -215,7 +211,7 @@ Pitch::to_relative_octave (Pitch p) const n = up_pitch; else n = down_pitch; - + n.octave_ += oct_mod; return n; } @@ -223,10 +219,8 @@ Pitch::to_relative_octave (Pitch p) const void Pitch::up_to (int notename) { - if (notename_ > notename) - { - octave_ ++; - } + if (notename_ > notename) + octave_++; notename_ = notename; } @@ -234,29 +228,22 @@ void Pitch::down_to (int notename) { if (notename_ < notename) - { - octave_ --; - } + octave_--; notename_ = notename; } - -LY_DEFINE(ly_pitch_transpose, - "ly:pitch-transpose", 2, 0, 0, - (SCM p, SCM delta), - "Transpose @var{p} by the amount @var{delta}, where @var{delta} is the " -" pitch that central C is transposed to.") + +LY_DEFINE (ly_pitch_transpose, "ly:pitch-transpose", + 2, 0, 0, (SCM p, SCM delta), + "Transpose @var{p} by the amount @var{delta}, " + "where @var{delta} is the pitch that middle C is transposed to.") { Pitch* t = unsmob_pitch (p); Pitch *d = unsmob_pitch (delta); - SCM_ASSERT_TYPE(t, p, SCM_ARG1, __FUNCTION__, "pitch") ; - SCM_ASSERT_TYPE(d, delta, SCM_ARG1, __FUNCTION__, "pitch") ; - + SCM_ASSERT_TYPE (t, p, SCM_ARG1, __FUNCTION__, "pitch"); + SCM_ASSERT_TYPE (d, delta, SCM_ARG1, __FUNCTION__, "pitch"); return t->transposed (*d).smobbed_copy (); } -/****************************************************************/ - - IMPLEMENT_TYPE_P (Pitch, "ly:pitch?"); SCM @@ -269,20 +256,18 @@ IMPLEMENT_SIMPLE_SMOBS (Pitch); int Pitch::print_smob (SCM s, SCM port, scm_print_state *) { - Pitch *r = (Pitch *) ly_cdr (s); - + Pitch *r = (Pitch *) ly_cdr (s); scm_puts ("#to_string ().to_str0 ()), port); scm_puts (" >", port); - return 1; } SCM Pitch::equal_p (SCM a , SCM b) { - Pitch *p = (Pitch *) ly_cdr (a); - Pitch *q = (Pitch *) ly_cdr (b); + Pitch *p = (Pitch *) ly_cdr (a); + Pitch *q = (Pitch *) ly_cdr (b); bool eq = p->notename_ == q->notename_ && p->octave_ == q->octave_ @@ -304,100 +289,94 @@ Pitch::less_p (SCM p1, SCM p2) return SCM_BOOL_F; } -/* - should add optional args - */ - -LY_DEFINE(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. @var{note} is a number from 0 to 6, with 0 corresponding to C " - "and 6 corresponding to B. The @var{alter} is zero for a natural, negative for " - "flats, or positive for sharps. ") +/* Should add optional args. */ +LY_DEFINE (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. " + "@var{note} is a number from 0 to 6, " + "with 0 corresponding to C and 6 corresponding to B. " + "The @var{alter} is zero for a natural, negative for " + "flats, or positive for sharps. ") { - SCM_ASSERT_TYPE(scm_integer_p (octave)== SCM_BOOL_T , octave, SCM_ARG1, __FUNCTION__, "integer"); - SCM_ASSERT_TYPE(scm_integer_p (note)== SCM_BOOL_T, note, SCM_ARG2, __FUNCTION__, "integer"); - SCM_ASSERT_TYPE(scm_integer_p (alter)== SCM_BOOL_T, alter, SCM_ARG3, __FUNCTION__, "integer"); + SCM_ASSERT_TYPE (scm_integer_p (octave)== SCM_BOOL_T , octave, SCM_ARG1, __FUNCTION__, "integer"); + SCM_ASSERT_TYPE (scm_integer_p (note)== SCM_BOOL_T, note, SCM_ARG2, __FUNCTION__, "integer"); + SCM_ASSERT_TYPE (scm_integer_p (alter)== SCM_BOOL_T, alter, SCM_ARG3, __FUNCTION__, "integer"); Pitch p (gh_scm2int (octave), gh_scm2int (note), gh_scm2int (alter)); return p.smobbed_copy (); } -LY_DEFINE(pitch_steps, "ly:pitch-steps", 1, 0,0, - (SCM p), - "Number of steps counted from central C of the pitch @var{p}.") +LY_DEFINE (pitch_steps, "ly:pitch-steps", 1, 0, 0, + (SCM p), + "Number of steps counted from middle C of the pitch @var{p}.") { Pitch *pp = unsmob_pitch (p); - SCM_ASSERT_TYPE(pp, p, SCM_ARG1, __FUNCTION__, "Pitch"); - - return gh_int2scm (pp->steps()); + SCM_ASSERT_TYPE (pp, p, SCM_ARG1, __FUNCTION__, "Pitch"); + return gh_int2scm (pp->steps ()); } -LY_DEFINE(pitch_octave, "ly:pitch-octave", 1, 0, 0, - (SCM pp), - "extract the octave from pitch @var{p}.") +LY_DEFINE (pitch_octave, "ly:pitch-octave", + 1, 0, 0, (SCM pp), + "extract the octave from pitch @var{p}.") { Pitch *p = unsmob_pitch (pp); - SCM_ASSERT_TYPE(p, pp, SCM_ARG1, __FUNCTION__, "Pitch"); + SCM_ASSERT_TYPE (p, pp, SCM_ARG1, __FUNCTION__, "Pitch"); int q = p->get_octave (); - return gh_int2scm (q); } -LY_DEFINE(pitch_alteration, "ly:pitch-alteration", 1, 0, 0, - (SCM pp), - "extract the alteration from pitch @var{p}.") +LY_DEFINE (pitch_alteration, "ly:pitch-alteration", + 1, 0, 0, (SCM pp), + "extract the alteration from pitch @var{p}.") { Pitch *p = unsmob_pitch (pp); - SCM_ASSERT_TYPE(p, pp, SCM_ARG1, __FUNCTION__, "Pitch"); - int q = p->get_alteration (); + SCM_ASSERT_TYPE (p, pp, SCM_ARG1, __FUNCTION__, "Pitch"); + int q = p->get_alteration (); return gh_int2scm (q); } -LY_DEFINE(pitch_notename, "ly:pitch-notename", 1, 0, 0, - (SCM pp), - "extract the note name from pitch @var{pp}.") +LY_DEFINE (pitch_notename, "ly:pitch-notename", + 1, 0, 0, (SCM pp), + "extract the note name from pitch @var{pp}.") { Pitch *p = unsmob_pitch (pp); - SCM_ASSERT_TYPE(p, pp, SCM_ARG1, __FUNCTION__, "Pitch"); - int q = p->get_notename (); - + SCM_ASSERT_TYPE (p, pp, SCM_ARG1, __FUNCTION__, "Pitch"); + int q = p->get_notename (); return gh_int2scm (q); } -LY_DEFINE(ly_pitch_quartertones, "ly:pitch-quartertones", 1, 0, 0, - (SCM pp), - "calculate the number of semitones of @var{p} from central C.") +LY_DEFINE (ly_pitch_quartertones, "ly:pitch-quartertones", + 1, 0, 0, (SCM pp), + "calculate the number of semitones of @var{p} from middle C.") { Pitch *p = unsmob_pitch (pp); - SCM_ASSERT_TYPE(p, pp, SCM_ARG1, __FUNCTION__, "Pitch"); - + SCM_ASSERT_TYPE (p, pp, SCM_ARG1, __FUNCTION__, "Pitch"); int q = p->quartertone_pitch (); - return gh_int2scm (q); } -LY_DEFINE(ly_pitch_semitones, "ly:pitch-semitones", 1, 0, 0, - (SCM pp), - "calculate the number of semitones of @var{p} from central C.") +LY_DEFINE (ly_pitch_semitones, "ly:pitch-semitones", + 1, 0, 0, (SCM pp), + "calculate the number of semitones of @var{p} from middle C.") { Pitch *p = unsmob_pitch (pp); - SCM_ASSERT_TYPE(p, pp, SCM_ARG1, __FUNCTION__, "Pitch"); - + SCM_ASSERT_TYPE (p, pp, SCM_ARG1, __FUNCTION__, "Pitch"); int q = p->semitone_pitch (); - return gh_int2scm (q); } -LY_DEFINE(pitch_less, "ly:pitchsmobbed_self (); } @@ -447,7 +425,7 @@ Pitch::get_alteration () const Pitch Pitch::transposed (Pitch d) const { - Pitch p =*this; + Pitch p = *this; p.transpose (d); return p; } diff --git a/lily/script-column.cc b/lily/script-column.cc index 337ad20ee8..5121d5e77f 100644 --- a/lily/script-column.cc +++ b/lily/script-column.cc @@ -23,13 +23,12 @@ Script_column::add_staff_sided (Grob *me, Item *i) me->add_dependency (i); } -LY_DEFINE(grob_script_priority_less, - "ly:grob-script-priority-less", 2, 0, 0, - (SCM a, SCM b), +LY_DEFINE (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.") { - Grob * i1 = unsmob_grob (a); - Grob* i2 = unsmob_grob (b); + Grob *i1 = unsmob_grob (a); + Grob *i2 = unsmob_grob (b); SCM p1 = i1->get_property ("script-priority"); SCM p2 = i2->get_property ("script-priority"); @@ -37,9 +36,7 @@ LY_DEFINE(grob_script_priority_less, return gh_scm2int (p1) < gh_scm2int (p2) ? SCM_BOOL_T : SCM_BOOL_F; } - - -MAKE_SCHEME_CALLBACK (Script_column,before_line_breaking,1); +MAKE_SCHEME_CALLBACK (Script_column, before_line_breaking, 1); SCM Script_column::before_line_breaking (SCM smob) { @@ -47,15 +44,16 @@ Script_column::before_line_breaking (SCM smob) Drul_array scripts (SCM_EOL, SCM_EOL); Link_array staff_sided; - for (SCM s = me->get_property( "scripts"); gh_pair_p (s); s = gh_cdr( s)) + for (SCM s = me->get_property ("scripts"); gh_pair_p (s); s = gh_cdr (s)) { Grob *sc = unsmob_grob (gh_car (s)); - if (!sc->has_offset_callback (Side_position_interface::aligned_side_proc, X_AXIS)) + if (!sc->has_offset_callback (Side_position_interface::aligned_side_proc, + X_AXIS)) staff_sided.push (sc); } - for (int i=0; i < staff_sided.size (); i++) + for (int i = 0; i < staff_sided.size (); i++) { Grob* g = staff_sided[i]; Direction d = Side_position_interface::get_direction (g); @@ -66,32 +64,31 @@ Script_column::before_line_breaking (SCM smob) g->set_property ("direction", gh_int2scm (d)); } - scripts[d] = scm_cons (g->self_scm(), scripts[d]); + scripts[d] = scm_cons (g->self_scm (), scripts[d]); } Direction d = DOWN; - do { - SCM ss = scm_reverse_x (scripts[d], SCM_EOL); - ss = scm_stable_sort_x (ss, grob_script_priority_less_proc); - - Grob * last = 0; - for (SCM s = ss; gh_pair_p (s); s = gh_cdr (s)) - { - Grob* g = unsmob_grob (gh_car (s)); - if (last) - Side_position_interface::add_support (g,last); - - last = g; - } - - } while (flip (&d) != DOWN); + do + { + SCM ss = scm_reverse_x (scripts[d], SCM_EOL); + ss = scm_stable_sort_x (ss, grob_script_priority_less_proc); + + Grob * last = 0; + for (SCM s = ss; gh_pair_p (s); s = gh_cdr (s)) + { + Grob *g = unsmob_grob (gh_car (s)); + if (last) + Side_position_interface::add_support (g,last); + + last = g; + } + + } while (flip (&d) != DOWN); return SCM_UNSPECIFIED; } - ADD_INTERFACE (Script_column,"script-column-interface", - "An interface that sorts scripts according to their @code{script-priority}", - ""); - - + "An interface that sorts scripts " + "according to their @code{script-priority}", + ""); diff --git a/lily/staff-symbol-referencer.cc b/lily/staff-symbol-referencer.cc index aa4749cb83..c8340ecb60 100644 --- a/lily/staff-symbol-referencer.cc +++ b/lily/staff-symbol-referencer.cc @@ -1,72 +1,70 @@ -/* +/* staff-symbol-referencer.cc -- implement Staff_symbol_referencer - + source file of the GNU LilyPond music typesetter - + (c) 1999--2004 Han-Wen Nienhuys - */ +*/ #include #include "staff-symbol-referencer.hh" #include "staff-symbol.hh" #include "paper-def.hh" -#include "libc-extension.hh" +#include "libc-extension.hh" int -Staff_symbol_referencer::line_count (Grob*me) +Staff_symbol_referencer::line_count (Grob *me) { - Grob *st = get_staff_symbol (me); - return st ? Staff_symbol::line_count (st) : 0; + Grob *st = get_staff_symbol (me); + return st ? Staff_symbol::line_count (st) : 0; } bool -Staff_symbol_referencer::on_staffline (Grob*me) +Staff_symbol_referencer::on_staffline (Grob *me) { return on_staffline (me, (int) rint (get_position (me))); } bool -Staff_symbol_referencer::on_staffline (Grob*me, int pos) +Staff_symbol_referencer::on_staffline (Grob *me, int pos) { - int sz = line_count (me)-1; + int sz = line_count (me) - 1; return ((pos + sz) % 2) == 0; } Grob* -Staff_symbol_referencer::get_staff_symbol (Grob*me) +Staff_symbol_referencer::get_staff_symbol (Grob *me) { SCM st = me->get_property ("staff-symbol"); return unsmob_grob (st); } Real -Staff_symbol_referencer::staff_space (Grob*me) +Staff_symbol_referencer::staff_space (Grob *me) { - Grob * st = get_staff_symbol (me); + Grob *st = get_staff_symbol (me); if (st) return Staff_symbol::staff_space (st); - return 1.0; } Real -Staff_symbol_referencer::line_thickness (Grob*me) +Staff_symbol_referencer::line_thickness (Grob *me) { - Grob * st = get_staff_symbol (me); + Grob *st = get_staff_symbol (me); if (st) return Staff_symbol::get_line_thickness (st); - return me->get_paper ()->get_realvar (ly_symbol2scm ("linethickness")); } Real -Staff_symbol_referencer::get_position (Grob*me) +Staff_symbol_referencer::get_position (Grob *me) { - Real p =0.0; - Grob * st = get_staff_symbol (me); - Grob * c = st ? me->common_refpoint (st, Y_AXIS) : 0; + Real p = 0.0; + Grob *st = get_staff_symbol (me); + Grob *c = st ? me->common_refpoint (st, Y_AXIS) : 0; if (st && c) { Real y = me->relative_coordinate (c, Y_AXIS) @@ -76,16 +74,15 @@ Staff_symbol_referencer::get_position (Grob*me) return p; } - return robust_scm2double ( me->get_property ("staff-position"), p); + return robust_scm2double (me->get_property ("staff-position"), p); } -LY_DEFINE(ly_grob_staff_position, - "ly:grob-staff-position", - 1, 0,0, (SCM sg), - "Return the Y-position of this grob relative to the staff.") +LY_DEFINE (ly_grob_staff_position, "ly:grob-staff-position", + 1, 0,0, (SCM sg), + "Return the Y-position of this grob relative to the staff.") { - Grob * g = unsmob_grob (sg); + Grob *g = unsmob_grob (sg); SCM_ASSERT_TYPE (g, sg, SCM_ARG1, __FUNCTION__, "grob"); Real pos = Staff_symbol_referencer::get_position (g); @@ -97,9 +94,7 @@ LY_DEFINE(ly_grob_staff_position, } -/* - should use offset callback! - */ +/* should use offset callback! */ MAKE_SCHEME_CALLBACK (Staff_symbol_referencer,callback,2); SCM Staff_symbol_referencer::callback (SCM element_smob, SCM) @@ -107,74 +102,64 @@ Staff_symbol_referencer::callback (SCM element_smob, SCM) Grob *me = unsmob_grob (element_smob); SCM pos = me->get_property ("staff-position"); - Real off =0.0; + Real off = 0.0; if (gh_number_p (pos)) { Real space = Staff_symbol_referencer::staff_space (me); - off = gh_scm2double (pos) * space/2.0; + off = gh_scm2double (pos) * space / 2.0; me->set_property ("staff-position", gh_int2scm (0)); } return gh_double2scm (off); } - /* - - This sets the position relative to the center of the staff symbol. - - The function is hairy, because it can be callled in two situations: - - 1. There is no staff yet; we must set staff-position - - 2. There is a staff, and perhaps someone even applied a - translate_axis (). Then we must compensate for the translation - - In either case, we set a callback to be sure that our new position - will be extracted from staff-position - - */ +/* This sets the position relative to the center of the staff symbol. + +The function is hairy, because it can be callled in two situations: + +1. There is no staff yet; we must set staff-position + +2. There is a staff, and perhaps someone even applied a +translate_axis (). Then we must compensate for the translation + +In either case, we set a callback to be sure that our new position +will be extracted from staff-position */ + void -Staff_symbol_referencer::set_position (Grob*me,Real p) +Staff_symbol_referencer::set_position (Grob *me, Real p) { - Grob * st = get_staff_symbol (me); + Grob *st = get_staff_symbol (me); if (st && me->common_refpoint (st, Y_AXIS)) { Real oldpos = get_position (me); me->set_property ("staff-position", gh_double2scm (p - oldpos)); } else - { - me->set_property ("staff-position", - gh_double2scm (p)); + me->set_property ("staff-position", gh_double2scm (p)); - } - - if (me->has_offset_callback (Staff_symbol_referencer::callback_proc, Y_AXIS)) - return ; - - me->add_offset_callback (Staff_symbol_referencer::callback_proc, Y_AXIS); + if (!me->has_offset_callback (Staff_symbol_referencer::callback_proc, + Y_AXIS)) + me->add_offset_callback (Staff_symbol_referencer::callback_proc, Y_AXIS); } -/* - Half of the height, in staff space, i.e. 2.0 for a normal staff. -*/ +/* Half of the height, in staff space, i.e. 2.0 for a normal staff. */ Real -Staff_symbol_referencer::staff_radius (Grob*me) +Staff_symbol_referencer::staff_radius (Grob *me) { - return (line_count (me) -1) / 2.0; + return (line_count (me) - 1) / 2.0; } - int -compare_position (Grob *const &a, Grob * const &b) +compare_position (Grob *const &a, Grob *const &b) { - return sign (Staff_symbol_referencer::get_position ((Grob*)a) - - Staff_symbol_referencer::get_position ((Grob*)b)); + return sign (Staff_symbol_referencer::get_position ((Grob*)a) + - Staff_symbol_referencer::get_position ((Grob*) b)); } ADD_INTERFACE (Staff_symbol_referencer,"staff-symbol-referencer-interface", "An object whose Y position is meant relative to a staff " - "symbol. These usually have " - "@code{Staff_symbol_referencer::callback} in their @code{Y-offset-callbacks}. " + "symbol. " + "These usually have @code{Staff_symbol_referencer::callback} " + "in their @code{Y-offset-callbacks}. " , "staff-position"); diff --git a/lily/stencil-scheme.cc b/lily/stencil-scheme.cc index eb28d72152..b4e92ffae2 100644 --- a/lily/stencil-scheme.cc +++ b/lily/stencil-scheme.cc @@ -9,8 +9,9 @@ #include "font-metric.hh" #include "stencil.hh" -LY_DEFINE (ly_stencil_set_extent_x,"ly:stencil-set-extent!", 3 , 0, 0, - (SCM stil, SCM axis, SCM np), + +LY_DEFINE (ly_stencil_set_extent_x,"ly:stencil-set-extent!", + 3, 0, 0, (SCM stil, SCM axis, SCM np), "Set the extent of @var{stil} " "(@var{extent} must be a pair of numbers) " "in @var{axis} direction (0 or 1 for x- and y-axis respectively).") @@ -26,8 +27,8 @@ LY_DEFINE (ly_stencil_set_extent_x,"ly:stencil-set-extent!", 3 , 0, 0, return SCM_UNDEFINED; } -LY_DEFINE (ly_translate_stencil_axis,"ly:stencil-translate-axis", 3, 0, 0, - (SCM stil, SCM amount, SCM axis), +LY_DEFINE (ly_translate_stencil_axis, "ly:stencil-translate-axis", + 3, 0, 0, (SCM stil, SCM amount, SCM axis), "Return a @var{stil}, " "but translated by @var{amount} in @var{axis} direction.") { @@ -42,8 +43,8 @@ LY_DEFINE (ly_translate_stencil_axis,"ly:stencil-translate-axis", 3, 0, 0, return q.smobbed_copy(); } -LY_DEFINE (ly_translate_stencil,"ly:stencil-translate", 2, 0, 0, - (SCM stil, SCM offset), +LY_DEFINE (ly_translate_stencil,"ly:stencil-translate", + 2, 0, 0, (SCM stil, SCM offset), "Return a @var{stil}, " "but translated by @var{offset} (a pair of numbers).") { @@ -51,14 +52,14 @@ LY_DEFINE (ly_translate_stencil,"ly:stencil-translate", 2, 0, 0, SCM_ASSERT_TYPE (s, stil, SCM_ARG1, __FUNCTION__, "stencil"); SCM_ASSERT_TYPE (is_number_pair (offset), offset, SCM_ARG2, __FUNCTION__, "number pair"); Offset o = ly_scm2offset (offset); - + Stencil q (*s); q.translate (o); return q.smobbed_copy(); } -LY_DEFINE (ly_stencil_get_expr, - "ly:stencil-get-expr", 1 , 0, 0, (SCM stil), +LY_DEFINE (ly_stencil_get_expr, "ly:stencil-get-expr", + 1 , 0, 0, (SCM stil), "Return the expression of @var{stil}.") { Stencil *s = unsmob_stencil (stil); @@ -74,7 +75,7 @@ LY_DEFINE (ly_stencil_get_extent, Stencil *s = unsmob_stencil (stil); SCM_ASSERT_TYPE (s, stil, SCM_ARG1, __FUNCTION__, "stencil"); SCM_ASSERT_TYPE (is_axis (axis), axis, SCM_ARG2, __FUNCTION__, "axis"); - + return ly_interval2scm (s->extent (Axis (gh_scm2int (axis)))); } @@ -110,7 +111,7 @@ LY_DEFINE (ly_stencil_combined_at_edge, SCM_ASSERT_TYPE(gh_number_p (minimum), minimum, SCM_ARG6, __FUNCTION__, "number"); m = gh_scm2double (minimum); } - + if (s1) result = *s1; if (s2) @@ -121,7 +122,7 @@ LY_DEFINE (ly_stencil_combined_at_edge, } /* FIXME: support variable number of arguments. */ -LY_DEFINE (ly_stencil_add , +LY_DEFINE (ly_stencil_add , "ly:stencil-add", 0, 0, 1, (SCM args), "Combine stencils. Takes any number of arguments.") { @@ -139,7 +140,7 @@ LY_DEFINE (ly_stencil_add , result.add_stencil (*s); args = gh_cdr (args); } - + return result.smobbed_copy (); } @@ -154,7 +155,7 @@ LY_DEFINE (ly_make_stencil, "2: the vertical and horizontal extents of the object.\n\n") { SCM_ASSERT_TYPE (is_number_pair (xext), xext, SCM_ARG2, __FUNCTION__, "number pair"); - SCM_ASSERT_TYPE (is_number_pair (yext), yext, SCM_ARG3, __FUNCTION__, "number pair"); + SCM_ASSERT_TYPE (is_number_pair (yext), yext, SCM_ARG3, __FUNCTION__, "number pair"); Box b (ly_scm2interval (xext), ly_scm2interval(yext)); Stencil s (b, expr); @@ -171,7 +172,7 @@ fontify_atom (Font_metric const *met, SCM f) ly_quote_scm (met->description_), f, SCM_UNDEFINED); } -LY_DEFINE (ly_fontify_atom,"ly:fontify-atom", 2, 0, 0, +LY_DEFINE (ly_fontify_atom,"ly:fontify-atom", 2, 0, 0, (SCM met, SCM f), "Add a font selection command for the font metric @var{met} " "to @var{f}.") @@ -181,8 +182,8 @@ LY_DEFINE (ly_fontify_atom,"ly:fontify-atom", 2, 0, 0, return fontify_atom (unsmob_metrics (met), f); } -LY_DEFINE (ly_align_to_x,"ly:stencil-align-to!", 3, 0, 0, - (SCM stil, SCM axis, SCM dir), +LY_DEFINE (ly_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. " "Other values are interpolated (so 0 means the center. ") @@ -193,6 +194,5 @@ LY_DEFINE (ly_align_to_x,"ly:stencil-align-to!", 3, 0, 0, unsmob_stencil (stil)->align_to ((Axis)gh_scm2int (axis), gh_scm2double (dir)); - return SCM_UNDEFINED; } diff --git a/lily/translator-scheme.cc b/lily/translator-scheme.cc index 5ec875cc11..1129a7b99a 100644 --- a/lily/translator-scheme.cc +++ b/lily/translator-scheme.cc @@ -1,6 +1,6 @@ -/* +/* translator-scheme.cc -- implement Scheme context functions - + source file of the GNU LilyPond music typesetter (c) 2002--2004 Han-Wen Nienhuys @@ -9,46 +9,37 @@ #include "translator.hh" #include "context-def.hh" - #include "translator-group.hh" #include "lily-guile.hh" - - -LY_DEFINE(ly_translator_name, - "ly:translator-name", 1,0,0, (SCM trans), - "Return the type name of the translator object @var{trans}. The name is a symbol.") +LY_DEFINE (ly_translator_name, "ly:translator-name", + 1, 0, 0, (SCM trans), + "Return the type name of the translator object @var{trans}. " + "The name is a symbol.") { - Translator * tr = unsmob_translator (trans); - SCM_ASSERT_TYPE(tr, trans, SCM_ARG1, __FUNCTION__, "Translator"); - - char const* nm = classname (tr); + Translator *tr = unsmob_translator (trans); + SCM_ASSERT_TYPE (tr, trans, SCM_ARG1, __FUNCTION__, "Translator"); + char const *nm = classname (tr); return ly_symbol2scm (nm); } - -LY_DEFINE(ly_translator_description, - "ly:translator-description", +LY_DEFINE (ly_translator_description, "ly:translator-description", 1,0,0, (SCM me), "Return an alist of properties of translator @var{me}.") { - Translator *tr =unsmob_translator (me); + Translator *tr = unsmob_translator (me); SCM_ASSERT_TYPE (tr, me, SCM_ARG1, __FUNCTION__, "Translator"); - return tr->translator_description (); } - int Translator::print_smob (SCM s, SCM port, scm_print_state *) { - Translator *sc = (Translator *) ly_cdr (s); - + Translator *sc = (Translator*) ly_cdr (s); scm_puts ("#", port); - return 1; } diff --git a/stepmake/stepmake/c++-vars.make b/stepmake/stepmake/c++-vars.make index 09b9ad958e..40d03d1aa0 100644 --- a/stepmake/stepmake/c++-vars.make +++ b/stepmake/stepmake/c++-vars.make @@ -19,5 +19,6 @@ ALL_CC_SOURCES += $(HH_FILES) $(INL_FILES) $(CC_FILES) $(YY_FILES) $(LL_FILES) O_FILES+=$(addprefix $(outdir)/, $(CC_FILES:.cc=.o) $(LL_FILES:.ll=.o) $(YY_FILES:.yy=.o)) -TAGS_FILES += $(TCC_FILES) $(HH_FILES) $(INL_FILES) $(CC_FILES) $(YY_FILES) $(LL_FILES) +TAGS_SOURCES += $(TCC_FILES) $(INL_FILES) $(CC_FILES) $(YY_FILES) $(LL_FILES) +TAGS_HEADERS += $(HH_FILES) $(INL_FILES) diff --git a/stepmake/stepmake/c-vars.make b/stepmake/stepmake/c-vars.make index 2637bf2332..765ab367cb 100644 --- a/stepmake/stepmake/c-vars.make +++ b/stepmake/stepmake/c-vars.make @@ -9,7 +9,8 @@ SOURCE_FILES+=$(Y_FILES) $(C_FILES) $(L_FILES) $(H_FILES) O_FILES+=$(addprefix $(outdir)/, $(Y_FILES:.y=.o) $(C_FILES:.c=.o) $(L_FILES:.l=.o)) -TAGS_FILES += $(C_FILES) $(H_FILES) +TAGS_SOURCES += $(C_FILES) +TAGS_HEADERS += $(H_FILES) ALL_C_SOURCES += $(H_FILES) $(C_FILES) $(Y_FILES) $(L_FILES) diff --git a/stepmake/stepmake/generic-targets.make b/stepmake/stepmake/generic-targets.make index 603ffa1375..deb74de3db 100644 --- a/stepmake/stepmake/generic-targets.make +++ b/stepmake/stepmake/generic-targets.make @@ -88,12 +88,17 @@ local-dist: $(DIST_FILES) $(OUT_DIST_FILES) $(NON_ESSENTIAL_DIST_FILES) html: $(HTML_FILES) TAGS: - -if [ "$(TAGS_FILES)" != "" ]; then \ - etags $(ETAGS_FLAGS) $(TAGS_FILES) || \ - ctags $(CTAGS_FLAGS) ".h.hh.tcc.icc" $(TAGS_FILES) $(ERROR_LOG); \ - fi - $(LOOP) + $(MAKE) local-tags + +DEEPER_TAGS_FILES = $(shell find $(pwd) -mindepth 2 -name 'TAGS') +local-tags: + -if [ -n "$(TAGS_HEADERS)$(TAGS_SOURCES)$(DEEPER_TAGS_FILES)" ]; then \ + etags $(ETAGS_FLAGS) $(DEEPER_TAGS_FILES:%=--include=%) \ + $(TAGS_SOURCES) $(TAGS_HEADERS) $(ERROR_LOG) ; \ + ctags $(CTAGS_FLAGS) $(TAGS_SOURCES) $(TAGS_HEADERS) \ + $(ERROR_LOG) ; \ + fi $(outdir)/version.hh: $(depth)/VERSION $(config_make) $(PYTHON) $(step-bindir)/make-version.py $< > $@ diff --git a/stepmake/stepmake/generic-vars.make b/stepmake/stepmake/generic-vars.make index 117afbfdc9..01f32a6256 100644 --- a/stepmake/stepmake/generic-vars.make +++ b/stepmake/stepmake/generic-vars.make @@ -96,9 +96,8 @@ STRIP=strip --strip-debug DO_STRIP=true LOOP=$(foreach i, $(SUBDIRS), $(MAKE) PACKAGE=$(PACKAGE) package=$(package) -C $(i) $@ &&) true -# different redhat releases need different flags for etags. Just use defaults. -ETAGS_FLAGS= # -CT -CTAGS_FLAGS=-h +ETAGS_FLAGS = +CTAGS_FLAGS = makeflags=$(patsubst %==, %, $(patsubst ---%,,$(patsubst ----%,,$(MAKEFLAGS:%=--%)))) diff --git a/stepmake/stepmake/scm-vars.make b/stepmake/stepmake/scm-vars.make index 115a05fb18..9a53ec0723 100644 --- a/stepmake/stepmake/scm-vars.make +++ b/stepmake/stepmake/scm-vars.make @@ -3,5 +3,5 @@ SCM_FILES := $(wildcard *.scm) SOURCE_FILES += $(SCM_FILES) -TAGS_FILES += $(SCM_FILES) +TAGS_SOURCES += $(SCM_FILES) -- 2.39.2