OLD | NEW |
1 /* | 1 /* |
2 This file is part of LilyPond, the GNU music typesetter. | 2 This file is part of LilyPond, the GNU music typesetter. |
3 | 3 |
4 Copyright (C) 1997--2015 Han-Wen Nienhuys <hanwen@xs4all.nl> | 4 Copyright (C) 1997--2015 Han-Wen Nienhuys <hanwen@xs4all.nl> |
5 | 5 |
6 LilyPond is free software: you can redistribute it and/or modify | 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 | 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 | 8 the Free Software Foundation, either version 3 of the License, or |
9 (at your option) any later version. | 9 (at your option) any later version. |
10 | 10 |
(...skipping 20 matching lines...) Expand all Loading... |
31 | 31 |
32 #define TRANSLATOR_FAMILY_DECLARATIONS(NAME) \ | 32 #define TRANSLATOR_FAMILY_DECLARATIONS(NAME) \ |
33 public: \ | 33 public: \ |
34 VIRTUAL_COPY_CONSTRUCTOR (Translator, NAME); \ | 34 VIRTUAL_COPY_CONSTRUCTOR (Translator, NAME); \ |
35 virtual void fetch_precomputable_methods (SCM methods[]); \ | 35 virtual void fetch_precomputable_methods (SCM methods[]); \ |
36 DECLARE_TRANSLATOR_CALLBACKS (NAME); \ | 36 DECLARE_TRANSLATOR_CALLBACKS (NAME); \ |
37 TRANSLATOR_INHERIT (Translator) \ | 37 TRANSLATOR_INHERIT (Translator) \ |
38 /* end #define */ | 38 /* end #define */ |
39 | 39 |
40 #define TRANSLATOR_INHERIT(BASE) \ | 40 #define TRANSLATOR_INHERIT(BASE) \ |
41 using BASE::method_finder; \ | 41 using BASE::method_finder; |
42 using BASE::ack_finder; | |
43 | 42 |
44 #define DECLARE_TRANSLATOR_CALLBACKS(NAME) \ | 43 #define DECLARE_TRANSLATOR_CALLBACKS(NAME) \ |
45 template <void (NAME::*mf)()> \ | 44 template <void (NAME::*mf)()> \ |
46 static SCM method_finder () { return method_find_base<NAME, mf> (); } \ | 45 static SCM method_finder () { return method_find_base<NAME, mf> (); } \ |
47 template <void (NAME::*callback)(Grob_info)> \ | |
48 static SCM ack_finder () { return ack_find_base<NAME, callback> (); } \ | |
49 /* end #define */ | 46 /* end #define */ |
50 | 47 |
51 /* | 48 /* |
52 Each translator class has a static alist of event class symbols | 49 Each translator class has a static alist of event class symbols |
53 mapping to callbacks that are called with a translator instance and | 50 mapping to callbacks that are called with a translator instance and |
54 a stream event when an event of the appropriate event class is | 51 a stream event when an event of the appropriate event class is |
55 announced in a context. | 52 announced in a context. |
56 */ | 53 */ |
57 | 54 |
58 #define TRANSLATOR_DECLARATIONS(NAME) \ | 55 #define TRANSLATOR_DECLARATIONS(NAME) \ |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 template <class T, void (T::*mf)()> | 164 template <class T, void (T::*mf)()> |
168 static SCM | 165 static SCM |
169 method_find_base () { return Callback0_wrapper::make_smob<T, mf> (); } | 166 method_find_base () { return Callback0_wrapper::make_smob<T, mf> (); } |
170 | 167 |
171 // Fallback for non-overriden callbacks for which &T::x degrades to | 168 // Fallback for non-overriden callbacks for which &T::x degrades to |
172 // &Translator::x | 169 // &Translator::x |
173 template <void (Translator::*)()> | 170 template <void (Translator::*)()> |
174 static SCM | 171 static SCM |
175 method_finder () { return SCM_UNDEFINED; } | 172 method_finder () { return SCM_UNDEFINED; } |
176 | 173 |
177 // Overriden in Engraver. | |
178 template <class T, void (T::*callback)(Grob_info)> | |
179 static SCM | |
180 ack_find_base () { return SCM_UNDEFINED; } | |
181 | |
182 template <void (Translator::*)(Grob_info)> | |
183 static SCM | |
184 ack_finder () { return SCM_UNDEFINED; } | |
185 | |
186 virtual void derived_mark () const; | 174 virtual void derived_mark () const; |
187 static SCM event_class_symbol (const char *ev_class); | 175 static SCM event_class_symbol (const char *ev_class); |
188 SCM static_translator_description (const char *grobs, | 176 SCM static_translator_description (const char *grobs, |
189 const char *desc, | 177 const char *desc, |
190 SCM listener_list, | 178 SCM listener_list, |
191 const char *read, | 179 const char *read, |
192 const char *write) const; | 180 const char *write) const; |
193 | 181 |
194 friend class Translator_group; | 182 friend class Translator_group; |
195 }; | 183 }; |
196 | 184 |
197 void add_translator (Translator *trans); | 185 void add_translator (Translator *trans); |
198 | 186 |
199 Translator *get_translator (SCM s); | 187 Translator *get_translator (SCM s); |
200 | 188 |
201 SCM | 189 SCM |
202 generic_get_acknowledger (SCM sym, SCM ack_hash); | 190 generic_get_acknowledger (SCM sym, SCM ack_hash); |
203 | 191 |
204 Moment get_event_length (Stream_event *s, Moment now); | 192 Moment get_event_length (Stream_event *s, Moment now); |
205 Moment get_event_length (Stream_event *s); | 193 Moment get_event_length (Stream_event *s); |
206 | 194 |
207 /* | 195 /* |
208 This helper is only meaningful inside listen_* methods. | 196 This helper is only meaningful inside listen_* methods. |
209 */ | 197 */ |
210 extern bool internal_event_assignment (Stream_event **old_ev, Stream_event *new_
ev, const char *function); | 198 extern bool internal_event_assignment (Stream_event **old_ev, Stream_event *new_
ev, const char *function); |
211 #define ASSIGN_EVENT_ONCE(o,n) internal_event_assignment (&o, n, __FUNCTION__) | 199 #define ASSIGN_EVENT_ONCE(o,n) internal_event_assignment (&o, n, __FUNCTION__) |
212 | 200 |
213 #endif // TRANSLATOR_HH | 201 #endif // TRANSLATOR_HH |
OLD | NEW |