-
Notifications
You must be signed in to change notification settings - Fork 513
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
Fix string constants for standalone sys #2500
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,8 +67,15 @@ fn standalone_imp(gen: &mut Gen, names: &[&str]) -> String { | |
.find(|field| gen.reader.field_name(*field) == type_name.name) | ||
{ | ||
constants.insert(field); | ||
gen.reader | ||
.type_collect_standalone(&gen.reader.field_type(field, None), &mut types); | ||
|
||
let ft = gen.reader.field_type(field, None); | ||
|
||
// String normally gets resolved to HSTRING, but since macros | ||
// from windows_core/windows_sys::core are used to create the | ||
// string literals we can skip the type collection | ||
if ft != Type::String { | ||
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. This seems like a hack. String constants should not be depending on 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. I see that they are in fact |
||
gen.reader.type_collect_standalone(&ft, &mut types); | ||
} | ||
} | ||
|
||
if let Some(field) = gen | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Bindings generated by `windows-bindgen` 0.49.0 | ||
|
||
#![allow( | ||
non_snake_case, | ||
non_upper_case_globals, | ||
non_camel_case_types, | ||
dead_code, | ||
clippy::all | ||
)] | ||
pub const ADDRESS_FAMILY_VALUE_NAME: ::windows_core::PCWSTR = ::windows_core::w!("AddressFamily"); | ||
pub const JOY_CONFIGCHANGED_MSGSTRING: ::windows_core::PCSTR = | ||
::windows_core::s!("MSJSTICK_VJOYD_MSGSTR"); | ||
pub type PCSTR = *const u8; | ||
pub type PCWSTR = *const u16; |
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.
This is a bit problematic since this assumes that sys-style code gen should assume a dependency on
windows-core
which is designed for non-sys style code gen. I'd like to avoid adding a "core" crate forwindows-sys
but this conflates the two.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.
Right, I considered this the simpler fix in hopes of merging, but like I said in the PR description I think the better option is just to remove the need for the macros altogether, but I figured that would be harder to pass review.
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.
Yep, it's not a simple fix but I'd prefer to find a good solution rather than fix a problem by introducing another problem. 😉
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.
ok