From: Doug Coleman Date: Thu, 16 Sep 2010 20:40:36 +0000 (-0500) Subject: Move win32-handle to windows.handles and update using lists to avoid pulling in the... X-Git-Tag: 0.97~4257^2~118 X-Git-Url: https://gitweb.factorcode.org/gitweb.cgi?p=factor.git;a=commitdiff_plain;h=5c8316be070bbea9b40f4bf2575610965925e8c7 Move win32-handle to windows.handles and update using lists to avoid pulling in the io backend where not necessary --- diff --git a/basis/io/backend/windows/nt/nt.factor b/basis/io/backend/windows/nt/nt.factor index aa8a61b87a..3114073c9d 100755 --- a/basis/io/backend/windows/nt/nt.factor +++ b/basis/io/backend/windows/nt/nt.factor @@ -1,11 +1,10 @@ -USING: alien alien.c-types alien.data alien.syntax 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 classes.struct -combinators.short-circuit ; +USING: accessors alien alien.c-types alien.data alien.syntax +arrays assocs classes.struct combinators +combinators.short-circuit destructors io io.backend +io.backend.windows io.buffers io.files.windows io.ports +io.streams.c io.streams.null io.timeouts kernel libc locals +math namespaces sequences system threads windows.errors +windows.handles windows.kernel32 ; IN: io.backend.windows.nt ! Global variable with assoc mapping overlapped to threads diff --git a/basis/io/backend/windows/windows.factor b/basis/io/backend/windows/windows.factor index 8864dff9ad..e0dd806212 100755 --- a/basis/io/backend/windows/windows.factor +++ b/basis/io/backend/windows/windows.factor @@ -1,37 +1,10 @@ -! Copyright (C) 2004, 2008 Mackenzie Straight, Doug Coleman. +! Copyright (C) 2004, 2010 Mackenzie Straight, Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. -USING: alien alien.c-types arrays destructors io io.backend -io.buffers io.files io.ports io.binary io.timeouts system -strings kernel math namespaces sequences windows.errors -windows.kernel32 windows.shell32 windows.types splitting -continuations math.bitwise accessors init sets assocs -classes.struct classes literals ; +USING: accessors alien.c-types classes.struct destructors +io.backend kernel literals windows.errors windows.handles +windows.kernel32 ; IN: io.backend.windows -TUPLE: win32-handle < disposable handle ; - -: set-inherit ( handle ? -- ) - [ handle>> HANDLE_FLAG_INHERIT ] dip - >BOOLEAN SetHandleInformation win32-error=0/f ; - -: new-win32-handle ( handle class -- win32-handle ) - new-disposable swap >>handle - dup f set-inherit ; - -: ( handle -- win32-handle ) - win32-handle new-win32-handle ; - -M: win32-handle dispose* ( handle -- ) - handle>> CloseHandle win32-error=0/f ; - -TUPLE: win32-file < win32-handle ptr ; - -: ( handle -- win32-file ) - win32-file new-win32-handle ; - -M: win32-file dispose - [ cancel-operation ] [ call-next-method ] bi ; - HOOK: CreateFile-flags io-backend ( DWORD -- DWORD ) HOOK: FileArgs-overlapped io-backend ( port -- overlapped/f ) HOOK: add-completion io-backend ( port -- ) @@ -47,7 +20,7 @@ CONSTANT: share-mode FILE_SHARE_WRITE FILE_SHARE_DELETE } - + : default-security-attributes ( -- obj ) SECURITY_ATTRIBUTES SECURITY_ATTRIBUTES heap-size >>nLength ; diff --git a/basis/io/launcher/windows/nt/nt.factor b/basis/io/launcher/windows/nt/nt.factor index 959bf93119..3651785242 100644 --- a/basis/io/launcher/windows/nt/nt.factor +++ b/basis/io/launcher/windows/nt/nt.factor @@ -1,11 +1,10 @@ ! Copyright (C) 2007, 2008 Doug Coleman, Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: alien alien.c-types arrays continuations destructors io -io.backend.windows libc io.ports io.pipes windows.types math -windows.kernel32 windows namespaces make io.launcher kernel -sequences windows.errors assocs splitting system strings -io.launcher.windows io.files.windows io.backend io.files -io.files.private combinators shuffle accessors locals ; +USING: accessors alien.c-types combinators destructors +io.backend io.backend.windows io.files.windows io.launcher +io.launcher.windows io.pipes io.ports kernel locals strings +system windows.errors windows.handles windows.kernel32 +windows.types ; IN: io.launcher.windows.nt : duplicate-handle ( handle -- handle' ) diff --git a/basis/io/mmap/windows/windows.factor b/basis/io/mmap/windows/windows.factor index b1191082b3..27382a5118 100644 --- a/basis/io/mmap/windows/windows.factor +++ b/basis/io/mmap/windows/windows.factor @@ -1,8 +1,7 @@ -USING: alien alien.c-types arrays destructors generic io.mmap -io.ports io.backend.windows io.files.windows io.backend.windows.privileges -io.mmap.private kernel libc math math.bitwise namespaces quotations sequences -windows windows.advapi32 windows.kernel32 io.backend system -accessors locals windows.errors literals ; +USING: accessors destructors io.backend.windows.privileges +io.files.windows io.mmap io.mmap.private kernel literals locals +math math.bitwise system windows.errors windows.handles +windows.kernel32 ; IN: io.mmap.windows : create-file-mapping ( hFile lpAttributes flProtect dwMaximumSizeHigh dwMaximumSizeLow lpName -- HANDLE ) diff --git a/basis/io/sockets/windows/windows.factor b/basis/io/sockets/windows/windows.factor index d14833e61e..3d9b3a6e14 100755 --- a/basis/io/sockets/windows/windows.factor +++ b/basis/io/sockets/windows/windows.factor @@ -1,8 +1,9 @@ ! Copyright (C) 2007, 2009 Slava Pestov, Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. -USING: kernel accessors io.sockets io.sockets.private -io.backend.windows io.backend windows.winsock system destructors -alien.c-types classes.struct combinators ; +USING: accessors alien.c-types classes.struct combinators +destructors io.backend io.backend.windows io.sockets +io.sockets.private kernel system windows.handles +windows.winsock ; FROM: namespaces => get ; IN: io.sockets.windows diff --git a/basis/random/windows/windows.factor b/basis/random/windows/windows.factor index 55d568f01d..0bf08b7878 100755 --- a/basis/random/windows/windows.factor +++ b/basis/random/windows/windows.factor @@ -1,8 +1,7 @@ -USING: accessors alien.c-types alien.data byte-arrays -combinators.short-circuit continuations destructors init kernel -locals namespaces random windows.advapi32 windows.errors -windows.kernel32 windows.types math.bitwise sequences fry -literals io.backend.windows ; +USING: accessors alien.data byte-arrays continuations +destructors init kernel literals locals namespaces random +sequences windows.advapi32 windows.errors windows.handles +windows.types ; IN: random.windows TUPLE: windows-crypto-context < win32-handle provider type ; diff --git a/basis/windows/handles/authors.txt b/basis/windows/handles/authors.txt new file mode 100644 index 0000000000..7c1b2f2279 --- /dev/null +++ b/basis/windows/handles/authors.txt @@ -0,0 +1 @@ +Doug Coleman diff --git a/basis/windows/handles/handles.factor b/basis/windows/handles/handles.factor new file mode 100644 index 0000000000..70ffdf80a6 --- /dev/null +++ b/basis/windows/handles/handles.factor @@ -0,0 +1,29 @@ +! Copyright (C) 2010 Doug Coleman. +! See http://factorcode.org/license.txt for BSD license. +USING: accessors destructors io.timeouts kernel windows.errors +windows.kernel32 windows.types ; +IN: windows.handles + +TUPLE: win32-handle < disposable handle ; + +: set-inherit ( handle ? -- ) + [ handle>> HANDLE_FLAG_INHERIT ] dip + >BOOLEAN SetHandleInformation win32-error=0/f ; + +: new-win32-handle ( handle class -- win32-handle ) + new-disposable swap >>handle + dup f set-inherit ; + +: ( handle -- win32-handle ) + win32-handle new-win32-handle ; + +M: win32-handle dispose* ( handle -- ) + handle>> CloseHandle win32-error=0/f ; + +TUPLE: win32-file < win32-handle ptr ; + +: ( handle -- win32-file ) + win32-file new-win32-handle ; + +M: win32-file dispose + [ cancel-operation ] [ call-next-method ] bi ; diff --git a/basis/windows/time/time.factor b/basis/windows/time/time.factor index 904c85200e..913e613312 100644 --- a/basis/windows/time/time.factor +++ b/basis/windows/time/time.factor @@ -2,7 +2,7 @@ ! See http://factorcode.org/license.txt for BSD license. USING: alien alien.c-types kernel math windows.errors windows.kernel32 windows.types namespaces calendar math.bitwise -accessors classes.struct ; +accessors classes.struct windows.handles ; IN: windows.time : >64bit ( lo hi -- n )