]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/grob.cc
*** empty log message ***
[lilypond.git] / lily / grob.cc
index 072f77a00a648ca16cc8b6b005240800b7934ba6..477577066388d5d2059d8e62044fe4eebc6ac877 100644 (file)
@@ -36,7 +36,6 @@ remove dynamic_cast<Spanner,Item> and put this code into respective
   subclass.
 */
 
-//#define HASHING_FOR_MUTABLE_PROPS
 #define HASH_SIZE 3
 #define INFINITY_MSG "Infinity or NaN encountered"
 
@@ -60,9 +59,6 @@ Grob::Grob (SCM basicprops)
   smobify_self ();
 
 
-#ifdef HASHING_FOR_MUTABLE_PROPS
-  mutable_property_alist_ = scm_c_make_hash_table (HASH_SIZE);
-#endif
   
   SCM meta = get_property ("meta");
   if (ly_c_pair_p (meta))
@@ -112,8 +108,8 @@ Grob::Grob (SCM basicprops)
       if (is_number_pair (xt))
        cb = xt;
       else if (cb != SCM_BOOL_F
-         && !is_procedure (cb) && !ly_c_pair_p (cb)
-         && is_procedure (get_property ("print-function")))
+         && !ly_c_procedure_p (cb) && !ly_c_pair_p (cb)
+         && ly_c_procedure_p (get_property ("print-function")))
        cb = stencil_extent_proc;
     
       dim_cache_[a].dimension_ = cb;
@@ -138,17 +134,10 @@ Grob::Grob (Grob const&s)
   pscore_ = 0;
 
   smobify_self ();
-
-#ifdef HASHING_FOR_MUTABLE_PROPS
-  mutable_property_alist_ = scm_c_make_hash_table (HASH_SIZE);
-#endif
 }
 
 Grob::~Grob ()
 {
-  /*
-    do nothing scm-ish and no unprotecting here.
-   */
 }
 
 
@@ -166,19 +155,28 @@ Grob::stencil_extent (SCM element_smob, SCM scm_axis)
   return ly_interval2scm (e);
 }
 
-Paper_def*
+Output_def*
 Grob::get_paper ()  const
 {
  return pscore_ ? pscore_->paper_ : 0;
 }
 
