1 ! Copyright (C) 2007 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
4 USING: kernel io io.timeouts io.streams.duplex destructors ;
8 M: null-stream dispose drop ;
9 M: null-stream set-timeout 2drop ;
11 TUPLE: null-reader < null-stream ;
13 M: null-reader stream-readln drop f ;
14 M: null-reader stream-read1 drop f ;
15 M: null-reader stream-read-until 2drop f f ;
16 M: null-reader stream-read 2drop f ;
18 TUPLE: null-writer < null-stream ;
20 M: null-writer stream-write1 2drop ;
21 M: null-writer stream-write 2drop ;
22 M: null-writer stream-nl drop ;
23 M: null-writer stream-flush drop ;
24 M: null-writer stream-format 3drop ;
25 M: null-writer make-span-stream nip ;
26 M: null-writer make-block-stream nip ;
27 M: null-writer make-cell-stream nip ;
28 M: null-writer stream-write-table 3drop ;
30 : with-null-reader ( quot -- )
31 T{ null-reader } swap with-input-stream* ; inline
33 : with-null-writer ( quot -- )
34 T{ null-writer } swap with-output-stream* ; inline
36 : with-null-stream ( quot -- )
37 T{ duplex-stream f T{ null-reader } T{ null-writer } }
38 swap with-stream* ; inline