2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 1997--2015 Han-Wen Nienhuys <hanwen@xs4all.nl>
6 LilyPond is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 LilyPond is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
20 #include "translator.hh"
22 #include "international.hh"
23 #include "scm-hash.hh"
25 #include "protected-scm.hh"
28 should delete these after exit.
31 Protected_scm global_translator_dict;
33 LY_DEFINE (get_all_translators, "ly:get-all-translators", 0, 0, 0, (),
34 "Return a list of all translator objects that may be"
37 Scheme_hash_table *dict = unsmob<Scheme_hash_table> (global_translator_dict);
38 SCM l = dict ? dict->to_alist () : SCM_EOL;
40 for (SCM s = l; scm_is_pair (s); s = scm_cdr (s))
41 scm_set_car_x (s, scm_cdar (s));
47 add_translator (Translator *t)
49 Scheme_hash_table *dict = unsmob<Scheme_hash_table> (global_translator_dict);
52 global_translator_dict = Scheme_hash_table::make_smob ();
53 dict = unsmob<Scheme_hash_table> (global_translator_dict);
56 SCM k = ly_symbol2scm (t->class_name ());
57 dict->set (k, t->unprotect ());
61 get_translator (SCM sym)
64 Scheme_hash_table *dict = unsmob<Scheme_hash_table> (global_translator_dict);
66 dict->try_retrieve (sym, &v);
70 warning (_f ("unknown translator: `%s'", ly_symbol2string (sym).c_str ()));
74 return unsmob<Translator> (v);