]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/include/translator.hh
Imported Upstream version 2.14.2
[lilypond.git] / lily / include / translator.hh
index f5065f50b25e3f613bc61bcb107a149b3defd56b..d2723929ee83c9671f448da8e73e115a5b942925 100644 (file)
@@ -1,9 +1,20 @@
 /*
-  translator.hh -- declare Translator
+  This file is part of LilyPond, the GNU music typesetter.
 
-  source file of the GNU LilyPond music typesetter
+  Copyright (C) 1997--2011 Han-Wen Nienhuys <hanwen@xs4all.nl>
 
-  (c) 1997--2009 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_HH
@@ -21,6 +32,11 @@ struct Acknowledge_information
 {
   SCM symbol_;
   Engraver_void_function_engraver_grob_info function_;
+
+  Acknowledge_information () {
+    symbol_ = SCM_EOL;
+    function_ = 0;
+  }
 };
 
 
@@ -30,14 +46,21 @@ struct Acknowledge_information
   listeners to a context.
 */
 typedef struct translator_listener_record {
-  Listener (*get_listener_) (void *);
+  Listener (*get_listener_) (void *, SCM event_class);
   SCM event_class_;
   struct translator_listener_record *next_;
+
+  translator_listener_record () {
+    next_ = 0;
+    event_class_ = SCM_EOL;
+    get_listener_ = 0;
+  }
+    
 } translator_listener_record;
 
-#define TRANSLATOR_DECLARATIONS(NAME)                                  \
+
+#define TRANSLATOR_DECLARATIONS_NO_LISTENER(NAME)                       \
 private:                                                               \
-  static translator_listener_record *listener_list_;                   \
   public:                                                              \
   NAME ();                                                             \
   VIRTUAL_COPY_CONSTRUCTOR (Translator, NAME);                         \
@@ -46,6 +69,8 @@ private:                                                              \
   virtual void fetch_precomputable_methods (Translator_void_method_ptr methods[]); \
   virtual SCM static_translator_description () const;                  \
   virtual SCM translator_description () const;                         \
+  static Engraver_void_function_engraver_grob_info static_get_acknowledger (SCM sym); \
+  static Engraver_void_function_engraver_grob_info static_get_end_acknowledger(SCM); \
   virtual Engraver_void_function_engraver_grob_info get_acknowledger (SCM sym) \
   {                                                                    \
     return static_get_acknowledger (sym);                              \
@@ -54,8 +79,12 @@ private:                                                             \
   {                                                                    \
     return static_get_end_acknowledger (sym);                          \
   } \
-  static Engraver_void_function_engraver_grob_info static_get_acknowledger (SCM sym); \
-  static Engraver_void_function_engraver_grob_info static_get_end_acknowledger(SCM); \
+  /* end #define */
+
+#define TRANSLATOR_DECLARATIONS(NAME)                                  \
+  TRANSLATOR_DECLARATIONS_NO_LISTENER(NAME)                            \
+private:                                                               \
+  static translator_listener_record *listener_list_;                   \
 public:                                                                        \
   virtual translator_listener_record *get_listener_list () const       \
   {                                                                    \
@@ -69,7 +98,7 @@ inline void listen_ ## m (Stream_event *);            \
 /* Should be private */                                        \
 static void _internal_declare_ ## m ();                        \
 private:                                               \
-static Listener _get_ ## m ## _listener (void *);      \
+ static Listener _get_ ## m ## _listener (void *, SCM);        \
 DECLARE_LISTENER (_listen_scm_ ## m);
 
 #define DECLARE_ACKNOWLEDGER(x) public : void acknowledge_ ## x (Grob_info); protected:
@@ -91,12 +120,7 @@ class Translator
 {
   void init ();
 
-protected:
-  bool must_be_last_;
-
 public:
-  bool must_be_last () const;
-
   Context *context () const { return daddy_context_; }
 
   Translator (Translator const &);
@@ -106,11 +130,12 @@ public:
   virtual Output_def *get_output_def () const;
   virtual Translator_group *get_daddy_translator ()const;
   virtual Moment now_mom () const;
+  virtual bool must_be_last () const;
 
   virtual void initialize ();
   virtual void finalize ();
 
-  /*should maybe be virtual*/
+  /* should maybe be virtual */
   void connect_to_context (Context *c);
   void disconnect_from_context (Context *c);
 
@@ -129,7 +154,10 @@ protected:                 // should be private.
   Context *daddy_context_;
   void protect_event (SCM ev);
   virtual void derived_mark () const;
-  static void add_translator_listener (translator_listener_record **listener_list, translator_listener_record *r, Listener (*get_listener) (void *), const char *ev_class);
+  static void add_translator_listener (translator_listener_record **listener_list,
+                                      translator_listener_record *r,
+                                      Listener (*get_listener) (void *, SCM),
+                                      const char *ev_class);
   SCM static_translator_description (const char *grobs, 
                                     const char *desc,
                                     translator_listener_record *listener_list,
@@ -138,6 +166,7 @@ protected:                  // should be private.
 
   friend class Translator_group;
 };
+
 void add_translator (Translator *trans);
 
 Translator *get_translator (SCM s);
@@ -153,4 +182,5 @@ extern bool internal_event_assignment (Stream_event **old_ev, Stream_event *new_
 #define ASSIGN_EVENT_ONCE(o,n) internal_event_assignment (&o, n, __FUNCTION__)
 
 
+
 #endif // TRANSLATOR_HH