From c6758d6d12e33779fc81218693d5650682d8a1ca Mon Sep 17 00:00:00 2001 From: David Kastrup Date: Thu, 3 Mar 2016 00:32:33 +0100 Subject: [PATCH] Remove Smob::type_p_name_ default This was the single most problematic thing across C++ compilers and standards. Foregoing it means a hassle, but using it turned out to be worse. --- lily/all-font-metrics.cc | 2 ++ lily/include/all-font-metrics.hh | 1 + lily/include/listener.hh | 1 + lily/include/paper-outputter.hh | 1 + lily/include/scale.hh | 1 + lily/include/scm-hash.hh | 1 + lily/include/smobs.hh | 17 +++++------------ lily/include/translator-dispatch-list.hh | 1 + lily/listener.cc | 2 ++ lily/paper-outputter.cc | 2 ++ lily/scale.cc | 2 ++ lily/scm-hash.cc | 2 ++ lily/translator-dispatch-list.cc | 2 ++ lily/unpure-pure-container.cc | 3 +++ 14 files changed, 26 insertions(+), 12 deletions(-) diff --git a/lily/all-font-metrics.cc b/lily/all-font-metrics.cc index ab4f2a4ce4..a560a25940 100644 --- a/lily/all-font-metrics.cc +++ b/lily/all-font-metrics.cc @@ -27,6 +27,8 @@ #include "scm-hash.hh" #include "warn.hh" +const char * const All_font_metrics::type_p_name_ = 0; + Index_to_charcode_map const * All_font_metrics::get_index_to_charcode_map (const string &filename, int face_index, diff --git a/lily/include/all-font-metrics.hh b/lily/include/all-font-metrics.hh index a2d090a6df..f206a3b95d 100644 --- a/lily/include/all-font-metrics.hh +++ b/lily/include/all-font-metrics.hh @@ -48,6 +48,7 @@ class All_font_metrics : public Smob All_font_metrics (All_font_metrics const &); public: + static const char * const type_p_name_; // = 0 SCM mark_smob () const; Index_to_charcode_map const *get_index_to_charcode_map (const string &filename, diff --git a/lily/include/listener.hh b/lily/include/listener.hh index 00a64eebb8..27e7d85b71 100644 --- a/lily/include/listener.hh +++ b/lily/include/listener.hh @@ -179,6 +179,7 @@ class Callback_wrapper : public Simple_smob Callback_wrapper (void (*trampoline) (SCM, SCM)) : trampoline_ (trampoline) { } // Private constructor, use only in make_smob public: + static const char * const type_p_name_; // = 0 LY_DECLARE_SMOB_PROC (&Callback_wrapper::call, 2, 0, 0) SCM call (SCM target, SCM ev) { diff --git a/lily/include/paper-outputter.hh b/lily/include/paper-outputter.hh index cd1a5e2c92..8683b4c6d1 100644 --- a/lily/include/paper-outputter.hh +++ b/lily/include/paper-outputter.hh @@ -33,6 +33,7 @@ class Paper_outputter : public Smob { public: + static const char * const type_p_name_; // = 0 SCM mark_smob () const; virtual ~Paper_outputter (); private: diff --git a/lily/include/scale.hh b/lily/include/scale.hh index 19cd175c79..7c990e5034 100644 --- a/lily/include/scale.hh +++ b/lily/include/scale.hh @@ -26,6 +26,7 @@ struct Scale : public Smob { + static const char * const type_p_name_; // = 0 virtual ~Scale (); Scale (vector const &); Scale (Scale const &); diff --git a/lily/include/scm-hash.hh b/lily/include/scm-hash.hh index 3453904f71..241f316c4e 100644 --- a/lily/include/scm-hash.hh +++ b/lily/include/scm-hash.hh @@ -46,6 +46,7 @@ class Scheme_hash_table : public Smob1 { public: + static const char * const type_p_name_; // = 0 int print_smob (SCM, scm_print_state *) const; bool try_retrieve (SCM key, SCM *val); bool contains (SCM key) const; diff --git a/lily/include/smobs.hh b/lily/include/smobs.hh index 9ccaa61345..889d86a8ca 100644 --- a/lily/include/smobs.hh +++ b/lily/include/smobs.hh @@ -185,18 +185,11 @@ private: static int print_trampoline (SCM, SCM, scm_print_state *); static void smob_proc_init (scm_t_bits) { }; - // type_p_name_ can be overriden in the Super class with a static - // const char [] string. This requires both a declaration in the - // class as well as a single instantiation outside. Using a - // template specialization for supplying a different string name - // right in Smob_base itself seems tempting, but the C++ - // rules would then require a specialization declaration at the - // class definition site as well as a specialization instantiation - // in a single compilation unit. That requires just as much source - // code maintenance while being harder to understand and quite - // trickier in its failure symptoms when things go wrong. So we - // just use a static zero as "not here" indication. - static const int type_p_name_ = 0; + // type_p_name_ has to be defined in the Super class, either with a + // static const char [] string or as a null pointer of type const + // char *. We used to provide a default here for convenience, but + // battling the various conflicting C++ standards was too much of a + // hassle. // LY_DECLARE_SMOB_PROC is used in the Super class definition for // making a smob callable like a function. Its first argument is a diff --git a/lily/include/translator-dispatch-list.hh b/lily/include/translator-dispatch-list.hh index 6c365d088e..6fd03beecf 100644 --- a/lily/include/translator-dispatch-list.hh +++ b/lily/include/translator-dispatch-list.hh @@ -35,6 +35,7 @@ class Engraver_dispatch_list : public Simple_smob { vector dispatch_entries_; public: + static const char * const type_p_name_; // = 0 void apply (Grob_info); SCM static create (SCM trans_list, SCM iface_list, Direction); diff --git a/lily/listener.cc b/lily/listener.cc index 2a8d28d8cb..c1e0b442e2 100644 --- a/lily/listener.cc +++ b/lily/listener.cc @@ -19,4 +19,6 @@ #include "listener.hh" +const char * const Callback_wrapper::type_p_name_ = 0; + const char Listener::type_p_name_[] = "ly:listener?"; diff --git a/lily/paper-outputter.cc b/lily/paper-outputter.cc index a72ea59ccd..471a36a41a 100644 --- a/lily/paper-outputter.cc +++ b/lily/paper-outputter.cc @@ -40,6 +40,8 @@ using namespace std; #include "lily-imports.hh" +const char * const Paper_outputter::type_p_name_ = 0; + Paper_outputter::Paper_outputter (SCM port, const string &format) { file_ = port; diff --git a/lily/scale.cc b/lily/scale.cc index 02c1dc5f8e..d6f566b9ed 100644 --- a/lily/scale.cc +++ b/lily/scale.cc @@ -90,6 +90,8 @@ LY_DEFINE (ly_set_default_scale, "ly:set-default-scale", return SCM_UNSPECIFIED; } +const char * const Scale::type_p_name_ = 0; + int Scale::step_count () const { diff --git a/lily/scm-hash.cc b/lily/scm-hash.cc index dd8f9257b9..3eb40ada7b 100644 --- a/lily/scm-hash.cc +++ b/lily/scm-hash.cc @@ -21,6 +21,8 @@ #include +const char * const Scheme_hash_table::type_p_name_ = 0; + SCM Scheme_hash_table::make_smob () { diff --git a/lily/translator-dispatch-list.cc b/lily/translator-dispatch-list.cc index 10bf064075..41d5a17182 100644 --- a/lily/translator-dispatch-list.cc +++ b/lily/translator-dispatch-list.cc @@ -21,6 +21,8 @@ #include "engraver.hh" +const char * const Engraver_dispatch_list::type_p_name_ = 0; + void Engraver_dispatch_list::apply (Grob_info gi) { diff --git a/lily/unpure-pure-container.cc b/lily/unpure-pure-container.cc index 0e389d4bcd..7a7d6d48d1 100644 --- a/lily/unpure-pure-container.cc +++ b/lily/unpure-pure-container.cc @@ -25,6 +25,7 @@ class Unpure_pure_call : public Smob1 { public: + static const char * const type_p_name_; // = 0 // Smob procedures unfortunately can only take at most 3 SCM // arguments. Otherwise we could use a "3, 0, 1" call signature and // not require an argument count check of our own. @@ -37,6 +38,8 @@ public: } }; +const char * const Unpure_pure_call::type_p_name_ = 0; + SCM Unpure_pure_container::pure_part () const { -- 2.39.2