2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 2002--2011 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 "grob-interface.hh"
23 #include "international.hh"
24 #include "protected-scm.hh"
25 #include "string-convert.hh"
29 SCM add_interface (char const *cxx_name,
33 string suffix ("-interface");
34 string lispy_name = camel_case_to_lisp_identifier (cxx_name);
35 vsize end = max (int (0), int (lispy_name.length () - suffix.length ()));
36 if (lispy_name.substr (end) != suffix)
39 SCM s = ly_symbol2scm (lispy_name.c_str ());
40 SCM d = scm_from_locale_string (descr);
41 SCM l = parse_symbol_list (vars);
43 internal_add_interface (s, d, l);
49 check_interfaces_for_property (Grob const *me, SCM sym)
51 if (sym == ly_symbol2scm ("meta"))
54 otherwise we get in a nasty recursion loop.
59 SCM ifs = me->interfaces ();
61 SCM all_ifaces = ly_all_grob_interfaces ();
63 for (; !found && scm_is_pair (ifs); ifs = scm_cdr (ifs))
65 SCM iface = scm_hashq_ref (all_ifaces, scm_car (ifs), SCM_BOOL_F);
66 if (iface == SCM_BOOL_F)
68 string msg = to_string (_f ("Unknown interface `%s'",
69 ly_symbol2string (scm_car (ifs)).c_str ()));
70 programming_error (msg);
74 found = found || (scm_c_memq (sym, scm_caddr (iface)) != SCM_BOOL_F);
79 string str = to_string (_f ("Grob `%s' has no interface for property `%s'",
81 ly_symbol2string (sym).c_str ()));
82 programming_error (str);