move null streams to core and make them not depend on io.styles and io.timeouts, initialize the std streams to null-streams on windows in win32 mode
parent
dbddd6ad0d
commit
c253cd854a
basis/io
backend/windows/nt
timeouts
core/io
|
@ -120,6 +120,9 @@ M: winnt (wait-to-read) ( port -- )
|
|||
tri
|
||||
] with-destructors ;
|
||||
|
||||
M: winnt (init-stdio) init-c-stdio ;
|
||||
: console-app? ( -- ? ) GetConsoleWindow ;
|
||||
|
||||
M: winnt (init-stdio)
|
||||
console-app? [ f f f f ] [ init-c-stdio t ] if ;
|
||||
|
||||
winnt set-io-backend
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
! Copyright (C) 2008 Slava Pestov, Doug Coleman
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: kernel calendar alarms io io.encodings accessors
|
||||
namespaces fry ;
|
||||
namespaces fry io.streams.null ;
|
||||
IN: io.timeouts
|
||||
|
||||
GENERIC: timeout ( obj -- dt/f )
|
||||
|
@ -27,3 +27,5 @@ GENERIC: cancel-operation ( obj -- )
|
|||
: timeouts ( dt -- )
|
||||
[ input-stream get set-timeout ]
|
||||
[ output-stream get set-timeout ] bi ;
|
||||
|
||||
M: null-stream set-timeout 2drop ;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
! Copyright (C) 2007, 2009 Slava Pestov.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: init kernel system namespaces io io.encodings
|
||||
io.encodings.utf8 init assocs splitting alien ;
|
||||
io.encodings.utf8 init assocs splitting alien io.streams.null ;
|
||||
IN: io.backend
|
||||
|
||||
SYMBOL: io-backend
|
||||
|
@ -12,13 +12,22 @@ io-backend global [ c-io-backend or ] change-at
|
|||
|
||||
HOOK: init-io io-backend ( -- )
|
||||
|
||||
HOOK: (init-stdio) io-backend ( -- stdin stdout stderr )
|
||||
HOOK: (init-stdio) io-backend ( -- stdin stdout stderr ? )
|
||||
|
||||
: set-stdio ( input-handle output-handle error-handle -- )
|
||||
[ input-stream set-global ]
|
||||
[ output-stream set-global ]
|
||||
[ error-stream set-global ] tri* ;
|
||||
|
||||
: init-stdio ( -- )
|
||||
(init-stdio)
|
||||
[ utf8 <decoder> input-stream set-global ]
|
||||
[ utf8 <encoder> output-stream set-global ]
|
||||
[ utf8 <encoder> error-stream set-global ] tri* ;
|
||||
(init-stdio) [
|
||||
[ utf8 <decoder> ]
|
||||
[ utf8 <encoder> ]
|
||||
[ utf8 <encoder> ] tri*
|
||||
] [
|
||||
3drop
|
||||
null-reader null-writer null-writer
|
||||
] if set-stdio ;
|
||||
|
||||
HOOK: io-multiplex io-backend ( us -- )
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ M: c-io-backend init-io ;
|
|||
stdout-handle <c-writer>
|
||||
stderr-handle <c-writer> ;
|
||||
|
||||
M: c-io-backend (init-stdio) init-c-stdio ;
|
||||
M: c-io-backend (init-stdio) init-c-stdio t ;
|
||||
|
||||
M: c-io-backend io-multiplex 60 60 * 1000 * 1000 * or (sleep) ;
|
||||
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
! Copyright (C) 2007, 2009 Slava Pestov.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: kernel io io.timeouts io.styles destructors ;
|
||||
USING: kernel io destructors io.streams.plain ;
|
||||
IN: io.streams.null
|
||||
|
||||
SINGLETONS: null-reader null-writer ;
|
||||
UNION: null-stream null-reader null-writer ;
|
||||
INSTANCE: null-writer plain-writer
|
||||
|
||||
M: null-stream dispose drop ;
|
||||
M: null-stream set-timeout 2drop ;
|
||||
|
||||
M: null-reader stream-readln drop f ;
|
||||
M: null-reader stream-read1 drop f ;
|
||||
|
@ -16,16 +16,10 @@ M: null-reader stream-read 2drop f ;
|
|||
|
||||
M: null-writer stream-write1 2drop ;
|
||||
M: null-writer stream-write 2drop ;
|
||||
M: null-writer stream-nl drop ;
|
||||
M: null-writer stream-flush drop ;
|
||||
M: null-writer stream-format 3drop ;
|
||||
M: null-writer make-span-stream nip ;
|
||||
M: null-writer make-block-stream nip ;
|
||||
M: null-writer make-cell-stream nip ;
|
||||
M: null-writer stream-write-table 3drop ;
|
||||
|
||||
: with-null-reader ( quot -- )
|
||||
null-reader swap with-input-stream* ; inline
|
||||
|
||||
: with-null-writer ( quot -- )
|
||||
null-writer swap with-output-stream* ; inline
|
||||
null-writer swap with-output-stream* ; inline
|
Loading…
Reference in New Issue