]> git.donarmstrong.com Git - lilypond.git/commitdiff
* lily/smobs.cc (protect_smob): switch off fancy smob protection
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Wed, 23 Aug 2006 20:43:29 +0000 (20:43 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Wed, 23 Aug 2006 20:43:29 +0000 (20:43 +0000)
for now.

* lily/include/performer.hh (class Performer): strip get_tempo() method.

* lily/midi-def.cc: strip file.

* lily/lexer.ll (Lily_lexer): don't protect hash key separately.

* lily/include/context-def.hh (struct Context_def): use
VIRTUAL_COPY_CONSTRUCTOR().

* lily/source-file.cc: smobification.

* lily/include/source-file.hh (class Source_file): smobify
Source_file. Trim redundant members.

* lily/parser.yy (Lily_lexer::try_special_identifiers): unprotect
clones after creation. This plugs a huge memory leak.

* python/convertrules.py (FatalConversionError.sub_tempo):
complete rule for \midi{ \tempo }

* input/mutopia/J.S.Bach/wtk1-fugue2.ly (bassdux): idem.

* input/mutopia/F.Schubert/morgenlied.ly (pianoLH): update tempo.

33 files changed:
ChangeLog
THANKS
input/mutopia/F.Schubert/morgenlied.ly
input/mutopia/J.S.Bach/wtk1-fugue2.ly
lily/binary-source-file.cc
lily/context-def.cc
lily/include/context-def.hh
lily/include/input.hh
lily/include/ly-smobs.icc
lily/include/output-def.hh
lily/include/performer-group.hh
lily/include/performer.hh
lily/include/score-performer.hh
lily/include/smobs.hh
lily/include/source-file.hh
lily/input-smob.cc
lily/lexer.ll
lily/lily-guile.cc
lily/metronome-engraver.cc
lily/midi-def.cc
lily/parser.yy
lily/performance.cc
lily/performer-group.cc
lily/performer.cc
lily/pfb.cc
lily/prob.cc
lily/score-performer.cc
lily/smobs.cc
lily/source-file.cc
lily/source.cc
lily/staff-performer.cc
lily/tfm-reader.cc
python/convertrules.py

index fa82ee28f6af8bed7bdecbca67cee79babc16658..5fefaf8d204567250c450adc74fa600c343a3dc8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,32 @@
+2006-08-23  Han-Wen Nienhuys  <hanwen@lilypond.org>
+
+       * lily/smobs.cc (protect_smob): switch off fancy smob protection
+       for now. 
+
+       * lily/include/performer.hh (class Performer): strip get_tempo() method.
+
+       * lily/midi-def.cc: strip file.
+
+       * lily/lexer.ll (Lily_lexer): don't protect hash key separately.
+
+       * lily/include/context-def.hh (struct Context_def): use
+       VIRTUAL_COPY_CONSTRUCTOR().
+
+       * lily/source-file.cc: smobification.
+
+       * lily/include/source-file.hh (class Source_file): smobify
+       Source_file. Trim redundant members.
+
+       * lily/parser.yy (Lily_lexer::try_special_identifiers): unprotect
+       clones after creation. This plugs a huge memory leak.
+
+       * python/convertrules.py (FatalConversionError.sub_tempo):
+       complete rule for \midi{ \tempo }
+
+       * input/mutopia/J.S.Bach/wtk1-fugue2.ly (bassdux): idem.
+
+       * input/mutopia/F.Schubert/morgenlied.ly (pianoLH): update tempo.
+
 2006-08-22  Han-Wen Nienhuys  <hanwen@lilypond.org>
 
        * python/convertrules.py (conv): warning on \tempo{}
@@ -16,7 +45,8 @@
 
        * lily/parser.yy (output_def_body): disallow \tempo in \midi{}
 
-       * lily/duration-scheme.cc (LY_DEFINE): ly:duration-length: new function.
+       * lily/duration-scheme.cc (LY_DEFINE): ly:duration-length: new
+       function.
 
        * scm/lily.scm (define-scheme-options): alphabetize, add eps-pad-boxes.
 
diff --git a/THANKS b/THANKS
index c9af7de1b00b2ee8ef299bf02e781811e0bdd95f..8be5301cbf27af1a7bfdf336ee2cd34f47dc389b 100644 (file)
--- a/THANKS
+++ b/THANKS
@@ -1,6 +1,7 @@
 Release 2.9
 ***********
 
+
 DEVELOPMENT TEAM
 
 Han-Wen Nienhuys  - Core development
@@ -8,6 +9,7 @@ Jan Nieuwenhuizen - Core development
 Graham Percival   - Documentation Editor
 Mats Bengtsson    - Support Guru 
 
+
 CONTRIBUTORS
 
 Angelo Contardi
@@ -18,6 +20,7 @@ Guido Amoruso
 Heikki Junes
 Joe Neeman
 
+
 SPONSORS
 
 Andrew Sidwell
index 18cd30924a889a28cfc73192bec2ed5a25b0f146..d34939a15dc295be2f441e2084138dca75299604 100644 (file)
@@ -160,7 +160,7 @@ pianoLH =  \relative c'' \repeat volta 2 {
           \lyricsto "singer" \new Lyrics \firstVerse
           \lyricsto "singer" \new Lyrics \secondVerse
           \new PianoStaff << 
-              \set PianoStaff.instrument = \markup {
+              \set PianoStaff.instrumentName = \markup {
                   \bold
                   \bigger\bigger\bigger\bigger \huge "2.  " }
               \new Staff \pianoRH
@@ -186,7 +186,10 @@ pianoLH =  \relative c'' \repeat volta 2 {
            }
        }
        \midi {
-           \tempo 4 = 70
+         \context {
+           \Score
+           tempoWholesPerMinute = #(ly:make-moment 70 4)
+         }
        }
     }
 }