+
+/*
+  Recursively track all dependencies of this Grob.  The
+  status_ field is used as a mark-field.  It is marked with
+  BUSY during execution of this function, and marked with FINAL
+  when finished.
+
+  FUNCPTR is the function to call to update this element.
+*/
 void
 Grob::calculate_dependencies (int final, int busy, SCM funcname)
 {
   if (status_ >= final)
     return;
 
-  if (status_== busy)
+  if (status_ == busy)
     {
       programming_error ("Element is busy, come back later");
       return;
@@ -195,16 +193,16 @@ Grob::calculate_dependencies (int final, int busy, SCM funcname)
 
   
   SCM proc = internal_get_property (funcname);
-  if (is_procedure (proc))
+  if (ly_c_procedure_p (proc))
     scm_call_1 (proc, this->self_scm ());
  
-  status_= final;
+  status_ = final;
 }
 
 Stencil *
 Grob::get_stencil ()  const
 {
-  if (!live ())
+  if (!is_live ())
     {
       return 0;
     }
@@ -215,7 +213,7 @@ Grob::get_stencil ()  const
 
   mol = get_uncached_stencil ();
   
-  if (live ())
+  if (is_live ())
     {
       Grob *me = (Grob*)this;
       me->set_property ("stencil", mol);
@@ -230,40 +228,34 @@ Grob::get_uncached_stencil ()const
   SCM proc = get_property ("print-function");
 
   SCM  mol = SCM_EOL;
-  if (is_procedure (proc)) 
+  if (ly_c_procedure_p (proc)) 
     mol = scm_apply_0 (proc, scm_list_n (this->self_scm (), SCM_UNDEFINED));
   
-  Stencil *m = unsmob_stencil (mol);
-  
-  if (unsmob_stencil (mol))
-    {
-      SCM origin = ly_symbol2scm ("no-origin");
+  if (Stencil *m = unsmob_stencil (mol))
+     {
+      if (to_boolean (get_property ("transparent")))
+       mol = Stencil (m->extent_box (), SCM_EOL).smobbed_copy ();
+    else
+      {
+       SCM origin = ly_symbol2scm ("no-origin");
       
-      if (store_locations_global_b)
-       {
-         SCM cause = get_property ("cause");
-         if (Music*m = unsmob_music (cause))
-           {
-             SCM music_origin = m->get_property ("origin");
-             if (unsmob_input (music_origin))
-               origin = music_origin;
-           }
+       if (store_locations_global_b)
+         {
+           SCM cause = get_property ("cause");
+           if (Music*m = unsmob_music (cause))
+             {
+               SCM music_origin = m->get_property ("origin");
+               if (unsmob_input (music_origin))
+                 origin = music_origin;
+             }
+         }
+
+       // ugr.
+       mol = Stencil (m->extent_box (),
+                      scm_list_n (origin, m->expr (), SCM_UNDEFINED)
+                      ). smobbed_copy ();
       }
-
-      // ugr.
-      
-      mol = Stencil (m->extent_box (),
-                     scm_list_n (origin, m->get_expr (), SCM_UNDEFINED)
-                     ). smobbed_copy ();
-
-      m = unsmob_stencil (mol);
-    }
-  
-  /*
-    transparent retains dimensions of element.
-   */
-  if (m && to_boolean (get_property ("transparent")))
-    mol = Stencil (m->extent_box (), SCM_EOL).smobbed_copy ();
+    }  
 
   return mol;
 }
@@ -295,7 +287,6 @@ Grob::add_dependency (Grob*e)
     programming_error ("Null dependency added");
 }
 
-
 void
 Grob::handle_broken_dependencies ()
 {
@@ -320,7 +311,7 @@ Grob::handle_broken_dependencies ()
 
   System *system = get_system ();
 
-  if (live ()
+  if (is_live ()
       && system && common_refpoint (system, X_AXIS) && common_refpoint (system, Y_AXIS))
     {
       substitute_mutable_properties (system ? system->self_scm () : SCM_UNDEFINED,
@@ -353,12 +344,9 @@ Grob::handle_broken_dependencies ()
 void
 Grob::suicide ()
 {
-  if (!live ())
+  if (!is_live ())
     return; 
 
-#if 0 // see below. 
-   String nm = name ();
-#endif
   
   mutable_property_alist_ = SCM_EOL;
   immutable_property_alist_ = SCM_EOL;
@@ -371,19 +359,6 @@ Grob::suicide ()
       dim_cache_[a].offset_callbacks_ = SCM_EOL;
       dim_cache_[a].offsets_left_ = 0;
     }
-
-#if 0
-  /*
-    This can make debugging a little easier: we can still know what
-    the object used to be. However, since all its links have been
-    broken, it's usually more convenient to set a conditional
-    breakpoint in GDB before the property lists are wiped.
-   */
-  mutable_property_alist_ = scm_acons (ly_symbol2scm ("name"),
-                                      scm_makfrom0str (nm.to_str0()),
-                                      mutable_property_alist_
-                                      );
-#endif
 }
 
 void
@@ -476,7 +451,7 @@ bool
 Grob::is_empty (Axis a)const
 {
   return ! (ly_c_pair_p (dim_cache_[a].dimension_) ||
-           is_procedure (dim_cache_[a].dimension_));
+           ly_c_procedure_p (dim_cache_[a].dimension_));
 }
 
 Interval
@@ -489,7 +464,7 @@ Grob::extent (Grob * refp, Axis a) const
   Interval ext ;   
   if (ly_c_pair_p (d->dimension_))
     ;
-  else if (is_procedure (d->dimension_))
+  else if (ly_c_procedure_p (d->dimension_))
     {
       /*
        FIXME: add doco on types, and should typecheck maybe? 
@@ -593,7 +568,7 @@ Grob::name () const
   SCM meta = get_property ("meta");
   SCM nm = scm_assoc (ly_symbol2scm ("name"), meta);
   nm = (ly_c_pair_p (nm)) ? ly_cdr (nm) : SCM_EOL;
-  return  is_symbol (nm) ? ly_symbol2string (nm) :  classname (this);  
+  return  ly_c_symbol_p (nm) ? ly_symbol2string (nm) :  classname (this);  
 }
 
 void
@@ -622,7 +597,7 @@ Grob::has_offset_callback (SCM cb, Axis a)const
 void
 Grob::set_extent (SCM dc, Axis a)
 {
-  dim_cache_[a].dimension_ =dc;
+  dim_cache_[a].dimension_ = dc;
 }
 
 void