1 ! Copyright (C) 2007, 2009 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: kernel io destructors io.streams.plain ;
6 SINGLETONS: null-reader null-writer ;
7 UNION: null-stream null-reader null-writer ;
8 INSTANCE: null-reader input-stream
9 INSTANCE: null-writer output-stream
10 INSTANCE: null-writer plain-writer
12 M: null-stream dispose drop ;
14 M: null-reader stream-element-type drop +byte+ ;
15 M: null-reader stream-readln drop f ;
16 M: null-reader stream-read1 drop f ;
17 M: null-reader stream-read-until 2drop f f ;
18 M: null-reader stream-read-unsafe 3drop 0 ;
19 M: null-reader stream-read-partial-unsafe 3drop 0 ;
21 M: null-writer stream-element-type drop +byte+ ;
22 M: null-writer stream-write1 2drop ;
23 M: null-writer stream-write 2drop ;
24 M: null-writer stream-flush drop ;
26 : with-null-reader ( quot -- )
27 null-reader swap with-input-stream* ; inline
29 : with-null-writer ( quot -- )
30 null-writer swap with-output-stream* ; inline