From: Vincent Pit Date: Sat, 19 Sep 2009 23:22:09 +0000 (+0200) Subject: Make Parser::XML::Twig collect the protocol version X-Git-Tag: v1.10~8 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=76eed0759a5b942bf1a9a8be439eebd9459f7c7c;p=perl%2Fmodules%2FTest-Valgrind.git Make Parser::XML::Twig collect the protocol version --- diff --git a/lib/Test/Valgrind/Parser/XML/Twig.pm b/lib/Test/Valgrind/Parser/XML/Twig.pm index c1eeea9..878ef4d 100644 --- a/lib/Test/Valgrind/Parser/XML/Twig.pm +++ b/lib/Test/Valgrind/Parser/XML/Twig.pm @@ -12,7 +12,8 @@ use base qw/Test::Valgrind::Parser::XML Test::Valgrind::Carp XML::Twig/; BEGIN { XML::Twig->add_options('Stash'); } my %handlers = ( - '/valgrindoutput/error' => \&handle_error, + '/valgrindoutput/protocolversion' => \&handle_version, + '/valgrindoutput/error' => \&handle_error, ); sub new { @@ -32,11 +33,12 @@ sub new { sub stash { shift->{Stash} } +eval "sub $_ { \@_ <= 1 ? \$_[0]->{$_} : (\$_[0]->{$_} = \$_[1]) }" + for qw/_session protocol_version/; + # We must store the session in ourselves because it's only possible to pass # arguments to XML::Twig objects by a global stash. -sub _session { @_ <= 1 ? $_[0]->{_session} : ($_[0]->{_session} = $_[1]) } - sub start { my ($self, $sess) = @_; @@ -64,6 +66,14 @@ sub finish { return; } +sub handle_version { + my ($twig, $node) = @_; + + $twig->protocol_version($node->text); + + $twig->purge; +} + sub handle_error { my ($twig, $node) = @_;