2005-07-19 Han-Wen Nienhuys <hanwen@xs4all.nl>
+ * lily/include/translator.icc
+ (IMPLEMENT_FETCH_PRECOMPUTABLE_METHODS): directly jump into
+ Translator methods, without _static helper.
+
+ * lily/grob-smob.cc (derived_mark): rename from
+ do_derived_mark(). Don't return SCM.
+
* scm/define-context-properties.scm
(all-internal-translation-properties): remove tweakCount/tweakRank.
#include "audio-item.hh"
#include "music.hh"
+#include "translator.icc"
+
/*
TODO:
public:
TRANSLATOR_DECLARATIONS (Dynamic_performer);
protected:
- virtual bool try_music (Music *req);
+ virtual bool try_music (Music *event);
PRECOMPUTED_VIRTUAL void stop_translation_timestep ();
virtual void create_audio_elements ();
private:
- Music *script_req_;
+ Music *script_event_;
Audio_dynamic *audio_;
};
Dynamic_performer::Dynamic_performer ()
{
- script_req_ = 0;
+ script_event_ = 0;
audio_ = 0;
}
void
Dynamic_performer::create_audio_elements ()
{
- if (script_req_)
+ if (script_event_)
{
SCM proc = get_property ("dynamicAbsoluteVolumeFunction");
if (ly_is_procedure (proc))
{
// urg
- svolume = scm_call_1 (proc, script_req_->get_property ("text"));
+ svolume = scm_call_1 (proc, script_event_->get_property ("text"));
}
Real volume = robust_scm2double (svolume, 0.5);
}
audio_ = new Audio_dynamic (volume);
- Audio_element_info info (audio_, script_req_);
+ Audio_element_info info (audio_, script_event_);
announce_element (info);
- script_req_ = 0;
+ script_event_ = 0;
}
}
bool
Dynamic_performer::try_music (Music *r)
{
- if (!script_req_)
+ if (!script_event_)
{
if (r->is_mus_type ("absolute-dynamic-event")) // fixme.
{
- script_req_ = r;
+ script_event_ = r;
return true;
}
}
return false;
}
-#include "translator.icc"
-
ADD_TRANSLATOR (Dynamic_performer,
/*descr*/ "",
/* creats*/ "",
IMPLEMENT_SMOBS (Grob);
IMPLEMENT_DEFAULT_EQUAL_P (Grob);
+IMPLEMENT_TYPE_P (Grob, "ly:grob?");
SCM
Grob::mark_smob (SCM ses)
if (s->pscore_)
scm_gc_mark (s->pscore_->self_scm ());
- s->do_derived_mark ();
+ s->derived_mark ();
scm_gc_mark (s->object_alist_);
scm_gc_mark (s->interfaces_);
return 1;
}
-SCM
-Grob::do_derived_mark () const
+void
+Grob::derived_mark () const
{
- return SCM_EOL;
}
-
-IMPLEMENT_TYPE_P (Grob, "ly:grob?");
-
virtual void do_break_processing ();
virtual Grob *find_broken_piece (System *) const;
virtual void discretionary_processing ();
- virtual SCM do_derived_mark () const;
+ virtual void derived_mark () const;
Stencil *get_stencil () const;
SCM get_uncached_stencil () const;
protected:
virtual void discretionary_processing ();
void copy_breakable_items ();
- virtual SCM do_derived_mark () const;
+ virtual void derived_mark () const;
};
#endif
static int compare (Spanner *const &, Spanner *const &);
virtual Grob *find_broken_piece (System *) const;
- virtual SCM do_derived_mark () const;
+ virtual void derived_mark () const;
static bool has_interface (Grob *);
virtual System *get_system () const;
void pre_processing ();
protected:
- virtual SCM do_derived_mark () const;
+ virtual void derived_mark () const;
virtual Grob *clone (int count) const;
};
typedef void (*Translator_void_method_ptr)(Translator*);
-#define DECLARE_STATIC_METHOD(x) static void x ## _static (Translator*)
#define TRANSLATOR_DECLARATIONS(NAME) \
public: \
- DECLARE_STATIC_METHOD(start_translation_timestep); \
- DECLARE_STATIC_METHOD(stop_translation_timestep); \
- DECLARE_STATIC_METHOD(process_music); \
- DECLARE_STATIC_METHOD(process_acknowledged); \
NAME (); \
VIRTUAL_COPY_CONSTRUCTOR (Translator, NAME); \
static SCM static_description_; \
ADD_GLOBAL_CTOR (_ ## T ## _adder);
#define ADD_TRANSLATOR(classname, desc, grobs, accepted, acked, read, write) \
- DEFINE_STATIC_METHODS(classname);\
IMPLEMENT_FETCH_PRECOMPUTABLE_METHODS(classname); \
ADD_THIS_TRANSLATOR (classname); \
SCM \
return static_properties; \
}
-
-/*
- FIXME: should be able to cast statically to (T*) -iow.- remove
- Translator as a virtual base class.
- */
-#define DEFINE_STATIC_METHOD(T, x) \
-void \
-T::x ## _static (Translator* tr) \
-{ \
- T * t_ptr = (T*) (tr); \
- t_ptr->x ();\
-}
-
-#define DEFINE_STATIC_METHODS(T) \
- DEFINE_STATIC_METHOD(T,start_translation_timestep)\
- DEFINE_STATIC_METHOD(T,stop_translation_timestep)\
- DEFINE_STATIC_METHOD(T,process_music)\
- DEFINE_STATIC_METHOD(T,process_acknowledged)
-
#define IMPLEMENT_FETCH_PRECOMPUTABLE_METHODS(T) \
void \
T::fetch_precomputable_methods (Translator_void_method_ptr ptrs[])\
((Translator_void_method_ptr) &T::start_translation_timestep == \
(Translator_void_method_ptr) &Translator::start_translation_timestep) \
? 0 \
- : &T::start_translation_timestep_static; \
+ : (Translator_void_method_ptr) &T::start_translation_timestep; \
\
ptrs[STOP_TRANSLATION_TIMESTEP] = \
((Translator_void_method_ptr) &T::stop_translation_timestep == (Translator_void_method_ptr) &Translator::stop_translation_timestep) \
? 0 \
- : &T::stop_translation_timestep_static; \
+ : (Translator_void_method_ptr) &T::stop_translation_timestep; \
\
ptrs[PROCESS_MUSIC] = \
((Translator_void_method_ptr) &T::process_music == (Translator_void_method_ptr) &Translator::process_music) \
? 0 \
- : &T::process_music_static; \
+ : (Translator_void_method_ptr) &T::process_music; \
\
ptrs[PROCESS_ACKNOWLEDGED] = \
((Translator_void_method_ptr) &T::process_acknowledged == (Translator_void_method_ptr) &Translator::process_acknowledged) \
? 0 \
- : &T::process_acknowledged_static; \
+ : (Translator_void_method_ptr) &T::process_acknowledged; \
}
}
}
-SCM
-Item::do_derived_mark () const
+void
+Item::derived_mark () const
{
if (broken_to_drul_[LEFT])
scm_gc_mark (broken_to_drul_[LEFT]->self_scm ());
if (broken_to_drul_[RIGHT])
scm_gc_mark (broken_to_drul_[RIGHT]->self_scm ());
- return SCM_EOL;
}
Item *
Font_metric *fm = Font_interface::get_default_font (me);
- Direction stem_dir = CENTER;
- if (Grob *stem = unsmob_grob (me->get_object ("stem")))
- {
- stem_dir = get_grob_direction (stem);
- if (stem_dir == CENTER)
- programming_error ("must have stem dir for note head");
- }
+ String idx = "noteheads.s" + suffix;
- Stencil out;
-
- String prefix = "noteheads.";
- String idx
- = prefix + ((stem_dir == UP) ? "u" : "d") + suffix;
- out = fm->find_by_name (idx);
+ Stencil out = fm->find_by_name (idx);
if (out.is_empty ())
{
- idx = prefix + "s" + suffix;
+ String prefix = "noteheads.";
+ Grob *stem = unsmob_grob (me->get_object ("stem"));
+ Direction stem_dir = stem ? get_grob_direction (stem) : CENTER;
+
+ if (stem_dir == CENTER)
+ programming_error ("must have stem dir for note head");
+ String idx = prefix + ((stem_dir == UP) ? "u" : "d") + suffix;
out = fm->find_by_name (idx);
}
return 0.0;
}
-SCM
-Spanner::do_derived_mark () const
+void
+Spanner::derived_mark () const
{
-#if 0
- /*
- We'd be fucked if this is called before spanned_drul_[] is inited. */
- if (status_ == ORPHAN)
- return SCM_EOL;
-#endif
-
Direction d = LEFT;
do
if (spanned_drul_[d])
for (int i = broken_intos_.size (); i--;)
scm_gc_mark (broken_intos_[i]->self_scm ());
-
- return SCM_EOL;
}
/*
}
}
-SCM
-System::do_derived_mark () const
+void
+System::derived_mark () const
{
if (!all_elements_->is_empty ())
{
ptr ++;
}
}
- return Spanner::do_derived_mark ();
+ Spanner::derived_mark ();
}
static void