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
#![deny(missing_docs)]
pub mod interfaces;
#[doc(hidden)]
pub mod offset;
mod ptr;
mod rc;
#[doc(hidden)]
pub mod registration;
pub mod runtime;
pub mod sys;
use interfaces::IUnknown;
pub use ptr::ComPtr;
pub use rc::ComRc;
#[doc(inline)]
pub use sys::{CLSID, IID};
pub unsafe trait ComInterface: IUnknown + 'static {
type VTable;
type Super: ComInterface + ?Sized;
const IID: IID;
fn is_iid_in_inheritance_chain(riid: &IID) -> bool {
riid == &Self::IID
|| (Self::IID != <dyn IUnknown as ComInterface>::IID
&& <Self::Super as ComInterface>::is_iid_in_inheritance_chain(riid))
}
}
pub unsafe trait CoClass: IUnknown {}
pub trait ProductionComInterface<T: IUnknown>: ComInterface {
fn vtable<O: offset::Offset>() -> Self::VTable;
}
#[doc(hidden)]
#[macro_export]
macro_rules! vtable {
($class:ident: $interface:ident, $offset:ident) => {
<dyn $interface as $crate::ProductionComInterface<$class>>::vtable::<
$crate::offset::$offset,
>();
};
($class:ident: $interface:ident, 4usize) => {
$crate::vtable!($class: $interface, Four)
};
($class:ident: $interface:ident, 3usize) => {
$crate::vtable!($class: $interface, Three)
};
($class:ident: $interface:ident, 2usize) => {
$crate::vtable!($class: $interface, Two)
};
($class:ident: $interface:ident, 1usize) => {
$crate::vtable!($class: $interface, One)
};
($class:ident: $interface:ident, 0usize) => {
$crate::vtable!($class: $interface, Zero)
};
($class:ident: $interface:ident) => {
$crate::vtable!($class: $interface, Zero)
};
}
#[doc(hidden)]
pub use com_macros::{co_class, com_interface, VTable};
#[doc(hidden)]
extern crate self as com;