Make sure io.backend.windows loads the implementations for the generics it defines. Make windows.handles not depend on io.timeouts. Fix typo in win32-file-attributes. Fix bug in null-output word. Clean up error checking code.
parent
04be762fac
commit
7122f9fccb
|
@ -3,8 +3,8 @@ arrays assocs classes.struct combinators
|
||||||
combinators.short-circuit destructors io io.backend
|
combinators.short-circuit destructors io io.backend
|
||||||
io.backend.windows io.buffers io.files.windows io.ports
|
io.backend.windows io.buffers io.files.windows io.ports
|
||||||
io.streams.c io.streams.null io.timeouts kernel libc locals
|
io.streams.c io.streams.null io.timeouts kernel libc locals
|
||||||
math namespaces sequences system threads windows.errors
|
math namespaces sequences system threads vocabs.loader
|
||||||
windows.handles windows.kernel32 ;
|
windows.errors windows.handles windows.kernel32 ;
|
||||||
IN: io.backend.windows.nt
|
IN: io.backend.windows.nt
|
||||||
|
|
||||||
! Global variable with assoc mapping overlapped to threads
|
! Global variable with assoc mapping overlapped to threads
|
||||||
|
@ -32,8 +32,8 @@ SYMBOL: master-completion-port
|
||||||
: <master-completion-port> ( -- handle )
|
: <master-completion-port> ( -- handle )
|
||||||
INVALID_HANDLE_VALUE f <completion-port> ;
|
INVALID_HANDLE_VALUE f <completion-port> ;
|
||||||
|
|
||||||
M: winnt add-completion ( win32-handle -- )
|
M: winnt add-completion ( win32-handle -- win32-handle )
|
||||||
handle>> master-completion-port get-global <completion-port> drop ;
|
dup handle>> master-completion-port get-global <completion-port> drop ;
|
||||||
|
|
||||||
: eof? ( error -- ? )
|
: eof? ( error -- ? )
|
||||||
{ [ ERROR_HANDLE_EOF = ] [ ERROR_BROKEN_PIPE = ] } 1|| ;
|
{ [ ERROR_HANDLE_EOF = ] [ ERROR_BROKEN_PIPE = ] } 1|| ;
|
||||||
|
@ -144,4 +144,5 @@ M: winnt init-stdio
|
||||||
[ init-c-stdio ]
|
[ init-c-stdio ]
|
||||||
[ null-reader null-writer null-writer set-stdio ] if ;
|
[ null-reader null-writer null-writer set-stdio ] if ;
|
||||||
|
|
||||||
|
"io.files.windows.nt" require
|
||||||
winnt set-io-backend
|
winnt set-io-backend
|
||||||
|
|
|
@ -1,18 +1,24 @@
|
||||||
! Copyright (C) 2004, 2010 Mackenzie Straight, Doug Coleman.
|
! Copyright (C) 2004, 2010 Mackenzie Straight, Doug Coleman.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: accessors alien.c-types classes.struct destructors
|
USING: accessors alien.c-types classes.struct destructors
|
||||||
io.backend kernel literals windows.errors windows.handles
|
io.backend io.timeouts kernel literals windows.errors
|
||||||
windows.kernel32 ;
|
windows.handles windows.kernel32 vocabs.loader ;
|
||||||
IN: io.backend.windows
|
IN: io.backend.windows
|
||||||
|
|
||||||
HOOK: CreateFile-flags io-backend ( DWORD -- DWORD )
|
HOOK: CreateFile-flags io-backend ( DWORD -- DWORD )
|
||||||
HOOK: FileArgs-overlapped io-backend ( port -- overlapped/f )
|
HOOK: FileArgs-overlapped io-backend ( port -- overlapped/f )
|
||||||
HOOK: add-completion io-backend ( port -- )
|
HOOK: add-completion io-backend ( port -- port )
|
||||||
|
|
||||||
|
TUPLE: win32-file < win32-handle ptr ;
|
||||||
|
|
||||||
|
: <win32-file> ( handle -- win32-file )
|
||||||
|
win32-file new-win32-handle ;
|
||||||
|
|
||||||
|
M: win32-file dispose
|
||||||
|
[ cancel-operation ] [ call-next-method ] bi ;
|
||||||
|
|
||||||
: opened-file ( handle -- win32-file )
|
: opened-file ( handle -- win32-file )
|
||||||
dup invalid-handle?
|
check-invalid-handle <win32-file> |dispose add-completion ;
|
||||||
<win32-file> |dispose
|
|
||||||
dup add-completion ;
|
|
||||||
|
|
||||||
CONSTANT: share-mode
|
CONSTANT: share-mode
|
||||||
flags{
|
flags{
|
||||||
|
@ -24,3 +30,5 @@ CONSTANT: share-mode
|
||||||
: default-security-attributes ( -- obj )
|
: default-security-attributes ( -- obj )
|
||||||
SECURITY_ATTRIBUTES <struct>
|
SECURITY_ATTRIBUTES <struct>
|
||||||
SECURITY_ATTRIBUTES heap-size >>nLength ;
|
SECURITY_ATTRIBUTES heap-size >>nLength ;
|
||||||
|
|
||||||
|
"io.files.windows" require
|
|
@ -2,8 +2,7 @@ USING: accessors alien.c-types alien.strings classes.struct
|
||||||
combinators combinators.short-circuit continuations environment
|
combinators combinators.short-circuit continuations environment
|
||||||
io.backend io.backend.windows io.encodings.utf16n
|
io.backend io.backend.windows io.encodings.utf16n
|
||||||
io.files.private io.files.windows io.pathnames kernel math
|
io.files.private io.files.windows io.pathnames kernel math
|
||||||
sequences specialized-arrays
|
sequences specialized-arrays system tr
|
||||||
specialized-arrays.instances.alien.c-types.ushort system tr
|
|
||||||
windows windows.errors windows.kernel32 windows.shell32
|
windows windows.errors windows.kernel32 windows.shell32
|
||||||
windows.time ;
|
windows.time ;
|
||||||
SPECIALIZED-ARRAY: ushort
|
SPECIALIZED-ARRAY: ushort
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: accessors alien.c-types alien.data combinators
|
USING: accessors alien.c-types alien.data combinators
|
||||||
destructors io.backend.windows io.binary io.buffers io.files
|
destructors io.backend.windows io.binary io.buffers io.files
|
||||||
io.files.types io.ports kernel literals make math.bitwise
|
io.files.types io.ports kernel literals make
|
||||||
system windows.errors windows.handles windows.kernel32
|
math.bitwise system windows.errors windows.handles
|
||||||
windows.time windows.types ;
|
windows.kernel32 windows.time windows.types vocabs.loader ;
|
||||||
IN: io.files.windows
|
IN: io.files.windows
|
||||||
|
|
||||||
: open-file ( path access-mode create-mode flags -- handle )
|
: open-file ( path access-mode create-mode flags -- handle )
|
||||||
|
@ -98,7 +98,7 @@ SYMBOLS: +read-only+ +hidden+ +system+
|
||||||
+sparse-file+ +reparse-point+ +compressed+ +offline+
|
+sparse-file+ +reparse-point+ +compressed+ +offline+
|
||||||
+not-content-indexed+ +encrypted+ ;
|
+not-content-indexed+ +encrypted+ ;
|
||||||
|
|
||||||
: win32-file-attribute ( n attr symbol -- )
|
: win32-file-attribute ( n symbol attr -- )
|
||||||
rot mask? [ , ] [ drop ] if ;
|
rot mask? [ , ] [ drop ] if ;
|
||||||
|
|
||||||
: win32-file-attributes ( n -- seq )
|
: win32-file-attributes ( n -- seq )
|
||||||
|
@ -127,3 +127,5 @@ SYMBOLS: +read-only+ +hidden+ +system+
|
||||||
: (set-file-times) ( handle timestamp/f timestamp/f timestamp/f -- )
|
: (set-file-times) ( handle timestamp/f timestamp/f timestamp/f -- )
|
||||||
[ timestamp>FILETIME ] tri@
|
[ timestamp>FILETIME ] tri@
|
||||||
SetFileTime win32-error=0/f ;
|
SetFileTime win32-error=0/f ;
|
||||||
|
|
||||||
|
"io.files.windows.nt" require
|
|
@ -23,7 +23,7 @@ IN: io.launcher.windows.nt
|
||||||
(pipe) [ in>> &dispose ] [ out>> dispose ] bi ;
|
(pipe) [ in>> &dispose ] [ out>> dispose ] bi ;
|
||||||
|
|
||||||
: null-output ( -- pipe )
|
: null-output ( -- pipe )
|
||||||
(pipe) [ in>> dispose ] [ out>> &dispose ] bi ;
|
(pipe) [ out>> &dispose ] [ in>> dispose ] bi ;
|
||||||
|
|
||||||
: null-pipe ( mode -- pipe )
|
: null-pipe ( mode -- pipe )
|
||||||
{
|
{
|
||||||
|
@ -48,7 +48,7 @@ IN: io.launcher.windows.nt
|
||||||
create-mode
|
create-mode
|
||||||
FILE_ATTRIBUTE_NORMAL ! flags and attributes
|
FILE_ATTRIBUTE_NORMAL ! flags and attributes
|
||||||
f ! template file
|
f ! template file
|
||||||
CreateFile dup invalid-handle? <win32-file> &dispose ;
|
CreateFile check-invalid-handle <win32-file> &dispose ;
|
||||||
|
|
||||||
: redirect-append ( path access-mode create-mode -- handle )
|
: redirect-append ( path access-mode create-mode -- handle )
|
||||||
[ path>> ] 2dip
|
[ path>> ] 2dip
|
||||||
|
|
|
@ -38,7 +38,7 @@ M: win32-socket dispose* ( stream -- )
|
||||||
[ empty-sockaddr/size ] [ protocol-family ] bi pick family<< ;
|
[ empty-sockaddr/size ] [ protocol-family ] bi pick family<< ;
|
||||||
|
|
||||||
: opened-socket ( handle -- win32-socket )
|
: opened-socket ( handle -- win32-socket )
|
||||||
<win32-socket> |dispose dup add-completion ;
|
<win32-socket> |dispose add-completion ;
|
||||||
|
|
||||||
: open-socket ( addrspec type -- win32-socket )
|
: open-socket ( addrspec type -- win32-socket )
|
||||||
[ protocol-family ] dip
|
[ protocol-family ] dip
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
! Copyright (C) 2008 Slava Pestov, Doug Coleman
|
! Copyright (C) 2008 Slava Pestov, Doug Coleman
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: kernel calendar timers io io.encodings accessors
|
USING: accessors fry io io.encodings io.streams.null kernel
|
||||||
namespaces fry io.streams.null ;
|
namespaces timers ;
|
||||||
IN: io.timeouts
|
IN: io.timeouts
|
||||||
|
|
||||||
GENERIC: timeout ( obj -- dt/f )
|
GENERIC: timeout ( obj -- dt/f )
|
||||||
|
|
|
@ -734,10 +734,8 @@ ERROR: windows-error n string ;
|
||||||
: win32-error<0 ( n -- ) 0 < [ win32-error ] when ;
|
: win32-error<0 ( n -- ) 0 < [ win32-error ] when ;
|
||||||
: win32-error<>0 ( n -- ) zero? [ win32-error ] unless ;
|
: win32-error<>0 ( n -- ) zero? [ win32-error ] unless ;
|
||||||
|
|
||||||
: invalid-handle? ( handle -- )
|
: check-invalid-handle ( handle -- handle )
|
||||||
INVALID_HANDLE_VALUE = [
|
dup INVALID_HANDLE_VALUE = [ win32-error-string throw ] when ;
|
||||||
win32-error-string throw
|
|
||||||
] when ;
|
|
||||||
|
|
||||||
CONSTANT: expected-io-errors
|
CONSTANT: expected-io-errors
|
||||||
${
|
${
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
! Copyright (C) 2010 Doug Coleman.
|
! Copyright (C) 2010 Doug Coleman.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: accessors destructors io.timeouts kernel windows.errors
|
USING: accessors destructors kernel windows.errors
|
||||||
windows.kernel32 windows.types ;
|
windows.kernel32 windows.types ;
|
||||||
IN: windows.handles
|
IN: windows.handles
|
||||||
|
|
||||||
|
@ -19,11 +19,3 @@ TUPLE: win32-handle < disposable handle ;
|
||||||
|
|
||||||
M: win32-handle dispose* ( handle -- )
|
M: win32-handle dispose* ( handle -- )
|
||||||
handle>> CloseHandle win32-error=0/f ;
|
handle>> CloseHandle win32-error=0/f ;
|
||||||
|
|
||||||
TUPLE: win32-file < win32-handle ptr ;
|
|
||||||
|
|
||||||
: <win32-file> ( handle -- win32-file )
|
|
||||||
win32-file new-win32-handle ;
|
|
||||||
|
|
||||||
M: win32-file dispose
|
|
||||||
[ cancel-operation ] [ call-next-method ] bi ;
|
|
||||||
|
|
Loading…
Reference in New Issue