Skip to content

Commit

Permalink
Avoids name collision in vtable generation (#1649)
Browse files Browse the repository at this point in the history
  • Loading branch information
kennykerr authored Mar 31, 2022
1 parent ab6994f commit 3376a14
Show file tree
Hide file tree
Showing 817 changed files with 47,450 additions and 46,934 deletions.
2 changes: 1 addition & 1 deletion crates/libs/bindgen/src/delegates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ fn gen_win_delegate(def: &TypeDef, gen: &Gen) -> TokenStream {
#features
impl<#(#constraints)* #fn_constraint> #boxed<#(#generics)* F> {
const VTABLE: #vtbl<#(#generics)*> = #vtbl::<#(#generics)*>{
base: ::windows::core::IUnknownVtbl{QueryInterface: Self::QueryInterface, AddRef: Self::AddRef, Release: Self::Release},
base__: ::windows::core::IUnknownVtbl{QueryInterface: Self::QueryInterface, AddRef: Self::AddRef, Release: Self::Release},
Invoke: Self::Invoke,
#(#named_phantoms)*
};
Expand Down
6 changes: 3 additions & 3 deletions crates/libs/bindgen/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,12 @@ pub fn gen_vtbl(def: &TypeDef, cfg: &Cfg, gen: &Gen) -> TokenStream {
method_names.add_vtable_types(def);

match def.vtable_types().last() {
Some(Type::IUnknown) => methods.combine(&quote! { pub base: ::windows::core::IUnknownVtbl, }),
Some(Type::IInspectable) => methods.combine(&quote! { pub base: ::windows::core::IInspectableVtbl, }),
Some(Type::IUnknown) => methods.combine(&quote! { pub base__: ::windows::core::IUnknownVtbl, }),
Some(Type::IInspectable) => methods.combine(&quote! { pub base__: ::windows::core::IInspectableVtbl, }),
Some(Type::TypeDef(def)) => {
let vtbl = gen_vtbl_ident(def, gen);
let namespace = gen.namespace(def.namespace());
methods.combine(&quote! { pub base: #namespace #vtbl, });
methods.combine(&quote! { pub base__: #namespace #vtbl, });
}
_ => {}
}
Expand Down
6 changes: 3 additions & 3 deletions crates/libs/bindgen/src/implements.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,12 @@ pub fn gen(def: &TypeDef, gen: &Gen) -> TokenStream {
let mut methods = quote! {};

match def.vtable_types().last() {
Some(Type::IUnknown) => methods.combine(&quote! { base: ::windows::core::IUnknownVtbl::new::<Identity, OFFSET>(), }),
Some(Type::IInspectable) => methods.combine(&quote! { base: ::windows::core::IInspectableVtbl::new::<Identity, #type_ident<#(#generics)*>, OFFSET>(), }),
Some(Type::IUnknown) => methods.combine(&quote! { base__: ::windows::core::IUnknownVtbl::new::<Identity, OFFSET>(), }),
Some(Type::IInspectable) => methods.combine(&quote! { base__: ::windows::core::IInspectableVtbl::new::<Identity, #type_ident<#(#generics)*>, OFFSET>(), }),
Some(Type::TypeDef(def)) => {
let vtbl = gen_vtbl_ident(def, gen);
let namespace = gen.namespace(def.namespace());
methods.combine(&quote! { base: #namespace #vtbl::new::<Identity, Impl, OFFSET>(), });
methods.combine(&quote! { base__: #namespace #vtbl::new::<Identity, Impl, OFFSET>(), });
}
_ => {}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/libs/bindgen/src/methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ pub fn gen_com_method(def: &TypeDef, kind: InterfaceKind, method: &MethodDef, me
let mut bases = quote! {};

for _ in 0..base_count {
bases.combine(&quote! { .base });
bases.combine(&quote! { .base__ });
}

match signature.kind() {
Expand Down
4 changes: 2 additions & 2 deletions crates/libs/interface/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,14 +210,14 @@ impl Interface {
#[repr(C)]
#[doc(hidden)]
#vis struct #vtable_name {
pub base: #parent_vtable,
pub base__: #parent_vtable,
#(#vtable_entries)*
}

impl #vtable_name {
pub const fn new<Identity: ::windows::core::IUnknownImpl, Impl: #trait_name, const OFFSET: isize>() -> Self {
#(#functions)*
Self { base: #parent_vtable::new::<#parent_vtable_generics>(), #(#entries),* }
Self { base__: #parent_vtable::new::<#parent_vtable_generics>(), #(#entries),* }
}

pub fn matches(iid: &windows::core::GUID) -> bool {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ impl ILearningModelVariableDescriptorPreview_Vtbl {
}
}
Self {
base: ::windows::core::IInspectableVtbl::new::<Identity, ILearningModelVariableDescriptorPreview, OFFSET>(),
base__: ::windows::core::IInspectableVtbl::new::<Identity, ILearningModelVariableDescriptorPreview, OFFSET>(),
Name: Name::<Identity, Impl, OFFSET>,
Description: Description::<Identity, Impl, OFFSET>,
ModelFeatureKind: ModelFeatureKind::<Identity, Impl, OFFSET>,
Expand Down
24 changes: 12 additions & 12 deletions crates/libs/windows/src/Windows/AI/MachineLearning/Preview/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ unsafe impl ::windows::core::Interface for IImageVariableDescriptorPreview {
#[repr(C)]
#[doc(hidden)]
pub struct IImageVariableDescriptorPreview_Vtbl {
pub base: ::windows::core::IInspectableVtbl,
pub base__: ::windows::core::IInspectableVtbl,
#[cfg(all(feature = "Graphics_Imaging", feature = "deprecated"))]
pub BitmapPixelFormat: unsafe extern "system" fn(this: *mut ::core::ffi::c_void, result__: *mut super::super::super::Graphics::Imaging::BitmapPixelFormat) -> ::windows::core::HRESULT,
#[cfg(not(all(feature = "Graphics_Imaging", feature = "deprecated")))]
Expand All @@ -95,7 +95,7 @@ unsafe impl ::windows::core::Interface for IInferencingOptionsPreview {
#[repr(C)]
#[doc(hidden)]
pub struct IInferencingOptionsPreview_Vtbl {
pub base: ::windows::core::IInspectableVtbl,
pub base__: ::windows::core::IInspectableVtbl,
#[cfg(feature = "deprecated")]
pub PreferredDeviceKind: unsafe extern "system" fn(this: *mut ::core::ffi::c_void, result__: *mut LearningModelDeviceKindPreview) -> ::windows::core::HRESULT,
#[cfg(not(feature = "deprecated"))]
Expand Down Expand Up @@ -150,7 +150,7 @@ unsafe impl ::windows::core::Interface for ILearningModelBindingPreview {
#[repr(C)]
#[doc(hidden)]
pub struct ILearningModelBindingPreview_Vtbl {
pub base: ::windows::core::IInspectableVtbl,
pub base__: ::windows::core::IInspectableVtbl,
#[cfg(feature = "deprecated")]
pub Bind: unsafe extern "system" fn(this: *mut ::core::ffi::c_void, name: ::core::mem::ManuallyDrop<::windows::core::HSTRING>, value: *mut ::core::ffi::c_void) -> ::windows::core::HRESULT,
#[cfg(not(feature = "deprecated"))]
Expand All @@ -177,7 +177,7 @@ unsafe impl ::windows::core::Interface for ILearningModelBindingPreviewFactory {
#[repr(C)]
#[doc(hidden)]
pub struct ILearningModelBindingPreviewFactory_Vtbl {
pub base: ::windows::core::IInspectableVtbl,
pub base__: ::windows::core::IInspectableVtbl,
#[cfg(feature = "deprecated")]
pub CreateFromModel: unsafe extern "system" fn(this: *mut ::core::ffi::c_void, model: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(feature = "deprecated"))]
Expand All @@ -196,7 +196,7 @@ unsafe impl ::windows::core::Interface for ILearningModelDescriptionPreview {
#[repr(C)]
#[doc(hidden)]
pub struct ILearningModelDescriptionPreview_Vtbl {
pub base: ::windows::core::IInspectableVtbl,
pub base__: ::windows::core::IInspectableVtbl,
#[cfg(feature = "deprecated")]
pub Author: unsafe extern "system" fn(this: *mut ::core::ffi::c_void, result__: *mut ::core::mem::ManuallyDrop<::windows::core::HSTRING>) -> ::windows::core::HRESULT,
#[cfg(not(feature = "deprecated"))]
Expand Down Expand Up @@ -243,7 +243,7 @@ unsafe impl ::windows::core::Interface for ILearningModelEvaluationResultPreview
#[repr(C)]
#[doc(hidden)]
pub struct ILearningModelEvaluationResultPreview_Vtbl {
pub base: ::windows::core::IInspectableVtbl,
pub base__: ::windows::core::IInspectableVtbl,
#[cfg(feature = "deprecated")]
pub CorrelationId: unsafe extern "system" fn(this: *mut ::core::ffi::c_void, result__: *mut ::core::mem::ManuallyDrop<::windows::core::HSTRING>) -> ::windows::core::HRESULT,
#[cfg(not(feature = "deprecated"))]
Expand All @@ -266,7 +266,7 @@ unsafe impl ::windows::core::Interface for ILearningModelPreview {
#[repr(C)]
#[doc(hidden)]
pub struct ILearningModelPreview_Vtbl {
pub base: ::windows::core::IInspectableVtbl,
pub base__: ::windows::core::IInspectableVtbl,
#[cfg(all(feature = "Foundation", feature = "deprecated"))]
pub EvaluateAsync: unsafe extern "system" fn(this: *mut ::core::ffi::c_void, binding: ::windows::core::RawPtr, correlationid: ::core::mem::ManuallyDrop<::windows::core::HSTRING>, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(all(feature = "Foundation", feature = "deprecated")))]
Expand Down Expand Up @@ -301,7 +301,7 @@ unsafe impl ::windows::core::Interface for ILearningModelPreviewStatics {
#[repr(C)]
#[doc(hidden)]
pub struct ILearningModelPreviewStatics_Vtbl {
pub base: ::windows::core::IInspectableVtbl,
pub base__: ::windows::core::IInspectableVtbl,
#[cfg(all(feature = "Foundation", feature = "Storage", feature = "deprecated"))]
pub LoadModelFromStorageFileAsync: unsafe extern "system" fn(this: *mut ::core::ffi::c_void, modelfile: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(all(feature = "Foundation", feature = "Storage", feature = "deprecated")))]
Expand Down Expand Up @@ -439,7 +439,7 @@ unsafe impl ::windows::core::Interface for ILearningModelVariableDescriptorPrevi
#[repr(C)]
#[doc(hidden)]
pub struct ILearningModelVariableDescriptorPreview_Vtbl {
pub base: ::windows::core::IInspectableVtbl,
pub base__: ::windows::core::IInspectableVtbl,
#[cfg(feature = "deprecated")]
pub Name: unsafe extern "system" fn(this: *mut ::core::ffi::c_void, result__: *mut ::core::mem::ManuallyDrop<::windows::core::HSTRING>) -> ::windows::core::HRESULT,
#[cfg(not(feature = "deprecated"))]
Expand Down Expand Up @@ -470,7 +470,7 @@ unsafe impl ::windows::core::Interface for IMapVariableDescriptorPreview {
#[repr(C)]
#[doc(hidden)]
pub struct IMapVariableDescriptorPreview_Vtbl {
pub base: ::windows::core::IInspectableVtbl,
pub base__: ::windows::core::IInspectableVtbl,
#[cfg(feature = "deprecated")]
pub KeyKind: unsafe extern "system" fn(this: *mut ::core::ffi::c_void, result__: *mut FeatureElementKindPreview) -> ::windows::core::HRESULT,
#[cfg(not(feature = "deprecated"))]
Expand Down Expand Up @@ -501,7 +501,7 @@ unsafe impl ::windows::core::Interface for ISequenceVariableDescriptorPreview {
#[repr(C)]
#[doc(hidden)]
pub struct ISequenceVariableDescriptorPreview_Vtbl {
pub base: ::windows::core::IInspectableVtbl,
pub base__: ::windows::core::IInspectableVtbl,
#[cfg(feature = "deprecated")]
pub ElementType: unsafe extern "system" fn(this: *mut ::core::ffi::c_void, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(feature = "deprecated"))]
Expand All @@ -520,7 +520,7 @@ unsafe impl ::windows::core::Interface for ITensorVariableDescriptorPreview {
#[repr(C)]
#[doc(hidden)]
pub struct ITensorVariableDescriptorPreview_Vtbl {
pub base: ::windows::core::IInspectableVtbl,
pub base__: ::windows::core::IInspectableVtbl,
#[cfg(feature = "deprecated")]
pub DataType: unsafe extern "system" fn(this: *mut ::core::ffi::c_void, result__: *mut FeatureElementKindPreview) -> ::windows::core::HRESULT,
#[cfg(not(feature = "deprecated"))]
Expand Down
8 changes: 4 additions & 4 deletions crates/libs/windows/src/Windows/AI/MachineLearning/impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ impl ILearningModelFeatureDescriptor_Vtbl {
}
}
Self {
base: ::windows::core::IInspectableVtbl::new::<Identity, ILearningModelFeatureDescriptor, OFFSET>(),
base__: ::windows::core::IInspectableVtbl::new::<Identity, ILearningModelFeatureDescriptor, OFFSET>(),
Name: Name::<Identity, Impl, OFFSET>,
Description: Description::<Identity, Impl, OFFSET>,
Kind: Kind::<Identity, Impl, OFFSET>,
Expand Down Expand Up @@ -89,7 +89,7 @@ impl ILearningModelFeatureValue_Vtbl {
::core::result::Result::Err(err) => err.into(),
}
}
Self { base: ::windows::core::IInspectableVtbl::new::<Identity, ILearningModelFeatureValue, OFFSET>(), Kind: Kind::<Identity, Impl, OFFSET> }
Self { base__: ::windows::core::IInspectableVtbl::new::<Identity, ILearningModelFeatureValue, OFFSET>(), Kind: Kind::<Identity, Impl, OFFSET> }
}
pub fn matches(iid: &windows::core::GUID) -> bool {
iid == &<ILearningModelFeatureValue as ::windows::core::Interface>::IID
Expand All @@ -101,7 +101,7 @@ impl ::windows::core::RuntimeName for ILearningModelOperatorProvider {
}
impl ILearningModelOperatorProvider_Vtbl {
pub const fn new<Identity: ::windows::core::IUnknownImpl, Impl: ILearningModelOperatorProvider_Impl, const OFFSET: isize>() -> ILearningModelOperatorProvider_Vtbl {
Self { base: ::windows::core::IInspectableVtbl::new::<Identity, ILearningModelOperatorProvider, OFFSET>() }
Self { base__: ::windows::core::IInspectableVtbl::new::<Identity, ILearningModelOperatorProvider, OFFSET>() }
}
pub fn matches(iid: &windows::core::GUID) -> bool {
iid == &<ILearningModelOperatorProvider as ::windows::core::Interface>::IID
Expand Down Expand Up @@ -144,7 +144,7 @@ impl ITensor_Vtbl {
}
}
Self {
base: ::windows::core::IInspectableVtbl::new::<Identity, ITensor, OFFSET>(),
base__: ::windows::core::IInspectableVtbl::new::<Identity, ITensor, OFFSET>(),
TensorKind: TensorKind::<Identity, Impl, OFFSET>,
Shape: Shape::<Identity, Impl, OFFSET>,
}
Expand Down
Loading

0 comments on commit 3376a14

Please sign in to comment.