+Context *
+Context::create_context (Context_def *cdef,
+ String id,
+ SCM ops)
+{
+ String type = ly_symbol2string (cdef->get_context_name ());
+ Object_key const *key = get_context_key (type, id);
+ Context *new_context
+ = cdef->instantiate (ops, key);
+
+ new_context->id_string_ = id;
+ add_context (new_context);
+ apply_property_operations (new_context, ops);
+
+ return new_context;
+}
+
+Object_key const *
+Context::get_context_key (String type, String id)
+{
+ if (!use_object_keys)
+ return 0;
+
+ String now_key = type + "@" + id;
+
+ int disambiguation_count = 0;
+ if (context_counts_.find (now_key) != context_counts_.end ())
+ disambiguation_count = context_counts_[now_key];
+
+ context_counts_[now_key] = disambiguation_count + 1;
+
+ return new Lilypond_context_key (get_key (),
+ now_mom (),
+ type, id,
+ disambiguation_count);
+}
+
+Object_key const *
+Context::get_grob_key (String name)
+{
+ if (!use_object_keys)
+ return 0;
+
+ int disambiguation_count = 0;
+ if (grob_counts_.find (name) != grob_counts_.end ())
+ disambiguation_count = grob_counts_[name];
+ grob_counts_[name] = disambiguation_count + 1;
+
+ Object_key *k = new Lilypond_grob_key (get_key (),
+ now_mom (),
+ name,
+ disambiguation_count);
+
+ return k;
+}
+