# Abstract input streams
class IStream
-special IOS
+ super IOS
# Read a character. Return its ASCII value, -1 on EOF or timeout
fun read_char: Int is abstract
# Read a string until the end of the line and append it to `s'.
fun append_line_to(s: Buffer)
do
- while true do
+ loop
var x = read_char
if x == -1 then
if eof then return
# Abstract output stream
class OStream
-special IOS
+ super IOS
# write a string
fun write(s: String) is abstract
# Input streams with a buffer
class BufferedIStream
-special IStream
+ super IStream
redef fun read_char
do
assert not eof
redef fun append_line_to(s)
do
- while true do
+ loop
# First phase: look for a '\n'
var i = _buffer_pos
while i < _buffer.length and _buffer[i] != '\n' do i += 1
end
class IOStream
-special IStream
-special OStream
+ super IStream
+ super OStream
end
##############################################################"
class FDStream
-special IOS
+ super IOS
# File description
var _fd: Int
end
class FDIStream
-special FDStream
-special IStream
+ super FDStream
+ super IStream
redef readable var _eof: Bool = false
redef fun read_char
end
class FDOStream
-special FDStream
-special OStream
+ super FDStream
+ super OStream
redef readable var _is_writable: Bool
redef fun write(s)
end
class FDIOStream
-special FDIStream
-special FDOStream
-special IOStream
+ super FDIStream
+ super FDOStream
+ super IOStream
init(fd: Int)
do
_fd = fd