Open Boddlnagg opened 7 years ago
How this is done in the modern C++ projection is nicely explained in https://www.youtube.com/watch?v=lm4IwfiJ3EU#t=31m40s
Another point to consider: Versioned interfaces such as ILauncherOptions2
and ILauncherOptions3
are added in newer releases, when only ILauncherOption
exists originally. This means that a newer SDK will know these interfaces while an older SDK doesn't. When we check in the generated code as part of the crate, we always build with the SDK that is installed on the build machine, not the one that is installed on the user machine. So there might be interfaces in the generated code that do not yet exist on the OS of the user of the crate. In such cases, QueryInterface
will return an error and we must not wrap it in such a way that these kinds of errors get lost.
Parent interfaces (and the main interface of classes) work through Deref
, for other interfaces we probably need Into
/From
.
Many classes implement other interfaces besides their main interface. For example,
Windows.System.LauncherOptions
implementsILauncherOptions
, but alsoILauncherViewOptions
,ILauncherOptions2
andILauncherOptions3
.QueryInterface
can be used to get implementations of these other interfaces, but can generally query arbitrary interfaces and might fail if the interface is not actually available, therefore it returnsResult<>
. We should add a way to query those interfaces that are known to be valid (from the metadata), which can then be returned directly.Maybe this could make use of Rust's conversion traits. Ideally it could work automatically, so that an instance of
ComPtr<LauncherOptions>
, which allows calls to methods defined onILauncherOptions
through deref, could also allow calls to methods defined on the other interfaces.