-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Win: define Win32 API functions #4832
Merged
Merged
Changes from 1 commit
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
54c41eb
function import from Windows shared libs
txe 6467ece
run file through format tool
txe b380d2d
put winapi bindings under src/lib_c/x86_64-windows-gnu
txe 9ab0fe2
WinError is subclass Errno
txe 47669e3
run file through format tool
txe 27b96fa
x86_64-windows-gnu was renamed x86_64-windows-msvc
txe 51ef5c6
injected 'win32' flag
txe 8501cdc
replace magic numbers with their respective constants
txe 6fa4c19
removed a duplication
txe 7392588
refactored winerror.cr
txe 9dc4c97
keep exact naming of structs and field as in MSDN
txe 9610937
add brackets
txe f416f6c
fun can start with with an uppercase letter
txe 00a6232
Revert "fun can start with with an uppercase letter"
txe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
lib LibC | ||
# source https://docs.microsoft.com/en-us/cpp/c-runtime-library/errno-doserrno-sys-errlist-and-sys-nerr | ||
EPERM = 1 | ||
ENOENT = 2 | ||
ESRCH = 3 | ||
EINTR = 4 | ||
EIO = 5 | ||
ENXIO = 6 | ||
E2BIG = 7 | ||
ENOEXEC = 8 | ||
EBADF = 9 | ||
ECHILD = 10 | ||
EAGAIN = 11 | ||
ENOMEM = 12 | ||
EACCES = 13 | ||
EFAULT = 14 | ||
EBUSY = 16 | ||
EEXIST = 17 | ||
EXDEV = 18 | ||
ENODEV = 19 | ||
ENOTDIR = 20 | ||
EISDIR = 21 | ||
EINVAL = 22 | ||
ENFILE = 23 | ||
EMFILE = 24 | ||
ENOTTY = 25 | ||
EFBIG = 27 | ||
ENOSPC = 28 | ||
ESPIPE = 29 | ||
EROFS = 30 | ||
EMLINK = 31 | ||
EPIPE = 32 | ||
EDOM = 33 | ||
ERANGE = 34 | ||
EDEADLK = 36 | ||
ENAMETOOLONG = 38 | ||
ENOLCK = 39 | ||
ENOSYS = 40 | ||
ENOTEMPTY = 41 | ||
EILSEQ = 42 | ||
STRUNCATE = 80 | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,82 +12,83 @@ class WinError < Errno | |
super "#{message}: [WinError #{code}, #{details}]", winerror_to_errno(code) | ||
end | ||
|
||
# https://github.com/python/cpython/blob/master/PC/generrmap.c | ||
# https://github.com/python/cpython/blob/master/PC/errmap.h | ||
def winerror_to_errno(winerror) | ||
case winerror | ||
when 2; return 2 | ||
when 3; return 2 | ||
when 4; return 24 | ||
when 5; return 13 | ||
when 6; return 9 | ||
when 7; return 12 | ||
when 8; return 12 | ||
when 9; return 12 | ||
when 10; return 7 | ||
when 11; return 8 | ||
when 15; return 2 | ||
when 16; return 13 | ||
when 17; return 18 | ||
when 18; return 2 | ||
when 19; return 13 | ||
when 20; return 13 | ||
when 21; return 13 | ||
when 22; return 13 | ||
when 23; return 13 | ||
when 24; return 13 | ||
when 25; return 13 | ||
when 26; return 13 | ||
when 27; return 13 | ||
when 28; return 13 | ||
when 29; return 13 | ||
when 30; return 13 | ||
when 31; return 13 | ||
when 32; return 13 | ||
when 33; return 13 | ||
when 34; return 13 | ||
when 35; return 13 | ||
when 36; return 13 | ||
when 53; return 2 | ||
when 65; return 13 | ||
when 67; return 2 | ||
when 80; return 17 | ||
when 82; return 13 | ||
when 83; return 13 | ||
when 89; return 11 | ||
when 108; return 13 | ||
when 109; return 32 | ||
when 112; return 28 | ||
when 114; return 9 | ||
when 128; return 10 | ||
when 129; return 10 | ||
when 130; return 9 | ||
when 132; return 13 | ||
when 145; return 41 | ||
when 158; return 13 | ||
when 161; return 2 | ||
when 164; return 11 | ||
when 167; return 13 | ||
when 183; return 17 | ||
when 188; return 8 | ||
when 189; return 8 | ||
when 190; return 8 | ||
when 191; return 8 | ||
when 192; return 8 | ||
when 193; return 8 | ||
when 194; return 8 | ||
when 195; return 8 | ||
when 196; return 8 | ||
when 197; return 8 | ||
when 198; return 8 | ||
when 199; return 8 | ||
when 200; return 8 | ||
when 201; return 8 | ||
when 202; return 8 | ||
when 206; return 2 | ||
when 215; return 11 | ||
when 232; return 32 | ||
when 267; return 20 | ||
when 1816; return 12 | ||
else return Errno::EINVAL | ||
when ERROR_FILE_NOT_FOUND ; return Errno::ENOENT | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You don't need semicolons. In fact you don't even need when ERROR_FILE_NOT_FOUND then Errno::ENOENT |
||
when ERROR_PATH_NOT_FOUND ; return Errno::ENOENT | ||
when ERROR_TOO_MANY_OPEN_FILES ; return Errno::EMFILE | ||
when ERROR_ACCESS_DENIED ; return Errno::EACCES | ||
when ERROR_INVALID_HANDLE ; return Errno::EBADF | ||
when ERROR_ARENA_TRASHED ; return Errno::ENOMEM | ||
when ERROR_NOT_ENOUGH_MEMORY ; return Errno::ENOMEM | ||
when ERROR_INVALID_BLOCK ; return Errno::ENOMEM | ||
when ERROR_BAD_ENVIRONMENT ; return Errno::E2BIG | ||
when ERROR_BAD_FORMAT ; return Errno::ENOEXEC | ||
when ERROR_INVALID_DRIVE ; return Errno::ENOENT | ||
when ERROR_CURRENT_DIRECTORY ; return Errno::EACCES | ||
when ERROR_NOT_SAME_DEVICE ; return Errno::EXDEV | ||
when ERROR_NO_MORE_FILES ; return Errno::ENOENT | ||
when ERROR_WRITE_PROTECT ; return Errno::EACCES | ||
when ERROR_BAD_UNIT ; return Errno::EACCES | ||
when ERROR_NOT_READY ; return Errno::EACCES | ||
when ERROR_BAD_COMMAND ; return Errno::EACCES | ||
when ERROR_CRC ; return Errno::EACCES | ||
when ERROR_BAD_LENGTH ; return Errno::EACCES | ||
when ERROR_SEEK ; return Errno::EACCES | ||
when ERROR_NOT_DOS_DISK ; return Errno::EACCES | ||
when ERROR_SECTOR_NOT_FOUND ; return Errno::EACCES | ||
when ERROR_OUT_OF_PAPER ; return Errno::EACCES | ||
when ERROR_WRITE_FAULT ; return Errno::EACCES | ||
when ERROR_READ_FAULT ; return Errno::EACCES | ||
when ERROR_GEN_FAILURE ; return Errno::EACCES | ||
when ERROR_SHARING_VIOLATION ; return Errno::EACCES | ||
when ERROR_LOCK_VIOLATION ; return Errno::EACCES | ||
when ERROR_WRONG_DISK ; return Errno::EACCES | ||
when ERROR_SHARING_BUFFER_EXCEEDED ; return Errno::EACCES | ||
when ERROR_BAD_NETPATH ; return Errno::ENOENT | ||
when ERROR_NETWORK_ACCESS_DENIED ; return Errno::EACCES | ||
when ERROR_BAD_NET_NAME ; return Errno::ENOENT | ||
when ERROR_FILE_EXISTS ; return Errno::EEXIST | ||
when ERROR_CANNOT_MAKE ; return Errno::EACCES | ||
when ERROR_FAIL_I24 ; return Errno::EACCES | ||
when ERROR_NO_PROC_SLOTS ; return Errno::EAGAIN | ||
when ERROR_DRIVE_LOCKED ; return Errno::EACCES | ||
when ERROR_BROKEN_PIPE ; return Errno::EPIPE | ||
when ERROR_DISK_FULL ; return Errno::ENOSPC | ||
when ERROR_INVALID_TARGET_HANDLE ; return Errno::EBADF | ||
when ERROR_WAIT_NO_CHILDREN ; return Errno::ECHILD | ||
when ERROR_CHILD_NOT_COMPLETE ; return Errno::ECHILD | ||
when ERROR_DIRECT_ACCESS_HANDLE ; return Errno::EBADF | ||
when ERROR_SEEK_ON_DEVICE ; return Errno::EACCES | ||
when ERROR_DIR_NOT_EMPTY ; return Errno::ENOTEMPTY | ||
when ERROR_NOT_LOCKED ; return Errno::EACCES | ||
when ERROR_BAD_PATHNAME ; return Errno::ENOENT | ||
when ERROR_MAX_THRDS_REACHED ; return Errno::EAGAIN | ||
when ERROR_LOCK_FAILED ; return Errno::EACCES | ||
when ERROR_ALREADY_EXISTS ; return Errno::EEXIST | ||
when ERROR_INVALID_STARTING_CODESEG ; return Errno::ENOEXEC | ||
when ERROR_INVALID_STACKSEG ; return Errno::ENOEXEC | ||
when ERROR_INVALID_MODULETYPE ; return Errno::ENOEXEC | ||
when ERROR_INVALID_EXE_SIGNATURE ; return Errno::ENOEXEC | ||
when ERROR_EXE_MARKED_INVALID ; return Errno::ENOEXEC | ||
when ERROR_BAD_EXE_FORMAT ; return Errno::ENOEXEC | ||
when ERROR_ITERATED_DATA_EXCEEDS_64k; return Errno::ENOEXEC | ||
when ERROR_INVALID_MINALLOCSIZE ; return Errno::ENOEXEC | ||
when ERROR_DYNLINK_FROM_INVALID_RING; return Errno::ENOEXEC | ||
when ERROR_IOPL_NOT_ENABLED ; return Errno::ENOEXEC | ||
when ERROR_INVALID_SEGDPL ; return Errno::ENOEXEC | ||
when ERROR_AUTODATASEG_EXCEEDS_64k ; return Errno::ENOEXEC | ||
when ERROR_RING2SEG_MUST_BE_MOVABLE ; return Errno::ENOEXEC | ||
when ERROR_RELOC_CHAIN_XEEDS_SEGLIM ; return Errno::ENOEXEC | ||
when ERROR_INFLOOP_IN_RELOC_CHAIN ; return Errno::ENOEXEC | ||
when ERROR_FILENAME_EXCED_RANGE ; return Errno::ENOENT | ||
when ERROR_NESTING_NOT_ALLOWED ; return Errno::EAGAIN | ||
when ERROR_NO_DATA ; return Errno::EPIPE | ||
when ERROR_DIRECTORY ; return Errno::ENOTDIR | ||
when ERROR_NOT_ENOUGH_QUOTA ; return Errno::ENOMEM | ||
else return Errno::EINVAL | ||
end | ||
end | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a tiny subjective nitpick, can we have brackets here (
super("#{message}: [WinError #{code}, #{details}]", winerror_to_errno(code))
), it looks weird without (I actually missed thewinerror_to_errno
call).