source file of the GNU LilyPond music typesetter
- (c) 1997--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
+ (c) 1997--2008 Han-Wen Nienhuys <hanwen@xs4all.nl>
*/
#include "translator.hh"
LY_DEFINE (ly_get_listened_event_classes, "ly:get-listened-event-classes",
0, 0, 0, (),
- "Returns a list of all event classes that some translator listens to.")
+ "Return a list of all event classes that some translator listens"
+ " to.")
{
ensure_listened_hash ();
return ly_hash_table_keys (listened_event_class_table);
{
/* ev_class is the C++ identifier name. Convert to scm symbol */
string name = string (ev_class);
- name = replace_all (name, '_', '-');
+ name = replace_all (&name, '_', '-');
name += "-event";
SCM class_sym = scm_str2symbol (name.c_str ());
}
/*
- Used by ADD_THIS_TRANSLATOR to extract a list of event-class names
- for each translator. This list is used by the internals
- documentation.
+ Helps the individual static_translator_description methods of translators.
*/
SCM
-Translator::get_listened_class_list (const translator_listener_record *listeners) const
+Translator::static_translator_description (const char *grobs,
+ const char *desc,
+ translator_listener_record *listener_list,
+ const char *read,
+ const char *write) const
{
+ SCM static_properties = SCM_EOL;
+
+ static_properties = scm_acons (ly_symbol2scm ("grobs-created"),
+ parse_symbol_list (grobs), static_properties);
+
+ static_properties = scm_acons (ly_symbol2scm ("description"),
+ scm_from_locale_string (desc), static_properties);
+
SCM list = SCM_EOL;
- for (; listeners; listeners = listeners->next_)
- list = scm_cons (listeners->event_class_, list);
- return list;
+ for (; listener_list; listener_list = listener_list->next_)
+ list = scm_cons (listener_list->event_class_, list);
+ static_properties = scm_acons (ly_symbol2scm ("events-accepted"),
+ list, static_properties);
+
+ static_properties = scm_acons (ly_symbol2scm ("properties-read"),
+ parse_symbol_list (read), static_properties);
+
+ static_properties = scm_acons (ly_symbol2scm ("properties-written"),
+ parse_symbol_list (write), static_properties);
+
+ return static_properties;
}
-
+
/*
SMOBS
*/
string interface_name (func_name);
- interface_name = replace_all (interface_name, '_', '-');
+ interface_name = replace_all (&interface_name, '_', '-');
interface_name += "-interface";
/*
- this is only called during program init, so safe to use scm_gc_protect_object()
+ this is only called during program init, so safe to use scm_gc_protect_object ()
*/
inf.symbol_ = scm_gc_protect_object (ly_symbol2scm (interface_name.c_str ()));
ack_array->push_back (inf);
return 0;
}
+
Moment
get_event_length (Stream_event *e)
{
return Moment (0);
}
+Moment
+get_event_length (Stream_event *e, Moment now)
+{
+ Moment len = get_event_length (e);
+
+ if (now.grace_part_)
+ {
+ len.grace_part_ = len.main_part_;
+ len.main_part_ = Rational (0);
+ }
+ return len;
+}
+
/*
Helper, used through ASSIGN_EVENT_ONCE to throw warnings for
simultaneous events. The helper is only useful in listen_* methods
bool
internal_event_assignment (Stream_event **old_ev, Stream_event *new_ev, const char *function)
{
- if (*old_ev)
+ if (*old_ev &&
+ !to_boolean (scm_equal_p ((*old_ev)->self_scm (),
+ new_ev->self_scm ())))
{
/* extract event class from function name */
- const char *prefix = "listen_";
string ev_class = function;
+
/* This assertion fails if EVENT_ASSIGNMENT was called outside a
translator listener. Don't do that. */
+ const char *prefix = "listen_";
assert (0 == ev_class.find (prefix));
/* "listen_foo_bar" -> "foo-bar" */
- ev_class.erase (0, strlen(prefix));
- replace_all (ev_class, '_', '-');
+ ev_class.erase (0, strlen (prefix));
+ replace_all (&ev_class, '_', '-');
new_ev->origin ()->warning (_f ("Two simultaneous %s events, junking this one", ev_class.c_str ()));
(*old_ev)->origin ()->warning (_f ("Previous %s event here", ev_class.c_str ()));
}
ADD_TRANSLATOR (Translator,
- "Base class. Unused",
- "",
+ /* doc */
+ "Base class. Not instantiated.",
+
+ /* create */
"",
+
+ /* read */
"",
- "");
+
+ /* write */
+ ""
+ );