Use scalar instead of embedded_scm for context mod overrides.
[lilypond/mpolesky.git] / lily / beam-setting-scheme.cc
blob9ac70202cda9480b452d37302592344fa81412fc
1 /*
2 beam-setting-scheme.cc -- Retrieving beam settings
4 source file of the GNU LilyPond music typesetter
6 Copyright (c) 2009 Carl Sorensen <c_sorensen@byu.edu>
7 */
9 #include "beam-settings.hh"
10 #include "context.hh"
11 #include "guile-compatibility.hh"
13 LY_DEFINE (ly_grouping_rules, "ly:grouping-rules",
14 3, 0, 0, (SCM settings, SCM time_signature, SCM rule_type),
15 "Return grouping rules for @var{time-signature} and"
16 " @var{rule-type} from @var{settings}.")
18 LY_ASSERT_TYPE (ly_cheap_is_list, settings, 1);
19 LY_ASSERT_TYPE (scm_is_pair, time_signature, 2);
20 LY_ASSERT_TYPE (ly_is_symbol, rule_type, 3);
22 SCM grouping_rules = SCM_EOL;
23 if (scm_is_pair (settings))
24 grouping_rules =
25 ly_assoc_get (scm_list_2 (time_signature, rule_type),
26 settings,
27 SCM_EOL);
28 return grouping_rules;
31 LY_DEFINE (ly_beam_grouping, "ly:beam-grouping",
32 4, 0, 0, (SCM settings, SCM time_signature, SCM rule_type,
33 SCM beam_type),
34 "Return grouping for beams of @var{beam-type} in"
35 " @var{time-signature} for"
36 " @var{rule-type} from @var{settings}.")
38 LY_ASSERT_TYPE (ly_cheap_is_list, settings, 1);
39 LY_ASSERT_TYPE (scm_is_pair, time_signature, 2);
40 LY_ASSERT_TYPE (ly_is_symbol, rule_type, 3);
41 SCM_ASSERT_TYPE (scm_is_symbol(beam_type) || scm_is_pair(beam_type),
42 beam_type, SCM_ARG4, __FUNCTION__, "symbol or pair");
43 SCM beam_grouping =
44 ly_assoc_get (beam_type,
45 ly_grouping_rules (settings,time_signature,rule_type),
46 SCM_EOL);
47 return beam_grouping;
50 LY_DEFINE (ly_beat_grouping, "ly:beat-grouping",
51 1, 0, 0, (SCM context),
52 "Return default beat grouping currently active in @var{context}.")
54 LY_ASSERT_SMOB (Context, context, 1);
55 Context *c = unsmob_context (context);
56 SCM time_signature =
57 c->get_property ("timeSignatureFraction");
58 SCM settings =
59 c->get_property("beamSettings");
60 SCM beat_grouping =
61 ly_beam_grouping (settings,
62 time_signature,
63 ly_symbol2scm ("end"),
64 ly_symbol2scm ("*"));
65 return beat_grouping;