From: Vincent Pit Date: Sat, 19 Sep 2009 22:06:01 +0000 (+0200) Subject: Move the rest of the XML parser from Tool::memcheck to Parser::XML::Twig X-Git-Tag: v1.10~16 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=08f451d35014a7f8587fba4bc20103a018487653;p=perl%2Fmodules%2FTest-Valgrind.git Move the rest of the XML parser from Tool::memcheck to Parser::XML::Twig --- diff --git a/lib/Test/Valgrind/Parser/XML/Twig.pm b/lib/Test/Valgrind/Parser/XML/Twig.pm index a949e81..b3568c8 100644 --- a/lib/Test/Valgrind/Parser/XML/Twig.pm +++ b/lib/Test/Valgrind/Parser/XML/Twig.pm @@ -22,11 +22,6 @@ sub new { my %args = @_; my $stash = delete $args{stash} || { }; - my $tool = delete $args{tool}; - $class->_croak('Invalid tool') unless Scalar::Util::blessed($tool) - and $tool->isa('Test::Valgrind::Tool'); - $stash->{tool} = $tool; - bless $class->XML::Twig::new( elt_class => __PACKAGE__ . '::Elt', stash => $stash, @@ -37,6 +32,38 @@ sub new { sub stash { shift->{Stash} } +# 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) = @_; + + $self->SUPER::start($sess); + $self->_session($sess); + + return; +} + +sub parse { + my ($self, $sess, $fh) = @_; + + $self->XML::Twig::parse($fh); + $self->purge; + + return; +} + +sub finish { + my ($self, $sess) = @_; + + $self->_session(undef); + $self->SUPER::finish($sess); + + return; +} + sub handle_error { my ($twig, $node) = @_; @@ -68,10 +95,9 @@ sub handle_error { $origin->kid('stack')->children('frame') ]; } - my $tool = $twig->stash->{tool}; - my $sess = $tool->_session; + my $sess = $twig->_session; - $sess->report($tool->report_class($sess)->new( + $sess->report($sess->report_class($sess)->new( kind => $kind, id => $id, data => $data, diff --git a/lib/Test/Valgrind/Tool/memcheck.pm b/lib/Test/Valgrind/Tool/memcheck.pm index 87852cf..e75f0c0 100644 --- a/lib/Test/Valgrind/Tool/memcheck.pm +++ b/lib/Test/Valgrind/Tool/memcheck.pm @@ -58,8 +58,6 @@ sub new { $self->{callers} = $callers; - $self->{twig} = Test::Valgrind::Tool::memcheck::Twig->new(tool => $self); - $self; } @@ -73,14 +71,6 @@ Read-only accessor for the C option. sub callers { $_[0]->{callers} } -=head2 C - -Read-only accessor for the underlying L parser. - -=cut - -sub twig { $_[0]->{twig} } - sub suppressions_tag { 'memcheck-' . $_[1]->version } =head2 C @@ -114,39 +104,6 @@ sub args { return @args; } -# 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) = @_; - - $self->SUPER::start($sess); - $self->_session($sess); - - return; -} - -sub parse_analysis { - my ($self, $sess, $fh) = @_; - - my $twig = $self->twig; - $twig->parse($fh); - $twig->purge; - - return; -} - -sub finish { - my ($self, $sess) = @_; - - $self->_session(undef); - $self->SUPER::finish($sess); - - return; -} - =head1 SEE ALSO L, L.