Skip to content
Closed
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
42 changes: 0 additions & 42 deletions crates/libs/bindgen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -766,48 +766,6 @@ impl Bindgen {
ReferenceStage::parse("windows_future,flat,Windows.Foundation.IAsync*"),
);
}

if reader.contains_key("Windows.Win32.Foundation") {
if self.specific_deps {
references.insert(
0,
ReferenceStage::parse(
"windows_result,flat,Windows.Win32.Foundation.WIN32_ERROR",
),
);
references.insert(
0,
ReferenceStage::parse(
"windows_result,flat,Windows.Win32.Foundation.NTSTATUS",
),
);
references.insert(
0,
ReferenceStage::parse(
"windows_result,flat,Windows.Win32.System.Rpc.RPC_STATUS",
),
);
} else {
references.insert(
0,
ReferenceStage::parse(
"windows_core,flat,Windows.Win32.Foundation.WIN32_ERROR",
),
);
references.insert(
0,
ReferenceStage::parse(
"windows_core,flat,Windows.Win32.Foundation.NTSTATUS",
),
);
references.insert(
0,
ReferenceStage::parse(
"windows_core,flat,Windows.Win32.System.Rpc.RPC_STATUS",
),
);
}
}
}

let derive_str: Vec<&str> = self.derive.iter().map(|s| s.as_str()).collect();
Expand Down
35 changes: 35 additions & 0 deletions crates/libs/bindgen/src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ pub use method::*;
pub use r#enum::*;
pub use r#struct::*;

