From e319b8b2e19181a6e0864139bd94a36d66adb602 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Sun, 10 Oct 1999 17:19:11 +0200 Subject: [PATCH] patch::: 1.2.12.jcn2 pl 12.jcn2 - smobs --- CHANGES | 4 +++ VERSION | 2 +- lily/engraver.cc | 7 +++++ lily/include/score-element.hh | 8 +++++ lily/lily-guile.cc | 3 ++ lily/paper-score.cc | 5 +-- lily/score-element.cc | 59 +++++++++++++++++++++++++++++++++++ 7 files changed, 85 insertions(+), 3 deletions(-) diff --git a/CHANGES b/CHANGES index 4c8deed900..8d88e61cef 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,7 @@ +pl 12.jcn2 + - smobs + + pl 12.jcn1 - auto-knees, input/test/auto-knee.ly diff --git a/VERSION b/VERSION index b14be88b79..23ddbdd17e 100644 --- a/VERSION +++ b/VERSION @@ -2,7 +2,7 @@ PACKAGE_NAME=LilyPond MAJOR_VERSION=1 MINOR_VERSION=2 PATCH_LEVEL=12 -MY_PATCH_LEVEL=jcn1 +MY_PATCH_LEVEL=jcn2 # use the above to send patches: MY_PATCH_LEVEL is always empty for a # released version. diff --git a/lily/engraver.cc b/lily/engraver.cc index f8ed5e5d6a..d5e82fd1a4 100644 --- a/lily/engraver.cc +++ b/lily/engraver.cc @@ -12,6 +12,7 @@ #include "engraver-group-engraver.hh" #include "debug.hh" #include "paper-def.hh" +#include "score-element.hh" void Engraver::fill_staff_info (Staff_info&) @@ -23,6 +24,12 @@ void Engraver::announce_element (Score_element_info i) { i.origin_trans_l_arr_.push (this); + Score_element *s = i.elem_l_; + if (s->self_scm_ == SCM_EOL) + { + scm_protect_object (s->smobify_self ()); + } + daddy_grav_l()->announce_element (i); } diff --git a/lily/include/score-element.hh b/lily/include/score-element.hh index af9b484faa..69ac3526fd 100644 --- a/lily/include/score-element.hh +++ b/lily/include/score-element.hh @@ -144,6 +144,14 @@ protected: virtual Link_array get_extra_dependencies () const; static Interval dim_cache_callback (Dimension_cache*); +public: + SCM smobify_self (); + static SCM mark_smob (SCM); + static scm_sizet free_smob (SCM s); + static int print_smob (SCM s, SCM p, scm_print_state*); + static long smob_tag; + static void init_smobs(); + SCM self_scm_; }; diff --git a/lily/lily-guile.cc b/lily/lily-guile.cc index b2017c27af..311397cdd8 100644 --- a/lily/lily-guile.cc +++ b/lily/lily-guile.cc @@ -169,10 +169,13 @@ init_functions () } extern void init_symbols (); +extern void init_smobs (); // guh -> .hh + void init_lily_guile () { init_symbols(); init_functions (); + init_smobs (); } diff --git a/lily/paper-score.cc b/lily/paper-score.cc index 5de1ecf8cb..8769502ec9 100644 --- a/lily/paper-score.cc +++ b/lily/paper-score.cc @@ -57,9 +57,10 @@ Paper_score::typeset_element (Score_element * elem_p) elem_p->pscore_l_ = this; // take over protection. - SCM_CDR(protected_scms_) = gh_cons (elem_p->element_property_alist_, + assert (elem_p->self_scm_ != SCM_EOL); + SCM_CDR(protected_scms_) = gh_cons (elem_p->self_scm_, SCM_CDR (protected_scms_)); - scm_unprotect_object (elem_p->element_property_alist_); + scm_unprotect_object (elem_p->self_scm_); SCM p = elem_p->remove_elt_property (break_helper_only_scm_sym); if (p != SCM_BOOL_F) diff --git a/lily/score-element.cc b/lily/score-element.cc index bdb4f4bd30..5f7c890e76 100644 --- a/lily/score-element.cc +++ b/lily/score-element.cc @@ -44,6 +44,7 @@ Score_element::Score_element() pscore_l_=0; lookup_l_ =0; status_i_ = 0; + self_scm_ = SCM_EOL; original_l_ = 0; element_property_alist_ = scm_protect_object (gh_cons (gh_cons (void_scm_sym, SCM_BOOL_T) , SCM_EOL)); } @@ -51,6 +52,7 @@ Score_element::Score_element() Score_element::Score_element (Score_element const&s) : Graphical_element (s) { + self_scm_ = SCM_EOL; used_b_ = true; original_l_ =(Score_element*) &s; element_property_alist_ = scm_protect_object (scm_list_copy (s.element_property_alist_)); @@ -424,3 +426,60 @@ Score_element::find_broken_piece (Line_of_score*) const { return 0; } + +static scm_smobfuns score_elt_funs = { + Score_element::mark_smob, Score_element::free_smob, + Score_element::print_smob, 0, +}; + + +SCM +Score_element::smobify_self () +{ + if (self_scm_ != SCM_EOL) + return self_scm_; + + SCM s; + SCM_NEWCELL(s); + SCM_SETCAR(s,smob_tag); + SCM_SETCDR(s,this); + self_scm_ = s; + scm_unprotect_object (element_property_alist_); // ugh + return s; +} + +SCM +Score_element::mark_smob (SCM ses) +{ + Score_element * s = (Score_element*) SCM_CDR(ses); + scm_gc_mark (s->self_scm_); + return s->element_property_alist_; +} + +scm_sizet +Score_element::free_smob (SCM ses) +{ + Score_element * s = (Score_element*) SCM_CDR(ses); + delete s; + return 0; +} + +int +Score_element::print_smob (SCM s, SCM p, scm_print_state *) +{ + return 0; +} + +long Score_element::smob_tag; + +void +Score_element::init_smobs () +{ + smob_tag = scm_newsmob (&score_elt_funs); +} + +void +init_smobs() +{ + Score_element::init_smobs (); +} -- 2.39.2