Clean up init-stdio implementations and move io.streams.null to basis
parent
6e08e29a3a
commit
96b1ae86a4
|
@ -173,10 +173,11 @@ M: stdin refill
|
|||
size-read-fd <fd> init-fd <input-port> >>size
|
||||
data-read-fd <fd> >>data ;
|
||||
|
||||
M: unix (init-stdio)
|
||||
M: unix init-stdio
|
||||
<stdin> <input-port>
|
||||
1 <fd> <output-port>
|
||||
2 <fd> <output-port> t ;
|
||||
2 <fd> <output-port>
|
||||
set-stdio ;
|
||||
|
||||
! mx io-task for embedding an fd-based mx inside another mx
|
||||
TUPLE: mx-port < port mx ;
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
USING: alien alien.c-types arrays assocs combinators
|
||||
continuations destructors io io.backend io.ports io.timeouts
|
||||
io.backend.windows io.files.windows io.files.windows.nt io.files
|
||||
io.pathnames io.buffers io.streams.c libc kernel math namespaces
|
||||
sequences threads windows windows.errors windows.kernel32
|
||||
strings splitting ascii system accessors locals ;
|
||||
USING: alien alien.c-types arrays assocs combinators continuations
|
||||
destructors io io.backend io.ports io.timeouts io.backend.windows
|
||||
io.files.windows io.files.windows.nt io.files io.pathnames io.buffers
|
||||
io.streams.c io.streams.null libc kernel math namespaces sequences
|
||||
threads windows windows.errors windows.kernel32 strings splitting
|
||||
ascii system accessors locals ;
|
||||
QUALIFIED: windows.winsock
|
||||
IN: io.backend.windows.nt
|
||||
|
||||
|
@ -140,7 +140,9 @@ M: winnt (wait-to-read) ( port -- )
|
|||
|
||||
: console-app? ( -- ? ) GetConsoleWindow >boolean ;
|
||||
|
||||
M: winnt (init-stdio)
|
||||
console-app? [ init-c-stdio t ] [ f f f f ] if ;
|
||||
M: winnt init-stdio
|
||||
console-app?
|
||||
[ init-c-stdio ]
|
||||
[ null-reader null-writer null-writer init-stdio ] if ;
|
||||
|
||||
winnt set-io-backend
|
||||
|
|
|
@ -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.streams.null ;
|
||||
io.encodings.utf8 init assocs splitting alien ;
|
||||
IN: io.backend
|
||||
|
||||
SYMBOL: io-backend
|
||||
|
@ -12,22 +12,12 @@ io-backend [ c-io-backend ] initialize
|
|||
|
||||
HOOK: init-io io-backend ( -- )
|
||||
|
||||
HOOK: (init-stdio) io-backend ( -- stdin stdout stderr ? )
|
||||
HOOK: init-stdio io-backend ( -- )
|
||||
|
||||
: 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> ]
|
||||
[ utf8 <encoder> ]
|
||||
[ utf8 <encoder> ] tri*
|
||||
] [
|
||||
3drop
|
||||
null-reader null-writer null-writer
|
||||
] if set-stdio ;
|
||||
: set-stdio ( input output error -- )
|
||||
[ utf8 <decoder> input-stream set-global ]
|
||||
[ utf8 <encoder> output-stream set-global ]
|
||||
[ utf8 <encoder> error-stream set-global ] tri* ;
|
||||
|
||||
HOOK: io-multiplex io-backend ( us -- )
|
||||
|
||||
|
|
|
@ -60,12 +60,13 @@ M: c-io-backend init-io ;
|
|||
: stdout-handle ( -- alien ) 12 getenv ;
|
||||
: stderr-handle ( -- alien ) 61 getenv ;
|
||||
|
||||
: init-c-stdio ( -- stdin stdout stderr )
|
||||
: init-c-stdio ( -- )
|
||||
stdin-handle <c-reader>
|
||||
stdout-handle <c-writer>
|
||||
stderr-handle <c-writer> ;
|
||||
stderr-handle <c-writer>
|
||||
set-stdio ;
|
||||
|
||||
M: c-io-backend (init-stdio) init-c-stdio t ;
|
||||
M: c-io-backend init-stdio init-c-stdio ;
|
||||
|
||||
M: c-io-backend io-multiplex 60 60 * 1000 * 1000 * or (sleep) ;
|
||||
|
||||
|
|
Loading…
Reference in New Issue