]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/translator-def.cc
release: 1.5.34
[lilypond.git] / lily / translator-def.cc
index aaec32d796b4551eb28ea7ae2744d0bba7138837..79c4087bdbacbb8cd6b5587281e6983531d256aa 100644 (file)
@@ -3,7 +3,7 @@
   
   source file of the GNU LilyPond music typesetter
   
-  (c) 2000--2001 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c) 2000--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
   
  */
 
@@ -12,7 +12,6 @@
 #include "translator-group.hh"
 #include "warn.hh"
 #include "music-output-def.hh"
-
 #include "ly-smobs.icc"
 
 int
@@ -41,17 +40,6 @@ Translator_def::mark_smob (SCM smob)
   return me->type_name_;
 }
 
-SCM push_sym;
-SCM assign_sym;
-
-static void
-foo_init ()
-{
-  push_sym = scm_permanent_object (ly_symbol2scm ("push"));
-  assign_sym = scm_permanent_object (ly_symbol2scm ("assign"));
-}
-
-ADD_SCM_INIT_FUNC (transdef, foo_init);
 
 Translator_def::Translator_def ()
 {
@@ -138,28 +126,25 @@ Translator_def::add_last_element (SCM s)
 void
 Translator_def::add_push_property (SCM props, SCM syms,  SCM vals)
 {
-  this->property_ops_ = gh_cons (gh_list (push_sym, props, syms, vals, SCM_UNDEFINED),
+  this->property_ops_ = gh_cons (scm_list_n (ly_symbol2scm ("push"), props, syms, vals, SCM_UNDEFINED),
                                 this->property_ops_);
 }
 
 void
 Translator_def::add_pop_property (SCM props, SCM syms)
 {
-  this->property_ops_ = gh_cons (gh_list (push_sym, props, syms, SCM_UNDEFINED),
+  this->property_ops_ = gh_cons (scm_list_n (ly_symbol2scm ("push"), props, syms, SCM_UNDEFINED),
                                 this->property_ops_);
 }
 
 /*
-  Do it. SYMS maybe a symbol or a list of symbols. VAL is
-  SCM_UNDEFINED in case of a pop
+  Do it. SYM is single symbol. VAL is SCM_UNDEFINED in case of a pop
 */
 void
-Translator_def::apply_pushpop_property (Translator_group* me,SCM syms, SCM eprop, SCM val)
+Translator_def::apply_pushpop_property (Translator_group* me,SCM sym, SCM eprop, SCM val)
 {
-  if (gh_symbol_p (syms))
-    dynamic_cast<Translator_group*> (me)->execute_single_pushpop_property (syms, eprop, val);
-  else for (SCM s = syms; gh_pair_p (s); s = gh_cdr (s))
-    dynamic_cast<Translator_group*> (me)->execute_single_pushpop_property (gh_car (s), eprop, val);
+  dynamic_cast<Translator_group*> (me)
+    ->execute_single_pushpop_property (sym, eprop, val);
 }
 
 
@@ -170,9 +155,9 @@ Translator_def::path_to_acceptable_translator (SCM type_str, Music_output_def* o
   assert (gh_string_p (type_str));
   
   Link_array<Translator_def> accepted_arr;
-  for (SCM s = accepts_name_list_; gh_pair_p (s); s = gh_cdr (s))
+  for (SCM s = accepts_name_list_; gh_pair_p (s); s = ly_cdr (s))
     {
-      Translator_def *t = unsmob_translator_def (odef->find_translator_l (gh_car (s)));
+      Translator_def *t = unsmob_translator_def (odef->find_translator_l (ly_car (s)));
       if (!t)
        continue;
       accepted_arr.push (t);
@@ -208,7 +193,7 @@ Translator_def::path_to_acceptable_translator (SCM type_str, Music_output_def* o
 
   return best_result;
 }
-IMPLEMENT_UNSMOB (Translator_def,translator_def);
+
 IMPLEMENT_SMOBS (Translator_def);
 IMPLEMENT_DEFAULT_EQUAL_P (Translator_def);
 
@@ -217,9 +202,9 @@ static SCM
 trans_list (SCM namelist, Translator_group*tg)
 {
   SCM l = SCM_EOL;
-  for (SCM s = namelist; gh_pair_p (s) ; s = gh_cdr (s))
+  for (SCM s = namelist; gh_pair_p (s) ; s = ly_cdr (s))
     {
-      Translator * t = get_translator_l (ly_scm2string (gh_car (s)));
+      Translator * t = get_translator_l (ly_scm2string (ly_car (s)));
       if (!t)
        warning (_f ("can't find: `%s'", s));
       else
@@ -248,6 +233,10 @@ Translator_def::instantiate (Music_output_def* md)
   tg->output_def_l_ = md;
   tg->definition_ = self_scm ();
   tg->type_str_ = ly_scm2string (type_name_);
+
+  /*
+    TODO: ugh. we're reversing CONSISTS_NAME_LIST_ here
+   */
   SCM l1 = trans_list (consists_name_list_, tg);
   SCM l2 =trans_list (end_consists_name_list_,tg);
   l1 = scm_reverse_x (l1, l2);
@@ -262,22 +251,22 @@ void
 Translator_def::apply_property_operations (Translator_group*tg)
 {
   SCM correct_order = scm_reverse (property_ops_); // pity of the mem.
-  for (SCM s = correct_order; gh_pair_p (s); s = gh_cdr (s))
+  for (SCM s = correct_order; gh_pair_p (s); s = ly_cdr (s))
     {
-      SCM entry = gh_car (s);
-      SCM type = gh_car (entry);
-      entry = gh_cdr (entry); 
+      SCM entry = ly_car (s);
+      SCM type = ly_car (entry);
+      entry = ly_cdr (entry); 
       
-      if (type == push_sym)
+      if (type == ly_symbol2scm ("push"))
        {
-         SCM val = gh_cddr (entry);
-         val = gh_pair_p (val) ? gh_car (val) : SCM_UNDEFINED;
+         SCM val = ly_cddr (entry);
+         val = gh_pair_p (val) ? ly_car (val) : SCM_UNDEFINED;
 
-         apply_pushpop_property (tg, gh_car (entry), gh_cadr (entry), val);
+         apply_pushpop_property (tg, ly_car (entry), ly_cadr (entry), val);
        }
-      else if (type == assign_sym)
+      else if (type == ly_symbol2scm ("assign"))
        {
-         tg->set_property (gh_car (entry), gh_cadr (entry));
+         tg->internal_set_property (ly_car (entry), ly_cadr (entry));
        }
     }
 }
@@ -299,7 +288,7 @@ Translator_def::make_scm ()
 void
 Translator_def::add_property_assign (SCM nm, SCM val)
 {
-  this->property_ops_ = gh_cons (gh_list (assign_sym, scm_string_to_symbol (nm), val, SCM_UNDEFINED),
+  this->property_ops_ = gh_cons (scm_list_n (ly_symbol2scm ("assign"), scm_string_to_symbol (nm), val, SCM_UNDEFINED),
                                 this->property_ops_);
 }
 
@@ -311,7 +300,7 @@ SCM
 Translator_def::default_child_context_name ()
 {
   SCM d = accepts_name_list_;
-  return gh_pair_p (d) ? gh_car (scm_last_pair (d)) : SCM_EOL;
+  return gh_pair_p (d) ? ly_car (scm_last_pair (d)) : SCM_EOL;
 }
 
 SCM