]> git.donarmstrong.com Git - lilypond.git/commitdiff
Issue 4141/1: Define inline members unsmob and is_smob for several derived classes
authorDavid Kastrup <dak@gnu.org>
Mon, 29 Sep 2014 18:11:48 +0000 (20:11 +0200)
committerDavid Kastrup <dak@gnu.org>
Mon, 6 Oct 2014 07:31:20 +0000 (09:31 +0200)
18 files changed:
lily/engraver.cc
lily/global-context.cc
lily/include/engraver.hh
lily/include/global-context.hh
lily/include/item.hh
lily/include/music.hh
lily/include/paper-score.hh
lily/include/performance.hh
lily/include/performer.hh
lily/include/spanner.hh
lily/include/stream-event.hh
lily/item.cc
lily/music.cc
lily/paper-score.cc
lily/performance.cc
lily/performer.cc
lily/spanner.cc
lily/stream-event.cc

index 76117a66e8847e153d52c31f7513379be597e4d3..e6d3142b141291cec0d46e7ca367f018d967fb65 100644 (file)
@@ -171,12 +171,6 @@ Engraver::internal_make_spanner (SCM x, SCM cause, char const *name,
   return sp;
 }
 
   return sp;
 }
 
-Engraver *
-Engraver::unsmob (SCM eng)
-{
-  return dynamic_cast<Engraver *> (Translator::unsmob (eng));
-}
-
 bool
 ly_is_grob_cause (SCM obj)
 {
 bool
 ly_is_grob_cause (SCM obj)
 {
index 94f8efa82f50859d179640bbdcff33b5a9714e21..9168f612a94e0e2d265cafeccbfa180ec5844c75 100644 (file)
@@ -207,9 +207,3 @@ Global_context::get_default_interpreter (const string &/* context_id */)
   else
     return Context::get_default_interpreter ();
 }
   else
     return Context::get_default_interpreter ();
 }
-
-Global_context *
-Global_context::unsmob (SCM x)
-{
-  return dynamic_cast<Global_context *> (Context::unsmob (x));
-}
index 2cb28292fc30290c029744893dfa89caaf7ff7d4..77f55f0e488708e9b404204189ac0936aa21b379 100644 (file)
@@ -65,7 +65,12 @@ public:
      override other ctor
   */
   TRANSLATOR_DECLARATIONS (Engraver);
      override other ctor
   */
   TRANSLATOR_DECLARATIONS (Engraver);
-  static Engraver *unsmob (SCM eng);
+  static Engraver *unsmob (SCM eng) {
+    return dynamic_cast<Engraver *> (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__)
 };
 
 #define make_item(x, cause) internal_make_item (ly_symbol2scm (x), cause, x, __FILE__, __LINE__, __FUNCTION__)
index 31e2190bc21c22dbb08d458774c4982f8fecdb1d..f940561739a4e2b5800caba811c2f7b4d4e0d4f3 100644 (file)
@@ -48,7 +48,12 @@ public:
   virtual Moment now_mom () const;
   virtual Context *get_default_interpreter (const string &context_id = "");
 
   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<Global_context *> (Context::unsmob (x));
+  }
+  static bool is_smob (SCM x) {
+    return Context::is_smob (x) && unsmob (x);
+  }
 
   Moment previous_moment () const;
 protected:
 
   Moment previous_moment () const;
 protected:
index ac945eac413527b926defcdef5e66b514465f88a..9342d6f981700db69ba3461b15e821016edd7692 100644 (file)
@@ -36,7 +36,12 @@ public:
   Item (SCM);
   Item (Item const &);
 
   Item (SCM);
   Item (Item const &);
 
-  static Item *unsmob (SCM);
+  static Item *unsmob (SCM g) {
+    return dynamic_cast <Item *> (Grob::unsmob (g));
+  }
+  static bool is_smob (SCM g) {
+    return Grob::is_smob (g) && unsmob (g);
+  }
 
   virtual Grob *clone () const;
 
 
   virtual Grob *clone () const;
 