index 22406fd1e6c8f75c431971375644890e1351f378..38ee277e1bddfb81de2f3227d7db2874ebc46542 100644 (file)
@@ -219,7 +219,10 @@ bassdux = \context Voice = "three"  \relative c' {
        }
        \layout {}
        \midi {
-           \tempo 4 =84
+         \context {
+           \Score
+           tempoWholesPerMinute = #(ly:make-moment 84 4)
+         }
        }
     }
     \paper {
index 90d4a4ac02a10ee3a61501d32cd53694e2dd4fb7..3a8728694cf3f020818b11494a03a917228250bf 100644 (file)
@@ -61,7 +61,11 @@ Binary_source_file::get_line (char const *pos_str0) const
 U8
 Binary_source_file::get_U8 ()
 {
+#if 0                          // FIXME
   return *(U8 *)forward_str0 (1);
+#endif
+  assert (false);
+  return 0;
 }
 
 U16
index f15a1ab1413e0c0f9e1b74617ee887a9c1503e21..b856486dba4900e3fd7bd158ea4fb32943b233e7 100644 (file)
@@ -262,13 +262,6 @@ Context_def::instantiate (SCM ops, Object_key const *key)
   return context;
 }
 
-SCM
-Context_def::clone_scm () const
-{
-  Context_def *t = new Context_def (*this);
-  return t->unprotect ();
-}
-
 SCM
 Context_def::make_scm ()
 {
index df69f257dd6f1a62bfec6ab46a2901bc22cbb087..a92ad4fee53e352c8c650018e0ffbab884c78caf 100644 (file)
@@ -43,6 +43,8 @@ public:
   SCM get_translator_group_type () const { return translator_group_type_; }
   void set_acceptor (SCM accepts, bool add);
 
+  VIRTUAL_COPY_CONSTRUCTOR(Context_def, Context_def);
+
   vector<Context_def*> path_to_acceptable_context (SCM type_string,
                                                      Output_def *) const;
   Context *instantiate (SCM extra_ops, Object_key const *);
@@ -50,7 +52,6 @@ public:
   SCM to_alist () const;
   static SCM make_scm ();
 
-  SCM clone_scm () const;
   void apply_default_property_operations (Context *);
 
 private:
index e211dc15c3f5dda4b323797ef77e76d55580c1e2..f7224ec7d342f8fcd000f9be53b875e98fe262d5 100644 (file)
@@ -20,7 +20,6 @@ class Input
   char const *start_;
   char const *end_;
   Source_file *source_file_;
-
 public:
   Source_file *get_source_file () const;
   char const *start () const;
index 2475b8ca751daebe3db6e80163dc75013dd2b378..99c09fc0435f3e51792fd3966bc507c88235d81d 100644 (file)
@@ -74,8 +74,8 @@
     void                                                               \
   CL::smobify_self ()                                                  \
   {                                                                    \
-    self_scm_ = unprotected_smobify_self ();                           \
     protection_cons_ = SCM_EOL;                                                \
+    self_scm_ = unprotected_smobify_self ();                           \
     protect ();                                                                \
   }                                                                    \
   void                                                                 \
@@ -86,7 +86,7 @@
   SCM                                                                  \
   CL::unprotect ()                                                     \
   {                                                                    \
-    unprotect_smob (&protection_cons_);                                        \
+    unprotect_smob (self_scm_, &protection_cons_);                     \
     return self_scm_;                                                  \
   }                                                                    \
   SCM                                                                  \
index 7d5563d4743487118d0f45792b9c9507c8031af3..de190a7c86ff07174fe5a75500ee51c28acd9b89 100644 (file)
@@ -67,9 +67,6 @@ SCM get_font_table (Output_def *def);
 void assign_context_def (Output_def *m, SCM transdef);
 SCM find_context_def (Output_def const *m, SCM name);
 
-int get_tempo (Output_def*def, Moment moment);
-void set_tempo (Output_def*def, Moment moment, int count_per_minute_i);
-
 Interval line_dimensions_int (Output_def*def, int);
  
 
index f5c1256a22eed053387d7a70338accea6187d331..b12a73c58680d93c22256f7eff2eaf7ffbef702b 100644 (file)
@@ -21,7 +21,6 @@ public:
   void do_announces ();
   virtual void announce_element (Audio_element_info);
   virtual void play_element (Audio_element *p);
-  virtual int get_tempo () const;
 
 protected:
   vector<Audio_element_info> announce_infos_;
index 658a822b03ec66f5994a80aefa70d87f1dd20111..b97cea1926e4e24e45cdc3d07a2746066506a9cf 100644 (file)
@@ -25,7 +25,6 @@ protected:
   virtual void announce_element (Audio_element_info);
   virtual void acknowledge_audio_element (Audio_element_info);
   virtual void create_audio_elements ();
-  virtual int get_tempo () const;
   virtual void play_element (Audio_element *elem);
 };
 
