[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 1/5] Issue 4840: Make Translator/Performer/Engraver abstract base
From: |
David Kastrup |
Subject: |
[PATCH 1/5] Issue 4840: Make Translator/Performer/Engraver abstract base classes |
Date: |
Tue, 3 May 2016 00:58:28 +0200 |
It does not make sense for them to be instantiable.
---
lily/engraver.cc | 17 -----------------
lily/include/engraver.hh | 3 ++-
lily/include/performer.hh | 2 +-
lily/include/scheme-engraver.hh | 3 +++
lily/include/translator.hh | 9 ++++++++-
lily/include/translator.icc | 2 +-
lily/translator.cc | 14 +-------------
7 files changed, 16 insertions(+), 34 deletions(-)
diff --git a/lily/engraver.cc b/lily/engraver.cc
index 25ae579..5a14869 100644
--- a/lily/engraver.cc
+++ b/lily/engraver.cc
@@ -175,20 +175,3 @@ ly_is_grob_cause (SCM obj)
{
return unsmob<Grob> (obj) || unsmob<Stream_event> (obj) || scm_is_null (obj);
}
-
-#include "translator.icc"
-
-ADD_TRANSLATOR (Engraver,
- /* doc */
- "Base class for engravers. Does nothing, so it is not used.",
-
- /* create */
- "",
-
- /* read */
- "",
-
- /* write */
- ""
- );
-
diff --git a/lily/include/engraver.hh b/lily/include/engraver.hh
index 956f493..1f7e31c 100644
--- a/lily/include/engraver.hh
+++ b/lily/include/engraver.hh
@@ -64,7 +64,8 @@ public:
/**
override other ctor
*/
- TRANSLATOR_DECLARATIONS (Engraver);
+ DECLARE_CLASSNAME (Engraver);
+ Engraver ();
};
#define make_item(x, cause) internal_make_item (ly_symbol2scm (x), cause, x,
__FILE__, __LINE__, __FUNCTION__)
diff --git a/lily/include/performer.hh b/lily/include/performer.hh
index a640e24..70354fd 100644
--- a/lily/include/performer.hh
+++ b/lily/include/performer.hh
@@ -30,7 +30,7 @@
class Performer : public Translator
{
public:
- VIRTUAL_COPY_CONSTRUCTOR (Translator, Performer);
+ DECLARE_CLASSNAME (Performer);
friend class Performer_group;
Performer_group *get_daddy_performer () const;
diff --git a/lily/include/scheme-engraver.hh b/lily/include/scheme-engraver.hh
index e22e572..d8265f9 100644
--- a/lily/include/scheme-engraver.hh
+++ b/lily/include/scheme-engraver.hh
@@ -48,6 +48,9 @@ protected:
private:
void acknowledge_grob_by_hash (Grob_info info, SCM iface_function_hash);
void init_acknowledgers (SCM alist, SCM *hash);
+ // For now no description. In future, something derived from the
+ // definition might make sense.
+ SCM translator_description () const { return SCM_EOL; }
DECLARE_ACKNOWLEDGER (grob);
DECLARE_END_ACKNOWLEDGER (grob);
diff --git a/lily/include/translator.hh b/lily/include/translator.hh
index 1182207..5a93564 100644
--- a/lily/include/translator.hh
+++ b/lily/include/translator.hh
@@ -105,6 +105,7 @@ private:
public:
Context *context () const { return daddy_context_; }
+ Translator ();
Translator (Translator const &);
SCM internal_get_property (SCM symbol) const;
@@ -128,7 +129,13 @@ public:
Context *get_score_context () const;
Global_context *get_global_context () const;
- TRANSLATOR_DECLARATIONS (Translator);
+ DECLARE_CLASSNAME (Translator);
+ virtual Translator *clone () const = 0;
+ virtual void fetch_precomputable_methods (Callback methods[]) = 0;
+ virtual SCM get_listener_list () const = 0;
+ virtual SCM translator_description () const = 0;
+ virtual Grob_info_callback get_acknowledger (SCM sym) = 0;
+ virtual Grob_info_callback get_end_acknowledger (SCM sym) = 0;
protected: // should be private.
Context *daddy_context_;
diff --git a/lily/include/translator.icc b/lily/include/translator.icc
index 250a923..3b700d8 100644
--- a/lily/include/translator.icc
+++ b/lily/include/translator.icc
@@ -77,7 +77,7 @@
DEFINE_ACKNOWLEDGERS(classname) \
#define ADD_TRANSLATOR(classname, desc, grobs, read, write) \
- ADD_TRANSLATOR_FAMILY (classname) \
+ ADD_TRANSLATOR_FAMILY (classname); \
ADD_THIS_TRANSLATOR (classname); \
DEFINE_TRANSLATOR_DOC(classname, desc, grobs, read, write) \
DEFINE_TRANSLATOR_LISTENER_LIST(classname) \
diff --git a/lily/translator.cc b/lily/translator.cc
index 370f777..9c667a8 100644
--- a/lily/translator.cc
+++ b/lily/translator.cc
@@ -318,16 +318,4 @@ internal_event_assignment (Stream_event **old_ev,
Stream_event *new_ev, const ch
}
}
-ADD_TRANSLATOR (Translator,
- /* doc */
- "Base class. Not instantiated.",
-
- /* create */
- "",
-
- /* read */
- "",
-
- /* write */
- ""
- );
+// Base class. Not instantiated. No ADD_TRANSLATOR call.
--
2.7.4
- Moving a number of C++ constructs to SCM, David Kastrup, 2016/05/02
- [PATCH 3/5] Add Method_instance class, David Kastrup, 2016/05/02
- [PATCH 1/5] Issue 4840: Make Translator/Performer/Engraver abstract base classes,
David Kastrup <=
- [PATCH 4/5] Replace Engraver_dispatch_entry with Method_instance, David Kastrup, 2016/05/02
- [PATCH 2/5] Add Callback0_wrapper and Callback2_wrapper class, David Kastrup, 2016/05/02
- [PATCH 5/5] Replace Translator_method et al, David Kastrup, 2016/05/02
- Re: Moving a number of C++ constructs to SCM, David Kastrup, 2016/05/03
- Re: Moving a number of C++ constructs to SCM, James Lowe, 2016/05/04