From f23f64a82826003dd5555c8405610531fa3f9fd0 Mon Sep 17 00:00:00 2001 From: janneke Date: Wed, 24 Jul 2002 16:11:10 +0000 Subject: [PATCH] Update to new system-count function names. Use LY_DEFINE. Remove DECLARE_SCHEME_CALLBACKs. --- ChangeLog | 11 ++++ .../J.S.Bach/baerenreiter-sarabande.ly | 25 +++++++- input/test/count-systems.ly | 12 ++-- lily/grob.cc | 63 ++++++++++++++----- lily/include/duration.hh | 3 +- lily/include/grob.hh | 33 +--------- lily/include/spanner.hh | 3 +- lily/spanner.cc | 32 +++++----- 8 files changed, 107 insertions(+), 75 deletions(-) diff --git a/ChangeLog b/ChangeLog index da93cbba21..e972ce915d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,17 @@ 2002-07-24 Jan Nieuwenhuizen + * input/mutopia/J.S.Bach/baerenreiter-sarabande.ly: * + input/test/count-systems.ly: Update to new system-count function + names. + + * lily/grob.cc (get_line, get_original): Use LY_DEFINE. + + * lily/spanner.cc (get_broken_into): Use LY_DEFINE. + + * lily/include/spanner.hh: + * lily/include/grob.hh: Remove DECLARE_SCHEME_CALLBACKs. + * input/mutopia/J.S.Bach/baerenreiter-sarabande.ly: Add forcedBreak options and fix measure count comments. diff --git a/input/mutopia/J.S.Bach/baerenreiter-sarabande.ly b/input/mutopia/J.S.Bach/baerenreiter-sarabande.ly index c6e1724e45..2c08b7e058 100644 --- a/input/mutopia/J.S.Bach/baerenreiter-sarabande.ly +++ b/input/mutopia/J.S.Bach/baerenreiter-sarabande.ly @@ -1,11 +1,25 @@ #(set! point-and-click line-column-location) -forcedBreak = \notes { } -%%forcedBreak = \notes { \break } +%%forcedBreak = \notes { } +forcedBreak = \notes { \break } forcedLastBreak = \notes { \break } %%forcedLastBreak = \notes { } +%% We want this to perfectly match the Baerenreiter spacing. +%% If we're not using 6 systems, there's definately a problem. +#(define (assert-system-count smob n) + (let ((systems (length (get-broken-into + (get-original + (get-line smob)))))) + (if (not (equal? n systems)) + ;; Can't use error yet, as we know that we're not using 6... + ;;(error + (warn + (string-append "Got " (number->string systems) + " systems (expecting " (number->string n)))))) + + \header { title = "Solo Cello Suite II" piece ="Sarabande" @@ -112,7 +126,12 @@ sarabandeA = \context Voice \notes \relative c { [a,8 e'] \oneVoice [d' cis] | - d4 d,,2 | + %% d4 d,,2 | + d4 + \property Thread.NoteHead + \override #'after-line-breaking-callback + = #(lambda (smob) (assert-system-count smob 6.1)) + d,,2 | } diff --git a/input/test/count-systems.ly b/input/test/count-systems.ly index 5869fcad6f..c7f4ba6130 100644 --- a/input/test/count-systems.ly +++ b/input/test/count-systems.ly @@ -7,9 +7,9 @@ } #(define (display-systemno smob) - (let* ((this-line (Grob::line_scm smob)) - (systems (Spanner::get_broken_into - (Grob::original_scm this-line)))) + (let* ((this-line (get-line smob)) + (systems (get-broken-into + (get-original this-line)))) (display smob) (display (list-index systems this-line)) (newline))) @@ -17,9 +17,9 @@ #(define (display-system-count smob) (display (length - (Spanner::get_broken_into - (Grob::original_scm - (Grob::line_scm smob)))))) + (get-broken-into + (get-original + (get-line smob)))))) diff --git a/lily/grob.cc b/lily/grob.cc index f4cb9937b1..76e2503745 100644 --- a/lily/grob.cc +++ b/lily/grob.cc @@ -308,26 +308,32 @@ Grob::line_l () const return 0; } -MAKE_SCHEME_CALLBACK (Grob, line_scm, 1); -SCM -Grob::line_scm (SCM smob) -{ - Grob *me = unsmob_grob (smob); +LY_DEFINE (get_line, + "get-line", + 1, 0, 0, (SCM grob), + " +Return the Line Grob of @var{grob}. +") +{ + Grob *me = unsmob_grob (grob); + SCM_ASSERT_TYPE (me, grob, SCM_ARG1, __FUNCTION__, "grob"); + if (Grob *g = me->line_l ()) return g->self_scm (); - + return SCM_EOL; } -MAKE_SCHEME_CALLBACK (Grob, original_scm, 1); -SCM -Grob::original_scm (SCM smob) +LY_DEFINE (get_original, + "get-original", + 1, 0, 0, (SCM grob), + " +Return the original Grob of @var{grob} +") { - Grob *me = unsmob_grob (smob); - if (me->original_l_) - return me->original_l_->self_scm (); - - return SCM_EOL; + Grob *me = unsmob_grob (grob); + SCM_ASSERT_TYPE (me, grob, SCM_ARG1, __FUNCTION__, "grob"); + return me->original_l_ ? me->original_l_->self_scm () : me->self_scm (); } void @@ -799,6 +805,35 @@ Grob::internal_has_interface (SCM k) return scm_memq (k, ifs) != SCM_BOOL_F; } + +/** Return Array of Grobs in SCM list L */ +Link_array +ly_scm2grob_array (SCM l) +{ + Link_array arr; + + for (SCM s = l; gh_pair_p (s); s = gh_cdr (s)) + { + SCM e = gh_car (s); + arr.push (unsmob_grob (e)); + } + + arr.reverse (); + return arr; +} + +/** Return SCM list of Grob array A */ +SCM +ly_grob_array2scm (Link_array a) +{ + SCM s = SCM_EOL; + for (int i = a.size (); i; i--) + s = gh_cons (a[i-1]->self_scm (), s); + + return s; +} + + IMPLEMENT_TYPE_P (Grob, "ly-grob?"); ADD_INTERFACE (Grob, "grob-interface", diff --git a/lily/include/duration.hh b/lily/include/duration.hh index 654db0db8b..f301fe296a 100644 --- a/lily/include/duration.hh +++ b/lily/include/duration.hh @@ -46,8 +46,7 @@ private: #include "compare.hh" INSTANTIATE_COMPARE (Duration, Duration::compare); -DECLARE_UNSMOB(Duration,duration); - +DECLARE_UNSMOB (Duration, duration); #endif // DURATION_HH diff --git a/lily/include/grob.hh b/lily/include/grob.hh index bc62ac7e25..6c3ef633c1 100644 --- a/lily/include/grob.hh +++ b/lily/include/grob.hh @@ -154,8 +154,6 @@ public: Grob *get_parent (Axis a) const { return dim_cache_[a].parent_l_; } DECLARE_SCHEME_CALLBACK (fixup_refpoint, (SCM)); - DECLARE_SCHEME_CALLBACK (original_scm, (SCM smob)); - DECLARE_SCHEME_CALLBACK (line_scm, (SCM smob)); }; DECLARE_UNSMOB(Grob,grob); @@ -168,35 +166,8 @@ Grob*common_refpoint_of_array (Link_array const&, Grob * , Axis a); void set_break_subsititution (SCM criterion); SCM substitute_mutable_property_alist (SCM alist); - -/** Return Array of Grobs in SCM list L */ -inline Link_array -ly_scm2grob_array (SCM l) -{ - Link_array arr; - - for (SCM s = l; gh_pair_p (s); s = gh_cdr (s)) - { - SCM e = gh_car (s); - arr.push (unsmob_grob (e)); - } - - arr.reverse (); - return arr; -} - -#if 0 -/** Return SCM list of Grob array A */ -inline SCM -ly_grob_array2scm (Link_array a) -{ - SCM s = SCM_EOL; - for (int i = a.size (); i; i--) - s = gh_cons (a[i-1]->self_scm (), s); - - return s; -} -#endif +Link_array ly_scm2grob_array (SCM l); +SCM ly_grob_array2scm (Link_array a); #endif // STAFFELEM_HH diff --git a/lily/include/spanner.hh b/lily/include/spanner.hh index cc0bd57753..9ea2df7870 100644 --- a/lily/include/spanner.hh +++ b/lily/include/spanner.hh @@ -34,7 +34,6 @@ class Spanner : public Grob { public: DECLARE_SCHEME_CALLBACK (set_spacing_rods, (SCM)); - DECLARE_SCHEME_CALLBACK (get_broken_into, (SCM)); Link_array broken_into_l_arr_; @@ -66,6 +65,6 @@ protected: void add_bound_item (Spanner*, Grob*); - +///DECLARE_UNSMOB (Spanner, spanner); #endif diff --git a/lily/spanner.cc b/lily/spanner.cc index 7cae376694..9b2f30fcbc 100644 --- a/lily/spanner.cc +++ b/lily/spanner.cc @@ -19,24 +19,22 @@ #include "system.hh" #include "group-interface.hh" - -MAKE_SCHEME_CALLBACK (Spanner, get_broken_into, 1); -SCM -Spanner::get_broken_into (SCM smob) +/* spanner in name? */ +LY_DEFINE (get_broken_into, + "get-broken-into", 1, 0, 0, (SCM spanner), + " +Return broken-into list for @var{spanner}. +" +) { - if (Spanner *me = dynamic_cast (unsmob_grob (smob))) -#if 0 - return ly_grob_array2scm (me->broken_into_l_arr_); -#else - { - SCM s = SCM_EOL; - for (int i = me->broken_into_l_arr_.size (); i; i--) - s = gh_cons (me->broken_into_l_arr_[i-1]->self_scm (), s); - return s; - } -#endif - - return SCM_EOL; + /// Spanner *me = unsmob_spanner (spanner); + Spanner *me = dynamic_cast (unsmob_grob (spanner)); + SCM_ASSERT_TYPE (me, spanner, SCM_ARG1, __FUNCTION__, "spanner"); + + SCM s = SCM_EOL; + for (int i = me->broken_into_l_arr_.size (); i; i--) + s = gh_cons (me->broken_into_l_arr_[i-1]->self_scm (), s); + return s; } void -- 2.39.5