factor/unmaintained/ce/backend/backend.factor

51 lines
1.4 KiB
Factor
Raw Normal View History

2008-05-13 19:24:46 -04:00
USING: io.ports io.windows threads.private kernel
2007-11-07 14:01:45 -05:00
io.backend windows.winsock windows.kernel32 windows
2007-11-09 03:01:45 -05:00
io.streams.duplex io namespaces alien.syntax system combinators
io.buffers io.encodings io.encodings.utf8 combinators.lib ;
2007-11-06 20:44:45 -05:00
IN: io.windows.ce.backend
: port-errored ( port -- )
win32-error-string swap set-port-error ;
2008-04-02 21:09:56 -04:00
M: wince io-multiplex ( ms -- )
2008-02-21 21:57:41 -05:00
60 60 * 1000 * or (sleep) ;
2008-04-02 21:09:56 -04:00
M: wince add-completion ( handle -- ) drop ;
2007-11-06 20:44:45 -05:00
GENERIC: wince-read ( port port-handle -- )
M: input-port (wait-to-read) ( port -- )
dup dup port-handle wince-read pending-error ;
2007-11-06 20:44:45 -05:00
GENERIC: wince-write ( port port-handle -- )
2007-11-09 03:01:45 -05:00
M: port port-flush
dup buffer-empty? over port-error or [
drop
] [
dup dup port-handle wince-write port-flush
] if ;
2007-11-06 20:44:45 -05:00
2008-04-02 21:09:56 -04:00
M: wince init-io ( -- )
2007-11-06 20:44:45 -05:00
init-winsock ;
2007-11-07 14:01:45 -05:00
LIBRARY: libc
FUNCTION: void* _getstdfilex int fd ;
FUNCTION: void* _fileno void* file ;
2008-04-02 21:09:56 -04:00
M: wince (init-stdio) ( -- )
2007-11-07 14:01:45 -05:00
#! We support Windows NT too, to make this I/O backend
#! easier to debug.
2007-11-09 03:01:45 -05:00
512 default-buffer-size [
2008-04-02 19:25:33 -04:00
os winnt? [
2007-11-07 14:01:45 -05:00
STD_INPUT_HANDLE GetStdHandle
STD_OUTPUT_HANDLE GetStdHandle
STD_ERROR_HANDLE GetStdHandle
2007-11-07 14:01:45 -05:00
] [
0 _getstdfilex _fileno
1 _getstdfilex _fileno
2 _getstdfilex _fileno
] if [ f <win32-file> ] 3apply
[ <input-port> ] [ <output-port> ] [ <output-port> ] tri*
] with-variable ;