qemu-rust
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 10/10] rust: bindings for MemoryRegionOps


From: Paolo Bonzini
Subject: Re: [PATCH 10/10] rust: bindings for MemoryRegionOps
Date: Thu, 6 Feb 2025 10:15:04 +0100
User-agent: Mozilla Thunderbird

On 2/6/25 10:15, Zhao Liu wrote:
Throughout the entire holiday, I couldn't think of a better way to
express this. I find it particularly useful when wrapping multiple
callbacks. In the future, I want to explore more use cases where this
pattern can be applied.

Thanks very much. Despite having written most of the bindings code, I don't want to give the impression that everything that I send to the mailing list is gold. So it matters to me that you send serious reviews, and that you can learn something but also suggest clarifications and improvements.

I find even if I drop the `inline` attribution, the test.rs can still be
compiled (by `make check`), I think it's because test.rs hasn't involved
memory related tests so that do_init_io isn't linked into test.rs.

Hmm, maybe it's only with some linkers.  I don't remember.

This is ugly because do_init_io exists *exactly* to extract the part
that is not generic. (See
https://users.rust-lang.org/t/soft-question-significantly-improve-rust-compile-time-via-minimizing-generics/103632/8
for an example of this; I think there's even a procedural macro crate
that does that for you, but I can't find it right now).

Thanks! I see. I agree to keep `inline` anyway.

In the meanwhile I found it, it's https://github.com/llogiq/momo/blob/master/wasm/src/lib.rs. QEMU could add something like that macro to qemu_api_macros, so that

#[qemu_api_macros::upcast]
fn foo<T>(t: &T) where T: IsA<U> {
}

could be converted to

#[inline(always)]
fn foo<T>(&self) where T: IsA<U> {
    fn inner_foo(u: &U) {
    }
    inner_foo(self.upcast())
}

Paolo




reply via email to

[Prev in Thread] Current Thread [Next in Thread]