? .sconf_temp ? build-stamp ? context-unique.diff ? def-rel-music-funciton.diff ? delay-music-functions.diff ? exjobb.diff3 ? fonts ? lib ? lilypond.kdevelop ? lilypond.kdevelop.pcs ? lilypond.kdevses ? optimized ? os ? ref1.diff ? ref2.diff ? repeat.diff ? scons.cache ? Documentation/out ? Documentation/out-www ? Documentation/bibliography/out ? Documentation/bibliography/out-www ? Documentation/misc/out ? Documentation/misc/out-www ? Documentation/pictures/out ? Documentation/pictures/out-www ? Documentation/topdocs/out ? Documentation/topdocs/out-www ? Documentation/user/out ? Documentation/user/out-www ? buildscripts/out ? buildscripts/out-www ? cygwin/out ? cygwin/out-www ? debian/out ? elisp/out ? elisp/out-www ? flower/out ? flower/out-scons ? flower/out-www ? flower/include/.sconsign ? flower/include/out ? flower/include/out-www ? input/Diagram1.dia.autosave ? input/les-nereides.pdf ? input/les-nereides.ps ? input/out ? input/out-www ? input/mutopia/out ? input/mutopia/out-www ? input/mutopia/E.Satie/out ? input/mutopia/E.Satie/out-www ? input/mutopia/F.Schubert/morgenlied.midi ? input/mutopia/F.Schubert/morgenlied.pdf ? input/mutopia/F.Schubert/morgenlied.ps ? input/mutopia/F.Schubert/out ? input/mutopia/F.Schubert/out-www ? input/mutopia/J.S.Bach/out ? input/mutopia/J.S.Bach/out-www ? input/mutopia/R.Schumann/out ? input/mutopia/R.Schumann/out-www ? input/mutopia/W.A.Mozart/out ? input/mutopia/W.A.Mozart/out-www ? input/no-notation/out ? input/no-notation/out-www ? input/no-notation/to-xml.pdf ? input/no-notation/to-xml.ps ? input/regression/chord-tremolo.pdf ? input/regression/chord-tremolo.ps ? input/regression/out ? input/regression/out-www ? input/template/out ? input/test/new ? input/test/out ? input/test/out-www ? input/tutorial/out ? input/tutorial/out-www ? kpath-guile/out ? kpath-guile/out-scons ? lily/On ? lily/busy-playing-listener.cc ? lily/foo.pdf ? lily/foo.ps ? lily/lilypond ? lily/lilypond.gdt ? lily/lilypond.gpr ? lily/out ? lily/out-scons ? lily/out-www ? lily/include/.sconsign ? lily/include/busy-playing-listener.hh ? lily/include/out ? lily/include/out-www ? ly/out ? ly/out-www ? make/out ? make/out-www ? mf/feta-alphabet11.600pk ? mf/feta-alphabet13.600pk ? mf/feta-alphabet14.600pk ? mf/feta-alphabet16.600pk ? mf/feta-alphabet18.600pk ? mf/feta-alphabet20.600pk ? mf/feta-alphabet23.600pk ? mf/feta-alphabet26.600pk ? mf/feta-braces-a.600pk ? mf/feta-braces-b.600pk ? mf/feta-braces-c.600pk ? mf/feta-braces-d.600pk ? mf/feta-braces-e.600pk ? mf/feta-braces-f.600pk ? mf/feta-braces-g.600pk ? mf/feta-braces-h.600pk ? mf/feta-braces-i.600pk ? mf/feta11.600pk ? mf/feta13.600pk ? mf/feta14.600pk ? mf/feta16.600pk ? mf/feta18.600pk ? mf/feta20.600pk ? mf/feta23.600pk ? mf/feta26.600pk ? mf/out ? mf/out-scons ? mf/out-www ? mf/parmesan11.600pk ? mf/parmesan13.600pk ? mf/parmesan14.600pk ? mf/parmesan16.600pk ? mf/parmesan18.600pk ? mf/parmesan20.600pk ? mf/parmesan23.600pk ? mf/parmesan26.600pk ? po/out ? po/out-www ? ps/out ? ps/out-www ? python/convertrules.pyc ? python/fontextract.pyc ? python/lilylib.pyc ? python/out ? python/out-www ? scm/out ? scm/out-www ? scripts/lilypond-book-36.py ? scripts/lilypond-book.py.new ? scripts/out ? scripts/out-www ? scripts/stat ? stepmake/out ? stepmake/out-www ? stepmake/bin/out ? stepmake/bin/out-www ? stepmake/bin/packagepython.pyc ? stepmake/stepmake/out ? stepmake/stepmake/out-www ? tex/out ? tex/out-www ? ttftool/out ? ttftool/out-scons ? ttftool/include/.sconsign ? ttftool/include/out ? vim/out ? vim/out-www Index: THANKS =================================================================== RCS file: /sources/lilypond/lilypond/THANKS,v retrieving revision 1.229 diff -u -r1.229 THANKS --- THANKS 26 May 2006 14:52:47 -0000 1.229 +++ THANKS 29 May 2006 06:52:59 -0000 @@ -49,6 +49,7 @@ David Rogers J. Leung Harald Wellmann +Karim Haddad Karl Hammar Keith Packard Orm Finnendahl Index: lily/context.cc =================================================================== RCS file: /sources/lilypond/lilypond/lily/context.cc,v retrieving revision 1.83 diff -u -r1.83 context.cc --- lily/context.cc 24 May 2006 07:00:41 -0000 1.83 +++ lily/context.cc 29 May 2006 06:52:59 -0000 @@ -59,29 +59,13 @@ } void -Context::add_context (Context *t) +Context::add_context (Context *child) { - SCM ts = t->self_scm (); context_list_ = ly_append2 (context_list_, - scm_cons (ts, SCM_EOL)); + scm_cons (child->self_scm (), SCM_EOL)); - t->daddy_context_ = this; - if (!t->init_) - { - t->init_ = true; - - t->unprotect (); - Context_def *td = unsmob_context_def (t->definition_); - - /* This cannot move before add_context (), because \override - operations require that we are in the hierarchy. */ - td->apply_default_property_operations (t); - - recurse_over_translators (t, - &Translator::initialize, - &Translator_group::initialize, - DOWN); - } + child->daddy_context_ = this; + this->events_below_->register_as_listener (child->events_below_); } @@ -89,7 +73,6 @@ : key_manager_ (key) { daddy_context_ = 0; - init_ = false; aliases_ = SCM_EOL; iterator_count_ = 0; implementation_ = 0; @@ -98,7 +81,6 @@ context_list_ = SCM_EOL; definition_ = SCM_EOL; definition_mods_ = SCM_EOL; - unique_ = -1; event_source_ = 0; events_below_ = 0; @@ -235,36 +217,106 @@ return ret; } -Context * -Context::create_context (Context_def *cdef, - string id, - SCM ops) +IMPLEMENT_LISTENER (Context, acknowledge_infant); +void +Context::acknowledge_infant (SCM sev) { - int unique = get_global_context()->new_unique(); + infant_event_ = unsmob_stream_event (sev); +} - // TODO: The following should be carried out by a listener. - string type = ly_symbol2string (cdef->get_context_name ()); +/* + Creates a new context from a CreateContext event, and sends an + AnnounceNewContext event to this context. +*/ +IMPLEMENT_LISTENER (Context, create_context_from_event); +void +Context::create_context_from_event (SCM sev) +{ + Stream_event *ev = unsmob_stream_event (sev); + + string id = ly_scm2string (ev->get_property ("id")); + SCM ops = ev->get_property ("ops"); + SCM type_scm = ev->get_property ("type"); + string type = ly_symbol2string (type_scm); Object_key const *key = key_manager_.get_context_key (now_mom(), type, id); - Context *new_context - = cdef->instantiate (ops, key); + + vector path + = unsmob_context_def (definition_)->path_to_acceptable_context (type_scm, get_output_def ()); + if (path.size () != 1) + { + programming_error (_f ("Invalid CreateContext event: Cannot create %s context", type.c_str ())); + return; + } + Context_def *cdef = path[0]; + + Context *new_context = cdef->instantiate (ops, key); new_context->id_string_ = id; - new_context->unique_ = unique; + /* Register various listeners: + - Make the new context hear events that universally affect contexts + - connect events_below etc. properly */ + /* We want to be the first ones to hear our own events. Therefore, wait + before registering events_below_ */ + new_context->event_source ()-> + add_listener (GET_LISTENER (new_context->create_context_from_event), + ly_symbol2scm ("CreateContext")); + /* Add more here (properties, ChangeContext, etc) */ + new_context->events_below_->register_as_listener (new_context->event_source_); - - add_context (new_context); + this->add_context (new_context); + + new_context->unprotect (); + + Context_def *td = unsmob_context_def (new_context->definition_); + + /* This cannot move before add_context (), because \override + operations require that we are in the hierarchy. */ + td->apply_default_property_operations (new_context); apply_property_operations (new_context, ops); - events_below_->register_as_listener (new_context->events_below_); + recurse_over_translators (new_context, + &Translator::initialize, + &Translator_group::initialize, + DOWN); + + send_stream_event (new_context, "AnnounceNewContext", 0, + ly_symbol2scm ("context"), new_context->self_scm (), + ly_symbol2scm ("creator"), sev); +} - // TODO: The above operations should be performed by a listener to the following event. - send_stream_event (this, "CreateContext", - ly_symbol2scm ("unique"), scm_int2num (unique), +Context * +Context::create_context (Context_def *cdef, + string id, + SCM ops) +{ + infant_event_ = 0; + /* TODO: This is fairly misplaced. We can fix this when we have taken out all + iterator specific stuff from the Context class */ + events_below_-> + add_listener (GET_LISTENER (acknowledge_infant), + ly_symbol2scm ("AnnounceNewContext")); + /* The CreateContext creates a new context, and sends an announcement of the + new context through another event. That event will be stored in + infant_event_ to create a return value. */ + send_stream_event (this, "CreateContext", 0, ly_symbol2scm ("ops"), ops, ly_symbol2scm ("type"), cdef->get_context_name (), ly_symbol2scm ("id"), scm_makfrom0str (id.c_str ())); + events_below_-> + remove_listener (GET_LISTENER (acknowledge_infant), + ly_symbol2scm ("AnnounceNewContext")); + + assert (infant_event_); + SCM infant_scm = infant_event_->get_property ("context"); + Context *infant = unsmob_context (infant_scm); - return new_context; + if (!infant || infant->get_parent_context () != this) + { + programming_error ("create_context: can't locate newly created context"); + return 0; + } + + return infant; } /* @@ -351,9 +403,9 @@ be called from any other place than the send_stream_event macro. */ void -Context::internal_send_stream_event (SCM type, SCM props[]) +Context::internal_send_stream_event (SCM type, Input *origin, SCM props[]) { - Stream_event *e = new Stream_event (this, type); + Stream_event *e = new Stream_event (type, origin); for (int i = 0; props[i]; i += 2) { e->internal_set_property (props[i], props[i+1]); @@ -404,13 +456,14 @@ Remove a context from the hierarchy. */ Context * -Context::remove_context (Context *trans) +Context::remove_context (Context *child) { - assert (trans); + assert (child); - context_list_ = scm_delq_x (trans->self_scm (), context_list_); - trans->daddy_context_ = 0; - return trans; + context_list_ = scm_delq_x (child->self_scm (), context_list_); + child->daddy_context_ = 0; + this->events_below_->unregister_as_listener (child->events_below_); + return child; } @@ -439,25 +492,6 @@ return found; } -Context * -find_context_below (Context *where, - int unique) -{ - if (where->get_unique () == unique) - return where; - - Context *found = 0; - for (SCM s = where->children_contexts (); - !found && scm_is_pair (s); s = scm_cdr (s)) - { - Context *tr = unsmob_context (scm_car (s)); - - found = find_context_below (tr, unique); - } - - return found; -} - SCM Context::properties_as_alist () const { Index: lily/dispatcher.cc =================================================================== RCS file: /sources/lilypond/lilypond/lily/dispatcher.cc,v retrieving revision 1.2 diff -u -r1.2 dispatcher.cc --- lily/dispatcher.cc 16 May 2006 11:30:54 -0000 1.2 +++ lily/dispatcher.cc 29 May 2006 06:52:59 -0000 @@ -7,6 +7,7 @@ */ #include "dispatcher.hh" +#include "input.hh" #include "international.hh" #include "ly-smobs.icc" #include "stream-event.hh" @@ -72,11 +73,16 @@ SCM class_symbol = ev->get_property ("class"); if (!scm_symbol_p (class_symbol)) { - warning (_f ("Unknown event class %s", ly_symbol2string (class_symbol).c_str ())); + warning (_f ("Event class should be a symbol")); return; } SCM class_list = scm_call_1 (ly_lily_module_constant ("ly:make-event-class"), class_symbol); + if (!scm_is_pair (class_list)) + { + ev->origin ()->warning (_f ("Unknown event class %s", ly_symbol2string (class_symbol).c_str ())); + return; + } bool sent = false; int num_classes = scm_ilength (class_list); @@ -171,9 +177,10 @@ Dispatcher::internal_add_listener (Listener l, SCM ev_class, int priority) { SCM list = scm_hashq_ref (listeners_, ev_class, SCM_EOL); - if (list == SCM_EOL) + if (!scm_is_pair (list)) { - /* Register with all dispatchers. */ + /* Tell all dispatchers that we listen to, that we want to hear ev_class + events */ for (SCM disp = dispatchers_; scm_is_pair(disp); disp = scm_cdr (disp)) { int priority = scm_to_int (scm_cdar (disp)); @@ -183,7 +190,7 @@ listen_classes_ = scm_cons (ev_class, listen_classes_); } SCM entry = scm_cons (scm_int2num (priority), l.smobbed_copy ()); - list = scm_merge_x (list, scm_list_1 (entry), ly_lily_module_constant ("car<")); + list = scm_merge (list, scm_list_1 (entry), ly_lily_module_constant ("car<")); scm_hashq_set_x (listeners_, ev_class, list); } @@ -213,10 +220,11 @@ else e = scm_cdr (e); list = scm_cdr (dummy); + scm_hashq_set_x (listeners_, ev_class, list); if (first) warning ("Attempting to remove nonexisting listener."); - else if (list == SCM_EOL) + else if (!scm_is_pair (list)) { /* Unregister with all dispatchers. */ for (SCM disp = dispatchers_; disp != SCM_EOL; disp = scm_cdr (disp)) @@ -256,9 +264,9 @@ { dispatchers_ = scm_assq_remove_x (dispatchers_, disp->self_scm ()); - Listener list = GET_LISTENER (dispatch); - for (SCM cl = listen_classes_; cl != SCM_EOL; cl = scm_cdr (cl)) + Listener listener = GET_LISTENER (dispatch); + for (SCM cl = listen_classes_; scm_is_pair (cl); cl = scm_cdr (cl)) { - disp->remove_listener (list, scm_car (cl)); + disp->remove_listener (listener, scm_car (cl)); } } Index: lily/global-context.cc =================================================================== RCS file: /sources/lilypond/lilypond/lily/global-context.cc,v retrieving revision 1.41 diff -u -r1.41 global-context.cc --- lily/global-context.cc 5 May 2006 15:59:21 -0000 1.41 +++ lily/global-context.cc 29 May 2006 06:52:59 -0000 @@ -12,6 +12,7 @@ using namespace std; #include "context-def.hh" +#include "dispatcher.hh" #include "international.hh" #include "lilypond-key.hh" #include "music-iterator.hh" @@ -28,8 +29,11 @@ output_def_ = o; final_mom_ = final; definition_ = find_context_def (o, ly_symbol2scm ("Global")); - unique_count_ = 0; - unique_ = 0; + + /* We only need the most basic stuff to bootstrap the context tree */ + event_source ()->add_listener (GET_LISTENER (create_context_from_event), + ly_symbol2scm ("CreateContext")); + events_below ()->register_as_listener (event_source_); Context_def *globaldef = unsmob_context_def (definition_); if (!globaldef) @@ -206,9 +210,3 @@ else return Context::get_default_interpreter (); } - -int -Global_context::new_unique () -{ - return ++unique_count_; -} Index: lily/music.cc =================================================================== RCS file: /sources/lilypond/lilypond/lily/music.cc,v retrieving revision 1.151 diff -u -r1.151 music.cc --- lily/music.cc 16 May 2006 12:36:54 -0000 1.151 +++ lily/music.cc 29 May 2006 06:52:59 -0000 @@ -239,7 +239,7 @@ void Music::send_to_context (Context *c) { - send_stream_event (c, "MusicEvent", + send_stream_event (c, "MusicEvent", 0, ly_symbol2scm("music"), self_scm (), 0); } Index: lily/part-combine-iterator.cc =================================================================== RCS file: /sources/lilypond/lilypond/lily/part-combine-iterator.cc,v retrieving revision 1.31 diff -u -r1.31 part-combine-iterator.cc --- lily/part-combine-iterator.cc 24 May 2006 07:00:41 -0000 1.31 +++ lily/part-combine-iterator.cc 29 May 2006 06:52:59 -0000 @@ -424,6 +424,9 @@ Moment now = get_outlet ()->now_mom (); Moment *splitm = 0; + if (start_moment_.main_part_.is_infinity () && start_moment_ < 0) + start_moment_ = now; + for (; scm_is_pair (split_list_); split_list_ = scm_cdr (split_list_)) { splitm = unsmob_moment (scm_caar (split_list_)); Index: lily/stream-event.cc =================================================================== RCS file: /sources/lilypond/lilypond/lily/stream-event.cc,v retrieving revision 1.1 diff -u -r1.1 stream-event.cc --- lily/stream-event.cc 5 May 2006 15:59:21 -0000 1.1 +++ lily/stream-event.cc 29 May 2006 06:52:59 -0000 @@ -13,8 +13,6 @@ #include "input.hh" #include "input-smob.hh" -// ES todo: Add stuff to lily-proto.hh: Stream_event and its subclasses, Stream_creator, etc. - Stream_event::~Stream_event () { } @@ -24,7 +22,6 @@ { self_scm_ = SCM_EOL; property_alist_ = SCM_EOL; - origin_ = 0; smobify_self (); } @@ -34,39 +31,37 @@ init (); } -Stream_event::Stream_event (Context *c, Input *origin) -{ - init (); - set_property ("context", scm_int2num (c->get_unique())); - origin_ = origin; -} - Stream_event::Stream_event (SCM property_alist) { init (); property_alist_ = property_alist; - origin_ = &dummy_input_global; } -Stream_event::Stream_event (Context *c, SCM class_name) +/* Hm. Perhaps Stream_event should be a prob, with class_name and origin as immutable props? */ +Stream_event::Stream_event (SCM class_name, Input *origin) { init (); - set_property ("context", scm_int2num (c->get_unique())); set_property ("class", class_name); - origin_ = &dummy_input_global; + if (origin) + set_spot (origin); } Stream_event::Stream_event (Stream_event *ev) { init (); property_alist_ = scm_copy_tree (ev->property_alist_); - origin_ = ev->origin_; } Input * Stream_event::origin () const { - return origin_; + Input *i = unsmob_input (get_property ("origin")); + return i ? i : &dummy_input_global; +} + +void Stream_event::set_spot (Input *i) +{ + set_property ("origin", make_input (*i)); } SCM Index: lily/include/context.hh =================================================================== RCS file: /sources/lilypond/lilypond/lily/include/context.hh,v retrieving revision 1.40 diff -u -r1.40 context.hh --- lily/include/context.hh 16 May 2006 11:30:55 -0000 1.40 +++ lily/include/context.hh 29 May 2006 06:52:59 -0000 @@ -9,12 +9,12 @@ #ifndef CONTEXT_HH #define CONTEXT_HH - -#include "std-vector.hh" -#include "moment.hh" +#include "context-key-manager.hh" #include "lily-proto.hh" +#include "listener.hh" +#include "moment.hh" +#include "std-vector.hh" #include "virtual-methods.hh" -#include "context-key-manager.hh" class Context { @@ -28,10 +28,11 @@ private: friend class Context_handle; int iterator_count_; - bool init_; + + /* Used internally by create_context */ + Stream_event *infant_event_; protected: - int unique_; Context *daddy_context_; /* The used Context_def */ SCM definition_; @@ -61,15 +62,16 @@ Object_key const *get_grob_key (string name); Object_key const *get_context_key (string name, string id); + DECLARE_LISTENER (create_context_from_event); + DECLARE_LISTENER (acknowledge_infant); Context *create_context (Context_def *, string, SCM); string id_string () const { return id_string_; } SCM children_contexts () const { return context_list_; } SCM default_child_context_name () const; - int get_unique() { return unique_; } Dispatcher *event_source () const { return event_source_; } Dispatcher *events_below () const { return events_below_; } - void internal_send_stream_event (SCM type, SCM props[]); + void internal_send_stream_event (SCM type, Input *origin, SCM props[]); SCM get_definition () const { return definition_; } SCM get_definition_mods () const { return definition_mods_; } @@ -134,10 +136,10 @@ void set_context_property_on_children (Context *trans, SCM sym, SCM val); /* Shorthand for creating and broadcasting stream events. */ -#define send_stream_event(ctx, type, ...) \ +#define send_stream_event(ctx, type, origin, ...) \ { \ SCM props[] = { __VA_ARGS__, 0 }; \ - ctx->internal_send_stream_event (ly_symbol2scm (type), props); \ + ctx->internal_send_stream_event (ly_symbol2scm (type), origin, props); \ } #endif /* CONTEXT_HH */ Index: lily/include/global-context.hh =================================================================== RCS file: /sources/lilypond/lilypond/lily/include/global-context.hh,v retrieving revision 1.14 diff -u -r1.14 global-context.hh --- lily/include/global-context.hh 5 May 2006 15:59:21 -0000 1.14 +++ lily/include/global-context.hh 29 May 2006 06:52:59 -0000 @@ -16,7 +16,6 @@ { PQueue extra_mom_pq_; Output_def *output_def_; - int unique_count_; DECLARE_CLASSNAME(Global_context); @@ -40,7 +39,6 @@ virtual Moment now_mom () const; virtual Context *get_default_interpreter (); - int new_unique (); Moment previous_moment () const; protected: Moment final_mom_; Index: lily/include/stream-event.hh =================================================================== RCS file: /sources/lilypond/lilypond/lily/include/stream-event.hh,v retrieving revision 1.2 diff -u -r1.2 stream-event.hh --- lily/include/stream-event.hh 16 May 2006 11:30:55 -0000 1.2 +++ lily/include/stream-event.hh 29 May 2006 06:52:59 -0000 @@ -22,14 +22,14 @@ public: Stream_event (); Input *origin () const; + void set_spot (Input *i); DECLARE_SCHEME_CALLBACK (undump, (SCM)); DECLARE_SCHEME_CALLBACK (dump, (SCM)); - // todo: make Input mandatory. + // todo: remove unneeded constructors Stream_event (SCM property_alist); - Stream_event (Context *c, SCM class_name); - Stream_event (Context *c, Input *); + Stream_event (SCM class_name, Input *); Stream_event (Stream_event *ev); SCM internal_get_property (SCM) const; Index: scm/define-event-classes.scm =================================================================== RCS file: /sources/lilypond/lilypond/scm/define-event-classes.scm,v retrieving revision 1.2 diff -u -r1.2 define-event-classes.scm --- scm/define-event-classes.scm 16 May 2006 11:30:55 -0000 1.2 +++ scm/define-event-classes.scm 29 May 2006 06:52:59 -0000 @@ -12,6 +12,8 @@ '(((StreamEvent) . '()) ((RemoveContext ChangeParent Override Revert UnsetProperty SetProperty MusicEvent CreateContext Prepare OneTimeStep Finish) . StreamEvent) + ((Announcement) . '()) + ((AnnounceNewContext) . Announcement) )) ;; Maps event-class to a list of ancestors (inclusive)