nitc/android: "handle" all config changes
[nit.git] / lib / filter_stream.nit
index 4146345..8fb57fd 100644 (file)
@@ -5,33 +5,28 @@
 #
 # This file is free software, which comes along with NIT.  This software is
 # distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
-# without  even  the implied warranty of  MERCHANTABILITY or  FITNESS FOR A 
+# without  even  the implied warranty of  MERCHANTABILITY or  FITNESS FOR A
 # PARTICULAR PURPOSE.  You can modify it is you want,  provided this header
 # is kept unaltered, and a notification of the changes is added.
 # You  are  allowed  to  redistribute it and sell it, alone or is a part of
 # another product.
 
 class FilterIStream
-special IStream
+       super IStream
        # Filter readed elements
-       readable var _stream: nullable IStream
+       var stream: nullable IStream = null
 
        redef fun eof: Bool
        do
                assert stream != null
                return stream.eof
        end
-
-       private fun stream=(i: nullable IStream)
-       do
-               _stream = i
-       end
 end
 
 class FilterOStream
-special OStream
+       super OStream
        # Filter outputed elements
-       readable var _stream: nullable OStream
+       var stream: nullable OStream = null
 
        # Can the stream be used to write
        redef fun is_writable: Bool
@@ -39,16 +34,11 @@ special OStream
                assert stream != null
                return stream.is_writable
        end
-
-       private fun stream=(i: OStream)
-       do
-               _stream = i
-       end
 end
 
 class StreamCat
-special FilterIStream
-       var _streams: Iterator[IStream]
+       super FilterIStream
+       private var streams: Iterator[IStream]
 
        redef fun eof: Bool
        do
@@ -65,12 +55,14 @@ special FilterIStream
 
        redef fun stream: nullable IStream
        do
-               if _stream == null and _streams.is_ok then
-                       stream = _streams.item
-                       assert _stream != null
+               var res = super
+               if res == null and _streams.is_ok then
+                       res = _streams.item
+                       stream = res
+                       assert stream != null
                        _streams.next
                end
-               return _stream
+               return res
        end
 
        redef fun read_char: Int
@@ -91,15 +83,15 @@ special FilterIStream
        do
                _streams = streams.iterator
        end
-       init(streams: IStream ...)
-       do
+
+       init(streams: IStream ...) is old_style_init do
                _streams = streams.iterator
        end
 end
 
 class StreamDemux
-special FilterOStream
-       var _streams: Array[OStream]
+       super FilterOStream
+       private var streams: Array[OStream]
 
        redef fun is_writable: Bool
        do
@@ -116,7 +108,7 @@ special FilterOStream
                end
        end
 
-       redef fun write(s: String)
+       redef fun write(s: Text)
        do
                for i in _streams
                do
@@ -141,8 +133,7 @@ special FilterOStream
                _streams = streams
        end
 
-       init(streams: OStream ...)
-       do
+       init(streams: OStream ...) is old_style_init do
                _streams = streams
        end
 end