]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-1.3.74
authorfred <fred>
Tue, 26 Mar 2002 23:25:13 +0000 (23:25 +0000)
committerfred <fred>
Tue, 26 Mar 2002 23:25:13 +0000 (23:25 +0000)
lily/include/music.hh
lily/property-engraver.cc
lily/scm-hash.cc
lily/scope.cc
lily/tfm-reader.cc

index 2eee399d18de24bc6be327c4a755bfdeac18fe31..fc3d8ae05cf708487b983d8af9d94e8dfdd17608 100644 (file)
   */
 class Music {
 public:
-  DECLARE_SMOBS;
-  SCM immutable_property_alist_;
-  SCM mutable_property_alist_;
   Input *origin () const; 
   void set_spot (Input);  
   
@@ -46,13 +42,11 @@ public:
   void set_mus_pointer (const char*, SCM val);
   SCM remove_mus_property (const char* nm);
 
-  virtual SCM do_derived_mark ();
   virtual Musical_pitch to_relative_octave (Musical_pitch);
 
   /// The duration of this piece of music
   virtual Moment length_mom () const;
 
-  virtual ~Music();
   void print() const;
   /// Transpose, with the interval central C to #p#
   virtual void transpose (Musical_pitch p);
@@ -64,6 +58,10 @@ public:
   Music();
 protected:
   virtual void do_print() const;
+  DECLARE_SMOBS(Music,);
+  SCM immutable_property_alist_;
+  SCM mutable_property_alist_;
 };
 
 
index 35d19d162a5e2580603f9ca8c5c45b9f37738d14..c6e54302637fb1b2523d54014a2cddef262cd8e5 100644 (file)
@@ -19,24 +19,47 @@ class Property_engraver : public Engraver
   /*
     UGH. Junk Dictionary
   */
-  Scheme_hash_table prop_dict_;        // junkme
+  Scheme_hash_table *prop_dict_;       // junkme
   void apply_properties (SCM, Score_element*);
 
 protected:
   virtual void acknowledge_element (Score_element_info ei);
   virtual void do_creation_processing ();
-
+  virtual void do_removal_processing ();
+public:
+  ~Property_engraver();
+  Property_engraver();
   VIRTUAL_COPY_CONS(Translator);
 };
 
+
+
+Property_engraver::Property_engraver()
+{
+  prop_dict_ = 0;
+}
+void
+Property_engraver::do_removal_processing()
+{
+  
+}
+
+Property_engraver::~Property_engraver ()
+{
+  if (prop_dict_)
+    scm_unprotect_object (prop_dict_->self_scm ());
+}
+
 void
 Property_engraver::do_creation_processing ()
 {
+  prop_dict_ = new Scheme_hash_table;
+
   SCM plist = get_property ("Generic_property_list");
   for (; gh_pair_p (plist); plist = gh_cdr (plist))
     {
       SCM elt_props = gh_car (plist);
-      prop_dict_.set (gh_car (elt_props), gh_cdr (elt_props));
+      prop_dict_->set (gh_car (elt_props), gh_cdr (elt_props));
     }
 }
 
@@ -47,13 +70,13 @@ Property_engraver::acknowledge_element (Score_element_info i)
   SCM props;
   for (; gh_pair_p (ifs); ifs = gh_cdr (ifs))
     {      
-      if (prop_dict_.try_retrieve (gh_car (ifs), &props))
+      if (prop_dict_->try_retrieve (gh_car (ifs), &props))
        {
          apply_properties (props,i.elem_l_);
        }
     }
 
-  if (prop_dict_.try_retrieve (ly_symbol2scm ("all"), &props))
+  if (prop_dict_->try_retrieve (ly_symbol2scm ("all"), &props))
     {
       apply_properties (props, i.elem_l_);
     }
index 98c430b3ebe7a3a3e9b788bf882f74016b40a241..16c59747376ed9c2fe32d86686867ca2d1426a4b 100644 (file)
 
 Scheme_hash_table::Scheme_hash_table ()
 {
-  self_scm_ = SCM_EOL;
+  smobify_self ();
+}
+
+
+Scheme_hash_table::Scheme_hash_table (Scheme_hash_table const &src)
+  : Scm_stl_map (src)
+{
   smobify_self ();
 }
 
@@ -23,13 +29,10 @@ Scheme_hash_table::operator =(Scheme_hash_table const & src)
 {
   Scm_stl_map::operator = (src);
        
-  // we do not copy the self_scm_ field!
+  // we do not copy the self_scm () field!
 }
 
