]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/translator.cc
* Documentation/user/refman.itely,
[lilypond.git] / lily / translator.cc
index 905266cbeab94cdc7e07db923ebfa4f7a7935c6d..477d2a111b8d87af9308165fa470588d624df066 100644 (file)
@@ -3,22 +3,18 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c)  1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c)  1997--2003 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 */
 
 
 #include "translator.hh"
-#include "debug.hh"
+#include "warn.hh"
 #include "translator-group.hh"
+#include "translator-def.hh"
 
 #include "moment.hh"
 #include "ly-smobs.icc"
 
-char const*
-Translator::name() const
-{
-  return classname(this);
-}
 
 Translator::~Translator ()
 {
@@ -27,28 +23,27 @@ Translator::~Translator ()
 void
 Translator::init ()
 {
-  status_ = ORPHAN;
   simple_trans_list_ = SCM_EOL;
   trans_group_list_ = SCM_EOL;
   properties_scm_ = SCM_EOL;
   definition_ = SCM_EOL;
-  daddy_trans_l_ =0;
+  daddy_trans_ =0;
 }
 
 Translator::Translator ()
 {
+  self_scm_ = SCM_EOL;
   init ();
-  output_def_l_ = 0;
+  output_def_ = 0;
   smobify_self ();
-
 }
 
 Translator::Translator (Translator const &s)
-  : Input (s)
 {
+  self_scm_ = SCM_EOL;
   init ();
-  output_def_l_ = s.output_def_l_;
-  type_str_ = s.type_str_;
+  output_def_ = s.output_def_;
+  type_string_ = s.type_string_;
 
   smobify_self ();
 }
@@ -56,11 +51,17 @@ Translator::Translator (Translator const &s)
 bool
 Translator::is_alias_b (String s) const
 {
-  return s == type_str_;
+  bool b  = s == type_string_;
+
+  for (SCM a = unsmob_translator_def (definition_)->type_aliases_;
+       !b && gh_pair_p (a); a = ly_cdr (a))
+    b = b || s == ly_scm2string (ly_car (a));
+
+  return b;
 }
 
 bool
-Translator::do_try_music (Music *)
+Translator::try_music (Music *)
 {
   return false;
 }
@@ -69,132 +70,49 @@ Translator::do_try_music (Music *)
 Moment
 Translator::now_mom () const
 {
-  return daddy_trans_l_->now_mom ();
-}
-
-
-void
-Translator::add_processing ()
-{
-  if (status_ > ORPHAN)
-    return;
-  
-  do_add_processing ();
-  status_ = VIRGIN;
-}
-
-void
-Translator::do_add_processing ()
-{
-}
-
-
-
-
-
-void
-Translator::creation_processing ()
-{
-  if (status_ >= CREATION_INITED)
-    return ;
-  
-  do_creation_processing ();
-  status_ = CREATION_INITED;
-}
-
-void
-Translator::post_move_processing ()
-{
-  if (status_ >= MOVE_INITED)
-    return;
-
-  creation_processing ();
-  do_post_move_processing ();
-  status_ = MOVE_INITED;
+  return daddy_trans_->now_mom ();
 }
 
 void
 Translator::removal_processing ()
 {
-  if (status_ == ORPHAN)
-    return;
-  creation_processing ();
-  do_removal_processing ();
-  // elegancy ...
-  // status_ = ORPHAN;
-}
-
-
-bool
-Translator::try_music (Music * r)
-{
-  if (status_ < MOVE_INITED)
-    post_move_processing ();
-
-  return do_try_music (r);
+  finalize ();
 }
 
 void
-Translator::process_music ()
+Translator::do_announces ()
 {
-  if (status_ < PROCESSED_REQS)
-    post_move_processing ();
-  else if (status_ >= PROCESSED_REQS)
-    return; 
-  
-  status_ = PROCESSED_REQS;
-  do_process_music ();
 }
 
-void
-Translator::pre_move_processing ()
-{
-  do_pre_move_processing ();
-  status_ = CREATION_INITED;
-}
-
-
-
 Music_output_def *
-Translator::output_def_l () const
-{
-  return output_def_l_;
-}
-
-SCM
-Translator::get_property (char const * id) const
+Translator::get_output_def () const
 {
-  return daddy_trans_l_->get_property (ly_symbol2scm (id));
+  return output_def_;
 }
 
 SCM
-Translator::get_property (SCM sym) const
-{
-  return daddy_trans_l_->get_property (sym);
-}
-
-void
-Translator:: do_pre_move_processing ()
+Translator::internal_get_property (SCM sym) const
 {
+  return daddy_trans_->internal_get_property (sym);
 }
 
 void
-Translator::do_post_move_processing ()
+Translator:: stop_translation_timestep ()
 {
 }
 
 void
-Translator::do_process_music ()
+Translator::start_translation_timestep ()
 {
 }
 
 void
-Translator::do_creation_processing ()
+Translator::initialize ()
 {
 }
 
 void
-Translator::do_removal_processing ()
+Translator::finalize ()
 {
 }
 
@@ -207,7 +125,7 @@ Translator::do_removal_processing ()
 SCM
 Translator::mark_smob (SCM sm)
 {
-  Translator * me = (Translator*) SCM_CELL_WORD_1(sm);
+  Translator * me = (Translator*) SCM_CELL_WORD_1 (sm);
   scm_gc_mark (me->simple_trans_list_);
   scm_gc_mark (me->trans_group_list_);
   scm_gc_mark (me->definition_);  
@@ -216,27 +134,18 @@ Translator::mark_smob (SCM sm)
   return me->properties_scm_;
 }
 
-
-int
-Translator::print_smob (SCM s, SCM port, scm_print_state *)
+SCM
+Translator::translator_description () const
 {
-  Translator *sc = (Translator *) gh_cdr (s);
-     
-  scm_puts ("#<Translator ", port);
-  scm_puts ((char *)sc->name (), port);
-  scm_display (sc->simple_trans_list_, port);
-  /*
-    don't try to print properties, that is too much hassle.
-   */
-  scm_puts (" >", port);
-
-  
-  
-  return 1;
+  return SCM_EOL;
 }
 
+SCM
+Translator::static_translator_description ()const
+{
+  return SCM_EOL;
+}
 
 
-IMPLEMENT_UNSMOB(Translator, translator);
-IMPLEMENT_SMOBS(Translator);
-IMPLEMENT_DEFAULT_EQUAL_P(Translator);
+IMPLEMENT_SMOBS (Translator);
+IMPLEMENT_DEFAULT_EQUAL_P (Translator);