Expand description
ferroui-microcom
Minimal COM runtime used by the bindings that microcom-codegen generates
from MicroCom IDL files (the Rust counterpart of the MicroCom runtime and its callback base class).
Two directions are covered:
- native -> Rust proxies: an interface type such as
IFrnWindowis a#[repr(C)]struct whose only field is the vtable pointer, i.e. a*mut IFrnWindowis the native interface pointer.ComPtr<T>owns one reference to such an object (AddRefon clone,Releaseon drop) and derefs to&T, on which the generated methods live. - Rust -> native callbacks (COM callable wrappers):
ComObject<T>is one interface of a Rust value as native code sees it: a vtable pointer, followed by a pointer to the object, which holds an atomic reference count, the wrappers of its interfaces and the Rust value. Generated code provides the vtables (extern "system"thunks) for everyTimplementing the interface’s...Impltrait throughImplementedBy.make_commakes an object with one interface,make_com_withone with several, each of which answersQueryInterfacefor all of them.
ABI: Itanium C++ single-inheritance layout — slot 0..2 are
QueryInterface, AddRef, Release, followed by the methods of each
interface in the chain in declaration order; this is the first argument
of every slot. The calling convention is the one of the system
(extern "system"): the C convention on every target but 32-bit x86
Windows, where COM is stdcall. On that target a virtual method of the
system’s COM returns a structure through a hidden parameter after this,
which the generated signatures do not model: no interface the port binds
returns one.
Structs§
- ComObject
- One interface of a Rust-implemented COM object as native code sees it (a
“COM callable wrapper” of the MicroCom runtime): the first word is the
vtable pointer, so a
*mut ComObject<T>is the interface pointer; the second leads to the object the wrapper belongs to. - ComPtr
- Owning, non-null COM interface pointer: holds exactly one reference.
- Guid
- Binary-compatible with the
GUIDstruct declared incom.h. - HResult
- A failed (or, rarely, non-
S_OKsuccess)HRESULT; the error type of every generated method whose IDL signature returnsHRESULT. - IUnknown
- The root interface. A
*mut IUnknownis a nativeIUnknown*. - IUnknown
Vtbl - Interface
Entry - An interface a Rust value is exposed through: its vtable and the test for the identifiers it answers to (its own and those of its bases).
Constants§
- COR_
E_ INVALIDOPERATION - COR_
E_ OBJECTDISPOSED - E_ABORT
- E_FAIL
- E_
HANDLE - E_
INVALIDARG - E_
NOINTERFACE - E_
NOTIMPL - E_
POINTER - E_
UNEXPECTED - S_OK
Traits§
- IUnknown
Impl - Implementation-side counterpart of
IUnknown: the root of every generatedI...Impltrait hierarchy. It has no methods — reference counting andQueryInterfaceare provided bycrate::ComObject— and is blanket-implemented for every type. - Implemented
By - Links an interface
Selfto a Rust typeTthat implements its callbacks: supplies the vtable native code will call through. - Interface
- Implemented (by generated code) for every COM interface type.
Functions§
- make_
com - Moves
valueto the heap behind a COM vtable for interfaceIand returns the (single) owning reference. - make_
com_ with - Moves
valueto the heap as a COM object that implements interfaceIand every interface ofmore, and returns the (single) owning reference asI. - set_
inner ⚠ - Makes the object of
thisthe outer object of an aggregate: the object whose implementation ofQueryInterfaceasksinnerfor every interface it was not made with, and which releasesinnerwhen it is destroyed.
Type Aliases§
- ComResult
- Result of a COM call returning
HRESULT. - RawH
Result HRESULTas it crosses the ABI (typedef unsigned int HRESULTincom.h).