Anonymous avatar Anonymous committed 50a76e6

Modified Files:
lib/XML/LibXML/NodeList.pm t/08findnodes.t LibXML.pm
removed iterator code.

Comments (0)

Files changed (3)

 }
 
 sub iterator {
-    my $self = shift;
-    require XML::LibXML::Iterator;
-    return XML::LibXML::Iterator->new( $self );
+    warn "this function is obsolete!\nIt was disabled in version 1.54\n";
+    return undef;
 }
 
 

lib/XML/LibXML/NodeList.pm

 }
 
 sub iterator {
-    my $self = CORE::shift;
-    return XML::LibXML::NodeList::Iterator->new( $self );
-}
-
-1;
-
-package XML::LibXML::NodeList::Iterator;
-
-use strict;
-use XML::NodeFilter qw(:results);
-
-use overload
-  '++' => sub { $_[0]->next;     $_[0]; },
-  '--' => sub { $_[0]->previous; $_[0] },
-  '<>'  =>  sub {
-      if ( wantarray ) {
-          my @rv = ();
-          while ( $_[0]->next ){ push @rv,$_;}
-          return @rv;
-      } else {
-          return $_[0]->next
-      };
-  },
-;
-
-sub new {
-    my $class = shift;
-    my $list  = shift;
-    my $self  = undef;
-    if ( defined $list ) {
-        $self = bless [
-                       $list,
-                       0,
-                       [],
-                      ], $class;
-    }
-
-    return $self;
-}
-
-sub set_filter {
-    my $self = shift;
-    $self->[2] = [ @_ ];
-}
-
-sub add_filter {
-    my $self = shift;
-    push @{$self->[2]}, @_;
-}
-
-# helper function.
-sub accept_node {
-    foreach ( @{$_[0][2]} ) {
-        my $r = $_->accept_node($_[1]);
-        return $r if $r;
-    }
-    # no filters or all decline ...
-    return FILTER_ACCEPT;
-}
-
-sub first    { $_[0][1]=0;
-               my $s = scalar(@{$_[0][0]});
-               while ( $_[0][1] < $s ) {
-                   last if $_[0]->accept_node($_[0][0][$_[0][1]]) == FILTER_ACCEPT;
-                   $_[0][1]++;
-               }
-               return undef if $_[0][1] == $s;
-               return $_[0][0][$_[0][1]]; }
-
-sub last     {
-    my $i = scalar(@{$_[0][0]})-1;
-    while($i >= 0){
-        if ( $_[0]->accept_node($_[0][0][$i] == FILTER_ACCEPT) ) {
-            $_[0][1] = $i;
-            last;
-        }
-        $i--;
-    }
-
-    if ( $i < 0 ) {
-        # this costs a lot, but is more safe
-        return $_[0]->first;
-    }
-    return $_[0][0][$i];
-}
-
-sub current  { return $_[0][0][$_[0][1]]; }
-sub index    { return $_[0][1]; }
-
-sub next     {
-    if ( (scalar @{$_[0][0]}) <= ($_[0][1] + 1)) {
-        return undef;
-    }
-    my $i = $_[0][1];
-    while ( 1 ) {
-        $i++;
-        return undef if $i >= scalar @{$_[0][0]};
-        if ( $_[0]->accept_node( $_[0][0]->[$i] ) == FILTER_ACCEPT ) {
-            $_[0][1] = $i;
-            last;
-        }
-    }
-    return $_[0][0]->[$_[0][1]];
-}
-
-sub previous {
-    if ( $_[0][1] <= 0 ) {
-        return undef;
-    }
-    my $i = $_[0][1];
-    while ( 1 ) {
-        $i--;
-        return undef if $i < 0;
-        if ( $_[0]->accept_node( $_[0][0]->[$i] ) == FILTER_ACCEPT ) {
-            $_[0][1] = $i;
-            last;
-        }
-    }
-    return $_[0][0][$_[0][1]];
-}
-
-sub iterate  {
-    my $self = shift;
-    my $funcref = shift;
-    return unless defined $funcref && ref( $funcref ) eq 'CODE';
-    $self->[1] = -1;
-    my $rv;
-    while ( $self->next ) {
-        $rv = $funcref->( $self, $_ );
-    }
-    return $rv;
+    warn "this function is obsolete!\nIt was disabled in version 1.54\n";
+    return undef;
 }
 
 1;
 use Test;
-BEGIN { plan tests=>36}
+BEGIN { plan tests=>35}
 END {ok(0) unless $loaded;}
 use XML::LibXML;
 $loaded = 1;
 # everywhere.
 
 my $file    = "example/dromeds.xml";
-$itervar    = undef;
-
 
 # init the file parser
 my $parser = XML::LibXML->new();
     
     my $telem = $dom->createElement('test');
     $telem->appendWellBalancedChunk('<b>c</b>');
-
-    $telem->iterator->iterate( sub { shift; $itervar.=$_[0]->getName(); } );
-    ok( $itervar, 'testbtext' );
   
     finddoc($dom);
     ok(1);
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.