]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/windows/errors/errors.factor
Merge branch 'master' of git://factorcode.org/git/factor into struct-updates
[factor.git] / basis / windows / errors / errors.factor
index e08704d46970102f21a3e48e639834417b1a13ec..5a1bf74d19e04a860715b866fa6e8d7a1ff9b73f 100644 (file)
@@ -1,9 +1,11 @@
 USING: alien.c-types kernel locals math math.bitwise
 windows.kernel32 sequences byte-arrays unicode.categories
 io.encodings.string io.encodings.utf16n alien.strings
-arrays ;
+arrays literals ;
 IN: windows.errors
 
+<< "TCHAR" require-c-arrays >>
+
 CONSTANT: ERROR_SUCCESS                               0
 CONSTANT: ERROR_INVALID_FUNCTION                      1
 CONSTANT: ERROR_FILE_NOT_FOUND                        2
@@ -696,6 +698,8 @@ CONSTANT: FORMAT_MESSAGE_MAX_WIDTH_MASK   HEX: 000000FF
 : make-lang-id ( lang1 lang2 -- n )
     10 shift bitor ; inline
 
+<< "TCHAR" require-c-arrays >>
+
 ERROR: error-message-failed id ;
 :: n>win32-error-string ( id -- string )
     {
@@ -705,7 +709,7 @@ ERROR: error-message-failed id ;
     f
     id
     LANG_NEUTRAL SUBLANG_DEFAULT make-lang-id
-    32768 [ "TCHAR" <c-array> ] keep 
+    32768 [ "TCHAR" <c-array> ] [ ] bi
     f pick [ FormatMessage 0 = [ id error-message-failed ] when ] dip
     utf16n alien>string [ blank? ] trim ;
 
@@ -713,11 +717,7 @@ ERROR: error-message-failed id ;
     GetLastError n>win32-error-string ;
 
 : (win32-error) ( n -- )
-    dup zero? [
-        drop
-    ] [
-        win32-error-string throw
-    ] if ;
+    [ win32-error-string throw ] unless-zero ;
 
 : win32-error ( -- )
     GetLastError (win32-error) ;
@@ -732,11 +732,13 @@ ERROR: error-message-failed id ;
         win32-error-string throw
     ] when ;
 
-: expected-io-errors ( -- seq )
-    ERROR_SUCCESS
-    ERROR_IO_INCOMPLETE
-    ERROR_IO_PENDING
-    WAIT_TIMEOUT 4array ; foldable
+CONSTANT: expected-io-errors
+    ${
+        ERROR_SUCCESS
+        ERROR_IO_INCOMPLETE
+        ERROR_IO_PENDING
+        WAIT_TIMEOUT
+    }
 
 : expected-io-error? ( error-code -- ? )
     expected-io-errors member? ;