factor/extra/io/windows/ce/backend/backend.factor

46 lines
1.3 KiB
Factor
Raw Normal View History

2007-11-06 20:44:45 -05:00
USING: io.nonblocking 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
2008-02-22 21:41:14 -05:00
io.buffers io.encodings io.encodings.utf8 ;
2007-11-06 20:44:45 -05:00
IN: io.windows.ce.backend
: port-errored ( port -- )
win32-error-string swap set-port-error ;
M: windows-ce-io io-multiplex ( ms -- ) (sleep) ;
2008-01-28 00:59:36 -05:00
M: windows-ce-io 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
M: windows-ce-io init-io ( -- )
init-winsock ;
2007-11-07 14:01:45 -05:00
LIBRARY: libc
FUNCTION: void* _getstdfilex int fd ;
FUNCTION: void* _fileno void* file ;
M: windows-ce-io init-stdio ( -- )
#! 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 [
2007-11-07 14:01:45 -05:00
winnt? [
STD_INPUT_HANDLE GetStdHandle
STD_OUTPUT_HANDLE GetStdHandle
] [
0 _getstdfilex _fileno
1 _getstdfilex _fileno
2008-02-22 21:41:14 -05:00
] if <win32-duplex-stream> utf8 <encoded-duplex>
2008-01-09 01:50:25 -05:00
] with-variable stdio set-global ;