Project

General

Profile

Backport #5835 ยป backport_5835.patch

ayumin (Ayumu AIZAWA), 01/04/2012 01:28 AM

View differences:

lib/rexml/parsers/baseparser.rb
114 114

  
115 115
      def initialize( source )
116 116
        self.stream = source
117
        @listeners = []
117 118
      end
118 119

  
119 120
      def add_listener( listener )
120
        if !defined?(@listeners) or !@listeners
121
          @listeners = []
122
          instance_eval <<-EOL
123
            alias :_old_pull :pull
124
            def pull
125
              event = _old_pull
126
              @listeners.each do |listener|
127
                listener.receive event
128
              end
129
              event
130
            end
131
          EOL
132
        end
133 121
        @listeners << listener
134 122
      end
135 123

  
......
192 180

  
193 181
      # Returns the next event.  This is a +PullEvent+ object.
194 182
      def pull
183
        pull_event.tap do |event|
184
          @listeners.each do |listener|
185
            listener.receive event
186
          end
187
        end
188
      end
189

  
190
      def pull_event
195 191
        if @closed
196 192
          x, @closed = @closed, nil
197 193
          return [ :end_element, x ]
......
440 436
        end
441 437
        return [ :dummy ]
442 438
      end
439
      private :pull_event
443 440

  
444 441
      def entity( reference, entities )
445 442
        value = nil