#[allow(non_camel_case_types)]
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub enum Type {
CppFn(CppFn),
Expand Down Expand Up @@ -76,6 +77,9 @@ pub enum Type {
PCWSTR,
GUID,
HRESULT,
WIN32_ERROR,
NTSTATUS,
RPC_STATUS,
IUnknown,
BSTR,
BOOL,
Expand Down Expand Up @@ -174,6 +178,10 @@ impl Type {
Remap::Type(Self::HRESULT)
}

("Windows.Win32.Foundation", "WIN32_ERROR") => Remap::Type(Self::WIN32_ERROR),
("Windows.Win32.Foundation", "NTSTATUS") => Remap::Type(Self::NTSTATUS),
("Windows.Win32.System.Rpc", "RPC_STATUS") => Remap::Type(Self::RPC_STATUS),

("Windows.Foundation", "EventRegistrationToken")
| ("Windows.Win32.System.WinRT", "EventRegistrationToken") => Remap::Type(Self::I64),

Expand Down Expand Up @@ -413,6 +421,18 @@ impl Type {
let result = config.write_result();
quote! { #result HRESULT }
}
Self::WIN32_ERROR => {
let result = config.write_result();
quote! { #result WIN32_ERROR }
}
Self::NTSTATUS => {
let result = config.write_result();
quote! { #result NTSTATUS }
}
Self::RPC_STATUS => {
let result = config.write_result();
quote! { #result RPC_STATUS }
}
Self::BOOL => {
let result = config.write_result();
quote! { #result BOOL }
Expand Down Expand Up @@ -708,6 +728,9 @@ impl Type {
| Self::ISize
| Self::USize
| Self::HRESULT
| Self::WIN32_ERROR
| Self::NTSTATUS
| Self::RPC_STATUS
| Self::BOOL
| Self::PtrConst(_, _)
| Self::PtrMut(_, _) => true,
Expand Down Expand Up @@ -777,6 +800,9 @@ impl Type {
Self::Enum(ty) => ty.def.underlying_type_ext(reader),
Self::CppStruct(ty) => ty.def.underlying_type_ext(reader),
Self::HRESULT => Self::I32,
Self::WIN32_ERROR => Self::U32,
Self::NTSTATUS => Self::I32,
Self::RPC_STATUS => Self::I32,
Self::BOOL => Self::I32,
_ => self.clone(),
}
Expand All @@ -789,6 +815,9 @@ impl Type {

match self {
Self::HRESULT => quote! { pub type HRESULT = i32; },
Self::WIN32_ERROR => quote! { pub type WIN32_ERROR = u32; },
Self::NTSTATUS => quote! { pub type NTSTATUS = i32; },
Self::RPC_STATUS => quote! { pub type RPC_STATUS = i32; },
Self::BOOL => quote! { pub type BOOL = i32; },

Self::PWSTR => quote! { pub type PWSTR = *mut u16; },
Expand Down Expand Up @@ -884,6 +913,9 @@ impl Type {
Self::PCWSTR => TypeName("", "PCWSTR"),
Self::GUID => TypeName("", "GUID"),
Self::HRESULT => TypeName("", "HRESULT"),
Self::WIN32_ERROR => TypeName("", "WIN32_ERROR"),
Self::NTSTATUS => TypeName("", "NTSTATUS"),
Self::RPC_STATUS => TypeName("", "RPC_STATUS"),
Self::BOOL => TypeName("", "BOOL"),
Self::IUnknown => TypeName("", "IUnknown"),
Self::BSTR => TypeName("", "BSTR"),
Expand All @@ -903,6 +935,9 @@ impl Type {
| Self::PCWSTR
| Self::GUID
| Self::HRESULT
| Self::WIN32_ERROR
| Self::NTSTATUS
| Self::RPC_STATUS
| Self::BOOL
| Self::IUnknown
| Self::Object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
pub struct WAIT_EVENT(pub u32);
#[repr(transparent)]
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
pub struct WIN32_ERROR(pub u32);
pub struct NTSTATUS_FACILITY_CODE(pub u32);
Original file line number Diff line number Diff line change
@@ -1 +1 @@
args = "--no-comment --in default --flat --filter WAIT_EVENT WIN32_ERROR --derive WAIT_EVENT=PartialOrd"
args = "--no-comment --in default --flat --filter WAIT_EVENT NTSTATUS_FACILITY_CODE --derive WAIT_EVENT=PartialOrd"
6 changes: 3 additions & 3 deletions crates/tests/misc/just_core/src/bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub unsafe fn CoGetCallerTID() -> windows_core::Result<u32> {
}
#[inline]
pub unsafe fn GetLastError() -> windows_core::WIN32_ERROR {
windows_core::link!("kernel32.dll" "system" fn GetLastError() -> windows_core:: WIN32_ERROR);
windows_core::link!("kernel32.dll" "system" fn GetLastError() -> windows_core::WIN32_ERROR);
unsafe { GetLastError() }
}
#[inline]
Expand All @@ -26,7 +26,7 @@ pub unsafe fn IsCharLowerA(ch: i8) -> windows_core::Result<()> {
}
#[inline]
pub unsafe fn RpcMgmtEnableIdleCleanup() -> windows_core::RPC_STATUS {
windows_core::link!("rpcrt4.dll" "system" fn RpcMgmtEnableIdleCleanup() -> windows_core:: RPC_STATUS);
windows_core::link!("rpcrt4.dll" "system" fn RpcMgmtEnableIdleCleanup() -> windows_core::RPC_STATUS);
unsafe { RpcMgmtEnableIdleCleanup() }
}
#[inline]
Expand All @@ -36,7 +36,7 @@ pub unsafe fn SysFreeString(bstrstring: &windows_core::BSTR) {
}
#[inline]
pub unsafe fn VhfStart(vhfhandle: *const core::ffi::c_void) -> windows_core::NTSTATUS {
windows_core::link!("vhfum.dll" "system" fn VhfStart(vhfhandle : *const core::ffi::c_void) -> windows_core:: NTSTATUS);
windows_core::link!("vhfum.dll" "system" fn VhfStart(vhfhandle : *const core::ffi::c_void) -> windows_core::NTSTATUS);
unsafe { VhfStart(vhfhandle) }
}
windows_core::imp::define_interface!(
Expand Down
6 changes: 3 additions & 3 deletions crates/tests/misc/no_core/src/bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub unsafe fn CoGetCallerTID() -> windows_result::Result<u32> {
}
#[inline]
pub unsafe fn GetLastError() -> windows_result::WIN32_ERROR {
windows_link::link!("kernel32.dll" "system" fn GetLastError() -> windows_result:: WIN32_ERROR);
windows_link::link!("kernel32.dll" "system" fn GetLastError() -> windows_result::WIN32_ERROR);
unsafe { GetLastError() }
}
#[inline]
Expand All @@ -26,7 +26,7 @@ pub unsafe fn IsCharLowerA(ch: i8) -> windows_result::Result<()> {
}
#[inline]
pub unsafe fn RpcMgmtEnableIdleCleanup() -> windows_result::RPC_STATUS {
windows_link::link!("rpcrt4.dll" "system" fn RpcMgmtEnableIdleCleanup() -> windows_result:: RPC_STATUS);
windows_link::link!("rpcrt4.dll" "system" fn RpcMgmtEnableIdleCleanup() -> windows_result::RPC_STATUS);
unsafe { RpcMgmtEnableIdleCleanup() }
}
#[inline]
Expand All @@ -36,7 +36,7 @@ pub unsafe fn SysFreeString(bstrstring: &windows_strings::BSTR) {
}
#[inline]
pub unsafe fn VhfStart(vhfhandle: *const core::ffi::c_void) -> windows_result::NTSTATUS {
windows_link::link!("vhfum.dll" "system" fn VhfStart(vhfhandle : *const core::ffi::c_void) -> windows_result:: NTSTATUS);
windows_link::link!("vhfum.dll" "system" fn VhfStart(vhfhandle : *const core::ffi::c_void) -> windows_result::NTSTATUS);
unsafe { VhfStart(vhfhandle) }
}
#[inline]
Expand Down
5 changes: 0 additions & 5 deletions crates/tools/bindings/src/windows.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,3 @@
!Windows.Win32.System.WinRT.Xaml
!Windows.Win32.UI.Xaml
!Windows.Win32.Web.MsHtml

// windows-result
!Windows.Win32.Foundation.WIN32_ERROR
!Windows.Win32.Foundation.NTSTATUS
!Windows.Win32.System.Rpc.RPC_STATUS
Loading