index e59f82c758f6a26d408a275c414298bb881f8d80..72b48859c22eaf6fe51ccafdb2b0aceb4c7e825d 100644 (file)
@@ -47,7 +47,12 @@ public:
   Moment get_length () const;
   Moment start_mom () const;
   void print () const;
   Moment get_length () const;
   Moment start_mom () const;
   void print () const;
-  static Music *unsmob (SCM);
+  static Music *unsmob (SCM m) {
+    return dynamic_cast <Music *> (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);
 
   /// Transpose, with the interval central C to #p#
   void transpose (Pitch p);
index 05933d49f39ca8e20f1a506301131899a4a63e74..a919cebce0973b5173af1b91e1eb1dc835b84a7c 100644 (file)
@@ -39,7 +39,12 @@ public:
 
   DECLARE_CLASSNAME (Paper_score);
 
 
   DECLARE_CLASSNAME (Paper_score);
 
-  static Paper_score *unsmob (SCM);
+  static Paper_score *unsmob (SCM ps) {
+    return dynamic_cast <Paper_score *> (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;
 
   Output_def *layout () const;
   System *root_system () const;
index f3093f82c5060699bddb979a5aa0f7e428c735dc..2df4bb75c63e4a03311e99f87b458a0b2597fd4f 100644 (file)
@@ -31,7 +31,12 @@ public:
   ~Performance ();
   DECLARE_CLASSNAME (Performance);
 
   ~Performance ();
   DECLARE_CLASSNAME (Performance);
 
-  static Performance *unsmob (SCM);
+  static Performance *unsmob (SCM p) {
+    return dynamic_cast <Performance *> (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 ();
 
   void add_element (Audio_element *p);
   virtual void process ();
index aa9b098d34d3e478dbd6343c373f288b87309d98..123713d3cbeeae1dcbdaf6f76de299f2d2ad852a 100644 (file)
@@ -33,7 +33,12 @@ public:
   VIRTUAL_COPY_CONSTRUCTOR (Translator, Performer);
   friend class Performer_group;
   Performer_group *get_daddy_performer () const;
   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 <Performer *> (Translator::unsmob (perf));
+  }
+  static bool is_smob (SCM perf) {
+    return Translator::is_smob (perf) && unsmob (perf);
+  }
 
 protected:
   virtual void announce_element (Audio_element_info);
 
 protected:
   virtual void announce_element (Audio_element_info);
index b56cc2264de02372fa8ae4f41fc7881bd73f8a75..f618e9c58ef3f8ef1fb8cbfe701518df2a204754 100644 (file)
@@ -52,7 +52,12 @@ public:
   DECLARE_SCHEME_CALLBACK (bounds_width, (SCM));
   DECLARE_SCHEME_CALLBACK (kill_zero_spanned_time, (SCM));
 
   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 <Spanner *> (Grob::unsmob (s));
+  }
+  static bool is_smob (SCM s) {
+    return Grob::is_smob (s) && unsmob (s);
+  }
 
   vector<Spanner *> broken_intos_;
 
 
   vector<Spanner *> broken_intos_;
 
index 14a8af41dca73f2559765398d227a04445163afa..8c56f16340a3a32fd485aaf5773405129d75c3ed 100644 (file)
@@ -30,7 +30,12 @@ public:
   Stream_event ();
   VIRTUAL_COPY_CONSTRUCTOR (Stream_event, Stream_event);
 
   Stream_event ();
   VIRTUAL_COPY_CONSTRUCTOR (Stream_event, Stream_event);
 
-  static Stream_event *unsmob (SCM);
+  static Stream_event *unsmob (SCM s) {
+    return dynamic_cast <Stream_event *> (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 *);
 
   Stream_event (SCM event_class, SCM immutable_props = SCM_EOL);
   Stream_event (SCM class_name, Input *);
index bcde47616d9915d7032944a3d2374d2e19cb6b39..ec5c943f2a84b8cfd8170dd73646588f3ac22c93 100644 (file)
@@ -223,12 +223,6 @@ Item::derived_mark () const
     scm_gc_mark (broken_to_drul_[RIGHT]->self_scm ());
 }
 
     scm_gc_mark (broken_to_drul_[RIGHT]->self_scm ());
 }
 
-Item *
-Item::unsmob (SCM s)
-{
-  return dynamic_cast<Item *> (Grob::unsmob (s));
-}
-
 Interval
 Item::pure_height (Grob *g, int start, int end)
 {
 Interval
 Item::pure_height (Grob *g, int start, int end)
 {
index 7db54d3ed930b334c825faea2f5e6a30738de437..c19c56a1ae660021bc76f710ed37756ee1af8042 100644 (file)
@@ -329,9 +329,3 @@ Music::duration_length_callback (SCM m)
     mom = d->get_length ();
   return mom.smobbed_copy ();
 }
     mom = d->get_length ();
   return mom.smobbed_copy ();
 }
-
-Music *
-Music::unsmob (SCM m)
-{
-  return dynamic_cast<Music *> (Prob::unsmob (m));
-}
index bcc6e12e870274a00ad3e27e8ca117c8ea5e4ef7..38f108f3c425bda821f93e0a4adc3269228e7fab 100644 (file)
@@ -165,9 +165,3 @@ Paper_score::get_paper_systems ()
     }
   return paper_systems_;
 }
     }
   return paper_systems_;
 }
