| 1 | #[cfg (windows)] |
| 2 | include!("windows.rs" ); |
| 3 | |
| 4 | mod can_into; |
| 5 | mod com_bindings; |
| 6 | mod ref_count; |
| 7 | mod sha1; |
| 8 | mod weak_ref_count; |
| 9 | |
| 10 | pub use can_into::*; |
| 11 | pub use com_bindings::*; |
| 12 | pub use ref_count::*; |
| 13 | pub use sha1::*; |
| 14 | pub use weak_ref_count::*; |
| 15 | |
| 16 | #[doc (hidden)] |
| 17 | #[macro_export ] |
| 18 | macro_rules! interface_hierarchy { |
| 19 | ($child:ident, $parent:ty) => { |
| 20 | impl ::windows_core::imp::CanInto<$parent> for $child {} |
| 21 | impl ::core::convert::From<&$child> for &$parent { |
| 22 | fn from(value: &$child) -> Self { |
| 23 | unsafe { ::core::mem::transmute(value) } |
| 24 | } |
| 25 | } |
| 26 | impl ::core::convert::From<$child> for $parent { |
| 27 | fn from(value: $child) -> Self { |
| 28 | unsafe { ::core::mem::transmute(value) } |
| 29 | } |
| 30 | } |
| 31 | }; |
| 32 | ($child:ident, $first:ty, $($rest:ty),+) => { |
| 33 | $crate::imp::interface_hierarchy!($child, $first); |
| 34 | $crate::imp::interface_hierarchy!($child, $($rest),+); |
| 35 | }; |
| 36 | } |
| 37 | |
| 38 | #[doc (hidden)] |
| 39 | pub use interface_hierarchy; |
| 40 | |
| 41 | #[doc (hidden)] |
| 42 | #[macro_export ] |
| 43 | macro_rules! required_hierarchy { |
| 44 | ($child:ident, $parent:ty) => { |
| 45 | impl ::windows_core::imp::CanInto<$parent> for $child { const QUERY: bool = true; } |
| 46 | }; |
| 47 | ($child:ident, $first:ty, $($rest:ty),+) => { |
| 48 | $crate::imp::required_hierarchy!($child, $first); |
| 49 | $crate::imp::required_hierarchy!($child, $($rest),+); |
| 50 | }; |
| 51 | } |
| 52 | |
| 53 | #[doc (hidden)] |
| 54 | pub use required_hierarchy; |
| 55 | |
| 56 | #[doc (hidden)] |
| 57 | #[macro_export ] |
| 58 | macro_rules! define_interface { |
| 59 | ($name:ident, $vtbl:ident, $iid:literal) => { |
| 60 | #[repr(transparent)] |
| 61 | #[derive(::core::cmp::PartialEq, ::core::cmp::Eq, ::core::clone::Clone)] |
| 62 | pub struct $name(::windows_core::IUnknown); |
| 63 | unsafe impl ::windows_core::Interface for $name { |
| 64 | type Vtable = $vtbl; |
| 65 | const IID: ::windows_core::GUID = ::windows_core::GUID::from_u128($iid); |
| 66 | } |
| 67 | impl ::core::fmt::Debug for $name { |
| 68 | fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> core::fmt::Result { |
| 69 | f.debug_tuple(stringify!($name)) |
| 70 | .field(&::windows_core::Interface::as_raw(self)) |
| 71 | .finish() |
| 72 | } |
| 73 | } |
| 74 | }; |
| 75 | ($name:ident, $vtbl:ident) => { |
| 76 | #[repr(transparent)] |
| 77 | #[derive(::core::cmp::PartialEq, ::core::cmp::Eq, ::core::clone::Clone)] |
| 78 | pub struct $name(::core::ptr::NonNull<::core::ffi::c_void>); |
| 79 | unsafe impl ::windows_core::Interface for $name { |
| 80 | type Vtable = $vtbl; |
| 81 | const IID: ::windows_core::GUID = ::windows_core::GUID::zeroed(); |
| 82 | const UNKNOWN: bool = false; |
| 83 | } |
| 84 | impl ::core::fmt::Debug for $name { |
| 85 | fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> core::fmt::Result { |
| 86 | f.debug_tuple(stringify!($name)).field(&self.0).finish() |
| 87 | } |
| 88 | } |
| 89 | }; |
| 90 | } |
| 91 | |
| 92 | #[doc (hidden)] |
| 93 | pub use define_interface; |
| 94 | |
| 95 | #[doc (hidden)] |
| 96 | pub use alloc::boxed::Box; |
| 97 | |