staff-symbol-referencer.cc: Junk redundant functions.
[lilypond.git] / lily / translator-ctors.cc
blobc024abe38858c3d016101e752eb4aa6a7c83d587
1 /*
2 translator-ctors.cc -- implement Translator construction
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2007 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 */
9 #include "translator.hh"
11 #include "international.hh"
12 #include "scm-hash.hh"
13 #include "warn.hh"
16 should delete these after exit.
19 Scheme_hash_table *global_translator_dict = 0;
21 LY_DEFINE (get_all_translators, "ly:get-all-translators", 0, 0, 0, (),
22 "Return a list of all translator objects that may be"
23 " instantiated.")
25 SCM l = global_translator_dict ? global_translator_dict->to_alist () : SCM_EOL;
27 for (SCM s = l; scm_is_pair (s); s = scm_cdr (s))
28 scm_set_car_x (s, scm_cdar (s));
30 return l;
33 void
34 add_translator (Translator *t)
36 if (!global_translator_dict)
37 global_translator_dict = new Scheme_hash_table;
39 SCM k = ly_symbol2scm (t->class_name ());
40 global_translator_dict->set (k, t->self_scm ());
42 t->unprotect ();
45 Translator *
46 get_translator (SCM sym)
48 SCM v = SCM_BOOL_F;
49 if (global_translator_dict)
50 global_translator_dict->try_retrieve (sym, &v);
52 if (v == SCM_BOOL_F)
53 error (_f ("unknown translator: `%s'", ly_symbol2string (sym).c_str ()));
55 return unsmob_translator (v);