]> git.donarmstrong.com Git - lilypond.git/commitdiff
Merge branch 'master' of ssh+git://hanwen@git.sv.gnu.org/srv/git/lilypond
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Wed, 17 Jan 2007 01:00:44 +0000 (02:00 +0100)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Wed, 17 Jan 2007 01:00:44 +0000 (02:00 +0100)
23 files changed:
input/test/engraver-one-by-one.ly
lily/all-font-metrics.cc
lily/audio-element.cc
lily/audio-staff.cc
lily/grob-smob.cc
lily/include/all-font-metrics.hh
lily/include/midi-item.hh
lily/include/midi-stream.hh
lily/include/midi-walker.hh
lily/include/pango-font.hh
lily/include/smobs.hh
lily/midi-item.cc
lily/midi-stream.cc
lily/midi-walker.cc
lily/pango-font.cc
lily/paper-def.cc
lily/performance.cc
lily/program-option.cc
lily/relocate.cc
lily/skyline.cc
lily/system-start-delimiter-engraver.cc
scm/lily.scm
scm/standalone.scm

index c4199cb643fedce3ea7ef5e9417c56d8eced6119..1fdb502d1cf0e68098bf78b5375e03b4f6a386e6 100644 (file)
@@ -105,7 +105,6 @@ MyVoice = \context {
   \consists "Chord_tremolo_engraver"
   \consists "Percent_repeat_engraver"
   \consists "Slash_repeat_engraver"
-  \consists "Melisma_translator"
 
 %{
   Must come before text_engraver, but after note_column engraver.
index 0d7fdd822bc0fdb320e3bb4ce81182d2df4c06f7..f8da4b2ecdf4ef205e0989baa64b83f85b0ba76c 100644 (file)
@@ -65,15 +65,10 @@ All_font_metrics::All_font_metrics (All_font_metrics const &)
 #if HAVE_PANGO_FT2
 
 Pango_font *
-All_font_metrics::find_pango_font (PangoFontDescription *description,
-                                  Real magnification,
+All_font_metrics::find_pango_font (PangoFontDescription const *description,
                                   Real output_scale
                                   )
 {
-  pango_font_description_set_size (description,
-                                  gint (magnification *
-                                        pango_font_description_get_size (description)));
-
   gchar *pango_fn = pango_font_description_to_filename (description);
   SCM key = ly_symbol2scm (pango_fn);
 
index cb498f5dbf7f9acf4c7944108ba20479b0200d7f..8d3a3e39534384768a34ae87f2de82df9ea8b66e 100644 (file)
@@ -5,6 +5,7 @@
 
   (c) 1997--2007 Han-Wen Nienhuys <hanwen@xs4all.nl>
 */
+#include <cassert> 
 
 #include "audio-element.hh"
 
index 7ddd646b53c7dd7e317594b7faa6d7854582fe20..120313ef6455c2505e7af243992a8960590eb1df 100644 (file)
@@ -28,10 +28,11 @@ Audio_staff::output (Midi_stream &midi_stream, int channel)
 {
   Midi_track midi_track;
   midi_track.number_ = channel;
-  
-  for (Midi_walker i (this, &midi_track, channel); i.ok (); i++)
+
+  Midi_walker i (this, &midi_track, channel);
+  for (; i.ok (); i++)
     i.process ();
   
-  midi_stream << midi_track;
+  midi_stream.write (midi_track);
 }
 
index 44c16e149fe9b478f55ad39615073718eae03da8..1011d47fdcf1f1a55441cfb31e6f703547880c56 100644 (file)
@@ -9,6 +9,7 @@
 #include "grob.hh"
 
 #include "paper-score.hh"
+#include "warn.hh"
 
 #include "ly-smobs.icc"
 
@@ -19,6 +20,8 @@ IMPLEMENT_TYPE_P (Grob, "ly:grob?");
 SCM
 Grob::mark_smob (SCM ses)
 {
+  ASSERT_LIVE_IS_ALLOWED();
+  
   Grob *s = (Grob *) SCM_CELL_WORD_1 (ses);
   scm_gc_mark (s->immutable_property_alist_);
 
index edf50f301fef357a4762e8211e41d656a8c27415..073b839d9a1ff874cd9b0f880a665468f82f9d32 100644 (file)
@@ -43,11 +43,8 @@ public:
   All_font_metrics (string search_path);
   ~All_font_metrics ();
 
-#if HAVE_PANGO_FT2
-  Pango_font *find_pango_font (PangoFontDescription *description,
-                              Real magnification,
+  Pango_font *find_pango_font (PangoFontDescription const *description,
                               Real scale);
-#endif
 
   Font_metric *find_font (string name);
   Open_type_font *find_otf (string name);
index 6d77f21afc29872c1162f040b50f1ed61bb3cba9..f7ea0e0585c07cce1551692ef714b1b78660bb7d 100644 (file)
@@ -37,8 +37,6 @@ public:
   int channel_;
   DECLARE_CLASSNAME(Midi_channel_item);
   Midi_channel_item ();
-  virtual const char *name () const { return "Midi_channel_item"; }
-  virtual ~Midi_channel_item ();
 };
 
 /**
@@ -125,9 +123,6 @@ public:
   int clocks_per_1_;
 };
 
-/**
-   Turn a note on.
-*/
 class Midi_note : public Midi_channel_item
 {
 public:
@@ -145,9 +140,6 @@ public:
   Byte dynamic_byte_;
 };
 
-/**
-   Turn a note off
-*/
 class Midi_note_off : public Midi_note
 {
 public:
@@ -216,9 +208,6 @@ public:
   int number_;
   DECLARE_CLASSNAME(Midi_track);
 
-  /*
-    Compensate for starting grace notes.
-  */
   vector<Midi_event*> events_;
 
   Midi_track ();
index 18e38ca2c00c6cebb41367b32d9128d02ff170f4..1d9066e8654b5de80e9ee713689fbf21924ace52 100644 (file)
@@ -20,9 +20,9 @@ struct Midi_stream
   Midi_stream (string file_name_string);
   ~Midi_stream ();
 
-  Midi_stream &operator << (string str);
-  Midi_stream &operator << (Midi_item const &midi_c_r);
-  Midi_stream &operator << (int i);
+  void write (string);
+  void write (Midi_item const &);
+  void write (int);
 
   void open ();
 
index ee523e5faa850a0dbc71d5daf3d32cbd101b80d4..69bf4c8a9b939589e41caf9fa62cc2390cd174a3 100644 (file)
@@ -14,7 +14,7 @@
 
 struct Midi_note_event : PQueue_ent<int, Midi_note *>
 {
-  bool ignore_b_;
+  bool ignore_;
   Midi_note_event ();
 };
 
@@ -38,7 +38,7 @@ private:
   void do_start_note (Midi_note *note);
   void do_stop_notes (int);
   void output_event (int, Midi_item *l);
-
+  
   int channel_;
   Midi_track *track_;
   Audio_staff *staff_;
@@ -46,6 +46,7 @@ private:
   vector<Audio_item*> items_;
   PQueue<Midi_note_event> stop_note_queue;
   int last_tick_;
+
 };
 
 #endif // MIDI_WALKER_HH
index 013f3504638a2c7d867f132a69cab44d265b7f5e..c0d6ff336863d7ff022005257a1276b2eb612a39 100644 (file)
@@ -31,7 +31,7 @@ class Pango_font : public Font_metric
 public:
   SCM physical_font_tab () const;
   Pango_font (PangoFT2FontMap *,
-             PangoFontDescription *,
+             PangoFontDescription const *,
              Real);
   ~Pango_font ();
 
index a8f3ac5164c70151d7c67c4d2b10e7296b6f6840..5bd403bce45364763f307fb2014960034e146b58 100644 (file)
@@ -142,12 +142,16 @@ void unprotect_smob (SCM smob, SCM *prot_cons);
 
 extern bool parsed_objects_should_be_dead;
 
+#ifndef NDEDUG
 #define ASSERT_LIVE_IS_ALLOWED()     \
   static bool passed_here_once;\
   if (parsed_objects_should_be_dead && !passed_here_once) { \
-    programming_error (string ("Parsed object should be dead: ")  + __PRETTY_FUNCTION__ ); \
+    ::programming_error (string ("Parsed object should be dead: ")  + __PRETTY_FUNCTION__ ); \
     passed_here_once = true;\
   }    
+#else
+#define ASSERT_LIVE_IS_ALLOWED()
+#endif
 
 #endif /* SMOBS_HH */
 
index ee05d4ed58dcabbf614703854bb542ba4c2c41f6..88f9aeb86f0525a8788ce7490f1d0799bf3dc96d 100644 (file)
@@ -1,5 +1,5 @@
 /*
-  midi-item.cc -- implement Midi items.
+  midi-item.cc -- implement MIDI items.
 
   source file of the GNU LilyPond music typesetter
 
@@ -40,12 +40,10 @@ Midi_item::get_midi (Audio_item *a)
   else if (Audio_time_signature *i = dynamic_cast<Audio_time_signature *> (a))
     return new Midi_time_signature (i);
   else if (Audio_text *i = dynamic_cast<Audio_text *> (a))
-    //return i->text_string_.length () ? new Midi_text (i) : 0;
     return new Midi_text (i);
   else
     assert (0);
 
-  // isn't C++ grand?
   return 0;
 }
 
@@ -150,11 +148,6 @@ Midi_item::Midi_item ()
 {
 }
 
-Midi_channel_item::~Midi_channel_item ()
-{
-  channel_ = 0;
-}
-
 Midi_channel_item::Midi_channel_item ()
 {
   channel_ = 0;
@@ -455,15 +448,11 @@ string
 Midi_track::data_string () const
 {
   string str = Midi_chunk::data_string ();
-  if (do_midi_debugging_global)
-    str += "\n";
 
   for (vector<Midi_event*>::const_iterator i (events_.begin());
        i != events_.end(); i ++)
     {
       str += (*i)->to_string ();
-      if (do_midi_debugging_global)
-       str += "\n";
     }
   return str;
 }
index 893ca3d8df1b5883ad9134c2249c8ccb4cf46f67..11afe02cf46b13e0dcc53f9a681348fdcbd558b3 100644 (file)
@@ -33,8 +33,8 @@ Midi_stream::~Midi_stream ()
   fclose (out_file_);
 }
 
-Midi_stream &
-Midi_stream::operator << (string str)
+void
+Midi_stream::write (string str)
 {
   size_t sz = sizeof (Byte);
   size_t n = str.length ();
@@ -42,34 +42,19 @@ Midi_stream::operator << (string str)
 
   if (written != sz * n)
     warning (_ ("cannot write to file: `%s'"));
-
-  return *this;
 }
 
-Midi_stream &
-Midi_stream::operator << (Midi_item const &midi_c_r)
+void
+Midi_stream::write (Midi_item const &midi)
 {
-  string str = midi_c_r.to_string ();
-
-  // ugh, should have separate debugging output with Midi*::print routines
-  if (do_midi_debugging_global)
-    {
-      str = String_convert::bin2hex (str) + "\n";
-      for (ssize i = str.find ("0a"); i != NPOS; i = str.find ("0a"))
-       {
-         str[i] = '\n';
-         str[i + 1] = '\t';
-       }
-    }
+  string str = midi.to_string ();
 
-  return operator << (str);
+  return write (str);
 }
 
-Midi_stream &
-Midi_stream::operator << (int i)
+void
+Midi_stream::write (int i)
 {
-  // output binary string ourselves
-  *this << Midi_item::i2varint_string (i);
-  return *this;
+  write (Midi_item::i2varint_string (i));
 }
 
index aa491bc930ddf8e202010b2a8ddf30df3b967a98..941e64c282932e753a97c1aa494327d339929ef8 100644 (file)
@@ -17,7 +17,7 @@
 
 Midi_note_event::Midi_note_event ()
 {
-  ignore_b_ = false;
+  ignore_ = false;
 }
 
 int
@@ -53,9 +53,10 @@ Midi_walker::Midi_walker (Audio_staff *audio_staff, Midi_track *track,
 
 Midi_walker::~Midi_walker ()
 {
-  do_stop_notes (last_tick_ + 384);
+  do_stop_notes (INT_MAX);
 }
 
+
 /**
    Find out if start_note event is needed, and do it if needed.
 */
@@ -77,7 +78,8 @@ Midi_walker::do_start_note (Midi_note *note)
            {
              /* let stopnote in queue be ignored,
                 new stop note wins */
-             stop_note_queue[i].ignore_b_ = true;
+             stop_note_queue[i].ignore_ = true;
+
              /* don't replay start note, */
              play_start = false;
              break;
@@ -114,7 +116,7 @@ Midi_walker::do_stop_notes (int max_ticks)
   while (stop_note_queue.size () && stop_note_queue.front ().key <= max_ticks)
     {
       Midi_note_event e = stop_note_queue.get ();
-      if (e.ignore_b_)
+      if (e.ignore_)
        {
          delete e.val;
          continue;
@@ -127,9 +129,6 @@ Midi_walker::do_stop_notes (int max_ticks)
     }
 }
 
-/**
-   Advance the track to #now#, output the item, and adjust current "moment".
-*/
 void
 Midi_walker::output_event (int now_ticks, Midi_item *l)
 {
@@ -160,7 +159,6 @@ Midi_walker::process ()
       if (Midi_channel_item *mci = dynamic_cast<Midi_channel_item*> (midi))
        mci->channel_ = channel_;
       
-      //midi->channel_ = track_->number_;
       if (Midi_note *note = dynamic_cast<Midi_note *> (midi))
        {
          if (note->audio_->length_mom_.to_bool ())
index 75103e3b7bbed5651f1e6454e98e69c717e92428..f91eafb9844743dd1a6ae89904e5c48ebb0f81b8 100644 (file)
 #include "stencil.hh"
 
 Pango_font::Pango_font (PangoFT2FontMap *fontmap,
-                       PangoFontDescription *description,
+                       PangoFontDescription const *description,
                        Real output_scale)
 {
   (void) fontmap;
+  
   physical_font_tab_ = scm_c_make_hash_table (11);
   PangoDirection pango_dir = PANGO_DIRECTION_LTR;
   context_
     = pango_ft2_get_context (PANGO_RESOLUTION, PANGO_RESOLUTION);
-  //  context_ = pango_ft2_font_map_create_context (fontmap);
 
   pango_description_ = pango_font_description_copy (description);
   attribute_list_ = pango_attr_list_new ();
@@ -104,7 +104,7 @@ Pango_font::pango_item_string_stencil (PangoItem const *item, string str,
   char glyph_name[GLYPH_NAME_LEN];
   PangoAnalysis const *pa = &(item->analysis);
   PangoGlyphString *pgs = pango_glyph_string_new ();
-
+  
   pango_shape (str.c_str () + item->offset,
               item->length, (PangoAnalysis*) pa, pgs);
 
@@ -215,6 +215,8 @@ Pango_font::pango_item_string_stencil (PangoItem const *item, string str,
       tail = SCM_CDRLOC (*tail);
     }
 
+  pango_glyph_string_free (pgs);  
+  pgs = 0;
   PangoFontDescription *descr = pango_font_describe (pa->font);
   Real size = pango_font_description_get_size (descr)
     / (Real (PANGO_SCALE));
@@ -363,6 +365,7 @@ Pango_font::text_stencil (string str, bool tight) const
       return Stencil (b, exp);
     }
 
+  g_list_free (items);
 
   return dest;
 }
index 3a1cafbb199178f61ed7677f1521745b65992117..e9a56ae0e190f269ce0c0ed690c933e0c46defd8 100644 (file)
@@ -80,10 +80,17 @@ find_pango_font (Output_def *layout, SCM descr, Real factor)
 
   PangoFontDescription *description
     = pango_font_description_from_string (scm_i_string_chars (descr));
+
+  pango_font_description_set_size (description,
+                                  gint (factor *
+                                        pango_font_description_get_size (description)));
+
+  
   Font_metric *fm = all_fonts_global->find_pango_font (description,
-                                                      factor,
                                                       output_scale (layout));
 
+  pango_font_description_free (description);
   sizes = scm_acons (size_key, fm->self_scm (), sizes);
   scm_hash_set_x (table, descr, sizes);
 
index 2c02fc32f94f3ff64aacab4a6dfc1bce18845982..439d9489f175727bc3ad0624179acaa49b8145d2 100644 (file)
@@ -38,7 +38,7 @@ Performance::output (Midi_stream &midi_stream) const
 {
   int tracks_ = audio_staffs_.size ();
 
-  midi_stream << Midi_header (1, tracks_, 384);
+  midi_stream.write (Midi_header (1, tracks_, 384));
   if (be_verbose_global)
     progress_indication (_ ("Track...") + " ");
   
index 8f593aaa393c3d9e8a8a28bbd3fecd25a258914b..5d9bebd7382728656addb4e9e5b01ac75fe1776c 100644 (file)
@@ -19,8 +19,6 @@ using namespace std;
 #include "string-convert.hh"
 #include "warn.hh"
 
-/* Write midi as formatted ascii stream? */
-bool do_midi_debugging_global;
 bool debug_skylines;
 
 /*
@@ -48,11 +46,6 @@ void internal_set_option (SCM var, SCM val)
       profile_property_accesses = to_boolean (val);
       val = scm_from_bool (to_boolean (val));
     }
-  else if (var == ly_symbol2scm ("debug-midi"))
-    {
-      do_midi_debugging_global = to_boolean (val);
-      val = scm_from_bool (to_boolean (val));
-    }
   else if (var == ly_symbol2scm ("point-and-click"))
     {
       point_and_click_global = to_boolean (val);
index 05d98b72cafd070ddcf916cee0acb665640e763c..47502f7dbda9f054f9524c0587763cf5b26bc91b 100644 (file)
@@ -44,7 +44,12 @@ sane_putenv (char const *key, string value, bool overwrite)
        progress_indication (_f ("Setting %s to %s" , key, value.c_str ())
                             + "\n");
                             
-      return putenv (s);
+      int retval =  putenv (s);
+      /*
+       unfortunately, we can't portably free S here,
+       due to various bugs in glibc prior to 2.1.1
+       */ 
+      return retval;
     }
   
   return -1;
index 744cceb4c3219a65fd3e7a5e8d800bc151db1d72..b729e5312b15a56471f9f7b58ca542e0db947281 100644 (file)
@@ -651,6 +651,7 @@ IMPLEMENT_DEFAULT_EQUAL_P (Skyline_pair);
 SCM
 Skyline::mark_smob (SCM)
 {
+  ASSERT_LIVE_IS_ALLOWED();
   return SCM_EOL;
 }
 
index a558965f1094a9f6ee5bf42f9207047d1f9ada9e..479618addcdb1b50aef2c4768a373964ce157aff 100644 (file)
@@ -96,8 +96,7 @@ Bracket_nesting_group::add_support (Grob *g)
 
 Bracket_nesting_group::~Bracket_nesting_group ()
 {
-  for (vsize i = 0 ; i < children_.size (); i++)
-    delete children_[i];
+  junk_pointers (children_);
 }
 
 void
@@ -212,6 +211,8 @@ System_start_delimiter_engraver::finalize ()
       nesting_->set_bound (RIGHT,
                           unsmob_grob (get_property ("currentCommandColumn")));
       nesting_->set_nesting_support (0);
+
+      delete nesting_;
     }
 }
 
index e10b4b7d3374b4d687ed282ea1988fcec87b012d..c8c3a010ac14856cbfab72bb61a87d6c8bfbef67 100644 (file)
@@ -36,7 +36,6 @@
              (debug-gc-assert-parsed-dead #f "for memory debugging:
 ensure that all refs to parsed objects are dead.  This is an internal option, and is switched on automatically for -ddebug-gc.") 
              (debug-lexer #f "debug the flex lexer")
-             (debug-midi #f "generate human readable MIDI")
              (debug-parser #f "debug the bison parser")
              (debug-skylines #f "debug skylines")
              (delete-intermediate-files #f
@@ -100,6 +99,7 @@ on errors, and print a stack trace.")
 
 (use-modules (ice-9 regex)
             (ice-9 safe)
+            (ice-9 rdelim)
              (ice-9 optargs)
             (oop goops)
             (srfi srfi-1)
@@ -402,6 +402,15 @@ The syntax is the same as `define*-public'."
 
 (define gc-dumping #f)
 (define gc-protect-stat-count 0)
+
+(define-public (dump-live-object-stats outfile)
+  (for-each
+   (lambda (x)
+     (format outfile "~a: ~a\n" (car x) (cdr x)))
+   (sort (gc-live-object-stats)
+        (lambda (x y)
+          (string<? (car x) (car y))))))
+
 (define-public (dump-gc-protects)
   (set! gc-protect-stat-count (1+ gc-protect-stat-count))
   (let* ((protects (sort
@@ -450,14 +459,7 @@ The syntax is the same as `define*-public'."
 
          (set! stats (gc-live-object-stats))
          (display "Dumping live object statistics.\n")
-         
-         (for-each
-          (lambda (x)
-            (format outfile "~a: ~a\n" (car x) (cdr x)))
-          (sort (gc-live-object-stats)
-                (lambda (x y)
-                  (string<? (car x) (car y)))))))
-
+         (dump-live-object-stats outfile)))
 
     (newline outfile)
     (let*
@@ -479,6 +481,36 @@ The syntax is the same as `define*-public'."
                           )))
 
     (set! gc-dumping #f)
+    (close-port outfile)
+    
+    ))
+
+
+(define (check-memory)
+  "read /proc/self to check up on memory use." 
+  (define (gulp-file name)
+    (let* ((file (open-input-file name))
+          (text (read-delimited "" file)))
+      (close file)
+      text))
+  (let*
+      ((stat (gulp-file "/proc/self/status"))
+       (lines (string-split stat #\newline))
+       (interesting (filter identity
+                           (map
+                            (lambda (l)
+                              (string-match "^VmData:[ \t]*([0-9]*) kB" l))
+                            lines)))
+       (mem (string->number (match:substring (car interesting) 1)))
+       )
+
+    
+    (display (format  "VMDATA: ~a\n" mem))
+    (display (gc-stats))
+    (if (> mem 100000)
+       (begin
+         (dump-gc-protects)
+         (raise 1)))
     
     ))
 
@@ -628,12 +660,12 @@ The syntax is the same as `define*-public'."
          (lambda (s)
            (ly:set-option (car s) (cdr s)))
          all-settings)
-        
+
         (ly:clear-anonymous-modules)
         (ly:set-option 'debug-gc-assert-parsed-dead #t)
         (gc)
         (ly:set-option 'debug-gc-assert-parsed-dead #f)
-        
+
         
         (if (ly:get-option 'debug-gc)
             (dump-gc-protects)
index 681a49d04297727f11ff25c2ac8a757e7d755811..5a644d2b3d1b8c9e1312f90b5b39ea306e469ab2 100644 (file)
@@ -5,6 +5,9 @@
 ;;;; (c) 1998--2006 Jan Nieuwenhuizen <janneke@gnu.org>
 ;;;;                 Han-Wen Nienhuys <hanwen@xs4all.nl>
 
+
+(use-modules (ice-9 rdelim))
+
 (define standalone (not (defined? 'ly:gulp-file)))
 ;;(write standalone (current-error-port))
 
@@ -16,8 +19,8 @@
 
 (define (scm-gulp-file name)
   (set! %load-path 
-       (cons (string-append (getenv 'LILYPONDPREFIX) "/ly")
-             (cons (string-append (getenv 'LILYPONDPREFIX) "/ps")
+       (cons (string-append (getenv "LILYPONDPREFIX") "/ly")
+             (cons (string-append (getenv "LILYPONDPREFIX") "/ps")
                    %load-path)))
   (let ((path (%search-load-path name)))
        (if path