]> git.donarmstrong.com Git - lilypond.git/blob - lily/grob-interface.cc
* flower/include/std-string.hh:
[lilypond.git] / lily / grob-interface.cc
1 /*
2   grob-interface.cc -- implement graphic objects interface
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 2002--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 */
8
9 #include "grob-interface.hh"
10
11 #include "grob.hh"
12 #include "international.hh"
13 #include "protected-scm.hh"
14 #include "std-string.hh"
15 #include "warn.hh"
16
17 void add_interface (char const *symbol,
18                     char const *descr,
19                     char const *vars)
20 {
21   SCM s = ly_symbol2scm (symbol);
22   SCM d = scm_makfrom0str (descr);
23   SCM l = parse_symbol_list (vars);
24
25   ly_add_interface (s, d, l);
26 }
27
28 void
29 check_interfaces_for_property (Grob const *me, SCM sym)
30 {
31   if (sym == ly_symbol2scm ("meta"))
32     {
33       /*
34         otherwise we get in a nasty recursion loop.
35       */
36       return;
37     }
38
39   SCM ifs = me->interfaces ();
40
41   SCM all_ifaces = ly_all_grob_interfaces ();
42   bool found = false;
43   for (; !found && scm_is_pair (ifs); ifs = scm_cdr (ifs))
44     {
45       SCM iface = scm_hashq_ref (all_ifaces, scm_car (ifs), SCM_BOOL_F);
46       if (iface == SCM_BOOL_F)
47         {
48           string msg = to_string (_f ("Unknown interface `%s'",
49                                       ly_symbol2string (scm_car (ifs)).c_str ()));
50           programming_error (msg);
51           continue;
52         }
53
54       found = found || (scm_c_memq (sym, scm_caddr (iface)) != SCM_BOOL_F);
55     }
56
57   if (!found)
58     {
59       string str = to_string (_f ("Grob `%s' has no interface for property `%s'",
60                                   me->name ().c_str (),
61                                   ly_symbol2string (sym).c_str ()));
62       programming_error (str);
63     }
64 }