]> gitweb.factorcode.org Git - factor.git/blob - basis/io/streams/null/null.factor
e1688c87fecde2886975cbe2fc8578a9a7256035
[factor.git] / basis / io / streams / null / null.factor
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 ;
4 IN: io.streams.null
5
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
11
12 M: null-stream dispose drop ;
13
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 ;
20
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 ;
25
26 : with-null-reader ( quot -- )
27     null-reader swap with-input-stream* ; inline
28
29 : with-null-writer ( quot -- )
30     null-writer swap with-output-stream* ; inline