From 7d19fbe203dbc1134c0cb6ff17271b1db958dd20 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Fri, 17 Feb 2012 19:41:25 -0500 Subject: [PATCH] Replace C++0x auto with Boost Typeof library Signed-off-by: Anders Kaseorg --- src/frontend/terminaloverlay.cc | 31 +++++++++++++++-------------- src/network/transportsender.cc | 7 ++++--- src/terminal/terminaldisplay.cc | 3 ++- src/terminal/terminalframebuffer.cc | 3 ++- 4 files changed, 24 insertions(+), 20 deletions(-) diff --git a/src/frontend/terminaloverlay.cc b/src/frontend/terminaloverlay.cc index 5ce4e07..462c39a 100644 --- a/src/frontend/terminaloverlay.cc +++ b/src/frontend/terminaloverlay.cc @@ -18,6 +18,7 @@ #include #include +#include #include #include #include @@ -100,9 +101,9 @@ Validity ConditionalOverlayCell::get_validity( const Framebuffer &fb, int row, || ( (sent_frame <= early_ack) && (expiration_time <= now) ) ) { if ( (current.contents == replacement.contents) || (current.is_blank() && replacement.is_blank()) ) { - auto it = find_if( original_contents.begin(), original_contents.end(), - (replacement.is_blank() && bind( &Cell::is_blank, _1 )) - || replacement.contents == (&_1)->*&Cell::contents ); + BOOST_AUTO( it, find_if( original_contents.begin(), original_contents.end(), + (replacement.is_blank() && bind( &Cell::is_blank, _1 )) + || replacement.contents == (&_1)->*&Cell::contents ) ); if ( it == original_contents.end() ) { return Correct; } else { @@ -340,8 +341,8 @@ void PredictionEngine::kill_epoch( uint64_t epoch, const Framebuffer &fb ) prediction_epoch ) ); cursor().active = true; - for ( auto i = overlays.begin(); i != overlays.end(); i++ ) { - for ( auto j = i->overlay_cells.begin(); j != i->overlay_cells.end(); j++ ) { + for ( BOOST_AUTO( i, overlays.begin() ); i != overlays.end(); i++ ) { + for ( BOOST_AUTO( j, i->overlay_cells.begin() ); j != i->overlay_cells.end(); j++ ) { if ( j->tentative( epoch - 1 ) ) { j->reset(); } @@ -405,9 +406,9 @@ void PredictionEngine::cull( const Framebuffer &fb ) /* go through cell predictions */ - auto i = overlays.begin(); + BOOST_AUTO( i, overlays.begin() ); while ( i != overlays.end() ) { - auto inext = i; + BOOST_AUTO( inext, i ); inext++; if ( (i->row_num < 0) || (i->row_num >= fb.ds.get_height()) ) { overlays.erase( i ); @@ -415,7 +416,7 @@ void PredictionEngine::cull( const Framebuffer &fb ) continue; } - for ( auto j = i->overlay_cells.begin(); j != i->overlay_cells.end(); j++ ) { + for ( BOOST_AUTO( j, i->overlay_cells.begin() ); j != i->overlay_cells.end(); j++ ) { if ( j->start_clock( local_frame_acked, now, send_interval ) ) { last_scheduled_timeout = max( last_scheduled_timeout, j->expiration_time ); } @@ -505,7 +506,7 @@ void PredictionEngine::cull( const Framebuffer &fb ) } /* go through cursor predictions */ - for ( auto it = cursors.begin(); it != cursors.end(); it++ ) { + for ( BOOST_AUTO( it, cursors.begin() ); it != cursors.end(); it++ ) { if ( it->start_clock( local_frame_acked, now, send_interval ) ) { last_scheduled_timeout = max( last_scheduled_timeout, it->expiration_time ); } @@ -536,8 +537,8 @@ void PredictionEngine::cull( const Framebuffer &fb ) ConditionalOverlayRow & PredictionEngine::get_or_make_row( int row_num, int num_cols ) { - auto it = find_if( overlays.begin(), overlays.end(), - (&_1)->*&ConditionalOverlayRow::row_num == row_num ); + BOOST_AUTO( it, find_if( overlays.begin(), overlays.end(), + (&_1)->*&ConditionalOverlayRow::row_num == row_num ) ); if ( it != overlays.end() ) { return *it; @@ -573,7 +574,7 @@ void PredictionEngine::new_user_byte( char the_byte, const Framebuffer &fb ) list actions( parser.input( the_byte ) ); - for ( auto it = actions.begin(); it != actions.end(); it++ ) { + for ( BOOST_AUTO( it, actions.begin() ); it != actions.end(); it++ ) { Parser::Action *act = *it; /* @@ -743,9 +744,9 @@ void PredictionEngine::newline_carriage_return( const Framebuffer &fb ) init_cursor( fb ); cursor().col = 0; if ( cursor().row == fb.ds.get_height() - 1 ) { - for ( auto i = overlays.begin(); i != overlays.end(); i++ ) { + for ( BOOST_AUTO( i, overlays.begin() ); i != overlays.end(); i++ ) { i->row_num--; - for ( auto j = i->overlay_cells.begin(); j != i->overlay_cells.end(); j++ ) { + for ( BOOST_AUTO( j, i->overlay_cells.begin() ); j != i->overlay_cells.end(); j++ ) { if ( j->active ) { j->expire( local_frame_sent + 1, now ); } @@ -754,7 +755,7 @@ void PredictionEngine::newline_carriage_return( const Framebuffer &fb ) /* make blank prediction for last row */ ConditionalOverlayRow &the_row = get_or_make_row( cursor().row, fb.ds.get_width() ); - for ( auto j = the_row.overlay_cells.begin(); j != the_row.overlay_cells.end(); j++ ) { + for ( BOOST_AUTO( j, the_row.overlay_cells.begin() ); j != the_row.overlay_cells.end(); j++ ) { j->active = true; j->tentative_until_epoch = prediction_epoch; j->expire( local_frame_sent + 1, now ); diff --git a/src/network/transportsender.cc b/src/network/transportsender.cc index a9309f9..fe27ff7 100644 --- a/src/network/transportsender.cc +++ b/src/network/transportsender.cc @@ -17,6 +17,7 @@ */ #include +#include #include #include #include @@ -162,7 +163,7 @@ void TransportSender::add_sent_state( uint64_t the_timestamp, uint64_t { sent_states.push_back( TimestampedState( the_timestamp, num, state ) ); if ( sent_states.size() > 32 ) { /* limit on state queue */ - auto last = sent_states.end(); + BOOST_AUTO( last, sent_states.end() ); for ( int i = 0; i < 16; i++ ) { last--; } sent_states.erase( last ); /* erase state from middle of queue */ } @@ -259,7 +260,7 @@ void TransportSender::send_in_fragments( string diff, uint64_t new_num vector fragments = fragmenter.make_fragments( inst, connection->get_MTU() ); - for ( auto i = fragments.begin(); i != fragments.end(); i++ ) { + for ( BOOST_AUTO( i, fragments.begin() ); i != fragments.end(); i++ ) { connection->send( i->tostring() ); if ( verbose ) { @@ -311,7 +312,7 @@ uint64_t TransportSender::get_late_ack( uint64_t now ) { uint64_t newest_echo_ack = 0; - for ( auto i = ack_history.begin(); i != ack_history.end(); i++ ) { + for ( BOOST_AUTO( i, ack_history.begin() ); i != ack_history.end(); i++ ) { if ( i->second < now - ECHO_TIMEOUT ) { newest_echo_ack = i->first; } diff --git a/src/terminal/terminaldisplay.cc b/src/terminal/terminaldisplay.cc index c105b5e..9fc6cac 100644 --- a/src/terminal/terminaldisplay.cc +++ b/src/terminal/terminaldisplay.cc @@ -16,6 +16,7 @@ along with this program. If not, see . */ +#include #include #include @@ -42,7 +43,7 @@ std::string Display::new_frame( bool initialized, const Framebuffer &last, const /* set window title */ frame.append( "\033]0;" ); const std::deque &window_title( f.get_window_title() ); - for ( auto i = window_title.begin(); + for ( BOOST_AUTO( i, window_title.begin() ); i != window_title.end(); i++ ) { snprintf( tmp, 64, "%lc", *i ); diff --git a/src/terminal/terminalframebuffer.cc b/src/terminal/terminalframebuffer.cc index 5f65455..a9ed554 100644 --- a/src/terminal/terminalframebuffer.cc +++ b/src/terminal/terminalframebuffer.cc @@ -16,6 +16,7 @@ along with this program. If not, see . */ +#include #include #include @@ -429,7 +430,7 @@ void Row::reset( int background_color ) void Framebuffer::prefix_window_title( const std::deque &s ) { - for ( auto i = s.rbegin(); i != s.rend(); i++ ) { + for ( BOOST_AUTO( i, s.rbegin() ); i != s.rend(); i++ ) { window_title.push_front( *i ); } }