]> git.donarmstrong.com Git - lilypond.git/blob - lily/translator-scheme.cc
* scm/auto-beam.scm (revert-property-setting): Bugfixes: add
[lilypond.git] / lily / translator-scheme.cc
1 /*
2   translator-scheme.cc -- implement Scheme context functions
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 2002--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8
9 #include "context-def.hh"
10 #include "translator-group.hh"
11 #include "moment.hh"
12
13 LY_DEFINE (ly_translator_name, "ly:translator-name",
14            1, 0, 0, (SCM trans),
15            "Return the type name of the translator object @var{trans}. "
16            "The name is a symbol.")
17 {
18   Translator *tr = unsmob_translator (trans);
19   SCM_ASSERT_TYPE (tr, trans, SCM_ARG1, __FUNCTION__, "Translator");
20   char const *nm = classname (tr);
21   return ly_symbol2scm (nm);
22 }
23
24 LY_DEFINE (ly_translator_now, "ly:translator-now",
25            1, 0, 0, (SCM trans),
26            "Return now-moment of translater TRANS")
27 {
28   Translator *tr = unsmob_translator (trans);
29   SCM_ASSERT_TYPE (tr, trans, SCM_ARG1, __FUNCTION__, "Translator");
30   return tr->now_mom ().smobbed_copy ();
31 }
32
33 LY_DEFINE (ly_translator_description, "ly:translator-description",
34            1, 0, 0, (SCM me),
35            "Return an alist of properties of  translator @var{me}.")
36 {
37   Translator *tr = unsmob_translator (me);
38   SCM_ASSERT_TYPE (tr, me, SCM_ARG1, __FUNCTION__, "Translator");
39   return tr->translator_description ();
40 }
41
42 LY_DEFINE (ly_translator_property, "ly:translator-property",
43            2, 0, 0, (SCM translator, SCM sym),
44            "Return the value of a value in translator @var{g} of property @var{sym}. "
45            "It will return @code{' ()} (end-of-list) "
46            "if  @var{sym} is undefined in @var{g}."
47            "\n\n")
48 {
49   Translator *sc = unsmob_translator (translator);
50   SCM_ASSERT_TYPE (sc, translator, SCM_ARG1, __FUNCTION__, "translator");
51   SCM_ASSERT_TYPE (scm_is_symbol (sym), sym, SCM_ARG2, __FUNCTION__, "symbol");
52
53   return sc->internal_get_property (sym);
54 }
55
56 int
57 Translator::print_smob (SCM s, SCM port, scm_print_state *)
58 {
59   Translator *me = (Translator *) SCM_CELL_WORD_1 (s);
60   scm_puts ("#<Translator ", port);
61   scm_puts (classname (me), port);
62   scm_puts (" >", port);
63   return 1;
64 }
65