/*
- translator.icc -- declare Translator glue wiring.
+ This file is part of LilyPond, the GNU music typesetter.
- source file of the GNU LilyPond music typesetter
+ Copyright (C) 2005--2009 Han-Wen Nienhuys <hanwen@xs4all.nl>
- (c) 2005--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
+ LilyPond is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ LilyPond is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TRANSLATOR_ICC
#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 () \
{ \
{ \
return static_description_; \
} \
- ADD_GLOBAL_CTOR (_ ## T ## _adder);
+ ADD_GLOBAL_CTOR (_ ## T ## _adder); \
+ /* end define */
+
+#define DEFINE_TRANSLATOR_LISTENER_LIST(T) \
+ translator_listener_record *T::listener_list_; \
+ /* end define */
-#define ADD_TRANSLATOR(classname, desc, grobs, accepted, read, write) \
+#define DEFINE_ACKNOWLEDGERS(classname) \
Drul_array< vector<Acknowledge_information> > classname::acknowledge_static_array_drul_; \
- IMPLEMENT_FETCH_PRECOMPUTABLE_METHODS (classname); \
- ADD_THIS_TRANSLATOR (classname); \
Engraver_void_function_engraver_grob_info \
classname::static_get_acknowledger (SCM sym) \
{ \
{ \
return generic_get_acknowledger (sym, &acknowledge_static_array_drul_[STOP]); \
} \
+ /* end define */
+
+#define DEFINE_TRANSLATOR_DOC(classname, desc, grobs, read, write) \
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 ADD_TRANSLATOR(classname, desc, grobs, read, write) \
+ IMPLEMENT_FETCH_PRECOMPUTABLE_METHODS (classname); \
+ ADD_THIS_TRANSLATOR (classname); \
+ DEFINE_TRANSLATOR_DOC(classname, desc, grobs, read, write) \
+ DEFINE_ACKNOWLEDGERS(classname) \
+ DEFINE_TRANSLATOR_LISTENER_LIST(classname) \
+
#define IMPLEMENT_FETCH_PRECOMPUTABLE_METHODS(T) \
void \
T::fetch_precomputable_methods (Translator_void_method_ptr ptrs[]) \
ADD_SCM_INIT_FUNC (cl ## _declare_event_ ## m, cl::_internal_declare_ ## m); \
\
Listener \
-cl :: _get_ ## m ## _listener (void *me) \
+ cl :: _get_ ## m ## _listener (void *me, SCM unused) \
{ \
cl *obj = (cl *) me; \
+ (void) unused; \
return obj->GET_LISTENER (_listen_scm_ ## m); \
} \
\