]> git.donarmstrong.com Git - lilypond.git/blob - lily/translator-ctors.cc
release: 1.5.13
[lilypond.git] / lily / translator-ctors.cc
1 /*
2   translator-ctors.cc -- implement Translator construction
3
4   source file of the GNU LilyPond music typesetter
5
6   (c)  1997--2001 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8
9 #include "translator.hh"
10 #include "dictionary.hh"
11 #include "debug.hh"
12
13 /*
14   should delete these after exit.
15  */
16
17 /*
18   UGH. Dictionary is deprecated
19  */
20 Dictionary<Translator*> *global_translator_dict_p=0;
21
22
23 SCM
24 ly_get_all_translators ()
25 {
26   SCM l = SCM_EOL;
27   for (std::map<String,Translator*>::const_iterator (ci (global_translator_dict_p->begin()));
28        ci != global_translator_dict_p->end (); ci++)
29     {
30       l = scm_cons ((*ci).second->self_scm (), l);
31     }
32   return l;
33 }
34
35 static void
36 all_trans_init()
37 {
38   scm_c_define_gsubr ("ly-get-all-translators", 0, 0, 0, (Scheme_function_unknown) ly_get_all_translators);
39 }
40
41 ADD_SCM_INIT_FUNC(all_trans_init,all_trans_init);
42
43 void
44 add_translator (Translator *t)
45 {
46   if (!global_translator_dict_p)
47     global_translator_dict_p = new Dictionary<Translator*>;
48
49  (*global_translator_dict_p)[classname (t)] = t;
50 }
51
52 Translator*
53 get_translator_l (String s)
54 {
55   if (global_translator_dict_p->elem_b (s))
56     {
57         Translator* t = (*global_translator_dict_p)[s];
58         return t;
59     }
60
61   error (_f ("unknown translator: `%s'", s));
62   return 0;
63 }
64