factor/basis/io/streams/null/null.factor

31 lines
974 B
Factor
Raw Normal View History

! Copyright (C) 2007, 2009 Slava Pestov.
2007-09-20 18:09:08 -04:00
! See http://factorcode.org/license.txt for BSD license.
USING: kernel io destructors io.streams.plain ;
2007-09-20 18:09:08 -04:00
IN: io.streams.null
SINGLETONS: null-reader null-writer ;
UNION: null-stream null-reader null-writer ;
INSTANCE: null-reader input-stream
INSTANCE: null-writer output-stream
INSTANCE: null-writer plain-writer
2007-09-20 18:09:08 -04:00
M: null-stream dispose drop ;
2009-03-15 18:11:18 -04:00
M: null-reader stream-element-type drop +byte+ ;
M: null-reader stream-readln drop f ;
M: null-reader stream-read1 drop f ;
M: null-reader stream-read-until 2drop f f ;
2011-10-12 14:59:24 -04:00
M: null-reader stream-read-unsafe 3drop 0 ;
M: null-reader stream-read-partial-unsafe 3drop 0 ;
2009-03-15 18:11:18 -04:00
M: null-writer stream-element-type drop +byte+ ;
M: null-writer stream-write1 2drop ;
M: null-writer stream-write 2drop ;
M: null-writer stream-flush drop ;
: with-null-reader ( quot -- )
null-reader swap with-input-stream* ; inline
: with-null-writer ( quot -- )
null-writer swap with-output-stream* ; inline