index 0987ef7d686ff5873e8f8a4f6beb375ac8deb32f..32344aa3a9d701cc5e4a71909cfef607ca86f37b 100644 (file)
@@ -32,7 +32,6 @@ protected:
   virtual void disconnect_from_context ();
   virtual void initialize ();
   virtual void announce_element (Audio_element_info);
-  virtual int get_tempo () const;
   virtual void play_element (Audio_element *p);
   virtual void derived_mark () const;
 private:
index be08a073b0f072983d2ecb630adc9f9cf9c72b6a..dd384786edc3bc61696f70563aaea19faf5bff76 100644 (file)
 #define DECLARE_TYPE_P(CL) extern SCM CL ## _type_p_proc
 
 void protect_smob (SCM smob, SCM *prot_cons);
-void unprotect_smob (SCM *prot_cons);
+void unprotect_smob (SCM smob, SCM *prot_cons);
 
 #endif /* SMOBS_HH */
 
index 33b4051c4cc2e97190429acc3d1a1f7148d7f59a..05fd73359fe4db7b47145602f97249f874fecf58 100644 (file)
@@ -12,7 +12,7 @@
 #include "flower-proto.hh"
 #include "std-vector.hh"
 #include "lily-proto.hh"
-#include "protected-scm.hh"
+#include "smobs.hh"
 
 #include <iostream>
 using namespace std;
@@ -27,12 +27,21 @@ using namespace std;
 
 class Source_file
 {
+  vector<char*> newline_locations_;
+  istream *istream_;
+  vector<char> characters_;
+  SCM str_port_;
+
+  char const *contents_str0 () const;
+  void load_stdin ();
+  void init_port ();
+  void init ();
+  
+  DECLARE_SMOBS(Source_file, bla);
 public:
   Source_file (string fn);
   Source_file (string, string);
 
-  virtual ~Source_file ();
-
   char const *c_str () const;
   virtual string quote_input (char const *pos_str0) const;
   istream *get_istream ();
@@ -43,46 +52,19 @@ public:
   string name_string () const;
   string file_line_column_string (char const *str0) const;
 
-  // return start + n
-  char const *seek_str0 (int n);
-
-  int tell () const;
-  // return here + n bytes
-  char const *forward_str0 (int n);
-  char const *pos_str0 () { return pos_str0_; }
-  string get_string (int n);
-  void set_pos (char const *pos_str0);
 public:
   Slice line_slice (char const *pos_str0) const;
   string line_string (char const *pos_str0) const;
   void get_counts (char const *pos_str0, int *, int *, int *) const;
-
-  /*
-    JUNKME.
-
-    This thing doubles as a file-storage/file-iterator object.
-  */
-  char const *pos_str0_;
-
+  
   SCM get_port () const;
   string name_;
 
 protected:
   int line_offset_;
-
-private:
-  vector<char*> newline_locations_;
-  istream *istream_;
-  char *contents_str0_;
-  vector<char> chs_;
-  int length_;
-  void load_stdin ();
-  void init_port ();
-
-  Protected_scm str_port_;
 };
 
-char *gulp_file (string fn, int *len);
+vector<char> gulp_file (string fn, int desired);
 
 #endif /* SOURCE_FILE_HH */
 
index e3bc5d275d8f90907351184820cf01091c4cf971..72b293f10c09c3bf968e5433c45815dc656eb501 100644 (file)
@@ -7,7 +7,7 @@
 */
 
 #include "input-smob.hh"
-
+#include "source-file.hh"
 #include "std-string.hh"
 
 #include "ly-smobs.icc"
@@ -18,8 +18,13 @@ Input dummy_input_global;
 static long input_tag;
 
 static
-SCM mark_smob (SCM)
+SCM mark_smob (SCM s)
 {
+  Input *sc = (Input *) SCM_CELL_WORD_1 (s);
+
+  if (Source_file *sf = sc->get_source_file ())
+    return sf->self_scm ();
+
   return SCM_EOL;
 }
 
index 2fd018ff1b2afa0ee6846d385057e7ff58ef3534..98332a1eb3679fe26fb07d619ed37a2c90f1b9f1 100644 (file)
@@ -338,7 +338,7 @@ BOM_UTF8    \357\273\277
        }
                
        yylval.scm = sval;
