2 translator-ctors.cc -- implement Translator construction
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
9 #include "translator.hh"
10 #include "scm-hash.hh"
14 should delete these after exit.
17 Scheme_hash_table *global_translator_dict = 0;
19 LY_DEFINE (get_all_translators, "ly:get-all-translators", 0, 0, 0, (),
20 "Return a list of all translator objects that may be instantiated. ")
22 SCM l = global_translator_dict ? global_translator_dict->to_alist () : SCM_EOL;
24 for (SCM s = l; scm_is_pair (s); s = scm_cdr (s))
25 scm_set_car_x (s, scm_cdar (s));
31 add_translator (Translator *t)
33 if (!global_translator_dict)
34 global_translator_dict = new Scheme_hash_table;
36 SCM k = ly_symbol2scm (t->class_name ());
37 global_translator_dict->set (k, t->self_scm ());
43 get_translator (SCM sym)
46 if (global_translator_dict)
47 global_translator_dict->try_retrieve (sym, &v);
50 error (_f ("unknown translator: `%s'", ly_symbol2string (sym).to_str0 ()));
52 return unsmob_translator (v);