* lily/parser.yy (music_output_def_body): plug memory leak.
* lily/translator-group.cc (add_fresh_group_translator): plug
memory leak: unprotect Translator_group once added.
* lily/span-dynamic-performer.cc (process_music): deprecate span-type.
* scripts/lilypond-book.py (Lilypond_snippet.notice_include):
write .dep file.
(Lilypond_snippet.ly): add \renameinput.
2004-02-09 Han-Wen Nienhuys <hanwen@xs4all.nl>
+ * lily/paper-score.cc (process): move gc stat stuff to init.ly
+
+ * lily/parser.yy (music_output_def_body): plug memory leak.
+
+ * lily/translator-group.cc (add_fresh_group_translator): plug
+ memory leak: unprotect Translator_group once added.
+
* lily/span-dynamic-performer.cc (process_music): deprecate span-type.
* scripts/lilypond-book.py (Lilypond_snippet.notice_include):
\version "2.1.7"
+
% A simple scale in LilyPond
%
% Type:
void
Accidental_engraver::finalize ()
{
+ /*
+ Must reset, since Accidental_engraver is GCd.
+ */
last_keysig_ = SCM_EOL;
}
virtual void stop_translation_timestep ();
virtual void process_music ();
virtual bool try_music (Music *);
-
+ virtual void finalize ();
private:
void add_note (Music *);
Protected_scm last_chord_;
};
+void
+Chord_name_engraver::finalize ()
+{
+ last_chord_ = SCM_EOL;
+}
+
Chord_name_engraver::Chord_name_engraver ()
{
chord_name_ = 0;
{
if (current_cresc_ev_)
{
- Direction sd = to_dir (current_cresc_ev_->get_mus_property ("span-direction"));
- String msg = sd == 1
- ? _ ("already have a crescendo")
- : _ ("already have a decrescendo");
-
+ String msg = _ ("already have a decrescendo");
+ if (current_cresc_ev_->is_mus_type ("decrescendo-event"))
+ msg = _ ("already have a crescendo");
+
accepted_spanreqs_drul_[START]->origin ()->warning (msg);
current_cresc_ev_->origin ()->warning (_("Cresc started here"));
}
void set_variable (SCM, SCM sym);
DECLARE_SMOBS (Music_output_def,);
-
-
};
DECLARE_UNSMOB(Music_output_def,music_output_def);
*/
char const* pos_str0_;
- SCM get_port()const { return str_port_; }
+ SCM get_port () const { return str_port_; }
String name_;
private:
void init_port ();
Protected_scm str_port_;
-
};
char * gulp_file (String fn, int *len);
bool store_locations_global_b;
+/*
+ TODO: should merge with My_lily_parser.
+ */
/*
no ! suffix since it doesn't modify 1st argument.
yy_pop_state();
this->here_input().source_file_->name_ = s;
- progress_indication (_f("\nRenamed input to `%s'", s.to_str0()));
+ progress_indication (_f("\nRenamed input to `%s'\n", s.to_str0()));
scm_module_define (gh_car (scopes_),
ly_symbol2scm ("input-file-name"),
scm_makfrom0str (s.to_str0()));
}
return tab;
}
+
+#if 1
+/*
+ Debugging mem leaks:
+ */
+LY_DEFINE(ly_protects, "ly:protects", 0, 0, 0, (),
+ "Return hash of protected objects.")
+{
+ return scm_protects;
+}
+#endif
init = "init.ly";
do_one_file (init, inpath.to_string (), outpath.to_string ());
+
+#if 0
+ /*
+ Code to debug memory leaks. Cannot call from within .ly since
+ then we get the protects from the parser state too.
+ */
+ static SCM proc ;
+ if (!proc)
+ proc = scm_c_eval_string ("dump-gc-protects");
+ scm_gc ();
+ scm_call_0 (proc);
+#endif
p++;
} while ((arg = oparser_p_static->get_next_arg ()));
scope_ = ly_make_anonymous_module();
}
-
-
Music_output_def::~Music_output_def ()
{
}
s = *unsmob_moment (m);
}
return s != Moment (0);
-
}
/*
Be sure to set breakability on first & last column.
*/
- Link_array<Grob> pc (system_->columns ());
+ {
+ Link_array<Grob> pc (system_->columns ());
- pc[0]->set_grob_property ("breakable", SCM_BOOL_T);
- pc.top ()->set_grob_property ("breakable", SCM_BOOL_T);
-
+ pc[0]->set_grob_property ("breakable", SCM_BOOL_T);
+ pc.top ()->set_grob_property ("breakable", SCM_BOOL_T);
+ }
system_->pre_processing ();
Array<Column_x_positions> breaking = calc_breaking ();
// huh?
delete outputter_;
outputter_ = 0;
-
- if (verbose_global_b)
- {
- scm_write (scm_gc_stats (), scm_current_error_port ());
- scm_flush (scm_current_error_port ());
- }
}
}
| music_output_def_head '{' MUSIC_OUTPUT_DEF_IDENTIFIER {
+ scm_gc_unprotect_object ($1->self_scm ());
Music_output_def * o = unsmob_music_output_def ($3);
$$ = o;
THIS->lexer_->remove_scope ();
some cases (two isolated, consecutive clef changes) won't be
nicely folded, but hey, then don't do that.
*/
- if(! ((Paper_column::musical_b (l_neighbor) || Item::breakable_b (l_neighbor))
- && (Paper_column::musical_b (r_neighbor) || Item::breakable_b (r_neighbor))) )
+ if(! ((Paper_column::is_musical (l_neighbor) || Item::breakable_b (l_neighbor))
+ && (Paper_column::is_musical (r_neighbor) || Item::breakable_b (r_neighbor))) )
{
return false;
}
Real increment = robust_scm2double (me->get_grob_property ("spacing-increment"), 1.2);
for (int i=0; i < cols->size (); i++)
{
- if (Item::breakable_b (cols->elem(i)) || Paper_column::musical_b (cols->elem (i)))
+ if (Item::breakable_b (cols->elem(i)) || Paper_column::is_musical (cols->elem (i)))
{
newcols.push (cols->elem(i));
continue;
for (int i = 0; i < cols.size (); i++)
{
Item * it = dynamic_cast<Item*>(cols[i]);
- if (!Item::breakable_b (it) && !Paper_column::musical_b (it))
+ if (!Item::breakable_b (it) && !Paper_column::is_musical (it))
continue;
// it->breakable || it->musical
for (int i =0 ; i < cols.size (); i++)
{
- if (Paper_column::musical_b (cols[i]))
+ if (Paper_column::is_musical (cols[i]))
{
Moment *when = unsmob_moment (cols[i]->get_grob_property ("when"));
Paper_column * lc = dynamic_cast<Paper_column*> (l);
Paper_column * rc = dynamic_cast<Paper_column*> (r);
- if (!Paper_column::musical_b (l))
+ if (!Paper_column::is_musical (l))
{
breakable_column_spacing (me, l, r, shortest);
do
{
- if (!Paper_column::musical_b (cols[d]))
+ if (!Paper_column::is_musical (cols[d]))
{
/*
Tied accidentals over barlines cause problems, so lets see
Moment rwhen = Paper_column::when_mom (rc);
Moment delta_t = rwhen - lwhen;
- if (!Paper_column::musical_b (rc ))
+ if (!Paper_column::is_musical (rc ))
{
/*
when toying with mmrests, it is possible to have musical
#include "event.hh"
#include "audio-item.hh"
+/*
+ TODO: fold this into 1 engraver: \< and \> should also stop when
+ absdyn is encountered.
+ */
+
struct Audio_dynamic_tuple
{
Audio_dynamic* audio_;
private:
Audio_dynamic* audio_;
Real last_volume_;
- Music* span_start_req_;
- Drul_array<Music*> span_req_l_drul_;
+ Music* span_start_event_;
+ Drul_array<Music*> span_events_;
Array<Audio_dynamic_tuple> dynamic_tuples_;
Array<Audio_dynamic_tuple> finished_dynamic_tuples_;
Direction dir_;
Span_dynamic_performer::Span_dynamic_performer ()
{
- span_req_l_drul_[START] = 0;
- span_req_l_drul_[STOP] = 0;
- span_start_req_ = 0;
+ span_events_[START] = 0;
+ span_events_[STOP] = 0;
+ span_start_event_ = 0;
audio_ = 0;
last_volume_ = 0;
}
void
Span_dynamic_performer::process_music ()
{
- if (span_start_req_ || span_req_l_drul_[START])
+ if (span_start_event_ || span_events_[START])
{
audio_ = new Audio_dynamic (0);
- Audio_element_info info (audio_, span_req_l_drul_[START]
- ? span_req_l_drul_[START]
- : span_req_l_drul_[STOP]);
+ Audio_element_info info (audio_, span_events_[START]
+ ? span_events_[START]
+ : span_events_[STOP]);
announce_element (info);
Audio_dynamic_tuple a = { audio_, now_mom () };
dynamic_tuples_.push (a);
}
- if (span_req_l_drul_[STOP])
+ if (span_events_[STOP])
{
- if (!span_start_req_)
+ if (!span_start_event_)
{
- span_req_l_drul_[STOP]->origin ()->warning (_ ("can't find start of (de)crescendo"));
- span_req_l_drul_[STOP] = 0;
+ span_events_[STOP]->origin ()->warning (_ ("can't find start of (de)crescendo"));
+ span_events_[STOP] = 0;
}
else
{
finished_dynamic_tuples_ = dynamic_tuples_;
}
dynamic_tuples_.clear ();
- span_start_req_ = 0;
+ span_start_event_ = 0;
}
- if (span_req_l_drul_[START])
+ if (span_events_[START])
{
- String t = ly_scm2string (span_req_l_drul_[START]->get_mus_property ("span-type"));
- dir_ = (t == "crescendo") ? RIGHT : LEFT;
- span_start_req_ = span_req_l_drul_[START];
+ dir_ = (span_events_[START]->is_mus_type ("crescendo-event"))
+ ? RIGHT : LEFT;
+ span_start_event_ = span_events_[START];
dynamic_tuples_.clear ();
Audio_dynamic_tuple a = { audio_, now_mom () };
}
- if (span_req_l_drul_[STOP])
+ if (span_events_[STOP])
{
finished_dynamic_tuples_.top ().audio_->volume_ = last_volume_;
}
- if (span_req_l_drul_[START])
+ if (span_events_[START])
{
dynamic_tuples_[0].audio_->volume_ = last_volume_;
}
- span_start_req_ = 0;
- span_req_l_drul_[START] = 0;
- span_req_l_drul_[STOP] = 0;
+ span_start_event_ = 0;
+ span_events_[START] = 0;
+ span_events_[STOP] = 0;
}
void
audio_ = 0;
}
- span_req_l_drul_[STOP] = 0;
- span_req_l_drul_[START] = 0;
+ span_events_[STOP] = 0;
+ span_events_[START] = 0;
}
|| r->is_mus_type ("decrescendo-event"))
{
Direction d = to_dir (r->get_mus_property ("span-direction"));
- span_req_l_drul_[d] = r;
+ span_events_[d] = r;
return true;
}
return false;
{
SCM c = me->get_grob_property ("head-pair");
- if (gh_pair_p)
+ if (gh_pair_p (c))
return unsmob_grob (index_get_cell (c, d));
else
return 0;
Translator_group::add_fresh_group_translator (Translator*t)
{
Translator_group*tg = dynamic_cast<Translator_group*> (t);
- trans_group_list_ = add_translator (trans_group_list_,t);
+ trans_group_list_ = add_translator (trans_group_list_,t);
+ scm_gc_unprotect_object (t->self_scm ());
+
Context_def * td = unsmob_context_def (tg->definition_);
/*
}
Translator_group *tg = t->instantiate (output_def_, SCM_EOL);
add_fresh_group_translator (tg);
-
if (!tg->is_bottom_context ())
return tg->get_default_interpreter ();
else
(ly:warn (string-append
"\n"
input-file-name ": old relative compatibility was not used.")))
+
+
+#(if (ly:get-option 'verbose)
+ (begin
+ (gc)
+ (write (gc-stats) (current-error-port))
+ (flush-all-ports)))
+
))
+;; debug mem leaks
+
+(define gc-protect-stat-count 0)
+(define-public (dump-gc-protects)
+ (set! gc-protect-stat-count (1+ gc-protect-stat-count) )
+
+ (display
+ (map (lambda (y)
+ (let
+ ((x (car y))
+ (c (cdr y)))
+
+ (string-append
+ (string-join
+ (map object->string (list (object-address x) c x))
+ " ")
+ "\n")))
+
+ (sort
+ (hash-table->alist (ly:protects))
+ (lambda (a b)
+ (< (object-address (car a))
+ (object-address (car b)))))
+
+ )
+ (open-file (string-append
+ "gcstat-" (number->string gc-protect-stat-count)
+ ".scm"
+ ) "w")))
+
def ly (self):
if self.type == 'lilypond_file':
name = self.substring ('filename')
- return open (find_file (name)).read ()
+ return '\\renameinput \"%s\"\n' % name\
+ + open (find_file (name)).read ()
else:
return self.substring ('code')