Closed Rantanen closed 4 years ago
A quick draft of the mechanisms in playground: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2015&gist=cacd413edc05c59e6c3b8e6dcc56d518
And I just realized that this provides one option for functions to react to type system changes.
#[com_interface]
trait IFoo {
fn type_system_specific_function<TS: TypeSystem>();
}
A while back, I started pondering implementing a TypeSystem trait:
This would allow creating generic methods that handle different type systems, such as:
However I started wondering whether it would be possible to allow Intercom users to extend our type systems in such a way that they could introduce their own types that differ for each type system.
We could then hopefully provide a blanket default impl, which takes care of the types that do not differ between the type systems:
And for types that do differ, we'd implement the type system specific types with an explicit trait impls:
At this point our extern functions would take the following form (with error handling omitted):
The big downside here is that without our current
tyhandlers
, the proper COM type isn't resolved in the model. This means that the C++ and IDL generators may need to do some extra work to deduce the correct type for the type system (Currently they just do InBSTR -> BSTR, *const c_char -> char*. After this change they need to do String -> BSTR, String -> char* depending on the type system).However supporting user types in those generators would need a change of some sort for them anyway.
The big benefits with this change are:
method_impl<TypeSystem>(..)
variant.