]> gitweb.factorcode.org Git - factor.git/commitdiff
use structs in a few places in windows backend
authorDoug Coleman <doug.coleman@gmail.com>
Tue, 25 Aug 2009 22:23:23 +0000 (17:23 -0500)
committerDoug Coleman <doug.coleman@gmail.com>
Tue, 25 Aug 2009 22:23:23 +0000 (17:23 -0500)
basis/io/backend/windows/nt/nt.factor
basis/io/backend/windows/windows.factor
basis/io/files/info/windows/windows.factor
basis/windows/kernel32/kernel32.factor

index 69a695ac7205826bd6fffb2575150f09b01f1ce3..e29aa6c6188b70ed5683c7791adef1557113fa5c 100755 (executable)
@@ -3,7 +3,7 @@ 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 ;
+ascii system accessors locals classes.struct ;
 QUALIFIED: windows.winsock
 IN: io.backend.windows.nt
 
index 5922e217b0ef299e9f7b536906db9a79e7fbf219..c7be2229ccefa061e2659e0a4e8c23b77fea2409 100755 (executable)
@@ -4,7 +4,8 @@ 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 windows.winsock
-splitting continuations math.bitwise accessors init sets assocs ;
+splitting continuations math.bitwise accessors init sets assocs
+classes.struct classes ;
 IN: io.backend.windows
 
 TUPLE: win32-handle < disposable handle ;
@@ -50,6 +51,5 @@ HOOK: add-completion io-backend ( port -- )
     } flags ; foldable
 
 : default-security-attributes ( -- obj )
-    "SECURITY_ATTRIBUTES" <c-object>
-    "SECURITY_ATTRIBUTES" heap-size
-    over set-SECURITY_ATTRIBUTES-nLength ;
+    SECURITY_ATTRIBUTES <struct>
+    dup class heap-size >>nLength ;
index 38165e4267819d36c9e61c546afa7dc2aa0a1601..248eacf571dd3b54432f99e6cc89b2d24c96cc1b 100755 (executable)
@@ -5,7 +5,7 @@ io.files.windows io.files.windows.nt kernel windows.kernel32
 windows.time windows accessors alien.c-types combinators
 generalizations system alien.strings io.encodings.utf16n
 sequences splitting windows.errors fry continuations destructors
