Skip to content

Commit

Permalink
Simpler associated item code gen (#2744)
Browse files Browse the repository at this point in the history
  • Loading branch information
kennykerr authored Dec 14, 2023
1 parent 4f2d08d commit cda1583
Show file tree
Hide file tree
Showing 62 changed files with 1,085 additions and 1,085 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
struct StockIterable<T>
where
T: ::windows_core::RuntimeType + 'static,
<T as ::windows_core::Type<T>>::Default: Clone,
T::Default: Clone,
{
values: Vec<T::Default>,
}

impl<T> IIterable_Impl<T> for StockIterable<T>
where
T: ::windows_core::RuntimeType,
<T as ::windows_core::Type<T>>::Default: Clone,
T::Default: Clone,
{
fn First(&self) -> ::windows_core::Result<IIterator<T>> {
unsafe {
Expand All @@ -29,7 +29,7 @@ where
struct StockIterator<T>
where
T: ::windows_core::RuntimeType + 'static,
<T as ::windows_core::Type<T>>::Default: Clone,
T::Default: Clone,
{
owner: IIterable<T>,
current: ::std::sync::atomic::AtomicUsize,
Expand All @@ -38,7 +38,7 @@ where
impl<T> IIterator_Impl<T> for StockIterator<T>
where
T: ::windows_core::RuntimeType,
<T as ::windows_core::Type<T>>::Default: Clone,
T::Default: Clone,
{
fn Current(&self) -> ::windows_core::Result<T> {
let owner: &StockIterable<T> = unsafe { ::windows_core::AsImpl::as_impl(&self.owner) };
Expand Down Expand Up @@ -86,7 +86,7 @@ where
impl<T> ::core::convert::TryFrom<Vec<T::Default>> for IIterable<T>
where
T: ::windows_core::RuntimeType,
<T as ::windows_core::Type<T>>::Default: Clone,
T::Default: Clone,
{
type Error = ::windows_core::Error;
fn try_from(values: Vec<T::Default>) -> ::windows_core::Result<Self> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ struct StockMapView<K, V>
where
K: ::windows_core::RuntimeType + 'static,
V: ::windows_core::RuntimeType + 'static,
<K as ::windows_core::Type<K>>::Default: Clone + Ord,
<V as ::windows_core::Type<V>>::Default: Clone,
K::Default: Clone + Ord,
V::Default: Clone,
{
map: std::collections::BTreeMap<K::Default, V::Default>,
}
Expand All @@ -13,8 +13,8 @@ impl<K, V> IIterable_Impl<IKeyValuePair<K, V>> for StockMapView<K, V>
where
K: ::windows_core::RuntimeType,
V: ::windows_core::RuntimeType,
<K as ::windows_core::Type<K>>::Default: Clone + Ord,
<V as ::windows_core::Type<V>>::Default: Clone,
K::Default: Clone + Ord,
V::Default: Clone,
{
fn First(&self) -> ::windows_core::Result<IIterator<IKeyValuePair<K, V>>> {
unsafe {
Expand All @@ -33,8 +33,8 @@ impl<K, V> IMapView_Impl<K, V> for StockMapView<K, V>
where
K: ::windows_core::RuntimeType,
V: ::windows_core::RuntimeType,
<K as ::windows_core::Type<K>>::Default: Clone + Ord,
<V as ::windows_core::Type<V>>::Default: Clone,
K::Default: Clone + Ord,
V::Default: Clone,
{
fn Lookup(&self, key: &K::Default) -> ::windows_core::Result<V> {
let value = self
Expand Down Expand Up @@ -65,8 +65,8 @@ struct StockMapViewIterator<'a, K, V>
where
K: ::windows_core::RuntimeType + 'static,
V: ::windows_core::RuntimeType + 'static,
<K as ::windows_core::Type<K>>::Default: Clone + Ord,
<V as ::windows_core::Type<V>>::Default: Clone,
K::Default: Clone + Ord,
V::Default: Clone,
{
_owner: IIterable<IKeyValuePair<K, V>>,
current: ::std::sync::RwLock<std::collections::btree_map::Iter<'a, K::Default, V::Default>>,
Expand All @@ -76,8 +76,8 @@ impl<'a, K, V> IIterator_Impl<IKeyValuePair<K, V>> for StockMapViewIterator<'a,
where
K: ::windows_core::RuntimeType,
V: ::windows_core::RuntimeType,
<K as ::windows_core::Type<K>>::Default: Clone + Ord,
<V as ::windows_core::Type<V>>::Default: Clone,
K::Default: Clone + Ord,
V::Default: Clone,
{
fn Current(&self) -> ::windows_core::Result<IKeyValuePair<K, V>> {
let mut current = self.current.read().unwrap().clone().peekable();
Expand Down Expand Up @@ -134,8 +134,8 @@ struct StockKeyValuePair<K, V>
where
K: ::windows_core::RuntimeType + 'static,
V: ::windows_core::RuntimeType + 'static,
<K as ::windows_core::Type<K>>::Default: Clone,
<V as ::windows_core::Type<V>>::Default: Clone,
K::Default: Clone,
V::Default: Clone,
{
key: K::Default,
value: V::Default,
Expand All @@ -145,8 +145,8 @@ impl<K, V> IKeyValuePair_Impl<K, V> for StockKeyValuePair<K, V>
where
K: ::windows_core::RuntimeType,
V: ::windows_core::RuntimeType,
<K as ::windows_core::Type<K>>::Default: Clone,
<V as ::windows_core::Type<V>>::Default: Clone,
K::Default: Clone,
V::Default: Clone,
{
fn Key(&self) -> ::windows_core::Result<K> {
K::from_default(&self.key)
Expand All @@ -161,8 +161,8 @@ impl<K, V> ::core::convert::TryFrom<std::collections::BTreeMap<K::Default, V::De
where
K: ::windows_core::RuntimeType,
V: ::windows_core::RuntimeType,
<K as ::windows_core::Type<K>>::Default: Clone + Ord,
<V as ::windows_core::Type<V>>::Default: Clone,
K::Default: Clone + Ord,
V::Default: Clone,
{
type Error = ::windows_core::Error;
fn try_from(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
struct StockVectorView<T>
where
T: ::windows_core::RuntimeType + 'static,
<T as ::windows_core::Type<T>>::Default: Clone + PartialEq,
T::Default: Clone + PartialEq,
{
values: Vec<T::Default>,
}

impl<T> IIterable_Impl<T> for StockVectorView<T>
where
T: ::windows_core::RuntimeType,
<T as ::windows_core::Type<T>>::Default: Clone + PartialEq,
T::Default: Clone + PartialEq,
{
fn First(&self) -> ::windows_core::Result<IIterator<T>> {
unsafe {
Expand All @@ -28,7 +28,7 @@ where
impl<T> IVectorView_Impl<T> for StockVectorView<T>
where
T: ::windows_core::RuntimeType,
<T as ::windows_core::Type<T>>::Default: Clone + PartialEq,
T::Default: Clone + PartialEq,
{
fn GetAt(&self, index: u32) -> ::windows_core::Result<T> {
let item = self
Expand Down Expand Up @@ -65,7 +65,7 @@ where
struct StockVectorViewIterator<T>
where
T: ::windows_core::RuntimeType + 'static,
<T as ::windows_core::Type<T>>::Default: Clone + PartialEq,
T::Default: Clone + PartialEq,
{
owner: IIterable<T>,
current: ::std::sync::atomic::AtomicUsize,
Expand All @@ -74,7 +74,7 @@ where
impl<T> IIterator_Impl<T> for StockVectorViewIterator<T>
where
T: ::windows_core::RuntimeType,
<T as ::windows_core::Type<T>>::Default: Clone + PartialEq,
T::Default: Clone + PartialEq,
{
fn Current(&self) -> ::windows_core::Result<T> {
let owner: &StockVectorView<T> = unsafe { ::windows_core::AsImpl::as_impl(&self.owner) };
Expand Down Expand Up @@ -122,7 +122,7 @@ where
impl<T> ::core::convert::TryFrom<Vec<T::Default>> for IVectorView<T>
where
T: ::windows_core::RuntimeType,
<T as ::windows_core::Type<T>>::Default: Clone + PartialEq,
T::Default: Clone + PartialEq,
{
type Error = ::windows_core::Error;
fn try_from(values: Vec<T::Default>) -> ::windows_core::Result<Self> {
Expand Down
4 changes: 2 additions & 2 deletions crates/libs/bindgen/src/rust/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ impl Writer {
};

quote! {
.push_other(<#g as ::windows_core::RuntimeType>::SIGNATURE)
.push_other(#g::SIGNATURE)
#semi
}
});
Expand Down Expand Up @@ -900,7 +900,7 @@ impl Writer {
quote! { result__ as *mut _ as *mut _, }
}
metadata::SignatureKind::Query(query) | metadata::SignatureKind::QueryOptional(query) if query.guid == position => {
quote! { &<T as ::windows_core::ComInterface>::IID, }
quote! { &T::IID, }
}
_ => {
let name = self.param_name(param.def);
Expand Down
6 changes: 3 additions & 3 deletions crates/libs/core/src/imp/com_bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ impl IAgileReference {
T: ::windows_core::ComInterface,
{
let mut result__ = ::std::ptr::null_mut();
(::windows_core::Interface::vtable(self).Resolve)(::windows_core::Interface::as_raw(self), &<T as ::windows_core::ComInterface>::IID, &mut result__).from_abi(result__)
(::windows_core::Interface::vtable(self).Resolve)(::windows_core::Interface::as_raw(self), &T::IID, &mut result__).from_abi(result__)
}
}
::windows_core::imp::interface_hierarchy!(IAgileReference, ::windows_core::IUnknown);
Expand Down Expand Up @@ -796,7 +796,7 @@ impl<T: ::windows_core::RuntimeType + 'static> ::windows_core::CanInto<::windows
impl<T: ::windows_core::RuntimeType + 'static> ::windows_core::CanInto<::windows_core::IInspectable> for IReference<T> {}
impl<T: ::windows_core::RuntimeType + 'static> ::windows_core::CanTryInto<IPropertyValue> for IReference<T> {}
impl<T: ::windows_core::RuntimeType + 'static> ::windows_core::RuntimeType for IReference<T> {
const SIGNATURE: ::windows_core::imp::ConstBuffer = { ::windows_core::imp::ConstBuffer::new().push_slice(b"pinterface(").push_slice(b"{61c17706-2d65-11e0-9ae8-d48564015472}").push_slice(b";").push_other(<T as ::windows_core::RuntimeType>::SIGNATURE).push_slice(b")") };
const SIGNATURE: ::windows_core::imp::ConstBuffer = { ::windows_core::imp::ConstBuffer::new().push_slice(b"pinterface(").push_slice(b"{61c17706-2d65-11e0-9ae8-d48564015472}").push_slice(b";").push_other(T::SIGNATURE).push_slice(b")") };
}
unsafe impl<T: ::windows_core::RuntimeType + 'static> ::windows_core::Interface for IReference<T> {
type Vtable = IReference_Vtbl<T>;
Expand Down Expand Up @@ -879,7 +879,7 @@ impl IWeakReference {
T: ::windows_core::ComInterface,
{
let mut result__ = ::std::ptr::null_mut();
(::windows_core::Interface::vtable(self).Resolve)(::windows_core::Interface::as_raw(self), &<T as ::windows_core::ComInterface>::IID, &mut result__).from_abi(result__)
(::windows_core::Interface::vtable(self).Resolve)(::windows_core::Interface::as_raw(self), &T::IID, &mut result__).from_abi(result__)
}
}
::windows_core::imp::interface_hierarchy!(IWeakReference, ::windows_core::IUnknown);
Expand Down
Loading

0 comments on commit cda1583

Please sign in to comment.