1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
use ;
/*
// This is a reimplementation of windows-rs IEnumFORMATETC which allows to return a HRESULT instead of a Result<()> for the Next() method, to return S_FALSE (which is a success) when no more items are available in the enumeration
#[repr(transparent)]pub struct IEnumFORMATETC(core::IUnknown);
impl IEnumFORMATETC {
pub unsafe fn Next(
&self,
rgelt: &mut [FORMATETC],
pceltfetched: Option<*mut u32>
) -> core::HRESULT { // <-- here
(core::Interface::vtable(self).Next)(
core::Interface::as_raw(self),
rgelt.len() as _,
std::mem::transmute(rgelt.as_ptr()),
std::mem::transmute(pceltfetched.unwrap_or(::std::ptr::null_mut()))
)
}
pub unsafe fn Skip(&self, celt: u32) -> core::Result<()> {
(core::Interface::vtable(self).Skip)(
core::Interface::as_raw(self),
celt
).ok()
}
pub unsafe fn Reset(&self) -> core::Result<()> {
(core::Interface::vtable(self).Reset)(
core::Interface::as_raw(self)
).ok()
}
pub unsafe fn Clone(&self) -> core::Result<IEnumFORMATETC> {
let mut result__ = std::mem::zeroed();
(core::Interface::vtable(self).Clone)(
core::Interface::as_raw(self),&mut result__
).from_abi(result__)
}
}
impl std::cmp::Eq for IEnumFORMATETC { }
impl std::cmp::PartialEq for IEnumFORMATETC {
fn eq(&self, other: &Self) -> bool {
self.0 == other.0
}
}
impl std::clone::Clone for IEnumFORMATETC {
fn clone(&self) -> Self {
Self(self.0.clone())
}
}
impl std::fmt::Debug for IEnumFORMATETC {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_tuple("IEnumFORMATETC").field(&self.0).finish()
}
}
unsafe impl core::Interface for IEnumFORMATETC {
type Vtable = IEnumFORMATETC_Vtbl;
}
unsafe impl core::ComInterface for IEnumFORMATETC {
const IID: core::GUID = core::GUID::from_u128(0x00000103_0000_0000_c000_000000000046);
}
impl core::CanInto<core::IUnknown> for IEnumFORMATETC { }
#[repr(C)]
pub struct IEnumFORMATETC_Vtbl {
pub base__: core::IUnknown_Vtbl,
pub Next: unsafe extern "system" fn(this: *mut ::core::ffi::c_void, celt: u32, rgelt: *mut FORMATETC, pceltfetched: *mut u32) -> core::HRESULT,
pub Skip: unsafe extern "system" fn(this: *mut ::core::ffi::c_void, celt: u32) -> core::HRESULT,
pub Reset: unsafe extern "system" fn(this: *mut ::core::ffi::c_void) -> core::HRESULT,
pub Clone: unsafe extern "system" fn(this: *mut ::core::ffi::c_void, ppenum: *mut *mut ::core::ffi::c_void) -> core::HRESULT,
}
pub trait IEnumFORMATETC_Impl: Sized {
fn Next(&self, celt: u32, rgelt: *mut FORMATETC, pceltfetched: *mut u32) -> core::HRESULT; // <-- and here
fn Skip(&self, celt: u32) -> core::Result<()>;
fn Reset(&self) -> core::Result<()>;
fn Clone(&self) -> core::Result<IEnumFORMATETC>;
}
impl core::RuntimeName for IEnumFORMATETC { }
impl IEnumFORMATETC_Vtbl {
pub const fn new<Identity: core::IUnknownImpl<Impl = Impl>, Impl: IEnumFORMATETC_Impl, const OFFSET: isize>() -> IEnumFORMATETC_Vtbl {
unsafe extern "system" fn Next<Identity: core::IUnknownImpl<Impl = Impl>, Impl: IEnumFORMATETC_Impl, const OFFSET: isize>(this: *mut std::ffi::c_void, celt: u32, rgelt: *mut FORMATETC, pceltfetched: *mut u32) -> core::HRESULT {
let this = (this as *const *const ()).offset(OFFSET) as *const Identity;
let this = (*this).get_impl();
this.Next(std::mem::transmute_copy(&celt), std::mem::transmute_copy(&rgelt), std::mem::transmute_copy(&pceltfetched))
}
unsafe extern "system" fn Skip<Identity: core::IUnknownImpl<Impl = Impl>, Impl: IEnumFORMATETC_Impl, const OFFSET: isize>(this: *mut std::ffi::c_void, celt: u32) -> core::HRESULT {
let this = (this as *const *const ()).offset(OFFSET) as *const Identity;
let this = (*this).get_impl();
this.Skip(std::mem::transmute_copy(&celt)).into()
}
unsafe extern "system" fn Reset<Identity: core::IUnknownImpl<Impl = Impl>, Impl: IEnumFORMATETC_Impl, const OFFSET: isize>(this: *mut std::ffi::c_void) -> core::HRESULT {
let this = (this as *const *const ()).offset(OFFSET) as *const Identity;
let this = (*this).get_impl();
this.Reset().into()
}
unsafe extern "system" fn Clone<Identity: core::IUnknownImpl<Impl = Impl>, Impl: IEnumFORMATETC_Impl, const OFFSET: isize>(this: *mut std::ffi::c_void, ppenum: *mut *mut std::ffi::c_void) -> core::HRESULT {
let this = (this as *const *const ()).offset(OFFSET) as *const Identity;
let this = (*this).get_impl();
match this.Clone() {
std::result::Result::Ok(ok__) => {
std::ptr::write(ppenum, std::mem::transmute(ok__));
core::HRESULT(0)
}
std::result::Result::Err(err) => err.into(),
}
}
Self {
base__: core::IUnknown_Vtbl::new::<Identity, OFFSET>(),
Next: Next::<Identity, Impl, OFFSET>,
Skip: Skip::<Identity, Impl, OFFSET>,
Reset: Reset::<Identity, Impl, OFFSET>,
Clone: Clone::<Identity, Impl, OFFSET>,
}
}
pub fn matches(iid: &core::GUID) -> bool {
iid == &<IEnumFORMATETC as core::ComInterface>::IID
}
}*/
/*
implement_com!{
for_struct: EnumFormatEtc,
identity: IEnumFORMATETC,
wrapper_struct: EnumFormatEtc_Com,
interface_count: 1,
interfaces: {
0: IEnumFORMATETC
}
}*/
// IEnumFORMATETC implementation for EnumFormatEtc, which hosts a list of FORMATETCs that can be queried by COM and DoDragDrop