Skip to content

Commit

Permalink
Include cfg depedencies for types with generic interface type depeden…
Browse files Browse the repository at this point in the history
…cies (#1832)
  • Loading branch information
kennykerr authored Jun 21, 2022
1 parent b8d83c2 commit 6a3a748
Show file tree
Hide file tree
Showing 10 changed files with 150 additions and 133 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ jobs:
cargo clippy -p test_arch &&
cargo clippy -p test_arch_feature &&
cargo clippy -p test_bstr &&
cargo clippy -p test_cfg_generic &&
cargo clippy -p test_class_factory &&
cargo clippy -p test_component &&
cargo clippy -p test_component_client &&
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,13 @@ jobs:
cargo test --target ${{ matrix.target }} -p test_arch &&
cargo test --target ${{ matrix.target }} -p test_arch_feature &&
cargo test --target ${{ matrix.target }} -p test_bstr &&
cargo test --target ${{ matrix.target }} -p test_cfg_generic &&
cargo test --target ${{ matrix.target }} -p test_class_factory &&
cargo test --target ${{ matrix.target }} -p test_component &&
cargo test --target ${{ matrix.target }} -p test_component_client &&
cargo test --target ${{ matrix.target }} -p test_const_fields &&
cargo test --target ${{ matrix.target }} -p test_core &&
cargo clean &&
cargo test --target ${{ matrix.target }} -p test_core &&
cargo test --target ${{ matrix.target }} -p test_data_object &&
cargo test --target ${{ matrix.target }} -p test_debug &&
cargo test --target ${{ matrix.target }} -p test_deprecated &&
Expand Down
10 changes: 5 additions & 5 deletions crates/libs/bindgen/src/iterators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ pub fn gen(gen: &Gen, def: TypeDef, generics: &[Type], ident: &TokenStream, cons
TypeName::IVectorView => {
let item = gen.type_name(&interface_generics[0]);
let mut cfg = cfg.clone();
cfg.add_feature("Windows.Foundation.Collections");
gen.reader.type_def_cfg_combine(*interface, interface_generics, &mut cfg);
let features = gen.cfg_features(&cfg);

return quote! {
Expand All @@ -180,7 +180,7 @@ pub fn gen(gen: &Gen, def: TypeDef, generics: &[Type], ident: &TokenStream, cons
TypeName::IVector => {
let item = gen.type_name(&interface_generics[0]);
let mut cfg = cfg.clone();
cfg.add_feature("Windows.Foundation.Collections");
gen.reader.type_def_cfg_combine(*interface, interface_generics, &mut cfg);
let features = gen.cfg_features(&cfg);

return quote! {
Expand All @@ -205,7 +205,7 @@ pub fn gen(gen: &Gen, def: TypeDef, generics: &[Type], ident: &TokenStream, cons
};
}
TypeName::IIterable => {
iterable = Some(interface_generics.to_vec());
iterable = Some((*interface, interface_generics.to_vec()));
}
_ => {}
}
Expand All @@ -214,10 +214,10 @@ pub fn gen(gen: &Gen, def: TypeDef, generics: &[Type], ident: &TokenStream, cons

match iterable {
None => TokenStream::new(),
Some(interface_generics) => {
Some((interface, interface_generics)) => {
let item = gen.type_name(&interface_generics[0]);
let mut cfg = cfg.clone();
cfg.add_feature("Windows.Foundation.Collections");
gen.reader.type_def_cfg_combine(interface, &interface_generics, &mut cfg);
let features = gen.cfg_features(&cfg);

quote! {
Expand Down
2 changes: 1 addition & 1 deletion crates/libs/bindgen/src/winrt_methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub fn gen(gen: &Gen, def: TypeDef, generics: &[Type], kind: InterfaceKind, meth
let vname = virtual_names.add(gen, method);
let constraints = gen.param_constraints(params);
let mut cfg = gen.reader.signature_cfg(&signature);
cfg.add_feature(gen.reader.type_def_namespace(def));
gen.reader.type_def_cfg_combine(def, generics, &mut cfg);
let doc = gen.cfg_doc(&cfg);
let features = gen.cfg_features(&cfg);
let args = gen_winrt_abi_args(gen, params);
Expand Down
8 changes: 4 additions & 4 deletions crates/libs/metadata/src/reader/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1034,16 +1034,16 @@ impl<'a> Reader<'a> {
self.cfg_add_attributes(&mut cfg, self.type_def_attributes(def));
cfg
}
fn type_def_cfg_combine(&'a self, row: TypeDef, generics: &[Type], cfg: &mut Cfg<'a>) {
pub fn type_def_cfg_combine(&'a self, row: TypeDef, generics: &[Type], cfg: &mut Cfg<'a>) {
for generic in generics {
self.type_cfg_combine(generic, cfg);
}

if cfg.types.entry(self.type_def_namespace(row)).or_default().insert(row) {
match self.type_def_kind(row) {
TypeKind::Class => {
if let Some(Type::TypeDef((row, _))) = self.type_def_interfaces(row, generics).find(|row| row.kind == InterfaceKind::Default).map(|interface| interface.ty) {
cfg.add_feature(self.type_def_namespace(row));
if let Some(default_interface) = self.type_def_default_interface(row) {
self.type_cfg_combine(&default_interface, cfg);
}
}
TypeKind::Interface => {
Expand Down Expand Up @@ -1241,7 +1241,7 @@ impl<'a> Reader<'a> {
self.type_cfg_combine(ty, &mut cfg);
cfg
}
fn type_cfg_combine(&'a self, ty: &Type, cfg: &mut Cfg<'a>) {
pub fn type_cfg_combine(&'a self, ty: &Type, cfg: &mut Cfg<'a>) {
match ty {
Type::TypeDef((row, generics)) => self.type_def_cfg_combine(*row, generics, cfg),
Type::Win32Array((ty, _)) => self.type_cfg_combine(ty, cfg),
Expand Down
48 changes: 24 additions & 24 deletions crates/libs/windows/src/Windows/Devices/Sms/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -979,11 +979,11 @@ impl<'a> ::windows::core::IntoParam<'a, super::super::Foundation::IAsyncOperatio
::core::convert::TryInto::<super::super::Foundation::IAsyncOperation<ISmsMessage>>::try_into(self).map(::windows::core::Param::Owned).unwrap_or(::windows::core::Param::None)
}
}
#[doc = "*Required features: `\"Devices_Sms\"`, `\"Foundation\"`, `\"deprecated\"`*"]
#[cfg(all(feature = "Foundation", feature = "deprecated"))]
#[doc = "*Required features: `\"Devices_Sms\"`, `\"Foundation_Collections\"`, `\"deprecated\"`*"]
#[cfg(all(feature = "Foundation_Collections", feature = "deprecated"))]
#[repr(transparent)]
pub struct GetSmsMessagesOperation(::windows::core::IUnknown);
#[cfg(all(feature = "Foundation", feature = "deprecated"))]
#[cfg(all(feature = "Foundation_Collections", feature = "deprecated"))]
impl GetSmsMessagesOperation {
#[doc = "*Required features: `\"Devices_Sms\"`, `\"Foundation\"`*"]
#[cfg(feature = "Foundation")]
Expand Down Expand Up @@ -1064,44 +1064,44 @@ impl GetSmsMessagesOperation {
}
}
}
#[cfg(all(feature = "Foundation", feature = "deprecated"))]
#[cfg(all(feature = "Foundation_Collections", feature = "deprecated"))]
impl ::core::clone::Clone for GetSmsMessagesOperation {
fn clone(&self) -> Self {
Self(self.0.clone())
}
}
#[cfg(all(feature = "Foundation", feature = "deprecated"))]
#[cfg(all(feature = "Foundation_Collections", feature = "deprecated"))]
impl ::core::cmp::PartialEq for GetSmsMessagesOperation {
fn eq(&self, other: &Self) -> bool {
self.0 == other.0
}
}
#[cfg(all(feature = "Foundation", feature = "deprecated"))]
#[cfg(all(feature = "Foundation_Collections", feature = "deprecated"))]
impl ::core::cmp::Eq for GetSmsMessagesOperation {}
#[cfg(all(feature = "Foundation", feature = "deprecated"))]
#[cfg(all(feature = "Foundation_Collections", feature = "deprecated"))]
impl ::core::fmt::Debug for GetSmsMessagesOperation {
fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
f.debug_tuple("GetSmsMessagesOperation").field(&self.0).finish()
}
}
#[cfg(all(feature = "Foundation", feature = "deprecated"))]
#[cfg(all(feature = "Foundation_Collections", feature = "deprecated"))]
unsafe impl ::windows::core::RuntimeType for GetSmsMessagesOperation {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.Devices.Sms.GetSmsMessagesOperation;pinterface({b5d036d7-e297-498f-ba60-0289e76e23dd};pinterface({bbe1fa4c-b0e3-4583-baef-1f1b2e483e56};{ed3c5e28-6984-4b07-811d-8d5906ed3cea});i4))");
type DefaultType = ::core::option::Option<Self>;
fn from_default(from: &Self::DefaultType) -> ::windows::core::Result<Self> {
from.as_ref().cloned().ok_or(::windows::core::Error::OK)
}
}
#[cfg(all(feature = "Foundation", feature = "deprecated"))]
#[cfg(all(feature = "Foundation_Collections", feature = "deprecated"))]
unsafe impl ::windows::core::Interface for GetSmsMessagesOperation {
type Vtable = super::super::Foundation::IAsyncOperationWithProgress_Vtbl<super::super::Foundation::Collections::IVectorView<ISmsMessage>, i32>;
const IID: ::windows::core::GUID = <super::super::Foundation::IAsyncOperationWithProgress<super::super::Foundation::Collections::IVectorView<ISmsMessage>, i32> as ::windows::core::Interface>::IID;
}
#[cfg(all(feature = "Foundation", feature = "deprecated"))]
#[cfg(all(feature = "Foundation_Collections", feature = "deprecated"))]
impl ::windows::core::RuntimeName for GetSmsMessagesOperation {
const NAME: &'static str = "Windows.Devices.Sms.GetSmsMessagesOperation";
}
#[cfg(all(feature = "Foundation", feature = "deprecated"))]
#[cfg(all(feature = "Foundation_Collections", feature = "deprecated"))]
impl GetSmsMessagesOperation {
pub fn get(&self) -> ::windows::core::Result<super::super::Foundation::Collections::IVectorView<ISmsMessage>> {
if self.Status()? == super::super::Foundation::AsyncStatus::Started {
Expand All @@ -1116,7 +1116,7 @@ impl GetSmsMessagesOperation {
self.GetResults()
}
}
#[cfg(all(feature = "Foundation", feature = "deprecated"))]
#[cfg(all(feature = "Foundation_Collections", feature = "deprecated"))]
impl ::std::future::Future for GetSmsMessagesOperation {
type Output = ::windows::core::Result<super::super::Foundation::Collections::IVectorView<ISmsMessage>>;
fn poll(self: ::std::pin::Pin<&mut Self>, context: &mut ::std::task::Context) -> ::std::task::Poll<Self::Output> {
Expand All @@ -1132,75 +1132,75 @@ impl ::std::future::Future for GetSmsMessagesOperation {
}
}
}
#[cfg(all(feature = "Foundation", feature = "deprecated"))]
#[cfg(all(feature = "Foundation_Collections", feature = "deprecated"))]
impl ::core::convert::From<GetSmsMessagesOperation> for ::windows::core::IUnknown {
fn from(value: GetSmsMessagesOperation) -> Self {
unsafe { ::core::mem::transmute(value) }
}
}
#[cfg(all(feature = "Foundation", feature = "deprecated"))]
#[cfg(all(feature = "Foundation_Collections", feature = "deprecated"))]
impl ::core::convert::From<&GetSmsMessagesOperation> for ::windows::core::IUnknown {
fn from(value: &GetSmsMessagesOperation) -> Self {
::core::convert::From::from(::core::clone::Clone::clone(value))
}
}
#[cfg(all(feature = "Foundation", feature = "deprecated"))]
#[cfg(all(feature = "Foundation_Collections", feature = "deprecated"))]
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for GetSmsMessagesOperation {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(unsafe { ::core::mem::transmute(self) })
}
}
#[cfg(all(feature = "Foundation", feature = "deprecated"))]
#[cfg(all(feature = "Foundation_Collections", feature = "deprecated"))]
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a GetSmsMessagesOperation {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(unsafe { ::core::mem::transmute(self) })
}
}
#[cfg(all(feature = "Foundation", feature = "deprecated"))]
#[cfg(all(feature = "Foundation_Collections", feature = "deprecated"))]
impl ::core::convert::From<GetSmsMessagesOperation> for ::windows::core::IInspectable {
fn from(value: GetSmsMessagesOperation) -> Self {
unsafe { ::core::mem::transmute(value) }
}
}
#[cfg(all(feature = "Foundation", feature = "deprecated"))]
#[cfg(all(feature = "Foundation_Collections", feature = "deprecated"))]
impl ::core::convert::From<&GetSmsMessagesOperation> for ::windows::core::IInspectable {
fn from(value: &GetSmsMessagesOperation) -> Self {
::core::convert::From::from(::core::clone::Clone::clone(value))
}
}
#[cfg(all(feature = "Foundation", feature = "deprecated"))]
#[cfg(all(feature = "Foundation_Collections", feature = "deprecated"))]
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for GetSmsMessagesOperation {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Owned(unsafe { ::core::mem::transmute(self) })
}
}
#[cfg(all(feature = "Foundation", feature = "deprecated"))]
#[cfg(all(feature = "Foundation_Collections", feature = "deprecated"))]
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for &'a GetSmsMessagesOperation {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Borrowed(unsafe { ::core::mem::transmute(self) })
}
}
#[cfg(all(feature = "Foundation", feature = "deprecated"))]
#[cfg(all(feature = "Foundation_Collections", feature = "deprecated"))]
impl ::core::convert::TryFrom<GetSmsMessagesOperation> for super::super::Foundation::IAsyncInfo {
type Error = ::windows::core::Error;
fn try_from(value: GetSmsMessagesOperation) -> ::windows::core::Result<Self> {
::core::convert::TryFrom::try_from(&value)
}
}
#[cfg(all(feature = "Foundation", feature = "deprecated"))]
#[cfg(all(feature = "Foundation_Collections", feature = "deprecated"))]
impl ::core::convert::TryFrom<&GetSmsMessagesOperation> for super::super::Foundation::IAsyncInfo {
type Error = ::windows::core::Error;
fn try_from(value: &GetSmsMessagesOperation) -> ::windows::core::Result<Self> {
::windows::core::Interface::cast(value)
}
}
#[cfg(all(feature = "Foundation", feature = "deprecated"))]
#[cfg(all(feature = "Foundation_Collections", feature = "deprecated"))]
impl<'a> ::windows::core::IntoParam<'a, super::super::Foundation::IAsyncInfo> for GetSmsMessagesOperation {
fn into_param(self) -> ::windows::core::Param<'a, super::super::Foundation::IAsyncInfo> {
::windows::core::IntoParam::into_param(&self)
}
}
#[cfg(all(feature = "Foundation", feature = "deprecated"))]
#[cfg(all(feature = "Foundation_Collections", feature = "deprecated"))]
impl<'a> ::windows::core::IntoParam<'a, super::super::Foundation::IAsyncInfo> for &GetSmsMessagesOperation {
fn into_param(self) -> ::windows::core::Param<'a, super::super::Foundation::IAsyncInfo> {
::core::convert::TryInto::<super::super::Foundation::IAsyncInfo>::try_into(self).map(::windows::core::Param::Owned).unwrap_or(::windows::core::Param::None)
Expand Down
Loading

0 comments on commit 6a3a748

Please sign in to comment.