+ // The 'accepts elements in definition_mods_ is a list of ('accepts string),
+ // but the Context_def expects to see elements of the form ('accepts symbol).
+ SCM accepts = SCM_EOL;
+ for (SCM s = scm_reverse (definition_mods_); scm_is_pair (s); s = scm_cdr (s))
+ if (scm_caar (s) == ly_symbol2scm ("accepts"))
+ {
+ SCM elt = scm_list_2 (scm_caar (s), scm_string_to_symbol (scm_cadar (s)));
+ accepts = scm_cons (elt, accepts);
+ }
+
+ return unsmob_context_def (definition_)->path_to_acceptable_context (name,
+ get_output_def (),
+ accepts);
+
+}
+
+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 */
+ event_source_->
+ 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"), ly_string2scm (id));
+ event_source_->
+ 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);
+
+ if (!infant || infant->get_parent_context () != this)