Skip to content

Commit 48374b8

Browse files
authored
Minor improvements to the windows-sys crate (#1319)
1 parent 1870eae commit 48374b8

72 files changed

Lines changed: 233 additions & 231 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

crates/deps/gen/src/sys.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@ fn gen_struct(def: &TypeDef, gen: &Gen) -> TokenStream {
139139

140140
fn gen_struct_with_name(def: &TypeDef, struct_name: &str, gen: &Gen, cfg: &TokenStream) -> TokenStream {
141141
let name = to_ident(struct_name);
142+
let is_union = def.is_explicit();
143+
let is_handle = def.is_handle();
142144

143145
let (doc, cfg) = if cfg.is_empty() {
144146
let features = features(def, gen);
@@ -180,13 +182,12 @@ fn gen_struct_with_name(def: &TypeDef, struct_name: &str, gen: &Gen, cfg: &Token
180182
let repr = if let Some(layout) = def.class_layout() {
181183
let packing = Literal::u32_unsuffixed(layout.packing_size());
182184
quote! { #[repr(C, packed(#packing))] }
185+
} else if is_handle {
186+
quote! { #[repr(transparent)] }
183187
} else {
184188
quote! { #[repr(C)] }
185189
};
186190

187-
let is_union = def.is_explicit();
188-
let is_handle = def.is_handle();
189-
190191
let fields = fields.iter().map(|(_, signature, name)| {
191192
let kind = gen_sys_sig(signature, gen);
192193

crates/deps/sys/src/Windows/Win32/Devices/AllJoyn/mod.rs

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1241,15 +1241,15 @@ impl ::core::clone::Clone for alljoyn_about_announceflag {
12411241
*self
12421242
}
12431243
}
1244-
#[repr(C)]
1244+
#[repr(transparent)]
12451245
pub struct alljoyn_aboutdata(pub isize);
12461246
impl ::core::marker::Copy for alljoyn_aboutdata {}
12471247
impl ::core::clone::Clone for alljoyn_aboutdata {
12481248
fn clone(&self) -> Self {
12491249
*self
12501250
}
12511251
}
1252-
#[repr(C)]
1252+
#[repr(transparent)]
12531253
pub struct alljoyn_aboutdatalistener(pub isize);
12541254
impl ::core::marker::Copy for alljoyn_aboutdatalistener {}
12551255
impl ::core::clone::Clone for alljoyn_aboutdatalistener {
@@ -1274,7 +1274,7 @@ impl ::core::clone::Clone for alljoyn_aboutdatalistener_callbacks {
12741274
#[cfg(feature = "Win32_Foundation")]
12751275
pub type alljoyn_aboutdatalistener_getaboutdata_ptr = unsafe extern "system" fn(context: *const ::core::ffi::c_void, msgarg: alljoyn_msgarg, language: super::super::Foundation::PSTR) -> QStatus;
12761276
pub type alljoyn_aboutdatalistener_getannouncedaboutdata_ptr = unsafe extern "system" fn(context: *const ::core::ffi::c_void, msgarg: alljoyn_msgarg) -> QStatus;
1277-
#[repr(C)]
1277+
#[repr(transparent)]
12781278
pub struct alljoyn_aboutlistener(pub isize);
12791279
impl ::core::marker::Copy for alljoyn_aboutlistener {}
12801280
impl ::core::clone::Clone for alljoyn_aboutlistener {
@@ -1295,23 +1295,23 @@ impl ::core::clone::Clone for alljoyn_aboutlistener_callback {
12951295
*self
12961296
}
12971297
}
1298-
#[repr(C)]
1298+
#[repr(transparent)]
12991299
pub struct alljoyn_aboutobj(pub isize);
13001300
impl ::core::marker::Copy for alljoyn_aboutobj {}
13011301
impl ::core::clone::Clone for alljoyn_aboutobj {
13021302
fn clone(&self) -> Self {
13031303
*self
13041304
}
13051305
}
1306-
#[repr(C)]
1306+
#[repr(transparent)]
13071307
pub struct alljoyn_aboutobjectdescription(pub isize);
13081308
impl ::core::marker::Copy for alljoyn_aboutobjectdescription {}
13091309
impl ::core::clone::Clone for alljoyn_aboutobjectdescription {
13101310
fn clone(&self) -> Self {
13111311
*self
13121312
}
13131313
}
1314-
#[repr(C)]
1314+
#[repr(transparent)]
13151315
pub struct alljoyn_aboutproxy(pub isize);
13161316
impl ::core::marker::Copy for alljoyn_aboutproxy {}
13171317
impl ::core::clone::Clone for alljoyn_aboutproxy {
@@ -1331,7 +1331,7 @@ impl ::core::clone::Clone for alljoyn_applicationstate {
13311331
*self
13321332
}
13331333
}
1334-
#[repr(C)]
1334+
#[repr(transparent)]
13351335
pub struct alljoyn_applicationstatelistener(pub isize);
13361336
impl ::core::marker::Copy for alljoyn_applicationstatelistener {}
13371337
impl ::core::clone::Clone for alljoyn_applicationstatelistener {
@@ -1350,7 +1350,7 @@ impl ::core::clone::Clone for alljoyn_applicationstatelistener_callbacks {
13501350
}
13511351
}
13521352
pub type alljoyn_applicationstatelistener_state_ptr = unsafe extern "system" fn(busname: *mut i8, publickey: *mut i8, applicationstate: alljoyn_applicationstate, context: *mut ::core::ffi::c_void);
1353-
#[repr(C)]
1353+
#[repr(transparent)]
13541354
pub struct alljoyn_authlistener(pub isize);
13551355
impl ::core::marker::Copy for alljoyn_authlistener {}
13561356
impl ::core::clone::Clone for alljoyn_authlistener {
@@ -1401,7 +1401,7 @@ impl ::core::clone::Clone for alljoyn_authlistenerasync_callbacks {
14011401
*self
14021402
}
14031403
}
1404-
#[repr(C)]
1404+
#[repr(transparent)]
14051405
pub struct alljoyn_autopinger(pub isize);
14061406
impl ::core::marker::Copy for alljoyn_autopinger {}
14071407
impl ::core::clone::Clone for alljoyn_autopinger {
@@ -1413,7 +1413,7 @@ impl ::core::clone::Clone for alljoyn_autopinger {
14131413
pub type alljoyn_autopinger_destination_found_ptr = unsafe extern "system" fn(context: *const ::core::ffi::c_void, group: super::super::Foundation::PSTR, destination: super::super::Foundation::PSTR);
14141414
#[cfg(feature = "Win32_Foundation")]
14151415
pub type alljoyn_autopinger_destination_lost_ptr = unsafe extern "system" fn(context: *const ::core::ffi::c_void, group: super::super::Foundation::PSTR, destination: super::super::Foundation::PSTR);
1416-
#[repr(C)]
1416+
#[repr(transparent)]
14171417
pub struct alljoyn_busattachment(pub isize);
14181418
impl ::core::marker::Copy for alljoyn_busattachment {}
14191419
impl ::core::clone::Clone for alljoyn_busattachment {
@@ -1423,7 +1423,7 @@ impl ::core::clone::Clone for alljoyn_busattachment {
14231423
}
14241424
pub type alljoyn_busattachment_joinsessioncb_ptr = unsafe extern "system" fn(status: QStatus, sessionid: u32, opts: alljoyn_sessionopts, context: *mut ::core::ffi::c_void);
14251425
pub type alljoyn_busattachment_setlinktimeoutcb_ptr = unsafe extern "system" fn(status: QStatus, timeout: u32, context: *mut ::core::ffi::c_void);
1426-
#[repr(C)]
1426+
#[repr(transparent)]
14271427
pub struct alljoyn_buslistener(pub isize);
14281428
impl ::core::marker::Copy for alljoyn_buslistener {}
14291429
impl ::core::clone::Clone for alljoyn_buslistener {
@@ -1463,7 +1463,7 @@ pub type alljoyn_buslistener_listener_unregistered_ptr = unsafe extern "system"
14631463
pub type alljoyn_buslistener_lost_advertised_name_ptr = unsafe extern "system" fn(context: *const ::core::ffi::c_void, name: super::super::Foundation::PSTR, transport: u16, nameprefix: super::super::Foundation::PSTR);
14641464
#[cfg(feature = "Win32_Foundation")]
14651465
pub type alljoyn_buslistener_name_owner_changed_ptr = unsafe extern "system" fn(context: *const ::core::ffi::c_void, busname: super::super::Foundation::PSTR, previousowner: super::super::Foundation::PSTR, newowner: super::super::Foundation::PSTR);
1466-
#[repr(C)]
1466+
#[repr(transparent)]
14671467
pub struct alljoyn_busobject(pub isize);
14681468
impl ::core::marker::Copy for alljoyn_busobject {}
14691469
impl ::core::clone::Clone for alljoyn_busobject {
@@ -1552,15 +1552,15 @@ impl ::core::clone::Clone for alljoyn_claimcapabilityadditionalinfo_masks {
15521552
*self
15531553
}
15541554
}
1555-
#[repr(C)]
1555+
#[repr(transparent)]
15561556
pub struct alljoyn_credentials(pub isize);
15571557
impl ::core::marker::Copy for alljoyn_credentials {}
15581558
impl ::core::clone::Clone for alljoyn_credentials {
15591559
fn clone(&self) -> Self {
15601560
*self
15611561
}
15621562
}
1563-
#[repr(C)]
1563+
#[repr(transparent)]
15641564
pub struct alljoyn_interfacedescription(pub isize);
15651565
impl ::core::marker::Copy for alljoyn_interfacedescription {}
15661566
impl ::core::clone::Clone for alljoyn_interfacedescription {
@@ -1616,15 +1616,15 @@ impl ::core::clone::Clone for alljoyn_interfacedescription_securitypolicy {
16161616
}
16171617
#[cfg(feature = "Win32_Foundation")]
16181618
pub type alljoyn_interfacedescription_translation_callback_ptr = unsafe extern "system" fn(sourcelanguage: super::super::Foundation::PSTR, targetlanguage: super::super::Foundation::PSTR, sourcetext: super::super::Foundation::PSTR) -> super::super::Foundation::PSTR;
1619-
#[repr(C)]
1619+
#[repr(transparent)]
16201620
pub struct alljoyn_keystore(pub isize);
16211621
impl ::core::marker::Copy for alljoyn_keystore {}
16221622
impl ::core::clone::Clone for alljoyn_keystore {
16231623
fn clone(&self) -> Self {
16241624
*self
16251625
}
16261626
}
1627-
#[repr(C)]
1627+
#[repr(transparent)]
16281628
pub struct alljoyn_keystorelistener(pub isize);
16291629
impl ::core::marker::Copy for alljoyn_keystorelistener {}
16301630
impl ::core::clone::Clone for alljoyn_keystorelistener {
@@ -1671,7 +1671,7 @@ impl ::core::clone::Clone for alljoyn_manifestarray {
16711671
*self
16721672
}
16731673
}
1674-
#[repr(C)]
1674+
#[repr(transparent)]
16751675
pub struct alljoyn_message(pub isize);
16761676
impl ::core::marker::Copy for alljoyn_message {}
16771677
impl ::core::clone::Clone for alljoyn_message {
@@ -1697,15 +1697,15 @@ impl ::core::clone::Clone for alljoyn_messagetype {
16971697
*self
16981698
}
16991699
}
1700-
#[repr(C)]
1700+
#[repr(transparent)]
17011701
pub struct alljoyn_msgarg(pub isize);
17021702
impl ::core::marker::Copy for alljoyn_msgarg {}
17031703
impl ::core::clone::Clone for alljoyn_msgarg {
17041704
fn clone(&self) -> Self {
17051705
*self
17061706
}
17071707
}
1708-
#[repr(C)]
1708+
#[repr(transparent)]
17091709
pub struct alljoyn_observer(pub isize);
17101710
impl ::core::marker::Copy for alljoyn_observer {}
17111711
impl ::core::clone::Clone for alljoyn_observer {
@@ -1715,7 +1715,7 @@ impl ::core::clone::Clone for alljoyn_observer {
17151715
}
17161716
pub type alljoyn_observer_object_discovered_ptr = unsafe extern "system" fn(context: *const ::core::ffi::c_void, proxyref: alljoyn_proxybusobject_ref);
17171717
pub type alljoyn_observer_object_lost_ptr = unsafe extern "system" fn(context: *const ::core::ffi::c_void, proxyref: alljoyn_proxybusobject_ref);
1718-
#[repr(C)]
1718+
#[repr(transparent)]
17191719
pub struct alljoyn_observerlistener(pub isize);
17201720
impl ::core::marker::Copy for alljoyn_observerlistener {}
17211721
impl ::core::clone::Clone for alljoyn_observerlistener {
@@ -1734,7 +1734,7 @@ impl ::core::clone::Clone for alljoyn_observerlistener_callback {
17341734
*self
17351735
}
17361736
}
1737-
#[repr(C)]
1737+
#[repr(transparent)]
17381738
pub struct alljoyn_permissionconfigurationlistener(pub isize);
17391739
impl ::core::marker::Copy for alljoyn_permissionconfigurationlistener {}
17401740
impl ::core::clone::Clone for alljoyn_permissionconfigurationlistener {
@@ -1759,15 +1759,15 @@ pub type alljoyn_permissionconfigurationlistener_endmanagement_ptr = unsafe exte
17591759
pub type alljoyn_permissionconfigurationlistener_factoryreset_ptr = unsafe extern "system" fn(context: *const ::core::ffi::c_void) -> QStatus;
17601760
pub type alljoyn_permissionconfigurationlistener_policychanged_ptr = unsafe extern "system" fn(context: *const ::core::ffi::c_void);
17611761
pub type alljoyn_permissionconfigurationlistener_startmanagement_ptr = unsafe extern "system" fn(context: *const ::core::ffi::c_void);
1762-
#[repr(C)]
1762+
#[repr(transparent)]
17631763
pub struct alljoyn_permissionconfigurator(pub isize);
17641764
impl ::core::marker::Copy for alljoyn_permissionconfigurator {}
17651765
impl ::core::clone::Clone for alljoyn_permissionconfigurator {
17661766
fn clone(&self) -> Self {
17671767
*self
17681768
}
17691769
}
1770-
#[repr(C)]
1770+
#[repr(transparent)]
17711771
pub struct alljoyn_pinglistener(pub isize);
17721772
impl ::core::marker::Copy for alljoyn_pinglistener {}
17731773
impl ::core::clone::Clone for alljoyn_pinglistener {
@@ -1789,7 +1789,7 @@ impl ::core::clone::Clone for alljoyn_pinglistener_callback {
17891789
*self
17901790
}
17911791
}
1792-
#[repr(C)]
1792+
#[repr(transparent)]
17931793
pub struct alljoyn_proxybusobject(pub isize);
17941794
impl ::core::marker::Copy for alljoyn_proxybusobject {}
17951795
impl ::core::clone::Clone for alljoyn_proxybusobject {
@@ -1803,23 +1803,23 @@ pub type alljoyn_proxybusobject_listener_introspectcb_ptr = unsafe extern "syste
18031803
#[cfg(feature = "Win32_Foundation")]
18041804
pub type alljoyn_proxybusobject_listener_propertieschanged_ptr = unsafe extern "system" fn(obj: alljoyn_proxybusobject, ifacename: super::super::Foundation::PSTR, changed: alljoyn_msgarg, invalidated: alljoyn_msgarg, context: *mut ::core::ffi::c_void);
18051805
pub type alljoyn_proxybusobject_listener_setpropertycb_ptr = unsafe extern "system" fn(status: QStatus, obj: alljoyn_proxybusobject, context: *mut ::core::ffi::c_void);
1806-
#[repr(C)]
1806+
#[repr(transparent)]
18071807
pub struct alljoyn_proxybusobject_ref(pub isize);
18081808
impl ::core::marker::Copy for alljoyn_proxybusobject_ref {}
18091809
impl ::core::clone::Clone for alljoyn_proxybusobject_ref {
18101810
fn clone(&self) -> Self {
18111811
*self
18121812
}
18131813
}
1814-
#[repr(C)]
1814+
#[repr(transparent)]
18151815
pub struct alljoyn_securityapplicationproxy(pub isize);
18161816
impl ::core::marker::Copy for alljoyn_securityapplicationproxy {}
18171817
impl ::core::clone::Clone for alljoyn_securityapplicationproxy {
18181818
fn clone(&self) -> Self {
18191819
*self
18201820
}
18211821
}
1822-
#[repr(C)]
1822+
#[repr(transparent)]
18231823
pub struct alljoyn_sessionlistener(pub isize);
18241824
impl ::core::marker::Copy for alljoyn_sessionlistener {}
18251825
impl ::core::clone::Clone for alljoyn_sessionlistener {
@@ -1861,15 +1861,15 @@ impl ::core::clone::Clone for alljoyn_sessionlostreason {
18611861
*self
18621862
}
18631863
}
1864-
#[repr(C)]
1864+
#[repr(transparent)]
18651865
pub struct alljoyn_sessionopts(pub isize);
18661866
impl ::core::marker::Copy for alljoyn_sessionopts {}
18671867
impl ::core::clone::Clone for alljoyn_sessionopts {
18681868
fn clone(&self) -> Self {
18691869
*self
18701870
}
18711871
}
1872-
#[repr(C)]
1872+
#[repr(transparent)]
18731873
pub struct alljoyn_sessionportlistener(pub isize);
18741874
impl ::core::marker::Copy for alljoyn_sessionportlistener {}
18751875
impl ::core::clone::Clone for alljoyn_sessionportlistener {

crates/deps/sys/src/Windows/Win32/Devices/Bluetooth/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1052,7 +1052,7 @@ pub const GenericAudioServiceClassID_UUID16: u32 = 4611u32;
10521052
pub const GenericFileTransferServiceClassID_UUID16: u32 = 4610u32;
10531053
pub const GenericNetworkingServiceClassID_UUID16: u32 = 4609u32;
10541054
pub const GenericTelephonyServiceClassID_UUID16: u32 = 4612u32;
1055-
#[repr(C)]
1055+
#[repr(transparent)]
10561056
pub struct HANDLE_SDP_TYPE(pub u64);
10571057
impl ::core::marker::Copy for HANDLE_SDP_TYPE {}
10581058
impl ::core::clone::Clone for HANDLE_SDP_TYPE {

crates/deps/sys/src/Windows/Win32/Devices/DeviceAndDriverInstallation/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2909,7 +2909,7 @@ pub const GUID_WUDF_DEVICE_HOST_PROBLEM: ::windows_sys::core::GUID = ::windows_s
29092909
data3: 16622,
29102910
data4: [162, 210, 215, 12, 21, 248, 183, 91],
29112911
};
2912-
#[repr(C)]
2912+
#[repr(transparent)]
29132913
pub struct HCMNOTIFICATION(pub isize);
29142914
impl ::core::marker::Copy for HCMNOTIFICATION {}
29152915
impl ::core::clone::Clone for HCMNOTIFICATION {

crates/deps/sys/src/Windows/Win32/Devices/Display/mod.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -853,15 +853,15 @@ pub const DEVPKEY_IndirectDisplay: super::super::UI::Shell::PropertiesSystem::PR
853853
},
854854
pid: 1u32,
855855
};
856-
#[repr(C)]
856+
#[repr(transparent)]
857857
pub struct DHPDEV(pub isize);
858858
impl ::core::marker::Copy for DHPDEV {}
859859
impl ::core::clone::Clone for DHPDEV {
860860
fn clone(&self) -> Self {
861861
*self
862862
}
863863
}
864-
#[repr(C)]
864+
#[repr(transparent)]
865865
pub struct DHSURF(pub isize);
866866
impl ::core::marker::Copy for DHSURF {}
867867
impl ::core::clone::Clone for DHSURF {
@@ -2599,31 +2599,31 @@ pub const GX_GENERAL: i32 = 3i32;
25992599
pub const GX_IDENTITY: i32 = 0i32;
26002600
pub const GX_OFFSET: i32 = 1i32;
26012601
pub const GX_SCALE: i32 = 2i32;
2602-
#[repr(C)]
2602+
#[repr(transparent)]
26032603
pub struct HBM(pub isize);
26042604
impl ::core::marker::Copy for HBM {}
26052605
impl ::core::clone::Clone for HBM {
26062606
fn clone(&self) -> Self {
26072607
*self
26082608
}
26092609
}
2610-
#[repr(C)]
2610+
#[repr(transparent)]
26112611
pub struct HDEV(pub isize);
26122612
impl ::core::marker::Copy for HDEV {}
26132613
impl ::core::clone::Clone for HDEV {
26142614
fn clone(&self) -> Self {
26152615
*self
26162616
}
26172617
}
2618-
#[repr(C)]
2618+
#[repr(transparent)]
26192619
pub struct HDRVOBJ(pub isize);
26202620
impl ::core::marker::Copy for HDRVOBJ {}
26212621
impl ::core::clone::Clone for HDRVOBJ {
26222622
fn clone(&self) -> Self {
26232623
*self
26242624
}
26252625
}
2626-
#[repr(C)]
2626+
#[repr(transparent)]
26272627
pub struct HFASTMUTEX(pub isize);
26282628
impl ::core::marker::Copy for HFASTMUTEX {}
26292629
impl ::core::clone::Clone for HFASTMUTEX {
@@ -2659,15 +2659,15 @@ pub const HOST_DSI_OS_REJECTED_PACKET: u32 = 512u32;
26592659
pub const HOST_DSI_TRANSMISSION_CANCELLED: u32 = 16u32;
26602660
pub const HOST_DSI_TRANSMISSION_DROPPED: u32 = 32u32;
26612661
pub const HOST_DSI_TRANSMISSION_TIMEOUT: u32 = 64u32;
2662-
#[repr(C)]
2662+
#[repr(transparent)]
26632663
pub struct HSEMAPHORE(pub isize);
26642664
impl ::core::marker::Copy for HSEMAPHORE {}
26652665
impl ::core::clone::Clone for HSEMAPHORE {
26662666
fn clone(&self) -> Self {
26672667
*self
26682668
}
26692669
}
2670-
#[repr(C)]
2670+
#[repr(transparent)]
26712671
pub struct HSURF(pub isize);
26722672
impl ::core::marker::Copy for HSURF {}
26732673
impl ::core::clone::Clone for HSURF {

crates/deps/sys/src/Windows/Win32/Devices/Enumeration/Pnp/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub const FAULT_INVALID_ACTION: u32 = 401u32;
2323
pub const FAULT_INVALID_ARG: u32 = 402u32;
2424
pub const FAULT_INVALID_SEQUENCE_NUMBER: u32 = 403u32;
2525
pub const FAULT_INVALID_VARIABLE: u32 = 404u32;
26-
#[repr(C)]
26+
#[repr(transparent)]
2727
pub struct HSWDEVICE(pub isize);
2828
impl ::core::marker::Copy for HSWDEVICE {}
2929
impl ::core::clone::Clone for HSWDEVICE {

crates/deps/sys/src/Windows/Win32/Devices/SerialCommunication/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pub const CDB_REPORT_BITS: u32 = 0u32;
1414
pub const CDB_REPORT_BYTES: u32 = 1u32;
1515
pub const COMDB_MAX_PORTS_ARBITRATED: u32 = 4096u32;
1616
pub const COMDB_MIN_PORTS_ARBITRATED: u32 = 256u32;
17-
#[repr(C)]
17+
#[repr(transparent)]
1818
pub struct HCOMDB(pub isize);
1919
impl ::core::marker::Copy for HCOMDB {}
2020
impl ::core::clone::Clone for HCOMDB {

0 commit comments

Comments
 (0)