From 00b9619cea1020f6773f23df8764ef85ee2912bf Mon Sep 17 00:00:00 2001 From: David Kastrup Date: Wed, 10 Sep 2014 17:01:43 +0200 Subject: [PATCH] Issue 4135/2: Replace mark_smob static member functions with non-static members Since the mark functions generally need to access a number of members, it is quite more convenient if the mark functions are proper non-static member functions. --- lily/book.cc | 16 +++++++--------- lily/context-def.cc | 28 +++++++++++++--------------- lily/context-mod.cc | 6 ++---- lily/context-property.cc | 13 ++++++------- lily/context.cc | 32 +++++++++++++++----------------- lily/dispatcher.cc | 9 ++++----- lily/font-metric.cc | 7 +++---- lily/grob-array.cc | 4 +--- lily/grob-smob.cc | 19 +++++++++---------- lily/include/book.hh | 2 +- lily/include/context-def.hh | 2 +- lily/include/context-mod.hh | 2 +- lily/include/context.hh | 2 +- lily/include/dispatcher.hh | 2 +- lily/include/font-metric.hh | 2 +- lily/include/grob-array.hh | 2 +- lily/include/grob.hh | 2 +- lily/include/input.hh | 2 +- lily/include/lily-lexer.hh | 2 +- lily/include/lily-parser.hh | 2 +- lily/include/listener.hh | 2 +- lily/include/music-function.hh | 2 +- lily/include/music-iterator.hh | 2 +- lily/include/music-output.hh | 2 +- lily/include/output-def.hh | 2 +- lily/include/page-marker.hh | 2 +- lily/include/paper-book.hh | 2 +- lily/include/paper-outputter.hh | 2 +- lily/include/pitch.hh | 2 +- lily/include/prob.hh | 2 +- lily/include/scheme-listener.hh | 2 +- lily/include/scm-hash.hh | 2 +- lily/include/score.hh | 2 +- lily/include/small-smobs.hh | 14 +++++++------- lily/include/smobs.hh | 4 +++- lily/include/smobs.tcc | 19 +++++++++++++++++-- lily/include/source-file.hh | 2 +- lily/include/stencil.hh | 2 +- lily/include/translator-group.hh | 2 +- lily/include/translator.hh | 2 +- lily/input-smob.cc | 6 ++---- lily/lily-lexer.cc | 22 ++++++++++------------ lily/lily-parser.cc | 7 +++---- lily/listener.cc | 7 +++---- lily/music-function.cc | 6 +++--- lily/music-iterator.cc | 14 ++++++-------- lily/music-output.cc | 6 ++---- lily/output-def.cc | 10 ++++------ lily/page-marker.cc | 9 ++++----- lily/paper-book.cc | 25 ++++++++++++------------- lily/paper-outputter.cc | 7 +++---- lily/pitch.cc | 6 +++--- lily/prob.cc | 11 +++++------ lily/scheme-listener.cc | 5 ++--- lily/scm-hash.cc | 5 ++--- lily/score.cc | 14 ++++++-------- lily/source-file.cc | 6 ++---- lily/stencil.cc | 5 ++--- lily/translator-group.cc | 10 ++++------ lily/translator.cc | 5 ++--- lily/undead.cc | 6 +++--- 61 files changed, 198 insertions(+), 221 deletions(-) diff --git a/lily/book.cc b/lily/book.cc index 6a09d77b69..4c426da4fd 100644 --- a/lily/book.cc +++ b/lily/book.cc @@ -106,17 +106,15 @@ Book::~Book () SCM -Book::mark_smob (SCM s) +Book::mark_smob () { - Book *book = (Book *) SCM_CELL_WORD_1 (s); + if (paper_) + scm_gc_mark (paper_->self_scm ()); + scm_gc_mark (scores_); + scm_gc_mark (bookparts_); + scm_gc_mark (input_location_); - if (book->paper_) - scm_gc_mark (book->paper_->self_scm ()); - scm_gc_mark (book->scores_); - scm_gc_mark (book->bookparts_); - scm_gc_mark (book->input_location_); - - return book->header_; + return header_; } int diff --git a/lily/context-def.cc b/lily/context-def.cc index 3d9caa2734..24803a5d94 100644 --- a/lily/context-def.cc +++ b/lily/context-def.cc @@ -98,22 +98,20 @@ Context_def::print_smob (SCM smob, SCM port, scm_print_state *) } SCM -Context_def::mark_smob (SCM smob) +Context_def::mark_smob () { - ASSERT_LIVE_IS_ALLOWED (smob); - - Context_def *me = (Context_def *) SCM_CELL_WORD_1 (smob); - - scm_gc_mark (me->description_); - scm_gc_mark (me->context_aliases_); - scm_gc_mark (me->accept_mods_); - scm_gc_mark (me->translator_mods_); - scm_gc_mark (me->property_ops_); - scm_gc_mark (me->translator_group_type_); - scm_gc_mark (me->default_child_); - scm_gc_mark (me->input_location_); - - return me->context_name_; + ASSERT_LIVE_IS_ALLOWED (self_scm ()); + + scm_gc_mark (description_); + scm_gc_mark (context_aliases_); + scm_gc_mark (accept_mods_); + scm_gc_mark (translator_mods_); + scm_gc_mark (property_ops_); + scm_gc_mark (translator_group_type_); + scm_gc_mark (default_child_); + scm_gc_mark (input_location_); + + return context_name_; } void diff --git a/lily/context-mod.cc b/lily/context-mod.cc index 329bb092dc..16910aa37e 100644 --- a/lily/context-mod.cc +++ b/lily/context-mod.cc @@ -48,11 +48,9 @@ Context_mod::print_smob (SCM smob, SCM port, scm_print_state *) } SCM -Context_mod::mark_smob (SCM smob) +Context_mod::mark_smob () { - Context_mod *me = (Context_mod *) SCM_CELL_WORD_1 (smob); - - return me->mods_; + return mods_; } void diff --git a/lily/context-property.cc b/lily/context-property.cc index 000bd0b5cc..369037381a 100644 --- a/lily/context-property.cc +++ b/lily/context-property.cc @@ -67,7 +67,7 @@ class Grob_properties : public Simple_smob { public: static int print_smob (SCM, SCM, scm_print_state *); - static SCM mark_smob (SCM); + SCM mark_smob (); static const char type_p_name_[]; private: friend class Grob_property_info; @@ -98,13 +98,12 @@ private: const char Grob_properties::type_p_name_[] = "ly:grob-properties?"; SCM -Grob_properties::mark_smob (SCM smob) +Grob_properties::mark_smob () { - Grob_properties *gp = (Grob_properties *) SCM_SMOB_DATA (smob); - scm_gc_mark (gp->alist_); - scm_gc_mark (gp->based_on_); - scm_gc_mark (gp->cooked_); - return gp->cooked_from_; + scm_gc_mark (alist_); + scm_gc_mark (based_on_); + scm_gc_mark (cooked_); + return cooked_from_; } int diff --git a/lily/context.cc b/lily/context.cc index da18102401..e43c10dc2a 100644 --- a/lily/context.cc +++ b/lily/context.cc @@ -690,28 +690,26 @@ Context::print_smob (SCM s, SCM port, scm_print_state *) } SCM -Context::mark_smob (SCM sm) +Context::mark_smob () { - Context *me = (Context *) SCM_CELL_WORD_1 (sm); + scm_gc_mark (context_list_); + scm_gc_mark (aliases_); + scm_gc_mark (definition_); + scm_gc_mark (definition_mods_); + scm_gc_mark (properties_scm_); + scm_gc_mark (accepts_list_); + scm_gc_mark (default_child_); - scm_gc_mark (me->context_list_); - scm_gc_mark (me->aliases_); - scm_gc_mark (me->definition_); - scm_gc_mark (me->definition_mods_); - scm_gc_mark (me->properties_scm_); - scm_gc_mark (me->accepts_list_); - scm_gc_mark (me->default_child_); + if (implementation_) + scm_gc_mark (implementation_->self_scm ()); - if (me->implementation_) - scm_gc_mark (me->implementation_->self_scm ()); + if (event_source_) + scm_gc_mark (event_source_->self_scm ()); - if (me->event_source_) - scm_gc_mark (me->event_source_->self_scm ()); + if (events_below_) + scm_gc_mark (events_below_->self_scm ()); - if (me->events_below_) - scm_gc_mark (me->events_below_->self_scm ()); - - return me->properties_scm_; + return properties_scm_; } const char Context::type_p_name_[] = "ly:context?"; diff --git a/lily/dispatcher.cc b/lily/dispatcher.cc index 2e53730791..41f3237651 100644 --- a/lily/dispatcher.cc +++ b/lily/dispatcher.cc @@ -41,12 +41,11 @@ Dispatcher::Dispatcher () } SCM -Dispatcher::mark_smob (SCM sm) +Dispatcher::mark_smob () { - Dispatcher *me = (Dispatcher *) SCM_CELL_WORD_1 (sm); - scm_gc_mark (me->dispatchers_); - scm_gc_mark (me->listen_classes_); - return me->listeners_; + scm_gc_mark (dispatchers_); + scm_gc_mark (listen_classes_); + return listeners_; } int diff --git a/lily/font-metric.cc b/lily/font-metric.cc index ab0f8f47e3..899d80f821 100644 --- a/lily/font-metric.cc +++ b/lily/font-metric.cc @@ -94,11 +94,10 @@ Font_metric::derived_mark () const } SCM -Font_metric::mark_smob (SCM s) +Font_metric::mark_smob () { - Font_metric *m = (Font_metric *) SCM_CELL_WORD_1 (s); - m->derived_mark (); - return m->description_; + derived_mark (); + return description_; } int diff --git a/lily/grob-array.cc b/lily/grob-array.cc index 593ce6a568..f1f47561e3 100644 --- a/lily/grob-array.cc +++ b/lily/grob-array.cc @@ -52,10 +52,8 @@ Grob_array::array () const } SCM -Grob_array::mark_smob (SCM s) +Grob_array::mark_smob () { - (void) s; - #if 0 /* see System::derived_mark () const */ Grob_array *ga = Grob_array::unsmob (s); for (vsize i = 0; i < ga->grobs_.size (); i++) diff --git a/lily/grob-smob.cc b/lily/grob-smob.cc index eaec5420c2..dc7082e3d5 100644 --- a/lily/grob-smob.cc +++ b/lily/grob-smob.cc @@ -26,12 +26,11 @@ const char Grob::type_p_name_[] = "ly:grob?"; SCM -Grob::mark_smob (SCM ses) +Grob::mark_smob () { - ASSERT_LIVE_IS_ALLOWED (ses); + ASSERT_LIVE_IS_ALLOWED (self_scm ()); - Grob *s = (Grob *) SCM_CELL_WORD_1 (ses); - scm_gc_mark (s->immutable_property_alist_); + scm_gc_mark (immutable_property_alist_); /* Do not mark the parents. The pointers in the mutable property list form two tree like structures (one for X @@ -40,14 +39,14 @@ Grob::mark_smob (SCM ses) between X and Y in an erratic manner, leading to much more recursion depth (and core dumps if we link to pthreads). */ - if (s->original ()) - scm_gc_mark (s->original ()->self_scm ()); + if (original ()) + scm_gc_mark (original ()->self_scm ()); - s->derived_mark (); - scm_gc_mark (s->object_alist_); - scm_gc_mark (s->interfaces_); + derived_mark (); + scm_gc_mark (object_alist_); + scm_gc_mark (interfaces_); - return s->mutable_property_alist_; + return mutable_property_alist_; } int diff --git a/lily/include/book.hh b/lily/include/book.hh index eb0a105f86..0910a9b9e7 100644 --- a/lily/include/book.hh +++ b/lily/include/book.hh @@ -30,7 +30,7 @@ class Book : public Smob { public: static int print_smob (SCM, SCM, scm_print_state *); - static SCM mark_smob (SCM); + SCM mark_smob (); static const char type_p_name_[]; virtual ~Book (); SCM header_; diff --git a/lily/include/context-def.hh b/lily/include/context-def.hh index 258d07ba92..ba1aad2f2b 100644 --- a/lily/include/context-def.hh +++ b/lily/include/context-def.hh @@ -33,7 +33,7 @@ */ struct Context_def : public Smob { - static SCM mark_smob (SCM); + SCM mark_smob (); static int print_smob (SCM, SCM, scm_print_state *); static const char type_p_name_[]; virtual ~Context_def (); diff --git a/lily/include/context-mod.hh b/lily/include/context-mod.hh index 424f06a8ec..665dc3b64f 100644 --- a/lily/include/context-mod.hh +++ b/lily/include/context-mod.hh @@ -36,7 +36,7 @@ */ struct Context_mod : public Simple_smob { - static SCM mark_smob (SCM); + SCM mark_smob (); static int print_smob (SCM, SCM, scm_print_state *); static const char type_p_name_[]; private: diff --git a/lily/include/context.hh b/lily/include/context.hh index ae21895590..150996c4e4 100644 --- a/lily/include/context.hh +++ b/lily/include/context.hh @@ -31,7 +31,7 @@ class Context : public Smob { public: - static SCM mark_smob (SCM); + SCM mark_smob (); static int print_smob (SCM, SCM, scm_print_state *); static const char type_p_name_[]; virtual ~Context (); diff --git a/lily/include/dispatcher.hh b/lily/include/dispatcher.hh index 2be14d9177..5532d935fc 100644 --- a/lily/include/dispatcher.hh +++ b/lily/include/dispatcher.hh @@ -27,7 +27,7 @@ class Dispatcher : public Smob { public: static int print_smob (SCM, SCM, scm_print_state *); - static SCM mark_smob (SCM); + SCM mark_smob (); static const char type_p_name_[]; virtual ~Dispatcher (); private: diff --git a/lily/include/font-metric.hh b/lily/include/font-metric.hh index 0eb2e0808b..e5a2b236be 100644 --- a/lily/include/font-metric.hh +++ b/lily/include/font-metric.hh @@ -34,7 +34,7 @@ class Font_metric : public Smob { public: static int print_smob (SCM, SCM, scm_print_state *); - static SCM mark_smob (SCM); + SCM mark_smob (); static const char type_p_name_[]; virtual ~Font_metric (); private: diff --git a/lily/include/grob-array.hh b/lily/include/grob-array.hh index feeda8a36a..093b2d6bdc 100644 --- a/lily/include/grob-array.hh +++ b/lily/include/grob-array.hh @@ -28,7 +28,7 @@ class Grob_array : public Simple_smob { public: static int print_smob (SCM, SCM, scm_print_state *); - static SCM mark_smob (SCM); + SCM mark_smob (); static const char type_p_name_[]; private: vector grobs_; diff --git a/lily/include/grob.hh b/lily/include/grob.hh index ae2a9a20a1..10d8c794eb 100644 --- a/lily/include/grob.hh +++ b/lily/include/grob.hh @@ -31,7 +31,7 @@ class Grob : public Smob { public: static int print_smob (SCM, SCM, scm_print_state *); - static SCM mark_smob (SCM); + SCM mark_smob (); static const char type_p_name_[]; virtual ~Grob (); private: diff --git a/lily/include/input.hh b/lily/include/input.hh index 5cdbdca2e6..12c3485b11 100644 --- a/lily/include/input.hh +++ b/lily/include/input.hh @@ -35,7 +35,7 @@ public: static const char type_p_name_[]; static int print_smob (SCM, SCM, scm_print_state *); static SCM equal_p (SCM, SCM); - static SCM mark_smob (SCM); + SCM mark_smob (); Source_file *get_source_file () const; char const *start () const; char const *end () const; diff --git a/lily/include/lily-lexer.hh b/lily/include/lily-lexer.hh index 050e01f525..eb57de8f6a 100644 --- a/lily/include/lily-lexer.hh +++ b/lily/include/lily-lexer.hh @@ -35,7 +35,7 @@ class Lily_lexer : public Smob, public Includable_lexer { public: static int print_smob (SCM, SCM, scm_print_state *); - static SCM mark_smob (SCM); + SCM mark_smob (); static const char type_p_name_[]; virtual ~Lily_lexer (); private: diff --git a/lily/include/lily-parser.hh b/lily/include/lily-parser.hh index 2ea3b0c6dc..0255b46074 100644 --- a/lily/include/lily-parser.hh +++ b/lily/include/lily-parser.hh @@ -33,7 +33,7 @@ class Lily_parser : public Smob { public: static int print_smob (SCM, SCM, scm_print_state *); - static SCM mark_smob (SCM); + SCM mark_smob (); static const char type_p_name_[]; virtual ~Lily_parser (); Lily_lexer *lexer_; diff --git a/lily/include/listener.hh b/lily/include/listener.hh index 38b11b2d34..2dfdc0c9f8 100644 --- a/lily/include/listener.hh +++ b/lily/include/listener.hh @@ -75,7 +75,7 @@ class Listener : public Simple_smob public: static SCM equal_p (SCM, SCM); static int print_smob (SCM, SCM, scm_print_state *); - static SCM mark_smob (SCM); + SCM mark_smob (); static const char type_p_name_[]; private: void *target_; diff --git a/lily/include/music-function.hh b/lily/include/music-function.hh index 0c3c67a5ca..2356c3ecef 100644 --- a/lily/include/music-function.hh +++ b/lily/include/music-function.hh @@ -28,7 +28,7 @@ class Music_function : public Smob2 { public: static const char type_p_name_[]; - static SCM mark_smob (SCM); + SCM mark_smob (); static int print_smob (SCM, SCM, scm_print_state *); SCM get_signature () { return scm1 (); } SCM get_function () { return scm2 (); } diff --git a/lily/include/music-iterator.hh b/lily/include/music-iterator.hh index cf7d640626..9ca076c625 100644 --- a/lily/include/music-iterator.hh +++ b/lily/include/music-iterator.hh @@ -62,7 +62,7 @@ class Music_iterator : public Smob { public: static int print_smob (SCM, SCM, scm_print_state *); - static SCM mark_smob (SCM); + SCM mark_smob (); static const char type_p_name_[]; virtual ~Music_iterator (); protected: diff --git a/lily/include/music-output.hh b/lily/include/music-output.hh index 685b764160..b9f99f2221 100644 --- a/lily/include/music-output.hh +++ b/lily/include/music-output.hh @@ -30,7 +30,7 @@ class Music_output : public Smob { public: static int print_smob (SCM, SCM, scm_print_state *); - static SCM mark_smob (SCM); + SCM mark_smob (); static const char type_p_name_[]; virtual ~Music_output (); private: diff --git a/lily/include/output-def.hh b/lily/include/output-def.hh index 1e572e6e30..518171120a 100644 --- a/lily/include/output-def.hh +++ b/lily/include/output-def.hh @@ -50,7 +50,7 @@ class Output_def : public Smob { public: static int print_smob (SCM, SCM, scm_print_state *); - static SCM mark_smob (SCM); + SCM mark_smob (); virtual ~Output_def (); VIRTUAL_COPY_CONSTRUCTOR (Output_def, Output_def); diff --git a/lily/include/page-marker.hh b/lily/include/page-marker.hh index 53c29d4f32..57315f5322 100644 --- a/lily/include/page-marker.hh +++ b/lily/include/page-marker.hh @@ -27,7 +27,7 @@ class Page_marker : public Smob { public: static int print_smob (SCM, SCM, scm_print_state *); - static SCM mark_smob (SCM); + SCM mark_smob (); static const char type_p_name_[]; virtual ~Page_marker (); private: diff --git a/lily/include/paper-book.hh b/lily/include/paper-book.hh index beca941da7..c1c8d2267b 100644 --- a/lily/include/paper-book.hh +++ b/lily/include/paper-book.hh @@ -31,7 +31,7 @@ class Paper_book : public Smob { public: static int print_smob (SCM, SCM, scm_print_state *); - static SCM mark_smob (SCM); + SCM mark_smob (); static const char type_p_name_[]; virtual ~Paper_book (); private: diff --git a/lily/include/paper-outputter.hh b/lily/include/paper-outputter.hh index a156c382d9..624ae65a39 100644 --- a/lily/include/paper-outputter.hh +++ b/lily/include/paper-outputter.hh @@ -34,7 +34,7 @@ class Paper_outputter : public Smob { public: static int print_smob (SCM, SCM, scm_print_state *); - static SCM mark_smob (SCM); + SCM mark_smob (); virtual ~Paper_outputter (); private: SCM output_module_; diff --git a/lily/include/pitch.hh b/lily/include/pitch.hh index e21f629b57..a6e3c3860a 100644 --- a/lily/include/pitch.hh +++ b/lily/include/pitch.hh @@ -37,7 +37,7 @@ class Pitch : public Simple_smob public: static SCM equal_p (SCM, SCM); static int print_smob (SCM, SCM, scm_print_state *); - static SCM mark_smob (SCM); + SCM mark_smob (); static const char type_p_name_[]; private: int octave_; diff --git a/lily/include/prob.hh b/lily/include/prob.hh index eb19c8d79a..793d390b08 100644 --- a/lily/include/prob.hh +++ b/lily/include/prob.hh @@ -35,7 +35,7 @@ class Prob : public Smob { public: static int print_smob (SCM, SCM, scm_print_state *); - static SCM mark_smob (SCM); + SCM mark_smob (); static SCM equal_p (SCM, SCM); static const char type_p_name_[]; virtual ~Prob (); diff --git a/lily/include/scheme-listener.hh b/lily/include/scheme-listener.hh index b8e42ee911..00242083fd 100644 --- a/lily/include/scheme-listener.hh +++ b/lily/include/scheme-listener.hh @@ -30,7 +30,7 @@ class Scheme_listener : public Smob { public: static int print_smob (SCM, SCM, scm_print_state *); - static SCM mark_smob (SCM); + SCM mark_smob (); virtual ~Scheme_listener (); Scheme_listener (SCM callback); DECLARE_LISTENER (call); diff --git a/lily/include/scm-hash.hh b/lily/include/scm-hash.hh index 1a15aff359..eea2d1436a 100644 --- a/lily/include/scm-hash.hh +++ b/lily/include/scm-hash.hh @@ -47,7 +47,7 @@ class Scheme_hash_table : public Smob { public: static int print_smob (SCM, SCM, scm_print_state *); - static SCM mark_smob (SCM); + SCM mark_smob (); virtual ~Scheme_hash_table (); bool try_retrieve (SCM key, SCM *val); bool contains (SCM key) const; diff --git a/lily/include/score.hh b/lily/include/score.hh index 15e32ab173..f66a81ba62 100644 --- a/lily/include/score.hh +++ b/lily/include/score.hh @@ -31,7 +31,7 @@ class Score : public Smob { public: static int print_smob (SCM, SCM, scm_print_state *); - static SCM mark_smob (SCM); + SCM mark_smob (); static const char type_p_name_[]; virtual ~Score (); private: diff --git a/lily/include/small-smobs.hh b/lily/include/small-smobs.hh index 0a3f6f0d2d..a752662c1e 100644 --- a/lily/include/small-smobs.hh +++ b/lily/include/small-smobs.hh @@ -33,7 +33,7 @@ public: SCM_RETURN_NEWSMOB (Smob_base::smob_tag (), SCM_UNPACK (arg1)); } static const int free_smob = 0; - static SCM mark_smob (SCM s) { return SCM_SMOB_OBJECT (s); }; + SCM mark_smob () { return scm1 (); }; static Super *unchecked_unsmob (SCM s) { return reinterpret_cast (SCM_UNPACK (s)); } @@ -54,10 +54,10 @@ public: SCM_UNPACK (arg2)); } static const int free_smob = 0; - static SCM mark_smob (SCM s) + SCM mark_smob () { - scm_gc_mark (SCM_SMOB_OBJECT_2 (s)); - return SCM_SMOB_OBJECT (s); + scm_gc_mark (scm2 ()); + return scm1 (); } static Super *unchecked_unsmob (SCM s) { return reinterpret_cast (SCM_UNPACK (s)); @@ -85,9 +85,9 @@ public: static const int free_smob = 0; static SCM mark_smob (SCM s) { - scm_gc_mark (SCM_SMOB_OBJECT_3 (s)); - scm_gc_mark (SCM_SMOB_OBJECT_2 (s)); - return SCM_SMOB_OBJECT (s); + scm_gc_mark (scm3 ()); + scm_gc_mark (scm2 ()); + return scm1 (); } static Super *unchecked_unsmob (SCM s) { return reinterpret_cast (SCM_UNPACK (s)); diff --git a/lily/include/smobs.hh b/lily/include/smobs.hh index c3a9f4bf4c..f9eeed7f85 100644 --- a/lily/include/smobs.hh +++ b/lily/include/smobs.hh @@ -179,7 +179,9 @@ private: // # would depend on memory layout, thus // being unsuitable for regtest comparisons unless filtered. - static const int mark_smob = 0; + SCM mark_smob (void); // Should not be inline since we do an address + // comparison + static SCM mark_trampoline (SCM); // Used for calling mark_smob static const int equal_p = 0; static const int smob_proc = 0; static const int smob_proc_signature_ = 0; diff --git a/lily/include/smobs.tcc b/lily/include/smobs.tcc index f990a08f53..c2616b3216 100644 --- a/lily/include/smobs.tcc +++ b/lily/include/smobs.tcc @@ -28,6 +28,13 @@ #include "smobs.hh" #include +template +SCM +Smob_base::mark_trampoline (SCM arg) +{ + return (Super::unsmob (arg))->mark_smob (); +} + template SCM Smob_base::register_ptr (Super *p) @@ -42,6 +49,14 @@ Smob_base::register_ptr (Super *p) return s; } +// Default, should not actually get called +template +SCM +Smob_base::mark_smob () +{ + return SCM_UNSPECIFIED; +} + template int Smob_base::print_smob (SCM, SCM p, scm_print_state *) @@ -90,8 +105,8 @@ void Smob_base::init () if (Super::free_smob != 0) scm_set_smob_free (smob_tag_, Super::free_smob); - if (Super::mark_smob != 0) - scm_set_smob_mark (smob_tag_, Super::mark_smob); + if (&Super::mark_smob != &Smob_base::mark_smob) + scm_set_smob_mark (smob_tag_, Super::mark_trampoline); if (Super::print_smob != 0) scm_set_smob_print (smob_tag_, Super::print_smob); if (Super::equal_p != 0) diff --git a/lily/include/source-file.hh b/lily/include/source-file.hh index 7647ce3830..8dfbab6c62 100644 --- a/lily/include/source-file.hh +++ b/lily/include/source-file.hh @@ -39,7 +39,7 @@ class Source_file : public Smob { public: static int print_smob (SCM, SCM, scm_print_state *); - static SCM mark_smob (SCM); + SCM mark_smob (); static const char type_p_name_[]; virtual ~Source_file (); private: diff --git a/lily/include/stencil.hh b/lily/include/stencil.hh index e91cfa9759..ad686dcfe7 100644 --- a/lily/include/stencil.hh +++ b/lily/include/stencil.hh @@ -58,7 +58,7 @@ using namespace std; class Stencil : public Simple_smob { public: - static SCM mark_smob (SCM); + SCM mark_smob (); static int print_smob (SCM, SCM, scm_print_state *); static const char type_p_name_[]; private: diff --git a/lily/include/translator-group.hh b/lily/include/translator-group.hh index 17352269d9..1c907ef25f 100644 --- a/lily/include/translator-group.hh +++ b/lily/include/translator-group.hh @@ -50,7 +50,7 @@ struct Translator_method_binding class Translator_group : public Smob { public: - static SCM mark_smob (SCM); + SCM mark_smob (); static int print_smob (SCM, SCM, scm_print_state *); static const char type_p_name_[]; virtual ~Translator_group (); diff --git a/lily/include/translator.hh b/lily/include/translator.hh index 31cbe0590d..f7b9677a00 100644 --- a/lily/include/translator.hh +++ b/lily/include/translator.hh @@ -121,7 +121,7 @@ class Translator : public Smob { public: static int print_smob (SCM, SCM, scm_print_state *); - static SCM mark_smob (SCM); + SCM mark_smob (); static const char type_p_name_[]; virtual ~Translator (); private: diff --git a/lily/input-smob.cc b/lily/input-smob.cc index 6700936d44..4439955af4 100644 --- a/lily/input-smob.cc +++ b/lily/input-smob.cc @@ -28,11 +28,9 @@ Input dummy_input_global; const char Input::type_p_name_[] = "ly:input-location?"; SCM -Input::mark_smob (SCM s) +Input::mark_smob () { - Input *sc = unsmob (s); - - if (Source_file *sf = sc->get_source_file ()) + if (Source_file *sf = get_source_file ()) return sf->self_scm (); return SCM_EOL; diff --git a/lily/lily-lexer.cc b/lily/lily-lexer.cc index 921dd2ad7a..c02143da4c 100644 --- a/lily/lily-lexer.cc +++ b/lily/lily-lexer.cc @@ -368,19 +368,17 @@ Lily_lexer::add_lexed_char (int count) const char Lily_lexer::type_p_name_[] = "ly:lily-lexer?"; SCM -Lily_lexer::mark_smob (SCM s) +Lily_lexer::mark_smob () { - ASSERT_LIVE_IS_ALLOWED (s); - - Lily_lexer *lexer = (Lily_lexer *) SCM_CELL_WORD_1 (s); - - scm_gc_mark (lexer->chordmodifier_tab_); - if (lexer->parser_) - scm_gc_mark (lexer->parser_->self_scm ()); - scm_gc_mark (lexer->pitchname_tab_stack_); - scm_gc_mark (lexer->start_module_); - scm_gc_mark (lexer->extra_tokens_); - return lexer->scopes_; + ASSERT_LIVE_IS_ALLOWED (self_scm ()); + + scm_gc_mark (chordmodifier_tab_); + if (parser_) + scm_gc_mark (parser_->self_scm ()); + scm_gc_mark (pitchname_tab_stack_); + scm_gc_mark (start_module_); + scm_gc_mark (extra_tokens_); + return scopes_; } int diff --git a/lily/lily-parser.cc b/lily/lily-parser.cc index b9100e1236..fd1eb48981 100644 --- a/lily/lily-parser.cc +++ b/lily/lily-parser.cc @@ -76,11 +76,10 @@ Lily_parser::~Lily_parser () } SCM -Lily_parser::mark_smob (SCM s) +Lily_parser::mark_smob () { - Lily_parser *parser = (Lily_parser *) SCM_CELL_WORD_1 (s); - scm_gc_mark (parser->closures_); - return (parser->lexer_) ? parser->lexer_->self_scm () : SCM_EOL; + scm_gc_mark (closures_); + return (lexer_) ? lexer_->self_scm () : SCM_EOL; } int diff --git a/lily/listener.cc b/lily/listener.cc index 7dc4cc370c..a6dcbd1020 100644 --- a/lily/listener.cc +++ b/lily/listener.cc @@ -44,11 +44,10 @@ void Listener::listen (SCM ev) const } SCM -Listener::mark_smob (SCM sm) +Listener::mark_smob () { - Listener *me = (Listener *) SCM_CELL_WORD_1 (sm); - if (me->type_) - (me->type_->mark_callback) (me->target_); + if (type_) + (type_->mark_callback) (target_); return SCM_EOL; } diff --git a/lily/music-function.cc b/lily/music-function.cc index 743b7f6767..79d872c43b 100644 --- a/lily/music-function.cc +++ b/lily/music-function.cc @@ -34,8 +34,8 @@ Music_function::print_smob (SCM b, SCM port, scm_print_state *) } SCM -Music_function::mark_smob (SCM s) +Music_function::mark_smob () { - ASSERT_LIVE_IS_ALLOWED (s); - return Smob2::mark_smob (s); + ASSERT_LIVE_IS_ALLOWED (self_scm ()); + return Smob2::mark_smob (); } diff --git a/lily/music-iterator.cc b/lily/music-iterator.cc index 3647d4dc46..293a91ed4b 100644 --- a/lily/music-iterator.cc +++ b/lily/music-iterator.cc @@ -195,11 +195,9 @@ Music_iterator::get_music () const const char Music_iterator::type_p_name_[] = "ly:iterator?"; SCM -Music_iterator::mark_smob (SCM smob) +Music_iterator::mark_smob () { - Music_iterator *mus = (Music_iterator *)SCM_CELL_WORD_1 (smob); - - mus->derived_mark (); + derived_mark (); /* Careful with GC, although we intend the following as pointers only, we _must_ mark them. @@ -207,10 +205,10 @@ Music_iterator::mark_smob (SCM smob) /* Use handle_ directly as get_outlet is a virtual function and we need to protect the context until Music_iterator::quit is being run. */ - if (mus->handle_.get_context ()) - scm_gc_mark (mus->handle_.get_context ()->self_scm ()); - if (mus->music_) - scm_gc_mark (mus->music_->self_scm ()); + if (handle_.get_context ()) + scm_gc_mark (handle_.get_context ()->self_scm ()); + if (music_) + scm_gc_mark (music_->self_scm ()); return SCM_EOL; } diff --git a/lily/music-output.cc b/lily/music-output.cc index d0c08a1188..18eb372020 100644 --- a/lily/music-output.cc +++ b/lily/music-output.cc @@ -42,11 +42,9 @@ Music_output::derived_mark () const const char Music_output::type_p_name_[] = "ly:music-output?"; SCM -Music_output::mark_smob (SCM s) +Music_output::mark_smob () { - Music_output *sc = (Music_output *) SCM_CELL_WORD_1 (s); - - sc->derived_mark (); + derived_mark (); return SCM_EOL; } diff --git a/lily/output-def.cc b/lily/output-def.cc index ca0f7ad88a..eeb5a7a84c 100644 --- a/lily/output-def.cc +++ b/lily/output-def.cc @@ -62,16 +62,14 @@ Output_def::~Output_def () SCM -Output_def::mark_smob (SCM m) +Output_def::mark_smob () { - Output_def *mo = (Output_def*) SCM_CELL_WORD_1 (m); - /* FIXME: why is this necessary? all paper_ should be protected by themselves. */ - if (mo->parent_) - scm_gc_mark (mo->parent_->self_scm ()); + if (parent_) + scm_gc_mark (parent_->self_scm ()); - return mo->scope_; + return scope_; } void diff --git a/lily/page-marker.cc b/lily/page-marker.cc index ba5342ab2b..f2940d2b76 100644 --- a/lily/page-marker.cc +++ b/lily/page-marker.cc @@ -42,12 +42,11 @@ Page_marker::~Page_marker () const char Page_marker::type_p_name_[] = "ly:page-marker?"; SCM -Page_marker::mark_smob (SCM smob) +Page_marker::mark_smob () { - Page_marker *pm = (Page_marker *) SCM_CELL_WORD_1 (smob); - scm_gc_mark (pm->symbol_); - scm_gc_mark (pm->permission_); - scm_gc_mark (pm->label_); + scm_gc_mark (symbol_); + scm_gc_mark (permission_); + scm_gc_mark (label_); return SCM_EOL; } diff --git a/lily/paper-book.cc b/lily/paper-book.cc index 3a6d4b1074..cfc1caf2af 100644 --- a/lily/paper-book.cc +++ b/lily/paper-book.cc @@ -54,20 +54,19 @@ Paper_book::~Paper_book () const char Paper_book::type_p_name_[] = "ly:paper-book?"; SCM -Paper_book::mark_smob (SCM smob) +Paper_book::mark_smob () { - Paper_book *b = (Paper_book *) SCM_CELL_WORD_1 (smob); - if (b->paper_) - scm_gc_mark (b->paper_->self_scm ()); - if (b->parent_) - scm_gc_mark (b->parent_->self_scm ()); - scm_gc_mark (b->header_); - scm_gc_mark (b->header_0_); - scm_gc_mark (b->pages_); - scm_gc_mark (b->performances_); - scm_gc_mark (b->scores_); - scm_gc_mark (b->bookparts_); - return b->systems_; + if (paper_) + scm_gc_mark (paper_->self_scm ()); + if (parent_) + scm_gc_mark (parent_->self_scm ()); + scm_gc_mark (header_); + scm_gc_mark (header_0_); + scm_gc_mark (pages_); + scm_gc_mark (performances_); + scm_gc_mark (scores_); + scm_gc_mark (bookparts_); + return systems_; } int diff --git a/lily/paper-outputter.cc b/lily/paper-outputter.cc index 712c9c9bab..91bffa2242 100644 --- a/lily/paper-outputter.cc +++ b/lily/paper-outputter.cc @@ -62,11 +62,10 @@ Paper_outputter::~Paper_outputter () SCM -Paper_outputter::mark_smob (SCM x) +Paper_outputter::mark_smob () { - Paper_outputter *p = (Paper_outputter *) SCM_CELL_WORD_1 (x); - scm_gc_mark (p->output_module_); - return p->file_; + scm_gc_mark (output_module_); + return file_; } int diff --git a/lily/pitch.cc b/lily/pitch.cc index 8fd4d67171..08e6556cf6 100644 --- a/lily/pitch.cc +++ b/lily/pitch.cc @@ -219,11 +219,11 @@ Pitch::down_to (int notename) } const char Pitch::type_p_name_[] = "ly:pitch?"; + SCM -Pitch::mark_smob (SCM x) +Pitch::mark_smob () { - Pitch *p = (Pitch *) SCM_CELL_WORD_1 (x); - return p->scale_->self_scm (); + return scale_->self_scm (); } int diff --git a/lily/prob.cc b/lily/prob.cc index bb679512d3..490ae2f0c5 100644 --- a/lily/prob.cc +++ b/lily/prob.cc @@ -113,15 +113,14 @@ Prob::derived_mark () const } SCM -Prob::mark_smob (SCM smob) +Prob::mark_smob () { - ASSERT_LIVE_IS_ALLOWED (smob); + ASSERT_LIVE_IS_ALLOWED (self_scm ()); - Prob *system = (Prob *) SCM_CELL_WORD_1 (smob); - scm_gc_mark (system->mutable_property_alist_); - system->derived_mark (); + scm_gc_mark (mutable_property_alist_); + derived_mark (); - return system->immutable_property_alist_; + return immutable_property_alist_; } int diff --git a/lily/scheme-listener.cc b/lily/scheme-listener.cc index 2807cc4ad1..6e567b0aeb 100644 --- a/lily/scheme-listener.cc +++ b/lily/scheme-listener.cc @@ -35,10 +35,9 @@ Scheme_listener::Scheme_listener (SCM c) } SCM -Scheme_listener::mark_smob (SCM obj) +Scheme_listener::mark_smob () { - Scheme_listener *me = (Scheme_listener *) SCM_CELL_WORD_1 (obj); - return me->callback_; + return callback_; } int diff --git a/lily/scm-hash.cc b/lily/scm-hash.cc index 173dd49ccc..1944b537e1 100644 --- a/lily/scm-hash.cc +++ b/lily/scm-hash.cc @@ -71,10 +71,9 @@ Scheme_hash_table::~Scheme_hash_table () } SCM -Scheme_hash_table::mark_smob (SCM s) +Scheme_hash_table::mark_smob () { - Scheme_hash_table *me = (Scheme_hash_table *) SCM_CELL_WORD_1 (s); - scm_gc_mark (me->hash_tab_); + scm_gc_mark (hash_tab_); return SCM_EOL; } diff --git a/lily/score.cc b/lily/score.cc index 2074f810e7..b1659e2fbb 100644 --- a/lily/score.cc +++ b/lily/score.cc @@ -62,16 +62,14 @@ Score::~Score () const char Score::type_p_name_[] = "ly:score?"; SCM -Score::mark_smob (SCM s) +Score::mark_smob () { - Score *sc = (Score *) SCM_CELL_WORD_1 (s); + scm_gc_mark (header_); + for (vsize i = defs_.size (); i--;) + scm_gc_mark (defs_[i]->self_scm ()); - scm_gc_mark (sc->header_); - for (vsize i = sc->defs_.size (); i--;) - scm_gc_mark (sc->defs_[i]->self_scm ()); - - scm_gc_mark (sc->input_location_); - return sc->music_; + scm_gc_mark (input_location_); + return music_; } int diff --git a/lily/source-file.cc b/lily/source-file.cc index 34f8c8b9c5..849a8f7e6f 100644 --- a/lily/source-file.cc +++ b/lily/source-file.cc @@ -362,11 +362,9 @@ Source_file::get_port () const const char Source_file::type_p_name_[] = "ly:source-file?"; SCM -Source_file::mark_smob (SCM smob) +Source_file::mark_smob () { - Source_file *sc = (Source_file *) SCM_CELL_WORD_1 (smob); - - return sc->str_port_; + return str_port_; } int diff --git a/lily/stencil.cc b/lily/stencil.cc index 331dde2831..1e5e0ad4cc 100644 --- a/lily/stencil.cc +++ b/lily/stencil.cc @@ -47,10 +47,9 @@ Stencil::print_smob (SCM, SCM port, scm_print_state *) } SCM -Stencil::mark_smob (SCM smob) +Stencil::mark_smob () { - Stencil *s = (Stencil *) SCM_CELL_WORD_1 (smob); - return s->expr_; + return expr_; } const char Stencil::type_p_name_[] = "ly:stencil?"; diff --git a/lily/translator-group.cc b/lily/translator-group.cc index 23aae462e5..5f5e12aeba 100644 --- a/lily/translator-group.cc +++ b/lily/translator-group.cc @@ -358,11 +358,9 @@ Translator_group::print_smob (SCM s, SCM port, scm_print_state *) } SCM -Translator_group::mark_smob (SCM smob) +Translator_group::mark_smob () { - Translator_group *me = (Translator_group *)SCM_CELL_WORD_1 (smob); - - me->derived_mark (); - scm_gc_mark (me->protected_events_); - return me->simple_trans_list_; + derived_mark (); + scm_gc_mark (protected_events_); + return simple_trans_list_; } diff --git a/lily/translator.cc b/lily/translator.cc index e48b8956cf..4b73b7cd54 100644 --- a/lily/translator.cc +++ b/lily/translator.cc @@ -199,10 +199,9 @@ Translator::static_translator_description (const char *grobs, SMOBS */ SCM -Translator::mark_smob (SCM sm) +Translator::mark_smob () { - Translator *me = (Translator *) SCM_CELL_WORD_1 (sm); - me->derived_mark (); + derived_mark (); return SCM_EOL; } diff --git a/lily/undead.cc b/lily/undead.cc index 33d5ed5455..9105a995ea 100644 --- a/lily/undead.cc +++ b/lily/undead.cc @@ -23,7 +23,7 @@ class Undead : public Simple_smob { public: static int print_smob (SCM, SCM, scm_print_state *); - static SCM mark_smob (SCM); + SCM mark_smob (); static const char type_p_name_[]; private: SCM object_; @@ -33,11 +33,11 @@ public: }; SCM -Undead::mark_smob (SCM s) +Undead::mark_smob () { bool saved = parsed_objects_should_be_dead; parsed_objects_should_be_dead = false; - scm_gc_mark (Undead::unsmob (s)->object ()); + scm_gc_mark (object ()); parsed_objects_should_be_dead = saved; return SCM_UNDEFINED; } -- 2.39.2