-       return SCM_T;
+       return SCM_TOKEN;
 }
 <INITIAL,notes,lyrics>{ 
        \<\<    {
@@ -912,7 +912,7 @@ static void init_signature_hash_table ()
        };
 
        for (int i = 0; sigs[i].symbol; i++)
-               scm_hashq_set_x (signature_hash_table, scm_gc_protect_object (ly_symbol2scm (sigs[i].symbol)),
+               scm_hashq_set_x (signature_hash_table, ly_symbol2scm (sigs[i].symbol),
                                 scm_from_int (sigs[i].token_type));
 }
 
index f7938cfc210643a57993e34fbaf54e16fef3cc6a..971063e54ec382c823785f5833e5caa61f99df34 100644 (file)
@@ -105,10 +105,8 @@ gulp_file_to_string (string fn, bool must_exist, int size)
   if (be_verbose_global)
     progress_indication ("[" + s);
 
-  int n = size;
-  char *str = gulp_file (s, &n);
-  string result (str, n);
-  delete[] str;
+  vector<char> chars = gulp_file (s, size);
+  string result (&chars[0], chars.size ());
 
   if (be_verbose_global)
     progress_indication ("]");
index 40be81e22181a15f51b3505c49fdb9b67b900162..cfae9a5ee87c4f0cba3e124df239e78c3de013b6 100644 (file)
@@ -85,10 +85,10 @@ Metronome_mark_engraver::process_music ()
                               context ()->self_scm ());
 
       text_->set_property ("text", result);
-
-      last_duration_ = duration;
-      last_count_ = count;
     }
+
+  last_duration_ = duration;
+  last_count_ = count;
 }
 
 #include "translator.icc"
index c3b80dbeae332a60a1a71eeb5c51e498104aca39..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,46 +0,0 @@
-/*
-  midi-def.cc -- implement midi output def functions
-
-  source file of the GNU LilyPond music typesetter
-
-  (c) 1997--2006 Jan Nieuwenhuizen <janneke@gnu.org>
-*/
-
-
-#include "misc.hh"
-#include "output-def.hh"
-#include "moment.hh"
-#include "warn.hh"
-#include "scm-hash.hh"
-
-int
-get_tempo (Output_def *def,
-          Moment one_beat_mom)
-{
-  SCM wis = ly_symbol2scm ("whole-in-seconds");
-  Moment *w = unsmob_moment (def->lookup_variable (wis));
-
-  Moment wholes_per_min = Moment (60);
-  if (!w)
-    {
-      programming_error ("wholes-in-seconds not set.");
-      wholes_per_min /= 4;
-    }
-  else
-    wholes_per_min /= *w;
-
-  Rational beats_per_min =  (wholes_per_min / one_beat_mom).main_part_;
-  return beats_per_min.to_int ();
-}
-
-void
-set_tempo (Output_def *def,
-          Moment one_beat_mom,
-          int beats_per_minute_i)
-{
-  Moment beats_per_second = Moment (beats_per_minute_i) / Moment (60);
-
-  Moment m = Moment (1) / Moment (beats_per_second * one_beat_mom);
-  def->set_variable (ly_symbol2scm ("whole-in-seconds"), m.smobbed_copy ());
-}
-
index 7c04cb0c262f46160f64e10044a6a2f92f29eb55..c9dbb79f980f3c50b393b80135c7b2a4bcce1a96 100644 (file)
@@ -250,7 +250,6 @@ If we give names, Bison complains.
 %token CHORDMODIFIERS
 %token LYRIC_MARKUP
 %token MULTI_MEASURE_REST
-%token SCM_T
 
 
 %token <i> DIGIT
@@ -301,7 +300,7 @@ If we give names, Bison complains.
 %token <scm> REAL
 %token <scm> RESTNAME
 %token <scm> SCM_IDENTIFIER
-%token <scm> SCM_T
+%token <scm> SCM_TOKEN
 %token <scm> SCORE_IDENTIFIER
 %token <scm> STRING
 %token <scm> STRING_IDENTIFIER
@@ -504,7 +503,7 @@ toplevel_expression:
        ;
 
 embedded_scm:
-       SCM_T
+       SCM_TOKEN
        | SCM_IDENTIFIER
        ;
 
