#include "warn.hh"
#include "lily-imports.hh"
-using std::string;
-using std::vector;
-
bool
Context::is_removable () const
{
ctx->check_removal ();
if (ctx->is_removable ())
{
- recurse_over_translators (ctx, &Translator::finalize,
- &Translator_group::finalize,
- UP);
+ recurse_over_translators
+ (ctx,
+ Callback0_wrapper::make_smob
+ <Translator, &Translator::finalize> (),
+ Callback0_wrapper::make_smob
+ <Translator_group, &Translator_group::finalize> (),
+ UP);
send_stream_event (ctx, "RemoveContext", 0, 0);
}
}
smobify_self ();
- Scheme_hash_table *tab = new Scheme_hash_table;
- properties_scm_ = tab->unprotect ();
+ properties_scm_ = Scheme_hash_table::make_smob ();
event_source_ = new Dispatcher ();
event_source_->unprotect ();
events_below_ = new Dispatcher ();
ok = type_check_assignment (sym, val, ly_symbol2scm ("translation-type?"));
if (ok)
- set_property (sym, val);
+ {
+ if (to_boolean (ev->get_property ("once")))
+ {
+ if (Global_context *g = get_global_context ())
+ {
+ SCM old_val = SCM_UNDEFINED;
+ if (here_defined (sym, &old_val))
+ g->add_finalization (scm_list_4 (ly_context_set_property_x_proc,
+ self_scm (),
+ sym,
+ old_val));
+ else
+ g->add_finalization (scm_list_3 (ly_context_unset_property_proc,
+ self_scm (),
+ sym));
+ }
+ }
+ set_property (sym, val);
+ }
}
}
Stream_event *ev = unsmob<Stream_event> (sev);
SCM sym = ev->get_property ("symbol");
- type_check_assignment (sym, SCM_EOL, ly_symbol2scm ("translation-type?"));
- unset_property (sym);
+ bool ok = type_check_assignment (sym, SCM_EOL, ly_symbol2scm ("translation-type?"));
+
+ if (ok)
+ {
+ if (to_boolean (ev->get_property ("once")))
+ {
+ if (Global_context *g = get_global_context ())
+ {
+ SCM old_val = SCM_UNDEFINED;
+ if (here_defined (sym, &old_val))
+ g->add_finalization (scm_list_4 (ly_context_set_property_x_proc,
+ self_scm (),
+ sym,
+ old_val));
+ else
+ g->add_finalization (scm_list_3 (ly_context_unset_property_proc,
+ self_scm (),
+ sym));
+ }
+ }
+ unset_property (sym);
+ }
}
/*
return properties_scm_;
}
-const char Context::type_p_name_[] = "ly:context?";
+const char * const Context::type_p_name_ = "ly:context?";
Global_context *
Context::get_global_context () const