Use shared_ptr and references for Actions.
This slows terminal emulation slightly.
This commit is contained in:
@@ -52,9 +52,8 @@ string Complete::act( const string &str )
|
||||
for ( Actions::iterator it = actions.begin();
|
||||
it != actions.end();
|
||||
it++ ) {
|
||||
Action *act = *it;
|
||||
act->act_on_terminal( &terminal );
|
||||
delete act;
|
||||
Action &act = **it;
|
||||
act.act_on_terminal( &terminal );
|
||||
}
|
||||
actions.clear();
|
||||
}
|
||||
@@ -62,10 +61,10 @@ string Complete::act( const string &str )
|
||||
return terminal.read_octets_to_host();
|
||||
}
|
||||
|
||||
string Complete::act( const Action *act )
|
||||
string Complete::act( const Action &act )
|
||||
{
|
||||
/* apply action to terminal */
|
||||
act->act_on_terminal( &terminal );
|
||||
act.act_on_terminal( &terminal );
|
||||
return terminal.read_octets_to_host();
|
||||
}
|
||||
|
||||
@@ -112,9 +111,8 @@ void Complete::apply_string( const string & diff )
|
||||
string terminal_to_host = act( input.instruction( i ).GetExtension( hostbytes ).hoststring() );
|
||||
assert( terminal_to_host.empty() ); /* server never interrogates client terminal */
|
||||
} else if ( input.instruction( i ).HasExtension( resize ) ) {
|
||||
Resize new_size( input.instruction( i ).GetExtension( resize ).width(),
|
||||
input.instruction( i ).GetExtension( resize ).height() );
|
||||
act( &new_size );
|
||||
act( Resize( input.instruction( i ).GetExtension( resize ).width(),
|
||||
input.instruction( i ).GetExtension( resize ).height() ) );
|
||||
} else if ( input.instruction( i ).HasExtension( echoack ) ) {
|
||||
uint64_t inst_echo_ack_num = input.instruction( i ).GetExtension( echoack ).echo_ack_num();
|
||||
assert( inst_echo_ack_num >= echo_ack );
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace Terminal {
|
||||
actions(), input_history(), echo_ack( 0 ) {}
|
||||
|
||||
std::string act( const std::string &str );
|
||||
std::string act( const Parser::Action *act );
|
||||
std::string act( const Parser::Action &act );
|
||||
|
||||
const Framebuffer & get_fb( void ) const { return terminal.get_fb(); }
|
||||
void reset_input( void ) { parser.reset_input(); }
|
||||
|
||||
@@ -123,15 +123,16 @@ void UserStream::apply_string( const string &diff )
|
||||
}
|
||||
}
|
||||
|
||||
const Parser::Action *UserStream::get_action( unsigned int i ) const
|
||||
const Parser::Action &UserStream::get_action( unsigned int i ) const
|
||||
{
|
||||
switch( actions[ i ].type ) {
|
||||
case UserByteType:
|
||||
return &( actions[ i ].userbyte );
|
||||
return actions[ i ].userbyte;
|
||||
case ResizeType:
|
||||
return &( actions[ i ].resize );
|
||||
return actions[ i ].resize;
|
||||
default:
|
||||
assert( false );
|
||||
return NULL;
|
||||
static const Parser::Ignore nothing = Parser::Ignore();
|
||||
return nothing;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ namespace Network {
|
||||
|
||||
bool empty( void ) const { return actions.empty(); }
|
||||
size_t size( void ) const { return actions.size(); }
|
||||
const Parser::Action *get_action( unsigned int i ) const;
|
||||
const Parser::Action &get_action( unsigned int i ) const;
|
||||
|
||||
/* interface for Network::Transport */
|
||||
void subtract( const UserStream *prefix );
|
||||
|
||||
Reference in New Issue
Block a user