for (SCM s = trans_names; scm_is_pair (s); s = scm_cdr (s))
{
- SCM definition = scm_car (s);
- bool is_scheme = false;
-
- Translator *type = 0;
- if (ly_is_symbol (definition))
- type = get_translator (definition);
- else if (ly_is_pair (definition))
- {
- is_scheme = true;
- }
- else if (ly_is_procedure (definition))
+ SCM trans = scm_car (s);
+
+ if (ly_is_symbol (trans))
+ trans = get_translator_creator (trans);
+ if (ly_is_procedure (trans))
+ trans = scm_call_1 (trans, cs);
+ if (ly_cheap_is_list (trans))
+ trans = (new Scheme_engraver (trans, new_context))->unprotect ();
+ Translator *instance = unsmob<Translator> (trans);
+ if (!instance)
{
- // `definition' is a procedure, which takes the context as
- // an argument and evaluates to an a-list scheme engraver
- // definition.
- definition = scm_call_1 (definition, cs);
- is_scheme = true;
+ warning (_f ("cannot find: `%s'", ly_scm_write_string (trans).c_str ()));
+ continue;
}
- if (!is_scheme && !type)
- warning (_f ("cannot find: `%s'", ly_symbol2string (scm_car (s)).c_str ()));
- else
+ if (instance->must_be_last ())
{
- Translator *instance = is_scheme ? new Scheme_engraver (definition)
- : type->clone ();
-
- SCM str = instance->self_scm ();
-
- if (instance->must_be_last ())
- {
- SCM cons = scm_cons (str, SCM_EOL);
- if (scm_is_pair (trans_list))
- scm_set_cdr_x (scm_last_pair (trans_list), cons);
- else
- trans_list = cons;
- }
+ SCM cons = scm_cons (trans, SCM_EOL);
+ if (scm_is_pair (trans_list))
+ scm_set_cdr_x (scm_last_pair (trans_list), cons);
else
- trans_list = scm_cons (str, trans_list);
-
- instance->daddy_context_ = new_context;
- instance->unprotect ();
+ trans_list = cons;
}
+ else
+ trans_list = scm_cons (trans, trans_list);
+
}
/* Filter unwanted translator types. Required to make
if (tg && dir == DOWN)
{
tg->precomputed_translator_foreach (idx);
- tg->call_precomputed_self_method (idx);
}
for (SCM s = c->children_contexts (); scm_is_pair (s);
if (tg && dir == UP)
{
tg->precomputed_translator_foreach (idx);
- tg->call_precomputed_self_method (idx);
}
}
}
}
- fetch_precomputable_methods (precomputed_self_method_bindings_);
}
void
bindings[i]();
}
-void
-Translator_group::fetch_precomputable_methods (SCM ptrs[])
-{
- for (int i = 0; i < TRANSLATOR_METHOD_PRECOMPUTE_COUNT; i++)
- ptrs[i] = SCM_UNDEFINED;
-}
-
-void
-Translator_group::call_precomputed_self_method (Translator_precompute_index idx)
-{
- if (!SCM_UNBNDP (precomputed_self_method_bindings_[idx]))
- scm_call_1 (precomputed_self_method_bindings_[idx], self_scm ());
-}
-
Translator_group::~Translator_group ()
{
}
-const char Translator_group::type_p_name_[] = "ly:translator-group?";
+const char * const Translator_group::type_p_name_ = "ly:translator-group?";
int
Translator_group::print_smob (SCM port, scm_print_state *) const