-void
-Scheme_hash_table::do_smobify_self ()
-{
-}
+
 
 
 SCM
@@ -39,7 +42,7 @@ Scheme_hash_table::mark_smob (SCM s)
     can't typecheck naively, since GC bit lives in CAR of S
    */
   
-  Scheme_hash_table *me = SMOB_TO_TYPE(Scheme_hash_table,s);
+  Scheme_hash_table *me = (Scheme_hash_table*) SCM_CELL_WORD_1(s);
 
   for (Scm_stl_map::const_iterator i= me->begin (); i != me->end(); i++)
     {
@@ -49,22 +52,14 @@ Scheme_hash_table::mark_smob (SCM s)
   return SCM_EOL;
 }
 
-
-Scheme_hash_table::Scheme_hash_table (Scheme_hash_table const &src)
-  : Scm_stl_map (src)
-{
-  self_scm_ = SCM_EOL;
-  smobify_self ();
-}
-
 int
 Scheme_hash_table::print_smob (SCM s, SCM p, scm_print_state*)
 {
-  assert (SMOB_IS_TYPE_B (Scheme_hash_table, s));
+  assert (unsmob (s));
   char str[1000];
   sprintf (str, "#<Scheme_hash_table 0x%0x ", s);
   scm_puts (str, p);      
-  Scheme_hash_table *me = SMOB_TO_TYPE(Scheme_hash_table,s);
+  Scheme_hash_table *me = unsmob(s);
   for (Scm_stl_map::const_iterator i = me->begin (); i != me->end(); i++)
     {
       scm_display ((*i).first, p);
@@ -109,7 +104,6 @@ Scheme_hash_table::get (SCM k)const
 
 Scheme_hash_table::~Scheme_hash_table( )
 {
-  unsmobify_self ();
 }
 
 SCM
@@ -125,5 +119,6 @@ Scheme_hash_table::to_alist () const
 #include "ly-smobs.icc"
 IMPLEMENT_UNSMOB(Scheme_hash_table,scheme_hash);
 IMPLEMENT_SMOBS(Scheme_hash_table);
+IMPLEMENT_DEFAULT_EQUAL_P(Scheme_hash_table);
 
 
index c04878f93404c54865193ea6e60014e9224185df..85837e5d0979ca048aa9872620b6d74bb1bf9e6a 100644 (file)
 
 Scope::~Scope ()
 {
-  delete id_dict_;
+  scm_unprotect_object (id_dict_->self_scm ());
 }
 
 Scope::Scope (Scope const&s)
-  : id_dict_ (new Scheme_hash_table (*s.id_dict_))
 {
+  id_dict_ =new Scheme_hash_table (*s.id_dict_);
 }
 
 Scope::Scope ()
@@ -72,7 +72,7 @@ Scope::set (String s, SCM id)
 void
 Scope::set (String s, Identifier * id) 
 {
-  return id_dict_->set (ly_symbol2scm (s.ch_C()), smobify (id));
+  return id_dict_->set (ly_symbol2scm (s.ch_C()), id->self_scm ());
 }
 
 SCM
index 7bc495b49bd29340133da4c8844633b1a0eb9e86..f188e300c2a4cdee48a70fec22f679b480c6ea0d 100644 (file)
 static const Real fix_to_real (Fix f);
 
 
-Tex_font_metric_reader::Tex_font_metric_reader (Tex_font_metric* fp, String name)
+Tex_font_metric_reader::Tex_font_metric_reader (String name)
   : input_ (name)
 {
-  tfm_l_=fp;
-  tfm_l_->clear (TFM_SIZE);
+  
+  for (int i=0; i < TFM_SIZE; i++)
+    ascii_to_metric_idx_.push (-1);
+
   read_header ();
   read_params ();
   read_char_metrics ();
 
 }
 
-Tex_font_metric * 
-Tex_font_metric_reader::read_file (String name)
-{
-  Tex_font_metric * tfmp = new Tex_font_metric;
-  Tex_font_metric_reader tfm_reader (tfmp, name);
-
-  return tfmp;
-}
-
-
-
-
 static const Real
 fix_to_real (Fix f)
 {
@@ -62,7 +52,7 @@ Tex_font_metric_reader::get_U32_fix_f ()
 Real
 Tex_font_metric_reader::get_U32_fix_scaled_f ()
 {
-  return get_U32_fix_f () * tfm_l_->info_.design_size;
+  return get_U32_fix_f () * info_.design_size;
 }
 
 String
@@ -83,8 +73,8 @@ Tex_font_metric_reader::read_header ()
   (void) file_length;
   U16 header_length = input_.get_U16 ();
 
-  tfm_l_->info_.first_charcode = input_.get_U16 ();
-  tfm_l_->info_.last_charcode = input_.get_U16 ();
+  info_.first_charcode = input_.get_U16 ();
+  info_.last_charcode = input_.get_U16 ();
   U16 width_word_count = input_.get_U16 ();
   U16 height_word_count = input_.get_U16 ();
   U16 depth_word_count = input_.get_U16 ();
@@ -95,38 +85,38 @@ Tex_font_metric_reader::read_header ()
   U16 extensible_word_count = input_.get_U16 ();
   (void)extensible_word_count;
   
-  tfm_l_->header_.param_word_count = input_.get_U16 ();
-  tfm_l_->info_.parameter_count = tfm_l_->header_.param_word_count;
-
-  tfm_l_->header_.char_info_pos = (6 + header_length) * 4;
-  tfm_l_->header_.width_pos = tfm_l_->header_.char_info_pos
-                         + (tfm_l_->info_.last_charcode
-                            - tfm_l_->info_.first_charcode + 1) * 4;
-  tfm_l_->header_.height_pos = tfm_l_->header_.width_pos + width_word_count * 4;
-  tfm_l_->header_.depth_pos = tfm_l_->header_.height_pos + height_word_count * 4;
-  tfm_l_->header_.italic_correction_pos = tfm_l_->header_.depth_pos
+  header_.param_word_count = input_.get_U16 ();
+  info_.parameter_count = header_.param_word_count;
+
+  header_.char_info_pos = (6 + header_length) * 4;
+  header_.width_pos = header_.char_info_pos
+                         + (info_.last_charcode
+                            - info_.first_charcode + 1) * 4;
+  header_.height_pos = header_.width_pos + width_word_count * 4;
+  header_.depth_pos = header_.height_pos + height_word_count * 4;
+  header_.italic_correction_pos = header_.depth_pos
                                      + depth_word_count * 4;
-  tfm_l_->header_.lig_kern_pos = tfm_l_->header_.italic_correction_pos
+  header_.lig_kern_pos = header_.italic_correction_pos
     + italic_correction_word_count * 4;
-  tfm_l_->header_.kern_pos = tfm_l_->header_.lig_kern_pos + lig_kern_word_count * 4;
+  header_.kern_pos = header_.lig_kern_pos + lig_kern_word_count * 4;
   /* We don't care about the extensible table.  */
 
   if (header_length < 2)
     error (_f ("TFM header of `%s' has only %u word(s)",
               input_.name_str ().ch_C (), header_length));
 
-  tfm_l_->info_.checksum = input_.get_U32 ();
-  tfm_l_->info_.design_size = get_U32_fix_f ();
+  info_.checksum = input_.get_U32 ();
+  info_.design_size = get_U32_fix_f ();
 
   /* Although the coding scheme might be interesting to the caller, the
      font family and face byte probably aren't.  So we don't read them.  */
-  tfm_l_->info_.coding_scheme = header_length > 2
+  info_.coding_scheme = header_length > 2
     ? get_bcpl_str () : "unspecified";
 
   DEBUG_OUT << format_str ("TFM checksum = %u, design_size = %fpt, coding scheme = `%s'.\n",
-                     tfm_l_->info_.checksum,
-                     tfm_l_->info_.design_size,
-                     tfm_l_->info_.coding_scheme.ch_C ());
+                     info_.checksum,
+                     info_.design_size,
+                     info_.coding_scheme.ch_C ());
 }
 
 /* Although TFM files are only usable by TeX if they have at least seven
@@ -139,34 +129,34 @@ void
 Tex_font_metric_reader::read_params ()
 {
   /* If we have no font parameters at all, we're done.  */
-  if (tfm_l_->header_.param_word_count == 0)
+  if (header_.param_word_count == 0)
     return;
 
   //brrr
   /* Move to the beginning of the parameter table in the file.  */
-  input_.seek_ch_C (-4 * tfm_l_->header_.param_word_count);
+  input_.seek_ch_C (-4 * header_.param_word_count);
 
   /* It's unlikely but possible that this TFM file has more fontdimens
      than we can deal with.  */
-  if (tfm_l_->header_.param_word_count > TFM_MAX_FONTDIMENS)
+  if (header_.param_word_count > TFM_MAX_FONTDIMENS)
     {
       warning (_f ("%s: TFM file has %u parameters, which is more than the %u I can handle",
                   input_.name_str ().ch_C (),
-                  tfm_l_->header_.param_word_count,
+                  header_.param_word_count,
                   TFM_MAX_FONTDIMENS));
-      tfm_l_->header_.param_word_count = TFM_MAX_FONTDIMENS;
+      header_.param_word_count = TFM_MAX_FONTDIMENS;
     }
 
   /* The first parameter is different than all the rest, because it
      isn't scaled by the design size.  */
-  tfm_l_->info_.parameters[(TFM_SLANT_PARAMETER) - 1] = get_U32_fix_f ();
+  info_.parameters[(TFM_SLANT_PARAMETER) - 1] = get_U32_fix_f ();
 
-  for (Char_code i = 2; i <= tfm_l_->header_.param_word_count; i++)
-    tfm_l_->info_.parameters[i - 1] = get_U32_fix_scaled_f ();
+  for (Char_code i = 2; i <= header_.param_word_count; i++)
+    info_.parameters[i - 1] = get_U32_fix_scaled_f ();
 
 #ifdef PRINT
-  for (Char_code i = 1; i <= tfm_l_->header_.param_word_count; i++)
-    DEBUG_OUT << format_str ("TFM parameter %d: %.3f", i, tfm_l_->info_.parameters[i - 1]);
+  for (Char_code i = 1; i <= header_.param_word_count; i++)
+    DEBUG_OUT << format_str ("TFM parameter %d: %.3f", i, info_.parameters[i - 1]);
 #endif
 }
 