@@ -535,15 +534,6 @@ assignment_id:
 
 assignment:
        assignment_id '=' identifier_init  {
-               if (! is_regular_identifier ($1))
-               {
-#if 0
-                       /* no longer valid with dashes in \paper{} block. */ 
-                       @1.warning (_ ("identifier should have alphabetic characters only"));
-#endif
-               }
-
-
                PARSER->lexer_->set_identifier ($1, $3);
 
 /*
@@ -2360,17 +2350,26 @@ Lily_lexer::try_special_identifiers (SCM *destination, SCM sid)
                *destination = sid;
                return STRING_IDENTIFIER;
        } else if (unsmob_book (sid)) {
-               *destination = unsmob_book (sid)->clone ()->self_scm ();
+               Book *book =  unsmob_book (sid)->clone ();
+               *destination = book->self_scm ();
+               book->unprotect ();
+
                return BOOK_IDENTIFIER;
        } else if (scm_is_number (sid)) {
                *destination = sid;
                return NUMBER_IDENTIFIER;
        } else if (unsmob_context_def (sid)) {
-               *destination = unsmob_context_def (sid)->clone_scm ();
+               Context_def *def= unsmob_context_def (sid)->clone ();
+
+               *destination = def->self_scm ();
+               def->unprotect ();
+               
                return CONTEXT_DEF_IDENTIFIER;
        } else if (unsmob_score (sid)) {
                Score *score = new Score (*unsmob_score (sid));
                *destination = score->self_scm ();
+
+               score->unprotect ();
                return SCORE_IDENTIFIER;
        } else if (Music *mus = unsmob_music (sid)) {
                mus = mus->clone ();
@@ -2381,6 +2380,7 @@ Lily_lexer::try_special_identifiers (SCM *destination, SCM sid)
                bool is_event = scm_memq (ly_symbol2scm ("event"), mus->get_property ("types"))
                        != SCM_BOOL_F;
 
+               mus->unprotect ();
                return is_event ? EVENT_IDENTIFIER : MUSIC_IDENTIFIER;
        } else if (unsmob_duration (sid)) {
                *destination = unsmob_duration (sid)->smobbed_copy ();
@@ -2388,8 +2388,9 @@ Lily_lexer::try_special_identifiers (SCM *destination, SCM sid)
        } else if (unsmob_output_def (sid)) {
                Output_def *p = unsmob_output_def (sid);
                p = p->clone ();
-
+       
                *destination = p->self_scm ();
+               p->unprotect ();
                return OUTPUT_DEF_IDENTIFIER;
        } else if (Text_interface::is_markup (sid)) {
                *destination = sid;
index f765a3193772b021c0bcda98209810b2f676753e..35d47e2ebc4869a3839771d15905e36430de77ab 100644 (file)
@@ -129,12 +129,6 @@ Performance::output_header_track (Midi_stream &midi_stream)
   Midi_text track_name (&track_name_a);
 
   midi_track.add (Moment (0), &track_name);
-
-  // Some sequencers read track 0 last.
-  //  Audio_tempo tempo_a (midi_->get_tempo (Moment (Rational (1, 4))));
-  //  Midi_tempo tempo (&tempo_a);
-  //  midi_track.add (Moment (0), &tempo);
-
   midi_stream << midi_track;
 }
 
index 9e71c6e7629c4ec817db3ca75bbea04fa337832c..990f478bf823f5395ec2715d90912342d0b228b3 100644 (file)
@@ -96,15 +96,3 @@ Performer_group::play_element (Audio_element *e)
     }
 }
 
-int
-Performer_group::get_tempo () const
-{
-  Context *c = context_->get_parent_context ();
-  if (c)
-    {
-      Performer_group *pgp = dynamic_cast<Performer_group *> (c->implementation ());
-      return pgp->get_tempo ();
-    }
-  return 60;
-}
-
index af896f23dd9ee60938e1337d9bac9b1cb5dc082e..28726bc7ef1bfa995ae0d1e6d50607870fbb19ff 100644 (file)
@@ -17,12 +17,6 @@ Performer::play_element (Audio_element *p)
   get_daddy_performer ()->play_element (p);
 }
 
-int
-Performer::get_tempo () const
-{
-  return get_daddy_performer ()->get_tempo ();
-}
-
 Performer_group *
 Performer::get_daddy_performer () const
 {
index 678e480b90f6a693e318bcdb3bf1d76ffd948e00..a96aac7761deb7518e5c69e6c6132463b5ee5a16 100644 (file)
@@ -78,17 +78,16 @@ LY_DEFINE (ly_pfb_to_pfa, "ly:pfb->pfa",
                   SCM_ARG1, __FUNCTION__, "string");
 
   string file_name = ly_scm2string (pfb_file_name);
-  int len = -1;
 
   if (be_verbose_global)
     progress_indication ("[" + file_name);
   
-  char *str = gulp_file (file_name, &len);
-  char *pfa = pfb2pfa ((Byte *)str, len);
-
+  vector<char> pfb_string = gulp_file (file_name, 0);
+  char *pfa = pfb2pfa ((Byte *) &pfb_string[0], pfb_string.size ());
+  
   SCM pfa_scm = scm_makfrom0str (pfa);
   free (pfa);
-  delete str;
+
   if (be_verbose_global)
     progress_indication ("]");
 
index 5a1caca15508fe0e6cc0a5ce7ed86da6eba782f3..2640bdf87094076079449ee50fe820d3169f7d2e 100644 (file)
@@ -25,6 +25,7 @@ Prob::Prob (SCM type, SCM immutable_init)
   smobify_self ();
 }
 
+
 Prob::~Prob ()
 {
 }
index a0b0c7d17e4c44120df756404628d047d59cece1..7252b0cff7832c11ce56296d51612bc842981a37 100644 (file)
@@ -124,12 +124,6 @@ Score_performer::one_time_step (SCM)
   precomputed_recurse_over_translators (context (), STOP_TRANSLATION_TIMESTEP, UP);
 }
 
-int
-Score_performer::get_tempo () const
-{
-  return ::get_tempo (performance_->midi_, Moment (Rational (1, 4)));
-}
-
 void
 Score_performer::derived_mark () const
 {
index a6fdc76b9e754ee306802d4d4c213f91960e0e31..9629ed45ee610702f2d3e4b1024b56be9e3ac693 100644 (file)
 /*
   The CDR contains the actual protected list.
  */
-static SCM smob_protection_list;
+static SCM smob_protection_list = SCM_EOL;
 
 void
 init_smob_protection ()
 {
-  smob_protection_list = scm_cons (SCM_UNDEFINED, SCM_EOL);
-  scm_permanent_object (smob_protection_list);
+  smob_protection_list = scm_cons (SCM_BOOL_F, SCM_EOL);
+  scm_gc_protect_object (smob_protection_list);
 }
 ADD_SCM_INIT_FUNC (init_smob_protection, init_smob_protection);
 
 LY_DEFINE(ly_smob_protects, "ly:smob-protects",
-         0,0,0, (),
+         0, 0, 0, (),
          "Return lily's internal smob protection list")
 {
-  return scm_cdr (smob_protection_list);
+  return scm_is_pair (smob_protection_list)
+    ? scm_cdr (smob_protection_list)
+    : SCM_EOL;
 }
 
-         
-         
-
 void
 protect_smob (SCM smob, SCM *prot_cons)
 {
+#if 0
   SCM s = scm_cdr (smob_protection_list);
-  while (scm_is_pair (s) && scm_car (s) == SCM_UNDEFINED)
-    s = scm_cdr (s);
-
+  while (scm_is_pair (s) && scm_car (s) == SCM_BOOL_F)
+    {
+      s = scm_cdr (s);
+    }
   SCM prot = scm_cons (smob, s);
   scm_set_cdr_x (smob_protection_list,
                 prot);
   *prot_cons = prot;
+#else
+  scm_gc_protect_object (smob);
+#endif
 }
 
 void
-unprotect_smob (SCM *prot_cons)
+unprotect_smob (SCM smob, SCM *prot_cons)
 {
+#if 1
+  scm_gc_unprotect_object (smob);
+#else
   SCM next = scm_cdr (*prot_cons);
 
   if (next == SCM_EOL)
-    scm_set_car_x (*prot_cons, SCM_UNDEFINED);
+    scm_set_car_x (*prot_cons, SCM_BOOL_F);
   else
     {
-      scm_set_car_x (*prot_cons, SCM_UNDEFINED);
+      scm_set_car_x (*prot_cons, SCM_BOOL_F);
       while (scm_is_pair (next)
-            && scm_car (next) == SCM_UNDEFINED)
+            && scm_car (next) == SCM_BOOL_F)
 
        next = scm_cdr (next);
 
@@ -63,4 +70,5 @@ unprotect_smob (SCM *prot_cons)
     }
 
   *prot_cons = SCM_EOL;
+#endif
 }
index b44066f2673b8e598a63703624a67c661c1a3c34..cfa66b628f738d55b2f677d92535e7667a4d4563 100644 (file)
@@ -34,19 +34,16 @@ using namespace std;
 void
 Source_file::load_stdin ()
 {
-  length_ = 0;
-  chs_.clear ();
+  characters_.clear ();
   int c;
   while ((c = fgetc (stdin)) != EOF)
-    chs_.push_back (c);
+    characters_.push_back (c);
 
-  chs_.push_back (0);
-  length_ = chs_.size ();
-  contents_str0_ = &chs_[0];
+  characters_.push_back (0);
 }
 
-char *
-gulp_file (string filename, int *filesize)
+vector<char>
+gulp_file (string filename, int desired_size)
 {
   /* "b" must ensure to open literally, avoiding text (CR/LF)
      conversions.  */
@@ -54,15 +51,17 @@ gulp_file (string filename, int *filesize)
   if (!f)
     {
       warning (_f ("can't open file: `%s'", filename.c_str ()));
-      return 0;
+
+      vector<char> cxx_arr;
+      return cxx_arr;
     }
 
   fseek (f, 0, SEEK_END);
   int real_size = ftell (f);
   int read_count = real_size;
 
-  if (*filesize >= 0)
-    read_count = min (read_count, *filesize);
+  if (desired_size > 0)
+    read_count = min (read_count, desired_size);
   
   rewind (f);
 
@@ -74,62 +73,81 @@ gulp_file (string filename, int *filesize)
     warning (_f ("expected to read %d characters, got %d", bytes_read,
                 read_count));
   fclose (f);
-  *filesize = bytes_read;
-  return str;
+  int filesize = bytes_read;
+
+  vector<char> cxx_arr;
+  cxx_arr.resize (filesize);
+
+  /* ugh, how to do neatly in STL? */
+  memcpy (&cxx_arr[0], str, filesize);
+  
+  free (str);
+  return cxx_arr;
 }
 
-Source_file::Source_file (string filename, string data)
+char const * 
+Source_file::contents_str0 () const
+{
+  return &characters_[0];
+}
+
+void
+Source_file::init ()
 {
-  name_ = filename;
   istream_ = 0;
   line_offset_ = 0;
-  length_ = data.length ();
-  contents_str0_ = string_copy (data);
-  pos_str0_ = c_str ();
+  str_port_ = SCM_EOL;
+  self_scm_ = SCM_EOL;
+  smobify_self ();
+}
+
+Source_file::Source_file (string filename, string data)
+{
+  init ();
+  
+  name_ = filename;
+
+  characters_.resize (data.length ());
+  /* ugh, how to do neatly in STL? */
+  memcpy ((&characters_[0]), data.c_str (), data.length ());
+  
   init_port ();
 
-  for (int i = 0; i < length_; i++)
-    if (contents_str0_[i] == '\n')
-      newline_locations_.push_back (contents_str0_ + i);
+  for (vsize i = 0; i < characters_.size (); i++)
+    if (characters_[i] == '\n')
+      newline_locations_.push_back (&characters_[0] + i);
 }
 
 Source_file::Source_file (string filename_string)
 {
+  init ();
+  
   name_ = filename_string;
-  istream_ = 0;
-  line_offset_ = 0;
-  contents_str0_ = 0;
 
   if (filename_string == "-")
     load_stdin ();
   else
     {
-      length_ = -1;
-      contents_str0_ = gulp_file (filename_string, &length_);
+      characters_ = gulp_file (filename_string, -1);
+      characters_.push_back (0);
     }
-  
-  pos_str0_ = c_str ();
 
   init_port ();
 
-  for (int i = 0; i < length_; i++)
-    if (contents_str0_[i] == '\n')
-      newline_locations_.push_back (contents_str0_ + i);
+  for (vsize i = 0; i < characters_.size (); i++)
+    if (characters_[i] == '\n')
+      newline_locations_.push_back (&characters_[0] + i);
 }
 
 void
 Source_file::init_port ()
 {
-  SCM str = scm_makfrom0str (contents_str0_);
+  SCM str = scm_makfrom0str (contents_str0 ());
   str_port_ = scm_mkstrport (SCM_INUM0, str, SCM_OPN | SCM_RDNG, __FUNCTION__);
   scm_set_port_filename_x (str_port_, scm_makfrom0str (name_.c_str ()));
 }
 
-int
-Source_file::tell () const
-{
-  return pos_str0_ - contents_str0_;
-}
 
 istream *
 Source_file::get_istream ()
@@ -189,7 +207,6 @@ Source_file::~Source_file ()
 {
   delete istream_;
   istream_ = 0;
-  delete[] contents_str0_;
 }
 
 Slice
@@ -346,60 +363,48 @@ Source_file::set_line (char const *pos_str0, int line)
 int
 Source_file::length () const
 {
-  return length_;
+  return characters_.size ();
 }
 
 char const *
 Source_file::c_str () const
 {
-  return contents_str0_;
+  return &characters_[0];
 }
 
-void
-Source_file::set_pos (char const *pos_str0)
+SCM
+Source_file::get_port () const
 {
-  if (contains (pos_str0))
-    pos_str0_ = pos_str0;
-  else
-    error (quote_input (pos_str0) + "invalid pos");
+  return str_port_;
 }
 
-char const *
-Source_file::seek_str0 (int n)
-{
-  char const *new_str0 = c_str () + n;
-  if (n < 0)
-    new_str0 += length ();
-  if (contains (new_str0))
-    pos_str0_ = new_str0;
-  else
-    error (quote_input (new_str0) + "seek past eof");
+/****************************************************************/
 
-  return pos_str0_;
-}
+#include "ly-smobs.icc"
 
-char const *
-Source_file::forward_str0 (int n)
+IMPLEMENT_SMOBS(Source_file);
+IMPLEMENT_DEFAULT_EQUAL_P(Source_file);
+IMPLEMENT_TYPE_P(Source_file, "ly:source-file?");
+
+SCM
+Source_file::mark_smob (SCM smob)
 {
-  char const *old_pos = pos_str0_;
-  char const *new_str0 = pos_str0_ + n;
-  if (contains (new_str0))
-    pos_str0_ = new_str0;
-  else
-    error (quote_input (new_str0) + "forward past eof");
+  Source_file *sc = (Source_file *) SCM_CELL_WORD_1 (smob);
 
-  return old_pos;
+  return sc->str_port_;
 }
 
-string
-Source_file::get_string (int n)
-{
-  string str = string ((char const *)forward_str0 (n), n);
-  return str;
-}
 
-SCM
-Source_file::get_port () const
+int
+Source_file::print_smob (SCM smob, SCM port, scm_print_state *)
 {
-  return str_port_;
+  Source_file *sc = (Source_file *) SCM_CELL_WORD_1 (smob);
+
+  scm_puts ("#<Source_file ", port);
+  scm_puts (sc->name_.c_str (), port);
+
+  /* Do not print properties, that is too much hassle.  */
+  scm_puts (" >", port);
+  return 1;
 }
+
index 002768038c0069a8b33fd2f649dfc35c72655a24..9d978d4fae93d9b5e20e8b86fed9f6daa7b331ba 100644 (file)
@@ -58,7 +58,10 @@ Sources::add (Source_file *sourcefile)
 
 Sources::~Sources ()
 {
-  junk_pointers (sourcefiles_);
+  for (vsize i = 0; i < sourcefiles_.size (); i++)
+    {
+      sourcefiles_[i]->unprotect ();
+    }
 }
 
 Source_file *