-
-Paper_score *
-Paper_score::unsmob (SCM x)
-{
-  return dynamic_cast<Paper_score *> (Music_output::unsmob (x));
-}
index f0b9c001927a39ceab84b46b1de6e3080aa33ad7..800b3cb52ef4863012b4b5bb8362b7c511a29597 100644 (file)
@@ -97,9 +97,3 @@ void
 Performance::process ()
 {
 }
 Performance::process ()
 {
 }
-
-Performance *
-Performance::unsmob (SCM x)
-{
-  return dynamic_cast<Performance *> (Music_output::unsmob (x));
-}
index fad7db5959a617fad7abd540c427daa51860ab60..fed24aadb2ccf6a4aeb2bf9981b10d8d995c3279 100644 (file)
@@ -48,9 +48,3 @@ Performer::announce_element (Audio_element_info i)
 
   get_daddy_performer ()->announce_element (i);
 }
 
   get_daddy_performer ()->announce_element (i);
 }
-
-Performer *
-Performer::unsmob (SCM perf)
-{
-  return dynamic_cast<Performer *> (Translator::unsmob (perf));
-}
index 52745136fc54a891498ca96ba53b8273465e3ccd..e3d8cb6169db20d4582d5a67a9d424dd5383a4ed 100644 (file)
@@ -465,12 +465,6 @@ Spanner::calc_normalized_endpoints (SCM smob)
   return result;
 }
 
   return result;
 }
 
-Spanner *
-Spanner::unsmob (SCM s)
-{
-  return dynamic_cast<Spanner *> (Grob::unsmob (s));
-}
-
 MAKE_SCHEME_CALLBACK (Spanner, bounds_width, 1);
 SCM
 Spanner::bounds_width (SCM grob)
 MAKE_SCHEME_CALLBACK (Spanner, bounds_width, 1);
 SCM
 Spanner::bounds_width (SCM grob)
index 4351f16a5a3a99165f4f3aa5353377586981cef1..e17d6c711b1806b5417b1f7e5ac33510503b79db 100644 (file)
@@ -113,9 +113,3 @@ Stream_event::undump (SCM data)
   obj->mutable_property_alist_ = scm_reverse (scm_cdr (data));
   return obj->unprotect ();
 }
   obj->mutable_property_alist_ = scm_reverse (scm_cdr (data));
   return obj->unprotect ();
 }
-
-Stream_event *
-Stream_event::unsmob (SCM m)
-{
-  return dynamic_cast<Stream_event *> (Prob::unsmob (m));
-}