[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: vtables and procedural macros (was Re: [PATCH] rust: pl011: convert
From: |
Paolo Bonzini |
Subject: |
Re: vtables and procedural macros (was Re: [PATCH] rust: pl011: convert pl011_create to safe Rust) |
Date: |
Tue, 11 Feb 2025 10:00:19 +0100 |
On Tue, Feb 11, 2025 at 7:47 AM Junjie Mao <junjie.mao@hotmail.com> wrote:
> I would suggest to keep the "sysbus" prefix in the method name, or in
> general, keep the class prefix in the method names in XXXClassMethods
> traits. Otherwise APIs from different parent classes may also
> conflict. As an example, in the following class hierarchy:
>
> Object -> DeviceState -> PCIDevice -> PCIBridge -> ...
>
> For PCIDevice instances there is an API pci_device_reset(), and for
> PCIBridge ones pci_bridge_reset(). Without class prefixes both will be
> wrapped (as blanket impl in two traits) as reset() and a dev.reset()
> call will lead to a "multiple applicable items in scope" build error.
Yes, reset is definitely a problem.
I will wrap qdev_realize() in DeviceMethods to check if you get
"multiple applicable items" from that as well.
I can also go back and add "sysbus_" in front of init_mmio, init_irq,
etc.; but on the other hand we have Timer::{modify, delete} and
DeviceMethods::init_{clock,qdev}_{in,out}, should they be changed as
well? I'm not sure there is a single solution that always works.
> I agree that uses of proc macros should be carefully evaluated to see if
> they really help or hurt. In this specific case, I'm not sure if using
> attributes solves the root cause, though.
Yes, it doesn't help if you have multiple similarly-named methods
across the "superclasses".
Paolo
- [PATCH] rust: add --rust-target option for bindgen, Paolo Bonzini, 2025/02/06
- [PATCH] rust: pl011: convert pl011_create to safe Rust, Paolo Bonzini, 2025/02/06
- Re: [PATCH] rust: pl011: convert pl011_create to safe Rust, Zhao Liu, 2025/02/10
- vtables and procedural macros (was Re: [PATCH] rust: pl011: convert pl011_create to safe Rust), Paolo Bonzini, 2025/02/10
- Re: vtables and procedural macros (was Re: [PATCH] rust: pl011: convert pl011_create to safe Rust), Junjie Mao, 2025/02/11
- Re: vtables and procedural macros (was Re: [PATCH] rust: pl011: convert pl011_create to safe Rust),
Paolo Bonzini <=
- Re: vtables and procedural macros (was Re: [PATCH] rust: pl011: convert pl011_create to safe Rust), Junjie Mao, 2025/02/11
- Re: vtables and procedural macros (was Re: [PATCH] rust: pl011: convert pl011_create to safe Rust), Junjie Mao, 2025/02/11
- Re: vtables and procedural macros (was Re: [PATCH] rust: pl011: convert pl011_create to safe Rust), Paolo Bonzini, 2025/02/11
- Re: vtables and procedural macros (was Re: [PATCH] rust: pl011: convert pl011_create to safe Rust), Junjie Mao, 2025/02/11
Re: [PATCH] rust: add --rust-target option for bindgen, Philippe Mathieu-Daudé, 2025/02/06