From c3ff3d74ca155bac9f4676f172a7daa7af0ae5d1 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Tue, 19 Jul 2005 00:41:14 +0000 Subject: [PATCH] * lily/include/translator.icc (IMPLEMENT_FETCH_PRECOMPUTABLE_METHODS): directly jump into Translator methods, without _static helper. * lily/grob-smob.cc (derived_mark): rename from do_derived_mark(). Don't return SCM. * lily/item.cc (handle_prebroken_dependencies): use a vector of 3 booleans for break-visibility. * lily/include/translator.icc: new file. * lily/include/translator.hh (class Translator): rename process_acknowledged_grobs() to process_acknowledged() and move to Translator. * lily/note-head.cc (internal_print): only call glyph-name-procedure if style != default. 3 % speed increase (wtk2-fugue1). --- ChangeLog | 7 +++++++ lily/dynamic-performer.cc | 22 +++++++++++----------- lily/grob-smob.cc | 11 ++++------- lily/include/grob.hh | 2 +- lily/include/item.hh | 2 +- lily/include/spanner.hh | 2 +- lily/include/system.hh | 2 +- lily/include/translator.hh | 5 ----- lily/include/translator.icc | 28 ++++------------------------ lily/item.cc | 5 ++--- lily/note-head.cc | 23 +++++++++-------------- lily/spanner.cc | 13 ++----------- lily/system.cc | 6 +++--- 13 files changed, 46 insertions(+), 82 deletions(-) diff --git a/ChangeLog b/ChangeLog index 63eb492617..0d5d1f35b2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 2005-07-19 Han-Wen Nienhuys + * lily/include/translator.icc + (IMPLEMENT_FETCH_PRECOMPUTABLE_METHODS): directly jump into + Translator methods, without _static helper. + + * lily/grob-smob.cc (derived_mark): rename from + do_derived_mark(). Don't return SCM. + * scm/define-context-properties.scm (all-internal-translation-properties): remove tweakCount/tweakRank. diff --git a/lily/dynamic-performer.cc b/lily/dynamic-performer.cc index b264e72edd..e39ea70593 100644 --- a/lily/dynamic-performer.cc +++ b/lily/dynamic-performer.cc @@ -10,6 +10,8 @@ #include "audio-item.hh" #include "music.hh" +#include "translator.icc" + /* TODO: @@ -23,25 +25,25 @@ class Dynamic_performer : public Performer public: TRANSLATOR_DECLARATIONS (Dynamic_performer); protected: - virtual bool try_music (Music *req); + virtual bool try_music (Music *event); PRECOMPUTED_VIRTUAL void stop_translation_timestep (); virtual void create_audio_elements (); private: - Music *script_req_; + Music *script_event_; Audio_dynamic *audio_; }; Dynamic_performer::Dynamic_performer () { - script_req_ = 0; + script_event_ = 0; audio_ = 0; } void Dynamic_performer::create_audio_elements () { - if (script_req_) + if (script_event_) { SCM proc = get_property ("dynamicAbsoluteVolumeFunction"); @@ -49,7 +51,7 @@ Dynamic_performer::create_audio_elements () if (ly_is_procedure (proc)) { // urg - svolume = scm_call_1 (proc, script_req_->get_property ("text")); + svolume = scm_call_1 (proc, script_event_->get_property ("text")); } Real volume = robust_scm2double (svolume, 0.5); @@ -95,9 +97,9 @@ Dynamic_performer::create_audio_elements () } audio_ = new Audio_dynamic (volume); - Audio_element_info info (audio_, script_req_); + Audio_element_info info (audio_, script_event_); announce_element (info); - script_req_ = 0; + script_event_ = 0; } } @@ -114,19 +116,17 @@ Dynamic_performer::stop_translation_timestep () bool Dynamic_performer::try_music (Music *r) { - if (!script_req_) + if (!script_event_) { if (r->is_mus_type ("absolute-dynamic-event")) // fixme. { - script_req_ = r; + script_event_ = r; return true; } } return false; } -#include "translator.icc" - ADD_TRANSLATOR (Dynamic_performer, /*descr*/ "", /* creats*/ "", diff --git a/lily/grob-smob.cc b/lily/grob-smob.cc index 556b68bedb..836d42c4c9 100644 --- a/lily/grob-smob.cc +++ b/lily/grob-smob.cc @@ -16,6 +16,7 @@ IMPLEMENT_SMOBS (Grob); IMPLEMENT_DEFAULT_EQUAL_P (Grob); +IMPLEMENT_TYPE_P (Grob, "ly:grob?"); SCM Grob::mark_smob (SCM ses) @@ -45,7 +46,7 @@ Grob::mark_smob (SCM ses) if (s->pscore_) scm_gc_mark (s->pscore_->self_scm ()); - s->do_derived_mark (); + s->derived_mark (); scm_gc_mark (s->object_alist_); scm_gc_mark (s->interfaces_); @@ -65,11 +66,7 @@ Grob::print_smob (SCM s, SCM port, scm_print_state *) return 1; } -SCM -Grob::do_derived_mark () const +void +Grob::derived_mark () const { - return SCM_EOL; } - -IMPLEMENT_TYPE_P (Grob, "ly:grob?"); - diff --git a/lily/include/grob.hh b/lily/include/grob.hh index 6b8d864449..111e4b3b0b 100644 --- a/lily/include/grob.hh +++ b/lily/include/grob.hh @@ -100,7 +100,7 @@ public: virtual void do_break_processing (); virtual Grob *find_broken_piece (System *) const; virtual void discretionary_processing (); - virtual SCM do_derived_mark () const; + virtual void derived_mark () const; Stencil *get_stencil () const; SCM get_uncached_stencil () const; diff --git a/lily/include/item.hh b/lily/include/item.hh index aa8bcb4b66..9b50af6db3 100644 --- a/lily/include/item.hh +++ b/lily/include/item.hh @@ -41,7 +41,7 @@ public: protected: virtual void discretionary_processing (); void copy_breakable_items (); - virtual SCM do_derived_mark () const; + virtual void derived_mark () const; }; #endif diff --git a/lily/include/spanner.hh b/lily/include/spanner.hh index b06c0a4cc0..d1042348e9 100644 --- a/lily/include/spanner.hh +++ b/lily/include/spanner.hh @@ -56,7 +56,7 @@ public: static int compare (Spanner *const &, Spanner *const &); virtual Grob *find_broken_piece (System *) const; - virtual SCM do_derived_mark () const; + virtual void derived_mark () const; static bool has_interface (Grob *); virtual System *get_system () const; diff --git a/lily/include/system.hh b/lily/include/system.hh index 18ef76e739..82d942d396 100644 --- a/lily/include/system.hh +++ b/lily/include/system.hh @@ -45,7 +45,7 @@ public: void pre_processing (); protected: - virtual SCM do_derived_mark () const; + virtual void derived_mark () const; virtual Grob *clone (int count) const; }; diff --git a/lily/include/translator.hh b/lily/include/translator.hh index 351149548c..af21e10ab9 100644 --- a/lily/include/translator.hh +++ b/lily/include/translator.hh @@ -20,13 +20,8 @@ typedef void (*Translator_void_method_ptr)(Translator*); -#define DECLARE_STATIC_METHOD(x) static void x ## _static (Translator*) #define TRANSLATOR_DECLARATIONS(NAME) \ public: \ - DECLARE_STATIC_METHOD(start_translation_timestep); \ - DECLARE_STATIC_METHOD(stop_translation_timestep); \ - DECLARE_STATIC_METHOD(process_music); \ - DECLARE_STATIC_METHOD(process_acknowledged); \ NAME (); \ VIRTUAL_COPY_CONSTRUCTOR (Translator, NAME); \ static SCM static_description_; \ diff --git a/lily/include/translator.icc b/lily/include/translator.icc index 5bffbf8d2a..ce57a3c4d6 100644 --- a/lily/include/translator.icc +++ b/lily/include/translator.icc @@ -29,7 +29,6 @@ ADD_GLOBAL_CTOR (_ ## T ## _adder); #define ADD_TRANSLATOR(classname, desc, grobs, accepted, acked, read, write) \ - DEFINE_STATIC_METHODS(classname);\ IMPLEMENT_FETCH_PRECOMPUTABLE_METHODS(classname); \ ADD_THIS_TRANSLATOR (classname); \ SCM \ @@ -59,25 +58,6 @@ return static_properties; \ } - -/* - FIXME: should be able to cast statically to (T*) -iow.- remove - Translator as a virtual base class. - */ -#define DEFINE_STATIC_METHOD(T, x) \ -void \ -T::x ## _static (Translator* tr) \ -{ \ - T * t_ptr = (T*) (tr); \ - t_ptr->x ();\ -} - -#define DEFINE_STATIC_METHODS(T) \ - DEFINE_STATIC_METHOD(T,start_translation_timestep)\ - DEFINE_STATIC_METHOD(T,stop_translation_timestep)\ - DEFINE_STATIC_METHOD(T,process_music)\ - DEFINE_STATIC_METHOD(T,process_acknowledged) - #define IMPLEMENT_FETCH_PRECOMPUTABLE_METHODS(T) \ void \ T::fetch_precomputable_methods (Translator_void_method_ptr ptrs[])\ @@ -86,22 +66,22 @@ T::fetch_precomputable_methods (Translator_void_method_ptr ptrs[])\ ((Translator_void_method_ptr) &T::start_translation_timestep == \ (Translator_void_method_ptr) &Translator::start_translation_timestep) \ ? 0 \ - : &T::start_translation_timestep_static; \ + : (Translator_void_method_ptr) &T::start_translation_timestep; \ \ ptrs[STOP_TRANSLATION_TIMESTEP] = \ ((Translator_void_method_ptr) &T::stop_translation_timestep == (Translator_void_method_ptr) &Translator::stop_translation_timestep) \ ? 0 \ - : &T::stop_translation_timestep_static; \ + : (Translator_void_method_ptr) &T::stop_translation_timestep; \ \ ptrs[PROCESS_MUSIC] = \ ((Translator_void_method_ptr) &T::process_music == (Translator_void_method_ptr) &Translator::process_music) \ ? 0 \ - : &T::process_music_static; \ + : (Translator_void_method_ptr) &T::process_music; \ \ ptrs[PROCESS_ACKNOWLEDGED] = \ ((Translator_void_method_ptr) &T::process_acknowledged == (Translator_void_method_ptr) &Translator::process_acknowledged) \ ? 0 \ - : &T::process_acknowledged_static; \ + : (Translator_void_method_ptr) &T::process_acknowledged; \ } diff --git a/lily/item.cc b/lily/item.cc index 922faf0abd..7e36b762d9 100644 --- a/lily/item.cc +++ b/lily/item.cc @@ -159,14 +159,13 @@ Item::handle_prebroken_dependencies () } } -SCM -Item::do_derived_mark () const +void +Item::derived_mark () const { if (broken_to_drul_[LEFT]) scm_gc_mark (broken_to_drul_[LEFT]->self_scm ()); if (broken_to_drul_[RIGHT]) scm_gc_mark (broken_to_drul_[RIGHT]->self_scm ()); - return SCM_EOL; } Item * diff --git a/lily/note-head.cc b/lily/note-head.cc index 796e01b3a3..a106fd2ab0 100644 --- a/lily/note-head.cc +++ b/lily/note-head.cc @@ -48,23 +48,18 @@ internal_print (Grob *me, String *font_char) Font_metric *fm = Font_interface::get_default_font (me); - Direction stem_dir = CENTER; - if (Grob *stem = unsmob_grob (me->get_object ("stem"))) - { - stem_dir = get_grob_direction (stem); - if (stem_dir == CENTER) - programming_error ("must have stem dir for note head"); - } + String idx = "noteheads.s" + suffix; - Stencil out; - - String prefix = "noteheads."; - String idx - = prefix + ((stem_dir == UP) ? "u" : "d") + suffix; - out = fm->find_by_name (idx); + Stencil out = fm->find_by_name (idx); if (out.is_empty ()) { - idx = prefix + "s" + suffix; + String prefix = "noteheads."; + Grob *stem = unsmob_grob (me->get_object ("stem")); + Direction stem_dir = stem ? get_grob_direction (stem) : CENTER; + + if (stem_dir == CENTER) + programming_error ("must have stem dir for note head"); + String idx = prefix + ((stem_dir == UP) ? "u" : "d") + suffix; out = fm->find_by_name (idx); } diff --git a/lily/spanner.cc b/lily/spanner.cc index 1909eee4fe..a015e0355b 100644 --- a/lily/spanner.cc +++ b/lily/spanner.cc @@ -288,16 +288,9 @@ Spanner::get_broken_left_end_align () const return 0.0; } -SCM -Spanner::do_derived_mark () const +void +Spanner::derived_mark () const { -#if 0 - /* - We'd be fucked if this is called before spanned_drul_[] is inited. */ - if (status_ == ORPHAN) - return SCM_EOL; -#endif - Direction d = LEFT; do if (spanned_drul_[d]) @@ -307,8 +300,6 @@ Spanner::do_derived_mark () const for (int i = broken_intos_.size (); i--;) scm_gc_mark (broken_intos_[i]->self_scm ()); - - return SCM_EOL; } /* diff --git a/lily/system.cc b/lily/system.cc index a69725d701..898e07871d 100644 --- a/lily/system.cc +++ b/lily/system.cc @@ -87,8 +87,8 @@ System::typeset_grob (Grob *elem) } } -SCM -System::do_derived_mark () const +void +System::derived_mark () const { if (!all_elements_->is_empty ()) { @@ -100,7 +100,7 @@ System::do_derived_mark () const ptr ++; } } - return Spanner::do_derived_mark (); + Spanner::derived_mark (); } static void -- 2.39.5