-calendar ascii combinators.short-circuit locals ;
+calendar ascii combinators.short-circuit locals classes.struct ;
 IN: io.files.info.windows
 
 :: round-up-to ( n multiple -- n' )
@@ -57,35 +57,26 @@ TUPLE: windows-file-info < file-info attributes ;
 : BY_HANDLE_FILE_INFORMATION>file-info ( HANDLE_FILE_INFORMATION -- file-info )
     [ \ windows-file-info new ] dip
     {
-        [ BY_HANDLE_FILE_INFORMATION-dwFileAttributes win32-file-type >>type ]
-        [ BY_HANDLE_FILE_INFORMATION-dwFileAttributes win32-file-attributes >>attributes ]
+        [ dwFileAttributes>> win32-file-type >>type ]
+        [ dwFileAttributes>> win32-file-attributes >>attributes ]
         [
-            [ BY_HANDLE_FILE_INFORMATION-nFileSizeLow ]
-            [ BY_HANDLE_FILE_INFORMATION-nFileSizeHigh ] bi >64bit >>size
+            [ nFileSizeLow>> ]
+            [ nFileSizeHigh>> ] bi >64bit >>size
         ]
-        [ BY_HANDLE_FILE_INFORMATION-dwFileAttributes >>permissions ]
-        [
-            BY_HANDLE_FILE_INFORMATION-ftCreationTime
-            FILETIME>timestamp >>created
-        ]
-        [
-            BY_HANDLE_FILE_INFORMATION-ftLastWriteTime
-            FILETIME>timestamp >>modified
-        ]
-        [
-            BY_HANDLE_FILE_INFORMATION-ftLastAccessTime
-            FILETIME>timestamp >>accessed
-        ]
-        ! [ BY_HANDLE_FILE_INFORMATION-nNumberOfLinks ]
+        [ dwFileAttributes>> >>permissions ]
+        [ ftCreationTime>> FILETIME>timestamp >>created ]
+        [ ftLastWriteTime>> FILETIME>timestamp >>modified ]
+        [ ftLastAccessTime>> FILETIME>timestamp >>accessed ]
+        ! [ nNumberOfLinks>> ]
         ! [
-          ! [ BY_HANDLE_FILE_INFORMATION-nFileIndexLow ]
-          ! [ BY_HANDLE_FILE_INFORMATION-nFileIndexHigh ] bi >64bit
+          ! [ nFileIndexLow>> ]
+          ! [ nFileIndexHigh>> ] bi >64bit
         ! ]
     } cleave ;
 
 : get-file-information ( handle -- BY_HANDLE_FILE_INFORMATION )
     [
-        "BY_HANDLE_FILE_INFORMATION" <c-object>
+        BY_HANDLE_FILE_INFORMATION <struct>
         [ GetFileInformationByHandle win32-error=0/f ] keep
     ] keep CloseHandle win32-error=0/f ;
 
index 38c63abc725d03d2651dfe978231c68931bb4a06..d1fee4c3889e272806839df03daf79644fb4e32d 100755 (executable)
@@ -1,6 +1,7 @@
 ! Copyright (C) 2005, 2006 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: alien alien.syntax kernel windows.types multiline ;
+USING: alien alien.syntax kernel windows.types multiline
+classes.struct ;
 IN: windows.kernel32
 
 CONSTANT: MAX_PATH 260
@@ -707,17 +708,17 @@ C-STRUCT: WIN32_FIND_DATA
     { { "TCHAR" 260 } "cFileName" }
     { { "TCHAR" 14 } "cAlternateFileName" } ;
 
-C-STRUCT: BY_HANDLE_FILE_INFORMATION
-    { "DWORD" "dwFileAttributes" }
-    { "FILETIME" "ftCreationTime" }
-    { "FILETIME" "ftLastAccessTime" }
-    { "FILETIME" "ftLastWriteTime" }
-    { "DWORD" "dwVolumeSerialNumber" }
-    { "DWORD" "nFileSizeHigh" }
-    { "DWORD" "nFileSizeLow" }
-    { "DWORD" "nNumberOfLinks" }
-    { "DWORD" "nFileIndexHigh" }
-    { "DWORD" "nFileIndexLow" } ;
+STRUCT: BY_HANDLE_FILE_INFORMATION
+    { dwFileAttributes DWORD }
+    { ftCreationTime FILETIME }
+    { ftLastAccessTime FILETIME }
+    { ftLastWriteTime FILETIME }
+    { dwVolumeSerialNumber DWORD }
+    { nFileSizeHigh DWORD }
+    { nFileSizeLow DWORD }
+    { nNumberOfLinks DWORD }
+    { nFileIndexHigh DWORD }
+    { nFileIndexLow DWORD } ;
 
 TYPEDEF: WIN32_FIND_DATA* PWIN32_FIND_DATA
 TYPEDEF: WIN32_FIND_DATA* LPWIN32_FIND_DATA
@@ -737,10 +738,10 @@ TYPEDEF: PFILETIME LPFILETIME
 
 TYPEDEF: int GET_FILEEX_INFO_LEVELS
 
-C-STRUCT: SECURITY_ATTRIBUTES
-    { "DWORD" "nLength" }
-    { "LPVOID" "lpSecurityDescriptor" }
-    { "BOOL" "bInheritHandle" } ;
+STRUCT: SECURITY_ATTRIBUTES
+    { nLength DWORD }
+    { lpSecurityDescriptor LPVOID }
+    { bInheritHandle BOOL } ;
 
 CONSTANT: HANDLE_FLAG_INHERIT 1
 CONSTANT: HANDLE_FLAG_PROTECT_FROM_CLOSE 2