Skip to content
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

Improve HRESULT constant literal generation #2857

Merged
merged 11 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions crates/libs/bindgen/src/rust/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,18 @@ pub fn writer(writer: &Writer, def: metadata::Field) -> TokenStream {
}
} else {
let kind = writer.type_default_name(&ty);
let value = writer.value(&constant.value());
let mut value = writer.value(&constant.value());
let underlying_type = type_underlying_type(&ty);

let value = if underlying_type == constant_type {
value
if underlying_type == constant_type {
if ty == metadata::Type::HRESULT {
if let metadata::Value::I32(signed) = constant.value() {
value = format!("0x{:X}_u32 as _", signed).into();
}
}
} else {
quote! { #value as _ }
};
value = quote! { #value as _ };
}

if !writer.sys && type_has_replacement(&ty) {
quote! {
Expand Down
14 changes: 7 additions & 7 deletions crates/libs/core/src/imp/com_bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ impl ::core::fmt::Debug for AgileReferenceOptions {
f.debug_tuple("AgileReferenceOptions").field(&self.0).finish()
}
}
pub const CO_E_NOTINITIALIZED: ::windows_core::HRESULT = ::windows_core::HRESULT(-2147221008i32);
pub const CO_E_NOTINITIALIZED: ::windows_core::HRESULT = ::windows_core::HRESULT(0x800401F0_u32 as _);
#[repr(C)]
pub struct DateTime {
pub UniversalTime: i64,
Expand Down Expand Up @@ -61,9 +61,9 @@ impl ::core::default::Default for DateTime {
unsafe { ::core::mem::zeroed() }
}
}
pub const E_BOUNDS: ::windows_core::HRESULT = ::windows_core::HRESULT(-2147483637i32);
pub const E_NOINTERFACE: ::windows_core::HRESULT = ::windows_core::HRESULT(-2147467262i32);
pub const E_OUTOFMEMORY: ::windows_core::HRESULT = ::windows_core::HRESULT(-2147024882i32);
pub const E_BOUNDS: ::windows_core::HRESULT = ::windows_core::HRESULT(0x8000000B_u32 as _);
pub const E_NOINTERFACE: ::windows_core::HRESULT = ::windows_core::HRESULT(0x80004002_u32 as _);
pub const E_OUTOFMEMORY: ::windows_core::HRESULT = ::windows_core::HRESULT(0x8007000E_u32 as _);
::windows_core::imp::com_interface!(IAgileObject, IAgileObject_Vtbl, 0x94ea2b94_e9cc_49e0_c0ff_ee64ca8f5b90);
::windows_core::imp::interface_hierarchy!(IAgileObject, ::windows_core::IUnknown);
impl IAgileObject {}
Expand Down Expand Up @@ -696,7 +696,7 @@ pub struct IWeakReferenceSource_Vtbl {
pub base__: ::windows_core::IUnknown_Vtbl,
pub GetWeakReference: unsafe extern "system" fn(*mut ::core::ffi::c_void, *mut *mut ::core::ffi::c_void) -> ::windows_core::HRESULT,
}
pub const JSCRIPT_E_CANTEXECUTE: ::windows_core::HRESULT = ::windows_core::HRESULT(-1996357631i32);
pub const JSCRIPT_E_CANTEXECUTE: ::windows_core::HRESULT = ::windows_core::HRESULT(0x89020001_u32 as _);
#[repr(C)]
pub struct Point {
pub X: f32,
Expand Down Expand Up @@ -1035,7 +1035,7 @@ impl PropertyValue {
impl ::windows_core::RuntimeName for PropertyValue {
const NAME: &'static str = "Windows.Foundation.PropertyValue";
}
pub const RPC_E_DISCONNECTED: ::windows_core::HRESULT = ::windows_core::HRESULT(-2147417848i32);
pub const RPC_E_DISCONNECTED: ::windows_core::HRESULT = ::windows_core::HRESULT(0x80010108_u32 as _);
#[repr(C)]
pub struct Rect {
pub X: f32,
Expand Down Expand Up @@ -1104,7 +1104,7 @@ impl ::core::default::Default for Size {
unsafe { ::core::mem::zeroed() }
}
}
pub const TYPE_E_TYPEMISMATCH: ::windows_core::HRESULT = ::windows_core::HRESULT(-2147316576i32);
pub const TYPE_E_TYPEMISMATCH: ::windows_core::HRESULT = ::windows_core::HRESULT(0x80028CA0_u32 as _);
#[repr(C)]
pub struct TimeSpan {
pub Duration: i64,
Expand Down
4 changes: 2 additions & 2 deletions crates/libs/result/src/bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ pub type BOOL = i32;
pub type BSTR = *const u16;
pub const ERROR_INVALID_DATA: WIN32_ERROR = 13u32;
pub const ERROR_NO_UNICODE_TRANSLATION: WIN32_ERROR = 1113u32;
pub const E_INVALIDARG: HRESULT = -2147024809i32;
pub const E_UNEXPECTED: HRESULT = -2147418113i32;
pub const E_INVALIDARG: HRESULT = 0x80070057_u32 as _;
pub const E_UNEXPECTED: HRESULT = 0x8000FFFF_u32 as _;
pub const FORMAT_MESSAGE_ALLOCATE_BUFFER: FORMAT_MESSAGE_OPTIONS = 256u32;
pub const FORMAT_MESSAGE_FROM_SYSTEM: FORMAT_MESSAGE_OPTIONS = 4096u32;
pub const FORMAT_MESSAGE_IGNORE_INSERTS: FORMAT_MESSAGE_OPTIONS = 512u32;
Expand Down
124 changes: 62 additions & 62 deletions crates/libs/sys/src/Windows/Win32/Data/HtmlHelp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,68 +14,68 @@ pub const CLSID_IITWordWheelLocal: ::windows_sys::core::GUID = ::windows_sys::co
pub const CLSID_IITWordWheelUpdate: ::windows_sys::core::GUID = ::windows_sys::core::GUID::from_u128(0x4662daa5_d393_11d0_9a56_00c04fb68bf7);
pub const CLSID_ITEngStemmer: ::windows_sys::core::GUID = ::windows_sys::core::GUID::from_u128(0x8fa0d5a8_dedf_11d0_9a61_00c04fb68bf7);
pub const CLSID_ITStdBreaker: ::windows_sys::core::GUID = ::windows_sys::core::GUID::from_u128(0x4662daaf_d393_11d0_9a56_00c04fb68bf7);
pub const E_ALL_WILD: ::windows_sys::core::HRESULT = -2147479467i32;
pub const E_ALREADYINIT: ::windows_sys::core::HRESULT = -2147479421i32;
pub const E_ALREADYOPEN: ::windows_sys::core::HRESULT = -2147479533i32;
pub const E_ASSERT: ::windows_sys::core::HRESULT = -2147479546i32;
pub const E_BADBREAKER: ::windows_sys::core::HRESULT = -2147479469i32;
pub const E_BADFILE: ::windows_sys::core::HRESULT = -2147479549i32;
pub const E_BADFILTERSIZE: ::windows_sys::core::HRESULT = -2147479528i32;
pub const E_BADFORMAT: ::windows_sys::core::HRESULT = -2147479548i32;
pub const E_BADINDEXFLAGS: ::windows_sys::core::HRESULT = -2147479456i32;
pub const E_BADPARAM: ::windows_sys::core::HRESULT = -2147479535i32;
pub const E_BADRANGEOP: ::windows_sys::core::HRESULT = -2147479459i32;
pub const E_BADVALUE: ::windows_sys::core::HRESULT = -2147479468i32;
pub const E_BADVERSION: ::windows_sys::core::HRESULT = -2147479550i32;
pub const E_CANTFINDDLL: ::windows_sys::core::HRESULT = -2147479538i32;
pub const E_DISKFULL: ::windows_sys::core::HRESULT = -2147479496i32;
pub const E_DUPLICATE: ::windows_sys::core::HRESULT = -2147479551i32;
pub const E_EXPECTEDTERM: ::windows_sys::core::HRESULT = -2147479465i32;
pub const E_FILECLOSE: ::windows_sys::core::HRESULT = -2147479503i32;
pub const E_FILECREATE: ::windows_sys::core::HRESULT = -2147479504i32;
pub const E_FILEDELETE: ::windows_sys::core::HRESULT = -2147479499i32;
pub const E_FILEINVALID: ::windows_sys::core::HRESULT = -2147479498i32;
pub const E_FILENOTFOUND: ::windows_sys::core::HRESULT = -2147479497i32;
pub const E_FILEREAD: ::windows_sys::core::HRESULT = -2147479502i32;
pub const E_FILESEEK: ::windows_sys::core::HRESULT = -2147479501i32;
pub const E_FILEWRITE: ::windows_sys::core::HRESULT = -2147479500i32;
pub const E_GETLASTERROR: ::windows_sys::core::HRESULT = -2147479536i32;
pub const E_GROUPIDTOOBIG: ::windows_sys::core::HRESULT = -2147479542i32;
pub const E_INTERRUPT: ::windows_sys::core::HRESULT = -2147479545i32;
pub const E_INVALIDSTATE: ::windows_sys::core::HRESULT = -2147479534i32;
pub const E_MISSINGPROP: ::windows_sys::core::HRESULT = -2147479424i32;
pub const E_MISSLPAREN: ::windows_sys::core::HRESULT = -2147479464i32;
pub const E_MISSQUOTE: ::windows_sys::core::HRESULT = -2147479462i32;
pub const E_MISSRPAREN: ::windows_sys::core::HRESULT = -2147479463i32;
pub const E_NAMETOOLONG: ::windows_sys::core::HRESULT = -2147479520i32;
pub const E_NOHANDLE: ::windows_sys::core::HRESULT = -2147479537i32;
pub const E_NOKEYPROP: ::windows_sys::core::HRESULT = -2147479417i32;
pub const E_NOMERGEDDATA: ::windows_sys::core::HRESULT = -2147479540i32;
pub const E_NOPERMISSION: ::windows_sys::core::HRESULT = -2147479547i32;
pub const E_NOSTEMMER: ::windows_sys::core::HRESULT = -2147479454i32;
pub const E_NOTEXIST: ::windows_sys::core::HRESULT = -2147479552i32;
pub const E_NOTFOUND: ::windows_sys::core::HRESULT = -2147479539i32;
pub const E_NOTINIT: ::windows_sys::core::HRESULT = -2147479420i32;
pub const E_NOTOPEN: ::windows_sys::core::HRESULT = -2147479533i32;
pub const E_NOTSUPPORTED: ::windows_sys::core::HRESULT = -2147479544i32;
pub const E_NULLQUERY: ::windows_sys::core::HRESULT = -2147479461i32;
pub const E_OUTOFRANGE: ::windows_sys::core::HRESULT = -2147479543i32;
pub const E_PROPLISTEMPTY: ::windows_sys::core::HRESULT = -2147479422i32;
pub const E_PROPLISTNOTEMPTY: ::windows_sys::core::HRESULT = -2147479423i32;
pub const E_RESULTSETEMPTY: ::windows_sys::core::HRESULT = -2147479419i32;
pub const E_STOPWORD: ::windows_sys::core::HRESULT = -2147479460i32;
pub const E_TOODEEP: ::windows_sys::core::HRESULT = -2147479466i32;
pub const E_TOOMANYCOLUMNS: ::windows_sys::core::HRESULT = -2147479418i32;
pub const E_TOOMANYDUPS: ::windows_sys::core::HRESULT = -2147479471i32;
pub const E_TOOMANYOBJECTS: ::windows_sys::core::HRESULT = -2147479527i32;
pub const E_TOOMANYTITLES: ::windows_sys::core::HRESULT = -2147479541i32;
pub const E_TOOMANYTOPICS: ::windows_sys::core::HRESULT = -2147479472i32;
pub const E_TREETOOBIG: ::windows_sys::core::HRESULT = -2147479470i32;
pub const E_UNKNOWN_TRANSPORT: ::windows_sys::core::HRESULT = -2147479530i32;
pub const E_UNMATCHEDTYPE: ::windows_sys::core::HRESULT = -2147479458i32;
pub const E_UNSUPPORTED_TRANSPORT: ::windows_sys::core::HRESULT = -2147479529i32;
pub const E_WILD_IN_DTYPE: ::windows_sys::core::HRESULT = -2147479455i32;
pub const E_WORDTOOLONG: ::windows_sys::core::HRESULT = -2147479457i32;
pub const E_ALL_WILD: ::windows_sys::core::HRESULT = 0x80001055_u32 as _;
pub const E_ALREADYINIT: ::windows_sys::core::HRESULT = 0x80001083_u32 as _;
pub const E_ALREADYOPEN: ::windows_sys::core::HRESULT = 0x80001013_u32 as _;
pub const E_ASSERT: ::windows_sys::core::HRESULT = 0x80001006_u32 as _;
pub const E_BADBREAKER: ::windows_sys::core::HRESULT = 0x80001053_u32 as _;
pub const E_BADFILE: ::windows_sys::core::HRESULT = 0x80001003_u32 as _;
pub const E_BADFILTERSIZE: ::windows_sys::core::HRESULT = 0x80001018_u32 as _;
pub const E_BADFORMAT: ::windows_sys::core::HRESULT = 0x80001004_u32 as _;
pub const E_BADINDEXFLAGS: ::windows_sys::core::HRESULT = 0x80001060_u32 as _;
pub const E_BADPARAM: ::windows_sys::core::HRESULT = 0x80001011_u32 as _;
pub const E_BADRANGEOP: ::windows_sys::core::HRESULT = 0x8000105D_u32 as _;
pub const E_BADVALUE: ::windows_sys::core::HRESULT = 0x80001054_u32 as _;
pub const E_BADVERSION: ::windows_sys::core::HRESULT = 0x80001002_u32 as _;
pub const E_CANTFINDDLL: ::windows_sys::core::HRESULT = 0x8000100E_u32 as _;
pub const E_DISKFULL: ::windows_sys::core::HRESULT = 0x80001038_u32 as _;
pub const E_DUPLICATE: ::windows_sys::core::HRESULT = 0x80001001_u32 as _;
pub const E_EXPECTEDTERM: ::windows_sys::core::HRESULT = 0x80001057_u32 as _;
pub const E_FILECLOSE: ::windows_sys::core::HRESULT = 0x80001031_u32 as _;
pub const E_FILECREATE: ::windows_sys::core::HRESULT = 0x80001030_u32 as _;
pub const E_FILEDELETE: ::windows_sys::core::HRESULT = 0x80001035_u32 as _;
pub const E_FILEINVALID: ::windows_sys::core::HRESULT = 0x80001036_u32 as _;
pub const E_FILENOTFOUND: ::windows_sys::core::HRESULT = 0x80001037_u32 as _;
pub const E_FILEREAD: ::windows_sys::core::HRESULT = 0x80001032_u32 as _;
pub const E_FILESEEK: ::windows_sys::core::HRESULT = 0x80001033_u32 as _;
pub const E_FILEWRITE: ::windows_sys::core::HRESULT = 0x80001034_u32 as _;
pub const E_GETLASTERROR: ::windows_sys::core::HRESULT = 0x80001010_u32 as _;
pub const E_GROUPIDTOOBIG: ::windows_sys::core::HRESULT = 0x8000100A_u32 as _;
pub const E_INTERRUPT: ::windows_sys::core::HRESULT = 0x80001007_u32 as _;
pub const E_INVALIDSTATE: ::windows_sys::core::HRESULT = 0x80001012_u32 as _;
pub const E_MISSINGPROP: ::windows_sys::core::HRESULT = 0x80001080_u32 as _;
pub const E_MISSLPAREN: ::windows_sys::core::HRESULT = 0x80001058_u32 as _;
pub const E_MISSQUOTE: ::windows_sys::core::HRESULT = 0x8000105A_u32 as _;
pub const E_MISSRPAREN: ::windows_sys::core::HRESULT = 0x80001059_u32 as _;
pub const E_NAMETOOLONG: ::windows_sys::core::HRESULT = 0x80001020_u32 as _;
pub const E_NOHANDLE: ::windows_sys::core::HRESULT = 0x8000100F_u32 as _;
pub const E_NOKEYPROP: ::windows_sys::core::HRESULT = 0x80001087_u32 as _;
pub const E_NOMERGEDDATA: ::windows_sys::core::HRESULT = 0x8000100C_u32 as _;
pub const E_NOPERMISSION: ::windows_sys::core::HRESULT = 0x80001005_u32 as _;
pub const E_NOSTEMMER: ::windows_sys::core::HRESULT = 0x80001062_u32 as _;
pub const E_NOTEXIST: ::windows_sys::core::HRESULT = 0x80001000_u32 as _;
pub const E_NOTFOUND: ::windows_sys::core::HRESULT = 0x8000100D_u32 as _;
pub const E_NOTINIT: ::windows_sys::core::HRESULT = 0x80001084_u32 as _;
pub const E_NOTOPEN: ::windows_sys::core::HRESULT = 0x80001013_u32 as _;
pub const E_NOTSUPPORTED: ::windows_sys::core::HRESULT = 0x80001008_u32 as _;
pub const E_NULLQUERY: ::windows_sys::core::HRESULT = 0x8000105B_u32 as _;
pub const E_OUTOFRANGE: ::windows_sys::core::HRESULT = 0x80001009_u32 as _;
pub const E_PROPLISTEMPTY: ::windows_sys::core::HRESULT = 0x80001082_u32 as _;
pub const E_PROPLISTNOTEMPTY: ::windows_sys::core::HRESULT = 0x80001081_u32 as _;
pub const E_RESULTSETEMPTY: ::windows_sys::core::HRESULT = 0x80001085_u32 as _;
pub const E_STOPWORD: ::windows_sys::core::HRESULT = 0x8000105C_u32 as _;
pub const E_TOODEEP: ::windows_sys::core::HRESULT = 0x80001056_u32 as _;
pub const E_TOOMANYCOLUMNS: ::windows_sys::core::HRESULT = 0x80001086_u32 as _;
pub const E_TOOMANYDUPS: ::windows_sys::core::HRESULT = 0x80001051_u32 as _;
pub const E_TOOMANYOBJECTS: ::windows_sys::core::HRESULT = 0x80001019_u32 as _;
pub const E_TOOMANYTITLES: ::windows_sys::core::HRESULT = 0x8000100B_u32 as _;
pub const E_TOOMANYTOPICS: ::windows_sys::core::HRESULT = 0x80001050_u32 as _;
pub const E_TREETOOBIG: ::windows_sys::core::HRESULT = 0x80001052_u32 as _;
pub const E_UNKNOWN_TRANSPORT: ::windows_sys::core::HRESULT = 0x80001016_u32 as _;
pub const E_UNMATCHEDTYPE: ::windows_sys::core::HRESULT = 0x8000105E_u32 as _;
pub const E_UNSUPPORTED_TRANSPORT: ::windows_sys::core::HRESULT = 0x80001017_u32 as _;
pub const E_WILD_IN_DTYPE: ::windows_sys::core::HRESULT = 0x80001061_u32 as _;
pub const E_WORDTOOLONG: ::windows_sys::core::HRESULT = 0x8000105F_u32 as _;
pub const HHACT_BACK: i32 = 7i32;
pub const HHACT_CONTRACT: i32 = 6i32;
pub const HHACT_CUSTOMIZE: i32 = 16i32;
Expand Down
Loading