@@ -176,12 +166,12 @@ Tex_font_metric_reader::read_params ()
 void
 Tex_font_metric_reader::read_char_metrics ()
 {
-  for (int i = tfm_l_->info_.first_charcode; i <= tfm_l_->info_.last_charcode; i++)
+  for (int i = info_.first_charcode; i <= info_.last_charcode; i++)
     {
       Tex_font_char_metric tfm_char = read_char_metric (i);
       if (tfm_char.exists_b_)
-       tfm_l_->ascii_to_metric_idx_[tfm_char.code_] = tfm_l_->char_metrics_.size ();
-      tfm_l_->char_metrics_.push (tfm_char);
+       ascii_to_metric_idx_[tfm_char.code_] = char_metrics_.size ();
+      char_metrics_.push (tfm_char);
     }
 }
 
@@ -196,12 +186,12 @@ Tex_font_metric_reader::read_char_metric (Char_code code)
 
   /* If the character is outside the declared bounds in the file, don't
      try to read it. */
-  if (code < tfm_l_->info_.first_charcode || code > tfm_l_->info_.last_charcode)
+  if (code < info_.first_charcode || code > info_.last_charcode)
     return tfm_char;
   
   //brr
   /* Move to the appropriate place in the `char_info' array.  */
-  input_.seek_ch_C (tfm_l_->header_.char_info_pos + (code - tfm_l_->info_.first_charcode) * 4);
+  input_.seek_ch_C (header_.char_info_pos + (code - info_.first_charcode) * 4);
 
   /* Read the character.  */
   tfm_char = read_char ();
