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--2019 Han-Wen Nienhuys <hanwen@xs4all.nl> | 4 Copyright (C) 1997--2019 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 template <class T> Translator * | 68 template <class T> Translator * |
69 Translator_creator::allocate (Context *ctx) | 69 Translator_creator::allocate (Context *ctx) |
70 { | 70 { |
71 return new T(ctx); | 71 return new T(ctx); |
72 } | 72 } |
73 | 73 |
74 #define TRANSLATOR_FAMILY_DECLARATIONS(NAME) \ | 74 #define TRANSLATOR_FAMILY_DECLARATIONS(NAME) \ |
75 public: \ | 75 public: \ |
76 DECLARE_CLASSNAME (NAME); \ | 76 DECLARE_CLASSNAME (NAME); \ |
77 virtual void fetch_precomputable_methods (SCM methods[]); \ | 77 virtual void fetch_precomputable_methods (SCM methods[]); \ |
78 DECLARE_TRANSLATOR_CALLBACKS (NAME); \ | 78 /* Fallback for non-overriden callbacks for which &T::x degrades to \ |
79 TRANSLATOR_INHERIT (Translator); \ | 79 &Translator::x */ \ |
| 80 template <void (Translator::*)()> \ |
| 81 static SCM method_finder () \ |
| 82 { \ |
| 83 return SCM_UNDEFINED; \ |
| 84 } \ |
| 85 DECLARE_TRANSLATOR_CALLBACKS (NAME) \ |
80 /* end #define */ | 86 /* end #define */ |
81 | 87 |
82 #define TRANSLATOR_INHERIT(BASE) \ | 88 #define TRANSLATOR_INHERIT(BASE) \ |
83 using BASE::method_finder | 89 DECLARE_TRANSLATOR_CALLBACKS (BASE) |
84 | 90 |
85 #define DECLARE_TRANSLATOR_CALLBACKS(NAME) \ | 91 #define DECLARE_TRANSLATOR_CALLBACKS(NAME) \ |
86 template <void (NAME::*mf)()> \ | 92 template <void (NAME::*mf)()> \ |
87 static SCM method_finder () \ | 93 static SCM method_finder () \ |
88 { \ | 94 { \ |
89 return Callback0_wrapper::make_smob<NAME, mf> (); \ | 95 return Callback0_wrapper::make_smob<NAME, mf> (); \ |
90 } \ | 96 } \ |
91 template <void (NAME::*mf)(Stream_event *)> \ | 97 template <void (NAME::*mf)(Stream_event *)> \ |
92 static SCM method_finder () \ | 98 static SCM method_finder () \ |
93 { \ | 99 { \ |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 { | 196 { |
191 T *t = unsmob<T> (target); | 197 T *t = unsmob<T> (target); |
192 LY_ASSERT_SMOB (T, target, 1); | 198 LY_ASSERT_SMOB (T, target, 1); |
193 LY_ASSERT_SMOB (Stream_event, event, 2); | 199 LY_ASSERT_SMOB (Stream_event, event, 2); |
194 | 200 |
195 t->protect_event (event); | 201 t->protect_event (event); |
196 (t->*callback) (unsmob<Stream_event> (event)); | 202 (t->*callback) (unsmob<Stream_event> (event)); |
197 return SCM_UNSPECIFIED; | 203 return SCM_UNSPECIFIED; |
198 } | 204 } |
199 | 205 |
200 // Fallback for non-overriden callbacks for which &T::x degrades to | |
201 // &Translator::x | |
202 template <void (Translator::*)()> | |
203 static SCM | |
204 method_finder () { return SCM_UNDEFINED; } | |
205 | |
206 virtual void derived_mark () const; | 206 virtual void derived_mark () const; |
207 static SCM event_class_symbol (const char *ev_class); | 207 static SCM event_class_symbol (const char *ev_class); |
208 static SCM | 208 static SCM |
209 static_translator_description (const char *grobs, | 209 static_translator_description (const char *grobs, |
210 const char *desc, | 210 const char *desc, |
211 SCM listener_list, | 211 SCM listener_list, |
212 const char *read, | 212 const char *read, |
213 const char *write); | 213 const char *write); |
214 | 214 |
215 friend class Translator_group; | 215 friend class Translator_group; |
216 }; | 216 }; |
217 | 217 |
218 SCM | 218 SCM |
219 generic_get_acknowledger (SCM sym, SCM ack_hash); | 219 generic_get_acknowledger (SCM sym, SCM ack_hash); |
220 | 220 |
221 void add_translator_creator (SCM creator, SCM name, SCM description); | 221 void add_translator_creator (SCM creator, SCM name, SCM description); |
222 | 222 |
223 SCM get_translator_creator (SCM s); | 223 SCM get_translator_creator (SCM s); |
224 Moment get_event_length (Stream_event *s, Moment now); | 224 Moment get_event_length (Stream_event *s, Moment now); |
225 Moment get_event_length (Stream_event *s); | 225 Moment get_event_length (Stream_event *s); |
226 | 226 |
227 #endif // TRANSLATOR_HH | 227 #endif // TRANSLATOR_HH |
OLD | NEW |