Simultaneous_music_iterator): use SCM list for list of iterators.
* lily/cxx-function-smob.cc: remove file.
* lily/include/cxx-function-smob.hh: remove file.
* lily/include/music-iterator.hh (class Music_iterator): smobify
music-iterator; many changes throughout. They are now constructed
through procedures that return the smobbed iterator.
* lily/syllable-group.cc (set_lyric_align): remove conditional
again.
* Documentation/bibliography/computer-notation.bib (note): add
Beyond MIDI and The Virtual Score.
+2002-09-08 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+
+ * lily/include/simultaneous-music-iterator.hh (class
+ Simultaneous_music_iterator): use SCM list for list of iterators.
+
+ * lily/cxx-function-smob.cc: remove file.
+
+ * lily/include/cxx-function-smob.hh: remove file.
+
+ * lily/include/music-iterator.hh (class Music_iterator): smobify
+ music-iterator; many changes throughout. They are now constructed
+ through procedures that return the smobbed iterator.
+
+ * lily/include/*.hh: all derived_mark() functions are now const.
+
+ * lily/syllable-group.cc (set_lyric_align): remove conditional
+ again.
+
+ * Documentation/bibliography/computer-notation.bib (note): add
+ Beyond MIDI and The Virtual Score.
+
2002-09-07 Rune Zedeler <rune@zedeler.dk>
* input/sondag-morgen/*.ly: Tablature fixes
* lily/musical-request.cc (String_number_req): Added
- * lily/tab-note-heads-engraver.cc: Use String_number_req instead of Text_script_req;
- read properties stringOneTopmost and highStringOne.
+ * lily/tab-note-heads-engraver.cc: Use String_number_req instead
+ of Text_script_req; read properties stringOneTopmost and
+ highStringOne.
* ly/engraver-init.ly (tabStaffContext): Bugfix: remove Key_engraver
set stringOneTopmost and highStringOne to #t
* scm/output-lib.scm (tablature-stem-attachment-function): Changed
(guitar-tunings): List added
+ ((every-nth-bar-number-visible n) barnum): Instead of
+ default-bar-number-visibility
((every-nth-bar-number-visible n) barnum): added
* scm/grob-description.scm (TabNoteHead): Extra-offset added (UGH!)
}
+@Book{selfridge-field97:_beyon_midi,
+ editor = {Eleanor Selfridge-Field},
+ title = {Beyond MIDI},
+ publisher = {MIT Press},
+ year = 1997,
+ note = {Description of various music interchange formats.}
+}
+
+
+@Book{hewlett01:_virtual_score,
+ editor = {Walter B. Hewlett and Eleanor Selfridge-Field},
+ title = {The Virtual Score; representation, retrieval and restoration},
+ publisher = {MIT Press},
+series = {Computing in Musicology},
+ year = 2001
+}
+
+
+
+@InProceedings{hoos98:_guido_music_notat_format,
+title={The {GUIDO} Music Notation Format---A Novel Approach
+for Adequately Representing Score-level Music},
+author = {H. H. Hoos and K. A. Hamel and K. Renz and J. Kilian},
+booktitle = {Proceedings of International Computer Music Conference},
+year = 1998,
+pages = {451--454},
+}
% LIME
@Article {haken93,
* Completely rewritten MIDI import support.
-* Completely rewritten grace note support. Practically speaking this means
-that grace notes can be slurred to normal normal notes.
+* Completely rewritten grace note support. Practically speaking this
+means that grace notes can be slurred to normal normal notes.
* Improved accidental handling and formatting: styles for producing
cautionaries may vary, and complex collisions between accidentals of a
%\paper { linewidth = -1. }
\score {
- \addlyrics
- \context Voice = "v" \notes \relative c'' {
+< \context Voice = "v" \notes \relative c'' {
\property Staff.automaticMelismata = ##t
\cadenzaOn
a\breve \bar "||" a1 \bar "|" a \bar "|" a \bar "||" \break a \bar "|" a \bar "|" a \bar "|" a \bar "||" \break a \bar "|" a \bar "|."
\property Lyrics . LyricText \override #'alignment = #-1
\property Lyrics . LyricText \override #'begin-alignment = #8
- "Particularly useful for reciting notes "
- left
+ "Particularly useful for reciting notes "\breve
+ left1
\property Lyrics . LyricText \override #'alignment = #0
-
centered
\property Lyrics . LyricText \override #'alignment = #1
}
\context LyricsVoice = "v-2" \lyrics {
% \property LyricsVoice . stanza = "2:"
- " with many syllables under them." l c r l l l x x x note' true'
+ " with many syllables under them."\breve
+ l1 c r1 l
+ l1 l x x x
+
+ % note' true'
+ %% ? what are the last 2 for?
}
>
+ >
}
m = iter->pending_moment ();
}
- delete iter;
return ps;
}
VIRTUAL_COPY_CONS(Bar_check_iterator);
virtual void process (Moment);
Bar_check_iterator( );
- static SCM constructor_cxx_function;
+ DECLARE_SCHEME_CALLBACK(constructor, ());
};
-IMPLEMENT_CTOR_CALLBACK (Bar_check_iterator);
+IMPLEMENT_CTOR_CALLBACK(Bar_check_iterator);
Music * get_barcheck ()
{
Music *bc = new Music;
- bc->set_mus_property ("iterator-ctor", Bar_check_iterator::constructor_cxx_function);
+ bc->set_mus_property ("iterator-ctor", Bar_check_iterator::constructor_proc);
return bc;
}
SCM proc = me->get_grob_property ("break-glyph-function");
g = gh_call2 (proc, g, scm_int2num (bsd));
}
-
if (!gh_string_p (g))
{
{
Repeated_music * rp = dynamic_cast<Repeated_music*> (m);
if (rp
- && rp->get_mus_property ("iterator-ctor") == Chord_tremolo_iterator::constructor_cxx_function
+ && rp->get_mus_property ("iterator-ctor") == Chord_tremolo_iterator::constructor_proc
&& !repeat_)
{
Moment l = rp->length_mom ();
{
Repeated_music * rep = dynamic_cast<Repeated_music*> (get_music ());
factor_ = Moment (Rational(1, 1));
- child_iter_ = get_iterator (rep->body ());
+ child_iter_ = unsmob_iterator (get_iterator (rep->body ()));
}
Chord_tremolo_iterator::Chord_tremolo_iterator ()
: Music_iterator (src)
{
factor_ = src.factor_;
- child_iter_ = src.child_iter_ ? src.child_iter_->clone () : 0;
+ child_iter_ = src.child_iter_ ? src.child_iter_->clone () : 0;
+ if (child_iter_)
+ scm_gc_unprotect_object (child_iter_->self_scm());
+}
+
+void
+Chord_tremolo_iterator::derived_mark () const
+{
+ if (child_iter_)
+ scm_gc_mark (child_iter_->self_scm());
}
void
return child_iter_ && child_iter_->ok ();
}
-Chord_tremolo_iterator::~Chord_tremolo_iterator ()
-{
- delete child_iter_;
-}
-
Music_iterator*
Chord_tremolo_iterator::try_music_in_children (Music *m) const
{
-/*
- grob-callback.cc -- implement Callback smob.
-
- source file of the GNU LilyPond music typesetter
-
- (c) 2000--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
-
-#include "cxx-function-smob.hh"
-#include "ly-smobs.icc"
-
-static scm_t_bits callback_tag;
-
-static
-SCM mark_smob (SCM)
-{
- return SCM_EOL;
-}
-
-static int
-print_smob (SCM, SCM port, scm_print_state *)
-{
- scm_puts ("#<encapsulated C++ function>", port);
- return 1;
-}
-
-static size_t
-free_smob (SCM)
-{
- return 0;
-}
-
-LY_DEFINE(cxx_function_type, "c++-function?", 1, 0, 0, (SCM x),
- "Is this an encapsulated C++ function ?")
-{
- return (SCM_CELL_TYPE (x)) == callback_tag ? SCM_BOOL_T : SCM_BOOL_F;
-}
-
-void init_cxx_function_smobs ()
-{
- callback_tag = scm_make_smob_type ("callback", 0);
- scm_set_smob_mark (callback_tag, mark_smob);
- scm_set_smob_free (callback_tag, free_smob);
- scm_set_smob_print (callback_tag, print_smob);
- scm_set_smob_equalp (callback_tag, 0);
-}
-
-SCM
-smobify_cxx_function (Cxx_function cb)
-{
- SCM z;
- SCM_NEWSMOB(z,callback_tag, cb) ;
- return z;
-}
-
-
-Cxx_function
-unsmob_cxx_function (SCM x)
-{
-
- if (SCM_NIMP (x) && SCM_CELL_TYPE (x) == callback_tag)
- return (Cxx_function) SCM_CELL_WORD_1 (x);
- else
- return 0;
-}
-
return main_iter_ || alternative_iter_;
}
-Folded_repeat_iterator::~Folded_repeat_iterator ()
-{
- delete main_iter_;
- delete alternative_iter_;
-}
-
Folded_repeat_iterator::Folded_repeat_iterator (Folded_repeat_iterator const &src)
: Music_iterator (src)
{
main_iter_ = src.main_iter_ ? src.main_iter_->clone () : 0;
alternative_iter_ = src.alternative_iter_ ? src.alternative_iter_->clone () : 0;
main_length_mom_ = src.main_length_mom_;
+ if (main_iter_)
+ scm_gc_unprotect_object (main_iter_->self_scm());
+ if (alternative_iter_)
+ scm_gc_unprotect_object (alternative_iter_->self_scm());
}
Moment
Folded_repeat_iterator::construct_children ()
{
Repeated_music * mus = dynamic_cast<Repeated_music*> (get_music ());
- main_iter_ = get_iterator (mus->body ());
+ main_iter_ = unsmob_iterator (get_iterator (mus->body ()));
if (!main_iter_->ok ())
{
leave_body ();
alternative_iter_->process (m - main_length_mom_);
if (!alternative_iter_->ok ())
{
- delete alternative_iter_;
alternative_iter_ =0;
}
}
Folded_repeat_iterator::leave_body ()
{
Repeated_music * mus = dynamic_cast<Repeated_music *> (get_music ());
- delete main_iter_;
+
main_iter_ = 0;
main_length_mom_ += mus->body ()->length_mom ();
}
return alternative_iter_->try_music (m);
return 0;
}
-
+void
+Folded_repeat_iterator::derived_mark()const
+{
+ if (main_iter_)
+ scm_gc_mark (main_iter_->self_scm());
+ if (alternative_iter_)
+ scm_gc_mark (alternative_iter_->self_scm());
+}
IMPLEMENT_CTOR_CALLBACK (Folded_repeat_iterator);
void
-Font_metric::derived_mark ()
+Font_metric::derived_mark ()const
{
}
#include "global-translator.hh"
#include "warn.hh"
-
-Grace_iterator::~Grace_iterator ()
-{
- // child_iter_ = 0;
-}
-
-
void
Grace_iterator::process (Moment m)
{
Grace_music::Grace_music ()
{
set_mus_property ("iterator-ctor",
- Grace_iterator::constructor_cxx_function);
+ Grace_iterator::constructor_proc);
}
Grace_music::Grace_music (SCM p)
: Music_wrapper (p)
{
set_mus_property ("iterator-ctor",
- Grace_iterator::constructor_cxx_function);
+ Grace_iterator::constructor_proc);
}
ADD_MUSIC (Grace_music);
}
SCM
-Grob::do_derived_mark ()
+Grob::do_derived_mark () const
{
return SCM_EOL;
}
#include "drul-array.hh"
/**
- Any piece of audio information.
- We need virtual conclassors,
- let's try decentralised factory for specific audio implemenations.
-
+
+ Any piece of audio information. We need virtual constructors, let's
+ try decentralised factory for specific audio implemenations.
*/
class Audio_item : public Audio_element
{
{
public:
VIRTUAL_COPY_CONS (Music_iterator);
- static SCM constructor_cxx_function;
+ DECLARE_SCHEME_CALLBACK(constructor, ());
Auto_change_iterator ();
VIRTUAL_COPY_CONS (Music_iterator);
/* constructor is public */
virtual void process (Moment);
- static SCM constructor_cxx_function;
+ DECLARE_SCHEME_CALLBACK(constructor, ());
+
private:
void error (String);
};
{
public:
VIRTUAL_COPY_CONS (Music_iterator);
- static SCM constructor_cxx_function;
+ DECLARE_SCHEME_CALLBACK(constructor, ());
Chord_tremolo_iterator ();
Chord_tremolo_iterator (Chord_tremolo_iterator const & );
protected:
- virtual ~Chord_tremolo_iterator ();
+ virtual void derived_mark () const;
virtual Moment pending_moment () const;
virtual void construct_children () ;
virtual bool ok () const;
virtual void process (Moment) ;
virtual Music_iterator *try_music_in_children (Music *) const;
-
private:
Moment factor_;
Music_iterator * child_iter_;
-/*
- cxx-function-smob.hh --
- source file of the GNU LilyPond music typesetter
-
- (c) 2000--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
-
-#ifndef CXX_FUNCT_SMOB_HH
-#define CXX_FUNCT_SMOB_HH
-
-#include "lily-proto.hh"
-#include "lily-guile.hh"
-
-typedef void * (*Cxx_function) (SCM param);
-Cxx_function unsmob_cxx_function (SCM x);
-SCM smobify_cxx_function (Cxx_function cb);
-
-
-#endif /* CXX_FUNCT_SMOB_HH */
-
{
public:
VIRTUAL_COPY_CONS (Music_iterator);
- static SCM constructor_cxx_function;
+ DECLARE_SCHEME_CALLBACK(constructor, ());
Folded_repeat_iterator (Folded_repeat_iterator const &src);
Folded_repeat_iterator ();
- ~Folded_repeat_iterator ();
-
+ virtual void derived_mark () const;
virtual void construct_children ();
virtual Moment pending_moment () const;
virtual bool ok () const;
private:
Font_metric (Font_metric const&); // no copy.
protected:
- virtual void derived_mark();
+ virtual void derived_mark () const;
Font_metric ();
};
{
public:
VIRTUAL_COPY_CONS (Music_iterator);
- ~Grace_iterator ();
virtual void construct_children () ;
virtual void process (Moment);
- static SCM constructor_cxx_function;
+ DECLARE_SCHEME_CALLBACK(constructor, ());
Moment pending_moment () const;
};
virtual void do_break_processing ();
virtual Grob *find_broken_piece (System*) const;
virtual void discretionary_processing ();
- virtual SCM do_derived_mark ();
+ virtual SCM do_derived_mark () const;
Molecule * get_molecule () const;
SCM get_uncached_molecule () const;
protected:
virtual void discretionary_processing ();
void copy_breakable_items ();
- virtual SCM do_derived_mark ();
+ virtual SCM do_derived_mark () const;
};
} _ ## name ## _scm_initter; \
/* end define */
-#define LY_DEFINE(FNAME, PRIMNAME, REQ, OPT, VAR, ARGLIST, DOCSTRING) \
-SCM FNAME ARGLIST ; \
+#define LY_DEFINE_WITHOUT_DECL(INITPREFIX, FNAME, PRIMNAME, REQ, OPT, VAR, ARGLIST, DOCSTRING) \
SCM FNAME ## _proc;\
void \
-FNAME ## init ()\
+INITPREFIX ## init ()\
{\
FNAME ## _proc \
= scm_c_define_gsubr (PRIMNAME,REQ, OPT, VAR, (Scheme_function_unknown) FNAME);\
ly_add_function_documentation (PRIMNAME, #ARGLIST, DOCSTRING);\
}\
-ADD_SCM_INIT_FUNC (FNAME ## init_unique_prefix, FNAME ## init);\
+ADD_SCM_INIT_FUNC (INITPREFIX ## init_unique_prefix, INITPREFIX ## init);\
SCM \
FNAME ARGLIST\
+#define LY_DEFINE(FNAME, PRIMNAME, REQ, OPT, VAR, ARGLIST, DOCSTRING) \
+SCM FNAME ARGLIST ; \
+LY_DEFINE_WITHOUT_DECL(FNAME, FNAME, PRIMNAME, REQ, OPT, VAR, ARGLIST, DOCSTRING)
+
+
+#define LY_DEFINE_MEMBER_FUNCTION(CLASS, FNAME, PRIMNAME, REQ, OPT, VAR, ARGLIST, DOCSTRING) \
+SCM FNAME ARGLIST ; \
+LY_DEFINE_WITHOUT_DECL(CLASS ## FNAME, CLASS::FNAME, PRIMNAME, REQ, OPT, VAR, ARGLIST, DOCSTRING)
+
+
#endif /* LILY_GUILE_HH */
VIRTUAL_COPY_CONS (Music_iterator);
Lyric_combine_music_iterator ();
Lyric_combine_music_iterator (Lyric_combine_music_iterator const&src);
- static SCM constructor_cxx_function;
+ DECLARE_SCHEME_CALLBACK(constructor, ());
protected:
virtual void construct_children ();
virtual Moment pending_moment () const;
virtual Music_iterator *try_music_in_children (Music *) const;
virtual bool ok () const;
- virtual ~Lyric_combine_music_iterator ();
-
+ virtual void derived_mark () const;
private:
bool get_busy_status ()const ;
Music_iterator * music_iter_;
#include "virtual-methods.hh"
#include "interpretation-context-handle.hh"
#include "cxx-function-smob.hh"
+#include "smobs.hh"
/**
---
protected:
Moment music_length_;
Moment start_mom_;
+
+ DECLARE_SMOBS (Music_iterator,dummy);
public:
VIRTUAL_COPY_CONS (Music_iterator);
-
+
Moment music_length_mom () const;
Moment music_start_mom () const;
Music_iterator ();
Music_iterator (Music_iterator const&);
- virtual ~Music_iterator ();
/**
Do the reporting. Will try MUSIC_L_ in its own translator first,
/** Get an iterator matching the type of MUS, and use TRANS to find
an accompanying translation unit
*/
- static Music_iterator* get_static_get_iterator (Music * mus);
+ static SCM get_static_get_iterator (Music * mus);
void init_translator (Music *, Translator_group *);
virtual Moment pending_moment () const;
virtual SCM get_pending_events (Moment until)const;
virtual void process (Moment until);
virtual void skip (Moment until);
-
+ virtual void derived_mark ()const;
+
/**
Construct sub-iterators, and set the translator to
report to.
*/
virtual void construct_children ();
- static SCM constructor_cxx_function;
+ DECLARE_SCHEME_CALLBACK(constructor, ());
/**
Get an iterator for MUS, inheriting the translation unit from THIS.
*/
- Music_iterator* get_iterator (Music *) const;
+ SCM get_iterator (Music *) const;
virtual Music_iterator* try_music_in_children (Music *) const;
};
-/*
- implement Class::constructor, a SCM function that
- returns an encapsulated factory function.
- */
#define IMPLEMENT_CTOR_CALLBACK(Class) \
-static void * \
-Class ## _ctor (SCM) \
+LY_DEFINE_MEMBER_FUNCTION(Class,constructor, #Class "::constructor",\
+ 0,0,0,\
+ (),\
+ "Construct a " #Class " music iterator")\
{ \
- return new Class ; \
+ SCM val = (new Class)->self_scm(); \
+ scm_gc_unprotect_object (val);\
+ return val ; \
} \
-SCM Class :: constructor_cxx_function;\
-void \
-Class ## _constructor_init () \
-{ \
- SCM s = smobify_cxx_function (& Class ## _ctor); \
- scm_permanent_object (s);\
- gh_define (#Class "::constructor", s);\
- Class :: constructor_cxx_function = s;\
-}\
-ADD_SCM_INIT_FUNC (Class ## _ctor_init, Class ## _constructor_init);
-
-
-
-
-
+DECLARE_UNSMOB(Music_iterator, iterator);
#endif // MUSIC_ITERATOR_HH
{
public:
VIRTUAL_COPY_CONS (Music_iterator);
- static SCM constructor_cxx_function;
+ DECLARE_SCHEME_CALLBACK(constructor, ());
Music_wrapper_iterator ();
Music_wrapper_iterator (Music_wrapper_iterator const&);
- ~Music_wrapper_iterator ();
+ virtual void derived_mark () const;
virtual void construct_children () ;
virtual Moment pending_moment () const;
virtual bool ok () const;
{
public:
VIRTUAL_COPY_CONS (Music_iterator);
- static SCM constructor_cxx_function;
+ DECLARE_SCHEME_CALLBACK(constructor, ());
/* construction */
protected:
virtual void process (Moment);
Part_combine_music_iterator ();
enum State { UNKNOWN, UNRELATED=1, SOLO1=2, SOLO2=4, UNIRHYTHM=8, UNISON=16, UNISILENCE=32, SPLIT_INTERVAL=64 };
- static SCM constructor_cxx_function;
+ DECLARE_SCHEME_CALLBACK(constructor, ());
protected:
- virtual ~Part_combine_music_iterator ();
+ virtual void derived_mark () const;
Part_combine_music_iterator (Part_combine_music_iterator const &);
virtual void construct_children ();
virtual Moment pending_moment () const;
{
public:
VIRTUAL_COPY_CONS (Music_iterator);
- static SCM constructor_cxx_function;
+ DECLARE_SCHEME_CALLBACK(constructor, ());
Percent_repeat_iterator ();
Percent_repeat_iterator (Percent_repeat_iterator const & );
protected:
- virtual ~Percent_repeat_iterator ();
+ virtual void derived_mark () const;
virtual Moment pending_moment () const;
virtual void construct_children () ;
virtual bool ok () const;
{
public:
VIRTUAL_COPY_CONS (Music_iterator);
- static SCM constructor_cxx_function;
+ DECLARE_SCHEME_CALLBACK(constructor, ());
/* construction */
protected:
virtual void process (Moment);
{
public:
VIRTUAL_COPY_CONS (Music_iterator);
- static SCM constructor_cxx_function;
+ DECLARE_SCHEME_CALLBACK(constructor, ());
/* construction */
protected:
virtual void process (Moment);
{
public:
VIRTUAL_COPY_CONS (Music_iterator);
- static SCM constructor_cxx_function;
+ DECLARE_SCHEME_CALLBACK(constructor, ());
protected:
/* construction */
virtual void process (Moment);
class Pop_property_iterator : public Simple_music_iterator
{
public:
- static SCM constructor_cxx_function;
+ DECLARE_SCHEME_CALLBACK(constructor, ());
VIRTUAL_COPY_CONS (Music_iterator);
protected:
/* construction */
enum { NONE_DONE, START_DONE, END_DONE } status_;
public:
VIRTUAL_COPY_CONS (Music_iterator);
- static SCM constructor_cxx_function;
+ DECLARE_SCHEME_CALLBACK(constructor, ());
Request_chord_iterator ();
Request_chord_iterator (Request_chord_iterator const&);
Grace_fixup * grace_fixups_;
VIRTUAL_COPY_CONS (Music_iterator);
- static SCM constructor_cxx_function;
+ DECLARE_SCHEME_CALLBACK(constructor, ());
Sequential_iterator ();
Sequential_iterator (Sequential_iterator const&);
- virtual ~Sequential_iterator ();
+ virtual void derived_mark () const;
virtual void construct_children ();
virtual Moment pending_moment () const;
{
public:
VIRTUAL_COPY_CONS (Music_iterator);
- static SCM constructor_cxx_function;
+ DECLARE_SCHEME_CALLBACK(constructor, ());
private:
virtual SCM get_music_list()const;
virtual void descend_to_child ();
Moment last_processed_mom_;
public:
VIRTUAL_COPY_CONS (Music_iterator);
- static SCM constructor_cxx_function;
+ DECLARE_SCHEME_CALLBACK(constructor, ());
Simple_music_iterator ();
Simple_music_iterator (Simple_music_iterator const &);
virtual void process (Moment);
#define SIMULTANEOUS_MUSIC_ITERATOR_HH
#include "music-iterator.hh"
-#include "cons.hh"
class Simultaneous_music_iterator : public Music_iterator
{
VIRTUAL_COPY_CONS (Music_iterator);
Simultaneous_music_iterator ();
Simultaneous_music_iterator (Simultaneous_music_iterator const&);
- virtual ~Simultaneous_music_iterator ();
- static SCM constructor_cxx_function;
+ virtual void derived_mark () const;
+ DECLARE_SCHEME_CALLBACK(constructor, ());
/// make a new context for every child.
bool separate_contexts_b_;
virtual Music_iterator *try_music_in_children (Music *) const;
private:
- Cons_list<Music_iterator> children_p_list_;
+ SCM children_list_;
};
#endif // SIMULTANEOUS_MUSIC_ITERATOR_HH
static int compare (Spanner * const &,Spanner * const &);
virtual Grob* find_broken_piece (System*) const;
- virtual SCM do_derived_mark ();
+ virtual SCM do_derived_mark () const;
static bool has_interface (Grob*);
virtual System *get_system () const;
protected:
{
public:
VIRTUAL_COPY_CONS (Music_iterator);
- static SCM constructor_cxx_function;
+ DECLARE_SCHEME_CALLBACK(constructor, ());
/* construction */
protected:
virtual void process (Moment);
virtual Molecule find_by_name (String) const;
protected:
- virtual void derived_mark();
+ virtual void derived_mark () const;
};
}
SCM
-Item::do_derived_mark ()
+Item::do_derived_mark ()const
{
if (broken_to_drul_[LEFT])
scm_gc_mark (broken_to_drul_[LEFT]->self_scm ());
scm_init_funcs_->push (f);
}
-extern void init_cxx_function_smobs ();
-
void
ly_init_guile ()
SCM last_mod = scm_current_module ();
scm_set_current_module (scm_c_resolve_module ("guile"));
- init_cxx_function_smobs ();
for (int i=scm_init_funcs_->size () ; i--;)
(scm_init_funcs_->elem (i)) ();
return music_iter_->ok ();
}
+void
+Lyric_combine_music_iterator::derived_mark()const
+{
+ if (music_iter_)
+ scm_gc_mark (music_iter_->self_scm());
+ if (lyric_iter_)
+ scm_gc_mark (lyric_iter_->self_scm());
+}
void
Lyric_combine_music_iterator::construct_children ()
{
Lyric_combine_music const * m = dynamic_cast<Lyric_combine_music const*> (get_music ());
- music_iter_ = get_iterator (m->get_music ());
- lyric_iter_ = get_iterator (m->get_lyrics ());
+ music_iter_ = unsmob_iterator (get_iterator (m->get_music ()));
+ lyric_iter_ = unsmob_iterator (get_iterator (m->get_lyrics ()));
+
+ scm_gc_unprotect_object (music_iter_->self_scm());
+ scm_gc_unprotect_object (lyric_iter_->self_scm());
}
bool
}
-Lyric_combine_music_iterator::~Lyric_combine_music_iterator ()
-{
- delete lyric_iter_;
- delete music_iter_;
-}
Lyric_combine_music_iterator::Lyric_combine_music_iterator (Lyric_combine_music_iterator const & src)
: Music_iterator (src)
{
lyric_iter_ = src.lyric_iter_ ? src.lyric_iter_->clone () : 0;
music_iter_ = src.music_iter_ ? src.music_iter_->clone () : 0;
+
+ scm_gc_unprotect_object (music_iter_->self_scm());
+ scm_gc_unprotect_object (lyric_iter_->self_scm());
}
Music_iterator*
: Music (l)
{
set_mus_property ("iterator-ctor",
- Lyric_combine_music_iterator::constructor_cxx_function);
+ Lyric_combine_music_iterator::constructor_proc);
}
#include "simple-music-iterator.hh"
#include "context-specced-music.hh"
+#include "ly-smobs.icc"
+
Music_iterator::Music_iterator ()
{
+ smobify_self ();
}
Music_iterator::Music_iterator (Music_iterator const& src)
music_ = src.music_;
music_length_ = src.music_length_;
start_mom_ = src.start_mom_;
+ smobify_self ();
}
Music_iterator::~Music_iterator ()
return handle_.report_to ();
}
-
void
Music_iterator::set_translator (Translator_group *trans)
{
return SCM_EOL;
}
-Music_iterator*
+SCM
Music_iterator::get_static_get_iterator (Music *m)
{
Music_iterator * p =0;
SCM ctor = m->get_mus_property ("iterator-ctor") ;
- if (unsmob_cxx_function (ctor))
+ SCM iter = SCM_EOL;
+ if (gh_procedure_p (ctor))
{
- Cxx_function f = unsmob_cxx_function (ctor);
-
- p = (Music_iterator*) (*f) (SCM_EOL);
+ iter = gh_call0 (ctor);
+ p = unsmob_iterator (iter);
}
- else if (dynamic_cast<Music_wrapper *> (m))
- p = new Music_wrapper_iterator;
else
{
- p = new Simple_music_iterator ;
+ if (dynamic_cast<Music_wrapper *> (m))
+ p = new Music_wrapper_iterator;
+ else
+ p = new Simple_music_iterator;
+
+ iter = p->self_scm();
+ scm_gc_unprotect_object (iter);
}
p->music_ = m;
assert (m);
p->music_length_ = m->length_mom ();
p->start_mom_ = m->start_mom ();
- return p;
+ return iter;
}
Music_iterator::music_length_mom () const
{
return music_length_;
-
}
Moment
}
-Music_iterator*
+SCM
Music_iterator::get_iterator (Music *m) const
{
- Music_iterator*p = get_static_get_iterator (m);
+ SCM ip = get_static_get_iterator (m);
+ Music_iterator*p = unsmob_iterator (ip);
+
p->init_translator (m, report_to ());
p->construct_children ();
- return p;
+ return ip;
}
/*
Iterator::try_music
*/
-
Music_iterator*
Music_iterator::try_music (Music *m) const
{
{
return music_;
}
+
+/****************************************************************/
+
+IMPLEMENT_TYPE_P (Music_iterator, "ly-iterator?");
+IMPLEMENT_SMOBS(Music_iterator);
+IMPLEMENT_DEFAULT_EQUAL_P(Music_iterator);
+
+SCM
+Music_iterator::mark_smob (SCM smob)
+{
+ Music_iterator * mus = (Music_iterator *)SCM_CELL_WORD_1 (smob);
+ mus->derived_mark ();
+ return SCM_EOL;
+}
+
+int
+Music_iterator::print_smob (SCM , SCM port, scm_print_state*)
+{
+ scm_puts ("#<Music iterator>", port);
+ return 1;
+}
+
+void
+Music_iterator::derived_mark()const
+{
+}
Music_wrapper_iterator::Music_wrapper_iterator (Music_wrapper_iterator const &src)
: Music_iterator (src)
{
+ child_iter_ = (src.child_iter_) ? src.child_iter_->clone () : 0;
if (src.child_iter_)
- child_iter_ = src.child_iter_->clone ();
- else
- child_iter_ = 0;
+ scm_gc_unprotect_object (child_iter_->self_scm());
}
-Music_wrapper_iterator::~Music_wrapper_iterator ()
+void
+Music_wrapper_iterator::derived_mark()const
{
- delete child_iter_;
+ if (child_iter_)
+ scm_gc_mark (child_iter_->self_scm());
}
void
Music_wrapper_iterator::construct_children ()
{
- child_iter_ =
- get_iterator (dynamic_cast<Music_wrapper const*> (get_music ())->element ());
+ Music * m = dynamic_cast<Music_wrapper const*> (get_music ())-> element();
+ child_iter_ = unsmob_iterator (get_iterator (m));
}
bool
Output_property_engraver::try_music (Music* m)
{
if (m->get_mus_property ("iterator-ctor") ==
- Output_property_music_iterator::constructor_cxx_function)
+ Output_property_music_iterator::constructor_proc)
{
props_.push (m);
return true;
Music * p = new Music (SCM_EOL);
p->set_mus_property ("symbol", sym);
p->set_mus_property ("iterator-ctor",
- Property_iterator::constructor_cxx_function);
+ Property_iterator::constructor_proc);
p->set_mus_property ("value", value);
return p;
m->set_mus_property ("grob-property", $3);
m->set_mus_property ("grob-value", $5);
m->set_mus_property ("iterator-ctor",
- Output_property_music_iterator::constructor_cxx_function);
+ Output_property_music_iterator::constructor_proc);
$$ = m;
}
| AUTOCHANGE STRING Music {
Music * chm = new Music_wrapper (SCM_EOL);
chm->set_mus_property ("element", $3->self_scm ());
- chm->set_mus_property ("iterator-ctor", Auto_change_iterator::constructor_cxx_function);
+ chm->set_mus_property ("iterator-ctor", Auto_change_iterator::constructor_proc);
scm_gc_unprotect_object ($3->self_scm ());
chm->set_mus_property ("what", $2);
TRANSLATOR STRING '=' STRING {
Music * t = new Music (SCM_EOL);
t->set_mus_property ("iterator-ctor",
- Change_iterator::constructor_cxx_function);
+ Change_iterator::constructor_proc);
t-> set_mus_property ("change-to-type", $2);
t-> set_mus_property ("change-to-id", $4);
Music *t = new Music (SCM_EOL);
t->set_mus_property ("iterator-ctor",
- Property_unset_iterator::constructor_cxx_function);
+ Property_unset_iterator::constructor_proc);
t->set_mus_property ("symbol", scm_string_to_symbol ($4));
Context_specced_music *csm = new Context_specced_music (SCM_EOL);
bool itc = internal_type_checking_global_b;
Music *t = new Music (SCM_EOL);
t->set_mus_property ("iterator-ctor",
- Push_property_iterator::constructor_cxx_function);
+ Push_property_iterator::constructor_proc);
t->set_mus_property ("symbol", scm_string_to_symbol ($4));
t->set_mus_property ("pop-first", SCM_BOOL_T);
if (autobeam)
Music *t = new Music (SCM_EOL);
t->set_mus_property ("iterator-ctor",
- Push_property_iterator::constructor_cxx_function);
+ Push_property_iterator::constructor_proc);
t->set_mus_property ("symbol", scm_string_to_symbol ($4));
if (autobeam)
bool itc = internal_type_checking_global_b;
t->set_mus_property ("iterator-ctor",
- Pop_property_iterator::constructor_cxx_function);
+ Pop_property_iterator::constructor_proc);
t->set_mus_property ("symbol", scm_string_to_symbol ($4));
if (autobeam)
internal_type_checking_global_b = false;
second_until_ = 0;
}
-Part_combine_music_iterator::~Part_combine_music_iterator ()
+void
+Part_combine_music_iterator::derived_mark () const
{
- delete second_iter_;
- delete first_iter_;
+ if (first_iter_)
+ scm_gc_mark (first_iter_->self_scm());
+ if (second_iter_)
+ scm_gc_mark(second_iter_->self_scm());
}
Part_combine_music_iterator::Part_combine_music_iterator (Part_combine_music_iterator const &src)
second_until_ = src.second_until_;
state_ = src.state_;
suffix_ = src.suffix_;
+
+ if (first_iter_)
+ scm_gc_unprotect_object (first_iter_->self_scm());
+ if (second_iter_)
+ scm_gc_unprotect_object (second_iter_->self_scm());
}
Moment
{
Part_combine_music const * m = dynamic_cast<Part_combine_music const*> (get_music ());
- first_iter_ = get_iterator (m->get_first ());
- second_iter_ = get_iterator (m->get_second ());
+ first_iter_ = unsmob_iterator (get_iterator (m->get_first ()));
+ second_iter_ = unsmob_iterator (get_iterator (m->get_second ()));
}
void
second_iter->skip (pending);
now = pending;
}
- delete first_iter;
- delete second_iter;
+ scm_gc_unprotect_object ( first_iter->self_scm());
+ scm_gc_unprotect_object( second_iter->self_scm());
}
return state;
}
: Music (l)
{
set_mus_property ("iterator-ctor",
- Part_combine_music_iterator::constructor_cxx_function);
+ Part_combine_music_iterator::constructor_proc);
}
void
Repeated_music * rp = dynamic_cast<Repeated_music*> (m);
if (rp
&& rp->get_mus_property ("iterator-ctor")
- == Percent_repeat_iterator::constructor_cxx_function
+ == Percent_repeat_iterator::constructor_proc
&& !repeat_)
{
body_length_ = rp->body_length_mom ();
{
child_iter_ = p.child_iter_ ? p.child_iter_->clone (): 0;
finish_mom_ = p.finish_mom_ ;
+
+ if(child_iter_)
+ scm_gc_unprotect_object (child_iter_->self_scm());
}
bool
{
Repeated_music * mus =dynamic_cast<Repeated_music *> (get_music ());
finish_mom_ = mus->length_mom ();
- child_iter_ = get_iterator (mus->body ());
+ child_iter_ = unsmob_iterator (get_iterator (mus->body ()));
}
if (finish_mom_ <= m )
{
- delete child_iter_;
child_iter_ = 0;
}
}
return child_iter_->try_music (m);
}
-
-Percent_repeat_iterator::~Percent_repeat_iterator ()
+void
+Percent_repeat_iterator::derived_mark()const
{
- delete child_iter_;
+ if (child_iter_)
+ scm_gc_mark (child_iter_->self_scm());
}
: Simultaneous_music (s)
{
set_mus_property ("iterator-ctor",
- Request_chord_iterator::constructor_cxx_function);
+ Request_chord_iterator::constructor_proc);
}
Request_chord::Request_chord ()
{
set_mus_property ("iterator-ctor",
- Request_chord_iterator::constructor_cxx_function);
+ Request_chord_iterator::constructor_proc);
}
Pitch
Music * music = unsmob_music (music_);
trans->final_mom_ = music->length_mom ();
-
- Music_iterator * iter = Music_iterator::get_static_get_iterator (music);
+ SCM protected_iter = Music_iterator::get_static_get_iterator (music);
+ Music_iterator * iter = unsmob_iterator (protected_iter);
iter->init_translator (music, trans);
iter->construct_children ();
if (! iter->ok ())
{
- delete iter;
warning (_ ("Need music in a score"));
errorlevel_ =1;
return ;
trans->start ();
trans->run_iterator_on_me (iter);
- delete iter;
+ scm_remember_upto_here_1 (protected_iter);
trans->finish ();
if (errorlevel_)
*/
-/*
-
- TODO: the grace note handling hasn't been done for skip() and
- get_pending_events(), meaning that staff-switching and partcombining will be
- broken with grace notes.
-
- */
-/*
-
- TODO: the grace note handling hasn't been done for skip() and
- get_pending_events(), meaning that staff-switching and partcombining will be
- broken with grace notes.
-
- */
/*
Invariant for the data structure.
iter_ = src.iter_->clone ();
else
iter_ = 0;
+
+ if (iter_)
+ scm_gc_unprotect_object (iter_->self_scm());
}
-Sequential_iterator::~Sequential_iterator ()
+void
+Sequential_iterator::derived_mark ()const
{
- delete iter_;
+ if (iter_)
+ scm_gc_mark (iter_->self_scm());
}
list_ = get_music_list ();
cursor_ = list_;
- iter_ = gh_pair_p (cursor_) ? get_iterator (unsmob_music (ly_car (cursor_))) : 0;
+ iter_ = 0;
+ if (gh_pair_p (cursor_))
+ {
+ Music *m =unsmob_music (ly_car (cursor_));
+ iter_ = unsmob_iterator ( get_iterator (m));
+ }
+
while (iter_ && !iter_->ok ())
{
next_element (true);
here_mom_ += len;
}
- delete iter_;
cursor_ = ly_cdr (cursor_);
if (gh_pair_p (cursor_))
- iter_ = get_iterator (unsmob_music (ly_car (cursor_)));
+ iter_ = unsmob_iterator (get_iterator (unsmob_music (ly_car (cursor_))));
else
iter_ = 0;
}
Skip events till UNTIL. We don't do any other side effects such as
descending to child iterator contexts, because they might depend on
\context specs and \translator changes being executed
-
- TODO: check support for grace notes here.
*/
void
Sequential_iterator::skip (Moment until)
: Music_sequence (head)
{
set_mus_property ("iterator-ctor",
- Sequential_music_iterator::constructor_cxx_function);
+ Sequential_music_iterator::constructor_proc);
}
Sequential_music::Sequential_music ()
: Music_sequence ()
{
set_mus_property ("iterator-ctor",
- Sequential_music_iterator::constructor_cxx_function);
+ Sequential_music_iterator::constructor_proc);
}
: Music_iterator (src)
{
separate_contexts_b_ = src.separate_contexts_b_;
- for (Cons<Music_iterator> *p = src.children_p_list_.head_; p; p = p->next_)
+
+ SCM children_list = SCM_EOL;
+ SCM *tail = &children_list_;
+ for (SCM s = src.children_list_; gh_pair_p (s); s = gh_cdr(s))
{
- Music_iterator *i = p->car_;
- children_p_list_.append (new Killing_cons<Music_iterator> (i->clone (), 0));
+ Music_iterator *i = unsmob_iterator (gh_car (s));
+ SCM cl = i->clone ()->self_scm();
+ *tail = scm_cons (cl, *tail);
+ tail = SCM_CDRLOC (*tail);
+ scm_gc_unprotect_object (cl);
}
+
+ children_list_ = children_list;
+ scm_remember_upto_here_1 (children_list);
}
-Simultaneous_music_iterator::~Simultaneous_music_iterator ()
+void
+Simultaneous_music_iterator::derived_mark()const
{
- children_p_list_.junk ();
+ scm_gc_mark (children_list_);
}
SCM
Simultaneous_music_iterator::get_pending_events (Moment m)const
{
SCM s = SCM_EOL;
- for (Cons<Music_iterator> *p = children_p_list_.head_; p; p = p->next_)
+ for (SCM s = children_list_; gh_pair_p (s); s = gh_cdr(s))
{
- s = gh_append2 (p->car_->get_pending_events (m), s);
+ s = gh_append2 (unsmob_iterator (gh_car (s))->get_pending_events (m), s);
}
return s;
}
int j = 0;
SCM i = get_music ()->get_mus_property ("elements");
+
+ children_list_ = SCM_EOL;
+ SCM * tail = &children_list_;
for (; gh_pair_p (i); i = ly_cdr (i), j++)
{
Music *mus = unsmob_music (ly_car (i));
- Music_iterator * mi = get_static_get_iterator (mus);
+
+ SCM scm_iter = get_static_get_iterator (mus);
+ Music_iterator * mi = unsmob_iterator (scm_iter);
/* if separate_contexts_b_ is set, create a new context with the
number number as name */
mi->init_translator (mus, t);
mi->construct_children ();
-
+
if (mi->ok ())
{
- children_p_list_.append (new Killing_cons<Music_iterator> (mi,0));
+ *tail = scm_cons (scm_iter, *tail);
+ tail = SCM_CDRLOC (*tail);
}
- else
- delete mi;
}
}
void
Simultaneous_music_iterator::process (Moment until)
{
- for (Cons<Music_iterator> **pp = &children_p_list_.head_; *pp;)
+ SCM *proc = &children_list_;
+ while(gh_pair_p (*proc))
{
- Music_iterator * i = (*pp)->car_;
+ Music_iterator * i = unsmob_iterator (gh_car (*proc));
if (i->pending_moment () == until)
{
i->process (until);
}
if (!i->ok ())
- delete children_p_list_.remove_cons (pp);
+ {
+ *proc = gh_cdr (*proc);
+ }
else
- pp = & (*pp)->next_;
+ {
+ proc = SCM_CDRLOC(*proc);
+ }
}
}
void
Simultaneous_music_iterator::skip (Moment until)
{
- for (Cons<Music_iterator> **pp = &children_p_list_.head_; *pp;)
+ SCM *proc = &children_list_;
+ while(gh_pair_p (*proc))
{
- Music_iterator * i = (*pp)->car_;
+ Music_iterator * i = unsmob_iterator (gh_car (*proc));
if (i->pending_moment () <= until)
{
i->skip (until);
}
if (!i->ok ())
- delete children_p_list_.remove_cons (pp);
+ {
+ *proc = gh_cdr (*proc);
+ }
else
- pp = & (*pp)->next_;
+ {
+ proc = SCM_CDRLOC(*proc);
+ }
}
}
Moment next;
next.set_infinite (1);
- for (Cons<Music_iterator> *p = children_p_list_.head_; p; p = p->next_)
- next = next <? p->car_->pending_moment () ;
+ for (SCM s = children_list_; gh_pair_p (s); s = gh_cdr(s))
+ next = next <? unsmob_iterator (gh_car (s))->pending_moment () ;
return next;
}
bool
Simultaneous_music_iterator::ok () const
{
- return children_p_list_.head_;
+ return gh_pair_p (children_list_);
}
Music_iterator*
Simultaneous_music_iterator::try_music_in_children (Music *m) const
{
Music_iterator * b=0;
- for (Cons<Music_iterator> *p = children_p_list_.head_; !b && p; p = p->next_)
- b =p->car_->try_music (m);
+ for (SCM s = children_list_; !b && gh_pair_p (s); s = gh_cdr(s))
+ b =unsmob_iterator (gh_car (s))->try_music (m);
return b;
}
: Music_sequence (head)
{
set_mus_property ("iterator-ctor",
- Simultaneous_music_iterator::constructor_cxx_function);
+ Simultaneous_music_iterator::constructor_proc);
}
Simultaneous_music::Simultaneous_music ()
: Music_sequence ()
{
set_mus_property ("iterator-ctor",
- Simultaneous_music_iterator::constructor_cxx_function);
+ Simultaneous_music_iterator::constructor_proc);
}
}
SCM
-Spanner::do_derived_mark ()
+Spanner::do_derived_mark () const
{
/*
We'd be fucked if this is called before spanned_drul_[] is inited. */
bool
Syllable_group::set_lyric_align (const char *punc, Grob *default_notehead)
{
- if (lyrics_.size ()<=1)
+ if (lyrics_.size () <= 0)
{
- // No lyrics or single line: nothing to do.
+ // No lyrics: nothing to do.
return true;
}
-
+
Grob * lyric;
alignment_ = appropriate_alignment (punc);
Music_wrapper_iterator::process (m);
}
-
+
IMPLEMENT_CTOR_CALLBACK (Time_scaled_music_iterator);
: Music_wrapper (l)
{
set_mus_property ("iterator-ctor",
- Time_scaled_music_iterator::constructor_cxx_function);
+ Time_scaled_music_iterator::constructor_proc);
}
class Unfolded_repeat_iterator : public Sequential_iterator
{
public:
- static SCM constructor_cxx_function;
+ DECLARE_SCHEME_CALLBACK(constructor, ());
VIRTUAL_COPY_CONS (Music_iterator);
protected:
virtual SCM get_music_list () const;
class Volta_repeat_iterator : public Sequential_iterator
{
public:
- static SCM constructor_cxx_function;
+ DECLARE_SCHEME_CALLBACK(constructor, ());
VIRTUAL_COPY_CONS (Music_iterator);
Volta_repeat_iterator();
}
void
-Virtual_font_metric::derived_mark()
+Virtual_font_metric::derived_mark()const
{
scm_gc_mark (font_list_);
-
}
int
-(music-property-description 'iterator-ctor c++-function? "Function to construct music-event-iterator object for this Music")
+(music-property-description 'iterator-ctor procedure? "Function to construct music-event-iterator object for this Music")
(music-property-description 'duration duration? "Duration of this note/lyric.")
(music-property-description 'metronome-count number? "How many beats in a minute?")
(music-property-description 'span-type string? "What kind of spanner should be created?