@@ -239,10 +229,10 @@ Tex_font_metric_reader::read_char ()
 #define GET_CHAR_DIMEN(d) \
    if (d##_index != 0) \
      { \
-       input_.seek_ch_C (tfm_l_->header_.##d##_pos + d##_index*4); \
+       input_.seek_ch_C (header_.##d##_pos + d##_index*4); \
        tfm_char.d##_fix_ = input_.get_U32 (); \
        tfm_char.d##_ = fix_to_real (tfm_char.d##_fix_) \
-                      * tfm_l_->info_.design_size; \
+                      * info_.design_size; \
      }
 
   GET_CHAR_DIMEN (width);
@@ -265,7 +255,7 @@ Tex_font_metric_reader::read_char ()
 
   if (tag == 1)
     {
-      input_.seek_ch_C (tfm_l_->header_.lig_kern_pos + remainder * 4);
+      input_.seek_ch_C (header_.lig_kern_pos + remainder * 4);
       read_lig_kern_program (&tfm_char.ligature_arr_, &tfm_char.kern_arr_);
     }
 
@@ -303,7 +293,7 @@ Tex_font_metric_reader::read_lig_kern_program (Array <Tfm_ligature>* ligature_ar
          kern_element.character = next_char;
 
          char const* old_pos = input_.pos_ch_C ();
-         input_.seek_ch_C (tfm_l_->header_.kern_pos + remainder * 4);
+         input_.seek_ch_C (header_.kern_pos + remainder * 4);
          kern_element.kern = get_U32_fix_scaled_f ();
          input_.set_pos (old_pos);