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>
9 #include "translator.hh"
11 #include "international.hh"
12 #include "scm-hash.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"
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
));
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 ());
46 get_translator (SCM sym
)
49 if (global_translator_dict
)
50 global_translator_dict
->try_retrieve (sym
, &v
);
53 error (_f ("unknown translator: `%s'", ly_symbol2string (sym
).c_str ()));
55 return unsmob_translator (v
);