source file of the GNU LilyPond music typesetter
- (c) 2005--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
+ (c) 2005--2009 Han-Wen Nienhuys <hanwen@xs4all.nl>
*/
#ifndef TRANSLATOR_ICC
#define TRANSLATOR_ICC
+#include "listener.hh"
#include "std-vector.hh"
#include "translator.hh"
+/*
+ TODO: derive "foo-bar-interface" from Foo_bar classname.
+ */
+
/**
A macro to automate administration of translators.
*/
#define ADD_THIS_TRANSLATOR(T) \
+ translator_listener_record *T::listener_list_; \
SCM T::static_description_ = SCM_EOL; \
static void _ ## T ## _adder () \
{ \
} \
ADD_GLOBAL_CTOR (_ ## T ## _adder);
-#define ADD_TRANSLATOR(classname, desc, grobs, accepted, read, write) \
+#define ADD_TRANSLATOR(classname, desc, grobs, read, write) \
Drul_array< vector<Acknowledge_information> > classname::acknowledge_static_array_drul_; \
IMPLEMENT_FETCH_PRECOMPUTABLE_METHODS (classname); \
ADD_THIS_TRANSLATOR (classname); \
SCM \
classname::static_translator_description () const \
{ \
- SCM static_properties = SCM_EOL; \
- /* static_properties = acons (name , gh_str02scm (Translator::name (self_scm ())), \
- static_properties_); \
- */ \
- static_properties = scm_acons (ly_symbol2scm ("grobs-created"), \
- parse_symbol_list (grobs), static_properties); \
- \
- static_properties = scm_acons (ly_symbol2scm ("description"), \
- scm_makfrom0str (desc), static_properties); \
- \
- static_properties = scm_acons (ly_symbol2scm ("events-accepted"), \
- parse_symbol_list (accepted), 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; \
+ return Translator::static_translator_description (grobs, desc, listener_list_, read, write); \
}
#define IMPLEMENT_FETCH_PRECOMPUTABLE_METHODS(T) \
} \
ADD_SCM_INIT_FUNC (CLASS ## NAME ## _end_ack_adder_initclass, CLASS ## NAME ## _end_ack_adder);
+/*
+ Implement the method cl::listen_##m, and make it listen to stream
+ events of class m.
+ */
+#define IMPLEMENT_TRANSLATOR_LISTENER(cl, m) \
+void \
+cl :: _internal_declare_ ## m () \
+{ \
+ static translator_listener_record r; \
+ add_translator_listener (&listener_list_, &r, _get_ ## m ## _listener, #m); \
+} \
+ \
+ADD_SCM_INIT_FUNC (cl ## _declare_event_ ## m, cl::_internal_declare_ ## m); \
+ \
+Listener \
+cl :: _get_ ## m ## _listener (void *me) \
+{ \
+ cl *obj = (cl *) me; \
+ return obj->GET_LISTENER (_listen_scm_ ## m); \
+} \
+ \
+IMPLEMENT_LISTENER (cl, _listen_scm_ ## m) \
+void \
+cl::_listen_scm_ ## m (SCM sev) \
+{ \
+ Stream_event *ev = unsmob_stream_event (sev); \
+ protect_event (sev); \
+ listen_ ## m (ev); \
+}
#endif /* TRANSLATOR_ICC */
-