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

Apply type cfg to Send and Sync implementations #3438

Merged
merged 1 commit into from
Jan 14, 2025
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
18 changes: 9 additions & 9 deletions crates/libs/bindgen/src/types/cpp_interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,15 @@ impl CppInterface {

result.combine(vtbl);

if self.def.is_agile() {
result.combine(quote! {
#cfg
unsafe impl Send for #name {}
#cfg
unsafe impl Sync for #name {}
});
}

let impl_name: TokenStream = format!("{}_Impl", self.def.name()).into();

let cfg = if writer.config.package {
Expand Down Expand Up @@ -388,15 +397,6 @@ impl CppInterface {
}
});

if self.def.is_agile() {
result.combine(quote! {
#cfg
unsafe impl Send for #name {}
#cfg
unsafe impl Sync for #name {}
});
}

result
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,8 @@ pub struct ID2D1SimplifiedGeometrySink_Vtbl {
pub EndFigure: unsafe extern "system" fn(*mut core::ffi::c_void, D2D1_FIGURE_END),
pub Close: unsafe extern "system" fn(*mut core::ffi::c_void) -> windows_core::HRESULT,
}
unsafe impl Send for ID2D1SimplifiedGeometrySink {}
unsafe impl Sync for ID2D1SimplifiedGeometrySink {}
pub trait ID2D1SimplifiedGeometrySink_Impl: windows_core::IUnknownImpl {
fn SetFillMode(&self, fillmode: D2D1_FILL_MODE);
fn SetSegmentFlags(&self, vertexflags: D2D1_PATH_SEGMENT);
Expand Down Expand Up @@ -539,5 +541,3 @@ impl ID2D1SimplifiedGeometrySink_Vtbl {
}
}
impl windows_core::RuntimeName for ID2D1SimplifiedGeometrySink {}
unsafe impl Send for ID2D1SimplifiedGeometrySink {}
unsafe impl Sync for ID2D1SimplifiedGeometrySink {}
612 changes: 230 additions & 382 deletions crates/libs/windows/src/Windows/Win32/Graphics/Direct2D/mod.rs

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions crates/libs/windows/src/Windows/Win32/Graphics/Direct3D/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,8 @@ pub struct ID3DBlob_Vtbl {
pub GetBufferPointer: unsafe extern "system" fn(*mut core::ffi::c_void) -> *mut core::ffi::c_void,
pub GetBufferSize: unsafe extern "system" fn(*mut core::ffi::c_void) -> usize,
}
unsafe impl Send for ID3DBlob {}
unsafe impl Sync for ID3DBlob {}
pub trait ID3DBlob_Impl: windows_core::IUnknownImpl {
fn GetBufferPointer(&self) -> *mut core::ffi::c_void;
fn GetBufferSize(&self) -> usize;
Expand Down Expand Up @@ -796,8 +798,6 @@ impl ID3DBlob_Vtbl {
}
}
impl windows_core::RuntimeName for ID3DBlob {}
unsafe impl Send for ID3DBlob {}
unsafe impl Sync for ID3DBlob {}
windows_core::imp::define_interface!(ID3DDestructionNotifier, ID3DDestructionNotifier_Vtbl, 0xa06eb39a_50da_425b_8c31_4eecd6c270f3);
windows_core::imp::interface_hierarchy!(ID3DDestructionNotifier, windows_core::IUnknown);
impl ID3DDestructionNotifier {
Expand All @@ -817,6 +817,8 @@ pub struct ID3DDestructionNotifier_Vtbl {
pub RegisterDestructionCallback: unsafe extern "system" fn(*mut core::ffi::c_void, PFN_DESTRUCTION_CALLBACK, *const core::ffi::c_void, *mut u32) -> windows_core::HRESULT,
pub UnregisterDestructionCallback: unsafe extern "system" fn(*mut core::ffi::c_void, u32) -> windows_core::HRESULT,
}
unsafe impl Send for ID3DDestructionNotifier {}
unsafe impl Sync for ID3DDestructionNotifier {}
pub trait ID3DDestructionNotifier_Impl: windows_core::IUnknownImpl {
fn RegisterDestructionCallback(&self, callbackfn: PFN_DESTRUCTION_CALLBACK, pdata: *const core::ffi::c_void) -> windows_core::Result<u32>;
fn UnregisterDestructionCallback(&self, callbackid: u32) -> windows_core::Result<()>;
Expand Down Expand Up @@ -852,8 +854,6 @@ impl ID3DDestructionNotifier_Vtbl {
}
}
impl windows_core::RuntimeName for ID3DDestructionNotifier {}
unsafe impl Send for ID3DDestructionNotifier {}
unsafe impl Sync for ID3DDestructionNotifier {}
windows_core::imp::define_interface!(ID3DInclude, ID3DInclude_Vtbl);
impl ID3DInclude {
pub unsafe fn Open<P1>(&self, includetype: D3D_INCLUDE_TYPE, pfilename: P1, pparentdata: *const core::ffi::c_void, ppdata: *mut *mut core::ffi::c_void, pbytes: *mut u32) -> windows_core::Result<()>
Expand All @@ -871,6 +871,8 @@ pub struct ID3DInclude_Vtbl {
pub Open: unsafe extern "system" fn(*mut core::ffi::c_void, D3D_INCLUDE_TYPE, windows_core::PCSTR, *const core::ffi::c_void, *mut *mut core::ffi::c_void, *mut u32) -> windows_core::HRESULT,
pub Close: unsafe extern "system" fn(*mut core::ffi::c_void, *const core::ffi::c_void) -> windows_core::HRESULT,
}
unsafe impl Send for ID3DInclude {}
unsafe impl Sync for ID3DInclude {}
pub trait ID3DInclude_Impl {
fn Open(&self, includetype: D3D_INCLUDE_TYPE, pfilename: &windows_core::PCSTR, pparentdata: *const core::ffi::c_void, ppdata: *mut *mut core::ffi::c_void, pbytes: *mut u32) -> windows_core::Result<()>;
fn Close(&self, pdata: *const core::ffi::c_void) -> windows_core::Result<()>;
Expand Down Expand Up @@ -905,8 +907,6 @@ impl ID3DInclude {
unsafe { windows_core::ScopedInterface::new(core::mem::transmute(&this.vtable)) }
}
}
unsafe impl Send for ID3DInclude {}
unsafe impl Sync for ID3DInclude {}
pub type PFN_DESTRUCTION_CALLBACK = Option<unsafe extern "system" fn(pdata: *mut core::ffi::c_void)>;
pub const WKPDID_CommentStringW: windows_core::GUID = windows_core::GUID::from_u128(0xd0149dc0_90e8_4ec8_8144_e900ad266bb2);
pub const WKPDID_D3D12UniqueObjectId: windows_core::GUID = windows_core::GUID::from_u128(0x1b39de15_ec04_4bae_ba4d_8cef79fc04c1);
Expand Down
Loading