#include "scm-hash.hh"
#include "translator-group.hh"
#include "warn.hh"
+#include "lily-imports.hh"
bool
Context::is_removable () const
scm_cons (child->self_scm (), SCM_EOL));
child->daddy_context_ = this;
- this->events_below_->register_as_listener (child->events_below_);
+ events_below_->register_as_listener (child->events_below_);
}
Context::Context ()
ly_symbol2scm ("UnsetProperty"));
new_context->events_below_->register_as_listener (new_context->event_source_);
- this->add_context (new_context);
+ add_context (new_context);
new_context->unprotect ();
if (!t)
{
warning (_f ("cannot find or create: `%s'", name.c_str ()));
- t = unsmob<Context_def> (this->definition_);
+ t = unsmob<Context_def> (definition_);
}
if (scm_is_symbol (t->get_default_child (SCM_EOL)))
{
void
Context::internal_send_stream_event (SCM type, Input *origin, SCM props[])
{
- Stream_event *e = new Stream_event
- (scm_call_1 (ly_lily_module_constant ("ly:make-event-class"), type),
- origin);
+ Stream_event *e = new Stream_event (Lily::ly_make_event_class (type), origin);
for (int i = 0; props[i]; i += 2)
{
e->set_property (props[i], props[i + 1]);
void
Context::disconnect_from_parent ()
{
- daddy_context_->events_below_->unregister_as_listener (this->events_below_);
- daddy_context_->context_list_ = scm_delq_x (this->self_scm (), daddy_context_->context_list_);
+ daddy_context_->events_below_->unregister_as_listener (events_below_);
+ daddy_context_->context_list_ = scm_delq_x (self_scm (), daddy_context_->context_list_);
daddy_context_ = 0;
}
-/*
- ID == "" means accept any ID.
-*/
+Context *
+find_context_above (Context *where, SCM type)
+{
+ while (where && !where->is_alias (type))
+ where = where->get_parent_context ();
+
+ return where;
+}
+
+Context *
+find_context_above_by_parent_type (Context *where, SCM parent_type)
+{
+ for (Context *child = 0; where;
+ child = where, where = where->get_parent_context ())
+ if (where->is_alias (parent_type))
+ return child;
+
+ return 0;
+}
+
Context *
find_context_below (Context *where,
SCM type, const string &id)
return found;
}
+Context *
+find_context_near (Context *where,
+ SCM type, const string &id)
+{
+ for ( ; where; where = where->get_parent_context ())
+ {
+ Context *found = find_context_below (where, type, id);
+ if (found)
+ return found;
+ }
+
+ return 0;
+}
+
+Context *
+find_top_context (Context *where)
+{
+ Context *top = where;
+ for ( ; where; where = where->get_parent_context())
+ top = where;
+ return top;
+}
+
SCM
Context::properties_as_alist () const
{
}
int
-Context::print_smob (SCM port, scm_print_state *)
+Context::print_smob (SCM port, scm_print_state *) const
{
scm_puts ("#<", port);
scm_puts (class_name (), port);
}
SCM
-Context::mark_smob ()
+Context::mark_smob () const
{
scm_gc_mark (context_list_);
scm_gc_mark (aliases_);