2 grob-interface.cc -- implement graphic objects interface
4 source file of the GNU LilyPond music typesetter
6 (c) 2002--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
9 #include "grob-interface.hh"
12 #include "international.hh"
13 #include "protected-scm.hh"
14 #include "std-string.hh"
15 #include "string-convert.hh"
19 void add_interface (char const *cxx_name,
24 string suffix ("-interface");
25 string lispy_name = camel_case_to_lisp_identifier (cxx_name);
26 vsize end = max (int (0), int (lispy_name.length () - suffix.length ()));
27 if (lispy_name.substr (end) != suffix)
30 if (lispy_name != string (symbol))
31 programming_error (String_convert::form_string ("%s != %s", lispy_name.c_str (),
34 SCM s = ly_symbol2scm (symbol);
35 SCM d = scm_makfrom0str (descr);
36 SCM l = parse_symbol_list (vars);
38 ly_add_interface (s, d, l);
42 check_interfaces_for_property (Grob const *me, SCM sym)
44 if (sym == ly_symbol2scm ("meta"))
47 otherwise we get in a nasty recursion loop.
52 SCM ifs = me->interfaces ();
54 SCM all_ifaces = ly_all_grob_interfaces ();
56 for (; !found && scm_is_pair (ifs); ifs = scm_cdr (ifs))
58 SCM iface = scm_hashq_ref (all_ifaces, scm_car (ifs), SCM_BOOL_F);
59 if (iface == SCM_BOOL_F)
61 string msg = to_string (_f ("Unknown interface `%s'",
62 ly_symbol2string (scm_car (ifs)).c_str ()));
63 programming_error (msg);
67 found = found || (scm_c_memq (sym, scm_caddr (iface)) != SCM_BOOL_F);
72 string str = to_string (_f ("Grob `%s' has no interface for property `%s'",
74 ly_symbol2string (sym).c_str ()));
75 programming_error (str);