You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A familiar foe returns: I'm trying to create a compatibility library that binds XAudio 2.7 to XAudio 2.9 for a legacy game.
However, I can't declare a few APIs using the #[interface] macro since they derive from IXAudio2Voice, which isn't a COM interface.
This is related to #2098 (and other issues/PRs related to that).
For a minimum repro, use the following test (which was modified from non_com_new.rs):
#![allow(non_snake_case, non_camel_case_types)]use windows::core::*;// The `interface` macro defines a new local interface that does not derive from `IUnknown` and thus is not a COM interface at all.#[interface]unsafetraitIBase{unsafefnBaseValue(&self) -> i32;}#[interface]unsafetraitIDerived:IBase{unsafefnDerivedValue(&self) -> i32;}structBase(i32);implIBase_ImplforBase{unsafefnBaseValue(&self) -> i32{self.0}}structDerived(i32,i32);implIBase_ImplforDerived{unsafefnBaseValue(&self) -> i32{self.0}}implIDerived_ImplforDerived{unsafefnDerivedValue(&self) -> i32{self.1}}unsafefnbase_value(test:&IBase) -> i32{
test.BaseValue()}unsafefnderived_value(test:&IDerived) -> i32{
test.DerivedValue()}#[test]fnbase(){unsafe{// Since the interface is not rooted in `IUnknown`, there's no COM-style lifetime and the resulting implementation merely// exists for the lifetime of the referenced implementation.let test = Base(456);let interface = IBase::new(&test);assert_eq!(base_value(&interface), 456);assert_eq!(interface.BaseValue(), 456);}}#[test]fnderived(){unsafe{let test = Derived(123,456);let interface = IDerived::new(&test);assert_eq!(base_value(&interface), 123);assert_eq!(interface.BaseValue(), 123);assert_eq!(derived_value(&interface), 456);assert_eq!(interface.DerivedValue(), 456);}}
Specifically, this is the error thrown:
error[E0107]: this associated function takes 1 generic argument but 3 generic arguments were supplied
--> crates\tests\interface\tests\non_com_new.rs:11:1
|
11 | #[interface]
| ^^^^^^^^^^^^
| |
| expected 1 generic argument
| help: remove these generic arguments
|
Cc @kennykerr (you seem to be the one most familiar with this class of issues)
The text was updated successfully, but these errors were encountered:
Yep, I think I know what's wrong. The interface macro is a challenge. I'll be away for a few days but will take a closer look next week. Thanks for the repro!
I had a closer look. It's challenging because Rust macros don't have any context - they only see the tokens passed to the macro - so the interface macro doesn't know what IBase is and specifically whether it derives from IUnknown. We might have to find a more general way to describe interfaces so that it can support both scenarios.
A familiar foe returns: I'm trying to create a compatibility library that binds XAudio 2.7 to XAudio 2.9 for a legacy game.
However, I can't declare a few APIs using the
#[interface]
macro since they derive fromIXAudio2Voice
, which isn't a COM interface.This is related to #2098 (and other issues/PRs related to that).
For a minimum repro, use the following test (which was modified from
non_com_new.rs
):Specifically, this is the error thrown:
Cc @kennykerr (you seem to be the one most familiar with this class of issues)
The text was updated successfully, but these errors were encountered: