]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-0.1.11
authorfred <fred>
Sun, 24 Mar 2002 19:55:46 +0000 (19:55 +0000)
committerfred <fred>
Sun, 24 Mar 2002 19:55:46 +0000 (19:55 +0000)
lib/binary-source-file.cc
lib/duration.cc
lib/input.cc
lib/plet.cc
lib/source-file.cc
lib/windhoos-suck-suck-suck-thank-you-cygnus.cc
lily/bar-grav.cc
lily/engraver-group.cc
lily/engraver.cc
lily/timing-grav.cc

index 8c4aac44741aeb2cf7716848fab5b1830ca4fcfb..306ca9785547dd62495d86e6c10c1e734fc257d2 100644 (file)
@@ -17,8 +17,8 @@
 #include "binary-source-file.hh"
 #include "string-convert.hh"
 
-Binary_source_file::Binary_source_file( String& filename_str )
-       : Source_file( filename_str )
+Binary_source_file::Binary_source_file(String& filename_str)
+       : Source_file(filename_str)
 {
 }
 
@@ -27,35 +27,35 @@ Binary_source_file::~Binary_source_file()
 }
 
 String
-Binary_source_file::error_str( char const* pos_ch_c_l ) const
+Binary_source_file::error_str(char const* pos_ch_c_l) const
 {
-    assert( this );
-    if ( !in_b( pos_ch_c_l ) )
+    assert(this);
+    if (!in_b(pos_ch_c_l))
        return "";
 
     char const* begin_ch_c_l = pos_ch_c_l - 8 >? ch_C();
     char const* end_ch_c_l = pos_ch_c_l + 7 <? ch_C() + length_i();
 
-    String pre_str( (Byte const*)begin_ch_c_l, pos_ch_c_l - begin_ch_c_l );
-    pre_str = String_convert::bin2hex_str( pre_str );
-    for ( int i = 2; i < pre_str.length_i(); i += 3 )
-       pre_str = pre_str.left_str( i ) + " " + pre_str.mid_str( i, INT_MAX );
-    String post_str( (Byte const*)pos_ch_c_l, end_ch_c_l - pos_ch_c_l );
-    post_str = String_convert::bin2hex_str( post_str );
-    for ( int i = 2; i < post_str.length_i(); i += 3 )
-       post_str = post_str.left_str( i ) + " " + post_str.mid_str( i, INT_MAX );
+    String pre_str((Byte const*)begin_ch_c_l, pos_ch_c_l - begin_ch_c_l);
+    pre_str = String_convert::bin2hex_str(pre_str);
+    for (int i = 2; i < pre_str.length_i(); i += 3)
+       pre_str = pre_str.left_str(i) + " " + pre_str.mid_str(i, INT_MAX);
+    String post_str((Byte const*)pos_ch_c_l, end_ch_c_l - pos_ch_c_l);
+    post_str = String_convert::bin2hex_str(post_str);
+    for (int i = 2; i < post_str.length_i(); i += 3)
+       post_str = post_str.left_str(i) + " " + post_str.mid_str(i, INT_MAX);
 
     String str = pre_str
-       + String( '\n' )
-       + String( ' ', pre_str.length_i() + 1 
+       + String('\n')
+       + String(' ', pre_str.length_i() + 1
        + post_str;
     return str;
 }
 
 int
-Binary_source_file::line_i( char const* pos_ch_c_l ) const
+Binary_source_file::line_i(char const* pos_ch_c_l) const
 {
-    if ( !in_b( pos_ch_c_l ) )
+    if (!in_b(pos_ch_c_l))
        return 0;
 
     return pos_ch_c_l - ch_C();
index 24ae6b5da69ad6f38275c649db1dad4a3d3b7212..f04c5e42c05b6a4744d91f805aa5f55b9df4fd03 100644 (file)
@@ -34,7 +34,7 @@ Duration::duration_type_b(int t)
   /*
     ugh. Assuming behavior of conversion funcs on broken input.
    */
-  return t == Duration_convert::type2_i( Duration_convert::i2_type(t));
+  return t == Duration_convert::type2_i(Duration_convert::i2_type(t));
 }
 
 // ugh, what's this?
@@ -60,15 +60,15 @@ Duration::set_plet(Duration d)
 }
 
 void
-Duration::set_ticks( int ticks_i )
+Duration::set_ticks(int ticks_i)
 {
-  assert( durlog_i_ <10 );
-  assert( !dots_i_ );
+  assert(durlog_i_ <10);
+  assert(!dots_i_);
   ticks_i_ = ticks_i;
 }
 
 String
-Duration::str()const
+Duration::str() const
 {
   return Duration_convert::dur2_str(*this);
 }
index 6f05290422b128aae18787e0f00495395e091121..3ef073cb39620a3fadeb018d4c5b1803379c818d 100644 (file)
@@ -36,37 +36,37 @@ Input::set_spot(Input const &i)
 }
 
 void
-Input::message(String message_str)const
+Input::message(String message_str) const
 {
     String str = "";
     
-    if ( source_file_l_ 
+    if (source_file_l_
       {
        str += location_str() + String(": ");
       }
     
     str += message_str;
-    if ( source_file_l_ 
+    if (source_file_l_
       {
        str += ":\n";
-       str += source_file_l_->error_str( defined_ch_C_);
+       str += source_file_l_->error_str(defined_ch_C_);
       }
     cerr << str << endl;
 }
 
 void
-Input::warning( String message_str)const
+Input::warning(String message_str) const
 {
-    message( "warning: " + message_str);
+    message("warning: " + message_str);
 }
 void
-Input::error(String s)const
+Input::error(String s) const
 {
     message("error: "+ s);
 }
 
 String
-Input::location_str()const
+Input::location_str() const
 {
     if (source_file_l_) 
        return source_file_l_->file_line_no_str(defined_ch_C_);
index 73df524f7d76e0a2ec69f219980ed72038920720..686909382a19cb3119a8fa4a2d094332c1460720 100644 (file)
@@ -16,13 +16,13 @@ Plet::Plet()
 }
 
 Moment
-Plet::mom()const
+Plet::mom() const
 {
-  return  Moment( iso_i_, type_i_ );
+  return  Moment(iso_i_, type_i_);
 }
 
 bool
-Plet::unit_b()const
+Plet::unit_b() const
 {
   return type_i_ == 1 && iso_i_ == 1;
 }
index 4ac7017f051eb67ca1a774ba31e6fc1458b88e4b..7d912edd6367a05890acabbaaeef50a100b11c1d 100644 (file)
@@ -19,7 +19,7 @@
 #include "source-file.hh"
 #include "file-storage.hh"
 
-Source_file::Source_file( String filename_str )
+Source_file::Source_file(String filename_str)
 {
     name_str_ = filename_str;
     istream_p_ = 0;
@@ -29,16 +29,16 @@ Source_file::Source_file( String filename_str )
 istream*
 Source_file::istream_l()
 {
-    if ( !name_str_.length_i())
+    if (!name_str_.length_i())
        return &cin;
     
-    if ( !istream_p_ 
+    if (!istream_p_
       {
-       if ( length_i() ) // can-t this be done without such a hack?
-           istream_p_ = new istrstream( ch_C(), length_i() );
+       if (length_i()) // can-t this be done without such a hack?
+           istream_p_ = new istrstream(ch_C(), length_i());
         else 
           {
-           istream_p_ = new istrstream( "", 0 );
+           istream_p_ = new istrstream("", 0);
            istream_p_->set(ios::eofbit);
          }
       }
@@ -46,14 +46,17 @@ Source_file::istream_l()
 }
 
 String
-Source_file::file_line_no_str(char const *ch_C )const
+Source_file::file_line_no_str(char const *context_ch_C) const
 {
+  if  (!ch_C())
+    return "(unknown)";
+  else
     return name_str() + ": "
-       + String( line_i( ch_C ) );
+       + String(line_i(context_ch_C));
 }
 
 String
-Source_file::name_str()const
+Source_file::name_str() const
 {
     return name_str_;
 }
@@ -66,79 +69,82 @@ Source_file::~Source_file()
 }
 
 String
-Source_file::error_str( char const* pos_ch_C )const
+Source_file::error_str(char const* pos_ch_C) const
 {
     char const* data_ch_C = ch_C();
     char const * eof_C_ = data_ch_C + length_i();
-    if ( !in_b( pos_ch_C ) )
+    if (!in_b(pos_ch_C))
        return "(position unknown)";
 
     
-    if ( pos_ch_C == eof_C_)
+    if (pos_ch_C == eof_C_)
        pos_ch_C --;
     char const* begin_ch_C = pos_ch_C;
-    while ( begin_ch_C > data_ch_C )
-        if ( *--begin_ch_C == '\n' 
+    while (begin_ch_C > data_ch_C)
+        if (*--begin_ch_C == '\n'
           {
            begin_ch_C++;
            break;
          }
 
     char const* end_ch_C = pos_ch_C;
-    while ( end_ch_C < eof_C_ )
-        if ( *end_ch_C++ == '\n' 
+    while (end_ch_C < eof_C_)
+        if (*end_ch_C++ == '\n'
           {
          end_ch_C--;
          break;
          }
   
-       //    String( char const* p, int length ) is missing!?
-    String line_str( (Byte const*)begin_ch_C, end_ch_C - begin_ch_C );
+       //    String(char const* p, int length) is missing!?
+    String line_str((Byte const*)begin_ch_C, end_ch_C - begin_ch_C);
 
     int error_col_i = 0;
     char const* scan_ch_C = begin_ch_C;
-    while ( scan_ch_C < pos_ch_C )
-       if ( *scan_ch_C++ == '\t' )
-           error_col_i = ( error_col_i / 8 + 1 ) * 8;
+    while (scan_ch_C < pos_ch_C)
+       if (*scan_ch_C++ == '\t')
+           error_col_i = (error_col_i / 8 + 1) * 8;
        else
            error_col_i++;
 
-    String str = line_str.left_str( pos_ch_C - begin_ch_C 
-       + String( '\n' )
-       + String( ' ', error_col_i 
-       + line_str.mid_str( pos_ch_C - begin_ch_C, INT_MAX ); // String::mid should take 0 arg..
+    String str = line_str.left_str(pos_ch_C - begin_ch_C
+       + String('\n')
+       + String(' ', error_col_i
+       + line_str.mid_str(pos_ch_C - begin_ch_C, INT_MAX); // String::mid should take 0 arg..
     return str;
 }
 
 bool
-Source_file::in_b( char const* pos_ch_C )const
+Source_file::in_b(char const* pos_ch_C) const
 {
-    return ( pos_ch_C && ( pos_ch_C >= ch_C() ) && ( pos_ch_C <= ch_C() + length_i() ) );
+    return (pos_ch_C && (pos_ch_C >= ch_C()) && (pos_ch_C <= ch_C() + length_i()));
 }
 
 
 int
-Source_file::line_i( char const* pos_ch_C )const
+Source_file::line_i(char const* pos_ch_C) const
 {
-    if ( !in_b( pos_ch_C ) )
+    if (!in_b(pos_ch_C))
        return 0;
 
     int i = 1;
     char const* scan_ch_C = ch_C();
-    while ( scan_ch_C < pos_ch_C )
-       if ( *scan_ch_C++ == '\n' )
+    if (!scan_ch_C)
+      return 0;
+    
+    while (scan_ch_C < pos_ch_C)
+       if (*scan_ch_C++ == '\n')
                i++;
     return i;
 }
 
 int
-Source_file::length_i()const
+Source_file::length_i() const
 {
     return storage_p_->length_i();
 }
 
 char const *
-Source_file::ch_C()const
+Source_file::ch_C() const
 {
     return storage_p_->ch_C();
 }
index b2681e482635fa094fc6f5d0b9a2d20954c7d757..8a7fe9f8b25b9e169be5a6aa0fb9e4caea68296f 100644 (file)
@@ -18,7 +18,7 @@ HANDLE CreateFileMapping(
     DWORD dwMaximumSizeHigh,   // high-order 32 bits of object size  
     DWORD dwMaximumSizeLow,    // low-order 32 bits of object size  
     LPCTSTR lpName     // name of file-mapping object 
-   );  
+);     
  
 
 LPVOID MapViewOfFile(
@@ -27,11 +27,11 @@ LPVOID MapViewOfFile(
     DWORD dwFileOffsetHigh,    // high-order 32 bits of file offset 
     DWORD dwFileOffsetLow,     // low-order 32 bits of file offset 
     DWORD dwNumberOfBytesToMap         // number of bytes to map 
-   );  
+);     
  
 
 io.h:
-long _get_osfhandle( int filehandle );
+long _get_osfhandle(int filehandle);
 */
 
 // cygnus's gnu-win32-b17.1 does not have _get_osfhandle
@@ -46,9 +46,9 @@ static const int OSF_FACTOR_i = 8;
 
 // #define HAVE_GET_OSFHANDLE  // no we still cannot; works only with cl.exe
 long
-_get_osfhandle( int filedes_i )
+_get_osfhandle(int filedes_i)
 {
-    return (long)( OSF_OFFSET_i + ( filedes_i + OSF_BASE_i ) * OSF_FACTOR_i );
+    return (long)(OSF_OFFSET_i + (filedes_i + OSF_BASE_i) * OSF_FACTOR_i);
 }
 
 #ifdef HAVE_GET_OSFHANDLE
@@ -61,10 +61,10 @@ mmap(caddr_t addr, size_t len, int prot, int flags, int fd, off_t offset)
     (void)flags;
     (void)prot;
     (void)addr;
-    HANDLE osf = (HANDLE)_get_osfhandle( fd );
-    HANDLE file_handle = CreateFileMapping( osf, (void*)0, PAGE_READONLY,
-       0, len, 0 ); 
-    return (caddr_t)MapViewOfFile( file_handle, FILE_MAP_READ, 0, offset, len );
+    HANDLE osf = (HANDLE)_get_osfhandle(fd);
+    HANDLE file_handle = CreateFileMapping(osf, (void*)0, PAGE_READONLY,
+       0, len, 0); 
+    return (caddr_t)MapViewOfFile(file_handle, FILE_MAP_READ, 0, offset, len);
 }
 
 
@@ -72,7 +72,7 @@ int
 munmap(caddr_t addr, size_t len)
 {
     (void)len;
-    return UnmapViewOfFile( addr );
+    return UnmapViewOfFile(addr);
 }
 
 #else // ! HAVE_GET_OSFHANDLE //
@@ -85,8 +85,8 @@ mmap(caddr_t addr, size_t len, int prot, int flags, int fd, off_t offset)
     (void)addr;
     (void)offset;
     char* ch_p = new char[ len ];
-    if ( ch_p )
-        read( fd, (void*)ch_p, len );
+    if (ch_p)
+        read(fd, (void*)ch_p, len);
     return ch_p;
 }
 
index c390c78a31420cc04586cead10e5d28d5a6b6fc2..c11a7debeefae3b31455c16f560465bd6e006f94 100644 (file)
@@ -22,10 +22,10 @@ Bar_engraver::do_try_request (Request*r_l)
 {
   Command_req* c_l = r_l->command();
   if (!c_l|| !c_l->bar()) 
-       return false;
+    return false;
   Bar_req  * b= c_l->bar();
   if (bar_req_l_ && bar_req_l_->equal_b (b))
-       return false;
+    return false;
   
   bar_req_l_ = b;
 
@@ -37,22 +37,24 @@ Bar_engraver::do_process_requests()
 {
   if (bar_req_l_) 
     {
-       bar_p_ = new Bar;
-       bar_p_->type_str_=bar_req_l_->type_str_;
+      bar_p_ = new Bar;
+      bar_p_->type_str_=bar_req_l_->type_str_;
     }
-  else if (!get_staff_info().time_C_->whole_in_measure_) 
+  else 
     {
+      Time_description const *time = get_staff_info().time_C_;
+      if (time && !time->whole_in_measure_) 
        bar_p_ = new Bar;
     }
   
   if (bar_p_)
     {
-       announce_element (Score_elem_info (bar_p_, bar_req_l_));
+      announce_element (Score_elem_info (bar_p_, bar_req_l_));
     }
   else 
     {
-       Disallow_break_req r;
-       daddy_grav_l_->try_request (&r);
+      Disallow_break_req r;
+      daddy_grav_l_->try_request (&r);
     }
 }
 
@@ -60,11 +62,11 @@ Bar_engraver::do_process_requests()
 void 
 Bar_engraver::do_pre_move_processing()
 {
-    if (bar_p_) 
-      {
-         typeset_element (bar_p_);
-         bar_p_ =0;
-      }
+  if (bar_p_) 
+    {
+      typeset_element (bar_p_);
+      bar_p_ =0;
+    }
 }
 
 void
index aae1051fb2360c6ec213b091a1456e42e18e9d60..3c7e7ca86b5670959a4e2db110c29d9c7af71d06 100644 (file)
@@ -18,7 +18,7 @@
 Engraver* get_engraver_p (String);
 
 void
-Engraver_group_engraver::print()const
+Engraver_group_engraver::print() const
 { 
   Engraver::print(); 
 }
@@ -33,16 +33,16 @@ Engraver_group_engraver::check_removal()
 {
   for (int i =0; i < group_l_arr_.size();) 
     {
-       group_l_arr_[i]->check_removal();
-       if (group_l_arr_[i]->removable_b())
-           terminate_engraver (group_l_arr_[i]);
-       else 
-           i++;
+      group_l_arr_[i]->check_removal();
+      if (group_l_arr_[i]->removable_b())
+       terminate_engraver (group_l_arr_[i]);
+      else 
+       i++;
     }
 }
 
 bool
-Engraver_group_engraver::removable_b()const
+Engraver_group_engraver::removable_b() const
 {
   return !iterator_count_&& !group_l_arr_.size() ;
 }
@@ -59,9 +59,9 @@ Engraver_group_engraver::set_feature (Feature d)
   // why the while construct?
   while (i.ok()) 
     {
-       // this construction to ensure clean deletion
-       Engraver *grav_l = i++; 
-       grav_l->set_feature (d);
+      // this construction to ensure clean deletion
+      Engraver *grav_l = i++; 
+      grav_l->set_feature (d);
     }
 }
 
@@ -71,8 +71,8 @@ Engraver_group_engraver::sync_features()
   PCursor<Engraver*> i (grav_list_.top());
   while (i.ok()) 
     {
-       Engraver *grav_l = i++; 
-       grav_l->sync_features();
+      Engraver *grav_l = i++; 
+      grav_l->sync_features();
     }
 }
 
@@ -82,8 +82,8 @@ Engraver_group_engraver::do_pre_move_processing()
   PCursor<Engraver*> i (grav_list_.top());
   while (i.ok()) 
     {
-       Engraver *grav_l = i++; 
-       grav_l->pre_move_processing();
+      Engraver *grav_l = i++; 
+      grav_l->pre_move_processing();
     }
 }
 
@@ -93,8 +93,8 @@ Engraver_group_engraver::do_process_requests()
   PCursor<Engraver*> i (grav_list_.top());
   while (i.ok()) 
     {
-       Engraver *grav_l = i++; 
-       grav_l->process_requests();
+      Engraver *grav_l = i++; 
+      grav_l->process_requests();
     }
 }
 
@@ -105,23 +105,23 @@ Engraver_group_engraver::do_post_move_processing()
   PCursor<Engraver*> i (grav_list_.top());
   while (i.ok()) 
     {
-               // this construction to ensure clean deletion
-       Engraver *grav_l = i++; 
-       grav_l->post_move_processing();
+      // this construction to ensure clean deletion
+      Engraver *grav_l = i++; 
+      grav_l->post_move_processing();
     }
 }
 
 
 bool
-Engraver_group_engraver::contains_b (Engraver* grav_l)const
+Engraver_group_engraver::contains_b (Engraver* grav_l) const
 {
   bool parent_b = Engraver::contains_b (grav_l);
   
   if (parent_b)
-       return true;
+    return true;
   for (PCursor<Engraver*> i (grav_list_.top()); i.ok (); i++)
-       if (i->contains_b (grav_l))
-           return true;
+    if (i->contains_b (grav_l))
+      return true;
   return false;
 }
        
@@ -132,9 +132,9 @@ Engraver_group_engraver::do_try_request (Request*req_l)
 {
   bool hebbes_b =false;
   for (int i =0; !hebbes_b && i < nongroup_l_arr_.size() ; i++)
-       hebbes_b =nongroup_l_arr_[i]->try_request (req_l);
+    hebbes_b =nongroup_l_arr_[i]->try_request (req_l);
   if (!hebbes_b && daddy_grav_l_)
-       hebbes_b = daddy_grav_l_->try_request (req_l);
+    hebbes_b = daddy_grav_l_->try_request (req_l);
   return hebbes_b ;
 }
 
@@ -152,11 +152,11 @@ Engraver_group_engraver::add (Engraver *grav_p)
 
   if (grav_p->is_type_b (Engraver_group_engraver::static_name())) 
     {
-       group_l_arr_.push ((Engraver_group_engraver*)grav_p);
+      group_l_arr_.push ((Engraver_group_engraver*)grav_p);
     }
   else 
     {
-       nongroup_l_arr_ .push (grav_p);
+      nongroup_l_arr_ .push (grav_p);
     }
 }
 
@@ -186,15 +186,15 @@ IMPLEMENT_IS_TYPE_B2(Engraver_group_engraver,Engraver, Translator);
 ADD_THIS_ENGRAVER(Engraver_group_engraver);
 
 void
-Engraver_group_engraver::do_print()const
+Engraver_group_engraver::do_print() const
 {
 #ifndef NPRINT
-  if ( !check_debug)
-       return ;
+  if (!check_debug)
+    return ;
   DOUT << "ID: " << id_str_ ;
   DOUT << " iterators: " << iterator_count_<< "\n";
   for (PCursor<Engraver*> i (grav_list_.top()); i.ok (); i++)
-       i->print();
+    i->print();
 #endif
 }
 
@@ -203,11 +203,11 @@ Engraver_group_engraver*
 Engraver_group_engraver::find_engraver_l (String n, String id)
 {
   if (name() == n && id_str_ == id)
-       return this;
+    return this;
   Engraver_group_engraver * r = 0;
   for (int i =0; !r && i<  group_l_arr_.size(); i++) 
     {
-       r = group_l_arr_[i]->find_engraver_l (n,id);
+      r = group_l_arr_[i]->find_engraver_l (n,id);
     }
   
   return r;
@@ -217,37 +217,37 @@ Translator*
 Engraver_group_engraver::find_get_translator_l (String n,String id)
 {
   Translator * ret=0;
-  Input_translator * itrans_l= itrans_l_-> recursive_find ( n);
+  Input_translator * itrans_l= itrans_l_-> recursive_find (n);
   if (itrans_l) 
     {
-       ret = find_engraver_l (n,id);
-       if (!ret) 
-         {
-           Engraver_group_engraver * group = 
-               itrans_l-> get_group_engraver_p();
+      ret = find_engraver_l (n,id);
+      if (!ret) 
+       {
+         Engraver_group_engraver * group = 
+           itrans_l-> get_group_engraver_p();
            
-           add (group);
-           ret = group;
+         add (group);
+         ret = group;
            
-           if (group->itrans_l_->is_name_b (n) )
-               ret ->id_str_ = id;
-           else
-               return ret->find_get_translator_l (n,id);
+         if (group->itrans_l_->is_name_b (n))
+           ret ->id_str_ = id;
+         else
+           return ret->find_get_translator_l (n,id);
 
-         }
+       }
     }
   else if (daddy_grav_l_)
-       ret =daddy_grav_l_->find_get_translator_l (n,id);
+    ret =daddy_grav_l_->find_get_translator_l (n,id);
   else 
     {
-       warning ("Can't find or create `" + n + "' called `" + id + "'\n");
-       ret =0;
+      warning ("Can't find or create `" + n + "' called `" + id + "'\n");
+      ret =0;
     }
   return ret;
 }
 
 int
-Engraver_group_engraver::depth_i()const
+Engraver_group_engraver::depth_i() const
 {
   return daddy_grav_l_->depth_i()  + 1;
 }
@@ -256,7 +256,7 @@ Translator*
 Engraver_group_engraver::ancestor_l (int l)
 {
   if (!l || !daddy_grav_l_)
-       return this;
+    return this;
   
   return daddy_grav_l_->ancestor_l (l-1);
 }
@@ -273,21 +273,21 @@ Engraver_group_engraver::do_announces()
 {
   for (int i=0; i < group_l_arr_.size(); i++) 
     {
-       group_l_arr_[i]->do_announces();
+      group_l_arr_[i]->do_announces();
     }
   
   Request dummy_req;
  
   for (int j =0; j < announce_info_arr_.size(); j++)
     {
-     Score_elem_info info = announce_info_arr_[j];
+      Score_elem_info info = announce_info_arr_[j];
      
-     if (!info.req_l_)
-           info.req_l_ = &dummy_req;
-     for (int i=0; i < nongroup_l_arr_.size(); i++) {  // Is this good enough?6
-          if (nongroup_l_arr_[i] != info.origin_grav_l_arr_[0])
-              nongroup_l_arr_[i]->acknowledge_element (info);
-       }
+      if (!info.req_l_)
+       info.req_l_ = &dummy_req;
+      for (int i=0; i < nongroup_l_arr_.size(); i++) { // Is this good enough?6
+       if (nongroup_l_arr_[i] != info.origin_grav_l_arr_[0])
+         nongroup_l_arr_[i]->acknowledge_element (info);
+      }
     }
   announce_info_arr_.clear();
 }
@@ -297,16 +297,16 @@ void
 Engraver_group_engraver::do_removal_processing()
 {
   for (PCursor<Engraver*> i (grav_list_.top()); i.ok (); i++)
-       i->removal_processing();
+    i->removal_processing();
 }
 
 Staff_info
-Engraver_group_engraver::get_staff_info()const
+Engraver_group_engraver::get_staff_info() const
 {
   Staff_info inf = Engraver::get_staff_info();
 
   for (int i=0; i < nongroup_l_arr_.size(); i++)
-       nongroup_l_arr_[i]->fill_staff_info (inf);
+    nongroup_l_arr_[i]->fill_staff_info (inf);
   
   return inf;
 }
@@ -315,34 +315,34 @@ Translator*
 Engraver_group_engraver::get_default_interpreter()
 {
   // ? 
-  if ( is_bottom_engraver_b())
-       return daddy_grav_l_->get_default_interpreter();
+  if (is_bottom_engraver_b())
+    return daddy_grav_l_->get_default_interpreter();
 
   Engraver_group_engraver *grav_p= itrans_l_->
-       get_default_itrans_l()->get_group_engraver_p ();
+    get_default_itrans_l()->get_group_engraver_p ();
   add (grav_p);
   if (grav_p->is_bottom_engraver_b())
-       return grav_p;
+    return grav_p;
   else
-       return grav_p->get_default_interpreter();
+    return grav_p->get_default_interpreter();
 }
 
 bool
-Engraver_group_engraver::is_bottom_engraver_b()const
+Engraver_group_engraver::is_bottom_engraver_b() const
 {
   return !itrans_l_->get_default_itrans_l();
 }
 
 Engraver*
-Engraver_group_engraver::get_simple_engraver (char const *type)const
+Engraver_group_engraver::get_simple_engraver (char const *type) const
 {
   for (int i=0; i < nongroup_l_arr_.size(); i++) 
     {
-       if (nongroup_l_arr_[i]->name() == type)
-           return nongroup_l_arr_[i];
+      if (nongroup_l_arr_[i]->name() == type)
+       return nongroup_l_arr_[i];
     }
-  if ( daddy_grav_l_)
-       return daddy_grav_l_->get_simple_engraver (type);
+  if (daddy_grav_l_)
+    return daddy_grav_l_->get_simple_engraver (type);
   return 0;
 }
 
index 52eba772e03b7caf8a9c961a4d97997b0f9448a5..11ac18d61e62230e57f1842ca16a6e0df1a428ec 100644 (file)
@@ -30,7 +30,7 @@ Engraver::post_move_processing()
 void
 Engraver::removal_processing()
 {
-  if ( status < CREATION_INITED)
+  if (status < CREATION_INITED)
        do_creation_processing();
   
   do_removal_processing();
@@ -102,13 +102,13 @@ Engraver::typeset_element (Score_elem*p)
 }
 
 Paper_def*
-Engraver::paper()const
+Engraver::paper() const
 {
   return daddy_grav_l_->paper();
 }
 
 bool
-Engraver::contains_b (Engraver *grav_l)const
+Engraver::contains_b (Engraver *grav_l) const
 {
   return this == grav_l;
 }
@@ -116,7 +116,10 @@ Engraver::contains_b (Engraver *grav_l)const
 Staff_info
 Engraver::get_staff_info() const
 {
-  return daddy_grav_l_->get_staff_info();
+  if (daddy_grav_l_)
+    return daddy_grav_l_->get_staff_info();
+  Staff_info info;
+  return info;
 }
 
 void
index 251c8065364562b16242cd7a87db3aa15a1ba1f5..f27e9f92befb02db8014ac3fb7f887886e05c796 100644 (file)
@@ -5,8 +5,7 @@
 
   (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
 */
-#if 0
-
+#include "score-grav.hh"
 #include "timing-grav.hh"
 #include "command-request.hh"
 
@@ -23,5 +22,123 @@ Timing_engraver::fill_staff_info (Staff_info &inf)
   inf.rhythmic_C_ = &default_grouping_;
 }
 
+bool
+Timing_engraver::do_try_request(Request*r)
+{
+  Command_req * c = r->command();
+  if (!(c && c->timing()))
+    return false;
+  for (int i=0; i < timing_req_l_arr_.size (); i++) 
+    {
+      if (timing_req_l_arr_[i]->equal_b(r))
+       return true;
+      if (timing_req_l_arr_[i]->name() == r->name()) 
+       {
+         r->warning ("conflicting timing request");
+         return false;
+       }
+    }
+  
+  timing_req_l_arr_.push(c->timing());
+  return true;
+}
+
+Meter_change_req*
+Timing_engraver::meter_req_l() const
+{
+  Meter_change_req *m_l=0;
+  for (int i=0; !m_l && i < timing_req_l_arr_.size (); i++) 
+    {
+      m_l=timing_req_l_arr_[i]->meterchange();
+    }
+  return m_l;  
+}
+
+void
+Timing_engraver::do_process_requests()
+{
+  for (int i=0; i < timing_req_l_arr_.size (); i++) 
+    {
+      Timing_req * tr_l = timing_req_l_arr_[i];
+      Meter_change_req *m_l = tr_l->meterchange();
+      if (m_l) 
+       {
+         int b_i= m_l->beats_i_;
+         int o_i = m_l->one_beat_i_;
+         if (! time_.allow_meter_change_b())
+           tr_l->warning ("Meter change not allowed here");
+         else
+           {
+             time_.set_meter (b_i, o_i);
+             default_grouping_ = 
+               Rhythmic_grouping (MInterval (0,Moment (b_i, o_i)), b_i);
+           }
+       }
+      else if (tr_l->partial()) 
+       {
+         Moment m = tr_l->partial()->duration_;
+         String error = time_.try_set_partial_str (m);
+         if (error != "") 
+           {
+             tr_l->warning (error);
+           }
+         else 
+           time_.setpartial (m);
+       }
+      else if (tr_l->barcheck()) 
+       {
+         if (time_.whole_in_measure_) 
+           {
+             tr_l ->warning ("Barcheck failed");
+           
+             time_.whole_in_measure_ = 0; // resync
+             time_.error_b_ = true;
+           }
+
+       }
+      else if (tr_l->cadenza()) 
+       {
+         time_.set_cadenza (tr_l->cadenza()->on_b_);
+
+       }
+      else if (tr_l->measuregrouping()) 
+       {
+         default_grouping_ = 
+           parse_grouping (tr_l->measuregrouping()->beat_i_arr_,
+                           tr_l->measuregrouping()->elt_length_arr_);
+
+       }
+    }
+}
+
+
+void
+Timing_engraver::do_pre_move_processing()
+{
+  timing_req_l_arr_.set_size (0);
+  Engraver_group_engraver * grav_l = daddy_grav_l_;
+  while (grav_l->daddy_grav_l_) 
+    {
+      grav_l = grav_l->daddy_grav_l_;
+    }
+  
+  assert (grav_l->name() == Score_engraver::static_name ());
+  if (!time_.cadenza_b_)
+    ((Score_engraver*)grav_l)->add_moment_to_process (time_.next_bar_moment());
+}
+
+IMPLEMENT_IS_TYPE_B1(Timing_engraver, Engraver);
+ADD_THIS_ENGRAVER(Timing_engraver);
+
+void
+Timing_engraver::do_creation_processing()
+{
+  time_.when_ = get_staff_info().when ();
+}
+
+void
+Timing_engraver::do_post_move_processing()
+{
+  time_.add (get_staff_info().when ()  - time_.when_);
+}
 
-#endif