From: David Kastrup Date: Mon, 29 Sep 2014 18:11:48 +0000 (+0200) Subject: Issue 4141/1: Define inline members unsmob and is_smob for several derived classes X-Git-Tag: release/2.19.16-1~30 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=2558bbf111c416f0c7093f7f8a3129533310cf37;p=lilypond.git Issue 4141/1: Define inline members unsmob and is_smob for several derived classes --- diff --git a/lily/engraver.cc b/lily/engraver.cc index 76117a66e8..e6d3142b14 100644 --- a/lily/engraver.cc +++ b/lily/engraver.cc @@ -171,12 +171,6 @@ Engraver::internal_make_spanner (SCM x, SCM cause, char const *name, return sp; } -Engraver * -Engraver::unsmob (SCM eng) -{ - return dynamic_cast (Translator::unsmob (eng)); -} - bool ly_is_grob_cause (SCM obj) { diff --git a/lily/global-context.cc b/lily/global-context.cc index 94f8efa82f..9168f612a9 100644 --- a/lily/global-context.cc +++ b/lily/global-context.cc @@ -207,9 +207,3 @@ Global_context::get_default_interpreter (const string &/* context_id */) else return Context::get_default_interpreter (); } - -Global_context * -Global_context::unsmob (SCM x) -{ - return dynamic_cast (Context::unsmob (x)); -} diff --git a/lily/include/engraver.hh b/lily/include/engraver.hh index 2cb28292fc..77f55f0e48 100644 --- a/lily/include/engraver.hh +++ b/lily/include/engraver.hh @@ -65,7 +65,12 @@ public: override other ctor */ TRANSLATOR_DECLARATIONS (Engraver); - static Engraver *unsmob (SCM eng); + static Engraver *unsmob (SCM eng) { + return dynamic_cast (Translator::unsmob (eng)); + } + static bool is_smob (SCM eng) { + return Translator::is_smob (eng) && unsmob (eng); + } }; #define make_item(x, cause) internal_make_item (ly_symbol2scm (x), cause, x, __FILE__, __LINE__, __FUNCTION__) diff --git a/lily/include/global-context.hh b/lily/include/global-context.hh index 31e2190bc2..f940561739 100644 --- a/lily/include/global-context.hh +++ b/lily/include/global-context.hh @@ -48,7 +48,12 @@ public: virtual Moment now_mom () const; virtual Context *get_default_interpreter (const string &context_id = ""); - static Global_context *unsmob (SCM x); + static Global_context *unsmob (SCM x) { + return dynamic_cast (Context::unsmob (x)); + } + static bool is_smob (SCM x) { + return Context::is_smob (x) && unsmob (x); + } Moment previous_moment () const; protected: diff --git a/lily/include/item.hh b/lily/include/item.hh index ac945eac41..9342d6f981 100644 --- a/lily/include/item.hh +++ b/lily/include/item.hh @@ -36,7 +36,12 @@ public: Item (SCM); Item (Item const &); - static Item *unsmob (SCM); + static Item *unsmob (SCM g) { + return dynamic_cast (Grob::unsmob (g)); + } + static bool is_smob (SCM g) { + return Grob::is_smob (g) && unsmob (g); + } virtual Grob *clone () const; diff --git a/lily/include/music.hh b/lily/include/music.hh index e59f82c758..72b48859c2 100644 --- a/lily/include/music.hh +++ b/lily/include/music.hh @@ -47,7 +47,12 @@ public: Moment get_length () const; Moment start_mom () const; void print () const; - static Music *unsmob (SCM); + static Music *unsmob (SCM m) { + return dynamic_cast (Prob::unsmob (m)); + } + static bool is_smob (SCM m) { + return Prob::is_smob (m) && unsmob (m); + } /// Transpose, with the interval central C to #p# void transpose (Pitch p); diff --git a/lily/include/paper-score.hh b/lily/include/paper-score.hh index 05933d49f3..a919cebce0 100644 --- a/lily/include/paper-score.hh +++ b/lily/include/paper-score.hh @@ -39,7 +39,12 @@ public: DECLARE_CLASSNAME (Paper_score); - static Paper_score *unsmob (SCM); + static Paper_score *unsmob (SCM ps) { + return dynamic_cast (Music_output::unsmob (ps)); + } + static bool is_smob (SCM ps) { + return Music_output::is_smob (ps) && unsmob (ps); + } Output_def *layout () const; System *root_system () const; diff --git a/lily/include/performance.hh b/lily/include/performance.hh index f3093f82c5..2df4bb75c6 100644 --- a/lily/include/performance.hh +++ b/lily/include/performance.hh @@ -31,7 +31,12 @@ public: ~Performance (); DECLARE_CLASSNAME (Performance); - static Performance *unsmob (SCM); + static Performance *unsmob (SCM p) { + return dynamic_cast (Music_output::unsmob (p)); + } + static bool is_smob (SCM p) { + return Music_output::is_smob (p) && unsmob (p); + } void add_element (Audio_element *p); virtual void process (); diff --git a/lily/include/performer.hh b/lily/include/performer.hh index aa9b098d34..123713d3cb 100644 --- a/lily/include/performer.hh +++ b/lily/include/performer.hh @@ -33,7 +33,12 @@ public: VIRTUAL_COPY_CONSTRUCTOR (Translator, Performer); friend class Performer_group; Performer_group *get_daddy_performer () const; - static Performer *unsmob (SCM perf); + static Performer *unsmob (SCM perf) { + return dynamic_cast (Translator::unsmob (perf)); + } + static bool is_smob (SCM perf) { + return Translator::is_smob (perf) && unsmob (perf); + } protected: virtual void announce_element (Audio_element_info); diff --git a/lily/include/spanner.hh b/lily/include/spanner.hh index b56cc2264d..f618e9c58e 100644 --- a/lily/include/spanner.hh +++ b/lily/include/spanner.hh @@ -52,7 +52,12 @@ public: DECLARE_SCHEME_CALLBACK (bounds_width, (SCM)); DECLARE_SCHEME_CALLBACK (kill_zero_spanned_time, (SCM)); - static Spanner *unsmob (SCM); + static Spanner *unsmob (SCM s) { + return dynamic_cast (Grob::unsmob (s)); + } + static bool is_smob (SCM s) { + return Grob::is_smob (s) && unsmob (s); + } vector broken_intos_; diff --git a/lily/include/stream-event.hh b/lily/include/stream-event.hh index 14a8af41dc..8c56f16340 100644 --- a/lily/include/stream-event.hh +++ b/lily/include/stream-event.hh @@ -30,7 +30,12 @@ public: Stream_event (); VIRTUAL_COPY_CONSTRUCTOR (Stream_event, Stream_event); - static Stream_event *unsmob (SCM); + static Stream_event *unsmob (SCM s) { + return dynamic_cast (Prob::unsmob (s)); + } + static bool is_smob (SCM s) { + return Prob::is_smob (s) && unsmob (s); + } Stream_event (SCM event_class, SCM immutable_props = SCM_EOL); Stream_event (SCM class_name, Input *); diff --git a/lily/item.cc b/lily/item.cc index bcde47616d..ec5c943f2a 100644 --- a/lily/item.cc +++ b/lily/item.cc @@ -223,12 +223,6 @@ Item::derived_mark () const scm_gc_mark (broken_to_drul_[RIGHT]->self_scm ()); } -Item * -Item::unsmob (SCM s) -{ - return dynamic_cast (Grob::unsmob (s)); -} - Interval Item::pure_height (Grob *g, int start, int end) { diff --git a/lily/music.cc b/lily/music.cc index 7db54d3ed9..c19c56a1ae 100644 --- a/lily/music.cc +++ b/lily/music.cc @@ -329,9 +329,3 @@ Music::duration_length_callback (SCM m) mom = d->get_length (); return mom.smobbed_copy (); } - -Music * -Music::unsmob (SCM m) -{ - return dynamic_cast (Prob::unsmob (m)); -} diff --git a/lily/paper-score.cc b/lily/paper-score.cc index bcc6e12e87..38f108f3c4 100644 --- a/lily/paper-score.cc +++ b/lily/paper-score.cc @@ -165,9 +165,3 @@ Paper_score::get_paper_systems () } return paper_systems_; } - -Paper_score * -Paper_score::unsmob (SCM x) -{ - return dynamic_cast (Music_output::unsmob (x)); -} diff --git a/lily/performance.cc b/lily/performance.cc index f0b9c00192..800b3cb52e 100644 --- a/lily/performance.cc +++ b/lily/performance.cc @@ -97,9 +97,3 @@ void Performance::process () { } - -Performance * -Performance::unsmob (SCM x) -{ - return dynamic_cast (Music_output::unsmob (x)); -} diff --git a/lily/performer.cc b/lily/performer.cc index fad7db5959..fed24aadb2 100644 --- a/lily/performer.cc +++ b/lily/performer.cc @@ -48,9 +48,3 @@ Performer::announce_element (Audio_element_info i) get_daddy_performer ()->announce_element (i); } - -Performer * -Performer::unsmob (SCM perf) -{ - return dynamic_cast (Translator::unsmob (perf)); -} diff --git a/lily/spanner.cc b/lily/spanner.cc index 52745136fc..e3d8cb6169 100644 --- a/lily/spanner.cc +++ b/lily/spanner.cc @@ -465,12 +465,6 @@ Spanner::calc_normalized_endpoints (SCM smob) return result; } -Spanner * -Spanner::unsmob (SCM s) -{ - return dynamic_cast (Grob::unsmob (s)); -} - MAKE_SCHEME_CALLBACK (Spanner, bounds_width, 1); SCM Spanner::bounds_width (SCM grob) diff --git a/lily/stream-event.cc b/lily/stream-event.cc index 4351f16a5a..e17d6c711b 100644 --- a/lily/stream-event.cc +++ b/lily/stream-event.cc @@ -113,9 +113,3 @@ Stream_event::undump (SCM data) obj->mutable_property_alist_ = scm_reverse (scm_cdr (data)); return obj->unprotect (); } - -Stream_event * -Stream_event::unsmob (SCM m) -{ - return dynamic_cast (Prob::unsmob (m)); -}