index b8facd23645e3abbad7fe2bb0a625ff08097a0ac..54a57b94515fa72d5be2ce7d7e51fcdba307e478 100644 (file)
@@ -64,7 +64,13 @@ Staff_performer::initialize ()
 {
   audio_staff_ = new Audio_staff;
   name_ = new Audio_text (Audio_text::TRACK_NAME, context ()->id_string ());
-  tempo_ = new Audio_tempo (get_tempo ());
+
+  Rational r = robust_scm2moment (get_property ("tempoWholesPerMinute"),
+                                 Moment (15,1)).main_part_;
+
+  r *= Rational (4,1);
+  
+  tempo_ = new Audio_tempo (r.to_int ());
 
   audio_staff_->add_audio_item (name_);
   audio_staff_->add_audio_item (tempo_);
index b41630113470c4bc794137e0e1407a1a95e0ad54..58e5b124d3f54ff1c3ac2c808302056c48d7e9fd 100644 (file)
@@ -58,8 +58,12 @@ Tex_font_metric_reader::get_U32_fix_scaled ()
 string
 Tex_font_metric_reader::get_bcpl_string ()
 {
-  U8 length_u8 = input_.get_U8 ();
+ string str;
+#if 0                          // FIXME.
+ U8 length_u8 = input_.get_U8 ();
   string str = input_.get_string (length_u8);
+#endif
   return str;
 }
 
@@ -131,8 +135,12 @@ Tex_font_metric_reader::read_params ()
 
   //brrr
   /* Move to the beginning of the parameter table in the file.  */
-  input_.seek_str0 (-4 * header_.param_word_count);
 
+#if 0
+  // FIXME.
+  input_.seek_str0 (-4 * header_.param_word_count);
+#endif
+  
   /* It's unlikely but possible that this TFM file has more fontdimens
      than we can deal with.  */
   if (header_.param_word_count > TFM_MAX_FONTDIMENS)
@@ -181,10 +189,12 @@ Tex_font_metric_reader::read_char_metric (Char_code code)
   if (code < info_.first_charcode || code > info_.last_charcode)
     return tfm_char;
 
+#if 0                          // FIXME.
   //brr
   /* Move to the appropriate place in the `char_info' array.  */
   input_.seek_str0 (header_.char_info_pos + (code - info_.first_charcode) * 4);
-
+#endif
+  
   /* Read the character.  */
   tfm_char = read_char ();
 
@@ -217,10 +227,11 @@ Tex_font_metric_reader::read_char ()
 
   Tex_font_char_metric tfm_char;
 
+  // FIXME.
 #define GET_CHAR_DIMEN(d)                                      \
   if (d##_index != 0)                                          \
     {                                                          \
-      input_.seek_str0 (header_.d##_pos + d##_index * 4);      \
+      /* input_.seek_str0 (header_.d##_pos + d##_index * 4);*/ \
       tfm_char.d##_fix_ = input_.get_U32 ();                   \
       tfm_char.d##_ = fix_to_real (tfm_char.d##_fix_)          \
        * info_.design_size;                                    \
@@ -239,7 +250,9 @@ Tex_font_metric_reader::read_char ()
 
   if (tag == 1)
     {
+#if 0                  //  FIXME.
       input_.seek_str0 (header_.lig_kern_pos + remainder * 4);
+#endif
       read_lig_kern_program (&tfm_char.ligatures_, &tfm_char.kerns_);
     }
 
@@ -272,10 +285,15 @@ Tex_font_metric_reader::read_lig_kern_program (vector<Tfm_ligature> *ligatures,
          Tfm_kern kern_element;
          kern_element.character = next_char;
 
+#if 0 
          char const *old_pos = input_.pos_str0 ();
          input_.seek_str0 (header_.kern_pos + remainder * 4);
+#endif
+         
          kern_element.kern = get_U32_fix_scaled ();
-         input_.set_pos (old_pos);
+
+         // FIXME
+         ///     input_.set_pos (old_pos);
 
          kerns->push_back (kern_element);
        }
index 3f10e386fb1f973ee98d368882bc946b40546efd..4eed7ace8b9c22f58a471e11d973d471974c52f1 100644 (file)
@@ -2834,8 +2834,8 @@ conversions.append (((2, 9, 13), conv, """instrument -> instrumentName, instr ->
 
 
 def conv (str):
-    m = re.search (r'\\tempo ([0-9]+)\s*([.]*)\s*=\s*([0-9]+)', str)
-    if m and re.search (r'\\midi', str):
+
+    def sub_tempo (m):
         dur = int (m.group (1))
         dots = len (m.group (2))
         count = int (m.group (3))
@@ -2848,10 +2848,7 @@ def conv (str):
         den = (1 << dots) * (1 << log2)
         num = ((1 << (dots+1))  - 1)
 
-        error_file.write (r"""
-
-\tempo in \midi is no longer supported. Use
-
+        return  """
   \midi {
     \context {
       \Score
@@ -2859,8 +2856,9 @@ def conv (str):
       }
     }
 
-""" % (num*count, den))
-        
+""" % (num*count, den)
+    
+    str = re.sub (r'\\midi\s*{\s*\\tempo ([0-9]+)\s*([.]*)\s*=\s*([0-9]+)\s*}', sub_tempo, str)
     return str
 
 conversions.append (((2, 9, 16), conv, """deprecate \\tempo in \\midi"""))