-
Notifications
You must be signed in to change notification settings - Fork 17
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
Implement windows
backend without windows-sys
#96
Conversation
9ecc98c
to
41172b5
Compare
082e3a0
to
9ea50b2
Compare
windows
backend without windows-sys
Tested successfully with {x86_64,i686}-pc-windows-{msvc,gnu}. It cross-compiles successfully for aarch64-pc-windows-msvc, but I have no device to test it on. |
9ea50b2
to
54c10b6
Compare
This PR removes the `windows-sys` and `winapi` dependency completely. Instead, the relevant API was extracted from `windows-sys`, which in turn is generated from Windows's header files. The only Windows specific depency now is `windows-targets`, which was a transitive dependency before. It contains the proper mappings between a function name, its mangled name, and its `.dll`. The rationale for this change is that the previously used `winapi` crate is unmaintained for the last three years, even though it contains some (minor) errors. The alternative to `winapi`, `windows-sys` is still fast moving. In its (at the time of writing this PR) newest release 0.45.0 it removed all WinRT functions, so it arguably does not any function we need to implement our library anymore.
54c10b6
to
79d0da7
Compare
let mut pos = 0; | ||
while pos < INPUT.len() { | ||
// ensure that the input string is ASCII and does not contain any NUL characters | ||
let _ascii_only = [0][if matches!(INPUT[pos], 1..=0x7f) { 0 } else { 1 }]; |
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.
The ASCII check isn't used for anything... but presumably it should be?
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.
Actually, no. I removed the UTF-8 → UCS2 conversion from the source, and the line is meant to throw an error at compile time if not all characters were in ASCII range. Panicking in const
contexts is only stable since 1.57, so I used the older workaround to access an array out of bounds, which is caught by the compiler. I only gave the result a name, so it would occur in the error message quoting the offending line
I confirm this is working for me on |
5f47dbc
to
6ad6fae
Compare
6ad6fae
to
caf7869
Compare
Thank you for opening the thread over at windows-rs! I added another commit to make the error checking a little easier to read. I think the code is not too bad. It's just not rusty, and more like C++ written in Rust. :-/ |
I think this is superseded by #97. I will close this for now. (I'll be glad if we don't have to maintain this amount of |
This PR removes the
windows-sys
andwinapi
dependency completely.Instead, the relevant API was extracted from
windows-sys
, which inturn is generated from Windows's header files. The only Windows specific
depency now is
windows-targets
, which was a transitive dependencybefore. It contains the proper mappings between a function name, its
mangled name, and its
.dll
.The rationale for this change is that the previously used
winapi
crateis unmaintained for the last three years, even though it contains some
(minor) errors.
The alternative to
winapi
,windows-sys
is still fast moving. In its(at the time of writing this PR) newest release 0.45.0 it removed all
WinRT functions, so it arguably does not provide any function we need to
implement our library anymore.