Skip to main content

Crate ferroui_microcom

Crate ferroui_microcom 

Source
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 IFrnWindow is a #[repr(C)] struct whose only field is the vtable pointer, i.e. a *mut IFrnWindow is the native interface pointer. ComPtr<T> owns one reference to such an object (AddRef on clone, Release on 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 every T implementing the interface’s ...Impl trait through ImplementedBy. make_com makes an object with one interface, make_com_with one with several, each of which answers QueryInterface for 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 GUID struct declared in com.h.
HResult
A failed (or, rarely, non-S_OK success) HRESULT; the error type of every generated method whose IDL signature returns HRESULT.
IUnknown
The root interface. A *mut IUnknown is a native IUnknown*.
IUnknownVtbl
InterfaceEntry
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§

IUnknownImpl
Implementation-side counterpart of IUnknown: the root of every generated I...Impl trait hierarchy. It has no methods — reference counting and QueryInterface are provided by crate::ComObject — and is blanket-implemented for every type.
ImplementedBy
Links an interface Self to a Rust type T that 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 value to the heap behind a COM vtable for interface I and returns the (single) owning reference.
make_com_with
Moves value to the heap as a COM object that implements interface I and every interface of more, and returns the (single) owning reference as I.
set_inner⚠
Makes the object of this the outer object of an aggregate: the object whose implementation of QueryInterface asks inner for every interface it was not made with, and which releases inner when it is destroyed.

Type Aliases§

ComResult
Result of a COM call returning HRESULT.
RawHResult
HRESULT as it crosses the ABI (typedef unsigned int HRESULT in com.h).