X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Flilypond-key.cc;h=e69de29bb2d1d6434b8b29ae775ad8c2e48c5391;hb=8bfcd362b5beed8b7fd6905a2732e282cd1d5477;hp=dbe82a7dd0e7a807d7a0d8882a829469ad53d5b4;hpb=474c8729dc274a30558102a015a01fa5882673db;p=lilypond.git diff --git a/lily/lilypond-key.cc b/lily/lilypond-key.cc index dbe82a7dd0..e69de29bb2 100644 --- a/lily/lilypond-key.cc +++ b/lily/lilypond-key.cc @@ -1,226 +0,0 @@ -/* - lilypond-key.cc -- implement Lilypond_{grob, context}_key - - source file of the GNU LilyPond music typesetter - - (c) 2004--2007 Han-Wen Nienhuys -*/ - -#include "lilypond-key.hh" - -Lilypond_grob_key::Lilypond_grob_key (Object_key const *context, - Moment start, - string name, - int disambiguation_count) -{ - context_ = context; - creation_moment_ = start; - grob_name_ = name; - disambiguation_count_ = disambiguation_count; -} - -void -Lilypond_grob_key::derived_mark () const -{ - if (context_) - scm_gc_mark (context_->self_scm ()); -} - -// todo: reverse order of comparison for efficiency reasons. -int -Lilypond_grob_key::do_compare (Object_key const *key) const -{ - Lilypond_grob_key const *other = dynamic_cast (key); - int c; - - c = context_->compare (other->context_); - if (c) - return c; - - c = Moment::compare (creation_moment_, other->creation_moment_); - if (c) - return c; - - c = grob_name_.compare (other->grob_name_); - if (c) - return c; - - c = sign (disambiguation_count_ - other->disambiguation_count_); - if (c) - return c; - - return 0; -} - -int -Lilypond_grob_key::get_type () const -{ - return GROB_KEY; -} - -SCM -Lilypond_grob_key::as_scheme () const -{ - return scm_list_4 (context_ ? context_->self_scm () : SCM_BOOL_F, - creation_moment_.smobbed_copy (), - ly_string2scm (grob_name_), - scm_from_int (disambiguation_count_)); -} - -Object_key * -Lilypond_grob_key::from_scheme (SCM a) -{ - return new Lilypond_grob_key (unsmob_key (scm_car (a)), - *unsmob_moment (scm_cadr (a)), - ly_scm2string (scm_caddr (a)), - scm_to_int (scm_list_ref (a, scm_from_int (3)))); -} - -/****************************************************************/ - -void -Lilypond_context_key::derived_mark () const -{ - if (parent_context_) - scm_gc_mark (parent_context_->self_scm ()); -} - -Lilypond_context_key::Lilypond_context_key (Object_key const *parent, - Moment start, - string type, - string id, - int count) -{ - disambiguation_count_ = count; - parent_context_ = parent; - start_moment_ = start; - context_name_ = type; - id_ = id; -} - -int -Lilypond_context_key::do_compare (Object_key const *key) const -{ - Lilypond_context_key const *other - = dynamic_cast (key); - - int c; - if (parent_context_ && other->parent_context_) - { - c = parent_context_->compare (other->parent_context_); - if (c) - return c; - } - else if (parent_context_) - return -1; - else if (other->parent_context_) - return 1; - - c = Moment::compare (start_moment_, other->start_moment_); - if (c) - return c; - - c = context_name_.compare (other->context_name_); - if (c) - return c; - - c = id_.compare (other->id_); - if (c) - return c; - - c = sign (disambiguation_count_ - other->disambiguation_count_); - if (c) - return c; - - return 0; -} - -int -Lilypond_context_key::get_type () const -{ - return CONTEXT_KEY; -} - -SCM -Lilypond_context_key::as_scheme () const -{ - return scm_list_5 (parent_context_ ? parent_context_->self_scm () : SCM_BOOL_F, - start_moment_.smobbed_copy (), - ly_string2scm (context_name_), - ly_string2scm (id_), - scm_from_int (disambiguation_count_)); -} - -Object_key * -Lilypond_context_key::from_scheme (SCM a) -{ - return new Lilypond_context_key (unsmob_key (scm_car (a)), - *unsmob_moment (scm_cadr (a)), - ly_scm2string (scm_list_ref (a, scm_from_int (2))), - ly_scm2string (scm_list_ref (a, scm_from_int (3))), - scm_to_int (scm_list_ref (a, scm_from_int (4)))); -} - -/****************************************************************/ - -int -Lilypond_general_key::get_type () const -{ - return GENERAL_KEY; -} - -void -Lilypond_general_key::derived_mark () const -{ - if (parent_) - scm_gc_mark (parent_->self_scm ()); -} - -Lilypond_general_key::Lilypond_general_key (Object_key const *parent, - string name, - int count) -{ - parent_ = parent; - name_ = name; - disambiguation_count_ = count; -} - -int -Lilypond_general_key::do_compare (Object_key const *key)const -{ - Lilypond_general_key const *other - = dynamic_cast (key); - - if (parent_ && other->parent_) - parent_->compare (other->parent_); - else if (parent_) - return -1; - else if (other->parent_) - return 1; - - int c = name_.compare (other->name_); - if (c) - return c; - - c = sign (disambiguation_count_ - other->disambiguation_count_); - if (c) - return c; - - return 0; -} - -SCM -Lilypond_general_key::as_scheme () const -{ - return scm_list_3 (parent_ ? parent_->self_scm () : SCM_BOOL_F, - ly_string2scm (name_), - scm_from_int (disambiguation_count_)); -} - -Object_key * -Lilypond_general_key::from_scheme (SCM a) -{ - return new Lilypond_general_key (unsmob_key (scm_car (a)), - ly_scm2string (scm_list_ref (a, scm_from_int (1))), - scm_to_int (scm_list_ref (a, scm_from_int (2)))); -}